phaser4-rex-plugins
Version:
1 lines • 80.7 kB
JavaScript
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,n=e.defaultRenderNodes;(r.Submitter||n.Submitter).run(i,e,s,0,r.Texturer||n.Texturer,r.Transformer||n.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,n,h,o,a,l){var d=this.scene.sys.textures.getFrame(t,e);if(!d)return this;var u=d.cutWidth,c=d.cutHeight;void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=u),void 0===n&&(n=c),void 0===h&&(h=0),void 0===o&&(o=0),void 0===a&&(a=u),void 0===l&&(l=c);var g=d.cutX+h,p=d.cutY+o;return this.context.drawImage(d.source.image,g,p,a,l,i,s,r,n),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,n){if("number"!=typeof i){var h=i;i=h.red,s=h.green,r=h.blue,n=h.alpha}void 0===n&&(n=0!==i||0!==s||0!==r?255:0);var o=this.context.createImageData(1,1);return o.data[0]=i,o.data[1]=s,o.data[2]=r,o.data[3]=n,this.context.putImageData(o,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 n=i.width,h=i.height;n===this.frame.width&&h===this.frame.height||(this.frame.setSize(n,h),this.frame.source.updateSize(n,h),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 o=this.input;return o&&!o.customHitArea&&(o.hitArea.width=this.width,o.hitArea.height=this.height),this},generateTexture(t,e,i,s,r){var n=this.canvas;return void 0===s?s=n.width:s*=this.resolution,void 0===r?r=n.height:r*=this.resolution,function(t,e,i,s,r,n,h){var o,a=t.sys.textures,l=t.renderer;void 0===s&&(s=0),void 0===r&&(r=0),void 0===n&&(n=e.width),void 0===h&&(h=e.height);var d=(o=a.exists(i)?a.get(i):a.createCanvas(i,n,h)).getSourceImage();d.width!==n&&(d.width=n),d.height!==h&&(d.height=h);var u=d.getContext("2d",{willReadFrequently:!0});u.clearRect(0,0,n,h),u.drawImage(e,s,r,n,h),l.gl&&o&&l.canvasToTexture(d,o.source[0].glTexture,!0,0)}(this.scene,n,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 n=Phaser.Display.Canvas.CanvasPool,h=Phaser.GameObjects.GameObject,o=Phaser.Utils.String.UUID,a=Phaser.Renderer.WebGL.RenderNodes.Defaults.DefaultImageNodes;class l extends h{constructor(t,e,i,s,r,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=1),void 0===h&&(h=1),super(t,"rexCanvas"),this.renderer=t.sys.game.renderer,this._width=s,this._height=r,this.resolution=h,s=Math.max(Math.ceil(s*this.resolution),1),r=Math.max(Math.ceil(r*this.resolution),1),this.canvas=n.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=o(),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(){n.remove(this.canvas),this.canvas=null,this.context=null;var t=this.texture;t&&t.destroy()}get _defaultRenderNodesMap(){return a}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 u=Phaser.Utils.Objects.GetValue;var c=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=u(e,"left",0),t.right=u(e,"right",0),t.top=u(e,"top",0),t.bottom=u(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,n=i,h=0;h<s.length;h++){if(e=s[h],!r.hasOwnProperty(e)){n=i;break}r=n=r[e]}return n}(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 p{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(p.prototype,g);var f={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 m,w=function(t){void 0===m&&(m=new x);var e=t.drawTLX,i=t.drawTLY;return m.setTo(e,i,t.drawTRX-e,t.drawBLY-i),m};const C=Phaser.Math.RotateAround;var b,S=function(t,e,i,s){return void 0===s?s={}:!0===s&&(void 0===b&&(b={}),s=b),s.x=e,s.y=i,0!==t.rotation&&C(s,0,0,t.rotation),s.x=s.x*t.scaleX+t.drawX,s.y=s.y*t.scaleY+t.drawY,s};const O=Phaser.GameObjects.Components.TransformMatrix;var k,T,P={},_=function(t,e,i,s,r){var n=S(e,i,s,!0),h=function(t,e,i,s){void 0===s?s={}:!0===s&&(s=P);var r=e-t.width*t.originX,n=i-t.height*t.originY;return void 0===k&&(k=new O,T=new O),t.parentContainer?t.getWorldTransformMatrix(k,T):k.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),k.transformPoint(r,n,s),s}(t,n.x,n.y,r);return h},L=function(t,e,i,s,r){"number"!=typeof i&&(r=i,i=0,s=0);var n=e.drawCenterX+i,h=e.drawCenterY+s;return _(t,e,n,h,r)},E={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 w(this).contains(i.x,i.y)},getWorldPosition:function(t,e,i){return L(this.parent,this,t,e,i)}};Object.assign(E,f);const R=Phaser.Math.DegToRad,X=Phaser.Math.RadToDeg,Y=Phaser.Utils.Objects.GetValue;class A extends p{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 X(this._rotation)}set angle(t){this.rotation=R(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=Y(t,"width",void 0),i=Y(t,"height",void 0),s=Y(t,"scaleX",void 0),r=Y(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,E);const W=Phaser.Utils.String.Pad;var B=function(t,e,i){if(null==t)return t;switch(typeof t){case"string":default:return t;case"number":return`#${W(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}},M=function(t,e,i){return e.hasOwnProperty(t)?e[t]:i[t]};const D=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=D(t,"x",0),i=D(t,"y",0));var s=this.cornerRadius;s.tl=H(D(t,"tl",void 0),e,i),s.tr=H(D(t,"tr",void 0),e,i),s.bl=H(D(t,"bl",void 0),e,i),s.br=H(D(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 H=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),z(t),t},j=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=D(e,"x",0),t.y=D(e,"y",0)),z(t)},z=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)};const I=Phaser.Math.DegToRad;var G=function(t){return!t.hasOwnProperty("convex")||t.convex},U=function(t){return t.x>0&&t.y>0},N=function(t,e,i,s,r,n,h,o,a){if(o&&h>n?h-=360:!o&&h<n&&(h+=360),n=I(n),h=I(h),null==a)t.ellipse(e,i,s,r,0,n,h,o);else for(var l,d,u,c=(h-n)/(a+=1),g=0;g<=a;g++)u=n+c*g,l=e+s*Math.cos(u),d=i+r*Math.sin(u),t.lineTo(l,d)},V=function(t,e,i,s,r,n,h,o,a,l,d,u,c){var g;(function(t,e,i,s,r,n,h){var o,a,l,d,u,c=new F(e,i,s,r,n),g=c.minWidth,p=c.minHeight,f=s>=g?1:s/g,v=r>=p?1:r/p,y=c.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),o=y.tl,U(o)?(a=o.x*f,l=o.y*v,G(o)?N(t,a,l,a,l,180,270,!1,h):N(t,0,0,a,l,90,0,!0,h),d=0,u=l):(t.lineTo(0,0),d=0,u=0),o=y.tr,U(o)?(a=o.x*f,l=o.y*v,G(o)?N(t,s-a,l,a,l,270,360,!1,h):N(t,s,0,a,l,180,90,!0,h)):t.lineTo(s,0),o=y.br,U(o)?(a=o.x*f,l=o.y*v,G(o)?N(t,s-a,r-l,a,l,0,90,!1,h):N(t,s,r,a,l,270,180,!0,h)):t.lineTo(s,r),o=y.bl,U(o)?(a=o.x*f,l=o.y*v,G(o)?N(t,a,r-l,a,l,90,180,!1,h):N(t,0,r,a,l,360,270,!0,h)):t.lineTo(0,r),t.lineTo(d,u),t.closePath(),t.restore()}(e,i,s,r,n,h,c),null!=o)&&(null!=d&&((g=u?e.createLinearGradient(0,0,r,0):e.createLinearGradient(0,0,0,n)).addColorStop(0,o),g.addColorStop(1,d),o=g),e.fillStyle=o,e.fill());null!=a&&l>0&&(e.strokeStyle=a,e.lineWidth=l,e.stroke())};const $=Phaser.Utils.Objects.GetValue;class q extends A{constructor(t,e){super(t,"background"),this.setScrollFactor(0),this.setColor($(e,"color",null),$(e,"color2",null),$(e,"horizontalGradient",!0)),this.setStroke($(e,"stroke",null),$(e,"strokeThickness",2)),this.setCornerRadius($(e,"cornerRadius",0),$(e,"cornerIteration",null))}set color(t){t=B(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t}get color(){return this._color}set color2(t){t=B(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=B(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,M("color2",t,this),M("horizontalGradient",t,this)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,M("strokeThickness",t,this)),t.hasOwnProperty("cornerRadius")&&this.setCornerRadius(t.cornerRadius,M("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,n,h,o){if(null!=e||null!=i){var a=t.canvas.width,l=t.canvas.height;null==i&&(s=0);var d=s/2;a=Math.max(1,a-s),l=Math.max(1,l-s),V(t.canvas,t.context,d,d,a,l,r,e,i,s,n,h,o)}}(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=B(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t}get color(){return this._color}set color2(t){t=B(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=B(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,n=this.parent.width-i.left-i.right,h=this.parent.height-i.top-i.bottom,o=this.context;null!=this.color&&(null!=this.color2?((e=this.horizontalGradient?o.createLinearGradient(0,0,n,0):o.createLinearGradient(0,0,0,h)).addColorStop(0,this.color),e.addColorStop(1,this.color2),t=e):t=this.color,o.fillStyle=t,o.fillRect(s,r,n,h));null!=this.stroke&&this.strokeThickness>0&&(o.strokeStyle=this.stroke,o.lineWidth=this.strokeThickness,o.strokeRect(s,r,n,h))}}const Z=Phaser.Utils.Objects.GetValue;class Q{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(Z(t,"bold",!1)),this.setItalic(Z(t,"italic",!1)),this.setFontSize(Z(t,"fontSize","16px")),this.setFontFamily(Z(t,"fontFamily","Courier")),this.setColor(Z(t,"color","#fff")),this.setStrokeStyle(Z(t,"stroke",null),Z(t,"strokeThickness",0)),this.setShadow(Z(t,"shadowColor",null),Z(t,"shadowOffsetX",0),Z(t,"shadowOffsetY",0),Z(t,"shadowBlur",0)),this.setOffset(Z(t,"offsetX",0),Z(t,"offsetY",0)),this.setSpace(Z(t,"leftSpace",0),Z(t,"rightSpace",0)),this.setAlign(Z(t,"align",void 0)),this.setBackgroundColor(Z(t,"backgroundColor",null)),this.setBackgroundHeight(Z(t,"backgroundHeight",void 0)),this.setBackgroundBottomY(Z(t,"backgroundBottomY",void 0)),this.setBackgroundLeftX(Z(t,"backgroundLeftX",0)),this.setBackgroundRightX(Z(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(M("stroke",t,this),M("strokeThickness",t,this)),t.hasOwnProperty("shadowColor")&&this.setShadowColor(t.shadowColor),(t.hasOwnProperty("shadowOffsetX")||t.hasOwnProperty("shadowOffsetY"))&&this.setShadowOffset(M("shadowOffsetX",t,this),M("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 Q(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=B(t),this}get hasFill(){return null!=this.color}setStrokeStyle(t,e){return this.stroke=B(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=B(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=B(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",nt="space",ht="command";var ot=function(t){return t.type===it&&"\n"===t.text},at=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 Q(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 n=e.backgroundBottomY;null==n&&(n=this.drawBLY);var h=e.backgroundHeight;null==h&&(h=n-this.drawTLY);var o=n-h;t.fillRect(s,o,r,h)}}var a=e.hasFill,l=e.hasStroke;(a||l)&&(e.syncFont(t).syncStyle(t),l&&(e.syncShadow(t),t.strokeText(this.text,0,0)),a&&(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 ut=function(t,e){var i=this.createCharChildren(t,e);return this.addChild(i),this};const ct=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,n,h,o){void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=t.cutWidth),void 0===n&&(n=t.cutHeight),void 0===o&&(o=!1),o&&(i=Math.round(i),s=Math.round(s));var a=e.getContext("2d",{willReadFrequently:!0});if(h){var l=ct.create(null,r,n,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,n),d.globalCompositeOperation="source-in",d.fillStyle=h,d.fillRect(0,0,r,n),a.drawImage(l,0,0,r,n,i,s,r,n),ct.remove(l)}else a.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,i,s,r,n)}(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 pt 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 ft extends A{constructor(t,e){super(t,nt),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 p{constructor(t,e,i,s,r){super(t,ht),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 mt={none:0,word:1,char:2,character:2,mix:3};var wt=/^[\x00-\x7F]+$/,Ct=function(t,e,i,s){void 0===s&&(s={word:[],width:0}),s.word.length=0;for(var r,n=2===i,h=3===i,o=!n&&!h,a=t.length,l=e,d=s.word,u=0,c=!1;l<a;){var g=t[l];if(g.renderable){var p=g.type===it?g.text:null;if(null===p||"\n"===p||"\f"===p){l===e&&(d.push(g),u+=g.outerWidth);break}if(o){if(d.push(g),u+=g.outerWidth," "===p)break;l++}else{if(n){d.push(g),u+=g.outerWidth;break}if(h){if(r=p,!wt.test(r)){if(c)break;d.push(g),u+=g.outerWidth;var f=t[l+1];f&&f.type===it&&" "===f.text&&(d.push(f),u+=f.outerWidth);break}if(d.push(g),u+=g.outerWidth," "===p)break;l++,c=!0}}}else d.push(g),l++}return s.width=u,s},bt=function(t){for(var e=0,i=t.length;e<i;e++){var s=t[e];if(void 0!==s.align)return s.align}},St=function(t,e,i){if(0!==e||0!==i)for(var s=0,r=t.length;s<r;s++){var n=t[s];n.renderable&&(n.x+=e,n.y+=i)}},Ot=function(t,e){for(var i=e/t.length,s=0,r=t.length;s<r;s++){var n=t[s];n.renderable&&(n.x+=i*s)}},kt=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),Tt.ascent=t,Tt.descent=e,Tt.height=t+e,Tt},Tt={};const Pt=Phaser.Utils.Objects.GetValue;var _t=function(t){var e=Pt(t,"start",0);c(this.wrapPadding,Pt(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,n=Pt(t,"lineHeight"),h=Pt(t,"ascent",n);if(void 0===n){var o=Pt(t,"useDefaultTextHeight",!1);if(i=Pt(t,"maxLines",0),this.fixedHeight>0&&!o){var a=this.fixedHeight-s;i>0?n=a/i:(n=(l=kt.call(this)).height,h=l.ascent,i=Math.floor((a-h)/n))}else{var l;n=(l=kt.call(this)).height,h=l.ascent}}else this.fixedHeight>0?void 0===(i=Pt(t,"maxLines"))&&(a=this.fixedHeight-s,i=Math.floor(a/n)):i=Pt(t,"maxLines",0);void 0===h&&(h=n);var d=0===i,u=Pt(t,"wrapMode");void 0===u&&(u=Pt(t,"charWrap",!1)?"char":"word"),"string"==typeof u&&(u=mt[u]);var g=Pt(t,"wrapWidth",void 0);void 0===g&&(this.fixedWidth>0?g=this.fixedWidth-r:(g=1/0,u=0));for(var p=Pt(t,"letterSpacing",0),f=Pt(t,"hAlign",0),v=Pt(t,"vAlign",0),y=Pt(t,"justifyPercentage",.25),x=xt({callback:"runWordWrap",start:e,padding:this.wrapPadding,letterSpacing:p,maxLines:i,hAlign:f,vAlign:v,justifyPercentage:y,ascent:h,lineHeight:n,wrapWidth:g,wrapMode:u}),m=this.children,w=0,C=m.length;w<C;w++)m[w].setActive(!1);g+=p;for(var b,S=this.padding.left+this.wrapPadding.left,O=S,k=this.padding.top+this.wrapPadding.top+h,T=g,P=e,_=m.length,L=x.children,E=x.lines,R=[],X=0,Y=0,A=!1;P<_;){var W=(b=Ct(m,P,u,b)).word,B=W.length,M=b.width+B*p;P+=B;var D=ot(W[0]);A=at(W[0]);var F=D||A;if(T<M||F){if(F){var H=W[0];H.setActive().setPosition(O,k),L.push(H),R.push(H)}if(O=S,k+=n,T=g,E.push({children:R,width:X}),Y=Math.max(Y,X),X=0,R=[],A||!d&&E.length===i)break;if(F)continue}for(T-=M,X+=M,w=0,C=W.length;w<C;w++)(I=W[w]).setActive(),L.push(I),R.push(I),I.renderable&&(I.setPosition(O,k),O+=I.outerWidth+p)}R.length>0&&(E.push({children:R,width:X}),Y=Math.max(Y,X)),x.start+=L.length,x.isLastPage=!A&&x.start===_,x.maxLineWidth=Y,x.linesHeight=E.length*n;var j=this.fixedWidth>0?this.fixedWidth:x.maxLineWidth+r,z=this.fixedHeight>0?this.fixedHeight:x.linesHeight+s;for(function(t,e,i){for(var s,r,n=t.hAlign,h=t.vAlign,o=t.justifyPercentage,a=t.lines,l=0,d=a.length;l<d;l++){var u=a[l],c=u.width,g=u.children,p=bt(g);switch(void 0===p&&(p=n),p){case 0:case"left":default:s=0;break;case 1:case"center":s=(f=e-c)/2;break;case 2:case"right":s=f=e-c;break;case 3:case"justify":case"justify-left":(f=e-c)/e<o?(Ot(g,f),s=0):s=0;break;case 4:case"justify-center":(f=e-c)/e<o?(Ot(g,f),s=0):s=f/2;break;case 5:case"justify-right":var f;(f=e-c)/e<o?(Ot(g,f),s=0):s=f}var v=t.linesHeight;switch(h){case 1:case"center":r=(i-v)/2;break;case 2:case"bottom":r=i-v;break;default:r=0}St(g,s,r)}}(x,j-r,a=z-s),this.setCanvasSize(j,z),w=0,C=L.length;w<C;w++){var I;(I=L[w]).renderable&&(I.x0=I.x,I.y0=I.y)}return x};const Lt=Phaser.Utils.Objects.Merge,Et=Phaser.Utils.Objects.GetValue;var Rt=function(t){var e=Et(t,"start",0);c(this.wrapPadding,Et(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,n=Et(t,"lineWidth",void 0);if(void 0===n)i=Et(t,"maxLines",0),n=this.fixedWidth>0?(h=this.fixedWidth-r)/i:0;else if(this.fixedWidth>0){if(void 0===(i=Et(t,"maxLines",void 0))){var h=this.fixedWidth-r;i=Math.floor(h/n)+1}}else i=Et(t,"maxLines",0);var o=0===i,a=Et(t,"fixedCharacterHeight",void 0);if(void 0===a){var l=Et(t,"charPerLine",void 0);if(void 0!==l){var d=this.fixedHeight-s;a=Math.floor(d/l)}}var u=Et(t,"wrapHeight",void 0);void 0===u&&(u=this.fixedHeight>0?this.fixedHeight-s:1/0);for(var g=Et(t,"letterSpacing",0),p=Et(t,"rtl",!0),f=Et(t,"hAlign",p?2:0),v=Et(t,"vAlign",0),y=xt({callback:"runVerticalWrap",start:e,padding:this.wrapPadding,letterSpacing:g,maxLines:i,hAlign:f,vAlign:v,lineWidth:n,fixedCharacterHeight:a,wrapHeight:u,rtl:p}),x=this.children,m=0,w=x.length;m<w;m++)x[m].setActive(!1);u+=g;for(var C=this.padding.left+this.wrapPadding.left,b=this.padding.top+this.wrapPadding.top,S=C,O=b,k=u,T=e,P=x.length,_=y.children,L=y.lines,E=[],R=0,X=0;T<P;){var Y=x[T];if(T++,Y.renderable){var A=(void 0!==a?a:Y.height)+g,W=ot(Y),B=at(Y),M=W||B;if(k<A||M){if(W&&(Y.setActive().setPosition(S,O).setOrigin(.5),_.push(Y),E.push(Y)),S=C,O=b,k=u,L.push({children:E,height:R}),X=Math.max(X,R),R=0,E=[],B||!o&&L.length===i)break;if(M)continue}k-=A,R+=A,Y.setActive().setPosition(S,O).setOrigin(.5),_.push(Y),E.push(Y),O+=A}else Y.setActive(),_.push(Y),E.push(Y)}E.length>0&&(L.push({children:E,height:R}),X=Math.max(X,R)),y.start+=_.length,y.isLastPage=y.start===P,y.maxLineHeight=X,y.linesWidth=L.length*n;var D=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,n=t.hAlign,h=t.vAlign,o=t.rtl,a=t.lines,l=t.lineWidth,d=t.linesWidth;switch(n){case 1:case"center":s=(e-d)/2;break;case 2:case"right":s=e-d;break;default:s=0}o&&(s+=l);for(var u=0,c=a.length;u<c;u++){var g=a[o?c-u-1:u],p=g.children,f=g.height,v=bt(p);switch(void 0===v&&(v=h),v){case 1:case"center":r=(i-f)/2;break;case 2:case"bottom":r=i-f;break;default:r=0}St(p,s,r),s+=l}}(y,h=D-r,d=F-s),this.setCanvasSize(D,F),m=0,w=_.length;m<w;m++)(Y=_[m]).renderable&&(Y.x0=Y.x,Y.y0=Y.y);return y};const Xt=Phaser.Utils.Objects.Merge,Yt=Phaser.Utils.Objects.GetValue;var At={setVAlign(t){return this.wrapConfig.vAlign=t,this},setHAlign(t){return this.wrapConfig.hAlign=t,this}},Wt={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 Bt=Phaser.Utils.Array.GetAll,Mt=Phaser.Math.Distance.BetweenPointsSquared;var Dt=function(t,e,i){for(var s=0,r=t.length;s<r;s++){var n=t[s];if(n.active&&n.renderable&&n.contains(e,i))return n}return null},Ft=function(){return this.on("pointerdown",Ht,this).on("pointerdown",jt,this).on("pointermove",zt,this).on("pointerover",zt,this).on("pointerout",(function(t,e){zt.call(this,t,null,null,e)}),this),this},Ht=function(t,e,i,s){if(this.childrenInteractiveEnable){var r=Dt(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=Dt(this.children,e,i);r&&this.emit("child.pointerup",r,t,e,i,s)}},zt=function(t,e,i,s){if(this.childrenInteractiveEnable)if(null!==e){var r=Dt(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 It=Phaser.GameObjects.GameObject,Gt=Phaser.Utils.Array.BringToTop,Ut=Phaser.Utils.Array.SendToBack,Nt=Phaser.Utils.Array.MoveUp,Vt=Phaser.Utils.Array.MoveDown,$t=Phaser.Utils.Array.MoveAbove,qt=Phaser.Utils.Array.MoveBelow;var Jt={moveChildToFist(t){return Ut(this.children,t),this},moveChildToLast(t){return Gt(this.children,t),this},movechildUp(t){return Nt(this.children,t),this},movechildDown(t){return Vt(this.children,t),this},movechildAbove(t,e){return $t(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}},Zt={setInnerBoundsColor(t,e,i){return this.innerBounds.setColor(t,e,i),this},setInnerBoundsStroke(t,e){return this.innerBounds.setStroke(t,e),this}},Qt={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,n=i.top,h=i.bottom;return c(i,t,e),this.dirty=this.dirty||s!=i.left||r!=i.right||n!=i.top||h!=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 n=t.charAt(s),h=this.poolManager.allocate(it);null===h?h=new dt(this,n,this.textStyle):h.setParent(this).setActive().modifyStyle(this.textStyle).setText(n),i.push(h)}return i},setText:function(t,e){return void 0===t&&(t=""),this.removeChildren(),ut.call(this,t,e),this.dirty=!0,this},appendText:ut,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 pt(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(nt);return null===e?e=new ft(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(ht);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={}),_t.call(this,Lt(t,this.wrapConfig))},runVerticalWrap:function(t){return void 0===t&&(t={}),Rt.call(this,Xt(t,this.wrapConfig))},runWrap:function(t){var e=Yt(this.wrapConfig,"callback");return e||(e=Yt(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,n=s.length;r<n;r++){var h=s[r];if(e?t.call(this,h,r,s):t(h,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,n=s.length;r<n;r++){var h=s[r];if(e?t.call(this,h,r,s):t(h,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,n=s.length;r<n;r++){var h=s[r];if(e?t.call(this,h,r,s):t(h,r,s))break}return this},getChildren:function(){return this.children},getActiveChildren:function(){return Bt(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=Mt(i,function(t,e,i,s){"number"!=typeof e&&(s=e,e=0,i=0);var r=t.drawCenterX+e,n=t.drawCenterY+i;return S(t,r,n,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)),L(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 n=t[s];if(n.renderable&&n.active&&n.visible){var h=void 0!==n.x0?n.x0:n.x,o=void 0!==n.y0?n.y0:n.y;e=Math.max(e,h),i=Math.max(i,o)}}var a=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===a&&this.height===l||(this.dirty=!0,this.setCanvasSize(a,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 n=i[s];if((!e||n.active)&<(n)&&!n.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 n=i[s];if((!e||n.active)&<(n)&&!n.removed){if(0===t)return n;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 n=i[r];e&&!n.active||lt(n)&&!n.removed&&s++}return s},setChildrenInteractiveEnable:function(t){return void 0===t&&(t=!0),this.childrenInteractiveEnable!=