phaser3-rex-plugins
Version:
7 lines • 53.1 kB
JavaScript
var t,e;t=void 0,e=function(){var t=Phaser.Renderer.WebGL.Utils,e={renderWebGL:function(e,s,i,r){if(0!==s.width&&0!==s.height){i.addToRenderList(s);var n=s.frame,a=n.width,h=n.height,o=t.getTintAppendFloatAlpha,l=e.pipelines.set(s.pipeline,s),d=l.setTexture2D(n.glTexture,s);e.pipelines.preBatch(s),l.batchTexture(s,n.glTexture,a,h,s.x,s.y,a/s.style.resolution,h/s.style.resolution,s.scaleX,s.scaleY,s.rotation,s.flipX,s.flipY,s.scrollFactorX,s.scrollFactorY,s.displayOriginX,s.displayOriginY,0,0,a,h,o(s.tintTopLeft,i.alpha*s._alphaTL),o(s.tintTopRight,i.alpha*s._alphaTR),o(s.tintBottomLeft,i.alpha*s._alphaBL),o(s.tintBottomRight,i.alpha*s._alphaBR),s.tintFill,0,0,i,r,!1,d),e.pipelines.postBatch(s)}},renderCanvas:function(t,e,s,i){0!==e.width&&0!==e.height&&(s.addToRenderList(e),t.batchSprite(e,e.frame,s,i))}};const s=Phaser.Display.Canvas.CanvasPool;var i=!1;!function(t){if(!i){void 0===t&&(t=60);var e=Phaser.VERSION.split("."),s=parseInt(e[0]);if(3===s){var r=parseInt(e[1]);r<t&&console.error(`Minimum supported version : ${s}.${r}`)}else console.error(`Can't supported version : ${s}`);i=!0}}();const r=Phaser.GameObjects.GameObject;class n extends r{setStyle(t){return this.style.setStyle(t)}setFont(t){return this.style.setFont(t)}setFontFamily(t){return this.style.setFontFamily(t)}setFontSize(t){return this.style.setFontSize(t)}setFontStyle(t){return this.style.setFontStyle(t)}setTestString(t){return this.style.setTestString(t)}setFixedSize(t,e){return this.style.setFixedSize(t,e)}setBackgroundColor(t,e,s){return this.style.setBackgroundColor(t,e,s)}setBackgroundStrokeColor(t,e){return this.style.setBackgroundStrokeColor(t,e)}setBackgroundCornerRadius(t,e){return this.style.setBackgroundCornerRadius(t,e)}setFill(t){return this.style.setFill(t)}setColor(t){return this.style.setColor(t)}setStroke(t,e){return this.style.setStroke(t,e)}setShadow(t,e,s,i,r,n){return this.style.setShadow(t,e,s,i,r,n)}setShadowOffset(t,e){return this.style.setShadowOffset(t,e)}setShadowColor(t){return this.style.setShadowColor(t)}setShadowBlur(t){return this.style.setShadowBlur(t)}setShadowStroke(t){return this.style.setShadowStroke(t)}setShadowFill(t){return this.style.setShadowFill(t)}setUnderline(t,e,s){return this.style.setUnderline(t,e,s)}setUnderlineColor(t){return this.style.setUnderlineColor(t)}setUnderlineThickness(t){return this.style.setUnderlineThickness(t)}setUnderlineOffset(t){return this.style.setUnderlineOffset(t)}setStrikethrough(t,e,s){return this.style.setStrikethrough(t,e,s)}setStrikethroughColor(t){return this.style.setStrikethroughColor(t)}setStrikethroughThickness(t){return this.style.setStrikethroughThickness(t)}setStrikethroughOffset(t){return this.style.setStrikethroughOffset(t)}setWrapMode(t){return this.style.setWrapMode(t)}setWrapWidth(t){return this.style.setWrapWidth(t)}setWordWrapWidth(t){return this.style.setWrapWidth(t)}setAlign(t){return this.style.setHAlign(t)}setHAlign(t){return this.style.setHAlign(t)}setVAlign(t){return this.style.setVAlign(t)}get lineSpacing(){return this.style.lineSpacing}set lineSpacing(t){this.style.lineSpacing=t}setLineSpacing(t){return this.style.lineSpacing=t,this.updateText(!0),this}get letterSpacing(){return this.style.letterSpacing}set letterSpacing(t){this.style.letterSpacing=t}setLetterSpacing(t){return this.style.letterSpacing=t,this.updateText(!0),this}setXOffset(t){return this.style.setXOffset(t)}setMaxLines(t){return this.style.setMaxLines(t)}setResolution(t){return this.style.setResolution(t)}getTextMetrics(){return this.style.getTextMetrics()}setTextMetrics(t,e){return this.style.setTextMetrics(t,e)}measureTextMargins(t,e){return function(t,e,i){void 0===i&&(i={});var r=s.create(this),n=r.getContext("2d",{willReadFrequently:!0});t.syncFont(r,n);var a=n.measureText(e),h=Math.ceil(a.width*t.baselineX),o=h,l=2*o;if(o=o*t.baselineY|0,r.width=h,r.height=l,n.fillStyle="#f00",n.fillRect(0,0,h,l),n.font=t._font,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(t.testString,0,o),i.left=0,0===h||0===l||!n.getImageData(0,0,h,l))return s.remove(r),i;for(var d=n.getImageData(0,0,h,l).data,u=!1,g=0;g<h;g++){for(var c=0;c<l;c++)if(255!==d[4*(c*h+g)]){i.left=g,u=!0;break}if(u)break}return s.remove(r),i}(this.style,t,e)}}const a=Phaser.GameObjects.Components;Phaser.Class.mixin(n,[a.Alpha,a.BlendMode,a.ComputedSize,a.Crop,a.Depth,a.Flip,a.GetBounds,a.Mask,a.Origin,a.Pipeline,a.PostPipeline,a.ScrollFactor,a.Tint,a.Transform,a.Visible,e]);const h=Phaser.Utils.String.Pad;var o=function(t,e,s){if(null==t)return t;switch(typeof t){case"string":default:return t;case"number":return`#${h(Math.floor(t).toString(16),6,"0",1)}`;case"function":return t(e,s);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={backgroundColor:["backgroundColor",null,o],backgroundColor2:["backgroundColor2",null,o],backgroundHorizontalGradient:["backgroundHorizontalGradient",!0,null],backgroundStrokeColor:["backgroundStrokeColor",null,o],backgroundStrokeLineWidth:["backgroundStrokeLineWidth",2,null],backgroundCornerRadius:["backgroundCornerRadius",0,null],backgroundCornerIteration:["backgroundCornerIteration",null,null],fontFamily:["fontFamily","Courier",null],fontSize:["fontSize","16px",null],fontStyle:["fontStyle","",null],color:["color","#fff",o],stroke:["stroke","#fff",o],strokeThickness:["strokeThickness",0,null],shadowOffsetX:["shadow.offsetX",0,null],shadowOffsetY:["shadow.offsetY",0,null],shadowColor:["shadow.color","#000",o],shadowBlur:["shadow.blur",0,null],shadowStroke:["shadow.stroke",!1,null],shadowFill:["shadow.fill",!1,null],underlineColor:["underline.color","#000",o],underlineThickness:["underline.thickness",0,null],underlineOffset:["underline.offset",0,null],strikethroughColor:["strikethrough.color","#000",o],strikethroughThickness:["strikethrough.thickness",0,null],strikethroughOffset:["strikethrough.offset",0,null],halign:["halign","left",null],valign:["valign","top",null],maxLines:["maxLines",0,null],fixedWidth:["fixedWidth",0,null],fixedHeight:["fixedHeight",0,null],resolution:["resolution",0,null],lineSpacing:["lineSpacing",0,null],letterSpacing:["letterSpacing",0,null],xOffset:["xOffset",0,null],fixedLineHeightMode:["fixedLineHeightMode",!0,null],rtl:["rtl",!1,null],testString:["testString","|MÉqgy",null],baselineX:["baselineX",1.2,null],baselineY:["baselineY",1.4,null],wrapMode:["wrap.mode",0,null],wrapWidth:["wrap.width",0,null],wrapCallback:["wrap.callback",null],wrapCallbackScope:["wrap.callbackScope",null]};
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
const d=Phaser.Display.Canvas.CanvasPool;var u=function(t){var e=d.create(this),s=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,s);var i=s.measureText(t.testString);if("actualBoundingBoxAscent"in i){var r=i.actualBoundingBoxAscent,n=i.actualBoundingBoxDescent,a={ascent:r,descent:n,fontSize:r+n};return d.remove(e),a}var h=Math.ceil(i.width*t.baselineX),o=h,l=2*o;if(o=o*t.baselineY|0,e.width=h,e.height=l,s.fillStyle="#f00",s.fillRect(0,0,h,l),s.font=t._font,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(t.testString,0,o),a={ascent:0,descent:0,fontSize:0},!s.getImageData(0,0,h,l))return a.ascent=o,a.descent=o+6,a.fontSize=a.ascent+a.descent,d.remove(e),a;var u,g,c=s.getImageData(0,0,h,l).data,p=c.length,f=4*h,v=0,y=!1;for(u=0;u<o;u++){for(g=0;g<f;g+=4)if(255!==c[v+g]){y=!0;break}if(y)break;v+=f}for(a.ascent=o-u,v=p-f,y=!1,u=l;u>o;u--){for(g=0;g<f;g+=4)if(255!==c[v+g]){y=!0;break}if(y)break;v-=f}return a.descent=u-o,a.fontSize=a.ascent+a.descent,d.remove(e),a},g=0,c=1,p=2,f=0,v=1,y=2,x=/(?:\r\n|\r|\n)/;const w={none:f,word:v,char:y,character:y,mix:3},S=Phaser.Utils.Objects.GetAdvancedValue,m=Phaser.Utils.Objects.GetValue;class k{constructor(t,e,s){this.parent=t,void 0===s&&(s=l),this.propertyMap=s,this.backgroundColor,this.backgroundColor2,this.backgroundHorizontalGradient,this.backgroundStrokeColor,this.backgroundStrokeLineWidth,this.backgroundCornerRadius,this.backgroundCornerIteration,this.fontFamily,this.fontSize,this.fontStyle,this.color,this.stroke,this.strokeThickness,this.shadowOffsetX,this.shadowOffsetY,this.shadowColor,this.shadowBlur,this.shadowStroke,this.shadowFill,this.underlineColor,this.underlineThickness,this.underlineOffset,this.strikethroughColor,this.strikethroughThickness,this.strikethroughOffset,this.halign,this.valign,this.maxLines,this.fixedWidth,this.fixedHeight,this.resolution,this.xOffset,this.rtl,this.testString,this.baselineX,this.baselineY,this.wrapMode,this.wrapWidth,this.wrapCallback,this.wrapCallbackScope,this._font,this.setStyle(e,!1,!0)}get isWrapFitMode(){return this.fixedWidth>0&&this.wrapMode!==f&&0===this.wrapWidth}setStyle(t,e,s){if(void 0===e&&(e=!0),void 0===s&&(s=!1),t&&t.hasOwnProperty("wordWrap")){var i=t.wordWrap;i.hasOwnProperty("width")&&(t.wrap={mode:"word",width:i.width})}if(t&&t.hasOwnProperty("wrap")){var r=t.wrap;if(r.hasOwnProperty("mode")){var n=r.mode;"string"==typeof n&&(r.mode=w[n])}else r.hasOwnProperty("width")&&(r.mode=1)}t&&t.rtl&&s&&!t.hasOwnProperty("halign")&&(t.halign="right"),t&&t.hasOwnProperty("fontSize")&&"number"==typeof t.fontSize&&(t.fontSize=t.fontSize.toString()+"px");var a=this.propertyMap;for(var h in a){var l=a[h],d=l[0],g=s?l[1]:this[h],c=l[2];if("wrapCallback"===h||"wrapCallbackScope"===h)this[h]=m(t,d,g);else{var p=S(t,d,g);c&&(p=c(p)),this[h]=p}}var f=m(t,"font",null);this._font=null===f?this.fontStyle+" "+this.fontSize+" "+this.fontFamily:f;var v=m(t,"fill",null);null!==v&&(this.color=o(v));var y=m(t,"metrics",!1);return y?this.metrics={ascent:m(y,"ascent",0),descent:m(y,"descent",0),fontSize:m(y,"fontSize",0)}:!e&&this.metrics||(this.metrics=u(this)),e?this.parent.updateText():this.parent}syncFont(t,e){e.font=this._font}syncStyle(t,e){e.textBaseline="alphabetic",e.fillStyle=this.color,e.strokeStyle=this.stroke,e.lineWidth=this.strokeThickness,e.lineCap="round",e.lineJoin="round"}syncShadow(t,e){e?(t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur):(t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor=0,t.shadowBlur=0)}update(t){return t&&(this._font=`${this.fontStyle} ${this.fontSize} ${this.fontFamily}`.trim(),this.metrics=u(this)),this.parent.updateText(t)}buildFont(){var t=`${this.fontStyle} ${this.fontSize} ${this.fontFamily}`.trim();return t!==this._font&&(this._font=t),this}setFont(t){return"string"==typeof t?(this.fontFamily=t,this.fontSize="",this.fontStyle=""):(this.fontFamily=m(t,"fontFamily","Courier"),this.fontSize=m(t,"fontSize","16px"),this.fontStyle=m(t,"fontStyle","")),this.update(!0)}setFontFamily(t){return this.fontFamily=t,this.update(!0)}setFontStyle(t){return this.fontStyle=t,this.update(!0)}setFontSize(t){return"number"==typeof t&&(t=t.toString()+"px"),this.fontSize=t,this.update(!0)}setTestString(t){return this.testString=t,this.update(!0)}setFixedSize(t,e){return this.fixedWidth=t,this.fixedHeight=e,t&&(this.parent.width=t),e&&(this.parent.height=e),this.update(this.isWrapFitMode)}setResolution(t){return this.resolution=t,this.update(!1)}setXOffset(t){return this.xOffset=t,this.update(!1)}setBackgroundColor(t,e,s){return void 0===s&&(s=!0),this.backgroundColor=o(t,this.parent.canvas,this.parent.context),this.backgroundColor2=o(e,this.parent.canvas,this.parent.context),this.backgroundHorizontalGradient=s,this.update(!1)}setBackgroundStrokeColor(t,e){return this.backgroundStrokeColor=o(t,this.parent.canvas,this.parent.context),this.backgroundStrokeLineWidth=e,this.update(!1)}setBackgroundCornerRadius(t,e){return this.backgroundCornerRadius=t,this.backgroundCornerIteration=e,this.update(!1)}setFill(t){return this.color=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setColor(t){return this.color=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setStroke(t,e){return void 0===t?this.strokeThickness=0:(void 0===e&&(e=this.strokeThickness),this.stroke=o(t,this.parent.canvas,this.parent.context),this.strokeThickness=e),this.update(!0)}setShadow(t,e,s,i,r,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===s&&(s="#000"),void 0===i&&(i=0),void 0===r&&(r=!1),void 0===n&&(n=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=o(s,this.parent.canvas,this.parent.context),this.shadowBlur=i,this.shadowStroke=r,this.shadowFill=n,this.update(!1)}setShadowOffset(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.shadowOffsetX=t,this.shadowOffsetY=e,this.update(!1)}setShadowColor(t){return void 0===t&&(t="#000"),this.shadowColor=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setShadowBlur(t){return void 0===t&&(t=0),this.shadowBlur=t,this.update(!1)}setShadowStroke(t){return this.shadowStroke=t,this.update(!1)}setShadowFill(t){return this.shadowFill=t,this.update(!1)}setUnderline(t,e,s){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===s&&(s=0),this.underlineColor=o(t,this.parent.canvas,this.parent.context),this.underlineThickness=e,this.underlineOffset=s,this.update(!1)}setUnderlineColor(t){return void 0===t&&(t="#000"),this.underlineColor=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setUnderlineThickness(t){return void 0===t&&(t=0),this.underlineThickness=t,this.update(!1)}setUnderlineOffset(t){return void 0===t&&(t=0),this.underlineOffset=t,this.update(!1)}setStrikethrough(t,e,s){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===s&&(s=0),this.strikethroughColor=o(t,this.parent.canvas,this.parent.context),this.strikethroughThickness=e,this.strikethroughOffset=s,this.update(!1)}setStrikethroughColor(t){return void 0===t&&(t="#000"),this.strikethroughColor=o(t,this.parent.canvas,this.parent.context),this.update(!1)}setStrikethroughThickness(t){return void 0===t&&(t=0),this.strikethroughThickness=t,this.update(!1)}setStrikethroughOffset(t){return void 0===t&&(t=0),this.strikethroughOffset=t,this.update(!1)}setWrapMode(t){return"string"==typeof t&&(t=w[t.toLowerCase()]||0),this.wrapMode=t,this.update(!0)}setWrapWidth(t){return this.wrapWidth=t,this.update(!1)}setAlign(t,e){return void 0===t&&(t="left"),void 0===e&&(e="top"),this.halign=t,this.valign=e,this.update(!1)}setHAlign(t){return void 0===t&&(t="left"),this.halign=t,this.update(!1)}setVAlign(t){return void 0===t&&(t="top"),this.valign=t,this.update(!1)}setMaxLines(t){return void 0===t&&(t=0),this.maxLines=t,this.update(!1)}getTextMetrics(){var t=this.metrics;return{ascent:t.ascent,descent:t.descent,fontSize:t.fontSize}}setTextMetrics(t,e){return this.metrics.ascent=t.ascent,this.metrics.descent=t.descent,this.metrics.fontSize=t.fontSize,e&&("string"==typeof e?(this.fontFamily=e,this.fontSize="",this.fontStyle=""):(this.fontFamily=m(e,"fontFamily",this.fontFamily),this.fontSize=m(e,"fontSize",this.fontSize),this.fontStyle=m(e,"fontStyle",this.fontStyle))),this.parent.updateText(!0)}get lineHeight(){return this.metrics.fontSize+this.parent.lineSpacing}toJSON(){var t={},e=this.propertyMap;for(var s in e)t[s]=this[s];return t.metrics=this.getTextMetrics(),t}destroy(){this.parent=void 0}}const T=Phaser.Utils.Objects.GetValue;class P{constructor(t,e,s,i,r){void 0===t&&(t=0),void 0===e&&(e=t),void 0===s&&(s=0),void 0===i&&(i=0),void 0===r&&(r=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,s,i,r)}setTo(t,e,s,i,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(s,i),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,s;"number"==typeof t?(e=t,s=t):(e=T(t,"x",0),s=T(t,"y",0));var i=this.cornerRadius;i.tl=O(T(t,"tl",void 0),e,s),i.tr=O(T(t,"tr",void 0),e,s),i.bl=O(T(t,"bl",void 0),e,s),i.br=O(T(t,"br",void 0),e,s)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){b(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){b(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){b(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){b(this.cornerRadius.br,t)}}var O=function(t,e,s){return void 0===t?t={x:e,y:s}:"number"==typeof t&&(t={x:t,y:t}),M(t),t},b=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=T(e,"x",0),t.y=T(e,"y",0)),M(t)},M=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)};const C=Phaser.Math.DegToRad;var L=function(t){return!t.hasOwnProperty("convex")||t.convex},F=function(t){return t.x>0&&t.y>0},A=function(t,e,s,i,r,n,a,h,o){if(h&&a>n?a-=360:!h&&a<n&&(a+=360),n=C(n),a=C(a),null==o)t.ellipse(e,s,i,r,0,n,a,h);else for(var l,d,u,g=(a-n)/(o+=1),c=0;c<=o;c++)u=n+g*c,l=e+i*Math.cos(u),d=s+r*Math.sin(u),t.lineTo(l,d)},W=function(t,e,s,i,r,n,a,h,o,l,d,u,g){var c;(function(t,e,s,i,r,n,a){var h,o,l,d,u,g=new P(e,s,i,r,n),c=g.minWidth,p=g.minHeight,f=i>=c?1:i/c,v=r>=p?1:r/p,y=g.cornerRadius;t.save(),t.beginPath(),t.translate(e,s),h=y.tl,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,o,l,o,l,180,270,!1,a):A(t,0,0,o,l,90,0,!0,a),d=0,u=l):(t.lineTo(0,0),d=0,u=0),h=y.tr,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,i-o,l,o,l,270,360,!1,a):A(t,i,0,o,l,180,90,!0,a)):t.lineTo(i,0),h=y.br,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,i-o,r-l,o,l,0,90,!1,a):A(t,i,r,o,l,270,180,!0,a)):t.lineTo(i,r),h=y.bl,F(h)?(o=h.x*f,l=h.y*v,L(h)?A(t,o,r-l,o,l,90,180,!1,a):A(t,0,r,o,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(d,u),t.closePath(),t.restore()}(e,s,i,r,n,a,g),null!=h)&&(null!=d&&((c=u?e.createLinearGradient(0,0,r,0):e.createLinearGradient(0,0,0,n)).addColorStop(0,h),c.addColorStop(1,d),h=c),e.fillStyle=h,e.fill());null!=o&&l>0&&(e.strokeStyle=o,e.lineWidth=l,e.stroke())},H={draw(t,e,s,i){var r=this.penManager;this.hitAreaManager.clear();var n=this.context;n.save();var a=this.defaultStyle;this.clear(),function(t,e,s,i,r,n,a,h){if(null!=e||null!=s){var o=t.canvas.width,l=t.canvas.height;null==s&&(i=0);var d=i/2;o=Math.max(1,o-i),l=Math.max(1,l-i),W(t.canvas,t.context,d,d,o,l,r,e,s,i,n,a,h)}}(this,a.backgroundColor,a.backgroundStrokeColor,a.backgroundStrokeLineWidth,a.backgroundCornerRadius,a.backgroundColor2,a.backgroundHorizontalGradient,a.backgroundCornerIteration);var h=this.parent,o=h.padding,l=h.width-o.left-o.right,d=h.height-o.top-o.bottom,u=this.linesHeight,g=l>0&&d>0,c=h.style.fixedHeight>0,p=u>d,f=a.maxLines,v=f<=0&&"top"===a.valign&&g&&c&&p,y=v;y&&(n.save(),n.beginPath(),n.rect(o.left,o.top,l,d),n.clip()),t+=this.startXOffset,e+=this.startYOffset;var x,w,S,m,k,T,P=a.halign,O=a.valign,b=r.lines,M=b.length;if(v&&M>0){var C=-h.scrollY,L=C+d;S=function(t,e){for(var s=0,i=t.length-1,r=t.length;s<=i;){var n=s+i>>1;t[n].endOffset>e?(r=n,i=n-1):s=n+1}return r}(b,C),m=function(t,e){for(var s=0,i=t.length-1,r=t.length;s<=i;){var n=s+i>>1;t[n].startOffset>=e?(r=n,i=n-1):s=n+1}return r}(b,L),S<0&&(S=0),m>M&&(m=M),m<S&&(m=S)}else f>0&&M>f?(w=f,m=(S="center"===O?Math.floor((M-w)/2):"bottom"===O?M-w:0)+w):(S=0,m=M);var F=this.rtl,A=F?this.parent.width:void 0;if(v)T=e;else{var H=this.getLinesHeight(S,m);T="center"===O?Math.max((i-H)/2,0):"bottom"===O?Math.max(i-H-2,0):0,T+=e}for(var R=S;R<m;R++)if(0!==(x=r.getLineWidth(R))){var Y=b[R];if(Y){for(var z=Y.pens,I=z.length,_=P,B=0;B<I;B++){var X=z[B].prop.align;if(void 0!==X){_=X;break}}k="center"===_?(s-x)/2:"right"===_?F?0:s-x:F?s-x:0,k+=t;var $=this.getLineHeight(Y)+a.lineSpacing;for(B=0;B<I;B++)this.drawPen(z[B],k,T,A,$)}}y&&n.restore(),n.restore()},drawPen(t,e,s,i,r){e+=t.x,s+=t.y+(t.prop.y||0),void 0!==i&&(e=i-e);var n=this.canvas,a=this.context;a.save();var h=this.parser.propToContextStyle(this.defaultStyle,t.prop);if(null!==h.bgcolor&&t.width>0){var o=this.defaultStyle.metrics,l=s-o.ascent,d=o.fontSize;this.drawRectangle(e,l,t.width,d,h.bgcolor,h)}if(h.underlineThickness>0&&t.width>0){var u=s+h.underlineOffset-h.underlineThickness/2;this.drawLine(e,u,t.width,h.underlineThickness,h.underlineColor,h)}if(t.isTextPen&&(h.buildFont(),h.syncFont(n,a),h.syncStyle(n,a),this.drawText(e,s,t.text,h)),t.isImagePen&&this.drawImage(e,s,t.prop.img,t.prop.color,h),h.strikethroughThickness>0&&t.width>0&&(u=s+h.strikethroughOffset-h.strikethroughThickness/2,this.drawLine(e,u,t.width,h.strikethroughThickness,h.strikethroughColor,h)),a.restore(),t.hasAreaMarker&&t.width>0){var g,c=t.prop.area;if(c)g={key:c};else{var p=t.prop.url;g={key:`url:${p}`,url:p}}this.hitAreaManager.add(e,s-this.startYOffset,t.width,r||this.defaultStyle.lineHeight,g)}},clear(){var t=this.canvas;this.context.clearRect(0,0,t.width,t.height)},drawRectangle(t,e,s,i,r,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var a=this.context;a.fillStyle=r,a.fillRect(t,e,s,i)},drawLine(t,e,s,i,r,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var a=this.context;n.syncShadow(a,n.shadowStroke);var h=a.lineCap;a.lineCap="butt",a.strokeStyle=r,a.lineWidth=i,a.beginPath(),a.moveTo(t,e),a.lineTo(t+s,e),a.stroke(),a.lineCap=h},drawText(t,e,s,i){this.autoRound&&(t=Math.round(t),e=Math.round(e));var r=this.context,n=i.letterSpacing;if(0===n)i.stroke&&"none"!==i.stroke&&i.strokeThickness>0&&(i.syncShadow(r,i.shadowStroke),r.strokeText(s,t,e)),i.color&&"none"!==i.color&&(i.syncShadow(r,i.shadowFill),r.fillText(s,t,e));else for(var a=s.split(""),h=0,o=a.length;h<o;h++){var l=a[h];i.stroke&&"none"!==i.stroke&&i.strokeThickness>0&&(i.syncShadow(r,i.shadowStroke),r.strokeText(l,t,e)),i.color&&"none"!==i.color&&(i.syncShadow(r,i.shadowFill),r.fillText(l,t,e)),t+=r.measureText(l).width+n}},drawImage(t,e,s,i,r){e-=this.startYOffset,this.parent.imageManager.draw(s,this.context,t,e,i,this.autoRound)}};const R=Phaser.Utils.Objects.GetValue,Y=g,z=c;class I{constructor(t){this.prop={},this.resetFromJSON(t)}resetFromJSON(t){this.text=R(t,"text",""),this.x=R(t,"x",0),this.y=R(t,"y",0),this.width=R(t,"width",0),this.ascent=R(t,"ascent",0),this.descent=R(t,"descent",0);var e=R(t,"height",null);null==e&&(e=this.ascent+this.descent),this.height=e;var s=R(t,"prop",null);null===s&&(s={}),this.prop=s,this.newLineMode=R(t,"newLineMode",0),this.startIndex=R(t,"startIndex",0)}get plainText(){var t=this.text;return this.newLineMode===z&&(t+="\n"),t}get wrapText(){var t=this.text;return this.newLineMode!==Y&&(t+="\n"),t}get rawTextLength(){var t=this.text.length;return this.newLineMode===z&&(t+=1),t}get endIndex(){return this.startIndex+this.rawTextLength}get lastX(){return this.x+this.width}get isTextPen(){return""!==this.text}get isImagePen(){return!!this.prop.img}get hasAreaMarker(){return!!this.prop.area||!!this.prop.url}}class _{constructor(t){this.pens=t||[],this.maxAscent=0,this.maxDescent=0,this.lineHeight=0,this.startOffset=0,this.endOffset=0}reset(){return this.pens.length=0,this.maxAscent=0,this.maxDescent=0,this.lineHeight=0,this.startOffset=0,this.endOffset=0,this}addPen(t){return this.pens.push(t),t.ascent>this.maxAscent&&(this.maxAscent=t.ascent),t.descent>this.maxDescent&&(this.maxDescent=t.descent),this}get length(){return this.pens.length}get lastPen(){return this.pens[this.pens.length-1]}}var B=function(t,e){var s=Array.isArray(t);if(void 0===e?e=s?[]:{}:function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}(e),s){e.length=t.length;for(var i=0,r=t.length;i<r;i++)e[i]=t[i]}else for(var n in t)e[n]=t[n];return e},X=function(){};const $=Phaser.Utils.Objects.GetFastValue,D=g,j=p;class U{constructor(t){this.pens=[],this.lines=[],this.maxLinesWidth=void 0,this.pensPool=t.pensPool,this.linesPool=t.linesPool,this.tagToText=$(t,"tagToText",X),this.tagToTextScope=$(t,"tagToTextScope",void 0)}destroy(){this.clear(),this.tagToText=void 0,this.tagToTextScope=void 0}clear(){for(var t=0,e=this.lines.length;t<e;t++){var s=this.lines[t];s&&s.reset?s.reset():s&&(s.length=0)}this.pensPool.pushMultiple(this.pens),this.linesPool.pushMultiple(this.lines),this.maxLinesWidth=void 0}addTextPen(t,e,s,i,r,n,a){var h=this.pensPool.pop();if(null==h&&(h=new I),G.text=t,G.x=e,G.y=s,G.width=i,a){var o=null!=a.ascent?a.ascent:0,l=null!=a.descent?a.descent:0,d=null!=a.height?a.height:o+l;G.ascent=o,G.descent=l,G.height=d}else G.ascent=0,G.descent=0,G.height=0;return G.prop=r,G.newLineMode=n,h.resetFromJSON(G),this.addPen(h),this}addImagePen(t,e,s,i,r){return this.addTextPen("",t,e,s,i,D,r),this}addNewLinePen(){var t=this.lastPen,e=t?t.lastX:0,s=t?t.y:0,i=t?B(t.prop):null;return this.addTextPen("",e,s,0,i,j),this}addPen(t){var e=this.lastPen;t.startIndex=null==e?0:e.endIndex,this.pens.push(t);var s=this.lastLine;null==s?(s=this.newLine(),this.lines.push(s)):s.pens||(s=this.convertLine(s),this.lines[this.lines.length-1]=s),s.addPen?s.addPen(t):s.push(t),t.newLineMode!==D&&(s=this.newLine(),this.lines.push(s)),this.maxLinesWidth=void 0}clone(t){null==t&&(t=new U),t.clear();for(var e=0,s=this.lines.length;e<s;e++)for(var i=this.lines[e],r=i&&i.pens?i.pens:i,n=0,a=r.length;n<a;n++){var h=r[n];t.addPen(h.text,h.x,h.y,h.width,B(h.prop),h.newLineMode)}return t}get lastPen(){return this.pens[this.pens.length-1]}get lastLine(){return this.lines[this.lines.length-1]}getLineStartIndex(t){if(t>=this.lines.length)return this.getLineEndIndex(t);var e=this.lines[t],s=e&&e.pens?e.pens:e;return s&&s[0]?s[0].startIndex:0}getLineEndIndex(t){t>=this.lines.length&&(t=this.lines.length-1);var e,s,i=!1;for(e=t;e>=0;e--){var r;if(i=null!=(r=(s=this.lines[e])&&s.pens?s.pens:s)&&r.length>0)break}return i?(r=s&&s.pens?s.pens:s)[r.length-1].endIndex:0}getLineWidth(t){var e=this.lines[t];if(!e)return 0;var s=e&&e.pens?e.pens:e,i=s[s.length-1];return null==i?0:i.lastX}getMaxLineWidth(){if(void 0!==this.maxLinesWidth)return this.maxLinesWidth;for(var t,e=0,s=0,i=this.lines.length;s<i;s++)(t=this.getLineWidth(s))>e&&(e=t);return this.maxLinesWidth=e,e}getLineWidths(){for(var t=[],e=0,s=this.lines.length;e<s;e++)t.push(this.getLineWidth(e));return t}get linesCount(){return this.lines.length}newLine(){return this.convertLine(this.linesPool.pop())}convertLine(t){return t?t.pens?t.reset():Array.isArray(t)?new _(t).reset():new _:new _}get plainText(){for(var t="",e=this.pens,s=0,i=e.length;s<i;s++)t+=e[s].plainText;return t}get rawTextLength(){for(var t=0,e=this.pens,s=0,i=this.pens.length;s<i;s++)t+=e[s].rawTextLength;return t}getSliceTagText(t,e,s){var i=this.lastPen;if(null==i)return"";var r=i.endIndex;void 0!==t&&0!==t||(t=-1),void 0!==e&&e!==r||(e=r+1),void 0===s&&(s=!1);for(var n,a,h,o,l,d,u="",g=0,c=this.pens.length;g<c&&((o=(n=this.pens[g]).endIndex)<=t||(n=this.pens[g],a=s?n.wrapText:n.plainText,l=n.prop,(h=n.startIndex)>=t&&o<=e||(a=a.substring(t-h,e-h)),this.tagToTextScope?u+=this.tagToText.call(this.tagToTextScope,a,l,d):u+=this.tagToText(a,l,d),d=l,!(o>=e)));g++);return u}get length(){return this.lines.length}set length(t){this.clear()}}var G={};class K{constructor(){this.items=[]}destroy(){this.clear(),this.items=void 0}pop(){return this.items.length>0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const V=Phaser.Geom.Rectangle;var N=new K;class J{constructor(){this.hitAreas=[]}destroy(){this.clear()}clear(){for(var t=0,e=this.hitAreas.length;t<e;t++)this.hitAreas[t].data=null;return N.pushMultiple(this.hitAreas),this}add(t,e,s,i,r){void 0===r&&(r={});var n=N.pop();return null===n?n=new V(t,e,s,i):n.setTo(t,e,s,i),n.data=r,this.hitAreas.push(n),this}getFirst(t,e){for(var s=0,i=this.hitAreas.length;s<i;s++){var r=this.hitAreas[s];if(r.contains(t,e))return r}return null}getByKey(t){for(var e=0,s=this.hitAreas.length;e<s;e++){var i=this.hitAreas[e];if(i.data.key===t)return i}return null}drawBounds(t,e,s){void 0===e&&(e=16777215),s&&t.save().translateCanvas(s.x,s.y).rotateCanvas(s.rotation).scaleCanvas(s.scaleX,s.scaleY);for(var i=0,r=this.hitAreas.length;i<r;i++){var n=this.hitAreas[i];t.lineStyle(1,e).strokeRect(n.x,n.y,n.width,n.height)}return s&&t.restore(),this}}var q=function(t,e,s,i){var r=this.hitAreaManager.getFirst(e,s);if(null!==r){var n=r.data.key;Z.call(this,"areadown",n,t,e,s,i),r.data&&(r.data.isDown=!0)}},E=function(t,e,s,i){var r=this.hitAreaManager.getFirst(e,s);if(null!==r){var n=r.data.key;if(Z.call(this,"areaup",n,t,e,s,i),r.data){if(r.data.isDown){if(Z.call(this,"areaclick",n,t,e,s,i),!r.data)return;var a=r.data.url;a&&window.open(a,"_blank")}r.data.isDown=!1}}},Q=function(t,e,s,i){if(null!==e){var r=(a=this.hitAreaManager.getFirst(e,s))?a.data.key:null;if(this.lastHitAreaKey!==r){if(null!==this.lastHitAreaKey){Z.call(this,"areaout",this.lastHitAreaKey,t,e,s,i);var n=this.hitAreaManager.getByKey(this.lastHitAreaKey);n&&(this.urlTagCursorStyle&&tt(this.scene,n,""),n.data.isDown=!1)}null!==r&&(Z.call(this,"areaover",r,t,e,s,i),a.data&&this.urlTagCursorStyle&&tt(this.scene,a,this.urlTagCursorStyle)),this.lastHitAreaKey=r}}else{var a;null!==this.lastHitAreaKey&&(Z.call(this,"areaout",this.lastHitAreaKey,t,e,s,i),(a=this.hitAreaManager.getByKey(this.lastHitAreaKey))&&a.data&&(a.data.isDown=!1),this.lastHitAreaKey=null)}},Z=function(t,e,s,i,r,n){this.parent.emit(`${t}-${e}`,s,i,r,n),this.parent.emit(t,e,s,i,r,n)},tt=function(t,e,s){e&&e.data&&e.data.url&&(t.input.manager.canvas.style.cursor=s)};const et=Phaser.GameObjects.Components.TransformMatrix,st=Phaser.Math.TransformXY;var it,rt,nt={},at=/^[\x00-\x7F]+$/,ht=function(t){return at.test(t)};const ot=g,lt=c,dt=p,ut=f,gt=v,ct=y,pt=x;var ft=function(t,e,s,i,r,n,a){i<=0&&(s=ut);var h=[];if(!t||!t.length)return h;for(var o,l,d,u=s===ut,g=t.split(pt),c=0,p=g.length;c<p;c++)if(o=g[c],d=c===p-1?ot:lt,u){var f=e.measureText(o).width+r*o.length;h.push(a.getLine(o,f,d))}else{if(l=0===c?i-n:i,o.length<=100&&(f=e.measureText(o).width+r*o.length)<=l){h.push(a.getLine(o,f,d));continue}for(var v,y,x,w=vt(o,s),S="",m=0,k=0,T=w.length;k<T;k++){if(v=w[k],(y=e.measureText(v).width+r*v.length)>i&&yt(v)){""!==S?h.push(a.getLine(S,m,dt)):0===k&&n>0&&h.push(a.getLine("",0,dt)),h.push(...ft(v,e,ct,i,r,0,a));var P=h.pop();S=P.text,m=P.width,a.freeLine(P)," "===S&&(S="",m=0)}else(x=m+y)>l?(h.push(a.getLine(S,m,dt)),S=v,m=y,l=i):(S+=v,m=x);k===T-1&&h.push(a.getLine(S,m,d))}}return h},vt=function(t,e){var s;switch(e){case gt:s=[];for(var i=0,r=(t=t.split(" ")).length;i<r;i++){var n=t[i];i<r-1?s.push(n+" "):""!==n&&s.push(n)}break;case ct:s=t.split("");break;default:for(s=[],i=0,r=(t=t.split(" ")).length;i<r;i++)n=t[i],i<r-1?ht(n)?s.push(n+" "):(s.push(...n.split("")),s.push(" ")):""!==n&&(ht(n)?s.push(n):s.push(...n.split("")))}return s},yt=function(t){switch(t.length){case 1:return!1;case 2:return" "!==t.charAt(1);default:return!0}};const xt=Phaser.Utils.Objects.GetValue,wt=f,St=g,mt=p;class kt{constructor(t){this.parent=t.parent,this.scene=this.parent.scene,this.context=xt(t,"context",null),this.canvas=this.context.canvas,this.parser=xt(t,"parser",null),this.defaultStyle=xt(t,"style",null),this.autoRound=!0,this.pensPool=t.pensPool,this.linesPool=t.linesPool,this.wrapTextLinesPool=t.wrapTextLinesPool,this.penManager=this.newPenManager(),this._tmpPenManager=null,this.hitAreaManager=new J,this.lastHitAreaKey=null,this.urlTagCursorStyle=null}destroy(){this.parent=void 0,this.scene=void 0,this.context=void 0,this.canvas=void 0,this.parser=void 0,this.defaultStyle=void 0,this.penManager&&(this.penManager.destroy(),this.penManager=void 0),this._tmpPenManager&&(this._tmpPenManager.destroy(),this._tmpPenManager=void 0),this.hitAreaManager&&(this.hitAreaManager.destroy(),this.hitAreaManager=void 0),this.pensPool=void 0,this.linesPool=void 0,this.wrapTextLinesPool=void 0}updatePenManager(t,e,s,i,r){if(void 0===r&&(r=this.penManager),r.clear(),""===t)return r;var n=this.parent.style;if(n.isWrapFitMode){var a=this.parent.padding;s=n.fixedWidth-a.left-a.right}for(var h,o,l,d,g,c=this.canvas,p=this.context,f=0,v=0,y=n.wrapCallback,x=n.wrapCallbackScope,w=!y,S=!0,m=this.parser.splitText(t),k=this.wrapTextLinesPool,T=0,P=m.length;T<P;T++)if(h=(d=this.parser.tagTextToProp(m[T],o)).plainText,(o=d.prop).img){var O=this.addImagePen(o,f,v,s,e,i,r);f=O.x,v=O.y}else if(""!==h){p.save(),(l=this.parser.propToContextStyle(this.defaultStyle,o)).buildFont(),l.syncFont(c,p),l.syncStyle(c,p);var b=u(l);if(w)g=ft(h,p,e,s,l.letterSpacing,f,k);else{var M;"string"==typeof(g=y.call(x,h,p,s,l.letterSpacing,f))&&(g=g.split("\n"));for(var C=0,L=g.length;C<L;C++)"string"==typeof(M=g[C])?g[C]=k.getLine(M,p.measureText(M).width,C<L-1?mt:St):S=!1}for(C=0,L=g.length;C<L;C++)M=g[C],r.addTextPen(M.text,f,v,M.width,B(o),M.newLineMode,b),M.newLineMode!==St?(f=0,v+=i):f+=M.width;S&&k.freeLines(g),g=null,p.restore()}var F=r.lines;for(T=0,P=F.length;T<P;T++){var A=F[T].pens,W=A[A.length-1];W&&(W.width+=this.parser.getStrokeThinkness(this.defaultStyle,W.prop),W.width-=this.parser.getLetterSpacing(this.defaultStyle,W.prop))}return this.updateLineOffsets(F,n),r}addImagePen(t,e,s,i,r,n,a){var h,o=this.imageManager.getOuterWidth(t.img),l=this.imageManager.getOuterHeight(t.img);if(l>0){var d=this.defaultStyle.metrics.ascent,u=l-d;u<0&&(u=0),h={ascent:d,descent:u,height:d+u}}return i>0&&r!==wt&&i<e+o&&(a.addNewLinePen(),s+=n,e=0),a.addImagePen(e,s,o,B(t),h),{x:e+=o,y:s}}updateLineOffsets(t,e){for(var s=e.lineSpacing,i=this.defaultStyle.metrics,r=i.ascent,n=i.descent,a=0,h=e.fixedLineHeightMode,o=0,l=t.length;o<l;o++){var d=t[o],u=d.maxAscent,g=d.maxDescent;(h||0===u&&0===g)&&(u=r,g=n),d.maxAscent=u,d.maxDescent=g,d.lineHeight=u+g,d.startOffset=a,d.endOffset=a+d.lineHeight;for(var c=a+u-r,p=d.pens,f=0,v=p.length;f<v;f++)p[f].y=c;a=d.endOffset+s}}get startXOffset(){return this.defaultStyle.xOffset}get startYOffset(){return this.defaultStyle.metrics.ascent}get lines(){return this.penManager.lines}get displayLinesCount(){var t=this.penManager.linesCount,e=this.defaultStyle.maxLines;return e>0&&t>e&&(t=e),t}get linesWidth(){return Math.ceil(this.penManager.getMaxLineWidth())}get linesHeight(){var t=this.displayLinesCount;return this.getLinesHeight(0,t)}getLineHeight(t){var e=t?t.lineHeight:0;if(e>0)return e;var s=this.defaultStyle.metrics;return s.ascent+s.descent}getLinesHeight(t,e){var s=this.penManager.lines,i=s.length;if(void 0===t&&(t=0),(void 0===e||e>i)&&(e=i),e<=t)return 0;for(var r=0,n=t;n<e;n++)r+=this.getLineHeight(s[n]);var a=e-t;return a>1&&(r+=this.defaultStyle.lineSpacing*(a-1)),r}get imageManager(){return this.parent.imageManager}get rtl(){return this.parent.style.rtl}newPenManager(){return new U({pensPool:this.pensPool,linesPool:this.linesPool,tagToText:this.parser.propToTagText,tagToTextScope:this.parser})}get tmpPenManager(){return null===this._tmpPenManager&&(this._tmpPenManager=this.newPenManager()),this._tmpPenManager}getPlainText(t,e,s){var i;if(null==t)i=this.penManager.plainText;else{var r=this.parser.splitText(t,1);i="";for(var n=0,a=r.length;n<a;n++)i+=r[n]}return null==e&&null==s||(null==e&&(e=0),null==s&&(s=i.length),i=i.substring(e,s)),i}getPenManager(t,e){if(void 0===t)return this.copyPenManager(e,this.penManager);void 0===e&&(e=this.newPenManager());var s=this.defaultStyle;return this.updatePenManager(t,s.wrapMode,s.wrapWidth,s.lineHeight,e),e}getText(t,e,s,i){if(null==t)return this.penManager.getSliceTagText(e,s,i);var r=this.tmpPenManager,n=this.defaultStyle;return this.updatePenManager(t,n.wrapMode,n.wrapWidth,n.lineHeight,r),r.getSliceTagText(e,s,i)}copyPenManager(t,e){return void 0===e&&(e=this.penManager),e.copy(t)}getTextWidth(t){return void 0===t&&(t=this.penManager),t.getMaxLineWidth()}getLastPen(t){return void 0===t&&(t=this.penManager),t.lastPen}}var Tt={setInteractive:function(){this.parent.on("pointerdown",q,this).on("pointerup",E,this).on("pointermove",Q,this).on("pointerover",Q,this).on("pointerout",(function(t,e){Q.call(this,t,null,null,e)}),this)},getHitArea:function(t,e,s){var i=function(t,e,s,i,r){void 0===i&&(i=t.scene.cameras.main),void 0===r?r={}:!0===r&&(r=nt);var n=i.scrollX,a=i.scrollY,h=e+n*t.scrollFactorX-n,o=s+a*t.scrollFactorY-a;return t.parentContainer?(void 0===it&&(it=new et,rt=new et),t.getWorldTransformMatrix(it,rt),it.applyInverse(h,o,r)):st(h,o,t.x,t.y,t.rotation,t.scaleX,t.scaleY,r),r.x+=t.displayOriginX,r.y+=t.displayOriginY,r}(this.parent,t,e,s,!0),r=this.hitAreaManager.getFirst(i.x,i.y);if(null!==r)return r.data.key}};Object.assign(kt.prototype,H,Tt);class Pt extends K{freeLine(t){if(t)return this.push(t),this}freeLines(t){if(t)return this.pushMultiple(t),this}getLine(t,e,s){var i=this.pop();return null===i&&(i={}),i.text=t,i.width=e,i.newLineMode=s,i}}const Ot=Phaser.Utils.Objects.IsPlainObject,bt=Phaser.Utils.Objects.GetValue;var Mt=function(t,e){Ot(t)?t=(e=t).key:void 0===e&&(e={key:t}),e.hasOwnProperty("key")||(e.key=t);var s=e.key,i=e.frame,r=e.width,n=e.height;if(void 0===r||void 0===n){var a=this.textureManager.getFrame(s,i),h=a?a.cutWidth:0,o=a?a.cutHeight:0;void 0===r&&void 0===n?(r=h,n=o):void 0===r?r=h*(n/o):void 0===n&&(n=o*(r/h))}this.images[t]={key:s,frame:i,width:r,height:n,y:bt(e,"y",0),left:bt(e,"left",0),right:bt(e,"right",0),originX:bt(e,"originX",0),originY:bt(e,"originY",0),tintFill:bt(e,"tintFill",!1)}};const Ct=Phaser.Display.Canvas.CanvasPool;class Lt{constructor(t){this.textureManager=t.sys.textures,this.images={}}destroy(){this.textureManager=void 0,this.images=void 0}add(t,e){if("string"==typeof t)Mt.call(this,t,e);else if(Array.isArray(t))for(var s=0,i=(r=t).length;s<i;s++)Mt.call(this,r[s]);else{var r=t;for(var t in r)Mt.call(this,t,r[t])}return this}has(t){return this.images.hasOwnProperty(t)}remove(t){return this.has(t)&&delete this.images[t],this}get(t){return this.has(t)||this.textureManager.exists(t)&&this.add(t),this.images[t]}getOuterWidth(t){var e=this.get(t);return e?e.width+e.left+e.right:0}getOuterHeight(t){var e=this.get(t);return e?e.height:0}getFrame(t){var e=this.get(t);return e?this.textureManager.getFrame(e.key,e.frame):void 0}hasTexture(t){return!!this.getFrame(t)}}var Ft={draw:function(t,e,s,i,r,n){var a=this.get(t);if(a){var h=this.textureManager.getFrame(a.key,a.frame),o=a.width,l=a.height;s+=a.left-a.originX*o,i+=a.y-a.originY*l,a.tintFill||(r=void 0),function(t,e,s,i,r,n,a,h){void 0===s&&(s=0),void 0===i&&(i=0),void 0===r&&(r=t.cutWidth),void 0===n&&(n=t.cutHeight),void 0===h&&(h=!1),h&&(s=Math.round(s),i=Math.round(i));var o=e.getContext("2d",{willReadFrequently:!0});if(a){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=a,d.fillRect(0,0,r,n),o.drawImage(l,0,0,r,n,s,i,r,n),Ct.remove(l)}else o.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,s,i,r,n)}(h,e.canvas,s,i,o,l,r,n)}}};Object.assign(Lt.prototype,Ft);const At=Phaser.Utils.Objects.IsPlainObject,Wt=Phaser.DOM.AddToDOM,Ht=Phaser.Display.Canvas.CanvasPool,Rt=Phaser.GameObjects.GameObject,Yt=Phaser.Utils.Objects.GetValue,zt=Phaser.DOM.RemoveFromDOM,It=x,_t=Phaser.Utils.String.UUID,Bt=Phaser.Math.Clamp;var Xt=null,$t=null,Dt=null;class jt extends n{constructor(t,e,s,i,r,n,a){if(At(e)){var h=e;e=Yt(h,"x",0),s=Yt(h,"y",0),i=Yt(h,"text",""),r=Yt(h,"style")}if(void 0===e&&(e=0),void 0===s&&(s=0),super(t,n),this.renderer=t.sys.game.renderer,this.setPosition(e,s),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(!0),this.canvas=Ht.create(this),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this._imageManager=void 0,r){if(r.hasOwnProperty("align")){var o=r.align;delete r.align,r.halign=o}r.hasOwnProperty("stroke")&&!r.hasOwnProperty("strokeThickness")&&(r.strokeThickness=1)}this.style=new k(this,r);var l,d,u,g=Yt(r,"images",void 0);g&&this.addImage(g),this.autoRound=!0,this._text=void 0,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.dirty=!1,this._scrollY=0,0===this.style.resolution&&(this.style.resolution=1),this._crop=this.resetCropObject(),this._textureKey=_t(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.frame=this.texture.get(),this.frame.source.resolution=this.style.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),Yt(r,"sharedPool",!0)?(Xt||(Xt={},$t=new K,Dt=new Pt,this.scene.game.events.once("destroy",(function(){Xt=null,$t=null,Dt=null}))),Xt.hasOwnProperty(n)||(Xt[n]=new K),l=Xt[n],d=$t,u=Dt):(l=new K,d=new K,u=new Pt),this.canvasText=new kt({parent:this,context:this.context,parser:a,style:this.style,pensPool:l,linesPool:d,wrapTextLinesPool:u}),this.parser=a,this.initRTL(),r&&r.padding&&this.setPadding(r.padding),this.setText(i),this.setUrlTagCursorStyle(Yt(r,"urlTagCursorStyle","pointer")),Yt(r,"interactive",!1)&&this.setInteractive()}preDestroy(){zt(this.canvas),this.canvasText.destroy(),this.canvasText=void 0,this._imageManager&&(this._imageManager.destroy(),this._imageManager=void 0),Ht.remove(this.canvas);var t=this.texture;t&&t.destroy()}set text(t){this.setText(t)}get text(){return this._text}get topScrollY(){return 0}get bottomScrollY(){var t=this.contentHeight-this.viewportHeight;return t>0?-t:0}get scrollY(){return this._scrollY}set scrollY(t){this._scrollY!==t&&(this._scrollY=t,this.updateText(!1))}setScrollY(t,e){return void 0===e&&(e=!1),e&&(t=Bt(t,this.bottomScrollY,this.topScrollY)),this.scrollY=t,this}addScrollY(t,e){return this.setScrollY(this.scrollY+t,e)}get t(){var t=this.bottomScrollY;return 0===t?0:this._scrollY/t}set t(t){this.setT(t)}setT(t,e){void 0===e&&(e=!1),e&&(t=Bt(t,0,1));var s=this.bottomScrollY*t;return this.setScrollY(s,!1)}addT(t,e){return this.setT(this.t+t,e)}scrollToTop(){return this.setScrollY(this.topScrollY)}scrollToBottom(){return this.setScrollY(this.bottomScrollY)}initRTL(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",Wt(this.canvas,this.scene.sys.canvas),this.originX=1)}setRTL(t){void 0===t&&(t=!0);var e=this.style;if(e.rtl===t)return this;if(e.rtl=t,t?(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",Wt(this.canvas,this.scene.sys.canvas)):(this.canvas.dir="ltr",this.context.direction="ltr"),"left"===e.halign?e.halign="right":"right"===e.halign&&(e.halign="left"),this._imageManager){var s=this._imageManager.images;for(var i in s)s[i].originX=1-s[i].originX}return this}setText(t){return(t=function(t){return null==t?t="":Array.isArray(t)?t=t.join("\n"):"number"==typeof t&&(t=t.toString()),t}(t))===this._text||(this._text=t,this.updateText()),this}setPadding(t,e,s,i){if("object"==typeof t){var r=t,n=Yt(r,"x",null);null!==n?(t=n,s=n):(t=Yt(r,"left",0),s=Yt(r,"right",t));var a=Yt(r,"y",null);null!==a?(e=a,i=a):(e=Yt(r,"top",0),i=Yt(r,"bottom",e))}else void 0===t&&(t=0),void 0===e&&(e=t),void 0===s&&(s=t),void 0===i&&(i=e);return this.padding.left=t,this.padding.top=e,this.padding.right=s,this.padding.bottom=i,this.updateText(!1)}updateText(t){void 0===t&&(t=!0);var e=this.canvasText,s=this.style;t&&e.updatePenManager(this._text,s.wrapMode,s.wrapWidth,s.lineHeight);var i,r,n=this.padding,a=Math.ceil(e.linesWidth);0===s.fixedWidth?(this.width=a+n.left+n.right,i=a):(this.width=s.fixedWidth,(i=this.width-n.left-n.right)<a&&(i=a)),0===s.fixedHeight?(this.height=e.linesHeight+n.top+n.bottom,r=e.linesHeight):(this.height=s.fixedHeight,(r=this.height-n.top-n.bottom)<e.linesHeight&&(r=e.linesHeight));var h=this.width,o=this.height;this.updateDisplayOrigin();var l=s.resolution;h*=l,o*=l,h=Math.max(Math.ceil(h),1),o=Math.max(Math.ceil(o),1);var d=this.canvas,u=this.context;d.width!==h||d.height!==o?(d.width=h,d.height=o,this.frame.setSize(h,o)):u.clearRect(0,0,h,o),u.save(),u.scale(l,l);var g=this.style.rtl?n.right:n.left,c=n.top+this._scrollY;e.draw(g,c,i,r),u.restore(),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(d,this.frame.source.glTexture,!0),this.frame.glTexture.spectorMetadata={textureKey:"BBCodeText Game Object"}),this.dirty=!0;var p=this.input;return p&&!p.customHitArea&&(p.hitArea.width=this.width,p.hitArea.height=this.height),this}toJSON(){var t=Components.ToJSON(this),e={autoRound:this.autoRound,text:this._text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t}setInteractive(t,e,s){var i=!!this.input;return Rt.prototype.setInteractive.call(this,t,e,s),i||this.canvasText.setInteractive(),this}setUrlTagCursorStyle(t){return this.urlTagCursorStyle=t,this}get urlTagCursorStyle(){return this.canvasText.urlTagCursorStyle}set urlTagCursorStyle(t){this.canvasText.urlTagCursorStyle=t}getWrappedText(t,e,s){return"number"==typeof t&&(s=e,e=t,t=void 0),(t=this.canvasText.getText(t,e,s,!0)).split(It)}getPlainText(t,e,s){return"number"==typeof t&&(s=e,e=t,t=void 0),this.canvasText.getPlainText(t,e,s)}getText(t,e,s,i){return"number"==typeof t&&(i=s,s=e,e=t,t=void 0),void 0===i&&(i=!1),this.canvasText.getText(t,e,s,i)}getSubString(t,e,s){return"number"==typeof t&&(s=e,e=t,t=void 0),this.getText(t,e,s)}copyPenManager(t){return this.canvasText.copyPenManager(t)}getPenManager(t,e){return this.canvasText.getPenManager(t,e)}setSize(t,e){return this.setFixedSize(t,e)}resize(t,e){return this.setFixedSize(t,e)}get imageManager(){return this._imageManager||(this._imageManager=new Lt(this.scene)),this._imageManager}addImage(t,e){return this.imageManager.add(t,e),this}drawAreaBounds(t,e){return this.canvasText.hitAreaManager.drawBounds(t,e,this),this}generateTexture(t,e,s,i,r){var n=this.canvas;return void 0===i?i=n.width:i*=this.resolution,void 0===r?r=n.height:r*=this.resolution,function(t,e,s,i,r,n,a){var h,o=t.sys.textures,l=t.renderer;void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=e.width),void 0===a&&(a=e.height);var d=(h=o.exists(s)?o.get(s):o.createCanvas(s,n,a)).getSourceImage();d.width!==n&&(d.width=n),d.height!==a&&(d.height=a);var u=d.getContext("2d",{willReadFrequently:!0});u.clearRect(0,0,n,a),u.drawImage(e,i,r,n,a),l.gl&&h&&l.canvasToTexture(d,h.source[0].glTexture,!0,0)}(this.scene,n,t,e,s,i,r),this}getHitArea(t,e,s){return this.canvasText.getHitArea(t,e,s)}get viewportHeight(){var t=this.padding,e=this.height-t.top-t.bottom;return Math.max(e,0)}get contentHeight(){return this.canvasText.linesHeight}}var Ut={appendText:function(t,e){var s;return t||0===t||(t=""),void 0===e&&(e=!0),Array.isArray(t)&&(t=t.join("\n")),(s=e?`${this.text}\n${t}`:`${this.text}${t}`)!=this.text&&this.setText(s),this}};Object.assign(jt.prototype,Ut);var Gt={plainText:null,prevProp:null},Kt=new k;class Vt{constructor(t){void 0===t&&(t={}),this.tags=t}addTag(t,e){this.tags[t]=e}getTag(t){return this.tags[t]}splitText(t,e){for(var s=[],i=0;;){var r=qt.exec(t);if(!r)break;var n=r[0],a=qt.lastIndex-n.length;if(i<a&&s.push(t.substring(i,a)),void 0===e)s.push(n);else if(1===e)if(Et.test(n)){var h=n.match(Qt);s.push(h[2])}else Zt.test(n)&&(h=n.match(te),s.push(h[2]));i=qt.lastIndex}var o=t.length;return i<o&&s.push(t.substring(i,o)),s}tagTextToProp(t,e){var s,i;if(Et.test(t)){if(null!=(a=t.match(Qt))){var r=a[1],n=this.tags;(i=n.hasOwnProperty(r)?n[r]:{})._class=r,s=a[2]}}else if(Zt.test(t)){var a;if(null!=(a=t.match(te))){var h=a[1];(i=Nt(h))._style=h,s=a[2]}}null==s&&(s=t),null==i&&(i={});var o=Gt;return o.plainText=s,o.prop=i,o}propToContextStyle(t,e){var s=Kt;if(e.hasOwnProperty("img"))s.image=e.img;else{if(s.image=null,e.hasOwnProperty("family")||e.hasOwnProperty("fontFamily")||e.hasOwnProperty("font-family")){var i=e.hasOwnProperty("family")?e.family:e.hasOwnProperty("fontFamily")?e.fontFamily:e["font-family"];s.fontFamily=i}else s.fontFamily=t.fontFamily;if(e.hasOwnProperty("size")||e.hasOwnProperty("fontSize")||e.hasOwnProperty("font-size")){var r=e.hasOwnProperty("size")?e.size:e.hasOwnProperty("fontSize")?e.fontSize:e["font-size"];"number"==typeof r&&(r=`${r}px`),s.fontSize=r}else s.fontSize=t.fontSize;if(e.hasOwnProperty("style")||e.hasOwnProperty("fontStyle")||e.hasOwnProperty("font-style")){var n=e.hasOwnProperty("style")?e.style:e.hasOwnProperty("fontStyle")?e.fontStyle:e["font-style"];s.fontStyle=n}else s.fontStyle=t.fontStyle;if(e.hasOwnProperty("color")||e.hasOwnProperty("font-color")){var a=e.hasOwnProperty("color")?e.color:e["font-color"];s.color=a}else s.color=t.color;if(e.hasOwnProperty("stroke")){var h=e.stroke;s.stroke=h.hasOwnProperty("color")?h.color:t.stroke,s.strokeThickness=h.hasOwnProperty("thickness")?h.thickness:t.strokeThickness}else s.stroke=t.stroke,s.strokeThickness=t.strokeThickness}if(e.hasOwnProperty("shadow")){var o=e.shadow;s.shadowColor=o.hasOwnProperty("color")?o.color:t.shadowColor,s.shadowOffsetX=o.hasOwnProperty("offsetX")?o.offsetX:t.shadowOffsetX,s.shadowOffsetY=o.hasOwnProperty("offsetY")?o.offsetY:t.shadowOffsetY,s.shadowBlur=o.hasOwnProperty("blur")?o.blur:t.shadowBlur,s.shadowStroke=!0,s.shadowFill=!0}else s.shadowColor=t.shadowColor,s.shadowOffsetX=t.shadowOffsetX,s.shadowOffsetY=t.shadowOffsetY,s.shadowBlur=t.shadowBlur,s.shadowStroke=t.shadowStroke,s.shadowFill=t.shadowFill;if(e.hasOwnProperty("u")||e.hasOwnProperty("underline")){var l=e.hasOwnProperty("u")?e.u:e.underline;s.underlineColor=l.hasOwnProperty("color")?l.color:t.underlineColor,s.underlineThickness=l.hasOwnProperty("thickness")?l.thickness:t.underlineThickness,s.underlineOffset=l.hasOwnProperty("offset")?l.offset:t.un