@petkoneo/phaser3-rex-plugins
Version:
8 lines (7 loc) • 48.4 kB
JavaScript
var t,e;t=void 0,e=function(){var t=Phaser.Renderer.WebGL.Utils,e={renderWebGL:function(e,s,r,i){if(0!==s.width&&0!==s.height){r.addToRenderList(s);var n=s.frame,a=n.width,h=n.height,o=t.getTintAppendFloatAlpha,l=e.pipelines.set(s.pipeline,s),u=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,r.alpha*s._alphaTL),o(s.tintTopRight,r.alpha*s._alphaTR),o(s.tintBottomLeft,r.alpha*s._alphaBL),o(s.tintBottomRight,r.alpha*s._alphaBR),s.tintFill,0,0,r,i,!1,u),e.pipelines.postBatch(s)}},renderCanvas:function(t,e,s,r){0!==e.width&&0!==e.height&&(s.addToRenderList(e),t.batchSprite(e,e.frame,s,r))}};const s=Phaser.Display.Canvas.CanvasPool;var r=!1;!function(t){if(!r){void 0===t&&(t=60);var e=Phaser.VERSION.split("."),s=parseInt(e[0]);if(3===s){var i=parseInt(e[1]);i<t&&console.error(`Minimum supported version : ${s}.${i}`)}else console.error(`Can't supported version : ${s}`);r=!0}}();const i=Phaser.GameObjects.GameObject;class n extends i{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,r,i,n){return this.style.setShadow(t,e,s,r,i,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}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,r){void 0===r&&(r={});var i=s.create(this),n=i.getContext("2d",{willReadFrequently:!0});t.syncFont(i,n);var a=n.measureText(e),h=Math.ceil(a.width*t.baselineX),o=h,l=2*o;if(o=o*t.baselineY|0,i.width=h,i.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),r.left=0,0===h||0===l||!n.getImageData(0,0,h,l))return s.remove(i),r;for(var u=n.getImageData(0,0,h,l).data,d=!1,g=0;g<h;g++){for(var c=0;c<l;c++)if(255!==u[4*(c*h+g)]){r.left=g,d=!0;break}if(d)break}return s.remove(i),r}(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],xOffset:["xOffset",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 u=Phaser.Display.Canvas.CanvasPool;var d=function(t){var e=u.create(this),s=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,s);var r=s.measureText(t.testString);if("actualBoundingBoxAscent"in r){var i=r.actualBoundingBoxAscent,n=r.actualBoundingBoxDescent,a={ascent:i,descent:n,fontSize:i+n};return u.remove(e),a}var h=Math.ceil(r.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,u.remove(e),a;var d,g,c=s.getImageData(0,0,h,l).data,p=c.length,f=4*h,v=0,y=!1;for(d=0;d<o;d++){for(g=0;g<f;g+=4)if(255!==c[v+g]){y=!0;break}if(y)break;v+=f}for(a.ascent=o-d,v=p-f,y=!1,d=l;d>o;d--){for(g=0;g<f;g+=4)if(255!==c[v+g]){y=!0;break}if(y)break;v-=f}return a.descent=d-o,a.fontSize=a.ascent+a.descent,u.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},k=Phaser.Utils.Objects.GetAdvancedValue,T=Phaser.Utils.Objects.GetValue;class m{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 r=t.wordWrap;r.hasOwnProperty("width")&&(t.wrap={mode:"word",width:r.width})}if(t&&t.hasOwnProperty("wrap")){var i=t.wrap;if(i.hasOwnProperty("mode")){var n=i.mode;"string"==typeof n&&(i.mode=w[n])}else i.hasOwnProperty("width")&&(i.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],u=l[0],g=s?l[1]:this[h],c=l[2];if("wrapCallback"===h||"wrapCallbackScope"===h)this[h]=T(t,u,g);else{var p=k(t,u,g);c&&(p=c(p)),this[h]=p}}var f=T(t,"font",null);this._font=null===f?this.fontStyle+" "+this.fontSize+" "+this.fontFamily:f;var v=T(t,"fill",null);null!==v&&(this.color=o(v));var y=T(t,"metrics",!1);return y?this.metrics={ascent:T(y,"ascent",0),descent:T(y,"descent",0),fontSize:T(y,"fontSize",0)}:!e&&this.metrics||(this.metrics=d(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=d(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=T(t,"fontFamily","Courier"),this.fontSize=T(t,"fontSize","16px"),this.fontStyle=T(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,r,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===s&&(s="#000"),void 0===r&&(r=0),void 0===i&&(i=!1),void 0===n&&(n=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=o(s,this.parent.canvas,this.parent.context),this.shadowBlur=r,this.shadowStroke=i,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=T(e,"fontFamily",this.fontFamily),this.fontSize=T(e,"fontSize",this.fontSize),this.fontStyle=T(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 S=Phaser.Utils.Objects.GetValue;class P{constructor(t,e,s,r,i){void 0===t&&(t=0),void 0===e&&(e=t),void 0===s&&(s=0),void 0===r&&(r=0),void 0===i&&(i=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,s,r,i)}setTo(t,e,s,r,i){return this.setPosition(t,e),this.setRadius(i),this.setSize(s,r),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=S(t,"x",0),s=S(t,"y",0));var r=this.cornerRadius;r.tl=b(S(t,"tl",void 0),e,s),r.tr=b(S(t,"tr",void 0),e,s),r.bl=b(S(t,"bl",void 0),e,s),r.br=b(S(t,"br",void 0),e,s)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){O(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){O(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){O(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){O(this.cornerRadius.br,t)}}var b=function(t,e,s){return void 0===t?t={x:e,y:s}:"number"==typeof t&&(t={x:t,y:t}),M(t),t},O=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=S(e,"x",0),t.y=S(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 F=function(t){return!t.hasOwnProperty("convex")||t.convex},L=function(t){return t.x>0&&t.y>0},A=function(t,e,s,r,i,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,r,i,0,n,a,h);else for(var l,u,d,g=(a-n)/(o+=1),c=0;c<=o;c++)d=n+g*c,l=e+r*Math.cos(d),u=s+i*Math.sin(d),t.lineTo(l,u)},W=function(t,e,s,r,i,n,a,h,o,l,u,d,g){var c;(function(t,e,s,r,i,n,a){var h,o,l,u,d,g=new P(e,s,r,i,n),c=g.minWidth,p=g.minHeight,f=r>=c?1:r/c,v=i>=p?1:i/p,y=g.cornerRadius;t.save(),t.beginPath(),t.translate(e,s),h=y.tl,L(h)?(o=h.x*f,l=h.y*v,F(h)?A(t,o,l,o,l,180,270,!1,a):A(t,0,0,o,l,90,0,!0,a),u=0,d=l):(t.lineTo(0,0),u=0,d=0),h=y.tr,L(h)?(o=h.x*f,l=h.y*v,F(h)?A(t,r-o,l,o,l,270,360,!1,a):A(t,r,0,o,l,180,90,!0,a)):t.lineTo(r,0),h=y.br,L(h)?(o=h.x*f,l=h.y*v,F(h)?A(t,r-o,i-l,o,l,0,90,!1,a):A(t,r,i,o,l,270,180,!0,a)):t.lineTo(r,i),h=y.bl,L(h)?(o=h.x*f,l=h.y*v,F(h)?A(t,o,i-l,o,l,90,180,!1,a):A(t,0,i,o,l,360,270,!0,a)):t.lineTo(0,i),t.lineTo(u,d),t.closePath(),t.restore()}(e,s,r,i,n,a,g),null!=h)&&(null!=u&&((c=d?e.createLinearGradient(0,0,i,0):e.createLinearGradient(0,0,0,n)).addColorStop(0,h),c.addColorStop(1,u),h=c),e.fillStyle=h,e.fill());null!=o&&l>0&&(e.strokeStyle=o,e.lineWidth=l,e.stroke())},R={draw(t,e,s,r){var i=this.penManager;this.hitAreaManager.clear();var n=this.context;n.save();var a=this.defaultStyle;this.clear(),function(t,e,s,r,i,n,a,h){if(null!=e||null!=s){var o=t.canvas.width,l=t.canvas.height;null==s&&(r=0);var u=r/2;o=Math.max(1,o-r),l=Math.max(1,l-r),W(t.canvas,t.context,u,u,o,l,i,e,s,r,n,a,h)}}(this,a.backgroundColor,a.backgroundStrokeColor,a.backgroundStrokeLineWidth,a.backgroundCornerRadius,a.backgroundColor2,a.backgroundHorizontalGradient,a.backgroundCornerIteration),t+=this.startXOffset,e+=this.startYOffset;var h,o,l,u,d,g,c=a.halign,p=a.valign,f=a.lineHeight,v=i.lines,y=v.length,x=a.maxLines;x>0&&y>x?(o=x,l="center"===p?Math.floor((y-o)/2):"bottom"===p?y-o:0):(o=y,l=0),u=l+o;var w=this.rtl,k=w?this.parent.width:void 0;g="center"===p?Math.max((r-o*f)/2,0):"bottom"===p?Math.max(r-o*f-2,0):0,g+=e;for(var T=l;T<u;T++)if(0!==(h=i.getLineWidth(T))){for(var m=v[T],S=m.length,P=c,b=0;b<S;b++){var O=m[b].prop.align;if(void 0!==O){P=O;break}}for(d="center"===P?(s-h)/2:"right"===P?w?0:s-h:w?s-h:0,d+=t,b=0;b<S;b++)this.drawPen(m[b],d,g,k)}n.restore()},drawPen(t,e,s,r){e+=t.x,s+=t.y+(t.prop.y||0),void 0!==r&&(e=r-e);var i=this.canvas,n=this.context;n.save();var a=this.parser.propToContextStyle(this.defaultStyle,t.prop);if(null!==a.bgcolor&&t.width>0){var h=this.defaultStyle.metrics,o=s-h.ascent,l=h.fontSize;this.drawRectangle(e,o,t.width,l,a.bgcolor,a)}if(a.underlineThickness>0&&t.width>0){var u=s+a.underlineOffset-a.underlineThickness/2;this.drawLine(e,u,t.width,a.underlineThickness,a.underlineColor,a)}if(t.isTextPen&&(a.buildFont(),a.syncFont(i,n),a.syncStyle(i,n),this.drawText(e,s,t.text,a)),t.isImagePen&&this.drawImage(e,s,t.prop.img,t.prop.color,a),a.strikethroughThickness>0&&t.width>0&&(u=s+a.strikethroughOffset-a.strikethroughThickness/2,this.drawLine(e,u,t.width,a.strikethroughThickness,a.strikethroughColor,a)),n.restore(),t.hasAreaMarker&&t.width>0){var d,g=t.prop.area;if(g)d={key:g};else{var c=t.prop.url;d={key:`url:${c}`,url:c}}this.hitAreaManager.add(e,s-this.startYOffset,t.width,this.defaultStyle.lineHeight,d)}},clear(){var t=this.canvas;this.context.clearRect(0,0,t.width,t.height)},drawRectangle(t,e,s,r,i,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var a=this.context;a.fillStyle=i,a.fillRect(t,e,s,r)},drawLine(t,e,s,r,i,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=i,a.lineWidth=r,a.beginPath(),a.moveTo(t,e),a.lineTo(t+s,e),a.stroke(),a.lineCap=h},drawText(t,e,s,r){this.autoRound&&(t=Math.round(t),e=Math.round(e));var i=this.context;r.stroke&&"none"!==r.stroke&&r.strokeThickness>0&&(r.syncShadow(i,r.shadowStroke),i.strokeText(s,t,e)),r.color&&"none"!==r.color&&(r.syncShadow(i,r.shadowFill),i.fillText(s,t,e))},drawImage(t,e,s,r,i){e-=this.startYOffset,this.parent.imageManager.draw(s,this.context,t,e,r,this.autoRound)}};const z=Phaser.Utils.Objects.GetValue,I=g,B=c;class _{constructor(t){this.prop={},this.resetFromJSON(t)}resetFromJSON(t){this.text=z(t,"text",""),this.x=z(t,"x",0),this.y=z(t,"y",0),this.width=z(t,"width",0);var e=z(t,"prop",null);null===e&&(e={}),this.prop=e,this.newLineMode=z(t,"newLineMode",0),this.startIndex=z(t,"startIndex",0)}get plainText(){var t=this.text;return this.newLineMode===B&&(t+="\n"),t}get wrapText(){var t=this.text;return this.newLineMode!==I&&(t+="\n"),t}get rawTextLength(){var t=this.text.length;return this.newLineMode===B&&(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}}var H=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 r=0,i=t.length;r<i;r++)e[r]=t[r]}else for(var n in t)e[n]=t[n];return e},X=function(){};const Y=Phaser.Utils.Objects.GetFastValue,$=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=Y(t,"tagToText",X),this.tagToTextScope=Y(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++)this.lines[t].length=0;this.pensPool.pushMultiple(this.pens),this.linesPool.pushMultiple(this.lines),this.maxLinesWidth=void 0}addTextPen(t,e,s,r,i,n){var a=this.pensPool.pop();return null==a&&(a=new _),G.text=t,G.x=e,G.y=s,G.width=r,G.prop=i,G.newLineMode=n,a.resetFromJSON(G),this.addPen(a),this}addImagePen(t,e,s,r){return this.addTextPen("",t,e,s,r,$),this}addNewLinePen(){var t=this.lastPen,e=t?t.lastX:0,s=t?t.y:0,r=t?H(t.prop):null;return this.addTextPen("",e,s,0,r,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.linesPool.pop()||[],this.lines.push(s)),s.push(t),t.newLineMode!==$&&(s=this.linesPool.pop()||[],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 r=this.lines[e],i=0,n=r.length;i<n;i++){var a=r[i];t.addPen(a.text,a.x,a.y,a.width,H(a.prop),a.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];return e&&e[0]?e[0].startIndex:0}getLineEndIndex(t){t>=this.lines.length&&(t=this.lines.length-1);var e,s,r=!1;for(e=t;e>=0&&!(r=null!=(s=this.lines[e])&&s.length>0);e--);return r?s[s.length-1].endIndex:0}getLineWidth(t){var e=this.lines[t];if(!e)return 0;var s=e[e.length-1];return null==s?0:s.lastX}getMaxLineWidth(){if(void 0!==this.maxLinesWidth)return this.maxLinesWidth;for(var t,e=0,s=0,r=this.lines.length;s<r;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}get plainText(){for(var t="",e=this.pens,s=0,r=e.length;s<r;s++)t+=e[s].plainText;return t}get rawTextLength(){for(var t=0,e=this.pens,s=0,r=this.pens.length;s<r;s++)t+=e[s].rawTextLength;return t}getSliceTagText(t,e,s){var r=this.lastPen;if(null==r)return"";var i=r.endIndex;void 0!==t&&0!==t||(t=-1),void 0!==e&&e!==i||(e=i+1),void 0===s&&(s=!1);for(var n,a,h,o,l,u,d="",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?d+=this.tagToText.call(this.tagToTextScope,a,l,u):d+=this.tagToText(a,l,u),u=l,!(o>=e)));g++);return d}get length(){return this.lines.length}set length(t){this.clear()}}var G={};class D{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 K=Phaser.Geom.Rectangle;var V=new D;class N{constructor(){this.hitAreas=[]}destroy(){this.clear()}clear(){for(var t=0,e=this.hitAreas.length;t<e;t++)this.hitAreas[t].data=null;return V.pushMultiple(this.hitAreas),this}add(t,e,s,r,i){void 0===i&&(i={});var n=V.pop();return null===n?n=new K(t,e,s,r):n.setTo(t,e,s,r),n.data=i,this.hitAreas.push(n),this}getFirst(t,e){for(var s=0,r=this.hitAreas.length;s<r;s++){var i=this.hitAreas[s];if(i.contains(t,e))return i}return null}getByKey(t){for(var e=0,s=this.hitAreas.length;e<s;e++){var r=this.hitAreas[e];if(r.data.key===t)return r}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 r=0,i=this.hitAreas.length;r<i;r++){var n=this.hitAreas[r];t.lineStyle(1,e).strokeRect(n.x,n.y,n.width,n.height)}return s&&t.restore(),this}}var J=function(t,e,s,r){var i=this.hitAreaManager.getFirst(e,s);if(null!==i){var n=i.data.key;Q.call(this,"areadown",n,t,e,s,r),i.data&&(i.data.isDown=!0)}},q=function(t,e,s,r){var i=this.hitAreaManager.getFirst(e,s);if(null!==i){var n=i.data.key;if(Q.call(this,"areaup",n,t,e,s,r),i.data){if(i.data.isDown){if(Q.call(this,"areaclick",n,t,e,s,r),!i.data)return;var a=i.data.url;a&&window.open(a,"_blank")}i.data.isDown=!1}}},E=function(t,e,s,r){if(null!==e){var i=(a=this.hitAreaManager.getFirst(e,s))?a.data.key:null;if(this.lastHitAreaKey!==i){if(null!==this.lastHitAreaKey){Q.call(this,"areaout",this.lastHitAreaKey,t,e,s,r);var n=this.hitAreaManager.getByKey(this.lastHitAreaKey);n&&(this.urlTagCursorStyle&&Z(this.scene,n,""),n.data.isDown=!1)}null!==i&&(Q.call(this,"areaover",i,t,e,s,r),a.data&&this.urlTagCursorStyle&&Z(this.scene,a,this.urlTagCursorStyle)),this.lastHitAreaKey=i}}else{var a;null!==this.lastHitAreaKey&&(Q.call(this,"areaout",this.lastHitAreaKey,t,e,s,r),(a=this.hitAreaManager.getByKey(this.lastHitAreaKey))&&a.data&&(a.data.isDown=!1),this.lastHitAreaKey=null)}},Q=function(t,e,s,r,i,n){this.parent.emit(`${t}-${e}`,s,r,i,n),this.parent.emit(t,e,s,r,i,n)},Z=function(t,e,s){e&&e.data&&e.data.url&&(t.input.manager.canvas.style.cursor=s)};const tt=Phaser.GameObjects.Components.TransformMatrix,et=Phaser.Math.TransformXY;var st,rt,it={},nt=/^[\x00-\x7F]+$/,at=function(t){return nt.test(t)};const ht=g,ot=c,lt=p,ut=f,dt=v,gt=y,ct=x;var pt=function(t,e,s,r,i,n){r<=0&&(s=ut);var a=[];if(!t||!t.length)return a;for(var h,o,l,u=s===ut,d=t.split(ct),g=0,c=d.length;g<c;g++)if(h=d[g],l=g===c-1?ht:ot,u){var p=e.measureText(h).width;a.push(n.getLine(h,p,l))}else{if(o=0===g?r-i:r,h.length<=100&&(p=e.measureText(h).width)<=o){a.push(n.getLine(h,p,l));continue}for(var f,v,y,x=ft(h,s),w="",k=0,T=0,m=x.length;T<m;T++)if(f=x[T],(v=e.measureText(f).width)>r&&vt(f)){""!==w?a.push(n.getLine(w,k,lt)):0===T&&i>0&&a.push(n.getLine("",0,lt)),a.push(...pt(f,e,gt,r,0,n));var S=a.pop();w=S.text,k=S.width,n.freeLine(S)," "===w&&(w="",k=0)}else(y=k+v)>o?(a.push(n.getLine(w,k,lt)),w=f,k=v,o=r):(w+=f,k=y),T===m-1&&a.push(n.getLine(w,k,l))}return a},ft=function(t,e){var s;switch(e){case dt:s=[];for(var r=0,i=(t=t.split(" ")).length;r<i;r++){var n=t[r];r<i-1?s.push(n+" "):""!==n&&s.push(n)}break;case gt:s=t.split("");break;default:for(s=[],r=0,i=(t=t.split(" ")).length;r<i;r++)n=t[r],r<i-1?at(n)?s.push(n+" "):(s.push(...n.split("")),s.push(" ")):""!==n&&(at(n)?s.push(n):s.push(...n.split("")))}return s},vt=function(t){switch(t.length){case 1:return!1;case 2:return" "!==t.charAt(1);default:return!0}};const yt=Phaser.Utils.Objects.GetValue,xt=f,wt=g,kt=p;class Tt{constructor(t){this.parent=t.parent,this.scene=this.parent.scene,this.context=yt(t,"context",null),this.canvas=this.context.canvas,this.parser=yt(t,"parser",null),this.defaultStyle=yt(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 N,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,r,i){if(void 0===i&&(i=this.penManager),i.clear(),""===t)return i;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,u,d,g=this.canvas,c=this.context,p=0,f=0,v=n.wrapCallback,y=n.wrapCallbackScope,x=!0,w=this.parser.splitText(t),k=this.wrapTextLinesPool,T=0,m=w.length;T<m;T++)if(h=(u=this.parser.tagTextToProp(w[T],o)).plainText,(o=u.prop).img){var S=this.imageManager.getOuterWidth(o.img);s>0&&e!==xt&&s<p+S&&(i.addNewLinePen(),f+=r,p=0),i.addImagePen(p,f,S,H(o)),p+=S}else if(""!==h){if(c.save(),(l=this.parser.propToContextStyle(this.defaultStyle,o)).buildFont(),l.syncFont(g,c),l.syncStyle(g,c),v){"string"==typeof(d=v.call(y,h,c,s,p))&&(d=d.split("\n"));for(var P=0,b=d.length;P<b;P++)"string"==typeof(O=d[P])?d[P]=k.getLine(O,c.measureText(O).width,P<b-1?kt:wt):x=!1}else d=pt(h,c,e,s,p,k);var O;for(P=0,b=d.length;P<b;P++)O=d[P],i.addTextPen(O.text,p,f,O.width,H(o),O.newLineMode),O.newLineMode!==wt?(p=0,f+=r):p+=O.width;x&&k.freeLines(d),d=null,c.restore()}for(T=0,m=this.lines.length;T<m;T++){var M=this.lines[T],C=M[M.length-1];C&&(C.width+=this.parser.getStrokeThinkness(this.defaultStyle,C.prop))}return i}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,e=this.defaultStyle.lineHeight*t;return t>0&&(e-=this.defaultStyle.lineSpacing),e}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 r;if(null==t)r=this.penManager.plainText;else{var i=this.parser.splitText(t,1);r="";for(var n=0,a=i.length;n<a;n++)r+=i[n]}return null==e&&null==s||(null==e&&(e=0),null==s&&(s=r.length),r=r.substring(e,s)),r}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,r){if(null==t)return this.penManager.getSliceTagText(e,s,r);var i=this.tmpPenManager,n=this.defaultStyle;return this.updatePenManager(t,n.wrapMode,n.wrapWidth,n.lineHeight,i),i.getSliceTagText(e,s,r)}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 mt={setInteractive:function(){this.parent.on("pointerdown",J,this).on("pointerup",q,this).on("pointermove",E,this).on("pointerover",E,this).on("pointerout",(function(t,e){E.call(this,t,null,null,e)}),this)},getHitArea:function(t,e,s){var r=function(t,e,s,r,i){void 0===r&&(r=t.scene.cameras.main),void 0===i?i={}:!0===i&&(i=it);var n=r.scrollX,a=r.scrollY,h=e+n*t.scrollFactorX-n,o=s+a*t.scrollFactorY-a;return t.parentContainer?(void 0===st&&(st=new tt,rt=new tt),t.getWorldTransformMatrix(st,rt),st.applyInverse(h,o,i)):et(h,o,t.x,t.y,t.rotation,t.scaleX,t.scaleY,i),i.x+=t.displayOriginX,i.y+=t.displayOriginY,i}(this.parent,t,e,s,!0),i=this.hitAreaManager.getFirst(r.x,r.y);if(null!==i)return i.data.key}};Object.assign(Tt.prototype,R,mt);class St extends D{freeLine(t){if(t)return this.push(t),this}freeLines(t){if(t)return this.pushMultiple(t),this}getLine(t,e,s){var r=this.pop();return null===r&&(r={}),r.text=t,r.width=e,r.newLineMode=s,r}}const Pt=Phaser.Utils.Objects.IsPlainObject,bt=Phaser.Utils.Objects.GetValue;var Ot=function(t,e){Pt(t)?t=(e=t).key:void 0===e&&(e={key:t}),e.hasOwnProperty("key")||(e.key=t);var s=e.key,r=e.frame,i=e.width,n=e.height;if(void 0===i||void 0===n){var a=this.textureManager.getFrame(s,r),h=a?a.cutWidth:0,o=a?a.cutHeight:0;void 0===i&&void 0===n?(i=h,n=o):void 0===i?i=h*(n/o):void 0===n&&(n=o*(i/h))}this.images[t]={key:s,frame:r,width:i,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 Mt=Phaser.Display.Canvas.CanvasPool;class Ct{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)Ot.call(this,t,e);else if(Array.isArray(t))for(var s=0,r=(i=t).length;s<r;s++)Ot.call(this,i[s]);else{var i=t;for(var t in i)Ot.call(this,t,i[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}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,r,i,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,r+=a.y-a.originY*l,a.tintFill||(i=void 0),function(t,e,s,r,i,n,a,h){void 0===s&&(s=0),void 0===r&&(r=0),void 0===i&&(i=t.cutWidth),void 0===n&&(n=t.cutHeight),void 0===h&&(h=!1),h&&(s=Math.round(s),r=Math.round(r));var o=e.getContext("2d",{willReadFrequently:!0});if(a){var l=Mt.create(null,i,n,Phaser.CANVAS,!0),u=l.getContext("2d",{willReadFrequently:!0});u.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,0,0,i,n),u.globalCompositeOperation="source-in",u.fillStyle=a,u.fillRect(0,0,i,n),o.drawImage(l,0,0,i,n,s,r,i,n),Mt.remove(l)}else o.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,s,r,i,n)}(h,e.canvas,s,r,o,l,i,n)}}};Object.assign(Ct.prototype,Ft);const Lt=Phaser.Utils.Objects.IsPlainObject,At=Phaser.DOM.AddToDOM,Wt=Phaser.Display.Canvas.CanvasPool,Rt=Phaser.GameObjects.GameObject,zt=Phaser.Utils.Objects.GetValue,It=Phaser.DOM.RemoveFromDOM,Bt=x,_t=Phaser.Utils.String.UUID;var Ht=null,Xt=null,Yt=null;class $t extends n{constructor(t,e,s,r,i,n,a){if(Lt(e)){var h=e;e=zt(h,"x",0),s=zt(h,"y",0),r=zt(h,"text",""),i=zt(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=Wt.create(this),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this._imageManager=void 0,i){if(i.hasOwnProperty("align")){var o=i.align;delete i.align,i.halign=o}i.hasOwnProperty("stroke")&&!i.hasOwnProperty("strokeThickness")&&(i.strokeThickness=1)}this.style=new m(this,i);var l,u,d,g=zt(i,"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,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),zt(i,"sharedPool",!0)?(Ht||(Ht={},Xt=new D,Yt=new St,this.scene.game.events.once("destroy",(function(){Ht=null,Xt=null,Yt=null}))),Ht.hasOwnProperty(n)||(Ht[n]=new D),l=Ht[n],u=Xt,d=Yt):(l=new D,u=new D,d=new St),this.canvasText=new Tt({parent:this,context:this.context,parser:a,style:this.style,pensPool:l,linesPool:u,wrapTextLinesPool:d}),this.parser=a,this.initRTL(),i&&i.padding&&this.setPadding(i.padding),this.setText(r),this.setUrlTagCursorStyle(zt(i,"urlTagCursorStyle","pointer")),zt(i,"interactive",!1)&&this.setInteractive()}preDestroy(){It(this.canvas),this.canvasText.destroy(),this.canvasText=void 0,this._imageManager&&(this._imageManager.destroy(),this._imageManager=void 0),Wt.remove(this.canvas);var t=this.texture;t&&t.destroy()}set text(t){this.setText(t)}get text(){return this._text}initRTL(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",At(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",At(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 r in s)s[r].originX=1-s[r].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,r){if("object"==typeof t){var i=t,n=zt(i,"x",null);null!==n?(t=n,s=n):(t=zt(i,"left",0),s=zt(i,"right",t));var a=zt(i,"y",null);null!==a?(e=a,r=a):(e=zt(i,"top",0),r=zt(i,"bottom",e))}else void 0===t&&(t=0),void 0===e&&(e=t),void 0===s&&(s=t),void 0===r&&(r=e);return this.padding.left=t,this.padding.top=e,this.padding.right=s,this.padding.bottom=r,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 r,i,n=this.padding,a=Math.ceil(e.linesWidth);0===s.fixedWidth?(this.width=a+n.left+n.right,r=a):(this.width=s.fixedWidth,(r=this.width-n.left-n.right)<a&&(r=a)),0===s.fixedHeight?(this.height=e.linesHeight+n.top+n.bottom,i=e.linesHeight):(this.height=s.fixedHeight,(i=this.height-n.top-n.bottom)<e.linesHeight&&(i=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 u=this.canvas,d=this.context;u.width!==h||u.height!==o?(u.width=h,u.height=o,this.frame.setSize(h,o)):d.clearRect(0,0,h,o),d.save(),d.scale(l,l);var g=this.style.rtl?n.right:n.left,c=n.top;e.draw(g,c,r,i),d.restore(),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(u,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 r=!!this.input;return Rt.prototype.setInteractive.call(this,t,e,s),r||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(Bt)}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,r){return"number"==typeof t&&(r=s,s=e,e=t,t=void 0),void 0===r&&(r=!1),this.canvasText.getText(t,e,s,r)}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 Ct(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,r,i){var n=this.canvas;return void 0===r?r=n.width:r*=this.resolution,void 0===i?i=n.height:i*=this.resolution,function(t,e,s,r,i,n,a){var h,o=t.sys.textures,l=t.renderer;void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=e.width),void 0===a&&(a=e.height);var u=(h=o.exists(s)?o.get(s):o.createCanvas(s,n,a)).getSourceImage();u.width!==n&&(u.width=n),u.height!==a&&(u.height=a);var d=u.getContext("2d",{willReadFrequently:!0});d.clearRect(0,0,n,a),d.drawImage(e,r,i,n,a),l.gl&&h&&l.canvasToTexture(u,h.source[0].glTexture,!0,0)}(this.scene,n,t,e,s,r,i),this}getHitArea(t,e,s){return this.canvasText.getHitArea(t,e,s)}}var jt={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($t.prototype,jt);var Ut={plainText:null,prevProp:null},Gt=new m;class Dt{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=[],r=0;;){var i=Nt.exec(t);if(!i)break;var n=i[0],a=Nt.lastIndex-n.length;if(r<a&&s.push(t.substring(r,a)),void 0===e)s.push(n);else if(1===e)if(Jt.test(n)){var h=n.match(qt);s.push(h[2])}else Et.test(n)&&(h=n.match(Qt),s.push(h[2]));r=Nt.lastIndex}var o=t.length;return r<o&&s.push(t.substring(r,o)),s}tagTextToProp(t,e){var s,r;if(Jt.test(t)){if(null!=(a=t.match(qt))){var i=a[1],n=this.tags;(r=n.hasOwnProperty(i)?n[i]:{})._class=i,s=a[2]}}else if(Et.test(t)){var a;if(null!=(a=t.match(Qt))){var h=a[1];(r=Kt(h))._style=h,s=a[2]}}null==s&&(s=t),null==r&&(r={});var o=Ut;return o.plainText=s,o.prop=r,o}propToContextStyle(t,e){var s=Gt;if(e.hasOwnProperty("img"))s.image=e.img;else{if(s.image=null,e.hasOwnProperty("family")||e.hasOwnProperty("fontFamily")||e.hasOwnProperty("font-family")){var r=e.hasOwnProperty("family")?e.family:e.hasOwnProperty("fontFamily")?e.fontFamily:e["font-family"];s.fontFamily=r}else s.fontFamily=t.fontFamily;if(e.hasOwnProperty("size")||e.hasOwnProperty("fontSize")||e.hasOwnProperty("font-size")){var i=e.hasOwnProperty("size")?e.size:e.hasOwnProperty("fontSize")?e.fontSize:e["font-size"];"number"==typeof i&&(i=`${i}px`),s.fontSize=i}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.underlineOffset}else s.underlineColor=t.underlineColor,s.underlineThickness=t.underlineThickness,s.underlineOffset=t.underlineOffset;if(e.hasOwnProperty("s")||e.hasOwnProperty("strikethrough")){var u=e.hasOwnProperty("s")?e.s:e.strikethrough;s.strikethroughColor=u.hasOwnProperty("color")?u.color:t.strikethroughColor,s.strikethroughThickness=u.hasOwnProperty("thickness")?u.thickness:t.strikethroughThickness,s.strikethroughOffset=u.hasOwnProperty("offset")?u.offset:t.strikethroughOffset}else s.strikethroughColor=t.strikethroughColor,s.strikethroughThickness=t.strikethroughThickness,s.strikethroughOffset=t.strikethroughOffset;return e.hasOwnProperty("bgcolor")?s.bgcolor=e.bgcolor:s.bgcolor=null,s}getStrokeThinkness(t,e){var s;if(e.hasOwnProperty("stroke")){var r=e.stroke;s=r.hasOwnProperty("thickness")?r.thickness:t.strokeThickness}else s=t.strokeThickness;return s}propToTagText(t,e,s){return e.hasOwnProperty("_class")?""===t&&this.isTextTag(e._class)?"":`<class='${e._class}'>${t}</class>`:e.hasOwnProperty("_style")?`<style='${e._style}'>${t}</style>`:t}destroy(){this.tags=void 0}isTextTag(t){var e=this.tags[t];return!!e&&null==e.img}}var Kt=function(t){for(var e,s,r,i={},n=0,a=(t=t.split(";")).length;n<a;n++)if(s=(e=t[n].split(":"))[0],r=e[1],!Vt(s)&&!Vt(r)){switch(s){case"stroke":var h=r.split(" ");r={},(o=h.length)>=1&&(r.color=h[0]),o>=2&&(r.thickness=parseInt(h[1].replace("px","")));break;case"shadow":h=r.split(" "),r={},(o=h.length)>=1&&(r.color=h[0]),o>=2&&(r.offsetX=parseInt(h[1].replace("px",""))),o>=3&&(r.offsetY=parseInt(h[2].replace("px",""))),o>=4&&(r.blur=parseInt(h[3].replace("px","")));break;case"u":case"underline":case"s":case"strikethrough":var o;h=r.split(" "),r={},(o=h.length)>=1&&(r.color=h[0]),o>=2&&(r.thickness=parseInt(h[1].replace("px",""))),o>=3&&(r.offset=parseInt(h[2].replace("px",""))),"underline"===s?s="u":"strikethrough"===s&&(s="s");break;case"y":r=parseFloat(r)}i[s]=r}return i},Vt=function(t){return 0===(t=t.replace(Zt,"")).length},Nt=/<\s*class=["|']([^"|']+)["|']\s*\>([\s\S]*?)<\s*\/class\s*\>|<\s*style=["|']([^"|']+)["|']\s*\>([\s\S]*?)<\s*\/style\s*\>/g,Jt=/<\s*class=/i,qt=/<\s*class=["|']([^"|']+)["|']\s*\>([\s\S]*?)<\s*\/class\s*\>/,Et=/<\s*style=/i,Qt=/<\s*style=["|']([^"|']+)["|']\s*\>([\s\S]*?)<\s*\/style\s*\>/,Zt=/^\s+|\s+$/;const te=Phaser.Utils.Objects.GetValue;return class extends $t{constructor(t,e,s,r,i){var n=te(i,"tags",void 0);super(t,e,s,r,i,"rexTagText",new Dt(n))}addTag(t,e){return this.parser.addTag(t,e),this.updateText(!0)}addTags(t){for(var e in t)this.parser.addTag(e,t[e]);return this.updateText(!0)}getTag(t){return this.parser.getTag(t)}preDestroy(){super.preDestroy(),this.parser.destroy(),this.parser=void 0}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rextagtext=e();