screeps-client 0.3.2 → 0.3.3
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/assets/{CodePanel-GQ1H2o0G.js → CodePanel-BPalm7GH.js} +1 -1
- package/dist/{standalone/assets/MapViewer-DCxUvxoA.js → embedded/assets/MapViewer-sspEY1OS.js} +1 -1
- package/dist/embedded/assets/index-AMOP6Cjq.js +9 -0
- package/dist/{standalone/assets/vendor-codemirror-BbK0dVBs.js → embedded/assets/vendor-codemirror-D3PB7yT8.js} +13 -13
- package/dist/embedded/assets/vendor-pixi-Do7-_WYv.js +1160 -0
- package/dist/embedded/index.html +3 -3
- package/dist/standalone/assets/{CodePanel-HJOOsWME.js → CodePanel-CRqfH48W.js} +1 -1
- package/dist/{embedded/assets/MapViewer-wKjEVvA4.js → standalone/assets/MapViewer-CY4zWpjR.js} +1 -1
- package/dist/standalone/assets/index-Ct25GErL.js +9 -0
- package/dist/{xxscreeps-mod/assets/vendor-codemirror-BbK0dVBs.js → standalone/assets/vendor-codemirror-D3PB7yT8.js} +13 -13
- package/dist/standalone/assets/vendor-pixi-CXkRT4gi.js +1160 -0
- package/dist/standalone/index.html +3 -3
- package/dist/xxscreeps-mod/assets/{CodePanel-B3_bJRI_.js → CodePanel-CT25L3sq.js} +1 -1
- package/dist/xxscreeps-mod/assets/{MapViewer-DnXokgth.js → MapViewer-BPHjWJtJ.js} +1 -1
- package/dist/xxscreeps-mod/assets/index-BvL-GrqB.js +9 -0
- package/dist/{embedded/assets/vendor-codemirror-BbK0dVBs.js → xxscreeps-mod/assets/vendor-codemirror-D3PB7yT8.js} +13 -13
- package/dist/xxscreeps-mod/assets/vendor-pixi-CXkRT4gi.js +1160 -0
- package/dist/xxscreeps-mod/index.html +3 -3
- package/package.json +1 -1
- package/dist/embedded/assets/index-D_SIG01E.js +0 -4
- package/dist/embedded/assets/vendor-pixi-c1qrZX58.js +0 -906
- package/dist/standalone/assets/index-DcGHdH7Q.js +0 -4
- package/dist/standalone/assets/vendor-pixi-CqiKBxHw.js +0 -906
- package/dist/xxscreeps-mod/assets/index-DW5Xg-6n.js +0 -4
- package/dist/xxscreeps-mod/assets/vendor-pixi-CqiKBxHw.js +0 -906
|
@@ -0,0 +1,1160 @@
|
|
|
1
|
+
const Rc="modulepreload",Bc=function(s){return"/"+s},vn={},nr=function(e,t,r){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=Bc(h),h in vn)return;vn[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":Rc,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=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(b||{});const Ws=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Cr=(s,e)=>Ws(s).priority??e,W={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Ws).forEach(e=>{e.type.forEach(t=>{var r,i;return(i=(r=this._removeHandlers)[t])==null?void 0:i.call(r,e)})}),this},add(...s){return s.map(Ws).forEach(e=>{e.type.forEach(t=>{var n,o;const r=this._addHandlers,i=this._queue;r[t]?(o=r[t])==null||o.call(r,e):(i[t]=i[t]||[],(n=i[t])==null||n.push(e))})}),this},handle(s,e,t){var o;const r=this._addHandlers,i=this._removeHandlers;if(r[s]||i[s])throw new Error(`Extension type ${s} already has a handler`);r[s]=e,i[s]=t;const n=this._queue;return n[s]&&((o=n[s])==null||o.forEach(a=>e(a)),delete n[s]),this},handleByMap(s,e){return this.handle(s,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(s,e,t=-1){return this.handle(s,r=>{e.findIndex(n=>n.name===r.name)>=0||(e.push({name:r.name,value:r.ref}),e.sort((n,o)=>Cr(o.value,t)-Cr(n.value,t)))},r=>{const i=e.findIndex(n=>n.name===r.name);i!==-1&&e.splice(i,1)})},handleByList(s,e,t=-1){return this.handle(s,r=>{e.includes(r.ref)||(e.push(r.ref),e.sort((i,n)=>Cr(n,t)-Cr(i,t)))},r=>{const i=e.indexOf(r.ref);i!==-1&&e.splice(i,1)})},mixin(s,...e){for(const t of e)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(t))}},kc={extension:{type:b.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await nr(()=>Promise.resolve().then(()=>B_),void 0)}},Ic={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await nr(()=>Promise.resolve().then(()=>k_),void 0)}};class _e{constructor(e,t,r){this._x=t||0,this._y=r||0,this._observer=e}clone(e){return new _e(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 ha(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var hs={exports:{}},Tn;function Gc(){return Tn||(Tn=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__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 r:delete l._events[h]}function a(){this._events=new r,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 v=m.length,S;for(y=0;y<v;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 r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,s.exports=a})(hs)),hs.exports}var Fc=Gc();const ke=ha(Fc),Uc=Math.PI*2,Dc=180/Math.PI,Oc=Math.PI/180;class re{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new re(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 cs.x=0,cs.y=0,cs}}const cs=new re;class G{constructor(e=1,t=0,r=0,i=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=r,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,r,i,n,o){return this.a=e,this.b=t,this.c=r,this.d=i,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const r=t||this.array;return e?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(e,t){t=t||new re;const r=e.x,i=e.y;return t.x=this.a*r+this.c*i+this.tx,t.y=this.b*r+this.d*i+this.ty,t}applyInverse(e,t){t=t||new re;const r=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(r*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=r*h*u+-i*h*c+(-l*r+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),r=Math.sin(e),i=this.a,n=this.c,o=this.tx;return this.a=i*t-this.b*r,this.b=i*r+this.b*t,this.c=n*t-this.d*r,this.d=n*r+this.d*t,this.tx=o*t-this.ty*r,this.ty=o*r+this.ty*t,this}append(e){const t=this.a,r=this.b,i=this.c,n=this.d;return this.a=e.a*t+e.b*i,this.b=e.a*r+e.b*n,this.c=e.c*t+e.d*i,this.d=e.c*r+e.d*n,this.tx=e.tx*t+e.ty*i+this.tx,this.ty=e.tx*r+e.ty*n+this.ty,this}appendFrom(e,t){const r=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=r*h+i*u,this.b=r*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,r,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-(r*this.a+i*this.c),this.ty=t-(r*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 r=this.a,i=this.c;this.a=r*e.a+this.b*e.c,this.b=r*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,r=this.b,i=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-i,n),l=Math.atan2(r,t),h=Math.abs(a+l);return h<1e-5||Math.abs(Uc-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+r*r),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*r+o.y*n),e}invert(){const e=this.a,t=this.b,r=this.c,i=this.d,n=this.tx,o=e*i-t*r;return this.a=i/o,this.b=-t/o,this.c=-r/o,this.d=e/o,this.tx=(r*this.ty-i*n)/o,this.ty=-(e*this.ty-t*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new G;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Nc.identity()}static get shared(){return Lc.identity()}}const Lc=new G,Nc=new G,ct=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ut=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],dt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ft=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],zs=[],ca=[],wr=Math.sign;function Hc(){for(let s=0;s<16;s++){const e=[];zs.push(e);for(let t=0;t<16;t++){const r=wr(ct[s]*ct[t]+dt[s]*ut[t]),i=wr(ut[s]*ct[t]+ft[s]*ut[t]),n=wr(ct[s]*dt[t]+dt[s]*ft[t]),o=wr(ut[s]*dt[t]+ft[s]*ft[t]);for(let a=0;a<16;a++)if(ct[a]===r&&ut[a]===i&&dt[a]===n&&ft[a]===o){e.push(a);break}}}for(let s=0;s<16;s++){const e=new G;e.set(ct[s],ut[s],dt[s],ft[s],0,0),ca.push(e)}}Hc();const $={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>ct[s],uY:s=>ut[s],vX:s=>dt[s],vY:s=>ft[s],inv:s=>s&8?s&15:-s&7,add:(s,e)=>zs[s][e],sub:(s,e)=>zs[s][$.inv(e)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,e)=>Math.abs(s)*2<=Math.abs(e)?e>=0?$.S:$.N:Math.abs(e)*2<=Math.abs(s)?s>0?$.E:$.W:e>0?s>0?$.SE:$.SW:s>0?$.NE:$.NW,matrixAppendRotationInv:(s,e,t=0,r=0,i=0,n=0)=>{const o=ca[$.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=r-Math.min(0,l*i,c*n,l*i+c*n),f=s.a,p=s.b,g=s.c,m=s.d;s.a=a*f+l*g,s.b=a*p+l*m,s.c=h*f+c*g,s.d=h*p+c*m,s.tx=u*f+d*g+s.tx,s.ty=u*p+d*m+s.ty},transformRectCoords:(s,e,t,r)=>{const{x:i,y:n,width:o,height:a}=s,{x:l,y:h,width:c,height:u}=e;return t===$.E?(r.set(i+l,n+h,o,a),r):t===$.S?r.set(c-n-a+l,i+h,a,o):t===$.W?r.set(c-i-o+l,u-n-a+h,o,a):t===$.N?r.set(n+l,u-i-o+h,a,o):r.set(i+l,n+h,o,a)}},Pr=[new re,new re,new re,new re];class ee{constructor(e=0,t=0,r=0,i=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(r),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,r,i=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,h=r*(1-i),c=r-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 B=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=B)return!1;const w=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>w}const r=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=r||o<=n)return!1;const a=Pr[0].set(e.left,e.top),l=Pr[1].set(e.left,e.bottom),h=Pr[2].set(e.right,e.top),c=Pr[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)<=r||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*r+f*n,g=d*i+f*n,m=d*r+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),v=x*r+y*n,S=x*i+y*n,T=x*r+y*o,C=x*i+y*o;return!(Math.max(v,S,T,C)<=x*a.x+y*a.y||Math.min(v,S,T,C)>=x*c.x+y*c.y)}pad(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),r=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(r-t,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(e=1,t=.001){const r=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=r-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),r=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=r-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,r=e.y,i=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<this.x+this.width&&r>=this.y&&r<this.y+this.height&&i>=this.x&&i<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(e,t,r,i){return this.x=e,this.y=t,this.width=r,this.height=i,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const us={default:-1};function te(s="default"){return us[s]===void 0&&(us[s]=-1),++us[s]}const Sn=new Set,ie="8.0.0",Wc="8.3.4",Ft={quiet:!1,noColor:!1},O=((s,e,t=3)=>{if(Ft.quiet||Sn.has(e))return;let r=new Error().stack;const i=`${e}
|
|
2
|
+
Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!Ft.noColor;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",i):(r=r.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(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(r))),Sn.add(e)});Object.defineProperties(O,{quiet:{get:()=>Ft.quiet,set:s=>{Ft.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>Ft.noColor,set:s=>{Ft.noColor=s},enumerable:!0,configurable:!1}});const ua=()=>{};function Lt(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Cn(s){return!(s&s-1)&&!!s}function da(s){const e={};for(const t in s)s[t]!==void 0&&(e[t]=s[t]);return e}const wn=Object.create(null);function zc(s){const e=wn[s];return e===void 0&&(wn[s]=te("resource")),e}const fa=class pa extends ke{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...pa.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){O(ie,"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=zc(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};fa.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let yt=fa;const ma=class ga extends ke{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=te("textureSource"),this._resourceType="textureSource",this._resourceId=te("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={...ga.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 yt(da(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){var t,r;this.style!==e&&((t=this._style)==null||t.off("change",this._onStyleChange,this),this._style=e,(r=this._style)==null||r.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=te("resource"),this.emit("change",this),this.emit("unload",this);for(const r in this._gpuData)(t=(e=this._gpuData[r])==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,r){r||(r=this._resolution),e||(e=this.width),t||(t=this.height);const i=Math.round(e*r),n=Math.round(t*r);return this.width=i/r,this.height=n/r,this._resolution=r,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=te("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=Cn(this.pixelWidth)&&Cn(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};ma.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 pe=ma;class mi extends pe{constructor(e){const t=e.resource||new Float32Array(e.width*e.height*4);let r=e.format;r||(t instanceof Float32Array?r="rgba32float":t instanceof Int32Array||t instanceof Uint32Array?r="rgba32uint":t instanceof Int16Array||t instanceof Uint16Array?r="rgba16uint":(t instanceof Int8Array,r="bgra8unorm")),super({...e,resource:t,format:r}),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}}mi.extension=b.TextureSource;const Pn=new G;class _a{constructor(e,t){this.mapCoord=new G,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var t;this._texture!==e&&((t=this._texture)==null||t.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(e,t){t===void 0&&(t=e);const r=this.mapCoord;for(let i=0;i<e.length;i+=2){const n=e[i],o=e[i+1];t[i]=n*r.a+o*r.c+r.tx,t[i+1]=n*r.b+o*r.d+r.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 r=e.orig,i=e.trim;i&&(Pn.set(r.width/i.width,0,0,r.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(Pn));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 N extends ke{constructor({source:e,label:t,frame:r,orig:i,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=te("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 pe,this.noFrame=!r,r)this.frame.copyFrom(r);else{const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u}this.orig=i||this.frame,this.trim=n,this.rotate=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=h||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new _a(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:r,height:i}=this._source,n=t.x/r,o=t.y/i,a=t.width/r,l=t.height/i;let h=this.rotate;if(h){const c=a/2,u=l/2,d=n+c,f=o+u;h=$.add(h,$.NW),e.x0=d+c*$.uX(h),e.y0=f+u*$.uY(h),h=$.add(h,2),e.x1=d+c*$.uX(h),e.y1=f+u*$.uY(h),h=$.add(h,2),e.x2=d+c*$.uX(h),e.y2=f+u*$.uY(h),h=$.add(h,2),e.x3=d+c*$.uX(h),e.y3=f+u*$.uY(h)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+l,e.x3=n,e.y3=o+l}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return O(ie,"Texture.baseTexture is now Texture.source"),this._source}}N.EMPTY=new N({label:"EMPTY",source:new pe({label:"EMPTY"})});N.EMPTY.destroy=ua;N.WHITE=new N({source:new mi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});N.WHITE.destroy=ua;function xa(s,e,t){const{width:r,height:i}=t.orig,n=t.trim;if(n){const o=n.width,a=n.height;s.minX=n.x-e._x*r,s.maxX=s.minX+o,s.minY=n.y-e._y*i,s.maxY=s.minY+a}else s.minX=-e._x*r,s.maxX=s.minX+r,s.minY=-e._y*i,s.maxY=s.minY+i}const En=new G;class xe{constructor(e=1/0,t=1/0,r=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=En,this.minX=e,this.minY=t,this.maxX=r,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=En,this}set(e,t,r,i){this.minX=e,this.minY=t,this.maxX=r,this.maxY=i}addFrame(e,t,r,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*r+l*t+c,_=a*r+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*r+l*i+c,_=a*r+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,r=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*r+c,f=a*t+h*r+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=o*i+l*r+c,f=a*i+h*r+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=o*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,r,i){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<r&&(this.minY=r),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 xe(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,r,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<r;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 Vc={grad:.9,turn:360,rad:360/(2*Math.PI)},Ve=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},me=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*s)/t+0},Ae=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),s>t?t:s>e?s:e},ya=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Mn=function(s){return{r:Ae(s.r,0,255),g:Ae(s.g,0,255),b:Ae(s.b,0,255),a:Ae(s.a)}},ds=function(s){return{r:me(s.r),g:me(s.g),b:me(s.b),a:me(s.a,3)}},Xc=/^#([0-9a-f]{3,8})$/i,Er=function(s){var e=s.toString(16);return e.length<2?"0"+e:e},ba=function(s){var e=s.r,t=s.g,r=s.b,i=s.a,n=Math.max(e,t,r),o=n-Math.min(e,t,r),a=o?n===e?(t-r)/o:n===t?2+(r-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}},va=function(s){var e=s.h,t=s.s,r=s.v,i=s.a;e=e/360*6,t/=100,r/=100;var n=Math.floor(e),o=r*(1-t),a=r*(1-(e-n)*t),l=r*(1-(1-e+n)*t),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:i}},An=function(s){return{h:ya(s.h),s:Ae(s.s,0,100),l:Ae(s.l,0,100),a:Ae(s.a)}},Rn=function(s){return{h:me(s.h),s:me(s.s),l:me(s.l),a:me(s.a,3)}},Bn=function(s){return va((t=(e=s).s,{h:e.h,s:(t*=((r=e.l)<50?r:100-r)/100)>0?2*t/(r+t)*100:0,v:r+t,a:e.a}));var e,t,r},or=function(s){return{h:(e=ba(s)).h,s:(i=(200-(t=e.s))*(r=e.v)/100)>0&&i<200?t*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,t,r,i},$c=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vs={string:[[function(s){var e=Xc.exec(s);return e?(s=e[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?me(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?me(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var e=jc.exec(s)||qc.exec(s);return e?e[2]!==e[4]||e[4]!==e[6]?null:Mn({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(s){var e=$c.exec(s)||Yc.exec(s);if(!e)return null;var t,r,i=An({h:(t=e[1],r=e[2],r===void 0&&(r="deg"),Number(t)*(Vc[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Bn(i)},"hsl"]],object:[[function(s){var e=s.r,t=s.g,r=s.b,i=s.a,n=i===void 0?1:i;return Ve(e)&&Ve(t)&&Ve(r)?Mn({r:Number(e),g:Number(t),b:Number(r),a:Number(n)}):null},"rgb"],[function(s){var e=s.h,t=s.s,r=s.l,i=s.a,n=i===void 0?1:i;if(!Ve(e)||!Ve(t)||!Ve(r))return null;var o=An({h:Number(e),s:Number(t),l:Number(r),a:Number(n)});return Bn(o)},"hsl"],[function(s){var e=s.h,t=s.s,r=s.v,i=s.a,n=i===void 0?1:i;if(!Ve(e)||!Ve(t)||!Ve(r))return null;var o=(function(a){return{h:ya(a.h),s:Ae(a.s,0,100),v:Ae(a.v,0,100),a:Ae(a.a)}})({h:Number(e),s:Number(t),v:Number(r),a:Number(n)});return va(o)},"hsv"]]},kn=function(s,e){for(var t=0;t<e.length;t++){var r=e[t][0](s);if(r)return[r,e[t][1]]}return[null,void 0]},Kc=function(s){return typeof s=="string"?kn(s.trim(),Vs.string):typeof s=="object"&&s!==null?kn(s,Vs.object):[null,void 0]},fs=function(s,e){var t=or(s);return{h:t.h,s:Ae(t.s+100*e,0,100),l:t.l,a:t.a}},ps=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},In=function(s,e){var t=or(s);return{h:t.h,s:t.s,l:Ae(t.l+100*e,0,100),a:t.a}},Xs=(function(){function s(e){this.parsed=Kc(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return me(ps(this.rgba),2)},s.prototype.isDark=function(){return ps(this.rgba)<.5},s.prototype.isLight=function(){return ps(this.rgba)>=.5},s.prototype.toHex=function(){return e=ds(this.rgba),t=e.r,r=e.g,i=e.b,o=(n=e.a)<1?Er(me(255*n)):"","#"+Er(t)+Er(r)+Er(i)+o;var e,t,r,i,n,o},s.prototype.toRgb=function(){return ds(this.rgba)},s.prototype.toRgbString=function(){return e=ds(this.rgba),t=e.r,r=e.g,i=e.b,(n=e.a)<1?"rgba("+t+", "+r+", "+i+", "+n+")":"rgb("+t+", "+r+", "+i+")";var e,t,r,i,n},s.prototype.toHsl=function(){return Rn(or(this.rgba))},s.prototype.toHslString=function(){return e=Rn(or(this.rgba)),t=e.h,r=e.s,i=e.l,(n=e.a)<1?"hsla("+t+", "+r+"%, "+i+"%, "+n+")":"hsl("+t+", "+r+"%, "+i+"%)";var e,t,r,i,n},s.prototype.toHsv=function(){return e=ba(this.rgba),{h:me(e.h),s:me(e.s),v:me(e.v),a:me(e.a,3)};var e},s.prototype.invert=function(){return Le({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},s.prototype.saturate=function(e){return e===void 0&&(e=.1),Le(fs(this.rgba,e))},s.prototype.desaturate=function(e){return e===void 0&&(e=.1),Le(fs(this.rgba,-e))},s.prototype.grayscale=function(){return Le(fs(this.rgba,-1))},s.prototype.lighten=function(e){return e===void 0&&(e=.1),Le(In(this.rgba,e))},s.prototype.darken=function(e){return e===void 0&&(e=.1),Le(In(this.rgba,-e))},s.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},s.prototype.alpha=function(e){return typeof e=="number"?Le({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):me(this.rgba.a,3);var t},s.prototype.hue=function(e){var t=or(this.rgba);return typeof e=="number"?Le({h:e,s:t.s,l:t.l,a:t.a}):me(t.h)},s.prototype.isEqual=function(e){return this.toHex()===Le(e).toHex()},s})(),Le=function(s){return s instanceof Xs?s:new Xs(s)},Gn=[],Zc=function(s){s.forEach(function(e){Gn.indexOf(e)<0&&(e(Xs,Vs),Gn.push(e))})};function Qc(s,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"},r={};for(var i in t)r[t[i]]=i;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=r[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 s(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 s(l).toRgb():null},"name"])}Zc([Qc]);const Nt=class rr{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 rr)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 r=typeof e;if(r!==typeof t)return!1;if(r==="number"||r==="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,r,i]=this._components;return{r:e,g:t,b:r,a:i}}toRgb(){const[e,t,r]=this._components;return{r:e,g:t,b:r}}toRgbaString(){const[e,t,r]=this.toUint8RgbArray();return`rgba(${e},${t},${r},${this.alpha})`}toUint8RgbArray(e){const[t,r,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(r*255),e[2]=Math.round(i*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,r,i,n]=this._components;return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,r,i]=this._components;return e[0]=t,e[1]=r,e[2]=i,e}toNumber(){return this._int}toBgrNumber(){const[e,t,r]=this.toUint8RgbArray();return(r<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,r,i,n]=rr._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=r,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 r=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return t&&(r=r*e+.5|0,i=i*e+.5|0,n=n*e+.5|0),(e*255<<24)+(r<<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,r,i,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,r=(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,r,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,r,i,n=255]=e,t/=255,r/=255,i/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=rr.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=Le(e);o.isValid()&&({r:t,g:r,b:i,a:n}=o.rgba,t/=255,r/=255,i/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=r,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,r]=this._components;this._int=(e*255<<16)+(t*255<<8)+(r*255|0)}_clamp(e,t=0,r=1){return typeof e=="number"?Math.min(Math.max(e,t),r):(e.forEach((i,n)=>{e[n]=Math.min(Math.max(i,t),r)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof rr||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}};Nt.shared=new Nt;Nt._temp=new Nt;Nt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Q=Nt;const Jc={cullArea:null,cullable:!1,cullableChildren:!0};let ms=0;const Fn=500;function z(...s){ms!==Fn&&(ms++,ms===Fn?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}const $t={_registeredResources:new Set,register(s){this._registeredResources.add(s)},unregister(s){this._registeredResources.delete(s)},release(){this._registeredResources.forEach(s=>s.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear()}};class eu{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 r;let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),(r=t.init)==null||r.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 tu{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 eu(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const r=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[r]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const ge=new tu;$t.register(ge);const ru={get isCachedAsTexture(){var s;return!!((s=this.renderGroup)!=null&&s.isCachedAsTexture)},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){var s;(s=this.renderGroup)==null||s.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){O("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function Ta(s,e,t){const r=s.length;let i;if(e>=r||t===0)return;t=e+t>r?r-e:t;const n=r-t;for(i=e;i<n;++i)s[i]=s[i+t];s.length=n}const su={allowChildren:!0,removeChildren(s=0,e){var n;const t=e??this.children.length,r=t-s,i=[];if(r>0&&r<=t){for(let a=t-1;a>=s;a--){const l=this.children[a];l&&(i.push(l),l.parent=null)}Ta(this.children,s,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(r===0&&this.children.length===0)return i;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const e=this.getChildAt(s);return this.removeChild(e)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,e)},getChildIndex(s){const e=this.children.indexOf(s);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(s,e){this.allowChildren||O(ie,"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(`${s}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);const r=s.parent===this;if(s.parent){const n=s.parent.children.indexOf(s);if(r){if(n===e)return s;s.parent.children.splice(n,1)}else s.removeFromParent()}e===t.length?t.push(s):t.splice(e,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),r||(this.emit("childAdded",s,this,e),s.emit("added",this)),s},swapChildren(s,e){if(s===e)return;const t=this.getChildIndex(s),r=this.getChildIndex(e);this.children[t]=e,this.children[r]=s;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(e=>this.reparentChildAt(e,this.children.length)),s[0])},reparentChildAt(s,e){if(s.parent===this)return this.setChildIndex(s,e),s;const t=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,e);const r=this.worldTransform.clone();return r.invert(),t.prepend(r),s.setFromMatrix(t),s},replaceChild(s,e){s.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(s)),e.setFromMatrix(s.localTransform),e.updateLocalTransform(),this.removeChild(s)}},iu={collectRenderables(s,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,e,t))},collectRenderablesSimple(s,e,t){const r=this.children,i=r.length;for(let n=0;n<i;n++)r[n].collectRenderables(s,e,t)},collectRenderablesWithEffects(s,e,t){const{renderPipes:r}=e;for(let i=0;i<this.effects.length;i++){const n=this.effects[i];r[n.pipe].push(n,this,s)}this.collectRenderablesSimple(s,e,t);for(let i=this.effects.length-1;i>=0;i--){const n=this.effects[i];r[n.pipe].pop(n,this,s)}}};class jr{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 nu{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 r=this._tests[t];if(r.test(e))return ge.get(r.maskClass,e)}return e}returnMaskEffect(e){ge.return(e)}}const $s=new nu;W.handleByList(b.MaskEffect,$s._effectClasses);const ou={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)},addEffect(s){this.effects.indexOf(s)===-1&&(this.effects.push(s),this.effects.sort((t,r)=>t.priority-r.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){const e=this.effects.indexOf(s);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){const e=this._maskEffect;(e==null?void 0:e.mask)!==s&&(e&&(this.removeEffect(e),$s.returnMaskEffect(e),this._maskEffect=null),s!=null&&(this._maskEffect=$s.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const e=this._filterEffect||(this._filterEffect=new jr);s=s;const t=(s==null?void 0:s.length)>0,r=((n=e.filters)==null?void 0:n.length)>0,i=t!==r;s=Array.isArray(s)?s.slice(0):s,e.filters=Object.freeze(s),i&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new jr),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},au={label:null,get name(){return O(ie,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){O(ie,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,e=!1){return this.getChildByLabel(s,e)},getChildByLabel(s,e=!1){const t=this.children;for(let r=0;r<t.length;r++){const i=t[r];if(i.label===s||s instanceof RegExp&&s.test(i.label))return i}if(e)for(let r=0;r<t.length;r++){const n=t[r].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,e=!1,t=[]){const r=this.children;for(let i=0;i<r.length;i++){const n=r[i];(n.label===s||s instanceof RegExp&&s.test(n.label))&&t.push(n)}if(e)for(let i=0;i<r.length;i++)r[i].getChildrenByLabel(s,!0,t);return t}},be=ge.getPool(G),qe=ge.getPool(xe),lu=new G,hu={getFastGlobalBounds(s,e){e||(e=new xe),e.clear(),this._getGlobalBoundsRecursive(!!s,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(s,e,t){let r=e;if(s&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(r=qe.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;r.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(s,r,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,r.applyMatrix(o.worldTransform)),this.effects[a].addBounds(r,!0));n&&r.applyMatrix(o.worldTransform.copyTo(lu).invert()),e.addBounds(r),qe.return(r)}else this.renderGroup&&(e.addBounds(r,this.relativeGroupTransform),qe.return(r))}};function gi(s,e,t){t.clear();let r,i;return s.parent?e?r=s.parent.worldTransform:(i=be.get().identity(),r=_i(s,i)):r=G.IDENTITY,Sa(s,t,r,e),i&&be.return(i),t.isValid||t.set(0,0,0,0),t}function Sa(s,e,t,r){var a,l;if(!s.visible||!s.measurable)return;let i;r?i=s.worldTransform:(s.updateLocalTransform(),i=be.get(),i.appendFrom(s.localTransform,t));const n=e,o=!!s.effects.length;if(o&&(e=qe.get().clear()),s.boundsArea)e.addRect(s.boundsArea,i);else{const h=s.bounds;h&&!h.isEmpty()&&(e.matrix=i,e.addBounds(h));for(let c=0;c<s.children.length;c++)Sa(s.children[c],e,i,r)}if(o){for(let h=0;h<s.effects.length;h++)(l=(a=s.effects[h]).addBounds)==null||l.call(a,e);n.addBounds(e,G.IDENTITY),qe.return(e)}r||be.return(i)}function _i(s,e){const t=s.parent;return t&&(_i(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function Dt(s,e){if(s===16777215||!e)return e;if(e===16777215||!s)return s;const t=s>>16&255,r=s>>8&255,i=s&255,n=e>>16&255,o=e>>8&255,a=e&255,l=t*n/255|0,h=r*o/255|0,c=i*a/255|0;return(l<<16)+(h<<8)+c}const Un=16777215;function qr(s,e){return s===Un?e:e===Un?s:Dt(s,e)}function Ot(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const cu={getGlobalAlpha(s){if(s)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(s=new G,e){if(e)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const t=_i(this,be.get().identity());return s.appendFrom(this.localTransform,t),be.return(t),s},getGlobalTint(s){if(s)return this.renderGroup?Ot(this.renderGroup.worldColor):this.parentRenderGroup?Ot(qr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=qr(e,t.localColor),t=t.parent;return Ot(e)}};function xi(s,e,t){return e.clear(),t||(t=G.IDENTITY),Ca(s,e,t,s,!0),e.isValid||e.set(0,0,0,0),e}function Ca(s,e,t,r,i){var l,h;let n;if(i)n=be.get(),n=t.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const c=s.localTransform;n=be.get(),n.appendFrom(c,t)}const o=e,a=!!s.effects.length;if(a&&(e=qe.get().clear()),s.boundsArea)e.addRect(s.boundsArea,n);else{s.renderPipeId&&(e.matrix=n,e.addBounds(s.bounds));const c=s.children;for(let u=0;u<c.length;u++)Ca(c[u],e,n,r,!1)}if(a){for(let c=0;c<s.effects.length;c++)(h=(l=s.effects[c]).addLocalBounds)==null||h.call(l,e,r);o.addBounds(e,G.IDENTITY),qe.return(e)}be.return(n)}function wa(s,e){const t=s.children;for(let r=0;r<t.length;r++){const i=t[r],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&&wa(i,e)}return e.didChange}const uu=new G,du={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=s/e*t:this.scale.x=t},_setHeight(s,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=s/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new xe});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),wa(this,s),s.didChange&&xi(this,s.localBounds,uu),s.localBounds},getBounds(s,e){return gi(this,s,e||new xe)}},fu={_onRender:null,set onRender(s){const e=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},pu={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,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(mu))}};function mu(s,e){return s._zIndex-e._zIndex}const gu={getGlobalPosition(s=new re,e=!1){return this.parent?this.parent.toGlobal(this._position,s,e):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,e,t=!1){const r=this.getGlobalTransform(be.get(),t);return e=r.apply(s,e),be.return(r),e},toLocal(s,e,t,r){e&&(s=e.toGlobal(s,t,r));const i=this.getGlobalTransform(be.get(),r);return t=i.applyInverse(s,t),be.return(i),t}};class yi{constructor(){this.uid=te("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 _u=0;class xu{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new yt(this.textureOptions)}createTexture(e,t,r,i){const n=new pe({...this.textureOptions,width:e,height:t,resolution:1,antialias:r,autoGarbageCollect:!1,autoGenerateMipmaps:i});return new N({source:n,label:`texturePool_${_u++}`})}getOptimalTexture(e,t,r=1,i,n=!1){let o=Math.ceil(e*r-1e-6),a=Math.ceil(t*r-1e-6);o=Lt(o),a=Lt(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=r,u.source.width=o/r,u.source.height=a/r,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 r=e.source;return this.getOptimalTexture(e.width,e.height,r._resolution,t)}returnTexture(e,t=!1){const r=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[r].push(e)}clear(e){if(e=e!==!1,e)for(const t in this._texturePool){const r=this._texturePool[t];if(r)for(let i=0;i<r.length;i++)r[i].destroy(!0)}this._texturePool={}}}const ce=new xu;$t.register(ce);class Ys{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new G,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new yi,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 r=0;r<t.length;r++){const i=t[r];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(ce.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 r=0;r<t.length;r++)this.addChild(t[r])}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 r=0;r<t.length;r++)this.removeChild(t[r])}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 r=0;r<t.length;r++)this._getChildren(t[r],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;const r=e.children;for(let i=0;i<r.length;i++)this._getChildren(r[i],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new G),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new G),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new G),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function yu(s,e,t={}){for(const r in e)!t[r]&&e[r]!==void 0&&(s[r]=e[r])}const gs=new _e(null),Mr=new _e(null),_s=new _e(null,1,1),Ar=new _e(null),Kr=1,bi=2,ar=4;class ve extends ke{constructor(e={}){var t,r;super(),this.uid=te("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new G,this.relativeGroupTransform=new G,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new _e(this,0,0),this._scale=_s,this._pivot=Mr,this._origin=Ar,this._skew=gs,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=[],yu(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(i=>this.addChild(i)),(r=e.parent)==null||r.addChild(this)}static mixin(e){O("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),W.mixin(ve,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||O(ie,"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],r=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),r&&(r.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,r&&r.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],r=this.children.indexOf(t);return r>-1&&(this._didViewChangeTick++,this.children.splice(r,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,r),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=ge.get(Ys,this),this.groupTransform=G.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),ge.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new G),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*Dc}set angle(e){this.rotation=e*Oc}get pivot(){return this._pivot===Mr&&(this._pivot=new _e(this,0,0)),this._pivot}set pivot(e){this._pivot===Mr&&(this._pivot=new _e(this,0,0),this._origin!==Ar&&z("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===gs&&(this._skew=new _e(this,0,0)),this._skew}set skew(e){this._skew===gs&&(this._skew=new _e(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===_s&&(this._scale=new _e(this,1,1)),this._scale}set scale(e){this._scale===_s&&(this._scale=new _e(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===Ar&&(this._origin=new _e(this,0,0)),this._origin}set origin(e){this._origin===Ar&&(this._origin=new _e(this,0,0),this._pivot!==Mr&&z("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 r=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,r.width),t!==void 0&&this._setHeight(t,r.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,r=this._scale,i=this._pivot,n=this._origin,o=this._position,a=r._x,l=r._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|=Kr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const r=Q.shared.setValue(e??16777215).toBgrNumber();r!==this.localColor&&(this.localColor=r,this._updateFlags|=Kr,this._onUpdate())}get tint(){return Ot(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=bi,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|=ar,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|=ar,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|=ar,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}}W.mixin(ve,su,hu,gu,fu,du,ou,au,pu,Jc,ru,cu,iu);class vi extends ve{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 xe(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:r,y:i}=e;return r>=t.minX&&r<=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,r){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,r);i.blendMode.popBlendMode(e)}}class Ht extends vi{constructor(e=N.EMPTY){e instanceof N&&(e={texture:e});const{texture:t=N.EMPTY,anchor:r,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 _e({_onUpdate:()=>{this.onViewUpdate()}}),r?this.anchor=r: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 N?new Ht(e):new Ht(N.from(e,t))}set texture(e){e||(e=N.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 xa(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return O("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,r=this._bounds,{width:i,height:n}=t.orig;r.minX=-e._x*i,r.maxX=r.minX+i,r.minY=-e._y*n,r.maxY=r.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const r=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(r)}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 bu=new xe;function Pa(s,e,t){const r=bu;s.measurable=!0,gi(s,t,r),e.addBoundsMask(r),s.measurable=!1}function Ea(s,e,t){const r=qe.get();s.measurable=!0;const i=be.get().identity(),n=Ma(s,t,i);xi(s,r,n),s.measurable=!1,e.addBoundsMask(r),be.return(i),qe.return(r)}function Ma(s,e,t){return s?(s!==e&&(Ma(s.parent,e,t),s.updateLocalTransform(),t.append(s.localTransform)),t):(z("Mask bounds, renderable is not inside the root container"),t)}class Aa{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 Ht),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||Pa(this.mask,e,t)}addLocalBounds(e,t){Ea(this.mask,e,t)}containsPoint(e,t){const r=this.mask;return t(r,e)}destroy(){this.reset()}static test(e){return e instanceof Ht}}Aa.extension=b.MaskEffect;class Ra{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"}}Ra.extension=b.MaskEffect;class Ba{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){Pa(this.mask,e,t)}addLocalBounds(e,t){Ea(this.mask,e,t)}containsPoint(e,t){const r=this.mask;return t(r,e)}destroy(){this.reset()}static test(e){return e instanceof ve}}Ba.extension=b.MaskEffect;const vu={createCanvas:(s,e)=>{const t=document.createElement("canvas");return t.width=s,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,e)=>fetch(s,e),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Dn=vu;const Y={get(){return Dn},set(s){Dn=s}};class He extends pe{constructor(e){e.resource||(e.resource=Y.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,r=this._resolution){const i=super.resize(e,t,r);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"))}}He.extension=b.TextureSource;class Zr extends pe{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}}Zr.extension=b.TextureSource;var Wt=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Wt||{});class xs{constructor(e,t=null,r=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=r,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 ka=class Ce{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new xs(null,null,1/0),this.deltaMS=1/Ce.targetFPMS,this.elapsedMS=1/Ce.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,r=Wt.NORMAL){return this._addListener(new xs(e,t,r))}addOnce(e,t,r=Wt.NORMAL){return this._addListener(new xs(e,t,r,!0))}_addListener(e){let t=this._head.next,r=this._head;if(!t)e.connect(r);else{for(;t;){if(e.priority>t.priority){e.connect(r);break}r=t,t=t.next}e.previous||e.connect(r)}return this._startIfPossible(),this}remove(e,t){let r=this._head.next;for(;r;)r.match(e,t)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Ce.targetFPMS;const r=this._head;let i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(Math.max(0,e)/1e3,Ce.targetFPMS);this._maxElapsedMS=1/t,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!Ce._shared){const e=Ce._shared=new Ce;e.autoStart=!0,e._protected=!0}return Ce._shared}static get system(){if(!Ce._system){const e=Ce._system=new Ce;e.autoStart=!0,e._protected=!0}return Ce._system}};ka.targetFPMS=.06;let Re=ka,ys;async function Tu(){return ys??(ys=(async()=>{var o;const e=Y.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 r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);const i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,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(r),(o=e.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ys}const ns=class Ia extends pe{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...Ia.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=Re.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 Tu(),this._load=new Promise((r,i)=>{this.isValid?r(this):(this._resolve=r,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&&(Re.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||(Re.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Re.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};ns.extension=b.TextureSource;ns.defaultOptions={...pe.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};ns.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Su=ns;const kt=(s,e,t=!1)=>(Array.isArray(s)||(s=[s]),e?s.map(r=>typeof r=="string"||t?e(r):r):s);class Cu{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||z(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const r=kt(e);let i;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.test(t)){i=h.getCacheableAssets(r,t);break}}const n=new Map(Object.entries(i||{}));i||r.forEach(l=>{n.set(l,t)});const o=[...n.keys()],a={cacheKeys:o,keys:r};r.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&&z("[Cache] already has key:",l),this._cache.set(l,n.get(l))})}remove(e){if(!this._cacheMap.has(e)){z(`[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 It=new Cu,js=[];W.handleByList(b.TextureSource,js);function Ga(s={}){const e=s&&s.resource,t=e?s.resource:s,r=e?s:{resource:s};for(let i=0;i<js.length;i++){const n=js[i];if(n.test(t))return new n(r)}throw new Error(`Could not find a source type for resource: ${r.resource}`)}function wu(s={},e=!1){const t=s&&s.resource,r=t?s.resource:s,i=t?s:{resource:s};if(!e&&It.has(r))return It.get(r);const n=new N({source:Ga(i)});return n.on("destroy",()=>{It.has(r)&&It.remove(r)}),e||It.set(r,n),n}function Pu(s,e=!1){return typeof s=="string"?It.get(s):s instanceof pe?new N({source:s}):wu(s,e)}N.from=Pu;pe.from=Ga;W.add(Aa,Ra,Ba,Su,Zr,He,mi);var Fa=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Fa||{});function Ge(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function qt(s){return s.split("?")[0].split("#")[0]}function Eu(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mu(s,e,t){return s.replace(new RegExp(Eu(e),"g"),t)}function Au(s,e){let t="",r=0,i=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a<s.length)o=s.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||r!==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="",r=0):(t=t.slice(0,l),r=t.length-1-t.lastIndexOf("/")),i=a,n=0;continue}}else if(t.length===2||t.length===1){t="",r=0,i=a,n=0;continue}}}else t.length>0?t+=`/${s.slice(i+1,a)}`:t=s.slice(i+1,a),r=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return t}const dr={toPosix(s){return Mu(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Ge(s),s=this.toPosix(s);const e=/^file:\/\/\//.exec(s);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(s);return t?t[0]:""},toAbsolute(s,e,t){if(Ge(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const r=qt(this.toPosix(e??Y.get().getBaseUrl())),i=qt(this.toPosix(t??this.rootname(r)));return s=this.toPosix(s),s.startsWith("/")?dr.join(i,s.slice(1)):this.isAbsolute(s)?s:this.join(r,s)},normalize(s){if(Ge(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let e="";const t=s.startsWith("/");this.hasProtocol(s)&&(e=this.rootname(s),s=s.slice(e.length));const r=s.endsWith("/");return s=Au(s),s.length>0&&r&&(s+="/"),t?`/${s}`:e+s},isAbsolute(s){return Ge(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let e;for(let t=0;t<s.length;++t){const r=s[t];if(Ge(r),r.length>0)if(e===void 0)e=r;else{const i=s[t-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?e+=`/../${r}`:e+=`/${r}`}}return e===void 0?".":this.normalize(e)},dirname(s){if(Ge(s),s.length===0)return".";s=this.toPosix(s);let e=s.charCodeAt(0);const t=e===47;let r=-1,i=!0;const n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(e=s.charCodeAt(a),e===47){if(!i){r=a;break}}else i=!1;return r===-1?t?"/":this.isUrl(o)?n+s:n:t&&r===1?"//":n+s.slice(0,r)},rootname(s){Ge(s),s=this.toPosix(s);let e="";if(s.startsWith("/")?e="/":e=this.getProtocol(s),this.isUrl(s)){const t=s.indexOf("/",e.length);t!==-1?e=s.slice(0,t):e=s,e.endsWith("/")||(e+="/")}return e},basename(s,e){Ge(s),e&&Ge(e),s=qt(this.toPosix(s));let t=0,r=-1,i=!0,n;if(e!==void 0&&e.length>0&&e.length<=s.length){if(e.length===s.length&&e===s)return"";let o=e.length-1,a=-1;for(n=s.length-1;n>=0;--n){const l=s.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&&(r=n):(o=-1,r=a))}return t===r?r=a:r===-1&&(r=s.length),s.slice(t,r)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!i){t=n+1;break}}else r===-1&&(i=!1,r=n+1);return r===-1?"":s.slice(t,r)},extname(s){Ge(s),s=qt(this.toPosix(s));let e=-1,t=0,r=-1,i=!0,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!i){t=o+1;break}continue}r===-1&&(i=!1,r=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||r===-1||n===0||n===1&&e===r-1&&e===t+1?"":s.slice(e,r)},parse(s){Ge(s);const e={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return e;s=qt(this.toPosix(s));let t=s.charCodeAt(0);const r=this.isAbsolute(s);let i;e.root=this.rootname(s),r||this.hasProtocol(s)?i=1:i=0;let n=-1,o=0,a=-1,l=!0,h=s.length-1,c=0;for(;h>=i;--h){if(t=s.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&&r?e.base=e.name=s.slice(1,a):e.base=e.name=s.slice(o,a)):(o===0&&r?(e.name=s.slice(1,n),e.base=s.slice(1,a)):(e.name=s.slice(o,n),e.base=s.slice(o,a)),e.ext=s.slice(n,a)),e.dir=this.dirname(s),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function Ua(s,e,t,r,i){const n=e[t];for(let o=0;o<n.length;o++){const a=n[o];t<e.length-1?Ua(s.replace(r[t],a),e,t+1,r,i):i.push(s.replace(r[t],a))}}function Ru(s){const e=/\{(.*?)\}/g,t=s.match(e),r=[];if(t){const i=[];t.forEach(n=>{const o=n.substring(1,n.length-1).split(",");i.push(o)}),Ua(s,i,0,t,r)}else r.push(s);return r}const On=s=>!Array.isArray(s);class Da{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(r=>`${encodeURIComponent(r)}=${encodeURIComponent(t[r])}`).join("&")}}getAlias(e){const{alias:t,src:r}=e;return kt(t||r,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&&z("[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 r=[];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);r.push(h),l=[a,h]}else{const h=a.map(c=>this._createBundleAssetId(e,c));r.push(...h),l=[...a,...h]}this.add({...n,alias:l,src:o})}),this._bundles[e]=r}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let r;r=n=>{this.hasKey(n)&&z(`[Resolver] already has key: ${n} overwriting`)},kt(t).forEach(n=>{const{src:o}=n;let{data:a,format:l,loadParser:h,parser:c}=n;const u=kt(o).map(g=>typeof g=="string"?Ru(g):Array.isArray(g)?g:[g]),d=this.getAlias(n);Array.isArray(d)?d.forEach(r):r(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=On(e);e=kt(e);const r={};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}r[i]=a}}),t?r[e[0]]:r}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const r={};for(const i in t)r[i]=t[i].src;return r}return t.src}resolve(e){const t=On(e);e=kt(e);const r={};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},{});r[i]=this._resolverHash[i]}),t?r[e[0]]:r}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const r=e[t],i=this._preferredOrder.find(n=>n.params.format.includes(r.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:r,data:i,loadParser:n,parser:o,format:a,progressSize:l}=t;return(this._basePath||this._rootPath)&&(e.src=dr.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=r??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??Bu(e.src),l!==void 0&&(e.progressSize=l),e}}Da.RETINA_PREFIX=/@([0-9\.]+)x/;function Bu(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Ln=(s,e)=>{const t=e.split("?")[1];return t&&(s+=`?${t}`),s},Oa=class sr{constructor(e,t){this.linkedSheets=[];let r=e;(e==null?void 0:e.source)instanceof pe&&(r={texture:e,data:t});const{texture:i,data:n,cachePrefix:o=""}=r;this.cachePrefix=o,this._texture=i instanceof N?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<=sr.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 r=e;const i=t?1/0:sr.BATCH_SIZE;for(;r-e<i&&r<this._frameKeys.length;){const n=this._frameKeys[r],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 N({source:this.textureSource,frame:l,orig:u,trim:h,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}r++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let r=0;r<e[t].length;r++){const i=e[t][r];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*sr.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*sr.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const r in this.textures)this.textures[r].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=[]}};Oa.BATCH_SIZE=1e3;let Nn=Oa;const ku=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function La(s,e,t){const r={};if(s.forEach(i=>{r[i]=e}),Object.keys(e.textures).forEach(i=>{r[`${e.cachePrefix}${i}`]=e.textures[i]}),!t){const i=dr.dirname(s[0]);e.linkedSheets.forEach((n,o)=>{const a=La([`${i}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(r,a)})}return r}const Iu={extension:b.Asset,cache:{test:s=>s instanceof Nn,getCacheableAssets:(s,e)=>La(s,e,!1)},resolver:{extension:{type:b.ResolveParser,name:"resolveSpritesheet"},test:s=>{const t=s.split("?")[0].split("."),r=t.pop(),i=t.pop();return r==="json"&&ku.includes(i)},parse:s=>{var t;const e=s.split(".");return{resolution:parseFloat(((t=Da.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:e[e.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:b.LoadParser,priority:Fa.Normal,name:"spritesheetLoader"},async testParse(s,e){return dr.extname(e.src).toLowerCase()===".json"&&!!s.frames},async parse(s,e,t){var u,d;const{texture:r,imageFilename:i,textureOptions:n,cachePrefix:o}=(e==null?void 0:e.data)??{};let a=dr.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(r instanceof N)l=r;else{const f=Ln(a+(i??s.meta.image),e.src);l=(await t.load([{src:f,data:n}]))[f]}const h=new Nn({texture:l.source,data:s,cachePrefix:o});await h.parse();const c=(u=s==null?void 0:s.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=Ln(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(s,e,t){await t.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};W.add(Iu);class Na{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),r=this._canvas.width,i=this._canvas.height,n=t.width/r*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 r=this.canvas.width,i=this.canvas.height,n=t.contentRect.width/r*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||Re.shared.add(this.updateTranslation,this,Wt.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Re.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 yr{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=yr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new re,this.page=new re,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,r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,r,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 bs=/iPhone/i,Hn=/iPod/i,Wn=/iPad/i,zn=/\biOS-universal(?:.+)Mac\b/i,vs=/\bAndroid(?:.+)Mobile\b/i,Vn=/Android/i,wt=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Rr=/Silk/i,Xe=/Windows Phone/i,Xn=/\bWindows(?:.+)ARM\b/i,$n=/BlackBerry/i,Yn=/BB10/i,jn=/Opera Mini/i,qn=/\b(CriOS|Chrome)(?:.+)Mobile/i,Kn=/Mobile(?:.+)Firefox\b/i,Zn=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function Gu(s){return function(e){return e.test(s)}}function Qn(s){var e={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?e.userAgent=s:s&&s.userAgent&&(e={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var t=e.userAgent,r=t.split("[FBAN");typeof r[1]<"u"&&(t=r[0]),r=t.split("Twitter"),typeof r[1]<"u"&&(t=r[0]);var i=Gu(t),n={apple:{phone:i(bs)&&!i(Xe),ipod:i(Hn),tablet:!i(bs)&&(i(Wn)||Zn(e))&&!i(Xe),universal:i(zn),device:(i(bs)||i(Hn)||i(Wn)||i(zn)||Zn(e))&&!i(Xe)},amazon:{phone:i(wt),tablet:!i(wt)&&i(Rr),device:i(wt)||i(Rr)},android:{phone:!i(Xe)&&i(wt)||!i(Xe)&&i(vs),tablet:!i(Xe)&&!i(wt)&&!i(vs)&&(i(Rr)||i(Vn)),device:!i(Xe)&&(i(wt)||i(Rr)||i(vs)||i(Vn))||i(/\bokhttp\b/i)},windows:{phone:i(Xe),tablet:i(Xn),device:i(Xe)||i(Xn)},other:{blackberry:i($n),blackberry10:i(Yn),opera:i(jn),firefox:i(Kn),chrome:i(qn),device:i($n)||i(Yn)||i(jn)||i(Kn)||i(qn)},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 Fu=Qn.default??Qn,Uu=Fu(globalThis.navigator),Du=9,Jn=100,Ou=0,Lu=0,eo=2,to=1,Nu=-1e3,Hu=-1e3,Wu=2,Ti=class Ha{constructor(e,t=Uu){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${to}px`,e.style.height=`${to}px`,e.style.position="absolute",e.style.top=`${Nu}px`,e.style.left=`${Hu}px`,e.style.zIndex=Wu.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=`${Ou}px`,this._div.style.left=`${Lu}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=eo.toString(),this._canvasObserver=new Na({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 r of this._children)(e=r._accessibleDiv)!=null&&e.parentNode&&(r._accessibleDiv.parentNode.removeChild(r._accessibleDiv),r._accessibleDiv=null),r._accessibleActive=!1;for(const r in this._pools)this._pools[r].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[r];(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 r=0;r<t.length;r++)this._updateAccessibleObjects(t[r])}init(e){const r={accessibilityOptions:{...Ha.defaultOptions,...(e==null?void 0:e.accessibilityOptions)||{}}};this.debug=r.accessibilityOptions.debug,this._activateOnTab=r.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=r.accessibilityOptions.deactivateOnMouseMove,r.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 r of this._children)r._renderId===this._renderId&&t.add(this._children.indexOf(r))}for(let r=this._children.length-1;r>=0;r--){const i=this._children[r];t.has(r)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,Ta(this._children,r,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let r=0;r<this._children.length;r++){const i=this._children[r];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:r}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>r&&(e.height=r-e.y)}_addChild(e){let r=this._getPool(e.accessibleType).pop();r?(r.innerHTML="",r.removeAttribute("title"),r.removeAttribute("aria-label"),r.tabIndex=0):(e.accessibleType==="button"?r=document.createElement("button"):(r=document.createElement(e.accessibleType),r.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&&(r.innerText=e.accessibleText)),r.style.width=`${Jn}px`,r.style.height=`${Jn}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=eo.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=e.accessiblePointerEvents,r.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?r.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(r.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&r.setAttribute("aria-label",e.accessibleHint),e.interactive?r.tabIndex=e.tabIndex:r.tabIndex=0,this.debug&&this._updateDebugHTML(r),e._accessibleActive=!0,e._accessibleDiv=r,r.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv)}_dispatchEvent(e,t){const{container:r}=e.target,i=this._renderer.events.rootBoundary,n=Object.assign(new yr(i),{target:r});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!==Du||!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]}};Ti.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};Ti.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let zu=Ti;const Vu={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1},Ts=Object.create(null),ro=Object.create(null);function fr(s,e){let t=ro[s];return t===void 0&&(Ts[e]===void 0&&(Ts[e]=1),ro[s]=t=Ts[e]++),t}let Pt;function Wa(){return(!Pt||Pt!=null&&Pt.isContextLost())&&(Pt=Y.get().createCanvas().getContext("webgl",{})),Pt}let Br;function Xu(){if(!Br){Br="mediump";const s=Wa();s&&s.getShaderPrecisionFormat&&(Br=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Br}function $u(s,e,t){return e?s:t?(s=s.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
|
+
${s}
|
|
25
|
+
`):`
|
|
26
|
+
|
|
27
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
28
|
+
#define in attribute
|
|
29
|
+
#define out varying
|
|
30
|
+
#endif
|
|
31
|
+
${s}
|
|
32
|
+
`}function Yu(s,e,t){const r=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let i=t?e.requestedFragmentPrecision:e.requestedVertexPrecision;return i==="highp"&&r!=="highp"&&(i="mediump"),`precision ${i} float;
|
|
33
|
+
${s}`}else if(r!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function ju(s,e){return e?`#version 300 es
|
|
34
|
+
${s}`:s}const qu={},Ku={};function Zu(s,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const r=t?qu:Ku;return r[e]?(r[e]++,e+=`-${r[e]}`):r[e]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${e}`}
|
|
35
|
+
${s}`}function Qu(s,e){return e?s.replace("#version 300 es",""):s}const Ss={stripVersion:Qu,ensurePrecision:Yu,addProgramDefines:$u,setProgramName:Zu,insertVersion:ju},Kt=Object.create(null),za=class qs{constructor(e){e={...qs.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,r={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Xu()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let i=e.fragment,n=e.vertex;Object.keys(Ss).forEach(o=>{const a=r[o];i=Ss[o](i,a,!0),n=Ss[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=fr(`${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,Kt[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return Kt[t]||(Kt[t]=new qs(e),Kt[t]._cacheKey=t),Kt[t]}};za.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let ot=za;const so={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 pr(s){return so[s]??so.float32}const Ju={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"},io=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function no(s,e){let t;for(;(t=io.exec(s))!==null;){const r=Ju[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:r,stride:pr(r).stride,offset:0,instance:!1,start:0}}io.lastIndex=0}function ed(s){return s.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function td({source:s,entryPoint:e}){const t={},r=ed(s),i=r.indexOf(`fn ${e}(`);if(i===-1)return t;const n=r.indexOf("->",i);if(n===-1)return t;const o=r.substring(i,n);if(no(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=r.match(h);c&&no(c[1],t)}}return t}function Cs(s){var u,d;const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,r=/@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=s.match(e))==null?void 0:u.map(f=>({group:parseInt(f.match(t)[1],10),binding:parseInt(f.match(r)[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=s.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 pt=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(pt||{});function rd({groups:s}){const e=[];for(let t=0;t<s.length;t++){const r=s[t];e[r.group]||(e[r.group]=[]),r.isUniform?e[r.group].push({binding:r.binding,visibility:pt.VERTEX|pt.FRAGMENT,buffer:{type:"uniform"}}):r.type==="sampler"?e[r.group].push({binding:r.binding,visibility:pt.FRAGMENT,sampler:{type:"filtering"}}):r.type==="texture_2d"||r.type.startsWith("texture_2d<")?e[r.group].push({binding:r.binding,visibility:pt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):r.type==="texture_2d_array"||r.type.startsWith("texture_2d_array<")?e[r.group].push({binding:r.binding,visibility:pt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(r.type==="texture_cube"||r.type.startsWith("texture_cube<"))&&e[r.group].push({binding:r.binding,visibility:pt.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function sd({groups:s}){const e=[];for(let t=0;t<s.length;t++){const r=s[t];e[r.group]||(e[r.group]={}),e[r.group][r.name]=r.binding}return e}function id(s,e){const t=new Set,r=new Set,i=[...s.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),n=[...s.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return r.has(a)?!1:(r.add(a),!0)});return{structs:i,groups:n}}const Zt=Object.create(null);class Ze{constructor(e){var a,l;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:r,layout:i,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=r,t.source===r.source){const h=Cs(t.source);this.structsAndGroups=h}else{const h=Cs(r.source),c=Cs(t.source);this.structsAndGroups=id(h,c)}this.layout=i??sd(this.structsAndGroups),this.gpuLayout=n??rd(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,r=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=fr(r,"program")}get attributeData(){return this._attributeData??(this._attributeData=td(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Zt[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return Zt[t]||(Zt[t]=new Ze(e),Zt[t]._cacheKey=t),Zt[t]}}const Va=["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>"],nd=Va.reduce((s,e)=>(s[e]=!0,s),{});function od(s,e){switch(s){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 Xa=class $a{constructor(e,t){this._touched=0,this.uid=te("uniform"),this._resourceType="uniformGroup",this._resourceId=te("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...$a.defaultOptions,...t},this.uniformStructures=e;const r={};for(const i in e){const n=e[i];if(n.name=i,n.size=n.size??1,!nd[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: ${Va.join(", ")}`)}n.value??(n.value=od(n.type,n.size)),r[i]=n.value}this.uniforms=r,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=fr(Object.keys(r).map(i=>`${i}-${e[i].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Xa.defaultOptions={ubo:!1,isStatic:!1};let De=Xa;class it{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const r in e){const i=e[r];this.setResource(i,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const r in this.resources)e[t++]=this.resources[r]._resourceId;this._key=e.join("|")}setResource(e,t){var i,n;const r=this.resources[t];e!==r&&((i=r==null?void 0:r.off)==null||i.call(r,"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 r=this.resources;for(const i in r)r[i]._gcLastUsed=e,r[i]._touched=t}destroy(){var t;const e=this.resources;for(const r in e){const i=e[r];(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 Pe=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.CANVAS=4]="CANVAS",s[s.BOTH=3]="BOTH",s))(Pe||{});class Qe extends ke{constructor(e){super(),this.uid=te("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:r,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=r,o===void 0&&(o=0,t&&(o|=Pe.WEBGPU),r&&(o|=Pe.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 it,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 De(d));const f=l[u];f&&(i[f.group]||(i[f.group]=new it,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,r){var i,n;(i=this._uniformBindMap)[t]||(i[t]={}),(n=this._uniformBindMap[t])[r]||(n[r]=e),this.groups[t]||(this.groups[t]=new it,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const r={};for(const i in t){const n=t[i];Object.defineProperty(r,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return r}destroy(e=!1){var t,r;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&((t=this.gpuProgram)==null||t.destroy(),(r=this.glProgram)==null||r.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:r,...i}=e;let n,o;return t&&(n=Ze.from(t)),r&&(o=ot.from(r)),new Qe({gpuProgram:n,glProgram:o,...i})}}const ad={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},ws=0,Ps=1,Es=2,Ms=3,As=4,Rs=5,Ks=class Ya{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ws)}set blend(e){!!(this.data&1<<ws)!==e&&(this.data^=1<<ws)}get offsets(){return!!(this.data&1<<Ps)}set offsets(e){!!(this.data&1<<Ps)!==e&&(this.data^=1<<Ps)}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<<Es)}set culling(e){!!(this.data&1<<Es)!==e&&(this.data^=1<<Es)}get depthTest(){return!!(this.data&1<<Ms)}set depthTest(e){!!(this.data&1<<Ms)!==e&&(this.data^=1<<Ms)}get depthMask(){return!!(this.data&1<<Rs)}set depthMask(e){!!(this.data&1<<Rs)!==e&&(this.data^=1<<Rs)}get clockwiseFrontFace(){return!!(this.data&1<<As)}set clockwiseFrontFace(e){!!(this.data&1<<As)!==e&&(this.data^=1<<As)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=ad[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 Ya;return e.depthTest=!1,e.blend=!0,e}};Ks.default2d=Ks.for2d();let Je=Ks;const ja=class Zs extends Qe{constructor(e){e={...Zs.defaultOptions,...e},super(e),this.enabled=!0,this._state=Je.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,r,i){e.applyFilter(this,t,r,i)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:r,...i}=e;let n,o;return t&&(n=Ze.from(t)),r&&(o=ot.from(r)),new Zs({gpuProgram:n,glProgram:o,...i})}};ja.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let br=ja;const Qs=[];W.handleByNamedList(b.Environment,Qs);async function ld(s){if(!s)for(let e=0;e<Qs.length;e++){const t=Qs[e];if(t.value.test()){await t.value.load();return}}}let Qt;function qa(){if(typeof Qt=="boolean")return Qt;try{Qt=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Qt=!1}return Qt}function oo(s,e,t=2){const r=e&&e.length,i=r?e[0]*t:s.length;let n=Ka(s,0,i,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,h;if(r&&(n=fd(s,e,n,t)),s.length>80*t){a=s[0],l=s[1];let c=a,u=l;for(let d=t;d<i;d+=t){const f=s[d],p=s[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 mr(n,o,t,a,l,h,0),o}function Ka(s,e,t,r,i){let n;if(i===Cd(s,e,t,r)>0)for(let o=e;o<t;o+=r)n=ao(o/r|0,s[o],s[o+1],n);else for(let o=t-r;o>=e;o-=r)n=ao(o/r|0,s[o],s[o+1],n);return n&&zt(n,n.next)&&(_r(n),n=n.next),n}function bt(s,e){if(!s)return s;e||(e=s);let t=s,r;do if(r=!1,!t.steiner&&(zt(t,t.next)||ae(t.prev,t,t.next)===0)){if(_r(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function mr(s,e,t,r,i,n,o){if(!s)return;!o&&n&&xd(s,r,i,n);let a=s;for(;s.prev!==s.next;){const l=s.prev,h=s.next;if(n?cd(s,r,i,n):hd(s)){e.push(l.i,s.i,h.i),_r(s),s=h.next,a=h.next;continue}if(s=h,s===a){o?o===1?(s=ud(bt(s),e),mr(s,e,t,r,i,n,2)):o===2&&dd(s,e,t,r,i,n):mr(bt(s),e,t,r,i,n,1);break}}}function hd(s){const e=s.prev,t=s,r=s.next;if(ae(e,t,r)>=0)return!1;const i=e.x,n=t.x,o=r.x,a=e.y,l=t.y,h=r.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=r.next;for(;p!==e;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&ir(i,a,n,l,o,h,p.x,p.y)&&ae(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function cd(s,e,t,r){const i=s.prev,n=s,o=s.next;if(ae(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),_=Js(f,p,e,t,r),x=Js(g,m,e,t,r);let y=s.prevZ,v=s.nextZ;for(;y&&y.z>=_&&v&&v.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==i&&y!==o&&ir(a,c,l,u,h,d,y.x,y.y)&&ae(y.prev,y,y.next)>=0||(y=y.prevZ,v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==i&&v!==o&&ir(a,c,l,u,h,d,v.x,v.y)&&ae(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==i&&y!==o&&ir(a,c,l,u,h,d,y.x,y.y)&&ae(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==i&&v!==o&&ir(a,c,l,u,h,d,v.x,v.y)&&ae(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function ud(s,e){let t=s;do{const r=t.prev,i=t.next.next;!zt(r,i)&&Qa(r,t,t.next,i)&&gr(r,i)&&gr(i,r)&&(e.push(r.i,t.i,i.i),_r(t),_r(t.next),t=s=i),t=t.next}while(t!==s);return bt(t)}function dd(s,e,t,r,i,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&vd(o,a)){let l=Ja(o,a);o=bt(o,o.next),l=bt(l,l.next),mr(o,e,t,r,i,n,0),mr(l,e,t,r,i,n,0);return}a=a.next}o=o.next}while(o!==s)}function fd(s,e,t,r){const i=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*r,l=n<o-1?e[n+1]*r:s.length,h=Ka(s,a,l,r,!1);h===h.next&&(h.steiner=!0),i.push(bd(h))}i.sort(pd);for(let n=0;n<i.length;n++)t=md(i[n],t);return t}function pd(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const r=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function md(s,e){const t=gd(s,e);if(!t)return e;const r=Ja(t,s);return bt(r,r.next),bt(t,t.next)}function gd(s,e){let t=e;const r=s.x,i=s.y;let n=-1/0,o;if(zt(s,t))return t;do{if(zt(s,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<=r&&u>n&&(n=u,o=t.x<t.next.x?t:t.next,u===r))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(r>=t.x&&t.x>=l&&r!==t.x&&Za(i<h?r:n,i,l,h,i<h?n:r,i,t.x,t.y)){const u=Math.abs(i-t.y)/(r-t.x);gr(t,s)&&(u<c||u===c&&(t.x>o.x||t.x===o.x&&_d(o,t)))&&(o=t,c=u)}t=t.next}while(t!==a);return o}function _d(s,e){return ae(s.prev,s,e.prev)<0&&ae(e.next,s,s.next)<0}function xd(s,e,t,r){let i=s;do i.z===0&&(i.z=Js(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,yd(i)}function yd(s){let e,t=1;do{let r=s,i;s=null;let n=null;for(e=0;r;){e++;let o=r,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||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:s=i,i.prevZ=n,n=i;r=o}n.nextZ=null,t*=2}while(e>1);return s}function Js(s,e,t,r,i){return s=(s-t)*i|0,e=(e-r)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function bd(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Za(s,e,t,r,i,n,o,a){return(i-o)*(e-a)>=(s-o)*(n-a)&&(s-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(i-o)*(r-a)}function ir(s,e,t,r,i,n,o,a){return!(s===o&&e===a)&&Za(s,e,t,r,i,n,o,a)}function vd(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Td(s,e)&&(gr(s,e)&&gr(e,s)&&Sd(s,e)&&(ae(s.prev,s,e.prev)||ae(s,e.prev,e))||zt(s,e)&&ae(s.prev,s,s.next)>0&&ae(e.prev,e,e.next)>0)}function ae(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function zt(s,e){return s.x===e.x&&s.y===e.y}function Qa(s,e,t,r){const i=Ir(ae(s,e,t)),n=Ir(ae(s,e,r)),o=Ir(ae(t,r,s)),a=Ir(ae(t,r,e));return!!(i!==n&&o!==a||i===0&&kr(s,t,e)||n===0&&kr(s,r,e)||o===0&&kr(t,s,r)||a===0&&kr(t,e,r))}function kr(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Ir(s){return s>0?1:s<0?-1:0}function Td(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&Qa(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function gr(s,e){return ae(s.prev,s,s.next)<0?ae(s,e,s.next)>=0&&ae(s,s.prev,e)>=0:ae(s,e,s.prev)<0||ae(s,s.next,e)<0}function Sd(s,e){let t=s,r=!1;const i=(s.x+e.x)/2,n=(s.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&&(r=!r),t=t.next;while(t!==s);return r}function Ja(s,e){const t=ei(s.i,s.x,s.y),r=ei(e.i,e.x,e.y),i=s.next,n=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,r.next=t,t.prev=r,n.next=r,r.prev=n,r}function ao(s,e,t,r){const i=ei(s,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function _r(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function ei(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Cd(s,e,t,r){let i=0;for(let n=e,o=t-r;n<t;n+=r)i+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return i}const wd=oo.default||oo;var we=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(we||{});class el{constructor(e){this.items=[],this._name=e}emit(e,t,r,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,r,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 Pd=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],tl=class rl extends ke{constructor(e){super(),this.tick=0,this.uid=te("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=[...Pd,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await ld(t),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const r in this._systemsHash)e={...this._systemsHash[r].constructor.defaultOptions,...e};e={...rl.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let r=0;r<this.runners.init.items.length;r++)await this.runners.init.items[r].init(e);this._initOptions=e}render(e,t){this.tick++;let r=e;if(r instanceof ve&&(r={container:r},t&&(O(ie,"passing a second argument is deprecated, please use render options instead"),r.target=t.renderTexture)),r.target||(r.target=this.view.renderTarget),r.target===this.view.renderTarget&&(this._lastObjectRendered=r.container,r.clearColor??(r.clearColor=this.background.colorRgba),r.clear??(r.clear=this.background.clearBeforeRender)),r.clearColor){const i=Array.isArray(r.clearColor)&&r.clearColor.length===4;r.clearColor=i?r.clearColor:Q.shared.setValue(r.clearColor).toArray()}r.transform||(r.container.updateLocalTransform(),r.transform=r.container.localTransform),r.container.visible&&(r.container.enableRenderGroup(),this.runners.prerender.emit(r),this.runners.renderStart.emit(r),this.runners.render.emit(r),this.runners.renderEnd.emit(r),this.runners.postrender.emit(r))}resize(e,t,r){const i=this.view.resolution;this.view.resize(e,t,r),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),r!==void 0&&r!==i&&this.runners.resolutionChange.emit(r)}clear(e={}){const t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=we.ALL);const{clear:r,clearColor:i,target:n,mipLevel:o,layer:a}=e;Q.shared.setValue(i??this.background.colorRgba),t.renderTarget.clear(n,r,Q.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 el(t)})}_addSystems(e){let t;for(t in e){const r=e[t];this._addSystem(r.value,r.name)}}_addSystem(e,t){const r=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=r,this._systemsHash[t]=r;for(const i in this.runners)this.runners[i].add(r);return this}_addPipes(e,t){const r=t.reduce((i,n)=>(i[n.name]=n.value,i),{});e.forEach(i=>{const n=i.value,o=i.name,a=r[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)&&$t.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(!qa())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()}};tl.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let vr=tl,Gr;function Ed(s){return Gr!==void 0||(Gr=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:s??vr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Y.get().getWebGLRenderingContext())return!1;let i=Y.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}})()),Gr}let Fr;async function Md(s={}){return Fr!==void 0||(Fr=await(async()=>{const e=Y.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Fr}const lo=["webgl","webgpu","canvas"];async function Ad(s){let e=[];s.preference?Array.isArray(s.preference)?e=s.preference.slice():(e.push(s.preference),lo.forEach(n=>{n!==s.preference&&e.push(n)})):e=lo.slice();let t,r={};for(let n=0;n<e.length;n++){const o=e[n];if(o==="webgpu"&&await Md()){const{WebGPURenderer:a}=await nr(async()=>{const{WebGPURenderer:l}=await Promise.resolve().then(()=>R_);return{WebGPURenderer:l}},void 0);t=a,r={...s,...s.webgpu};break}else if(o==="webgl"&&Ed(s.failIfMajorPerformanceCaveat??vr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await nr(async()=>{const{WebGLRenderer:l}=await Promise.resolve().then(()=>l_);return{WebGLRenderer:l}},void 0);t=a,r={...s,...s.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await nr(async()=>{const{CanvasRenderer:l}=await Promise.resolve().then(()=>ag);return{CanvasRenderer:l}},void 0);t=a,r={...s,...s.canvasOptions};break}}if(delete r.webgpu,delete r.webgl,delete r.canvasOptions,!t)throw new Error("No available renderer for the current environment");const i=new t;return await i.init(r),i}const Qr="8.18.1";class sl{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,Qr)}static destroy(){}}sl.extension=b.Application;class il{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,Qr)}destroy(){this._renderer=null}}il.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"initHook",priority:-10};class nl{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,r;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,r=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;t=i,r=n}this.renderer.resize(t,r),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}}nl.extension=b.Application;class ol{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,Wt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Re.shared:new Re,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}ol.extension=b.Application;W.add(nl);W.add(ol);const al=class ti{constructor(...e){this.stage=new ve,e[0]!==void 0&&O(ie,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new ve),this.renderer=await Ad(e),ti._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return O(ie,"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 r=ti._plugins.slice(0);r.reverse(),r.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};al._plugins=[];let Rd=al;W.handleByList(b.Application,Rd._plugins);W.add(sl);var Bs,ho;function Bd(){if(ho)return Bs;ho=1,Bs=t;var s={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==s[c])return h.unshift(l),o.push(h);if(h.length<s[c])throw new Error("malformed path data");o.push([l].concat(h.splice(0,s[c])))}}),o}var r=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function i(n){var o=n.match(r);return o?o.map(Number):[]}return Bs}var kd=Bd();const Id=ha(kd);function Gd(s,e){const t=Id(s),r=[];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(),r.length>0&&(i=r.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:z(`Unknown SVG path command: ${h}`)}h!=="Z"&&h!=="z"&&i===null&&(i={startX:n,startY:o},r.push(i))}return e}class Si{constructor(e=0,t=0,r=0){this.type="circle",this.x=e,this.y=t,this.radius=r}clone(){return new Si(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const r=this.radius*this.radius;let i=this.x-e,n=this.y-t;return i*=i,n*=n,i+n<=r}strokeContains(e,t,r,i=.5){if(this.radius===0)return!1;const n=this.x-e,o=this.y-t,a=this.radius,l=(1-i)*r,h=Math.sqrt(n*n+o*o);return h<=a+l&&h>a-(r-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 Ci{constructor(e=0,t=0,r=0,i=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=r,this.halfHeight=i}clone(){return new Ci(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(e-this.x)/this.halfWidth,i=(t-this.y)/this.halfHeight;return r*=r,i*=i,r+i<=1}strokeContains(e,t,r,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=r*(1-i),l=r-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 Fd(s,e,t,r,i,n){const o=s-t,a=e-r,l=i-t,h=n-r,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=r):d>1?(f=i,p=n):(f=t+d*l,p=r+d*h);const g=s-f,m=e-p;return g*g+m*m}let Ud,Dd;class lr{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const r=[];for(let i=0,n=t.length;i<n;i++)r.push(t[i].x,t[i].y);t=r}this.points=t,this.closePath=!0}isClockwise(){let e=0;const t=this.points,r=t.length;for(let i=0;i<r;i+=2){const n=t[i],o=t[i+1],a=t[(i+2)%r],l=t[(i+3)%r];e+=(a-n)*(l+o)}return e<0}containsPolygon(e){const t=this.getBounds(Ud),r=e.getBounds(Dd);if(!t.containsRect(r))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 lr(e);return t.closePath=this.closePath,t}contains(e,t){let r=!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&&(r=!r)}return r}strokeContains(e,t,r,i=.5){const n=r*r,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=Fd(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 r=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];r=h<r?h:r,i=h>i?h:i,n=c<n?c:n,o=c>o?c:o}return e.x=r,e.width=i-r,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 O("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return O("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 Ur=(s,e,t,r,i,n,o)=>{const a=s-t,l=e-r,h=Math.sqrt(a*a+l*l);return h>=i-n&&h<=i+o};class wi{constructor(e=0,t=0,r=0,i=0,n=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=r,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 wi(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 r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+r&&t<=this.y+this.height-r||e>=this.x+r&&e<=this.x+this.width-r)return!0;let i=e-(this.x+r),n=t-(this.y+r);const o=r*r;if(i*i+n*n<=o||(i=e-(this.x+this.width-r),i*i+n*n<=o)||(n=t-(this.y+this.height-r),i*i+n*n<=o)||(i=e-(this.x+r),i*i+n*n<=o))return!0}return!1}strokeContains(e,t,r,i=.5){const{x:n,y:o,width:a,height:l,radius:h}=this,c=r*(1-i),u=r-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&&Ur(e,t,d,f,h,u,c)||e>m-h&&t<f&&Ur(e,t,m-h,f,h,u,c)||e>m-h&&t>_-h&&Ur(e,t,m-h,_-h,h,u,c)||e<d&&t>_-h&&Ur(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 ll={};function Pi(s,e,t){let r=2166136261;for(let i=0;i<e;i++)r^=s[i].uid,r=Math.imul(r,16777619),r>>>=0;return ll[r]||Od(s,e,r,t)}function Od(s,e,t,r){const i={};let n=0;for(let a=0;a<r;a++){const l=a<e?s[a]:N.EMPTY.source;i[n++]=l.source,i[n++]=l.style}const o=new it(i);return ll[t]=o,o}class co{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 ri(s,e,t,r){if(t??(t=0),r??(r=Math.min(s.byteLength-t,e.byteLength)),!(t&7)&&!(r&7)){const i=r/8;new Float64Array(e,0,i).set(new Float64Array(s,t,i))}else if(!(t&3)&&!(r&3)){const i=r/4;new Float32Array(e,0,i).set(new Float32Array(s,t,i))}else new Uint8Array(e).set(new Uint8Array(s,t,r))}const Ld={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var de=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",s[s.NONE=5]="NONE",s))(de||{});function uo(s,e){return e.alphaMode==="no-premultiply-alpha"&&Ld[s]||s}const Nd=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
36
|
+
`);function Hd(s){let e="";for(let t=0;t<s;++t)t>0&&(e+=`
|
|
37
|
+
else `),t<s-1&&(e+=`if(test == ${t}.0){}`);return e}function hl(s,e){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const r=Nd.replace(/%forloop%/gi,Hd(s));if(e.shaderSource(t,r),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))s=s/2|0;else break}}finally{e.deleteShader(t)}return s}let Et=null;function Wd(){var e;if(Et)return Et;const s=Wa();return Et=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),Et=hl(Et,s),(e=s.getExtension("WEBGL_lose_context"))==null||e.loseContext(),Et}class zd{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 Vd{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new zd,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 hr=[];let Jr=0;$t.register({clear:()=>{if(hr.length>0)for(const s of hr)s&&s.destroy();hr.length=0,Jr=0}});function fo(){return Jr>0?hr[--Jr]:new Vd}function po(s){s.elements=null,hr[Jr++]=s}let Jt=0;const cl=class ul{constructor(e){this.uid=te("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...ul.defaultOptions,...e},e.maxTextures||(O("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=Wd());const{maxTextures:t,attributesInitialSize:r,indicesInitialSize:i}=e;this.attributeBuffer=new co(r*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++)po(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 r=e._batch.textures.ids[t._source.uid];return!r&&r!==0?!1:(e._textureId=r,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 r=fo(),i=r.textures;i.clear();const n=t[this.elementStart];let o=uo(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,v=uo(_.blendMode,y),S=o!==v||a!==_.topology;if(y._batchTick===Jt&&!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=r,p.push(_);continue}y._batchTick=Jt,(i.count>=g||S)&&(this._finishBatch(r,d,u-d,i,o,a,e,f,p),f="renderBatch",d=u,o=v,a=_.topology,r=fo(),i=r.textures,i.clear(),p=[],++Jt),_._textureId=y._textureBindLocation=i.count,i.ids[y.uid]=i.count,i.textures[i.count++]=y,_._batch=r,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(r,d,u-d,i,o,a,e,f,p),d=u,++Jt),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(e,t,r,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=r,e.elements=h,++Jt,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),r=new co(t);ri(this.attributeBuffer.rawBinaryData,r.rawBinaryData),this.attributeBuffer=r}_resizeIndexBuffer(e){const t=this.indexBuffer;let r=Math.max(e,t.length*1.5);r+=r%2;const i=r>65535?new Uint32Array(r):new Uint16Array(r);if(i.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let n=0;n<t.length;n++)i[n]=t[n];else ri(t.buffer,i.buffer);this.indexBuffer=i}packQuadIndex(e,t,r){e[t]=r+0,e[t+1]=r+1,e[t+2]=r+2,e[t+3]=r+0,e[t+4]=r+2,e[t+5]=r+3}packIndex(e,t,r,i){const n=e.indices,o=e.indexSize,a=e.indexOffset,l=e.attributeOffset;for(let h=0;h<o;h++)t[r++]=i+n[h+a]-l}destroy(e={}){var t;if(this.batches!==null){for(let r=0;r<this.batchIndex;r++)po(this.batches[r]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&((t=this.shader)==null||t.destroy(),this.shader=null);for(let r=0;r<this._elements.length;r++)this._elements[r]&&(this._elements[r]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};cl.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Xd=cl;var ne=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(ne||{});class nt extends ke{constructor(e){let{data:t,size:r}=e;const{usage:i,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=te("buffer"),this._resourceType="buffer",this._resourceId=te("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,r??(r=t==null?void 0:t.byteLength);const a=!!t;this.descriptor={size:r,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&ne.STATIC)}set static(e){e?this.descriptor.usage|=ne.STATIC:this.descriptor.usage&=~ne.STATIC}setDataWithSize(e,t,r){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){r&&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?r&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=te("resource"),this.emit("change",this));return}r&&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 dl(s,e){if(!(s instanceof nt)){let t=e?ne.INDEX:ne.VERTEX;s instanceof Array&&(e?(s=new Uint32Array(s),t=ne.INDEX|ne.COPY_DST):(s=new Float32Array(s),t=ne.VERTEX|ne.COPY_DST)),s=new nt({data:s,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return s}function $d(s,e,t){const r=s.getAttribute(e);if(!r)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const i=r.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const h=i.BYTES_PER_ELEMENT,c=(r.offset||0)/h,u=(r.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 Yd(s){return(s instanceof nt||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=dl(s.buffer,!1),s}class Ei extends ke{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=te("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new xe,this._boundsDirty=!0;const{attributes:t,indexBuffer:r,topology:i}=e;if(this.buffers=[],this.attributes={},t)for(const n in t)this.addAttribute(n,t[n]);this.instanceCount=e.instanceCount??1,r&&this.addIndex(r),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 r=Yd(t);this.buffers.indexOf(r.buffer)===-1&&(this.buffers.push(r.buffer),r.buffer.on("update",this.onBufferUpdate,this),r.buffer.on("change",this.onBufferUpdate,this)),this.attributes[e]=r}addIndex(e){this.indexBuffer=dl(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,$d(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(r=>r.destroy()),this.unload(),(t=this.indexBuffer)==null||t.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const jd=new Float32Array(1),qd=new Uint32Array(1);class Kd extends Ei{constructor(){const t=new nt({data:jd,label:"attribute-batch-buffer",usage:ne.VERTEX|ne.COPY_DST,shrinkToFit:!1}),r=new nt({data:qd,label:"index-batch-buffer",usage:ne.INDEX|ne.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:r})}}function mo(s,e,t){if(s)for(const r in s){const i=r.toLocaleLowerCase(),n=e[i];if(n){let o=s[r];r==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&n.push(`//----${t}----//`),n.push(o)}else z(`${r} placement hook does not exist in shader`)}}const Zd=/\{\{(.*?)\}\}/g;function go(s){var r;const e={};return(((r=s.match(Zd))==null?void 0:r.map(i=>i.replace(/[{()}]/g,"")))??[]).forEach(i=>{e[i]=[]}),e}function _o(s,e){let t;const r=/@in\s+([^;]+);/g;for(;(t=r.exec(s))!==null;)e.push(t[1])}function xo(s,e,t=!1){const r=[];_o(e,r),s.forEach(a=>{a.header&&_o(a.header,r)});const i=r;t&&i.sort();const n=i.map((a,l)=>` @location(${l}) ${a},`).join(`
|
|
38
|
+
`);let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
|
|
39
|
+
${n}
|
|
40
|
+
`),o}function yo(s,e){let t;const r=/@out\s+([^;]+);/g;for(;(t=r.exec(s))!==null;)e.push(t[1])}function Qd(s){const t=/\b(\w+)\s*:/g.exec(s);return t?t[1]:""}function Jd(s){const e=/@.*?\s+/g;return s.replace(e,"")}function ef(s,e){const t=[];yo(e,t),s.forEach(l=>{l.header&&yo(l.header,t)});let r=0;const i=t.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${r++}) ${l}`).join(`,
|
|
41
|
+
`),n=t.sort().map(l=>` var ${Jd(l)};`).join(`
|
|
42
|
+
`),o=`return VSOutput(
|
|
43
|
+
${t.sort().map(l=>` ${Qd(l)}`).join(`,
|
|
44
|
+
`)});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
|
|
45
|
+
${i}
|
|
46
|
+
`),a=a.replace("{{start}}",`
|
|
47
|
+
${n}
|
|
48
|
+
`),a=a.replace("{{return}}",`
|
|
49
|
+
${o}
|
|
50
|
+
`),a}function bo(s,e){let t=s;for(const r in e){const i=e[r];i.join(`
|
|
51
|
+
`).length?t=t.replace(`{{${r}}}`,`//-----${r} START-----//
|
|
52
|
+
${i.join(`
|
|
53
|
+
`)}
|
|
54
|
+
//----${r} FINISH----//`):t=t.replace(`{{${r}}}`,"")}return t}const st=Object.create(null),ks=new Map;let tf=0;function rf({template:s,bits:e}){const t=fl(s,e);if(st[t])return st[t];const{vertex:r,fragment:i}=nf(s,e);return st[t]=pl(r,i,e),st[t]}function sf({template:s,bits:e}){const t=fl(s,e);return st[t]||(st[t]=pl(s.vertex,s.fragment,e)),st[t]}function nf(s,e){const t=e.map(o=>o.vertex).filter(o=>!!o),r=e.map(o=>o.fragment).filter(o=>!!o);let i=xo(t,s.vertex,!0);i=ef(t,i);const n=xo(r,s.fragment,!0);return{vertex:i,fragment:n}}function fl(s,e){return e.map(t=>(ks.has(t)||ks.set(t,tf++),ks.get(t))).sort((t,r)=>t-r).join("-")+s.vertex+s.fragment}function pl(s,e,t){const r=go(s),i=go(e);return t.forEach(n=>{mo(n.vertex,r,n.name),mo(n.fragment,i,n.name)}),{vertex:bo(s,r),fragment:bo(e,i)}}const of=`
|
|
55
|
+
@in aPosition: vec2<f32>;
|
|
56
|
+
@in aUV: vec2<f32>;
|
|
57
|
+
|
|
58
|
+
@out @builtin(position) vPosition: vec4<f32>;
|
|
59
|
+
@out vUV : vec2<f32>;
|
|
60
|
+
@out vColor : vec4<f32>;
|
|
61
|
+
|
|
62
|
+
{{header}}
|
|
63
|
+
|
|
64
|
+
struct VSOutput {
|
|
65
|
+
{{struct}}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
@vertex
|
|
69
|
+
fn main( {{in}} ) -> VSOutput {
|
|
70
|
+
|
|
71
|
+
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
72
|
+
var modelMatrix = mat3x3<f32>(
|
|
73
|
+
1.0, 0.0, 0.0,
|
|
74
|
+
0.0, 1.0, 0.0,
|
|
75
|
+
0.0, 0.0, 1.0
|
|
76
|
+
);
|
|
77
|
+
var position = aPosition;
|
|
78
|
+
var uv = aUV;
|
|
79
|
+
|
|
80
|
+
{{start}}
|
|
81
|
+
|
|
82
|
+
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
83
|
+
|
|
84
|
+
{{main}}
|
|
85
|
+
|
|
86
|
+
vUV = uv;
|
|
87
|
+
|
|
88
|
+
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
89
|
+
|
|
90
|
+
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
91
|
+
|
|
92
|
+
vColor *= globalUniforms.uWorldColorAlpha;
|
|
93
|
+
|
|
94
|
+
{{end}}
|
|
95
|
+
|
|
96
|
+
{{return}}
|
|
97
|
+
};
|
|
98
|
+
`,af=`
|
|
99
|
+
@in vUV : vec2<f32>;
|
|
100
|
+
@in vColor : vec4<f32>;
|
|
101
|
+
|
|
102
|
+
{{header}}
|
|
103
|
+
|
|
104
|
+
@fragment
|
|
105
|
+
fn main(
|
|
106
|
+
{{in}}
|
|
107
|
+
) -> @location(0) vec4<f32> {
|
|
108
|
+
|
|
109
|
+
{{start}}
|
|
110
|
+
|
|
111
|
+
var outColor:vec4<f32>;
|
|
112
|
+
|
|
113
|
+
{{main}}
|
|
114
|
+
|
|
115
|
+
var finalColor:vec4<f32> = outColor * vColor;
|
|
116
|
+
|
|
117
|
+
{{end}}
|
|
118
|
+
|
|
119
|
+
return finalColor;
|
|
120
|
+
};
|
|
121
|
+
`,lf=`
|
|
122
|
+
in vec2 aPosition;
|
|
123
|
+
in vec2 aUV;
|
|
124
|
+
|
|
125
|
+
out vec4 vColor;
|
|
126
|
+
out vec2 vUV;
|
|
127
|
+
|
|
128
|
+
{{header}}
|
|
129
|
+
|
|
130
|
+
void main(void){
|
|
131
|
+
|
|
132
|
+
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
|
133
|
+
mat3 modelMatrix = mat3(
|
|
134
|
+
1.0, 0.0, 0.0,
|
|
135
|
+
0.0, 1.0, 0.0,
|
|
136
|
+
0.0, 0.0, 1.0
|
|
137
|
+
);
|
|
138
|
+
vec2 position = aPosition;
|
|
139
|
+
vec2 uv = aUV;
|
|
140
|
+
|
|
141
|
+
{{start}}
|
|
142
|
+
|
|
143
|
+
vColor = vec4(1.);
|
|
144
|
+
|
|
145
|
+
{{main}}
|
|
146
|
+
|
|
147
|
+
vUV = uv;
|
|
148
|
+
|
|
149
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
150
|
+
|
|
151
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
152
|
+
|
|
153
|
+
vColor *= uWorldColorAlpha;
|
|
154
|
+
|
|
155
|
+
{{end}}
|
|
156
|
+
}
|
|
157
|
+
`,hf=`
|
|
158
|
+
|
|
159
|
+
in vec4 vColor;
|
|
160
|
+
in vec2 vUV;
|
|
161
|
+
|
|
162
|
+
out vec4 finalColor;
|
|
163
|
+
|
|
164
|
+
{{header}}
|
|
165
|
+
|
|
166
|
+
void main(void) {
|
|
167
|
+
|
|
168
|
+
{{start}}
|
|
169
|
+
|
|
170
|
+
vec4 outColor;
|
|
171
|
+
|
|
172
|
+
{{main}}
|
|
173
|
+
|
|
174
|
+
finalColor = outColor * vColor;
|
|
175
|
+
|
|
176
|
+
{{end}}
|
|
177
|
+
}
|
|
178
|
+
`,cf={name:"global-uniforms-bit",vertex:{header:`
|
|
179
|
+
struct GlobalUniforms {
|
|
180
|
+
uProjectionMatrix:mat3x3<f32>,
|
|
181
|
+
uWorldTransformMatrix:mat3x3<f32>,
|
|
182
|
+
uWorldColorAlpha: vec4<f32>,
|
|
183
|
+
uResolution: vec2<f32>,
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
187
|
+
`}},uf={name:"global-uniforms-bit",vertex:{header:`
|
|
188
|
+
uniform mat3 uProjectionMatrix;
|
|
189
|
+
uniform mat3 uWorldTransformMatrix;
|
|
190
|
+
uniform vec4 uWorldColorAlpha;
|
|
191
|
+
uniform vec2 uResolution;
|
|
192
|
+
`}};function Mi({bits:s,name:e}){const t=rf({template:{fragment:af,vertex:of},bits:[cf,...s]});return Ze.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function Ai({bits:s,name:e}){return new ot({name:e,...sf({template:{vertex:lf,fragment:hf},bits:[uf,...s]})})}const ml={name:"color-bit",vertex:{header:`
|
|
193
|
+
@in aColor: vec4<f32>;
|
|
194
|
+
`,main:`
|
|
195
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
196
|
+
`}},gl={name:"color-bit",vertex:{header:`
|
|
197
|
+
in vec4 aColor;
|
|
198
|
+
`,main:`
|
|
199
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
200
|
+
`}},Is={};function df(s){const e=[];if(s===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 r=0;r<s;r++)e.push(`@group(1) @binding(${t++}) var textureSource${r+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${t++}) var textureSampler${r+1}: sampler;`)}return e.join(`
|
|
201
|
+
`)}function ff(s){const e=[];if(s===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let t=0;t<s;t++)t===s-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(`
|
|
202
|
+
`)}function _l(s){return Is[s]||(Is[s]={name:"texture-batch-bit",vertex:{header:`
|
|
203
|
+
@in aTextureIdAndRound: vec2<u32>;
|
|
204
|
+
@out @interpolate(flat) vTextureId : u32;
|
|
205
|
+
`,main:`
|
|
206
|
+
vTextureId = aTextureIdAndRound.y;
|
|
207
|
+
`,end:`
|
|
208
|
+
if(aTextureIdAndRound.x == 1)
|
|
209
|
+
{
|
|
210
|
+
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
211
|
+
}
|
|
212
|
+
`},fragment:{header:`
|
|
213
|
+
@in @interpolate(flat) vTextureId: u32;
|
|
214
|
+
|
|
215
|
+
${df(s)}
|
|
216
|
+
`,main:`
|
|
217
|
+
var uvDx = dpdx(vUV);
|
|
218
|
+
var uvDy = dpdy(vUV);
|
|
219
|
+
|
|
220
|
+
${ff(s)}
|
|
221
|
+
`}}),Is[s]}const Gs={};function pf(s){const e=[];for(let t=0;t<s;t++)t>0&&e.push("else"),t<s-1&&e.push(`if(vTextureId < ${t}.5)`),e.push("{"),e.push(` outColor = texture(uTextures[${t}], vUV);`),e.push("}");return e.join(`
|
|
222
|
+
`)}function xl(s){return Gs[s]||(Gs[s]={name:"texture-batch-bit",vertex:{header:`
|
|
223
|
+
in vec2 aTextureIdAndRound;
|
|
224
|
+
out float vTextureId;
|
|
225
|
+
|
|
226
|
+
`,main:`
|
|
227
|
+
vTextureId = aTextureIdAndRound.y;
|
|
228
|
+
`,end:`
|
|
229
|
+
if(aTextureIdAndRound.x == 1.)
|
|
230
|
+
{
|
|
231
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
232
|
+
}
|
|
233
|
+
`},fragment:{header:`
|
|
234
|
+
in float vTextureId;
|
|
235
|
+
|
|
236
|
+
uniform sampler2D uTextures[${s}];
|
|
237
|
+
|
|
238
|
+
`,main:`
|
|
239
|
+
|
|
240
|
+
${pf(s)}
|
|
241
|
+
`}}),Gs[s]}const Ri={name:"round-pixels-bit",vertex:{header:`
|
|
242
|
+
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
243
|
+
{
|
|
244
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
245
|
+
}
|
|
246
|
+
`}},Bi={name:"round-pixels-bit",vertex:{header:`
|
|
247
|
+
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
248
|
+
{
|
|
249
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
250
|
+
}
|
|
251
|
+
`}},vo={};function yl(s){let e=vo[s];if(e)return e;const t=new Int32Array(s);for(let r=0;r<s;r++)t[r]=r;return e=vo[s]=new De({uTextures:{value:t,type:"i32",size:s}},{isStatic:!0}),e}class To extends Qe{constructor(e){const t=Ai({name:"batch",bits:[gl,xl(e),Bi]}),r=Mi({name:"batch",bits:[ml,_l(e),Ri]});super({glProgram:t,gpuProgram:r,resources:{batchSamplers:yl(e)}}),this.maxTextures=e}}let er=null;const bl=class vl extends Xd{constructor(e){super(e),this.geometry=new Kd,this.name=vl.extension.name,this.vertexSize=6,er??(er=new To(e.maxTextures)),this.shader=er}packAttributes(e,t,r,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 v=y*2,S=p[v],T=p[v+1];t[i++]=l*S+c*T+d,t[i++]=u*T+h*S+f,t[i++]=g[v],t[i++]=g[v+1],r[i++]=m,r[i++]=o}}packQuadAttributes(e,t,r,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,v=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,r[i+4]=v,r[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,r[i+10]=v,r[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,r[i+16]=v,r[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,r[i+22]=v,r[i+23]=S}_updateMaxTextures(e){this.shader.maxTextures!==e&&(er=new To(e),this.shader=er)}destroy(){this.shader=null,super.destroy()}};bl.extension={type:[b.Batcher],name:"default"};let ki=bl;class ze{constructor(e){this.items=Object.create(null);const{renderer:t,type:r,onUnload:i,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",r,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 r=e._gpuData[this._renderer.uid];r&&((i=this._onUnload)==null||i.call(this,e,...t),r.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 mf(s,e,t,r,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=s[t],m=s[t+1];r[i]=h*g+u*m+f,r[i+1]=c*g+d*m+p,i+=n,t+=e,l++}}function gf(s,e,t,r){let i=0;for(e*=t;i<r;)s[e]=0,s[e+1]=0,e+=t,i++}function Tl(s,e,t,r,i){const n=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;t||(t=0),r||(r=2),i||(i=s.length/r-t);let u=t*r;for(let d=0;d<i;d++){const f=s[u],p=s[u+1];s[u]=n*f+a*p+h,s[u+1]=o*f+l*p+c,u+=r}}const _f=new G;class Ii{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,r=this.renderable;return r?Dt(t,r.groupColor)+(this.alpha*r.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){var e;return((e=this.renderable)==null?void 0:e.groupTransform)||_f}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 xr={extension:{type:b.ShapeBuilder,name:"circle"},build(s,e){let t,r,i,n,o,a;if(s.type==="circle"){const v=s;if(o=a=v.radius,o<=0)return!1;t=v.x,r=v.y,i=n=0}else if(s.type==="ellipse"){const v=s;if(o=v.halfWidth,a=v.halfHeight,o<=0||a<=0)return!1;t=v.x,r=v.y,i=n=0}else{const v=s,S=v.width/2,T=v.height/2;t=v.x+S,r=v.y+T,o=a=Math.max(0,Math.min(v.radius,Math.min(S,T))),i=S-o,n=T-a}if(i<0||n<0)return!1;const 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]=r+n,e[2]=e[4]=t-i,e[5]=e[7]=r-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=r+g;if(e[c++]=m,e[c++]=x,e[--u]=x,e[--u]=_,n){const v=r-g;e[d++]=_,e[d++]=v,e[--f]=v,e[--f]=m}for(let v=1;v<l;v++){const S=Math.PI/2*(v/l),T=i+Math.cos(S)*o,C=n+Math.sin(S)*a,B=t+T,M=t-T,w=r+C,E=r-C;e[c++]=B,e[c++]=w,e[--u]=w,e[--u]=M,e[d++]=M,e[d++]=E,e[--f]=E,e[--f]=B}p=i,g=n+a,m=t+p,_=t-p,x=r+g;const y=r-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(s,e,t,r,i,n){if(s.length===0)return;let o=0,a=0;for(let c=0;c<s.length;c+=2)o+=s[c],a+=s[c+1];o/=s.length/2,a/=s.length/2;let l=r;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<s.length;c+=2)e[l*t]=s[c],e[l*t+1]=s[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}},xf={...xr,extension:{...xr.extension,name:"ellipse"}},yf={...xr,extension:{...xr.extension,name:"roundedRectangle"}},Sl=1e-4,So=1e-4;function bf(s){const e=s.length;if(e<6)return 1;let t=0;for(let r=0,i=s[e-2],n=s[e-1];r<e;r+=2){const o=s[r],a=s[r+1];t+=(o-i)*(a+n),i=o,n=a}return t<0?-1:1}function Co(s,e,t,r,i,n,o,a){const l=s-t*i,h=e-r*i,c=s+t*n,u=e+r*n;let d,f;o?(d=r,f=-t):(d=-r,f=t);const p=l+d,g=h+f,m=c+d,_=u+f;return a.push(p,g),a.push(m,_),2}function lt(s,e,t,r,i,n,o,a){const l=t-s,h=r-e;let c=Math.atan2(l,h),u=Math.atan2(i-s,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(s,e),o.push(t,r);for(let x=1,y=d;x<m;x++,y+=_)o.push(s,e),o.push(s+Math.sin(y)*g,e+Math.cos(y)*g);o.push(s,e),o.push(i,n)}else{o.push(t,r),o.push(s,e);for(let x=1,y=d;x<m;x++,y+=_)o.push(s+Math.sin(y)*g,e+Math.cos(y)*g),o.push(s,e);o.push(i,n),o.push(s,e)}return m*2}function Gi(s,e,t,r,i,n){const o=Sl;if(s.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let R=bf(s);l=(l-.5)*R+.5}const h=new re(s[0],s[1]),c=new re(s[s.length-2],s[s.length-1]),u=r,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){s=s.slice(),d&&(s.pop(),s.pop(),c.set(s[s.length-2],s[s.length-1]));const R=(h.x+c.x)*.5,L=(c.y+h.y)*.5;s.unshift(R,L),s.push(R,L)}const f=i,p=s.length/2;let g=s.length;const m=f.length/2,_=a.width/2,x=_*_,y=a.miterLimit*a.miterLimit;let v=s[0],S=s[1],T=s[2],C=s[3],B=0,M=0,w=-(S-C),E=v-T,A=0,I=0,F=Math.sqrt(w*w+E*E);w/=F,E/=F,w*=_,E*=_;const le=l,P=(1-le)*2,k=le*2;u||(a.cap==="round"?g+=lt(v-w*(P-k)*.5,S-E*(P-k)*.5,v-w*P,S-E*P,v+w*k,S+E*k,f,!0)+2:a.cap==="square"&&(g+=Co(v,S,w,E,P,k,!0,f))),f.push(v-w*P,S-E*P),f.push(v+w*k,S+E*k);for(let R=1;R<p-1;++R){v=s[(R-1)*2],S=s[(R-1)*2+1],T=s[R*2],C=s[R*2+1],B=s[(R+1)*2],M=s[(R+1)*2+1],w=-(S-C),E=v-T,F=Math.sqrt(w*w+E*E),w/=F,E/=F,w*=_,E*=_,A=-(C-M),I=T-B,F=Math.sqrt(A*A+I*I),A/=F,I/=F,A*=_,I*=_;const L=T-v,j=S-C,U=T-B,q=M-C,se=L*U+j*q,oe=j*U-q*L,Z=oe<0;if(Math.abs(oe)<.001*Math.abs(se)){f.push(T-w*P,C-E*P),f.push(T+w*k,C+E*k),se>=0&&(a.join==="round"?g+=lt(T,C,T-w*P,C-E*P,T-A*P,C-I*P,f,!1)+4:g+=2,f.push(T-A*k,C-I*k),f.push(T+A*P,C+I*P));continue}const fe=(-w+v)*(-E+C)-(-w+T)*(-E+S),ye=(-A+B)*(-I+C)-(-A+T)*(-I+M),V=(L*ye-U*fe)/oe,Se=(q*fe-j*ye)/oe,Ee=(V-T)*(V-T)+(Se-C)*(Se-C),ue=T+(V-T)*P,Oe=C+(Se-C)*P,Ie=T-(V-T)*k,Me=C-(Se-C)*k,vt=Math.min(L*L+j*j,U*U+q*q),Tt=Z?P:k,jt=vt+Tt*Tt*x;Ee<=jt?a.join==="bevel"||Ee/x>y?(Z?(f.push(ue,Oe),f.push(T+w*k,C+E*k),f.push(ue,Oe),f.push(T+A*k,C+I*k)):(f.push(T-w*P,C-E*P),f.push(Ie,Me),f.push(T-A*P,C-I*P),f.push(Ie,Me)),g+=2):a.join==="round"?Z?(f.push(ue,Oe),f.push(T+w*k,C+E*k),g+=lt(T,C,T+w*k,C+E*k,T+A*k,C+I*k,f,!0)+4,f.push(ue,Oe),f.push(T+A*k,C+I*k)):(f.push(T-w*P,C-E*P),f.push(Ie,Me),g+=lt(T,C,T-w*P,C-E*P,T-A*P,C-I*P,f,!1)+4,f.push(T-A*P,C-I*P),f.push(Ie,Me)):(f.push(ue,Oe),f.push(Ie,Me)):(f.push(T-w*P,C-E*P),f.push(T+w*k,C+E*k),a.join==="round"?Z?g+=lt(T,C,T+w*k,C+E*k,T+A*k,C+I*k,f,!0)+2:g+=lt(T,C,T-w*P,C-E*P,T-A*P,C-I*P,f,!1)+2:a.join==="miter"&&Ee/x<=y&&(Z?(f.push(Ie,Me),f.push(Ie,Me)):(f.push(ue,Oe),f.push(ue,Oe)),g+=2),f.push(T-A*P,C-I*P),f.push(T+A*k,C+I*k),g+=2)}v=s[(p-2)*2],S=s[(p-2)*2+1],T=s[(p-1)*2],C=s[(p-1)*2+1],w=-(S-C),E=v-T,F=Math.sqrt(w*w+E*E),w/=F,E/=F,w*=_,E*=_,f.push(T-w*P,C-E*P),f.push(T+w*k,C+E*k),u||(a.cap==="round"?g+=lt(T-w*(P-k)*.5,C-E*(P-k)*.5,T-w*P,C-E*P,T+w*k,C+E*k,f,!1)+2:a.cap==="square"&&(g+=Co(T,C,w,E,P,k,!1,f)));const D=So*So;for(let R=m;R<g+m-2;++R)v=f[R*2],S=f[R*2+1],T=f[(R+1)*2],C=f[(R+1)*2+1],B=f[(R+2)*2],M=f[(R+2)*2+1],!(Math.abs(v*(C-M)+T*(M-S)+B*(S-C))<D)&&n.push(R,R+1,R+2)}function vf(s,e,t,r){const i=Sl;if(s.length===0)return;const n=s[0],o=s[1],a=s[s.length-2],l=s[s.length-1],h=e||Math.abs(n-a)<i&&Math.abs(o-l)<i,c=t,u=s.length/2,d=c.length/2;for(let f=0;f<u;f++)c.push(s[f*2]),c.push(s[f*2+1]);for(let f=0;f<u-1;f++)r.push(d+f,d+f+1);h&&r.push(d+u-1,d)}function Cl(s,e,t,r,i,n,o){const a=wd(s,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*r;for(let h=0;h<s.length;h+=2)t[l]=s[h],t[l+1]=s[h+1],l+=r}const Tf=[],Sf={extension:{type:b.ShapeBuilder,name:"polygon"},build(s,e){for(let t=0;t<s.points.length;t++)e[t]=s.points[t];return!0},triangulate(s,e,t,r,i,n){Cl(s,Tf,e,t,r,i,n)}},Cf={extension:{type:b.ShapeBuilder,name:"rectangle"},build(s,e){const t=s,r=t.x,i=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=r,e[1]=i,e[2]=r+n,e[3]=i,e[4]=r+n,e[5]=i+o,e[6]=r,e[7]=i+o,!0):!1},triangulate(s,e,t,r,i,n){let o=0;r*=t,e[r+o]=s[0],e[r+o+1]=s[1],o+=t,e[r+o]=s[2],e[r+o+1]=s[3],o+=t,e[r+o]=s[6],e[r+o+1]=s[7],o+=t,e[r+o]=s[4],e[r+o+1]=s[5],o+=t;const a=r/t;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},wf={extension:{type:b.ShapeBuilder,name:"triangle"},build(s,e){return e[0]=s.x,e[1]=s.y,e[2]=s.x2,e[3]=s.y2,e[4]=s.x3,e[5]=s.y3,!0},triangulate(s,e,t,r,i,n){let o=0;r*=t,e[r+o]=s[0],e[r+o+1]=s[1],o+=t,e[r+o]=s[2],e[r+o+1]=s[3],o+=t,e[r+o]=s[4],e[r+o+1]=s[5];const a=r/t;i[n++]=a,i[n++]=a+1,i[n++]=a+2}},wo=[{offset:0,color:"white"},{offset:1,color:"black"}],Fi=class si{constructor(...e){this.uid=te("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=Pf(e);t={...t.type==="radial"?si.defaultRadialOptions:si.defaultLinearOptions,...da(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:Q.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:r,y:i}=this.end,n=r-e,o=i-t;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=e;e=r,r=m,n*=-1}if(o<0){const m=t;t=i,i=m,o*=-1}}const l=this.colorStops.length?this.colorStops:wo,h=this._textureSize,{canvas:c,context:u}=Eo(h,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Po(d,l),u.fillStyle=d,u.fillRect(0,0,h,1),this.texture=new N({source:new Zr({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),g=new G;g.scale(f/h,1),g.rotate(p),g.translate(e,t),this.textureSpace==="local"&&g.scale(h,h),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:wo,t=this._textureSize,{canvas:r,context:i}=Eo(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);Po(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 N({source:new Zr({resource:r,addressMode:this._wrapMode})});const _=new G;_.scale(1/f,1/f),_.translate(u,d),this.textureSpace==="local"&&_.scale(t,t),this.transform=_}destroy(){var e;(e=this.texture)==null||e.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Fi.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Fi.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let We=Fi;function Po(s,e){for(let t=0;t<e.length;t++){const r=e[t];s.addColorStop(r.offset,r.color)}}function Eo(s,e){const t=Y.get().createCanvas(s,e),r=t.getContext("2d");return{canvas:t,context:r}}function Pf(s){let e=s[0]??{};return(typeof e=="number"||s[1])&&(O("8.5.2","use options object instead"),e={type:"linear",start:{x:s[0],y:s[1]},end:{x:s[2],y:s[3]},textureSpace:s[4],textureSize:s[5]??We.defaultLinearOptions.textureSize}),e}const Ef=new G,Mf=new ee;function wl(s,e,t,r){const i=e.matrix?s.copyFrom(e.matrix).invert():s.identity();if(e.textureSpace==="local"){const o=t.getBounds(Mf);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 We)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),r&&i.append(Ef.copyFrom(r).invert()),i}const Yt={};W.handleByMap(b.ShapeBuilder,Yt);W.add(Cf,Sf,wf,xr,xf,yf);const Af=new ee,Rf=new G;function Bf(s,e){const{geometryData:t,batches:r}=e;r.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let i=0;i<s.instructions.length;i++){const n=s.instructions[i];if(n.action==="texture")kf(n.data,r,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&&Mo(h.shapePath,l,!0,r,t),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),Mo(a,l,o,r,t)}}}function kf(s,e,t){const r=[],i=Yt.rectangle,n=Af;n.x=s.dx,n.y=s.dy,n.width=s.dw,n.height=s.dh;const o=s.transform;if(!i.build(n,r))return;const{vertices:a,uvs:l,indices:h}=t,c=h.length,u=a.length/2;o&&Tl(r,o),i.triangulate(r,a,2,u,h,c);const d=s.image,f=d.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=ge.get(Ii);p.indexOffset=c,p.indexSize=h.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=s.style,p.alpha=s.alpha,p.texture=d,p.geometryData=t,e.push(p)}function Mo(s,e,t,r,i){const{vertices:n,uvs:o,indices:a}=i;s.shapePrimitives.forEach(({shape:l,transform:h,holes:c})=>{const u=[],d=Yt[l.type];if(!d.build(l,u))return;const f=a.length,p=n.length/2;let g="triangle-list";if(h&&Tl(u,h),t){const y=l.closePath??!0,v=e;v.pixelLine?(vf(u,y,n,a),g="line-list"):Gi(u,v,!1,y,n,a)}else if(c){const y=[],v=u.slice();If(c).forEach(T=>{y.push(v.length/2),v.push(...T)}),Cl(v,y,n,2,p,a,f)}else d.triangulate(u,n,2,p,a,f);const m=o.length/2,_=e.texture;if(_!==N.WHITE){const y=wl(Rf,e,l,h);mf(n,2,p,o,m,2,n.length/2-p,y)}else gf(o,m,2,n.length/2-p);const x=ge.get(Ii);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,r.push(x)})}function If(s){const e=[];for(let t=0;t<s.length;t++){const r=s[t].shape,i=[];Yt[r.type].build(r,i)&&e.push(i)}return e}class Gf{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{ge.return(e)}),this.graphicsData&&ge.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 Ff{constructor(){this.instructions=new yi}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new ki({maxTextures:t}),this.instructions.reset()}get geometry(){return O(Wc,"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 Ui=class ii{constructor(e){this._renderer=e,this._managedContexts=new ze({renderer:e,type:"resource",name:"graphicsContext"})}init(e){ii.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??ii.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],r=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&r.reset(),Bf(e,r);const i=e.batchMode;e.customShader||i==="no-batch"?r.isBatchable=!1:i==="auto"?r.isBatchable=r.geometryData.vertices.length<400:r.isBatchable=!0,e.dirty=!1}return r}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=ge.get(Ff,{maxTextures:this._renderer.limits.maxBatchableTextures}),r=e._gpuData[this._renderer.uid],{batches:i,geometryData:n}=r;r.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=Pi(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new Gf;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Ui.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"graphicsContext"};Ui.defaultOptions={bezierSmoothness:.5};let Di=Ui;const Uf=8,Dr=11920929e-14,Df=1;function Pl(s,e,t,r,i,n,o,a,l,h){const u=Math.min(.99,Math.max(0,h??Di.defaultOptions.bezierSmoothness));let d=(Df-u)/1;return d*=d,Of(e,t,r,i,n,o,a,l,s,d),s}function Of(s,e,t,r,i,n,o,a,l,h){ni(s,e,t,r,i,n,o,a,l,h,0),l.push(o,a)}function ni(s,e,t,r,i,n,o,a,l,h,c){if(c>Uf)return;const u=(s+t)/2,d=(e+r)/2,f=(t+i)/2,p=(r+n)/2,g=(i+o)/2,m=(n+a)/2,_=(u+f)/2,x=(d+p)/2,y=(f+g)/2,v=(p+m)/2,S=(_+y)/2,T=(x+v)/2;if(c>0){let C=o-s,B=a-e;const M=Math.abs((t-o)*B-(r-a)*C),w=Math.abs((i-o)*B-(n-a)*C);if(M>Dr&&w>Dr){if((M+w)*(M+w)<=h*(C*C+B*B)){l.push(S,T);return}}else if(M>Dr){if(M*M<=h*(C*C+B*B)){l.push(S,T);return}}else if(w>Dr){if(w*w<=h*(C*C+B*B)){l.push(S,T);return}}else if(C=S-(s+o)/2,B=T-(e+a)/2,C*C+B*B<=h){l.push(S,T);return}}ni(s,e,u,d,_,x,S,T,l,h,c+1),ni(S,T,y,v,g,m,o,a,l,h,c+1)}const Lf=8,Nf=11920929e-14,Hf=1;function Wf(s,e,t,r,i,n,o,a){const h=Math.min(.99,Math.max(0,a??Di.defaultOptions.bezierSmoothness));let c=(Hf-h)/1;return c*=c,zf(e,t,r,i,n,o,s,c),s}function zf(s,e,t,r,i,n,o,a){oi(o,s,e,t,r,i,n,a,0),o.push(i,n)}function oi(s,e,t,r,i,n,o,a,l){if(l>Lf)return;const h=(e+r)/2,c=(t+i)/2,u=(r+n)/2,d=(i+o)/2,f=(h+u)/2,p=(c+d)/2;let g=n-e,m=o-t;const _=Math.abs((r-n)*m-(i-o)*g);if(_>Nf){if(_*_<=a*(g*g+m*m)){s.push(f,p);return}}else if(g=f-(e+n)/2,m=p-(t+o)/2,g*g+m*m<=a){s.push(f,p);return}oi(s,e,t,h,c,f,p,a,l+1),oi(s,f,p,u,d,n,o,a,l+1)}function El(s,e,t,r,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(r,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*r,g=t+f*r;s.push(p,g),c+=h}}function Vf(s,e,t,r,i,n){const o=s[s.length-2],l=s[s.length-1]-t,h=o-e,c=i-t,u=r-e,d=Math.abs(l*u-h*c);if(d<1e-8||n===0){(s[s.length-2]!==e||s[s.length-1]!==t)&&s.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,v=m*u+_*h,S=m*c+_*l,T=h*(_+x),C=l*(_+x),B=u*(m+y),M=c*(m+y),w=Math.atan2(C-S,T-v),E=Math.atan2(M-S,B-v);El(s,v+e,S+t,n,w,E,h*c>u*l)}const cr=Math.PI*2,Fs={centerX:0,centerY:0,ang1:0,ang2:0},Us=({x:s,y:e},t,r,i,n,o,a,l)=>{s*=t,e*=r;const h=i*s-n*e,c=n*s+i*e;return l.x=h+o,l.y=c+a,l};function Xf(s,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=e===1.5707963267948966?.551915024494:t,i=Math.cos(s),n=Math.sin(s),o=Math.cos(s+e),a=Math.sin(s+e);return[{x:i-n*r,y:n+i*r},{x:o+a*r,y:a-o*r},{x:o,y:a}]}const Ao=(s,e,t,r)=>{const i=s*r-e*t<0?-1:1;let n=s*t+e*r;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},$f=(s,e,t,r,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,v=h*x-l*y+(s+t)/2,S=l*x+h*y+(e+r)/2,T=(c-x)/i,C=(u-y)/n,B=(-c-x)/i,M=(-u-y)/n,w=Ao(1,0,T,C);let E=Ao(T,C,B,M);a===0&&E>0&&(E-=cr),a===1&&E<0&&(E+=cr),d.centerX=v,d.centerY=S,d.ang1=w,d.ang2=E};function Yf(s,e,t,r,i,n,o,a=0,l=0,h=0){if(n===0||o===0)return;const c=Math.sin(a*cr/360),u=Math.cos(a*cr/360),d=u*(e-r)/2+c*(t-i)/2,f=-c*(e-r)/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)),$f(e,t,r,i,n,o,l,h,c,u,d,f,Fs);let{ang1:g,ang2:m}=Fs;const{centerX:_,centerY:x}=Fs;let y=Math.abs(m)/(cr/4);Math.abs(1-y)<1e-7&&(y=1);const v=Math.max(Math.ceil(y),1);m/=v;let S=s[s.length-2],T=s[s.length-1];const C={x:0,y:0};for(let B=0;B<v;B++){const M=Xf(g,m),{x:w,y:E}=Us(M[0],n,o,u,c,_,x,C),{x:A,y:I}=Us(M[1],n,o,u,c,_,x,C),{x:F,y:le}=Us(M[2],n,o,u,c,_,x,C);Pl(s,S,T,w,E,A,I,F,le),S=F,T=le,g+=m}}function jf(s,e,t){const r=(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?s.moveTo(a.x,a.y):s.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=r(a,n),u=r(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,v=Math.atan2(c.ny,c.nx)+Math.PI/2*f,S=Math.atan2(u.ny,u.nx)-Math.PI/2*f;o===0&&s.moveTo(x+Math.cos(v)*m,y+Math.sin(v)*m),s.arc(x,y,m,v,S,p),n=a}}function qf(s,e,t,r){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?s.moveTo(l.x,l.y):s.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?s.moveTo(f.x,f.y):s.lineTo(f.x,f.y),s.quadraticCurveTo(l.x,l.y,g.x,g.y,r)}}const Kf=new ee;class Zf{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new xe,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const r=this._currentPoly.points,i=r[r.length-2],n=r[r.length-1];return(i!==e||n!==t)&&r.push(e,t),this}arc(e,t,r,i,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return El(a,e,t,r,i,n,o),this}arcTo(e,t,r,i,n){this._ensurePoly();const o=this._currentPoly.points;return Vf(o,e,t,r,i,n),this}arcToSvg(e,t,r,i,n,o,a){const l=this._currentPoly.points;return Yf(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,r,i,n),this}bezierCurveTo(e,t,r,i,n,o,a){this._ensurePoly();const l=this._currentPoly;return Pl(this._currentPoly.points,l.lastX,l.lastY,e,t,r,i,n,o,a),this}quadraticCurveTo(e,t,r,i,n){this._ensurePoly();const o=this._currentPoly;return Wf(this._currentPoly.points,o.lastX,o.lastY,e,t,r,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 r=this.shapePrimitives,i=r.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&r.length-i>1){let n=null;for(let o=i;o<r.length;o++){const a=r[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),r.copyWithin(o,o+1),r.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,r,i,n){return this.drawShape(new ee(e,t,r,i),n),this}circle(e,t,r,i){return this.drawShape(new Si(e,t,r),i),this}poly(e,t,r){const i=new lr(e);return i.closePath=t,this.drawShape(i,r),this}regularPoly(e,t,r,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+r*Math.cos(u),t+r*Math.sin(u))}return this.poly(h,!0,o),this}roundPoly(e,t,r,i,n,o=0,a){if(i=Math.max(i|0,3),n<=0)return this.regularPoly(e,t,r,i,o);const l=r*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+r*Math.cos(f),g=t+r*Math.sin(f),m=f+Math.PI+u,_=f-Math.PI-u,x=p+n*Math.cos(m),y=g+n*Math.sin(m),v=p+n*Math.cos(_),S=g+n*Math.sin(_);d===0?this.moveTo(x,y):this.lineTo(x,y),this.quadraticCurveTo(p,g,v,S,a)}return this.closePath()}roundShape(e,t,r=!1,i){return e.length<3?this:(r?qf(this,e,t,i):jf(this,e,t),this.closePath())}filletRect(e,t,r,i,n){if(n===0)return this.rect(e,t,r,i);const o=Math.min(r,i)/2,a=Math.min(o,Math.max(-o,n)),l=e+r,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+r-u,h,u).lineTo(e+u,h).arcTo(e+c,h-c,e,h-u,u).closePath()}chamferRect(e,t,r,i,n,o){if(n<=0)return this.rect(e,t,r,i);const a=Math.min(n,Math.min(r,i)/2),l=e+r,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,r,i,n){return this.drawShape(new Ci(e,t,r,i),n),this}roundRect(e,t,r,i,n,o){return this.drawShape(new wi(e,t,r,i,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let r=this._currentPoly;return r&&this.endPoly(),r=new lr,r.points.push(e,t),this._currentPoly=r,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 lr,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let r=t.shape.x,i=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,o=r;r=n.a*r+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(r,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 r=e.instructions[t];this[r.action](...r.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let r=0;r<t.length;r++){const i=t[r],n=i.shape.getBounds(Kf);i.transform?e.addRect(n,i.transform):e.addRect(n)}return e}}class Ke{constructor(e,t=!1){this.instructions=[],this.uid=te("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?Gd(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Zf(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,r,i,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(re.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,r,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,r){const i=this.instructions[this.instructions.length-1],n=this.getLastPoint(re.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,r]}),this._dirty=!0,this}rect(e,t,r,i,n){return this.instructions.push({action:"rect",data:[e,t,r,i,n]}),this._dirty=!0,this}circle(e,t,r,i){return this.instructions.push({action:"circle",data:[e,t,r,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,r,i,n,o,a){n||(n=i/2);const l=-1*Math.PI/2+o,h=r*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 Ke;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let r=0;r<this.instructions.length;r++){const i=this.instructions[r];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,r=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]=r*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]=r*c+n*u+a,x[2]=t*d+i*f+o,x[3]=r*d+n*f+a,x[4]=t*l+i*h+o,x[5]=r*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]=r*c+n*u+a,x[2]=t*l+i*h+o,x[3]=r*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]=r*p+n*g,x[5]=t*l+i*h+o,x[6]=r*l+n*h+a;break;case"circle":x[4]=Mt(x[3],e);break;case"rect":x[4]=Mt(x[4],e);break;case"ellipse":x[8]=Mt(x[8],e);break;case"roundRect":x[5]=Mt(x[5],e);break;case"addPath":x[0].transform(e);break;case"poly":x[2]=Mt(x[2],e);break;case"regularPoly":case"chamferRect":x[5]=Mt(x[5],e);break;case"closePath":break;default:z("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,r=this.instructions[t];if(!r)return e.x=0,e.y=0,e;for(;r.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;r=this.instructions[t]}switch(r.action){case"moveTo":case"lineTo":e.x=r.data[0],e.y=r.data[1];break;case"quadraticCurveTo":e.x=r.data[2],e.y=r.data[3];break;case"bezierCurveTo":e.x=r.data[4],e.y=r.data[5];break;case"arc":case"arcToSvg":e.x=r.data[5],e.y=r.data[6];break;case"addPath":r.data[0].getLastPoint(e);break}return e}}function Mt(s,e){return s?s.prepend(e):e.clone()}function he(s,e,t){const r=s.getAttribute(e);return r?Number(r):t}function Qf(s,e){const t=s.querySelectorAll("defs");for(let r=0;r<t.length;r++){const i=t[r];for(let n=0;n<i.children.length;n++){const o=i.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=Jf(o);break;case"radialgradient":e.defs[o.id]=ep();break}}}}function Jf(s){const e=he(s,"x1",0),t=he(s,"y1",0),r=he(s,"x2",1),i=he(s,"y2",0),n=s.getAttribute("gradientUnits")||"objectBoundingBox",o=new We(e,t,r,i,n==="objectBoundingBox"?"local":"global");for(let a=0;a<s.children.length;a++){const l=s.children[a],h=he(l,"offset",0),c=Q.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(h,c)}return o}function ep(s){return z("[SVG Parser] Radial gradients are not yet supported"),new We(0,0,1,0)}function Ro(s){const e=s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const Bo={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 Ml(s,e){const t=s.getAttribute("style"),r={},i={},n={strokeStyle:r,fillStyle:i,useFill:!1,useStroke:!1};for(const o in Bo){const a=s.getAttribute(o);a&&ko(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(":");Bo[h]&&ko(e,n,h,c.trim())}}return{strokeStyle:n.useStroke?r:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function ko(s,e,t,r){switch(t){case"stroke":if(r!=="none"){if(r.startsWith("url(")){const i=Ro(r);e.strokeStyle.fill=s.defs[i]}else e.strokeStyle.color=Q.shared.setValue(r).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(r);break;case"fill":if(r!=="none"){if(r.startsWith("url(")){const i=Ro(r);e.fillStyle.fill=s.defs[i]}else e.fillStyle.color=Q.shared.setValue(r).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(r);break;case"stroke-opacity":e.strokeStyle.alpha=Number(r);break;case"opacity":e.fillStyle.alpha=Number(r),e.strokeStyle.alpha=Number(r);break}}function tp(s){if(s.length<=2)return!0;const e=s.map(a=>a.area).sort((a,l)=>l-a),[t,r]=e,i=e[e.length-1],n=t/r,o=r/i;return!(n>3&&o<2)}function rp(s){return s.split(/(?=[Mm])/).filter(r=>r.trim().length>0)}function sp(s){const e=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),r=[],i=[];for(let c=0;c<t.length;c+=2)c+1<t.length&&(r.push(t[c]),i.push(t[c+1]));if(r.length===0||i.length===0)return 0;const n=Math.min(...r),o=Math.max(...r),a=Math.min(...i),l=Math.max(...i);return(o-n)*(l-a)}function Io(s,e){const t=new Ke(s,!1);for(const r of t.instructions)e.instructions.push(r)}function ip(s,e){if(typeof s=="string"){const o=document.createElement("div");o.innerHTML=s.trim(),s=o.querySelector("svg")}const t={context:e,defs:{},path:new Ke};Qf(s,t);const r=s.children,{fillStyle:i,strokeStyle:n}=Ml(s,t);for(let o=0;o<r.length;o++){const a=r[o];a.nodeName.toLowerCase()!=="defs"&&Al(a,t,i,n)}return e}function Al(s,e,t,r){const i=s.children,{fillStyle:n,strokeStyle:o}=Ml(s,e);n&&t?t={...t,...n}:n&&(t=n),o&&r?r={...r,...o}:o&&(r=o);const a=!t&&!r;a&&(t={color:0});let l,h,c,u,d,f,p,g,m,_,x,y,v,S,T,C,B;switch(s.nodeName.toLowerCase()){case"path":{S=s.getAttribute("d");const M=s.getAttribute("fill-rule"),w=rp(S),E=M==="evenodd",A=w.length>1;if(E&&A){const F=w.map(P=>({path:P,area:sp(P)}));if(F.sort((P,k)=>k.area-P.area),w.length>3||!tp(F))for(let P=0;P<F.length;P++){const k=F[P],D=P===0;e.context.beginPath();const R=new Ke(void 0,!0);Io(k.path,R),e.context.path(R),D?(t&&e.context.fill(t),r&&e.context.stroke(r)):e.context.cut()}else for(let P=0;P<F.length;P++){const k=F[P],D=P%2===1;e.context.beginPath();const R=new Ke(void 0,!0);Io(k.path,R),e.context.path(R),D?e.context.cut():(t&&e.context.fill(t),r&&e.context.stroke(r))}}else{const F=M?M==="evenodd":!0;T=new Ke(S,F),e.context.path(T),t&&e.context.fill(t),r&&e.context.stroke(r)}break}case"circle":p=he(s,"cx",0),g=he(s,"cy",0),m=he(s,"r",0),e.context.ellipse(p,g,m,m),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"rect":l=he(s,"x",0),h=he(s,"y",0),C=he(s,"width",0),B=he(s,"height",0),_=he(s,"rx",0),x=he(s,"ry",0),_||x?e.context.roundRect(l,h,C,B,_||x):e.context.rect(l,h,C,B),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"ellipse":p=he(s,"cx",0),g=he(s,"cy",0),_=he(s,"rx",0),x=he(s,"ry",0),e.context.beginPath(),e.context.ellipse(p,g,_,x),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"line":c=he(s,"x1",0),u=he(s,"y1",0),d=he(s,"x2",0),f=he(s,"y2",0),e.context.beginPath(),e.context.moveTo(c,u),e.context.lineTo(d,f),r&&e.context.stroke(r);break;case"polygon":v=s.getAttribute("points"),y=v.match(/-?\d+/g).map(M=>parseInt(M,10)),e.context.poly(y,!0),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"polyline":v=s.getAttribute("points"),y=v.match(/-?\d+/g).map(M=>parseInt(M,10)),e.context.poly(y,!1),r&&e.context.stroke(r);break;case"g":case"svg":break;default:{z(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(t=null);for(let M=0;M<i.length;M++)Al(i[M],e,t,r)}const Go={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 Tr{constructor(e,t){this.uid=te("fillPattern"),this._tick=0,this.transform=new G,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=Go[t].addressModeU,e.source.style.addressModeV=Go[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 np(s){return Q.isColorLike(s)}function Fo(s){return s instanceof Tr}function Uo(s){return s instanceof We}function op(s){return s instanceof N}function ap(s,e,t){const r=Q.shared.setValue(e??0);return s.color=r.toNumber(),s.alpha=r.alpha===1?t.alpha:r.alpha,s.texture=N.WHITE,{...t,...s}}function lp(s,e,t){return s.texture=e,{...t,...s}}function Do(s,e,t){return s.fill=e,s.color=16777215,s.texture=e.texture,s.matrix=e.transform,{...t,...s}}function Oo(s,e,t){return e.buildGradient(),s.fill=e,s.color=16777215,s.texture=e.texture,s.matrix=e.transform,s.textureSpace=e.textureSpace,{...t,...s}}function hp(s,e){const t={...e,...s},r=Q.shared.setValue(t.color);return t.alpha*=r.alpha,t.color=r.toNumber(),t}function _t(s,e){if(s==null)return null;const t={},r=s;return np(s)?ap(t,s,e):op(s)?lp(t,s,e):Fo(s)?Do(t,s,e):Uo(s)?Oo(t,s,e):r.fill&&Fo(r.fill)?Do(r,r.fill,e):r.fill&&Uo(r.fill)?Oo(r,r.fill,e):hp(r,e)}function es(s,e){const{width:t,alignment:r,miterLimit:i,cap:n,join:o,pixelLine:a,...l}=e,h=_t(s,l);return h?{width:t,alignment:r,miterLimit:i,cap:n,join:o,pixelLine:a,...h}:null}function cp(s,e){let t=1;const r=s.shapePath.shapePrimitives;for(let i=0;i<r.length;i++){const n=r[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,v=m-p,S=_-g,T=x*x+y*y,C=v*v+S*S;if(T<1e-12||C<1e-12)continue;let w=(x*v+y*S)/Math.sqrt(T*C);w<-1?w=-1:w>1&&(w=1);const E=Math.sqrt((1-w)*.5);if(E<1e-6)continue;const A=Math.min(1/E,e);A>t&&(t=A)}}return t}const up=new re,Lo=new G,Oi=class Ne extends ke{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=te("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Ke,this._transform=new G,this._fillStyle={...Ne.defaultFillStyle},this._strokeStyle={...Ne.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new xe,this._boundsDirty=!0}clone(){const e=new Ne;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=_t(e,Ne.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=es(e,Ne.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=_t(e,Ne.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=_t(e,Ne.defaultStrokeStyle),this}texture(e,t,r,i,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:r||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?Q.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Ke,this}fill(e,t){let r;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="stroke"?r=i.data.path:r=this._activePath.clone(),r?(e!=null&&(t!==void 0&&typeof e=="number"&&(O(ie,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=_t(e,Ne.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(re.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const r=this.instructions[this.instructions.length-1];return this._tick===0&&(r==null?void 0:r.action)==="fill"?t=r.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=es(e,Ne.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],r=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(r);else{t.data.hole=r;break}}return this._initNextPathLocation(),this}arc(e,t,r,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,r,i,n,o),this}arcTo(e,t,r,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*r+o.c*i+o.tx,o.b*r+o.d*i+o.ty,n),this}arcToSvg(e,t,r,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(e,t,r,i,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,t,r,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*r+l.c*i+l.tx,l.b*r+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,r,i){return this._tick++,this._activePath.ellipse(e,t,r,i,this._transform.clone()),this}circle(e,t,r){return this._tick++,this._activePath.circle(e,t,r,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const r=this._transform;return this._activePath.lineTo(r.a*e+r.c*t+r.tx,r.b*e+r.d*t+r.ty),this}moveTo(e,t){this._tick++;const r=this._transform,i=this._activePath.instructions,n=r.a*e+r.c*t+r.tx,o=r.b*e+r.d*t+r.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,r,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*r+o.c*i+o.tx,o.b*r+o.d*i+o.ty,n),this}rect(e,t,r,i){return this._tick++,this._activePath.rect(e,t,r,i,this._transform.clone()),this}roundRect(e,t,r,i,n){return this._tick++,this._activePath.roundRect(e,t,r,i,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,r,i,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,r,i,n,o),this}roundPoly(e,t,r,i,n,o){return this._tick++,this._activePath.roundPoly(e,t,r,i,n,o),this}roundShape(e,t,r,i){return this._tick++,this._activePath.roundShape(e,t,r,i),this}filletRect(e,t,r,i,n){return this._tick++,this._activePath.filletRect(e,t,r,i,n),this}chamferRect(e,t,r,i,n,o){return this._tick++,this._activePath.chamferRect(e,t,r,i,n,o),this}star(e,t,r,i,n=0,o=0){return this._tick++,this._activePath.star(e,t,r,i,n,o,this._transform.clone()),this}svg(e){return this._tick++,ip(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,r,i,n,o){return e instanceof G?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,r,i,n,o),this)}transform(e,t,r,i,n,o){return e instanceof G?(this._transform.append(e),this):(Lo.set(e,t,r,i,n,o),this._transform.append(Lo),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 r=this.instructions[t],i=r.action;if(i==="fill"){const n=r.data;e.addBounds(n.path.bounds)}else if(i==="texture"){const n=r.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(i==="stroke"){const n=r.data,o=n.style.alignment;let a=n.style.width*(1-o);n.style.join==="miter"&&(a*=cp(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 r=!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,up):e;if(o.action==="fill")r=d.contains(p.x,p.y);else{const m=h;r=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)&&(r=!1)}if(r)return!0}}return r}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 r=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(r)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(r))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Oi.defaultFillStyle={color:16777215,alpha:1,texture:N.WHITE,matrix:null,fill:null,textureSpace:"local"};Oi.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:N.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ue=Oi;class Rl{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 Na({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 r=e[t],i=r.element;if(!r.parent||r.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=r.worldTransform,o=r._anchor,a=r.width*o.x,l=r.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=r.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}}Rl.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"dom"};class dp{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||(Re.system.add(this._tickerUpdate,this,Wt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Re.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 Ye=new dp;class ts extends yr{constructor(){super(...arguments),this.client=new re,this.movement=new re,this.offset=new re,this.global=new re,this.screen=new re}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,r){return e.worldTransform.applyInverse(r||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,r,i,n,o,a,l,h,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class Fe extends ts{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 Vt extends ts{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Vt.DOM_DELTA_PIXEL=0;Vt.DOM_DELTA_LINE=1;Vt.DOM_DELTA_PAGE=2;const fp=2048,pp=new re,tr=new re;class mp{constructor(e){this.dispatch=new ke,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((r,i)=>r.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 r=0,i=t.length;r<i;r++)t[r].fn(e);else z(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Ye.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,pp.set(e,t),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(e,t){if(!e.target)return;const r=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let i=0,n=r.length-1;i<n;i++)if(e.currentTarget=r[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=r.length-2;i>=0;i--)if(e.currentTarget=r[i],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,r=this._allInteractiveElements){if(r.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const i=Array.isArray(t)?t:[t];for(let n=r.length-1;n>=0;n--)i.forEach(o=>{e.currentTarget=r[n],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let r=0;r<fp&&e!==this.rootTarget&&e.parent;r++){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,r,i,n,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Ye.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,r,i,n,o||n(e,r));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,r)&&i(e,r)?h?[e]:[]:null}hitTestRecursive(e,t,r,i,n){if(this._interactivePrune(e)||n(e,r))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Ye.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children,h=r;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,r)?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,tr),!e.hitArea.contains(tr.x,tr.y)))return!0;if(e.effects&&e.effects.length)for(let r=0;r<e.effects.length;r++){const i=e.effects[r];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,tr),e.containsPoint(tr)):!1}notifyTarget(e,t){var n,o;if(!e.currentTarget.isInteractive())return;t??(t=e.type);const r=`on${t}`;(o=(n=e.currentTarget)[r])==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 Fe)){z("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 r=this.trackingData(e.pointerId);r.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){var l,h;if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const r=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"),r&&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),r&&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"),r&&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),r&&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")),r&&(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 Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),r=this.createPointerEvent(e),i=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),i&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=(o=r.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(r,"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=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const r=e.pointerType==="mouse"||e.pointerType==="pen",i=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",i);this.dispatchEvent(n),r&&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),r&&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 Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),r=this.createPointerEvent(e);if(this.dispatchEvent(r,"pointerup"),r.pointerType==="touch")this.dispatchEvent(r,"touchend");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const a=r.button===2;this.dispatchEvent(r,a?"rightup":"mouseup")}const i=this.trackingData(e.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[e.button]);let o=n;if(n&&!r.composedPath().includes(n)){let a=n;for(;a&&!r.composedPath().includes(a);){if(r.currentTarget=a,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch")this.notifyTarget(r,"touchendoutside");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const l=r.button===2;this.notifyTarget(r,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(r,"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(r)}mapPointerUpOutside(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),r=this.findMountedTarget(t.pressTargetsByButton[e.button]),i=this.createPointerEvent(e);if(r){let n=r;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 Vt)){z("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 r=1;r<e.length&&e[r].parent===t;r++)t=e[r];return t}createPointerEvent(e,t,r){const i=this.allocateEvent(Fe);return this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.nativeEvent=e.nativeEvent,i.originalEvent=e,i.target=r??this.hitTest(i.global.x,i.global.y)??this._hitElements[0],typeof t=="string"&&(i.type=t),i}createWheelEvent(e){const t=this.allocateEvent(Vt);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 r=this.allocateEvent(Fe);return r.nativeEvent=e.nativeEvent,r.originalEvent=e.originalEvent,this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.target=e.target,r.path=e.composedPath().slice(),r.type=t??r.type,r}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof Fe&&t instanceof Fe&&(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 ts&&t instanceof ts&&(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 r=e.currentTarget._events[t];if(r)if("fn"in r)r.once&&e.currentTarget.removeListener(t,r.fn,void 0,!0),r.fn.call(r.context,e);else for(let i=0,n=r.length;i<n&&!e.propagationImmediatelyStopped;i++)r[i].once&&e.currentTarget.removeListener(t,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,e)}}const gp=1,_p={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Li=class ai{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new mp(null),Ye.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Fe(null),this._rootWheelEvent=new Vt(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...ai.defaultEventFeatures},{set:(t,r,i)=>(r==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),t[r]=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:r}=this.renderer;this.setTargetElement(t),this.resolution=r,ai._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){Ye.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 r=this.cursorStyles[e];if(r)switch(typeof r){case"string":t&&(this.domElement.style.cursor=r);break;case"function":r(e);break;case"object":t&&Object.assign(this.domElement.style,r);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 r=0,i=t.length;r<i;r++){const n=t[r],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,Ye.pointerMoved();const t=this._normalizeToPointerData(e);for(let r=0,i=t.length;r<i;r++){const n=this._bootstrapEvent(this._rootPointerEvent,t[r]);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 r=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+=r,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 r=0,i=t.length;r<i;r++){const n=this._bootstrapEvent(this._rootPointerEvent,t[r]);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,Ye.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Ye.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;Ye.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,r){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=(r-i.top)*(this.domElement.height/i.height)*n}_normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let r=0,i=e.changedTouches.length;r<i;r++){const n=e.changedTouches[r];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 r=e;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=gp),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),r.isNormalized=!0,t.push(r)}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=_p[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}};Li.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1};Li.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Bl=Li;const xp={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(s){this.eventMode=s?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Bl.defaultEventMode},set eventMode(s){this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,e,t){const r=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;s=r?`${s}capture`:s;const a=typeof e=="function"?e:e.handleEvent,l=this;i&&i.addEventListener("abort",()=>{l.off(s,a,o)}),n?l.once(s,a,o):l.on(s,a,o)},removeEventListener(s,e,t){const r=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,i=typeof e=="function"?void 0:e;s=r?`${s}capture`:s,e=typeof e=="function"?e:e.handleEvent,this.off(s,e,i)},dispatchEvent(s){if(!(s instanceof yr))throw new Error("Container cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};let At;function No(s){const e=Y.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=s,t.fillRect(0,0,6,1),e}function kl(){if(At!==void 0)return At;try{const s=No("#ff00ff"),e=No("#ffff00"),r=Y.get().createCanvas(6,1).getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(s,0,0),r.drawImage(e,2,0);const i=r.getImageData(2,0,1,1);if(!i)At=!1;else{const n=i.data;At=n[0]===255&&n[1]===0&&n[2]===0}}catch{At=!1}return At}const X={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:kl(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,t=e==null?void 0:e.resource;if(!t)return null;const r=e.alphaMode==="premultiplied-alpha",i=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=i!==e.pixelWidth||n!==e.pixelHeight;if(r){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=X._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=X._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=Y.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),X._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(r){const a=Y.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),X._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=X._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const l=Y.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,h.drawImage(t,0,0),X._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return t},getTintedCanvas:(s,e)=>{const t=s.texture,r=Q.shared.setValue(e).toHex(),i=t.tintCache||(t.tintCache={}),n=i[r],o=t.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:Y.get().createCanvas();return X.tintMethod(t,e,a),a.tintId=o,i[r]=a,i[r]},getTintedPattern:(s,e)=>{const t=Q.shared.setValue(e).toHex(),r=s.patternCache||(s.patternCache={}),i=s.source._resourceId;let n=r[t];return(n==null?void 0:n.tintId)===i||(X.canvas||(X.canvas=Y.get().createCanvas()),X.tintMethod(s,e,X.canvas),n=X.canvas.getContext("2d").createPattern(X.canvas,"repeat"),n.tintId=i,r[t]=n),n},applyPatternTransform:(s,e,t=!0)=>{if(!e)return;const r=s;if(!r.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]);r.setTransform(t?n.inverse():n)},tintWithMultiply:(s,e,t)=>{const r=t.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=$.isVertical(o),l=a?i.height:i.width,h=a?i.width:i.height;t.width=Math.ceil(l),t.height=Math.ceil(h),r.save(),r.fillStyle=Q.shared.setValue(e).toHex(),r.fillRect(0,0,l,h),r.globalCompositeOperation="multiply";const c=X.getCanvasSource(s);if(!c){r.restore();return}o&&X._applyInverseRotation(r,o,i.width,i.height),r.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithOverlay:(s,e,t)=>{const r=t.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=$.isVertical(o),l=a?i.height:i.width,h=a?i.width:i.height;t.width=Math.ceil(l),t.height=Math.ceil(h),r.save(),r.globalCompositeOperation="copy",r.fillStyle=Q.shared.setValue(e).toHex(),r.fillRect(0,0,l,h),r.globalCompositeOperation="destination-atop";const c=X.getCanvasSource(s);if(!c){r.restore();return}o&&X._applyInverseRotation(r,o,i.width,i.height),r.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithPerPixel:(s,e,t)=>{const r=t.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=$.isVertical(o),l=a?i.height:i.width,h=a?i.width:i.height;t.width=Math.ceil(l),t.height=Math.ceil(h),r.save(),r.globalCompositeOperation="copy";const c=X.getCanvasSource(s);if(!c){r.restore();return}o&&X._applyInverseRotation(r,o,i.width,i.height),r.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore();const u=e>>16&255,d=e>>8&255,f=e&255,p=r.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;r.putImageData(p,0,0)},_applyInverseRotation:(s,e,t,r)=>{const i=$.inv(e),n=$.uX(i),o=$.uY(i),a=$.vX(i),l=$.vY(i),h=-Math.min(0,n*t,a*r,n*t+a*r),c=-Math.min(0,o*t,l*r,o*t+l*r);s.transform(n,o,a,l,h,c)}};X.tintMethod=X.canUseMultiply?X.tintWithMultiply:X.tintWithPerPixel;class yp{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const r=Y.get().createCanvas();r.width=e,r.height=t;const i=r.getContext("2d");return{canvas:r,context:i}}getOptimalCanvasAndContext(e,t,r=1){e=Math.ceil(e*r-1e-6),t=Math.ceil(t*r-1e-6),e=Lt(e),t=Lt(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:r,height:i}=t,n=(r<<17)+(i<<1);e.context.resetTransform(),e.context.clearRect(0,0,r,i),this._canvasPool[n].push(e)}clear(){this._canvasPool={}}}const Xt=new yp;$t.register(Xt);const Ho=new G;function Il(s,e){e.clear();const t=e.matrix;for(let r=0;r<s.length;r++){const i=s[r];if(i.globalDisplayStatus<7)continue;const n=i.renderGroup??i.parentRenderGroup;n!=null&&n.isCachedAsTexture?e.matrix=Ho.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n!=null&&n._parentCacheAsTextureRenderGroup?e.matrix=Ho.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):e.matrix=i.worldTransform,e.addBounds(i.bounds)}return e.matrix=t,e}const bp=new xe;function Gl(s,e,t,r,i=!1){const n=bp;n.minX=0,n.minY=0,n.maxX=s.width/r|0,n.maxY=s.height/r|0;const o=ce.getOptimalTexture(n.width,n.height,r,!1,i);return o.source.uploadMethodId="image",o.source.resource=s,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=e/r,o.frame.height=t/r,o.source.emit("update",o.source),o.updateUvs(),o}function Wo(s){return typeof s.getCanvasFilterString=="function"}class vp{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new xe,this.cssFilterString=""}}class Fl{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(),r=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=r,t.container=e.container,t.cssFilterString="",r.every(l=>!l.enabled)){t.skip=!0;return}const i=[],n=1;for(const l of r){if(!l.enabled)continue;if(!Wo(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 r=this.renderer.canvasContext.activeContext;e.useClip?r.restore():r.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!(t!=null&&t.length)||t.every(_=>!_.enabled))return e;const r=[],i=1;for(const _ of t){if(!_.enabled)continue;if(!Wo(_)){this._warnUnsupportedFilter(_);continue}const x=_.getCanvasFilterString();if(x===null){this._warnUnsupportedFilter(_);continue}x&&r.push(x)}if(r.length===0&&i===1)return e;const n=X.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=Xt.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),r.length&&(d.filter=r.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,Gl(u,l,h,a)}_calculateFilterArea(e,t){if(e.renderables?Il(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 r=e.container.renderGroup||e.container.parentRenderGroup,i=r==null?void 0:r.cacheToLocalTransform;i&&t.applyMatrix(i)}}_warnUnsupportedFilter(e){var r;const t=((r=e==null?void 0:e.constructor)==null?void 0:r.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 vp),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}}Fl.extension={type:[b.CanvasSystem],name:"filter"};var Ul=`in vec2 aPosition;
|
|
252
|
+
out vec2 vTextureCoord;
|
|
253
|
+
|
|
254
|
+
uniform vec4 uInputSize;
|
|
255
|
+
uniform vec4 uOutputFrame;
|
|
256
|
+
uniform vec4 uOutputTexture;
|
|
257
|
+
|
|
258
|
+
vec4 filterVertexPosition( void )
|
|
259
|
+
{
|
|
260
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
261
|
+
|
|
262
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
263
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
264
|
+
|
|
265
|
+
return vec4(position, 0.0, 1.0);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
vec2 filterTextureCoord( void )
|
|
269
|
+
{
|
|
270
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
void main(void)
|
|
274
|
+
{
|
|
275
|
+
gl_Position = filterVertexPosition();
|
|
276
|
+
vTextureCoord = filterTextureCoord();
|
|
277
|
+
}
|
|
278
|
+
`;const Dl={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]},Tp=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(`
|
|
279
|
+
`);function Sp(s){const e=Dl[s],t=e.length;let r="";const i="finalColor = ",n=" + ",o="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let a=0;a<s;a++){const l=a===0?i:n,h=a<t?a:s-a-1,c=o.replace("%index%",a.toString()).replace("%value%",e[h].toString());r+=`${l}${c}
|
|
280
|
+
`}return Tp.replace("%blur%",`${r};`).replace("%size%",s.toString())}const Cp=`
|
|
281
|
+
in vec2 aPosition;
|
|
282
|
+
|
|
283
|
+
uniform float uStrength;
|
|
284
|
+
|
|
285
|
+
out vec2 vBlurTexCoords[%size%];
|
|
286
|
+
|
|
287
|
+
uniform vec4 uInputSize;
|
|
288
|
+
uniform vec4 uOutputFrame;
|
|
289
|
+
uniform vec4 uOutputTexture;
|
|
290
|
+
|
|
291
|
+
vec4 filterVertexPosition( void )
|
|
292
|
+
{
|
|
293
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
294
|
+
|
|
295
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
296
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
297
|
+
|
|
298
|
+
return vec4(position, 0.0, 1.0);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
vec2 filterTextureCoord( void )
|
|
302
|
+
{
|
|
303
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
void main(void)
|
|
307
|
+
{
|
|
308
|
+
gl_Position = filterVertexPosition();
|
|
309
|
+
|
|
310
|
+
float pixelStrength = uInputSize.%dimension% * uStrength;
|
|
311
|
+
|
|
312
|
+
vec2 textureCoord = filterTextureCoord();
|
|
313
|
+
%blur%
|
|
314
|
+
}`;function wp(s,e){const t=Math.ceil(s/2);let r=Cp,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<s;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(t-1)}.0`),i+=a,i+=`
|
|
315
|
+
`}return r=r.replace("%blur%",i),r=r.replace("%size%",s.toString()),r=r.replace("%dimension%",e?"z":"w"),r}function Pp(s,e){const t=wp(e,s),r=Sp(e);return ot.from({vertex:t,fragment:r,name:`blur-${s?"horizontal":"vertical"}-pass-filter`})}var Ep=`
|
|
316
|
+
|
|
317
|
+
struct GlobalFilterUniforms {
|
|
318
|
+
uInputSize:vec4<f32>,
|
|
319
|
+
uInputPixel:vec4<f32>,
|
|
320
|
+
uInputClamp:vec4<f32>,
|
|
321
|
+
uOutputFrame:vec4<f32>,
|
|
322
|
+
uGlobalFrame:vec4<f32>,
|
|
323
|
+
uOutputTexture:vec4<f32>,
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
struct BlurUniforms {
|
|
327
|
+
uStrength:f32,
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
331
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
332
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
333
|
+
|
|
334
|
+
@group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
struct VSOutput {
|
|
338
|
+
@builtin(position) position: vec4<f32>,
|
|
339
|
+
%blur-struct%
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
343
|
+
{
|
|
344
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
345
|
+
|
|
346
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
347
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
348
|
+
|
|
349
|
+
return vec4(position, 0.0, 1.0);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
353
|
+
{
|
|
354
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
358
|
+
{
|
|
359
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
fn getSize() -> vec2<f32>
|
|
363
|
+
{
|
|
364
|
+
return gfu.uGlobalFrame.zw;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
@vertex
|
|
369
|
+
fn mainVertex(
|
|
370
|
+
@location(0) aPosition : vec2<f32>,
|
|
371
|
+
) -> VSOutput {
|
|
372
|
+
|
|
373
|
+
let filteredCord = filterTextureCoord(aPosition);
|
|
374
|
+
|
|
375
|
+
let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;
|
|
376
|
+
|
|
377
|
+
return VSOutput(
|
|
378
|
+
filterVertexPosition(aPosition),
|
|
379
|
+
%blur-vertex-out%
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
@fragment
|
|
384
|
+
fn mainFragment(
|
|
385
|
+
@builtin(position) position: vec4<f32>,
|
|
386
|
+
%blur-fragment-in%
|
|
387
|
+
) -> @location(0) vec4<f32> {
|
|
388
|
+
|
|
389
|
+
var finalColor = vec4(0.0);
|
|
390
|
+
|
|
391
|
+
%blur-sampling%
|
|
392
|
+
|
|
393
|
+
return finalColor;
|
|
394
|
+
}
|
|
395
|
+
`;function Mp(s,e){const t=Dl[e],r=t.length,i=[],n=[],o=[];for(let u=0;u<e;u++){i[u]=`@location(${u}) offset${u}: vec2<f32>,`,s?n[u]=`filteredCord + vec2(${u-r+1} * pixelStrength, 0.0),`:n[u]=`filteredCord + vec2(0.0, ${u-r+1} * pixelStrength),`;const d=u<r?u:e-u-1,f=t[d].toString();o[u]=`finalColor += textureSample(uTexture, uSampler, offset${u}) * ${f};`}const a=i.join(`
|
|
396
|
+
`),l=n.join(`
|
|
397
|
+
`),h=o.join(`
|
|
398
|
+
`),c=Ep.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",h).replace("%dimension%",s?"z":"w");return Ze.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}const Ol=class Ll extends br{constructor(e){e={...Ll.defaultOptions,...e};const t=Pp(e.horizontal,e.kernelSize),r=Mp(e.horizontal,e.kernelSize);super({glProgram:t,gpuProgram:r,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,r,i){this.legacy?this._applyLegacy(e,t,r,i):this._applyOptimized(e,t,r,i)}_applyLegacy(e,t,r,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)e.applyFilter(this,t,r,i);else{const n=ce.getSameSizeTexture(t);let o=t,a=n;this._state.blend=!1;const l=e.renderer.type===Pe.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,r,i),ce.returnTexture(n)}}_applyOptimized(e,t,r,i){if(this._uniforms.uStrength=this._calculateInitialStrength(),this.passes===1)e.applyFilter(this,t,r,i);else{const n=ce.getSameSizeTexture(t);let o=t,a=n;this._state.blend=!1;const l=e.renderer,h=l.type===Pe.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,r,i),ce.returnTexture(n)}}_calculateInitialStrength(){let e=1,t=.5;for(let r=1;r<this.passes;r++)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}};Ol.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};let Ds=Ol;class Ap extends br{constructor(...e){let t=e[0]??{};typeof t=="number"&&(O(ie,"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={...Ds.defaultOptions,...t};const{strength:r,strengthX:i,strengthY:n,quality:o,...a}=t;super({...a,compatibleRenderers:Pe.BOTH,resources:{}}),this._repeatEdgePixels=!1,this.blurXFilter=new Ds({horizontal:!0,...t}),this.blurYFilter=new Ds({horizontal:!1,...t}),this.quality=o,this.strengthX=i??r,this.strengthY=n??r,this.repeatEdgePixels=!1}apply(e,t,r,i){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=ce.getSameSizeTexture(t);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(e,t,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(e,a,r,i),ce.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(e,t,r,i)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(e,t,r,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 O("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength}set blur(e){O("8.3.0","BlurFilter.blur is deprecated, please use BlurFilter.strength instead."),this.strength=e}get blurX(){return O("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX}set blurX(e){O("8.3.0","BlurFilter.blurX is deprecated, please use BlurFilter.strengthX instead."),this.strengthX=e}get blurY(){return O("8.3.0","BlurFilter.blurY is deprecated, please use BlurFilter.strengthY instead."),this.strengthY}set blurY(e){O("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()}}Ap.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var Rp=`
|
|
399
|
+
in vec2 vTextureCoord;
|
|
400
|
+
in vec4 vColor;
|
|
401
|
+
|
|
402
|
+
out vec4 finalColor;
|
|
403
|
+
|
|
404
|
+
uniform float uNoise;
|
|
405
|
+
uniform float uSeed;
|
|
406
|
+
uniform sampler2D uTexture;
|
|
407
|
+
|
|
408
|
+
float rand(vec2 co)
|
|
409
|
+
{
|
|
410
|
+
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
void main()
|
|
414
|
+
{
|
|
415
|
+
vec4 color = texture(uTexture, vTextureCoord);
|
|
416
|
+
float randomValue = rand(gl_FragCoord.xy * uSeed);
|
|
417
|
+
float diff = (randomValue - 0.5) * uNoise;
|
|
418
|
+
|
|
419
|
+
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
420
|
+
if (color.a > 0.0) {
|
|
421
|
+
color.rgb /= color.a;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
color.r += diff;
|
|
425
|
+
color.g += diff;
|
|
426
|
+
color.b += diff;
|
|
427
|
+
|
|
428
|
+
// Premultiply alpha again.
|
|
429
|
+
color.rgb *= color.a;
|
|
430
|
+
|
|
431
|
+
finalColor = color;
|
|
432
|
+
}
|
|
433
|
+
`,zo=`
|
|
434
|
+
|
|
435
|
+
struct GlobalFilterUniforms {
|
|
436
|
+
uInputSize:vec4<f32>,
|
|
437
|
+
uInputPixel:vec4<f32>,
|
|
438
|
+
uInputClamp:vec4<f32>,
|
|
439
|
+
uOutputFrame:vec4<f32>,
|
|
440
|
+
uGlobalFrame:vec4<f32>,
|
|
441
|
+
uOutputTexture:vec4<f32>,
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
struct NoiseUniforms {
|
|
445
|
+
uNoise:f32,
|
|
446
|
+
uSeed:f32,
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
450
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
451
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
452
|
+
|
|
453
|
+
@group(1) @binding(0) var<uniform> noiseUniforms : NoiseUniforms;
|
|
454
|
+
|
|
455
|
+
struct VSOutput {
|
|
456
|
+
@builtin(position) position: vec4<f32>,
|
|
457
|
+
@location(0) uv : vec2<f32>
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
461
|
+
{
|
|
462
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
463
|
+
|
|
464
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
465
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
466
|
+
|
|
467
|
+
return vec4(position, 0.0, 1.0);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
471
|
+
{
|
|
472
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
476
|
+
{
|
|
477
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
fn getSize() -> vec2<f32>
|
|
481
|
+
{
|
|
482
|
+
return gfu.uGlobalFrame.zw;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
@vertex
|
|
486
|
+
fn mainVertex(
|
|
487
|
+
@location(0) aPosition : vec2<f32>,
|
|
488
|
+
) -> VSOutput {
|
|
489
|
+
return VSOutput(
|
|
490
|
+
filterVertexPosition(aPosition),
|
|
491
|
+
filterTextureCoord(aPosition)
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
fn rand(co:vec2<f32>) -> f32
|
|
496
|
+
{
|
|
497
|
+
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
@fragment
|
|
503
|
+
fn mainFragment(
|
|
504
|
+
@location(0) uv: vec2<f32>,
|
|
505
|
+
@builtin(position) position: vec4<f32>
|
|
506
|
+
) -> @location(0) vec4<f32> {
|
|
507
|
+
|
|
508
|
+
var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy);
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
var sample = textureSample(uTexture, uSampler, uv);
|
|
512
|
+
var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed);
|
|
513
|
+
var diff = (randomValue - 0.5) * noiseUniforms.uNoise;
|
|
514
|
+
|
|
515
|
+
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
516
|
+
if (sample.a > 0.0) {
|
|
517
|
+
sample.r /= sample.a;
|
|
518
|
+
sample.g /= sample.a;
|
|
519
|
+
sample.b /= sample.a;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
sample.r += diff;
|
|
523
|
+
sample.g += diff;
|
|
524
|
+
sample.b += diff;
|
|
525
|
+
|
|
526
|
+
// Premultiply alpha again.
|
|
527
|
+
sample.r *= sample.a;
|
|
528
|
+
sample.g *= sample.a;
|
|
529
|
+
sample.b *= sample.a;
|
|
530
|
+
|
|
531
|
+
return sample;
|
|
532
|
+
}`;const Nl=class Hl extends br{constructor(e={}){e={...Hl.defaultOptions,...e};const t=Ze.from({vertex:{source:zo,entryPoint:"mainVertex"},fragment:{source:zo,entryPoint:"mainFragment"}}),r=ot.from({vertex:Ul,fragment:Rp,name:"noise-filter"}),{noise:i,seed:n,...o}=e;super({...o,gpuProgram:t,glProgram:r,resources:{noiseUniforms:new De({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}};Nl.defaultOptions={noise:.5};let I_=Nl;var Bp=`in vec2 vTextureCoord;
|
|
533
|
+
out vec4 finalColor;
|
|
534
|
+
uniform sampler2D uTexture;
|
|
535
|
+
void main() {
|
|
536
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
537
|
+
}
|
|
538
|
+
`,Vo=`struct GlobalFilterUniforms {
|
|
539
|
+
uInputSize: vec4<f32>,
|
|
540
|
+
uInputPixel: vec4<f32>,
|
|
541
|
+
uInputClamp: vec4<f32>,
|
|
542
|
+
uOutputFrame: vec4<f32>,
|
|
543
|
+
uGlobalFrame: vec4<f32>,
|
|
544
|
+
uOutputTexture: vec4<f32>,
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
548
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
549
|
+
@group(0) @binding(2) var uSampler: sampler;
|
|
550
|
+
|
|
551
|
+
struct VSOutput {
|
|
552
|
+
@builtin(position) position: vec4<f32>,
|
|
553
|
+
@location(0) uv: vec2<f32>
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
557
|
+
{
|
|
558
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
559
|
+
|
|
560
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
561
|
+
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
562
|
+
|
|
563
|
+
return vec4(position, 0.0, 1.0);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
567
|
+
{
|
|
568
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
@vertex
|
|
572
|
+
fn mainVertex(
|
|
573
|
+
@location(0) aPosition: vec2<f32>,
|
|
574
|
+
) -> VSOutput {
|
|
575
|
+
return VSOutput(
|
|
576
|
+
filterVertexPosition(aPosition),
|
|
577
|
+
filterTextureCoord(aPosition)
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
@fragment
|
|
582
|
+
fn mainFragment(
|
|
583
|
+
@location(0) uv: vec2<f32>,
|
|
584
|
+
) -> @location(0) vec4<f32> {
|
|
585
|
+
return textureSample(uTexture, uSampler, uv);
|
|
586
|
+
}
|
|
587
|
+
`;class kp extends br{constructor(){const e=Ze.from({vertex:{source:Vo,entryPoint:"mainVertex"},fragment:{source:Vo,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=ot.from({vertex:Ul,fragment:Bp,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class Wl{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.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}}Wl.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const Ip=new Ei({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 Gp{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new xe,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 zl{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new De({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 it({}),this.renderer=e}get activeBackTexture(){var e;return(e=this._activeFilterData)==null?void 0:e.backTexture}push(e){const t=this.renderer,r=e.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=r,i.container=e.container,i.outputRenderSurface=t.renderTarget.renderSurface;const n=t.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(r.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 r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=t;const i=e.source,n=i.resolution,o=i.antialias;if(t.every(f=>!f.enabled))return r.skip=!0,e;const a=r.bounds;if(a.addRect(e.frame),this._calculateFilterBounds(r,a.rectangle,o,n,0),r.skip)return e;const l=n;this._calculateGlobalFrame(r,0,0,l,i.width,i.height),r.outputRenderSurface=ce.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=N.EMPTY,r.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);const d=r.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&&ce.returnTexture(t.backTexture),ce.returnTexture(t.inputTexture))}getBackTexture(e,t,r){const i=e.colorTexture.source._resolution,n=ce.getOptimalTexture(t.width,t.height,i,!1);let o=t.minX,a=t.minY;r&&(o-=r.minX,a-=r.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,r,i){const n=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,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,r,o,u,d,c,l,i);const f=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,t,n)}calculateSpriteMatrix(e,t){const r=this._activeFilterData,i=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(G.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/t.texture.orig.width,1/t.texture.orig.height),i.translate(t.anchor.x,t.anchor.y),i}destroy(){var e;(e=this._passthroughFilter)==null||e.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new kp),this._passthroughFilter}_setupBindGroupsAndRender(e,t,r){if(r.renderPipes.uniformBatch){const i=r.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,r.encoder.draw({geometry:Ip,shader:e,state:e._state,topology:"triangle-list"}),r.type===Pe.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,r,i){if(e.backTexture=N.EMPTY,e.inputTexture=ce.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){r.renderTarget.finishRenderPass();const n=r.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(n,t,i==null?void 0:i.bounds)}r.renderTarget.bind(e.inputTexture,!0),r.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,r,i,n,o){const a=e.globalFrame;a.x=t*i,a.y=r*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(e,t,r,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]=r.bounds.minX-i,c[1]=r.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 N&&(t.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!l),t instanceof N?(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,r=this._filterStackIndex;for(;r>0;){r--;const i=this._filterStack[r];if(!i.skip){e=i.bounds.minX,t=i.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?Il(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 r=e.inputTexture,i=e.bounds,n=e.filters,o=e.firstEnabledIndex,a=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===a)n[o].apply(this,r,e.outputRenderSurface,t);else{let l=e.inputTexture;const h=ce.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),ce.returnTexture(h)}}_calculateFilterBounds(e,t,r,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=r),y.clipToViewport||(p=!1),!!!(y.compatibleRenderers&o.type)){f=!1;break}if(y.blendRequired&&!(((_=o.backBuffer)==null?void 0:_.useBackBuffer)??!0)){z("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,d||(d=y.blendRequired)}if(!f){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 Gp),this._filterStackIndex++,e}}zl.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};var Fp=`in vec2 vMaskCoord;
|
|
588
|
+
in vec2 vTextureCoord;
|
|
589
|
+
|
|
590
|
+
uniform sampler2D uTexture;
|
|
591
|
+
uniform sampler2D uMaskTexture;
|
|
592
|
+
|
|
593
|
+
uniform float uAlpha;
|
|
594
|
+
uniform vec4 uMaskClamp;
|
|
595
|
+
uniform float uInverse;
|
|
596
|
+
uniform float uChannel;
|
|
597
|
+
|
|
598
|
+
out vec4 finalColor;
|
|
599
|
+
|
|
600
|
+
void main(void)
|
|
601
|
+
{
|
|
602
|
+
float clip = step(3.5,
|
|
603
|
+
step(uMaskClamp.x, vMaskCoord.x) +
|
|
604
|
+
step(uMaskClamp.y, vMaskCoord.y) +
|
|
605
|
+
step(vMaskCoord.x, uMaskClamp.z) +
|
|
606
|
+
step(vMaskCoord.y, uMaskClamp.w));
|
|
607
|
+
|
|
608
|
+
// TODO look into why this is needed
|
|
609
|
+
float npmAlpha = uAlpha;
|
|
610
|
+
vec4 original = texture(uTexture, vTextureCoord);
|
|
611
|
+
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
612
|
+
|
|
613
|
+
float a;
|
|
614
|
+
if (uChannel == 1.0) {
|
|
615
|
+
a = masky.a * npmAlpha * clip;
|
|
616
|
+
} else {
|
|
617
|
+
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
618
|
+
a = alphaMul * masky.r * npmAlpha * clip;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (uInverse == 1.0) {
|
|
622
|
+
a = 1.0 - a;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
finalColor = original * a;
|
|
626
|
+
}
|
|
627
|
+
`,Up=`in vec2 aPosition;
|
|
628
|
+
|
|
629
|
+
out vec2 vTextureCoord;
|
|
630
|
+
out vec2 vMaskCoord;
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
uniform vec4 uInputSize;
|
|
634
|
+
uniform vec4 uOutputFrame;
|
|
635
|
+
uniform vec4 uOutputTexture;
|
|
636
|
+
uniform mat3 uFilterMatrix;
|
|
637
|
+
|
|
638
|
+
vec4 filterVertexPosition( vec2 aPosition )
|
|
639
|
+
{
|
|
640
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
641
|
+
|
|
642
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
643
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
644
|
+
|
|
645
|
+
return vec4(position, 0.0, 1.0);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
vec2 filterTextureCoord( vec2 aPosition )
|
|
649
|
+
{
|
|
650
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
vec2 getFilterCoord( vec2 aPosition )
|
|
654
|
+
{
|
|
655
|
+
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
void main(void)
|
|
659
|
+
{
|
|
660
|
+
gl_Position = filterVertexPosition(aPosition);
|
|
661
|
+
vTextureCoord = filterTextureCoord(aPosition);
|
|
662
|
+
vMaskCoord = getFilterCoord(aPosition);
|
|
663
|
+
}
|
|
664
|
+
`,Xo=`struct GlobalFilterUniforms {
|
|
665
|
+
uInputSize:vec4<f32>,
|
|
666
|
+
uInputPixel:vec4<f32>,
|
|
667
|
+
uInputClamp:vec4<f32>,
|
|
668
|
+
uOutputFrame:vec4<f32>,
|
|
669
|
+
uGlobalFrame:vec4<f32>,
|
|
670
|
+
uOutputTexture:vec4<f32>,
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
struct MaskUniforms {
|
|
674
|
+
uFilterMatrix:mat3x3<f32>,
|
|
675
|
+
uMaskClamp:vec4<f32>,
|
|
676
|
+
uAlpha:f32,
|
|
677
|
+
uInverse:f32,
|
|
678
|
+
uChannel:f32,
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
682
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
683
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
684
|
+
|
|
685
|
+
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
686
|
+
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
687
|
+
|
|
688
|
+
struct VSOutput {
|
|
689
|
+
@builtin(position) position: vec4<f32>,
|
|
690
|
+
@location(0) uv : vec2<f32>,
|
|
691
|
+
@location(1) filterUv : vec2<f32>,
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
695
|
+
{
|
|
696
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
697
|
+
|
|
698
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
699
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
700
|
+
|
|
701
|
+
return vec4(position, 0.0, 1.0);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
705
|
+
{
|
|
706
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
710
|
+
{
|
|
711
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
715
|
+
{
|
|
716
|
+
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
fn getSize() -> vec2<f32>
|
|
720
|
+
{
|
|
721
|
+
return gfu.uGlobalFrame.zw;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
@vertex
|
|
725
|
+
fn mainVertex(
|
|
726
|
+
@location(0) aPosition : vec2<f32>,
|
|
727
|
+
) -> VSOutput {
|
|
728
|
+
return VSOutput(
|
|
729
|
+
filterVertexPosition(aPosition),
|
|
730
|
+
filterTextureCoord(aPosition),
|
|
731
|
+
getFilterCoord(aPosition)
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
@fragment
|
|
736
|
+
fn mainFragment(
|
|
737
|
+
@location(0) uv: vec2<f32>,
|
|
738
|
+
@location(1) filterUv: vec2<f32>,
|
|
739
|
+
@builtin(position) position: vec4<f32>
|
|
740
|
+
) -> @location(0) vec4<f32> {
|
|
741
|
+
|
|
742
|
+
var maskClamp = filterUniforms.uMaskClamp;
|
|
743
|
+
var uAlpha = filterUniforms.uAlpha;
|
|
744
|
+
|
|
745
|
+
var clip = step(3.5,
|
|
746
|
+
step(maskClamp.x, filterUv.x) +
|
|
747
|
+
step(maskClamp.y, filterUv.y) +
|
|
748
|
+
step(filterUv.x, maskClamp.z) +
|
|
749
|
+
step(filterUv.y, maskClamp.w));
|
|
750
|
+
|
|
751
|
+
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
752
|
+
var source = textureSample(uTexture, uSampler, uv);
|
|
753
|
+
|
|
754
|
+
var a: f32;
|
|
755
|
+
if (filterUniforms.uChannel == 1.0) {
|
|
756
|
+
a = mask.a * uAlpha * clip;
|
|
757
|
+
} else {
|
|
758
|
+
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
|
|
759
|
+
a = alphaMul * mask.r * uAlpha * clip;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (filterUniforms.uInverse == 1.0) {
|
|
763
|
+
a = 1.0 - a;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return source * a;
|
|
767
|
+
}
|
|
768
|
+
`;class Dp extends br{constructor(e){const{sprite:t,...r}=e,i=new _a(t.texture),n=new De({uFilterMatrix:{value:new G,type:"mat3x3<f32>"},uMaskClamp:{value:i.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"},uChannel:{value:e.channel==="alpha"?1:0,type:"f32"}}),o=Ze.from({vertex:{source:Xo,entryPoint:"mainVertex"},fragment:{source:Xo,entryPoint:"mainFragment"}}),a=ot.from({vertex:Up,fragment:Fp,name:"mask-filter"});super({...r,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,r,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,r,i)}}class Op{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Lp{constructor(){this.instructions=new yi}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Ni=class li{constructor(e){this._renderer=e,this._managedContexts=new ze({renderer:e,type:"resource",name:"graphicsContext"})}init(e){li.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??li.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=e._gpuData,r=!!t[this._renderer.uid],i=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!r)&&(r&&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 Lp,r=this.getGpuContext(e);return r.graphicsData=t,t.init(),t}_initContext(e){const t=new Op;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Ni.extension={type:[b.CanvasSystem],name:"graphicsContext"};Ni.defaultOptions={bezierSmoothness:.5};let Np=Ni;class Vl{constructor(e,t){this.state=Je.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}}Vl.extension={type:[b.CanvasPipes],name:"graphics"};function Xl(s,e,t){const r=(s>>24&255)/255;e[t++]=(s&255)/255*r,e[t++]=(s>>8&255)/255*r,e[t++]=(s>>16&255)/255*r,e[t++]=r}class Hp{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{ge.return(e)}),this.batches.length=0}}class $l{constructor(e,t){this.state=Je.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,r=!!e._gpuData,n=this.renderer.graphicsContext.updateGpuContext(t);return!!(n.isBatchable||r!==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 r=this._getGpuDataForRenderable(e).batches;for(let i=0;i<r.length;i++){const n=r[i];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;const t=this.renderer,r=e.context;if(!t.graphicsContext.getGpuContext(r).batches.length)return;const n=r.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,Xl(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 r=this.renderer.renderPipes.batch,i=this._getGpuDataForRenderable(e).batches;for(let n=0;n<i.length;n++){const o=i[n];r.addToBatch(o,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){const t=new Hp;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){const r=e.context,n=this.renderer.graphicsContext.getGpuContext(r),o=this.renderer._roundPixels|e._roundPixels;t.batches=n.batches.map(a=>{const l=ge.get(Ii);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}}$l.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"graphics"};W.add(Vl);W.add($l);W.add(Np);W.add(Di);class rs extends vi{constructor(e){e instanceof Ue&&(e={context:e});const{context:t,roundPixels:r,...i}=e||{};super({label:"Graphics",...i}),this.renderPipeId="graphics",t?this.context=t:(this.context=this._ownedContext=new Ue,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=r??!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 rs(this._context.clone()):(this._ownedContext=null,new rs(this._context))}lineStyle(e,t,r){O(ie,"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),r&&(i.alpha=r),this.context.strokeStyle=i,this}beginFill(e,t){O(ie,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const r={};return e!==void 0&&(r.color=e),t!==void 0&&(r.alpha=t),this.context.fillStyle=r,this}endFill(){O(ie,"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!==Ue.defaultStrokeStyle.width||e.color!==Ue.defaultStrokeStyle.color||e.alpha!==Ue.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return O(ie,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return O(ie,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return O(ie,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return O(ie,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return O(ie,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return O(ie,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}const zr={name:"local-uniform-bit",vertex:{header:`
|
|
769
|
+
|
|
770
|
+
struct LocalUniforms {
|
|
771
|
+
uTransformMatrix:mat3x3<f32>,
|
|
772
|
+
uColor:vec4<f32>,
|
|
773
|
+
uRound:f32,
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
777
|
+
`,main:`
|
|
778
|
+
vColor *= localUniforms.uColor;
|
|
779
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
780
|
+
`,end:`
|
|
781
|
+
if(localUniforms.uRound == 1)
|
|
782
|
+
{
|
|
783
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
784
|
+
}
|
|
785
|
+
`}},Wp={...zr,vertex:{...zr.vertex,header:zr.vertex.header.replace("group(1)","group(2)")}},Yl={name:"local-uniform-bit",vertex:{header:`
|
|
786
|
+
|
|
787
|
+
uniform mat3 uTransformMatrix;
|
|
788
|
+
uniform vec4 uColor;
|
|
789
|
+
uniform float uRound;
|
|
790
|
+
`,main:`
|
|
791
|
+
vColor *= uColor;
|
|
792
|
+
modelMatrix = uTransformMatrix;
|
|
793
|
+
`,end:`
|
|
794
|
+
if(uRound == 1.)
|
|
795
|
+
{
|
|
796
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
797
|
+
}
|
|
798
|
+
`}};class zp extends vi{constructor(e,t){const{text:r,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=r??"",this.style=n,this.resolution=i??null,this.allowChildren=!1,this._anchor=new _e({_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,r=this.bounds.height,i=-t*this.anchor.x;let n=0;return e.x>=i&&e.x<=i+t&&(n=-r*this.anchor.y,e.y>=n&&e.y<=n+r)}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 Vp(s,e){let t=s[0]??{};return(typeof t=="string"||s[1])&&(O(ie,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:s[1]}),t}let ht=null,je=null;function Xp(s,e){ht||(ht=Y.get().createCanvas(256,128),je=ht.getContext("2d",{willReadFrequently:!0}),je.globalCompositeOperation="copy",je.globalAlpha=1),(ht.width<s||ht.height<e)&&(ht.width=Lt(s),ht.height=Lt(e))}function $o(s,e,t){for(let r=0,i=4*t*e;r<e;++r,i+=4)if(s[i+3]!==0)return!1;return!0}function Yo(s,e,t,r,i){const n=4*e;for(let o=r,a=r*n+4*t;o<=i;++o,a+=n)if(s[a+3]!==0)return!1;return!0}function $p(...s){let e=s[0];e.canvas||(e={canvas:s[0],resolution:s[1]});const{canvas:t}=e,r=Math.min(e.resolution??1,1),i=e.width??t.width,n=e.height??t.height;let o=e.output;if(Xp(i,n),!je)throw new TypeError("Failed to get canvas 2D context");je.drawImage(t,0,0,i,n,0,0,i*r,n*r);const l=je.getImageData(0,0,i,n).data;let h=0,c=0,u=i-1,d=n-1;for(;c<n&&$o(l,i,c);)++c;if(c===n)return ee.EMPTY;for(;$o(l,i,d);)--d;for(;Yo(l,i,h,c,d);)++h;for(;Yo(l,i,u,c,d);)--u;return++u,++d,je.globalCompositeOperation="source-over",je.strokeRect(h,c,u-h,d-c),je.globalCompositeOperation="copy",o??(o=new ee),o.set(h/r,c/r,(u-h)/r,(d-c)/r),o}/**
|
|
799
|
+
* tiny-lru
|
|
800
|
+
*
|
|
801
|
+
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
802
|
+
* @license BSD-3-Clause
|
|
803
|
+
* @version 11.4.7
|
|
804
|
+
*/class Yp{constructor(e=0,t=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=r,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 r=0;r<e.length;r++){const i=e[r];t[r]=[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,r=0;for(;t!==null;)e[r++]=t.key,t=t.next;return e}setWithEvicted(e,t,r=this.resetTtl){let i=null;if(this.has(e))this.set(e,t,!0,r);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,r=!1,i=this.resetTtl){let n=this.items[e];return r||n!==void 0?(n.value=t,r===!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 r=0;r<e.length;r++)t[r]=this.get(e[r]);return t}}function jp(s=1e3,e=0,t=!1){if(isNaN(s)||s<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 Yp(s,e,t)}function jl(s){return!!s.tagStyles&&Object.keys(s.tagStyles).length>0}function ql(s){return s.includes("<")}function qp(s,e){return s.clone().assign(e)}function Kp(s,e){const t=[],r=e.tagStyles;if(!jl(e)||!ql(s))return t.push({text:s,style:e}),t;const i=[e],n=[];let o="",a=0;for(;a<s.length;){const l=s[a];if(l==="<"){const h=s.indexOf(">",a);if(h===-1){o+=l,a++;continue}const c=s.indexOf("<",a+1);if(c!==-1&&c<h){o+=l,a++;continue}const u=s.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+=s.slice(a,h+1),a=h+1;continue}}else{const d=u.trim();if(r[d]){o.length>0&&(t.push({text:o,style:i[i.length-1]}),o="");const f=i[i.length-1],p=qp(f,r[d]);i.push(p),n.push(d),a=h+1;continue}else{o+=s.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 Zp=[10,13],Qp=new Set(Zp),Jp=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],em=new Set(Jp),tm=[9,32];new Set(tm);const rm=[45,8208,8211,8212,173],sm=new Set(rm),im=/(\r\n|\r|\n)/,nm=/(?:\r\n|\r|\n)/;function ss(s){return typeof s!="string"?!1:Qp.has(s.charCodeAt(0))}function Be(s,e){return typeof s!="string"?!1:em.has(s.charCodeAt(0))}function om(s){return typeof s!="string"?!1:sm.has(s.charCodeAt(0))}function Kl(s){return s==="normal"||s==="pre-line"}function Zl(s){return s==="normal"}function $e(s){if(typeof s!="string")return"";let e=s.length-1;for(;e>=0&&Be(s[e]);)e--;return e<s.length-1?s.slice(0,e+1):s}function Ql(s){const e=[],t=[];if(typeof s!="string")return e;for(let r=0;r<s.length;r++){const i=s[r],n=s[r+1];if(Be(i)||ss(i)){t.length>0&&(e.push(t.join("")),t.length=0),i==="\r"&&n===`
|
|
805
|
+
`?(e.push(`\r
|
|
806
|
+
`),r++):e.push(i);continue}t.push(i),om(i)&&n&&!Be(n)&&!ss(n)&&(e.push(t.join("")),t.length=0)}return t.length>0&&e.push(t.join("")),e}function Jl(s,e,t,r){const i=t(s),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(!r(l,c,s,o,e))a+=c,l=c,h++;else break}o+=h-1,n.push(a)}return n}const am=/\r\n|\r|\n/g;function lm(s,e,t,r,i,n,o,a,l){var F,le;const h=Kp(s,e);if(Zl(e.whiteSpace))for(let P=0;P<h.length;P++){const k=h[P];h[P]={text:k.text.replace(am," "),style:k.style}}const u=[];let d=[];for(const P of h){const k=P.text.split(im);for(let D=0;D<k.length;D++){const R=k[D];R===`\r
|
|
807
|
+
`||R==="\r"||R===`
|
|
808
|
+
`?(u.push(d),d=[]):R.length>0&&d.push({text:R,style:P.style})}}(d.length>0||u.length===0)&&u.push(d);const f=t?hm(u,e,r,n,a,l):u,p=[],g=[],m=[],_=[],x=[];let y=0;const v=e._fontString,S=o(v);S.fontSize===0&&(S.fontSize=e.fontSize,S.ascent=e.fontSize);let T="",C=!!e.dropShadow,B=((F=e._stroke)==null?void 0:F.width)||0;for(const P of f){let k=0,D=S.ascent,R=S.descent,L="";for(const U of P){const q=U.style._fontString,se=o(q);q!==T&&(r.font=q,T=q);const oe=i(U.text,U.style.letterSpacing,r);k+=oe,D=Math.max(D,se.ascent),R=Math.max(R,se.descent),L+=U.text;const Z=((le=U.style._stroke)==null?void 0:le.width)||0;Z>B&&(B=Z),!C&&U.style.dropShadow&&(C=!0)}P.length===0&&(D=S.ascent,R=S.descent),p.push(k),g.push(D),m.push(R),x.push(L);const j=e.lineHeight||D+R;_.push(j+e.leading),y=Math.max(y,k)}const M=B,w=y+M+(e.dropShadow?e.dropShadow.distance:0);let E=0;for(let P=0;P<_.length;P++)E+=_[P];E=Math.max(E,_[0]+M);const A=E+(e.dropShadow?e.dropShadow.distance:0),I=e.lineHeight||S.fontSize;return{width:w,height:A,lines:x,lineWidths:p,lineHeight:I+e.leading,maxLineWidth:y,fontProperties:S,runsByLine:f,lineAscents:g,lineDescents:m,lineHeights:_,hasDropShadow:C}}function hm(s,e,t,r,i,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:h}=e,c=Kl(a),u=l+o,d={};let f="";const p=(_,x)=>{const y=`${_}|${x.styleKey}`;let v=d[y];if(v===void 0){const S=x._fontString;S!==f&&(t.font=S,f=S),v=r(_,x.letterSpacing,t)+x.letterSpacing,d[y]=v}return v},g=[];for(const _ of s){const x=cm(_),y=g.length,v=A=>{let I=0,F=A;do{const{token:le,style:P}=x[F];I+=p(le,P),F++}while(F<x.length&&x[F].continuesFromPrevious);return I},S=A=>{const I=[];let F=A;do I.push({token:x[F].token,style:x[F].style}),F++;while(F<x.length&&x[F].continuesFromPrevious);return I};let T=[],C=0,B=!c,M=null;const w=()=>{M&&M.text.length>0&&T.push(M),M=null},E=()=>{if(w(),T.length>0){const A=T[T.length-1];A.text=$e(A.text),A.text.length===0&&T.pop()}g.push(T),T=[],C=0,B=!1};for(let A=0;A<x.length;A++){const{token:I,style:F,continuesFromPrevious:le}=x[A],P=p(I,F);if(c){const R=Be(I),L=(M==null?void 0:M.text[M.text.length-1])??((m=T[T.length-1])==null?void 0:m.text.slice(-1))??"",j=L?Be(L):!1;if(R&&j)continue}const k=!le,D=k?v(A):P;if(D>u&&k)if(C>0&&E(),h){const R=S(A);for(let L=0;L<R.length;L++){const j=R[L].token,U=R[L].style,q=Jl(j,h,n,i);for(const se of q){const oe=p(se,U);oe+C>u&&E(),!M||M.style!==U?(w(),M={text:se,style:U}):M.text+=se,C+=oe}}A+=R.length-1}else{const R=S(A);w(),g.push(R.map(L=>({text:L.token,style:L.style}))),B=!1,A+=R.length-1}else if(D+C>u&&k){if(Be(I)){B=!1;continue}E(),M={text:I,style:F},C=P}else if(le&&!h)!M||M.style!==F?(w(),M={text:I,style:F}):M.text+=I,C+=P;else{const R=Be(I);if(C===0&&R&&!B)continue;!M||M.style!==F?(w(),M={text:I,style:F}):M.text+=I,C+=P}}if(w(),T.length>0){const A=T[T.length-1];A.text=$e(A.text),A.text.length===0&&T.pop()}(T.length>0||g.length===y)&&g.push(T)}return g}function cm(s){const e=[];let t=!1;for(const r of s){const i=Ql(r.text);let n=!0;for(const o of i){const a=Be(o)||ss(o),l=n&&t&&!a;e.push({token:o,style:r.style,continuesFromPrevious:l}),t=!a,n=!1}}return e}const um={willReadFrequently:!0};function jo(s,e,t,r,i){let n=t[s];return typeof n!="number"&&(n=i(s,e,r)+e,t[s]=n),n}function dm(s,e,t,r,i,n,o){const a=t.getContext("2d",um);a.font=e._fontString;let l=0,h="";const c=[],u=Object.create(null),{letterSpacing:d,whiteSpace:f}=e,p=Kl(f),g=Zl(f);let m=!p;const _=e.wordWrapWidth+d,x=Ql(s);for(let v=0;v<x.length;v++){let S=x[v];if(ss(S)){if(!g){c.push($e(h)),m=!p,h="",l=0;continue}S=" "}if(p){const C=Be(S),B=Be(h[h.length-1]);if(C&&B)continue}const T=jo(S,d,u,a,r);if(T>_)if(h!==""&&(c.push($e(h)),h="",l=0),i(S,e.breakWords)){const C=Jl(S,e.breakWords,o,n);for(const B of C){const M=jo(B,d,u,a,r);M+l>_&&(c.push($e(h)),m=!1,h="",l=0),h+=B,l+=M}}else h.length>0&&(c.push($e(h)),h="",l=0),c.push($e(S)),m=!1,h="",l=0;else T+l>_&&(m=!1,c.push($e(h)),h="",l=0),(h.length>0||!Be(S)||m)&&(h+=S,l+=T)}const y=$e(h);return y.length>0&&c.push(y),c.join(`
|
|
809
|
+
`)}const qo={willReadFrequently:!0},et=class H{static get experimentalLetterSpacingSupported(){let e=H._experimentalLetterSpacingSupported;if(e===void 0){const t=Y.get().getCanvasRenderingContext2D().prototype;e=H._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,r,i,n,o,a,l,h,c){this.text=e,this.style=t,this.width=r,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,r=H._canvas,i=t.wordWrap){var v;const n=`${e}-${t.styleKey}-wordWrap-${i}`;if(H._measurementCache.has(n))return H._measurementCache.get(n);if(jl(t)&&ql(e)){const S=lm(e,t,i,H._context,H._measureText,H._measureTextAdvance,H.measureFont,H.canBreakChars,H.wordWrapSplit),T=new H(e,t,S.width,S.height,S.lines,S.lineWidths,S.lineHeight,S.maxLineWidth,S.fontProperties,{runsByLine:S.runsByLine,lineAscents:S.lineAscents,lineDescents:S.lineDescents,lineHeights:S.lineHeights,hasDropShadow:S.hasDropShadow});return H._measurementCache.set(n,T),T}const a=t._fontString,l=H.measureFont(a);l.fontSize===0&&(l.fontSize=t.fontSize,l.ascent=t.fontSize,l.descent=0);const h=H._context;h.font=a;const u=(i?H._wordWrap(e,t,r):e).split(nm),d=new Array(u.length);let f=0;for(let S=0;S<u.length;S++){const T=H._measureText(u[S],t.letterSpacing,h);d[S]=T,f=Math.max(f,T)}const p=((v=t._stroke)==null?void 0:v.width)??0,g=t.lineHeight||l.fontSize,m=H._adjustWidthForStyle(f,t),_=Math.max(g,l.fontSize+p)+(u.length-1)*(g+t.leading),x=H._adjustHeightForStyle(_,t),y=new H(e,t,m,x,u,d,g+t.leading,f,l);return H._measurementCache.set(n,y),y}static _adjustWidthForStyle(e,t){var n;const r=((n=t._stroke)==null?void 0:n.width)||0;let i=e+r;return t.dropShadow&&(i+=t.dropShadow.distance),i}static _adjustHeightForStyle(e,t){let r=e;return t.dropShadow&&(r+=t.dropShadow.distance),r}static _measureText(e,t,r){const{metricWidth:i,metrics:n,letterSpacingVal:o}=H._measureTextCore(e,t,r),a=-(n.actualBoundingBoxLeft??0);let h=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(h+=o),Math.max(i,h)}static _measureTextAdvance(e,t,r){return H._measureTextCore(e,t,r).metricWidth}static _measureTextCore(e,t,r){let i=!1;H.experimentalLetterSpacingSupported&&(H.experimentalLetterSpacing?(r.letterSpacing=`${t}px`,r.textLetterSpacing=`${t}px`,i=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));const n=r.measureText(e);let o=n.width,a=0;return o>0&&(i?a=-t:a=(H.graphemeSegmenter(e).length-1)*t,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,t,r=H._canvas){return dm(e,t,r,H._measureTextAdvance,H.canBreakWords,H.canBreakChars,H.wordWrapSplit)}static isBreakingSpace(e,t){return Be(e)}static canBreakWords(e,t){return t}static canBreakChars(e,t,r,i,n){return!0}static wordWrapSplit(e){return H.graphemeSegmenter(e)}static measureFont(e){if(H._fonts[e])return H._fonts[e];const t=H._context;t.font=e;const r=t.measureText(H.METRICS_STRING+H.BASELINE_SYMBOL),i=r.actualBoundingBoxAscent??0,n=r.actualBoundingBoxDescent??0,o={ascent:i,descent:n,fontSize:i+n};return H._fonts[e]=o,o}static clearMetrics(e=""){e?delete H._fonts[e]:H._fonts={}}static get _canvas(){if(!H.__canvas){let e;try{const t=new OffscreenCanvas(0,0),r=t.getContext("2d",qo);if(r!=null&&r.measureText)return H.__canvas=t,t;e=Y.get().createCanvas()}catch{e=Y.get().createCanvas()}e.width=e.height=10,H.__canvas=e}return H.__canvas}static get _context(){return H.__context||(H.__context=H._canvas.getContext("2d",qo)),H.__context}};et.METRICS_STRING="|ÉqÅ";et.BASELINE_SYMBOL="M";et.BASELINE_MULTIPLIER=1.4;et.HEIGHT_MULTIPLIER=2;et.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return e=>{const t=s.segment(e),r=[];let i=0;for(const n of t)r[i++]=n.segment;return r}}return s=>[...s]})();et.experimentalLetterSpacing=!1;et._fonts={};et._measurementCache=jp(1e3);let rt=et;const fm=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function hi(s){const e=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let t=s.fontFamily;Array.isArray(s.fontFamily)||(t=s.fontFamily.split(","));for(let r=t.length-1;r>=0;r--){let i=t[r].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!fm.includes(i)&&(i=`"${i}"`),t[r]=i}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${e} ${t.join(",")}`}const Ko=1e5;function Or(s,e,t,r=0,i=0,n=0){if(s.texture===N.WHITE&&!s.fill)return Q.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof Tr){const o=s.fill,a=e.createPattern(o.texture.source.resource,"repeat"),l=o.transform.copyTo(G.shared);return l.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),a.setTransform(l),a}else if(s.fill instanceof We){const o=s.fill,a=o.type==="linear",l=o.textureSpace==="local";let h=1,c=1;l&&t&&(h=t.width+r,c=t.height+r);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+r/2)/c;o.colorStops.forEach(m=>{let _=g+m.offset*f;_=Math.max(0,Math.min(1,_)),u.addColorStop(Math.floor(_*Ko)/Ko,Q.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,Q.shared.setValue(f.color).toHex())});return u}}else{const o=e.createPattern(s.texture.source.resource,"repeat"),a=s.matrix.copyTo(G.shared);return a.scale(s.texture.source.pixelWidth,s.texture.source.pixelHeight),o.setTransform(a),o}return z("FillStyle not recognised",s),"red"}const Zo=new ee;function Rt(s){let e=0;for(let t=0;t<s.length;t++)s.charCodeAt(t)===32&&e++;return e}class pm{getCanvasAndContext(e){const{text:t,style:r,resolution:i=1}=e,n=r._getFinalPadding(),o=rt.measureText(t||" ",r),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=Xt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(r,n,i,h,o);const c=r.trim?$p({canvas:h.canvas,width:a,height:l,resolution:1,output:Zo}):Zo.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(e){Xt.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,r,i,n){var S,T,C;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,r,i);return}const{canvas:o,context:a}=i,l=hi(e),h=n.lines,c=n.lineHeight,u=n.lineWidths,d=n.maxLineWidth,f=n.fontProperties,p=o.height;if(a.resetTransform(),a.scale(r,r),a.textBaseline=e.textBaseline,(S=e._stroke)!=null&&S.width){const B=e._stroke;a.lineWidth=B.width,a.miterLimit=B.miterLimit,a.lineJoin=B.join,a.lineCap=B.cap}a.font=l;let g,m;const _=e.dropShadow?2:1,y=(((T=e._stroke)==null?void 0:T.width)??0)/2;let v=(c-f.fontSize)/2;c-f.fontSize<0&&(v=0);for(let B=0;B<_;++B){const M=e.dropShadow&&B===0,w=M?Math.ceil(Math.max(1,p)+t*2):0,E=w*r;if(M)this._setupDropShadow(a,e,r,E);else{const A=e._gradientBounds,I=e._gradientOffset;if(A){const F={width:A.width,height:A.height,lineHeight:A.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,F,t,y,(I==null?void 0:I.x)??0,(I==null?void 0:I.y)??0)}else I?this._setFillAndStrokeStyles(a,e,n,t,y,I.x,I.y):this._setFillAndStrokeStyles(a,e,n,t,y);a.shadowColor="rgba(0,0,0,0)"}for(let A=0;A<h.length;A++){g=y,m=y+A*c+f.ascent+v,g+=this._getAlignmentOffset(u[A],d,e.align);let I=0;if(e.align==="justify"&&e.wordWrap&&A<h.length-1){const F=Rt(h[A]);F>0&&(I=(d-u[A])/F)}(C=e._stroke)!=null&&C.width&&this._drawLetterSpacing(h[A],e,i,g+t,m+t-w,!0,I),e._fill!==void 0&&this._drawLetterSpacing(h[A],e,i,g+t,m+t-w,!1,I)}}}_renderTaggedTextToCanvas(e,t,r,i,n){var y,v,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 T of l)for(const C of T){const B=((v=C.style._stroke)==null?void 0:v.width)??0;B>m&&(m=B)}const _=m/2,x=[];for(let T=0;T<l.length;T++){const C=l[T],B=[];for(const M of C){const w=hi(M.style);a.font=w,B.push({width:rt._measureText(M.text,M.style.letterSpacing,a),font:w})}x.push(B)}for(let T=0;T<g;++T){const C=f&&T===0,B=C?Math.ceil(Math.max(1,p)+r*2):0,M=B*i;C||(a.shadowColor="rgba(0,0,0,0)");let w=_;for(let E=0;E<l.length;E++){const A=l[E],I=h[E],F=u[E],le=d[E],P=x[E];let k=_;k+=this._getAlignmentOffset(I,c,t.align);let D=0;if(t.align==="justify"&&t.wordWrap&&E<l.length-1){let j=0;for(const U of A)j+=Rt(U.text);j>0&&(D=(c-I)/j)}const R=w+F;let L=k+r;for(let j=0;j<A.length;j++){const U=A[j],{width:q,font:se}=P[j];if(a.font=se,a.textBaseline=U.style.textBaseline,(S=U.style._stroke)!=null&&S.width){const Z=U.style._stroke;if(a.lineWidth=Z.width,a.miterLimit=Z.miterLimit,a.lineJoin=Z.join,a.lineCap=Z.cap,C)if(U.style.dropShadow)this._setupDropShadow(a,U.style,i,M);else{const fe=Rt(U.text);L+=q+fe*D;continue}else{const fe=rt.measureFont(se),ye=U.style.lineHeight||fe.fontSize,V={width:q,height:ye,lineHeight:ye,lines:[U.text]};a.strokeStyle=Or(Z,a,V,r*2,L-r,w)}this._drawLetterSpacing(U.text,U.style,n,L,R+r-B,!0,D)}const oe=Rt(U.text);L+=q+oe*D}L=k+r;for(let j=0;j<A.length;j++){const U=A[j],{width:q,font:se}=P[j];if(a.font=se,a.textBaseline=U.style.textBaseline,U.style._fill!==void 0){if(C)if(U.style.dropShadow)this._setupDropShadow(a,U.style,i,M);else{const Z=Rt(U.text);L+=q+Z*D;continue}else{const Z=rt.measureFont(se),fe=U.style.lineHeight||Z.fontSize,ye={width:q,height:fe,lineHeight:fe,lines:[U.text]};a.fillStyle=Or(U.style._fill,a,ye,r*2,L-r,w)}this._drawLetterSpacing(U.text,U.style,n,L,R+r-B,!1,D)}const oe=Rt(U.text);L+=q+oe*D}w+=le}}}_setFillAndStrokeStyles(e,t,r,i,n,o=0,a=0){var l;if(e.fillStyle=t._fill?Or(t._fill,e,r,i*2,o,a):null,(l=t._stroke)!=null&&l.width){const h=n+i*2;e.strokeStyle=Or(t._stroke,e,r,h,o,a)}}_setupDropShadow(e,t,r,i){e.fillStyle="black",e.strokeStyle="black";const n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=Q.shared.setValue(o).setAlpha(a).toRgbaString();const l=n.blur*r,h=n.distance*r;e.shadowBlur=l,e.shadowOffsetX=Math.cos(n.angle)*h,e.shadowOffsetY=Math.sin(n.angle)*h+i}_getAlignmentOffset(e,t,r){return r==="right"?t-e:r==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,r,i,n,o=!1,a=0){const{context:l}=r,h=t.letterSpacing;let c=!1;if(rt.experimentalLetterSpacingSupported&&(rt.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=rt.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 Ut=new pm,Hi=class mt extends ke{constructor(e={}){super(),this.uid=te("textStyle"),this._tick=0,this._cachedFontString=null,mm(e),e instanceof mt&&(e=e._toObject());const i={...mt.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({...mt.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...mt.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({...Ue.defaultFillStyle,...e},()=>{this._fill=_t({...this._originalFill},Ue.defaultFillStyle)})),this._fill=_t(e===0?"black":e,Ue.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ue.defaultStrokeStyle,...e},()=>{this._stroke=es({...this._originalStroke},Ue.defaultStrokeStyle)})),this._stroke=es(e,Ue.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=mt.defaultTextStyle;for(const t in e)this[t]=e[t]}assign(e){for(const t in e){const r=t;this[r]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=hi(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 mt(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 r,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;(r=this._fill)!=null&&r.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:(r,i,n)=>(r[i]===n||(r[i]=n,t==null||t(i,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(Q.isColorLike(e)||e instanceof We||e instanceof Tr)}};Hi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Hi.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 is=Hi;function mm(s){const e=s;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=is.defaultDropShadow;s.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){O(ie,"strokeThickness is now a part of stroke");const t=e.stroke;let r={};if(Q.isColorLike(t))r.color=t;else if(t instanceof We||t instanceof Tr)r.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))r=t;else throw new Error("Invalid stroke value.");s.stroke={...r,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(O(ie,"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&&z("The number of fill colors must match the number of fill gradient stops.");const t=new We({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),r=e.fillGradientStops.slice(),i=e.fill.map(n=>Q.shared.setValue(n).toNumber());r.forEach((n,o)=>{t.addColorStop(n,i[o])}),s.fill={fill:t}}}function gm(s,e){const{texture:t,bounds:r}=s,i=e._style._getFinalPadding();xa(r,e._anchor,t);const n=e._anchor._x*i*2,o=e._anchor._y*i*2;r.minX-=i-n,r.minY-=i-o,r.maxX-=i-n,r.maxY-=i-o}class Wi{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 _m extends Wi{}class eh{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),r=e.styleKey;return t.currentKey!==r?!0:e._didTextUpdate}addRenderable(e,t){const r=this._getGpuText(e);if(e._didTextUpdate){const i=e._autoResolution?this._renderer.resolution:e.resolution;(r.currentKey!==e.styleKey||e._resolution!==i)&&this._updateGpuText(e),e._didTextUpdate=!1,gm(r,e)}this._renderer.renderPipes.batch.addToBatch(r,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 _m;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:r}=this._renderer;r.getReferenceCount(t.currentKey)>0?r.decreaseReferenceCount(t.currentKey):t.texture&&r.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}eh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};class th{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,r,i){typeof e=="string"&&(O("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:r,resolution:t}),e.style instanceof is||(e.style=new is(e.style)),e.textureStyle instanceof yt||(e.textureStyle=new yt(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}=Ut.getCanvasAndContext({text:n,style:o,resolution:h}),d=Gl(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),Ut.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Ut.returnCanvasAndContext(u),d}returnTexture(e){const t=e.source,r=t.resource;if(this._retainCanvasContext&&(r!=null&&r.getContext)){const i=r.getContext("2d");i&&Ut.returnCanvasAndContext({canvas:r,context:i})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",ce.returnTexture(e,!0)}renderTextToCanvas(){O("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 r=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle,autoGenerateMipmaps:e.autoGenerateMipmaps});return this._activeTextures[t]={texture:r,usageCount:1},r}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 r=this._renderer.renderTarget.renderTarget,i=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind(r,!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 rh extends th{constructor(e){super(e,!0)}}rh.extension={type:[b.CanvasSystem],name:"canvasText"};class sh extends th{constructor(e){super(e,!1)}}sh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"canvasText"};W.add(rh);W.add(sh);W.add(eh);class G_ extends zp{constructor(...e){const t=Vp(e,"Text");super(t,is),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof yt?t.textureStyle:new yt(t.textureStyle)),this.autoGenerateMipmaps=t.autoGenerateMipmaps??pe.defaultOptions.autoGenerateMipmaps}updateBounds(){const e=this._bounds,t=this._anchor;let r=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Ut.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ut.returnCanvasAndContext(o),r=n.width,i=n.height}else{const n=rt.measureText(this._text,this._style);r=n.width,i=n.height}e.minX=-t._x*r,e.maxX=e.minX+r,e.minY=-t._y*i,e.maxY=e.minY+i}}function xm(){const{userAgent:s}=Y.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(s)}const zi=class gt{static _getPatternRepeat(e,t){const r=e&&e!=="clamp-to-edge",i=t&&t!=="clamp-to-edge";return r&&i?"repeat":r?"repeat-x":i?"repeat-y":"no-repeat"}start(e,t,r){}execute(e,t){var a,l,h,c;const r=t.elements;if(!r||!r.length)return;const i=e.renderer,n=i.canvasContext,o=n.activeContext;for(let u=0;u<r.length;u++){const d=r[u];if(!d.packAsQuad)continue;const f=d,p=f.texture,g=p?X.getCanvasSource(p):null;if(!g)continue;const m=p.source.style,_=n.smoothProperty,x=m.scaleMode!=="nearest";o[_]!==x&&(o[_]=x),n.setBlendMode(t.blendMode);const y=((a=i.globalUniforms.globalUniformData)==null?void 0:a.worldColor)??4294967295,v=f.color,S=(y>>>24&255)/255,T=(v>>>24&255)/255,C=((l=i.filter)==null?void 0:l.alphaMultiplier)??1,B=S*T*C;if(B<=0)continue;o.globalAlpha=B;const M=y&16777215,w=v&16777215,E=Ot(Dt(w,M)),A=p.frame,I=m.addressModeU??m.addressMode,F=m.addressModeV??m.addressMode,le=gt._getPatternRepeat(I,F),P=p.source._resolution??p.source.resolution??1,k=(c=(h=f.renderable)==null?void 0:h.renderGroup)==null?void 0:c.isCachedAsTexture,D=A.x*P,R=A.y*P,L=A.width*P,j=A.height*P,U=f.bounds,q=i.renderTarget.renderTarget.isRoot,se=U.minX,oe=U.minY,Z=U.maxX-U.minX,fe=U.maxY-U.minY,ye=p.rotate,V=p.uvs,Se=Math.min(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),Ee=Math.max(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),ue=le!=="no-repeat"&&(Se<0||Ee>1),Ie=ye&&!(!ue&&(E!==16777215||ye));Ie?(gt._tempPatternMatrix.copyFrom(f.transform),$.matrixAppendRotationInv(gt._tempPatternMatrix,ye,se,oe,Z,fe),n.setContextTransform(gt._tempPatternMatrix,f.roundPixels===1,void 0,k&&q)):n.setContextTransform(f.transform,f.roundPixels===1,void 0,k&&q);const Me=Ie?0:se,vt=Ie?0:oe,Tt=Z,jt=fe;if(ue){let Sr=g;const St=E!==16777215&&!ye,Ct=A.width<=p.source.width&&A.height<=p.source.height;St&&Ct&&(Sr=X.getTintedCanvas({texture:p},E));const os=o.createPattern(Sr,le);if(!os)continue;const fn=Tt,pn=jt;if(fn===0||pn===0)continue;const mn=1/fn,gn=1/pn,_n=(V.x1-V.x0)*mn,xn=(V.y1-V.y0)*mn,yn=(V.x3-V.x0)*gn,bn=(V.y3-V.y0)*gn,Mc=V.x0-_n*Me-yn*vt,Ac=V.y0-xn*Me-bn*vt,as=p.source.pixelWidth,ls=p.source.pixelHeight;gt._tempPatternMatrix.set(_n*as,xn*ls,yn*as,bn*ls,Mc*as,Ac*ls),X.applyPatternTransform(os,gt._tempPatternMatrix),o.fillStyle=os,o.fillRect(Me,vt,Tt,jt)}else{const St=E!==16777215||ye?X.getTintedCanvas({texture:p},E):g,Ct=St!==g;o.drawImage(St,Ct?0:D,Ct?0:R,Ct?St.width:L,Ct?St.height:j,Me,vt,Tt,jt)}}}};zi._tempPatternMatrix=new G;zi.extension={type:[b.CanvasPipesAdaptor],name:"batch"};let ym=zi;class ih{constructor(){this._tempState=Je.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,r){const i=e.renderer,n=this._didUploadHash[r.uid];i.shader.bind(r,n),n||(this._didUploadHash[r.uid]=!0),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(t,r.glProgram)}execute(e,t){const r=e.renderer;this._tempState.blendMode=t.blendMode,r.state.set(this._tempState);const i=t.textures.textures;for(let n=0;n<t.textures.count;n++)r.texture.bind(i[n],n);r.geometry.draw(t.topology,t.size,t.start)}}ih.extension={type:[b.WebGLPipesAdaptor],name:"batch"};const Lr=Je.for2d();class nh{start(e,t,r){const i=e.renderer,n=i.encoder,o=r.gpuProgram;this._shader=r,this._geometry=t,n.setGeometry(t,o),Lr.blendMode="normal",i.pipeline.getPipeline(t,o,Lr);const a=i.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(e,t){const r=this._shader.gpuProgram,i=e.renderer,n=i.encoder;if(!t.bindGroup){const l=t.textures;t.bindGroup=Pi(l.textures,l.count,i.limits.maxBatchableTextures)}Lr.blendMode=t.blendMode;const o=i.bindGroup.getBindGroup(t.bindGroup,r,1),a=i.pipeline.getPipeline(this._geometry,r,Lr,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)}}nh.extension={type:[b.WebGPUPipesAdaptor],name:"batch"};const Vi=class oh{constructor(e,t){var r,i;this.state=Je.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,(i=(r=this._adaptor).init)==null||i.call(r,this)}static getBatcher(e){return new this._availableBatchers[e]}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new ki({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const r in this._activeBatches)this._activeBatches[r].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let r=this._activeBatches[e.batcherName];r||(r=this._activeBatches[e.batcherName]=oh.getBatcher(e.batcherName),r.begin()),this._activeBatch=r}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const r in t){const i=t[r],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 r in t){const i=t[r],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,r=t.geometry,i=t.shader;this._adaptor.start(this,r,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}};Vi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};Vi._availableBatchers=Object.create(null);let Xi=Vi;W.handleByMap(b.Batcher,Xi._availableBatchers);W.add(ki);const bm={name:"texture-bit",vertex:{header:`
|
|
810
|
+
|
|
811
|
+
struct TextureUniforms {
|
|
812
|
+
uTextureMatrix:mat3x3<f32>,
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
816
|
+
`,main:`
|
|
817
|
+
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
818
|
+
`},fragment:{header:`
|
|
819
|
+
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
820
|
+
@group(2) @binding(1) var uSampler: sampler;
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
`,main:`
|
|
824
|
+
outColor = textureSample(uTexture, uSampler, vUV);
|
|
825
|
+
`}},vm={name:"texture-bit",vertex:{header:`
|
|
826
|
+
uniform mat3 uTextureMatrix;
|
|
827
|
+
`,main:`
|
|
828
|
+
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
829
|
+
`},fragment:{header:`
|
|
830
|
+
uniform sampler2D uTexture;
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
`,main:`
|
|
834
|
+
outColor = texture(uTexture, vUV);
|
|
835
|
+
`}},Tm=new xe;class Sm extends jr{constructor(){super(),this.filters=[new Dp({sprite:new Ht(N.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 $i{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,r){const i=this._renderer;if(i.renderPipes.batch.break(r),r.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(r,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,r=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const i=ge.get(Sm);if(i.inverse=e.inverse,i.channel=e.mask.channel,r){e.mask.mask.measurable=!0;const n=gi(e.mask.mask,!0,Tm);e.mask.mask.measurable=!1,n.ceil();const o=t.renderTarget.renderTarget.colorTexture.source,a=ce.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];r&&(t.type===Pe.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();r&&ce.returnTexture(i.filterTexture),ge.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}$i.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"};class ah{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,r){this._renderer.renderPipes.batch.break(r);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,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ah.extension={type:[b.CanvasPipes],name:"colorMask"};class lh{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,r){this._renderer.renderPipes.batch.break(r);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,r.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,r.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}lh.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"colorMask"};function Cm(s,e,t,r,i,n){n=Math.max(0,Math.min(n,Math.min(r,i)/2)),s.moveTo(e+n,t),s.lineTo(e+r-n,t),s.quadraticCurveTo(e+r,t,e+r,t+n),s.lineTo(e+r,t+i-n),s.quadraticCurveTo(e+r,t+i,e+r-n,t+i),s.lineTo(e+n,t+i),s.quadraticCurveTo(e,t+i,e,t+i-n),s.lineTo(e,t+n),s.quadraticCurveTo(e,t,e+n,t)}function hh(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Cm(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.moveTo(t.x+t.radius,t.y),s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?(s.moveTo(t.x+t.halfWidth,t.y),s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.moveTo(1,0),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}case"polygon":default:{const t=e,r=t.points;if(!(r!=null&&r.length))break;s.moveTo(r[0],r[1]);for(let i=2;i<r.length;i+=2)s.lineTo(r[i],r[i+1]);t.closePath&&s.closePath();break}}}function wm(s,e,t){const r=[],i=[],n=[],o=Yt[e.type];if(!(o!=null&&o.build(e,r)))return!1;const a=e.closePath??!0;Gi(r,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;s.moveTo(i[h],i[h+1]),s.lineTo(i[c],i[c+1]),s.lineTo(i[u],i[u+1]),s.closePath()}return!0}function Pm(s,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!(r!=null&&r.shape))continue;const i=r.transform,n=i&&!i.isIdentity();n&&(s.save(),s.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),hh(s,r.shape),n&&s.restore()}return!0}class ch{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.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,r=t.canvasContext,i=r==null?void 0:r.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 rs)){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(),r.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 v=0;v<y.length;v++){const S=y[v];if(!(S!=null&&S.shape))continue;const T=S.transform,C=T&&!T.isIdentity();C&&(i.save(),i.transform(T.a,T.b,T.c,T.d,T.tx,T.ty)),x&&m.style?l=wm(i,S.shape,m.style)||l:(hh(i,S.shape),h=Pm(i,S.holes)||h,l=!0),C&&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),z(t))}}ch.extension={type:[b.CanvasPipes],name:"stencilMask"};class uh{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,r){var i;const n=e,o=this._renderer;o.renderPipes.batch.break(r),o.renderPipes.blendMode.setBlendMode(n.mask,"none",r),r.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=r.instructionSize,a.collectRenderables(r,o,null),a.includeInBuild=!1,o.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const h=r.instructionSize-l.instructionsStart-1;l.instructionsLength=h;const c=o.renderTarget.renderTarget.uid;(i=this._maskStackHash)[c]??(i[c]=0)}pop(e,t,r){const i=e,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(i.mask,"none",r),r.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++)r.instructions[r.instructionSize++]=r.instructions[o.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){var t;const r=this._renderer,i=r,n=r.renderTarget.renderTarget.uid;let o=(t=this._maskStackHash)[n]??(t[n]=0);e.action==="pushMaskBegin"?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(de.RENDERING_MASK_ADD,o),o++,i.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?i.stencil.setStencilMode(de.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(de.MASK_ACTIVE,o),i.colorMask.setMask(15)):e.action==="popMaskBegin"?(i.colorMask.setMask(0),o!==0?i.stencil.setStencilMode(de.RENDERING_MASK_REMOVE,o):(i.renderTarget.clear(null,we.STENCIL),i.stencil.setStencilMode(de.DISABLED,o)),o--):e.action==="popMaskEnd"&&(e.inverse?i.stencil.setStencilMode(de.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(de.MASK_ACTIVE,o),i.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}uh.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"stencilMask"};const J="source-over";function Em(){const s=kl(),e=Object.create(null);return e.inherit=J,e.none=J,e.normal="source-over",e.add="lighter",e.multiply=s?"multiply":J,e.screen=s?"screen":J,e.overlay=s?"overlay":J,e.darken=s?"darken":J,e.lighten=s?"lighten":J,e["color-dodge"]=s?"color-dodge":J,e["color-burn"]=s?"color-burn":J,e["hard-light"]=s?"hard-light":J,e["soft-light"]=s?"soft-light":J,e.difference=s?"difference":J,e.exclusion=s?"exclusion":J,e.saturation=s?"saturation":J,e.color=s?"color":J,e.luminosity=s?"luminosity":J,e["linear-burn"]=s?"color-burn":J,e["linear-dodge"]=s?"color-dodge":J,e["linear-light"]=s?"hard-light":J,e["pin-light"]=s?"hard-light":J,e["vivid-light"]=s?"hard-light":J,e["hard-mix"]=J,e.negation=s?"difference":J,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=J,e.divide=J,e.min=J,e.max=J,e}const Mm=new G;class dh{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=Em(),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,r,i){var h;const n=i?G.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||G.IDENTITY;let o=Mm;o.copyFrom(n),o.append(e);const a=this._projTransform,l=this.activeResolution;if(r=r||l,a){const c=G.shared;c.copyFrom(o),c.prepend(a),o=c}t?this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*l|0,o.ty*l|0):this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*l,o.ty*l)}clear(e,t){const r=this.activeContext,i=this._renderer;if(r.clearRect(0,0,i.width,i.height),e){const n=Q.shared.setValue(e);r.globalAlpha=t??n.alpha,r.fillStyle=n.toHex(),r.fillRect(0,0,i.width,i.height),r.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()}}dh.extension={type:[b.CanvasSystem],name:"canvasContext"};class fh{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}fh.extension={type:[b.CanvasSystem],name:"limits"};class Yi{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}}Yi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"};function ci(s,e){const t=s.instructionSet,r=t.instructions;for(let i=0;i<t.instructionSize;i++){const n=r[i];e[n.renderPipeId].execute(n)}}class ji{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&&(ge.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const r=e._batchableRenderGroup??(e._batchableRenderGroup=ge.get(Wi));r.renderable=e.root,r.transform=e.root.relativeGroupTransform,r.texture=e.texture,r.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(r,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new G().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push(e.texture,!0,null,e.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),ci(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}),ci(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}ji.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"};const Am="#808080",Nr=new G,Rm=new G,Bm=new G,Os=new G;function km(s,e,t){s.beginPath();for(let r=0;r<t.length;r+=3){const i=t[r]*2,n=t[r+1]*2,o=t[r+2]*2;s.moveTo(e[i],e[i+1]),s.lineTo(e[n],e[n+1]),s.lineTo(e[o],e[o+1]),s.closePath()}s.fill()}function Im(s){return`#${(s&16777215).toString(16).padStart(6,"0")}`}function Gm(s,e,t,r,i,n){n=Math.max(0,Math.min(n,Math.min(r,i)/2)),s.moveTo(e+n,t),s.lineTo(e+r-n,t),s.quadraticCurveTo(e+r,t,e+r,t+n),s.lineTo(e+r,t+i-n),s.quadraticCurveTo(e+r,t+i,e+r-n,t+i),s.lineTo(e+n,t+i),s.quadraticCurveTo(e,t+i,e,t+i-n),s.lineTo(e,t+n),s.quadraticCurveTo(e,t,e+n,t)}function Vr(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Gm(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}case"polygon":default:{const t=e,r=t.points;if(!(r!=null&&r.length))break;s.moveTo(r[0],r[1]);for(let i=2;i<r.length;i+=2)s.lineTo(r[i],r[i+1]);t.closePath&&s.closePath();break}}}function Fm(s,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!(r!=null&&r.shape))continue;const i=r.transform,n=i&&!i.isIdentity();n&&(s.save(),s.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),Vr(s,r.shape),n&&s.restore()}return!0}function Um(s,e,t,r){const i=s.fill;if(i instanceof We){i.buildGradient();const o=i.texture;if(o){const a=X.getTintedPattern(o,e),l=t?Os.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):Os.copyFrom(i.transform);return r&&!s.textureSpace&&l.append(r),X.applyPatternTransform(a,l),a}}if(i instanceof Tr){const o=X.getTintedPattern(i.texture,e);return X.applyPatternTransform(o,i.transform),o}const n=s.texture;if(n&&n!==N.WHITE){if(!n.source.resource)return Am;const o=X.getTintedPattern(n,e),a=t?Os.copyFrom(t).scale(n.source.pixelWidth,n.source.pixelHeight):s.matrix;return X.applyPatternTransform(o,a),o}return Im(e)}class ph{constructor(){this.shader=null}contextChange(e){}execute(e,t){var x,y,v,S,T,C,B;const r=e.renderer,i=r.canvasContext,n=i.activeContext,o=t.groupTransform,a=((x=r.globalUniforms.globalUniformData)==null?void 0:x.worldColor)??4294967295,l=t.groupColorAlpha,h=(a>>>24&255)/255,c=(l>>>24&255)/255,u=((y=r.filter)==null?void 0:y.alphaMultiplier)??1,d=h*c*u;if(d<=0)return;const f=a&16777215,p=l&16777215,g=Ot(Dt(p,f)),m=r._roundPixels|t._roundPixels;n.save(),i.setContextTransform(o,m===1),i.setBlendMode(t.groupBlendMode);const _=t.context.instructions;for(let M=0;M<_.length;M++){const w=_[M];if(w.action==="texture"){const D=w.data,R=D.image,L=R?X.getCanvasSource(R):null;if(!L)continue;const j=D.alpha*d;if(j<=0)continue;const U=Dt(D.style,g);n.globalAlpha=j;let q=L;U!==16777215&&(q=X.getTintedCanvas({texture:R},U));const se=R.frame,oe=R.source._resolution??R.source.resolution??1;let Z=se.x*oe,fe=se.y*oe;const ye=se.width*oe,V=se.height*oe;q!==L&&(Z=0,fe=0);const Se=D.transform,Ee=Se&&!Se.isIdentity(),ue=R.rotate;Ee||ue?(Nr.copyFrom(o),Ee&&Nr.append(Se),ue&&$.matrixAppendRotationInv(Nr,ue,D.dx,D.dy,D.dw,D.dh),i.setContextTransform(Nr,m===1)):i.setContextTransform(o,m===1),n.drawImage(q,Z,fe,q===L?ye:q.width,q===L?V:q.height,ue?0:D.dx,ue?0:D.dy,D.dw,D.dh),(Ee||ue)&&i.setContextTransform(o,m===1);continue}const E=w.data,A=(v=E==null?void 0:E.path)==null?void 0:v.shapePath;if(!((S=A==null?void 0:A.shapePrimitives)!=null&&S.length))continue;const I=E.style,F=Dt(I.color,g),le=I.alpha*d;if(le<=0)continue;const P=w.action==="stroke";if(n.globalAlpha=le,P){const D=I;n.lineWidth=D.width,n.lineCap=D.cap,n.lineJoin=D.join,n.miterLimit=D.miterLimit}const k=A.shapePrimitives;if(!P&&((B=(C=(T=E.hole)==null?void 0:T.shapePath)==null?void 0:C.shapePrimitives)!=null&&B.length)){const D=k[k.length-1];D.holes=E.hole.shapePath.shapePrimitives}for(let D=0;D<k.length;D++){const R=k[D];if(!(R!=null&&R.shape))continue;const L=R.transform,j=L&&!L.isIdentity(),U=I.texture&&I.texture!==N.WHITE,q=I.textureSpace==="global"?L:null,se=U?wl(Rm,I,R.shape,q):null,oe=j?Bm.copyFrom(o).append(L):o,Z=Um(I,F,se,oe);if(j&&(n.save(),n.transform(L.a,L.b,L.c,L.d,L.tx,L.ty)),P){const fe=I;if(fe.alignment!==.5&&!fe.pixelLine){const V=[],Se=[],Ee=[],ue=Yt[R.shape.type];if(ue!=null&&ue.build(R.shape,V)){const Oe=R.shape.closePath??!0;Gi(V,fe,!1,Oe,Se,Ee),n.fillStyle=Z,km(n,Se,Ee)}else n.strokeStyle=Z,n.beginPath(),Vr(n,R.shape),n.stroke()}else n.strokeStyle=Z,n.beginPath(),Vr(n,R.shape),n.stroke()}else n.fillStyle=Z,n.beginPath(),Vr(n,R.shape),Fm(n,R.holes)?n.fill("evenodd"):n.fill();j&&n.restore()}}n.restore()}destroy(){this.shader=null}}ph.extension={type:[b.CanvasPipesAdaptor],name:"graphics"};class qi{constructor(e){this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,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 Wi;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}}qi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"};const ur={};W.handle(b.BlendMode,s=>{if(!s.name)throw new Error("BlendMode extension must have a name property");ur[s.name]=s.ref},s=>{delete ur[s.name]});class Ki{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,r){this._blendModeStack.push(t),this.setBlendMode(e,t,r)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,r){var n;const i=e instanceof Ys;if(this._activeBlendMode===t){this._isAdvanced&&e&&!i&&((n=this._renderableList)==null||n.push(e));return}this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=t,e&&(this._isAdvanced=!!ur[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,r))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const r=this._activeBlendMode;if(!ur[r]){z(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const i=this._ensureFilterEffect(r),n=e instanceof Ys,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 jr,t.filters=[new ur[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}}Ki.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"};function ui(s,e){e||(e=0);for(let t=e;t<s.length&&s[t];t++)s[t]=null}const Dm=new ve,Qo=ar|Kr|bi;function mh(s,e=!1){Om(s);const t=s.childrenToUpdate,r=s.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===s&&c.relativeRenderGroupDepth===n&&gh(c,r,0)}ui(a,l),o.index=0}if(e)for(let i=0;i<s.renderGroupChildren.length;i++)mh(s.renderGroupChildren[i],e)}function Om(s){const e=s.root;let t;if(s.renderGroupParent){const r=s.renderGroupParent;s.worldTransform.appendFrom(e.relativeGroupTransform,r.worldTransform),s.worldColor=qr(e.groupColor,r.worldColor),t=e.groupAlpha*r.worldAlpha}else s.worldTransform.copyFrom(e.localTransform),s.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,s.worldAlpha=t,s.worldColorAlpha=s.worldColor+((t*255|0)<<24)}function gh(s,e,t){if(e===s.updateTick)return;s.updateTick=e,s.didChange=!1;const r=s.localTransform;s.updateLocalTransform();const i=s.parent;if(i&&!i.renderGroup?(t|=s._updateFlags,s.relativeGroupTransform.appendFrom(r,i.relativeGroupTransform),t&Qo&&Jo(s,i,t)):(t=s._updateFlags,s.relativeGroupTransform.copyFrom(r),t&Qo&&Jo(s,Dm,t)),!s.renderGroup){const n=s.children,o=n.length;for(let h=0;h<o;h++)gh(n[h],e,t);const a=s.parentRenderGroup,l=s;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Jo(s,e,t){if(t&Kr){s.groupColor=qr(s.localColor,e.groupColor);let r=s.localAlpha*e.groupAlpha;r=r<0?0:r>1?1:r,s.groupAlpha=r,s.groupColorAlpha=s.groupColor+((r*255|0)<<24)}t&bi&&(s.groupBlendMode=s.localBlendMode==="inherit"?e.groupBlendMode:s.localBlendMode),t&ar&&(s.globalDisplayStatus=s.localDisplayStatus&e.globalDisplayStatus),s._updateFlags=0}function Lm(s,e){const{list:t}=s.childrenRenderablesToUpdate;let r=!1;for(let i=0;i<s.childrenRenderablesToUpdate.index;i++){const n=t[i];if(r=e[n.renderPipeId].validateRenderable(n),r)break}return s.structureDidChange=r,r}const Nm=new G;class _h{constructor(e){this._renderer=e}render({container:e,transform:t}){const r=e.parent,i=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const n=this._renderer,o=Nm;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}),ci(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=r,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 r=e.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(e.renderGroupChildren[r],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const r=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;r.ceil(),e.texture&&ce.returnTexture(e.texture,!0);const h=ce.getOptimalTexture(r.width,r.height,n,o);h._source.style=new yt({scaleMode:a}),e.texture=h,e._textureBounds||(e._textureBounds=new xe),e._textureBounds.copyFrom(r),l!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(ce.returnTexture(e.texture,!0),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,r=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=r,e.structureDidChange?ui(e.childrenRenderablesToUpdate.list,0):Lm(e,r),mh(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:r}=e.childrenRenderablesToUpdate;for(let i=0;i<r;i++){const n=t[i];n.didViewUpdate&&e.updateRenderable(n)}ui(t,r)}_buildInstructions(e,t){const r=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(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(i,n,null),o.batch.buildEnd(i),o.blendMode.buildEnd(i)}}_h.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"};const Zi=class xh{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Q(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...xh.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){Q.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&z("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Zi.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0};Zi.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Hm=Zi;const Ls={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Qi=class yh{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof ve||e instanceof N?{target:e,...t}:{...t,...e}}async image(e){const t=Y.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,yh.defaultImageOptions);const{format:t,quality:r}=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)},Ls[t],r)});if(i.toDataURL!==void 0)return i.toDataURL(Ls[t],r);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:Ls[t],quality:r});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,r=this._renderer;if(t instanceof N)return r.texture.generateCanvas(t);const i=r.textureGenerator.generateTexture(e),n=r.texture.generateCanvas(i);return i.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);const t=e.target,r=this._renderer,i=t instanceof N?t:r.textureGenerator.generateTexture(e),n=r.texture.getPixels(i);return t instanceof ve&&i.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof N?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),r=document.createElement("a");r.download=e.filename??"image.png",r.href=t.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const r=this.canvas(e),i=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.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}};Qi.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"extract"};Qi.defaultImageOptions={format:"png",quality:1};let Wm=Qi;class Ji extends N{static create(e){const{dynamic:t,textureOptions:r,...i}=e;return new Ji({...r,source:new pe(i),dynamic:t??!1})}resize(e,t,r){return this.source.resize(e,t,r),this}}const zm=new ee,Vm=new xe,Xm=[0,0,0,0];class bh{constructor(e){this._renderer=e}generateTexture(e){var c;e instanceof ve&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,i=e.target;let n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:Q.shared.setValue(n).toArray():n=Xm;const o=((c=e.frame)==null?void 0:c.copyTo(zm))||xi(i,Vm).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=Ji.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:r,textureOptions:a}),h=G.shared.translate(-o.x,-o.y);return this._renderer.render({container:i,transform:h,target:l,clearColor:n}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}bh.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"textureGenerator"};function $m(s){let e=!1;for(const r in s)if(s[r]==null){e=!0;break}if(!e)return s;const t=Object.create(null);for(const r in s){const i=s[r];i&&(t[r]=i)}return t}function Ym(s){let e=0;for(let t=0;t<s.length;t++)s[t]==null?e++:s[t-e]=s[t];return s.length-=e,s}const en=class vh{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(e){e={...vh.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:r,collection:i,type:n}=t;n==="hash"?r[i]=$m(r[i]):r[i]=Ym(r[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 r of e.renderGroupChildren)this._updateInstructionGCTick(r,t)}addCollection(e,t,r){this._managedCollections.push({context:e,collection:t,type:r})}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 r=this._managedResources.length;e._gcData={index:r,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 r=t.index,i=this._managedResources.length-1;if(r!==i){const n=this._managedResources[i];this._managedResources[r]=n,n._gcData.index=r}this._managedResources.length--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,r,i=0){this._managedResourceHashes.push({context:e,hash:t,type:r,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 r=0;for(let i=0;i<this._managedResources.length;i++){const n=this._managedResources[i];r=this.runOnResource(n,e,r)}this._managedResources.length=r}updateRenderableGCTick(e,t){var n,o;const r=e.renderGroup??e.parentRenderGroup,i=((n=r==null?void 0:r.instructionSet)==null?void 0:n.gcTick)??-1;((r==null?void 0:r.gcTick)??0)===i&&(e._gcLastUsed=t,(o=e._onTouch)==null||o.call(e,t))}runOnResource(e,t,r){const i=e._gcData;return i.type==="renderable"&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[r]=e,i.index=r,r++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off("unload",this.removeResource,this)),r}_createHashClone(e,t){const r=Object.create(null);for(const i in e){if(i===t)break;e[i]!==null&&(r[i]=e[i])}return r}runOnHash(e,t){var h;const{context:r,hash:i,type:n}=e,o=r[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&&(r[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}};en.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"gc",priority:0};en.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let jm=en;class Th{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:r,worldColor:i,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new G,worldColor:4294967295,offset:new re},l={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:r||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,Xl(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 it,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===Pe.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 De({uProjectionMatrix:{value:new G,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new G,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Th.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"};let qm=1;class Sh{constructor(){this._tasks=[],this._offset=0}init(){Re.system.add(this._update,this)}repeat(e,t,r=!0){const i=qm++;let n=0;return r&&(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 r=this._tasks[t];if(e-r.offset-r.last>=r.duration){const i=e-r.start;r.func(i),r.last=e}}}destroy(){Re.system.remove(this._update,this),this._tasks.length=0}}Sh.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"scheduler",priority:0};let ea=!1;function Km(s){if(!ea){if(Y.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Qr} (${s}) http://www.pixijs.com/
|
|
836
|
+
|
|
837
|
+
`,"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 ${Qr} - ${s} - http://www.pixijs.com/`);ea=!0}}class tn{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===Pe.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),Km(t)}}}tn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2};tn.defaultOptions={hello:!1};const rn=class Ch{constructor(e){this._renderer=e}init(e){e={...Ch.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return O("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){O("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){O("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){O("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){O("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){O("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};rn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderableGC",priority:0};rn.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Zm=rn;const sn=class Xr{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){O("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){O("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){O("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){O("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!==Xr.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==Xr.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==Xr.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){O("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};sn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"};sn.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Qm=sn;const wh=class Ph{constructor(e={}){if(this.uid=te("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...Ph.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 pe({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(r=>r.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 N||e.depthStencilTexture instanceof pe?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 pe({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(e,t,r=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(e,t,r)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,r)}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)}};wh.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let di=wh;const Gt=new Map;$t.register(Gt);function Eh(s,e){if(!Gt.has(s)){const t=new N({source:new He({resource:s,...e})}),r=()=>{Gt.get(s)===t&&Gt.delete(s)};t.once("destroy",r),t.source.once("destroy",r),Gt.set(s,t)}return Gt.get(s)}const nn=class Mh{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={...Mh.defaultOptions,...e},e.view&&(O(ie,"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||Y.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Eh(this.canvas,e),this.renderTarget=new di({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(e,t,r){this.texture.source.resize(e,t,r),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()}};nn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0};nn.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Jm=nn;const on=[Hm,Th,tn,Jm,_h,jm,Qm,bh,Wm,il,Zm,Sh],Ah=[Ki,Xi,qi,ji,$i,uh,lh,Yi];function eg(s,e,t,r,i,n){const o=n?1:-1;return s.identity(),s.a=1/r*2,s.d=o*(1/i*2),s.tx=-1-e*s.a,s.ty=-o-t*s.d,s}function tg(s){const e=s.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class an{constructor(e){this.rootViewPort=new ee,this.viewport=new ee,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new el("onRenderTargetChange"),this.projectionMatrix=new G,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:r,frame:i,mipLevel:n,layer:o}){var a,l;this._renderTargetStack.length=0,this.push(e,t,r,i,n??0,o??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=tg(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,r,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 N&&(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,v=i.height*g+.5|0;let S=Math.floor(_/m),T=Math.floor(x/m),C=Math.ceil(y/m),B=Math.ceil(v/m);S=Math.min(Math.max(S,0),f-1),T=Math.min(Math.max(T,0),p-1),C=Math.min(Math.max(C,1),f-S),B=Math.min(Math.max(B,1),p-T),u.x=S,u.y=T,u.width=C,u.height=B}else u.x=0,u.y=0,u.width=f,u.height=p;return eg(this.projectionMatrix,0,0,u.width/c.resolution,u.height/c.resolution,!a.isRoot),this.adaptor.startRenderPass(a,t,r,u,n,o),l&&this.onRenderTargetChange.emit(a),a}clear(e,t=we.ALL,r,i=this.mipLevel,n=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,r,this.viewport,i,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=we.ALL,r,i,n=0,o=0){const a=this.bind(e,t,r,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,r,i,n){r.x<0&&(i.width+=r.x,n.x-=r.x,r.x=0),r.y<0&&(i.height+=r.y,n.y-=r.y,r.y=0);const{pixelWidth:o,pixelHeight:a}=e;return i.width=Math.min(i.width,o-r.x),i.height=Math.min(i.height,a-r.y),this.adaptor.copyToTexture(e,t,r,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 He.test(e)&&(e=Eh(e).source),e instanceof di?t=e:e instanceof pe&&(t=new di({colorTextures:[e]}),e.source instanceof He&&(t.isRoot=!0),e.once("destroy",()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);const r=this._gpuRenderTargetHash[t.uid];r&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(r))})),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 rg{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:r,context:i}=this._ensureCanvas(t);return{canvas:r,context:i,width:r.width,height:r.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:r}=this._ensureCanvas(t);r.width=e.pixelWidth,r.height=e.pixelHeight}startRenderPass(e,t,r,i){const n=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,r,i)}clear(e,t,r,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),r){const l=Q.shared.setValue(r);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,r,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,r.x,r.y,i.width,i.height,c,u,i.width,i.height),l.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!He.test(t))&&(t=Y.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 r=t.getContext("2d");return{canvas:t,context:r}}}class Rh extends an{constructor(e){super(e),this.adaptor=new rg,this.adaptor.init(e,this)}}Rh.extension={type:[b.CanvasSystem],name:"renderTarget"};class Bh{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=Y.get().createCanvas(),r=t.getContext("2d"),i=X.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),r.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(){}}Bh.extension={type:[b.CanvasSystem],name:"texture"};const sg=[...on,dh,fh,Bh,Rh],ig=[Ki,Xi,qi,ji,$i,ch,ah,Yi],ng=[ym,ph],kh=[],Ih=[],Gh=[];W.handleByNamedList(b.CanvasSystem,kh);W.handleByNamedList(b.CanvasPipes,Ih);W.handleByNamedList(b.CanvasPipesAdaptor,Gh);W.add(...sg,...ig,...ng);class og extends vr{constructor(){const e={name:"canvas",type:Pe.CANVAS,systems:kh,renderPipes:Ih,renderPipeAdaptors:Gh};super(e)}}const ag=Object.freeze(Object.defineProperty({__proto__:null,CanvasRenderer:og},Symbol.toStringTag,{value:"Module"}));var $r=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))($r||{});class lg{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 Fh{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,r=this.getGlBuffer(e);t.bindBuffer(r.type,r.buffer)}bindBufferBase(e,t){const{_gl:r}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,r.bindBufferBase(r.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 r=0,i=this._nextBindBaseIndex;for(;r<2;){i>=this._maxBindings&&(i=this._minBaseLocation,r++);const n=this._boundBufferBases[i];if(n&&n._lastBindCallId===this._bindCallId){i++;continue}break}return t=i,this._nextBindBaseIndex=i+1,r>=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,r,i){const{_gl:n}=this;r||(r=0),t||(t=0),this._boundBufferBases[t]=null,n.bindBufferRange(n.UNIFORM_BUFFER,t||0,e.buffer,r*256,i||256)}updateBuffer(e){const{_gl:t}=this,r=this.getGlBuffer(e);if(e._updateID===r.updateID)return r;r.updateID=e._updateID,t.bindBuffer(r.type,r.buffer);const i=e.data,n=e.descriptor.usage&ne.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return i?r.byteLength>=i.byteLength?t.bufferSubData(r.type,0,i,0,e._updateSize/i.BYTES_PER_ELEMENT):(r.byteLength=i.byteLength,t.bufferData(r.type,i,n)):(r.byteLength=e.descriptor.size,t.bufferData(r.type,r.byteLength,n)),r}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const r=e._gpuData[this._renderer.uid];r&&(t||this._gl.deleteBuffer(r.buffer))}createGLBuffer(e){const{_gl:t}=this;let r=$r.ARRAY_BUFFER;e.descriptor.usage&ne.INDEX?r=$r.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&ne.UNIFORM&&(r=$r.UNIFORM_BUFFER);const i=new lg(t.createBuffer(),r);return e._gpuData[this._renderer.uid]=i,this._managedBuffers.add(e),i}resetState(){this._boundBufferBases=Object.create(null)}}Fh.extension={type:[b.WebGLSystem],name:"buffer"};const ln=class Uh{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={...Uh.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(z("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=Y.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const r=this._renderer.background.alpha<1,i=e.premultipliedAlpha??!0,n=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:r,premultipliedAlpha:i,antialias:n,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&z("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 Y.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 r;const i=this.canvas;if(e===2&&(r=i.getContext("webgl2",t)),!r&&(r=i.getContext("webgl",t),!r))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=r,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 r=e.getExtension("WEBGL_provoking_vertex");r&&r.provokingVertexWEBGL(r.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&&z("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=this.supports,i=this.webGLVersion===2,n=this.extensions;r.uint32Indices=i||!!n.uint32ElementIndex,r.uniformBufferObject=i,r.vertexArrayObject=i||!!n.vertexArrayObject,r.srgbTextures=i||!!n.srgb,r.nonPowOf2wrapping=i,r.nonPowOf2mipmaps=i,r.msaa=i,r.uint32Indices||z("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};ln.extension={type:[b.WebGLSystem],name:"context"};ln.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let hg=ln;function Dh(s,e){for(const t in s.attributes){const r=s.attributes[t],i=e[t];i?(r.format??(r.format=i.format),r.offset??(r.offset=i.offset),r.instance??(r.instance=i.instance)):z(`Attribute ${t} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}cg(s)}function cg(s){const{buffers:e,attributes:t}=s,r={},i={};for(const n in e){const o=e[n];r[o.uid]=0,i[o.uid]=0}for(const n in t){const o=t[n];r[o.buffer.uid]+=pr(o.format).stride}for(const n in t){const o=t[n];o.stride??(o.stride=r[o.buffer.uid]),o.start??(o.start=i[o.buffer.uid]),i[o.buffer.uid]+=pr(o.format).stride}}var fi=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(fi||{}),hn=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(hn||{}),K=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(K||{});const ta={uint8x2:K.UNSIGNED_BYTE,uint8x4:K.UNSIGNED_BYTE,sint8x2:K.BYTE,sint8x4:K.BYTE,unorm8x2:K.UNSIGNED_BYTE,unorm8x4:K.UNSIGNED_BYTE,snorm8x2:K.BYTE,snorm8x4:K.BYTE,uint16x2:K.UNSIGNED_SHORT,uint16x4:K.UNSIGNED_SHORT,sint16x2:K.SHORT,sint16x4:K.SHORT,unorm16x2:K.UNSIGNED_SHORT,unorm16x4:K.UNSIGNED_SHORT,snorm16x2:K.SHORT,snorm16x4:K.SHORT,float16x2:K.HALF_FLOAT,float16x4:K.HALF_FLOAT,float32:K.FLOAT,float32x2:K.FLOAT,float32x3:K.FLOAT,float32x4:K.FLOAT,uint32:K.UNSIGNED_INT,uint32x2:K.UNSIGNED_INT,uint32x3:K.UNSIGNED_INT,uint32x4:K.UNSIGNED_INT,sint32:K.INT,sint32x2:K.INT,sint32x3:K.INT,sint32x4:K.INT};function ug(s){return ta[s]??ta.float32}const dg={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class fg{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Oh{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 r=this._renderer.context.extensions.vertexAttribDivisorANGLE;r&&(e.drawArraysInstanced=(i,n,o,a)=>{r.drawArraysInstancedANGLE(i,n,o,a)},e.drawElementsInstanced=(i,n,o,a,l)=>{r.drawElementsInstancedANGLE(i,n,o,a,l)},e.vertexAttribDivisor=(i,n)=>r.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const r=this.gl;this._activeGeometry=e;const i=this.getVao(e,t);this._activeVao!==i&&(this._activeVao=i,r.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let r=0;r<e.buffers.length;r++){const i=e.buffers[r];t.updateBuffer(i)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const r=e.attributes,i=t._attributeData;for(const n in i)if(!r[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(e,t){const r=e.attributes,i=t._attributeData,n=["g",e.uid];for(const o in r)i[o]&&n.push(o,i[o].location);return n.join("-")}getVao(e,t){var r;return((r=e._gpuData[this._renderer.uid])==null?void 0:r.vaoCache[t._key])||this.initGeometryVao(e,t)}initGeometryVao(e,t,r=!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 fg,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;Dh(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 r=e._gpuData[this._renderer.uid];if(!r)return;const i=r.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 r=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;r.enableVertexAttribArray(f);const p=pr(h.format),g=ug(h.format);if(((a=d.format)==null?void 0:a.substring(1,4))==="int"?r.vertexAttribIPointer(f,p.size,g,h.stride,h.offset):r.vertexAttribPointer(f,p.size,g,p.normalised,h.stride,h.offset),h.instance)if(this.hasInstance){const m=h.divisor??1;r.vertexAttribDivisor(f,m)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,r,i){const{gl:n}=this._renderer,o=this._activeGeometry,a=dg[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,(r||0)*l,i):n.drawElements(a,t||o.indexBuffer.data.length,h,(r||0)*l)}else i!==1?n.drawArraysInstanced(a,r||0,t||o.getSize(),i):n.drawArrays(a,r||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}}Oh.extension={type:[b.WebGLSystem],name:"geometry"};const pg=new Ei({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),cn=class Lh{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:r}={...Lh.defaultOptions,...e};this.useBackBuffer=t,this._antialias=r,this._renderer.context.supports.msaa||(z("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Je.for2d();const i=new ot({vertex:`
|
|
838
|
+
attribute vec2 aPosition;
|
|
839
|
+
out vec2 vUv;
|
|
840
|
+
|
|
841
|
+
void main() {
|
|
842
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
843
|
+
|
|
844
|
+
vUv = (aPosition + 1.0) / 2.0;
|
|
845
|
+
|
|
846
|
+
// flip dem UVs
|
|
847
|
+
vUv.y = 1.0 - vUv.y;
|
|
848
|
+
}`,fragment:`
|
|
849
|
+
in vec2 vUv;
|
|
850
|
+
out vec4 finalColor;
|
|
851
|
+
|
|
852
|
+
uniform sampler2D uTexture;
|
|
853
|
+
|
|
854
|
+
void main() {
|
|
855
|
+
finalColor = texture(uTexture, vUv);
|
|
856
|
+
}`,name:"big-triangle"});this._bigTriangleShader=new Qe({glProgram:i,resources:{uTexture:N.WHITE.source}})}renderStart(e){const t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){const r=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=r.colorTexture,e.target=this._getBackBufferTexture(r.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:pg,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new N({source:new pe({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)}};cn.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1};cn.defaultOptions={useBackBuffer:!1};let mg=cn;class Nh{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)))}}Nh.extension={type:[b.WebGLSystem],name:"colorMask"};class Hh{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:r,shader:i,state:n,skipSync:o,topology:a,size:l,start:h,instanceCount:c}=e;t.shader.bind(i,o),t.geometry.bind(r,t.shader._activeProgram),n&&t.state.set(n),t.geometry.draw(a,l,h,c??r.instanceCount)}destroy(){this._renderer=null}}Hh.extension={type:[b.WebGLSystem],name:"encoder"};class Wh{constructor(e){this._renderer=e}contextChange(){const e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=hl(this.maxTextures,e);const t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Wh.extension={type:[b.WebGLSystem],name:"limits"};class gg{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const at=[];at[de.NONE]=void 0;at[de.DISABLED]={stencilWriteMask:0,stencilReadMask:0};at[de.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};at[de.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};at[de.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};at[de.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class zh{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:de.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:de.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=de.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=at[e],o=this._stencilCache;if(r.stencilMode=e,r.stencilReference=t,e===de.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]))}}zh.extension={type:[b.WebGLSystem],name:"stencil"};class Vh{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!qa())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 nt({data:new Float32Array(t.layout.size/4),usage:ne.UNIFORM|ne.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){const t=e._signature;let r=this._syncFunctionHash[t];if(!r){const i=Object.keys(e.uniformStructures).map(a=>e.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);r=this._syncFunctionHash[t]={layout:n,syncFunction:o}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,r){const i=this.getUniformGroupData(e);e.buffer||(e.buffer=new nt({data:new Float32Array(i.layout.size/4),usage:ne.UNIFORM|ne.COPY_DST}));let n=null;return t||(t=e.buffer.data,n=e.buffer.dataInt32),r||(r=0),i.syncFunction(e.uniforms,t,n,r),!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 Xh={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 _g(s){const e=s.map(n=>({data:n,offset:0,size:0})),t=16;let r=0,i=0;for(let n=0;n<e.length;n++){const o=e[n];if(r=Xh[o.data.type],!r)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(r=Math.max(r,t)*o.data.size);const a=r===12?16:r;o.size=r;const l=i%t;l>0&&t-l<a?i+=(t-l)%16:i+=(r-l%r)%r,o.offset=i,i+=r}return i=Math.ceil(i/16)*16,{uboElements:e,size:i}}const xt=[{type:"mat3x3<f32>",test:s=>s.value.a!==void 0,ubo:`
|
|
857
|
+
var matrix = uv[name].toArray(true);
|
|
858
|
+
data[offset] = matrix[0];
|
|
859
|
+
data[offset + 1] = matrix[1];
|
|
860
|
+
data[offset + 2] = matrix[2];
|
|
861
|
+
data[offset + 4] = matrix[3];
|
|
862
|
+
data[offset + 5] = matrix[4];
|
|
863
|
+
data[offset + 6] = matrix[5];
|
|
864
|
+
data[offset + 8] = matrix[6];
|
|
865
|
+
data[offset + 9] = matrix[7];
|
|
866
|
+
data[offset + 10] = matrix[8];
|
|
867
|
+
`,uniform:`
|
|
868
|
+
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
869
|
+
`},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.width!==void 0,ubo:`
|
|
870
|
+
v = uv[name];
|
|
871
|
+
data[offset] = v.x;
|
|
872
|
+
data[offset + 1] = v.y;
|
|
873
|
+
data[offset + 2] = v.width;
|
|
874
|
+
data[offset + 3] = v.height;
|
|
875
|
+
`,uniform:`
|
|
876
|
+
cv = ud[name].value;
|
|
877
|
+
v = uv[name];
|
|
878
|
+
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
879
|
+
cv[0] = v.x;
|
|
880
|
+
cv[1] = v.y;
|
|
881
|
+
cv[2] = v.width;
|
|
882
|
+
cv[3] = v.height;
|
|
883
|
+
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
884
|
+
}
|
|
885
|
+
`},{type:"vec2<f32>",test:s=>s.type==="vec2<f32>"&&s.size===1&&s.value.x!==void 0,ubo:`
|
|
886
|
+
v = uv[name];
|
|
887
|
+
data[offset] = v.x;
|
|
888
|
+
data[offset + 1] = v.y;
|
|
889
|
+
`,uniform:`
|
|
890
|
+
cv = ud[name].value;
|
|
891
|
+
v = uv[name];
|
|
892
|
+
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
893
|
+
cv[0] = v.x;
|
|
894
|
+
cv[1] = v.y;
|
|
895
|
+
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
896
|
+
}
|
|
897
|
+
`},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
|
|
898
|
+
v = uv[name];
|
|
899
|
+
data[offset] = v.red;
|
|
900
|
+
data[offset + 1] = v.green;
|
|
901
|
+
data[offset + 2] = v.blue;
|
|
902
|
+
data[offset + 3] = v.alpha;
|
|
903
|
+
`,uniform:`
|
|
904
|
+
cv = ud[name].value;
|
|
905
|
+
v = uv[name];
|
|
906
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
907
|
+
cv[0] = v.red;
|
|
908
|
+
cv[1] = v.green;
|
|
909
|
+
cv[2] = v.blue;
|
|
910
|
+
cv[3] = v.alpha;
|
|
911
|
+
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
912
|
+
}
|
|
913
|
+
`},{type:"vec3<f32>",test:s=>s.type==="vec3<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
|
|
914
|
+
v = uv[name];
|
|
915
|
+
data[offset] = v.red;
|
|
916
|
+
data[offset + 1] = v.green;
|
|
917
|
+
data[offset + 2] = v.blue;
|
|
918
|
+
`,uniform:`
|
|
919
|
+
cv = ud[name].value;
|
|
920
|
+
v = uv[name];
|
|
921
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
922
|
+
cv[0] = v.red;
|
|
923
|
+
cv[1] = v.green;
|
|
924
|
+
cv[2] = v.blue;
|
|
925
|
+
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
926
|
+
}
|
|
927
|
+
`}];function $h(s,e,t,r){const i=[`
|
|
928
|
+
var v = null;
|
|
929
|
+
var v2 = null;
|
|
930
|
+
var t = 0;
|
|
931
|
+
var index = 0;
|
|
932
|
+
var name = null;
|
|
933
|
+
var arrayOffset = null;
|
|
934
|
+
`];let n=0;for(let a=0;a<s.length;a++){const l=s[a],h=l.data.name;let c=!1,u=0;for(let d=0;d<xt.length;d++)if(xt[d].test(l.data)){u=l.offset/4,i.push(`name = "${h}";`,`offset += ${u-n};`,xt[d][e]||xt[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=r[l.data.type];u=l.offset/4,i.push(`
|
|
935
|
+
v = uv.${h};
|
|
936
|
+
offset += ${u-n};
|
|
937
|
+
${d};
|
|
938
|
+
`)}n=u}const o=i.join(`
|
|
939
|
+
`);return new Function("uv","data","dataInt32","offset",o)}function Bt(s,e){return`
|
|
940
|
+
for (let i = 0; i < ${s*e}; i++) {
|
|
941
|
+
data[offset + (((i / ${s})|0) * 4) + (i % ${s})] = v[i];
|
|
942
|
+
}
|
|
943
|
+
`}const Yh={f32:`
|
|
944
|
+
data[offset] = v;`,i32:`
|
|
945
|
+
dataInt32[offset] = v;`,"vec2<f32>":`
|
|
946
|
+
data[offset] = v[0];
|
|
947
|
+
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
948
|
+
data[offset] = v[0];
|
|
949
|
+
data[offset + 1] = v[1];
|
|
950
|
+
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
951
|
+
data[offset] = v[0];
|
|
952
|
+
data[offset + 1] = v[1];
|
|
953
|
+
data[offset + 2] = v[2];
|
|
954
|
+
data[offset + 3] = v[3];`,"vec2<i32>":`
|
|
955
|
+
dataInt32[offset] = v[0];
|
|
956
|
+
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
|
|
957
|
+
dataInt32[offset] = v[0];
|
|
958
|
+
dataInt32[offset + 1] = v[1];
|
|
959
|
+
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
|
|
960
|
+
dataInt32[offset] = v[0];
|
|
961
|
+
dataInt32[offset + 1] = v[1];
|
|
962
|
+
dataInt32[offset + 2] = v[2];
|
|
963
|
+
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
964
|
+
data[offset] = v[0];
|
|
965
|
+
data[offset + 1] = v[1];
|
|
966
|
+
data[offset + 4] = v[2];
|
|
967
|
+
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
968
|
+
data[offset] = v[0];
|
|
969
|
+
data[offset + 1] = v[1];
|
|
970
|
+
data[offset + 2] = v[2];
|
|
971
|
+
data[offset + 4] = v[3];
|
|
972
|
+
data[offset + 5] = v[4];
|
|
973
|
+
data[offset + 6] = v[5];
|
|
974
|
+
data[offset + 8] = v[6];
|
|
975
|
+
data[offset + 9] = v[7];
|
|
976
|
+
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
977
|
+
for (let i = 0; i < 16; i++) {
|
|
978
|
+
data[offset + i] = v[i];
|
|
979
|
+
}`,"mat3x2<f32>":Bt(3,2),"mat4x2<f32>":Bt(4,2),"mat2x3<f32>":Bt(2,3),"mat4x3<f32>":Bt(4,3),"mat2x4<f32>":Bt(2,4),"mat3x4<f32>":Bt(3,4)},xg={...Yh,"mat2x2<f32>":`
|
|
980
|
+
data[offset] = v[0];
|
|
981
|
+
data[offset + 1] = v[1];
|
|
982
|
+
data[offset + 2] = v[2];
|
|
983
|
+
data[offset + 3] = v[3];
|
|
984
|
+
`};function yg(s,e){const t=Math.max(Xh[s.data.type]/16,1),r=s.data.value.length/s.data.size,i=(4-r%4)%4,n=s.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
985
|
+
v = uv.${s.data.name};
|
|
986
|
+
offset += ${e};
|
|
987
|
+
|
|
988
|
+
arrayOffset = offset;
|
|
989
|
+
|
|
990
|
+
t = 0;
|
|
991
|
+
|
|
992
|
+
for(var i=0; i < ${s.data.size*t}; i++)
|
|
993
|
+
{
|
|
994
|
+
for(var j = 0; j < ${r}; j++)
|
|
995
|
+
{
|
|
996
|
+
${n}[arrayOffset++] = v[t++];
|
|
997
|
+
}
|
|
998
|
+
${i!==0?`arrayOffset += ${i};`:""}
|
|
999
|
+
}
|
|
1000
|
+
`}function bg(s){return $h(s,"uboStd40",yg,Yh)}class jh extends Vh{constructor(){super({createUboElements:_g,generateUboSync:bg})}}jh.extension={type:[b.WebGLSystem],name:"ubo"};class vg{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},(r,i)=>e.COLOR_ATTACHMENT0+i)}copyToTexture(e,t,r,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,r.x,r.y,i.width,i.height),t}startRenderPass(e,t=!0,r,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,r)}finishRenderPass(e){const r=this._renderTargetSystem.getGpuRenderTarget(e);if(!r.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,r.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,r.framebuffer),i.blitFramebuffer(0,0,r.width,r.height,0,0,r.width,r.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,r.framebuffer)}initGpuRenderTarget(e){const r=this._renderer.gl,i=new gg;return i._attachedMipLevel=0,i._attachedLayer=0,e.colorTexture instanceof He?(this._renderer.context.ensureCanvasSize(e.colorTexture.resource),i.framebuffer=null,i):(this._initColor(e,i),r.bindFramebuffer(r.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(r=>{t.deleteRenderbuffer(r)}),e.msaaRenderBuffer=null}clear(e,t,r,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?we.ALL:we.NONE);const l=this._renderer.gl;if(t&we.COLOR){r??(r=a.defaultClearColor);const h=this._clearColorCache,c=r;(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 r=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,r),(e.stencil||e.depth)&&this._resizeStencil(r)}_initColor(e,t){const r=this._renderer,i=r.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&&(r.context.supports.msaa?t.msaa=!0:z("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),r.texture.bindSource(h,0);const c=r.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(r.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 r=e.colorTexture.source;if(t.width=r.pixelWidth,t.height=r.pixelHeight,t._attachedMipLevel=0,t._attachedLayer=0,e.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(r.width,r.height,r._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,r=t.createRenderbuffer();e.depthStencilRenderBuffer=r,t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,r),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&&He.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(this._renderer.context.multiView&&He.test(e.colorTexture.resource)){const t=this._renderer.context.canvas,r=e.colorTexture;r.context2D.drawImage(t,0,r.pixelHeight-t.height)}}_setDrawBuffers(e,t){const r=e.colorTextures.length,i=this._drawBuffersCache[r];if(this._renderer.context.webGLVersion===1){const n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(i):z("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else t.drawBuffers(i)}}class qh extends an{constructor(e){super(e),this.adaptor=new vg,this.adaptor.init(e,this)}}qh.extension={type:[b.WebGLSystem],name:"renderTarget"};class un extends ke{constructor({buffer:e,offset:t,size:r}){super(),this.uid=te("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=te("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=r,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=te("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 Tg(s,e){const t=[],r=[`
|
|
1001
|
+
var g = s.groups;
|
|
1002
|
+
var sS = r.shader;
|
|
1003
|
+
var p = s.glProgram;
|
|
1004
|
+
var ugS = r.uniformGroup;
|
|
1005
|
+
var resources;
|
|
1006
|
+
`];let i=!1,n=0;const o=e._getProgramData(s.glProgram);for(const l in s.groups){const h=s.groups[l];t.push(`
|
|
1007
|
+
resources = g[${l}].resources;
|
|
1008
|
+
`);for(const c in h.resources){const u=h.resources[c];if(u instanceof De)if(u.ubo){const d=s._uniformBindMap[l][Number(c)];t.push(`
|
|
1009
|
+
sS.bindUniformBlock(
|
|
1010
|
+
resources[${c}],
|
|
1011
|
+
'${d}',
|
|
1012
|
+
${s.glProgram._uniformBlockData[d].index}
|
|
1013
|
+
);
|
|
1014
|
+
`)}else t.push(`
|
|
1015
|
+
ugS.updateUniformGroup(resources[${c}], p, sD);
|
|
1016
|
+
`);else if(u instanceof un){const d=s._uniformBindMap[l][Number(c)];t.push(`
|
|
1017
|
+
sS.bindUniformBlock(
|
|
1018
|
+
resources[${c}],
|
|
1019
|
+
'${d}',
|
|
1020
|
+
${s.glProgram._uniformBlockData[d].index}
|
|
1021
|
+
);
|
|
1022
|
+
`)}else if(u instanceof pe){const d=s._uniformBindMap[l][c],f=o.uniformData[d];f&&(i||(i=!0,r.push(`
|
|
1023
|
+
var tS = r.texture;
|
|
1024
|
+
`)),e._gl.uniform1i(f.location,n),t.push(`
|
|
1025
|
+
tS.bind(resources[${c}], ${n});
|
|
1026
|
+
`),n++)}}}const a=[...r,...t].join(`
|
|
1027
|
+
`);return new Function("r","s","sD",a)}class Sg{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 ra(s,e,t){const r=s.createShader(e);return s.shaderSource(r,t),s.compileShader(r),r}function Ns(s){const e=new Array(s);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Kh(s,e){switch(s){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 Ns(2*e);case"bvec3":return Ns(3*e);case"bvec4":return Ns(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 Hr=null;const sa={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"},Cg={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 Zh(s,e){if(!Hr){const t=Object.keys(sa);Hr={};for(let r=0;r<t.length;++r){const i=t[r];Hr[s[i]]=sa[i]}}return Hr[e]}function wg(s,e){const t=Zh(s,e);return Cg[t]||"float32"}function Pg(s,e,t=!1){const r={},i=e.getProgramParameter(s,e.ACTIVE_ATTRIBUTES);for(let o=0;o<i;o++){const a=e.getActiveAttrib(s,o);if(a.name.startsWith("gl_"))continue;const l=wg(e,a.type);r[a.name]={location:0,format:l,stride:pr(l).stride,offset:0,instance:!1,start:0}}const n=Object.keys(r);if(t){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)r[n[o]].location=o,e.bindAttribLocation(s,o,n[o]);e.linkProgram(s)}else for(let o=0;o<n.length;o++)r[n[o]].location=e.getAttribLocation(s,n[o]);return r}function Eg(s,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const t={},r=e.getProgramParameter(s,e.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;i++){const n=e.getActiveUniformBlockName(s,i),o=e.getUniformBlockIndex(s,n),a=e.getActiveUniformBlockParameter(s,i,e.UNIFORM_BLOCK_DATA_SIZE);t[n]={name:n,index:o,size:a}}return t}function Mg(s,e){const t={},r=e.getProgramParameter(s,e.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){const n=e.getActiveUniform(s,i),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Zh(e,n.type);t[o]={name:o,index:i,type:l,size:n.size,isArray:a,value:Kh(l,n.size)}}return t}function ia(s,e){const t=s.getShaderSource(e).split(`
|
|
1028
|
+
`).map((h,c)=>`${c}: ${h}`),r=s.getShaderInfoLog(e),i=r.split(`
|
|
1029
|
+
`),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(`
|
|
1030
|
+
`);a[0]=l,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Ag(s,e,t,r){s.getProgramParameter(e,s.LINK_STATUS)||(s.getShaderParameter(t,s.COMPILE_STATUS)||ia(s,t),s.getShaderParameter(r,s.COMPILE_STATUS)||ia(s,r),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(e)))}function Rg(s,e){const t=ra(s,s.VERTEX_SHADER,e.vertex),r=ra(s,s.FRAGMENT_SHADER,e.fragment),i=s.createProgram();s.attachShader(i,t),s.attachShader(i,r);const n=e.transformFeedbackVaryings;n&&(typeof s.transformFeedbackVaryings!="function"?z("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(i),s.getProgramParameter(i,s.LINK_STATUS)||Ag(s,i,t,r),e._attributeData=Pg(i,s,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=Mg(i,s),e._uniformBlockData=Eg(i,s),s.deleteShader(t),s.deleteShader(r);const o={};for(const l in e._uniformData){const h=e._uniformData[l];o[l]={location:s.getUniformLocation(i,l),value:Kh(h.type,h.size)}}return new Sg(i,o)}const Wr={textureCount:0,blockIndex:0};class Qh{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;Wr.textureCount=0,Wr.blockIndex=0;let r=this._shaderSyncFunctions[e.glProgram._key];r||(r=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),r(this._renderer,e,Wr)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,Wr)}bindUniformBlock(e,t,r=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[r]!==h&&(n.uniformBlockBindings[r]=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]=Rg(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 Tg(e,t)}resetState(){this._activeProgram=null}}Qh.extension={type:[b.WebGLSystem],name:"shader"};const Bg={f32:`if (cv !== v) {
|
|
1031
|
+
cu.value = v;
|
|
1032
|
+
gl.uniform1f(location, v);
|
|
1033
|
+
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1034
|
+
cv[0] = v[0];
|
|
1035
|
+
cv[1] = v[1];
|
|
1036
|
+
gl.uniform2f(location, v[0], v[1]);
|
|
1037
|
+
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1038
|
+
cv[0] = v[0];
|
|
1039
|
+
cv[1] = v[1];
|
|
1040
|
+
cv[2] = v[2];
|
|
1041
|
+
gl.uniform3f(location, v[0], v[1], v[2]);
|
|
1042
|
+
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1043
|
+
cv[0] = v[0];
|
|
1044
|
+
cv[1] = v[1];
|
|
1045
|
+
cv[2] = v[2];
|
|
1046
|
+
cv[3] = v[3];
|
|
1047
|
+
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
1048
|
+
}`,i32:`if (cv !== v) {
|
|
1049
|
+
cu.value = v;
|
|
1050
|
+
gl.uniform1i(location, v);
|
|
1051
|
+
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1052
|
+
cv[0] = v[0];
|
|
1053
|
+
cv[1] = v[1];
|
|
1054
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
1055
|
+
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1056
|
+
cv[0] = v[0];
|
|
1057
|
+
cv[1] = v[1];
|
|
1058
|
+
cv[2] = v[2];
|
|
1059
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
1060
|
+
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1061
|
+
cv[0] = v[0];
|
|
1062
|
+
cv[1] = v[1];
|
|
1063
|
+
cv[2] = v[2];
|
|
1064
|
+
cv[3] = v[3];
|
|
1065
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
1066
|
+
}`,u32:`if (cv !== v) {
|
|
1067
|
+
cu.value = v;
|
|
1068
|
+
gl.uniform1ui(location, v);
|
|
1069
|
+
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1070
|
+
cv[0] = v[0];
|
|
1071
|
+
cv[1] = v[1];
|
|
1072
|
+
gl.uniform2ui(location, v[0], v[1]);
|
|
1073
|
+
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1074
|
+
cv[0] = v[0];
|
|
1075
|
+
cv[1] = v[1];
|
|
1076
|
+
cv[2] = v[2];
|
|
1077
|
+
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
1078
|
+
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1079
|
+
cv[0] = v[0];
|
|
1080
|
+
cv[1] = v[1];
|
|
1081
|
+
cv[2] = v[2];
|
|
1082
|
+
cv[3] = v[3];
|
|
1083
|
+
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
1084
|
+
}`,bool:`if (cv !== v) {
|
|
1085
|
+
cu.value = v;
|
|
1086
|
+
gl.uniform1i(location, v);
|
|
1087
|
+
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
1088
|
+
cv[0] = v[0];
|
|
1089
|
+
cv[1] = v[1];
|
|
1090
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
1091
|
+
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
1092
|
+
cv[0] = v[0];
|
|
1093
|
+
cv[1] = v[1];
|
|
1094
|
+
cv[2] = v[2];
|
|
1095
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
1096
|
+
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
1097
|
+
cv[0] = v[0];
|
|
1098
|
+
cv[1] = v[1];
|
|
1099
|
+
cv[2] = v[2];
|
|
1100
|
+
cv[3] = v[3];
|
|
1101
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
1102
|
+
}`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},kg={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 Ig(s,e){const t=[`
|
|
1103
|
+
var v = null;
|
|
1104
|
+
var cv = null;
|
|
1105
|
+
var cu = null;
|
|
1106
|
+
var t = 0;
|
|
1107
|
+
var gl = renderer.gl;
|
|
1108
|
+
var name = null;
|
|
1109
|
+
`];for(const r in s.uniforms){if(!e[r]){s.uniforms[r]instanceof De?s.uniforms[r].ubo?t.push(`
|
|
1110
|
+
renderer.shader.bindUniformBlock(uv.${r}, "${r}");
|
|
1111
|
+
`):t.push(`
|
|
1112
|
+
renderer.shader.updateUniformGroup(uv.${r});
|
|
1113
|
+
`):s.uniforms[r]instanceof un&&t.push(`
|
|
1114
|
+
renderer.shader.bindBufferResource(uv.${r}, "${r}");
|
|
1115
|
+
`);continue}const i=s.uniformStructures[r];let n=!1;for(let o=0;o<xt.length;o++){const a=xt[o];if(i.type===a.type&&a.test(i)){t.push(`name = "${r}";`,xt[o].uniform),n=!0;break}}if(!n){const a=(i.size===1?Bg:kg)[i.type].replace("location",`ud["${r}"].location`);t.push(`
|
|
1116
|
+
cu = ud["${r}"];
|
|
1117
|
+
cv = cu.value;
|
|
1118
|
+
v = uv["${r}"];
|
|
1119
|
+
${a};`)}}return new Function("ud","uv","renderer","syncData",t.join(`
|
|
1120
|
+
`))}class Jh{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,r){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,r))}_getUniformSyncFunction(e,t){var r;return((r=this._uniformGroupSyncHash[e._signature])==null?void 0:r[t._key])||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){const r=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)),r[t._key]=this._cache[i],r[t._key]}_generateUniformsSync(e,t){return Ig(e,t)}_getSignature(e,t,r){const i=e.uniforms,n=[`${r}-`];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}}Jh.extension={type:[b.WebGLSystem],name:"uniformGroup"};function Gg(s){const e={};if(e.normal=[s.ONE,s.ONE_MINUS_SRC_ALPHA],e.add=[s.ONE,s.ONE],e.multiply=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],e.screen=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],e["screen-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],e.erase=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],!(s instanceof Y.get().getWebGLRenderingContext()))e.min=[s.ONE,s.ONE,s.ONE,s.ONE,s.MIN,s.MIN],e.max=[s.ONE,s.ONE,s.ONE,s.ONE,s.MAX,s.MAX];else{const r=s.getExtension("EXT_blend_minmax");r&&(e.min=[s.ONE,s.ONE,s.ONE,s.ONE,r.MIN_EXT,r.MIN_EXT],e.max=[s.ONE,s.ONE,s.ONE,s.ONE,r.MAX_EXT,r.MAX_EXT])}return e}const Fg=0,Ug=1,Dg=2,Og=3,Lg=4,Ng=5,ec=class pi{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Fg]=this.setBlend,this.map[Ug]=this.setOffset,this.map[Dg]=this.setCullFace,this.map[Og]=this.setDepthTest,this.map[Lg]=this.setFrontFace,this.map[Ng]=this.setDepthMask,this.checks=[],this.defaultState=Je.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=Gg(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let t=this.stateId^e.data,r=0;for(;t;)t&1&&this.map[r].call(this,!!(e.data&1<<r)),t>>=1,r++;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(pi._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(pi._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],r=this.gl;t.length===2?r.blendFunc(t[0],t[1]):r.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,r.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.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 r=this.checks.indexOf(e);t&&r===-1?this.checks.push(e):!t&&r!==-1&&this.checks.splice(r,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}};ec.extension={type:[b.WebGLSystem],name:"state"};let Hg=ec;class Wg{constructor(e){this.target=hn.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=K.UNSIGNED_BYTE,this.internalFormat=fi.RGBA,this.format=fi.RGBA,this.samplerType=0}destroy(){}}const zg={id:"buffer",upload(s,e,t,r,i,n=!1){const o=i||e.target;!n&&e.width===s.width&&e.height===s.height?t.texSubImage2D(o,0,0,0,s.width,s.height,e.format,e.type,s.resource):t.texImage2D(o,0,e.internalFormat,s.width,s.height,0,e.format,e.type,s.resource),e.width=s.width,e.height=s.height}},Vg={"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},Xg={id:"compressed",upload(s,e,t,r,i,n){const o=i??e.target;t.pixelStorei(t.UNPACK_ALIGNMENT,4);let a=s.pixelWidth,l=s.pixelHeight;const h=!!Vg[s.format];for(let c=0;c<s.resource.length;c++){const u=s.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)}}},na=["right","left","top","bottom","front","back"];function $g(s){return{id:"cube",upload(e,t,r,i){const n=e.faces;for(let o=0;o<na.length;o++){const a=na[o],l=n[a];(s[l.uploadMethodId]||s.image).upload(l,t,r,i,hn.TEXTURE_CUBE_MAP_POSITIVE_X+o,(t._layerInitMask&1<<o)===0),t._layerInitMask|=1<<o}t.width=e.pixelWidth,t.height=e.pixelHeight}}}const tc={id:"image",upload(s,e,t,r,i,n=!1){const o=i||e.target,a=s.pixelWidth,l=s.pixelHeight,h=s.resourceWidth,c=s.resourceHeight,u=r===2,d=n||e.width!==a||e.height!==l,f=h>=a&&c>=l,p=s.resource;(u?Yg:jg)(t,o,e,a,l,h,c,p,d,f),e.width=a,e.height=l}};function Yg(s,e,t,r,i,n,o,a,l,h){if(!h){l&&s.texImage2D(e,0,t.internalFormat,r,i,0,t.format,t.type,null),s.texSubImage2D(e,0,0,0,n,o,t.format,t.type,a);return}if(!l){s.texSubImage2D(e,0,0,0,t.format,t.type,a);return}s.texImage2D(e,0,t.internalFormat,r,i,0,t.format,t.type,a)}function jg(s,e,t,r,i,n,o,a,l,h){if(!h){l&&s.texImage2D(e,0,t.internalFormat,r,i,0,t.format,t.type,null),s.texSubImage2D(e,0,0,0,t.format,t.type,a);return}if(!l){s.texSubImage2D(e,0,0,0,t.format,t.type,a);return}s.texImage2D(e,0,t.internalFormat,t.format,t.type,a)}const qg=xm(),Kg={id:"video",upload(s,e,t,r,i,n=qg){if(!s.isValid){const o=i??e.target;t.texImage2D(o,0,e.internalFormat,1,1,0,e.format,e.type,null);return}tc.upload(s,e,t,r,i,n)}},oa={linear:9729,nearest:9728},Zg={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},Hs={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Qg={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function aa(s,e,t,r,i,n,o,a){const l=n;if(!a||s.addressModeU!=="repeat"||s.addressModeV!=="repeat"||s.addressModeW!=="repeat"){const h=Hs[o?"clamp-to-edge":s.addressModeU],c=Hs[o?"clamp-to-edge":s.addressModeV],u=Hs[o?"clamp-to-edge":s.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||s.magFilter!=="linear")&&e[i](l,e.TEXTURE_MAG_FILTER,oa[s.magFilter]),t){if(!a||s.mipmapFilter!=="linear"){const h=Zg[s.minFilter][s.mipmapFilter];e[i](l,e.TEXTURE_MIN_FILTER,h)}}else e[i](l,e.TEXTURE_MIN_FILTER,oa[s.minFilter]);if(r&&s.maxAnisotropy>1){const h=Math.min(s.maxAnisotropy,e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[i](l,r.TEXTURE_MAX_ANISOTROPY_EXT,h)}s.compare&&e[i](l,e.TEXTURE_COMPARE_FUNC,Qg[s.compare])}function Jg(s){return{r8unorm:s.RED,r8snorm:s.RED,r8uint:s.RED,r8sint:s.RED,r16uint:s.RED,r16sint:s.RED,r16float:s.RED,rg8unorm:s.RG,rg8snorm:s.RG,rg8uint:s.RG,rg8sint:s.RG,r32uint:s.RED,r32sint:s.RED,r32float:s.RED,rg16uint:s.RG,rg16sint:s.RG,rg16float:s.RG,rgba8unorm:s.RGBA,"rgba8unorm-srgb":s.RGBA,rgba8snorm:s.RGBA,rgba8uint:s.RGBA,rgba8sint:s.RGBA,bgra8unorm:s.RGBA,"bgra8unorm-srgb":s.RGBA,rgb9e5ufloat:s.RGB,rgb10a2unorm:s.RGBA,rg11b10ufloat:s.RGB,rg32uint:s.RG,rg32sint:s.RG,rg32float:s.RG,rgba16uint:s.RGBA,rgba16sint:s.RGBA,rgba16float:s.RGBA,rgba32uint:s.RGBA,rgba32sint:s.RGBA,rgba32float:s.RGBA,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT,depth24plus:s.DEPTH_COMPONENT,"depth24plus-stencil8":s.DEPTH_STENCIL,depth32float:s.DEPTH_COMPONENT,"depth32float-stencil8":s.DEPTH_STENCIL}}function e_(s,e){let t={},r=s.RGBA;return s instanceof Y.get().getWebGLRenderingContext()?e.srgb&&(t={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(t={"rgba8unorm-srgb":s.SRGB8_ALPHA8,"bgra8unorm-srgb":s.SRGB8_ALPHA8},r=s.RGBA8),{r8unorm:s.R8,r8snorm:s.R8_SNORM,r8uint:s.R8UI,r8sint:s.R8I,r16uint:s.R16UI,r16sint:s.R16I,r16float:s.R16F,rg8unorm:s.RG8,rg8snorm:s.RG8_SNORM,rg8uint:s.RG8UI,rg8sint:s.RG8I,r32uint:s.R32UI,r32sint:s.R32I,r32float:s.R32F,rg16uint:s.RG16UI,rg16sint:s.RG16I,rg16float:s.RG16F,rgba8unorm:s.RGBA,...t,rgba8snorm:s.RGBA8_SNORM,rgba8uint:s.RGBA8UI,rgba8sint:s.RGBA8I,bgra8unorm:r,rgb9e5ufloat:s.RGB9_E5,rgb10a2unorm:s.RGB10_A2,rg11b10ufloat:s.R11F_G11F_B10F,rg32uint:s.RG32UI,rg32sint:s.RG32I,rg32float:s.RG32F,rgba16uint:s.RGBA16UI,rgba16sint:s.RGBA16I,rgba16float:s.RGBA16F,rgba32uint:s.RGBA32UI,rgba32sint:s.RGBA32I,rgba32float:s.RGBA32F,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT16,depth24plus:s.DEPTH_COMPONENT24,"depth24plus-stencil8":s.DEPTH24_STENCIL8,depth32float:s.DEPTH_COMPONENT32F,"depth32float-stencil8":s.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 t_(s){return{r8unorm:s.UNSIGNED_BYTE,r8snorm:s.BYTE,r8uint:s.UNSIGNED_BYTE,r8sint:s.BYTE,r16uint:s.UNSIGNED_SHORT,r16sint:s.SHORT,r16float:s.HALF_FLOAT,rg8unorm:s.UNSIGNED_BYTE,rg8snorm:s.BYTE,rg8uint:s.UNSIGNED_BYTE,rg8sint:s.BYTE,r32uint:s.UNSIGNED_INT,r32sint:s.INT,r32float:s.FLOAT,rg16uint:s.UNSIGNED_SHORT,rg16sint:s.SHORT,rg16float:s.HALF_FLOAT,rgba8unorm:s.UNSIGNED_BYTE,"rgba8unorm-srgb":s.UNSIGNED_BYTE,rgba8snorm:s.BYTE,rgba8uint:s.UNSIGNED_BYTE,rgba8sint:s.BYTE,bgra8unorm:s.UNSIGNED_BYTE,"bgra8unorm-srgb":s.UNSIGNED_BYTE,rgb9e5ufloat:s.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:s.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:s.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:s.UNSIGNED_INT,rg32sint:s.INT,rg32float:s.FLOAT,rgba16uint:s.UNSIGNED_SHORT,rgba16sint:s.SHORT,rgba16float:s.HALF_FLOAT,rgba32uint:s.UNSIGNED_INT,rgba32sint:s.INT,rgba32float:s.FLOAT,stencil8:s.UNSIGNED_BYTE,depth16unorm:s.UNSIGNED_SHORT,depth24plus:s.UNSIGNED_INT,"depth24plus-stencil8":s.UNSIGNED_INT_24_8,depth32float:s.FLOAT,"depth32float-stencil8":s.FLOAT_32_UNSIGNED_INT_24_8_REV}}function r_(s){return{"2d":s.TEXTURE_2D,cube:s.TEXTURE_CUBE_MAP,"1d":null,"3d":(s==null?void 0:s.TEXTURE_3D)||null,"2d-array":(s==null?void 0:s.TEXTURE_2D_ARRAY)||null,"cube-array":(s==null?void 0:s.TEXTURE_CUBE_MAP_ARRAY)||null}}const s_=4;class rc{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:tc,buffer:zg,video:Kg,compressed:Xg};this._uploads={...t,cube:$g(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=e_(e,this._renderer.context.extensions),this._mapFormatToType=t_(e),this._mapFormatToFormat=Jg(e),this._mapViewDimensionToGlTarget=r_(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(N.EMPTY,t)}initSource(e){this.bind(e)}bind(e,t=0){const r=e.source;e?(this.bindSource(r,t),this._useSeparateSamplers&&this._bindSampler(r.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){const r=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||(e=N.EMPTY.source);const i=this.getGlSource(e);r.bindTexture(i.target,i.texture)}}_bindSampler(e,t=0){const r=this._gl;if(!e){this._boundSamplers[t]=null,r.bindSampler(t,null);return}const i=this._getGlSampler(e);this._boundSamplers[t]!==i&&(this._boundSamplers[t]=i,r.bindSampler(t,i))}unbind(e){const t=e.source,r=this._boundTextures,i=this._gl;for(let n=0;n<r.length;n++)if(r[n]===t){this._activateLocation(n);const o=this.getGlSource(t);i.bindTexture(o.target,null),r[n]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){const t=this._gl,r=new Wg(t.createTexture());if(r.type=this._mapFormatToType[e.format],r.internalFormat=this._mapFormatToInternalFormat[e.format],r.format=this._mapFormatToFormat[e.format],r.target=this._mapViewDimensionToGlTarget[e.viewDimension],r.target===null)throw new Error(`Unsupported view dimension: ${e.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(e.uploadMethodId==="cube"&&(r.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]=r,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),r}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){const r=this._gl,i=this.getGlSource(e);r.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=e,aa(e.style,r,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){const r=e._gpuData[this._renderer.uid];r&&(t||(this.unbind(e),this._gl.deleteTexture(r.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,r=this.getGlSource(e);t.bindTexture(r.target,r.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,r,t,this._renderer.context.webGLVersion);else if(r.target===t.TEXTURE_2D)this._initEmptyTexture2D(r,e);else if(r.target===t.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(r,e);else if(r.target===t.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(r,e);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(r,e),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);const r=this.getGlSource(e);this._gl.generateMipmap(r.target)}_initEmptyTexture2D(e,t){const r=this._gl;r.texImage2D(r.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++)r.texImage2D(r.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 r=this._gl,i=Math.max(t.arrayLayerCount|0,1);r.texImage3D(r.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++)r.texImage3D(r.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 r=this._gl,i=6;for(let a=0;a<i;a++)r.texImage2D(r.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++)r.texImage2D(r.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 r=this._gl,i=Math.max((t.mipLevelCount|0)-1,0);r.texParameteri(e.target,r.TEXTURE_BASE_LEVEL,0),r.texParameteri(e.target,r.TEXTURE_MAX_LEVEL,i)}_initSampler(e){const t=this._gl,r=this._gl.createSampler();return this._glSamplers[e._resourceId]=r,aa(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",r,!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:r,height:i}=this.getPixels(e),n=Y.get().createCanvas();n.width=r,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(r,i);a.data.set(t),o.putImageData(a,0,0)}return n}getPixels(e){const t=e.source.resolution,r=e.frame,i=Math.max(Math.round(r.width*t),1),n=Math.max(Math.round(r.height*t),1),o=new Uint8Array(s_*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(r.x*t),Math.round(r.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(N.EMPTY.source),this._boundSamplers=Object.create(null);const e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}rc.extension={type:[b.WebGLSystem],name:"texture"};class sc{contextChange(e){const t=new De({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),r=e.limits.maxBatchableTextures,i=Ai({name:"graphics",bits:[gl,xl(r),Yl,Bi]});this.shader=new Qe({glProgram:i,resources:{localUniforms:t,batchSamplers:yl(r)}})}execute(e,t){const r=t.context,i=r.customShader||this.shader,n=e.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r);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}}sc.extension={type:[b.WebGLPipesAdaptor],name:"graphics"};class ic{init(){const e=Ai({name:"mesh",bits:[Yl,vm,Bi]});this._shader=new Qe({glProgram:e,resources:{uTexture:N.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new G}}}})}execute(e,t){const r=e.renderer;let i=t._shader;if(i){if(!i.glProgram){z("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]=r.globalUniforms.bindGroup,i.groups[101]=e.localUniformsBindGroup,r.encoder.draw({geometry:t._geometry,shader:i,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}ic.extension={type:[b.WebGLPipesAdaptor],name:"mesh"};const i_=[...on,jh,mg,hg,Wh,Fh,rc,qh,Oh,Jh,Qh,Hh,Hg,zh,Nh],n_=[...Ah],o_=[ih,ic,sc],nc=[],oc=[],ac=[];W.handleByNamedList(b.WebGLSystem,nc);W.handleByNamedList(b.WebGLPipes,oc);W.handleByNamedList(b.WebGLPipesAdaptor,ac);W.add(...i_,...n_,...o_);class a_ extends vr{constructor(){const e={name:"webgl",type:Pe.WEBGL,systems:nc,renderPipes:oc,renderPipeAdaptors:ac};super(e)}}const l_=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:a_},Symbol.toStringTag,{value:"Module"}));class lc{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const i=this._gpu.device,n=t.layout[r],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[r],h=i.createBindGroup({layout:l,entries:o});return this._hash[e._key]=h,h}destroy(){this._hash=null,this._renderer=null}}lc.extension={type:[b.WebGPUSystem],name:"bindGroup"};class h_{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class hc{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),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.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=te("resource"),e.data&&(ri(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new h_(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}}hc.extension={type:[b.WebGPUSystem],name:"buffer"};class c_{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 r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class cc{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}}cc.extension={type:[b.WebGPUSystem],name:"colorMask"};class dn{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 Y.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>t.features.has(n)),i=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:i}}destroy(){this.gpu=null,this._renderer=null}}dn.extension={type:[b.WebGPUSystem],name:"device"};dn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class uc{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,r,i){const n=this._renderer.pipeline.getPipeline(e,t,r,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,r){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,r,e);this.renderPassEncoder.setBindGroup(e,i)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const i in r)this._setVertexBuffer(parseInt(i,10),e.attributes[r[i]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const i=e.groups[r];t||this._syncBindGroup(i),this.setBindGroup(r,i,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:i,topology:n,size:o,start:a,instanceCount:l,skipSync:h}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,i,n),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,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,r={...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 r)this._setVertexBuffer(a,r[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}}uc.extension={type:[b.WebGPUSystem],name:"encoder",priority:1};class dc{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}dc.extension={type:[b.WebGPUSystem],name:"limits"};class fc{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:de.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.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}}fc.extension={type:[b.WebGPUSystem],name:"stencil"};const Yr={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 u_(s){const e=s.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const i=e[r];let n=Yr[i.data.type].size;const o=Yr[i.data.type].align;if(!Yr[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 d_(s,e){const{size:t,align:r}=Yr[s.data.type],i=(r-t)/4,n=s.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
1121
|
+
v = uv.${s.data.name};
|
|
1122
|
+
${e!==0?`offset += ${e};`:""}
|
|
1123
|
+
|
|
1124
|
+
arrayOffset = offset;
|
|
1125
|
+
|
|
1126
|
+
t = 0;
|
|
1127
|
+
|
|
1128
|
+
for(var i=0; i < ${s.data.size*(t/4)}; i++)
|
|
1129
|
+
{
|
|
1130
|
+
for(var j = 0; j < ${t/4}; j++)
|
|
1131
|
+
{
|
|
1132
|
+
${n}[arrayOffset++] = v[t++];
|
|
1133
|
+
}
|
|
1134
|
+
${i!==0?`arrayOffset += ${i};`:""}
|
|
1135
|
+
}
|
|
1136
|
+
`}function f_(s){return $h(s,"uboWgsl",d_,xg)}class pc extends Vh{constructor(){super({createUboElements:u_,generateUboSync:f_})}}pc.extension={type:[b.WebGPUSystem],name:"ubo"};const tt=128;class mc{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new c_({minUniformOffsetAlignment:tt});const t=256/tt;for(let r=0;r<t;r++){let i=ne.UNIFORM|ne.COPY_DST;r===0&&(i|=ne.COPY_SRC),this._buffers.push(new nt({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 r=e.buffer.data,i=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,i/4),this._bindGroupHash[e.uid]=this._getBindGroup(i/tt),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);const t=e.buffer.data,r=this._batchBuffer.addGroup(t);return this._getBufferResource(r/tt)}getArrayBindGroup(e){const t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/tt)}getArrayBufferResource(e){const r=this._batchBuffer.addGroup(e)/tt;return this._getBufferResource(r)}_getBufferResource(e){if(!this._bufferResources[e]){const t=this._buffers[e%2];this._bufferResources[e]=new un({buffer:t,offset:(e/2|0)*256,size:tt})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){const t=new it({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 r=this._renderer.gpu.device.createCommandEncoder();for(let i=1;i<this._buffers.length;i++){const n=this._buffers[i];r.copyBufferToBuffer(e.getGPUBuffer(t),tt,e.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([r.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}}mc.extension={type:[b.WebGPUPipes],name:"uniformBatch"};const p_={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function m_(s,e,t,r,i){return s<<24|e<<16|t<<10|r<<5|i}function g_(s,e,t,r,i){return t<<8|s<<5|r<<3|i<<1|e}class gc{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(de.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=at[e],this._updatePipeHash())}setPipeline(e,t,r,i){const n=this.getPipeline(e,t,r);i.setPipeline(n)}getPipeline(e,t,r,i){e._layoutKey||(Dh(e,t.attributeData),this._generateBufferKey(e)),i||(i=e.topology);const n=m_(e._layoutKey,t._layoutKey,r.data,r._blendModeId,p_[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(e,t,r,i),this._pipeCache[n])}_createPipeline(e,t,r,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(e,t),a=this._renderer.state.getColorTargets(r,this._colorTargetCount),l=this._stencilMode===de.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:r.cullMode},layout:h,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:r.depthTest,depthCompare:r.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 r=0;const i=Object.keys(e.attributes).sort();for(let o=0;o<i.length;o++){const a=e.attributes[i[o]];t[r++]=a.offset,t[r++]=a.format,t[r++]=a.stride,t[r++]=a.instance}const n=t.join("|");return e._layoutKey=fr(n,"geometry"),e._layoutKey}_generateAttributeLocationsKey(e){const t=[];let r=0;const i=Object.keys(e.attributeData).sort();for(let o=0;o<i.length;o++){const a=e.attributeData[i[o]];t[r++]=a.location}const n=t.join("|");return e._attributeLocationsKey=fr(n,"programAttributes"),e._attributeLocationsKey}getBufferNamesToBind(e,t){const r=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[r])return this._bindingNamesCache[r];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[r]=n,n}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);const r=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[r])return this._bufferLayoutsCache[r];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&&z(`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[r]=i,i}_updatePipeHash(){const e=g_(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}}gc.extension={type:[b.WebGPUSystem],name:"pipeline"};class __{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class x_{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,r,i,n){const o=this._renderer,a=this._getGpuColorTexture(e),l=o.texture.getGpuSource(t.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:r},{texture:l,origin:n},i),t}startRenderPass(e,t=!0,r,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,r,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,r,i=0,n=0){typeof t=="boolean"&&(t=t?we.ALL:we.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&we.COLOR?"clear":"load";return r??(r=o.defaultClearColor),{view:p,resolveTarget:g,clearValue:r,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&we.STENCIL?"clear":"load",d=t&we.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,r,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,r,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,r,i,n,o)}initGpuRenderTarget(e){e.isRoot=!0;const t=new __;return t.colorTargetCount=e.colorTextures.length,e.colorTextures.forEach((r,i)=>{if(r instanceof He){const n=r.resource.getContext("webgpu"),o=r.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=r.source.antialias,r.source.antialias){const n=new pe({width:0,height:0,sampleCount:4,arrayLayerCount:r.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((r,i)=>{const n=t.msaaTextures[i];n==null||n.resize(r.source.width,r.source.height,r.source._resolution)})}}class _c extends an{constructor(e){super(e),this.adaptor=new x_,this.adaptor.init(e,this)}}_c.extension={type:[b.WebGPUSystem],name:"renderTarget"};class xc{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,r=e.gpuLayout.map(n=>t.createBindGroupLayout({entries:n})),i={bindGroupLayouts:r};return this._gpuProgramData[e._layoutKey]={bindGroups:r,pipeline:t.createPipelineLayout(i)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}xc.extension={type:[b.WebGPUSystem],name:"shader"};const Te={};Te.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};Te.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}};Te.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}};Te.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};Te.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};Te.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}};Te["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}};Te["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}};Te["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}};Te.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};Te.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}};Te.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class yc{constructor(){this.defaultState=new Je,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t){const r=Te[e.blendMode]||Te.normal,i=[],n={format:"bgra8unorm",writeMask:0,blend:r};for(let o=0;o<t;o++)i[o]=n;return i}destroy(){this.gpu=null}}yc.extension={type:[b.WebGPUSystem],name:"state"};const y_={type:"image",upload(s,e,t,r=0){const i=s.resource,n=(s.pixelWidth|0)*(s.pixelHeight|0),o=i.byteLength/n;t.device.queue.writeTexture({texture:e,origin:{x:0,y:0,z:r}},i,{offset:0,rowsPerImage:s.pixelHeight,bytesPerRow:s.pixelWidth*o},{width:s.pixelWidth,height:s.pixelHeight,depthOrArrayLayers:1})}},bc={"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}},b_={blockBytes:4,blockWidth:1,blockHeight:1},v_={type:"compressed",upload(s,e,t,r=0){let i=s.pixelWidth,n=s.pixelHeight;const o=bc[s.format]||b_;for(let a=0;a<s.resource.length;a++){const l=s.resource[a],h=Math.ceil(i/o.blockWidth)*o.blockBytes;t.device.queue.writeTexture({texture:e,mipLevel:a,origin:{x:0,y:0,z:r}},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)}}},la=["right","left","top","bottom","front","back"];function T_(s){return{type:"cube",upload(e,t,r){const i=e.faces;for(let n=0;n<la.length;n++){const o=la[n],a=i[o];(s[a.uploadMethodId]||s.image).upload(a,t,r,n)}}}}const vc={type:"image",upload(s,e,t,r=0){const i=s.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const l=Y.get().createCanvas(i.width,i.height);l.getContext("2d").drawImage(i,0,0,i.width,i.height),s.resource=l,z("ImageSource: Image element passed, converting to canvas and replacing resource.")}const n=Math.min(e.width,s.resourceWidth||s.pixelWidth),o=Math.min(e.height,s.resourceHeight||s.pixelHeight),a=s.alphaMode==="premultiply-alpha-on-upload";t.device.queue.copyExternalImageToTexture({source:i},{texture:e,origin:{x:0,y:0,z:r},premultipliedAlpha:a},{width:n,height:o})}},S_={type:"video",upload(s,e,t,r){vc.upload(s,e,t,r)}};class C_{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:`
|
|
1137
|
+
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
1138
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
|
1139
|
+
|
|
1140
|
+
struct VertexOutput {
|
|
1141
|
+
@builtin(position) position : vec4<f32>,
|
|
1142
|
+
@location(0) texCoord : vec2<f32>,
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
@vertex
|
|
1146
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
|
1147
|
+
var output : VertexOutput;
|
|
1148
|
+
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
|
1149
|
+
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
|
1150
|
+
return output;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
@group(0) @binding(0) var imgSampler : sampler;
|
|
1154
|
+
@group(0) @binding(1) var img : texture_2d<f32>;
|
|
1155
|
+
|
|
1156
|
+
@fragment
|
|
1157
|
+
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
1158
|
+
return textureSample(img, imgSampler, texCoord);
|
|
1159
|
+
}
|
|
1160
|
+
`})),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 r=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};r=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=r.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:r,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||r.destroy(),e}}class w_{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class Tc{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:vc,buffer:y_,video:S_,compressed:v_};this._uploads={...t,cube:T_(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 r=bc[e.format]||{blockWidth:1,blockHeight:1},i=Math.ceil(e.pixelWidth/r.blockWidth)*r.blockWidth,n=Math.ceil(e.pixelHeight/r.blockHeight)*r.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 w_(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 C_(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],r=t==null?void 0:t.gpuTexture;r?(r.width!==e.pixelWidth||r.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 it({0:t,1:t.style,2:new De({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 r=t._gpuData[this._renderer.uid];return r||(this.initSource(t),r=t._gpuData[this._renderer.uid]),r.textureView||(r.textureView=r.gpuTexture.createView({dimension:t.viewDimension})),r.textureView}generateCanvas(e){const t=this._renderer,r=t.gpu.device.createCommandEncoder(),i=Y.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:Y.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),r.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([r.finish()]),i}getPixels(e){const t=this.generateCanvas(e),r=Xt.getOptimalCanvasAndContext(t.width,t.height),i=r.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 Xt.returnCanvasAndContext(r),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(const e of Object.keys(this._bindGroupHash)){const t=Number(e),r=this._bindGroupHash[t];r==null||r.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}Tc.extension={type:[b.WebGPUSystem],name:"texture"};class Sc{constructor(){this._maxTextures=0}contextChange(e){const t=new De({uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=e.limits.maxBatchableTextures;const r=Mi({name:"graphics",bits:[ml,_l(this._maxTextures),Wp,Ri]});this.shader=new Qe({gpuProgram:r,resources:{localUniforms:t}})}execute(e,t){const r=t.context,i=r.customShader||this.shader,n=e.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r),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=Pi(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}}Sc.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"};class Cc{init(){const e=Mi({name:"mesh",bits:[zr,bm,Ri]});this._shader=new Qe({gpuProgram:e,resources:{uTexture:N.EMPTY._source,uSampler:N.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new G}}}})}execute(e,t){const r=e.renderer;let i=t._shader;if(!i)i=this._shader,i.groups[2]=r.texture.getTextureBindGroup(t.texture);else if(!i.gpuProgram){z("Mesh shader has no gpuProgram",t.shader);return}const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=r.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=e.localUniforms;i.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}r.encoder.draw({geometry:t._geometry,shader:i,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Cc.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"};const P_=[...on,pc,uc,dn,dc,hc,Tc,_c,xc,yc,gc,cc,fc,lc],E_=[...Ah,mc],M_=[nh,Cc,Sc],wc=[],Pc=[],Ec=[];W.handleByNamedList(b.WebGPUSystem,wc);W.handleByNamedList(b.WebGPUPipes,Pc);W.handleByNamedList(b.WebGPUPipesAdaptor,Ec);W.add(...P_,...E_,...M_);class A_ extends vr{constructor(){const e={name:"webgpu",type:Pe.WEBGPU,systems:wc,renderPipes:Pc,renderPipeAdaptors:Ec};super(e)}}const R_=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:A_},Symbol.toStringTag,{value:"Module"}));W.add(kc,Ic);W.add(zu);W.mixin(ve,Vu);W.add(Rl);W.add(Bl);W.mixin(ve,xp);W.add(zl,Fl);W.add(Wl);const B_=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),k_=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Rd as A,Ap as B,rt as C,rs as G,I_ as N,re as P,ee as R,Ht as S,G_ as T,nr as _,ve as a,is as b,N as c};
|