phaser4-rex-plugins
Version:
1 lines • 63.2 kB
JavaScript
var t,e;t=void 0,e=function(){const t=Phaser.GameObjects.GameObject;let e=class extends t{};const i=Phaser.GameObjects.Components;Phaser.Class.mixin(e,[i.AlphaSingle,i.BlendMode,i.Depth,i.Flip,i.Mask,i.Origin,i.RenderNodes,i.Size,i.Texture,i.Transform,i.Visible,i.ScrollFactor]);const s=Phaser.GameObjects.GetCalcMatrix;var r={multiTexturing:!1,smoothPixelArt:!1},a=function(){return 0===this.faces.length},n={renderWebGL:function(t,e,i,a){var n=i.camera;if(n.addToRenderList(e),!e.skipRender()){var h,o=s(e,n,a,!i.useCanvas).calc;e.dirty&&e.updateBuffers();var l=e.texture;h=l&&null!==l.smoothPixelArt?l.smoothPixelArt:e.scene.sys.game.config.smoothPixelArt,r.smoothPixelArt=h,(e.customRenderNodes.BatchHandler||e.defaultRenderNodes.BatchHandler).batchTriangles(i,e,o,e.texture.source[0].glTexture,e.vertexBuffer,e.uvBuffer,e.colorBuffer,e.alphaBuffer,e.alpha,e.tintFill,r,e.debugCallback)}},renderCanvas:function(t,e,i,s){},skipRender:a};const h=Phaser.Math.RotateAround;var o={};const l=Phaser.Math.Linear,c=Phaser.Math.RotateAround;class u{constructor(){this.parent=void 0,this.name="",this.u=0,this.v=0,this.frameU=0,this.frameV=0,this.frameX=0,this.frameY=0,this._dx=0,this._dy=0,this.localX=0,this.localY=0,this.alpha=1,this.color=16777215}setParent(t){return this.parent=t,this}setName(t){return this.name=t,this}get frameU(){return this._frameU}set frameU(t){this._frameU!==t&&(this._frameU=t,this.parent&&this.parent.setUVDirtyFlag())}get frameV(){return this._frameV}set frameV(t){this._frameV!==t&&(this._frameV=t,this.parent&&this.parent.setUVDirtyFlag())}get frameX(){return this._frameX}set frameX(t){this._frameX!==t&&(this._frameX=t,this._localX=t+this._dx,this.parent&&this.parent.setVertexDirtyFlag())}get frameY(){return this._frameY}set frameY(t){this._frameY!==t&&(this._frameY=t,this._localY=t+this._dy,this.parent&&this.parent.setVertexDirtyFlag())}get localX(){return this._localX}set localX(t){this._localX!==t&&(this._localX=t,this._dx=t-this._frameX,this.parent&&this.parent.setVertexDirtyFlag())}get localY(){return this._localY}set localY(t){this._localY!==t&&(this._localY=t,this._dy=t-this._frameY,this.parent&&this.parent.setVertexDirtyFlag())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.parent&&this.parent.setAlphaDirtyFlag())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.parent&&this.parent.setColorDirtyFlag())}setUV(t,e){return this.u=t,this.v=e,this}setFrameUV(t,e,i,s){return this.frameU=l(t,i,this.u),this.frameV=l(e,s,this.v),this}setFrameSize(t,e){return this.frameX=this.u*t,this.frameY=this.v*e,this}resetPosition(){return this.localX=this.frameX,this.localY=this.frameY,this}setLocalPosition(t,e){return this.localX=t,this.localY=e,this}rotateAround(t,e,i){return d.x=this.localX,d.y=this.localY,c(d,t,e,i),this.localX=d.x,this.localY=d.y,this}setAlpha(t){return this.alpha=t,this}setColor(t){return this.color=t,this}getWorldXY(t){return this.parent?function(t,e,i,s){void 0===s?s={}:!0===s&&(s=o);var r=t.displayOriginX,a=t.displayOriginY;return s.x=e-r,s.y=i-a,h(s,0,0,t.rotation),s.x*=t.scaleX,s.y*=t.scaleY,s.x+=t.x,s.y+=t.y,s}(this.parent,this.localX,this.localY,t):null}setWorldXY(t,e){var i=function(t,e,i,s){void 0===s?s={}:!0===s&&(s=o);var r=t.displayOriginX,a=t.displayOriginY;return s.x=e-t.x,s.y=i-t.y,s.x/=t.scaleX,s.y/=t.scaleY,h(s,0,0,-t.rotation),s.x+=r,s.y+=a,s}(this.parent,t,e,!0);return this.setLocalPosition(i.x,i.y),this}setPosition(t,e){return this.setWorldXY(t,e),this}get x(){return this.parent?this.getWorldXY(!0).x:null}set x(t){this.setWorldXY(t,this.y)}get y(){return this.parent?this.getWorldXY(!0).y:null}set y(t){this.setWorldXY(this.x,t)}}var d={};const p=Phaser.Geom.Triangle.InCenter;var v={},f={},g=new Phaser.Geom.Triangle;const y=Phaser.Math.RadToDeg,m=Phaser.Math.DegToRad;class C{constructor(t,e,i){void 0===t&&(t=new u),void 0===e&&(e=new u),void 0===i&&(i=new u),this.parent=void 0,this.name="",this.vertices=[t,e,i],this._localOffsetX=0,this._localOffsetY=0,this._rotation=0,this._alpha=1,this._color=16777215}setParent(t){return this.parent=t,this.vertices[0].setParent(t),this.vertices[1].setParent(t),this.vertices[2].setParent(t),this}setName(t){return this.name=t,this}get vertex0(){return this.vertices[0]}set vertex0(t){this.vertices[0]=t}get vertex1(){return this.vertices[1]}set vertex1(t){this.vertices[1]=t}get vertex2(){return this.vertices[2]}set vertex2(t){this.vertices[2]=t}get localOffsetX(){return this._localOffsetX}set localOffsetX(t){t!==this._localOffsetX&&(this._localOffsetX=t,this.updateVerticesPosition())}get localOffsetY(){return this._localOffsetY}set localOffsetY(t){t!==this._localOffsetY&&(this._localOffsetY=t,this.updateVerticesPosition())}get rotation(){return this._rotation}set rotation(t){if(t!==this._rotation){this._rotation=t;var e,i,s=(e=this,void 0===(i=!0)?i={}:!0===i&&(i=f),v.x1=e.vertices[0].localX,v.y1=e.vertices[0].localY,v.x2=e.vertices[1].localX,v.y2=e.vertices[1].localY,v.x3=e.vertices[2].localX,v.y3=e.vertices[2].localY,p(v,i)),r=s.x,a=s.y;this.vertices[0].rotateAround(r,a,t),this.vertices[1].rotateAround(r,a,t),this.vertices[2].rotateAround(r,a,t)}}get angle(){return y(this._rotation)}set angle(t){this.rotation=m(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.vertices[0].setAlpha(t),this.vertices[1].setAlpha(t),this.vertices[2].setAlpha(t))}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.vertices[0].setColor(t),this.vertices[1].setColor(t),this.vertices[2].setColor(t))}get isPositionModified(){return 0!==this._localOffsetX||0!==this._localOffsetY||0!==this._rotation}setUV(t,e,i,s,r,a){return this.vertices[0].setUV(t,e),this.vertices[1].setUV(i,s),this.vertices[2].setUV(r,a),this}setFrameUV(t,e,i,s){return this.vertices[0].setFrameUV(t,e,i,s),this.vertices[1].setFrameUV(t,e,i,s),this.vertices[2].setFrameUV(t,e,i,s),this}setFrameSize(t,e){for(var i=0,s=this.vertices.length;i<s;i++)this.vertices[i].setFrameSize(t,e);return this.isPositionModified&&this.updateVerticesPosition(),this}setLocalOffset(t,e){return this.localOffsetX=t,this.localOffsetY=e,this}resetVerticesPosition(){for(var t=0,e=this.vertices.length;t<e;t++)this.vertices[t].resetPosition();return this.isPositionModified&&this.updateVerticesPosition(),this}updateVerticesPosition(){for(var t=this._localOffsetX,e=this._localOffsetY,i=this.vertices,s=0,r=i.length;s<r;s++){var a=i[s];a.setLocalPosition(a.frameX+t,a.frameY+e)}var n=this.rotation;return this._rotation=0,this.rotation=n,this}setRotation(t){return this.rotation=t,this}setAngle(t){return this.angle=t,this}setAlpha(t){return this.alpha=t,this}setColor(t){return this.color=t,this}contains(t,e){return i=t,s=e,r=this.vertices,a=r[0],n=r[1],h=r[2],g.setTo(a.localX,a.localY,n.localX,n.localY,h.localX,h.localY),g.contains(i,s);var i,s,r,a,n,h}}const x=Phaser.Utils.Array.GetFirst;var P={clear(){return this.faces.length=0,this.vertices.length=0,this.setFaceCountDirtyFlag(),this},createVertex(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var i=new u;return i.setUV(t,e),i},createFace:(t,e,i)=>new C(t,e,i),addFace(t){if(this.faces.includes(t))return this;t.setParent(this),this.faces.push(t),this.setFaceCountDirtyFlag();var e=this.frame;t.setFrameSize(e.cutWidth,e.cutHeight).setFrameUV(e.u0,e.v0,e.u1,e.v1).resetVerticesPosition();var i=this.vertices;return t.vertices.forEach((function(t){i.includes(t)||i.push(t)})),this},addFaces(t){for(var e=0,i=t.length;e<i;e++)this.addFace(t[e]);return this},resetFaceSize(){for(var t=this.frame,e=t.realWidth,i=t.realHeight,s=this.faces,r=0,a=s.length;r<a;r++)s[r].setFrameSize(e,i);return this},addGridFaces(t,e,i){return function(t,e,i,s){if(function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}(e)){var r=e;e=r.columns,i=r.rows,s=r.sharedVertexMode}void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=!1);var a,n,h,o,l,c=[];if(s){a=[];for(var u=0;u<=i;u++)for(var d=0;d<=e;d++){var p=t.createVertex(d/e,u/i);a.push(p)}}for(u=0;u<i;u++)for(d=0;d<e;d++)if(s){var v=u*(e+1)+d,f=v+1,g=(u+1)*(e+1)+d,y=g+1,m=a[v],C=a[f],x=a[g],P=a[y];l=t.createFace(m,P,x),t.addFace(l),c.push(l),l=t.createFace(m,C,P),t.addFace(l),c.push(l)}else{var F=d/e,b=(d+1)/e,_=u/i,A=(u+1)/i;n=t.createVertex(F,_),h=t.createVertex(F,A),o=t.createVertex(b,A),l=t.createFace(n,h,o),t.addFace(l),c.push(l),n=t.createVertex(F,_),h=t.createVertex(b,A),o=t.createVertex(b,_),l=t.createFace(n,h,o),t.addFace(l),c.push(l)}s&&t.vertices.sort((function(t,e){return t.v===e.v?t.u-e.u:t.v-e.v}))}(this,t,e,i),this},getVertexByName(t){return x(this.vertices,"name",t)},getFaceByName(t){return x(this.faces,"name",t)},resetVerticesPosition(){for(var t=this.vertices,e=0,i=t.length;e<i;e++)t[e].resetPosition();return this}},F={clearDirtyFlag(){return this.dirtyFlags=0,this},setFaceCountDirtyFlag(){return this.dirtyFlags|=31,this},setUVDirtyFlag(){return this.dirtyFlags|=2,this},setVertexDirtyFlag(){return this.dirtyFlags|=4,this},setAlphaDirtyFlag(){return this.dirtyFlags|=8,this},setColorDirtyFlag(){return this.dirtyFlags|=16,this}},b={updateBuffers(){return this.dirty?(1&this.dirtyFlags&&this.resizeBuffers(),2&this.dirtyFlags&&this.updateUVBuffer(),4&this.dirtyFlags&&this.updateVertexBuffer(),8&this.dirtyFlags&&this.updateAlphaBuffer(),16&this.dirtyFlags&&this.updateColorBuffer(),this.clearDirtyFlag(),this):this},resizeBuffers(){var t=this.faces.length;return this.vertexBuffer=new Float32Array(6*t),this.uvBuffer=new Float32Array(6*t),this.colorBuffer=new Uint32Array(3*t),this.alphaBuffer=new Float32Array(3*t),this},updateUVBuffer(){for(var t,e,i=this.uvBuffer,s=this.faces,r=0,a=s.length;r<a;r++)e=s[r].vertices,i[t=6*r]=e[0].frameU,i[t+1]=e[0].frameV,i[t+2]=e[1].frameU,i[t+3]=e[1].frameV,i[t+4]=e[2].frameU,i[t+5]=e[2].frameV;return this},updateVertexBuffer(){for(var t,e,i=this.vertexBuffer,s=this.faces,r=0,a=s.length;r<a;r++)e=s[r].vertices,i[t=6*r]=e[0].localX,i[t+1]=e[0].localY,i[t+2]=e[1].localX,i[t+3]=e[1].localY,i[t+4]=e[2].localX,i[t+5]=e[2].localY;return this},updateAlphaBuffer(){for(var t,e,i=this.alphaBuffer,s=this.faces,r=0,a=s.length;r<a;r++)e=s[r].vertices,i[t=3*r]=e[0].alpha,i[t+1]=e[1].alpha,i[t+2]=e[2].alpha;return this},updateColorBuffer(){for(var t,e,i=this.colorBuffer,s=this.faces,r=0,a=s.length;r<a;r++)e=s[r].vertices,i[t=3*r]=e[0].color,i[t+1]=e[1].color,i[t+2]=e[2].color;return this}},_={setTintFill(t){return void 0===t&&(t=!1),this.tintFill=t,this},setTint(t){return this.tint=t,this},clearTint(){return this.setTint(16777215),this}},A={setDebug(t,e){return this.debugGraphic=t,this.debugCallback=t||e?e||this.renderDebugVerts:null,this},renderDebugVerts(t,e,i){for(var s=t.debugGraphic,r=0;r<e;r+=6){var a=i[r+0],n=i[r+1],h=i[r+2],o=i[r+3],l=i[r+4],c=i[r+5];s.lineBetween(a,n,h,o),s.lineBetween(h,o,l,c),s.lineBetween(l,c,a,n)}}};const R=Phaser.GameObjects.Components.TransformMatrix,T=Phaser.Math.TransformXY;var X,w,S={},Y={getFaceAt(t,e,i){for(var s=function(t,e,i,s,r){void 0===s&&(s=t.scene.cameras.main),void 0===r?r={}:!0===r&&(r=S);var a=s.scrollX,n=s.scrollY,h=e+a*t.scrollFactorX-a,o=i+n*t.scrollFactorY-n;return t.parentContainer?(void 0===X&&(X=new R,w=new R),t.getWorldTransformMatrix(X,w),X.applyInverse(h,o,r)):T(h,o,t.x,t.y,t.rotation,t.scaleX,t.scaleY,r),r.x+=t.displayOriginX,r.y+=t.displayOriginY,r}(this,t,e,i,!0),r=s.x,a=s.y,n=this.faces,h=0,o=n.length;h<o;h++){var l=n[h];if(l.contains(r,a))return l}return null},hasFaceAt(t,e,i){return!!this.getFaceAt(t,e,i)}},L=function(t,e,i,s){for(var r=s.faces,a=0,n=r.length;a<n;a++){var h=r[a];if(h.contains(e,i))return s.input.hitFace=h,!0}return s.input.hitFace=null,!1},O=function(t,e,i,s){var r=this.input.hitFace;this.emit("face.pointerdown",r,t,e,i,s)},k=function(t,e,i,s){var r=this.input.hitFace;this.emit("face.pointerup",r,t,e,i,s),this.input.hitFace=null},V=function(t,e,i,s){var r=this.input.hitFace,a=this.input.prevHitFace;r!==a?(a&&this.emit("face.pointerout",a,t,s),r&&this.emit("face.pointerover",r,t,s),this.input.prevHitFace=r):this.emit("face.pointermove",r,t,e,i,s)},D=function(t,e){var i=this.input.prevHitFace;i&&this.emit("face.pointerout",i,t,e),this.input.hitFace=null,this.input.prevHitFace=null},E={setFaceInteractive:function(t){if(!this.input)return void 0===t&&(t={}),t.hitArea={},t.hitAreaCallback=L,this.setInteractive(t).on("pointerdown",O,this).on("pointerup",k,this).on("pointermove",V,this).on("pointerover",V,this).on("pointerout",D,this),this}};Object.assign(E,P,F,b,_,A,Y);const B=Phaser.Renderer.WebGL.Shaders.MultiFrag,M=Phaser.Renderer.WebGL.Shaders.MultiVert,j=Phaser.Renderer.WebGL.ShaderAdditionMakers,G=j.MakeApplyTint,U=j.MakeDefineTexCount,Z=j.MakeGetTexCoordOut,N=j.MakeGetTexRes,W=j.MakeSmoothPixelArt,I=j.MakeGetTexture,z=Phaser.Renderer.WebGL.Utils,H=Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad,J=z.getTintAppendFloatAlpha;class $ extends H{constructor(t,e){super(t,e),this.renderOptions.multiTexturing=!0}_generateElementIndices(t){for(var e=new ArrayBuffer(5*t*2),i=new Uint16Array(e),s=0,r=0;r<t;r++){var a=3*r;i[s++]=a,i[s++]=a,i[s++]=a+1,i[s++]=a+2,i[s++]=a+2}return e}batchTriangles(t,e,i,s,r,a,n,h,o,l,c,u){0===this.instanceCount&&this.manager.setCurrentBatchNode(this,t);var d=r.length/(2*this.verticesPerInstance);if(d>this.instancesPerBatch)throw new Error("rexBatchHandlerTriangle: Vertex count exceeds maximum per batch ("+this.maxVerticesPerBatch+")");this.instanceCount+d>this.instancesPerBatch&&this.run(t),this.updateRenderOptions(c),this._renderOptionsChanged&&(this.run(t),this.updateShaderConfig());var p,v=this.batchTextures(s),f=this.instanceCount*this.floatsPerInstance,g=this.vertexBufferLayout.buffer,y=g.viewF32,m=g.viewU32;u&&(p=[]);for(var C=i.a,x=i.b,P=i.c,F=i.d,b=i.e,_=i.f,A=-e.displayOriginX,R=-e.displayOriginY,T=r.length,X=0;X<T;X+=6){for(var w=0;w<3;w++){var S=X+2*w,Y=r[S],L=r[S+1],O=(Y+=A)*C+(L+=R)*P+b,k=Y*x+L*F+_,V=X/2+w,D=J(n[V],h[V]*o);y[f++]=O,y[f++]=k,y[f++]=a[S],y[f++]=a[S+1],y[f++]=v,y[f++]=l,m[f++]=D,p&&p.push(O,k)}this.instanceCount++,this.currentBatchEntry.count++}u&&u.call(e,e,T,p)}}$.prototype.defaultConfig={name:"rexBatchHandlerTriangle",verticesPerInstance:3,indicesPerInstance:5,shaderName:"REXTRI",vertexSource:M,fragmentSource:B,shaderAdditions:[Z(),N(!0),W(!0),U(1),I(),G()],vertexBufferLayout:{usage:"DYNAMIC_DRAW",layout:[{name:"inPosition",size:2},{name:"inTexCoord",size:2},{name:"inTexDatum"},{name:"inTintEffect"},{name:"inTint",size:4,type:"UNSIGNED_BYTE",normalized:!0}]}};const Q=Phaser.Game;var q=function(t){return t instanceof Q};const K=Phaser.Scene;var tt=function(t){return t instanceof K},et=function(t){return null==t||"object"!=typeof t?null:q(t)?t:q(t.game)?t.game:tt(t)?t.sys.game:tt(t.scene)?t.scene.sys.game:void 0};const it=new Phaser.Structs.Map([["BatchHandler","rexBatchHandlerTriangles"]]);let st=class extends e{constructor(t,e,i,s,r){var a,n,h;void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s="__DEFAULT"),super(t,"rexMeshImage"),this.dirtyFlags=0,this.vertices=[],this.faces=[],this.vertexBuffer=null,this.uvBuffer=null,this.alphaBuffer=null,this.colorBuffer=null,this.tintFill=!1,this.debugCallback=null,this.debugGraphic=null,this.setTexture(s,r),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),a="rexBatchHandlerTriangles",n=$,(h=et(t).renderer.renderNodes).hasNode(a,!0)||h.addNodeConstructor(a,n),this.initRenderNodes(this._defaultRenderNodesMap)}get _defaultRenderNodesMap(){return it}get dirty(){return 0!==this.dirtyFlags}get frame(){return this._frame}set frame(t){if(this._frame!==t){this._frame=t;var e=this.faces;if(e){var i=t?t.u0:0,s=t?t.v0:0,r=t?t.u1:0,a=t?t.v1:0,n=t?t.cutWidth:0,h=t?t.cutHeight:0,o=this._frameWidthSave!==n||this._frameHeightSave!==h;this._frameWidthSave=n,this._frameHeightSave=h;for(var l=0,c=e.length;l<c;l++){var u=e[l];u.setFrameUV(i,s,r,a),o&&u.setFrameSize(n,h)}}}}get tint(){return this.faces.length>0?this.faces[0].color:16777215}set tint(t){for(var e=this.faces,i=0,s=e.length;i<s;i++)e[i].setColor(t)}addedToScene(){this.scene.sys.updateList.add(this)}removedFromScene(){this.scene.sys.updateList.remove(this)}};Object.assign(st.prototype,n,E);var rt={play(t,e){return this.anims.play(t,e)},playReverse(t,e){return this.anims.playReverse(t,e)},playAfterDelay(t,e){return this.anims.playAfterDelay(t,e)},playAfterRepeat(t,e){return this.anims.playAfterRepeat(t,e)},chain(t){return this.anims.chain(t)},stop(){return this.anims.stop()},stopAfterDelay(t){return this.anims.stopAfterDelay(t)},stopAfterRepeat(t){return this.anims.stopAfterRepeat(t)},stopOnFrame(t){return this.anims.stopOnFrame(t)}},at={};Object.assign(at,rt);const nt=Phaser.Animations.AnimationState;class ht extends st{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type="rexMeshSprite",this.anims=new nt(this)}preUpdate(t,e){this.anims.update(t,e)}preDestroy(){this.anims.destroy(),this.anims=void 0}}Object.assign(ht.prototype,at);var ot={skipRender(){return!(!this.hideBackFace||!this.isBackFace)||a.call(this)}},lt={setRotationXYZ(t,e,i){return void 0!==t&&(this.rotationX=t),void 0!==e&&(this.rotationY=e),void 0!==i&&(this.rotationZ=i),this},setRotationX(t){return this.rotationX=t,this},setRotationY(t){return this.rotationY=t,this},setRotationZ(t){return this.rotationZ=t,this},setAngleXYZ(t,e,i){return void 0!==t&&(this.angleX=t),void 0!==e&&(this.angleY=e),void 0!==i&&(this.angleZ=i),this},setAngleX(t){return this.angleX=t,this},setAngleXY(t){return this.angleY=t,this},setAngleXZ(t){return this.angleZ=t,this}},ct={};Object.assign(ct,ot,lt);const ut=Phaser.Utils.Objects.IsPlainObject,dt=Phaser.Utils.Objects.GetValue,pt=Phaser.Math.RadToDeg,vt=Phaser.Math.DegToRad;class ft extends ht{constructor(t,e,i,s,r,a){ut(e)&&(e=dt(a=e,"x",0),i=dt(a,"y",0),s=dt(a,"key",null),r=dt(a,"frame",null)),super(t,e,i,s,r),this.type="rexPerspectiveImage",this._rotationX=0,this._rotationY=0,this._rotationZ=0,this.isBackFace=!1,this.hideBackFace=dt(a,"hideBackFace",!0);var n=dt(a,"gridWidth",0),h=dt(a,"gridHeight",n);this.resetVertices(n,h)}resetVertices(t,e){if(void 0!==t&&(this.gridWidth=t),void 0!==e&&(this.gridHeight=e),this.clear(),0===this.width||0===this.height)return this;var i=this.frame.cutWidth,s=this.frame.cutHeight;return t=0===this.gridWidth?Math.max(i/8,32):this.gridWidth,e=0===this.gridHeight?Math.max(s/8,32):this.gridHeight,this.addGridFaces({columns:Math.ceil(i/t),rows:Math.ceil(s/e),sharedVertexMode:!0}),this}get rotationX(){return this._rotationX}set rotationX(t){this._rotationX!==t&&(this._rotationX=t,gt(this,this._rotationX,this._rotationY,this._rotationZ))}get angleX(){return pt(this.rotationX)}set angleX(t){this.rotationX=vt(t)}get rotationY(){return this._rotationY}set rotationY(t){this._rotationY!==t&&(this._rotationY=t,gt(this,this._rotationX,this._rotationY,this._rotationZ))}get angleY(){return pt(this.rotationY)}set angleY(t){this.rotationY=vt(t)}get rotationZ(){return this._rotationZ}set rotationZ(t){this._rotationZ!==t&&(this._rotationZ=t,gt(this,this._rotationX,this._rotationY,this._rotationZ))}get angleZ(){return pt(this.rotationZ)}set angleZ(t){this.rotationZ=vt(t)}}var gt=function(t,e,i,s){var r,a,n,h,o,l;!function(t,e,i,s,r,a){var n=t.vertices;if(0!==e||0!==i||0!==s){var h,o,l,c,u,d;void 0===r&&(r=t.width/2),void 0===a&&(a=t.height/2);var p,v,f=Math.cos(e),g=Math.sin(e),y=Math.cos(i),m=Math.sin(i),C=Math.cos(s),x=Math.sin(s),P=t.scene.scale.gameSize.width;for(F=0,b=n.length;F<b;F++)o=(h=n[F]).frameX-r,u=(l=h.frameY-a)*f-(c=0)*g,d=-o*m+(c=d=l*g+c*f)*y,u=(o=o*y+c*m)*x+(l=u)*C,o=o*C-l*x,l=u,p=P/(P-(c=d)),h.localX=o*p+r,h.localY=l*p+a,h.hasOwnProperty("xyz")||(h.xyz=[0,0,0]),(v=h.xyz)[0]=o,v[1]=l,v[2]=c}else for(var F=0,b=n.length;F<b;F++)n[F].resetPosition()}(t,e,i,s),t.faces.length>0?t.isBackFace=(r=t.faces[0],a=r.vertices[0].xyz,n=r.vertices[1].xyz,h=r.vertices[2].xyz,o=[n[0]-a[0],n[1]-a[1],n[2]-a[2]],l=[h[0]-a[0],h[1]-a[1],h[2]-a[2]],o[1],l[2],o[2],l[1],o[2],l[0],o[0],l[2],o[0]*l[1]-o[1]*l[0]<0):t.isBackFace=!1};function yt(t,e,i,s,r){var a=new ft(this.scene,t,e,i,s,r);return this.scene.add.existing(a),a}Object.assign(ft.prototype,ct);const mt=Phaser.Utils.Objects.GetAdvancedValue,Ct=Phaser.GameObjects.BuildGameObject;function xt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=mt(t,"key",null),s=mt(t,"frame",null),r=new ft(this.scene,0,0,i,s,t);return Ct(this.scene,r,t),r}const Pt=Phaser.Textures.DynamicTexture;var Ft=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},bt=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const _t=Phaser.Geom.Rectangle,At=Phaser.Math.Vector2,Rt=Phaser.Math.RotateAround,Tt=Phaser.GameObjects.Container;var Xt=function(t,e){if(void 0===e?e=new _t:!0===e&&(void 0===wt&&(wt=new _t),e=wt),t.getBounds&&!(t instanceof Tt))return t.getBounds(e);var i,s,r,a,n,h,o,l;if(t.parentContainer){var c=t.parentContainer.getBoundsTransformMatrix();St(t,e),c.transformPoint(e.x,e.y,e),i=e.x,s=e.y,Yt(t,e),c.transformPoint(e.x,e.y,e),r=e.x,a=e.y,Lt(t,e),c.transformPoint(e.x,e.y,e),n=e.x,h=e.y,Ot(t,e),c.transformPoint(e.x,e.y,e),o=e.x,l=e.y}else St(t,e),i=e.x,s=e.y,Yt(t,e),r=e.x,a=e.y,Lt(t,e),n=e.x,h=e.y,Ot(t,e),o=e.x,l=e.y;return e.x=Math.min(i,r,n,o),e.y=Math.min(s,a,h,l),e.width=Math.max(i,r,n,o)-e.x,e.height=Math.max(s,a,h,l)-e.y,e},wt=void 0,St=function(t,e,i){return void 0===e?e=new At:!0===e&&(void 0===kt&&(kt=new At),e=kt),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-Ft(t)*t.originX,e.y=t.y-bt(t)*t.originY,Vt(t,e,i))},Yt=function(t,e,i){return void 0===e?e=new At:!0===e&&(void 0===kt&&(kt=new At),e=kt),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-Ft(t)*t.originX+Ft(t),e.y=t.y-bt(t)*t.originY,Vt(t,e,i))},Lt=function(t,e,i){return void 0===e?e=new At:!0===e&&(void 0===kt&&(kt=new At),e=kt),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-Ft(t)*t.originX,e.y=t.y-bt(t)*t.originY+bt(t),Vt(t,e,i))},Ot=function(t,e,i){return void 0===e?e=new At:!0===e&&(void 0===kt&&(kt=new At),e=kt),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-Ft(t)*t.originX+Ft(t),e.y=t.y-bt(t)*t.originY+bt(t),Vt(t,e,i))},kt=void 0,Vt=function(t,e,i){return void 0===i&&(i=!1),0!==t.rotation&&Rt(e,t.x,t.y,t.rotation),i&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e};const Dt=Phaser.Geom.Rectangle,Et=Phaser.Geom.Rectangle.Union;var Bt,Mt=function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}(e),i){e.length=t.length;for(var s=0,r=t.length;s<r;s++)e[s]=t[s]}else for(var a in t)e[a]=t[a];return e},jt=function(t,e){if(t.length<=1)return t;var i;void 0===e&&(e=!1);for(var s=0,r=t.length;s<r;s++){var a=t[s];if(a.displayList?i=a.displayList:a.parentContainer&&(i=a.parentContainer.list),i)break}return i||(i=a.scene.sys.displayList),i.depthSort&&(i.depthSort(),i=i.list),e?t.sort((function(t,e){return i.indexOf(e)-i.indexOf(t)})):t.sort((function(t,e){return i.indexOf(t)-i.indexOf(e)})),t};const Gt=Phaser.GameObjects.GameObject,Ut=Phaser.GameObjects.Layer;var Zt=Phaser.Utils.Objects.GetValue,Nt=function(t){if(t){var e=t.gameObjects;Array.isArray(e)||(e=[e]);var i,s,r=t.renderTexture,a=t.saveTexture,n=Zt(t,"x",void 0),h=Zt(t,"y",void 0),o=Zt(t,"width",void 0),l=Zt(t,"height",void 0),c=Zt(t,"originX",0),u=Zt(t,"originY",0),d=Zt(t,"padding",0);if(void 0===o||void 0===l||void 0===n||void 0===h){var p=function(t,e){var i;void 0===e?e=new Dt:!0===e&&(void 0===Bt&&(Bt=new Dt),e=Bt),e.setTo(0,0,0,0);for(var s=!0,r=0,a=t.length;r<a;r++)if((i=t[r]).getBounds){var n=Xt(i,!0);s?(e.setTo(n.x,n.y,n.width,n.height),s=!1):Et(n,e,e)}return e}(e,!0);void 0!==n&&void 0!==h?(o=2*Math.max(n-p.left,p.right-n),l=2*Math.max(h-p.top,p.bottom-h),c=.5,u=.5):(n=p.x,h=p.y,o=p.width,l=p.height,c=0,u=0),i=p.x,s=p.y}else i=n+(0-c)*o,s=h+(0-u)*l;i-=d,s-=d,o+=2*d,l+=2*d;var v,f=e[0].scene,g=f.sys.textures;return a&&!r&&(r=g.addDynamicTexture(a,o,l)),r||(r=f.add.renderTexture(0,0,o,l)),r.setPosition&&r.setPosition(n,h),r.width===o&&r.height===l||r.setSize(o,l),r.setOrigin&&r.setOrigin(c,u),r.camera.setScroll(i,s),e=jt(Mt(e)),r.draw(e).render(),a&&((v=r)instanceof Gt||v instanceof Ut?r.saveTexture(a):r.key!==a&&g.renameTexture(r.key,key)),r}};const Wt=Phaser.Utils.Objects.IsPlainObject,It=Phaser.Utils.Objects.GetValue;let zt=class extends ft{constructor(t,e,i,s,r,a){Wt(e)&&(e=It(a=e,"x",0),i=It(a,"y",0),s=It(a,"width",32),r=It(a,"height",32));var n=function(t,e,i){return void 0===e&&(e=2),void 0===i&&(i=2),new Pt(t.sys.textures,null,e,i)}(t,s,r);super(t,e,i,n,null,a),this.type="rexPerspectiveRenderTexture",this.rt=this.texture}destroy(t){this.scene&&!this.ignoreDestroy&&(super.destroy(t),this.rt.destroy(),this.rt=null)}setSizeToFrame(t){var e=this.width,i=this.height;return super.setSizeToFrame(t),this.updateDisplayOrigin(),this.width===e&&this.height===i||void 0!==this.gridWidth&&this.resetVertices(),this}snapshot(t,e){return void 0===e&&(e={}),e.gameObjects=t,e.renderTexture=this.rt,Nt(e),this.setSizeToFrame(),this}};function Ht(t,e,i,s,r){var a=new zt(this.scene,t,e,i,s,r);return this.scene.add.existing(a),a}const Jt=Phaser.Utils.Objects.GetAdvancedValue,$t=Phaser.GameObjects.BuildGameObject;function Qt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=Jt(t,"width",32),s=Jt(t,"height",32),r=new zt(this.scene,0,0,i,s,t);return $t(this.scene,r,t),r}var qt=!1;!function(t){if(!qt){void 0===t&&(t=0);var e=Phaser.VERSION.split("."),i=parseInt(e[0]);if(4===i){var s=parseInt(e[1]);s<t&&console.error(`Minimum supported version : ${i}.${s}`)}else console.error(`Can't supported version : ${i}`);qt=!0}}();const Kt=Phaser.GameObjects.Zone,te=Phaser.Utils.Array.Add,ee=Phaser.Utils.Array.Remove;class ie extends Kt{constructor(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=1),super(t,e,i,s,r),this.children=[]}destroy(t){if(this.scene&&!this.ignoreDestroy){if(t)for(var e,i=this.children.length-1;i>=0;i--)(e=this.children[i]).parentContainer||e.displayList||e.destroy(t);this.clear(!t),super.destroy(t)}}contains(t){return-1!==this.children.indexOf(t)}add(t){var e=this;return te(this.children,t,0,(function(t){t.once("destroy",e.onChildDestroy,e)}),this),this}remove(t,e){var i=this;return ee(this.children,t,(function(t){t.off("destroy",i.onChildDestroy,i),e&&t.destroy()})),this}onChildDestroy(t,e){this.remove(t,!1)}clear(t){for(var e,i=0,s=this.children.length;i<s;i++)(e=this.children[i]).off("destroy",this.onChildDestroy,this),t&&e.destroy();return this.children.length=0,this}}const se=Phaser.GameObjects.Components;Phaser.Class.mixin(ie,[se.Alpha,se.Flip]);var re=function(t,e){var i;if(void 0===e)t.hasOwnProperty("rexContainer")&&(i=t.rexContainer.parent);else for(i=re(t);i&&i.name!==e;)i=re(i);return i};const ae=Phaser.Math.DegToRad,ne=Phaser.Math.RadToDeg;var he=function(t){if(!t.hasOwnProperty("rexContainer")){var e={parent:null,self:null,layer:null,x:0,y:0,syncPosition:!0,rotation:0,syncRotation:!0,scaleX:0,scaleY:0,syncScale:!0,alpha:0,syncAlpha:!0,syncScrollFactor:!0,syncCameraFilter:!0,syncDisplayList:!0,visible:!0,active:!0};Object.defineProperty(e,"angle",{get:function(){return ne(this.rotation)},set:function(t){this.rotation=ae(t)}}),Object.defineProperty(e,"displayWidth",{get:function(){return t.width*this.scaleX},set:function(e){this.scaleX=e/t.width}}),Object.defineProperty(e,"displayHeight",{get:function(){return t.height*this.scaleY},set:function(e){this.scaleY=e/t.height}}),t.rexContainer=e}return t.rexContainer},oe={setParent(t,e){void 0===e&&(e=this);var i=he(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent(t,e){return"string"==typeof t&&(e=t,t=void 0),void 0===t&&(t=this),re(t,e)},getTopmostParent(t){return void 0===t&&(t=this),function(t){for(var e=re(t);e;)t=e,e=re(e);return t}(t)}};const le=Phaser.Utils.Objects.GetValue,ce=ie.prototype.add;var ue=function(t,e){this.setParent(t);var i=he(t);return pe(i,e),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t).updateCameraFilter(t),ce.call(this,t),ve.call(this,t,i),this},de=function(t,e){this.setParent(t);var i=he(t);return pe(i,e),i.x=t.x,i.y=t.y,i.rotation=t.rotation,i.scaleX=t.scaleX,i.scaleY=t.scaleY,i.alpha=t.alpha,i.visible=t.visible,i.active=t.active,this.updateChildPosition(t).updateChildAlpha(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),ce.call(this,t),ve.call(this,t,i),this},pe=function(t,e){void 0===e&&(e=!0),"boolean"==typeof e?(t.syncPosition=e,t.syncRotation=e,t.syncScale=e,t.syncAlpha=e,t.syncScrollFactor=e,t.syncCameraFilter=e,t.syncDisplayList=e):(t.syncPosition=le(e,"syncPosition",!0),t.syncRotation=le(e,"syncRotation",!0),t.syncScale=le(e,"syncScale",!0),t.syncAlpha=le(e,"syncAlpha",!0),t.syncScrollFactor=le(e,"syncScrollFactor",!0),t.syncCameraFilter=le(e,"syncCameraFilter",!0),t.syncDisplayList=le(e,"syncDisplayList",!0))},ve=function(t,e){this.addToParentContainer(t),e.syncDisplayList&&this.addToPatentLayer(t),this.addToRenderLayer(t)},fe={add(t){return Array.isArray(t)?this.addMultiple(t):ue.call(this,t),this},pin(t,e){return Array.isArray(t)?this.addMultiple(t,e):ue.call(this,t,e),this},addMultiple(t){for(var e=Array.from(arguments),i=0,s=t.length;i<s;i++)e[0]=t[i],this.add.apply(this,e);return this},addLocal(t){return Array.isArray(t)?this.addMultiple(t):de.call(this,t),this},pinLocal(t,e){return Array.isArray(t)?this.addMultiple(t,e):de.call(this,t,e),this},addLocalMultiple(t){for(var e=0,i=t.length;e<i;e++)de.call(this,t[e]);return this}};const ge=ie.prototype.remove,ye=ie.prototype.clear;var me={remove(t,e){return re(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),ge.call(this,t,e)),this},unpin(t,e){return re(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),ge.call(this,t,e)),this},clear(t){for(var e=this.children,i=0,s=e.length;i<s;i++){var r=e[i];this.setParent(r,null),t||this.removeFromRenderLayer(r)}return ye.call(this,t),this}},Ce={getLocalState:t=>he(t),resetChildState(t){return this.resetChildPositionState(t).resetChildVisibleState(t).resetChildAlphaState(t).resetChildActiveState(t),this},resetChildrenState(t){for(var e=0,i=t.length;e<i;e++)this.resetChildState(t[e]);return this},syncProperties(){return this.syncPosition().syncVisible().syncAlpha().syncActive().syncScrollFactor().syncMask(),this}},xe={worldToLocal(t){t.x-=this.x,t.y-=this.y;var e=Math.cos(-this.rotation),i=Math.sin(-this.rotation),s=t.x,r=t.y;return t.x=s*e-r*i,t.y=s*i+r*e,t.x/=this.scaleX,t.y/=this.scaleY,t},localToWorld(t){t.x*=this.scaleX,t.y*=this.scaleY;var e=Math.cos(this.rotation),i=Math.sin(this.rotation),s=t.x,r=t.y;return t.x=s*e-r*i,t.y=s*i+r*e,t.x+=this.x,t.y+=this.y,t}},Pe=function(t,e){return t===e?1:t/e},Fe={updateChildPosition(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=he(t),i=e.parent;return e.syncPosition&&(t.x=e.x,t.y=e.y,i.localToWorld(t)),e.syncRotation&&(t.rotation=e.rotation+i.rotation),e.syncScale&&(t.scaleX=e.scaleX*i.scaleX,t.scaleY=e.scaleY*i.scaleY),t.isRexContainerLite&&(t.syncChildrenEnable=!0,t.syncPosition()),this},syncPosition(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildPosition,this),this},resetChildPositionState(t){var e=he(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=Pe(t.scaleX,i.scaleX),e.scaleY=Pe(t.scaleY,i.scaleY),e.rotation=t.rotation-i.rotation,this},setChildPosition(t,e,i){return t.x=e,t.y=i,this.resetChildPositionState(t),this},setChildLocalPosition(t,e,i){var s=he(t);return s.x=e,s.y=i,this.updateChildPosition(t),this},resetLocalPositionState(){var t=he(this).parent;return t&&t.resetChildPositionState(this),this},getChildLocalX:t=>he(t).x,getChildLocalY:t=>he(t).y};const be=Phaser.Math.DegToRad;var _e={updateChildRotation(t){var e=he(t),i=e.parent;return e.syncRotation&&(t.rotation=i.rotation+e.rotation),this},syncRotation(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildRotation,this),this},resetChildRotationState(t){var e=he(t),i=e.parent;return e.rotation=t.rotation-i.rotation,this},setChildRotation(t,e){return t.rotation=e,this.resetChildRotationState(t),this},setChildAngle(t,e){return t.angle=e,this.resetChildRotationState(t),this},setChildLocalRotation(t,e){return he(t).rotation=e,this.updateChildRotation(t),this},setChildLocalAngle(t,e){return he(t).rotation=be(e),this.updateChildRotation(t),this},resetLocalRotationState(){var t=he(this).parent;return t&&t.resetChildRotationState(this),this},getChildLocalRotation:t=>he(t).rotation},Ae={updateChildScale(t){var e=he(t),i=e.parent;return e.syncScale&&(t.scaleX=i.scaleX*e.scaleX,t.scaleY=i.scaleY*e.scaleY),this},syncScale(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScale,this),this},resetChildScaleState(t){var e=he(t),i=e.parent;return e.scaleX=Pe(t.scaleX,i.scaleX),e.scaleY=Pe(t.scaleY,i.scaleY),this},setChildScale(t,e,i){return void 0===i&&(i=e),t.scaleX=e,t.scaleY=i,this.resetChildScaleState(t),this},setChildLocalScale(t,e,i){void 0===i&&(i=e);var s=he(t);return s.scaleX=e,s.scaleY=i,this.updateChildScale(t),this},setChildDisplaySize(t,e,i){return t.setDisplaySize(e,i),this.resetChildScaleState(t),this},resetLocalScaleState(){var t=he(this).parent;return t&&t.resetChildScaleState(this),this},getChildLocalScaleX:t=>he(t).scaleX,getChildLocalScaleY:t=>he(t).scaleY},Re={updateChildVisible(t){var e=he(t),i=e.parent,s=!e.hasOwnProperty("maskVisible")||e.maskVisible,r=!i||i.visible;return t.visible=r&&e.visible&&s,this},syncVisible(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildVisible,this),this},resetChildVisibleState(t){var e=he(t);return e.hasOwnProperty("maskVisible")&&delete e.maskVisible,e.visible=t.visible,this},setChildVisible(t,e){return this.setChildLocalVisible(t,e),this},setChildLocalVisible(t,e){return void 0===e&&(e=!0),he(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible(t,e){return void 0===e&&(e=!0),he(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState(){var t=he(this).parent;return t&&t.resetChildVisibleState(this),this},getChildLocalVisible:t=>he(t).visible},Te={updateChildAlpha(t){var e=he(t),i=e.parent;return e.syncAlpha&&(t.alpha=i.alpha*e.alpha),this},syncAlpha(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState(t){var e=he(t),i=e.parent;return e.alpha=Pe(t.alpha,i.alpha),this},setChildAlpha(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha(t,e){return he(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState(){var t=he(this).parent;return t&&t.resetChildAlphaState(this),this},getChildLocalAlpha:t=>he(t).alpha},Xe={updateChildActive(t){var e=he(t),i=e.parent;return t.active=i.active&&e.active,this},syncActive(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildActive,this),this},resetChildActiveState(t){return he(t).active=t.active,this},setChildActive(t,e){return t.active=e,this.resetChildActiveState(t),this},setChildLocalActive(t,e){return void 0===e&&(e=!0),he(t).active=e,this.updateChildActive(t),this},resetLocalActiveState(){var t=he(this).parent;return t&&t.resetChildActiveState(this),this},getChildLocalActive:t=>he(t).active},we={updateChildScrollFactor(t){var e=he(t),i=e.parent;return e.syncScrollFactor&&(t.scrollFactorX=i.scrollFactorX,t.scrollFactorY=i.scrollFactorY),this},syncScrollFactor(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},Se={updateCameraFilter(t){var e=he(t),i=e.parent;return e.syncCameraFilter&&(t.cameraFilter=i.cameraFilter),this},syncCameraFilter(){return this.syncChildrenEnable&&this.children.forEach(this.updateCameraFilter,this),this}},Ye={updateChildMask(t){return null==this.mask||(this.mask.hasOwnProperty("geometryMask")?this.mask.geometryMask:this.mask.bitmapMask)!==t&&(t.mask=this.mask),this},syncMask(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildMask,this),this},setMask(t){return this.mask=t,this},clearMask(t){void 0===t&&(t=!1);var e=this;return this._mask=null,this.setChildMaskVisible(this),this.children.forEach((function(t){t.clearMask&&t.clearMask(!1),t.hasOwnProperty("isRexContainerLite")||e.setChildMaskVisible(t)})),t&&this.mask&&this.mask.destroy(),this}},Le=function(t){return t.filter((function(t){return!!t.displayList||!!t.parentContainer||void 0}))},Oe={setDepth(t,e){if(this.depth=t,!e&&this.children)for(var i=this.getAllChildren(),s=0,r=i.length;s<r;s++)i[s].depth=t;return this},swapDepth(t){var e=this.depth,i=t.depth;return this.setDepth(i),t.setDepth(e),this},incDepth(t){if(this.depth+=t,this.children)for(var e=this.getAllChildren(),i=0,s=e.length;i<s;i++)e[i].depth+=t;return this},bringToTop(){var t=this.displayList;if(!t)return this;var e=this.getAllChildren([this]);jt(e,!1);for(var i=0,s=e.length;i<s;i++){var r=e[i];t.exists(r)&&t.bringToTop(r)}return this},bringMeToTop(){return this.bringToTop()},sendToBack(){var t=this.displayList;if(!t)return this;var e=this.getAllChildren([this]);jt(e,!0);for(var i=0,s=e.length;i<s;i++){var r=e[i];t.exists(r)&&t.sendToBack(r)}return this},sendMeToBack(){return this.sendToBack()},moveDepthBelow(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);jt(i,!1);for(var s=0,r=i.length;s<r;s++){var a=i[s];if(e.exists(a)){e.moveBelow(t,a);break}}return this},moveMyDepthBelow(t){return this.moveDepthBelow(t)},moveDepthAbove(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);jt(i,!0);for(var s=0,r=i.length;s<r;s++){var a=i[s];if(e.exists(a)){e.moveAbove(t,a);break}}return this},moveMyDepthAbove(t){return this.moveDepthAbove(t)},bringChildToTop(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=Le(e),e=jt(e,!1)):e=[t];var i=this.getAllChildren([this]);i=Le(i);for(var s=(i=jt(i,!1))[i.length-1],r=0,a=e.length;r<a;r++){var n=e[r];s!==n&&(n!==this&&s.displayList!==n.displayList||(s.displayList.moveAbove(n,s),s=n))}return this},sendChildToBack(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=Le(e),e=jt(e,!1)):e=[t];var i=this.getAllChildren([this]);i=Le(i);for(var s=(i=jt(i,!1))[0],r=e.length-1;r>=0;r--){var a=e[r];s!==a&&(a!==this&&s.displayList!==a.displayList||(s.displayList.moveBelow(a,s),s=a))}return this}},ke=function(t,e){if(!e(t)&&t.isRexContainerLite)for(var i=t.children,s=0,r=i.length;s<r;s++)ke(i[s],e)},Ve=function(t,e){for(var i=[t];i.length>0;){var s=i.shift();!e(s)&&s.isRexContainerLite&&i.push(...s.children)}};const De=Phaser.Utils.Array;var Ee={getChildren(t){if(t)for(var e=0,i=this.children.length;e<i;e++)t.push(this.children[e]);else t=this.children;return t},getAllChildren(t){void 0===t&&(t=[]);var e=this;return Ve(e,(function(i){i!==e&&t.push(i)})),t},getAllVisibleChildren(t){void 0===t&&(t=[]);var e=this;return Ve(e,(function(i){if(i!==e)return!i.visible||void t.push(i)})),t},bfs(t,e){return void 0===e&&(e=this),Ve(e,t),this},dfs(t,e){return void 0===e&&(e=this),ke(e,t),this},contains(t){var e=re(t);return!!e&&(e===this||this.contains(e))},getByName(t,e){if(e){for(var i,s,r=[this];r.length;)for(var a=0,n=(i=r.shift()).children.length;a<n;a++){if((s=i.children[a]).name===t)return s;s.isRexContainerLite&&r.push(s)}return null}return De.GetFirst(this.children,"name",t)},getRandom(t,e){return De.GetRandom(this.children,t,e)},getFirst(t,e,i,s){return De.GetFirstElement(this.children,t,e,i,s)},getAll(t,e,i,s){return De.GetAll(this.children,t,e,i,s)},count(t,e,i,s){return De.CountAllMatching(this.children,t,e,i,s)},swap(t,e){return De.Swap(this.children,t,e),this},setAll(t,e,i,s){return De.SetAll(this.children,t,e,i,s),this}},Be=function(t){for(var e=[],i=0,s=t.length;i<s;i++){var r=t[i];r.hasOwnProperty("rexContainer")&&e.push(r.rexContainer)}return e},Me=function(t,e,i){if(i.parent){var s=i.parent,r=i.self;switch(e){case"x":case"y":s.updateChildPosition(r);break;case"angle":case"rotation":s.updateChildRotation(r);break;case"scaleX":case"scaleY":case"displayWidth":case"displayHeight":s.updateChildScale(r);break;case"alpha":s.updateChildAlpha(r);break;default:s.updateChildPosition(r),s.updateChildRotation(r),s.updateChildScale(r),s.updateChildAlpha(r)}}else t.remove()},je={tweenChild(t){var e=t.targets;Array.isArray(e)||(e=[e]);var i=this.scene||function(t){for(var e=0,i=t.length;e<i;e++){var s=t[e].scene;if(s)return s}return null}(e);if(i){t.targets=Be(e);var s=i.tweens.add(t);return s.on("update",Me),s}},tweenSelf(t){return t.targets=[this],this.tweenChild(t)},createTweenChildConfig(t){var e=t.targets;e&&(Array.isArray(e)||(e=[e]),t.targets=Be(e));var i=t.onUpdate;return t.onUpdate=function(t,e){i&&i(t,e),Me(t,void 0,e)},t},tween(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}};const Ge=Phaser.GameObjects.Container,Ue=Phaser.GameObjects.Layer;var Ze=function(t){return t instanceof Ue},Ne=function(t){var e=t.getAllChildren([t]);return e=e.filter((function(t){return!!t.displayList||!!t.parentContainer}))},We=function(t){var e=Ne(this);-1===e.indexOf(this)&&e.push(this),jt(e),t.add(e)},Ie=function(t,e,i){if(this.scene){var s=Ne(this);jt(s,e),t.remove(s),i&&s.forEach((function(t){t.addToDisplayList()}))}},ze={addToContainer(t){return t instanceof Ge?(this._setParentContainerFlag=!0,We.call(this,t),this._setParentContainerFlag=!1,this):this},addToLayer(t){return Ze(t)?(We.call(this,t),this):this},removeFromContainer(){return this.parentContainer?(this._setParentContainerFlag=!0,Ie.call(this,this.parentContainer,!0,!1),this._setParentContainerFlag=!1,this):this},removeFromLayer(t){return void 0===t&&(t=!0),Ze(this.displayList)?(Ie.call(this,this.displayList,!1,t),this):this},getParentContainer(){if(this.parentContainer)return this.parentContainer;for(var t=this.getParent();t;){var e=t.parentContainer;if(e)return e;t=t.getParent()}return null},addToParentContainer(t){if(!t.displayList)return this;var e=this.getParentContainer();return e?(t.isRexContainerLite?t.addToContainer(e):e.add(t),this):this},addToPatentLayer(t){if(!t.displayList)return this;var e=this.displayList;return e===t.displayList||Ze(e)&&(t.isRexContainerLite?t.addToLayer(e):e.add(t)),this}},He={hasLayer(){return!!this.privateRenderLayer},enableLayer(){if(this.hasLayer())return this;var t=this.scene.add.layer();return this.moveDepthBelow(t),this.addToLayer(t),this.privateRenderLayer=t,this},getLayer(){return this.hasLayer()||this.enableLayer(),this.privateRenderLayer},getRenderLayer(){if(this.hasLayer())return this.privateRenderLayer;for(var t=this.getParent();t;){var e=t.privateRenderLayer;if(e)return e;t=t.getParent()}return null},addToRenderLayer(t){if(!t.displayList)return this;var e=this.getRenderLayer();return e?(e===t.displayList||(t.isRexContainerLite?t.addToLayer(e):e.add(t),he(t).layer=e),this):this},removeFromRenderLayer(t){var e=he(t),i=e.layer;return i?(t.isRexContainerLite?t.removeFromLayer(!0):i.remove(t),e.layer=null,this):this}},Je={snapshot(t){var e=this.scaleX,i=this.scaleY,s=1===e&&1===i;s||this.setScale(1),void 0===t&&(t={}),t.gameObjects=this.getAllVisibleChildren(),t.x=this.x,t.y=this.y,t.originX=this.originX,t.originY=this.originY;var r=Nt(t),a=!!r.scene;return s||(this.setScale(e,i),a&&r.setScale(e,i)),a?r:this}};const $e=Phaser.Utils.Objects.GetValue;var Qe=function(t,e,i,s,r,a,n,h){if(t.getBounds||void 0!==t.width&&void 0!==t.height){var o=St(t,qe[0],h);o.x-=n,o.y-=n;var l=Yt(t,qe[1],h);l.x+=n,l.y-=n;var c=Ot(t,qe[2],h);c.x+=n,c.y+=n;var u=Lt(t,qe[3],h);u.x-=n,u.y+=n,null!==r&&e.fillStyle(r,a).fillPoints(qe,!0,!0),null!==i&&e.lineStyle(s,i).strokePoints(qe,!0,!0)}},qe=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const Ke=Phaser.Utils.Objects.GetValue,ti=Phaser.Math.RotateAround;var ei={changeOrigin:function(t,e){this.syncChildrenEnable=!1,function(t,e,i){void 0===i&&(i=e);var s={x:(e-t.originX)*t.displayWidth,y:(i-t.originY)*t.displayHeight};ti(s,0,0,t.rotation),t.originX=e,t.originY=i,t.x=t.x+s.x,t.y=t.y+s.y}(this,t,e),this.syncChildrenEnable=!0;for(var i=this.getAllChildren(),s=0,r=i.length;s<r;s++)this.resetChildPositionState(i[s]);return this},drawBounds:function(t,e){var i=Ke(e,"drawContainer",!0),s=Ke(e,"children");return void 0===s&&(s=this.getAllVisibleChildren([this])),i||(s=s.filter((function(t){return!t.isRexContainerLite}))),function(t,e,i){var s,r,a,n,h,o;if("number"==typeof i?s=i:(s=$e(i,"color"),r=$e(i,"lineWidth"),a=$e(i,"fillColor"),n=$e(i,"fillAlpha"),h=$e(i,"padding"),o=$e(i,"includeParent")),void 0===s&&(s=16777215),void 0===r&&(r=1),void 0===a&&(a=null),void 0===n&&(n=1),void 0===h&&(h=0),void 0===o&&(o=!0),Array.isArray(t))for(var l=0,c=t.length;l<c;l++)Qe(t[l],e,s,r,a,n,h,o);else Qe(t,e,s,r,a,n,h,o)}(s,t,e),this}};Object.assign(ei,oe,fe,me,Ce,xe,Fe,_e,Ae,Re,Te,Xe,we,Se,Ye,Oe,Ee,je,ze,He,Je);class ii extends ie{constructor(t,e,i,s,r,a){Array.isArray(s)&&(a=s,s=void 0,r=void 0),super(t,e,i,s,r),this.type="rexContainerLite",this.isRexContainerLite=!0,this.syncChildrenEnable=!0,this._active=!0,this._mask=null,this._scrollFactorX=1,this._scrollFactorY=1,this._cameraFilter=0,this.privateRenderLayer=void 0,a&&this.add(a)}destroy(t){this.scene&&!this.ignoreDestroy&&(this.syncChildrenEnable=!1,super.destroy(t),this.privateRenderLayer&&this.privateRenderLayer.scene&&(this.privateRenderLayer.list.length=0,this.privateRenderLayer.destroy()))}resize(t,e){return this.setSize(t,e),this}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.syncPosition())}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.syncPosition())}get rotation(){return super.rotation}set rotation(t){this.rotation!==t&&(super.rotation=t,this.syncPosition())}get scaleX(){return super.scaleX}set scaleX(t){this.scaleX!==t&&(super.scaleX=t,this.syncPosition())}get scaleY(){return super.scaleY}set scaleY(t){this.scaleY!==t&&(super.scaleY=t,this.syncPosition())}get scale(){return super.scale}set scale(t){this.scale!==t&&(super.scale=t,this.syncPosition())}get visible(){return super.visible}set visible(t){super.visible!==t&&(super.visible=t,this.syncVisible())}get alpha(){return super.alpha}set alpha(t){super.alpha!==t&&(super.alpha=t,this.syncAlpha())}get active(){return this._active}set active(t){this._active!==t&&(this._active=t,this.syncActive())}get mask(){return this._mask}set mask(t){this._mask!==t&&(this._mask=t,this.syncMask())}get scrollFactorX(){return this._scrollFactorX}set scrollFactorX(t){this._scrollFactorX!==t&&(this._scrollFactorX=t,this.syncScrollFactor())}get scrollFactorY(){return this._scrollFactorY}set scrollFactorY(t){this._scrollFactorY!==t&&(this._scrollFactorY=t,this.syncScrollFactor())}get cameraFilter(){return this._cameraFilter}set cameraFilter(t){this._cameraFilter!==t&&(this._cameraFilter=t,this.syncCameraFilter())}get list(){return this.children}static GetParent(t){return re(t)}get parentContainer(){return this._parentContainer}set parentContainer(t){this._parentContainer||t?this.setParentContainerFlag?this._parentContainer=t:this._parentContainer&&!t?(this.removeFromContainer(),this._parentContainer=t):t?(this._parentContainer=t,this.addToContainer(t)):this._parentContainer=t:this._parentContainer=t}get setParentContainerFlag(){if(this._setParentContainerFlag)return!0;var t=re(this);return!!t&&t.setParentContainerFlag}}Object.assign(ii.prototype,ei);var si=function(t,e,i,s){if(Array.isArray(t))for(var r=0,a=t.length;r<a;r++){var n=t[r];if((!s||n)&&(i?e.call(i,n,r,t):e(n,r,t)))return}else for(var h in t)if(n=t[h],(!s||n)&&(i?e.call(i,n,h,t):e(n,h,t)))return};const ri=Phaser.Math.RadToDeg,ai=Phaser.Math.DegToRad;class ni extends ii{constructor(t,e,i,s,r,a){super(t,e,i,s,r),this.faces=a,si(a,(function(t){t.setPosition(e,i),this.add(t)}),this,!0)}get rotationX(){return 0}set rotationX(t){}get angleX(){return ri(this.rotationX)}set angleX(t){this.rotationX=ai(t)}get rotateX(){return ri(this.rotationX)}set rotateX(t){this.rotationX=ai(t)}get rotationY(){return 0}set rotationY(t){}get angleY(){return ri(this.rotationY)}set angleY(t){this.rotationY=ai(t)}get rotateY(){return ri(this.rotationY)}set rotateY(t){this.rotationY=ai(t)}get rotationZ(){return 0}set rotationZ(t){}get angleZ(){return ri(this.rotationZ)}set angleZ(t){this.rotationZ=ai(t)}get rotateZ(){return ri(this.rotationZ)}set rotateZ(t){this.rotationZ=ai(t)}setDebug(t,e){return si(this.faces,(function(i){i.setDebug(t,e)}),null,!0),this}forEachFace(t,e,i){return si(this.faces,t,e,i),this}}Object.assign(ni.prototype,lt);const hi=Phaser.Utils.Objects.IsPlainObject,oi={key:"__WHITE"},li={image:ft,rendertexture:zt};var ci=function(t,e){var i;return void 0===e&&(e=oi),hi(e)?(e.hasOwnProperty("type")||(e.hasOwnProperty("key")?e.type="image":e.hasOwnProperty("width")&&(e.type="rendertexture")),i=new li[e.type](t,e),t.add.existing(i)):i=e,i},ui={setEventEmitter(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){re