UNPKG

phaser3-rex-plugins

Version:
6 lines 56.6 kB
!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).rexbbcodetext=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 i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(r=n.key,s=void 0,"symbol"==typeof(s=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(r,"string"))?s:String(s)),n);}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 n(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),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 i,n=s(t);if(e){var r=s(this).constructor;i=Reflect.construct(n,arguments,r);}else i=n.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,i)}}function l(t){return function(t){if(Array.isArray(t))return u(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 u(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return u(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 u(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var c,f=Phaser.Renderer.WebGL.Utils,d={renderWebGL:function(t,e,i,n){if(0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,s=r.width,a=r.height,o=f.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,i.alpha*e._alphaTL),o(e.tintTopRight,i.alpha*e._alphaTR),o(e.tintBottomLeft,i.alpha*e._alphaBL),o(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,n,!1,l),t.pipelines.postBatch(e);}},renderCanvas:function(t,e,i,n){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,n));}},g=Phaser.Display.Canvas.CanvasPool,p=!1;p||(void 0===c&&(c=60),parseInt(Phaser.VERSION.match(/\.(\d+)\./)[1])<c&&console.error("Minimum supported version : 3.".concat(c)),p=!0);var y=function(t){r(s,t);var i=h(s);function s(){return e(this,s),i.apply(this,arguments)}return n(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,i){return this.style.setBackgroundColor(t,e,i)}},{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,i,n,r,s){return this.style.setShadow(t,e,i,n,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,i){void 0===i&&(i={});var n=g.create(this),r=n.getContext("2d",{willReadFrequently:!0});t.syncFont(n,r);var s=r.measureText(e),a=Math.ceil(s.width*t.baselineX),o=a,h=2*o;if(o=o*t.baselineY|0,n.width=a,n.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),i.left=0,0===a||0===h||!r.getImageData(0,0,a,h))return g.remove(n),i;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)]){i.left=c,u=!0;break}if(u)break}return g.remove(n),i}(this.style,t,e)}}]),s}(Phaser.GameObjects.GameObject),v=Phaser.GameObjects.Components;Phaser.Class.mixin(y,[v.Alpha,v.BlendMode,v.ComputedSize,v.Crop,v.Depth,v.Flip,v.GetBounds,v.Mask,v.Origin,v.Pipeline,v.PostPipeline,v.ScrollFactor,v.Tint,v.Transform,v.Visible,d]);var k=Phaser.Utils.String.Pad,x=function(e,i,n){if(null==e)return e;switch(t(e)){case"string":default:return e;case"number":return "#".concat(k(Math.floor(e).toString(16),6,"0",1));case"function":return e(i,n);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}},w={backgroundColor:["backgroundColor",null,x],backgroundColor2:["backgroundColor2",null,x],backgroundHorizontalGradient:["backgroundHorizontalGradient",!0,null],backgroundStrokeColor:["backgroundStrokeColor",null,x],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",x],stroke:["stroke","#fff",x],strokeThickness:["strokeThickness",0,null],shadowOffsetX:["shadow.offsetX",0,null],shadowOffsetY:["shadow.offsetY",0,null],shadowColor:["shadow.color","#000",x],shadowBlur:["shadow.blur",0,null],shadowStroke:["shadow.stroke",!1,null],shadowFill:["shadow.fill",!1,null],underlineColor:["underline.color","#000",x],underlineThickness:["underline.thickness",0,null],underlineOffset:["underline.offset",0,null],strikethroughColor:["strikethrough.color","#000",x],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]},S=Phaser.Display.Canvas.CanvasPool,E=function(t){var e=S.create(this),i=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,i);var n=i.measureText(t.testString);if("actualBoundingBoxAscent"in n){var r=n.actualBoundingBoxAscent,s=n.actualBoundingBoxDescent,a={ascent:r,descent:s,fontSize:r+s};return S.remove(e),a}var o=Math.ceil(n.width*t.baselineX),h=o,l=2*h;h=h*t.baselineY|0,e.width=o,e.height=l,i.fillStyle="#f00",i.fillRect(0,0,o,l),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,h);a={ascent:0,descent:0,fontSize:0};if(!i.getImageData(0,0,o,l))return a.ascent=h,a.descent=h+6,a.fontSize=a.ascent+a.descent,S.remove(e),a;var u,c,f=i.getImageData(0,0,o,l).data,d=f.length,g=4*o,p=0,y=!1;for(u=0;u<h;u++){for(c=0;c<g;c+=4)if(255!==f[p+c]){y=!0;break}if(y)break;p+=g;}for(a.ascent=h-u,p=d-g,y=!1,u=l;u>h;u--){for(c=0;c<g;c+=4)if(255!==f[p+c]){y=!0;break}if(y)break;p-=g;}return a.descent=u-h,a.fontSize=a.ascent+a.descent,S.remove(e),a},T=0,m=1,O=2,R=0,_=1,P=2,b=/(?:\r\n|\r|\n)/,C=Phaser.Utils.Objects.GetAdvancedValue,M=Phaser.Utils.Objects.GetValue,L=function(){function t(i,n,r){e(this,t),this.parent=i,void 0===r&&(r=w),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(n,!1,!0);}return n(t,[{key:"isWrapFitMode",get:function(){return this.fixedWidth>0&&this.wrapMode!==R&&0===this.wrapWidth}},{key:"setStyle",value:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=!1),t&&t.hasOwnProperty("wrap")){var n=t.wrap;if(n.hasOwnProperty("mode")){var r=n.mode;"string"==typeof r&&(n.mode=A[r]);}else n.hasOwnProperty("width")&&(n.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 s=this.propertyMap;for(var a in s){var o=s[a],h=o[0],l=i?o[1]:this[a],u=o[2];if("wrapCallback"===a||"wrapCallbackScope"===a)this[a]=M(t,h,l);else {var c=C(t,h,l);u&&(c=u(c)),this[a]=c;}}var f=M(t,"font",null);this._font=null===f?this.fontStyle+" "+this.fontSize+" "+this.fontFamily:f;var d=M(t,"fill",null);null!==d&&(this.color=x(d));var g=M(t,"metrics",!1);return g?this.metrics={ascent:M(g,"ascent",0),descent:M(g,"descent",0),fontSize:M(g,"fontSize",0)}:!e&&this.metrics||(this.metrics=E(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=E(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=M(t,"fontFamily","Courier"),this.fontSize=M(t,"fontSize","16px"),this.fontStyle=M(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,i){return void 0===i&&(i=!0),this.backgroundColor=x(t,this.parent.canvas,this.parent.context),this.backgroundColor2=x(e,this.parent.canvas,this.parent.context),this.backgroundHorizontalGradient=i,this.update(!1)}},{key:"setBackgroundStrokeColor",value:function(t,e){return this.backgroundStrokeColor=x(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=x(t,this.parent.canvas,this.parent.context),this.update(!1)}},{key:"setColor",value:function(t){return this.color=x(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=x(t,this.parent.canvas,this.parent.context),this.strokeThickness=e),this.update(!0)}},{key:"setShadow",value:function(t,e,i,n,r,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="#000"),void 0===n&&(n=0),void 0===r&&(r=!1),void 0===s&&(s=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=x(i,this.parent.canvas,this.parent.context),this.shadowBlur=n,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=x(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,i){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===i&&(i=0),this.underlineColor=x(t,this.parent.canvas,this.parent.context),this.underlineThickness=e,this.underlineOffset=i,this.update(!1)}},{key:"setUnderlineColor",value:function(t){return void 0===t&&(t="#000"),this.underlineColor=x(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,i){return void 0===t&&(t="#000"),void 0===e&&(e=0),void 0===i&&(i=0),this.strikethroughColor=x(t,this.parent.canvas,this.parent.context),this.strikethroughThickness=e,this.strikethroughOffset=i,this.update(!1)}},{key:"setStrikethroughColor",value:function(t){return void 0===t&&(t="#000"),this.strikethroughColor=x(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=A[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=M(e,"fontFamily",this.fontFamily),this.fontSize=M(e,"fontSize",this.fontSize),this.fontStyle=M(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 i in e)t[i]=this[i];return t.metrics=this.getTextMetrics(),t}},{key:"destroy",value:function(){this.parent=void 0;}}]),t}(),A={none:R,word:_,char:P,character:P},F=Phaser.Utils.Objects.GetValue,I=function(){function t(i,n,r,s,a){e(this,t),void 0===i&&(i=0),void 0===n&&(n=i),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(i,n,r,s,a);}return n(t,[{key:"setTo",value:function(t,e,i,n,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(i,n),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,i;"number"==typeof t?(e=t,i=t):(e=F(t,"x",0),i=F(t,"y",0));var n=this.cornerRadius;n.tl=W(F(t,"tl",void 0),e,i),n.tr=W(F(t,"tr",void 0),e,i),n.bl=W(F(t,"bl",void 0),e,i),n.br=W(F(t,"br",void 0),e,i);}},{key:"radiusTL",get:function(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)},set:function(t){N(this.cornerRadius.tl,t);}},{key:"radiusTR",get:function(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)},set:function(t){N(this.cornerRadius.tr,t);}},{key:"radiusBL",get:function(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)},set:function(t){N(this.cornerRadius.bl,t);}},{key:"radiusBR",get:function(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)},set:function(t){N(this.cornerRadius.br,t);}}]),t}(),W=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),H(t),t},N=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=F(e,"x",0),t.y=F(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);},z=Phaser.Math.DegToRad,B=function(t){return !t.hasOwnProperty("convex")||t.convex},j=function(t){return t.x>0&&t.y>0},G=function(t,e,i,n,r,s,a,o,h){if(o&&a>s?a-=360:!o&&a<s&&(a+=360),s=z(s),a=z(a),null==h)t.ellipse(e,i,n,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+n*Math.cos(c),u=i+r*Math.sin(c),t.lineTo(l,u);},D=function(t,e,i,n,r,s,a,o,h,l,u,c,f){if(function(t,e,i,n,r,s,a){var o,h,l,u,c,f=new I(e,i,n,r,s),d=f.minWidth,g=f.minHeight,p=n>=d?1:n/d,y=r>=g?1:r/g,v=f.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),o=v.tl,j(o)?(h=o.x*p,l=o.y*y,B(o)?G(t,h,l,h,l,180,270,!1,a):G(t,0,0,h,l,90,0,!0,a),u=0,c=l):(t.lineTo(0,0),u=0,c=0),o=v.tr,j(o)?(h=o.x*p,l=o.y*y,B(o)?G(t,n-h,l,h,l,270,360,!1,a):G(t,n,0,h,l,180,90,!0,a)):t.lineTo(n,0),o=v.br,j(o)?(h=o.x*p,l=o.y*y,B(o)?G(t,n-h,r-l,h,l,0,90,!1,a):G(t,n,r,h,l,270,180,!0,a)):t.lineTo(n,r),o=v.bl,j(o)?(h=o.x*p,l=o.y*y,B(o)?G(t,h,r-l,h,l,90,180,!1,a):G(t,0,r,h,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(u,c),t.closePath(),t.restore();}(e,i,n,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());},X={draw:function(t,e,i,n){var r=this.penManager;this.hitAreaManager.clear();var s=this.context;s.save();var a=this.defaultStyle;this.clear(),function(t,e,i,n,r,s,a,o){if(null!=e||null!=i){var h=t.canvas.width,l=t.canvas.height;null==i&&(n=0);var u=n/2;h=Math.max(1,h-n),l=Math.max(1,l-n),D(t.canvas,t.context,u,u,h,l,r,e,i,n,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,p=a.lineHeight,y=r.lines,v=y.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((n-h*p)/2,0):"bottom"===g?Math.max(n-h*p-2,0):0,f+=e;for(var S=l;S<u;S++)if(0!==(o=r.getLineWidth(S))){for(var E=y[S],T=E.length,m=d,O=0;O<T;O++){var R=E[O].prop.align;if(void 0!==R){m=R;break}}c="center"===m?(i-o)/2:"right"===m?x?0:i-o:x?i-o:0,c+=t;for(O=0;O<T;O++)this.drawPen(E[O],c,f,w);}s.restore();},drawPen:function(t,e,i,n){e+=t.x,i+=t.y+(t.prop.y||0),void 0!==n&&(e=n-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=i+a.underlineOffset-a.underlineThickness/2;this.drawLine(e,o,t.width,a.underlineThickness,a.underlineColor,a);}if(t.isTextPen&&this.drawText(e,i,t.text,a),t.isImagePen&&this.drawImage(e,i,t.prop.img,a),a.strikethroughThickness>0&&t.width>0){o=i+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,i-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,i,n,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=n,a.beginPath(),a.moveTo(t,e),a.lineTo(t+i,e),a.stroke(),a.lineCap=o;},drawText:function(t,e,i,n){this.autoRound&&(t=Math.round(t),e=Math.round(e));var r=this.context;n.stroke&&"none"!==n.stroke&&n.strokeThickness>0&&(n.syncShadow(r,n.shadowStroke),r.strokeText(i,t,e)),n.color&&"none"!==n.color&&(n.syncShadow(r,n.shadowFill),r.fillText(i,t,e));},drawImage:function(t,e,i,n){e-=this.startYOffset,this.parent.imageManager.draw(i,this.context,t,e,this.autoRound);}},U=Phaser.Utils.Objects.GetValue,Y=T,K=m,V=function(){function t(i){e(this,t),this.prop={},this.resetFromJSON(i);}return n(t,[{key:"resetFromJSON",value:function(t){this.text=U(t,"text",""),this.x=U(t,"x",0),this.y=U(t,"y",0),this.width=U(t,"width",0);var e=U(t,"prop",null);null===e&&(e={}),this.prop=e,this.newLineMode=U(t,"newLineMode",0),this.startIndex=U(t,"startIndex",0);}},{key:"plainText",get:function(){var t=this.text;return this.newLineMode===K&&(t+="\n"),t}},{key:"wrapText",get:function(){var t=this.text;return this.newLineMode!==Y&&(t+="\n"),t}},{key:"rawTextLength",get:function(){var t=this.text.length;return this.newLineMode===K&&(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}(),J=function(e){if("object"!==t(e)||null===e)return e;if(Array.isArray(e))e.length=0;else for(var i in e)delete e[i];return e},q=function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:J(e),i){e.length=t.length;for(var n=0,r=t.length;n<r;n++)e[n]=t[n];}else for(var s in t)e[s]=t[s];return e},Z=function(){},$=Phaser.Utils.Objects.GetFastValue,Q=T,tt=O,et=function(){function t(i){e(this,t),this.pens=[],this.lines=[],this.maxLinesWidth=void 0,this.pensPool=i.pensPool,this.linesPool=i.linesPool,this.tagToText=$(i,"tagToText",Z),this.tagToTextScope=$(i,"tagToTextScope",void 0);}return n(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,i,n,r,s){var a=this.pensPool.pop();return null==a&&(a=new V),it.text=t,it.x=e,it.y=i,it.width=n,it.prop=r,it.newLineMode=s,a.resetFromJSON(it),this.addPen(a),this}},{key:"addImagePen",value:function(t,e,i,n){return this.addTextPen("",t,e,i,n,Q),this}},{key:"addNewLinePen",value:function(){var t=this.lastPen,e=t?t.lastX:0,i=t?t.y:0,n=t?q(t.prop):null;return this.addTextPen("",e,i,0,n,tt),this}},{key:"addPen",value:function(t){var e=this.lastPen;t.startIndex=null==e?0:e.endIndex,this.pens.push(t);var i=this.lastLine;null==i&&(i=this.linesPool.pop()||[],this.lines.push(i)),i.push(t),t.newLineMode!==Q&&(i=this.linesPool.pop()||[],this.lines.push(i)),this.maxLinesWidth=void 0;}},{key:"clone",value:function(e){null==e&&(e=new t),e.clear();for(var i=0,n=this.lines.length;i<n;i++)for(var r=this.lines[i],s=0,a=r.length;s<a;s++){var o=r[s];e.addPen(o.text,o.x,o.y,o.width,q(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,i,n=!1;for(e=t;e>=0&&!(n=null!=(i=this.lines[e])&&i.length>0);e--);return n?i[i.length-1].endIndex:0}},{key:"getLineWidth",value:function(t){var e=this.lines[t];if(!e)return 0;var i=e[e.length-1];return null==i?0:i.lastX}},{key:"getMaxLineWidth",value:function(){if(void 0!==this.maxLinesWidth)return this.maxLinesWidth;for(var t,e=0,i=0,n=this.lines.length;i<n;i++)(t=this.getLineWidth(i))>e&&(e=t);return this.maxLinesWidth=e,e}},{key:"getLineWidths",value:function(){for(var t=[],e=0,i=this.lines.length;e<i;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,i=0,n=e.length;i<n;i++)t+=e[i].plainText;return t}},{key:"rawTextLength",get:function(){for(var t=0,e=this.pens,i=0,n=this.pens.length;i<n;i++)t+=e[i].rawTextLength;return t}},{key:"getSliceTagText",value:function(t,e,i){var n=this.lastPen;if(null==n)return "";var r=n.endIndex;void 0!==t&&0!==t||(t=-1),void 0!==e&&e!==r||(e=r+1),void 0===i&&(i=!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=i?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={},nt=function(){function t(){e(this,t),this.items=[];}return n(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}(),rt=Phaser.Geom.Rectangle,st=new nt,at=function(){function t(){e(this,t),this.hitAreas=[];}return n(t,[{key:"destroy",value:function(){this.clear();}},{key:"clear",value:function(){for(var t=0,e=this.hitAreas.length;t<e;t++)J(this.hitAreas[t].data);return st.pushMultiple(this.hitAreas),this}},{key:"add",value:function(t,e,i,n,r){var s=st.pop();return null===s?s=new rt(t,e,i,n):s.setTo(t,e,i,n),s.data=r,this.hitAreas.push(s),this}},{key:"getFirst",value:function(t,e){for(var i=0,n=this.hitAreas.length;i<n;i++){var r=this.hitAreas[i];if(r.contains(t,e))return r}return null}},{key:"getByKey",value:function(t){for(var e=0,i=this.hitAreas.length;e<i;e++){var n=this.hitAreas[e];if(n.data.key===t)return n}return null}},{key:"drawBounds",value:function(t,e,i){void 0===e&&(e=16777215),i&&t.save().scaleCanvas(i.scaleX,i.scaleY).rotateCanvas(i.rotation).translateCanvas(i.x,i.y);for(var n=0,r=this.hitAreas.length;n<r;n++){var s=this.hitAreas[n];t.lineStyle(1,e).strokeRect(s.x,s.y,s.width,s.height);}return i&&t.restore(),this}}]),t}(),ot=function(t,e,i,n){var r=this.hitAreaManager.getFirst(e,i);if(null!==r){var s=r.data.key;ut.call(this,"areadown",s,t,e,i,n),r.data.isDown=!0;}},ht=function(t,e,i,n){var r=this.hitAreaManager.getFirst(e,i);if(null!==r){var s=r.data,a=s.key;if(ut.call(this,"areaup",a,t,e,i,n),s.isDown){ut.call(this,"areaclick",a,t,e,i,n);var o=s.url;o&&window.open(o,"_blank");}s.isDown=!1;}},lt=function(t,e,i,n){if(null!==e){var r=this.hitAreaManager.getFirst(e,i),s=r?r.data.key:null;if(this.lastHitAreaKey!==s){if(null!==this.lastHitAreaKey){ut.call(this,"areaout",this.lastHitAreaKey,t,e,i,n);var a=this.hitAreaManager.getByKey(this.lastHitAreaKey);this.urlTagCursorStyle&&a.data.url&&(this.scene.input.manager.canvas.style.cursor=""),a.isDown=!1;}null!==s&&(ut.call(this,"areaover",s,t,e,i,n),this.urlTagCursorStyle&&r.data.url&&(this.scene.input.manager.canvas.style.cursor=this.urlTagCursorStyle)),this.lastHitAreaKey=s;}}else null!==this.lastHitAreaKey&&(ut.call(this,"areaout",this.lastHitAreaKey,t,e,i,n),this.hitAreaManager.getByKey(this.lastHitAreaKey).isDown=!1,this.lastHitAreaKey=null);},ut=function(t,e,i,n,r,s){this.parent.emit("".concat(t,"-").concat(e),i,n,r,s),this.parent.emit(t,e,i,n,r,s);},ct=T,ft=m,dt=O,gt=R,pt=_,yt=P,vt=b,kt=function t(e,i,n,r,s,a){r<=0&&(n=gt);var o=[];if(!e||!e.length)return o;for(var h,u,c,f=n===gt,d=n===pt,g=e.split(vt),p=0,y=g.length;p<y;p++)if(h=g[p],c=p===y-1?ct:ft,f){var v=i(h);o.push(a.getLine(h,v,c));}else {var k,x,w,S,E;if(u=0===p?r-s:r,h.length<=100)if((v=i(h))<=u){o.push(a.getLine(h,v,c));continue}d?(x=""===(k=h.split(" "))[k.length-1])&&(k.length-=1):k=h;for(var T,m="",O=0,R=d?i(" "):void 0,_=0,P=k.length;_<P;_++)if(S=i(w=k[_]),E=_===P-1,!d||E&&!x||(w+=" ",S+=R),d&&S>r){""!==m?o.push(a.getLine(m,O,dt)):0===_&&s>0&&o.push(a.getLine("",0,dt)),o.push.apply(o,l(t(w,i,yt,r,0,a)));var b=o.pop();m=b.text,O=b.width,a.freeLine(b)," "===m&&(m="",O=0);}else (T=O+S)>u?(o.push(a.getLine(m,O,dt)),m=w,O=S,u=r):(m+=w,O=T),E&&o.push(a.getLine(m,O,c));}return o},xt=Phaser.Utils.Objects.GetValue,wt=R,St=T,Et=function(){function t(i){e(this,t),this.parent=i.parent,this.scene=this.parent.scene,this.context=xt(i,"context",null),this.canvas=this.context.canvas,this.parser=xt(i,"parser",null),this.defaultStyle=xt(i,"style",null),this.autoRound=!0,this.pensPool=i.pensPool,this.linesPool=i.linesPool,this.wrapTextLinesPool=i.wrapTextLinesPool,this.penManager=this.newPenManager(),this._tmpPenManager=null,this.hitAreaManager=new at,this.lastHitAreaKey=null,this.urlTagCursorStyle=null;var n=this.context;this.getTextWidth=function(t){return n.measureText(t).width};}return n(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,i,n,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;i=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},p=0,y=0,v=s.wrapCallback,k=s.wrapCallbackScope,x=!0,w=this.parser.splitText(t),S=this.wrapTextLinesPool,E=0,T=w.length;E<T;E++)if(o=(u=this.parser.tagTextToProp(w[E],h)).plainText,(h=u.prop).img){var m=this.imageManager.getOuterWidth(h.img);i>0&&e!==wt&&i<p+m&&(r.addNewLinePen(),y+=n,p=0),r.addImagePen(p,y,m,q(h)),p+=m;}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,i,p))&&(c=c.split("\n"));for(var O=0,R=c.length;O<R;O++)"string"==typeof(_=c[O])?c[O]=S.getLine(_,g(_),O<R-1?2:0):x=!1;}else c=kt(o,g,e,i,p,S);var _;for(O=0,R=c.length;O<R;O++)_=c[O],r.addTextPen(_.text,p,y,_.width,q(h),_.newLineMode),_.newLineMode!==St?(p=0,y+=n):p+=_.width;x&&S.freeLines(c),c=null,d.restore();}for(E=0,T=this.lines.length;E<T;E++){var P=this.lines[E],b=P[P.length-1];b&&(b.width+=this.parser.getStrokeThinkness(this.defaultStyle,b.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 et({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,i){var n;if(null==t)n=this.penManager.plainText;else {var r=this.parser.splitText(t,1);n="";for(var s=0,a=r.length;s<a;s++)n+=r[s];}return null==e&&null==i||(null==e&&(e=0),null==i&&(i=n.length),n=n.substring(e,i)),n}},{key:"getPenManager",value:function(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}},{key:"getText",value:function(t,e,i,n){if(null==t)return this.penManager.getSliceTagText(e,i,n);var r=this.tmpPenManager,s=this.defaultStyle;return this.updatePenManager(t,s.wrapMode,s.wrapWidth,s.lineHeight,r),r.getSliceTagText(e,i,n)}},{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}(),Tt={setInteractive:function(){this.parent.on("pointerdown",ot,this).on("pointerup",ht,this).on("pointermove",lt,this).on("pointerover",lt,this).on("pointerout",(function(t,e){lt.call(this,t,null,null,e);}),this);}};Object.assign(Et.prototype,X,Tt);var mt=function(t){r(s,t);var i=h(s);function s(){return e(this,s),i.apply(this,arguments)}return n(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,i){var n=this.pop();return null===n&&(n={}),n.text=t,n.width=e,n.newLineMode=i,n}}]),s}(nt),Ot=Phaser.Utils.Objects.IsPlainObject,Rt=Phaser.Utils.Objects.GetValue,_t=function(t,e){Ot(t)?t=(e=t).key:void 0===e&&(e={key:t}),e.hasOwnProperty("key")||(e.key=t);var i=e.key,n=e.frame,r=e.width,s=e.height;if(void 0===r||void 0===s){var a=this.textureManager.getFrame(i,n),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:i,frame:n,width:r,height:s,y:Rt(e,"y",0),left:Rt(e,"left",0),right:Rt(e,"right",0),originX:Rt(e,"originX",0),originY:Rt(e,"originY",0)};},Pt=function(){function t(i){e(this,t),this.textureManager=i.sys.textures,this.images={};}return n(t,[{key:"destroy",value:function(){this.textureManager=void 0,this.images=void 0;}},{key:"add",value:function(t,e){if("string"==typeof t)_t.call(this,t,e);else if(Array.isArray(t))for(var i=0,n=(r=t).length;i<n;i++)_t.call(this,r[i]);else {var r=t;for(var t in r)_t.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}(),bt={draw:function(t,e,i,n,r){var s=this.get(t),a=this.textureManager.getFrame(s.key,s.frame),o=s.width,h=s.height;i+=s.left-s.originX*o,n+=s.y-s.originY*h,r&&(i=Math.round(i),n=Math.round(n)),e.drawImage(a.source.image,a.cutX,a.cutY,a.cutWidth,a.cutHeight,i,n,o,h);}};Object.assign(Pt.prototype,bt);var Ct=Phaser.Utils.Objects.IsPlainObject,Mt=Phaser.DOM.AddToDOM,Lt=Phaser.Display.Canvas.CanvasPool,At=Phaser.GameObjects.GameObject,Ft=Phaser.Utils.Objects.GetValue,It=Phaser.DOM.RemoveFromDOM,Wt=b,Nt=null,Ht=null,zt=null,Bt=function(i){r(a,i);var s=h(a);function a(t,i,n,r,h,l,u){var c;if(e(this,a),Ct(i)){var f=i;i=Ft(f,"x",0),n=Ft(f,"y",0),r=Ft(f,"text",""),h=Ft(f,"style");}if(void 0===i&&(i=0),void 0===n&&(n=0),(c=s.call(this,t,l)).renderer=t.sys.game.renderer,c.setPosition(i,n),c.setOrigin(0,0),c.initPipeline(),c.initPostPipeline(!0),c.canvas=Lt.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 L(o(c),h);var g,p,y,v=Ft(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),Ft(h,"sharedPool",!0)?(Nt||(Nt={},Ht=new nt,zt=new mt,c.scene.game.events.once("destroy",(function(){Nt=null,Ht=null,zt=null;}))),Nt.hasOwnProperty(l)||(Nt[l]=new nt),g=Nt[l],p=Ht,y=zt):(g=new nt,p=new nt,y=new mt),c.canvasText=new Et({parent:o(c),context:c.context,parser:u,style:c.style,pensPool:g,linesPool:p,wrapTextLinesPool:y}),c.parser=u,c.initRTL(),h&&h.padding&&c.setPadding(h.padding),c.setText(r),c.setUrlTagCursorStyle(Ft(h,"urlTagCursorStyle","pointer")),Ft(h,"interactive",!1)&&c.setInteractive(),c}return n(a,[{key:"preDestroy",value:function(){It(this.canvas),this.canvasText.destroy(),this.canvasText=void 0,this._imageManager&&(this._imageManager.destroy(),this._imageManager=void 0),Lt.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",Mt(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",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 n in i)i[n].originX=1-i[n].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,i,n,r){if("object"===t(e)){var s=e,a=Ft(s,"x",null);null!==a?(e=a,n=a):(e=Ft(s,"left",0),n=Ft(s,"right",e));var o=Ft(s,"y",null);null!==o?(i=o,r=o):(i=Ft(s,"top",0),r=Ft(s,"bottom",i));}else void 0===e&&(e=0),void 0===i&&(i=e),void 0===n&&(n=e),void 0===r&&(r=i);return this.padding.left=e,this.padding.top=i,this.padding.right=n,this.padding.bottom=r,this.updateText(!1)}},{key:"updateText",value:function(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 n,r,s=this.padding,a=Math.ceil(e.linesWidth);0===i.fixedWidth?(this.width=a+s.left+s.right,n=a):(this.width=i.fixedWidth,(n=this.width-s.left-s.right)<a&&(n=a)),0===i.fixedHeight?(this.height=e.linesHeight+s.top+s.bottom,r=e.linesHeight):(this.height=i.fixedHeight,(r=this.height-s.top-s.bottom)<e.linesHeight&&(r=e.linesHeight));var o=this.width,h=this.height;this.updateDisplayOrigin();var l=i.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,n,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,i){var n=!!this.input;return At.prototype.setInteractive.call(this,t,e,i),n||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,i){return "number"==typeof t&&(i=e,e=t,t=void 0),(t=this.canvasText.getText(t,e,i,!0)).split(Wt)}},{key:"getPlainText",value:function(t,e,i){return "number"==typeof t&&(i=e,e=t,t=void 0),this.canvasText.getPlainText(t,e,i)}},{key:"getText",value:function(t,e,i,n){return "number"==typeof t&&(n=i,i=e,e=t,t=void 0),void 0===n&&(n=!1),this.canvasText.getText(t,e,i,n)}},{key:"getSubString",value:function(t,e,i){return "number"==typeof t&&(i=e,e=t,t=void 0),this.getText(t,e,i)}},{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 Pt(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,i,n,r){var s=this.canvas;return void 0===n?n=s.width:n*=this.resolution,void 0===r?r=s.height:r*=this.resolution,function(t,e,i,n,r,s,a){var o,h=t.sys.textures,l=t.renderer;void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=e.width),void 0===a&&(a=e.height);var u=(o=h.exists(i)?h.get(i):h.createCanvas(i,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,n,r,s,a),l.gl&&o&&l.canvasToTexture(u,o.source[0].glTexture,!0,0);}(this.scene,s,t,e,i,n,r),this}}]),a}(y),jt={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?"".concat(this.text,"\n").concat(t):"".concat(this.text).concat(t))!=this.text&&this.setText(i),this}};Object.assign(Bt.prototype,jt);var Gt,Dt,Xt=!1,Ut=!0,Yt={plainText:null,prevProp:null},Kt=function(t,e,i,n){return e===Ut?t[i]=n:t.hasOwnProperty(i)&&delete t[i],t},Vt=function(t){var e=t.b,i=t.weight,n=t.i;return e||i||n?n?e?"bold italic":i?"".concat(i," italic"):"italic":e?"bold":i.toString():""},Jt=new L,qt={},Zt=function(t){return t.replace($t,"\\$&").replace(Qt,"\\x2d")},$t=/[|\\{}()[\]^$+*?.]/g,Qt=/-/g,te={},ee=function(t,e,i,n){return void 0===n?"".concat(t).concat(i).concat(e):"".concat(t).concat(i,"=(").concat(n,")").concat(e)},ie=function(t,e,i){return "".concat(t,"/").concat(i).concat(e)},ne="[-.0-9]+",re="[a-z]+|#[0-9abcdef]+",se="[^\\]]+",ae=function(t,e){if(void 0===e){var i=t;t=i[0],e=i[1];}if(Gt===t&&Dt===e)return !1;Gt=t,Dt=e,t=Zt(t),e=Zt(e);var n=ee(t,e,"esc"),r=ie(t,e,"esc"),s=ee(t,e,"raw"),a=ie(t,e,"raw"),o=ee(t,e,"b"),h=ie(t,e,"b"),l=ee(t,e,"i"),u=ie(t,e,"i"),c="weight",f=ee(t,e,c,ne),d=ie(t,e,c),g="size",p=ee(t,e,g,ne),y=ie(t,e,g),v="color",k=ee(t,e,v,re),x=ie(t,e,v),w=ee(t,e,"u"),S=ee(t,e,"u",re),E=ie(t,e,"u"),T=ee(t,e,"s"),m=ee(t,e,"s",re),O=ie(t,e,"s"),R="shadow",_=ee(t,e,R),P=ie(t,e,R),b="stroke",C=ee(t,e,b),M=ee(t,e,b,re),L=ie(t,e,b),A=ee(t,e,"y",ne),F=ie(t,e,"y"),I=ee(t,e,"img",se),W=ie(t,e,"img"),N="area",H=ee(t,e,N,se),z=ie(t,e,N),B=ee(t,e,"url",se),j=ie(t,e,"url"),G="align",D=ee(t,e,G,se),X=ie(t,e,G);return te.RE_ESC_OPEN=new RegExp(n,"i"),te.RE_ESC_CLOSE=new RegExp(r,"i"),te.RE_RAW_OPEN=new RegExp(s,"i"),te.RE_RAW_CLOSE=new RegExp(a,"i"),te.RE_BLOD_OPEN=new RegExp(o,"i"),te.RE_BLOD_CLOSE=new RegExp(h,"i"),te.RE_ITALICS_OPEN=new RegExp(l,"i"),te.RE_ITALICS_CLOSE=new RegExp(u,"i"),te.RE_WEIGHT_OPEN=new RegExp(f,"i"),te.RE_WEIGHT_CLOSE=new RegExp(d,"i"),te.RE_SIZE_OPEN=new RegExp(p,"i"),te.RE_SIZE_CLOSE=new RegExp(y,"i"),te.RE_COLOR_OPEN=new RegExp(k,"i"),te.RE_COLOR_CLOSE=new RegExp(x,"i"),te.RE_UNDERLINE_OPEN=new RegExp(w,"i"),te.RE_UNDERLINE_OPENC=new RegExp(S,"i"),te.RE_UNDERLINE_CLOSE=new RegExp(E,"i"),te.RE_STRIKETHROUGH_OPEN=new RegExp(T,"i"),te.RE_STRIKETHROUGH_OPENC=new RegExp(m,"i"),te.RE_STRIKETHROUGH_CLOSE=new RegExp(O,"i"),te.RE_