UNPKG

phaser4-rex-plugins

Version:
1 lines 52.6 kB
var t,e;t=void 0,e=function(){var t={renderWebGL:function(t,e,i,s){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){i.camera.addToRenderList(e);var r=e.customRenderNodes,h=e.defaultRenderNodes;(r.Submitter||h.Submitter).run(i,e,s,0,r.Texturer||h.Texturer,r.Transformer||h.Transformer)}},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}};const e=Phaser.Display.Color;var i={clear(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},drawFrame(t,e,i,s,r,h,a,n,o,l){var d=this.scene.sys.textures.getFrame(t,e);if(!d)return this;var c=d.cutWidth,u=d.cutHeight;void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=c),void 0===h&&(h=u),void 0===a&&(a=0),void 0===n&&(n=0),void 0===o&&(o=c),void 0===l&&(l=u);var g=d.cutX+a,f=d.cutY+n;return this.context.drawImage(d.source.image,g,f,o,l,i,s,r,h),this.dirty=!0,this},getDataURL(t,e){return this.canvas.toDataURL(t,e)},getPixel(t,i,s){void 0===s&&(s=new e);var r=this.context.getImageData(t,i,1,1);return s.setTo(r.data[0],r.data[1],r.data[2],r.data[3]),s},setPixel(t,e,i,s,r,h){if("number"!=typeof i){var a=i;i=a.red,s=a.green,r=a.blue,h=a.alpha}void 0===h&&(h=0!==i||0!==s||0!==r?255:0);var n=this.context.createImageData(1,1);return n.data[0]=i,n.data[1]=s,n.data[2]=r,n.data[3]=h,this.context.putImageData(n,t,e),this.dirty=!0,this}},s={updateTexture(t,e){var i=this.canvas,s=this.context;if(t){var r=this.resolution;1!==r&&(this.context.save(),this.context.scale(r,r)),e?t.call(e,i,s):t(i,s),1!==r&&this.context.restore()}var h=i.width,a=i.height;h===this.frame.width&&a===this.frame.height||(this.frame.setSize(h,a),this.frame.source.updateSize(h,a),this.frame.updateUVs()),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(i,this.frame.source.glTexture,!0),this.frame.glTexture.spectorMetadata={textureKey:"Canvas Game Object"}),this.dirty=!1;var n=this.input;return n&&!n.customHitArea&&(n.hitArea.width=this.width,n.hitArea.height=this.height),this},generateTexture(t,e,i,s,r){var h=this.canvas;return void 0===s?s=h.width:s*=this.resolution,void 0===r?r=h.height:r*=this.resolution,function(t,e,i,s,r,h,a){var n,o=t.sys.textures,l=t.renderer;void 0===s&&(s=0),void 0===r&&(r=0),void 0===h&&(h=e.width),void 0===a&&(a=e.height);var d=(n=o.exists(i)?o.get(i):o.createCanvas(i,h,a)).getSourceImage();d.width!==h&&(d.width=h),d.height!==a&&(d.height=a);var c=d.getContext("2d",{willReadFrequently:!0});c.clearRect(0,0,h,a),c.drawImage(e,s,r,h,a),l.gl&&n&&l.canvasToTexture(d,n.source[0].glTexture,!0,0)}(this.scene,h,t,e,i,s,r),this},loadTexture(t,e){var i=this.scene.sys.textures.getFrame(t,e);return i?(this.width!==i.cutWidth||this.height!==i.cutHeight?this.setSize(i.cutWidth,i.cutHeight):this.clear(),this.drawFrame(t,e),this.dirty=!0,this):this}},r=!1;!function(t){if(!r){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}`);r=!0}}();const h=Phaser.Display.Canvas.CanvasPool,a=Phaser.GameObjects.GameObject,n=Phaser.Utils.String.UUID,o=Phaser.Renderer.WebGL.RenderNodes.Defaults.DefaultImageNodes;class l extends a{constructor(t,e,i,s,r,a){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=1),void 0===a&&(a=1),super(t,"rexCanvas"),this.renderer=t.sys.game.renderer,this._width=s,this._height=r,this.resolution=a,s=Math.max(Math.ceil(s*this.resolution),1),r=Math.max(Math.ceil(r*this.resolution),1),this.canvas=h.create(this,s,r),this.dirty=!1,this.setPosition(e,i),this.setOrigin(.5,.5),this.initRenderNodes(this._defaultRenderNodesMap),this._crop=this.resetCropObject(),this._textureKey=n(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.context=this.texture.context,this.frame=this.texture.get(),this.frame.source.resolution=this.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),this.dirty=!0}preDestroy(){h.remove(this.canvas),this.canvas=null,this.context=null;var t=this.texture;t&&t.destroy()}get _defaultRenderNodesMap(){return o}setResolution(t){if(this.resolution===t)return this;this.resolution=t;var e=Math.max(Math.ceil(this.width*t),1),i=Math.max(Math.ceil(this.height*t),1);return this.canvas.width=e,this.canvas.height=i,this.frame.source.resolution=t,this.dirty=!0,this}get width(){return this._width}set width(t){this.setSize(t,this._height)}get height(){return this._height}set height(t){this.setSize(this._width,t)}setCanvasSize(t,e){return this._width===t&&this._height===e||(this._width=t,this._height=e,this.updateDisplayOrigin(),t=Math.max(Math.ceil(t*this.resolution),1),e=Math.max(Math.ceil(e*this.resolution),1),this.canvas.width=t,this.canvas.height=e,this.frame.setSize(t,e),this.frame.source.updateSize(t,e),this.frame.updateUVs(),this.dirty=!0),this}setSize(t,e){return this.setCanvasSize(t,e),this}get displayWidth(){return this.scaleX*this._width}set displayWidth(t){this.scaleX=t/this._width}get displayHeight(){return this.scaleY*this._height}set displayHeight(t){this.scaleY=t/this._height}setDisplaySize(t,e){return this.displayWidth=t,this.displayHeight=e,this}getCanvas(t){return t||(this.dirty=!0),this.canvas}getContext(t){return t||(this.dirty=!0),this.context}needRedraw(){return this.dirty=!0,this}resize(t,e){return this.setSize(t,e),this}}const d=Phaser.GameObjects.Components;Phaser.Class.mixin(l,[d.Alpha,d.BlendMode,d.Crop,d.Depth,d.Flip,d.GetBounds,d.Lighting,d.Mask,d.Origin,d.RenderNodes,d.ScrollFactor,d.Tint,d.Transform,d.Visible,t,i,s]);const c=Phaser.Utils.Objects.GetValue;var u=function(t,e,i){void 0===t&&(t={}),void 0===e&&(e=0);var s=typeof e;return"string"===s?t[e]=i:"number"===s?(t.left=e,t.right=e,t.top=e,t.bottom=e):(t.left=c(e,"left",0),t.right=c(e,"right",0),t.top=c(e,"top",0),t.bottom=c(e,"bottom",0)),t},g={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t]}else this.data[t]=e;return this},getData(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,h=i,a=0;a<s.length;a++){if(e=s[a],!r.hasOwnProperty(e)){h=i;break}r=h=r[e]}return h}(this.data,t,e)},incData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData(){return this.data&&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]}(this.data),this}};class f{constructor(t,e){this.setParent(t),this.type=e,this.renderable=!1,this.reset().setActive()}destroy(){this.parent.removeChild(this)}setParent(t){return this.parent=t,this}get scene(){return this.parent.scene}get canvas(){return this.parent?this.parent.canvas:null}get context(){return this.parent?this.parent.context:null}setDirty(t){return t&&this.parent&&(this.parent.dirty=!0),this}get active(){return this._active}set active(t){this.setDirty(this._active!=t),this._active=t}setActive(t){return void 0===t&&(t=!0),this.active=t,this}modifyPorperties(t){return this}onFree(){this.reset().setParent()}reset(){return this}render(){}contains(t,e){return!1}}Object.assign(f.prototype,g);var p={renderContent(){},render(){if(!this.willRender)return this;var t=this.context;if(t.save(),t.globalAlpha=this.alpha,this.toLocalPosition){var e=this.drawX,i=this.drawY;this.autoRound&&(e=Math.round(e),i=Math.round(i)),t.translate(e,i),t.scale(this.scaleX,this.scaleY),t.rotate(this.rotation)}return this.drawBelowCallback&&this.drawBelowCallback(this),this.renderContent(),this.drawAboveCallback&&this.drawAboveCallback(this),t.restore(),this}};const v=Phaser.Math.RotateAround;var y;const x=Phaser.Geom.Rectangle;var w,m=function(t){void 0===w&&(w=new x);var e=t.drawTLX,i=t.drawTLY;return w.setTo(e,i,t.drawTRX-e,t.drawBLY-i),w};const b=Phaser.Math.RotateAround;var S,k=function(t,e,i,s){return void 0===s?s={}:!0===s&&(void 0===S&&(S={}),s=S),s.x=e,s.y=i,0!==t.rotation&&b(s,0,0,t.rotation),s.x=s.x*t.scaleX+t.drawX,s.y=s.y*t.scaleY+t.drawY,s};const C=Phaser.GameObjects.Components.TransformMatrix;var O,P,T={},X=function(t,e,i,s,r){var h=k(e,i,s,!0),a=function(t,e,i,s){void 0===s?s={}:!0===s&&(s=T);var r=e-t.width*t.originX,h=i-t.height*t.originY;return void 0===O&&(O=new C,P=new C),t.parentContainer?t.getWorldTransformMatrix(O,P):O.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),O.transformPoint(r,h,s),s}(t,h.x,h.y,r);return a},Y=function(t,e,i,s,r){"number"!=typeof i&&(r=i,i=0,s=0);var h=e.drawCenterX+i,a=e.drawCenterY+s;return X(t,e,h,a,r)},R={contains:function(t,e){if(0===this.width||0===this.height)return!1;var i=function(t,e,i,s){return void 0===s?s={}:!0===s&&(void 0===y&&(y={}),s=y),s.x=(t-i.drawX)/i.scaleX,s.y=(e-i.drawY)/i.scaleY,0!==i.rotation&&v(s,0,0,-i.rotation),s}(t,e,this,!0);return m(this).contains(i.x,i.y)},getWorldPosition:function(t,e,i){return Y(this.parent,this,t,e,i)}};Object.assign(R,p);const _=Phaser.Math.DegToRad,B=Phaser.Math.RadToDeg,W=Phaser.Utils.Objects.GetValue;class A extends f{constructor(t,e){super(t,e),this.renderable=!0,this.scrollFactorX=1,this.scrollFactorY=1,this.toLocalPosition=!0,this.originX=0,this.offsetX=0,this.offsetY=0}get visible(){return this._visible}set visible(t){this.setDirty(this._visible!=t),this._visible=t}setVisible(t){return void 0===t&&(t=!0),this.visible=t,this}get alpha(){return this._alpha}set alpha(t){this.setDirty(this._alpha!=t),this._alpha=t}setAlpha(t){return this.alpha=t,this}get x(){return this._x}set x(t){this.setDirty(this._x!=t),this._x=t}setX(t){return this.x=t,this}get y(){return this._y}set y(t){this.setDirty(this._y!=t),this._y=t}setY(t){return this.y=t,this}setPosition(t,e){return this.x=t,this.y=e,this}setInitialPosition(t,e){return this.x0=t,this.y0=e,this}setScrollFactorX(t){return this.scrollFactorX=t,this}setScrollFactorY(t){return this.scrollFactorY=t,this}setScrollFactor(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}get rotation(){return this._rotation}set rotation(t){this.setDirty(this._rotation!=t),this._rotation=t}setRotation(t){return this.rotation=t,this}get angle(){return B(this._rotation)}set angle(t){this.rotation=_(t)}setAngle(t){return this.angle=t,this}get scaleX(){return this._scaleX}set scaleX(t){this.setDirty(this._scaleX!==t),this._scaleX=t}setScaleX(t){return this.scaleX=t,this}get width(){return 0}set width(t){}setWidth(t,e){return void 0===e&&(e=!1),this.width=t,e&&(this.scaleY=this.scaleX),this}get leftSpace(){return this._leftSpace}set leftSpace(t){this.setDirty(this._leftSpace!==t),this._leftSpace=t}setLeftSpace(t){return this.leftSpace=t,this}get rightSpace(){return this._rightSpace}set rightSpace(t){this.setDirty(this._rightSpace!==t),this._rightSpace=t}setRightSpace(t){return this.rightSpace=t,this}get outerWidth(){return this.width+this.leftSpace+this.rightSpace}get scaleY(){return this._scaleY}set scaleY(t){this.setDirty(this._scaleY!==t),this._scaleY=t}setScaleY(t){return this.scaleY=t,this}get height(){return 0}set height(t){}setHeight(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}setScale(t,e){return void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this}setOrigin(t){return this.originX=t,this}setAlign(t){return this.align=t,this}modifyPorperties(t){if(!t)return this;t.hasOwnProperty("x")&&this.setX(t.x),t.hasOwnProperty("y")&&this.setY(t.y),t.hasOwnProperty("rotation")?this.setRotation(t.rotation):t.hasOwnProperty("angle")&&this.setAngle(t.angle),t.hasOwnProperty("alpha")&&this.setAlpha(t.alpha);var e=W(t,"width",void 0),i=W(t,"height",void 0),s=W(t,"scaleX",void 0),r=W(t,"scaleY",void 0);return void 0!==e?void 0===i&&void 0===r?this.setWidth(e,!0):this.setWidth(e):void 0!==s&&this.setScaleX(s),void 0!==i?void 0===e&&void 0===s?this.setHeight(i,!0):this.setHeight(i):void 0!==r&&this.setScaleY(r),t.hasOwnProperty("leftSpace")&&this.setLeftSpace(t.leftSpace),t.hasOwnProperty("rightSpace")&&this.setRightSpace(t.rightSpace),t.hasOwnProperty("align")&&this.setAlign(t.align),this}setDrawBelowCallback(t){return this.drawBelowCallback=t,this}setDrawAboveCallback(t){return this.drawAboveCallback=t,this}reset(){return this.setVisible().setAlpha(1).setPosition(0,0).setRotation(0).setScale(1,1).setLeftSpace(0).setRightSpace(0).setOrigin(0).setAlign().setDrawBelowCallback().setDrawAboveCallback(),this}get willRender(){return this.visible&&this.alpha>0}get drawX(){var t=this.x+this.leftSpace+this.offsetX-this.originX*this.width;return this.parent._textOX*this.scrollFactorX+t}get drawY(){var t=this.y+this.offsetY;return this.parent._textOY*this.scrollFactorY+t}get drawTLX(){return 0}get drawTLY(){return 0}get drawBLX(){return 0}get drawBLY(){return 0}get drawTRX(){return 0}get drawTRY(){return 0}get drawBRX(){return 0}get drawBRY(){return 0}get drawCenterX(){return(this.drawTRX+this.drawTLX)/2}get drawCenterY(){return(this.drawBLY+this.drawTLY)/2}}Object.assign(A.prototype,R);const D=Phaser.Utils.String.Pad;var M=function(t,e,i){if(null==t)return t;switch(typeof t){case"string":default:return t;case"number":return`#${D(Math.floor(t).toString(16),6,"0",1)}`;case"function":return t(e,i);case"object":return t.hasOwnProperty("r")?t.hasOwnProperty("a")?`rgba(${t.r},${t.g},${t.b},${t.a})`:`rgb(${t.r},${t.g},${t.b})`:t.hasOwnProperty("h")?t.hasOwnProperty("a")?`hsla(${t.h},${t.s},${t.l},${t.a})`:`hsl(${t.h},${t.s},${t.l})`:t}},L=function(t,e,i){return e.hasOwnProperty(t)?e[t]:i[t]};const H=Phaser.Utils.Objects.GetValue;class F{constructor(t,e,i,s,r){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,i,s,r)}setTo(t,e,i,s,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(i,s),this}setPosition(t,e){return this.x=t,this.y=e,this}setRadius(t){return void 0===t&&(t=0),this.radius=t,this}setSize(t,e){return this.width=t,this.height=e,this}get minWidth(){var t=this.cornerRadius;return Math.max(t.tl.x+t.tr.x,t.bl.x+t.br.x)}get minHeight(){var t=this.cornerRadius;return Math.max(t.tl.y+t.bl.y,t.tr.y+t.br.y)}get width(){return this._width}set width(t){null==t&&(t=0),this._width=Math.max(t,this.minWidth)}get height(){return this._height}set height(t){null==t&&(t=0),this._height=Math.max(t,this.minHeight)}get radius(){var t=this.cornerRadius;return Math.max(t.tl.x,t.tl.y,t.tr.x,t.tr.y,t.bl.x,t.bl.y,t.br.x,t.br.y)}set radius(t){var e,i;"number"==typeof t?(e=t,i=t):(e=H(t,"x",0),i=H(t,"y",0));var s=this.cornerRadius;s.tl=z(H(t,"tl",void 0),e,i),s.tr=z(H(t,"tr",void 0),e,i),s.bl=z(H(t,"bl",void 0),e,i),s.br=z(H(t,"br",void 0),e,i)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){j(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){j(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){j(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){j(this.cornerRadius.br,t)}}var z=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),I(t),t},j=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=H(e,"x",0),t.y=H(e,"y",0)),I(t)},I=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)};const G=Phaser.Math.DegToRad;var U=function(t){return!t.hasOwnProperty("convex")||t.convex},$=function(t){return t.x>0&&t.y>0},V=function(t,e,i,s,r,h,a,n,o){if(n&&a>h?a-=360:!n&&a<h&&(a+=360),h=G(h),a=G(a),null==o)t.ellipse(e,i,s,r,0,h,a,n);else for(var l,d,c,u=(a-h)/(o+=1),g=0;g<=o;g++)c=h+u*g,l=e+s*Math.cos(c),d=i+r*Math.sin(c),t.lineTo(l,d)},N=function(t,e,i,s,r,h,a,n,o,l,d,c,u){var g;(function(t,e,i,s,r,h,a){var n,o,l,d,c,u=new F(e,i,s,r,h),g=u.minWidth,f=u.minHeight,p=s>=g?1:s/g,v=r>=f?1:r/f,y=u.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),n=y.tl,$(n)?(o=n.x*p,l=n.y*v,U(n)?V(t,o,l,o,l,180,270,!1,a):V(t,0,0,o,l,90,0,!0,a),d=0,c=l):(t.lineTo(0,0),d=0,c=0),n=y.tr,$(n)?(o=n.x*p,l=n.y*v,U(n)?V(t,s-o,l,o,l,270,360,!1,a):V(t,s,0,o,l,180,90,!0,a)):t.lineTo(s,0),n=y.br,$(n)?(o=n.x*p,l=n.y*v,U(n)?V(t,s-o,r-l,o,l,0,90,!1,a):V(t,s,r,o,l,270,180,!0,a)):t.lineTo(s,r),n=y.bl,$(n)?(o=n.x*p,l=n.y*v,U(n)?V(t,o,r-l,o,l,90,180,!1,a):V(t,0,r,o,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(d,c),t.closePath(),t.restore()}(e,i,s,r,h,a,u),null!=n)&&(null!=d&&((g=c?e.createLinearGradient(0,0,r,0):e.createLinearGradient(0,0,0,h)).addColorStop(0,n),g.addColorStop(1,d),n=g),e.fillStyle=n,e.fill());null!=o&&l>0&&(e.strokeStyle=o,e.lineWidth=l,e.stroke())};const E=Phaser.Utils.Objects.GetValue;class q extends A{constructor(t,e){super(t,"background"),this.setScrollFactor(0),this.setColor(E(e,"color",null),E(e,"color2",null),E(e,"horizontalGradient",!0)),this.setStroke(E(e,"stroke",null),E(e,"strokeThickness",2)),this.setCornerRadius(E(e,"cornerRadius",0),E(e,"cornerIteration",null))}set color(t){t=M(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t}get color(){return this._color}set color2(t){t=M(t,this.canvas,this.context),this.setDirty(this._color2!=t),this._color2=t}get color2(){return this._color2}set horizontalGradient(t){this.setDirty(this._horizontalGradient!=t),this._horizontalGradient=t}get horizontalGradient(){return this._horizontalGradient}setColor(t,e,i){return void 0===i&&(i=!0),this.color=t,this.color2=e,this.horizontalGradient=i,this}set stroke(t){t=M(t,this.canvas,this.context),this.setDirty(this._stroke!=t),this._stroke=t}get stroke(){return this._stroke}set strokeThickness(t){this.setDirty(this._strokeThickness!=t),this._strokeThickness=t}get strokeThickness(){return this._strokeThickness}setStroke(t,e){return null!=t&&void 0===e&&(e=2),this.stroke=t,this.strokeThickness=e,this}set cornerRadius(t){this.setDirty(this._cornerRadius!=t),this._cornerRadius=t}get cornerRadius(){return this._cornerRadius}set cornerIteration(t){this.setDirty(this._cornerIteration!=t),this._cornerIteration=t}get cornerIteration(){return this._cornerIteration}modifyStyle(t){return t.hasOwnProperty("color")&&this.setColor(t.color,L("color2",t,this),L("horizontalGradient",t,this)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,L("strokeThickness",t,this)),t.hasOwnProperty("cornerRadius")&&this.setCornerRadius(t.cornerRadius,L("cornerIteration",t,this)),this}modifyPorperties(t){return super.modifyPorperties(t),this.modifyStyle(t),this}setCornerRadius(t,e){return this.cornerRadius=t,this.cornerIteration=e,this}renderContent(){!function(t,e,i,s,r,h,a,n){if(null!=e||null!=i){var o=t.canvas.width,l=t.canvas.height;null==i&&(s=0);var d=s/2;o=Math.max(1,o-s),l=Math.max(1,l-s),N(t.canvas,t.context,d,d,o,l,r,e,i,s,h,a,n)}}(this.parent,this.color,this.stroke,this.strokeThickness,this.cornerRadius,this.color2,this.horizontalGradient,this.cornerIteration)}}const J=Phaser.Utils.Objects.GetValue;class K extends A{constructor(t,e){super(t,"innerbounds"),this.setScrollFactor(0),this.setColor(J(e,"color",null),J(e,"color2",null),J(e,"horizontalGradient",!0)),this.setStroke(J(e,"stroke",null),J(e,"strokeThickness",2))}set color(t){t=M(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t}get color(){return this._color}set color2(t){t=M(t,this.canvas,this.context),this.setDirty(this._color2!=t),this._color2=t}get color2(){return this._color2}set horizontalGradient(t){this.setDirty(this._horizontalGradient!=t),this._horizontalGradient=t}get horizontalGradient(){return this._horizontalGradient}setColor(t,e,i){return void 0===i&&(i=!0),this.color=t,this.color2=e,this.horizontalGradient=i,this}set stroke(t){t=M(t,this.canvas,this.context),this.setDirty(this._stroke!=t),this._stroke=t}get stroke(){return this._stroke}set strokeThickness(t){this.setDirty(this._strokeThickness!=t),this._strokeThickness=t}get strokeThickness(){return this._strokeThickness}setStroke(t,e){return null!=t&&void 0===e&&(e=2),this.stroke=t,this.strokeThickness=e,this}modifyPorperties(t){super.modifyPorperties(t),t.hasOwnProperty("color")&&this.setColor(t.color,J(t,"color2",null),J(t,"horizontalGradient",!0)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,J(t,"strokeThickness",2))}renderContent(){var t,e,i=this.parent.padding,s=i.left,r=i.top,h=this.parent.width-i.left-i.right,a=this.parent.height-i.top-i.bottom,n=this.context;null!=this.color&&(null!=this.color2?((e=this.horizontalGradient?n.createLinearGradient(0,0,h,0):n.createLinearGradient(0,0,0,a)).addColorStop(0,this.color),e.addColorStop(1,this.color2),t=e):t=this.color,n.fillStyle=t,n.fillRect(s,r,h,a));null!=this.stroke&&this.strokeThickness>0&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeThickness,n.strokeRect(s,r,h,a))}}const Q=Phaser.Utils.Objects.GetValue;class Z{constructor(t,e){this.parent=t,this.set(e)}toJSON(){return{bold:this.bold,italic:this.italic,fontSize:this.fontSize,fontFamily:this.fontFamily,color:this.color,stroke:this.stroke,strokeThickness:this.strokeThickness,shaodwColor:this.shadowColor,shadowBlur:this.shadowBlur,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,offsetX:this.offsetX,offsetY:this.offsetY,leftSpace:this.leftSpace,rightSpace:this.rightSpace,backgroundHeight:this.backgroundHeight,backgroundBottomY:this.backgroundBottomY,align:this.align}}set(t){return this.setBold(Q(t,"bold",!1)),this.setItalic(Q(t,"italic",!1)),this.setFontSize(Q(t,"fontSize","16px")),this.setFontFamily(Q(t,"fontFamily","Courier")),this.setColor(Q(t,"color","#fff")),this.setStrokeStyle(Q(t,"stroke",null),Q(t,"strokeThickness",0)),this.setShadow(Q(t,"shadowColor",null),Q(t,"shadowOffsetX",0),Q(t,"shadowOffsetY",0),Q(t,"shadowBlur",0)),this.setOffset(Q(t,"offsetX",0),Q(t,"offsetY",0)),this.setSpace(Q(t,"leftSpace",0),Q(t,"rightSpace",0)),this.setAlign(Q(t,"align",void 0)),this.setBackgroundColor(Q(t,"backgroundColor",null)),this.setBackgroundHeight(Q(t,"backgroundHeight",void 0)),this.setBackgroundBottomY(Q(t,"backgroundBottomY",void 0)),this.setBackgroundLeftX(Q(t,"backgroundLeftX",0)),this.setBackgroundRightX(Q(t,"backgroundRightX",0)),this}modify(t){return t.hasOwnProperty("bold")&&this.setBold(t.bold),t.hasOwnProperty("italic")&&this.setItalic(t.italic),t.hasOwnProperty("fontSize")&&this.setFontSize(t.fontSize),t.hasOwnProperty("fontFamily")&&this.setFontFamily(t.fontFamily),t.hasOwnProperty("color")&&this.setColor(t.color),(t.hasOwnProperty("stroke")||t.hasOwnProperty("strokeThickness"))&&this.setStrokeStyle(L("stroke",t,this),L("strokeThickness",t,this)),t.hasOwnProperty("shadowColor")&&this.setShadowColor(t.shadowColor),(t.hasOwnProperty("shadowOffsetX")||t.hasOwnProperty("shadowOffsetY"))&&this.setShadowOffset(L("shadowOffsetX",t,this),L("shadowOffsetY",t,this)),t.hasOwnProperty("shadowBlur")&&this.setShadowBlur(t.shaodwBlur),t.hasOwnProperty("offsetX")&&this.setOffsetX(t.offsetX),t.hasOwnProperty("offsetY")&&this.setOffsetY(t.offsetY),t.hasOwnProperty("leftSpace")&&this.setLeftSpace(t.leftSpace),t.hasOwnProperty("rightSpace")&&this.setRightSpace(t.rightSpace),t.hasOwnProperty("align")&&this.setAlign(t.align),t.hasOwnProperty("backgroundColor")&&this.setBackgroundColor(t.backgroundColor),t.hasOwnProperty("backgroundHeight")&&this.setBackgroundHeight(t.backgroundHeight),t.hasOwnProperty("backgroundBottomY")&&this.setBackgroundBottomY(t.backgroundBottomY),t.hasOwnProperty("backgroundLeftX")&&this.setBackgroundLeftX(t.backgroundLeftX),t.hasOwnProperty("backgroundRightX")&&this.setBackgroundRightX(t.backgroundRightX),this}setUpdateTextFlag(){return this.parent&&(this.parent.updateTextFlag=!0),this}clone(){return new Z(null,this.toJSON())}copyFrom(t){return this.set(t.toJSON()),this}copyTo(t){return t.set(this.toJSON()),this}setBold(t){return void 0===t&&(t=!0),this.bold=t,this.setUpdateTextFlag(),this}setItalic(t){return void 0===t&&(t=!0),this.italic=t,this.setUpdateTextFlag(),this}get fontStyle(){return this.bold&&this.italic?"bold italic":this.bold?"bold":this.italic?"italic":""}setFontSize(t){return"number"==typeof t&&(t=`${t}px`),this.fontSize=t,this.setUpdateTextFlag(),this}setFontFamily(t){return this.fontFamily=t,this.setUpdateTextFlag(),this}get font(){return`${this.fontStyle} ${this.fontSize} ${this.fontFamily}`}setColor(t){return this.color=M(t),this}get hasFill(){return null!=this.color}setStrokeStyle(t,e){return this.stroke=M(t),void 0!==e&&(this.strokeThickness=e),this}setStrokeThickness(t){return this.strokeThickness=t,this}get hasStroke(){return null!=this.stroke&&this.strokeThickness>0}setShadowColor(t){return this.shadowColor=M(t),this}setShadowOffset(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.shadowOffsetX=t,this.shadowOffsetY=e,this}setShadowBlur(t){return void 0===t&&(t=0),this.shaodwBlur=t,this}setShadow(t,e,i,s){return this.setShadowColor(t).setShadowOffset(e,i).setShadowBlur(s),this}setBackgroundColor(t){return this.backgroundColor=M(t),this}get hasBackgroundColor(){return null!=this.backgroundColor}setBackgroundHeight(t){return this.backgroundHeight=t,this}setBackgroundBottomY(t){return this.backgroundBottomY=t,this}setBackgroundLeftX(t){return this.backgroundLeftX=t,this}setBackgroundRightX(t){return this.backgroundRightX=t,this}setOffsetX(t){return void 0===t&&(t=0),this.offsetX=t,this}setOffsetY(t){return void 0===t&&(t=0),this.offsetY=t,this}setOffset(t,e){return this.setOffsetX(t).setOffsetY(e),this}setLeftSpace(t){return void 0===t&&(t=0),this.leftSpace=t,this}setRightSpace(t){return void 0===t&&(t=0),this.rightSpace=t,this}setSpace(t,e){return this.setLeftSpace(t).setRightSpace(e),this}setAlign(t){return this.align=t,this}syncFont(t){return t.font=this.font,this}syncStyle(t){t.textBaseline="alphabetic";var e=this.hasFill,i=this.hasStroke;return t.fillStyle=e?this.color:"#000",t.strokeStyle=i?this.stroke:"#000",t.lineWidth=i?this.strokeThickness:0,t.lineCap="round",t.lineJoin="round",this}syncShadow(t){null!=t.shadowColor?(t.shadowColor=this.shadowColor,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowBlur=this.shadowBlur):(t.shadowColor=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0)}getTextMetrics(t,e){return this.syncFont(t).syncStyle(t),t.measureText(e)}}const tt=Phaser.Utils.Array.Remove,et=Phaser.Utils.Array.Remove,it="text",st="image",rt="drawer",ht="space",at="command";var nt=function(t){return t.type===it&&"\n"===t.text},ot=function(t){return t.type===it&&"\f"===t.text},lt=function(t){return t.type===it};class dt extends A{constructor(t,e,i){super(t,it),this.updateTextFlag=!1,this.style=new Z(this,i),this.setText(e)}get autoRound(){return this.parent.autoRound}get offsetX(){return this.style.offsetX}set offsetX(t){this.style&&(this.style.offsetX=t)}get offsetY(){return this.style.offsetY}set offsetY(t){this.style&&(this.style.offsetY=t)}get leftSpace(){return this.style.leftSpace*this.scaleX}set leftSpace(t){this.style&&(this.style.leftSpace=t),super.leftSpace=t}get rightSpace(){return this.style.rightSpace*this.scaleX}set rightSpace(t){this.style&&(this.style.rightSpace=t),super.rightSpace=t}get align(){return this.style.align}set align(t){this.style&&(this.style.align=t)}modifyStyle(t){return this.setDirty(!0),this.style.modify(t),this.updateTextFlag&&this.updateTextSize(),this}modifyPorperties(t){return t?(this.modifyStyle(t),super.modifyPorperties(t),this):this}setText(t){return this.setDirty(this.text!=t),this.text=t,this.updateTextSize(),this}updateTextSize(){var t=this.text;if("\n"===t||"\f"===t||""===t)this.clearTextSize();else{var e,i,s=this.style.getTextMetrics(this.context,this.text);this.textWidth=s.width,"actualBoundingBoxAscent"in s?(e=s.actualBoundingBoxAscent,i=s.actualBoundingBoxDescent):(e=0,i=0),this.textHeight=e+i,this.ascent=e,this.descent=i}return this.updateTextFlag=!1,this}clearTextSize(){return this.textWidth=0,this.textHeight=0,this.ascent=0,this.descent=0,this}copyTextSize(t){return this.textWidth=t.textWidth,this.textHeight=t.textHeight,this.ascent=t.ascent,this.descent=t.descent,this}get width(){return this.textWidth*this.scaleX}set width(t){this.textWidth>0?this.scaleX=t/this.textWidth:this.scaleX=1}get height(){return this.textHeight*this.scaleY}set height(t){this.textHeight>0?this.scaleY=t/this.textHeight:this.scaleY=1}get willRender(){return 0!==this.textWidth&&super.willRender}renderContent(){var t=this.context,e=this.style;if(e.hasBackgroundColor){t.fillStyle=e.backgroundColor;var i=this.drawTLX+e.backgroundLeftX,s=i,r=this.drawTRX+e.backgroundRightX-i+1;if(r>0){var h=e.backgroundBottomY;null==h&&(h=this.drawBLY);var a=e.backgroundHeight;null==a&&(a=h-this.drawTLY);var n=h-a;t.fillRect(s,n,r,a)}}var o=e.hasFill,l=e.hasStroke;(o||l)&&(e.syncFont(t).syncStyle(t),l&&(e.syncShadow(t),t.strokeText(this.text,0,0)),o&&(e.syncShadow(t),t.fillText(this.text,0,0)))}get drawTLX(){return-this.leftSpace}get drawTLY(){return-this.ascent}get drawBLX(){return-this.leftSpace}get drawBLY(){return this.descent}get drawTRX(){return this.textWidth+this.rightSpace}get drawTRY(){return-this.ascent}get drawBRX(){return this.textWidth+this.rightSpace}get drawBRY(){return this.descent}}var ct=function(t,e){var i=this.createCharChildren(t,e);return this.addChild(i),this};const ut=Phaser.Display.Canvas.CanvasPool;Phaser.Display.Canvas.CanvasPool;class gt extends A{constructor(t,e,i){super(t,st),this.setTexture(e,i),this.color=void 0}get frameWidth(){return this.frameObj?this.frameObj.cutWidth:0}get frameHeight(){return this.frameObj?this.frameObj.cutHeight:0}get offsetY(){return-this.height}set offsetY(t){}get key(){return this._key}set key(t){this.setDirty(this._key!=t),this._key=t}get frame(){return this._frame}set frame(t){this.setDirty(this._frame!=t),this._frame=t}setTexture(t,e){return this.key=t,this.frame=e,this.frameObj=this.scene.sys.textures.getFrame(t,e),this}get width(){return this.frameWidth*this.scaleX}set width(t){this.setDirty(this.width!==t),this.scaleX=t/this.frameWidth}get height(){return this.frameHeight*this.scaleY}set height(t){this.setDirty(this.height!==t),this.scaleY=t/this.frameHeight}setHeight(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}setColor(t){return this.color=t,this}modifyPorperties(t){return t.hasOwnProperty("color")&&this.setColor(t.color),super.modifyPorperties(t),this}renderContent(){!function(t,e,i,s,r,h,a,n){void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=t.cutWidth),void 0===h&&(h=t.cutHeight),void 0===n&&(n=!1),n&&(i=Math.round(i),s=Math.round(s));var o=e.getContext("2d",{willReadFrequently:!0});if(a){var l=ut.create(null,r,h,Phaser.CANVAS,!0),d=l.getContext("2d",{willReadFrequently:!0});d.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,0,0,r,h),d.globalCompositeOperation="source-in",d.fillStyle=a,d.fillRect(0,0,r,h),o.drawImage(l,0,0,r,h,i,s,r,h),ut.remove(l)}else o.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,i,s,r,h)}(this.frameObj,this.canvas,0,0,this.frameWidth,this.frameHeight,this.color,!1)}get drawTLX(){return-this.leftSpace}get drawTLY(){return 0}get drawBLX(){return-this.leftSpace}get drawBLY(){return this.frameHeight}get drawTRX(){return this.frameWidth+this.rightSpace}get drawTRY(){return 0}get drawBRX(){return this.frameWidth+this.rightSpace}get drawBRY(){return this.frameHeight}}class ft extends A{constructor(t,e,i,s){super(t,rt),this.setRenderCallback(e),this.setDrawerSize(i,s)}setRenderCallback(t){return t?this.renderContent=t.bind(this):delete this.renderContent,this}setDrawerSize(t,e){return!0===t?(this.toLocalPosition=!1,t=void 0,e=void 0):this.toLocalPosition=!0,void 0===t&&(t=0),void 0===e&&(e=t),this.drawerWidth=t,this.drawerHeight=e,this}onFree(){super.onFree(),this.setRenderCallback()}get width(){return this.drawerWidth*this.scaleX}set width(t){this.setDirty(this.width!==t),this.scaleX=this.drawerWidth>0?t/this.drawerWidth:1}get height(){return this.drawerHeight*this.scaleY}set height(t){this.setDirty(this.height!==t),this.scaleY=this.drawerHeight>0?t/this.drawerHeight:1}get offsetY(){return-this.height}set offsetY(t){}get drawTLX(){return-this.leftSpace}get drawTLY(){return 0}get drawBLX(){return-this.leftSpace}get drawBLY(){return this.drawerHeight}get drawTRX(){return this.drawerWidth+this.rightSpace}get drawTRY(){return 0}get drawBRX(){return this.drawerWidth+this.rightSpace}get drawBRY(){return this.drawerHeight}}class pt extends A{constructor(t,e){super(t,ht),this.setSpaceWidth(e)}get width(){return this.spaceWidth*this.scaleX}set width(t){this.spaceWidth>0?this.scaleX=t/this.spaceWidth:this.scaleX=1}setSpaceWidth(t){return this.spaceWidth=t,this}}class vt extends f{constructor(t,e,i,s,r){super(t,at),this.setName(e).setParameter(s).setCallback(i,r)}setName(t){return this.name=t,this}setParameter(t){return this.param=t,this}setCallback(t,e){return this.callback=t,this.scope=e,this}exec(){return this.scope?this.callback.call(this.scope,this.param,this.name):this.callback(this.param,this.name)}onFree(){super.onFree(),this.setName().setCallback().setParameter()}}function yt(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>yt(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let i in t)t.hasOwnProperty(i)&&(e[i]=yt(t[i]));return e}var xt=function(t){var e={callback:void 0,start:0,isLastPage:!1,maxLines:void 0,padding:void 0,letterSpacing:void 0,hAlign:void 0,vAlign:void 0,children:[],lines:[],maxLineWidth:0,linesHeight:0,lineHeight:void 0,maxLineHeight:0,linesWidth:0,lineWidth:void 0};return Object.assign(e,t)};const wt={none:0,word:1,char:2,character:2,mix:3};var mt=/^[\x00-\x7F]+$/,bt=function(t,e,i,s){void 0===s&&(s={word:[],width:0}),s.word.length=0;for(var r,h=2===i,a=3===i,n=!h&&!a,o=t.length,l=e,d=s.word,c=0,u=!1;l<o;){var g=t[l];if(g.renderable){var f=g.type===it?g.text:null;if(null===f||"\n"===f||"\f"===f){l===e&&(d.push(g),c+=g.outerWidth);break}if(n){if(d.push(g),c+=g.outerWidth," "===f)break;l++}else{if(h){d.push(g),c+=g.outerWidth;break}if(a){if(r=f,!mt.test(r)){if(u)break;d.push(g),c+=g.outerWidth;var p=t[l+1];p&&p.type===it&&" "===p.text&&(d.push(p),c+=p.outerWidth);break}if(d.push(g),c+=g.outerWidth," "===f)break;l++,u=!0}}}else d.push(g),l++}return s.width=c,s},St=function(t){for(var e=0,i=t.length;e<i;e++){var s=t[e];if(void 0!==s.align)return s.align}},kt=function(t,e,i){if(0!==e||0!==i)for(var s=0,r=t.length;s<r;s++){var h=t[s];h.renderable&&(h.x+=e,h.y+=i)}},Ct=function(t,e){for(var i=e/t.length,s=0,r=t.length;s<r;s++){var h=t[s];h.renderable&&(h.x+=i*s)}},Ot=function(){var t,e,i=this.defaultTextStyle.getTextMetrics(this.context,this.testString);return"actualBoundingBoxAscent"in i?(t=i.actualBoundingBoxAscent,e=i.actualBoundingBoxDescent):(t=0,e=0),Pt.ascent=t,Pt.descent=e,Pt.height=t+e,Pt},Pt={};const Tt=Phaser.Utils.Objects.GetValue;var Xt=function(t){var e=Tt(t,"start",0);u(this.wrapPadding,Tt(t,"padding",0));var i,s=this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom,r=this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,h=Tt(t,"lineHeight"),a=Tt(t,"ascent",h);if(void 0===h){var n=Tt(t,"useDefaultTextHeight",!1);if(i=Tt(t,"maxLines",0),this.fixedHeight>0&&!n){var o=this.fixedHeight-s;i>0?h=o/i:(h=(l=Ot.call(this)).height,a=l.ascent,i=Math.floor((o-a)/h))}else{var l;h=(l=Ot.call(this)).height,a=l.ascent}}else this.fixedHeight>0?void 0===(i=Tt(t,"maxLines"))&&(o=this.fixedHeight-s,i=Math.floor(o/h)):i=Tt(t,"maxLines",0);void 0===a&&(a=h);var d=0===i,c=Tt(t,"wrapMode");void 0===c&&(c=Tt(t,"charWrap",!1)?"char":"word"),"string"==typeof c&&(c=wt[c]);var g=Tt(t,"wrapWidth",void 0);void 0===g&&(this.fixedWidth>0?g=this.fixedWidth-r:(g=1/0,c=0));for(var f=Tt(t,"letterSpacing",0),p=Tt(t,"hAlign",0),v=Tt(t,"vAlign",0),y=Tt(t,"justifyPercentage",.25),x=xt({callback:"runWordWrap",start:e,padding:this.wrapPadding,letterSpacing:f,maxLines:i,hAlign:p,vAlign:v,justifyPercentage:y,ascent:a,lineHeight:h,wrapWidth:g,wrapMode:c}),w=this.children,m=0,b=w.length;m<b;m++)w[m].setActive(!1);g+=f;for(var S,k=this.padding.left+this.wrapPadding.left,C=k,O=this.padding.top+this.wrapPadding.top+a,P=g,T=e,X=w.length,Y=x.children,R=x.lines,_=[],B=0,W=0,A=!1;T<X;){var D=(S=bt(w,T,c,S)).word,M=D.length,L=S.width+M*f;T+=M;var H=nt(D[0]);A=ot(D[0]);var F=H||A;if(P<L||F){if(F){var z=D[0];z.setActive().setPosition(C,O),Y.push(z),_.push(z)}if(C=k,O+=h,P=g,R.push({children:_,width:B}),W=Math.max(W,B),B=0,_=[],A||!d&&R.length===i)break;if(F)continue}for(P-=L,B+=L,m=0,b=D.length;m<b;m++)(G=D[m]).setActive(),Y.push(G),_.push(G),G.renderable&&(G.setPosition(C,O),C+=G.outerWidth+f)}_.length>0&&(R.push({children:_,width:B}),W=Math.max(W,B)),x.start+=Y.length,x.isLastPage=!A&&x.start===X,x.maxLineWidth=W,x.linesHeight=R.length*h;var j=this.fixedWidth>0?this.fixedWidth:x.maxLineWidth+r,I=this.fixedHeight>0?this.fixedHeight:x.linesHeight+s;for(function(t,e,i){for(var s,r,h=t.hAlign,a=t.vAlign,n=t.justifyPercentage,o=t.lines,l=0,d=o.length;l<d;l++){var c=o[l],u=c.width,g=c.children,f=St(g);switch(void 0===f&&(f=h),f){case 0:case"left":default:s=0;break;case 1:case"center":s=(p=e-u)/2;break;case 2:case"right":s=p=e-u;break;case 3:case"justify":case"justify-left":(p=e-u)/e<n?(Ct(g,p),s=0):s=0;break;case 4:case"justify-center":(p=e-u)/e<n?(Ct(g,p),s=0):s=p/2;break;case 5:case"justify-right":var p;(p=e-u)/e<n?(Ct(g,p),s=0):s=p}var v=t.linesHeight;switch(a){case 1:case"center":r=(i-v)/2;break;case 2:case"bottom":r=i-v;break;default:r=0}kt(g,s,r)}}(x,j-r,o=I-s),this.setCanvasSize(j,I),m=0,b=Y.length;m<b;m++){var G;(G=Y[m]).renderable&&(G.x0=G.x,G.y0=G.y)}return x};const Yt=Phaser.Utils.Objects.Merge,Rt=Phaser.Utils.Objects.GetValue;var _t=function(t){var e=Rt(t,"start",0);u(this.wrapPadding,Rt(t,"padding",0));var i,s=this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom,r=this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,h=Rt(t,"lineWidth",void 0);if(void 0===h)i=Rt(t,"maxLines",0),h=this.fixedWidth>0?(a=this.fixedWidth-r)/i:0;else if(this.fixedWidth>0){if(void 0===(i=Rt(t,"maxLines",void 0))){var a=this.fixedWidth-r;i=Math.floor(a/h)+1}}else i=Rt(t,"maxLines",0);var n=0===i,o=Rt(t,"fixedCharacterHeight",void 0);if(void 0===o){var l=Rt(t,"charPerLine",void 0);if(void 0!==l){var d=this.fixedHeight-s;o=Math.floor(d/l)}}var c=Rt(t,"wrapHeight",void 0);void 0===c&&(c=this.fixedHeight>0?this.fixedHeight-s:1/0);for(var g=Rt(t,"letterSpacing",0),f=Rt(t,"rtl",!0),p=Rt(t,"hAlign",f?2:0),v=Rt(t,"vAlign",0),y=xt({callback:"runVerticalWrap",start:e,padding:this.wrapPadding,letterSpacing:g,maxLines:i,hAlign:p,vAlign:v,lineWidth:h,fixedCharacterHeight:o,wrapHeight:c,rtl:f}),x=this.children,w=0,m=x.length;w<m;w++)x[w].setActive(!1);c+=g;for(var b=this.padding.left+this.wrapPadding.left,S=this.padding.top+this.wrapPadding.top,k=b,C=S,O=c,P=e,T=x.length,X=y.children,Y=y.lines,R=[],_=0,B=0;P<T;){var W=x[P];if(P++,W.renderable){var A=(void 0!==o?o:W.height)+g,D=nt(W),M=ot(W),L=D||M;if(O<A||L){if(D&&(W.setActive().setPosition(k,C).setOrigin(.5),X.push(W),R.push(W)),k=b,C=S,O=c,Y.push({children:R,height:_}),B=Math.max(B,_),_=0,R=[],M||!n&&Y.length===i)break;if(L)continue}O-=A,_+=A,W.setActive().setPosition(k,C).setOrigin(.5),X.push(W),R.push(W),C+=A}else W.setActive(),X.push(W),R.push(W)}R.length>0&&(Y.push({children:R,height:_}),B=Math.max(B,_)),y.start+=X.length,y.isLastPage=y.start===T,y.maxLineHeight=B,y.linesWidth=Y.length*h;var H=this.fixedWidth>0?this.fixedWidth:y.linesWidth+r,F=this.fixedHeight>0?this.fixedHeight:y.maxLineHeight+s;for(function(t,e,i){var s,r,h=t.hAlign,a=t.vAlign,n=t.rtl,o=t.lines,l=t.lineWidth,d=t.linesWidth;switch(h){case 1:case"center":s=(e-d)/2;break;case 2:case"right":s=e-d;break;default:s=0}n&&(s+=l);for(var c=0,u=o.length;c<u;c++){var g=o[n?u-c-1:c],f=g.children,p=g.height,v=St(f);switch(void 0===v&&(v=a),v){case 1:case"center":r=(i-p)/2;break;case 2:case"bottom":r=i-p;break;default:r=0}kt(f,s,r),s+=l}}(y,a=H-r,d=F-s),this.setCanvasSize(H,F),w=0,m=X.length;w<m;w++)(W=X[w]).renderable&&(W.x0=W.x,W.y0=W.y);return y};const Bt=Phaser.Utils.Objects.Merge,Wt=Phaser.Utils.Objects.GetValue;var At={setVAlign(t){return this.wrapConfig.vAlign=t,this},setHAlign(t){return this.wrapConfig.hAlign=t,this}},Dt={setTextOX(t){return t===this._textOX||(this._textOX=t),this},setTextOY(t){return t===this._textOY||(this._textOY=t),this},setTextOXY(t,e){if(t!==this._textOX||e!==this._textOY)return this._textOX=t,this._textOY=e,this},addTextOX(t){return this.setTextOX(this._textOX+t),this},addTextOY(t){return this.setTextOY(this._textOY+t),this},addTextOXY(t,e){return this.setTextOXY(this._textOX+t,this._textOY+e),this}};const Mt=Phaser.Utils.Array.GetAll,Lt=Phaser.Math.Distance.BetweenPointsSquared;var Ht=function(t,e,i){for(var s=0,r=t.length;s<r;s++){var h=t[s];if(h.active&&h.renderable&&h.contains(e,i))return h}return null},Ft=function(){return this.on("pointerdown",zt,this).on("pointerdown",jt,this).on("pointermove",It,this).on("pointerover",It,this).on("pointerout",(function(t,e){It.call(this,t,null,null,e)}),this),this},zt=function(t,e,i,s){if(this.childrenInteractiveEnable){var r=Ht(this.children,e,i);r&&this.emit("child.pointerdown",r,t,e,i,s)}},jt=function(t,e,i,s){if(this.childrenInteractiveEnable){var r=Ht(this.children,e,i);r&&this.emit("child.pointerup",r,t,e,i,s)}},It=function(t,e,i,s){if(this.childrenInteractiveEnable)if(null!==e){var r=Ht(this.children,e,i);r!==this.lastOverChild&&(null!==this.lastOverChild&&this.emit("child.pointerout",this.lastOverChild,t,e,i,s),null!==r&&this.emit("child.pointerover",r,t,e,i,s),this.lastOverChild=r)}else null!==this.lastOverChild&&(this.emit("child.pointerout",this.lastOverChild,t,e,i,s),this.lastOverChild=null)};const Gt=Phaser.GameObjects.GameObject,Ut=Phaser.Utils.Array.BringToTop,$t=Phaser.Utils.Array.SendToBack,Vt=Phaser.Utils.Array.MoveUp,Nt=Phaser.Utils.Array.MoveDown,Et=Phaser.Utils.Array.MoveAbove,qt=Phaser.Utils.Array.MoveBelow;var Jt={moveChildToFist(t){return $t(this.children,t),this},moveChildToLast(t){return Ut(this.children,t),this},movechildUp(t){return Vt(this.children,t),this},movechildDown(t){return Nt(this.children,t),this},movechildAbove(t,e){return Et(this.children,t,e),this},movechildBelow(t,e){return qt(this.children,t,e),this}},Kt={setBackgroundColor(t,e,i){return this.background.setColor(t,e,i),this},setBackgroundStroke(t,e){return this.background.setStroke(t,e),this},setBackgroundCornerRadius(t,e){return this.background.setCornerRadius(t,e),this}},Qt={setInnerBoundsColor(t,e,i){return this.innerBounds.setColor(t,e,i),this},setInnerBoundsStroke(t,e){return this.innerBounds.setStroke(t,e),this}},Zt={setFixedSize:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fixedWidth===t&&this.fixedHeight===e||(this.fixedWidth=t,this.fixedHeight=e,this.dirty=!0,this.setCanvasSize(t>0?t:this.width,e>0?e:this.height)),this},setPadding:function(t,e){var i=this.padding,s=i.left,r=i.right,h=i.top,a=i.bottom;return u(i,t,e),this.dirty=this.dirty||s!=i.left||r!=i.right||h!=i.top||a!=i.bottom,this},getPadding:function(t){return function(t,e){return void 0===e?t:t[e]}(this.padding,t)},modifyTextStyle:function(t){return this.textStyle.modify(t),this},modifyDefaultTextStyle:function(t){return this.defaultTextStyle.modify(t),this},resetTextStyle:function(){return this.textStyle.copyFrom(this.defaultTextStyle),this},setTestString:function(t){return this.testString=t,this},removeChild:function(t){return this.poolManager.free(t),tt(this.children,t),this.lastAppendedChildren.length=0,this.lastOverChild=null,this.dirty=!0,this},removeChildren:function(){return this.poolManager.freeMultiple(this.children),this.children.length=0,this.lastAppendedChildren.length=0,this.lastOverChild=null,this.dirty=!0,this},popChild:function(t){return et(this.children,t),this.lastAppendedChildren.length=0,this.lastOverChild=null,this.dirty=!0,this},clearContent:function(){return this.setText(),this},addChild:function(t,e){var i=Array.isArray(t);return void 0===e||e===this.children.length?i?this.children.push(...t):this.children.push(t):i?this.children.splice(e,0,...t):this.children.splice(e,0,t),this.lastAppendedChildren.length=0,i?this.lastAppendedChildren.push(...t):this.lastAppendedChildren.push(t),this},createCharChild:function(t,e){e&&this.textStyle.modify(e);var i=this.poolManager.allocate(it);return null===i?i=new dt(this,t,this.textStyle):i.setParent(this).setActive().modifyStyle(this.textStyle).setText(t),i},createCharChildren:function(t,e){e&&this.textStyle.modify(e);for(var i=[],s=0,r=t.length;s<r;s++){var h=t.charAt(s),a=this.poolManager.allocate(it);null===a?a=new dt(this,h,this.textStyle):a.setParent(this).setActive().modifyStyle(this.textStyle).setText(h),i.push(a)}return i},setText:function(t,e){return void 0===t&&(t=""),this.removeChildren(),ct.call(this,t,e),this.dirty=!0,this},appendText:ct,insertText:function(t,e,i){var s=this.createCharChildren(e,i);return t=this.getCharChildIndex(t,!0),this.addChild(s,t),this},removeText:function(t,e){void 0===e&&(e=1);for(var i=0;i<e;i++){var s=this.getCharChildIndex(t,!0);if(void 0===s)break;this.removeChild(this.children[s])}return this},getText:function(t){var e="";return this.forEachCharChild((function(t){e+=t.text}),void 0,t),e},createImageChild:function(t,e,i){var s=this.poolManager.allocate(st);return null===s?s=new gt(this,t,e):s.setParent(this).setActive().setTexture(t,e),s.modifyPorperties(i),s},appendImage:function(t,e,i){var s=this.createImageChild(t,e,i);return this.addChild(s),this},createDrawerChild:function(t,e,i){var s=this.poolManager.allocate(rt);return null===s?s=new ft(this,t,e,i):s.setParent(this).setActive().setRenderCallback(t).setDrawerSize(e,i),s},appendDrawer:function(t,e,i){var s=this.createDrawerChild(t,e,i);return this.addChild(s),this},createSpaceChild:function(t){var e=this.poolManager.allocate(ht);return null===e?e=new pt(this,t):e.setParent(this).setActive().setSpaceWidth(t),e},appendSpace:function(t){var e=this.createSpaceChild(t);return this.addChild(e),this},createCommandChild:function(t,e,i,s){var r=this.poolManager.allocate(at);return null===r?r=new vt(this,t,e,i,s):r.setParent(this).setActive().setName(t).setCallback(e,s).setParameter(i),r},appendCommand:function(t,e,i,s){var r=this.createCommandChild(t,e,i,s);return this.addChild(r),this},setWrapConfig:function(t){return void 0===t?t={}:"object"==typeof t&&(t=yt(t)),this.wrapConfig=t,this},runWordWrap:function(t){return void 0===t&&(t={}),Xt.call(this,Yt(t,this.wrapConfig))},runVerticalWrap:function(t){return void 0===t&&(t={}),_t.call(this,Bt(t,this.wrapConfig))},runWrap:function(t){var e=Wt(this.wrapConfig,"callback");return e||(e=Wt(t,"callback",this.runWordWrap)),"string"==typeof e&&(e=this[e]),e.call(this,t)},renderContent:function(){var t;this.clear(),this.setCanvasSize(this.width,this.height),this.background.active&&this.background.render();for(var e=0,i=this.children.length;e<i;e++)(t=this.children[e]).active&&t.render();this.innerBounds.active&&this.innerBounds.render()},forEachChild:function(t,e,i){void 0===i&&(i=!0);for(var s=this.children.filter((function(t){return!(i&&!t.active)})),r=0,h=s.length;r<h;r++){var a=s[r];if(e?t.call(this,a,r,s):t(a,r,s))break}return this},forEachRenderableChild:function(t,e,i){void 0===i&&(i=!0);for(var s=this.children.filter((function(t){return!(i&&!t.active||!t.renderable||t.removed)})),r=0,h=s.length;r<h;r++){var a=s[r];if(e?t.call(this,a,r,s):t(a,r,s))break}return this},forEachCharChild:function(t,e,i){void 0===i&&(i=!0);for(var s=this.children.filter((function(t){return!(i&&!t.active||!lt(t)||t.removed)})),r=0,h=s.length;r<h;r++){var a=s[r];if(e?t.call(this,a,r,s):t(a,r,s))break}return this},getChildren:function(){return this.children},getActiveChildren:function(){return Mt(this.children,"active",!0)},getCharChildren:function(t,e){return void 0===e&&(e=[]),this.forEachCharChild((function(t){e.push(t)}),void 0,t),e},getLastAppendedChildren:function(){return this.lastAppendedChildren},getNearestChild:function(t,e){var i={x:t,y:e},s=1/0,r=null;return this.forEachRenderableChild((function(t){var e=Lt(i,function(t,e,i,s){"number"!=typeof e&&(s=e,e=0,i=0);var r=t.drawCenterX+e,h=t.drawCenterY+i;return k(t,r,h,s)}(t,!0));s>e&&(s=e,r=t)})),r},getCharWorldPosition:function(t,e,i,s){return"number"==typeof t&&(t=this.getCharChild(t,!0)),Y(this,t,e,i,s)},setToMinSize:function(){for(var t=this.children,e=0,i=0,s=0,r=t.length;s<r;s++){var h=t[s];if(h.renderable&&h.active&&h.visible){var a=void 0!==h.x0?h.x0:h.x,n=void 0!==h.y0?h.y0:h.y;e=Math.max(e,a),i=Math.max(i,n)}}var o=e+this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,l=i+this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom;return this.width===o&&this.height===l||(this.dirty=!0,this.setCanvasSize(o,l)),this},getCharChildIndex:function(t,e){void 0===e&&(e=!0);for(var i=this.children,s=0,r=i.length;s<r;s++){var h=i[s];if((!e||h.active)&&lt(h)&&!h.removed){if(0===t)return s;t--}}},getCharChild:function(t,e){void 0===e&&(e=!0);for(var i=this.children,s=0,r=i.length;s<r;s++){var h=i[s];if((!e||h.active)&&lt(h)&&!h.removed){if(0===t)return h;t--}}},getCharIndex:function(t,e){if("number"!=typeof t&&(t=this.children.indexOf(t))<0)return null;void 0===e&&(e=!0);var i=this.children;t>=i.length&&(t=i.length);for(var s=0,r=0;r<t;r++){var h=i[r];e&&!h.active||lt(h)&&!h.removed&&s++}return s},setChildrenInteractiveEnable:function(t){return void 0===t&&(t=!0),this.childrenInteractiveEnable!=