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