screeps-client 0.5.1 → 0.6.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.
- package/dist/embedded/_client/{CodePanel-DXjEDPYY.js → CodePanel-KBQ78175.js} +1 -1
- package/dist/{standalone/_client/MapViewer-rS_HNnKY.js → embedded/_client/MapViewer-BL7mzGWw.js} +1 -1
- package/dist/embedded/_client/index-KFumkHjd.js +24 -0
- package/dist/embedded/_client/vendor-pixi-CWBnI4gg.js +1280 -0
- package/dist/embedded/index.html +2 -2
- package/dist/embedded/themes/default/test.json +23 -23
- package/dist/embedded/themes/default/test.png +0 -0
- package/dist/standalone/_client/{CodePanel-CIPkcnIz.js → CodePanel-sM0UkfOw.js} +1 -1
- package/dist/{embedded/_client/MapViewer-DEfylty3.js → standalone/_client/MapViewer-B-eI44Qx.js} +1 -1
- package/dist/standalone/_client/index-CHCJvDO3.js +24 -0
- package/dist/standalone/_client/vendor-pixi-DrpfKiIN.js +1280 -0
- package/dist/standalone/index.html +2 -2
- package/dist/standalone/themes/default/test.json +23 -23
- package/dist/standalone/themes/default/test.png +0 -0
- package/dist/xxscreeps-mod/_client/{CodePanel-DUqUzGAY.js → CodePanel-Bfi6k72H.js} +1 -1
- package/dist/xxscreeps-mod/_client/{MapViewer-CmlSeGvz.js → MapViewer-CKPZHZAs.js} +1 -1
- package/dist/xxscreeps-mod/_client/index-04hhqfkD.js +24 -0
- package/dist/xxscreeps-mod/_client/vendor-pixi-CerEzm_8.js +1280 -0
- package/dist/xxscreeps-mod/index.html +2 -2
- package/dist/xxscreeps-mod/themes/default/test.json +23 -23
- package/dist/xxscreeps-mod/themes/default/test.png +0 -0
- package/package.json +1 -1
- package/dist/embedded/_client/index-iehPgM07.js +0 -24
- package/dist/embedded/_client/vendor-pixi-D-Qjltr2.js +0 -1215
- package/dist/standalone/_client/index-Bz8cf6rc.js +0 -24
- package/dist/standalone/_client/vendor-pixi-CVMJwxeR.js +0 -1215
- package/dist/xxscreeps-mod/_client/index-akQsPepe.js +0 -24
- package/dist/xxscreeps-mod/_client/vendor-pixi-DOKo__Ml.js +0 -1215
|
@@ -0,0 +1,1280 @@
|
|
|
1
|
+
const Cu="modulepreload",Au=function(r){return"/client/"+r},Jn={},jt=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=Au(h),h in Jn)return;Jn[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":Cu,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 xi=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},Ds=(r,e)=>xi(r).priority??e,H={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(xi).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(xi).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)=>Ds(o.value,t)-Ds(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)=>Ds(n,t)-Ds(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 jt(()=>Promise.resolve().then(()=>Iy),void 0)}},Eu={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await jt(()=>Promise.resolve().then(()=>Fy),void 0)}};class ue{constructor(e,t,s){this._x=t||0,this._y=s||0,this._observer=e}clone(e){return new ue(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 ja(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ir={exports:{}},eo;function Mu(){return eo||(eo=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})(Ir)),Ir.exports}var Ru=Mu();const Be=ja(Ru),Bu=Math.PI*2,ku=180/Math.PI,Iu=Math.PI/180;class J{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new J(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 Fr.x=0,Fr.y=0,Fr}}const Fr=new J;class F{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 J;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 J;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(Bu-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 F;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 Gu.identity()}static get shared(){return Fu.identity()}}const Fu=new F,Gu=new F,xt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],yt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],bt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],vt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],yi=[],Ya=[],Ls=Math.sign;function Uu(){for(let r=0;r<16;r++){const e=[];yi.push(e);for(let t=0;t<16;t++){const s=Ls(xt[r]*xt[t]+bt[r]*yt[t]),i=Ls(yt[r]*xt[t]+vt[r]*yt[t]),n=Ls(xt[r]*bt[t]+bt[r]*vt[t]),o=Ls(yt[r]*bt[t]+vt[r]*vt[t]);for(let a=0;a<16;a++)if(xt[a]===s&&yt[a]===i&&bt[a]===n&&vt[a]===o){e.push(a);break}}}for(let r=0;r<16;r++){const e=new F;e.set(xt[r],yt[r],bt[r],vt[r],0,0),Ya.push(e)}}Uu();const j={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=>xt[r],uY:r=>yt[r],vX:r=>bt[r],vY:r=>vt[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>yi[r][e],sub:(r,e)=>yi[r][j.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?j.S:j.N:Math.abs(e)*2<=Math.abs(r)?r>0?j.E:j.W:e>0?r>0?j.SE:j.SW:r>0?j.NE:j.NW,matrixAppendRotationInv:(r,e,t=0,s=0,i=0,n=0)=>{const o=Ya[j.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===j.E?(s.set(i+l,n+h,o,a),s):t===j.S?s.set(c-n-a+l,i+h,a,o):t===j.W?s.set(c-i-o+l,u-n-a+h,o,a):t===j.N?s.set(n+l,u-i-o+h,a,o):s.set(i+l,n+h,o,a)}},Ns=[new J,new J,new J,new J];class ee{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 ee(0,0,0,0)}clone(){return new ee(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 P=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=P)return!1;const A=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>A}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=Ns[0].set(e.left,e.top),l=Ns[1].set(e.left,e.bottom),h=Ns[2].set(e.right,e.top),c=Ns[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 ee),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 Gr={default:-1};function ne(r="default"){return Gr[r]===void 0&&(Gr[r]=-1),++Gr[r]}const to=new Set,Y="8.0.0",Ou="8.3.4",Vt={quiet:!1,noColor:!1},G=((r,e,t=3)=>{if(Vt.quiet||to.has(e))return;let s=new Error().stack;const i=`${e}
|
|
2
|
+
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!Vt.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))),to.add(e)});Object.defineProperties(G,{quiet:{get:()=>Vt.quiet,set:r=>{Vt.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Vt.noColor,set:r=>{Vt.noColor=r},enumerable:!0,configurable:!1}});const qa=()=>{};function Kt(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 so(r){return!(r&r-1)&&!!r}function Ka(r){const e={};for(const t in r)r[t]!==void 0&&(e[t]=r[t]);return e}const ro=Object.create(null);function Du(r){const e=ro[r];return e===void 0&&(ro[r]=ne("resource")),e}const Za=class Qa extends Be{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...Qa.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){G(Y,"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=Du(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Za.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ot=Za;const Ja=class el extends Be{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ne("textureSource"),this._resourceType="textureSource",this._resourceId=ne("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={...el.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 ot(Ka(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=ne("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=ne("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=so(this.pixelWidth)&&so(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Ja.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 ge=Ja;class ji extends ge{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}}ji.extension=b.TextureSource;const io=new F;class tl{constructor(e,t){this.mapCoord=new F,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&&(io.set(s.width/i.width,0,0,s.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(io));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 U extends Be{constructor({source:e,label:t,frame:s,orig:i,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=ne("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new ee,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=(e==null?void 0:e.source)??new ge,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 tl(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=j.add(h,j.NW),e.x0=d+c*j.uX(h),e.y0=f+u*j.uY(h),h=j.add(h,2),e.x1=d+c*j.uX(h),e.y1=f+u*j.uY(h),h=j.add(h,2),e.x2=d+c*j.uX(h),e.y2=f+u*j.uY(h),h=j.add(h,2),e.x3=d+c*j.uX(h),e.y3=f+u*j.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 G(Y,"Texture.baseTexture is now Texture.source"),this._source}}U.EMPTY=new U({label:"EMPTY",source:new ge({label:"EMPTY"})});U.EMPTY.destroy=qa;U.WHITE=new U({source:new ji({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});U.WHITE.destroy=qa;function sl(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 no=new F;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=no,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 ee);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=no,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 Lu={grad:.9,turn:360,rad:360/(2*Math.PI)},Qe=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},_e=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},Ue=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},rl=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},oo=function(r){return{r:Ue(r.r,0,255),g:Ue(r.g,0,255),b:Ue(r.b,0,255),a:Ue(r.a)}},Ur=function(r){return{r:_e(r.r),g:_e(r.g),b:_e(r.b),a:_e(r.a,3)}},Nu=/^#([0-9a-f]{3,8})$/i,Ws=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},il=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}},nl=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}},ao=function(r){return{h:rl(r.h),s:Ue(r.s,0,100),l:Ue(r.l,0,100),a:Ue(r.a)}},lo=function(r){return{h:_e(r.h),s:_e(r.s),l:_e(r.l),a:_e(r.a,3)}},ho=function(r){return nl((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},xs=function(r){return{h:(e=il(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},Wu=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hu=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,zu=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vu=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bi={string:[[function(r){var e=Nu.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?_e(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?_e(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=zu.exec(r)||Vu.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:oo({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=Wu.exec(r)||Hu.exec(r);if(!e)return null;var t,s,i=ao({h:(t=e[1],s=e[2],s===void 0&&(s="deg"),Number(t)*(Lu[s]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ho(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 Qe(e)&&Qe(t)&&Qe(s)?oo({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(!Qe(e)||!Qe(t)||!Qe(s))return null;var o=ao({h:Number(e),s:Number(t),l:Number(s),a:Number(n)});return ho(o)},"hsl"],[function(r){var e=r.h,t=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Qe(e)||!Qe(t)||!Qe(s))return null;var o=(function(a){return{h:rl(a.h),s:Ue(a.s,0,100),v:Ue(a.v,0,100),a:Ue(a.a)}})({h:Number(e),s:Number(t),v:Number(s),a:Number(n)});return nl(o)},"hsv"]]},co=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]},Xu=function(r){return typeof r=="string"?co(r.trim(),bi.string):typeof r=="object"&&r!==null?co(r,bi.object):[null,void 0]},Or=function(r,e){var t=xs(r);return{h:t.h,s:Ue(t.s+100*e,0,100),l:t.l,a:t.a}},Dr=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},uo=function(r,e){var t=xs(r);return{h:t.h,s:t.s,l:Ue(t.l+100*e,0,100),a:t.a}},vi=(function(){function r(e){this.parsed=Xu(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 _e(Dr(this.rgba),2)},r.prototype.isDark=function(){return Dr(this.rgba)<.5},r.prototype.isLight=function(){return Dr(this.rgba)>=.5},r.prototype.toHex=function(){return e=Ur(this.rgba),t=e.r,s=e.g,i=e.b,o=(n=e.a)<1?Ws(_e(255*n)):"","#"+Ws(t)+Ws(s)+Ws(i)+o;var e,t,s,i,n,o},r.prototype.toRgb=function(){return Ur(this.rgba)},r.prototype.toRgbString=function(){return e=Ur(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 lo(xs(this.rgba))},r.prototype.toHslString=function(){return e=lo(xs(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=il(this.rgba),{h:_e(e.h),s:_e(e.s),v:_e(e.v),a:_e(e.a,3)};var e},r.prototype.invert=function(){return $e({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),$e(Or(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),$e(Or(this.rgba,-e))},r.prototype.grayscale=function(){return $e(Or(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),$e(uo(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),$e(uo(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"?$e({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):_e(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=xs(this.rgba);return typeof e=="number"?$e({h:e,s:t.s,l:t.l,a:t.a}):_e(t.h)},r.prototype.isEqual=function(e){return this.toHex()===$e(e).toHex()},r})(),$e=function(r){return r instanceof vi?r:new vi(r)},fo=[],$u=function(r){r.forEach(function(e){fo.indexOf(e)<0&&(e(vi,bi),fo.push(e))})};function ju(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"])}$u([ju]);const Zt=class ms{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 ms)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]=ms._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=ms.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=$e(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 ms||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}};Zt.shared=new Zt;Zt._temp=new Zt;Zt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let se=Zt;const Yu={cullArea:null,cullable:!1,cullableChildren:!0};let Lr=0;const po=500;function W(...r){Lr!==po&&(Lr++,Lr===po?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}const ss={_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 qu{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 Ku{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 qu(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 xe=new Ku;ss.register(xe);const Zu={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){G("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function ol(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 Qu={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)}ol(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||G(Y,"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)}},Ju={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 dr{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 ed{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 xe.get(s.maskClass,e)}return e}returnMaskEffect(e){xe.return(e)}}const Ti=new ed;H.handleByList(b.MaskEffect,Ti._effectClasses);const td={_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),Ti.returnMaskEffect(e),this._maskEffect=null),r!=null&&(this._maskEffect=Ti.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 dr);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 dr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},sd={label:null,get name(){return G(Y,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){G(Y,"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=xe.getPool(F),it=xe.getPool(ye),rd=new F,id={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=it.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(rd).invert()),e.addBounds(s),it.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),it.return(s))}};function Yi(r,e,t){t.clear();let s,i;return r.parent?e?s=r.parent.worldTransform:(i=ve.get().identity(),s=qi(r,i)):s=F.IDENTITY,al(r,t,s,e),i&&ve.return(i),t.isValid||t.set(0,0,0,0),t}function al(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=it.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++)al(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,F.IDENTITY),it.return(e)}s||ve.return(i)}function qi(r,e){const t=r.parent;return t&&(qi(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function Pt(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 mo=16777215;function fr(r,e){return r===mo?e:e===mo?r:Pt(r,e)}function Et(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const nd={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 F,e){if(e)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const t=qi(this,ve.get().identity());return r.appendFrom(this.localTransform,t),ve.return(t),r},getGlobalTint(r){if(r)return this.renderGroup?Et(this.renderGroup.worldColor):this.parentRenderGroup?Et(fr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=fr(e,t.localColor),t=t.parent;return Et(e)}};function Ki(r,e,t){return e.clear(),t||(t=F.IDENTITY),ll(r,e,t,r,!0),e.isValid||e.set(0,0,0,0),e}function ll(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=it.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++)ll(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,F.IDENTITY),it.return(e)}ve.return(n)}function hl(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&&hl(i,e)}return e.didChange}const od=new F,ad={_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),hl(this,r),r.didChange&&Ki(this,r.localBounds,od),r.localBounds},getBounds(r,e){return Yi(this,r,e||new ye)}},ld={_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}},hd={_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(cd))}};function cd(r,e){return r._zIndex-e._zIndex}const ud={getGlobalPosition(r=new J,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 Zi{constructor(){this.uid=ne("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 dd=0;class fd{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new ot(this.textureOptions)}createTexture(e,t,s,i){const n=new ge({...this.textureOptions,width:e,height:t,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:i});return new U({source:n,label:`texturePool_${dd++}`})}getOptimalTexture(e,t,s=1,i,n=!1){let o=Math.ceil(e*s-1e-6),a=Math.ceil(t*s-1e-6);o=Kt(o),a=Kt(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 de=new fd;ss.register(de);class Si{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new F,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 Zi,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&&(de.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 F),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new F),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 F),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 pd(r,e,t={}){for(const s in e)!t[s]&&e[s]!==void 0&&(r[s]=e[s])}const Nr=new ue(null),Hs=new ue(null),Wr=new ue(null,1,1),zs=new ue(null),pr=1,Qi=2,ys=4;class Te extends Be{constructor(e={}){var t,s;super(),this.uid=ne("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 F,this.relativeGroupTransform=new F,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ue(this,0,0),this._scale=Wr,this._pivot=Hs,this._origin=zs,this._skew=Nr,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=[],pd(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){G("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),H.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||G(Y,"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=xe.get(Si,this),this.groupTransform=F.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),xe.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 F),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*ku}set angle(e){this.rotation=e*Iu}get pivot(){return this._pivot===Hs&&(this._pivot=new ue(this,0,0)),this._pivot}set pivot(e){this._pivot===Hs&&(this._pivot=new ue(this,0,0),this._origin!==zs&&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===Nr&&(this._skew=new ue(this,0,0)),this._skew}set skew(e){this._skew===Nr&&(this._skew=new ue(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Wr&&(this._scale=new ue(this,1,1)),this._scale}set scale(e){this._scale===Wr&&(this._scale=new ue(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===zs&&(this._origin=new ue(this,0,0)),this._origin}set origin(e){this._origin===zs&&(this._origin=new ue(this,0,0),this._pivot!==Hs&&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|=pr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const s=se.shared.setValue(e??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=pr,this._onUpdate())}get tint(){return Et(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Qi,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|=ys,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|=ys,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|=ys,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}}H.mixin(Te,Qu,id,ud,ld,ad,td,sd,hd,Yu,Zu,nd,Ju);class Tr 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 Qt extends Tr{constructor(e=U.EMPTY){e instanceof U&&(e={texture:e});const{texture:t=U.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 ue({_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 U?new Qt(e):new Qt(U.from(e,t))}set texture(e){e||(e=U.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 sl(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return G("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 md=new ye;function cl(r,e,t){const s=md;r.measurable=!0,Yi(r,t,s),e.addBoundsMask(s),r.measurable=!1}function ul(r,e,t){const s=it.get();r.measurable=!0;const i=ve.get().identity(),n=dl(r,t,i);Ki(r,s,n),r.measurable=!1,e.addBoundsMask(s),ve.return(i),it.return(s)}function dl(r,e,t){return r?(r!==e&&(dl(r.parent,e,t),r.updateLocalTransform(),t.append(r.localTransform)),t):(W("Mask bounds, renderable is not inside the root container"),t)}class fl{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 Qt),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||cl(this.mask,e,t)}addLocalBounds(e,t){ul(this.mask,e,t)}containsPoint(e,t){const s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof Qt}}fl.extension=b.MaskEffect;class pl{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"}}pl.extension=b.MaskEffect;class ml{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){cl(this.mask,e,t)}addLocalBounds(e,t){ul(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}}ml.extension=b.MaskEffect;const gd={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 go=gd;const V={get(){return go},set(r){go=r}};class Ye extends ge{constructor(e){e.resource||(e.resource=V.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"))}}Ye.extension=b.TextureSource;class Mt extends ge{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}}Mt.extension=b.TextureSource;var Jt=(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))(Jt||{});class Hr{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 gl=class Ae{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 Hr(null,null,1/0),this.deltaMS=1/Ae.targetFPMS,this.elapsedMS=1/Ae.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=Jt.NORMAL){return this._addListener(new Hr(e,t,s))}addOnce(e,t,s=Jt.NORMAL){return this._addListener(new Hr(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*Ae.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,Ae.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(!Ae._shared){const e=Ae._shared=new Ae;e.autoStart=!0,e._protected=!0}return Ae._shared}static get system(){if(!Ae._system){const e=Ae._system=new Ae;e.autoStart=!0,e._protected=!0}return Ae._system}};gl.targetFPMS=.06;let Oe=gl,zr;async function _l(){return zr??(zr=(async()=>{var o;const e=V.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"})()),zr}const Sr=class xl extends ge{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...xl.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=Oe.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 _l(),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&&(Oe.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||(Oe.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Oe.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Sr.extension=b.TextureSource;Sr.defaultOptions={...ge.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Sr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let bs=Sr;const We=(r,e,t=!1)=>(Array.isArray(r)||(r=[r]),e?r.map(s=>typeof s=="string"||t?e(s):s):r);class _d{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=We(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 re=new _d,wi=[];H.handleByList(b.TextureSource,wi);function yl(r={}){const e=r&&r.resource,t=e?r.resource:r,s=e?r:{resource:r};for(let i=0;i<wi.length;i++){const n=wi[i];if(n.test(t))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function xd(r={},e=!1){const t=r&&r.resource,s=t?r.resource:r,i=t?r:{resource:r};if(!e&&re.has(s))return re.get(s);const n=new U({source:yl(i)});return n.on("destroy",()=>{re.has(s)&&re.remove(s)}),e||re.set(s,n),n}function yd(r,e=!1){return typeof r=="string"?re.get(r):r instanceof ge?new U({source:r}):xd(r,e)}U.from=yd;ge.from=yl;H.add(fl,pl,ml,bs,Mt,Ye,ji);var ft=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(ft||{});function Le(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function ls(r){return r.split("?")[0].split("#")[0]}function bd(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vd(r,e,t){return r.replace(new RegExp(bd(e),"g"),t)}function Td(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 Me={toPosix(r){return vd(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){Le(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(Le(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=ls(this.toPosix(e??V.get().getBaseUrl())),i=ls(this.toPosix(t??this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?Me.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(Le(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=Td(r),r.length>0&&s&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return Le(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(Le(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(Le(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){Le(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){Le(r),e&&Le(e),r=ls(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){Le(r),r=ls(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){Le(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=ls(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 bl(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?bl(r.replace(s[t],a),e,t+1,s,i):i.push(r.replace(s[t],a))}}function Sd(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)}),bl(r,i,0,t,s)}else s.push(r);return s}const mr=r=>!Array.isArray(r);class rs{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 We(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`)},We(t).forEach(n=>{const{src:o}=n;let{data:a,format:l,loadParser:h,parser:c}=n;const u=We(o).map(g=>typeof g=="string"?Sd(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=mr(e);e=We(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=mr(e);e=We(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=Me.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??wd(e.src),l!==void 0&&(e.progressSize=l),e}}rs.RETINA_PREFIX=/@([0-9\.]+)x/;function wd(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Ci=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r},vl=class gs{constructor(e,t){this.linkedSheets=[];let s=e;(e==null?void 0:e.source)instanceof ge&&(s={texture:e,data:t});const{texture:i,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=i instanceof U?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<=gs.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:gs.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 ee(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?l=new ee(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 ee(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 ee(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 U({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*gs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*gs.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=[]}};vl.BATCH_SIZE=1e3;let _o=vl;const Cd=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Tl(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=Me.dirname(r[0]);e.linkedSheets.forEach((n,o)=>{const a=Tl([`${i}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const Ad={extension:b.Asset,cache:{test:r=>r instanceof _o,getCacheableAssets:(r,e)=>Tl(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"&&Cd.includes(i)},parse:r=>{var t;const e=r.split(".");return{resolution:parseFloat(((t=rs.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:ft.Normal,name:"spritesheetLoader"},async testParse(r,e){return Me.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=Me.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(s instanceof U)l=s;else{const f=Ci(a+(i??r.meta.image),e.src);l=(await t.load([{src:f,data:n}]))[f]}const h=new _o({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=Ci(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)}}};H.add(Ad);class Sl{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||Oe.shared.add(this.updateTranslation,this,Jt.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Oe.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 Is{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Is.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new J,this.page=new J,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 Vr=/iPhone/i,xo=/iPod/i,yo=/iPad/i,bo=/\biOS-universal(?:.+)Mac\b/i,Xr=/\bAndroid(?:.+)Mobile\b/i,vo=/Android/i,Ut=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Vs=/Silk/i,Je=/Windows Phone/i,To=/\bWindows(?:.+)ARM\b/i,So=/BlackBerry/i,wo=/BB10/i,Co=/Opera Mini/i,Ao=/\b(CriOS|Chrome)(?:.+)Mobile/i,Po=/Mobile(?:.+)Firefox\b/i,Eo=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 Mo(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(Vr)&&!i(Je),ipod:i(xo),tablet:!i(Vr)&&(i(yo)||Eo(e))&&!i(Je),universal:i(bo),device:(i(Vr)||i(xo)||i(yo)||i(bo)||Eo(e))&&!i(Je)},amazon:{phone:i(Ut),tablet:!i(Ut)&&i(Vs),device:i(Ut)||i(Vs)},android:{phone:!i(Je)&&i(Ut)||!i(Je)&&i(Xr),tablet:!i(Je)&&!i(Ut)&&!i(Xr)&&(i(Vs)||i(vo)),device:!i(Je)&&(i(Ut)||i(Vs)||i(Xr)||i(vo))||i(/\bokhttp\b/i)},windows:{phone:i(Je),tablet:i(To),device:i(Je)||i(To)},other:{blackberry:i(So),blackberry10:i(wo),opera:i(Co),firefox:i(Po),chrome:i(Ao),device:i(So)||i(wo)||i(Co)||i(Po)||i(Ao)},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 Ed=Mo.default??Mo,Md=Ed(globalThis.navigator),Rd=9,Ro=100,Bd=0,kd=0,Bo=2,ko=1,Id=-1e3,Fd=-1e3,Gd=2,Ji=class wl{constructor(e,t=Md){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=`${ko}px`,e.style.height=`${ko}px`,e.style.position="absolute",e.style.top=`${Id}px`,e.style.left=`${Fd}px`,e.style.zIndex=Gd.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=`${Bd}px`,this._div.style.left=`${kd}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Bo.toString(),this._canvasObserver=new Sl({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:{...wl.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,ol(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=`${Ro}px`,s.style.height=`${Ro}px`,s.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",s.style.position="absolute",s.style.zIndex=Bo.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 Is(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!==Rd||!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]}};Ji.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};Ji.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Ud=Ji;const Od={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1},$r=Object.create(null),Io=Object.create(null);function As(r,e){let t=Io[r];return t===void 0&&($r[e]===void 0&&($r[e]=1),Io[r]=t=$r[e]++),t}let Ot;function Cl(){return(!Ot||Ot!=null&&Ot.isContextLost())&&(Ot=V.get().createCanvas().getContext("webgl",{})),Ot}let Xs;function Dd(){if(!Xs){Xs="mediump";const r=Cl();r&&r.getShaderPrecisionFormat&&(Xs=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Xs}function Ld(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 Nd(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 Wd(r,e){return e?`#version 300 es
|
|
34
|
+
${r}`:r}const Hd={},zd={};function Vd(r,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const s=t?Hd:zd;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 Xd(r,e){return e?r.replace("#version 300 es",""):r}const jr={stripVersion:Xd,ensurePrecision:Nd,addProgramDefines:Ld,setProgramName:Vd,insertVersion:Wd},hs=Object.create(null),Al=class Ai{constructor(e){e={...Ai.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Dd()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let i=e.fragment,n=e.vertex;Object.keys(jr).forEach(o=>{const a=s[o];i=jr[o](i,a,!0),n=jr[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=As(`${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,hs[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return hs[t]||(hs[t]=new Ai(e),hs[t]._cacheKey=t),hs[t]}};Al.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let pt=Al;const Fo={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Ps(r){return Fo[r]??Fo.float32}const $d={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"},Go=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Uo(r,e){let t;for(;(t=Go.exec(r))!==null;){const s=$d[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:s,stride:Ps(s).stride,offset:0,instance:!1,start:0}}Go.lastIndex=0}function jd(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Yd({source:r,entryPoint:e}){const t={},s=jd(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(Uo(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&&Uo(c[1],t)}}return t}function Yr(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 Tt=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Tt||{});function qd({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:Tt.VERTEX|Tt.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?e[s.group].push({binding:s.binding,visibility:Tt.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?e[s.group].push({binding:s.binding,visibility:Tt.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:Tt.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:Tt.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function Kd({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 Zd(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 cs=Object.create(null);class at{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=Yr(t.source);this.structsAndGroups=h}else{const h=Yr(s.source),c=Yr(t.source);this.structsAndGroups=Zd(h,c)}this.layout=i??Kd(this.structsAndGroups),this.gpuLayout=n??qd(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=As(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Yd(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,cs[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return cs[t]||(cs[t]=new at(e),cs[t]._cacheKey=t),cs[t]}}const Pl=["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>"],Qd=Pl.reduce((r,e)=>(r[e]=!0,r),{});function Jd(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 El=class Ml{constructor(e,t){this._touched=0,this.uid=ne("uniform"),this._resourceType="uniformGroup",this._resourceId=ne("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...Ml.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,!Qd[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: ${Pl.join(", ")}`)}n.value??(n.value=Jd(n.type,n.size)),s[i]=n.value}this.uniforms=s,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=As(Object.keys(s).map(i=>`${i}-${e[i].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};El.defaultOptions={ubo:!1,isStatic:!1};let Re=El;class ut{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 Se=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Se||{});class Ke extends Be{constructor(e){super(),this.uid=ne("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|=Se.WEBGPU),s&&(o|=Se.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 ut,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 Re(d));const f=l[u];f&&(i[f.group]||(i[f.group]=new ut,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 ut,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=at.from(t)),s&&(o=pt.from(s)),new Ke({gpuProgram:n,glProgram:o,...i})}}const ef={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},qr=0,Kr=1,Zr=2,Qr=3,Jr=4,ei=5,Pi=class Rl{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<qr)}set blend(e){!!(this.data&1<<qr)!==e&&(this.data^=1<<qr)}get offsets(){return!!(this.data&1<<Kr)}set offsets(e){!!(this.data&1<<Kr)!==e&&(this.data^=1<<Kr)}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<<Zr)}set culling(e){!!(this.data&1<<Zr)!==e&&(this.data^=1<<Zr)}get depthTest(){return!!(this.data&1<<Qr)}set depthTest(e){!!(this.data&1<<Qr)!==e&&(this.data^=1<<Qr)}get depthMask(){return!!(this.data&1<<ei)}set depthMask(e){!!(this.data&1<<ei)!==e&&(this.data^=1<<ei)}get clockwiseFrontFace(){return!!(this.data&1<<Jr)}set clockwiseFrontFace(e){!!(this.data&1<<Jr)!==e&&(this.data^=1<<Jr)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=ef[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 Rl;return e.depthTest=!1,e.blend=!0,e}};Pi.default2d=Pi.for2d();let Ze=Pi;const Bl=class Ei extends Ke{constructor(e){e={...Ei.defaultOptions,...e},super(e),this.enabled=!0,this._state=Ze.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=at.from(t)),s&&(o=pt.from(s)),new Ei({gpuProgram:n,glProgram:o,...i})}};Bl.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Fs=Bl;const Mi=[];H.handleByNamedList(b.Environment,Mi);async function tf(r){if(!r)for(let e=0;e<Mi.length;e++){const t=Mi[e];if(t.value.test()){await t.value.load();return}}}let us;function kl(){if(typeof us=="boolean")return us;try{us=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{us=!1}return us}function Oo(r,e,t=2){const s=e&&e.length,i=s?e[0]*t:r.length;let n=Il(r,0,i,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,h;if(s&&(n=af(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 Es(n,o,t,a,l,h,0),o}function Il(r,e,t,s,i){let n;if(i===xf(r,e,t,s)>0)for(let o=e;o<t;o+=s)n=Do(o/s|0,r[o],r[o+1],n);else for(let o=t-s;o>=e;o-=s)n=Do(o/s|0,r[o],r[o+1],n);return n&&es(n,n.next)&&(Rs(n),n=n.next),n}function Rt(r,e){if(!r)return r;e||(e=r);let t=r,s;do if(s=!1,!t.steiner&&(es(t,t.next)||le(t.prev,t,t.next)===0)){if(Rs(t),t=e=t.prev,t===t.next)break;s=!0}else t=t.next;while(s||t!==e);return e}function Es(r,e,t,s,i,n,o){if(!r)return;!o&&n&&df(r,s,i,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,h=r.next;if(n?rf(r,s,i,n):sf(r)){e.push(l.i,r.i,h.i),Rs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=nf(Rt(r),e),Es(r,e,t,s,i,n,2)):o===2&&of(r,e,t,s,i,n):Es(Rt(r),e,t,s,i,n,1);break}}}function sf(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&&_s(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 rf(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),_=Ri(f,p,e,t,s),x=Ri(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&&_s(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&&_s(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&&_s(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&&_s(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 nf(r,e){let t=r;do{const s=t.prev,i=t.next.next;!es(s,i)&&Gl(s,t,t.next,i)&&Ms(s,i)&&Ms(i,s)&&(e.push(s.i,t.i,i.i),Rs(t),Rs(t.next),t=r=i),t=t.next}while(t!==r);return Rt(t)}function of(r,e,t,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&mf(o,a)){let l=Ul(o,a);o=Rt(o,o.next),l=Rt(l,l.next),Es(o,e,t,s,i,n,0),Es(l,e,t,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function af(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=Il(r,a,l,s,!1);h===h.next&&(h.steiner=!0),i.push(pf(h))}i.sort(lf);for(let n=0;n<i.length;n++)t=hf(i[n],t);return t}function lf(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 hf(r,e){const t=cf(r,e);if(!t)return e;const s=Ul(t,r);return Rt(s,s.next),Rt(t,t.next)}function cf(r,e){let t=e;const s=r.x,i=r.y;let n=-1/0,o;if(es(r,t))return t;do{if(es(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&&Fl(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);Ms(t,r)&&(u<c||u===c&&(t.x>o.x||t.x===o.x&&uf(o,t)))&&(o=t,c=u)}t=t.next}while(t!==a);return o}function uf(r,e){return le(r.prev,r,e.prev)<0&&le(e.next,r,r.next)<0}function df(r,e,t,s){let i=r;do i.z===0&&(i.z=Ri(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,ff(i)}function ff(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 Ri(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 pf(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 Fl(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 _s(r,e,t,s,i,n,o,a){return!(r===o&&e===a)&&Fl(r,e,t,s,i,n,o,a)}function mf(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!gf(r,e)&&(Ms(r,e)&&Ms(e,r)&&_f(r,e)&&(le(r.prev,r,e.prev)||le(r,e.prev,e))||es(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 es(r,e){return r.x===e.x&&r.y===e.y}function Gl(r,e,t,s){const i=js(le(r,e,t)),n=js(le(r,e,s)),o=js(le(t,s,r)),a=js(le(t,s,e));return!!(i!==n&&o!==a||i===0&&$s(r,t,e)||n===0&&$s(r,s,e)||o===0&&$s(t,r,s)||a===0&&$s(t,e,s))}function $s(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 js(r){return r>0?1:r<0?-1:0}function gf(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&&Gl(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Ms(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 _f(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 Ul(r,e){const t=Bi(r.i,r.x,r.y),s=Bi(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 Do(r,e,t,s){const i=Bi(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 Rs(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Bi(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xf(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 yf=Oo.default||Oo;var Pe=(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))(Pe||{});class Ol{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 bf=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Dl=class Ll extends Be{constructor(e){super(),this.tick=0,this.uid=ne("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=[...bf,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await tf(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={...Ll.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&&(G(Y,"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:se.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=Pe.ALL);const{clear:s,clearColor:i,target:n,mipLevel:o,layer:a}=e;se.shared.setValue(i??this.background.colorRgba),t.renderTarget.clear(n,s,se.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 Ol(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)&&ss.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(!kl())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()}};Dl.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Gs=Dl,Ys;function vf(r){return Ys!==void 0||(Ys=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r??Gs.defaultOptions.failIfMajorPerformanceCaveat};try{if(!V.get().getWebGLRenderingContext())return!1;let i=V.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}})()),Ys}let qs;async function Tf(r={}){return qs!==void 0||(qs=await(async()=>{const e=V.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),qs}const Lo=["webgl","webgpu","canvas"];async function Sf(r){let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Lo.forEach(n=>{n!==r.preference&&e.push(n)})):e=Lo.slice();let t,s={};for(let n=0;n<e.length;n++){const o=e[n];if(o==="webgpu"&&await Tf()){const{WebGPURenderer:a}=await jt(async()=>{const{WebGPURenderer:l}=await Promise.resolve().then(()=>Ry);return{WebGPURenderer:l}},void 0);t=a,s={...r,...r.webgpu};break}else if(o==="webgl"&&vf(r.failIfMajorPerformanceCaveat??Gs.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await jt(async()=>{const{WebGLRenderer:l}=await Promise.resolve().then(()=>ly);return{WebGLRenderer:l}},void 0);t=a,s={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await jt(async()=>{const{CanvasRenderer:l}=await Promise.resolve().then(()=>ax);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 gr="8.18.1";class Nl{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,gr)}static destroy(){}}Nl.extension=b.Application;class Wl{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,gr)}destroy(){this._renderer=null}}Wl.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"initHook",priority:-10};class Hl{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}}Hl.extension=b.Application;class zl{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,Jt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Oe.shared:new Oe,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}zl.extension=b.Application;H.add(Hl);H.add(zl);const Vl=class ki{constructor(...e){this.stage=new Te,e[0]!==void 0&&G(Y,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new Te),this.renderer=await Sf(e),ki._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return G(Y,"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=ki._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}};Vl._plugins=[];let wf=Vl;H.handleByList(b.Application,wf._plugins);H.add(Nl);const ti={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}},No={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}},Wo={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?No.test(V.get().parseXML(r)):!1},parse(r){return No.parse(V.get().parseXML(r))}},Cf=[".xml",".fnt"],Af={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:ft.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return Cf.includes(Me.extname(r).toLowerCase())},async testParse(r){return ti.test(r)||Wo.test(r)},async parse(r,e,t){const s=ti.test(r)?ti.parse(r):Wo.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=Me.join(Me.dirname(i),f);p=Ci(p,i),o.push({src:p,data:a})}const[l,{BitmapFont:h}]=await Promise.all([t.load(o),jt(()=>Promise.resolve().then(()=>ky),void 0)]),c=o.map(d=>l[d.src]);return new h({data:s,textures:c},i)},async load(r,e){return await(await V.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 Ef{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 Mf={extension:{type:b.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(e=>e instanceof U),getCacheableAssets:(r,e)=>{const t={};return r.forEach(s=>{e.forEach((i,n)=>{t[s+(n===0?"":n+1)]=i})}),t}};async function Xl(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 Rf={extension:{type:b.DetectionParser,priority:1},test:async()=>Xl("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(e=>e!=="avif")},Ho=["png","jpg","jpeg"],Bf={extension:{type:b.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Ho],remove:async r=>r.filter(e=>!Ho.includes(e))},kf="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function wr(r){return kf?!1:document.createElement("video").canPlayType(r)!==""}const If={extension:{type:b.DetectionParser,priority:0},test:async()=>wr("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(e=>e!=="mp4"&&e!=="m4v")},Ff={extension:{type:b.DetectionParser,priority:0},test:async()=>wr("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(e=>e!=="ogv")},Gf={extension:{type:b.DetectionParser,priority:0},test:async()=>wr("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(e=>e!=="webm")},Uf={extension:{type:b.DetectionParser,priority:0},test:async()=>Xl("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(e=>e!=="webp")},$l=class nr{constructor(){this.loadOptions={...nr.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"?{...nr.defaultOptions,...this.loadOptions,onProgress:t}:{...nr.defaultOptions,...this.loadOptions,...t||{}},{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l}=s;let h=0;const c={},u=mr(e),d=We(e,g=>({alias:[g],src:g,data:{}})),f=d.reduce((g,m)=>g+(m.progressSize||1),0),p=d.map(async g=>{const m=Me.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=We(e,i=>({alias:[i],src:i})).map(async i=>{var a,l;const n=Me.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}}};$l.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let Of=$l;function is(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 ns(r,e){const t=r.split("?")[0],s=Me.extname(t).toLowerCase();return Array.isArray(e)?e.includes(s):s===e}const Df=".json",Lf="application/json",Nf={extension:{type:b.LoadParser,priority:ft.Low},name:"loadJson",id:"json",test(r){return is(r,Lf)||ns(r,Df)},async load(r){return await(await V.get().fetch(r)).json()}},Wf=".txt",Hf="text/plain",zf={name:"loadTxt",id:"text",extension:{type:b.LoadParser,priority:ft.Low,name:"loadTxt"},test(r){return is(r,Hf)||ns(r,Wf)},async load(r){return await(await V.get().fetch(r)).text()}},Vf=["normal","bold","100","200","300","400","500","600","700","800","900"],Xf=[".ttf",".otf",".woff",".woff2"],$f=["font/ttf","font/otf","font/woff","font/woff2"],jf=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Yf(r){const e=Me.extname(r),i=Me.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(jf)){n=!1;break}let o=i.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const qf=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Kf(r){return qf.test(r)?r:encodeURI(r)}const Zf={extension:{type:b.LoadParser,priority:ft.Low},name:"loadWebFont",id:"web-font",test(r){return is(r,$f)||ns(r,Xf)},async load(r,e){var s,i,n;const t=V.get().getFontFaceSet();if(t){const o=[],a=((s=e.data)==null?void 0:s.family)??Yf(r),l=((n=(i=e.data)==null?void 0:i.weights)==null?void 0:n.filter(c=>Vf.includes(c)))??["normal"],h=e.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url('${Kf(r)}')`,{...h,weight:u});await d.load(),t.add(d),o.push(d)}return re.has(`${a}-and-url`)?re.get(`${a}-and-url`).entries.push({url:r,faces:o}):re.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=re.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=>{V.get().getFontFaceSet().delete(n)}),s.entries.length===0&&re.remove(`${t}-and-url`)}};var si,zo;function Qf(){if(zo)return si;zo=1,si=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 si}var Jf=Qf();const ep=ja(Jf);function tp(r,e){const t=ep(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 en{constructor(e=0,t=0,s=0){this.type="circle",this.x=e,this.y=t,this.radius=s}clone(){return new en(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 ee),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 tn{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 tn(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 ee),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 sp(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 rp,ip;class vs{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(rp),s=e.getBounds(ip);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 vs(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=sp(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 ee);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 G("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return G("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Ks=(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 sn{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 ee),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new sn(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&&Ks(e,t,d,f,h,u,c)||e>m-h&&t<f&&Ks(e,t,m-h,f,h,u,c)||e>m-h&&t>_-h&&Ks(e,t,m-h,_-h,h,u,c)||e<d&&t>_-h&&Ks(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 jl={};function rn(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 jl[s]||np(r,e,s,t)}function np(r,e,t,s){const i={};let n=0;for(let a=0;a<s;a++){const l=a<e?r[a]:U.EMPTY.source;i[n++]=l.source,i[n++]=l.style}const o=new ut(i);return jl[t]=o,o}class Vo{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 Ii(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 op={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var pe=(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))(pe||{});function Fi(r,e){return e.alphaMode==="no-premultiply-alpha"&&op[r]||r}const ap=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
37
|
+
`);function lp(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 Yl(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=ap.replace(/%forloop%/gi,lp(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 Dt=null;function hp(){var e;if(Dt)return Dt;const r=Cl();return Dt=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),Dt=Yl(Dt,r),(e=r.getExtension("WEBGL_lose_context"))==null||e.loseContext(),Dt}class cp{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 up{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new cp,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 Ts=[];let _r=0;ss.register({clear:()=>{if(Ts.length>0)for(const r of Ts)r&&r.destroy();Ts.length=0,_r=0}});function Xo(){return _r>0?Ts[--_r]:new up}function $o(r){r.elements=null,Ts[_r++]=r}let ds=0;const ql=class Kl{constructor(e){this.uid=ne("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...Kl.defaultOptions,...e},e.maxTextures||(G("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=hp());const{maxTextures:t,attributesInitialSize:s,indicesInitialSize:i}=e;this.attributeBuffer=new Vo(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++)$o(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=Xo(),i=s.textures;i.clear();const n=t[this.elementStart];let o=Fi(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=Fi(_.blendMode,y),S=o!==T||a!==_.topology;if(y._batchTick===ds&&!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=ds,(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=Xo(),i=s.textures,i.clear(),p=[],++ds),_._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,++ds),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,++ds,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 Vo(t);Ii(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 Ii(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++)$o(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}}};ql.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let dp=ql;var Q=(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))(Q||{});class He extends Be{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=ne("buffer"),this._resourceType="buffer",this._resourceId=ne("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&Q.STATIC)}set static(e){e?this.descriptor.usage|=Q.STATIC:this.descriptor.usage&=~Q.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=ne("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 Zl(r,e){if(!(r instanceof He)){let t=e?Q.INDEX:Q.VERTEX;r instanceof Array&&(e?(r=new Uint32Array(r),t=Q.INDEX|Q.COPY_DST):(r=new Float32Array(r),t=Q.VERTEX|Q.COPY_DST)),r=new He({data:r,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return r}function fp(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 pp(r){return(r instanceof He||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=Zl(r.buffer,!1),r}class Cr extends Be{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ne("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=pp(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=Zl(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,fp(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 mp=new Float32Array(1),gp=new Uint32Array(1);class _p extends Cr{constructor(){const t=new He({data:mp,label:"attribute-batch-buffer",usage:Q.VERTEX|Q.COPY_DST,shrinkToFit:!1}),s=new He({data:gp,label:"index-batch-buffer",usage:Q.INDEX|Q.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 jo(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 xp=/\{\{(.*?)\}\}/g;function Yo(r){var s;const e={};return(((s=r.match(xp))==null?void 0:s.map(i=>i.replace(/[{()}]/g,"")))??[]).forEach(i=>{e[i]=[]}),e}function qo(r,e){let t;const s=/@in\s+([^;]+);/g;for(;(t=s.exec(r))!==null;)e.push(t[1])}function Ko(r,e,t=!1){const s=[];qo(e,s),r.forEach(a=>{a.header&&qo(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 Zo(r,e){let t;const s=/@out\s+([^;]+);/g;for(;(t=s.exec(r))!==null;)e.push(t[1])}function yp(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function bp(r){const e=/@.*?\s+/g;return r.replace(e,"")}function vp(r,e){const t=[];Zo(e,t),r.forEach(l=>{l.header&&Zo(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 ${bp(l)};`).join(`
|
|
43
|
+
`),o=`return VSOutput(
|
|
44
|
+
${t.sort().map(l=>` ${yp(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 Qo(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 ct=Object.create(null),ri=new Map;let Tp=0;function Sp({template:r,bits:e}){const t=Ql(r,e);if(ct[t])return ct[t];const{vertex:s,fragment:i}=Cp(r,e);return ct[t]=Jl(s,i,e),ct[t]}function wp({template:r,bits:e}){const t=Ql(r,e);return ct[t]||(ct[t]=Jl(r.vertex,r.fragment,e)),ct[t]}function Cp(r,e){const t=e.map(o=>o.vertex).filter(o=>!!o),s=e.map(o=>o.fragment).filter(o=>!!o);let i=Ko(t,r.vertex,!0);i=vp(t,i);const n=Ko(s,r.fragment,!0);return{vertex:i,fragment:n}}function Ql(r,e){return e.map(t=>(ri.has(t)||ri.set(t,Tp++),ri.get(t))).sort((t,s)=>t-s).join("-")+r.vertex+r.fragment}function Jl(r,e,t){const s=Yo(r),i=Yo(e);return t.forEach(n=>{jo(n.vertex,s,n.name),jo(n.fragment,i,n.name)}),{vertex:Qo(r,s),fragment:Qo(e,i)}}const Ap=`
|
|
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
|
+
`,Ep=`
|
|
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
|
+
`,Mp=`
|
|
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
|
+
`,Rp={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
|
+
`}},Bp={name:"global-uniforms-bit",vertex:{header:`
|
|
189
|
+
uniform mat3 uProjectionMatrix;
|
|
190
|
+
uniform mat3 uWorldTransformMatrix;
|
|
191
|
+
uniform vec4 uWorldColorAlpha;
|
|
192
|
+
uniform vec2 uResolution;
|
|
193
|
+
`}};function Ar({bits:r,name:e}){const t=Sp({template:{fragment:Pp,vertex:Ap},bits:[Rp,...r]});return at.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function Pr({bits:r,name:e}){return new pt({name:e,...wp({template:{vertex:Ep,fragment:Mp},bits:[Bp,...r]})})}const eh={name:"color-bit",vertex:{header:`
|
|
194
|
+
@in aColor: vec4<f32>;
|
|
195
|
+
`,main:`
|
|
196
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
197
|
+
`}},th={name:"color-bit",vertex:{header:`
|
|
198
|
+
in vec4 aColor;
|
|
199
|
+
`,main:`
|
|
200
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
201
|
+
`}},ii={};function kp(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 Ip(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 sh(r){return ii[r]||(ii[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
|
+
${kp(r)}
|
|
217
|
+
`,main:`
|
|
218
|
+
var uvDx = dpdx(vUV);
|
|
219
|
+
var uvDy = dpdy(vUV);
|
|
220
|
+
|
|
221
|
+
${Ip(r)}
|
|
222
|
+
`}}),ii[r]}const ni={};function Fp(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 rh(r){return ni[r]||(ni[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
|
+
${Fp(r)}
|
|
242
|
+
`}}),ni[r]}const Er={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
|
+
`}},Mr={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
|
+
`}},Jo={};function ih(r){let e=Jo[r];if(e)return e;const t=new Int32Array(r);for(let s=0;s<r;s++)t[s]=s;return e=Jo[r]=new Re({uTextures:{value:t,type:"i32",size:r}},{isStatic:!0}),e}class ea extends Ke{constructor(e){const t=Pr({name:"batch",bits:[th,rh(e),Mr]}),s=Ar({name:"batch",bits:[eh,sh(e),Er]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:ih(e)}}),this.maxTextures=e}}let fs=null;const nh=class oh extends dp{constructor(e){super(e),this.geometry=new _p,this.name=oh.extension.name,this.vertexSize=6,fs??(fs=new ea(e.maxTextures)),this.shader=fs}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&&(fs=new ea(e),this.shader=fs)}destroy(){this.shader=null,super.destroy()}};nh.extension={type:[b.Batcher],name:"default"};let nn=nh;class ze{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 Gp(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 Up(r,e,t,s){let i=0;for(e*=t;i<s;)r[e]=0,r[e+1]=0,e+=t,i++}function ah(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 Op=new F;class on{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?Pt(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)||Op}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 Bs={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,P=t+v,R=t-v,A=s+w,C=s-w;e[c++]=P,e[c++]=A,e[--u]=A,e[--u]=R,e[d++]=R,e[d++]=C,e[--f]=C,e[--f]=P}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}},Dp={...Bs,extension:{...Bs.extension,name:"ellipse"}},Lp={...Bs,extension:{...Bs.extension,name:"roundedRectangle"}},lh=1e-4,ta=1e-4;function Np(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 sa(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 gt(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 an(r,e,t,s,i,n){const o=lh;if(r.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let B=Np(r);l=(l-.5)*B+.5}const h=new J(r[0],r[1]),c=new J(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],P=0,R=0,A=-(S-w),C=T-v,E=0,k=0,O=Math.sqrt(A*A+C*C);A/=O,C/=O,A*=_,C*=_;const he=l,M=(1-he)*2,I=he*2;u||(a.cap==="round"?g+=gt(T-A*(M-I)*.5,S-C*(M-I)*.5,T-A*M,S-C*M,T+A*I,S+C*I,f,!0)+2:a.cap==="square"&&(g+=sa(T,S,A,C,M,I,!0,f))),f.push(T-A*M,S-C*M),f.push(T+A*I,S+C*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],P=r[(B+1)*2],R=r[(B+1)*2+1],A=-(S-w),C=T-v,O=Math.sqrt(A*A+C*C),A/=O,C/=O,A*=_,C*=_,E=-(w-R),k=v-P,O=Math.sqrt(E*E+k*k),E/=O,k/=O,E*=_,k*=_;const N=v-T,q=S-w,D=v-P,K=R-w,oe=N*D+q*K,ae=q*D-K*N,te=ae<0;if(Math.abs(ae)<.001*Math.abs(oe)){f.push(v-A*M,w-C*M),f.push(v+A*I,w+C*I),oe>=0&&(a.join==="round"?g+=gt(v,w,v-A*M,w-C*M,v-E*M,w-k*M,f,!1)+4:g+=2,f.push(v-E*I,w-k*I),f.push(v+E*M,w+k*M));continue}const me=(-A+T)*(-C+w)-(-A+v)*(-C+S),be=(-E+P)*(-k+w)-(-E+v)*(-k+R),X=(N*be-D*me)/ae,Ce=(K*me-q*be)/ae,ke=(X-v)*(X-v)+(Ce-w)*(Ce-w),fe=v+(X-v)*M,Ve=w+(Ce-w)*M,De=v-(X-v)*I,Ie=w-(Ce-w)*I,kt=Math.min(N*N+q*q,D*D+K*K),It=te?M:I,as=kt+It*It*x;ke<=as?a.join==="bevel"||ke/x>y?(te?(f.push(fe,Ve),f.push(v+A*I,w+C*I),f.push(fe,Ve),f.push(v+E*I,w+k*I)):(f.push(v-A*M,w-C*M),f.push(De,Ie),f.push(v-E*M,w-k*M),f.push(De,Ie)),g+=2):a.join==="round"?te?(f.push(fe,Ve),f.push(v+A*I,w+C*I),g+=gt(v,w,v+A*I,w+C*I,v+E*I,w+k*I,f,!0)+4,f.push(fe,Ve),f.push(v+E*I,w+k*I)):(f.push(v-A*M,w-C*M),f.push(De,Ie),g+=gt(v,w,v-A*M,w-C*M,v-E*M,w-k*M,f,!1)+4,f.push(v-E*M,w-k*M),f.push(De,Ie)):(f.push(fe,Ve),f.push(De,Ie)):(f.push(v-A*M,w-C*M),f.push(v+A*I,w+C*I),a.join==="round"?te?g+=gt(v,w,v+A*I,w+C*I,v+E*I,w+k*I,f,!0)+2:g+=gt(v,w,v-A*M,w-C*M,v-E*M,w-k*M,f,!1)+2:a.join==="miter"&&ke/x<=y&&(te?(f.push(De,Ie),f.push(De,Ie)):(f.push(fe,Ve),f.push(fe,Ve)),g+=2),f.push(v-E*M,w-k*M),f.push(v+E*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],A=-(S-w),C=T-v,O=Math.sqrt(A*A+C*C),A/=O,C/=O,A*=_,C*=_,f.push(v-A*M,w-C*M),f.push(v+A*I,w+C*I),u||(a.cap==="round"?g+=gt(v-A*(M-I)*.5,w-C*(M-I)*.5,v-A*M,w-C*M,v+A*I,w+C*I,f,!1)+2:a.cap==="square"&&(g+=sa(v,w,A,C,M,I,!1,f)));const L=ta*ta;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],P=f[(B+2)*2],R=f[(B+2)*2+1],!(Math.abs(T*(w-R)+v*(R-S)+P*(S-w))<L)&&n.push(B,B+1,B+2)}function Wp(r,e,t,s){const i=lh;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 hh(r,e,t,s,i,n,o){const a=yf(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 Hp=[],zp={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){hh(r,Hp,e,t,s,i,n)}},Vp={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}},Xp={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}},ra=[{offset:0,color:"white"},{offset:1,color:"black"}],ln=class Gi{constructor(...e){this.uid=ne("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=$p(e);t={...t.type==="radial"?Gi.defaultRadialOptions:Gi.defaultLinearOptions,...Ka(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:se.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:ra,h=this._textureSize,{canvas:c,context:u}=na(h,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);ia(d,l),u.fillStyle=d,u.fillRect(0,0,h,1),this.texture=new U({source:new Mt({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),g=new F;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:ra,t=this._textureSize,{canvas:s,context:i}=na(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);ia(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 U({source:new Mt({resource:s,addressMode:this._wrapMode})});const _=new F;_.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}`}};ln.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};ln.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let qe=ln;function ia(r,e){for(let t=0;t<e.length;t++){const s=e[t];r.addColorStop(s.offset,s.color)}}function na(r,e){const t=V.get().createCanvas(r,e),s=t.getContext("2d");return{canvas:t,context:s}}function $p(r){let e=r[0]??{};return(typeof e=="number"||r[1])&&(G("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]??qe.defaultLinearOptions.textureSize}),e}const jp=new F,Yp=new ee;function ch(r,e,t,s){const i=e.matrix?r.copyFrom(e.matrix).invert():r.identity();if(e.textureSpace==="local"){const o=t.getBounds(Yp);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 qe)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),s&&i.append(jp.copyFrom(s).invert()),i}const os={};H.handleByMap(b.ShapeBuilder,os);H.add(Vp,zp,Xp,Bs,Dp,Lp);const qp=new ee,Kp=new F;function Zp(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")Qp(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&&oa(h.shapePath,l,!0,s,t),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),oa(a,l,o,s,t)}}}function Qp(r,e,t){const s=[],i=os.rectangle,n=qp;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&&ah(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=xe.get(on);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 oa(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=os[l.type];if(!d.build(l,u))return;const f=a.length,p=n.length/2;let g="triangle-list";if(h&&ah(u,h),t){const y=l.closePath??!0,T=e;T.pixelLine?(Wp(u,y,n,a),g="line-list"):an(u,T,!1,y,n,a)}else if(c){const y=[],T=u.slice();Jp(c).forEach(v=>{y.push(T.length/2),T.push(...v)}),hh(T,y,n,2,p,a,f)}else d.triangulate(u,n,2,p,a,f);const m=o.length/2,_=e.texture;if(_!==U.WHITE){const y=ch(Kp,e,l,h);Gp(n,2,p,o,m,2,n.length/2-p,y)}else Up(o,m,2,n.length/2-p);const x=xe.get(on);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 Jp(r){const e=[];for(let t=0;t<r.length;t++){const s=r[t].shape,i=[];os[s.type].build(s,i)&&e.push(i)}return e}class em{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{xe.return(e)}),this.graphicsData&&xe.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 tm{constructor(){this.instructions=new Zi}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new nn({maxTextures:t}),this.instructions.reset()}get geometry(){return G(Ou,"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 hn=class Ui{constructor(e){this._renderer=e,this._managedContexts=new ze({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Ui.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Ui.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(),Zp(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=xe.get(tm,{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=rn(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new em;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};hn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"graphicsContext"};hn.defaultOptions={bezierSmoothness:.5};let cn=hn;const sm=8,Zs=11920929e-14,rm=1;function uh(r,e,t,s,i,n,o,a,l,h){const u=Math.min(.99,Math.max(0,h??cn.defaultOptions.bezierSmoothness));let d=(rm-u)/1;return d*=d,im(e,t,s,i,n,o,a,l,r,d),r}function im(r,e,t,s,i,n,o,a,l,h){Oi(r,e,t,s,i,n,o,a,l,h,0),l.push(o,a)}function Oi(r,e,t,s,i,n,o,a,l,h,c){if(c>sm)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,P=a-e;const R=Math.abs((t-o)*P-(s-a)*w),A=Math.abs((i-o)*P-(n-a)*w);if(R>Zs&&A>Zs){if((R+A)*(R+A)<=h*(w*w+P*P)){l.push(S,v);return}}else if(R>Zs){if(R*R<=h*(w*w+P*P)){l.push(S,v);return}}else if(A>Zs){if(A*A<=h*(w*w+P*P)){l.push(S,v);return}}else if(w=S-(r+o)/2,P=v-(e+a)/2,w*w+P*P<=h){l.push(S,v);return}}Oi(r,e,u,d,_,x,S,v,l,h,c+1),Oi(S,v,y,T,g,m,o,a,l,h,c+1)}const nm=8,om=11920929e-14,am=1;function lm(r,e,t,s,i,n,o,a){const h=Math.min(.99,Math.max(0,a??cn.defaultOptions.bezierSmoothness));let c=(am-h)/1;return c*=c,hm(e,t,s,i,n,o,r,c),r}function hm(r,e,t,s,i,n,o,a){Di(o,r,e,t,s,i,n,a,0),o.push(i,n)}function Di(r,e,t,s,i,n,o,a,l){if(l>nm)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(_>om){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}Di(r,e,t,h,c,f,p,a,l+1),Di(r,f,p,u,d,n,o,a,l+1)}function dh(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 cm(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),P=u*(m+y),R=c*(m+y),A=Math.atan2(w-S,v-T),C=Math.atan2(R-S,P-T);dh(r,T+e,S+t,n,A,C,h*c>u*l)}const Ss=Math.PI*2,oi={centerX:0,centerY:0,ang1:0,ang2:0},ai=({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 um(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 aa=(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)},dm=(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,P=(-c-x)/i,R=(-u-y)/n,A=aa(1,0,v,w);let C=aa(v,w,P,R);a===0&&C>0&&(C-=Ss),a===1&&C<0&&(C+=Ss),d.centerX=T,d.centerY=S,d.ang1=A,d.ang2=C};function fm(r,e,t,s,i,n,o,a=0,l=0,h=0){if(n===0||o===0)return;const c=Math.sin(a*Ss/360),u=Math.cos(a*Ss/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)),dm(e,t,s,i,n,o,l,h,c,u,d,f,oi);let{ang1:g,ang2:m}=oi;const{centerX:_,centerY:x}=oi;let y=Math.abs(m)/(Ss/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 P=0;P<T;P++){const R=um(g,m),{x:A,y:C}=ai(R[0],n,o,u,c,_,x,w),{x:E,y:k}=ai(R[1],n,o,u,c,_,x,w),{x:O,y:he}=ai(R[2],n,o,u,c,_,x,w);uh(r,S,v,A,C,E,k,O,he),S=O,v=he,g+=m}}function pm(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 mm(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 gm=new ee;class _m{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 dh(a,e,t,s,i,n,o),this}arcTo(e,t,s,i,n){this._ensurePoly();const o=this._currentPoly.points;return cm(o,e,t,s,i,n),this}arcToSvg(e,t,s,i,n,o,a){const l=this._currentPoly.points;return fm(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 uh(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 lm(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 ee(e,t,s,i),n),this}circle(e,t,s,i){return this.drawShape(new en(e,t,s),i),this}poly(e,t,s){const i=new vs(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?mm(this,e,t,i):pm(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 tn(e,t,s,i),n),this}roundRect(e,t,s,i,n,o){return this.drawShape(new sn(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 vs,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 vs,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(gm);i.transform?e.addRect(n,i.transform):e.addRect(n)}return e}}class nt{constructor(e,t=!1){this.instructions=[],this.uid=ne("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?tp(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new _m(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(J.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(J.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 nt;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]=Lt(x[3],e);break;case"rect":x[4]=Lt(x[4],e);break;case"ellipse":x[8]=Lt(x[8],e);break;case"roundRect":x[5]=Lt(x[5],e);break;case"addPath":x[0].transform(e);break;case"poly":x[2]=Lt(x[2],e);break;case"regularPoly":case"chamferRect":x[5]=Lt(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 Lt(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 xm(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]=ym(o);break;case"radialgradient":e.defs[o.id]=bm();break}}}}function ym(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 qe(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=se.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(h,c)}return o}function bm(r){return W("[SVG Parser] Radial gradients are not yet supported"),new qe(0,0,1,0)}function la(r){const e=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const ha={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 fh(r,e){const t=r.getAttribute("style"),s={},i={},n={strokeStyle:s,fillStyle:i,useFill:!1,useStroke:!1};for(const o in ha){const a=r.getAttribute(o);a&&ca(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(":");ha[h]&&ca(e,n,h,c.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function ca(r,e,t,s){switch(t){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const i=la(s);e.strokeStyle.fill=r.defs[i]}else e.strokeStyle.color=se.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=la(s);e.fillStyle.fill=r.defs[i]}else e.fillStyle.color=se.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 vm(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 Tm(r){return r.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function Sm(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 ua(r,e){const t=new nt(r,!1);for(const s of t.instructions)e.instructions.push(s)}function wm(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 nt};xm(r,t);const s=r.children,{fillStyle:i,strokeStyle:n}=fh(r,t);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&ph(a,t,i,n)}return e}function ph(r,e,t,s){const i=r.children,{fillStyle:n,strokeStyle:o}=fh(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,P;switch(r.nodeName.toLowerCase()){case"path":{S=r.getAttribute("d");const R=r.getAttribute("fill-rule"),A=Tm(S),C=R==="evenodd",E=A.length>1;if(C&&E){const O=A.map(M=>({path:M,area:Sm(M)}));if(O.sort((M,I)=>I.area-M.area),A.length>3||!vm(O))for(let M=0;M<O.length;M++){const I=O[M],L=M===0;e.context.beginPath();const B=new nt(void 0,!0);ua(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<O.length;M++){const I=O[M],L=M%2===1;e.context.beginPath();const B=new nt(void 0,!0);ua(I.path,B),e.context.path(B),L?e.context.cut():(t&&e.context.fill(t),s&&e.context.stroke(s))}}else{const O=R?R==="evenodd":!0;v=new nt(S,O),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),P=ce(r,"height",0),_=ce(r,"rx",0),x=ce(r,"ry",0),_||x?e.context.roundRect(l,h,w,P,_||x):e.context.rect(l,h,w,P),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++)ph(i[R],e,t,s)}const da={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 Us{constructor(e,t){this.uid=ne("fillPattern"),this._tick=0,this.transform=new F,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=da[t].addressModeU,e.source.style.addressModeV=da[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 Cm(r){return se.isColorLike(r)}function fa(r){return r instanceof Us}function pa(r){return r instanceof qe}function Am(r){return r instanceof U}function Pm(r,e,t){const s=se.shared.setValue(e??0);return r.color=s.toNumber(),r.alpha=s.alpha===1?t.alpha:s.alpha,r.texture=U.WHITE,{...t,...r}}function Em(r,e,t){return r.texture=e,{...t,...r}}function ma(r,e,t){return r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,{...t,...r}}function ga(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 Mm(r,e){const t={...e,...r},s=se.shared.setValue(t.color);return t.alpha*=s.alpha,t.color=s.toNumber(),t}function Ct(r,e){if(r==null)return null;const t={},s=r;return Cm(r)?Pm(t,r,e):Am(r)?Em(t,r,e):fa(r)?ma(t,r,e):pa(r)?ga(t,r,e):s.fill&&fa(s.fill)?ma(s,s.fill,e):s.fill&&pa(s.fill)?ga(s,s.fill,e):Mm(s,e)}function xr(r,e){const{width:t,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...l}=e,h=Ct(r,l);return h?{width:t,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...h}:null}function Rm(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 A=(x*T+y*S)/Math.sqrt(v*w);A<-1?A=-1:A>1&&(A=1);const C=Math.sqrt((1-A)*.5);if(C<1e-6)continue;const E=Math.min(1/C,e);E>t&&(t=E)}}return t}const Bm=new J,_a=new F,un=class je extends Be{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ne("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new nt,this._transform=new F,this._fillStyle={...je.defaultFillStyle},this._strokeStyle={...je.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new ye,this._boundsDirty=!0}clone(){const e=new je;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=Ct(e,je.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=xr(e,je.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Ct(e,je.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Ct(e,je.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?se.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new nt,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"&&(G(Y,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Ct(e,je.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(J.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=xr(e,je.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++,wm(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 F?(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 F?(this._transform.append(e),this):(_a.set(e,t,s,i,n,o),this._transform.append(_a),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*=Rm(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,Bm):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}};un.defaultFillStyle={color:16777215,alpha:1,texture:U.WHITE,matrix:null,fill:null,textureSpace:"local"};un.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:U.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ge=un;function dn(r,e=1){var s;const t=(s=rs.RETINA_PREFIX)==null?void 0:s.exec(r);return t?parseFloat(t[1]):e}function fn(r,e,t){r.label=t,r._sourceOrigin=t;const s=new U({source:r,label:t}),i=()=>{delete e.promiseCache[t],re.has(t)&&re.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 km=".svg",Im="image/svg+xml",Fm={extension:{type:b.LoadParser,priority:ft.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return is(r,Im)||ns(r,km)},async load(r,e,t){var s;return((s=e.data)==null?void 0:s.parseAsGraphicsContext)??this.config.parseAsGraphicsContext?Um(r):Gm(r,e,t,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function Gm(r,e,t,s){var m,_,x;const i=await V.get().fetch(r),n=V.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)||dn(r),h=Math.ceil(o*l),c=Math.ceil(a*l),u=V.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 Mt({resource:u,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return fn(g,t,r)}async function Um(r){const t=await(await V.get().fetch(r)).text(),s=new Ge;return s.svg(t),s}const Om=`(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 Yt=null,Li=class{constructor(){Yt||(Yt=URL.createObjectURL(new Blob([Om],{type:"application/javascript"}))),this.worker=new Worker(Yt)}};Li.revokeObjectURL=function(){Yt&&(URL.revokeObjectURL(Yt),Yt=null)};const Dm=`(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 qt=null;class mh{constructor(){qt||(qt=URL.createObjectURL(new Blob([Dm],{type:"application/javascript"}))),this.worker=new Worker(qt)}}mh.revokeObjectURL=function(){qt&&(URL.revokeObjectURL(qt),qt=null)};let xa=0,li;class Lm{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 Li;t.addEventListener("message",s=>{t.terminate(),Li.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(){li===void 0&&(li=navigator.hardwareConcurrency||4);let e=this._workerPool.pop();return!e&&this._createdWorkers<li&&(this._createdWorkers++,e=new mh().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[xa]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:xa++,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 ya=new Lm,Nm=[".jpeg",".jpg",".png",".webp",".avif"],Wm=["image/jpeg","image/png","image/webp","image/avif"];async function Hm(r,e){var i;const t=await V.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 gh={name:"loadTextures",id:"texture",extension:{type:b.LoadParser,priority:ft.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return is(r,Wm)||ns(r,Nm)},async load(r,e,t){var n;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ya.isImageBitmapSupported()?s=await ya.loadImageBitmap(r,e):s=await Hm(r,e):s=await new Promise((o,a)=>{s=V.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):(s.onload=()=>{o(s)},s.onerror=a)});const i=new Mt({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((n=e.data)==null?void 0:n.resolution)||dn(r),...e.data});return fn(i,t,r)},unload(r){r.destroy(!0)}},zm=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let hi,ci;function Vm(r,e,t){t===void 0&&!e.startsWith("data:")?r.crossOrigin=$m(e):t!==!1&&(r.crossOrigin=typeof t=="string"?t:"anonymous")}function Xm(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 $m(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 jm(){const r=[],e=[];for(const t of zm){const s=bs.MIME_TYPES[t.substring(1)]||`video/${t.substring(1)}`;wr(s)&&(r.push(t),e.includes(s)||e.push(s))}return{validVideoExtensions:r,validVideoMime:e}}const Ym={name:"loadVideo",id:"video",extension:{type:b.LoadParser,name:"loadVideo"},test(r){if(!hi||!ci){const{validVideoExtensions:s,validVideoMime:i}=jm();hi=s,ci=i}const e=is(r,ci),t=ns(r,hi);return e||t},async load(r,e,t){var l,h;const s={...bs.defaultOptions,resolution:((l=e.data)==null?void 0:l.resolution)||dn(r),alphaMode:((h=e.data)==null?void 0:h.alphaMode)||await _l(),...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),Vm(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=bs.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 bs({...s,resource:i});p(),e.data.preload&&await Xm(i),c(fn(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)}},_h={extension:{type:b.ResolveParser,name:"resolveTexture"},test:gh.test,parse:r=>{var e;return{resolution:parseFloat(((e=rs.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:r.split(".").pop(),src:r}}},qm={extension:{type:b.ResolveParser,priority:-2,name:"resolveJson"},test:r=>rs.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:_h.parse};class Km{constructor(){this._detections=[],this._initialized=!1,this.resolver=new rs,this.loader=new Of,this.cache=re,this._backgroundLoader=new Ef(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=mr(e),i=We(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 re.get(e);const t={};for(let s=0;s<e.length;s++)t[s]=re.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}),re.set(l,a)}),n}async unload(e){this._initialized||await this.init();const t=We(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=We(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=>{re.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 Km;H.handleByList(b.LoadParser,Qs.loader.parsers).handleByList(b.ResolveParser,Qs.resolver.parsers).handleByList(b.CacheParser,Qs.cache.parsers).handleByList(b.DetectionParser,Qs.detections);H.add(Mf,Bf,Rf,Uf,If,Ff,Gf,Nf,zf,Zf,Fm,gh,Ym,Pf,Af,_h,qm);const ba={loader:b.LoadParser,resolver:b.ResolveParser,cache:b.CacheParser,detection:b.DetectionParser};H.handle(b.Asset,r=>{const e=r.ref;Object.entries(ba).filter(([t])=>!!e[t]).forEach(([t,s])=>H.add(Object.assign(e[t],{extension:e[t].extension??s})))},r=>{const e=r.ref;Object.keys(ba).filter(t=>!!e[t]).forEach(t=>H.remove(e[t]))});class xh{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 Sl({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}}xh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"dom"};class Zm{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||(Oe.system.add(this._tickerUpdate,this,Jt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Oe.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 st=new Zm;class yr extends Is{constructor(){super(...arguments),this.client=new J,this.movement=new J,this.offset=new J,this.global=new J,this.screen=new J}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 Ne extends yr{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 ts extends yr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}ts.DOM_DELTA_PIXEL=0;ts.DOM_DELTA_LINE=1;ts.DOM_DELTA_PAGE=2;const Qm=2048,Jm=new J,ps=new J;class eg{constructor(e){this.dispatch=new Be,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){st.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,Jm.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<Qm&&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")&&(st.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")&&(st.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,ps),!e.hitArea.contains(ps.x,ps.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,ps),e.containsPoint(ps)):!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 Ne)){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 Ne)){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 Ne)){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 Ne)){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 Ne)){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 Ne)){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 ts)){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(Ne);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(ts);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(Ne);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 Ne&&t instanceof Ne&&(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 yr&&t instanceof yr&&(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 tg=1,sg={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},pn=class Ni{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new eg(null),st.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Ne(null),this._rootWheelEvent=new ts(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ni.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,Ni._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){st.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,st.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,st.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;st.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;st.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=tg),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=sg[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}};pn.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1};pn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let yh=pn;const rg={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??yh.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 Is))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 Nt;function va(r){const e=V.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=r,t.fillRect(0,0,6,1),e}function bh(){if(Nt!==void 0)return Nt;try{const r=va("#ff00ff"),e=va("#ffff00"),s=V.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)Nt=!1;else{const n=i.data;Nt=n[0]===255&&n[1]===0&&n[2]===0}}catch{Nt=!1}return Nt}const $={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:bh(),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=$._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=$._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=V.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),$._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(s){const a=V.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),$._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=$._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=V.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,h.drawImage(t,0,0),$._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return t},getTintedCanvas:(r,e)=>{const t=r.texture,s=se.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:V.get().createCanvas();return $.tintMethod(t,e,a),a.tintId=o,i[s]=a,i[s]},getTintedPattern:(r,e)=>{const t=se.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||($.canvas||($.canvas=V.get().createCanvas()),$.tintMethod(r,e,$.canvas),n=$.canvas.getContext("2d").createPattern($.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=j.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=se.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="multiply";const c=$.getCanvasSource(r);if(!c){s.restore();return}o&&$._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=j.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=se.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="destination-atop";const c=$.getCanvasSource(r);if(!c){s.restore();return}o&&$._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=j.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=$.getCanvasSource(r);if(!c){s.restore();return}o&&$._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=j.inv(e),n=j.uX(i),o=j.uY(i),a=j.vX(i),l=j.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)}};$.tintMethod=$.canUseMultiply?$.tintWithMultiply:$.tintWithPerPixel;class ig{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const s=V.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=Kt(e),t=Kt(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 dt=new ig;ss.register(dt);const Ta=new F;function vh(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=Ta.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n!=null&&n._parentCacheAsTextureRenderGroup?e.matrix=Ta.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):e.matrix=i.worldTransform,e.addBounds(i.bounds)}return e.matrix=t,e}const ng=new ye;function Th(r,e,t,s,i=!1){const n=ng;n.minX=0,n.minY=0,n.maxX=r.width/s|0,n.maxY=r.height/s|0;const o=de.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 Sa(r){return typeof r.getCanvasFilterString=="function"}class og{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new ye,this.cssFilterString=""}}class Sh{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(!Sa(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(!Sa(_)){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=$.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=dt.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,Th(u,l,h,a)}_calculateFilterArea(e,t){if(e.renderables?vh(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 og),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}}Sh.extension={type:[b.CanvasSystem],name:"filter"};var wh=`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 Ch={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]},ag=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(`
|
|
329
|
+
`);function lg(r){const e=Ch[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 ag.replace("%blur%",`${s};`).replace("%size%",r.toString())}const hg=`
|
|
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 cg(r,e){const t=Math.ceil(r/2);let s=hg,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 ug(r,e){const t=cg(e,r),s=lg(e);return pt.from({vertex:t,fragment:s,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var dg=`
|
|
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 fg(r,e){const t=Ch[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=dg.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",h).replace("%dimension%",r?"z":"w");return at.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}const Ah=class Ph extends Fs{constructor(e){e={...Ph.defaultOptions,...e};const t=ug(e.horizontal,e.kernelSize),s=fg(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=de.getSameSizeTexture(t);let o=t,a=n;this._state.blend=!1;const l=e.renderer.type===Se.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),de.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=de.getSameSizeTexture(t);let o=t,a=n;this._state.blend=!1;const l=e.renderer,h=l.type===Se.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),de.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}};Ah.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};let ui=Ah;class pg extends Fs{constructor(...e){let t=e[0]??{};typeof t=="number"&&(G(Y,"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={...ui.defaultOptions,...t};const{strength:s,strengthX:i,strengthY:n,quality:o,...a}=t;super({...a,compatibleRenderers:Se.BOTH,resources:{}}),this._repeatEdgePixels=!1,this.blurXFilter=new ui({horizontal:!0,...t}),this.blurYFilter=new ui({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=de.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),de.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 G("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength}set blur(e){G("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength=e}get blurX(){return G("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX}set blurX(e){G("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX=e}get blurY(){return G("8.3.0","BlurFilter.blurY is deprecated, please use BlurFilter.strengthY instead."),this.strengthY}set blurY(e){G("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()}}pg.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var mg=`
|
|
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
|
+
`,wa=`
|
|
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 Eh=class Mh extends Fs{constructor(e={}){e={...Mh.defaultOptions,...e};const t=at.from({vertex:{source:wa,entryPoint:"mainVertex"},fragment:{source:wa,entryPoint:"mainFragment"}}),s=pt.from({vertex:wh,fragment:mg,name:"noise-filter"}),{noise:i,seed:n,...o}=e;super({...o,gpuProgram:t,glProgram:s,resources:{noiseUniforms:new Re({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}};Eh.defaultOptions={noise:.5};let Uy=Eh;var gg=`in vec2 vTextureCoord;
|
|
583
|
+
out vec4 finalColor;
|
|
584
|
+
uniform sampler2D uTexture;
|
|
585
|
+
void main() {
|
|
586
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
587
|
+
}
|
|
588
|
+
`,Ca=`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 _g extends Fs{constructor(){const e=at.from({vertex:{source:Ca,entryPoint:"mainVertex"},fragment:{source:Ca,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=pt.from({vertex:wh,fragment:gg,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class Rh{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}}Rh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const xg=new Cr({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 yg{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 Bh{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Re({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 ut({}),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=de.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=U.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&&de.returnTexture(t.backTexture),de.returnTexture(t.inputTexture))}getBackTexture(e,t,s){const i=e.colorTexture.source._resolution,n=de.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(F.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 _g),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:xg,shader:e,state:e._state,topology:"triangle-list"}),s.type===Se.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,s,i){if(e.backTexture=U.EMPTY,e.inputTexture=de.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 U&&(t.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!l),t instanceof U?(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?vh(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=de.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),de.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 yg),this._filterStackIndex++,e}}Bh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};var bg=`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
|
+
`,vg=`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
|
+
`,Aa=`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 Tg extends Fs{constructor(e){const{sprite:t,...s}=e,i=new tl(t.texture),n=new Re({uFilterMatrix:{value:new F,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=at.from({vertex:{source:Aa,entryPoint:"mainVertex"},fragment:{source:Aa,entryPoint:"mainFragment"}}),a=pt.from({vertex:vg,fragment:bg,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 Sg{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class wg{constructor(){this.instructions=new Zi}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const mn=class Wi{constructor(e){this._renderer=e,this._managedContexts=new ze({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Wi.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Wi.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 wg,s=this.getGpuContext(e);return s.graphicsData=t,t.init(),t}_initContext(e){const t=new Sg;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};mn.extension={type:[b.CanvasSystem],name:"graphicsContext"};mn.defaultOptions={bezierSmoothness:.5};let Cg=mn;class kh{constructor(e,t){this.state=Ze.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ze({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}}kh.extension={type:[b.CanvasPipes],name:"graphics"};function gn(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 Ag{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{xe.return(e)}),this.batches.length=0}}class Ih{constructor(e,t){this.state=Ze.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ze({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,gn(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 Ag;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=xe.get(on);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}}Ih.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"graphics"};H.add(kh);H.add(Ih);H.add(Cg);H.add(cn);class br extends Tr{constructor(e){e instanceof Ge&&(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 Ge,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 br(this._context.clone()):(this._ownedContext=null,new br(this._context))}lineStyle(e,t,s){G(Y,"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){G(Y,"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(){G(Y,"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!==Ge.defaultStrokeStyle.width||e.color!==Ge.defaultStrokeStyle.color||e.alpha!==Ge.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return G(Y,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return G(Y,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return G(Y,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return G(Y,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return G(Y,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return G(Y,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}const Fh=class Gh extends Cr{constructor(...e){let t=e[0]??{};t instanceof Float32Array&&(G(Y,"use new MeshGeometry({ positions, uvs, indices }) instead"),t={positions:t,uvs:e[1],indices:e[2]}),t={...Gh.defaultOptions,...t};const s=t.positions||new Float32Array([0,0,1,0,1,1,0,1]);let i=t.uvs;i||(t.positions?i=new Float32Array(s.length):i=new Float32Array([0,0,1,0,1,1,0,1]));const n=t.indices||new Uint32Array([0,1,2,0,2,3]),o=t.shrinkBuffersToFit,a=new He({data:s,label:"attribute-mesh-positions",shrinkToFit:o,usage:Q.VERTEX|Q.COPY_DST}),l=new He({data:i,label:"attribute-mesh-uvs",shrinkToFit:o,usage:Q.VERTEX|Q.COPY_DST}),h=new He({data:n,label:"index-mesh-buffer",shrinkToFit:o,usage:Q.INDEX|Q.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:8,offset:0},aUV:{buffer:l,format:"float32x2",stride:8,offset:0}},indexBuffer:h,topology:t.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};Fh.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Uh=Fh;class Pg{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(e){this._topology=e}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(e){this.texture!==e&&(this.texture=e,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),s=t.data;let i=s;const n=this.texture.textureMatrix;return n.isSimple||(i=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!i||i.length<s.length)&&(i=this._transformedUvs=new Float32Array(s.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.multiplyUvs(s,i))),i}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class Eg{constructor({matrix:e,observer:t}={}){this.dirty=!0,this._matrix=e??new F,this.observer=t,this.position=new ue(this,0,0),this.scale=new ue(this,1,1),this.pivot=new ue(this,0,0),this.skew=new ue(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const e=this._matrix;return this.dirty&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this.dirty=!1),e}_onUpdate(e){var t;this.dirty=!0,e===this.skew&&this.updateSkew(),(t=this.observer)==null||t._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}toString(){return`[pixi.js/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`}setFromMatrix(e){e.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this.skew))}}const Js=new F,et=new F,Xe=[new J,new J,new J,new J];class Oh{constructor(e){this._renderer=e}validateRenderable(e){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){var R,A;const t=this._renderer,s=t.canvasContext,i=s.activeContext;i.save(),s.setBlendMode(e.groupBlendMode);const n=((R=t.globalUniforms.globalUniformData)==null?void 0:R.worldColor)??4294967295,o=e.groupColorAlpha,a=(n>>>24&255)/255,l=(o>>>24&255)/255,h=((A=t.filter)==null?void 0:A.alphaMultiplier)??1,c=a*l*h;if(c<=0){i.restore();return}i.globalAlpha=c;const u=n&16777215,d=o&16777215,f=Et(Pt(d,u)),p=e.texture,g=$.getTintedPattern(p,f),m=e.width,_=e.height,x=e.groupTransform,y=p.source._resolution??p.source.resolution??1;et.copyFrom(e._tileTransform.matrix),e.applyAnchorToTexture||et.translate(-e.anchor.x*m,-e.anchor.y*_);const T=et.tx,S=et.ty;et.scale(1/y,1/y),et.tx=T,et.ty=S,Js.identity(),Js.prepend(et),Js.prepend(x);const v=t._roundPixels|e._roundPixels;s.setContextTransform(Js,v===1),i.fillStyle=g;const w=e.anchor.x*-m,P=e.anchor.y*-_;Xe[0].set(w,P),Xe[1].set(w+m,P),Xe[2].set(w+m,P+_),Xe[3].set(w,P+_);for(let C=0;C<4;C++)et.applyInverse(Xe[C],Xe[C]);i.beginPath(),i.moveTo(Xe[0].x,Xe[0].y);for(let C=1;C<4;C++)i.lineTo(Xe[C].x,Xe[C].y);i.closePath(),i.fill(),i.restore()}destroy(){this._renderer=null}}Oh.extension={type:[b.CanvasPipes],name:"tilingSprite"};const ws={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
|
+
`}},Mg={...ws,vertex:{...ws.vertex,header:ws.vertex.header.replace("group(1)","group(2)")}},_n={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
|
+
`}},Rg={name:"tiling-bit",vertex:{header:`
|
|
849
|
+
struct TilingUniforms {
|
|
850
|
+
uMapCoord:mat3x3<f32>,
|
|
851
|
+
uClampFrame:vec4<f32>,
|
|
852
|
+
uClampOffset:vec2<f32>,
|
|
853
|
+
uTextureTransform:mat3x3<f32>,
|
|
854
|
+
uSizeAnchor:vec4<f32>
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
858
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
859
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
860
|
+
`,main:`
|
|
861
|
+
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
862
|
+
|
|
863
|
+
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
864
|
+
`},fragment:{header:`
|
|
865
|
+
struct TilingUniforms {
|
|
866
|
+
uMapCoord:mat3x3<f32>,
|
|
867
|
+
uClampFrame:vec4<f32>,
|
|
868
|
+
uClampOffset:vec2<f32>,
|
|
869
|
+
uTextureTransform:mat3x3<f32>,
|
|
870
|
+
uSizeAnchor:vec4<f32>
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
874
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
875
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
876
|
+
`,main:`
|
|
877
|
+
|
|
878
|
+
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
879
|
+
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
880
|
+
var unclamped = coord;
|
|
881
|
+
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
882
|
+
|
|
883
|
+
var bias = 0.;
|
|
884
|
+
|
|
885
|
+
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
886
|
+
{
|
|
887
|
+
bias = -32.;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
891
|
+
`}},Bg={name:"tiling-bit",vertex:{header:`
|
|
892
|
+
uniform mat3 uTextureTransform;
|
|
893
|
+
uniform vec4 uSizeAnchor;
|
|
894
|
+
|
|
895
|
+
`,main:`
|
|
896
|
+
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
|
897
|
+
|
|
898
|
+
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
|
899
|
+
`},fragment:{header:`
|
|
900
|
+
uniform sampler2D uTexture;
|
|
901
|
+
uniform mat3 uMapCoord;
|
|
902
|
+
uniform vec4 uClampFrame;
|
|
903
|
+
uniform vec2 uClampOffset;
|
|
904
|
+
`,main:`
|
|
905
|
+
|
|
906
|
+
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
|
907
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
908
|
+
vec2 unclamped = coord;
|
|
909
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
910
|
+
|
|
911
|
+
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
912
|
+
|
|
913
|
+
`}};let di,fi;class kg extends Ke{constructor(){di??(di=Ar({name:"tiling-sprite-shader",bits:[ws,Rg,Er]})),fi??(fi=Pr({name:"tiling-sprite-shader",bits:[_n,Bg,Mr]}));const e=new Re({uMapCoord:{value:new F,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new F,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:fi,gpuProgram:di,resources:{localUniforms:new Re({uTransformMatrix:{value:new F,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:e,uTexture:U.EMPTY.source,uSampler:U.EMPTY.source.style}})}updateUniforms(e,t,s,i,n,o){const a=this.resources.tilingUniforms,l=o.width,h=o.height,c=o.textureMatrix,u=a.uniforms.uTextureTransform;u.set(s.a*l/e,s.b*l/t,s.c*h/e,s.d*h/t,s.tx/e,s.ty/t),u.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=u,a.uniforms.uSizeAnchor[0]=e,a.uniforms.uSizeAnchor[1]=t,a.uniforms.uSizeAnchor[2]=i,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class Ig extends Uh{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function Fg(r,e){const t=r.anchor.x,s=r.anchor.y;e[0]=-t*r.width,e[1]=-s*r.height,e[2]=(1-t)*r.width,e[3]=-s*r.height,e[4]=(1-t)*r.width,e[5]=(1-s)*r.height,e[6]=-t*r.width,e[7]=(1-s)*r.height}function Gg(r,e,t,s){let i=0;const n=r.length/e,o=s.a,a=s.b,l=s.c,h=s.d,c=s.tx,u=s.ty;for(t*=e;i<n;){const d=r[t],f=r[t+1];r[t]=o*d+l*f+c,r[t+1]=a*d+h*f+u,t+=e,i++}}function Ug(r,e){const t=r.texture,s=t.frame.width,i=t.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),e[0]=e[6]=-n,e[2]=e[4]=1-n,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=F.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/s,r.height/i),Gg(e,2,0,a)}const or=new Ig;class Og{constructor(){this.canBatch=!0,this.geometry=new Uh({indices:or.indices.slice(),positions:or.positions.slice(),uvs:or.uvs.slice()})}destroy(){var e;this.geometry.destroy(),(e=this.shader)==null||e.destroy()}}class Dh{constructor(e){this._state=Ze.default2d,this._renderer=e,this._managedTilingSprites=new ze({renderer:e,type:"renderable",name:"tilingSprite"})}validateRenderable(e){const t=this._getTilingSpriteData(e),s=t.canBatch;this._updateCanBatch(e);const i=t.canBatch;if(i&&i===s){const{batchableMesh:n}=t;return!n._batcher.checkAndUpdateTexture(n,e.texture)}return s!==i}addRenderable(e,t){const s=this._renderer.renderPipes.batch;this._updateCanBatch(e);const i=this._getTilingSpriteData(e),{geometry:n,canBatch:o}=i;if(o){i.batchableMesh||(i.batchableMesh=new Pg);const a=i.batchableMesh;e.didViewUpdate&&(this._updateBatchableMesh(e),a.geometry=n,a.renderable=e,a.transform=e.groupTransform,a.setTexture(e._texture)),a.roundPixels=this._renderer._roundPixels|e._roundPixels,s.addToBatch(a,t)}else s.break(t),i.shader||(i.shader=new kg),this.updateRenderable(e),t.add(e)}execute(e){const t=this._renderer,{shader:s}=this._getTilingSpriteData(e);s.groups[0]=t.globalUniforms.bindGroup;const i=s.resources.localUniforms.uniforms;i.uTransformMatrix=e.groupTransform,i.uRound=t._roundPixels|e._roundPixels,gn(e.groupColorAlpha,i.uColor,0),this._state.blendMode=Fi(e.groupBlendMode,e.texture._source),t.encoder.draw({geometry:or,shader:s,state:this._state})}updateRenderable(e){const t=this._getTilingSpriteData(e),{canBatch:s}=t;if(s){const{batchableMesh:i}=t;e.didViewUpdate&&this._updateBatchableMesh(e),i._batcher.updateElement(i)}else if(e.didViewUpdate){const{shader:i}=t;i.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}}_getTilingSpriteData(e){return e._gpuData[this._renderer.uid]||this._initTilingSpriteData(e)}_initTilingSpriteData(e){const t=new Og;return t.renderable=e,e._gpuData[this._renderer.uid]=t,this._managedTilingSprites.add(e),t}_updateBatchableMesh(e){const t=this._getTilingSpriteData(e),{geometry:s}=t,i=e.texture.source.style;i.addressMode!=="repeat"&&(i.addressMode="repeat",i.update()),Ug(e,s.uvs),Fg(e,s.positions)}destroy(){this._managedTilingSprites.destroy(),this._renderer=null}_updateCanBatch(e){const t=this._getTilingSpriteData(e),s=e.texture;let i=!0;return this._renderer.type===Se.WEBGL&&(i=this._renderer.context.supports.nonPowOf2wrapping),t.canBatch=s.textureMatrix.isSimple&&(i||s.source.isPowerOfTwo),t.canBatch}}Dh.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"tilingSprite"};H.add(Oh);H.add(Dh);const Lh=class ar extends Tr{constructor(...e){let t=e[0]||{};t instanceof U&&(t={texture:t}),e.length>1&&(G(Y,"use new TilingSprite({ texture, width:100, height:100 }) instead"),t.width=e[1],t.height=e[2]),t={...ar.defaultOptions,...t};const{texture:s,anchor:i,tilePosition:n,tileScale:o,tileRotation:a,width:l,height:h,applyAnchorToTexture:c,roundPixels:u,...d}=t??{};super({label:"TilingSprite",...d}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new ue({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=s,this._width=l??s.width,this._height=h??s.height,this._tileTransform=new Eg({observer:{_onUpdate:()=>this.onViewUpdate()}}),i&&(this.anchor=i),this.tilePosition=n,this.tileScale=o,this.tileRotation=a,this.roundPixels=u??!1}static from(e,t={}){return typeof e=="string"?new ar({texture:re.get(e),...t}):new ar({texture:e,...t})}get uvRespectAnchor(){return G(Y,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(e){G(Y,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=e}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(e){this._texture.textureMatrix.clampMargin=e}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get tilePosition(){return this._tileTransform.position}set tilePosition(e){this._tileTransform.position.copyFrom(e)}get tileScale(){return this._tileTransform.scale}set tileScale(e){typeof e=="number"?this._tileTransform.scale.set(e):this._tileTransform.scale.copyFrom(e)}set tileRotation(e){this._tileTransform.rotation=e}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(e){e||(e=U.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.onViewUpdate())}get texture(){return this._texture}set width(e){this._width=e,this.onViewUpdate()}get width(){return this._width}set height(e){this._height=e,this.onViewUpdate()}get height(){return this._height}setSize(e,t){typeof e=="object"&&(t=e.height??e.width,e=e.width),this._width=e,this._height=t??e,this.onViewUpdate()}getSize(e){return e||(e={}),e.width=this._width,e.height=this._height,e}updateBounds(){const e=this._bounds,t=this._anchor,s=this._width,i=this._height;e.minX=-t._x*s,e.maxX=e.minX+s,e.minY=-t._y*i,e.maxY=e.minY+i}containsPoint(e){const t=this._width,s=this._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)}destroy(e=!1){if(super.destroy(e),this._anchor=null,this._tileTransform=null,this._bounds=null,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}};Lh.defaultOptions={texture:U.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Oy=Lh;class Dg extends Tr{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 ue({_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 Lg(r,e){let t=r[0]??{};return(typeof t=="string"||r[1])&&(G(Y,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:r[1]}),t}let _t=null,rt=null;function Ng(r,e){_t||(_t=V.get().createCanvas(256,128),rt=_t.getContext("2d",{willReadFrequently:!0}),rt.globalCompositeOperation="copy",rt.globalAlpha=1),(_t.width<r||_t.height<e)&&(_t.width=Kt(r),_t.height=Kt(e))}function Pa(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 Ea(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 Wg(...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(Ng(i,n),!rt)throw new TypeError("Failed to get canvas 2D context");rt.drawImage(t,0,0,i,n,0,0,i*s,n*s);const l=rt.getImageData(0,0,i,n).data;let h=0,c=0,u=i-1,d=n-1;for(;c<n&&Pa(l,i,c);)++c;if(c===n)return ee.EMPTY;for(;Pa(l,i,d);)--d;for(;Ea(l,i,h,c,d);)++h;for(;Ea(l,i,u,c,d);)--u;return++u,++d,rt.globalCompositeOperation="source-over",rt.strokeRect(h,c,u-h,d-c),rt.globalCompositeOperation="copy",o??(o=new ee),o.set(h/s,c/s,(u-h)/s,(d-c)/s),o}/**
|
|
914
|
+
* tiny-lru
|
|
915
|
+
*
|
|
916
|
+
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
917
|
+
* @license BSD-3-Clause
|
|
918
|
+
* @version 11.4.7
|
|
919
|
+
*/class Hg{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 Nh(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 Hg(r,e,t)}function Wh(r){return!!r.tagStyles&&Object.keys(r.tagStyles).length>0}function Hh(r){return r.includes("<")}function zg(r,e){return r.clone().assign(e)}function Vg(r,e){const t=[],s=e.tagStyles;if(!Wh(e)||!Hh(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=zg(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 Xg=[10,13],$g=new Set(Xg),jg=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Yg=new Set(jg),qg=[9,32],Kg=new Set(qg),Zg=[45,8208,8211,8212,173],Qg=new Set(Zg),Jg=/(\r\n|\r|\n)/,e_=/(?:\r\n|\r|\n)/;function vr(r){return typeof r!="string"?!1:$g.has(r.charCodeAt(0))}function Ee(r,e){return typeof r!="string"?!1:Yg.has(r.charCodeAt(0))}function Ma(r){return typeof r!="string"?!1:Kg.has(r.charCodeAt(0))}function zh(r){return typeof r!="string"?!1:Qg.has(r.charCodeAt(0))}function xn(r){return r==="normal"||r==="pre-line"}function yn(r){return r==="normal"}function tt(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 Vh(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)||vr(i)){t.length>0&&(e.push(t.join("")),t.length=0),i==="\r"&&n===`
|
|
920
|
+
`?(e.push(`\r
|
|
921
|
+
`),s++):e.push(i);continue}t.push(i),zh(i)&&n&&!Ee(n)&&!vr(n)&&(e.push(t.join("")),t.length=0)}return t.length>0&&e.push(t.join("")),e}function Xh(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 t_=/\r\n|\r|\n/g;function s_(r,e,t,s,i,n,o,a,l){var O,he;const h=Vg(r,e);if(yn(e.whiteSpace))for(let M=0;M<h.length;M++){const I=h[M];h[M]={text:I.text.replace(t_," "),style:I.style}}const u=[];let d=[];for(const M of h){const I=M.text.split(Jg);for(let L=0;L<I.length;L++){const B=I[L];B===`\r
|
|
922
|
+
`||B==="\r"||B===`
|
|
923
|
+
`?(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?r_(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,P=((O=e._stroke)==null?void 0:O.width)||0;for(const M of f){let I=0,L=S.ascent,B=S.descent,N="";for(const D of M){const K=D.style._fontString,oe=o(K);K!==v&&(s.font=K,v=K);const ae=i(D.text,D.style.letterSpacing,s);I+=ae,L=Math.max(L,oe.ascent),B=Math.max(B,oe.descent),N+=D.text;const te=((he=D.style._stroke)==null?void 0:he.width)||0;te>P&&(P=te),!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 q=e.lineHeight||L+B;_.push(q+e.leading),y=Math.max(y,I)}const R=P,A=y+R+(e.dropShadow?e.dropShadow.distance:0);let C=0;for(let M=0;M<_.length;M++)C+=_[M];C=Math.max(C,_[0]+R);const E=C+(e.dropShadow?e.dropShadow.distance:0),k=e.lineHeight||S.fontSize;return{width:A,height:E,lines:x,lineWidths:p,lineHeight:k+e.leading,maxLineWidth:y,fontProperties:S,runsByLine:f,lineAscents:g,lineDescents:m,lineHeights:_,hasDropShadow:w}}function r_(r,e,t,s,i,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:h}=e,c=xn(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=i_(_),y=g.length,T=E=>{let k=0,O=E;do{const{token:he,style:M}=x[O];k+=p(he,M),O++}while(O<x.length&&x[O].continuesFromPrevious);return k},S=E=>{const k=[];let O=E;do k.push({token:x[O].token,style:x[O].style}),O++;while(O<x.length&&x[O].continuesFromPrevious);return k};let v=[],w=0,P=!c,R=null;const A=()=>{R&&R.text.length>0&&v.push(R),R=null},C=()=>{if(A(),v.length>0){const E=v[v.length-1];E.text=tt(E.text),E.text.length===0&&v.pop()}g.push(v),v=[],w=0,P=!1};for(let E=0;E<x.length;E++){const{token:k,style:O,continuesFromPrevious:he}=x[E],M=p(k,O);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))??"",q=N?Ee(N):!1;if(B&&q)continue}const I=!he,L=I?T(E):M;if(L>u&&I)if(w>0&&C(),h){const B=S(E);for(let N=0;N<B.length;N++){const q=B[N].token,D=B[N].style,K=Xh(q,h,n,i);for(const oe of K){const ae=p(oe,D);ae+w>u&&C(),!R||R.style!==D?(A(),R={text:oe,style:D}):R.text+=oe,w+=ae}}E+=B.length-1}else{const B=S(E);A(),g.push(B.map(N=>({text:N.token,style:N.style}))),P=!1,E+=B.length-1}else if(L+w>u&&I){if(Ee(k)){P=!1;continue}C(),R={text:k,style:O},w=M}else if(he&&!h)!R||R.style!==O?(A(),R={text:k,style:O}):R.text+=k,w+=M;else{const B=Ee(k);if(w===0&&B&&!P)continue;!R||R.style!==O?(A(),R={text:k,style:O}):R.text+=k,w+=M}}if(A(),v.length>0){const E=v[v.length-1];E.text=tt(E.text),E.text.length===0&&v.pop()}(v.length>0||g.length===y)&&g.push(v)}return g}function i_(r){const e=[];let t=!1;for(const s of r){const i=Vh(s.text);let n=!0;for(const o of i){const a=Ee(o)||vr(o),l=n&&t&&!a;e.push({token:o,style:s.style,continuesFromPrevious:l}),t=!a,n=!1}}return e}const n_={willReadFrequently:!0};function Ra(r,e,t,s,i){let n=t[r];return typeof n!="number"&&(n=i(r,e,s)+e,t[r]=n),n}function o_(r,e,t,s,i,n,o){const a=t.getContext("2d",n_);a.font=e._fontString;let l=0,h="";const c=[],u=Object.create(null),{letterSpacing:d,whiteSpace:f}=e,p=xn(f),g=yn(f);let m=!p;const _=e.wordWrapWidth+d,x=Vh(r);for(let T=0;T<x.length;T++){let S=x[T];if(vr(S)){if(!g){c.push(tt(h)),m=!p,h="",l=0;continue}S=" "}if(p){const w=Ee(S),P=Ee(h[h.length-1]);if(w&&P)continue}const v=Ra(S,d,u,a,s);if(v>_)if(h!==""&&(c.push(tt(h)),h="",l=0),i(S,e.breakWords)){const w=Xh(S,e.breakWords,o,n);for(const P of w){const R=Ra(P,d,u,a,s);R+l>_&&(c.push(tt(h)),m=!1,h="",l=0),h+=P,l+=R}}else h.length>0&&(c.push(tt(h)),h="",l=0),c.push(tt(S)),m=!1,h="",l=0;else v+l>_&&(m=!1,c.push(tt(h)),h="",l=0),(h.length>0||!Ee(S)||m)&&(h+=S,l+=v)}const y=tt(h);return y.length>0&&c.push(y),c.join(`
|
|
924
|
+
`)}const Ba={willReadFrequently:!0},lt=class z{static get experimentalLetterSpacingSupported(){let e=z._experimentalLetterSpacingSupported;if(e===void 0){const t=V.get().getCanvasRenderingContext2D().prototype;e=z._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=z._canvas,i=t.wordWrap){var T;const n=`${e}-${t.styleKey}-wordWrap-${i}`;if(z._measurementCache.has(n))return z._measurementCache.get(n);if(Wh(t)&&Hh(e)){const S=s_(e,t,i,z._context,z._measureText,z._measureTextAdvance,z.measureFont,z.canBreakChars,z.wordWrapSplit),v=new z(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 z._measurementCache.set(n,v),v}const a=t._fontString,l=z.measureFont(a);l.fontSize===0&&(l.fontSize=t.fontSize,l.ascent=t.fontSize,l.descent=0);const h=z._context;h.font=a;const u=(i?z._wordWrap(e,t,s):e).split(e_),d=new Array(u.length);let f=0;for(let S=0;S<u.length;S++){const v=z._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=z._adjustWidthForStyle(f,t),_=Math.max(g,l.fontSize+p)+(u.length-1)*(g+t.leading),x=z._adjustHeightForStyle(_,t),y=new z(e,t,m,x,u,d,g+t.leading,f,l);return z._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}=z._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 z._measureTextCore(e,t,s).metricWidth}static _measureTextCore(e,t,s){let i=!1;z.experimentalLetterSpacingSupported&&(z.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=(z.graphemeSegmenter(e).length-1)*t,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,t,s=z._canvas){return o_(e,t,s,z._measureTextAdvance,z.canBreakWords,z.canBreakChars,z.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 z.graphemeSegmenter(e)}static measureFont(e){if(z._fonts[e])return z._fonts[e];const t=z._context;t.font=e;const s=t.measureText(z.METRICS_STRING+z.BASELINE_SYMBOL),i=s.actualBoundingBoxAscent??0,n=s.actualBoundingBoxDescent??0,o={ascent:i,descent:n,fontSize:i+n};return z._fonts[e]=o,o}static clearMetrics(e=""){e?delete z._fonts[e]:z._fonts={}}static get _canvas(){if(!z.__canvas){let e;try{const t=new OffscreenCanvas(0,0),s=t.getContext("2d",Ba);if(s!=null&&s.measureText)return z.__canvas=t,t;e=V.get().createCanvas()}catch{e=V.get().createCanvas()}e.width=e.height=10,z.__canvas=e}return z.__canvas}static get _context(){return z.__context||(z.__context=z._canvas.getContext("2d",Ba)),z.__context}};lt.METRICS_STRING="|ÉqÅ";lt.BASELINE_SYMBOL="M";lt.BASELINE_MULTIPLIER=1.4;lt.HEIGHT_MULTIPLIER=2;lt.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]})();lt.experimentalLetterSpacing=!1;lt._fonts={};lt._measurementCache=Nh(1e3);let Fe=lt;const a_=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ks(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)&&!a_.includes(i)&&(i=`"${i}"`),t[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${e} ${t.join(",")}`}const ka=1e5;function Xt(r,e,t,s=0,i=0,n=0){if(r.texture===U.WHITE&&!r.fill)return se.shared.setValue(r.color).setAlpha(r.alpha??1).toHexa();if(r.fill){if(r.fill instanceof Us){const o=r.fill,a=e.createPattern(o.texture.source.resource,"repeat"),l=o.transform.copyTo(F.shared);return l.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(l),a}else if(r.fill instanceof qe){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(_*ka)/ka,se.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,se.shared.setValue(f.color).toHex())});return u}}else{const o=e.createPattern(r.texture.source.resource,"repeat"),a=r.matrix.copyTo(F.shared);return a.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(a),o}return W("FillStyle not recognised",r),"red"}const Ia=new ee;function Wt(r){let e=0;for(let t=0;t<r.length;t++)r.charCodeAt(t)===32&&e++;return e}class l_{getCanvasAndContext(e){const{text:t,style:s,resolution:i=1}=e,n=s._getFinalPadding(),o=Fe.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=dt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(s,n,i,h,o);const c=s.trim?Wg({canvas:h.canvas,width:a,height:l,resolution:1,output:Ia}):Ia.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(e){dt.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=ks(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 P=e._stroke;a.lineWidth=P.width,a.miterLimit=P.miterLimit,a.lineJoin=P.join,a.lineCap=P.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 P=0;P<_;++P){const R=e.dropShadow&&P===0,A=R?Math.ceil(Math.max(1,p)+t*2):0,C=A*s;if(R)this._setupDropShadow(a,e,s,C);else{const E=e._gradientBounds,k=e._gradientOffset;if(E){const O={width:E.width,height:E.height,lineHeight:E.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,O,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 E=0;E<h.length;E++){g=y,m=y+E*c+f.ascent+T,g+=this._getAlignmentOffset(u[E],d,e.align);let k=0;if(e.align==="justify"&&e.wordWrap&&E<h.length-1){const O=Wt(h[E]);O>0&&(k=(d-u[E])/O)}(w=e._stroke)!=null&&w.width&&this._drawLetterSpacing(h[E],e,i,g+t,m+t-A,!0,k),e._fill!==void 0&&this._drawLetterSpacing(h[E],e,i,g+t,m+t-A,!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 P=((T=w.style._stroke)==null?void 0:T.width)??0;P>m&&(m=P)}const _=m/2,x=[];for(let v=0;v<l.length;v++){const w=l[v],P=[];for(const R of w){const A=ks(R.style);a.font=A,P.push({width:Fe._measureText(R.text,R.style.letterSpacing,a),font:A})}x.push(P)}for(let v=0;v<g;++v){const w=f&&v===0,P=w?Math.ceil(Math.max(1,p)+s*2):0,R=P*i;w||(a.shadowColor="rgba(0,0,0,0)");let A=_;for(let C=0;C<l.length;C++){const E=l[C],k=h[C],O=u[C],he=d[C],M=x[C];let I=_;I+=this._getAlignmentOffset(k,c,t.align);let L=0;if(t.align==="justify"&&t.wordWrap&&C<l.length-1){let q=0;for(const D of E)q+=Wt(D.text);q>0&&(L=(c-k)/q)}const B=A+O;let N=I+s;for(let q=0;q<E.length;q++){const D=E[q],{width:K,font:oe}=M[q];if(a.font=oe,a.textBaseline=D.style.textBaseline,(S=D.style._stroke)!=null&&S.width){const te=D.style._stroke;if(a.lineWidth=te.width,a.miterLimit=te.miterLimit,a.lineJoin=te.join,a.lineCap=te.cap,w)if(D.style.dropShadow)this._setupDropShadow(a,D.style,i,R);else{const me=Wt(D.text);N+=K+me*L;continue}else{const me=Fe.measureFont(oe),be=D.style.lineHeight||me.fontSize,X={width:K,height:be,lineHeight:be,lines:[D.text]};a.strokeStyle=Xt(te,a,X,s*2,N-s,A)}this._drawLetterSpacing(D.text,D.style,n,N,B+s-P,!0,L)}const ae=Wt(D.text);N+=K+ae*L}N=I+s;for(let q=0;q<E.length;q++){const D=E[q],{width:K,font:oe}=M[q];if(a.font=oe,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 te=Wt(D.text);N+=K+te*L;continue}else{const te=Fe.measureFont(oe),me=D.style.lineHeight||te.fontSize,be={width:K,height:me,lineHeight:me,lines:[D.text]};a.fillStyle=Xt(D.style._fill,a,be,s*2,N-s,A)}this._drawLetterSpacing(D.text,D.style,n,N,B+s-P,!1,L)}const ae=Wt(D.text);N+=K+ae*L}A+=he}}}_setFillAndStrokeStyles(e,t,s,i,n,o=0,a=0){var l;if(e.fillStyle=t._fill?Xt(t._fill,e,s,i*2,o,a):null,(l=t._stroke)!=null&&l.width){const h=n+i*2;e.strokeStyle=Xt(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=se.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(Fe.experimentalLetterSpacingSupported&&(Fe.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=Fe.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 $t=new l_,bn=class St extends Be{constructor(e={}){super(),this.uid=ne("textStyle"),this._tick=0,this._cachedFontString=null,h_(e),e instanceof St&&(e=e._toObject());const i={...St.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({...St.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...St.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({...Ge.defaultFillStyle,...e},()=>{this._fill=Ct({...this._originalFill},Ge.defaultFillStyle)})),this._fill=Ct(e===0?"black":e,Ge.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ge.defaultStrokeStyle,...e},()=>{this._stroke=xr({...this._originalStroke},Ge.defaultStrokeStyle)})),this._stroke=xr(e,Ge.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=St.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=ks(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 St(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&&!(se.isColorLike(e)||e instanceof qe||e instanceof Us)}};bn.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};bn.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 Bt=bn;function h_(r){const e=r;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=Bt.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){G(Y,"strokeThickness is now a part of stroke");const t=e.stroke;let s={};if(se.isColorLike(t))s.color=t;else if(t instanceof qe||t instanceof Us)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(G(Y,"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 qe({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),i=e.fill.map(n=>se.shared.setValue(n).toNumber());s.forEach((n,o)=>{t.addColorStop(n,i[o])}),r.fill={fill:t}}}function c_(r,e){const{texture:t,bounds:s}=r,i=e._style._getFinalPadding();sl(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 vn{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 u_ extends vn{}class $h{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),this._managedTexts=new ze({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,c_(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 u_;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}}$h.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};class jh{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,s,i){typeof e=="string"&&(G("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:s,resolution:t}),e.style instanceof Bt||(e.style=new Bt(e.style)),e.textureStyle instanceof ot||(e.textureStyle=new ot(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}=$t.getCanvasAndContext({text:n,style:o,resolution:h}),d=Th(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),$t.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||$t.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&&$t.returnCanvasAndContext({canvas:s,context:i})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",de.returnTexture(e,!0)}renderTextToCanvas(){G("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 Yh extends jh{constructor(e){super(e,!0)}}Yh.extension={type:[b.CanvasSystem],name:"canvasText"};class qh extends jh{constructor(e){super(e,!1)}}qh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"canvasText"};H.add(Yh);H.add(qh);H.add($h);class Dy extends Dg{constructor(...e){const t=Lg(e,"Text");super(t,Bt),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof ot?t.textureStyle:new ot(t.textureStyle)),this.autoGenerateMipmaps=t.autoGenerateMipmaps??ge.defaultOptions.autoGenerateMipmaps}updateBounds(){const e=this._bounds,t=this._anchor;let s=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=$t.getCanvasAndContext({text:this.text,style:this._style,resolution:1});$t.returnCanvasAndContext(o),s=n.width,i=n.height}else{const n=Fe.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 Kh extends Be{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 G(Y,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return G(Y,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return G(Y,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return G(Y,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return G(Y,"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 Zh=class Qh extends Kh{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={...Qh.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=U.WHITE,s._fill.fill=null),this.applyFillAsTint=t.overrideFill;const i=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const n=ks(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 ot?t.textureStyle:new ot(t.textureStyle)),this.fontMetrics=Fe.measureFont(n),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(e){var _,x;const t=Fe.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=Fe.measureText(T,a,i,!1);S.lineHeight=S.height;const v=S.width*u,w=Math.ceil((a.fontStyle==="italic"?2:1)*v),P=S.height*u,R=w+f*2,A=P+f*2;if(p=!1,T!==`
|
|
925
|
+
`&&T!=="\r"&&T!==" "&&T!==" "&&(p=!0,c=Math.ceil(Math.max(A,c))),l+R>g&&(h+=c,c=A,l=0,h+c>m)){o.update();const E=this._nextPage();i=E.canvasAndContext.canvas,n=E.canvasAndContext.context,o=E.texture.source,l=0,h=0,c=0}const C=n.measureText(T).width/u;if(this.chars[T]={id:T.codePointAt(0),xOffset:-(f/u),yOffset:-(f/u),xAdvance:C,kerning:{}},p){this._drawGlyph(n,S,l+f,h+f,u,a);const E=o.width*u,k=o.height*u,O=new ee(l/E*o.width,h/k*o.height,R/E*o.width,A/k*o.height);this.chars[T].texture=new U({source:o,frame:O}),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 G(Y,"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=dt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);const s=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),i=new U({source:new Mt({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=ks(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=Xt(i,e)),t._fill&&(e.fillStyle=Xt(t._fill,e)),t.dropShadow){const o=t.dropShadow,a=se.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];dt.returnCanvasAndContext(t),s.destroy(!0)}this.pages=null}};Zh.defaultOptions={textureSize:512,style:new Bt,mipmap:!0};let Fa=Zh;function d_(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=xn(e.whiteSpace),g=yn(e.whiteSpace);if(p||g){const S=[];let v=p;for(let w=0;w<r.length;w++){let P=r[w];if(P==="\r"||P===`
|
|
926
|
+
`)if(g)P==="\r"&&r[w+1]===`
|
|
927
|
+
`&&w++,P=" ";else{p&&(v=!0),S.push(P);continue}if(Ee(P))if(p&&Ma(P)){if(v)continue;v=!0,S.push(" ")}else v=!1,S.push(P);else v=!1,S.push(P)}r=S}const m=S=>{const v=n.width;for(let w=0;w<l.index;w++){const P=S.positions[w];n.chars.push(S.chars[w]),n.charPositions.push(P+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(;Ma(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 P=t.chars[v];if(/(?:\s)/.test(v)||v==="\r"||v===`
|
|
928
|
+
`||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===`
|
|
929
|
+
`)_();else if(!w&&P){const E=P.xAdvance+(((y=P.kerning)==null?void 0:y[o])||0)+c;n.width+=E,n.spaceWidth=E,n.spacesIndex.push(n.charPositions.length),n.chars.push(v)}}else if(P){const C=((T=P.kerning)==null?void 0:T[o])||0,E=P.xAdvance+C+c;f&&x(l.width+E)&&(a||_(),m(l),_()),l.positions[l.index++]=l.width+C,l.chars.push(v),l.width+=E,zh(v)&&(!a&&e.wordWrap&&x(n.width+l.width)&&_(),m(l))}o=v}return _(),e.align==="center"?f_(i):e.align==="right"?p_(i):e.align==="justify"&&m_(i),i}function f_(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 p_(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 m_(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 g_(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 er=0;class __{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=Nh(1e3)}getFont(e,t){var o,a;let s=`${t.fontFamily}-bitmap`,i=!0;if(re.has(s)){const l=re.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}`,!re.has(s)){const l=Object.create(t);l._lineHeight=0;const h=new Fa({style:l,overrideFill:i,overrideSize:!0,...this.defaultOptions});er++,er>50&&W("BitmapText",`You have dynamically created ${er} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),h.once("destroy",()=>{er--,re.remove(s)}),re.set(s,h)}const n=re.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=Fe.graphemeSegmenter(e),a=d_(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},G(Y,"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 Bt?i:new Bt(i),o=t.dynamicFill??this._canUseTintForStyle(n),a=new Fa({style:n,overrideFill:o,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1,textureStyle:t.textureStyle}),l=g_(t.chars);return a.ensureCharacters(l.join("")),re.set(`${s}-bitmap`,a),a.once("destroy",()=>re.remove(`${s}-bitmap`)),a}uninstall(e){const t=`${e}-bitmap`,s=re.get(t);s&&s.destroy()}_canUseTintForStyle(e){return!e._stroke&&(!e.dropShadow||e.dropShadow.color===0)&&!e._fill.fill&&e._fill.color===16777215}}const Ga=new __;function x_(){const{userAgent:r}=V.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Tn=class wt{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?$.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,P=S*v*w;if(P<=0)continue;o.globalAlpha=P;const R=y&16777215,A=T&16777215,C=Et(Pt(A,R)),E=p.frame,k=m.addressModeU??m.addressMode,O=m.addressModeV??m.addressMode,he=wt._getPatternRepeat(k,O),M=p.source._resolution??p.source.resolution??1,I=(c=(h=f.renderable)==null?void 0:h.renderGroup)==null?void 0:c.isCachedAsTexture,L=E.x*M,B=E.y*M,N=E.width*M,q=E.height*M,D=f.bounds,K=i.renderTarget.renderTarget.isRoot,oe=D.minX,ae=D.minY,te=D.maxX-D.minX,me=D.maxY-D.minY,be=p.rotate,X=p.uvs,Ce=Math.min(X.x0,X.x1,X.x2,X.x3,X.y0,X.y1,X.y2,X.y3),ke=Math.max(X.x0,X.x1,X.x2,X.x3,X.y0,X.y1,X.y2,X.y3),fe=he!=="no-repeat"&&(Ce<0||ke>1),De=be&&!(!fe&&(C!==16777215||be));De?(wt._tempPatternMatrix.copyFrom(f.transform),j.matrixAppendRotationInv(wt._tempPatternMatrix,be,oe,ae,te,me),n.setContextTransform(wt._tempPatternMatrix,f.roundPixels===1,void 0,I&&K)):n.setContextTransform(f.transform,f.roundPixels===1,void 0,I&&K);const Ie=De?0:oe,kt=De?0:ae,It=te,as=me;if(fe){let Os=g;const Ft=C!==16777215&&!be,Gt=E.width<=p.source.width&&E.height<=p.source.height;Ft&&Gt&&(Os=$.getTintedCanvas({texture:p},C));const Rr=o.createPattern(Os,he);if(!Rr)continue;const Xn=It,$n=as;if(Xn===0||$n===0)continue;const jn=1/Xn,Yn=1/$n,qn=(X.x1-X.x0)*jn,Kn=(X.y1-X.y0)*jn,Zn=(X.x3-X.x0)*Yn,Qn=(X.y3-X.y0)*Yn,Su=X.x0-qn*Ie-Zn*kt,wu=X.y0-Kn*Ie-Qn*kt,Br=p.source.pixelWidth,kr=p.source.pixelHeight;wt._tempPatternMatrix.set(qn*Br,Kn*kr,Zn*Br,Qn*kr,Su*Br,wu*kr),$.applyPatternTransform(Rr,wt._tempPatternMatrix),o.fillStyle=Rr,o.fillRect(Ie,kt,It,as)}else{const Ft=C!==16777215||be?$.getTintedCanvas({texture:p},C):g,Gt=Ft!==g;o.drawImage(Ft,Gt?0:L,Gt?0:B,Gt?Ft.width:N,Gt?Ft.height:q,Ie,kt,It,as)}}}};Tn._tempPatternMatrix=new F;Tn.extension={type:[b.CanvasPipesAdaptor],name:"batch"};let y_=Tn;class Jh{constructor(){this._tempState=Ze.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)}}Jh.extension={type:[b.WebGLPipesAdaptor],name:"batch"};const tr=Ze.for2d();class ec{start(e,t,s){const i=e.renderer,n=i.encoder,o=s.gpuProgram;this._shader=s,this._geometry=t,n.setGeometry(t,o),tr.blendMode="normal",i.pipeline.getPipeline(t,o,tr);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=rn(l.textures,l.count,i.limits.maxBatchableTextures)}tr.blendMode=t.blendMode;const o=i.bindGroup.getBindGroup(t.bindGroup,s,1),a=i.pipeline.getPipeline(this._geometry,s,tr,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)}}ec.extension={type:[b.WebGPUPipesAdaptor],name:"batch"};const Sn=class tc{constructor(e,t){var s,i;this.state=Ze.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 nn({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]=tc.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}};Sn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};Sn._availableBatchers=Object.create(null);let wn=Sn;H.handleByMap(b.Batcher,wn._availableBatchers);H.add(nn);const b_={name:"texture-bit",vertex:{header:`
|
|
930
|
+
|
|
931
|
+
struct TextureUniforms {
|
|
932
|
+
uTextureMatrix:mat3x3<f32>,
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
936
|
+
`,main:`
|
|
937
|
+
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
938
|
+
`},fragment:{header:`
|
|
939
|
+
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
940
|
+
@group(2) @binding(1) var uSampler: sampler;
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
`,main:`
|
|
944
|
+
outColor = textureSample(uTexture, uSampler, vUV);
|
|
945
|
+
`}},v_={name:"texture-bit",vertex:{header:`
|
|
946
|
+
uniform mat3 uTextureMatrix;
|
|
947
|
+
`,main:`
|
|
948
|
+
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
949
|
+
`},fragment:{header:`
|
|
950
|
+
uniform sampler2D uTexture;
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
`,main:`
|
|
954
|
+
outColor = texture(uTexture, vUV);
|
|
955
|
+
`}},T_=new ye;class S_ extends dr{constructor(){super(),this.filters=[new Tg({sprite:new Qt(U.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 Cn{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=xe.get(S_);if(i.inverse=e.inverse,i.channel=e.mask.channel,s){e.mask.mask.measurable=!0;const n=Yi(e.mask.mask,!0,T_);e.mask.mask.measurable=!1,n.ceil();const o=t.renderTarget.renderTarget.colorTexture.source,a=de.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===Se.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&&de.returnTexture(i.filterTexture),xe.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Cn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"};class sc{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}}sc.extension={type:[b.CanvasPipes],name:"colorMask"};class rc{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}}rc.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"colorMask"};function w_(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 ic(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;w_(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 C_(r,e,t){const s=[],i=[],n=[],o=os[e.type];if(!(o!=null&&o.build(e,s)))return!1;const a=e.closePath??!0;an(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 A_(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)),ic(r,s.shape),n&&r.restore()}return!0}class nc{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 br)){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=C_(i,S.shape,m.style)||l:(ic(i,S.shape),h=A_(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))}}nc.extension={type:[b.CanvasPipes],name:"stencilMask"};class oc{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(pe.RENDERING_MASK_ADD,o),o++,i.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?i.stencil.setStencilMode(pe.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(pe.MASK_ACTIVE,o),i.colorMask.setMask(15)):e.action==="popMaskBegin"?(i.colorMask.setMask(0),o!==0?i.stencil.setStencilMode(pe.RENDERING_MASK_REMOVE,o):(i.renderTarget.clear(null,Pe.STENCIL),i.stencil.setStencilMode(pe.DISABLED,o)),o--):e.action==="popMaskEnd"&&(e.inverse?i.stencil.setStencilMode(pe.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(pe.MASK_ACTIVE,o),i.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}oc.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"stencilMask"};const ie="source-over";function P_(){const r=bh(),e=Object.create(null);return e.inherit=ie,e.none=ie,e.normal="source-over",e.add="lighter",e.multiply=r?"multiply":ie,e.screen=r?"screen":ie,e.overlay=r?"overlay":ie,e.darken=r?"darken":ie,e.lighten=r?"lighten":ie,e["color-dodge"]=r?"color-dodge":ie,e["color-burn"]=r?"color-burn":ie,e["hard-light"]=r?"hard-light":ie,e["soft-light"]=r?"soft-light":ie,e.difference=r?"difference":ie,e.exclusion=r?"exclusion":ie,e.saturation=r?"saturation":ie,e.color=r?"color":ie,e.luminosity=r?"luminosity":ie,e["linear-burn"]=r?"color-burn":ie,e["linear-dodge"]=r?"color-dodge":ie,e["linear-light"]=r?"hard-light":ie,e["pin-light"]=r?"hard-light":ie,e["vivid-light"]=r?"hard-light":ie,e["hard-mix"]=ie,e.negation=r?"difference":ie,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=ie,e.divide=ie,e.min=ie,e.max=ie,e}const E_=new F;class ac{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=P_(),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?F.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||F.IDENTITY;let o=E_;o.copyFrom(n),o.append(e);const a=this._projTransform,l=this.activeResolution;if(s=s||l,a){const c=F.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=se.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()}}ac.extension={type:[b.CanvasSystem],name:"canvasContext"};class lc{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}lc.extension={type:[b.CanvasSystem],name:"limits"};class An{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}}An.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"};function Hi(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 Pn{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&&(xe.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const s=e._batchableRenderGroup??(e._batchableRenderGroup=xe.get(vn));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 F().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}}),Hi(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}),Hi(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}Pn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"};const M_="#808080",sr=new F,R_=new F,B_=new F,pi=new F;function k_(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 I_(r){return`#${(r&16777215).toString(16).padStart(6,"0")}`}function F_(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 lr(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;F_(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 G_(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)),lr(r,s.shape),n&&r.restore()}return!0}function U_(r,e,t,s){const i=r.fill;if(i instanceof qe){i.buildGradient();const o=i.texture;if(o){const a=$.getTintedPattern(o,e),l=t?pi.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):pi.copyFrom(i.transform);return s&&!r.textureSpace&&l.append(s),$.applyPatternTransform(a,l),a}}if(i instanceof Us){const o=$.getTintedPattern(i.texture,e);return $.applyPatternTransform(o,i.transform),o}const n=r.texture;if(n&&n!==U.WHITE){if(!n.source.resource)return M_;const o=$.getTintedPattern(n,e),a=t?pi.copyFrom(t).scale(n.source.pixelWidth,n.source.pixelHeight):r.matrix;return $.applyPatternTransform(o,a),o}return I_(e)}class hc{constructor(){this.shader=null}contextChange(e){}execute(e,t){var x,y,T,S,v,w,P;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=Et(Pt(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 A=_[R];if(A.action==="texture"){const L=A.data,B=L.image,N=B?$.getCanvasSource(B):null;if(!N)continue;const q=L.alpha*d;if(q<=0)continue;const D=Pt(L.style,g);n.globalAlpha=q;let K=N;D!==16777215&&(K=$.getTintedCanvas({texture:B},D));const oe=B.frame,ae=B.source._resolution??B.source.resolution??1;let te=oe.x*ae,me=oe.y*ae;const be=oe.width*ae,X=oe.height*ae;K!==N&&(te=0,me=0);const Ce=L.transform,ke=Ce&&!Ce.isIdentity(),fe=B.rotate;ke||fe?(sr.copyFrom(o),ke&&sr.append(Ce),fe&&j.matrixAppendRotationInv(sr,fe,L.dx,L.dy,L.dw,L.dh),i.setContextTransform(sr,m===1)):i.setContextTransform(o,m===1),n.drawImage(K,te,me,K===N?be:K.width,K===N?X:K.height,fe?0:L.dx,fe?0:L.dy,L.dw,L.dh),(ke||fe)&&i.setContextTransform(o,m===1);continue}const C=A.data,E=(T=C==null?void 0:C.path)==null?void 0:T.shapePath;if(!((S=E==null?void 0:E.shapePrimitives)!=null&&S.length))continue;const k=C.style,O=Pt(k.color,g),he=k.alpha*d;if(he<=0)continue;const M=A.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=E.shapePrimitives;if(!M&&((P=(w=(v=C.hole)==null?void 0:v.shapePath)==null?void 0:w.shapePrimitives)!=null&&P.length)){const L=I[I.length-1];L.holes=C.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,q=N&&!N.isIdentity(),D=k.texture&&k.texture!==U.WHITE,K=k.textureSpace==="global"?N:null,oe=D?ch(R_,k,B.shape,K):null,ae=q?B_.copyFrom(o).append(N):o,te=U_(k,O,oe,ae);if(q&&(n.save(),n.transform(N.a,N.b,N.c,N.d,N.tx,N.ty)),M){const me=k;if(me.alignment!==.5&&!me.pixelLine){const X=[],Ce=[],ke=[],fe=os[B.shape.type];if(fe!=null&&fe.build(B.shape,X)){const Ve=B.shape.closePath??!0;an(X,me,!1,Ve,Ce,ke),n.fillStyle=te,k_(n,Ce,ke)}else n.strokeStyle=te,n.beginPath(),lr(n,B.shape),n.stroke()}else n.strokeStyle=te,n.beginPath(),lr(n,B.shape),n.stroke()}else n.fillStyle=te,n.beginPath(),lr(n,B.shape),G_(n,B.holes)?n.fill("evenodd"):n.fill();q&&n.restore()}}n.restore()}destroy(){this.shader=null}}hc.extension={type:[b.CanvasPipesAdaptor],name:"graphics"};class En{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 vn;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}}En.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"};const Cs={};H.handle(b.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Cs[r.name]=r.ref},r=>{delete Cs[r.name]});class Mn{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 Si;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=!!Cs[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,s))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const s=this._activeBlendMode;if(!Cs[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 Si,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 dr,t.filters=[new Cs[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}}Mn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"};function zi(r,e){e||(e=0);for(let t=e;t<r.length&&r[t];t++)r[t]=null}const O_=new Te,Ua=ys|pr|Qi;function cc(r,e=!1){D_(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&&uc(c,s,0)}zi(a,l),o.index=0}if(e)for(let i=0;i<r.renderGroupChildren.length;i++)cc(r.renderGroupChildren[i],e)}function D_(r){const e=r.root;let t;if(r.renderGroupParent){const s=r.renderGroupParent;r.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),r.worldColor=fr(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 uc(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&Ua&&Oa(r,i,t)):(t=r._updateFlags,r.relativeGroupTransform.copyFrom(s),t&Ua&&Oa(r,O_,t)),!r.renderGroup){const n=r.children,o=n.length;for(let h=0;h<o;h++)uc(n[h],e,t);const a=r.parentRenderGroup,l=r;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Oa(r,e,t){if(t&pr){r.groupColor=fr(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&Qi&&(r.groupBlendMode=r.localBlendMode==="inherit"?e.groupBlendMode:r.localBlendMode),t&ys&&(r.globalDisplayStatus=r.localDisplayStatus&e.globalDisplayStatus),r._updateFlags=0}function L_(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 N_=new F;class dc{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=N_;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}),Hi(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&&de.returnTexture(e.texture,!0);const h=de.getOptimalTexture(s.width,s.height,n,o);h._source.style=new ot({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&&(de.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?zi(e.childrenRenderablesToUpdate.list,0):L_(e,s),cc(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)}zi(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)}}dc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"};const Rn=class fc{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new se(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...fc.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){se.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(){}};Rn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0};Rn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let W_=Rn;const mi={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Bn=class pc{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof Te||e instanceof U?{target:e,...t}:{...t,...e}}async image(e){const t=V.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,pc.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)},mi[t],s)});if(i.toDataURL!==void 0)return i.toDataURL(mi[t],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:mi[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 U)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 U?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 U?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}};Bn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"extract"};Bn.defaultImageOptions={format:"png",quality:1};let H_=Bn;class kn extends U{static create(e){const{dynamic:t,textureOptions:s,...i}=e;return new kn({...s,source:new ge(i),dynamic:t??!1})}resize(e,t,s){return this.source.resize(e,t,s),this}}const z_=new ee,V_=new ye,X_=[0,0,0,0];class mc{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:se.shared.setValue(n).toArray():n=X_;const o=((c=e.frame)==null?void 0:c.copyTo(z_))||Ki(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=kn.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:s,textureOptions:a}),h=F.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}}mc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"textureGenerator"};function $_(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 j_(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 In=class gc{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(e){e={...gc.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[i]):s[i]=j_(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}};In.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"gc",priority:0};In.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Y_=In;class _c{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 F,worldColor:4294967295,offset:new J},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,gn(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 ut,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===Se.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 Re({uProjectionMatrix:{value:new F,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new F,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}}_c.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"};let q_=1;class xc{constructor(){this._tasks=[],this._offset=0}init(){Oe.system.add(this._update,this)}repeat(e,t,s=!0){const i=q_++;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(){Oe.system.remove(this._update,this),this._tasks.length=0}}xc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"scheduler",priority:0};let Da=!1;function K_(r){if(!Da){if(V.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${gr} (${r}) http://www.pixijs.com/
|
|
956
|
+
|
|
957
|
+
`,"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 ${gr} - ${r} - http://www.pixijs.com/`);Da=!0}}class Fn{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===Se.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),K_(t)}}}Fn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2};Fn.defaultOptions={hello:!1};const Gn=class yc{constructor(e){this._renderer=e}init(e){e={...yc.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return G("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){G("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){G("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){G("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){G("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){G("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Gn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderableGC",priority:0};Gn.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Z_=Gn;const Un=class hr{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){G("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){G("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){G("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){G("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!==hr.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==hr.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==hr.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){G("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Un.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"};Un.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Q_=Un;const bc=class vc{constructor(e={}){if(this.uid=ne("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...vc.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 ge({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 U||e.depthStencilTexture instanceof ge?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 ge({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)}};bc.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Vi=bc;const zt=new Map;ss.register(zt);function Tc(r,e){if(!zt.has(r)){const t=new U({source:new Ye({resource:r,...e})}),s=()=>{zt.get(r)===t&&zt.delete(r)};t.once("destroy",s),t.source.once("destroy",s),zt.set(r,t)}return zt.get(r)}const On=class Sc{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={...Sc.defaultOptions,...e},e.view&&(G(Y,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new ee(0,0,e.width,e.height),this.canvas=e.canvas||V.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Tc(this.canvas,e),this.renderTarget=new Vi({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()}};On.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0};On.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let J_=On;const Dn=[W_,_c,Fn,J_,dc,Y_,Q_,mc,H_,Wl,Z_,xc],wc=[Mn,wn,En,Pn,Cn,oc,rc,An];function ex(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 tx(r){const e=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class Ln{constructor(e){this.rootViewPort=new ee,this.viewport=new ee,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Ol("onRenderTargetChange"),this.projectionMatrix=new F,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=tx(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 U&&(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),P=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),P=Math.min(Math.max(P,1),p-v),u.x=S,u.y=v,u.width=w,u.height=P}else u.x=0,u.y=0,u.width=f,u.height=p;return ex(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=Pe.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=Pe.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 Ye.test(e)&&(e=Tc(e).source),e instanceof Vi?t=e:e instanceof ge&&(t=new Vi({colorTextures:[e]}),e.source instanceof Ye&&(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 sx{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=se.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||!Ye.test(t))&&(t=V.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 Cc extends Ln{constructor(e){super(e),this.adaptor=new sx,this.adaptor.init(e,this)}}Cc.extension={type:[b.CanvasSystem],name:"renderTarget"};class Ac{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=V.get().createCanvas(),s=t.getContext("2d"),i=$.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(){}}Ac.extension={type:[b.CanvasSystem],name:"texture"};const rx=[...Dn,ac,lc,Ac,Cc],ix=[Mn,wn,En,Pn,Cn,nc,sc,An],nx=[y_,hc],Pc=[],Ec=[],Mc=[];H.handleByNamedList(b.CanvasSystem,Pc);H.handleByNamedList(b.CanvasPipes,Ec);H.handleByNamedList(b.CanvasPipesAdaptor,Mc);H.add(...rx,...ix,...nx);class ox extends Gs{constructor(){const e={name:"canvas",type:Se.CANVAS,systems:Pc,renderPipes:Ec,renderPipeAdaptors:Mc};super(e)}}const ax=Object.freeze(Object.defineProperty({__proto__:null,CanvasRenderer:ox},Symbol.toStringTag,{value:"Module"}));var cr=(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))(cr||{});class lx{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 Rc{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new ze({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&Q.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=cr.ARRAY_BUFFER;e.descriptor.usage&Q.INDEX?s=cr.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&Q.UNIFORM&&(s=cr.UNIFORM_BUFFER);const i=new lx(t.createBuffer(),s);return e._gpuData[this._renderer.uid]=i,this._managedBuffers.add(e),i}resetState(){this._boundBufferBases=Object.create(null)}}Rc.extension={type:[b.WebGLSystem],name:"buffer"};const Nn=class Bc{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={...Bc.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=V.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 V.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")}};Nn.extension={type:[b.WebGLSystem],name:"context"};Nn.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let hx=Nn;function kc(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.`)}cx(r)}function cx(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]+=Ps(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]+=Ps(o.format).stride}}var Xi=(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))(Xi||{}),Wn=(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))(Wn||{}),Z=(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))(Z||{});const La={uint8x2:Z.UNSIGNED_BYTE,uint8x4:Z.UNSIGNED_BYTE,sint8x2:Z.BYTE,sint8x4:Z.BYTE,unorm8x2:Z.UNSIGNED_BYTE,unorm8x4:Z.UNSIGNED_BYTE,snorm8x2:Z.BYTE,snorm8x4:Z.BYTE,uint16x2:Z.UNSIGNED_SHORT,uint16x4:Z.UNSIGNED_SHORT,sint16x2:Z.SHORT,sint16x4:Z.SHORT,unorm16x2:Z.UNSIGNED_SHORT,unorm16x4:Z.UNSIGNED_SHORT,snorm16x2:Z.SHORT,snorm16x4:Z.SHORT,float16x2:Z.HALF_FLOAT,float16x4:Z.HALF_FLOAT,float32:Z.FLOAT,float32x2:Z.FLOAT,float32x3:Z.FLOAT,float32x4:Z.FLOAT,uint32:Z.UNSIGNED_INT,uint32x2:Z.UNSIGNED_INT,uint32x3:Z.UNSIGNED_INT,uint32x4:Z.UNSIGNED_INT,sint32:Z.INT,sint32x2:Z.INT,sint32x3:Z.INT,sint32x4:Z.INT};function ux(r){return La[r]??La.float32}const dx={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class fx{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Ic{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new ze({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 fx,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;kc(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=Ps(h.format),g=ux(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=dx[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}}Ic.extension={type:[b.WebGLSystem],name:"geometry"};const px=new Cr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Hn=class Fc{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:s}={...Fc.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=Ze.for2d();const i=new pt({vertex:`
|
|
958
|
+
attribute vec2 aPosition;
|
|
959
|
+
out vec2 vUv;
|
|
960
|
+
|
|
961
|
+
void main() {
|
|
962
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
963
|
+
|
|
964
|
+
vUv = (aPosition + 1.0) / 2.0;
|
|
965
|
+
|
|
966
|
+
// flip dem UVs
|
|
967
|
+
vUv.y = 1.0 - vUv.y;
|
|
968
|
+
}`,fragment:`
|
|
969
|
+
in vec2 vUv;
|
|
970
|
+
out vec4 finalColor;
|
|
971
|
+
|
|
972
|
+
uniform sampler2D uTexture;
|
|
973
|
+
|
|
974
|
+
void main() {
|
|
975
|
+
finalColor = texture(uTexture, vUv);
|
|
976
|
+
}`,name:"big-triangle"});this._bigTriangleShader=new Ke({glProgram:i,resources:{uTexture:U.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:px,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new U({source:new ge({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)}};Hn.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1};Hn.defaultOptions={useBackBuffer:!1};let mx=Hn;class Gc{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)))}}Gc.extension={type:[b.WebGLSystem],name:"colorMask"};class Uc{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}}Uc.extension={type:[b.WebGLSystem],name:"encoder"};class Oc{constructor(e){this._renderer=e}contextChange(){const e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Yl(this.maxTextures,e);const t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Oc.extension={type:[b.WebGLSystem],name:"limits"};class gx{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const mt=[];mt[pe.NONE]=void 0;mt[pe.DISABLED]={stencilWriteMask:0,stencilReadMask:0};mt[pe.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};mt[pe.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};mt[pe.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};mt[pe.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Dc{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:pe.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:pe.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=pe.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=mt[e],o=this._stencilCache;if(s.stencilMode=e,s.stencilReference=t,e===pe.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]))}}Dc.extension={type:[b.WebGLSystem],name:"stencil"};class Lc{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!kl())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 He({data:new Float32Array(t.layout.size/4),usage:Q.UNIFORM|Q.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 He({data:new Float32Array(i.layout.size/4),usage:Q.UNIFORM|Q.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 Nc={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 _x(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=Nc[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 At=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
|
|
977
|
+
var matrix = uv[name].toArray(true);
|
|
978
|
+
data[offset] = matrix[0];
|
|
979
|
+
data[offset + 1] = matrix[1];
|
|
980
|
+
data[offset + 2] = matrix[2];
|
|
981
|
+
data[offset + 4] = matrix[3];
|
|
982
|
+
data[offset + 5] = matrix[4];
|
|
983
|
+
data[offset + 6] = matrix[5];
|
|
984
|
+
data[offset + 8] = matrix[6];
|
|
985
|
+
data[offset + 9] = matrix[7];
|
|
986
|
+
data[offset + 10] = matrix[8];
|
|
987
|
+
`,uniform:`
|
|
988
|
+
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
989
|
+
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
|
|
990
|
+
v = uv[name];
|
|
991
|
+
data[offset] = v.x;
|
|
992
|
+
data[offset + 1] = v.y;
|
|
993
|
+
data[offset + 2] = v.width;
|
|
994
|
+
data[offset + 3] = v.height;
|
|
995
|
+
`,uniform:`
|
|
996
|
+
cv = ud[name].value;
|
|
997
|
+
v = uv[name];
|
|
998
|
+
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
999
|
+
cv[0] = v.x;
|
|
1000
|
+
cv[1] = v.y;
|
|
1001
|
+
cv[2] = v.width;
|
|
1002
|
+
cv[3] = v.height;
|
|
1003
|
+
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
1004
|
+
}
|
|
1005
|
+
`},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
|
|
1006
|
+
v = uv[name];
|
|
1007
|
+
data[offset] = v.x;
|
|
1008
|
+
data[offset + 1] = v.y;
|
|
1009
|
+
`,uniform:`
|
|
1010
|
+
cv = ud[name].value;
|
|
1011
|
+
v = uv[name];
|
|
1012
|
+
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
1013
|
+
cv[0] = v.x;
|
|
1014
|
+
cv[1] = v.y;
|
|
1015
|
+
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
1016
|
+
}
|
|
1017
|
+
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
|
|
1018
|
+
v = uv[name];
|
|
1019
|
+
data[offset] = v.red;
|
|
1020
|
+
data[offset + 1] = v.green;
|
|
1021
|
+
data[offset + 2] = v.blue;
|
|
1022
|
+
data[offset + 3] = v.alpha;
|
|
1023
|
+
`,uniform:`
|
|
1024
|
+
cv = ud[name].value;
|
|
1025
|
+
v = uv[name];
|
|
1026
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
1027
|
+
cv[0] = v.red;
|
|
1028
|
+
cv[1] = v.green;
|
|
1029
|
+
cv[2] = v.blue;
|
|
1030
|
+
cv[3] = v.alpha;
|
|
1031
|
+
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
1032
|
+
}
|
|
1033
|
+
`},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
|
|
1034
|
+
v = uv[name];
|
|
1035
|
+
data[offset] = v.red;
|
|
1036
|
+
data[offset + 1] = v.green;
|
|
1037
|
+
data[offset + 2] = v.blue;
|
|
1038
|
+
`,uniform:`
|
|
1039
|
+
cv = ud[name].value;
|
|
1040
|
+
v = uv[name];
|
|
1041
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
1042
|
+
cv[0] = v.red;
|
|
1043
|
+
cv[1] = v.green;
|
|
1044
|
+
cv[2] = v.blue;
|
|
1045
|
+
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
1046
|
+
}
|
|
1047
|
+
`}];function Wc(r,e,t,s){const i=[`
|
|
1048
|
+
var v = null;
|
|
1049
|
+
var v2 = null;
|
|
1050
|
+
var t = 0;
|
|
1051
|
+
var index = 0;
|
|
1052
|
+
var name = null;
|
|
1053
|
+
var arrayOffset = null;
|
|
1054
|
+
`];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<At.length;d++)if(At[d].test(l.data)){u=l.offset/4,i.push(`name = "${h}";`,`offset += ${u-n};`,At[d][e]||At[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(`
|
|
1055
|
+
v = uv.${h};
|
|
1056
|
+
offset += ${u-n};
|
|
1057
|
+
${d};
|
|
1058
|
+
`)}n=u}const o=i.join(`
|
|
1059
|
+
`);return new Function("uv","data","dataInt32","offset",o)}function Ht(r,e){return`
|
|
1060
|
+
for (let i = 0; i < ${r*e}; i++) {
|
|
1061
|
+
data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
|
|
1062
|
+
}
|
|
1063
|
+
`}const Hc={f32:`
|
|
1064
|
+
data[offset] = v;`,i32:`
|
|
1065
|
+
dataInt32[offset] = v;`,"vec2<f32>":`
|
|
1066
|
+
data[offset] = v[0];
|
|
1067
|
+
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
1068
|
+
data[offset] = v[0];
|
|
1069
|
+
data[offset + 1] = v[1];
|
|
1070
|
+
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
1071
|
+
data[offset] = v[0];
|
|
1072
|
+
data[offset + 1] = v[1];
|
|
1073
|
+
data[offset + 2] = v[2];
|
|
1074
|
+
data[offset + 3] = v[3];`,"vec2<i32>":`
|
|
1075
|
+
dataInt32[offset] = v[0];
|
|
1076
|
+
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
|
|
1077
|
+
dataInt32[offset] = v[0];
|
|
1078
|
+
dataInt32[offset + 1] = v[1];
|
|
1079
|
+
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
|
|
1080
|
+
dataInt32[offset] = v[0];
|
|
1081
|
+
dataInt32[offset + 1] = v[1];
|
|
1082
|
+
dataInt32[offset + 2] = v[2];
|
|
1083
|
+
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
1084
|
+
data[offset] = v[0];
|
|
1085
|
+
data[offset + 1] = v[1];
|
|
1086
|
+
data[offset + 4] = v[2];
|
|
1087
|
+
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
1088
|
+
data[offset] = v[0];
|
|
1089
|
+
data[offset + 1] = v[1];
|
|
1090
|
+
data[offset + 2] = v[2];
|
|
1091
|
+
data[offset + 4] = v[3];
|
|
1092
|
+
data[offset + 5] = v[4];
|
|
1093
|
+
data[offset + 6] = v[5];
|
|
1094
|
+
data[offset + 8] = v[6];
|
|
1095
|
+
data[offset + 9] = v[7];
|
|
1096
|
+
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
1097
|
+
for (let i = 0; i < 16; i++) {
|
|
1098
|
+
data[offset + i] = v[i];
|
|
1099
|
+
}`,"mat3x2<f32>":Ht(3,2),"mat4x2<f32>":Ht(4,2),"mat2x3<f32>":Ht(2,3),"mat4x3<f32>":Ht(4,3),"mat2x4<f32>":Ht(2,4),"mat3x4<f32>":Ht(3,4)},xx={...Hc,"mat2x2<f32>":`
|
|
1100
|
+
data[offset] = v[0];
|
|
1101
|
+
data[offset + 1] = v[1];
|
|
1102
|
+
data[offset + 2] = v[2];
|
|
1103
|
+
data[offset + 3] = v[3];
|
|
1104
|
+
`};function yx(r,e){const t=Math.max(Nc[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`
|
|
1105
|
+
v = uv.${r.data.name};
|
|
1106
|
+
offset += ${e};
|
|
1107
|
+
|
|
1108
|
+
arrayOffset = offset;
|
|
1109
|
+
|
|
1110
|
+
t = 0;
|
|
1111
|
+
|
|
1112
|
+
for(var i=0; i < ${r.data.size*t}; i++)
|
|
1113
|
+
{
|
|
1114
|
+
for(var j = 0; j < ${s}; j++)
|
|
1115
|
+
{
|
|
1116
|
+
${n}[arrayOffset++] = v[t++];
|
|
1117
|
+
}
|
|
1118
|
+
${i!==0?`arrayOffset += ${i};`:""}
|
|
1119
|
+
}
|
|
1120
|
+
`}function bx(r){return Wc(r,"uboStd40",yx,Hc)}class zc extends Lc{constructor(){super({createUboElements:_x,generateUboSync:bx})}}zc.extension={type:[b.WebGLSystem],name:"ubo"};class vx{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ee}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ee;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 gx;return i._attachedMipLevel=0,i._attachedLayer=0,e.colorTexture instanceof Ye?(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?Pe.ALL:Pe.NONE);const l=this._renderer.gl;if(t&Pe.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&&Ye.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(this._renderer.context.multiView&&Ye.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 Vc extends Ln{constructor(e){super(e),this.adaptor=new vx,this.adaptor.init(e,this)}}Vc.extension={type:[b.WebGLSystem],name:"renderTarget"};class zn extends Be{constructor({buffer:e,offset:t,size:s}){super(),this.uid=ne("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=ne("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=ne("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 Tx(r,e){const t=[],s=[`
|
|
1121
|
+
var g = s.groups;
|
|
1122
|
+
var sS = r.shader;
|
|
1123
|
+
var p = s.glProgram;
|
|
1124
|
+
var ugS = r.uniformGroup;
|
|
1125
|
+
var resources;
|
|
1126
|
+
`];let i=!1,n=0;const o=e._getProgramData(r.glProgram);for(const l in r.groups){const h=r.groups[l];t.push(`
|
|
1127
|
+
resources = g[${l}].resources;
|
|
1128
|
+
`);for(const c in h.resources){const u=h.resources[c];if(u instanceof Re)if(u.ubo){const d=r._uniformBindMap[l][Number(c)];t.push(`
|
|
1129
|
+
sS.bindUniformBlock(
|
|
1130
|
+
resources[${c}],
|
|
1131
|
+
'${d}',
|
|
1132
|
+
${r.glProgram._uniformBlockData[d].index}
|
|
1133
|
+
);
|
|
1134
|
+
`)}else t.push(`
|
|
1135
|
+
ugS.updateUniformGroup(resources[${c}], p, sD);
|
|
1136
|
+
`);else if(u instanceof zn){const d=r._uniformBindMap[l][Number(c)];t.push(`
|
|
1137
|
+
sS.bindUniformBlock(
|
|
1138
|
+
resources[${c}],
|
|
1139
|
+
'${d}',
|
|
1140
|
+
${r.glProgram._uniformBlockData[d].index}
|
|
1141
|
+
);
|
|
1142
|
+
`)}else if(u instanceof ge){const d=r._uniformBindMap[l][c],f=o.uniformData[d];f&&(i||(i=!0,s.push(`
|
|
1143
|
+
var tS = r.texture;
|
|
1144
|
+
`)),e._gl.uniform1i(f.location,n),t.push(`
|
|
1145
|
+
tS.bind(resources[${c}], ${n});
|
|
1146
|
+
`),n++)}}}const a=[...s,...t].join(`
|
|
1147
|
+
`);return new Function("r","s","sD",a)}class Sx{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 Na(r,e,t){const s=r.createShader(e);return r.shaderSource(s,t),r.compileShader(s),s}function gi(r){const e=new Array(r);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Xc(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 gi(2*e);case"bvec3":return gi(3*e);case"bvec4":return gi(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 rr=null;const Wa={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"},wx={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 $c(r,e){if(!rr){const t=Object.keys(Wa);rr={};for(let s=0;s<t.length;++s){const i=t[s];rr[r[i]]=Wa[i]}}return rr[e]}function Cx(r,e){const t=$c(r,e);return wx[t]||"float32"}function Ax(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=Cx(e,a.type);s[a.name]={location:0,format:l,stride:Ps(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 Px(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 Ex(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=$c(e,n.type);t[o]={name:o,index:i,type:l,size:n.size,isArray:a,value:Xc(l,n.size)}}return t}function Ha(r,e){const t=r.getShaderSource(e).split(`
|
|
1148
|
+
`).map((h,c)=>`${c}: ${h}`),s=r.getShaderInfoLog(e),i=s.split(`
|
|
1149
|
+
`),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(`
|
|
1150
|
+
`);a[0]=l,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Mx(r,e,t,s){r.getProgramParameter(e,r.LINK_STATUS)||(r.getShaderParameter(t,r.COMPILE_STATUS)||Ha(r,t),r.getShaderParameter(s,r.COMPILE_STATUS)||Ha(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(e)))}function Rx(r,e){const t=Na(r,r.VERTEX_SHADER,e.vertex),s=Na(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)||Mx(r,i,t,s),e._attributeData=Ax(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=Ex(i,r),e._uniformBlockData=Px(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:Xc(h.type,h.size)}}return new Sx(i,o)}const ir={textureCount:0,blockIndex:0};class jc{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;ir.textureCount=0,ir.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,ir)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,ir)}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]=Rx(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 Tx(e,t)}resetState(){this._activeProgram=null}}jc.extension={type:[b.WebGLSystem],name:"shader"};const Bx={f32:`if (cv !== v) {
|
|
1151
|
+
cu.value = v;
|
|
1152
|
+
gl.uniform1f(location, v);
|
|
1153
|
+
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1154
|
+
cv[0] = v[0];
|
|
1155
|
+
cv[1] = v[1];
|
|
1156
|
+
gl.uniform2f(location, v[0], v[1]);
|
|
1157
|
+
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1158
|
+
cv[0] = v[0];
|
|
1159
|
+
cv[1] = v[1];
|
|
1160
|
+
cv[2] = v[2];
|
|
1161
|
+
gl.uniform3f(location, v[0], v[1], v[2]);
|
|
1162
|
+
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1163
|
+
cv[0] = v[0];
|
|
1164
|
+
cv[1] = v[1];
|
|
1165
|
+
cv[2] = v[2];
|
|
1166
|
+
cv[3] = v[3];
|
|
1167
|
+
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
1168
|
+
}`,i32:`if (cv !== v) {
|
|
1169
|
+
cu.value = v;
|
|
1170
|
+
gl.uniform1i(location, v);
|
|
1171
|
+
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1172
|
+
cv[0] = v[0];
|
|
1173
|
+
cv[1] = v[1];
|
|
1174
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
1175
|
+
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1176
|
+
cv[0] = v[0];
|
|
1177
|
+
cv[1] = v[1];
|
|
1178
|
+
cv[2] = v[2];
|
|
1179
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
1180
|
+
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1181
|
+
cv[0] = v[0];
|
|
1182
|
+
cv[1] = v[1];
|
|
1183
|
+
cv[2] = v[2];
|
|
1184
|
+
cv[3] = v[3];
|
|
1185
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
1186
|
+
}`,u32:`if (cv !== v) {
|
|
1187
|
+
cu.value = v;
|
|
1188
|
+
gl.uniform1ui(location, v);
|
|
1189
|
+
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1190
|
+
cv[0] = v[0];
|
|
1191
|
+
cv[1] = v[1];
|
|
1192
|
+
gl.uniform2ui(location, v[0], v[1]);
|
|
1193
|
+
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1194
|
+
cv[0] = v[0];
|
|
1195
|
+
cv[1] = v[1];
|
|
1196
|
+
cv[2] = v[2];
|
|
1197
|
+
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
1198
|
+
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1199
|
+
cv[0] = v[0];
|
|
1200
|
+
cv[1] = v[1];
|
|
1201
|
+
cv[2] = v[2];
|
|
1202
|
+
cv[3] = v[3];
|
|
1203
|
+
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
1204
|
+
}`,bool:`if (cv !== v) {
|
|
1205
|
+
cu.value = v;
|
|
1206
|
+
gl.uniform1i(location, v);
|
|
1207
|
+
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1208
|
+
cv[0] = v[0];
|
|
1209
|
+
cv[1] = v[1];
|
|
1210
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
1211
|
+
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1212
|
+
cv[0] = v[0];
|
|
1213
|
+
cv[1] = v[1];
|
|
1214
|
+
cv[2] = v[2];
|
|
1215
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
1216
|
+
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1217
|
+
cv[0] = v[0];
|
|
1218
|
+
cv[1] = v[1];
|
|
1219
|
+
cv[2] = v[2];
|
|
1220
|
+
cv[3] = v[3];
|
|
1221
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
1222
|
+
}`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},kx={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 Ix(r,e){const t=[`
|
|
1223
|
+
var v = null;
|
|
1224
|
+
var cv = null;
|
|
1225
|
+
var cu = null;
|
|
1226
|
+
var t = 0;
|
|
1227
|
+
var gl = renderer.gl;
|
|
1228
|
+
var name = null;
|
|
1229
|
+
`];for(const s in r.uniforms){if(!e[s]){r.uniforms[s]instanceof Re?r.uniforms[s].ubo?t.push(`
|
|
1230
|
+
renderer.shader.bindUniformBlock(uv.${s}, "${s}");
|
|
1231
|
+
`):t.push(`
|
|
1232
|
+
renderer.shader.updateUniformGroup(uv.${s});
|
|
1233
|
+
`):r.uniforms[s]instanceof zn&&t.push(`
|
|
1234
|
+
renderer.shader.bindBufferResource(uv.${s}, "${s}");
|
|
1235
|
+
`);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o<At.length;o++){const a=At[o];if(i.type===a.type&&a.test(i)){t.push(`name = "${s}";`,At[o].uniform),n=!0;break}}if(!n){const a=(i.size===1?Bx:kx)[i.type].replace("location",`ud["${s}"].location`);t.push(`
|
|
1236
|
+
cu = ud["${s}"];
|
|
1237
|
+
cv = cu.value;
|
|
1238
|
+
v = uv["${s}"];
|
|
1239
|
+
${a};`)}}return new Function("ud","uv","renderer","syncData",t.join(`
|
|
1240
|
+
`))}class Yc{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 Ix(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}}Yc.extension={type:[b.WebGLSystem],name:"uniformGroup"};function Fx(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 V.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 Gx=0,Ux=1,Ox=2,Dx=3,Lx=4,Nx=5,qc=class $i{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Gx]=this.setBlend,this.map[Ux]=this.setOffset,this.map[Ox]=this.setCullFace,this.map[Dx]=this.setDepthTest,this.map[Lx]=this.setFrontFace,this.map[Nx]=this.setDepthMask,this.checks=[],this.defaultState=Ze.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=Fx(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($i._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck($i._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}};qc.extension={type:[b.WebGLSystem],name:"state"};let Wx=qc;class Hx{constructor(e){this.target=Wn.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=Z.UNSIGNED_BYTE,this.internalFormat=Xi.RGBA,this.format=Xi.RGBA,this.samplerType=0}destroy(){}}const zx={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},Xx={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)}}},za=["right","left","top","bottom","front","back"];function $x(r){return{id:"cube",upload(e,t,s,i){const n=e.faces;for(let o=0;o<za.length;o++){const a=za[o],l=n[a];(r[l.uploadMethodId]||r.image).upload(l,t,s,i,Wn.TEXTURE_CUBE_MAP_POSITIVE_X+o,(t._layerInitMask&1<<o)===0),t._layerInitMask|=1<<o}t.width=e.pixelWidth,t.height=e.pixelHeight}}}const Kc={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?jx:Yx)(t,o,e,a,l,h,c,p,d,f),e.width=a,e.height=l}};function jx(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 Yx(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 qx=x_(),Kx={id:"video",upload(r,e,t,s,i,n=qx){if(!r.isValid){const o=i??e.target;t.texImage2D(o,0,e.internalFormat,1,1,0,e.format,e.type,null);return}Kc.upload(r,e,t,s,i,n)}},Va={linear:9729,nearest:9728},Zx={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},_i={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Qx={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Xa(r,e,t,s,i,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const h=_i[o?"clamp-to-edge":r.addressModeU],c=_i[o?"clamp-to-edge":r.addressModeV],u=_i[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,Va[r.magFilter]),t){if(!a||r.mipmapFilter!=="linear"){const h=Zx[r.minFilter][r.mipmapFilter];e[i](l,e.TEXTURE_MIN_FILTER,h)}}else e[i](l,e.TEXTURE_MIN_FILTER,Va[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,Qx[r.compare])}function Jx(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 ey(r,e){let t={},s=r.RGBA;return r instanceof V.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 ty(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 sy(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 ry=4;class Zc{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 ze({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const t={image:Kc,buffer:zx,video:Kx,compressed:Xx};this._uploads={...t,cube:$x(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=ey(e,this._renderer.context.extensions),this._mapFormatToType=ty(e),this._mapFormatToFormat=Jx(e),this._mapViewDimensionToGlTarget=sy(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(U.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=U.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 Hx(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,Xa(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,Xa(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=V.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(ry*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(U.EMPTY.source),this._boundSamplers=Object.create(null);const e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Zc.extension={type:[b.WebGLSystem],name:"texture"};class Qc{contextChange(e){const t=new Re({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new F,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),s=e.limits.maxBatchableTextures,i=Pr({name:"graphics",bits:[th,rh(s),_n,Mr]});this.shader=new Ke({glProgram:i,resources:{localUniforms:t,batchSamplers:ih(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}}Qc.extension={type:[b.WebGLPipesAdaptor],name:"graphics"};class Jc{init(){const e=Pr({name:"mesh",bits:[_n,v_,Mr]});this._shader=new Ke({glProgram:e,resources:{uTexture:U.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new F}}}})}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}}Jc.extension={type:[b.WebGLPipesAdaptor],name:"mesh"};const iy=[...Dn,zc,mx,hx,Oc,Rc,Zc,Vc,Ic,Yc,jc,Uc,Wx,Dc,Gc],ny=[...wc],oy=[Jh,Jc,Qc],eu=[],tu=[],su=[];H.handleByNamedList(b.WebGLSystem,eu);H.handleByNamedList(b.WebGLPipes,tu);H.handleByNamedList(b.WebGLPipesAdaptor,su);H.add(...iy,...ny,...oy);class ay extends Gs{constructor(){const e={name:"webgl",type:Se.WEBGL,systems:eu,renderPipes:tu,renderPipeAdaptors:su};super(e)}}const ly=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:ay},Symbol.toStringTag,{value:"Module"}));class ru{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}}ru.extension={type:[b.WebGPUSystem],name:"bindGroup"};class hy{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class iu{constructor(e){this._renderer=e,this._managedBuffers=new ze({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=ne("resource"),e.data&&(Ii(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new hy(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}}iu.extension={type:[b.WebGPUSystem],name:"buffer"};class cy{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 nu{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}}nu.extension={type:[b.WebGPUSystem],name:"colorMask"};class Vn{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 V.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}}Vn.extension={type:[b.WebGPUSystem],name:"device"};Vn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class ou{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}}ou.extension={type:[b.WebGPUSystem],name:"encoder",priority:1};class au{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}au.extension={type:[b.WebGPUSystem],name:"limits"};class lu{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:pe.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}}lu.extension={type:[b.WebGPUSystem],name:"stencil"};const ur={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 uy(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=ur[i.data.type].size;const o=ur[i.data.type].align;if(!ur[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 dy(r,e){const{size:t,align:s}=ur[r.data.type],i=(s-t)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
1241
|
+
v = uv.${r.data.name};
|
|
1242
|
+
${e!==0?`offset += ${e};`:""}
|
|
1243
|
+
|
|
1244
|
+
arrayOffset = offset;
|
|
1245
|
+
|
|
1246
|
+
t = 0;
|
|
1247
|
+
|
|
1248
|
+
for(var i=0; i < ${r.data.size*(t/4)}; i++)
|
|
1249
|
+
{
|
|
1250
|
+
for(var j = 0; j < ${t/4}; j++)
|
|
1251
|
+
{
|
|
1252
|
+
${n}[arrayOffset++] = v[t++];
|
|
1253
|
+
}
|
|
1254
|
+
${i!==0?`arrayOffset += ${i};`:""}
|
|
1255
|
+
}
|
|
1256
|
+
`}function fy(r){return Wc(r,"uboWgsl",dy,xx)}class hu extends Lc{constructor(){super({createUboElements:uy,generateUboSync:fy})}}hu.extension={type:[b.WebGPUSystem],name:"ubo"};const ht=128;class cu{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new cy({minUniformOffsetAlignment:ht});const t=256/ht;for(let s=0;s<t;s++){let i=Q.UNIFORM|Q.COPY_DST;s===0&&(i|=Q.COPY_SRC),this._buffers.push(new He({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/ht),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/ht)}getArrayBindGroup(e){const t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/ht)}getArrayBufferResource(e){const s=this._batchBuffer.addGroup(e)/ht;return this._getBufferResource(s)}_getBufferResource(e){if(!this._bufferResources[e]){const t=this._buffers[e%2];this._bufferResources[e]=new zn({buffer:t,offset:(e/2|0)*256,size:ht})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){const t=new ut({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),ht,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}}cu.extension={type:[b.WebGPUPipes],name:"uniformBatch"};const py={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function my(r,e,t,s,i){return r<<24|e<<16|t<<10|s<<5|i}function gy(r,e,t,s,i){return t<<8|r<<5|s<<3|i<<1|e}class uu{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(pe.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=mt[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||(kc(e,t.attributeData),this._generateBufferKey(e)),i||(i=e.topology);const n=my(e._layoutKey,t._layoutKey,s.data,s._blendModeId,py[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===pe.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=As(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=As(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=gy(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}}uu.extension={type:[b.WebGPUSystem],name:"pipeline"};class _y{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class xy{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?Pe.ALL:Pe.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&Pe.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&Pe.STENCIL?"clear":"load",d=t&Pe.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 _y;return t.colorTargetCount=e.colorTextures.length,e.colorTextures.forEach((s,i)=>{if(s instanceof Ye){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 ge({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 du extends Ln{constructor(e){super(e),this.adaptor=new xy,this.adaptor.init(e,this)}}du.extension={type:[b.WebGPUSystem],name:"renderTarget"};class fu{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}}fu.extension={type:[b.WebGPUSystem],name:"shader"};const we={};we.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};we.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}};we.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}};we.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};we.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};we.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}};we["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}};we["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}};we["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}};we.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};we.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}};we.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class pu{constructor(){this.defaultState=new Ze,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t){const s=we[e.blendMode]||we.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}}pu.extension={type:[b.WebGPUSystem],name:"state"};const yy={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})}},mu={"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}},by={blockBytes:4,blockWidth:1,blockHeight:1},vy={type:"compressed",upload(r,e,t,s=0){let i=r.pixelWidth,n=r.pixelHeight;const o=mu[r.format]||by;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)}}},$a=["right","left","top","bottom","front","back"];function Ty(r){return{type:"cube",upload(e,t,s){const i=e.faces;for(let n=0;n<$a.length;n++){const o=$a[n],a=i[o];(r[a.uploadMethodId]||r.image).upload(a,t,s,n)}}}}const gu={type:"image",upload(r,e,t,s=0){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const l=V.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})}},Sy={type:"video",upload(r,e,t,s){gu.upload(r,e,t,s)}};class wy{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:`
|
|
1257
|
+
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
1258
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
|
1259
|
+
|
|
1260
|
+
struct VertexOutput {
|
|
1261
|
+
@builtin(position) position : vec4<f32>,
|
|
1262
|
+
@location(0) texCoord : vec2<f32>,
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1265
|
+
@vertex
|
|
1266
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
|
1267
|
+
var output : VertexOutput;
|
|
1268
|
+
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
|
1269
|
+
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
|
1270
|
+
return output;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
@group(0) @binding(0) var imgSampler : sampler;
|
|
1274
|
+
@group(0) @binding(1) var img : texture_2d<f32>;
|
|
1275
|
+
|
|
1276
|
+
@fragment
|
|
1277
|
+
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
1278
|
+
return textureSample(img, imgSampler, texCoord);
|
|
1279
|
+
}
|
|
1280
|
+
`})),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 Cy{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class _u{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new ze({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const t={image:gu,buffer:yy,video:Sy,compressed:vy};this._uploads={...t,cube:Ty(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=mu[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 Cy(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 wy(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 ut({0:t,1:t.style,2:new Re({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=V.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:V.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=dt.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 dt.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}}_u.extension={type:[b.WebGPUSystem],name:"texture"};class xu{constructor(){this._maxTextures=0}contextChange(e){const t=new Re({uTransformMatrix:{value:new F,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=Ar({name:"graphics",bits:[eh,sh(this._maxTextures),Mg,Er]});this.shader=new Ke({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=rn(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}}xu.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"};class yu{init(){const e=Ar({name:"mesh",bits:[ws,b_,Er]});this._shader=new Ke({gpuProgram:e,resources:{uTexture:U.EMPTY._source,uSampler:U.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new F}}}})}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}}yu.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"};const Ay=[...Dn,hu,ou,Vn,au,iu,_u,du,fu,pu,uu,nu,lu,ru],Py=[...wc,cu],Ey=[ec,yu,xu],bu=[],vu=[],Tu=[];H.handleByNamedList(b.WebGPUSystem,bu);H.handleByNamedList(b.WebGPUPipes,vu);H.handleByNamedList(b.WebGPUPipesAdaptor,Tu);H.add(...Ay,...Py,...Ey);class My extends Gs{constructor(){const e={name:"webgpu",type:Se.WEBGPU,systems:bu,renderPipes:vu,renderPipeAdaptors:Tu};super(e)}}const Ry=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:My},Symbol.toStringTag,{value:"Module"}));class By extends Kh{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=j.transformRectCoords(o,a,h,new ee),u=new U({frame:c,orig:new ee(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){Ga.install(e)}static uninstall(e){Ga.uninstall(e)}}const ky=Object.freeze(Object.defineProperty({__proto__:null,BitmapFont:By},Symbol.toStringTag,{value:"Module"}));H.add(Pu,Eu);H.add(Ud);H.mixin(Te,Od);H.add(xh);H.add(yh);H.mixin(Te,rg);H.add(Bh,Sh);H.add(Rh);const Iy=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Fy=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{wf as A,pg as B,Fe as C,br as G,Uy as N,J as P,ee as R,Qt as S,Dy as T,jt as _,Qs as a,Te as b,Bt as c,U as d,Oy as e};
|