phaser3-rex-plugins
Version:
7 lines • 58 kB
JavaScript
var t,e;t=void 0,e=function(){var t=Phaser.Renderer.WebGL.Utils,e={renderWebGL:function(e,i,s,r){if(0!==i.width&&0!==i.height){s.addToRenderList(i);var n=i.frame,a=n.width,h=n.height,o=t.getTintAppendFloatAlpha,l=e.pipelines.set(i.pipeline,i),u=l.setTexture2D(n.glTexture,i);e.pipelines.preBatch(i),l.batchTexture(i,n.glTexture,a,h,i.x,i.y,a/i.style.resolution,h/i.style.resolution,i.scaleX,i.scaleY,i.rotation,i.flipX,i.flipY,i.scrollFactorX,i.scrollFactorY,i.displayOriginX,i.displayOriginY,0,0,a,h,o(i.tintTopLeft,s.alpha*i._alphaTL),o(i.tintTopRight,s.alpha*i._alphaTR),o(i.tintBottomLeft,s.alpha*i._alphaBL),o(i.tintBottomRight,s.alpha*i._alphaBR),i.tintFill,0,0,s,r,!1,u),e.pipelines.postBatch(i)}},renderCanvas:function(t,e,i,s){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}};const i=Phaser.Display.Canvas.CanvasPool;var s=!1;!function(t){if(!s){void 0===t&&(t=60);var e=Phaser.VERSION.split("."),i=parseInt(e[0]);if(3===i){var r=parseInt(e[1]);r<t&&console.error(`Minimum supported version : ${i}.${r}`)}else console.error(`Can't supported version : ${i}`);s=!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,i){return this.style.setBackgroundColor(t,e,i)}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,i,s,r,n){return this.style.setShadow(t,e,i,s,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,i){return this.style.setUnderline(t,e,i)}setUnderlineColor(t){return this.style.setUnderlineColor(t)}setUnderlineThickness(t){return this.style.setUnderlineThickness(t)}setUnderlineOffset(t){return this.style.setUnderlineOffset(t)}setStrikethrough(t,e,i){return this.style.setStrikethrough(t,e,i)}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,s){void 0===s&&(s={});var r=i.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),s.left=0,0===h||0===l||!n.getImageData(0,0,h,l))return i.remove(r),s;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)]){s.left=g,d=!0;break}if(d)break}return i.remove(r),s}(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,i){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,i);case"object":return t.hasOwnProperty("r")?t.hasOwnProperty("a")?`rgba(${t.r},${t.g},${t.b},${t.a})`:`rgb(${t.r},${t.g},${t.b})`:t.hasOwnProperty("h")?t.hasOwnProperty("a")?`hsla(${t.h},${t.s},${t.l},${t.a})`:`hsl(${t.h},${t.s},${t.l})`:t}},l={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 u=Phaser.Display.Canvas.CanvasPool;var d=function(t){var e=u.create(this),i=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,i);var s=i.measureText(t.testString);if("actualBoundingBoxAscent"in s){var r=s.actualBoundingBoxAscent,n=s.actualBoundingBoxDescent,a={ascent:r,descent:n,fontSize:r+n};return u.remove(e),a}var h=Math.ceil(s.width*t.baselineX),o=h,l=2*o;if(o=o*t.baselineY|0,e.width=h,e.height=l,i.fillStyle="#f00",i.fillRect(0,0,h,l),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,o),a={ascent:0,descent:0,fontSize:0},!i.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=i.getImageData(0,0,h,l).data,p=c.length,f=4*h,v=0,x=!1;for(d=0;d<o;d++){for(g=0;g<f;g+=4)if(255!==c[v+g]){x=!0;break}if(x)break;v+=f}for(a.ascent=o-d,v=p-f,x=!1,d=l;d>o;d--){for(g=0;g<f;g+=4)if(255!==c[v+g]){x=!0;break}if(x)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,x=2,y=/(?:\r\n|\r|\n)/;const w={none:f,word:v,char:x,character:x,mix:3},S=Phaser.Utils.Objects.GetAdvancedValue,E=Phaser.Utils.Objects.GetValue;class O{constructor(t,e,i){this.parent=t,void 0===i&&(i=l),this.propertyMap=i,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,i){if(void 0===e&&(e=!0),void 0===i&&(i=!1),t&&t.hasOwnProperty("wordWrap")){var s=t.wordWrap;s.hasOwnProperty("width")&&(t.wrap={mode:"word",width:s.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&&i&&!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=i?l[1]:this[h],c=l[2];if("wrapCallback"===h||"wrapCallbackScope"===h)this[h]=E(t,u,g);else{var p=S(t,u,g);c&&(p=c(p)),this[h]=p}}var f=E(t,"font",null);this._font=null===f?this.fontStyle+" "+this.fontSize+" "+this.fontFamily:f;var v=E(t,"fill",null);null!==v&&(this.color=o(v));var x=E(t,"metrics",!1);return x?this.metrics={ascent:E(x,"ascent",0),descent:E(x,"descent",0),fontSize:E(x,"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=E(t,"fontFamily","Courier"),this.fontSize=E(t,"fontSize","16px"),this.fontStyle=E(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,i){return void 0===i&&(i=!0),this.backgroundColor=o(t,this.parent.canvas,this.parent.context),this.backgroundColor2=o(e,this.parent.canvas,this.parent.context),this.backgroundHorizontalGradient=i,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,i,s,r,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="#000"),void 0===s&&(s=0),void 0===r&&(r=!1),void 0===n&&(n=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=o(i,this.parent.canvas,this.parent.context),this.shadowBlur=s,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,i){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===i&&(i=0),this.underlineColor=o(t,this.parent.canvas,this.parent.context),this.underlineThickness=e,this.underlineOffset=i,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,i){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===i&&(i=0),this.strikethroughColor=o(t,this.parent.canvas,this.parent.context),this.strikethroughThickness=e,this.strikethroughOffset=i,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=E(e,"fontFamily",this.fontFamily),this.fontSize=E(e,"fontSize",this.fontSize),this.fontStyle=E(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 i in e)t[i]=this[i];return t.metrics=this.getTextMetrics(),t}destroy(){this.parent=void 0}}const m=Phaser.Utils.Objects.GetValue;class T{constructor(t,e,i,s,r){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,i,s,r)}setTo(t,e,i,s,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(i,s),this}setPosition(t,e){return this.x=t,this.y=e,this}setRadius(t){return void 0===t&&(t=0),this.radius=t,this}setSize(t,e){return this.width=t,this.height=e,this}get minWidth(){var t=this.cornerRadius;return Math.max(t.tl.x+t.tr.x,t.bl.x+t.br.x)}get minHeight(){var t=this.cornerRadius;return Math.max(t.tl.y+t.bl.y,t.tr.y+t.br.y)}get width(){return this._width}set width(t){null==t&&(t=0),this._width=Math.max(t,this.minWidth)}get height(){return this._height}set height(t){null==t&&(t=0),this._height=Math.max(t,this.minHeight)}get radius(){var t=this.cornerRadius;return Math.max(t.tl.x,t.tl.y,t.tr.x,t.tr.y,t.bl.x,t.bl.y,t.br.x,t.br.y)}set radius(t){var e,i;"number"==typeof t?(e=t,i=t):(e=m(t,"x",0),i=m(t,"y",0));var s=this.cornerRadius;s.tl=R(m(t,"tl",void 0),e,i),s.tr=R(m(t,"tr",void 0),e,i),s.bl=R(m(t,"bl",void 0),e,i),s.br=R(m(t,"br",void 0),e,i)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){_(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){_(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){_(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){_(this.cornerRadius.br,t)}}var R=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),k(t),t},_=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=m(e,"x",0),t.y=m(e,"y",0)),k(t)},k=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)};const P=Phaser.Math.DegToRad;var C=function(t){return!t.hasOwnProperty("convex")||t.convex},b=function(t){return t.x>0&&t.y>0},L=function(t,e,i,s,r,n,a,h,o){if(h&&a>n?a-=360:!h&&a<n&&(a+=360),n=P(n),a=P(a),null==o)t.ellipse(e,i,s,r,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+s*Math.cos(d),u=i+r*Math.sin(d),t.lineTo(l,u)},M=function(t,e,i,s,r,n,a,h,o,l,u,d,g){var c;(function(t,e,i,s,r,n,a){var h,o,l,u,d,g=new T(e,i,s,r,n),c=g.minWidth,p=g.minHeight,f=s>=c?1:s/c,v=r>=p?1:r/p,x=g.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),h=x.tl,b(h)?(o=h.x*f,l=h.y*v,C(h)?L(t,o,l,o,l,180,270,!1,a):L(t,0,0,o,l,90,0,!0,a),u=0,d=l):(t.lineTo(0,0),u=0,d=0),h=x.tr,b(h)?(o=h.x*f,l=h.y*v,C(h)?L(t,s-o,l,o,l,270,360,!1,a):L(t,s,0,o,l,180,90,!0,a)):t.lineTo(s,0),h=x.br,b(h)?(o=h.x*f,l=h.y*v,C(h)?L(t,s-o,r-l,o,l,0,90,!1,a):L(t,s,r,o,l,270,180,!0,a)):t.lineTo(s,r),h=x.bl,b(h)?(o=h.x*f,l=h.y*v,C(h)?L(t,o,r-l,o,l,90,180,!1,a):L(t,0,r,o,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(u,d),t.closePath(),t.restore()}(e,i,s,r,n,a,g),null!=h)&&(null!=u&&((c=d?e.createLinearGradient(0,0,r,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())},A={draw(t,e,i,s){var r=this.penManager;this.hitAreaManager.clear();var n=this.context;n.save();var a=this.defaultStyle;this.clear(),function(t,e,i,s,r,n,a,h){if(null!=e||null!=i){var o=t.canvas.width,l=t.canvas.height;null==i&&(s=0);var u=s/2;o=Math.max(1,o-s),l=Math.max(1,l-s),M(t.canvas,t.context,u,u,o,l,r,e,i,s,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,u=h.height-o.top-o.bottom,d=this.linesHeight,g=l>0&&u>0,c=h.style.fixedHeight>0,p=d>u,f=a.maxLines,v=f<=0&&"top"===a.valign&&g&&c&&p,x=v;x&&(n.save(),n.beginPath(),n.rect(o.left,o.top,l,u),n.clip()),t+=this.startXOffset,e+=this.startYOffset;var y,w,S,E,O,m,T=a.halign,R=a.valign,_=r.lines,k=_.length;if(v&&k>0){var P=-h.scrollY,C=P+u;S=function(t,e){for(var i=0,s=t.length-1,r=t.length;i<=s;){var n=i+s>>1;t[n].endOffset>e?(r=n,s=n-1):i=n+1}return r}(_,P),E=function(t,e){for(var i=0,s=t.length-1,r=t.length;i<=s;){var n=i+s>>1;t[n].startOffset>=e?(r=n,s=n-1):i=n+1}return r}(_,C),S<0&&(S=0),E>k&&(E=k),E<S&&(E=S)}else f>0&&k>f?(w=f,E=(S="center"===R?Math.floor((k-w)/2):"bottom"===R?k-w:0)+w):(S=0,E=k);var b=this.rtl,L=b?this.parent.width:void 0;if(v)m=e;else{var A=this.getLinesHeight(S,E);m="center"===R?Math.max((s-A)/2,0):"bottom"===R?Math.max(s-A-2,0):0,m+=e}for(var F=S;F<E;F++)if(0!==(y=r.getLineWidth(F))){var I=_[F];if(I){for(var N=I.pens,H=N.length,W=T,B=0;B<H;B++){var Y=N[B].prop.align;if(void 0!==Y){W=Y;break}}O="center"===W?(i-y)/2:"right"===W?b?0:i-y:b?i-y:0,O+=t;var $=this.getLineHeight(I)+a.lineSpacing;for(B=0;B<H;B++)this.drawPen(N[B],O,m,L,$)}}x&&n.restore(),n.restore()},drawPen(t,e,i,s,r){e+=t.x,i+=t.y+(t.prop.y||0),void 0!==s&&(e=s-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=i-o.ascent,u=o.fontSize;this.drawRectangle(e,l,t.width,u,h.bgcolor,h)}if(h.underlineThickness>0&&t.width>0){var d=i+h.underlineOffset-h.underlineThickness/2;this.drawLine(e,d,t.width,h.underlineThickness,h.underlineColor,h)}if(t.isTextPen&&(h.buildFont(),h.syncFont(n,a),h.syncStyle(n,a),this.drawText(e,i,t.text,h)),t.isImagePen&&this.drawImage(e,i,t.prop.img,t.prop.color,h),h.strikethroughThickness>0&&t.width>0&&(d=i+h.strikethroughOffset-h.strikethroughThickness/2,this.drawLine(e,d,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,i-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,i,s,r,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var a=this.context;a.fillStyle=r,a.fillRect(t,e,i,s)},drawLine(t,e,i,s,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=s,a.beginPath(),a.moveTo(t,e),a.lineTo(t+i,e),a.stroke(),a.lineCap=h},drawText(t,e,i,s){this.autoRound&&(t=Math.round(t),e=Math.round(e));var r=this.context,n=s.letterSpacing;if(0===n)s.stroke&&"none"!==s.stroke&&s.strokeThickness>0&&(s.syncShadow(r,s.shadowStroke),r.strokeText(i,t,e)),s.color&&"none"!==s.color&&(s.syncShadow(r,s.shadowFill),r.fillText(i,t,e));else for(var a=i.split(""),h=0,o=a.length;h<o;h++){var l=a[h];s.stroke&&"none"!==s.stroke&&s.strokeThickness>0&&(s.syncShadow(r,s.shadowStroke),r.strokeText(l,t,e)),s.color&&"none"!==s.color&&(s.syncShadow(r,s.shadowFill),r.fillText(l,t,e)),t+=r.measureText(l).width+n}},drawImage(t,e,i,s,r){e-=this.startYOffset,this.parent.imageManager.draw(i,this.context,t,e,s,this.autoRound)}};const F=Phaser.Utils.Objects.GetValue,I=g,N=c;class H{constructor(t){this.prop={},this.resetFromJSON(t)}resetFromJSON(t){this.text=F(t,"text",""),this.x=F(t,"x",0),this.y=F(t,"y",0),this.width=F(t,"width",0),this.ascent=F(t,"ascent",0),this.descent=F(t,"descent",0);var e=F(t,"height",null);null==e&&(e=this.ascent+this.descent),this.height=e;var i=F(t,"prop",null);null===i&&(i={}),this.prop=i,this.newLineMode=F(t,"newLineMode",0),this.startIndex=F(t,"startIndex",0)}get plainText(){var t=this.text;return this.newLineMode===N&&(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===N&&(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 W{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 i=Array.isArray(t);if(void 0===e?e=i?[]:{}:function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}(e),i){e.length=t.length;for(var s=0,r=t.length;s<r;s++)e[s]=t[s]}else for(var n in t)e[n]=t[n];return e},Y=function(){};const $=Phaser.Utils.Objects.GetFastValue,G=g,z=p;class D{constructor(t){this.pens=[],this.lines=[],this.maxLinesWidth=void 0,this.pensPool=t.pensPool,this.linesPool=t.linesPool,this.tagToText=$(t,"tagToText",Y),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 i=this.lines[t];i&&i.reset?i.reset():i&&(i.length=0)}this.pensPool.pushMultiple(this.pens),this.linesPool.pushMultiple(this.lines),this.maxLinesWidth=void 0}addTextPen(t,e,i,s,r,n,a){var h=this.pensPool.pop();if(null==h&&(h=new H),U.text=t,U.x=e,U.y=i,U.width=s,a){var o=null!=a.ascent?a.ascent:0,l=null!=a.descent?a.descent:0,u=null!=a.height?a.height:o+l;U.ascent=o,U.descent=l,U.height=u}else U.ascent=0,U.descent=0,U.height=0;return U.prop=r,U.newLineMode=n,h.resetFromJSON(U),this.addPen(h),this}addImagePen(t,e,i,s,r){return this.addTextPen("",t,e,i,s,G,r),this}addNewLinePen(){var t=this.lastPen,e=t?t.lastX:0,i=t?t.y:0,s=t?B(t.prop):null;return this.addTextPen("",e,i,0,s,z),this}addPen(t){var e=this.lastPen;t.startIndex=null==e?0:e.endIndex,this.pens.push(t);var i=this.lastLine;null==i?(i=this.newLine(),this.lines.push(i)):i.pens||(i=this.convertLine(i),this.lines[this.lines.length-1]=i),i.addPen?i.addPen(t):i.push(t),t.newLineMode!==G&&(i=this.newLine(),this.lines.push(i)),this.maxLinesWidth=void 0}clone(t){null==t&&(t=new D),t.clear();for(var e=0,i=this.lines.length;e<i;e++)for(var s=this.lines[e],r=s&&s.pens?s.pens:s,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],i=e&&e.pens?e.pens:e;return i&&i[0]?i[0].startIndex:0}getLineEndIndex(t){t>=this.lines.length&&(t=this.lines.length-1);var e,i,s=!1;for(e=t;e>=0;e--){var r;if(s=null!=(r=(i=this.lines[e])&&i.pens?i.pens:i)&&r.length>0)break}return s?(r=i&&i.pens?i.pens:i)[r.length-1].endIndex:0}getLineWidth(t){var e=this.lines[t];if(!e)return 0;var i=e&&e.pens?e.pens:e,s=i[i.length-1];return null==s?0:s.lastX}getMaxLineWidth(){if(void 0!==this.maxLinesWidth)return this.maxLinesWidth;for(var t,e=0,i=0,s=this.lines.length;i<s;i++)(t=this.getLineWidth(i))>e&&(e=t);return this.maxLinesWidth=e,e}getLineWidths(){for(var t=[],e=0,i=this.lines.length;e<i;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 W(t).reset():new W:new W}get plainText(){for(var t="",e=this.pens,i=0,s=e.length;i<s;i++)t+=e[i].plainText;return t}get rawTextLength(){for(var t=0,e=this.pens,i=0,s=this.pens.length;i<s;i++)t+=e[i].rawTextLength;return t}getSliceTagText(t,e,i){var s=this.lastPen;if(null==s)return"";var r=s.endIndex;void 0!==t&&0!==t||(t=-1),void 0!==e&&e!==r||(e=r+1),void 0===i&&(i=!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=i?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 U={};class X{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 j=Phaser.Geom.Rectangle;var K=new X;class V{constructor(){this.hitAreas=[]}destroy(){this.clear()}clear(){for(var t=0,e=this.hitAreas.length;t<e;t++)this.hitAreas[t].data=null;return K.pushMultiple(this.hitAreas),this}add(t,e,i,s,r){void 0===r&&(r={});var n=K.pop();return null===n?n=new j(t,e,i,s):n.setTo(t,e,i,s),n.data=r,this.hitAreas.push(n),this}getFirst(t,e){for(var i=0,s=this.hitAreas.length;i<s;i++){var r=this.hitAreas[i];if(r.contains(t,e))return r}return null}getByKey(t){for(var e=0,i=this.hitAreas.length;e<i;e++){var s=this.hitAreas[e];if(s.data.key===t)return s}return null}drawBounds(t,e,i){void 0===e&&(e=16777215),i&&t.save().translateCanvas(i.x,i.y).rotateCanvas(i.rotation).scaleCanvas(i.scaleX,i.scaleY);for(var s=0,r=this.hitAreas.length;s<r;s++){var n=this.hitAreas[s];t.lineStyle(1,e).strokeRect(n.x,n.y,n.width,n.height)}return i&&t.restore(),this}}var J=function(t,e,i,s){var r=this.hitAreaManager.getFirst(e,i);if(null!==r){var n=r.data.key;Q.call(this,"areadown",n,t,e,i,s),r.data&&(r.data.isDown=!0)}},q=function(t,e,i,s){var r=this.hitAreaManager.getFirst(e,i);if(null!==r){var n=r.data.key;if(Q.call(this,"areaup",n,t,e,i,s),r.data){if(r.data.isDown){if(Q.call(this,"areaclick",n,t,e,i,s),!r.data)return;var a=r.data.url;a&&window.open(a,"_blank")}r.data.isDown=!1}}},Z=function(t,e,i,s){if(null!==e){var r=(a=this.hitAreaManager.getFirst(e,i))?a.data.key:null;if(this.lastHitAreaKey!==r){if(null!==this.lastHitAreaKey){Q.call(this,"areaout",this.lastHitAreaKey,t,e,i,s);var n=this.hitAreaManager.getByKey(this.lastHitAreaKey);n&&(this.urlTagCursorStyle&&tt(this.scene,n,""),n.data.isDown=!1)}null!==r&&(Q.call(this,"areaover",r,t,e,i,s),a.data&&this.urlTagCursorStyle&&tt(this.scene,a,this.urlTagCursorStyle)),this.lastHitAreaKey=r}}else{var a;null!==this.lastHitAreaKey&&(Q.call(this,"areaout",this.lastHitAreaKey,t,e,i,s),(a=this.hitAreaManager.getByKey(this.lastHitAreaKey))&&a.data&&(a.data.isDown=!1),this.lastHitAreaKey=null)}},Q=function(t,e,i,s,r,n){this.parent.emit(`${t}-${e}`,i,s,r,n),this.parent.emit(t,e,i,s,r,n)},tt=function(t,e,i){e&&e.data&&e.data.url&&(t.input.manager.canvas.style.cursor=i)};const et=Phaser.GameObjects.Components.TransformMatrix,it=Phaser.Math.TransformXY;var st,rt,nt={},at=/^[\x00-\x7F]+$/,ht=function(t){return at.test(t)};const ot=g,lt=c,ut=p,dt=f,gt=v,ct=x,pt=y;var ft=function(t,e,i,s,r,n,a){s<=0&&(i=dt);var h=[];if(!t||!t.length)return h;for(var o,l,u,d=i===dt,g=t.split(pt),c=0,p=g.length;c<p;c++)if(o=g[c],u=c===p-1?ot:lt,d){var f=e.measureText(o).width+r*o.length;h.push(a.getLine(o,f,u))}else{if(l=0===c?s-n:s,o.length<=100&&(f=e.measureText(o).width+r*o.length)<=l){h.push(a.getLine(o,f,u));continue}for(var v,x,y,w=vt(o,i),S="",E=0,O=0,m=w.length;O<m;O++){if(v=w[O],(x=e.measureText(v).width+r*v.length)>s&&xt(v)){""!==S?h.push(a.getLine(S,E,ut)):0===O&&n>0&&h.push(a.getLine("",0,ut)),h.push(...ft(v,e,ct,s,r,0,a));var T=h.pop();S=T.text,E=T.width,a.freeLine(T)," "===S&&(S="",E=0)}else(y=E+x)>l?(h.push(a.getLine(S,E,ut)),S=v,E=x,l=s):(S+=v,E=y);O===m-1&&h.push(a.getLine(S,E,u))}}return h},vt=function(t,e){var i;switch(e){case gt:i=[];for(var s=0,r=(t=t.split(" ")).length;s<r;s++){var n=t[s];s<r-1?i.push(n+" "):""!==n&&i.push(n)}break;case ct:i=t.split("");break;default:for(i=[],s=0,r=(t=t.split(" ")).length;s<r;s++)n=t[s],s<r-1?ht(n)?i.push(n+" "):(i.push(...n.split("")),i.push(" ")):""!==n&&(ht(n)?i.push(n):i.push(...n.split("")))}return i},xt=function(t){switch(t.length){case 1:return!1;case 2:return" "!==t.charAt(1);default:return!0}};const yt=Phaser.Utils.Objects.GetValue,wt=f,St=g,Et=p;class Ot{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 V,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,i,s,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;i=n.fixedWidth-a.left-a.right}for(var h,o,l,u,g,c=this.canvas,p=this.context,f=0,v=0,x=n.wrapCallback,y=n.wrapCallbackScope,w=!x,S=!0,E=this.parser.splitText(t),O=this.wrapTextLinesPool,m=0,T=E.length;m<T;m++)if(h=(u=this.parser.tagTextToProp(E[m],o)).plainText,(o=u.prop).img){var R=this.addImagePen(o,f,v,i,e,s,r);f=R.x,v=R.y}else if(""!==h){p.save(),(l=this.parser.propToContextStyle(this.defaultStyle,o)).buildFont(),l.syncFont(c,p),l.syncStyle(c,p);var _=d(l);if(w)g=ft(h,p,e,i,l.letterSpacing,f,O);else{var k;"string"==typeof(g=x.call(y,h,p,i,l.letterSpacing,f))&&(g=g.split("\n"));for(var P=0,C=g.length;P<C;P++)"string"==typeof(k=g[P])?g[P]=O.getLine(k,p.measureText(k).width,P<C-1?Et:St):S=!1}for(P=0,C=g.length;P<C;P++)k=g[P],r.addTextPen(k.text,f,v,k.width,B(o),k.newLineMode,_),k.newLineMode!==St?(f=0,v+=s):f+=k.width;S&&O.freeLines(g),g=null,p.restore()}var b=r.lines;for(m=0,T=b.length;m<T;m++){var L=b[m].pens,M=L[L.length-1];M&&(M.width+=this.parser.getStrokeThinkness(this.defaultStyle,M.prop),M.width-=this.parser.getLetterSpacing(this.defaultStyle,M.prop))}return this.updateLineOffsets(b,n),r}addImagePen(t,e,i,s,r,n,a){var h,o=this.imageManager.getOuterWidth(t.img),l=this.imageManager.getOuterHeight(t.img);if(l>0){var u=this.defaultStyle.metrics.ascent,d=l-u;d<0&&(d=0),h={ascent:u,descent:d,height:u+d}}return s>0&&r!==wt&&s<e+o&&(a.addNewLinePen(),i+=n,e=0),a.addImagePen(e,i,o,B(t),h),{x:e+=o,y:i}}updateLineOffsets(t,e){for(var i=e.lineSpacing,s=this.defaultStyle.metrics,r=s.ascent,n=s.descent,a=0,h=e.fixedLineHeightMode,o=0,l=t.length;o<l;o++){var u=t[o],d=u.maxAscent,g=u.maxDescent;(h||0===d&&0===g)&&(d=r,g=n),u.maxAscent=d,u.maxDescent=g,u.lineHeight=d+g,u.startOffset=a,u.endOffset=a+u.lineHeight;for(var c=a+d-r,p=u.pens,f=0,v=p.length;f<v;f++)p[f].y=c;a=u.endOffset+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;return this.getLinesHeight(0,t)}getLineHeight(t){var e=t?t.lineHeight:0;if(e>0)return e;var i=this.defaultStyle.metrics;return i.ascent+i.descent}getLinesHeight(t,e){var i=this.penManager.lines,s=i.length;if(void 0===t&&(t=0),(void 0===e||e>s)&&(e=s),e<=t)return 0;for(var r=0,n=t;n<e;n++)r+=this.getLineHeight(i[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 D({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,i){var s;if(null==t)s=this.penManager.plainText;else{var r=this.parser.splitText(t,1);s="";for(var n=0,a=r.length;n<a;n++)s+=r[n]}return null==e&&null==i||(null==e&&(e=0),null==i&&(i=s.length),s=s.substring(e,i)),s}getPenManager(t,e){if(void 0===t)return this.copyPenManager(e,this.penManager);void 0===e&&(e=this.newPenManager());var i=this.defaultStyle;return this.updatePenManager(t,i.wrapMode,i.wrapWidth,i.lineHeight,e),e}getText(t,e,i,s){if(null==t)return this.penManager.getSliceTagText(e,i,s);var r=this.tmpPenManager,n=this.defaultStyle;return this.updatePenManager(t,n.wrapMode,n.wrapWidth,n.lineHeight,r),r.getSliceTagText(e,i,s)}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",Z,this).on("pointerover",Z,this).on("pointerout",(function(t,e){Z.call(this,t,null,null,e)}),this)},getHitArea:function(t,e,i){var s=function(t,e,i,s,r){void 0===s&&(s=t.scene.cameras.main),void 0===r?r={}:!0===r&&(r=nt);var n=s.scrollX,a=s.scrollY,h=e+n*t.scrollFactorX-n,o=i+a*t.scrollFactorY-a;return t.parentContainer?(void 0===st&&(st=new et,rt=new et),t.getWorldTransformMatrix(st,rt),st.applyInverse(h,o,r)):it(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,i,!0),r=this.hitAreaManager.getFirst(s.x,s.y);if(null!==r)return r.data.key}};Object.assign(Ot.prototype,A,mt);class Tt extends X{freeLine(t){if(t)return this.push(t),this}freeLines(t){if(t)return this.pushMultiple(t),this}getLine(t,e,i){var s=this.pop();return null===s&&(s={}),s.text=t,s.width=e,s.newLineMode=i,s}}const Rt=Phaser.Utils.Objects.IsPlainObject,_t=Phaser.Utils.Objects.GetValue;var kt=function(t,e){Rt(t)?t=(e=t).key:void 0===e&&(e={key:t}),e.hasOwnProperty("key")||(e.key=t);var i=e.key,s=e.frame,r=e.width,n=e.height;if(void 0===r||void 0===n){var a=this.textureManager.getFrame(i,s),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:i,frame:s,width:r,height:n,y:_t(e,"y",0),left:_t(e,"left",0),right:_t(e,"right",0),originX:_t(e,"originX",0),originY:_t(e,"originY",0),tintFill:_t(e,"tintFill",!1)}};const Pt=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)kt.call(this,t,e);else if(Array.isArray(t))for(var i=0,s=(r=t).length;i<s;i++)kt.call(this,r[i]);else{var r=t;for(var t in r)kt.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 bt={draw:function(t,e,i,s,r,n){var a=this.get(t);if(a){var h=this.textureManager.getFrame(a.key,a.frame),o=a.width,l=a.height;i+=a.left-a.originX*o,s+=a.y-a.originY*l,a.tintFill||(r=void 0),function(t,e,i,s,r,n,a,h){void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=t.cutWidth),void 0===n&&(n=t.cutHeight),void 0===h&&(h=!1),h&&(i=Math.round(i),s=Math.round(s));var o=e.getContext("2d",{willReadFrequently:!0});if(a){var l=Pt.create(null,r,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,r,n),u.globalCompositeOperation="source-in",u.fillStyle=a,u.fillRect(0,0,r,n),o.drawImage(l,0,0,r,n,i,s,r,n),Pt.remove(l)}else o.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,i,s,r,n)}(h,e.canvas,i,s,o,l,r,n)}}};Object.assign(Ct.prototype,bt);const Lt=Phaser.Utils.Objects.IsPlainObject,Mt=Phaser.DOM.AddToDOM,At=Phaser.Display.Canvas.CanvasPool,Ft=Phaser.GameObjects.GameObject,It=Phaser.Utils.Objects.GetValue,Nt=Phaser.DOM.RemoveFromDOM,Ht=y,Wt=Phaser.Utils.String.UUID,Bt=Phaser.Math.Clamp;var Yt=null,$t=null,Gt=null;class zt extends n{constructor(t,e,i,s,r,n,a){if(Lt(e)){var h=e;e=It(h,"x",0),i=It(h,"y",0),s=It(h,"text",""),r=It(h,"style")}if(void 0===e&&(e=0),void 0===i&&(i=0),super(t,n),this.renderer=t.sys.game.renderer,this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(!0),this.canvas=At.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 O(this,r);var l,u,d,g=It(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=Wt(),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),It(r,"sharedPool",!0)?(Yt||(Yt={},$t=new X,Gt=new Tt,this.scene.game.events.once("destroy",(function(){Yt=null,$t=null,Gt=null}))),Yt.hasOwnProperty(n)||(Yt[n]=new X),l=Yt[n],u=$t,d=Gt):(l=new X,u=new X,d=new Tt),this.canvasText=new Ot({parent:this,context:this.context,parser:a,style:this.style,pensPool:l,linesPool:u,wrapTextLinesPool:d}),this.parser=a,this.initRTL(),r&&r.padding&&this.setPadding(r.padding),this.setText(s),this.setUrlTagCursorStyle(It(r,"urlTagCursorStyle","pointer")),It(r,"interactive",!1)&&this.setInteractive()}preDestroy(){Nt(this.canvas),this.canvasText.destroy(),this.canvasText=void 0,this._imageManager&&(this._imageManager.destroy(),this._imageManager=void 0),At.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 i=this.bottomScrollY*t;return this.setScrollY(i,!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",Mt(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",Mt(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 i=this._imageManager.images;for(var s in i)i[s].originX=1-i[s].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,i,s){if("object"==typeof t){var r=t,n=It(r,"x",null);null!==n?(t=n,i=n):(t=It(r,"left",0),i=It(r,"right",t));var a=It(r,"y",null);null!==a?(e=a,s=a):(e=It(r,"top",0),s=It(r,"bottom",e))}else void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=t),void 0===s&&(s=e);return this.padding.left=t,this.padding.top=e,this.padding.right=i,this.padding.bottom=s,this.updateText(!1)}updateText(t){void 0===t&&(t=!0);var e=this.canvasText,i=this.style;t&&e.updatePenManager(this._text,i.wrapMode,i.wrapWidth,i.lineHeight);var s,r,n=this.padding,a=Math.ceil(e.linesWidth);0===i.fixedWidth?(this.width=a+n.left+n.right,s=a):(this.width=i.fixedWidth,(s=this.width-n.left-n.right)<a&&(s=a)),0===i.fixedHeight?(this.height=e.linesHeight+n.top+n.bottom,r=e.linesHeight):(this.height=i.fixedHeight,(r=this.height-n.top-n.bottom)<e.linesHeight&&(r=e.linesHeight));var h=this.width,o=this.height;this.updateDisplayOrigin();var l=i.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+this._scrollY;e.draw(g,c,s,r),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,i){var s=!!this.input;return Ft.prototype.setInteractive.call(this,t,e,i),s||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,i){return"number"==typeof t&&(i=e,e=t,t=void 0),(t=this.canvasText.getText(t,e,i,!0)).split(Ht)}getPlainText(t,e,i){return"number"==typeof t&&(i=e,e=t,t=void 0),this.canvasText.getPlainText(t,e,i)}getText(t,e,i,s){return"number"==typeof t&&(s=i,i=e,e=t,t=void 0),void 0===s&&(s=!1),this.canvasText.getText(t,e,i,s)}getSubString(t,e,i){return"number"==typeof t&&(i=e,e=t,t=void 0),this.getText(t,e,i)}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,i,s,r){var n=this.canvas;return void 0===s?s=n.width:s*=this.resolution,void 0===r?r=n.height:r*=this.resolution,function(t,e,i,s,r,n,a){var h,o=t.sys.textures,l=t.renderer;void 0===s&&(s=0),void 0===r&&(r=0),void 0===n&&(n=e.width),void 0===a&&(a=e.height);var u=(h=o.exists(i)?o.get(i):o.createCanvas(i,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,s,r,n,a),l.gl&&h&&l.canvasToTexture(u,h.source[0].glTexture,!0,0)}(this.scene,n,t,e,i,s,r),this}getHitArea(t,e,i){return this.canvasText.getHitArea(t,e,i)}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 Dt={appendText:function(t,e){var i;return t||0===t||(t=""),void 0===e&&(e=!0),Array.isArray(t)&&(t=t.join("\n")),(i=e?`${this.text}\n${t}`:`${this.text}${t}`)!=this.text&&this.setText(i),this}};Object.assign(zt.prototype,Dt);const Ut=!1,Xt=!0;var jt,Kt,Vt={plainText:null,prevProp:null},Jt=function(t,e,i,s){return e===Xt?t[i]=s:t.hasOwnProperty(i)&&delete t[i],t},qt=function(t){var e=t.b,i=t.weight,s=t.i;return e||i||s?s?e?"bold italic":i?`${i} italic`:"italic":e?"bold":i.toString():""},Zt=new O,Qt={},te=function(t){return t.replace(ee,"\\$&").replace(ie,"\\x2d")},ee=/[|\\{}()[\]^$+*?.]/g,ie=/-/g,se={},re=function(t,e,i,s){return void 0===s?`${t}${i}${e}`:`${t}${i}=(${s})${e}`},ne=function(t,e,i){return`${t}/${i}${e}`},ae="[-.0-9]+",he=["[a-zA-Z]+","#[0-9abcdef]+","rgba?\\(s*[.0-9]+s*(,s*[.0-9]+s*){2,3}\\)"].join("|"),oe=function(t,e){if(void 0===e){var i=t;t=i[0],e=i[1]}if(jt===t&&Kt===e)return!1;jt=t,Kt=e,t=te(t);var s=function(t){return`[^${t}]+`}(e=te(e)),r=re(t,e,"esc"),n=ne(t,e,"esc"),a=re(t,e,"raw"),h=ne(t,e,"raw"),o=re(t,e,"b"),l=ne(t,e,"b"),u=re(t,e,"i"),d=ne(t,e,"i"),g="weight",c=re(t,e,g,ae),p=ne(t,e,g),f="size",v=re(t,e,f,ae),x=ne(t,e,f),y="family",w=re(t,e,y,s),S=ne(t,e,y),E="color",O=re(t,e,E,he),m=ne(t,e,E),T=re(t,e,"u"),R=re(t,e,"u",he),_=ne(t,e,"u"),k=re(t,e,"s"),P=re(t,e,"s",he),C=ne(t,e,"s"),b="shadow",L=re(t,e,b),M=re(t,e,b,he),A=ne(t,e,b),F="stroke",I=re(t,e,F),N=re(t,e,F,he),H=ne(t,e,F),W="bgcolor",B=re(t,e,W,he),Y=ne(t,e,W),$=re(t,e,"y",ae),G=ne(t,e,"y"),z="spacing",D=re(t,e,z,ae),U=ne(t,e,z),X=re(t,e,"img",s),j=ne(t,e,"img"),K="area",V=re(t,e,K,s),J=ne(t,e,K),q=re(t,e,"url",s),Z=ne(t,e,"url"),Q="align",tt=re(t,e,Q,s),et=ne(t,e,Q),it=re(t,e,"id",s),st=ne(t,e,"id");return se.RE_ESC_OPEN=new RegExp(r,"i"),se.RE_ESC_CLOSE=new RegExp(n,"i"),se.RE_RAW_OPEN=new RegExp(a,"i"),se.RE_RAW_CLOSE=new RegExp(h,"i"),se.RE_BLOD_OPEN=new RegExp(o,"i"),se.RE_BLOD_CLOSE=new RegExp(l,"i"),se.RE_ITALICS_OPEN=new RegExp(u,"i"),se.RE_ITALICS_CLOSE=new RegExp(d,"i"),se.RE_WEIGHT_OPEN=new RegExp(c,"i"),se.RE_WEIGHT_CLOSE=new RegExp(p,"i"),se.RE_SIZE_OPEN=new RegExp(v,"i"),se.RE_SIZE_CLOSE=new RegExp(x,"i"),se.RE_FAMILY_OPEN=new RegExp(w,"i"),se.RE_FAMILY_CLOSE=new RegExp(S,"i"),se.RE_COLOR_OPEN=new RegExp(O,"i"),se.RE_COLOR_CLOSE=new RegExp(m,"i"),se.RE_UNDERLINE_OPEN=new RegExp(T,"i"),se.RE_UNDERLINE_OPENC=new RegExp(R,"i"),se.RE_UNDERLINE_CLOSE=new RegExp(_,"i"),se.RE_STRIKETHROUGH_OPEN=new RegExp(k,"i"),se.RE_STRIKETHROUGH_OPENC=new RegExp(P,"i"),se.RE_STRIKETHROUGH_CLOSE=new RegExp(C,"i"),se.RE_SHADOW_OPEN=new RegExp(L,"i"),se.RE_SHADOW_OPENC=new RegExp(M,"i"),se.RE_SHADOW_CLOSE=new RegExp(A,"i"),se.RE_STROKE_OPEN=new RegExp(I,"i"),se.RE_STROKE_OPENC=new RegExp(N,"i"),se.RE_STROKE_CLOSE=new RegExp(H,"i"),se.RE_BGCOLOR_OPEN=new RegExp(B,"i"),se.RE_BGCOLOR_CLOSE=new RegExp(Y,"i"),se.RE_OFFSETY_OPEN=new RegExp($,"i"),se.RE_OFFSETY_CLOSE=new RegExp(G,"i"),se.RE_SPACING_OPEN=new RegExp(D,"i"),se.RE_SPACING_CLOSE=new RegExp(U,"i"),se.RE_IMAGE_OPEN=new RegExp(X,"i"),se.RE_IMAGE_CLOSE=new RegExp(j,"i"),se.