UNPKG

phaser3-rex-plugins

Version:
1 lines 85.8 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).rexcanvasinputplugin=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,p(n.key),n);}}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&&o(t,e);}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function a(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 h(t)}(this,i)}}function u(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}function l(){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=u(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},l.apply(this,arguments)}function c(t,e,i,n){return c="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,i,n){var r,s=u(t,e);if(s){if((r=Object.getOwnPropertyDescriptor(s,e)).set)return r.set.call(n,i),!0;if(!r.writable)return !1}if(r=Object.getOwnPropertyDescriptor(n,e)){if(!r.writable)return !1;r.value=i,Object.defineProperty(n,e,r);}else !function(t,e,i){(e=p(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i;}(n,e,i);return !0},c(t,e,i,n)}function d(t,e,i,n,r){if(!c(t,e,i,n||t)&&r)throw new TypeError("failed to set property");return i}function f(t){return function(t){if(Array.isArray(t))return v(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 v(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 v(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 v(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}function p(t){var e=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)}(t,"string");return "symbol"==typeof e?e:String(e)}var y,g=Phaser.Renderer.WebGL.Utils,k={renderWebGL:function(t,e,i,n){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,s=r.width,o=r.height,h=g.getTintAppendFloatAlpha,a=t.pipelines.set(e.pipeline,e),u=a.setTexture2D(r.glTexture,e);t.pipelines.preBatch(e),a.batchTexture(e,r.glTexture,s,o,e.x,e.y,s/e.resolution,o/e.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,s,o,h(e.tintTopLeft,i.alpha*e._alphaTL),h(e.tintTopRight,i.alpha*e._alphaTR),h(e.tintBottomLeft,i.alpha*e._alphaBL),h(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,n,!1,u),t.pipelines.postBatch(e);}},renderCanvas:function(t,e,i,n){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,n));}},x=Phaser.Display.Color,m={clear:function(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill:function(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},drawFrame:function(t,e,i,n,r,s,o,h,a,u){var l=this.scene.sys.textures.getFrame(t,e);if(!l)return this;var c=l.cutWidth,d=l.cutHeight;void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=c),void 0===s&&(s=d),void 0===o&&(o=0),void 0===h&&(h=0),void 0===a&&(a=c),void 0===u&&(u=d);var f=l.cutX+o,v=l.cutY+h;return this.context.drawImage(l.source.image,f,v,a,u,i,n,r,s),this.dirty=!0,this},getDataURL:function(t,e){return this.canvas.toDataURL(t,e)},getPixel:function(t,e,i){void 0===i&&(i=new x);var n=this.context.getImageData(t,e,1,1);return i.setTo(n.data[0],n.data[1],n.data[2],n.data[3]),i},setPixel:function(t,e,i,n,r,s){if("number"!=typeof i){var o=i;i=o.red,n=o.green,r=o.blue,s=o.alpha;}void 0===s&&(s=0!==i||0!==n||0!==r?255:0);var h=this.context.createImageData(1,1);return h.data[0]=i,h.data[1]=n,h.data[2]=r,h.data[3]=s,this.context.putImageData(h,t,e),this.dirty=!0,this}},w={updateTexture:function(t,e){t&&(e?t.call(e,this.canvas,this.context):t(this.canvas,this.context)),this.canvas.width===this.frame.width&&this.canvas.height===this.frame.height||this.frame.setSize(this.canvas.width,this.canvas.height),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(this.canvas,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!1;var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=this.width,i.hitArea.height=this.height),this},generateTexture: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,o){var h,a=t.sys.textures,u=t.renderer;void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=e.width),void 0===o&&(o=e.height);var l=(h=a.exists(i)?a.get(i):a.createCanvas(i,s,o)).getSourceImage();l.width!==s&&(l.width=s),l.height!==o&&(l.height=o);var c=l.getContext("2d",{willReadFrequently:!0});c.clearRect(0,0,s,o),c.drawImage(e,n,r,s,o),u.gl&&h&&u.canvasToTexture(l,h.source[0].glTexture,!0,0);}(this.scene,s,t,e,i,n,r),this},loadTexture:function(t,e){var i=this.scene.sys.textures.getFrame(t,e);return i?(this.width!==i.cutWidth||this.height!==i.cutHeight?this.setSize(i.cutWidth,i.cutHeight):this.clear(),this.drawFrame(t,e),this.dirty=!0,this):this}},b=!1;b||(void 0===y&&(y=60),parseInt(Phaser.VERSION.match(/\.(\d+)\./)[1])<y&&console.error("Minimum supported version : 3.".concat(y)),b=!0);var C=Phaser.Display.Canvas.CanvasPool,S=function(t){r(s,t);var i=a(s);function s(t,n,r,o,a){var u;return e(this,s),void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=1),void 0===a&&(a=1),(u=i.call(this,t,"rexCanvas")).renderer=t.sys.game.renderer,u.resolution=1,u._width=o,u._height=a,o=Math.max(Math.ceil(o*u.resolution),1),a=Math.max(Math.ceil(a*u.resolution),1),u.canvas=C.create(h(u),o,a),u.context=u.canvas.getContext("2d",{willReadFrequently:!0}),u.dirty=!1,u.setPosition(n,r),u.setOrigin(.5,.5),u.initPipeline(),u.initPostPipeline(!0),u._crop=u.resetCropObject(),u.texture=t.sys.textures.addCanvas(null,u.canvas,!0),u.frame=u.texture.get(),u.frame.source.resolution=u.resolution,u.renderer&&u.renderer.gl&&(u.renderer.deleteTexture(u.frame.source.glTexture),u.frame.source.glTexture=null),u.dirty=!0,u}return n(s,[{key:"preDestroy",value:function(){C.remove(this.canvas),this.texture.destroy(),this.canvas=null,this.context=null;}},{key:"width",get:function(){return this._width},set:function(t){this.setSize(t,this._height);}},{key:"height",get:function(){return this._height},set:function(t){this.setSize(this._width,t);}},{key:"setCanvasSize",value:function(t,e){return this._width===t&&this._height===e||(this._width=t,this._height=e,this.updateDisplayOrigin(),t=Math.max(Math.ceil(t*this.resolution),1),e=Math.max(Math.ceil(e*this.resolution),1),this.canvas.width=t,this.canvas.height=e,this.frame.setSize(t,e),this.dirty=!0),this}},{key:"setSize",value:function(t,e){return this.setCanvasSize(t,e),this}},{key:"displayWidth",get:function(){return this.scaleX*this._width},set:function(t){this.scaleX=t/this._width;}},{key:"displayHeight",get:function(){return this.scaleY*this._height},set:function(t){this.scaleY=t/this._height;}},{key:"setDisplaySize",value:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}},{key:"getCanvas",value:function(t){return t||(this.dirty=!0),this.canvas}},{key:"getContext",value:function(t){return t||(this.dirty=!0),this.context}},{key:"needRedraw",value:function(){return this.dirty=!0,this}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}}]),s}(Phaser.GameObjects.GameObject),O=Phaser.GameObjects.Components;Phaser.Class.mixin(S,[O.Alpha,O.BlendMode,O.Crop,O.Depth,O.Flip,O.GetBounds,O.Mask,O.Origin,O.Pipeline,O.PostPipeline,O.ScrollFactor,O.Tint,O.Transform,O.Visible,k,m,w]);var T=Phaser.Utils.Objects.GetValue,P=function(e,i,n){void 0===e&&(e={}),void 0===i&&(i=0);var r=t(i);return "string"===r?e[i]=n:"number"===r?(e.left=i,e.right=i,e.top=i,e.bottom=i):(e.left=T(i,"left",0),e.right=T(i,"right",0),e.top=T(i,"top",0),e.bottom=T(i,"bottom",0)),e},_={enableData:function(){return void 0===this.data&&(this.data={}),this},setData:function(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t];}else this.data[t]=e;return this},getData:function(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1!==e.indexOf(".")){for(var n=e.split("."),r=t,s=i,o=0;o<n.length;o++){if(!r.hasOwnProperty(n[o])){s=i;break}s=r[n[o]],r=r[n[o]];}return s}return i}return i}(this.data,t,e)},incData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData:function(){return this.data&&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];}(this.data),this}},E=function(){function t(i,n){e(this,t),this.setParent(i),this.type=n,this.renderable=!1,this.reset().setActive();}return n(t,[{key:"destroy",value:function(){this.parent.removeChild(this);}},{key:"setParent",value:function(t){return this.parent=t,this}},{key:"scene",get:function(){return this.parent.scene}},{key:"canvas",get:function(){return this.parent?this.parent.canvas:null}},{key:"context",get:function(){return this.parent?this.parent.context:null}},{key:"setDirty",value:function(t){return t&&this.parent&&(this.parent.dirty=!0),this}},{key:"active",get:function(){return this._active},set:function(t){this.setDirty(this._active!=t),this._active=t;}},{key:"setActive",value:function(t){return void 0===t&&(t=!0),this.active=t,this}},{key:"modifyPorperties",value:function(t){return this}},{key:"onFree",value:function(){this.reset().setParent();}},{key:"reset",value:function(){return this}},{key:"render",value:function(){}},{key:"contains",value:function(t,e){return !1}}]),t}();Object.assign(E.prototype,_);var Y,A,L,R,X,W={renderContent:function(){},render:function(){if(!this.willRender)return this;var t=this.context;if(t.save(),t.globalAlpha=this.alpha,this.toLocalPosition){var e=this.drawX,i=this.drawY;this.autoRound&&(e=Math.round(e),i=Math.round(i)),t.translate(e,i),t.scale(this.scaleX,this.scaleY),t.rotate(this.rotation);}return this.drawBelowCallback&&this.drawBelowCallback(this),this.renderContent(),this.drawAboveCallback&&this.drawAboveCallback(this),t.restore(),this}},B=Phaser.Math.RotateAround,j=Phaser.Geom.Rectangle,D=function(t){void 0===A&&(A=new j);var e=t.drawTLX,i=t.drawTLY;return A.setTo(e,i,t.drawTRX-e,t.drawBLY-i),A},F=Phaser.Math.RotateAround,H=function(t,e,i,n){return void 0===n?n={}:!0===n&&(void 0===L&&(L={}),n=L),n.x=e,n.y=i,0!==t.rotation&&F(n,0,0,t.rotation),n.x=n.x*t.scaleX+t.drawX,n.y=n.y*t.scaleY+t.drawY,n},M=Phaser.GameObjects.Components.TransformMatrix,z={},I=function(t,e,i,n,r){var s=H(e,i,n,!0),o=function(t,e,i,n){void 0===n?n={}:!0===n&&(n=z);var r=e-t.width*t.originX,s=i-t.height*t.originY;return void 0===R&&(R=new M,X=new M),t.parentContainer?t.getWorldTransformMatrix(R,X):R.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),R.transformPoint(r,s,n),n}(t,s.x,s.y,r);return o},G=function(t,e,i,n,r){"number"!=typeof i&&(r=i,i=0,n=0);var s=e.drawCenterX+i,o=e.drawCenterY+n;return I(t,e,s,o,r)},U={contains:function(t,e){if(0===this.width||0===this.height)return !1;var i=function(t,e,i,n){return void 0===n?n={}:!0===n&&(void 0===Y&&(Y={}),n=Y),n.x=(t-i.drawX)/i.scaleX,n.y=(e-i.drawY)/i.scaleY,0!==i.rotation&&B(n,0,0,-i.rotation),n}(t,e,this,!0);return D(this).contains(i.x,i.y)},getWorldPosition:function(t,e,i){return G(this.parent,this,t,e,i)}};Object.assign(U,W);var V=Phaser.Math.DegToRad,N=Phaser.Math.RadToDeg,q=Phaser.Utils.Objects.GetValue,J=function(t){r(s,t);var i=a(s);function s(t,n){var r;return e(this,s),(r=i.call(this,t,n)).renderable=!0,r.scrollFactorX=1,r.scrollFactorY=1,r.toLocalPosition=!0,r.originX=0,r.offsetX=0,r.offsetY=0,r}return n(s,[{key:"visible",get:function(){return this._visible},set:function(t){this.setDirty(this._visible!=t),this._visible=t;}},{key:"setVisible",value:function(t){return void 0===t&&(t=!0),this.visible=t,this}},{key:"alpha",get:function(){return this._alpha},set:function(t){this.setDirty(this._alpha!=t),this._alpha=t;}},{key:"setAlpha",value:function(t){return this.alpha=t,this}},{key:"x",get:function(){return this._x},set:function(t){this.setDirty(this._x!=t),this._x=t;}},{key:"setX",value:function(t){return this.x=t,this}},{key:"y",get:function(){return this._y},set:function(t){this.setDirty(this._y!=t),this._y=t;}},{key:"setY",value:function(t){return this.y=t,this}},{key:"setPosition",value:function(t,e){return this.x=t,this.y=e,this}},{key:"setInitialPosition",value:function(t,e){return this.x0=t,this.y0=e,this}},{key:"setScrollFactorX",value:function(t){return this.scrollFactorX=t,this}},{key:"setScrollFactorY",value:function(t){return this.scrollFactorY=t,this}},{key:"setScrollFactor",value:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}},{key:"rotation",get:function(){return this._rotation},set:function(t){this.setDirty(this._rotation!=t),this._rotation=t;}},{key:"setRotation",value:function(t){return this.rotation=t,this}},{key:"angle",get:function(){return N(this._rotation)},set:function(t){this.rotation=V(t);}},{key:"setAngle",value:function(t){return this.angle=t,this}},{key:"scaleX",get:function(){return this._scaleX},set:function(t){this.setDirty(this._scaleX!==t),this._scaleX=t;}},{key:"setScaleX",value:function(t){return this.scaleX=t,this}},{key:"width",get:function(){return 0},set:function(t){}},{key:"setWidth",value:function(t,e){return void 0===e&&(e=!1),this.width=t,e&&(this.scaleY=this.scaleX),this}},{key:"leftSpace",get:function(){return this._leftSpace},set:function(t){this.setDirty(this._leftSpace!==t),this._leftSpace=t;}},{key:"setLeftSpace",value:function(t){return this.leftSpace=t,this}},{key:"rightSpace",get:function(){return this._rightSpace},set:function(t){this.setDirty(this._rightSpace!==t),this._rightSpace=t;}},{key:"setRightSpace",value:function(t){return this.rightSpace=t,this}},{key:"outerWidth",get:function(){return this.width+this.leftSpace+this.rightSpace}},{key:"scaleY",get:function(){return this._scaleY},set:function(t){this.setDirty(this._scaleY!==t),this._scaleY=t;}},{key:"setScaleY",value:function(t){return this.scaleY=t,this}},{key:"height",get:function(){return 0},set:function(t){}},{key:"setHeight",value:function(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}},{key:"setScale",value:function(t,e){return void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this}},{key:"setOrigin",value:function(t){return this.originX=t,this}},{key:"setAlign",value:function(t){return this.align=t,this}},{key:"modifyPorperties",value:function(t){if(!t)return this;t.hasOwnProperty("x")&&this.setX(t.x),t.hasOwnProperty("y")&&this.setY(t.y),t.hasOwnProperty("rotation")?this.setRotation(t.rotation):t.hasOwnProperty("angle")&&this.setAngle(t.angle),t.hasOwnProperty("alpha")&&this.setAlpha(t.alpha);var e=q(t,"width",void 0),i=q(t,"height",void 0),n=q(t,"scaleX",void 0),r=q(t,"scaleY",void 0);return void 0!==e?void 0===i&&void 0===r?this.setWidth(e,!0):this.setWidth(e):void 0!==n&&this.setScaleX(n),void 0!==i?void 0===e&&void 0===n?this.setHeight(i,!0):this.setHeight(i):void 0!==r&&this.setScaleY(r),t.hasOwnProperty("leftSpace")&&this.setLeftSpace(t.leftSpace),t.hasOwnProperty("rightSpace")&&this.setRightSpace(t.rightSpace),t.hasOwnProperty("align")&&this.setAlign(t.align),this}},{key:"setDrawBelowCallback",value:function(t){return this.drawBelowCallback=t,this}},{key:"setDrawAboveCallback",value:function(t){return this.drawAboveCallback=t,this}},{key:"reset",value:function(){return this.setVisible().setAlpha(1).setPosition(0,0).setRotation(0).setScale(1,1).setLeftSpace(0).setRightSpace(0).setOrigin(0).setAlign().setDrawBelowCallback().setDrawAboveCallback(),this}},{key:"willRender",get:function(){return this.visible&&this.alpha>0}},{key:"drawX",get:function(){var t=this.x+this.leftSpace+this.offsetX-this.originX*this.width;return this.parent._textOX*this.scrollFactorX+t}},{key:"drawY",get:function(){var t=this.y+this.offsetY;return this.parent._textOY*this.scrollFactorY+t}},{key:"drawTLX",get:function(){return 0}},{key:"drawTLY",get:function(){return 0}},{key:"drawBLX",get:function(){return 0}},{key:"drawBLY",get:function(){return 0}},{key:"drawTRX",get:function(){return 0}},{key:"drawTRY",get:function(){return 0}},{key:"drawBRX",get:function(){return 0}},{key:"drawBRY",get:function(){return 0}},{key:"drawCenterX",get:function(){return (this.drawTRX+this.drawTLX)/2}},{key:"drawCenterY",get:function(){return (this.drawBLY+this.drawTLY)/2}}]),s}(E);Object.assign(J.prototype,U);var $=Phaser.Utils.String.Pad,Z=function(e,i,n){if(null==e)return e;switch(t(e)){case"string":default:return e;case"number":return "#".concat($(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}},K=function(t,e,i){return e.hasOwnProperty(t)?e[t]:i[t]},Q=Phaser.Utils.Objects.GetValue,tt=function(){function t(i,n,r,s,o){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===o&&(o=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(i,n,r,s,o);}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=Q(t,"x",0),i=Q(t,"y",0));var n=this.cornerRadius;n.tl=et(Q(t,"tl",void 0),e,i),n.tr=et(Q(t,"tr",void 0),e,i),n.bl=et(Q(t,"bl",void 0),e,i),n.br=et(Q(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){it(this.cornerRadius.tl,t);}},{key:"radiusTR",get:function(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.tr,t);}},{key:"radiusBL",get:function(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.bl,t);}},{key:"radiusBR",get:function(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)},set:function(t){it(this.cornerRadius.br,t);}}]),t}(),et=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),nt(t),t},it=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=Q(e,"x",0),t.y=Q(e,"y",0)),nt(t);},nt=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y);},rt=Phaser.Math.DegToRad,st=function(t){return !t.hasOwnProperty("convex")||t.convex},ot=function(t){return t.x>0&&t.y>0},ht=function(t,e,i,n,r,s,o,h,a){if(h&&o>s?o-=360:!h&&o<s&&(o+=360),s=rt(s),o=rt(o),null==a)t.ellipse(e,i,n,r,0,s,o,h);else for(var u,l,c,d=(o-s)/(a+=1),f=0;f<=a;f++)c=s+d*f,u=e+n*Math.cos(c),l=i+r*Math.sin(c),t.lineTo(u,l);},at=function(t,e,i,n,r,s,o,h,a,u,l,c,d){if(function(t,e,i,n,r,s,o){var h,a,u,l,c,d=new tt(e,i,n,r,s),f=d.minWidth,v=d.minHeight,p=n>=f?1:n/f,y=r>=v?1:r/v,g=d.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),h=g.tl,ot(h)?(a=h.x*p,u=h.y*y,st(h)?ht(t,a,u,a,u,180,270,!1,o):ht(t,0,0,a,u,90,0,!0,o),l=0,c=u):(t.lineTo(0,0),l=0,c=0),h=g.tr,ot(h)?(a=h.x*p,u=h.y*y,st(h)?ht(t,n-a,u,a,u,270,360,!1,o):ht(t,n,0,a,u,180,90,!0,o)):t.lineTo(n,0),h=g.br,ot(h)?(a=h.x*p,u=h.y*y,st(h)?ht(t,n-a,r-u,a,u,0,90,!1,o):ht(t,n,r,a,u,270,180,!0,o)):t.lineTo(n,r),h=g.bl,ot(h)?(a=h.x*p,u=h.y*y,st(h)?ht(t,a,r-u,a,u,90,180,!1,o):ht(t,0,r,a,u,360,270,!0,o)):t.lineTo(0,r),t.lineTo(l,c),t.closePath(),t.restore();}(e,i,n,r,s,o,d),null!=h){var f;if(null!=l)(f=c?e.createLinearGradient(0,0,r,0):e.createLinearGradient(0,0,0,s)).addColorStop(0,h),f.addColorStop(1,l),h=f;e.fillStyle=h,e.fill();}null!=a&&u>0&&(e.strokeStyle=a,e.lineWidth=u,e.stroke());},ut=Phaser.Utils.Objects.GetValue,lt=function(t){r(o,t);var i=a(o);function o(t,n){var r;return e(this,o),(r=i.call(this,t,"background")).setScrollFactor(0),r.setColor(ut(n,"color",null),ut(n,"color2",null),ut(n,"horizontalGradient",!0)),r.setStroke(ut(n,"stroke",null),ut(n,"strokeThickness",2)),r.setCornerRadius(ut(n,"cornerRadius",0),ut(n,"cornerIteration",null)),r}return n(o,[{key:"color",get:function(){return this._color},set:function(t){t=Z(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t;}},{key:"color2",get:function(){return this._color2},set:function(t){t=Z(t,this.canvas,this.context),this.setDirty(this._color2!=t),this._color2=t;}},{key:"horizontalGradient",get:function(){return this._horizontalGradient},set:function(t){this.setDirty(this._horizontalGradient!=t),this._horizontalGradient=t;}},{key:"setColor",value:function(t,e,i){return void 0===i&&(i=!0),this.color=t,this.color2=e,this.horizontalGradient=i,this}},{key:"stroke",get:function(){return this._stroke},set:function(t){t=Z(t,this.canvas,this.context),this.setDirty(this._stroke!=t),this._stroke=t;}},{key:"strokeThickness",get:function(){return this._strokeThickness},set:function(t){this.setDirty(this._strokeThickness!=t),this._strokeThickness=t;}},{key:"setStroke",value:function(t,e){return null!=t&&void 0===e&&(e=2),this.stroke=t,this.strokeThickness=e,this}},{key:"cornerRadius",get:function(){return this._cornerRadius},set:function(t){this.setDirty(this._cornerRadius!=t),this._cornerRadius=t;}},{key:"cornerIteration",get:function(){return this._cornerIteration},set:function(t){this.setDirty(this._cornerIteration!=t),this._cornerIteration=t;}},{key:"modifyStyle",value:function(t){return t.hasOwnProperty("color")&&this.setColor(t.color,K("color2",t,this),K("horizontalGradient",t,this)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,K("strokeThickness",t,this)),t.hasOwnProperty("cornerRadius")&&this.setCornerRadius(t.cornerRadius,K("cornerIteration",t,this)),this}},{key:"modifyPorperties",value:function(t){return l(s(o.prototype),"modifyPorperties",this).call(this,t),this.modifyStyle(t),this}},{key:"setCornerRadius",value:function(t,e){return this.cornerRadius=t,this.cornerIteration=e,this}},{key:"renderContent",value:function(){!function(t,e,i,n,r,s,o,h){if(null!=e||null!=i){var a=t.canvas.width,u=t.canvas.height;null==i&&(n=0);var l=n/2;a=Math.max(1,a-n),u=Math.max(1,u-n),at(t.canvas,t.context,l,l,a,u,r,e,i,n,s,o,h);}}(this.parent,this.color,this.stroke,this.strokeThickness,this.cornerRadius,this.color2,this.horizontalGradient,this.cornerIteration);}}]),o}(J),ct=Phaser.Utils.Objects.GetValue,dt=function(t){r(o,t);var i=a(o);function o(t,n){var r;return e(this,o),(r=i.call(this,t,"innerbounds")).setScrollFactor(0),r.setColor(ct(n,"color",null),ct(n,"color2",null),ct(n,"horizontalGradient",!0)),r.setStroke(ct(n,"stroke",null),ct(n,"strokeThickness",2)),r}return n(o,[{key:"color",get:function(){return this._color},set:function(t){t=Z(t,this.canvas,this.context),this.setDirty(this._color!=t),this._color=t;}},{key:"color2",get:function(){return this._color2},set:function(t){t=Z(t,this.canvas,this.context),this.setDirty(this._color2!=t),this._color2=t;}},{key:"horizontalGradient",get:function(){return this._horizontalGradient},set:function(t){this.setDirty(this._horizontalGradient!=t),this._horizontalGradient=t;}},{key:"setColor",value:function(t,e,i){return void 0===i&&(i=!0),this.color=t,this.color2=e,this.horizontalGradient=i,this}},{key:"stroke",get:function(){return this._stroke},set:function(t){t=Z(t,this.canvas,this.context),this.setDirty(this._stroke!=t),this._stroke=t;}},{key:"strokeThickness",get:function(){return this._strokeThickness},set:function(t){this.setDirty(this._strokeThickness!=t),this._strokeThickness=t;}},{key:"setStroke",value:function(t,e){return null!=t&&void 0===e&&(e=2),this.stroke=t,this.strokeThickness=e,this}},{key:"modifyPorperties",value:function(t){l(s(o.prototype),"modifyPorperties",this).call(this,t),t.hasOwnProperty("color")&&this.setColor(t.color,ct(t,"color2",null),ct(t,"horizontalGradient",!0)),t.hasOwnProperty("stroke")&&this.setStroke(t.stroke,ct(t,"strokeThickness",2));}},{key:"renderContent",value:function(){var t=this.parent.padding,e=t.left,i=t.top,n=this.parent.width-t.left-t.right,r=this.parent.height-t.top-t.bottom,s=this.context;if(null!=this.color){var o,h;if(null!=this.color2)(h=this.horizontalGradient?s.createLinearGradient(0,0,n,0):s.createLinearGradient(0,0,0,r)).addColorStop(0,this.color),h.addColorStop(1,this.color2),o=h;else o=this.color;s.fillStyle=o,s.fillRect(e,i,n,r);}null!=this.stroke&&this.strokeThickness>0&&(s.strokeStyle=this.stroke,s.lineWidth=this.strokeThickness,s.strokeRect(e,i,n,r));}}]),o}(J),ft=Phaser.Utils.Objects.GetValue,vt=function(){function t(i,n){e(this,t),this.parent=i,this.set(n);}return n(t,[{key:"toJSON",value:function(){return {bold:this.bold,italic:this.italic,fontSize:this.fontSize,fontFamily:this.fontFamily,color:this.color,stroke:this.stroke,strokeThickness:this.strokeThickness,shaodwColor:this.shadowColor,shadowBlur:this.shadowBlur,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,offsetX:this.offsetX,offsetY:this.offsetY,leftSpace:this.leftSpace,rightSpace:this.rightSpace,backgroundHeight:this.backgroundHeight,backgroundBottomY:this.backgroundBottomY,align:this.align}}},{key:"set",value:function(t){return this.setBold(ft(t,"bold",!1)),this.setItalic(ft(t,"italic",!1)),this.setFontSize(ft(t,"fontSize","16px")),this.setFontFamily(ft(t,"fontFamily","Courier")),this.setColor(ft(t,"color","#fff")),this.setStrokeStyle(ft(t,"stroke",null),ft(t,"strokeThickness",0)),this.setShadow(ft(t,"shadowColor",null),ft(t,"shadowOffsetX",0),ft(t,"shadowOffsetY",0),ft(t,"shadowBlur",0)),this.setOffset(ft(t,"offsetX",0),ft(t,"offsetY",0)),this.setSpace(ft(t,"leftSpace",0),ft(t,"rightSpace",0)),this.setAlign(ft(t,"align",void 0)),this.setBackgroundColor(ft(t,"backgroundColor",null)),this.setBackgroundHeight(ft(t,"backgroundHeight",void 0)),this.setBackgroundBottomY(ft(t,"backgroundBottomY",void 0)),this}},{key:"modify",value:function(t){return t.hasOwnProperty("bold")&&this.setBold(t.bold),t.hasOwnProperty("italic")&&this.setItalic(t.italic),t.hasOwnProperty("fontSize")&&this.setFontSize(t.fontSize),t.hasOwnProperty("fontFamily")&&this.setFontFamily(t.fontFamily),t.hasOwnProperty("color")&&this.setColor(t.color),(t.hasOwnProperty("stroke")||t.hasOwnProperty("strokeThickness"))&&this.setStrokeStyle(K("stroke",t,this),K("strokeThickness",t,this)),t.hasOwnProperty("shadowColor")&&this.setShadowColor(t.shadowColor),(t.hasOwnProperty("shadowOffsetX")||t.hasOwnProperty("shadowOffsetY"))&&this.setShadowOffset(K("shadowOffsetX",t,this),K("shadowOffsetY",t,this)),t.hasOwnProperty("shadowBlur")&&this.setShadowBlur(t.shaodwBlur),t.hasOwnProperty("offsetX")&&this.setOffsetX(t.offsetX),t.hasOwnProperty("offsetY")&&this.setOffsetY(t.offsetY),t.hasOwnProperty("leftSpace")&&this.setLeftSpace(t.leftSpace),t.hasOwnProperty("rightSpace")&&this.setRightSpace(t.rightSpace),t.hasOwnProperty("align")&&this.setAlign(t.align),t.hasOwnProperty("backgroundColor")&&this.setBackgroundColor(t.backgroundColor),t.hasOwnProperty("backgroundHeight")&&this.setBackgroundHeight(t.backgroundHeight),t.hasOwnProperty("backgroundBottomY")&&this.setBackgroundBottomY(t.backgroundBottomY),this}},{key:"setUpdateTextFlag",value:function(){return this.parent&&(this.parent.updateTextFlag=!0),this}},{key:"clone",value:function(){return new t(null,this.toJSON())}},{key:"copyFrom",value:function(t){return this.set(t.toJSON()),this}},{key:"copyTo",value:function(t){return t.set(this.toJSON()),this}},{key:"setBold",value:function(t){return void 0===t&&(t=!0),this.bold=t,this.setUpdateTextFlag(),this}},{key:"setItalic",value:function(t){return void 0===t&&(t=!0),this.italic=t,this.setUpdateTextFlag(),this}},{key:"fontStyle",get:function(){return this.bold&&this.italic?"bold italic":this.bold?"bold":this.italic?"italic":""}},{key:"setFontSize",value:function(t){return "number"==typeof t&&(t="".concat(t,"px")),this.fontSize=t,this.setUpdateTextFlag(),this}},{key:"setFontFamily",value:function(t){return this.fontFamily=t,this.setUpdateTextFlag(),this}},{key:"font",get:function(){return "".concat(this.fontStyle," ").concat(this.fontSize," ").concat(this.fontFamily)}},{key:"setColor",value:function(t){return this.color=Z(t),this}},{key:"hasFill",get:function(){return null!=this.color}},{key:"setStrokeStyle",value:function(t,e){return this.stroke=Z(t),void 0!==e&&(this.strokeThickness=e),this}},{key:"setStrokeThickness",value:function(t){return this.strokeThickness=t,this}},{key:"hasStroke",get:function(){return null!=this.stroke&&this.strokeThickness>0}},{key:"setShadowColor",value:function(t){return this.shadowColor=Z(t),this}},{key:"setShadowOffset",value:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.shadowOffsetX=t,this.shadowOffsetY=e,this}},{key:"setShadowBlur",value:function(t){return void 0===t&&(t=0),this.shaodwBlur=t,this}},{key:"setShadow",value:function(t,e,i,n){return this.setShadowColor(t).setShadowOffset(e,i).setShadowBlur(n),this}},{key:"setBackgroundColor",value:function(t){return this.backgroundColor=Z(t),this}},{key:"hasBackgroundColor",get:function(){return null!=this.backgroundColor}},{key:"setBackgroundHeight",value:function(t){return this.backgroundHeight=t,this}},{key:"setBackgroundBottomY",value:function(t){return this.backgroundBottomY=t,this}},{key:"setOffsetX",value:function(t){return void 0===t&&(t=0),this.offsetX=t,this}},{key:"setOffsetY",value:function(t){return void 0===t&&(t=0),this.offsetY=t,this}},{key:"setOffset",value:function(t,e){return this.setOffsetX(t).setOffsetY(e),this}},{key:"setLeftSpace",value:function(t){return void 0===t&&(t=0),this.leftSpace=t,this}},{key:"setRightSpace",value:function(t){return void 0===t&&(t=0),this.rightSpace=t,this}},{key:"setSpace",value:function(t,e){return this.setLeftSpace(t).setRightSpace(e),this}},{key:"setAlign",value:function(t){return this.align=t,this}},{key:"syncFont",value:function(t){return t.font=this.font,this}},{key:"syncStyle",value:function(t){t.textBaseline="alphabetic";var e=this.hasFill,i=this.hasStroke;return t.fillStyle=e?this.color:"#000",t.strokeStyle=i?this.stroke:"#000",t.lineWidth=i?this.strokeThickness:0,t.lineCap="round",t.lineJoin="round",this}},{key:"syncShadow",value:function(t){null!=t.shadowColor?(t.shadowColor=this.shadowColor,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowBlur=this.shadowBlur):(t.shadowColor=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0);}},{key:"getTextMetrics",value:function(t,e){return this.syncFont(t).syncStyle(t),t.measureText(e)}}]),t}(),pt=Phaser.Utils.Array.Remove,yt=Phaser.Utils.Array.Remove,gt="text",kt="image",xt="drawer",mt="space",wt="command",bt=function(t){return t.type===gt&&"\n"===t.text},Ct=function(t){return t.type===gt&&"\f"===t.text},St=function(t){return t.type===gt},Ot=function(t){r(o,t);var i=a(o);function o(t,n,r){var s;return e(this,o),(s=i.call(this,t,gt)).updateTextFlag=!1,s.style=new vt(h(s),r),s.setText(n),s}return n(o,[{key:"autoRound",get:function(){return this.parent.autoRound}},{key:"offsetX",get:function(){return this.style.offsetX},set:function(t){this.style&&(this.style.offsetX=t);}},{key:"offsetY",get:function(){return this.style.offsetY},set:function(t){this.style&&(this.style.offsetY=t);}},{key:"leftSpace",get:function(){return this.style.leftSpace*this.scaleX},set:function(t){this.style&&(this.style.leftSpace=t),d(s(o.prototype),"leftSpace",t,this,!0);}},{key:"rightSpace",get:function(){return this.style.rightSpace*this.scaleX},set:function(t){this.style&&(this.style.rightSpace=t),d(s(o.prototype),"rightSpace",t,this,!0);}},{key:"align",get:function(){return this.style.align},set:function(t){this.style&&(this.style.align=t);}},{key:"modifyStyle",value:function(t){return this.setDirty(!0),this.style.modify(t),this.updateTextFlag&&this.updateTextSize(),this}},{key:"modifyPorperties",value:function(t){return t?(this.modifyStyle(t),l(s(o.prototype),"modifyPorperties",this).call(this,t),this):this}},{key:"setText",value:function(t){return this.setDirty(this.text!=t),this.text=t,this.updateTextSize(),this}},{key:"updateTextSize",value:function(){var t=this.text;if("\n"===t||"\f"===t||""===t)this.clearTextSize();else {var e,i,n=this.style.getTextMetrics(this.context,this.text);this.textWidth=n.width,"actualBoundingBoxAscent"in n?(e=n.actualBoundingBoxAscent,i=n.actualBoundingBoxDescent):(e=0,i=0),this.textHeight=e+i,this.ascent=e,this.descent=i;}return this.updateTextFlag=!1,this}},{key:"clearTextSize",value:function(){return this.textWidth=0,this.textHeight=0,this.ascent=0,this.descent=0,this}},{key:"copyTextSize",value:function(t){return this.textWidth=t.textWidth,this.textHeight=t.textHeight,this.ascent=t.ascent,this.descent=t.descent,this}},{key:"width",get:function(){return this.textWidth*this.scaleX},set:function(t){this.textWidth>0?this.scaleX=t/this.textWidth:this.scaleX=1;}},{key:"height",get:function(){return this.textHeight*this.scaleY},set:function(t){this.textHeight>0?this.scaleY=t/this.textHeight:this.scaleY=1;}},{key:"willRender",get:function(){return 0!==this.textWidth&&l(s(o.prototype),"willRender",this)}},{key:"renderContent",value:function(){var t=this.context,e=this.style;if(e.hasBackgroundColor){t.fillStyle=e.backgroundColor;var i=this.drawTLX,n=this.drawTRX-i,r=e.backgroundBottomY;null==r&&(r=this.drawBLY);var s=e.backgroundHeight;null==s&&(s=r-this.drawTLY);var o=r-s;t.fillRect(i,o,n,s);}var h=e.hasFill,a=e.hasStroke;(h||a)&&(e.syncFont(t).syncStyle(t),a&&(e.syncShadow(t),t.strokeText(this.text,0,0)),h&&(e.syncShadow(t),t.fillText(this.text,0,0)));}},{key:"drawTLX",get:function(){return -this.leftSpace}},{key:"drawTLY",get:function(){return -this.ascent}},{key:"drawBLX",get:function(){return -this.leftSpace}},{key:"drawBLY",get:function(){return this.descent}},{key:"drawTRX",get:function(){return this.textWidth+this.rightSpace}},{key:"drawTRY",get:function(){return -this.ascent}},{key:"drawBRX",get:function(){return this.textWidth+this.rightSpace}},{key:"drawBRY",get:function(){return this.descent}}]),o}(J),Tt=function(t,e){var i=this.createCharChildren(t,e);return this.addChild(i),this},Pt=function(t){r(s,t);var i=a(s);function s(t,n,r){var o;return e(this,s),(o=i.call(this,t,kt)).setTexture(n,r),o}return n(s,[{key:"frameWidth",get:function(){return this.frameObj?this.frameObj.cutWidth:0}},{key:"frameHeight",get:function(){return this.frameObj?this.frameObj.cutHeight:0}},{key:"offsetY",get:function(){return -this.height},set:function(t){}},{key:"key",get:function(){return this._key},set:function(t){this.setDirty(this._key!=t),this._key=t;}},{key:"frame",get:function(){return this._frame},set:function(t){this.setDirty(this._frame!=t),this._frame=t;}},{key:"setTexture",value:function(t,e){return this.key=t,this.frame=e,this.frameObj=this.scene.sys.textures.getFrame(t,e),this}},{key:"width",get:function(){return this.frameWidth*this.scaleX},set:function(t){this.setDirty(this.width!==t),this.scaleX=t/this.frameWidth;}},{key:"height",get:function(){return this.frameHeight*this.scaleY},set:function(t){this.setDirty(this.height!==t),this.scaleY=t/this.frameHeight;}},{key:"setHeight",value:function(t,e){return void 0===e&&(e=!1),this.height=t,e&&(this.scaleX=this.scaleY),this}},{key:"renderContent",value:function(){var t=this.context,e=this.frameObj,i=this.frameWidth,n=this.frameHeight;t.drawImage(e.source.image,e.cutX,e.cutY,i,n,0,0,i,n);}},{key:"drawTLX",get:function(){return -this.leftSpace}},{key:"drawTLY",get:function(){return 0}},{key:"drawBLX",get:function(){return -this.leftSpace}},{key:"drawBLY",get:function(){return this.frameHeight}},{key:"drawTRX",get:function(){return this.frameWidth+this.rightSpace}},{key:"drawTRY",get:function(){return 0}},{key:"drawBRX",get:function(){return this.frameWidth+this.rightSpace}},{key:"drawBRY",get:function(){return this.frameHeight}}]),s}(J),_t=function(t){r(o,t);var i=a(o);function o(t,n,r,s){var h;return e(this,o),(h=i.call(this,t,xt)).setRenderCallback(n),h.setDrawerSize(r,s),h}return n(o,[{key:"setRenderCallback",value:function(t){return t?this.renderContent=t.bind(this):delete this.renderContent,this}},{key:"setDrawerSize",value:function(t,e){return !0===t?(this.toLocalPosition=!1,t=void 0,e=void 0):this.toLocalPosition=!0,void 0===t&&(t=0),void 0===e&&(e=t),this.drawerWidth=t,this.drawerHeight=e,this}},{key:"onFree",value:function(){l(s(o.prototype),"onFree",this).call(this),this.setRenderCallback();}},{key:"width",get:function(){return this.drawerWidth*this.scaleX},set:function(t){this.setDirty(this.width!==t),this.scaleX=this.drawerWidth>0?t/this.drawerWidth:1;}},{key:"height",get:function(){return this.drawerHeight*this.scaleY},set:function(t){this.setDirty(this.height!==t),this.scaleY=this.drawerHeight>0?t/this.drawerHeight:1;}},{key:"offsetY",get:function(){return -this.height},set:function(t){}},{key:"drawTLX",get:function(){return -this.leftSpace}},{key:"drawTLY",get:function(){return 0}},{key:"drawBLX",get:function(){return -this.leftSpace}},{key:"drawBLY",get:function(){return this.drawerHeight}},{key:"drawTRX",get:function(){return this.drawerWidth+this.rightSpace}},{key:"drawTRY",get:function(){return 0}},{key:"drawBRX",get:function(){return this.drawerWidth+this.rightSpace}},{key:"drawBRY",get:function(){return this.drawerHeight}}]),o}(J),Et=function(t){r(s,t);var i=a(s);function s(t,n){var r;return e(this,s),(r=i.call(this,t,mt)).setSpaceWidth(n),r}return n(s,[{key:"width",get:function(){return this.spaceWidth*this.scaleX},set:function(t){this.spaceWidth>0?this.scaleX=t/this.spaceWidth:this.scaleX=1;}},{key:"setSpaceWidth",value:function(t){return this.spaceWidth=t,this}}]),s}(J),Yt=function(t){r(o,t);var i=a(o);function o(t,n,r,s,h){var a;return e(this,o),(a=i.call(this,t,wt)).setName(n).setParameter(s).setCallback(r,h),a}return n(o,[{key:"setName",value:function(t){return this.name=t,this}},{key:"setParameter",value:function(t){return this.param=t,this}},{key:"setCallback",value:function(t,e){return this.callback=t,this.scope=e,this}},{key:"exec",value:function(){return this.scope?this.callback.call(this.scope,this.param,this.name):this.callback(this.param,this.name)}},{key:"onFree",value:function(){l(s(o.prototype),"onFree",this).call(this),this.setName().setCallback().setParameter();}}]),o}(E),At=function e(i){var n,r,s;if(null==i||"object"!==t(i))return i;if(n=Array.isArray(i)?[]:{},function(e){if("object"!==t(e)||e.nodeType||e===e.window)return !1;try{if(e.constructor&&!{}.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return !1}catch(t){return !1}return !0}(i))for(s in i)r=i[s],n[s]=e(r);else n=i;return n},Lt=function(t){var e={callback:void 0,start:0,isLastPage:!1,maxLines:void 0,padding:void 0,letterSpacing:void 0,hAlign:void 0,vAlign:void 0,children:[],lines:[],maxLineWidth:0,linesHeight:0,lineHeight:void 0,maxLineHeight:0,linesWidth:0,lineWidth:void 0};return Object.assign(e,t)},Rt=function(t,e,i,n){void 0===n&&(n={word:[],width:0}),n.word.length=0;for(var r=t.length,s=e,o=n.word,h=0;s<r;){var a=t[s];if(a.renderable){var u=a.type===gt?a.text:null;if(null===u||" "===u||"\n"===u||"\f"===u){s===e&&(o.push(a),h+=a.outerWidth);break}if(o.push(a),h+=a.outerWidth,s++,i)break}else o.push(a),s++;}return n.width=h,n},Xt=function(t){for(var e=0,i=t.length;e<i;e++){var n=t[e];if(void 0!==n.align)return n.align}},Wt=function(t,e,i){if(0!==e||0!==i)for(var n=0,r=t.length;n<r;n++){var s=t[n];s.renderable&&(s.x+=e,s.y+=i);}},Bt=function(){var t,e,i=this.defaultTextStyle.getTextMetrics(this.context,this.testString);return "actualBoundingBoxAscent"in i?(t=i.actualBoundingBoxAscent,e=i.actualBoundingBoxDescent):(t=0,e=0),jt.ascent=t,jt.descent=e,jt.height=t+e,jt},jt={},Dt=Phaser.Utils.Objects.GetValue,Ft=function(t){var e=Dt(t,"start",0);P(this.wrapPadding,Dt(t,"padding",0));var i,n=this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom,r=this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,s=Dt(t,"lineHeight"),o=Dt(t,"ascent",s);if(void 0===s){var h=Dt(t,"useDefaultTextHeight",!1);if(i=Dt(t,"maxLines",0),this.fixedHeight>0&&!h){var a=this.fixedHeight-n;if(i>0)s=a/i;else s=(u=Bt.call(this)).height,o=u.ascent,i=Math.floor((a-o)/s);}else {var u;s=(u=Bt.call(this)).height,o=u.ascent;}}else if(this.fixedHeight>0){if(void 0===(i=Dt(t,"maxLines"))){a=this.fixedHeight-n;i=Math.floor(a/s);}}else i=Dt(t,"maxLines",0);void 0===o&&(o=s);var l=0===i,c=Dt(t,"wrapWidth",void 0);void 0===c&&(c=this.fixedWidth>0?this.fixedWidth-r:1/0);for(var d=Dt(t,"letterSpacing",0),f=Dt(t,"hAlign",0),v=Dt(t,"vAlign",0),p=Dt(t,"charWrap",!1),y=Lt({callback:"runWordWrap",start:e,padding:this.wrapPadding,letterSpacing:d,maxLines:i,hAlign:f,vAlign:v,ascent:o,lineHeight:s,wrapWidth:c,charWrap:p}),g=this.children,k=0,x=g.length;k<x;k++)g[k].setActive(!1);c+=d;for(var m,w=this.padding.left+this.wrapPadding.left,b=w,C=this.padding.top+this.wrapPadding.top+o,S=c,O=e,T=g.length,_=y.children,E=y.lines,Y=[],A=0,L=0,R=!1;O<T;){var X=(m=Rt(g,O,p,m)).word,W=X.length,B=m.width+W*d;O+=W;var j=bt(X[0]);R=Ct(X[0]);var D=j||R;if(S<B||D){if(D){var F=X[0];F.setActive().setPosition(b,C),_.push(F),Y.push(F);}if(b=w,C+=s,S=c,E.push({children:Y,width:A}),L=Math.max(L,A),A=0,Y=[],R||!l&&E.length===i)break;if(D)continue}S-=B,A+=B;for(k=0,x=X.length;k<x;k++){(z=X[k]).setActive(),_.push(z),Y.push(z),z.renderable&&(z.setPosition(b,C),b+=z.outerWidth+d);}}Y.length>0&&(E.push({children:Y,width:A}),L=Math.max(L,A)),y.start+=_.length,y.isLastPage=!R&&y.start===T,y.maxLineWidth=L,y.linesHeight=E.length*s;var H=this.fixedWidth>0?this.fixedWidth:y.maxLineWidth+r,M=this.fixedHeight>0?this.fixedHeight:y.linesHeight+n;!function(t,e,i){var n,r,s=t.hAlign,o=t.vAlign,h=t.linesHeight;switch(o){case 1:case"center":r=(i-h)/2;break;case 2:case"bottom":r=i-h;break;default:r=0;}for(var a=t.lines,u=0,l=a.length;u<l;u++){var c=a[u],d=c.width,f=c.children,v=Xt(f);switch(void 0===v&&(v=s),v){case 1:case"center":n=(e-d)/2;break;case 2:case"right":n=e-d;break;default:n=0;}Wt(f,n,r);}}(y,H-r,a=M-n),this.setCanvasSize(H,M);for(k=0,x=_.length;k<x;k++){var z;(z=_[k]).renderable&&(z.x0=z.x,z.y0=z.y);}return y},Ht=Phaser.Utils.Objects.Merge,Mt=Phaser.Utils.Objects.GetValue,zt=function(t){var e=Mt(t,"start",0);P(this.wrapPadding,Mt(t,"padding",0));var i,n=this.padding.top+this.padding.bottom+this.wrapPadding.top+this.wrapPadding.bottom,r=this.padding.left+this.padding.right+this.wrapPadding.left+this.wrapPadding.right,s=Mt(t,"lineWidth",void 0);if(void 0===s)i=Mt(t,"maxLines",0),s=this.fixedWidth>0?(o=this.fixedWidth-r)/i:0;else if(this.fixedWidth>0){if(void 0===(i=Mt(t,"maxLines",void 0))){var o=this.fixedWidth-r;i=Math.floor(o/s)+1;}}else i=Mt(t,"maxLines",0);var h=0===i,a=Mt(t,"fixedCharacterHeight",void 0);if(void 0===a){var u=Mt(t,"charPerLine",void 0);if(void 0!==u){var l=this.fixedHeight-n;a=Math.floor(l/u);}}var c=Mt(t,"wrapHeight",void 0);void 0===c&&(c=this.fixedHeight>0?this.fixedHeight-n:1/0);for(var d=Mt(t,"letterSpacing",0),f=Mt(t,"rtl",!0),v=Mt(t,"hAlign",f?2:0),p=Mt(t,"vAlign",0),y=Lt({callback:"runVerticalWrap",start:e,padding:this.wrapPadding,letterSpacing:d,maxLines:i,hAlign:v,vAlign:p,lineWidth:s,fixedCharacterHeight:a,wrapHeight:c,rtl:f}),g=this.children,k=0,x=g.length;k<x;k++)g[k].setActive(!1);c+=d;for(var m=this.padding.left+this.wrapPadding.left,w=this.padding.top+this.wrapPadding.top,b=m,C=w,S=c,O=e,T=g.length,_=y.children,E=y.lines,Y=[],A=0,L=0;O<T;){var R=g[O];if(O++,R.renderable){var X=(void 0!==a?a:R.height)+d,W=bt(R),B=Ct(R),j=W||B;if(S<X||j){if(W&&(R.setActive().setPosition(b,C).setOrigin(.5),_.push(R),Y.push(R)),b=m,C=w,S=c,E.push({children:Y,height:A}),L=Math.max(L,A),A=0,Y=[],B||!h&&E.length===i)break;if(j)continue}S-=X,A+=X,R.setActive().setPosition(b,C).setOrigin(.5),_.push(R),Y.push(R),C+=X;}else R.setActive(),_.push(R),Y.push(R);}Y.length>0&&(E.push({children:Y,height:A}),L=Math.max(L,A)),y.start+=_.length,y.isLastPage=y.start===T,y.maxLineHeight=L,y.linesWidth=E.length*s;var D=this.fixedWidth>0?this.fixedWidth:y.linesWidth+r,F=this.fixedHeight>0?this.fixedHeight:y.maxLineHeight+n;!function(t,e,i){var n,r,s=t.hAlign,o=t.vAlign,h=t.rtl,a=t.lines,u=t.lineWidth,l=t.linesWidth;switch(s){case 1:case"center":n=(e-l)/2;break;case 2:case"right":n=e-l;break;default:n=0;}h&&(n+=u);for(var c=0,d=a.length;c<d;c++){var f=a[h?d-c-1:c],v=f.children,p=f.height,y=Xt(v);switch(void 0===y&&(y=o),y){case 1:case"center":r=(i-p)/2;break;case 2:case"bottom":r=i-p;break;default:r=0;}Wt(v,n,r),n+=u;}}(y,o=D-r,l=F-n),this.setCanvasSize(D,F);for(k=0,x=_.length;k<x;k++){(R=_[k]).renderable&&(R.x0=R.x,R.y0=R.y);}return y},It=Phaser.Utils.Objects.Merge,Gt=Phaser.Utils.Objects.GetValue,Ut=Phaser.Utils.Array.GetAll,Vt=Phaser.Math.Distance.BetweenPointsSquared,Nt=function(t,e,i){for(var n=0,r=(t=t).length;n<r;n++){var s=t[n];if(s.active&&s.renderable&&s.contains(e,i))return s}return null},qt=function(){return this.on("pointerdown",Jt,this).on("pointerdown",$t,this).on("pointermove",Zt,this).on("pointerover",Zt,this).on("pointerout",(function(t,e){Zt.call(this,t,null,null,e);}),this),this},Jt=function(t,e,i,n){if(this.childrenInteractiveEnable){var r=Nt(this.children,e,i);r&&this.emit("child.pointerdown",r,t,e,i,n);}},$t=function(t,e,i,n){if(this.childrenInteractiveEnable){var r=Nt(this.children,e,i);r&&this.emit("child.pointerup",r,t,e,i,n);}},Zt=function(t,e,i,n){if(this.childrenInteractiveEnable)if(null!==e){var r=Nt(this.children,e,i);r!==this.lastOverChild&&(null!==this.lastOverChild&&this.emit("child.pointerout",this.lastOverChild,t,e,i,n),null!==r&&this.emit("child.pointerover",r,t,e,i,n),this.lastOverChild=r);}else null!==this.lastOverChild&&(this.emit("child.pointerout",this.lastOverChild,t,e,i,n),this.lastOverChild=null);},Kt=Phaser.GameObjects.GameObject,Qt=Phaser.Utils.Array.BringToTop,te=Phaser.Utils.Array.SendToBack,ee=Phaser.Utils.Array.MoveUp,ie=Phaser.Utils.Array.MoveDown,ne=Phaser.Utils.Array.MoveAbove,re=Phaser.Utils.Array.MoveBelow,se={moveChildToFist:function(t){return te(this.children,t),this},moveChildToLast:function(t){return Qt(this.children,t),this},movechildUp:function(t){return ee(this.children,t),this},movechildDown:function(t){return ie(this.children,t),this},movechildAbove:function(t,e){return ne(this.children,t,e),this},movechildBelow:function(t,e){return re(this.children,t,e),this}},oe={setFixedSize:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fixedWidth===t&&this.fixedHeight===e||(this.fixedWidth=t,this.fixedHeight=e,this.dirty=!0,this.setCanvasSize(t>0?t:this.width,e>0?e:this.height)),this},setPadding:function(t,e){var i=this.padding,n=i.left,r=i.right,s=i.top,o=i.bottom;return P(i,t,e),this.dirty=th