angry-pixel 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/lib/component/Animator.d.ts +8 -4
  2. package/lib/component/AudioPlayer.d.ts +6 -4
  3. package/lib/component/Button.d.ts +42 -0
  4. package/lib/component/Camera.d.ts +1 -2
  5. package/lib/component/RigidBody.d.ts +5 -4
  6. package/lib/component/Transform.d.ts +4 -4
  7. package/lib/component/collider/BallCollider.d.ts +3 -2
  8. package/lib/component/collider/BoxCollider.d.ts +3 -2
  9. package/lib/component/collider/Collider.d.ts +6 -1
  10. package/lib/component/collider/EdgeCollider.d.ts +7 -4
  11. package/lib/component/collider/PolygonCollider.d.ts +7 -4
  12. package/lib/component/collider/TilemapCollider.d.ts +3 -2
  13. package/lib/component/rendering/MaskRenderer.d.ts +3 -2
  14. package/lib/component/rendering/SpriteRenderer.d.ts +6 -5
  15. package/lib/component/rendering/TextRenderer.d.ts +3 -2
  16. package/lib/component/rendering/tilemap/CsvTilemapRenderer.d.ts +6 -6
  17. package/lib/component/rendering/tilemap/TileData.d.ts +9 -6
  18. package/lib/component/rendering/tilemap/TiledTilemapRenderer.d.ts +10 -5
  19. package/lib/component/rendering/tilemap/TilemapRenderer.d.ts +9 -7
  20. package/lib/core/Component.d.ts +41 -86
  21. package/lib/core/Game.d.ts +14 -15
  22. package/lib/core/GameActor.d.ts +95 -0
  23. package/lib/core/GameObject.d.ts +69 -88
  24. package/lib/core/Scene.d.ts +6 -65
  25. package/lib/core/facades/GameObjectManagerFacade.d.ts +41 -25
  26. package/lib/core/facades/TimeManagerFacade.d.ts +1 -0
  27. package/lib/core/managers/AssetManager.d.ts +5 -2
  28. package/lib/core/managers/GameObjectManager.d.ts +11 -10
  29. package/lib/core/managers/HeadlessIterationManager.d.ts +29 -0
  30. package/lib/core/managers/IterationManager copy.d.ts +42 -0
  31. package/lib/core/managers/IterationManager.d.ts +19 -7
  32. package/lib/core/managers/IterationManagerOld.d.ts +42 -0
  33. package/lib/core/managers/SceneManager.d.ts +5 -4
  34. package/lib/core/managers/TimeManager.d.ts +10 -6
  35. package/lib/core/managers/headless/HeadlessIterationManager.d.ts +29 -0
  36. package/lib/core/managers/headless/HeadlessRenderManager.d.ts +10 -0
  37. package/lib/core/managers/iteration/BrowserIterationManager.d.ts +35 -0
  38. package/lib/core/managers/iteration/FrameEvent.d.ts +13 -0
  39. package/lib/core/managers/iteration/HeadlessIterationManager.d.ts +29 -0
  40. package/lib/core/managers/iteration/IIterationManager.d.ts +7 -0
  41. package/lib/gameObject/GameCamera.d.ts +2 -2
  42. package/lib/index.cjs.js +1 -1
  43. package/lib/index.d.ts +3 -1
  44. package/lib/index.esm.js +1 -1
  45. package/lib/index.js +1 -1
  46. package/lib/input/GamepadController.d.ts +16 -4
  47. package/lib/math/Rectangle.d.ts +9 -2
  48. package/lib/math/Utils.d.ts +8 -2
  49. package/lib/physics/collision/CollisionManager.d.ts +7 -3
  50. package/lib/physics/collision/resolver/AABBResolver.d.ts +2 -2
  51. package/lib/physics/collision/resolver/SatResolver.d.ts +1 -2
  52. package/lib/physics/rigodBody/RigidBodyData.d.ts +2 -1
  53. package/lib/physics/rigodBody/RigidBodyManager.d.ts +4 -1
  54. package/lib/rendering/RenderManager.d.ts +8 -1
  55. package/lib/rendering/renderData/TextRenderData.d.ts +1 -1
  56. package/package.json +1 -1
package/lib/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._x=t,this._y=e}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"magnitude",{get:function(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){this._x=t,this._y=e},t.prototype.copy=function(t){this.set(t.x,t.y)},t.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},t.prototype.clone=function(){return new t(this._x,this._y)},t.prototype.distance=function(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))},t.add=function(t,e,i){return t.set(e.x+i.x,e.y+i.y),t},t.subtract=function(t,e,i){return t.set(e.x-i.x,e.y-i.y),t},t.unit=function(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t},t.normal=function(t,e){return t.set(-e.y,e.x),this.unit(t,t)},t.scale=function(t,e,i){return t.set(e.x*i,e.y*i),t},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.round=function(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t},t}(),e=function(){function e(e,i,n,r){this._position=new t,this._center=new t,this._width=0,this._height=0,this.set(e,i,n,r)}return Object.defineProperty(e.prototype,"x",{get:function(){return this._position.x},set:function(t){this._position.set(t,this._position.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._position.y},set:function(t){this._position.set(this._position.x,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this._position.x+this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._position.y+this._height},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"center",{get:function(){return this._center.set(this.x+this.width/2,this.y+this.height/2),this._center},enumerable:!1,configurable:!0}),e.prototype.set=function(t,e,i,n){this._position.set(t,e),this._width=i,this._height=n},e.prototype.equals=function(t){return this.position.equals(t.position)&&this.width===t.width&&this.height===t.height},e.prototype.updateFromRect=function(t){this.set(t.x,t.y,t.width,t.height)},e.prototype.overlappingRectangle=function(t){return this.x1>=t.x&&this.x<=t.x1&&this.y1>=t.y&&this.y<=t.y1},e}(),i=function(t,e,i){return Math.min(i,Math.max(e,t))},n=function(t,e,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n},r=function(){function e(e,i){void 0===e&&(e=null),void 0===i&&(i=null),this._degrees=0,this._radians=0,this._direction=new t,e?this.radians=e:i&&(this.degrees=i)}return Object.defineProperty(e.prototype,"degrees",{get:function(){return this._degrees},set:function(t){this._degrees=t,this._radians=t*Math.PI/180,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radians",{get:function(){return this._radians},set:function(t){this._radians=t,this._degrees=180*t/Math.PI,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),e.prototype.updateDirection=function(){this._direction.set(Math.cos(this._radians),Math.sin(this._radians))},e}(),o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},o(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var s,h=function(){return h=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},h.apply(this,arguments)};function l(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}h((n=n.apply(t,e||[])).next())}))}function c(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function u(t,e,i){if(i||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}!function(t){t.Image="Image",t.Audio="Audio",t.Video="Video"}(s||(s={}));var p,d=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},f=function(){function t(){this.assets=[]}return t.prototype.getAssetsLoaded=function(){return this.assets.reduce((function(t,e){return t&&e.loaded}),!0)},t.prototype.laadImage=function(t){var e=this.createAsset(t,s.Image);return e.element=new Image,e.element.src=t,e.element.naturalWidth?e.loaded=!0:e.element.addEventListener("load",(function(){return e.loaded=!0})),e.element},t.prototype.loadAudio=function(t){var e=this.createAsset(t,s.Audio);return e.element=new Audio,e.element.src=t,e.element.duration?e.loaded=!0:e.element.addEventListener("canplaythrough",(function(){return e.loaded=!0})),e.element},t.prototype.getImage=function(t){return this.getAsset(t,s.Image)},t.prototype.getVideo=function(t){return this.getAsset(t,s.Video)},t.prototype.getAudio=function(t){return this.getAsset(t,s.Audio)},t.prototype.getAsset=function(t,e){return void 0===e&&(e=null),this.assets.reduce((function(i,n){return n.url!==t||null!==e&&e!==n.type?i:n}),null).element},t.prototype.createAsset=function(t,e){var i=new d;return i.type=e,i.url=t,this.assets.push(i),i},t}(),g=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return a(e,t),e}(Error),m=function(){function i(i,n,r,o){void 0===r&&(r=6),void 0===o&&(o=15),this._bounds=new e(0,0,0,0),this._items=[],this._quadrants=[],this.sw=0,this.se=1,this.nw=2,this.ne=3,this.center=new t,this.childrenWidth=0,this.childrenHeight=0,this.quadsForItem=[],this.level=i,this._bounds.updateFromRect(n),this.maxLevels=r,this.maxItems=o,this.updateCache()}return Object.defineProperty(i.prototype,"bounds",{get:function(){return this._bounds},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"quadrants",{get:function(){return this._quadrants},enumerable:!1,configurable:!0}),i.prototype.updateBounds=function(t){this._bounds.updateFromRect(t),this.updateCache()},i.prototype.clearItems=function(){this._items=[],this._quadrants.forEach((function(t){return t.clearItems()}))},i.prototype.clearQuadrants=function(){this._quadrants.forEach((function(t){return t.clearQuadrants()})),this._quadrants=[]},i.prototype.addItem=function(t){this._quadrants.length>0?this.insertItemIntoChildrenQuads(t):(this._items.push(t),this._items.length>this.maxItems&&this.level<this.maxLevels&&this.splitQuad())},i.prototype.retrieve=function(t){var e=[];this._quadrants.length>0&&this.getChildrenQuadrantForItem(t).forEach((function(i){return e.push.apply(e,i.retrieve(t))})),e.push.apply(e,this._items);var i=e.indexOf(t);return-1!==i&&e.splice(i,1),e},i.prototype.splitQuad=function(){var t=this;this._quadrants=[new e(this.center.x-this.childrenWidth,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new e(this.center.x,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new e(this.center.x-this.childrenWidth,this.center.y,this.childrenWidth,this.childrenHeight),new e(this.center.x,this.center.y,this.childrenWidth,this.childrenHeight)].map((function(e){return new i(t.level+1,e,t.maxLevels,t.maxItems)}));for(var n=0,r=this._items;n<r.length;n++){var o=r[n];this.insertItemIntoChildrenQuads(o)}this._items=[]},i.prototype.getChildrenQuadrantForItem=function(t){if(0===this._quadrants.length)throw new g("Current quadrant does not have quadrant children.");if(this.quadsForItem=[],t.x<=this.center.x&&t.y<=this.center.y&&this.quadsForItem.push(this._quadrants[this.sw]),t.x1>=this.center.x&&t.y<=this.center.y&&this.quadsForItem.push(this._quadrants[this.se]),t.x<=this.center.x&&t.y1>=this.center.y&&this.quadsForItem.push(this._quadrants[this.nw]),t.x1>=this.center.x&&t.y1>=this.center.y&&this.quadsForItem.push(this._quadrants[this.ne]),0===this.quadsForItem.length)throw new g("Item does not fit in any children quadrant");return this.quadsForItem},i.prototype.insertItemIntoChildrenQuads=function(t){this.getChildrenQuadrantForItem(t).forEach((function(e){return e.addItem(t)}))},i.prototype.updateCache=function(){this.center.set(this._bounds.width/2+this._bounds.x,this._bounds.height/2+this._bounds.y),this.childrenWidth=this._bounds.width/2,this.childrenHeight=this._bounds.height/2},i}(),y=function(){function i(i,n,r,o){void 0===n&&(n=null),this.collisions=[],this.minBounds=new t,this.maxBounds=new t,this.newBounds=new e(0,0,0,0),this.fixedQuadTree=null!==n,this.method=i,this.colliders=[],this.fixedQuadTree?this.bounds=n:this.bounds=new e(0,0,0,0),this.quadTree=new m(0,this.bounds,r,o)}return i.prototype.addCollider=function(t){this.colliders.push(t)},i.prototype.removeCollider=function(t){var e=this.colliders.indexOf(t);-1!==e&&(delete this.colliders[e],this.colliders.splice(e,1))},i.prototype.getFrameCollisionsForCollider=function(t){return this.collisions.filter((function(e){return e.localCollider===t}))},i.prototype.refreshCollisionsForCollider=function(t){var e;if(-1===this.colliders.indexOf(t))return[];var i=this.narrowPhase(t,this.broadPhase(t));return this.collisions=this.collisions.filter((function(e){return e.localCollider!==t})),(e=this.collisions).push.apply(e,i),i},i.prototype.clear=function(){this.colliders=[]},i.prototype.update=function(){if(this.collisions=[],0!==this.colliders.length){this.quadTree.clearItems(),this.quadTree.clearQuadrants(),!1===this.fixedQuadTree&&(this.updateNewBounds(),!1===this.newBounds.equals(this.bounds)&&(this.bounds.updateFromRect(this.newBounds),this.quadTree.updateBounds(this.bounds)));for(var t=0,e=this.colliders;t<e.length;t++){var i=e[t];this.quadTree.addItem(i)}this.updateCollisions()}},i.prototype.updateNewBounds=function(){var t=this;this.colliders.forEach((function(e){t.minBounds.set(Math.min(e.x,t.minBounds.x),Math.min(e.y,t.minBounds.y)),t.maxBounds.set(Math.max(e.x1,t.maxBounds.x),Math.max(e.y1,t.maxBounds.y))})),this.newBounds.set(this.minBounds.x,this.minBounds.y,this.maxBounds.x-this.minBounds.x,this.maxBounds.y-this.minBounds.y)},i.prototype.updateCollisions=function(){var t=this;this.colliders.filter((function(t){return t.updateCollisions})).forEach((function(e){var i;return(i=t.collisions).push.apply(i,t.narrowPhase(e,t.broadPhase(e)))}))},i.prototype.broadPhase=function(t){return this.quadTree.retrieve(t)},i.prototype.narrowPhase=function(t,e){var i=this,n=[];return e.filter((function(e){return e.id!==t.id})).forEach((function(e){var r=i.method.getCollisionResolution(t.shape,e.shape);null!==r&&n.push({localCollider:t,remoteCollider:e,resolution:r})})),n},i}(),b=function(){function t(t,e,i){if(this._canvas=null,!t)throw new g("containerNode cannot be empty or null.");this.containerNode=t,this.gameWidth=e,this.gameHeight=i,this.setupCanvas()}return Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),t.prototype.setupCanvas=function(){this._canvas=document.createElement("canvas"),this._canvas.id="angryPixelGameCanvas",this._canvas.width=Math.floor(this.gameWidth),this._canvas.height=Math.floor(this.gameHeight),this.canvas.tabIndex=0,this._canvas.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this.containerNode.appendChild(this._canvas),this.canvas.focus()},t}();!function(t){t[t.Init=0]="Init",t[t.Start=1]="Start",t[t.Update=2]="Update",t[t.UpdateEngine=3]="UpdateEngine",t[t.UpdateCollider=4]="UpdateCollider",t[t.UpdatePhysics=5]="UpdatePhysics",t[t.UpdateTransform=6]="UpdateTransform",t[t.UpdatePreRender=7]="UpdatePreRender",t[t.UpdateCamera=8]="UpdateCamera",t[t.UpdateRender=9]="UpdateRender",t[t.Destroy=10]="Destroy"}(p||(p={}));var x,v=function(){function t(t,e,i,n,r,o,a){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.renderManager=n,this.inputManager=r,this.gameObjectManager=o,this.sceneManager=a,this.gameLoopAccumulator=0,this.physicsLoopAccumulator=0,this.gameObjects=[],this.components=[]}return t.prototype.update=function(t){if(this.timeManager.update(t),this.gameLoopAccumulator+=this.timeManager.browserDeltaTime,this.load(),this.gameLoopAccumulator>=this.timeManager.minGameDeltatime&&(this.mainIteration(),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(),this.gameLoopAccumulator-=this.timeManager.minGameDeltatime),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate)for(this.physicsLoopAccumulator+=this.timeManager.browserDeltaTime;this.physicsLoopAccumulator>=this.timeManager.minPhysicsDeltaTime;)this.physicsLoopAccumulator-=this.timeManager.minPhysicsDeltaTime,this.timeManager.timeScale>0&&this.physicsIteration();this.preRenderIteration(),this.renderIteration(),this.sceneManager.update()},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.getGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return u(u([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.mainIteration=function(){this.physicsManager.clear(),this.dispatchFrameEvent(p.Start),this.inputManager.update(),this.dispatchFrameEvent(p.Update),this.dispatchFrameEvent(p.UpdateEngine),this.dispatchFrameEvent(p.UpdateTransform)},t.prototype.physicsIteration=function(){this.dispatchFrameEvent(p.UpdatePhysics),this.dispatchFrameEvent(p.UpdateCollider),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear()},t.prototype.preRenderIteration=function(){this.dispatchFrameEvent(p.UpdateTransform),this.dispatchFrameEvent(p.UpdatePreRender),this.dispatchFrameEvent(p.UpdateCamera)},t.prototype.renderIteration=function(){this.dispatchFrameEvent(p.UpdateRender),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.dispatchFrameEvent=function(t){t!==p.Start&&t!==p.Update||(this.currentScene.dispatch(t),this.gameObjects.forEach((function(e){return e.dispatch(t)}))),this.components.forEach((function(e){return e.dispatch(t)}))},t}(),M=function(){function t(){this.gameObjects=[]}return t.prototype.addGameObject=function(t,e,i){void 0===i&&(i=null);var n=this.findGameObjectByName(e);if(n&&!1===n.keep)throw new g("There is already a GameObject with the name "+e);if(n&&n.keep)return n;var r=t();return this.gameObjects.push(r),r.name=e,r.parent=i,r.dispatch(p.Init),r},t.prototype.getGameObjects=function(){return this.gameObjects},t.prototype.findGameObjectById=function(t){return this.gameObjects.reduce((function(e,i){return i.id===t?i:e}),null)},t.prototype.findGameObjectByName=function(t){return this.gameObjects.reduce((function(e,i){return i.name===t?i:e}),null)},t.prototype.findGameObjectsByParent=function(t){return this.gameObjects.filter((function(e){return e.parent===t}))},t.prototype.findGameObjectByParentAndName=function(t,e){return this.gameObjects.reduce((function(i,n){return n.name===e&&n.parent===t?n:i}),null)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjects.filter((function(e){return e.tag===t}))},t.prototype.findGameObjectByTag=function(t){var e;return null!==(e=this.findGameObjectsByTag(t)[0])&&void 0!==e?e:null},t.prototype.destroyAllGameObjects=function(){var t=this;this.gameObjects.filter((function(t){return!t.keep})).forEach((function(e){return t.destroy(e,!1)}))},t.prototype.destroyGameObject=function(t){this.destroy(t,!0)},t.prototype.destroy=function(t,e){var i=this.gameObjects.indexOf(t);if(-1!==i){var n=this.gameObjects.splice(i,1)[0];e&&this.destroyChildren(n),n.dispatch(p.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){e.destroyChildren(t),e.destroyGameObject(t)}))},t}(),w=function(){function t(){var t=this;this.gamepads=new Map,this.eventHandler=function(e){"gamepadconnected"===e.type?t.gamepadConnected(e.gamepad):"gamepaddisconnected"===e.type&&t.gamepadDisconected(e.gamepad)},window.addEventListener("gamepadconnected",this.eventHandler),window.addEventListener("gamepaddisconnected",this.eventHandler)}return t.prototype.getGamepad=function(t){var e;return null!==(e=this.gamepads.get(t))&&void 0!==e?e:null},t.prototype.gamepadConnected=function(t){this.gamepads.set(t.index,new _),this.gamepads.get(t.index).updateFromGamepad(t)},t.prototype.gamepadDisconected=function(t){this.gamepads.delete(t.index)},t.prototype.update=function(){for(var t=0,e=this.getGamepads();t<e.length;t++){var i=e[t];null!==i&&(!1===this.gamepads.has(i.index)&&this.gamepadConnected(i),this.gamepads.get(i.index).updateFromGamepad(i))}},t.prototype.getGamepads=function(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads:[]},t}(),_=function(){function e(){this._connected=!1,this._id=null,this.buttons=new Map,this.axes=new Map,this._dpadAxes=new t,this._leftStickAxes=new t,this._rightStickAxes=new t}return e.prototype.updateFromGamepad=function(t){var e=this;this._id=t.id,this._connected=t.connected,t.buttons.forEach((function(t,i){return e.buttons.set(i,t.pressed)})),t.axes.forEach((function(t,i){return e.axes.set(i,t)}))},Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),e.prototype.getButtonPressed=function(t){return this.buttons.get(t)},e.prototype.getAxis=function(t){return this.axes.get(t)},Object.defineProperty(e.prototype,"dpadAxes",{get:function(){return this._dpadAxes.set(this.dpadRight?1:this.dpadLeft?-1:0,this.dpadUp?1:this.dpadDown?-1:0),this._dpadAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickAxes",{get:function(){return this._leftStickAxes.set(this.leftStickHorizontal,this.leftStickVertical),this._leftStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickAxes",{get:function(){return this._rightStickAxes.set(this.rightStickHorizontal,this.rightStickVertical),this._rightStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connected",{get:function(){return this._connected},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadUp",{get:function(){var t;return null!==(t=this.buttons.get(12))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadDown",{get:function(){var t;return null!==(t=this.buttons.get(13))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadLeft",{get:function(){var t;return null!==(t=this.buttons.get(14))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadRight",{get:function(){var t;return null!==(t=this.buttons.get(15))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomFace",{get:function(){var t;return null!==(t=this.buttons.get(0))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightFace",{get:function(){var t;return null!==(t=this.buttons.get(1))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftFace",{get:function(){var t;return null!==(t=this.buttons.get(2))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topFace",{get:function(){var t;return null!==(t=this.buttons.get(3))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftShoulder",{get:function(){var t;return null!==(t=this.buttons.get(4))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightShoulder",{get:function(){var t;return null!==(t=this.buttons.get(5))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftTrigger",{get:function(){var t;return null!==(t=this.buttons.get(6))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightTrigger",{get:function(){var t;return null!==(t=this.buttons.get(7))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"back",{get:function(){var t;return null!==(t=this.buttons.get(8))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"start",{get:function(){var t;return null!==(t=this.buttons.get(9))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickButton",{get:function(){var t;return null!==(t=this.buttons.get(10))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickButton",{get:function(){var t;return null!==(t=this.buttons.get(11))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(0))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(1))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(2))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(3))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),e}(),O=function(){function t(t,e,i,n){this.mouse=t,this.keyboard=e,this.gamepad=i,this.touch=n}return t.prototype.update=function(){this.mouse.update(),this.gamepad.update()},t}(),j=function(){function t(t){var e=this;this.keyPresses=new Map,this.eventHandler=function(t){"keydown"===t.type&&e.keyPresses.set(t.code,!0),"keyup"===t.type&&e.keyPresses.set(t.code,!1)},this.canvas=t,this.canvas.addEventListener("keydown",this.eventHandler),this.canvas.addEventListener("keyup",this.eventHandler)}return t.prototype.isPressed=function(t){var e;return null!==(e=this.keyPresses.get(t))&&void 0!==e&&e},t.prototype.orPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t||null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!1)},t.prototype.andPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t&&null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!0)},t.prototype.isPressedReturn=function(t,e,i){return this.keyPresses.get(t)?e:i},t.prototype.orPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t||null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!1)?e:i},t.prototype.andPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t&&null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!0)?e:i},t}(),C=function(){function e(e){this._leftButtonPressed=!1,this._scrollButtonPressed=!1,this._rightButtonPressed=!1,this._positionInViewport=new t(0,0),this._hasMoved=!1,this.lastPositionInViewport=new t(0,0),this.canvas=e,this.setup()}return Object.defineProperty(e.prototype,"leftButtonPressed",{get:function(){return this._leftButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollButtonPressed",{get:function(){return this._scrollButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightButtonPressed",{get:function(){return this._rightButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),e.prototype.update=function(){!1===this._positionInViewport.equals(this.lastPositionInViewport)?(this._hasMoved=!0,this.lastPositionInViewport.copy(this._positionInViewport)):this._hasMoved=!1},e.prototype.setup=function(){var t=this;this.canvas.addEventListener("mousemove",(function(e){return t.updatePosition(e)})),this.canvas.addEventListener("mousedown",(function(e){return t.updateButtonDown(e)})),this.canvas.addEventListener("mouseup",(function(e){return t.updateButtonUp(e)}))},e.prototype.updateButtonDown=function(t){this.canvas.focus(),t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0===t.button,this._scrollButtonPressed=1===t.button,this._rightButtonPressed=2===t.button},e.prototype.updateButtonUp=function(t){t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0!==t.button&&this._leftButtonPressed,this._scrollButtonPressed=1!==t.button&&this._scrollButtonPressed,this._rightButtonPressed=2!==t.button&&this._rightButtonPressed},e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),this._positionInViewport.set(t.offsetX/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-t.offsetY/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2)},e}();!function(t){t[t.Image=0]="Image",t[t.Text=1]="Text",t[t.Tilemap=2]="Tilemap",t[t.Mask=3]="Mask",t[t.Geometric=4]="Geometric"}(x||(x={}));var P=function(){function e(){this.ui=!1,this.debug=!1,this.layer=null,this._position=new t(0,0),this._positionInViewport=new t(0,0)}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},set:function(t){this._positionInViewport.set(t.x,t.y)},enumerable:!1,configurable:!0}),e}(),R=function(){function t(t,e,i,n){void 0===n&&(n=!1),this.debug=!1,this.renderData=[],this.cameraData=[],this.renderer=t,this.cullingService=e,this.canvasColor=i,this.debug=n}return t.prototype.clearCanvas=function(){this.renderer.clearCanvas(this.canvasColor)},t.prototype.addRenderData=function(t){!1===this.debug&&t.debug||this.renderData.push(t)},t.prototype.addCameraData=function(t){this.cameraData.push(t)},t.prototype.render=function(){var t=this;this.cameraData.sort((function(t,e){return t.depth-e.depth})).forEach((function(e){return t.renderByCamera(e)})),this.clearData()},t.prototype.clearData=function(){this.renderData=[],this.cameraData=[]},t.prototype.renderByCamera=function(t){var e=this;this.orderRendeData(t),this.cullingService.applyCulling(t,this.renderData).forEach((function(i){e.updateFromCameraViewport(t,i),e.renderer.render(t,i)}))},t.prototype.orderRendeData=function(t){this.renderData.sort((function(e,i){return t.layers.indexOf(e.layer)-t.layers.indexOf(i.layer)}))},t.prototype.updateFromCameraViewport=function(t,e){var i=this;!0!==e.ui?e.type===x.Tilemap?e.tilesToRender.forEach((function(e){return i.setPositionInViewport(t,e)})):this.setPositionInViewport(t,e):e.positionInViewport=e.position},t.prototype.setPositionInViewport=function(t,e){e.positionInViewport.set(Math.round(e.position.x-t.worldSpaceRect.x-t.worldSpaceRect.width/2),Math.round(e.position.y-t.worldSpaceRect.y-t.worldSpaceRect.height/2))},t}(),D="undefined"!=typeof Float32Array?Float32Array:Array;function S(){var t=new D(16);return D!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function T(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B(t,e,i){var n,r,o,a,s,h,l,c,u,p,d,f,g=i[0],m=i[1],y=i[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*y+e[12],t[13]=e[1]*g+e[5]*m+e[9]*y+e[13],t[14]=e[2]*g+e[6]*m+e[10]*y+e[14],t[15]=e[3]*g+e[7]*m+e[11]*y+e[15]):(n=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=e[5],l=e[6],c=e[7],u=e[8],p=e[9],d=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=a,t[4]=s,t[5]=h,t[6]=l,t[7]=c,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=n*g+s*m+u*y+e[12],t[13]=r*g+h*m+p*y+e[13],t[14]=o*g+l*m+d*y+e[14],t[15]=a*g+c*m+f*y+e[15]),t}function A(t,e,i){var n=i[0],r=i[1],o=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function E(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],a=e[1],s=e[2],h=e[3],l=e[4],c=e[5],u=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+l*n,t[1]=a*r+c*n,t[2]=s*r+u*n,t[3]=h*r+p*n,t[4]=l*r-o*n,t[5]=c*r-a*n,t[6]=u*r-s*n,t[7]=p*r-h*n,t}function F(t,e,i,n,r,o,a){var s=1/(e-i),h=1/(n-r),l=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+i)*s,t[13]=(r+n)*h,t[14]=(a+o)*l,t[15]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var I,G=function(t){var e=/^#?([a-f\d]{2})?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[2],16)/256,g:parseInt(e[3],16)/256,b:parseInt(e[4],16)/256,a:void 0!==e[1]?parseInt(e[1],16)/256:1}:null},V=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S(),this.posVertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.texVertices=new Float32Array([0,1,0,0,1,1,1,1,0,0,1,0])}return t.prototype.render=function(t,e,i,n){var r;if("image"!==n&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.posVertices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.texVertices,this.gl.STATIC_DRAW)),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),E(this.modelMatrix,this.modelMatrix,i.rotation),A(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=T(this.textureMatrix),i.slice&&(B(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),A(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=T(this.projectionMatrix),F(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"image"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var o=G(i.tintColor),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.tintColorUniform,a,s,h,l)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,i.maskColor?1:0),i.maskColor){var c=G(i.maskColor);a=c.r,s=c.g,h=c.b;this.gl.uniform4f(this.programManager.maskColorUniform,a,s,h,i.alpha),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(r=i.maskColorMix)&&void 0!==r?r:0)}this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}(),U=function(){function t(t){this.shaderLoader=t}return t.prototype.create=function(t,e,i){var n=t.createProgram(),r=this.shaderLoader.load(t,t.VERTEX_SHADER,e),o=this.shaderLoader.load(t,t.FRAGMENT_SHADER,i);return this.link(t,n,r,o),n},t.prototype.link=function(t,e,i,n){t.attachShader(e,i),t.attachShader(e,n),t.linkProgram(e);var r=t.LINK_STATUS;if(!t.getProgramParameter(e,r)){var o=t.getProgramInfoLog(e);throw t.deleteProgram(e),new g("Unable to initialize the Program: "+o)}},t}(),L=function(){function t(){}return t.prototype.load=function(t,e,i){var n=t.createShader(e);t.shaderSource(n,i),t.compileShader(n);var r=t.COMPILE_STATUS;if(!t.getShaderParameter(n,r)){var o=t.getShaderInfoLog(n);throw t.deleteShader(n),new g("Unable to initialize the shader program: "+o)}return n},t}(),k=function(){function t(t,e){this.gl=e.getContext(t)}return t.prototype.createFromImage=function(t,e,i){var n=this;return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),t.naturalWidth?this.create(t,i,e):t.addEventListener("load",(function(){return n.create(t,i,e)})),i},t.prototype.createFromCanvas=function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),this.create(t,i,e),i},t.prototype.create=function(t,e,i){void 0===i&&(i=!0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),!1===i?(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST)):(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR)),this.gl.bindTexture(this.gl.TEXTURE_2D,null)},t}();!function(t){t.LegacyWebGL="webgl",t.WebGL2="webgl2"}(I||(I={}));var N,z=function(){function t(t,e,i,n,r,o,a,s,h,l){this.canvas=e,this.gl=this.canvas.getContext(t),i.loadProgram(),this.textureManager=n,this.imageRenderer=o,this.tilemapRenderer=a,this.textRenderer=s,this.geometricRenderer=h,this.maskRenderer=l,this.fontAtlasFactory=r}return t.prototype.clearCanvas=function(t){var e=G(t);this.gl.clearColor(e.r,e.g,e.b,e.a),this.gl.clear(this.gl.COLOR_BUFFER_BIT)},t.prototype.render=function(t,e){e.type===x.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===x.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===x.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===x.Geometric&&(this.geometricRenderer.render(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===x.Mask&&(this.renderMask(t,e),this.lastRender="mask")},t.prototype.renderImage=function(t,e){this.imageRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderTilemap=function(t,e){this.tilemapRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderText=function(t,e){this.fontAtlasFactory.loadingFontAtlas(e.fontFamily)||(this.fontAtlasFactory.hasFontAtlas(e.fontFamily)?this.fontAtlasLoaded(this.fontAtlasFactory.getFontAtlas(e.fontFamily),t,e):this.fontAtlasFactory.asyncCreate(e.charRanges,e.fontFamily,e.fontUrl,e.bitmapSize))},t.prototype.renderMask=function(t,e){this.maskRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,e,this.lastRender)},t.prototype.fontAtlasLoaded=function(t,e,i){this.textRenderer.render(!0===i.ui?e.originalViewportRect:e.viewportRect,this.textureManager.getOrCreateTextureFromCanvas(i.fontFamily,t.canvas,i.smooth),t,i,this.lastRender)},t}(),W=function(){function t(t,e){this.game=null,this.scenes=new Map,this.currentScene=null,this.openingSceneName=null,this.sceneToLoad=null,this.game=t,this.renderManager=e}return t.prototype.getCurrentScene=function(){return this.currentScene},t.prototype.addScene=function(t,e,i){if(void 0===i&&(i=!1),this.scenes.has(t))throw new g("There is already a scene with the name '"+t+"'");this.scenes.set(t,e),!0!==i&&null!==this.openingSceneName||(this.openingSceneName=t)},t.prototype.loadOpeningScene=function(){if(null===this.openingSceneName)throw new g("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new g("Game not initialized.");if(!1===this.scenes.has(t))throw new g("Scene with name "+t+" does not exists");this.sceneToLoad=t},t.prototype.update=function(){null!==this.sceneToLoad&&(this._loadScene(this.sceneToLoad),this.sceneToLoad=null)},t.prototype._loadScene=function(t){this.unloadCurrentScene(),this.currentScene=this.scenes.get(t)(),this.currentScene.name=t,this.currentScene.game=this.game,this.currentScene.dispatch(p.Init)},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(p.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager.clearData())},t}(),H=function(){function t(t){if(this.minGameDeltatime=0,this.minPhysicsDeltaTime=0,this.gameFramerate=60,this.physicsFramerate=240,this.timeScale=1,this.browserDeltaTime=0,this.unscaledGameDeltaTime=0,this.unscaledPhysicsDeltaTime=0,this.max=1/15,this.then=0,t<60)throw new g("Physics framerate cannot be less than 60");if(t%60!=0)throw new g("Physics framerate must be multiple of 60");this.physicsFramerate=t,this.minGameDeltatime=parseFloat((1/this.gameFramerate).toFixed(6)),this.minPhysicsDeltaTime=parseFloat((1/this.physicsFramerate).toFixed(6))}return t.prototype.update=function(t){var e=.001*t;this.browserDeltaTime=Math.min(Math.max(0,e-this.then),this.max),this.unscaledGameDeltaTime=Math.max(this.minGameDeltatime,this.browserDeltaTime),this.unscaledPhysicsDeltaTime=this.gameFramerate===this.physicsFramerate?this.unscaledGameDeltaTime:this.minPhysicsDeltaTime,this.then=e},Object.defineProperty(t.prototype,"deltaTime",{get:function(){return this.unscaledGameDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"physicsDeltaTime",{get:function(){return this.unscaledPhysicsDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),t}(),Y=function(){function t(t){this.textures=new Map,this.textureFactory=t}return t.prototype.getTexture=function(t){var e;return null!==(e=this.textures.get(Symbol.for(t)))&&void 0!==e?e:null},t.prototype.getOrCreateTextureFromImage=function(t,e){var i;return void 0===e&&(e=!0),null!==(i=this.textures.get(Symbol.for(t.src)))&&void 0!==i?i:this.createTextureFromImage(t,e)},t.prototype.createTextureFromImage=function(t,e){void 0===e&&(e=!0);var i=this.textureFactory.createFromImage(t,e);return this.textures.set(Symbol.for(t.src),i),i},t.prototype.getOrCreateTextureFromCanvas=function(t,e,i){var n;return void 0===i&&(i=!0),null!==(n=this.textures.get(Symbol.for(t)))&&void 0!==n?n:this.createTextureFromCanvas(t,e,i)},t.prototype.createTextureFromCanvas=function(t,e,i){void 0===i&&(i=!0);var n=this.textureFactory.createFromCanvas(e,i);return this.textures.set(Symbol.for(t),n),n},t}(),X=function(){function t(t,e,i){this.gl=i.getContext(e),this.programFactory=t,this.contextVersion=e}return t.prototype.loadProgram=function(){this.program=this.contextVersion===I.WebGL2?this.programFactory.create(this.gl,"#version 300 es\nprecision mediump float;\n\nin vec2 positionCoords;\nin vec2 textureCoords;\n\nout vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","#version 300 es\nprecision mediump float;\n\nout vec4 fragColor;\n\nin vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n fragColor = vec4(texColor.rgb, u_alpha * texColor.a); \n } else {\n fragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"):this.programFactory.create(this.gl,"precision mediump float;\n\nattribute vec2 positionCoords;\nattribute vec2 textureCoords;\n\nvarying vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","precision mediump float;\n\nvarying vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture2D(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n gl_FragColor = vec4(texColor.rgb, u_alpha * texColor.a);\n } else {\n gl_FragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"),this.positionBuffer=this.gl.createBuffer(),this.textureBuffer=this.gl.createBuffer(),this.positionCoordsAttr=this.gl.getAttribLocation(this.program,"positionCoords"),this.texCoordsAttr=this.gl.getAttribLocation(this.program,"textureCoords"),this.modelMatrixUniform=this.gl.getUniformLocation(this.program,"modelMatrix"),this.projectionMatrixUniform=this.gl.getUniformLocation(this.program,"projectionMatrix"),this.textureMatrixUniform=this.gl.getUniformLocation(this.program,"textureMatrix"),this.renderTextureUniform=this.gl.getUniformLocation(this.program,"u_renderTexture"),this.textureUniform=this.gl.getUniformLocation(this.program,"u_texImage"),this.solidColorUniform=this.gl.getUniformLocation(this.program,"u_solidColor"),this.useTintColorUniform=this.gl.getUniformLocation(this.program,"u_useTintColor"),this.tintColorUniform=this.gl.getUniformLocation(this.program,"u_tintColor"),this.useMaskColorUniform=this.gl.getUniformLocation(this.program,"u_useMaskColor"),this.maskColorUniform=this.gl.getUniformLocation(this.program,"u_maskColor"),this.maskColorMixUniform=this.gl.getUniformLocation(this.program,"u_maskColorMix"),this.alphaUniform=this.gl.getUniformLocation(this.program,"u_alpha"),this.gl.useProgram(this.program),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enableVertexAttribArray(this.positionCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.vertexAttribPointer(this.positionCoordsAttr,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.texCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureBuffer),this.gl.vertexAttribPointer(this.texCoordsAttr,2,this.gl.FLOAT,!1,0,0)},t}(),q=function(){function t(){this.bitmapSize=64,this.fontAtlas=new Map,this.loading=new Map}return t.prototype.hasFontAtlas=function(t){return this.fontAtlas.has(Symbol.for(t))},t.prototype.loadingFontAtlas=function(t){var e;return null!==(e=this.loading.get(Symbol.for(t)))&&void 0!==e&&e},t.prototype.getFontAtlas=function(t){return this.fontAtlas.get(Symbol.for(t))},t.prototype.asyncCreate=function(t,e,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),this.bitmapSize=null!=n?n:this.bitmapSize;var o=new Q(e);this.chars=[];for(var a=0;a<t.length;a+=2)for(var s=t[a];s<=t[a+1];s++)this.chars.push(String.fromCharCode(s));o.canvas.width=Math.round(Math.sqrt(this.chars.length))*this.bitmapSize,o.canvas.height=o.canvas.width,null!==i?this.loadFont(e,i).then((function(){return r.renderAtlas(o,e)})):this.renderAtlas(o,e)},t.prototype.loadFont=function(t,e){return l(this,void 0,void 0,(function(){var i;return c(this,(function(n){switch(n.label){case 0:return this.loading.set(Symbol.for(t),!0),[4,(i=new FontFace(t,"url("+e+")")).load()];case 1:return n.sent(),document.fonts.add(i),this.loading.set(Symbol.for(t),!1),[2]}}))}))},t.prototype.renderAtlas=function(t,e){var i=t.canvas.getContext("2d");i.clearRect(0,0,t.canvas.width,t.canvas.height),i.textBaseline="top",i.fillStyle="#000",i.font=this.bitmapSize+"px "+e;for(var n=0,r=0,o=0;o<this.chars.length;o++)i.fillText(this.chars[o],n,r),t.glyphsData.set(this.chars[o],{x:n,y:r,width:this.bitmapSize,height:this.bitmapSize}),(n+=this.bitmapSize)>t.canvas.width-this.bitmapSize&&(n=0,r+=this.bitmapSize);this.fontAtlas.set(Symbol.for(e),t)},t}(),Q=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},K=function(){function e(e,i,n){this.posVertices=[],this.texVertices=[],this.posVerticesSize=new t,this.lastTexture=null,this.gl=i.getContext(e),this.programManager=n,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S()}return e.prototype.render=function(t,e,i,n,r){if(n.text){this.generateTextVertices(i,n),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),E(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=T(this.textureMatrix),A(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=T(this.projectionMatrix),F(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),n.opacity<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.lastTexture===e&&"text"===r||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useTintColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,n.opacity);var o=G(n.color),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.maskColorUniform,a,s,h,l),this.gl.uniform1f(this.programManager.maskColorMixUniform,1),this.gl.uniform1i(this.programManager.useMaskColorUniform,1),this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)}},e.prototype.generateTextVertices=function(t,e){this.posVertices=[],this.texVertices=[];for(var i=this.getDimensions(e),n={x1:-i.width/2,y1:i.height/2-e.fontSize,x2:0,y2:i.height/2},r={x1:0,y1:0,x2:0,y2:0},o=0;o<e.text.length;o++){var a=e.text[o];if("\n"!==a)if(" "!==a){var s=t.glyphsData.get(a);s&&(n.x2=n.x1+e.fontSize,r.x1=s.x+e.bitmapOffset.x,r.y1=s.y+e.bitmapOffset.y,r.x2=s.x+s.width-1,r.y2=s.y+s.height-1,this.posVertices.push(n.x1,n.y1,n.x2,n.y1,n.x1,n.y2,n.x1,n.y2,n.x2,n.y1,n.x2,n.y2),this.texVertices.push(r.x1,r.y2,r.x2,r.y2,r.x1,r.y1,r.x1,r.y1,r.x2,r.y2,r.x2,r.y1)),n.x1+=e.fontSize+e.letterSpacing}else n.x1+=e.fontSize+e.letterSpacing;else n.y1-=e.fontSize+e.lineSeparation,n.y2=n.y1+e.fontSize,n.x1=-i.width/2}this.posVerticesSize.set(i.width,i.height)},e.prototype.getTranslationForOrientation=function(t){return[t.positionInViewport.x+("center"===t.orientation?0:this.posVerticesSize.x/2),t.positionInViewport.y+("rightDown"===t.orientation?-this.posVerticesSize.y/2:"rightUp"===t.orientation?this.posVerticesSize.y:0),0]},e.prototype.getDimensions=function(t){return t.text.split("\n").reduce((function(e,i,n){return e.width=Math.max(e.width,i.length*(t.fontSize+t.letterSpacing)),e.height+=t.fontSize+Math.min(n,1)*t.lineSeparation,e}),{width:0,height:0})},e}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}(N||(N={}));var $,J=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Geometric,e}return a(e,t),e}(P),Z=function(){function t(t,e,i){this.vertices=new Map,this.lastVertices=null,this.lastRender=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S();var r=2*Math.PI/60;this.circumferenceVertices=new Float32Array(n(1,60,1).reduce((function(t,e){return u(u([],t,!0),[Math.cos(e*r),Math.sin(e*r)],!1)}),[]))}return t.prototype.render=function(t,e,i){switch(this.lastRender=i,e.shape){case N.Polygon:case N.Line:this.renderLines(t,e,this.gl.LINE_LOOP);break;case N.Circumference:this.renderCircumference(t,e)}},t.prototype.renderLines=function(t,e,i){var n=e.vertexModel,r=e.positionInViewport,o=e.angle,a=e.color,s=this.generateVerticesKey(n);!1===this.vertices.has(s)&&this.vertices.set(s,new Float32Array(this.generatePolygonVertices(n)));var h=this.vertices.get(s);this.lastVertices===s&&"geometric"===this.lastRender||(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW)),this.lastVertices=s,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[r.x,r.y,0]),E(this.modelMatrix,this.modelMatrix,o),this.projectionMatrix=T(this.projectionMatrix),F(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var l=G(a),c=l.r,u=l.g,p=l.b,d=l.a;this.gl.uniform4f(this.programManager.solidColorUniform,c,u,p,d),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(i,0,h.length/2)},t.prototype.generateVerticesKey=function(t){return Symbol.for(t.reduce((function(t,e){return""+t+e.x+e.y}),t.length.toString()))},t.prototype.generatePolygonVertices=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i].x,t[i].y);return e},t.prototype.renderCircumference=function(t,e){var i=e.radius,n=e.positionInViewport,r=e.color;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),this.lastVertices=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[n.x,n.y,0]),A(this.modelMatrix,this.modelMatrix,[i,i,1]),this.projectionMatrix=T(this.projectionMatrix),F(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var o=G(r),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.solidColorUniform,a,s,h,l),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(this.gl.LINE_LOOP,0,this.circumferenceVertices.length/2)},t}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}($||($={}));var tt,et=function(){function t(t,e){this.circumferenceResolver=t,this.satResolver=e}return t.prototype.getCollisionResolution=function(t,e){return t.type===$.Circumference&&e.type===$.Circumference?this.circumferenceResolver.resolve(t,e):this.satResolver.resolve(t,e)},t}(),it=function(){function e(e){var i=this;this._touching=!1,this._positionInViewport=new t(0,0),this._radius=new t(0,0),this.eventHandler=function(t){"touchstart"===t.type&&(i._touching=!0,i.updatePosition(t)),"touchmove"===t.type&&i.updatePosition(t),"touchend"!==t.type&&"touchcancel"!==t.type||(i._touching=!1)},this.canvas=e,this.canvas.addEventListener("touchstart",this.eventHandler),this.canvas.addEventListener("touchend",this.eventHandler),this.canvas.addEventListener("touchcancel",this.eventHandler),this.canvas.addEventListener("touchmove",this.eventHandler)}return Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touching",{get:function(){return this._touching},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},enumerable:!1,configurable:!0}),e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),0!==t.targetTouches.length&&(this._positionInViewport.set((t.targetTouches[0].clientX-this.canvas.offsetLeft)/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-(t.targetTouches[0].clientY-this.canvas.offsetTop)/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2),this._radius.set(t.targetTouches[0].radiusX,t.targetTouches[0].radiusY))},e}(),nt=function(){function t(t,e,i){this.AABBResolver=t,this.circumferenceAABBResolver=e,this.circumferenceResolver=i}return t.prototype.getCollisionResolution=function(t,e){return t.type===$.Polygon&&e.type===$.Polygon?this.AABBResolver.resolve(t,e):t.type===$.Circumference&&e.type===$.Polygon?this.circumferenceAABBResolver.resolve(t,e):t.type===$.Polygon&&e.type===$.Circumference?this.circumferenceAABBResolver.resolve(e,t,!0):t.type===$.Circumference&&e.type===$.Circumference?this.circumferenceResolver.resolve(t,e):null},t}(),rt=function(){function t(){}return t.prototype.applyCulling=function(t,e){var i=this;return e.filter((function(e){if(!1===t.layers.includes(e.layer))return!1;var n=e.ui?t.viewportRect:t.worldSpaceRect;switch(e.type){case x.Image:return i.cullSprite(n,e);case x.Tilemap:return i.cullTilemap(n,e);case x.Geometric:return i.cullGeometric(n,e);case x.Text:return i.cullText(n,e);case x.Mask:return i.cullSprite(n,e)}}))},t.prototype.cullSprite=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.cullTilemap=function(t,e){var i=this;return e.tilesToRender=e.tilesData.filter((function(n){return i.isTargetVisible(t,{x:n.position.x-e.tileWidth/2,x1:n.position.x+e.tileWidth/2,y:n.position.y-e.tileHeight/2,y1:n.position.y+e.tileHeight/2})})),e.tilesData.length>0},t.prototype.cullGeometric=function(t,e){return this.isTargetVisible(t,e.boundingBox)},t.prototype.cullText=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.isTargetVisible=function(t,e){return t.x1>=e.x&&t.x<=e.x1&&t.y1>=e.y&&t.y<=e.y1},t}(),ot=function(){function t(t,e,i){this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.p={x1:0,y1:0,x2:0,y2:0},this.t={x1:0,y1:0,x2:0,y2:0},this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S()}return t.prototype.render=function(t,e,i,n){if(this.generateVertices(i),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=T(this.modelMatrix),this.textureMatrix=T(this.textureMatrix),A(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=T(this.projectionMatrix),F(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"tilemap"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useMaskColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var r=G(i.tintColor),o=r.r,a=r.g,s=r.b,h=r.a;this.gl.uniform4f(this.programManager.tintColorUniform,o,a,s,h)}this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)},t.prototype.generateVertices=function(t){var e=this;this.posVertices=[],this.texVertices=[],t.tilesToRender.forEach((function(i){var n,r;e.p.x1=i.positionInViewport.x-t.tileWidth/2,e.p.x2=i.positionInViewport.x+t.tileWidth/2,e.p.y1=i.positionInViewport.y-t.tileHeight/2,e.p.y2=i.positionInViewport.y+t.tileHeight/2,e.posVertices.push(e.p.x1,e.p.y1,e.p.x2,e.p.y1,e.p.x1,e.p.y2,e.p.x1,e.p.y2,e.p.x2,e.p.y1,e.p.x2,e.p.y2),e.t.x1=i.tile.x,e.t.y1=i.tile.y,e.t.x2=i.tile.x+i.tile.width-(null!==(n=t.textureCorrection)&&void 0!==n?n:0),e.t.y2=i.tile.y+i.tile.height-(null!==(r=t.textureCorrection)&&void 0!==r?r:0),e.texVertices.push(e.t.x1,e.t.y2,e.t.x2,e.t.y2,e.t.x1,e.t.y1,e.t.x1,e.t.y1,e.t.x2,e.t.y2,e.t.x2,e.t.y1)}))},t}(),at=function(){function t(){}return t.initialize=function(t){this.assetManager=t},t.getAssetsLoaded=function(){return this.assetManager.getAssetsLoaded()},t.loadImage=function(t){return this.assetManager.laadImage(t)},t.loadAudio=function(t){return this.assetManager.loadAudio(t)},t.getImage=function(t){return this.assetManager.getImage(t)},t.getAudio=function(t){return this.assetManager.getAudio(t)},t.assetManager=null,t}(),st=function(){function t(){}return t.initialize=function(t){this.domManager=t},Object.defineProperty(t,"gameWidth",{get:function(){return this.domManager.canvas.width},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gameHeight",{get:function(){return this.domManager.canvas.height},enumerable:!1,configurable:!0}),Object.defineProperty(t,"canvas",{get:function(){return this.domManager.canvas},enumerable:!1,configurable:!0}),t.domManager=null,t}(),ht=function(){function t(){}return t.initialize=function(t){this.inputManager=t},Object.defineProperty(t,"mouse",{get:function(){return this.inputManager.mouse},enumerable:!1,configurable:!0}),Object.defineProperty(t,"keyboard",{get:function(){return this.inputManager.keyboard},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gamepad",{get:function(){return this.inputManager.gamepad},enumerable:!1,configurable:!0}),Object.defineProperty(t,"touch",{get:function(){return this.inputManager.touch},enumerable:!1,configurable:!0}),t.inputManager=null,t}(),lt=function(){function t(){}return t.initialize=function(t){this.sceneManager=t},t.loadScene=function(t){this.sceneManager.loadScene(t)},t.getCurrentSceneName=function(){return this.sceneManager.currentSceneName},t.loadOpeningScene=function(){this.sceneManager.loadOpeningScene()},t.sceneManager=null,t}(),ct=function(){function t(){}return t.initialize=function(t){this.timeManager=t},Object.defineProperty(t,"deltaTime",{get:function(){return this.timeManager.deltaTime},enumerable:!1,configurable:!0}),t.getTimeScale=function(){return this.timeManager.timeScale},t.setTimeScale=function(t){this.timeManager.timeScale=t},Object.defineProperty(t,"unscaledDeltaTime",{get:function(){return this.timeManager.unscaledGameDeltaTime},enumerable:!1,configurable:!0}),Object.defineProperty(t,"physicsDeltaTime",{get:function(){return this.timeManager.physicsDeltaTime},enumerable:!1,configurable:!0}),t.timeManager=null,t}(),ut=function(){function t(){}return t.initialize=function(t){this.manager=t},t.addGameObject=function(t,e,i){return void 0===i&&(i=null),this.manager.addGameObject(t,e,i)},t.getGameObjects=function(){return this.manager.getGameObjects()},t.findGameObjectByName=function(t){return this.manager.findGameObjectByName(t)},t.findGameObjectsByParent=function(t){return this.manager.findGameObjectsByParent(t)},t.findGameObjectByParentAndName=function(t,e){return this.manager.findGameObjectByParentAndName(t,e)},t.findGameObjectsByTag=function(t){return this.manager.findGameObjectsByTag(t)},t.findGameObjectByTag=function(t){return this.manager.findGameObjectByTag(t)},t.destroyGameObject=function(t){this.manager.destroyGameObject(t)},t.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t}(),pt=function(){function t(t,e,i){this.vertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S()}return t.prototype.render=function(t,e,i){"mask"!==i&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW)),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),E(this.modelMatrix,this.modelMatrix,e.rotation),A(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=T(this.projectionMatrix),F(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),e.alpha<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var n=G(e.color),r=n.r,o=n.g,a=n.b,s=n.a;this.gl.uniform4f(this.programManager.solidColorUniform,r,o,a,s),this.gl.uniform1f(this.programManager.alphaUniform,e.alpha),this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}();exports.RigidBodyType=void 0,(tt=exports.RigidBodyType||(exports.RigidBodyType={}))[tt.Static=0]="Static",tt[tt.Dynamic=1]="Dynamic";var dt,ft=function(){function e(e){this.collisionManager=e,this.rigidBodyData=[],this.cacheVelocity=new t,this.cacheDisplacement=new t,this.cacheNewDisplacement=0}return e.prototype.addRigidBodyData=function(e){e.cacheVelocity?e.cacheVelocity.set(0,0):e.cacheVelocity=new t,this.rigidBodyData.push(e)},e.prototype.removeRigidBodyData=function(t){var e=this.rigidBodyData.indexOf(t);-1!==e&&(delete this.rigidBodyData[e],this.rigidBodyData.splice(e,1))},e.prototype.update=function(t){var e=this;this.rigidBodyData.forEach((function(i){e.applyGravity(i,t),e.applyVelocity(i,t,"x"),e.applyReposition(i,"x"),e.applyVelocity(i,t,"y"),e.applyReposition(i,"y")}))},e.prototype.applyGravity=function(t,e){t.gravity>0&&(t.velocity.y-=t.gravity*e)},e.prototype.applyVelocity=function(e,i,n){var r=this;this.cacheVelocity.set(0,0),this.cacheVelocity[n]=(0!==e.cacheVelocity[n]?e.cacheVelocity[n]:e.velocity[n])*i,t.add(e.position,e.position,this.cacheVelocity),e.colliders.forEach((function(e){t.add(e.shape.position,e.shape.position,r.cacheVelocity),e.shape.update(),r.collisionManager.refreshCollisionsForCollider(e)}))},e.prototype.applyReposition=function(e,i){var n=this;this.cacheCollisions=this.getCollisions(e),0!==this.cacheCollisions.length&&(this.cacheDisplacement.set(0,0),this.cacheCollisions.forEach((function(t){n.cacheNewDisplacement=t.resolution.displacementDirection[i]*t.resolution.penetration,n.cacheDisplacement[i]=Math.abs(n.cacheDisplacement[i])>Math.abs(n.cacheNewDisplacement)?n.cacheDisplacement[i]:n.cacheNewDisplacement})),this.cacheDisplacement.magnitude<=0||(t.add(e.position,e.position,this.cacheDisplacement),e.colliders.forEach((function(e){t.add(e.shape.position,e.shape.position,n.cacheDisplacement),e.shape.update(),n.collisionManager.refreshCollisionsForCollider(e)})),0!==this.cacheDisplacement[i]&&Math.sign(this.cacheDisplacement[i])!==Math.sign(e.velocity[i])&&(e.cacheVelocity[i]=e.velocity[i],e.velocity[i]=0)))},e.prototype.getCollisions=function(t){var e=this;return t.colliders.reduce((function(i,n){return i.push.apply(i,e.collisionManager.getFrameCollisionsForCollider(n).filter((function(e){return e.remoteCollider.physics&&e.remoteCollider.rigidBody&&t.layersToCollider.includes(e.remoteCollider.layer)}))),i}),[])},e.prototype.clear=function(){this.rigidBodyData=[]},e}(),gt=function(){function e(){this.direction=new t,this.displacementDirection=new t}return e.prototype.resolve=function(t,e){return this.overlapX=Math.min(t.boundingBox.x1,e.boundingBox.x1)-Math.max(t.boundingBox.x,e.boundingBox.x),this.overlapY=Math.min(t.boundingBox.y1,e.boundingBox.y1)-Math.max(t.boundingBox.y,e.boundingBox.y),this.overlapX<0||this.overlapY<0?null:(this.direction.set(Math.sign(e.boundingBox.x1-t.boundingBox.x1),Math.sign(e.boundingBox.y1-t.boundingBox.y1)),this.overlapY<this.overlapX?(this.minOverlap=this.overlapY,this.displacementDirection.set(0,-this.direction.y),this.preventContainment(t.boundingBox.y,e.boundingBox.y,t.boundingBox.y1,e.boundingBox.y1)):(this.minOverlap=this.overlapX,this.displacementDirection.set(-this.direction.x,this.overlapY===this.overlapX?-this.direction.y:0),this.preventContainment(t.boundingBox.x,e.boundingBox.x,t.boundingBox.x1,e.boundingBox.x1)),{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:this.direction.clone()})},e.prototype.preventContainment=function(e,i,n,r){if(e>n&&i<r||n>e&&r<i){var o=Math.abs(e-n),a=Math.abs(i-r);o<a?this.minOverlap+=o:(this.minOverlap+=a,t.scale(this.displacementDirection,this.displacementDirection,-1))}},e}(),mt=function(){function e(){this.closestPoint=new t,this.distance=new t,this.direction=new t}return e.prototype.resolve=function(e,n,r){return void 0===r&&(r=!1),this.closestPoint.set(i(e.position.x,n.boundingBox.x,n.boundingBox.x1),i(e.position.y,n.boundingBox.y,n.boundingBox.y1)),t.subtract(this.distance,this.closestPoint,e.position),this.distance.magnitude>e.radius?null:(t.unit(this.direction,this.distance),{penetration:e.radius-this.distance.magnitude,direction:r?t.scale(new t,this.direction,-1):this.direction.clone(),displacementDirection:r?this.direction.clone():t.scale(new t,this.direction,-1)})},e}(),yt=function(){function e(){this.distance=new t,this.direction=new t}return e.prototype.resolve=function(e,i){return t.subtract(this.distance,i.position,e.position),this.distance.magnitude>e.radius+i.radius?null:(t.unit(this.direction,this.distance),{penetration:e.radius+i.radius-this.distance.magnitude,direction:this.direction.clone(),displacementDirection:t.scale(new t,this.direction,-1)})},e}(),bt=function(){function e(){this.projA={min:0,max:0},this.projB={min:0,max:0},this.displaceDirection=new t,this.direction=new t,this.distance=new t(1/0,1/0),this.cache=new t}return e.prototype.resolve=function(e,i){this.currentOverlap=null,this.minOverlap=null,e.type===$.Circumference?this.setCircumferenceAxis(e,i):i.type===$.Circumference&&this.setCircumferenceAxis(i,e),this.axes=u(u([],e.projectionAxes,!0),i.projectionAxes,!0);for(var n=0;n<this.axes.length;n++){if(e.type===$.Circumference?this.setCircumferenceVertices(e,this.axes[n]):i.type===$.Circumference&&this.setCircumferenceVertices(i,this.axes[n]),this.projectShapeOntoAxis(this.projA,e,this.axes[n]),this.projectShapeOntoAxis(this.projB,i,this.axes[n]),this.currentOverlap=Math.min(this.projA.max,this.projB.max)-Math.max(this.projA.min,this.projB.min),this.currentOverlap<0)return null;this.preventContainment(n),(this.currentOverlap<this.minOverlap||null===this.minOverlap)&&(this.minOverlap=this.currentOverlap,this.displaceDirection.copy(this.axes[n]),this.projA.max<this.projB.max&&t.scale(this.displaceDirection,this.displaceDirection,-1))}return t.scale(this.direction,this.displaceDirection,-1),{penetration:this.minOverlap,displacementDirection:this.displaceDirection.clone(),direction:this.direction.clone()}},e.prototype.projectShapeOntoAxis=function(e,i,n){return e.min=t.dot(n,i.vertices[0]),e.max=e.min,i.vertices.forEach((function(i){e.min=Math.min(t.dot(n,i),e.min),e.max=Math.max(t.dot(n,i),e.max)})),e},e.prototype.preventContainment=function(e){if(this.projA.max>this.projB.max&&this.projA.min<this.projB.min||this.projA.max<this.projB.max&&this.projA.min>this.projB.min){var i=Math.abs(this.projA.min-this.projB.min),n=Math.abs(this.projA.max-this.projB.max);i<n?this.currentOverlap+=i:(this.currentOverlap+=n,t.scale(this.axes[e],this.axes[e],-1))}},e.prototype.setCircumferenceAxis=function(e,i){var n=this;this.distance.set(1/0,1/0),i.vertices.forEach((function(i){t.subtract(n.cache,i,e.position),n.cache.magnitude<n.distance.magnitude&&n.distance.copy(n.cache)})),t.unit(e.projectionAxes[0],this.distance)},e.prototype.setCircumferenceVertices=function(e,i){t.add(e.vertices[0],e.position,t.scale(this.cache,t.unit(this.cache,i),-e.radius)),t.add(e.vertices[1],e.position,t.scale(this.cache,t.unit(this.cache,i),e.radius))},e}(),xt=function(t,e){if(e.collisions.method===exports.CollisionMethodConfig.AABB)t.add("CollisionMethod",(function(){return new nt(new gt,new mt,new yt)}));else{if(e.collisions.method!==exports.CollisionMethodConfig.SAT)throw new g("Invalid collision method.");t.add("CollisionMethod",(function(){return new et(new yt,new bt)}))}t.add("CollisionManager",(function(){return new y(t.getSingleton("CollisionMethod"),e.collisions.quadTreeBounds,e.collisions.quadMaxLevel,e.collisions.collidersPerQuad)})),t.add("RigidBodyManager",(function(){return new ft(t.getSingleton("CollisionManager"))}))},vt=function(t,e,i){var n=_t();if(null===n)throw new g("WebGL not suported in your browser.");Mt(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")"),t.add("FontAtlasFactory",(function(){return new q})),t.add("CullingService",(function(){return new rt})),t.add("RenderManager",(function(){return new R(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},Mt=function(t,e,i){e.add("ShaderLoader",(function(){return new L})),e.add("ProgramFactory",(function(){return new U(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new X(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new k(t,i.canvas)})),e.add("TextureManager",(function(){return new Y(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new V(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new K(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new Z(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new ot(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new pt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new z(t,i.canvas,e.getSingleton("ProgramManager"),e.getSingleton("TextureManager"),e.getSingleton("FontAtlasFactory"),e.getSingleton("WebGLImageRenderer"),e.getSingleton("WebGLTilemapRenderer"),e.getSingleton("WebGLTextRenderer"),e.getSingleton("WebGLGeometricRenderer"),e.getSingleton("WebGLMaskRenderer"))}))},wt=function(t,e){t.add("InputManager",(function(){return new O(new C(e.canvas),new j(e.canvas),new w,new it(e.canvas))}))},_t=function(){return null!==document.createElement("canvas").getContext(I.WebGL2)?I.WebGL2:null!==document.createElement("canvas").getContext(I.LegacyWebGL)?I.LegacyWebGL:null},Ot=function(t){at.initialize(t.getSingleton("AssetManager")),st.initialize(t.getSingleton("DomManager")),ht.initialize(t.getSingleton("InputManager")),lt.initialize(t.getSingleton("SceneManager")),ct.initialize(t.getSingleton("TimeManager")),ut.initialize(t.getSingleton("GameObjectManager"))},jt=new(function(){function t(){this.instances=new Map,this.constructors=new Map,this.constants=new Map}return t.prototype.add=function(t,e){if(this.constructors.has(t))throw new g("There is already an object constructor with the name "+t);this.constructors.set(t,e)},t.prototype.getSingleton=function(t){if(!1===this.constructors.has(t))throw new g("Invalid object constructor name: "+t);return!1===this.instances.has(t)&&this.instances.set(t,this.constructors.get(t)()),this.instances.get(t)},t.prototype.getTranscient=function(t){if(!1===this.constructors.has(t))throw new g("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new g("There is already a constant value with the name "+t);this.constants.set(t,e)},t.prototype.getConstant=function(t){if(!1===this.constants.has(t))throw new g("Invalid constant name: "+t);return this.constants.get(t)},t}());exports.CollisionMethodConfig=void 0,(dt=exports.CollisionMethodConfig||(exports.CollisionMethodConfig={})).AABB="aabb",dt.SAT="sat";var Ct={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:240,collisions:{method:exports.CollisionMethodConfig.AABB,quadTreeBounds:null,quadMaxLevel:6,collidersPerQuad:15}},Pt=function(){function t(t){this._running=!1,this._stop=!1,this.frameRequestId=null,this._config=h(h({},Ct),t),this._config.collisions=h(h({},Ct.collisions),t.collisions),jt.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){!function(t,e){t.addConstant("GameConfig",e),t.add("DomManager",(function(){return new b(e.containerNode,e.gameWidth,e.gameHeight)}));var i=t.getSingleton("DomManager");t.add("TimeManager",(function(){return new H(e.physicsFramerate)})),vt(t,e,i),wt(t,i),xt(t,e),t.add("SceneManager",(function(){return new W(t.getConstant("Game"),t.getSingleton("RenderManager"))})),t.add("GameObjectManager",(function(){return new M})),t.add("AssetManager",(function(){return new f})),t.add("IterationManager",(function(){return new v(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})),Ot(t)}(jt,this._config),this.renderManager=jt.getSingleton("RenderManager"),this.sceneManager=jt.getSingleton("SceneManager"),this.iterationManager=jt.getSingleton("IterationManager")},Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"running",{get:function(){return this._running},enumerable:!1,configurable:!0}),t.prototype.addScene=function(t,e,i){void 0===i&&(i=!1),this.sceneManager.addScene(t,e,i)},t.prototype.run=function(){this.sceneManager.loadOpeningScene(),this.requestAnimationFrame()},t.prototype.stop=function(){this.pauseLoop(),this.sceneManager.unloadCurrentScene(),this.renderManager.clearCanvas()},t.prototype.gameLoop=function(t){!0!==this._stop&&(this._running=!0,this.iterationManager.update(t),this.requestAnimationFrame())},t.prototype.pauseLoop=function(){this._stop=!0,this._running=!1,null!==this.frameRequestId&&(window.cancelAnimationFrame(this.frameRequestId),this.frameRequestId=null)},t.prototype.resumeLoop=function(){0==this._running&&null===this.frameRequestId&&(this._stop=!1,this.requestAnimationFrame())},t.prototype.requestAnimationFrame=function(){var t=this;this.frameRequestId=window.requestAnimationFrame((function(e){return t.gameLoop(e)}))},t}(),Rt=function(){var t=(new Date).getTime(),e=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(i){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"==i?n:7&n|8).toString(16)}))},Dt=function(){function t(){this.sceneManager=jt.getSingleton("SceneManager"),this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.id=Rt(),this.allowMultiple=!0,this._active=!0,this.started=!1}return Object.defineProperty(t.prototype,"updateEvent",{get:function(){return p.Update},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._active},enumerable:!1,configurable:!0}),t.prototype.setActive=function(t){this._active=t,this.activeStateChange()},t.prototype.dispatch=function(t){!1!==this._active&&!1!==this.gameObject.active&&(t===p.Init?this.init():t===p.Start&&!1===this.started?(this.start(),this.started=!0):t===this.updateEvent&&!0===this.started?this.update():t===p.Destroy&&(this.destroy(),this._destroy()))},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.destroy=function(){},t.prototype.activeStateChange=function(){},t.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.getComponentByName=function(t){return this.gameObject.getComponentByName(t)},t.prototype.getComponentByType=function(t){return this.gameObject.getComponentByType(t)},t.prototype.getComponentsByType=function(t){return this.gameObject.getComponentsByType(t)},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype.hasComponentOfName=function(t){return null!==this.getComponentByName(t)},t.prototype.hasComponentOfType=function(t){return null!==this.getComponentByType(t)},t.prototype.removeComponentByName=function(t){this.gameObject.removeComponentByName(t)},t.prototype.removeComponentByType=function(t){this.gameObject.removeComponentByType(t)},t.prototype._destroy=function(){var t=this;Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),St=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateEngine},enumerable:!1,configurable:!0}),e}(Dt),Tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateCollider},enumerable:!1,configurable:!0}),e}(Dt),Bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdatePhysics},enumerable:!1,configurable:!0}),e}(Dt),At=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateTransform},enumerable:!1,configurable:!0}),e}(Dt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdatePreRender},enumerable:!1,configurable:!0}),e}(Dt),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateCamera},enumerable:!1,configurable:!0}),e}(Dt),It=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateRender},enumerable:!1,configurable:!0}),e}(Dt),Gt={Animator:"Animator",AudioPlayer:"AudioPlayer",Camera:"camera",RigidBody:"RigidBody",Transform:"Transform",BoxCollider:"BoxCollider",TilemapCollider:"TilemapCollider",PolygonCollider:"PolygonCollider",BallCollider:"BallCollider",EdgeCollider:"EdgeCollider",CsvTilemapRenderer:"CsvTilemapRenderer",SpriteRenderer:"SpriteRenderer",TextRenderer:"TextRenderer",TiledTilemapRenderer:"TiledTilemapRenderer",MaskRenderer:"MaskRenderer"},Vt=function(e){function i(){var i=e.call(this)||this;return i._position=new t,i._scale=new t(1,1),i._rotation=new r,i._innerPosition=new t,i._parent=null,i.parentScale=!0,i.parentRotation=!0,i.cache=new t,i.lastParentRadians=0,i.lastPosition=new t,i.scaledInnerPosition=new t,i.allowMultiple=!1,i.type=Gt.Transform,i}return a(i,e),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(t){this._scale.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._rotation.direction},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"innerPosition",{get:function(){return this._innerPosition},set:function(t){this._innerPosition.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,null!==this._parent&&this.updateInnerPositionFromParent()},enumerable:!1,configurable:!0}),i.prototype.update=function(){null!==this._parent?(!1===this.lastPosition.equals(this._position)&&this.updateInnerPositionFromParent(),this.setPositionFromParent()):this._innerPosition.copy(this._position),this.lastPosition.copy(this._position)},i.prototype.updateInnerPositionFromParent=function(){t.subtract(this._innerPosition,this._position,this._parent.position)},i.prototype.setPositionFromParent=function(){this._innerPosition.magnitude>0?(0!==this._parent.rotation.radians&&this.lastParentRadians!==this._parent.rotation.radians&&(this.translateInnerPosition(),this.lastParentRadians=this._parent.rotation.radians),this.parentScale?(this.updateScaledInnerPosition(),t.add(this._position,this._parent.position,this.scaledInnerPosition)):t.add(this._position,this._parent.position,this._innerPosition)):this._position.copy(this._parent.position),this._rotation.radians=this.parentRotation?this._parent.rotation.radians:this.rotation.radians,this.parentScale&&this._scale.copy(this._parent.scale)},i.prototype.translateInnerPosition=function(){var e=Math.atan2(this._innerPosition.y,this._innerPosition.x)+(this._parent.rotation.radians-this.lastParentRadians);this.cache.set(Math.cos(e),Math.sin(e)),t.scale(this._innerPosition,this.cache,this._innerPosition.magnitude)},i.prototype.updateScaledInnerPosition=function(){this.scaledInnerPosition.set(this._innerPosition.x*this._parent.scale.x,this._innerPosition.y*this._parent.scale.y)},i}(At),Ut=function(){function t(){this.id=Rt(),this.layer="Default",this.ui=!1,this.keep=!1,this._active=!0,this._parent=null,this.started=!1,this.sceneManager=jt.getSingleton("SceneManager"),this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.components=[],this.addComponent((function(){return new Vt}))}return Object.defineProperty(t.prototype,"active",{get:function(){return this._active},enumerable:!1,configurable:!0}),t.prototype.setActive=function(t){this._active=t},Object.defineProperty(t.prototype,"transform",{get:function(){return this.getComponentByType(Gt.Transform)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rigidBody",{get:function(){return this.getComponentByType(Gt.RigidBody)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,this.transform.parent=t?t.transform:null},enumerable:!1,configurable:!0}),t.prototype.dispatch=function(t){!1===this.active||this.parent&&!1===this.parent.active||(t===p.Init?this.init():t===p.Start&&!1===this.started?(this.start(),this.started=!0):t===p.Update&&this.started?this.update():t===p.Destroy&&(this.destroy(),this._destroy()))},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.destroy=function(){},t.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.addComponent=function(t,e){void 0===e&&(e=null);var i=t();return this.checkMultipleComponent(i),i.name=e,i.gameObject=this,i.dispatch(p.Init),this.components.push(i),i},t.prototype.checkMultipleComponent=function(t){if(!1===t.allowMultiple&&this.hasComponentOfType(t.type))throw new g("GameObject only allows one component of type "+t.type)},t.prototype.getComponents=function(){return this.components},t.prototype.getComponentByName=function(t){return this.components.reduce((function(e,i){return i.name===t?i:e}),null)},t.prototype.getComponentByType=function(t){return this.components.reduce((function(e,i){return i.type===t?i:e}),null)},t.prototype.getComponentsByType=function(t){return this.components.filter((function(e){return e.type===t}))},t.prototype.hasComponentOfName=function(t){return null!==this.getComponentByName(t)},t.prototype.hasComponentOfType=function(t){return null!==this.getComponentByType(t)},t.prototype.removeComponentByName=function(t){var e=this;this.components.every((function(i,n){if(i.name===t)return i.dispatch(p.Destroy),delete e.components[n],!1}))},t.prototype.removeComponentByType=function(t){var e=this;this.components.every((function(i,n){if(i.type===t)return i.dispatch(p.Destroy),delete e.components[n],!1}))},t.prototype.addChild=function(t,e){return this.gameObjectManager.addGameObject(t,e,this)},t.prototype.getChildren=function(){return this.gameObjectManager.findGameObjectsByParent(this)},t.prototype.getChild=function(t){return this.gameObjectManager.findGameObjectByParentAndName(this,t)},t.prototype.destroyChildren=function(){var t=this;this.gameObjectManager.findGameObjectsByParent(this).forEach((function(e){return t.gameObjectManager.destroyGameObject(e)}))},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype._destroy=function(){var t=this;this.destroyComponents(),Object.keys(this).forEach((function(e){return delete t[e]}))},t.prototype.destroyComponents=function(){for(var t=0;t<this.components.length;t++)this.components[t].dispatch(p.Destroy),delete this.components[t];this.components=[]},t}(),Lt=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},kt=["Default"],Nt=function(t){function i(){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.domManager=jt.getSingleton("DomManager"),i._layers=kt,i._depth=0,i._zoom=1,i._originalViewportRect=new e(0,0,0,0),i._viewportRect=new e(0,0,0,0),i._worldSpaceRect=new e(0,0,0,0),i.cameraData=new Lt,i.allowMultiple=!1,i.type=Gt.Camera,i.canvas=i.domManager.canvas,i}return a(i,t),Object.defineProperty(i.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=u(u([],kt,!0),t,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"zoom",{get:function(){return this._zoom},set:function(t){if(this.zoom<=0)throw new g("zoom must be greather than 0");this._zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"originalViewportRect",{get:function(){return this._originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"worldSpaceRect",{get:function(){return this._worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"viewportRect",{get:function(){return this._viewportRect},enumerable:!1,configurable:!0}),i.prototype.addLayer=function(t){this._layers.push(t)},i.prototype.update=function(){this.updateOriginalViewportRect(),this.updateViewportRect(),this.updateWorldSpaceRect(),this.updateCameraData()},i.prototype.updateOriginalViewportRect=function(){this._originalViewportRect.x=-this.canvas.width/2,this._originalViewportRect.y=-this.canvas.height/2,this._originalViewportRect.width=this.canvas.width,this._originalViewportRect.height=this.canvas.height},i.prototype.updateViewportRect=function(){var t=1/this._zoom;this._viewportRect.x=this._originalViewportRect.x*t,this._viewportRect.y=this._originalViewportRect.y*t,this._viewportRect.width=this._originalViewportRect.width*t,this._viewportRect.height=this._originalViewportRect.height*t},i.prototype.updateWorldSpaceRect=function(){this._worldSpaceRect.x=this.gameObject.transform.position.x-this._viewportRect.width/2,this._worldSpaceRect.y=this.gameObject.transform.position.y-this._viewportRect.height/2,this._worldSpaceRect.width=this._viewportRect.width,this._worldSpaceRect.height=this._viewportRect.height},i.prototype.updateCameraData=function(){this.cameraData.depth=this._depth,this.cameraData.layers=this._layers,this.cameraData.originalViewportRect=this._originalViewportRect,this.cameraData.viewportRect=this._viewportRect,this.cameraData.worldSpaceRect=this._worldSpaceRect,this.cameraData.zoom=this._zoom,this.renderManager.addCameraData(this.cameraData)},i}(Ft),zt=function(t){function e(){var e=t.call(this)||this;return e.transform.position.set(0,0),e.camera=e.addComponent((function(){return new Nt})),e}return a(e,t),Object.defineProperty(e.prototype,"layers",{get:function(){return this.camera.layers},set:function(t){this.camera.layers=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this.camera.depth},set:function(t){this.camera.depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this.camera.zoom},set:function(t){this.camera.zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalViewporRect",{get:function(){return this.camera.originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"worldSpaceRect",{get:function(){return this.camera.worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportRect",{get:function(){return this.camera.viewportRect},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){this.camera.layers.push(t)},e}(Ut),Wt=function(){function t(){this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.game=null,this.name=null,this.started=!1,this.addGameObject((function(){return new zt}),"GameCamera")}return Object.defineProperty(t.prototype,"gameCamera",{get:function(){return this.findGameObjectByName("GameCamera")},enumerable:!1,configurable:!0}),t.prototype.dispatch=function(t){t===p.Init?this.init():t!==p.Start||this.started?t===p.Update&&this.started?this.update():t===p.Destroy&&(this.destroy(),this._destroy()):(this.start(),this.started=!0)},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.destroy=function(){},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.getGameObjects=function(){return this.gameObjectManager.getGameObjects()},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype._destroy=function(){var t=this;this.gameObjectManager.destroyAllGameObjects(),Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=jt.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return a(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return t.collisionManager.addCollider(e)}))},e.prototype.collidesWithLayer=function(t){return null!==this.getCollisionWithLayer(t)},e.prototype.getCollisionWithLayer=function(t){for(var e=0,i=this.colliders;e<i.length;e++)for(var n=i[e],r=0,o=this.collisionManager.getFrameCollisionsForCollider(n);r<o.length;r++){var a=o[r];if(a.remoteCollider.layer===t)return{gameObject:this.gameObjectManager.findGameObjectById(a.remoteCollider.id),collider:a.remoteCollider,resolution:a.resolution}}return null},e.prototype.getCollisionsWithLayer=function(t){for(var e=[],i=0,n=this.colliders;i<n.length;i++)for(var r=n[i],o=0,a=this.collisionManager.getFrameCollisionsForCollider(r);o<a.length;o++){var s=a[o];s.remoteCollider.layer===t&&e.push({gameObject:this.gameObjectManager.findGameObjectById(s.remoteCollider.id),collider:s.remoteCollider,resolution:s.resolution})}return e},e.prototype.activeStateChange=function(){this.renderer&&this.renderer.setActive(this.active)},e}(Tt),Yt=function(){function t(t,e,i,n,r,o){this.shape=t,this.layer=e,this.id=i,this.updateCollisions=n,this.physics=r,this.rigidBody=o}return Object.defineProperty(t.prototype,"x",{get:function(){return this.shape.boundingBox.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.shape.boundingBox.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x1",{get:function(){return this.shape.boundingBox.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y1",{get:function(){return this.shape.boundingBox.y1},enumerable:!1,configurable:!0}),t}(),Xt=function(){function i(i){this._type=$.Polygon,this._vertices=[],this._boundingBox=new e(0,0,0,0),this._projectionAxes=[],this._position=new t,this._angle=0,this.boxMinX=Number.MAX_SAFE_INTEGER,this.boxMinY=Number.MAX_SAFE_INTEGER,this.boxMaxX=-Number.MAX_SAFE_INTEGER,this.boxMaxY=-Number.MAX_SAFE_INTEGER,this._vertexModel=i;for(var n=0;n<this._vertexModel.length;n++)this._vertices.push(new t),this._projectionAxes.push(new t)}return Object.defineProperty(i.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"boundingBox",{get:function(){return this._boundingBox},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"projectionAxes",{get:function(){return this._projectionAxes},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"vertexModel",{get:function(){return this._vertexModel},set:function(t){this._vertexModel=t},enumerable:!1,configurable:!0}),i.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},i.prototype.updateVertices=function(){for(var t=0;t<this._vertexModel.length;t++)this._vertices[t].set(this._vertexModel[t].x*Math.cos(this._angle)-this._vertexModel[t].y*Math.sin(this._angle)+this._position.x,this._vertexModel[t].x*Math.sin(this._angle)+this._vertexModel[t].y*Math.cos(this._angle)+this._position.y)},i.prototype.updateBoundingBox=function(){var t=this;this.boxMinX=this.vertices[0].x,this.boxMinY=this.vertices[0].y,this.boxMaxX=this.vertices[0].x,this.boxMaxY=this.vertices[0].y,this.vertices.forEach((function(e){t.boxMinX=Math.min(e.x,t.boxMinX),t.boxMinY=Math.min(e.y,t.boxMinY),t.boxMaxX=Math.max(e.x,t.boxMaxX),t.boxMaxY=Math.max(e.y,t.boxMaxY)})),this.boundingBox.set(this.boxMinX,this.boxMinY,this.boxMaxX-this.boxMinX,this.boxMaxY-this.boxMinY)},i.prototype.updateProjectionAxes=function(){for(var e,i=0;i<this._vertices.length;i++)t.normal(this.projectionAxes[i],t.subtract(this.projectionAxes[i],null!==(e=this._vertices[i+1])&&void 0!==e?e:this._vertices[0],this._vertices[i]))},i}(),qt=function(e){function i(i,n,r){var o=e.call(this,[new t(-i/2,-n/2),new t(-i/2,n/2),new t(i/2,n/2),new t(i/2,-n/2)])||this;return o.width=i,o.height=n,o._position.copy(r),o._projectionAxes=[new t,new t],o.update(),o}return a(i,e),i.prototype.updateSize=function(t,e){this.width=t,this.height=e,this.vertexModel[0].set(-t/2,-e/2),this.vertexModel[1].set(-t/2,e/2),this.vertexModel[2].set(t/2,e/2),this.vertexModel[3].set(t/2,-e/2)},i.prototype.updateProjectionAxes=function(){t.unit(this._projectionAxes[0],t.subtract(this.projectionAxes[0],this._vertices[1],this._vertices[0])),t.normal(this._projectionAxes[1],this._projectionAxes[0])},i}(Xt),Qt=function(e){function i(i){var n,o,a,s,h,l=e.call(this)||this;return l.debug=!1,l.offsetX=0,l.offsetY=0,l.realWidth=0,l.realHeight=0,l.realOffset=new t,l.realPosition=new t,l.realRotation=0,l.applyRotation=jt.getConstant("GameConfig").collisions.method===exports.CollisionMethodConfig.SAT,l.innerPosition=new t,l.type=Gt.BoxCollider,l.width=i.width,l.height=i.height,l.offsetX=null!==(n=i.offsetX)&&void 0!==n?n:l.offsetX,l.offsetY=null!==(o=i.offsetY)&&void 0!==o?o:l.offsetY,l.physics=null!==(a=i.physics)&&void 0!==a?a:l.physics,l.debug=(null!==(s=i.debug)&&void 0!==s?s:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new r,l.layer=i.layer,l}return a(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new Yt(new qt(this.realWidth,this.realHeight,this.realPosition),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Kt(e.colliders[0])})))},i.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateRealSize=function(){this.realWidth=this.width*Math.abs(this.gameObject.transform.scale.x),this.realHeight=this.height*Math.abs(this.gameObject.transform.scale.y),this.realOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.realOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.realRotation=this.applyRotation?this.gameObject.transform.rotation.radians+this.rotation.radians:0},i.prototype.updatePosition=function(){t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.realPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.realPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.realPosition,this.colliders[0].shape.angle=this.realRotation,this.colliders[0].shape.updateSize(this.realWidth,this.realHeight),this.colliders[0].shape.update()},i}(Ht),Kt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="BoxColliderRenderer",i.renderData=new J,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return a(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=N.Polygon,this.renderData.position=this.collider.shape.position,this.renderData.angle=this.collider.shape.angle,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},e}(It),$t=function(){function i(i){this.type=$.Circumference,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new e(0,0,0,0),this.angle=0,this.vertexModel=[],this.radius=0,this._position=new t,this.vertices=[new t,new t],this.radius=i}return Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),i.prototype.update=function(){this.updateBoundingBox()},i.prototype.updateBoundingBox=function(){this.boundingBox.set(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},i}(),Jt=function(e){function i(i){var n,r,o,a,s=e.call(this)||this;return s.debug=!1,s.offsetX=0,s.offsetY=0,s.realRadius=0,s.realOffset=new t,s.realPosition=new t,s.innerPosition=new t,s.type=Gt.BallCollider,s.radius=i.radius,s.offsetX=null!==(n=i.offsetX)&&void 0!==n?n:s.offsetX,s.offsetY=null!==(r=i.offsetY)&&void 0!==r?r:s.offsetY,s.physics=null!==(o=i.physics)&&void 0!==o?o:s.physics,s.debug=(null!==(a=i.debug)&&void 0!==a?a:s.debug)&&jt.getConstant("GameConfig").debugEnabled,s.layer=i.layer,s}return a(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new Yt(new $t(this.radius),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Zt(e.colliders[0])})))},i.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateRealSize=function(){this.realRadius=this.radius*Math.max(Math.abs(this.gameObject.transform.scale.x),Math.abs(this.gameObject.transform.scale.y)),this.realOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.realOffset.y=this.offsetY*this.gameObject.transform.scale.y},i.prototype.updatePosition=function(){t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.realPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.realPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.realPosition,this.colliders[0].shape.radius=this.realRadius,this.colliders[0].shape.update()},i}(Ht),Zt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="BallColliderRenderer",i.renderData=new J,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return a(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=N.Circumference,this.renderData.position=this.collider.shape.position,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.radius=this.collider.shape.radius,this.renderManager.addRenderData(this.renderData)},e}(It),te=function(e){function i(i){var n,r=e.call(this)||this;return r.debug=!1,r.needsCollider=function(t){r.cacheVertex[0].set(t.position.x,t.position.y+t.height),r.cacheVertex[1].set(t.position.x+t.width,t.position.y),r.cacheVertex[2].set(t.position.x,t.position.y-t.height),r.cacheVertex[3].set(t.position.x-t.width,t.position.y);for(var e=function(t){if(void 0===r.tilemapRenderer.tilesData.find((function(e){return e.position.equals(r.cacheVertex[t])})))return{value:!0}},i=0;i<r.cacheVertex.length;i++){var n=e(i);if("object"==typeof n)return n.value}return!1},r.type=Gt.TilemapCollider,r.tilemapRenderer=i.tilemapRenderer,r.layer=i.layer,r.debug=(null!==(n=i.debug)&&void 0!==n?n:r.debug)&&jt.getConstant("GameConfig").debugEnabled,r.physics=!0,r.cacheVertex=[new t,new t,new t,new t],r}return a(i,e),i.prototype.start=function(){var t,e=this;this.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.tilemapRenderer.tilesData.filter(this.needsCollider).forEach((function(t){return e.colliders.push(new Yt(new qt(t.width,t.height,t.position),e.layer,e.gameObject.id,!1,e.physics,e.hasComponentOfType(Gt.RigidBody)))})),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ee(e.colliders)})))},i.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return e.layer=t.layer})),e.prototype.update.call(this)},i}(Ht),ee=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.renderData=[],i.colliders=[],i.type="TilemapColliderRenderer",i.colliders=e,i.colliders.forEach((function(t,e){i.renderData[e]=new J,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00"})),i}return a(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].shape=N.Polygon,t.renderData[i].position=e.shape.position,t.renderData[i].angle=e.shape.angle,t.renderData[i].boundingBox=e.shape.boundingBox,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},e}(It),ie=function(e){function i(i){var n,o,a,s,h,l=e.call(this)||this;if(l.debug=!1,l.offsetX=0,l.offsetY=0,l.scaledVertexModel=[],l.scaledOffset=new t,l.scaledPosition=new t,l.finalRotation=0,l.innerPosition=new t,jt.getConstant("GameConfig").collisions.method!==exports.CollisionMethodConfig.SAT)throw new g("Polygon Colliders need SAT collision method.");if(i.vertexModel.length<3)throw new g("Polygon Collider needs at least 3 vertices.");l.type=Gt.PolygonCollider,l.debug=(null!==(n=i.debug)&&void 0!==n?n:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.vertexModel=i.vertexModel,l.offsetX=null!==(o=i.offsetX)&&void 0!==o?o:l.offsetX,l.offsetY=null!==(a=i.offsetY)&&void 0!==a?a:l.offsetY,l.physics=null!==(s=i.physics)&&void 0!==s?s:l.physics,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new r,l.layer=i.layer;for(var c=0;c<l.vertexModel.length;c++)l.scaledVertexModel.push(new t);return l}return a(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new Yt(new Xt(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ne(e.colliders[0])})))},i.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateSize=function(){var t=this;this.vertexModel.forEach((function(e,i){return t.scaledVertexModel[i].set(e.x*t.gameObject.transform.scale.x,e.y*t.gameObject.transform.scale.y)})),this.scaledOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.scaledOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.finalRotation=this.gameObject.transform.rotation.radians+this.rotation.radians},i.prototype.updatePosition=function(){t.add(this.scaledPosition,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.scaledPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.scaledPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.scaledPosition,this.colliders[0].shape.angle=this.finalRotation,this.colliders[0].shape.vertexModel=this.scaledVertexModel,this.colliders[0].shape.update()},i}(Ht),ne=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="PolygonColliderRenderer",i.renderData=new J,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return a(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=N.Polygon,this.renderData.position=this.collider.shape.position,this.renderData.angle=this.collider.shape.angle,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},e}(It),re=function(){function i(i){this.vertexModel=i,this.type=$.Polygon,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new e(0,0,0,0),this.angle=0,this._position=new t}return i.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),i.prototype.updateVertices=function(){for(var t=0;t<this.vertexModel.length;t++)this.vertices[t].set(this.vertexModel[t].x*Math.cos(this.angle)-this.vertexModel[t].y*Math.sin(this.angle)+this._position.x,this.vertexModel[t].x*Math.sin(this.angle)+this.vertexModel[t].y*Math.cos(this.angle)+this._position.y)},i.prototype.updateBoundingBox=function(){this.boundingBox.x=Math.min(this.vertices[0].x,this.vertices[1].x),this.boundingBox.y=Math.min(this.vertices[0].y,this.vertices[1].y),this.boundingBox.width=Math.max(this.vertices[0].x,this.vertices[1].x)-this.boundingBox.x,this.boundingBox.height=Math.max(this.vertices[0].y,this.vertices[1].y)-this.boundingBox.y},i.prototype.updateProjectionAxes=function(){t.normal(this.projectionAxes[0],t.subtract(this.projectionAxes[0],this.vertices[1],this.vertices[0]))},i}(),oe=function(e){function i(i){var n,o,a,s,h,l=e.call(this)||this;if(l.debug=!1,l.offsetX=0,l.offsetY=0,l.scaledVertexModel=[],l.scaledOffset=new t,l.scaledPosition=new t,l.finalRotation=0,l.innerPosition=new t,jt.getConstant("GameConfig").collisions.method!==exports.CollisionMethodConfig.SAT)throw new g("Edge Colliders need SAT collision method.");if(i.vertexModel.length<2)throw new g("Edge Collider needs at least 2 vertices.");l.type=Gt.EdgeCollider,l.debug=(null!==(n=i.debug)&&void 0!==n?n:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.vertexModel=i.vertexModel,l.offsetX=null!==(o=i.offsetX)&&void 0!==o?o:l.offsetX,l.offsetY=null!==(a=i.offsetY)&&void 0!==a?a:l.offsetY,l.physics=null!==(s=i.physics)&&void 0!==s?s:l.physics,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new r,l.layer=i.layer;for(var c=0;c<l.vertexModel.length;c++)l.scaledVertexModel.push(new t);return l}return a(i,e),i.prototype.start=function(){for(var t,e=this,i=0;i<this.scaledVertexModel.length-1;i++)this.colliders.push(new Yt(new re([this.scaledVertexModel[i],this.scaledVertexModel[i+1]]),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody)));this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ae(e.colliders)})))},i.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateColliders(),e.prototype.update.call(this)},i.prototype.updateSize=function(){var t=this;this.vertexModel.forEach((function(e,i){return t.scaledVertexModel[i].set(e.x*t.gameObject.transform.scale.x,e.y*t.gameObject.transform.scale.y)})),this.scaledOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.scaledOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.finalRotation=this.gameObject.transform.rotation.radians+this.rotation.radians},i.prototype.updatePosition=function(){t.add(this.scaledPosition,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.scaledPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.scaledPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateColliders=function(){for(var t,e=0;e<this.scaledVertexModel.length-1;e++)this.colliders[e].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[e].shape.position=this.scaledPosition,this.colliders[e].shape.angle=this.finalRotation,this.colliders[e].shape.vertexModel=[this.scaledVertexModel[e],this.scaledVertexModel[e+1]],this.colliders[e].shape.update()},i}(Ht),ae=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.renderData=[],i.colliders=[],i.type="EdgeColliderRenderer",i.colliders=e,i.colliders.forEach((function(t,e){i.renderData[e]=new J,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00",i.renderData[e].shape=N.Line})),i}return a(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].position=e.shape.position,t.renderData[i].angle=e.shape.angle,t.renderData[i].boundingBox=e.shape.boundingBox,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},e}(It),se=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Image,e}return a(e,t),e}(P),he=function(e){function i(i){var n,o,a,s,h,l,c,u,p,d,f;void 0===i&&(i={sprite:null});var g=e.call(this)||this;return g.renderManager=jt.getSingleton("RenderManager"),g.sprite=null,g.offset=new t,g.flipHorizontal=!1,g.flipVertical=!1,g.rotation=new r,g.smooth=!1,g.opacity=1,g._tiled=new t(1,1),g.maskColor=null,g.maskColorMix=0,g.tintColor=null,g.renderData=[],g.innerPosition=new t,g.cachePosition=new t,g.cacheRenderPosition=new t,g.scaledOffset=new t,g.type=Gt.SpriteRenderer,g.sprite=i.sprite,g.offset=null!==(n=i.offset)&&void 0!==n?n:g.offset,g.smooth=null!==(o=i.smooth)&&void 0!==o?o:g.smooth,g.rotation=null!==(a=i.rotation)&&void 0!==a?a:g.rotation,g.flipHorizontal=null!==(s=i.flipHorizontal)&&void 0!==s?s:g.flipHorizontal,g.flipVertical=null!==(h=i.flipVertical)&&void 0!==h?h:g.flipVertical,g.opacity=null!==(l=i.opacity)&&void 0!==l?l:g.opacity,g.tiled=null!==(c=i.tiled)&&void 0!==c?c:g._tiled,g.maskColor=null!==(u=i.maskColor)&&void 0!==u?u:g.maskColor,g.maskColorMix=null!==(p=i.maskColorMix)&&void 0!==p?p:g.maskColorMix,g.tintColor=null!==(d=i.tintColor)&&void 0!==d?d:g.tintColor,g.layer=null!==(f=i.layer)&&void 0!==f?f:g.layer,g}return a(i,e),Object.defineProperty(i.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new g("SpriteRenderer.tiled: Vector2 components must be integers");this._tiled.set(t.x,t.y)},enumerable:!1,configurable:!0}),i.prototype.update=function(){if(this.sprite&&!0===this.sprite.loaded){this.updateRenderDataArray();for(var t=0,e=0;e<this._tiled.x;e++)for(var i=0;i<this._tiled.y;i++)this.updateRenderData(t,e,i),t++}},i.prototype.updateRenderDataArray=function(){if(this.renderData.length!==this._tiled.x*this._tiled.y){this.renderData=[];for(var t=0;t<=this._tiled.x*this._tiled.y;t++)this.renderData[t]=new se}},i.prototype.updateRenderData=function(t,e,i){var n;this.renderData[t].ui=this.gameObject.ui,this.renderData[t].layer=null!==(n=this.layer)&&void 0!==n?n:this.gameObject.layer,this.renderData[t].image=this.sprite.image,this.renderData[t].width=this.sprite.width*Math.abs(this.gameObject.transform.scale.x),this.renderData[t].height=this.sprite.height*Math.abs(this.gameObject.transform.scale.y),this.renderData[t].slice=this.sprite.slice,this.renderData[t].flipHorizontal=this.flipHorizontal!==this.gameObject.transform.scale.x<0,this.renderData[t].flipVertical=this.flipVertical!==this.gameObject.transform.scale.y<0,this.renderData[t].rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData[t].smooth=this.sprite.smooth,this.renderData[t].alpha=this.opacity,this.renderData[t].maskColor=this.maskColor,this.renderData[t].maskColorMix=this.maskColorMix,this.renderData[t].tintColor=this.tintColor,this.calculateRenderPosition(t,e,i),this.renderManager.addRenderData(this.renderData[t])},i.prototype.calculateRenderPosition=function(e,i,n){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.cachePosition,this.gameObject.transform.position,this.scaledOffset),this.cacheRenderPosition.set(this.renderData[e].width/2*(this.tiled.x-1),this.renderData[e].height/2*(this.tiled.y-1)),t.subtract(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.cacheRenderPosition.set(i*this.renderData[e].width,n*this.renderData[e].height),t.add(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.renderData[e].position=this.cachePosition,0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition(e)},i.prototype.translateRenderPosition=function(e){t.subtract(this.innerPosition,this.renderData[e].position,this.gameObject.transform.position);var i=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData[e].position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(i),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(i))},i}(It),le=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Text,e}return a(e,t),e}(P),ce=function(e){function i(i){var n,o,a,s,h,l,c,u,p,d,f,m,y,b,x,v=e.call(this)||this;if(v.fontFamily="Sans",v.fontUrl=null,v.fontSize=12,v.width=100,v.height=100,v.offset=new t,v.color="#000000",v.lineSeparation=0,v.letterSpacing=0,v.bitmapSize=64,v.charRanges=[32,126,161,255],v.smooth=!1,v.bitmapOffset=new t,v.rotation=new r,v.opacity=1,v.orientation="center",v.renderManager=jt.getSingleton("RenderManager"),v.renderData=new le,v.lastFrameText="",v.type=Gt.TextRenderer,v.text=i.text,v.fontFamily=i.fontFamily,v.fontUrl=null!==(n=i.fontUrl)&&void 0!==n?n:v.fontUrl,v.fontSize=null!==(o=i.fontSize)&&void 0!==o?o:v.fontSize,v.width=null!==(a=i.width)&&void 0!==a?a:v.width,v.height=null!==(s=i.height)&&void 0!==s?s:v.height,v.offset=null!==(h=i.offset)&&void 0!==h?h:v.offset,v.color=null!==(l=i.color)&&void 0!==l?l:v.color,v.lineSeparation=null!==(c=i.lineSeparation)&&void 0!==c?c:v.lineSeparation,v.letterSpacing=null!==(u=i.letterSpacing)&&void 0!==u?u:v.letterSpacing,v.bitmapSize=null!==(p=i.bitmapSize)&&void 0!==p?p:v.bitmapSize,v.charRanges=null!==(d=i.charRanges)&&void 0!==d?d:v.charRanges,v.smooth=null!==(f=i.smooth)&&void 0!==f?f:v.smooth,v.bitmapOffset=null!==(m=i.bitmapOffset)&&void 0!==m?m:v.bitmapOffset,v.rotation=null!==(y=i.rotation)&&void 0!==y?y:v.rotation,v.opacity=null!==(b=i.opacity)&&void 0!==b?b:v.opacity,v.orientation=null!==(x=i.orientation)&&void 0!==x?x:v.orientation,v.charRanges.length%2!=0)throw new g("TextRenderer.charRanges must be a 2 column matrix");if(v.lineSeparation%2!=0)throw new g("TextRenderer.lineSeparation must be multiple of 2");return v}return a(i,e),i.prototype.start=function(){this.renderData.layer=this.gameObject.layer,this.renderData.ui=this.gameObject.ui,this.renderData.fontFamily=this.fontFamily,this.renderData.fontUrl=this.fontUrl,this.renderData.fontSize=this.fontSize,this.renderData.lineSeparation=this.lineSeparation,this.renderData.letterSpacing=this.letterSpacing,this.renderData.bitmapSize=this.bitmapSize,this.renderData.charRanges=this.charRanges,this.renderData.smooth=this.smooth,this.renderData.bitmapOffset=this.bitmapOffset,this.renderData.orientation=this.orientation,this.renderData.width=this.width,this.renderData.height=this.height},i.prototype.update=function(){this.text&&(this.renderData.text=this.text!==this.lastFrameText?this.crop():this.renderData.text,this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.opacity=this.opacity,t.add(this.renderData.position,this.gameObject.transform.position,this.offset),this.renderManager.addRenderData(this.renderData),this.lastFrameText=this.text)},i.prototype.crop=function(){var t;if(this.fontSize>this.height)return"";for(var e=[],i=0,n=0,r=this.text.split("\n");n<r.length;n++)for(var o=0,a=null!==(t=r[n].match(new RegExp(".{1,"+Math.floor(this.width/(this.fontSize+this.letterSpacing))+"}","g")))&&void 0!==t?t:[""];o<a.length;o++){var s=a[o];if((i+=this.fontSize+this.lineSeparation)>this.height)return e.join("\n");e.push(s)}return e.join("\n")},i}(It),ue=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Mask,e}return a(e,t),e}(P),pe=function(e){function i(i){var n,o,a,s,h=e.call(this)||this;return h.renderManager=jt.getSingleton("RenderManager"),h.offset=new t,h.rotation=new r,h.opacity=1,h.renderData=new ue,h.innerPosition=new t,h.scaledOffset=new t,h.type=Gt.MaskRenderer,h.width=i.width,h.height=i.height,h.color=i.color,h.offset=null!==(n=i.offset)&&void 0!==n?n:h.offset,h.rotation=null!==(o=i.rotation)&&void 0!==o?o:h.rotation,h.opacity=null!==(a=i.opacity)&&void 0!==a?a:h.opacity,h.layer=null!==(s=i.layer)&&void 0!==s?s:h.layer,h}return a(i,e),i.prototype.update=function(){var t;this.renderData.ui=this.gameObject.ui,this.renderData.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.renderData.width=this.width*Math.abs(this.gameObject.transform.scale.x),this.renderData.height=this.height*Math.abs(this.gameObject.transform.scale.y),this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.alpha=this.opacity,this.calculateRenderPosition(),this.renderManager.addRenderData(this.renderData)},i.prototype.calculateRenderPosition=function(){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.renderData.position,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition()},i.prototype.translateRenderPosition=function(){t.subtract(this.innerPosition,this.renderData.position,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData.position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i}(It),de=function(){function e(e,i,n){this._position=new t,this._position.set(e.x,e.y),this._width=i,this._height=n}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e}(),fe=function(){this.position=new t,this.positionInViewport=new t},ge=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return a(e,t),e}(P),me=function(e){function i(i){var n,r,o,a,s,h=e.call(this)||this;return h.renderOrder="center",h.smooth=!1,h.textureCorrection=null,h.tileScale=null!==(n=jt.getConstant("GameConfig").spriteDefaultScale)&&void 0!==n?n:new t(1,1),h.tileWidth=0,h.tileHeight=0,h.orientation=new t(1,1),h.renderManager=jt.getSingleton("RenderManager"),h.tilemapProcessed=!1,h.renderData=new Map,h.cols=[],h.rows=[],h._width=0,h._height=0,h.tiles=[],h._realWidth=0,h._realHeight=0,h.cacheV2=new t,h.allowMultiple=!1,h.tileset=i.tileset,h.tileScale=null!==(r=i.tileScale)&&void 0!==r?r:h.tileScale,h.smooth=null!==(o=i.smooth)&&void 0!==o?o:h.smooth,h.renderOrder=null!==(a=i.renderOrder)&&void 0!==a?a:h.renderOrder,h.textureCorrection=null!==(s=i.textureCorrection)&&void 0!==s?s:h.textureCorrection,h}return a(i,e),i.prototype.start=function(){this.tileWidth=this.tileset.tileWidth*this.tileScale.x*Math.abs(this.gameObject.transform.scale.x),this.tileHeight=this.tileset.tileHeight*this.tileScale.y*Math.abs(this.gameObject.transform.scale.y),this.orientation.set(Math.sign(this.gameObject.transform.scale.x),Math.sign(this.gameObject.transform.scale.y)),this.processTilemap(),this.updatePosition()},i.prototype.update=function(){var t=this;this.renderData.forEach((function(e){return t.renderManager.addRenderData(e)}))},i.prototype.processLayer=function(t){var e=new ge;e.ui=!1,e.alpha=t.alpha,e.image=this.tileset.image,e.layer=this.gameObject.layer,e.smooth=this.smooth,e.tileWidth=this.tileWidth,e.tileHeight=this.tileHeight,e.textureCorrection=this.textureCorrection,e.tintColor=t.tintColor,this.renderData.set(t.layer,e)},i.prototype.processTile=function(t){null!==t.tile&&this.addTileToRenderData(t),this.updateSizeInfo(t.col,t.row)},i.prototype.addTileToRenderData=function(t){if(this.renderData.has(t.layer)){var e=new fe;e.tile=t.tile,e.position.set(this.gameObject.transform.position.x+t.col*this.tileWidth*this.orientation.x+t.offset.x*Math.abs(this.gameObject.transform.scale.x)+this.tileWidth*this.orientation.x/2,this.gameObject.transform.position.y-t.row*this.tileHeight*this.orientation.y-t.offset.y*Math.abs(this.gameObject.transform.scale.y)-this.tileHeight*this.orientation.y/2),e.flipHorizontal=t.flip.h!==this.orientation.x<0,e.flipVertical=t.flip.v!==this.orientation.y<0,this.renderData.get(t.layer).tilesData.push(e)}},i.prototype.updateSizeInfo=function(t,e){this._width=!1===this.cols.includes(t)?this.cols.push(t):this._width,this._height=!1===this.rows.includes(e)?this.rows.push(e):this._height,this._realWidth=this._width*this.tileWidth,this._realHeight=this._height*this.tileHeight},i.prototype.updatePosition=function(){var e=this;this.cacheV2.set(("center"===this.renderOrder?-Math.round(this._realWidth/2):["left-down","left-up"].includes(this.renderOrder)?-this._realWidth:0)*this.orientation.x,("center"===this.renderOrder?Math.round(this._realHeight/2):["right-up","left-up"].includes(this.renderOrder)?this._realHeight:0)*this.orientation.y),this.renderData.forEach((function(i){return i.tilesData.forEach((function(i){t.add(i.position,i.position,e.cacheV2),e.addTileData(i)}))}))},i.prototype.addTileData=function(t){this.tiles.push(new de(t.position,this.tileWidth,this.tileHeight))},Object.defineProperty(i.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realWidth",{get:function(){return this._realWidth},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realHeight",{get:function(){return this._realHeight},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tilesData",{get:function(){return this.tiles},enumerable:!1,configurable:!0}),i}(It),ye=function(t){function e(e){var i,n,r=this;return e.renderOrder=null!==(i=e.renderOrder)&&void 0!==i?i:e.tilemapData.renderorder,(r=t.call(this,e)||this).type=Gt.TiledTilemapRenderer,r.tiledTilemap=e.tilemapData,r.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,r}return a(e,t),e.prototype.processTilemap=function(){var t=this;this.tiledTilemap.layers.forEach((function(e){var i,n,r;!0!==e.visible||null!==t.layerName&&t.layerName!==e.name||(t.renderData.has(e.name)||t.processLayer({layer:e.name,alpha:e.opacity,tintColor:null!==(i=e.tintcolor)&&void 0!==i?i:null}),!0===t.tiledTilemap.infinite?e.chunks.forEach((function(i){var n,r;return t.processChunk(e.name,i,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0})})):t.processChunk(e.name,e,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0}))})),this.tilemapProcessed=!0},e.prototype.processChunk=function(t,e,i){void 0===i&&(i={x:0,y:0});for(var n=0,r=0;r<e.height;r++)for(var o=0;o<e.width;o++){var a=this.tileset.getTile(e.data[n]-1);this.processTile({layer:t,tile:a,col:o+e.x,row:r+e.y,flip:{h:!1,v:!1},offset:i}),n++}},e}(me),be=1,xe=2,ve=3,Me=function(t){function e(e){var i,n,r=t.call(this,e)||this;return r.alpha=1,r.tintColor=null,r.type=Gt.CsvTilemapRenderer,r.tilemapData=e.tilemapData,r.alpha=null!==(i=e.alpha)&&void 0!==i?i:r.alpha,r.tintColor=null!==(n=e.tintColor)&&void 0!==n?n:r.tintColor,r}return a(e,t),e.prototype.processTilemap=function(){var t=this;this.processLayer({layer:"csv",alpha:this.alpha,tintColor:this.tintColor}),this.tilemapData.trim().split("\n").forEach((function(e,i){e.split(",").forEach((function(e,n){var r=parseInt(e.trim()),o=null,a={h:!1,v:!1};if(!1===isNaN(r)){var s=r>999?r%1e3:r,h=Math.round(r/1e3);o=t.tileset.getTile(s),a.h=[be,ve].includes(h),a.v=[xe,ve].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:a,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(me),we=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},_e=function(){function e(e){var i,n;this.image=null,this.offset=new t(0,0),this.tileSpacing=new t(0,0),this._tiles=[],this.image=e.image,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.gridWidth=e.gridWidth,this.gridHeight=e.gridHeight,this.offset=null!==(i=e.offset)&&void 0!==i?i:this.offset,this.tileSpacing=null!==(n=e.spacing)&&void 0!==n?n:this.tileSpacing,this.generateTiles()}return e.prototype.generateTiles=function(){for(var t=0,e=0;e<this.gridHeight;e++)for(var i=0;i<this.gridWidth;i++)this._tiles[t]=new we(i*this.tileWidth+i*this.tileSpacing.x+this.offset.x,e*this.tileHeight+e*this.tileSpacing.y+this.offset.y,this.tileWidth,this.tileHeight),t++},e.prototype.getTile=function(t){return this._tiles[t]?this._tiles[t]:null},Object.defineProperty(e.prototype,"tiles",{get:function(){return this._tiles},enumerable:!1,configurable:!0}),e}(),Oe=function(t){var e,i;this.sprites=[],this.framerate=10,this.loop=!1,this.sprites=t.sprites,this.framerate=null!==(e=t.framerate)&&void 0!==e?e:this.framerate,this.loop=null!==(i=t.loop)&&void 0!==i?i:this.loop},je=function(t){function e(e){var i=t.call(this)||this;return i.timeManager=jt.getSingleton("TimeManager"),i.spriteRenderer=null,i.animations=new Map,i.currentAnimation=null,i.type=Gt.Animator,i.spriteRenderer=e.spriteRenderer,i}return a(e,t),e.prototype.update=function(){null!==this.currentAnimation&&(this.currentAnimation.playFrame(this.timeManager.deltaTime),!0===this.currentAnimation.restarted&&!1===this.currentAnimation.loop?this.stopAnimation():this.spriteRenderer.sprite=this.currentAnimation.sprite)},e.prototype.addAnimation=function(t,e,i){return i&&(e.framerate=i),this.animations.set(t,new Ce(e)),this},e.prototype.playAnimation=function(t){if(!1!==this.active){if(!1===this.animations.has(t))throw new g("Animation with name "+t+" does not exist.");this.currentAnimation=this.animations.get(t)}},e.prototype.stopAnimation=function(){!1!==this.active&&null!==this.currentAnimation&&(this.currentAnimation=null)},e.prototype.isPlayingAnimation=function(t){return this.animations.get(t)&&this.animations.get(t)===this.currentAnimation},e}(St),Ce=function(){function t(t){this._sprite=null,this._restarted=!1,this.currentFrame=0,this.frameTime=0,this._animation=t}return Object.defineProperty(t.prototype,"sprite",{get:function(){return this._sprite},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"restarted",{get:function(){return this._restarted},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loop",{get:function(){return this._animation.loop},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animation",{get:function(){return this._animation},enumerable:!1,configurable:!0}),t.prototype.playFrame=function(t){this._restarted=!1,this.frameTime>=1/this._animation.framerate&&(this.frameTime=0,this.currentFrame=this.currentFrame+1===this._animation.sprites.length?0:this.currentFrame+1,this._restarted=0===this.currentFrame),this._sprite=this._animation.sprites[this.currentFrame],this.frameTime+=t},t}(),Pe=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],Re=function(t){function e(e){var i,n,r;void 0===e&&(e={audio:null,volume:1,loop:!1});var o=t.call(this)||this;return o.volume=1,o.loop=!1,o.audio=null,o.clones=new Map,o._playing=!1,o._paused=!1,o.audioEventHandler=function(t){"ended"===t.type&&(o._playing=!1,o.audio.removeEventListener("ended",o.audioEventHandler))},o.userinputEventHandler=function(){Pe.forEach((function(t){window.removeEventListener(t,o.userinputEventHandler)})),o.audio.play()},o.allowMultiple=!1,o.type=Gt.AudioPlayer,o.audio=null!==(i=e.audio)&&void 0!==i?i:o.audio,o.volume=null!==(n=e.volume)&&void 0!==n?n:o.volume,o.loop=null!==(r=e.loop)&&void 0!==r?r:o.loop,o}return a(e,t),e.prototype.playAudio=function(t,e){void 0===e&&(e=null),!1===this.clones.has(Symbol.for(t.src))&&this.cloneAudio(t);var i=this.clones.get(Symbol.for(t.src));i.currentTime>0&&(i.currentTime=0),i.volume=null!=e?e:this.volume,i.play()},e.prototype.cloneAudio=function(t){var e=t.cloneNode();this.clones.set(Symbol.for(t.src),e)},e.prototype.play=function(){var t=this;if(null!==this.audio&&(!this._playing||!1!==this._paused)){if(this._paused)return this._paused=!1,void this.audio.play();this.audio.volume=this.volume,this.audio.loop=this.loop,this.audio.addEventListener("ended",this.audioEventHandler),this._playing=!0,this.audio.play().then((function(){})).catch((function(){return Pe.forEach((function(e){return window.addEventListener(e,t.userinputEventHandler)}))}))}},e.prototype.stop=function(){this._playing&&(this.audio.pause(),this.audio.currentTime=0,this.audio.removeEventListener("ended",this.audioEventHandler),this._playing=!1,this._paused=!1)},e.prototype.pause=function(){this._playing&&!1===this._paused&&(this.audio.pause(),this._paused=!0)},e.prototype.activeStateChange=function(){!1===this.active&&this.stop()},e.prototype.destroy=function(){this.stop()},e}(St),De=function(e){function i(i){var n,r,o=e.call(this)||this;return o.rigidBodyManager=jt.getSingleton("RigidBodyManager"),o.type=Gt.RigidBody,o.allowMultiple=!1,o.rigidBodyType=i.rigidBodyType,o.data={position:null,gravity:null!==(n=Math.abs(i.gravity))&&void 0!==n?n:10,velocity:new t,layersToCollider:null!==(r=i.layersToCollide)&&void 0!==r?r:[],colliders:[]},o}return a(i,e),Object.defineProperty(i.prototype,"velocity",{get:function(){return this.data.velocity},set:function(t){this.data.velocity.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gravity",{get:function(){return this.data.gravity},set:function(t){this.data.gravity=Math.abs(t)},enumerable:!1,configurable:!0}),i.prototype.start=function(){if(0===this.getColliders().length)throw new g("RigidBody needs at least one Collider with physics");this.data.position=this.gameObject.transform.position},i.prototype.update=function(){this.data.colliders=this.getColliders(),this.rigidBodyType===exports.RigidBodyType.Dynamic&&this.rigidBodyManager.addRigidBodyData(this.data)},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Ht&&e.physics?u(u([],t,!0),e.colliders,!0):t}),[])},i}(St),Se=function(){function e(e){var i,n,r,o,a=this;this._image=null,this._slice=null,this._scale=null!==(i=jt.getConstant("GameConfig").spriteDefaultScale)&&void 0!==i?i:new t(1,1),this._smooth=!1,this._width=null,this._height=null,this._loaded=!1,this._image=e.image,this._slice=null!==(n=e.slice)&&void 0!==n?n:this._slice,null!==this._slice&&(this._width=this._slice.width,this._height=this._slice.height),this._scale=null!==(r=e.scale)&&void 0!==r?r:this._scale,this._smooth=null!==(o=e.smooth)&&void 0!==o?o:this._smooth,this._image.naturalWidth?this.onLoad():this._image.addEventListener("load",(function(){return a.onLoad()}))}return Object.defineProperty(e.prototype,"loaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"slice",{get:function(){return this._slice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"smooth",{get:function(){return this._smooth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e.prototype.onLoad=function(){var t,e;this._width=(null!==(t=this._width)&&void 0!==t?t:this._image.naturalWidth)*this._scale.x,this._height=(null!==(e=this._height)&&void 0!==e?e:this._image.naturalHeight)*this._scale.y,this._loaded=!0},e}(),Te=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return a(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){ht.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,ht.mouse.positionInViewport,1/this.camera.zoom),t.add(this.position,this.position,this.camera.worldSpaceRect.center),t.round(this.position,this.position),console.log("Space position: {x: "+this.position.x+", y: "+this.position.y+"}")),this.mousePressed=ht.mouse.leftButtonPressed},i}(Ut);exports.Animation=Oe,exports.Animator=je,exports.AssetManager=at,exports.AudioPlayer=Re,exports.BallCollider=Jt,exports.BoxCollider=Qt,exports.Camera=Nt,exports.ColliderData=Yt,exports.Component=Dt,exports.ComponentTypes=Gt,exports.CsvTilemapRenderer=Me,exports.DomManager=st,exports.EdgeCollider=oe,exports.GAME_CAMERA_ID="GameCamera",exports.Game=Pt,exports.GameCamera=zt,exports.GameObject=Ut,exports.GameObjectManager=ut,exports.GamepadController=w,exports.GamepadData=_,exports.InputManager=ht,exports.KeyboardController=j,exports.LAYER_DEFAULT="Default",exports.MaskRenderer=pe,exports.MouseController=C,exports.PhysicsComponent=Bt,exports.PolygonCollider=ie,exports.PreRenderComponent=Et,exports.Rectangle=e,exports.RigidBody=De,exports.Rotation=r,exports.Scene=Wt,exports.SceneManager=lt,exports.SpacePointer=Te,exports.Sprite=Se,exports.SpriteRenderer=he,exports.TextRenderer=ce,exports.TiledTilemapRenderer=ye,exports.TilemapCollider=te,exports.Tileset=_e,exports.TimeManager=ct,exports.TouchController=it,exports.Transform=Vt,exports.Vector2=t,exports.between=function(t,e,i){return t>=e&&t<=i},exports.clamp=i,exports.fixedRound=function(t,e){return Math.round(t*(10^e))/(10^e)},exports.random=function(t,e){return Math.floor(Math.random()*(e-t))+t},exports.range=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._x=t,this._y=e}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"magnitude",{get:function(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){this._x=t,this._y=e},t.prototype.copy=function(t){this.set(t.x,t.y)},t.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},t.prototype.clone=function(){return new t(this._x,this._y)},t.prototype.distance=function(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))},t.add=function(t,e,i){return t.set(e.x+i.x,e.y+i.y),t},t.subtract=function(t,e,i){return t.set(e.x-i.x,e.y-i.y),t},t.unit=function(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t},t.normal=function(t,e){return t.set(-e.y,e.x),this.unit(t,t)},t.scale=function(t,e,i){return t.set(e.x*i,e.y*i),t},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.round=function(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t},t}(),e=function(t,e,i){return Math.min(i,Math.max(e,t))},i=function(t,e){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)},n=function(t,e,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n},r=function(t,e,i){return t>=e&&t<=i},o=function(){function e(e,i,n,r){this._position=new t,this._center=new t,this._width=0,this._height=0,this.set(e,i,n,r)}return Object.defineProperty(e.prototype,"x",{get:function(){return this._position.x},set:function(t){this._position.set(t,this._position.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._position.y},set:function(t){this._position.set(this._position.x,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this._position.x+this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._position.y+this._height},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"center",{get:function(){return this._center.set(this.x+this.width/2,this.y+this.height/2),this._center},enumerable:!1,configurable:!0}),e.prototype.set=function(t,e,i,n){this._position.set(t,e),this._width=i,this._height=n},e.prototype.equals=function(t){return this.position.equals(t.position)&&this.width===t.width&&this.height===t.height},e.prototype.updateFromRect=function(t){this.set(t.x,t.y,t.width,t.height)},e.prototype.overlapRectangle=function(t){return this.x1>=t.x&&this.x<=t.x1&&this.y1>=t.y&&this.y<=t.y1},e.prototype.overlapVector=function(t){return r(t.x,this.x,this.x1)&&r(t.y,this.y,this.y1)},e}(),s=function(){function e(e,i){void 0===e&&(e=null),void 0===i&&(i=null),this._degrees=0,this._radians=0,this._direction=new t,e?this.radians=e:i&&(this.degrees=i)}return Object.defineProperty(e.prototype,"degrees",{get:function(){return this._degrees},set:function(t){this._degrees=t,this._radians=t*Math.PI/180,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radians",{get:function(){return this._radians},set:function(t){this._radians=t,this._degrees=180*t/Math.PI,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),e.prototype.updateDirection=function(){this._direction.set(Math.cos(this._radians),Math.sin(this._radians))},e}(),a=function(t,e){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},a(t,e)};function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var c,l=function(){return l=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},l.apply(this,arguments)};function u(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function p(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function d(t,e,i){if(i||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}!function(t){t.Image="Image",t.Audio="Audio",t.Video="Video"}(c||(c={}));var f,g=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},m=function(){function t(){this.assets=[]}return t.prototype.getAssetsLoaded=function(){return this.assets.reduce((function(t,e){return t&&e.loaded}),!0)},t.prototype.loadImage=function(t){var e=this.createAsset(t,c.Image);return e.element=new Image,e.element.crossOrigin="",e.element.src=t,e.element.naturalWidth?e.loaded=!0:e.element.addEventListener("load",(function(){return e.loaded=!0})),e.element},t.prototype.loadAudio=function(t){var e=this.createAsset(t,c.Audio);return e.element=new Audio,e.element.src=t,e.element.duration?e.loaded=!0:e.element.addEventListener("canplaythrough",(function(){return e.loaded=!0})),e.element},t.prototype.getImage=function(t){return this.getAsset(t,c.Image)},t.prototype.getAudio=function(t){return this.getAsset(t,c.Audio)},t.prototype.getAsset=function(t,e){return void 0===e&&(e=null),this.assets.reduce((function(i,n){return n.url!==t||null!==e&&e!==n.type?i:n}),null).element},t.prototype.createAsset=function(t,e){var i=new g;return i.type=e,i.url=t,this.assets.push(i),i},t}(),y=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return h(e,t),e}(Error),x=function(){function e(e,i,n,r){void 0===n&&(n=6),void 0===r&&(r=15),this._bounds=new o(0,0,0,0),this._items=[],this._quadrants=[],this.sw=0,this.se=1,this.nw=2,this.ne=3,this.center=new t,this.childrenWidth=0,this.childrenHeight=0,this.quadsForItem=[],this.level=e,this._bounds.updateFromRect(i),this.maxLevels=n,this.maxItems=r,this.updateCache()}return Object.defineProperty(e.prototype,"bounds",{get:function(){return this._bounds},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"quadrants",{get:function(){return this._quadrants},enumerable:!1,configurable:!0}),e.prototype.updateBounds=function(t){this._bounds.updateFromRect(t),this.updateCache()},e.prototype.clearItems=function(){this._items=[],this._quadrants.forEach((function(t){return t.clearItems()}))},e.prototype.clearQuadrants=function(){this._quadrants.forEach((function(t){return t.clearQuadrants()})),this._quadrants=[]},e.prototype.addItem=function(t){this._quadrants.length>0?this.insertItemIntoChildrenQuads(t):(this._items.push(t),this._items.length>this.maxItems&&this.level<this.maxLevels&&this.splitQuad())},e.prototype.retrieve=function(t){var e=[];this._quadrants.length>0&&this.getChildrenQuadrantForItem(t).forEach((function(i){return e.push.apply(e,i.retrieve(t))})),e.push.apply(e,this._items);var i=e.indexOf(t);return-1!==i&&e.splice(i,1),e},e.prototype.splitQuad=function(){var t=this;this._quadrants=[new o(this.center.x-this.childrenWidth,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new o(this.center.x,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new o(this.center.x-this.childrenWidth,this.center.y,this.childrenWidth,this.childrenHeight),new o(this.center.x,this.center.y,this.childrenWidth,this.childrenHeight)].map((function(i){return new e(t.level+1,i,t.maxLevels,t.maxItems)}));for(var i=0,n=this._items;i<n.length;i++){var r=n[i];this.insertItemIntoChildrenQuads(r)}this._items=[]},e.prototype.getChildrenQuadrantForItem=function(t){if(0===this._quadrants.length)throw new y("Current quadrant does not have quadrant children.");if(this.quadsForItem=[],t.x<=this.center.x&&t.y<=this.center.y&&this.quadsForItem.push(this._quadrants[this.sw]),t.x1>=this.center.x&&t.y<=this.center.y&&this.quadsForItem.push(this._quadrants[this.se]),t.x<=this.center.x&&t.y1>=this.center.y&&this.quadsForItem.push(this._quadrants[this.nw]),t.x1>=this.center.x&&t.y1>=this.center.y&&this.quadsForItem.push(this._quadrants[this.ne]),0===this.quadsForItem.length)throw new y("Item does not fit in any children quadrant");return this.quadsForItem},e.prototype.insertItemIntoChildrenQuads=function(t){this.getChildrenQuadrantForItem(t).forEach((function(e){return e.addItem(t)}))},e.prototype.updateCache=function(){this.center.set(this._bounds.width/2+this._bounds.x,this._bounds.height/2+this._bounds.y),this.childrenWidth=this._bounds.width/2,this.childrenHeight=this._bounds.height/2},e}(),b=function(){function e(e,i,n,r,s){this.collisions=[],this.minBounds=new t,this.maxBounds=new t,this.newBounds=new o(0,0,0,0),this.method=e,this.colliders=[],this.collisionMatrix=s,this.setupQuadTree(i,n,r)}return e.prototype.setupQuadTree=function(t,e,i){i?(this.bounds=i,this.fixedQuadTree=!0):(this.bounds=new o(0,0,0,0),this.fixedQuadTree=!1),this.quadTree=new x(0,this.bounds,t,e)},e.prototype.addCollider=function(t){this.colliders.push(t)},e.prototype.removeCollider=function(t){var e=this.colliders.indexOf(t);-1!==e&&(delete this.colliders[e],this.colliders.splice(e,1))},e.prototype.getCollisionsForCollider=function(t){return this.collisions.filter((function(e){return e.localCollider===t}))},e.prototype.refreshCollisionsForCollider=function(t){-1!==this.colliders.indexOf(t)&&(this.collisions=this.collisions.filter((function(e){return e.localCollider!==t&&e.remoteCollider!==t})),this.narrowPhase(t,this.broadPhase(t)))},e.prototype.clear=function(){this.colliders=[]},e.prototype.update=function(){if(this.collisions=[],0!==this.colliders.length){this.quadTree.clearItems(),this.quadTree.clearQuadrants(),!1===this.fixedQuadTree&&(this.updateNewBounds(),!1===this.newBounds.equals(this.bounds)&&(this.bounds.updateFromRect(this.newBounds),this.quadTree.updateBounds(this.bounds)));for(var t=0,e=this.colliders;t<e.length;t++){var i=e[t];this.quadTree.addItem(i)}this.updateCollisions()}},e.prototype.updateNewBounds=function(){var t=this;this.colliders.forEach((function(e){t.minBounds.set(Math.min(e.x,t.minBounds.x),Math.min(e.y,t.minBounds.y)),t.maxBounds.set(Math.max(e.x1,t.maxBounds.x),Math.max(e.y1,t.maxBounds.y))})),this.newBounds.set(this.minBounds.x,this.minBounds.y,this.maxBounds.x-this.minBounds.x,this.maxBounds.y-this.minBounds.y)},e.prototype.updateCollisions=function(){var t=this;this.colliders.filter((function(t){return t.updateCollisions})).forEach((function(e){return t.narrowPhase(e,t.broadPhase(e))}))},e.prototype.broadPhase=function(t){var e=this;return this.collisionMatrix?this.quadTree.retrieve(t).filter((function(i){return e.collisionMatrix.some((function(e){return e[0]===t.layer&&e[1]===i.layer||e[1]===t.layer&&e[0]===i.layer}))})):this.quadTree.retrieve(t)},e.prototype.narrowPhase=function(t,e){var i=this;e.filter((function(e){return e.id!==t.id})).forEach((function(e){if(!i.isResolved(t,e)){var n=i.method.getCollisionResolution(t.shape,e.shape);null!==n&&i.collisions.push({localCollider:t,remoteCollider:e,resolution:n},{localCollider:e,remoteCollider:t,resolution:{direction:n.displacementDirection,displacementDirection:n.direction,penetration:n.penetration}})}}))},e.prototype.isResolved=function(t,e){for(var i=0,n=this.collisions;i<n.length;i++){var r=n[i];if(r.localCollider===t&&r.remoteCollider===e)return!0}return!1},e}(),v=function(){function t(t,e,i){if(this._canvas=null,!t)throw new y("containerNode cannot be empty or null.");this.containerNode=t,this.gameWidth=e,this.gameHeight=i,this.setupCanvas()}return Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),t.prototype.setupCanvas=function(){this._canvas=document.createElement("canvas"),this._canvas.id="angryPixelGameCanvas",this._canvas.width=Math.floor(this.gameWidth),this._canvas.height=Math.floor(this.gameHeight),this.canvas.tabIndex=0,this._canvas.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this.containerNode.appendChild(this._canvas),this.canvas.focus()},t}();!function(t){t[t.Init=0]="Init",t[t.Start=1]="Start",t[t.Update=2]="Update",t[t.UpdateEngine=3]="UpdateEngine",t[t.UpdateCollider=4]="UpdateCollider",t[t.UpdatePhysics=5]="UpdatePhysics",t[t.UpdateTransform=6]="UpdateTransform",t[t.UpdatePreRender=7]="UpdatePreRender",t[t.UpdateCamera=8]="UpdateCamera",t[t.UpdateRender=9]="UpdateRender",t[t.Destroy=10]="Destroy"}(f||(f={}));var M,w=function(){function t(t,e,i,n,r,o,s){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.renderManager=n,this.inputManager=r,this.gameObjectManager=o,this.sceneManager=s,this.running=!1,this.gameLoopAccumulator=0,this.gameObjects=[],this.components=[]}return t.prototype.start=function(){this.startLoop(!0)},t.prototype.pause=function(){this.running=!1},t.prototype.resume=function(){this.startLoop(!1)},t.prototype.stop=function(){this.running=!1,this.sceneManager.unloadCurrentScene(),this.renderManager.clearCanvas()},t.prototype.startLoop=function(t){this.running||(this.running=!0,t&&this.sceneManager.loadOpeningScene(),this.requestAnimationLoop(window.performance.now()),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate&&this.asyncPhysicsLoop())},t.prototype.requestAnimationLoop=function(t){var e=this;this.running&&(this.timeManager.updateForBrowser(.001*t),this.gameLoopAccumulator+=this.timeManager.browserDeltaTime,this.gameLoopAccumulator>=this.timeManager.minGameDeltatime&&(this.gameLogicIteration(.001*t),this.gameLoopAccumulator-=this.timeManager.minGameDeltatime),this.renderIteration(),window.requestAnimationFrame((function(t){return e.requestAnimationLoop(t)})))},t.prototype.gameLogicIteration=function(t){this.timeManager.updateForGame(t),this.load(),this.physicsManager.clear(),this.dispatchFrameEvent(f.Start),this.inputManager.update(),this.dispatchFrameEvent(f.Update),this.dispatchFrameEvent(f.UpdateEngine),this.dispatchFrameEvent(f.UpdateTransform),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(t),this.dispatchFrameEvent(f.UpdatePreRender),this.sceneManager.update()},t.prototype.renderIteration=function(){this.dispatchFrameEvent(f.UpdatePreRender),this.dispatchFrameEvent(f.UpdateCamera),this.dispatchFrameEvent(f.UpdateRender),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.physicsIteration=function(t){this.timeManager.timeScale<=0||(this.timeManager.updateForPhysics(t),this.dispatchFrameEvent(f.UpdatePhysics),this.dispatchFrameEvent(f.UpdateCollider),this.dispatchFrameEvent(f.UpdateTransform),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear())},t.prototype.asyncPhysicsLoop=function(){var t=this;if(this.running){var e=.001*window.performance.now();document.hidden||this.physicsIteration(e);var i=1/this.timeManager.physicsFramerate-(.001*window.performance.now()-e);window.setTimeout((function(){return t.asyncPhysicsLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.findGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return d(d([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.dispatchFrameEvent=function(t){t!==f.Start&&t!==f.Update||(this.currentScene.dispatch(t),this.gameObjects.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))),this.components.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))},t}(),_=function(){function t(){this.gameObjects=[]}return t.prototype.addGameObject=function(t,e,i,n){var r=new t(n,i);return this.gameObjects.push(r),r.dispatch(f.Init,e),r},t.prototype.findGameObjects=function(t){return t?this.gameObjects.filter((function(e){return e instanceof t})):d([],this.gameObjects,!0)},t.prototype.findGameObjectById=function(t){return this.gameObjects.find((function(e){return e.id===t}))},t.prototype.findGameObject=function(t){return"string"==typeof t?this.gameObjects.find((function(e){return e.name===t})):this.gameObjects.find((function(e){return e instanceof t}))},t.prototype.findGameObjectsByParent=function(t){return this.gameObjects.filter((function(e){return e.parent===t}))},t.prototype.findGameObjectByParent=function(t,e){return"string"==typeof e?this.gameObjects.find((function(i){return i.name===e&&i.parent===t})):this.gameObjects.find((function(i){return i instanceof e&&i.parent===t}))},t.prototype.findGameObjectsByTag=function(t){return this.gameObjects.filter((function(e){return e.tag===t}))},t.prototype.destroyAllGameObjects=function(){var t=this;this.gameObjects.filter((function(t){return!t.keep})).forEach((function(e){return t.destroy(e,!1)}))},t.prototype.destroyGameObject=function(t){this.destroy(t,!0)},t.prototype.destroy=function(t,e){var i=this.gameObjects.indexOf(t);if(-1!==i){var n=this.gameObjects.splice(i,1)[0];e&&this.destroyChildren(n),n.dispatch(f.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){return e.destroyGameObject(t)}))},t}(),C=function(){function t(){var t=this;this.gamepads=new Map,this.eventHandler=function(e){"gamepadconnected"===e.type?t.gamepadConnected(e.gamepad):"gamepaddisconnected"===e.type&&t.gamepadDisconected(e.gamepad)},window.addEventListener("gamepadconnected",this.eventHandler),window.addEventListener("gamepaddisconnected",this.eventHandler)}return t.prototype.getGamepad=function(t){var e;return null!==(e=this.gamepads.get(t))&&void 0!==e?e:null},t.prototype.gamepadConnected=function(t){this.gamepads.set(t.index,new O),this.gamepads.get(t.index).updateFromGamepad(t)},t.prototype.gamepadDisconected=function(t){this.gamepads.delete(t.index)},t.prototype.update=function(){for(var t=0,e=this.getGamepads();t<e.length;t++){var i=e[t];null!==i&&(!1===this.gamepads.has(i.index)&&this.gamepadConnected(i),this.gamepads.get(i.index).updateFromGamepad(i))}},t.prototype.getGamepads=function(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads:[]},t}(),O=function(){function e(){this.buttons=new Map,this.axes=new Map,this._dpadAxes=new t,this._leftStickAxes=new t,this._rightStickAxes=new t}return e.prototype.updateFromGamepad=function(t){var e=this;this._gamepad=t,t.buttons.forEach((function(t,i){return e.buttons.set(i,t.pressed)})),t.axes.forEach((function(t,i){return e.axes.set(i,t)}))},Object.defineProperty(e.prototype,"id",{get:function(){return this._gamepad.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connected",{get:function(){return this._gamepad.connected},enumerable:!1,configurable:!0}),e.prototype.getButtonPressed=function(t){return this.buttons.get(t)},e.prototype.getAxis=function(t){return this.axes.get(t)},Object.defineProperty(e.prototype,"dpadAxes",{get:function(){return this._dpadAxes.set(this.dpadRight?1:this.dpadLeft?-1:0,this.dpadUp?1:this.dpadDown?-1:0),this._dpadAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickAxes",{get:function(){return this._leftStickAxes.set(this.leftStickHorizontal,this.leftStickVertical),this._leftStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickAxes",{get:function(){return this._rightStickAxes.set(this.rightStickHorizontal,this.rightStickVertical),this._rightStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadUp",{get:function(){var t;return null!==(t=this.buttons.get(12))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadDown",{get:function(){var t;return null!==(t=this.buttons.get(13))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadLeft",{get:function(){var t;return null!==(t=this.buttons.get(14))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadRight",{get:function(){var t;return null!==(t=this.buttons.get(15))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomFace",{get:function(){var t;return null!==(t=this.buttons.get(0))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightFace",{get:function(){var t;return null!==(t=this.buttons.get(1))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftFace",{get:function(){var t;return null!==(t=this.buttons.get(2))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topFace",{get:function(){var t;return null!==(t=this.buttons.get(3))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftShoulder",{get:function(){var t;return null!==(t=this.buttons.get(4))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightShoulder",{get:function(){var t;return null!==(t=this.buttons.get(5))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftTrigger",{get:function(){var t;return null!==(t=this.buttons.get(6))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightTrigger",{get:function(){var t;return null!==(t=this.buttons.get(7))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"back",{get:function(){var t;return null!==(t=this.buttons.get(8))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"start",{get:function(){var t;return null!==(t=this.buttons.get(9))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickButton",{get:function(){var t;return null!==(t=this.buttons.get(10))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickButton",{get:function(){var t;return null!==(t=this.buttons.get(11))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(0))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(1))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(2))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(3))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),e.prototype.vibrate=function(t,e,i,n){void 0===t&&(t=200),void 0===e&&(e=.2),void 0===i&&(i=.2),void 0===n&&(n=0),this._gamepad.vibrationActuator&&this._gamepad.vibrationActuator.playEffect(this._gamepad.vibrationActuator.type,{duration:t,weakMagnitude:e,strongMagnitude:i,startDelay:n})},e}(),j=function(){function t(t,e,i,n){this.mouse=t,this.keyboard=e,this.gamepad=i,this.touch=n}return t.prototype.update=function(){this.mouse.update(),this.gamepad.update()},t}(),P=function(){function t(t){var e=this;this.keyPresses=new Map,this.eventHandler=function(t){"keydown"===t.type&&e.keyPresses.set(t.code,!0),"keyup"===t.type&&e.keyPresses.set(t.code,!1)},this.canvas=t,this.canvas.addEventListener("keydown",this.eventHandler),this.canvas.addEventListener("keyup",this.eventHandler)}return t.prototype.isPressed=function(t){var e;return null!==(e=this.keyPresses.get(t))&&void 0!==e&&e},t.prototype.orPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t||null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!1)},t.prototype.andPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t&&null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!0)},t.prototype.isPressedReturn=function(t,e,i){return this.keyPresses.get(t)?e:i},t.prototype.orPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t||null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!1)?e:i},t.prototype.andPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t&&null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!0)?e:i},t}(),R=function(){function e(e){this._leftButtonPressed=!1,this._scrollButtonPressed=!1,this._rightButtonPressed=!1,this._positionInViewport=new t(0,0),this._hasMoved=!1,this.lastPositionInViewport=new t(0,0),this.canvas=e,this.setup()}return Object.defineProperty(e.prototype,"leftButtonPressed",{get:function(){return this._leftButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollButtonPressed",{get:function(){return this._scrollButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightButtonPressed",{get:function(){return this._rightButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),e.prototype.update=function(){!1===this._positionInViewport.equals(this.lastPositionInViewport)?(this._hasMoved=!0,this.lastPositionInViewport.copy(this._positionInViewport)):this._hasMoved=!1},e.prototype.setup=function(){var t=this;this.canvas.addEventListener("mousemove",(function(e){return t.updatePosition(e)})),this.canvas.addEventListener("mousedown",(function(e){return t.updateButtonDown(e)})),this.canvas.addEventListener("mouseup",(function(e){return t.updateButtonUp(e)}))},e.prototype.updateButtonDown=function(t){this.canvas.focus(),t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0===t.button,this._scrollButtonPressed=1===t.button,this._rightButtonPressed=2===t.button},e.prototype.updateButtonUp=function(t){t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0!==t.button&&this._leftButtonPressed,this._scrollButtonPressed=1!==t.button&&this._scrollButtonPressed,this._rightButtonPressed=2!==t.button&&this._rightButtonPressed},e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),this._positionInViewport.set(t.offsetX/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-t.offsetY/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2)},e}();!function(t){t[t.Image=0]="Image",t[t.Text=1]="Text",t[t.Tilemap=2]="Tilemap",t[t.Mask=3]="Mask",t[t.Geometric=4]="Geometric"}(M||(M={}));var D=function(){function e(){this.ui=!1,this.debug=!1,this.layer=null,this._position=new t(0,0),this._positionInViewport=new t(0,0)}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},set:function(t){this._positionInViewport.set(t.x,t.y)},enumerable:!1,configurable:!0}),e}(),S=function(){function t(t,e,i,n){void 0===n&&(n=!1),this.debug=!1,this.renderData=[],this.cameraData=[],this.renderer=t,this.cullingService=e,this.canvasColor=i,this.debug=n}return t.prototype.clearCanvas=function(){this.renderer.clearCanvas(this.canvasColor)},t.prototype.addRenderData=function(t){!1===this.debug&&t.debug||this.renderData.push(t)},t.prototype.addCameraData=function(t){this.cameraData.push(t)},t.prototype.render=function(){var t=this;this.cameraData.sort((function(t,e){return t.depth-e.depth})).forEach((function(e){return t.renderByCamera(e)})),this.clearData()},t.prototype.clearData=function(){this.renderData=[],this.cameraData=[]},t.prototype.renderByCamera=function(t){var e=this;this.orderRendeData(t),this.cullingService.applyCulling(t,this.renderData).forEach((function(i){e.updateFromCameraViewport(t,i),e.renderer.render(t,i)}))},t.prototype.orderRendeData=function(t){this.renderData.sort((function(e,i){return t.layers.indexOf(e.layer)-t.layers.indexOf(i.layer)}))},t.prototype.updateFromCameraViewport=function(t,e){var i=this;!0!==e.ui?e.type===M.Tilemap?e.tilesToRender.forEach((function(e){return i.setPositionInViewport(t,e)})):this.setPositionInViewport(t,e):e.positionInViewport=e.position},t.prototype.setPositionInViewport=function(t,e){e.positionInViewport.set(Math.round(e.position.x-t.worldSpaceRect.x-t.worldSpaceRect.width/2),Math.round(e.position.y-t.worldSpaceRect.y-t.worldSpaceRect.height/2))},t}(),A="undefined"!=typeof Float32Array?Float32Array:Array;function T(){var t=new A(16);return A!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function B(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function F(t,e,i){var n,r,o,s,a,h,c,l,u,p,d,f,g=i[0],m=i[1],y=i[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*y+e[12],t[13]=e[1]*g+e[5]*m+e[9]*y+e[13],t[14]=e[2]*g+e[6]*m+e[10]*y+e[14],t[15]=e[3]*g+e[7]*m+e[11]*y+e[15]):(n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],c=e[6],l=e[7],u=e[8],p=e[9],d=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=h,t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=n*g+a*m+u*y+e[12],t[13]=r*g+h*m+p*y+e[13],t[14]=o*g+c*m+d*y+e[14],t[15]=s*g+l*m+f*y+e[15]),t}function E(t,e,i){var n=i[0],r=i[1],o=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function I(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],s=e[1],a=e[2],h=e[3],c=e[4],l=e[5],u=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+c*n,t[1]=s*r+l*n,t[2]=a*r+u*n,t[3]=h*r+p*n,t[4]=c*r-o*n,t[5]=l*r-s*n,t[6]=u*r-a*n,t[7]=p*r-h*n,t}function V(t,e,i,n,r,o,s){var a=1/(e-i),h=1/(n-r),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(r+n)*h,t[14]=(s+o)*c,t[15]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var U,L=function(t){var e=/^#?([a-f\d]{2})?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[2],16)/256,g:parseInt(e[3],16)/256,b:parseInt(e[4],16)/256,a:void 0!==e[1]?parseInt(e[1],16)/256:1}:null},G=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=T(),this.modelMatrix=T(),this.textureMatrix=T(),this.posVertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.texVertices=new Float32Array([0,1,0,0,1,1,1,1,0,0,1,0])}return t.prototype.render=function(t,e,i,n){var r;if("image"!==n&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.posVertices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.texVertices,this.gl.STATIC_DRAW)),this.modelMatrix=B(this.modelMatrix),F(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),I(this.modelMatrix,this.modelMatrix,i.rotation),E(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=B(this.textureMatrix),i.slice&&(F(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),E(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=B(this.projectionMatrix),V(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"image"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var o=L(i.tintColor),s=o.r,a=o.g,h=o.b,c=o.a;this.gl.uniform4f(this.programManager.tintColorUniform,s,a,h,c)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,i.maskColor?1:0),i.maskColor){var l=L(i.maskColor);s=l.r,a=l.g,h=l.b;this.gl.uniform4f(this.programManager.maskColorUniform,s,a,h,i.alpha),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(r=i.maskColorMix)&&void 0!==r?r:0)}this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}(),k=function(){function t(t){this.shaderLoader=t}return t.prototype.create=function(t,e,i){var n=t.createProgram(),r=this.shaderLoader.load(t,t.VERTEX_SHADER,e),o=this.shaderLoader.load(t,t.FRAGMENT_SHADER,i);return this.link(t,n,r,o),n},t.prototype.link=function(t,e,i,n){t.attachShader(e,i),t.attachShader(e,n),t.linkProgram(e);var r=t.LINK_STATUS;if(!t.getProgramParameter(e,r)){var o=t.getProgramInfoLog(e);throw t.deleteProgram(e),new y("Unable to initialize the Program: "+o)}},t}(),z=function(){function t(){}return t.prototype.load=function(t,e,i){var n=t.createShader(e);t.shaderSource(n,i),t.compileShader(n);var r=t.COMPILE_STATUS;if(!t.getShaderParameter(n,r)){var o=t.getShaderInfoLog(n);throw t.deleteShader(n),new y("Unable to initialize the shader program: "+o)}return n},t}(),W=function(){function t(t,e){this.gl=e.getContext(t)}return t.prototype.createFromImage=function(t,e,i){var n=this;return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),t.naturalWidth?this.create(t,i,e):t.addEventListener("load",(function(){return n.create(t,i,e)})),i},t.prototype.createFromCanvas=function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),this.create(t,i,e),i},t.prototype.create=function(t,e,i){void 0===i&&(i=!0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),!1===i?(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST)):(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR)),this.gl.bindTexture(this.gl.TEXTURE_2D,null)},t}();!function(t){t.LegacyWebGL="webgl",t.WebGL2="webgl2"}(U||(U={}));var H,Y=function(){function t(t,e,i,n,r,o,s,a,h,c){this.canvas=e,this.gl=this.canvas.getContext(t),i.loadProgram(),this.textureManager=n,this.imageRenderer=o,this.tilemapRenderer=s,this.textRenderer=a,this.geometricRenderer=h,this.maskRenderer=c,this.fontAtlasFactory=r}return t.prototype.clearCanvas=function(t){var e=L(t);this.gl.clearColor(e.r,e.g,e.b,e.a),this.gl.clear(this.gl.COLOR_BUFFER_BIT)},t.prototype.render=function(t,e){e.type===M.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===M.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===M.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===M.Geometric&&(this.geometricRenderer.render(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===M.Mask&&(this.renderMask(t,e),this.lastRender="mask")},t.prototype.renderImage=function(t,e){this.imageRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderTilemap=function(t,e){this.tilemapRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderText=function(t,e){this.fontAtlasFactory.loadingFontAtlas(e.fontFamily)||(this.fontAtlasFactory.hasFontAtlas(e.fontFamily)?this.fontAtlasLoaded(this.fontAtlasFactory.getFontAtlas(e.fontFamily),t,e):this.fontAtlasFactory.asyncCreate(e.charRanges,e.fontFamily,e.fontUrl,e.bitmapSize))},t.prototype.renderMask=function(t,e){this.maskRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,e,this.lastRender)},t.prototype.fontAtlasLoaded=function(t,e,i){this.textRenderer.render(!0===i.ui?e.originalViewportRect:e.viewportRect,this.textureManager.getOrCreateTextureFromCanvas(i.fontFamily,t.canvas,i.smooth),t,i,this.lastRender)},t}(),N=function(){function t(t,e){this.game=t,this.renderManager=e,this.scenes=new Map,this.currentScene=null,this.openingSceneName=null,this.sceneToLoad=null}return t.prototype.getCurrentScene=function(){return this.currentScene},t.prototype.addScene=function(t,e,i,n){var r=this;if(void 0===n&&(n=!1),this.scenes.has(e))throw new y("There is already a scene with the name '"+e+"'");this.scenes.set(e,(function(){var n=new t(e,r.game);return r.currentScene=n,n.dispatch(f.Init,i),n})),!0!==n&&null!==this.openingSceneName||(this.openingSceneName=e)},t.prototype.loadOpeningScene=function(){if(null===this.openingSceneName)throw new y("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new y("Game not initialized.");if(!1===this.scenes.has(t))throw new y("Scene with name "+t+" does not exists");this.sceneToLoad=t},t.prototype.update=function(){null!==this.sceneToLoad&&(this._loadScene(this.sceneToLoad),this.sceneToLoad=null)},t.prototype._loadScene=function(t){this.unloadCurrentScene(),this.scenes.get(t)()},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(f.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager&&this.renderManager.clearData())},t}(),X=[60,120,180,240],q=function(){function t(t){if(this.minGameDeltatime=0,this.minPhysicsDeltaTime=0,this.gameFramerate=60,this.physicsFramerate=180,this.timeScale=1,this.browserDeltaTime=0,this.gameDeltaTime=0,this.unscaledGameDeltaTime=0,this.unscaledPhysicsDeltaTime=0,this.maxDeltaTime=1/15,this.thenForGame=0,this.thenForPhysics=0,this.thenForBrowser=0,!X.includes(t))throw new y("Invalid Physics frame rate. Allowed: ["+X.join(", ")+"]");this.physicsFramerate=t,this.minGameDeltatime=parseFloat((1/this.gameFramerate).toFixed(6)),this.minPhysicsDeltaTime=parseFloat((1/this.physicsFramerate).toFixed(6))}return t.prototype.updateForGame=function(t){this.unscaledGameDeltaTime=Math.min(Math.max(this.minGameDeltatime,t-this.thenForGame),this.maxDeltaTime),this.thenForGame=t},t.prototype.updateForBrowser=function(t){this.browserDeltaTime=Math.min(Math.max(0,t-this.thenForBrowser),this.maxDeltaTime),this.thenForBrowser=t},t.prototype.updateForPhysics=function(t){this.unscaledPhysicsDeltaTime=Math.min(Math.max(0,t-this.thenForPhysics),this.maxDeltaTime),this.thenForPhysics=t},Object.defineProperty(t.prototype,"deltaTime",{get:function(){return this.unscaledGameDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"physicsDeltaTime",{get:function(){return this.unscaledPhysicsDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),t}(),Q=function(){function t(t){this.textures=new Map,this.textureFactory=t}return t.prototype.getTexture=function(t){var e;return null!==(e=this.textures.get(Symbol.for(t)))&&void 0!==e?e:null},t.prototype.getOrCreateTextureFromImage=function(t,e){var i;return void 0===e&&(e=!0),null!==(i=this.textures.get(Symbol.for(t.src)))&&void 0!==i?i:this.createTextureFromImage(t,e)},t.prototype.createTextureFromImage=function(t,e){void 0===e&&(e=!0);var i=this.textureFactory.createFromImage(t,e);return this.textures.set(Symbol.for(t.src),i),i},t.prototype.getOrCreateTextureFromCanvas=function(t,e,i){var n;return void 0===i&&(i=!0),null!==(n=this.textures.get(Symbol.for(t)))&&void 0!==n?n:this.createTextureFromCanvas(t,e,i)},t.prototype.createTextureFromCanvas=function(t,e,i){void 0===i&&(i=!0);var n=this.textureFactory.createFromCanvas(e,i);return this.textures.set(Symbol.for(t),n),n},t}(),K=function(){function t(t,e,i){this.gl=i.getContext(e),this.programFactory=t,this.contextVersion=e}return t.prototype.loadProgram=function(){this.program=this.contextVersion===U.WebGL2?this.programFactory.create(this.gl,"#version 300 es\nprecision mediump float;\n\nin vec2 positionCoords;\nin vec2 textureCoords;\n\nout vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","#version 300 es\nprecision mediump float;\n\nout vec4 fragColor;\n\nin vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n fragColor = vec4(texColor.rgb, u_alpha * texColor.a); \n } else {\n fragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"):this.programFactory.create(this.gl,"precision mediump float;\n\nattribute vec2 positionCoords;\nattribute vec2 textureCoords;\n\nvarying vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","precision mediump float;\n\nvarying vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture2D(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n gl_FragColor = vec4(texColor.rgb, u_alpha * texColor.a);\n } else {\n gl_FragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"),this.positionBuffer=this.gl.createBuffer(),this.textureBuffer=this.gl.createBuffer(),this.positionCoordsAttr=this.gl.getAttribLocation(this.program,"positionCoords"),this.texCoordsAttr=this.gl.getAttribLocation(this.program,"textureCoords"),this.modelMatrixUniform=this.gl.getUniformLocation(this.program,"modelMatrix"),this.projectionMatrixUniform=this.gl.getUniformLocation(this.program,"projectionMatrix"),this.textureMatrixUniform=this.gl.getUniformLocation(this.program,"textureMatrix"),this.renderTextureUniform=this.gl.getUniformLocation(this.program,"u_renderTexture"),this.textureUniform=this.gl.getUniformLocation(this.program,"u_texImage"),this.solidColorUniform=this.gl.getUniformLocation(this.program,"u_solidColor"),this.useTintColorUniform=this.gl.getUniformLocation(this.program,"u_useTintColor"),this.tintColorUniform=this.gl.getUniformLocation(this.program,"u_tintColor"),this.useMaskColorUniform=this.gl.getUniformLocation(this.program,"u_useMaskColor"),this.maskColorUniform=this.gl.getUniformLocation(this.program,"u_maskColor"),this.maskColorMixUniform=this.gl.getUniformLocation(this.program,"u_maskColorMix"),this.alphaUniform=this.gl.getUniformLocation(this.program,"u_alpha"),this.gl.useProgram(this.program),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enableVertexAttribArray(this.positionCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.vertexAttribPointer(this.positionCoordsAttr,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.texCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureBuffer),this.gl.vertexAttribPointer(this.texCoordsAttr,2,this.gl.FLOAT,!1,0,0)},t}(),$=function(){function t(){this.bitmapSize=64,this.fontAtlas=new Map,this.loading=new Map}return t.prototype.hasFontAtlas=function(t){return this.fontAtlas.has(Symbol.for(t))},t.prototype.loadingFontAtlas=function(t){var e;return null!==(e=this.loading.get(Symbol.for(t)))&&void 0!==e&&e},t.prototype.getFontAtlas=function(t){return this.fontAtlas.get(Symbol.for(t))},t.prototype.asyncCreate=function(t,e,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),this.bitmapSize=null!=n?n:this.bitmapSize;var o=new J(e);this.chars=[];for(var s=0;s<t.length;s+=2)for(var a=t[s];a<=t[s+1];a++)this.chars.push(String.fromCharCode(a));o.canvas.width=Math.round(Math.sqrt(this.chars.length))*this.bitmapSize,o.canvas.height=o.canvas.width,null!==i?this.loadFont(e,i).then((function(){return r.renderAtlas(o,e)})):this.renderAtlas(o,e)},t.prototype.loadFont=function(t,e){return u(this,void 0,void 0,(function(){var i;return p(this,(function(n){switch(n.label){case 0:return this.loading.set(Symbol.for(t),!0),[4,(i=new FontFace(t,"url("+e+")")).load()];case 1:return n.sent(),document.fonts.add(i),this.loading.set(Symbol.for(t),!1),[2]}}))}))},t.prototype.renderAtlas=function(t,e){var i=t.canvas.getContext("2d");i.clearRect(0,0,t.canvas.width,t.canvas.height),i.textBaseline="top",i.fillStyle="#000",i.font=this.bitmapSize+"px "+e;for(var n=0,r=0,o=0;o<this.chars.length;o++)i.fillText(this.chars[o],n,r),t.glyphsData.set(this.chars[o],{x:n,y:r,width:this.bitmapSize,height:this.bitmapSize}),(n+=this.bitmapSize)>t.canvas.width-this.bitmapSize&&(n=0,r+=this.bitmapSize);this.fontAtlas.set(Symbol.for(e),t)},t}(),J=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},Z=function(){function e(e,i,n){this.posVertices=[],this.texVertices=[],this.posVerticesSize=new t,this.lastTexture=null,this.gl=i.getContext(e),this.programManager=n,this.projectionMatrix=T(),this.modelMatrix=T(),this.textureMatrix=T()}return e.prototype.render=function(t,e,i,n,r){if(n.text){this.generateTextVertices(i,n),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=B(this.modelMatrix),F(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),I(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=B(this.textureMatrix),E(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=B(this.projectionMatrix),V(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),n.opacity<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.lastTexture===e&&"text"===r||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useTintColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,n.opacity);var o=L(n.color),s=o.r,a=o.g,h=o.b,c=o.a;this.gl.uniform4f(this.programManager.maskColorUniform,s,a,h,c),this.gl.uniform1f(this.programManager.maskColorMixUniform,1),this.gl.uniform1i(this.programManager.useMaskColorUniform,1),this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)}},e.prototype.generateTextVertices=function(t,e){this.posVertices=[],this.texVertices=[];for(var i=this.getDimensions(e),n={x1:-i.width/2,y1:i.height/2-e.fontSize,x2:0,y2:i.height/2},r={x1:0,y1:0,x2:0,y2:0},o=0;o<e.text.length;o++){var s=e.text[o];if("\n"!==s)if(" "!==s){var a=t.glyphsData.get(s);a&&(n.x2=n.x1+e.fontSize,r.x1=a.x+e.bitmapOffset.x,r.y1=a.y+e.bitmapOffset.y,r.x2=a.x+a.width-1,r.y2=a.y+a.height-1,this.posVertices.push(n.x1,n.y1,n.x2,n.y1,n.x1,n.y2,n.x1,n.y2,n.x2,n.y1,n.x2,n.y2),this.texVertices.push(r.x1,r.y2,r.x2,r.y2,r.x1,r.y1,r.x1,r.y1,r.x2,r.y2,r.x2,r.y1)),n.x1+=e.fontSize+e.letterSpacing}else n.x1+=e.fontSize+e.letterSpacing;else n.y1-=e.fontSize+e.lineSeparation,n.y2=n.y1+e.fontSize,n.x1=-i.width/2}this.posVerticesSize.set(i.width,i.height)},e.prototype.getTranslationForOrientation=function(t){return[t.positionInViewport.x+("center"===t.orientation?0:this.posVerticesSize.x/2),t.positionInViewport.y+("rightDown"===t.orientation?-this.posVerticesSize.y/2:"rightUp"===t.orientation?this.posVerticesSize.y:0),0]},e.prototype.getDimensions=function(t){return t.text.split("\n").reduce((function(e,i,n){return e.width=Math.max(e.width,i.length*(t.fontSize+t.letterSpacing)),e.height+=t.fontSize+Math.min(n,1)*t.lineSeparation,e}),{width:0,height:0})},e}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}(H||(H={}));var tt,et=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=M.Geometric,e}return h(e,t),e}(D),it=function(){function t(t,e,i){this.vertices=new Map,this.lastVertices=null,this.lastRender=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=T(),this.modelMatrix=T(),this.textureMatrix=T();var r=2*Math.PI/60;this.circumferenceVertices=new Float32Array(n(1,60,1).reduce((function(t,e){return d(d([],t,!0),[Math.cos(e*r),Math.sin(e*r)],!1)}),[]))}return t.prototype.render=function(t,e,i){switch(this.lastRender=i,e.shape){case H.Polygon:this.renderLines(t,e,this.gl.LINE_LOOP);break;case H.Line:this.renderLines(t,e,this.gl.LINES);break;case H.Circumference:this.renderCircumference(t,e)}},t.prototype.renderLines=function(t,e,i){var n=e.vertexModel,r=e.positionInViewport,o=e.angle,s=e.color,a=this.generateVerticesKey(n);!1===this.vertices.has(a)&&this.vertices.set(a,new Float32Array(this.generatePolygonVertices(n)));var h=this.vertices.get(a);this.lastVertices===a&&"geometric"===this.lastRender||(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW)),this.lastVertices=a,this.modelMatrix=B(this.modelMatrix),F(this.modelMatrix,this.modelMatrix,[r.x,r.y,0]),I(this.modelMatrix,this.modelMatrix,o),this.projectionMatrix=B(this.projectionMatrix),V(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var c=L(s),l=c.r,u=c.g,p=c.b,d=c.a;this.gl.uniform4f(this.programManager.solidColorUniform,l,u,p,d),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(i,0,h.length/2)},t.prototype.generateVerticesKey=function(t){return Symbol.for(t.reduce((function(t,e){return""+t+e.x+e.y}),t.length.toString()))},t.prototype.generatePolygonVertices=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i].x,t[i].y);return e},t.prototype.renderCircumference=function(t,e){var i=e.radius,n=e.positionInViewport,r=e.color;this.lastVertices=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),this.modelMatrix=B(this.modelMatrix),F(this.modelMatrix,this.modelMatrix,[n.x,n.y,0]),E(this.modelMatrix,this.modelMatrix,[i,i,1]),this.projectionMatrix=B(this.projectionMatrix),V(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var o=L(r),s=o.r,a=o.g,h=o.b,c=o.a;this.gl.uniform4f(this.programManager.solidColorUniform,s,a,h,c),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(this.gl.LINE_LOOP,0,this.circumferenceVertices.length/2)},t}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}(tt||(tt={}));var nt,rt=function(){function t(t,e){this.circumferenceResolver=t,this.satResolver=e}return t.prototype.getCollisionResolution=function(t,e){return t.type===tt.Circumference&&e.type===tt.Circumference?this.circumferenceResolver.resolve(t,e):this.satResolver.resolve(t,e)},t}(),ot=function(){function e(e){var i=this;this._touching=!1,this._positionInViewport=new t(0,0),this._radius=new t(0,0),this.eventHandler=function(t){"touchstart"===t.type&&(i._touching=!0,i.updatePosition(t)),"touchmove"===t.type&&i.updatePosition(t),"touchend"!==t.type&&"touchcancel"!==t.type||(i._touching=!1)},this.canvas=e,this.canvas.addEventListener("touchstart",this.eventHandler),this.canvas.addEventListener("touchend",this.eventHandler),this.canvas.addEventListener("touchcancel",this.eventHandler),this.canvas.addEventListener("touchmove",this.eventHandler)}return Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touching",{get:function(){return this._touching},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},enumerable:!1,configurable:!0}),e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),0!==t.targetTouches.length&&(this._positionInViewport.set((t.targetTouches[0].clientX-this.canvas.offsetLeft)/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-(t.targetTouches[0].clientY-this.canvas.offsetTop)/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2),this._radius.set(t.targetTouches[0].radiusX,t.targetTouches[0].radiusY))},e}(),st=function(){function t(t,e,i){this.AABBResolver=t,this.circumferenceAABBResolver=e,this.circumferenceResolver=i}return t.prototype.getCollisionResolution=function(t,e){return t.type===tt.Polygon&&e.type===tt.Polygon?this.AABBResolver.resolve(t,e):t.type===tt.Circumference&&e.type===tt.Polygon?this.circumferenceAABBResolver.resolve(t,e):t.type===tt.Polygon&&e.type===tt.Circumference?this.circumferenceAABBResolver.resolve(e,t,!0):t.type===tt.Circumference&&e.type===tt.Circumference?this.circumferenceResolver.resolve(t,e):null},t}(),at=function(){function t(){}return t.prototype.applyCulling=function(t,e){var i=this;return e.filter((function(e){if(!1===t.layers.includes(e.layer))return!1;var n=e.ui?t.viewportRect:t.worldSpaceRect;switch(e.type){case M.Image:return i.cullSprite(n,e);case M.Tilemap:return i.cullTilemap(n,e);case M.Geometric:return i.cullGeometric(n,e);case M.Text:return i.cullText(n,e);case M.Mask:return i.cullSprite(n,e)}}))},t.prototype.cullSprite=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.cullTilemap=function(t,e){var i=this;return e.tilesToRender=e.tilesData.filter((function(n){return i.isTargetVisible(t,{x:n.position.x-e.tileWidth/2,x1:n.position.x+e.tileWidth/2,y:n.position.y-e.tileHeight/2,y1:n.position.y+e.tileHeight/2})})),e.tilesData.length>0},t.prototype.cullGeometric=function(t,e){return this.isTargetVisible(t,e.boundingBox)},t.prototype.cullText=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.isTargetVisible=function(t,e){return t.x1>=e.x&&t.x<=e.x1&&t.y1>=e.y&&t.y<=e.y1},t}(),ht=function(){function t(t,e,i){this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.p={x1:0,y1:0,x2:0,y2:0},this.t={x1:0,y1:0,x2:0,y2:0},this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=T(),this.modelMatrix=T(),this.textureMatrix=T()}return t.prototype.render=function(t,e,i,n){if(this.generateVertices(i),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=B(this.modelMatrix),this.textureMatrix=B(this.textureMatrix),E(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=B(this.projectionMatrix),V(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"tilemap"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useMaskColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var r=L(i.tintColor),o=r.r,s=r.g,a=r.b,h=r.a;this.gl.uniform4f(this.programManager.tintColorUniform,o,s,a,h)}this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)},t.prototype.generateVertices=function(t){var e=this;this.posVertices=[],this.texVertices=[],t.tilesToRender.forEach((function(i){var n,r;e.p.x1=i.positionInViewport.x-t.tileWidth/2,e.p.x2=i.positionInViewport.x+t.tileWidth/2,e.p.y1=i.positionInViewport.y-t.tileHeight/2,e.p.y2=i.positionInViewport.y+t.tileHeight/2,e.posVertices.push(e.p.x1,e.p.y1,e.p.x2,e.p.y1,e.p.x1,e.p.y2,e.p.x1,e.p.y2,e.p.x2,e.p.y1,e.p.x2,e.p.y2),e.t.x1=i.tile.x,e.t.y1=i.tile.y,e.t.x2=i.tile.x+i.tile.width-(null!==(n=t.textureCorrection)&&void 0!==n?n:0),e.t.y2=i.tile.y+i.tile.height-(null!==(r=t.textureCorrection)&&void 0!==r?r:0),e.texVertices.push(e.t.x1,e.t.y2,e.t.x2,e.t.y2,e.t.x1,e.t.y1,e.t.x1,e.t.y1,e.t.x2,e.t.y2,e.t.x2,e.t.y1)}))},t}(),ct=function(){function t(){}return t.initialize=function(t){this.assetManager=t},t.getAssetsLoaded=function(){return this.assetManager.getAssetsLoaded()},t.loadImage=function(t){return this.assetManager.loadImage(t)},t.loadAudio=function(t){return this.assetManager.loadAudio(t)},t.getImage=function(t){return this.assetManager.getImage(t)},t.getAudio=function(t){return this.assetManager.getAudio(t)},t.assetManager=null,t}(),lt=function(){function t(){}return t.initialize=function(t){this.domManager=t},Object.defineProperty(t,"gameWidth",{get:function(){return this.domManager.canvas.width},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gameHeight",{get:function(){return this.domManager.canvas.height},enumerable:!1,configurable:!0}),Object.defineProperty(t,"canvas",{get:function(){return this.domManager.canvas},enumerable:!1,configurable:!0}),t.domManager=null,t}(),ut=function(){function t(){}return t.initialize=function(t){this.inputManager=t},Object.defineProperty(t,"mouse",{get:function(){return this.inputManager.mouse},enumerable:!1,configurable:!0}),Object.defineProperty(t,"keyboard",{get:function(){return this.inputManager.keyboard},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gamepad",{get:function(){return this.inputManager.gamepad},enumerable:!1,configurable:!0}),Object.defineProperty(t,"touch",{get:function(){return this.inputManager.touch},enumerable:!1,configurable:!0}),t.inputManager=null,t}(),pt=function(){function t(){}return t.initialize=function(t){this.sceneManager=t},t.loadScene=function(t){this.sceneManager.loadScene(t)},t.getCurrentSceneName=function(){return this.sceneManager.currentSceneName},t.loadOpeningScene=function(){this.sceneManager.loadOpeningScene()},t.sceneManager=null,t}(),dt=function(){function t(){}return t.initialize=function(t){this.timeManager=t},Object.defineProperty(t,"deltaTime",{get:function(){return this.timeManager.deltaTime},enumerable:!1,configurable:!0}),t.getTimeScale=function(){return this.timeManager.timeScale},t.setTimeScale=function(t){this.timeManager.timeScale=t},Object.defineProperty(t,"unscaledDeltaTime",{get:function(){return this.timeManager.unscaledGameDeltaTime},enumerable:!1,configurable:!0}),Object.defineProperty(t,"physicsDeltaTime",{get:function(){return this.timeManager.physicsDeltaTime},enumerable:!1,configurable:!0}),Object.defineProperty(t,"browserDeltaTime",{get:function(){return this.timeManager.browserDeltaTime},enumerable:!1,configurable:!0}),t.timeManager=null,t}(),ft=function(){function t(){}return t.initialize=function(t){this.manager=t},t.addGameObject=function(t,e,i,n){return this.manager.addGameObject(t,e,i,n)},t.findAllGameObjects=function(){return this.manager.findGameObjects()},t.findGameObjects=function(t){return this.manager.findGameObjects(t)},t.findGameObject=function(t){return this.manager.findGameObject(t)},t.findGameObjectsByParent=function(t){return this.manager.findGameObjectsByParent(t)},t.findGameObjectByParent=function(t,e){return this.manager.findGameObjectByParent(t,e)},t.findGameObjectsByTag=function(t){return this.manager.findGameObjectsByTag(t)},t.destroyGameObject=function(t){this.manager.destroyGameObject(t)},t}(),gt=function(){function t(t,e,i){this.vertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=T(),this.modelMatrix=T(),this.textureMatrix=T()}return t.prototype.render=function(t,e,i){"mask"!==i&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW)),this.modelMatrix=B(this.modelMatrix),F(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),I(this.modelMatrix,this.modelMatrix,e.rotation),E(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=B(this.projectionMatrix),V(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),e.alpha<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var n=L(e.color),r=n.r,o=n.g,s=n.b,a=n.a;this.gl.uniform4f(this.programManager.solidColorUniform,r,o,s,a),this.gl.uniform1f(this.programManager.alphaUniform,e.alpha),this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}();exports.RigidBodyType=void 0,(nt=exports.RigidBodyType||(exports.RigidBodyType={}))[nt.Static=0]="Static",nt[nt.Dynamic=1]="Dynamic",nt[nt.Kinematic=2]="Kinematic";var mt,yt=function(){function e(e){this.collisionManager=e,this.rigidBodyData=[],this.cacheVelocity=new t,this.cacheDisplacement=new t,this.cacheNewDisplacement=0}return e.prototype.addRigidBodyData=function(e){e.cacheVelocity?e.cacheVelocity.set(0,0):e.cacheVelocity=new t,this.rigidBodyData.push(e)},e.prototype.removeRigidBodyData=function(t){var e=this.rigidBodyData.indexOf(t);-1!==e&&(delete this.rigidBodyData[e],this.rigidBodyData.splice(e,1))},e.prototype.update=function(t){var e=this;this.rigidBodyData.forEach((function(i){i.type===exports.RigidBodyType.Dynamic?e.dynamicUpdate(i,t):i.type===exports.RigidBodyType.Kinematic&&e.kinematicUpdate(i,t)}))},e.prototype.dynamicUpdate=function(t,e){this.applyGravity(t,e),this.applyVelocity(t,e,"x"),this.applyReposition(t,"x",!0),this.applyVelocity(t,e,"y"),this.applyReposition(t,"y",!0)},e.prototype.kinematicUpdate=function(e,i){t.add(e.position,e.position,t.scale(this.cacheVelocity,e.velocity,i))},e.prototype.applyGravity=function(t,e){t.gravity>0&&(t.velocity.y-=t.gravity*e)},e.prototype.applyVelocity=function(e,i,n){var r=this;this.cacheVelocity.set(0,0),this.cacheVelocity[n]=(0!==e.cacheVelocity[n]?e.cacheVelocity[n]:e.velocity[n])*i,t.add(e.position,e.position,this.cacheVelocity),e.colliders.forEach((function(e){t.add(e.shape.position,e.shape.position,r.cacheVelocity),e.shape.update(),r.collisionManager.refreshCollisionsForCollider(e)}))},e.prototype.applyReposition=function(e,i,n){var r=this;this.cacheCollisions=this.getCollisions(e),0!==this.cacheCollisions.length&&(this.cacheDisplacement.set(0,0),this.cacheCollisions.forEach((function(t){r.cacheNewDisplacement=t.resolution.displacementDirection[i]*t.resolution.penetration,r.cacheDisplacement[i]=Math.abs(r.cacheDisplacement[i])>Math.abs(r.cacheNewDisplacement)?r.cacheDisplacement[i]:r.cacheNewDisplacement})),this.cacheDisplacement.magnitude<=0||(t.add(e.position,e.position,this.cacheDisplacement),e.colliders.forEach((function(e){t.add(e.shape.position,e.shape.position,r.cacheDisplacement),e.shape.update(),r.collisionManager.refreshCollisionsForCollider(e)})),n&&0!==this.cacheDisplacement[i]&&Math.sign(this.cacheDisplacement[i])!==Math.sign(e.velocity[i])&&(e.cacheVelocity[i]=e.velocity[i],e.velocity[i]=0)))},e.prototype.getCollisions=function(t){var e=this;return t.colliders.reduce((function(t,i){return t.push.apply(t,e.collisionManager.getCollisionsForCollider(i).filter((function(t){return t.remoteCollider.physics&&t.remoteCollider.rigidBody}))),t}),[])},e.prototype.clear=function(){this.rigidBodyData=[]},e}(),xt=function(){function e(){this.direction=new t,this.displacementDirection=new t}return e.prototype.resolve=function(e,i){var n=e.boundingBox,r=i.boundingBox;return this.overlapX=Math.min(n.x1,r.x1)-Math.max(n.x,r.x),this.overlapY=Math.min(n.y1,r.y1)-Math.max(n.y,r.y),this.overlapX<0||this.overlapY<0?null:(this.direction.set(Math.sign(r.x1-n.x1),Math.sign(r.y1-n.y1)),this.overlapY<this.overlapX?(this.minOverlap=this.overlapY,this.displacementDirection.set(0,-this.direction.y),this.preventContainment(n.y,n.y1,r.y,r.y1)):(this.minOverlap=this.overlapX,this.displacementDirection.set(-this.direction.x,this.overlapY===this.overlapX?-this.direction.y:0),this.preventContainment(n.x,n.x1,r.x,r.x1)),t.unit(this.displacementDirection,this.displacementDirection),{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:t.scale(new t,this.displacementDirection,-1)})},e.prototype.preventContainment=function(e,i,n,r){if(e>n&&i<r||n>e&&r<i){var o=Math.abs(e-n),s=Math.abs(i-r);o<s?this.minOverlap+=o:(this.minOverlap+=s,t.scale(this.displacementDirection,this.displacementDirection,-1))}},e}(),bt=function(){function i(){this.closestPoint=new t,this.distance=new t,this.direction=new t}return i.prototype.resolve=function(i,n,r){return void 0===r&&(r=!1),this.closestPoint.set(e(i.position.x,n.boundingBox.x,n.boundingBox.x1),e(i.position.y,n.boundingBox.y,n.boundingBox.y1)),t.subtract(this.distance,this.closestPoint,i.position),this.distance.magnitude>i.radius?null:(t.unit(this.direction,this.distance),{penetration:i.radius-this.distance.magnitude,direction:r?t.scale(new t,this.direction,-1):this.direction.clone(),displacementDirection:r?this.direction.clone():t.scale(new t,this.direction,-1)})},i}(),vt=function(){function e(){this.distance=new t,this.direction=new t}return e.prototype.resolve=function(e,i){return t.subtract(this.distance,i.position,e.position),this.distance.magnitude>e.radius+i.radius?null:(t.unit(this.direction,this.distance),{penetration:e.radius+i.radius-this.distance.magnitude,direction:this.direction.clone(),displacementDirection:t.scale(new t,this.direction,-1)})},e}(),Mt=function(){function e(){this.projA={min:0,max:0},this.projB={min:0,max:0},this.displacementDirection=new t,this.distance=new t(1/0,1/0),this.cache=new t}return e.prototype.resolve=function(e,i){this.currentOverlap=null,this.minOverlap=null,e.type===tt.Circumference?this.setCircumferenceAxis(e,i):i.type===tt.Circumference&&this.setCircumferenceAxis(i,e),this.axes=d(d([],e.projectionAxes,!0),i.projectionAxes,!0);for(var n=0;n<this.axes.length;n++){if(e.type===tt.Circumference?this.setCircumferenceVertices(e,this.axes[n]):i.type===tt.Circumference&&this.setCircumferenceVertices(i,this.axes[n]),this.projectShapeOntoAxis(this.projA,e,this.axes[n]),this.projectShapeOntoAxis(this.projB,i,this.axes[n]),this.currentOverlap=Math.min(this.projA.max,this.projB.max)-Math.max(this.projA.min,this.projB.min),this.currentOverlap<0)return null;this.preventContainment(n),(this.currentOverlap<this.minOverlap||null===this.minOverlap)&&(this.minOverlap=this.currentOverlap,this.displacementDirection.copy(this.axes[n]),this.projA.max<this.projB.max&&t.scale(this.displacementDirection,this.displacementDirection,-1))}return{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:t.scale(new t,this.displacementDirection,-1)}},e.prototype.projectShapeOntoAxis=function(e,i,n){return e.min=t.dot(n,i.vertices[0]),e.max=e.min,i.vertices.forEach((function(i){e.min=Math.min(t.dot(n,i),e.min),e.max=Math.max(t.dot(n,i),e.max)})),e},e.prototype.preventContainment=function(e){if(this.projA.max>this.projB.max&&this.projA.min<this.projB.min||this.projA.max<this.projB.max&&this.projA.min>this.projB.min){var i=Math.abs(this.projA.min-this.projB.min),n=Math.abs(this.projA.max-this.projB.max);i<n?this.currentOverlap+=i:(this.currentOverlap+=n,t.scale(this.axes[e],this.axes[e],-1))}},e.prototype.setCircumferenceAxis=function(e,i){var n=this;this.distance.set(1/0,1/0),i.vertices.forEach((function(i){t.subtract(n.cache,i,e.position),n.cache.magnitude<n.distance.magnitude&&n.distance.copy(n.cache)})),t.unit(e.projectionAxes[0],this.distance)},e.prototype.setCircumferenceVertices=function(e,i){t.add(e.vertices[0],e.position,t.scale(this.cache,t.unit(this.cache,i),-e.radius)),t.add(e.vertices[1],e.position,t.scale(this.cache,t.unit(this.cache,i),e.radius))},e}(),wt=function(){function t(t,e,i,n,r){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.gameObjectManager=n,this.sceneManager=r,this.running=!1,this.gameObjects=[],this.components=[]}return t.prototype.start=function(){this.startLoop(!0)},t.prototype.pause=function(){this.running=!1},t.prototype.resume=function(){this.startLoop(!1)},t.prototype.stop=function(){this.running=!1,this.sceneManager.unloadCurrentScene()},t.prototype.startLoop=function(t){this.running||(this.running=!0,t&&this.sceneManager.loadOpeningScene(),this.asyncGameLoop(),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate&&this.asyncPhysicsLoop())},t.prototype.gameLogicIteration=function(t){this.timeManager.updateForGame(t),this.load(),this.physicsManager.clear(),this.dispatchFrameEvent(f.Start),this.dispatchFrameEvent(f.Update),this.dispatchFrameEvent(f.UpdateEngine),this.dispatchFrameEvent(f.UpdateTransform),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(t),this.sceneManager.update()},t.prototype.physicsIteration=function(t){this.timeManager.timeScale<=0||(this.timeManager.updateForPhysics(t),this.dispatchFrameEvent(f.UpdatePhysics),this.dispatchFrameEvent(f.UpdateCollider),this.dispatchFrameEvent(f.UpdateTransform),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear())},t.prototype.asyncGameLoop=function(){var t=this;if(this.running){var e=process.uptime();this.gameLogicIteration(e);var i=1/this.timeManager.gameFramerate-(process.uptime()-e);setTimeout((function(){return t.asyncGameLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.asyncPhysicsLoop=function(){var t=this;if(this.running){var e=process.uptime();this.physicsIteration(e);var i=1/this.timeManager.physicsFramerate-(process.uptime()-e);setTimeout((function(){return t.asyncPhysicsLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.findGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return d(d([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.dispatchFrameEvent=function(t){t!==f.Start&&t!==f.Update||(this.currentScene.dispatch(t),this.gameObjects.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))),this.components.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))},t}(),_t=function(t,e){if(e.collisions.method===exports.CollisionMethodConfig.AABB)t.add("CollisionMethod",(function(){return new st(new xt,new bt,new vt)}));else{if(e.collisions.method!==exports.CollisionMethodConfig.SAT)throw new y("Invalid collision method.");t.add("CollisionMethod",(function(){return new rt(new vt,new Mt)}))}t.add("CollisionManager",(function(){return new b(t.getSingleton("CollisionMethod"),e.collisions.quadMaxLevel,e.collisions.collidersPerQuad,e.collisions.quadTreeBounds,e.collisions.collisionMatrix)})),t.add("RigidBodyManager",(function(){return new yt(t.getSingleton("CollisionManager"))}))},Ct=function(t,e){var i=t.getSingleton("DomManager"),n=Pt();if(null===n)throw new y("WebGL not suported in your browser.");Ot(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")"),t.add("FontAtlasFactory",(function(){return new $})),t.add("CullingService",(function(){return new at})),t.add("RenderManager",(function(){return new S(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},Ot=function(t,e,i){e.add("ShaderLoader",(function(){return new z})),e.add("ProgramFactory",(function(){return new k(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new K(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new W(t,i.canvas)})),e.add("TextureManager",(function(){return new Q(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new G(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new Z(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new it(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new ht(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new gt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new Y(t,i.canvas,e.getSingleton("ProgramManager"),e.getSingleton("TextureManager"),e.getSingleton("FontAtlasFactory"),e.getSingleton("WebGLImageRenderer"),e.getSingleton("WebGLTilemapRenderer"),e.getSingleton("WebGLTextRenderer"),e.getSingleton("WebGLGeometricRenderer"),e.getSingleton("WebGLMaskRenderer"))}))},jt=function(t){var e=t.getSingleton("DomManager");t.add("InputManager",(function(){return new j(new R(e.canvas),new P(e.canvas),new C,new ot(e.canvas))}))},Pt=function(){return null!==document.createElement("canvas").getContext(U.WebGL2)?U.WebGL2:null!==document.createElement("canvas").getContext(U.LegacyWebGL)?U.LegacyWebGL:null},Rt=function(t,e){e.headless||(ct.initialize(t.getSingleton("AssetManager")),lt.initialize(t.getSingleton("DomManager")),ut.initialize(t.getSingleton("InputManager"))),pt.initialize(t.getSingleton("SceneManager")),dt.initialize(t.getSingleton("TimeManager")),ft.initialize(t.getSingleton("GameObjectManager"))},Dt=new(function(){function t(){this.instances=new Map,this.constructors=new Map,this.constants=new Map}return t.prototype.add=function(t,e){if(this.constructors.has(t))throw new y("There is already an object constructor with the name "+t);this.constructors.set(t,e)},t.prototype.getSingleton=function(t){if(!1===this.constructors.has(t))throw new y("Invalid object constructor name: "+t);return!1===this.instances.has(t)&&this.instances.set(t,this.constructors.get(t)()),this.instances.get(t)},t.prototype.getTranscient=function(t){if(!1===this.constructors.has(t))throw new y("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new y("There is already a constant value with the name "+t);this.constants.set(t,e)},t.prototype.getConstant=function(t){if(!1===this.constants.has(t))throw new y("Invalid constant name: "+t);return this.constants.get(t)},t}());exports.CollisionMethodConfig=void 0,(mt=exports.CollisionMethodConfig||(exports.CollisionMethodConfig={})).AABB="aabb",mt.SAT="sat";var St,At={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:180,headless:!1,collisions:{method:exports.CollisionMethodConfig.AABB,quadMaxLevel:6,collidersPerQuad:15}},Tt=function(){function t(t){this._config=l(l({},At),t),this._config.collisions=l(l({},At.collisions),t.collisions),Dt.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){!function(t,e){t.addConstant("GameConfig",e),t.add("TimeManager",(function(){return new q(e.physicsFramerate)})),t.add("GameObjectManager",(function(){return new _})),_t(t,e),e.headless?t.add("IterationManager",(function(){return new wt(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})):(t.add("DomManager",(function(){return new v(e.containerNode,e.gameWidth,e.gameHeight)})),Ct(t,e),jt(t),t.add("AssetManager",(function(){return new m})),t.add("IterationManager",(function(){return new w(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))}))),t.add("SceneManager",(function(){return new N(t.getConstant("Game"),e.headless?void 0:t.getSingleton("RenderManager"))})),Rt(t,e)}(Dt,this._config),this.sceneManager=Dt.getSingleton("SceneManager"),this.iterationManager=Dt.getSingleton("IterationManager")},Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"running",{get:function(){return this.iterationManager.running},enumerable:!1,configurable:!0}),t.prototype.addScene=function(t,e,i,n){void 0===n&&(n=!1),this.sceneManager.addScene(t,e,i,n)},t.prototype.run=function(){this.iterationManager.start()},t.prototype.stop=function(){this.iterationManager.stop()},t.prototype.pause=function(){this.iterationManager.pause()},t.prototype.resume=function(){this.iterationManager.resume()},t}(),Bt=function(){var t=(new Date).getTime(),e="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(i){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"==i?n:7&n|8).toString(16)}))},Ft=function(){function t(){this.gameObjectManager=Dt.getSingleton("GameObjectManager"),this.updateEvent=f.Update,this.started=!1}return t.prototype.dispatch=function(t,e){t===f.Init&&this.init?this.init(e):t!==f.Start||this.started?t===this.updateEvent&&this.started&&this.update?this.update():t===f.Destroy&&(this.onDestroy&&this.onDestroy(),this._destroy()):(this.start&&this.start(),this.started=!0)},t.prototype.addGameObject=function(t,e,i){return"string"==typeof e&&(i=e,e={}),this.gameObjectManager.addGameObject(t,e,void 0,i)},t.prototype.findGameObjects=function(t){return t?this.gameObjectManager.findGameObjects(t):this.gameObjectManager.findGameObjects()},t.prototype.findGameObject=function(t){return this.gameObjectManager.findGameObject(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t}(),Et=function(t){function e(e,i){void 0===i&&(i="");var n=t.call(this)||this;return n.sceneManager=Dt.getSingleton("SceneManager"),n.id=Bt(),n.allowMultiple=!0,n._active=!0,n.gameObject=e,n.name=i,n}return h(e,t),Object.defineProperty(e.prototype,"active",{get:function(){return this._active},set:function(t){this._active=t,this.onActiveChange()},enumerable:!1,configurable:!0}),e.prototype.onActiveChange=function(){},e.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},e.prototype.getGameObject=function(){return this.gameObject},e.prototype.getComponents=function(t){return t?this.gameObject.getComponents(t):this.gameObject.getComponents()},e.prototype.getComponent=function(t){return this.gameObject.getComponent(t)},e.prototype.hasComponent=function(t){return this.gameObject.hasComponent(t)},e.prototype.removeComponent=function(t){this.gameObject.removeComponent(t)},e.prototype._destroy=function(){var t=this;Object.keys(this).forEach((function(e){return delete t[e]}))},e}(Ft),It=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdateEngine,e}return h(e,t),e}(Et),Vt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdateCollider,e}return h(e,t),e}(Et),Ut=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdatePhysics,e}return h(e,t),e}(Et),Lt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdateTransform,e}return h(e,t),e}(Et),Gt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdatePreRender,e}return h(e,t),e}(Et),kt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdateCamera,e}return h(e,t),e}(Et),zt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=f.UpdateRender,e}return h(e,t),e}(Et),Wt=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.allowMultiple=!1,i.parentScale=!0,i.parentRotation=!0,i._position=new t,i._scale=new t(1,1),i._rotation=new s,i._innerPosition=new t,i._parent=null,i.cache=new t,i.lastParentRadians=0,i.lastPosition=new t,i.scaledInnerPosition=new t,i}return h(i,e),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(t){this._scale.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._rotation.direction},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"innerPosition",{get:function(){return this._innerPosition},set:function(t){this._innerPosition.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e,null!==this._parent&&t.subtract(this._innerPosition,this._position,this._parent.position)},enumerable:!1,configurable:!0}),i.prototype.update=function(){null!==this._parent&&this.setPositionFromParent(),this.lastPosition.copy(this._position)},i.prototype.setParent=function(){null!==this.gameObject.parent&&this._parent!==this.gameObject.parent.transform?(this._parent=this.gameObject.parent.transform,t.subtract(this._innerPosition,this._position,this._parent.position)):null===this.gameObject.parent&&(this._parent=null)},i.prototype.setPositionFromParent=function(){this._innerPosition.magnitude>0?(0!==this._parent.rotation.radians&&this.lastParentRadians!==this._parent.rotation.radians&&(this.translateInnerPosition(),this.lastParentRadians=this._parent.rotation.radians),this.parentScale?(this.updateScaledInnerPosition(),t.add(this._position,this._parent.position,this.scaledInnerPosition)):t.add(this._position,this._parent.position,this._innerPosition)):this._position.copy(this._parent.position),this._rotation.radians=this.parentRotation?this._parent.rotation.radians+this._rotation.radians:this._rotation.radians,this.parentScale&&this._scale.copy(this._parent.scale)},i.prototype.translateInnerPosition=function(){var e=Math.atan2(this._innerPosition.y,this._innerPosition.x)+(this._parent.rotation.radians-this.lastParentRadians);this.cache.set(Math.cos(e),Math.sin(e)),t.scale(this._innerPosition,this.cache,this._innerPosition.magnitude)},i.prototype.updateScaledInnerPosition=function(){this.scaledInnerPosition.set(this._innerPosition.x*this._parent.scale.x,this._innerPosition.y*this._parent.scale.y)},i}(Lt),Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=Dt.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return h(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return t.collisionManager.addCollider(e)}))},e.prototype.collidesWithLayer=function(t){return null!==this.getCollisionWithLayer(t)},e.prototype.getCollisionWithLayer=function(t){for(var e=0,i=this.colliders;e<i.length;e++)for(var n=i[e],r=0,o=this.collisionManager.getCollisionsForCollider(n);r<o.length;r++){var s=o[r];if(s.remoteCollider.layer===t)return this.createCollisionData(s)}return null},e.prototype.getCollisionsWithLayer=function(t){for(var e=[],i=0,n=this.colliders;i<n.length;i++)for(var r=n[i],o=0,s=this.collisionManager.getCollisionsForCollider(r);o<s.length;o++){var a=s[o];a.remoteCollider.layer===t&&e.push(this.createCollisionData(a))}return e},e.prototype.createCollisionData=function(t){return{gameObject:this.gameObjectManager.findGameObjectById(t.remoteCollider.id),collider:t.remoteCollider,resolution:t.resolution,getGameObject:function(){return this.gameObject}}},e.prototype.onActiveChange=function(){this.renderer&&(this.renderer.active=this.active)},e}(Vt),Yt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.allowMultiple=!1,t.rigidBodyManager=Dt.getSingleton("RigidBodyManager"),t}return h(i,e),Object.defineProperty(i.prototype,"velocity",{get:function(){return this.data.velocity},set:function(t){this.data.velocity.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gravity",{get:function(){return this.data.gravity},set:function(t){this.data.gravity=Math.abs(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rigidBodyType",{get:function(){return this.data.type},enumerable:!1,configurable:!0}),i.prototype.init=function(e){var i,n=e.rigidBodyType,r=e.gravity;this.data={type:n,position:null,gravity:null!==(i=Math.abs(r))&&void 0!==i?i:10,velocity:new t,colliders:[]}},i.prototype.start=function(){if(0===this.getColliders().length)throw new y("RigidBody needs at least one Collider with physics")},i.prototype.update=function(){this.data.type!==exports.RigidBodyType.Static&&(this.data.position=this.gameObject.transform.parent?this.gameObject.transform.innerPosition:this.gameObject.transform.position,this.data.colliders=this.getColliders(),this.rigidBodyManager.addRigidBodyData(this.data))},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Ht&&e.physics?d(d([],t,!0),e.colliders,!0):t}),[])},i}(It),Nt=function(t){function e(e,i){void 0===e&&(e="");var n=t.call(this)||this;return n.id=Bt(),n.layer="Default",n.ui=!1,n.keep=!1,n._parent=null,n._active=!0,n.sceneManager=Dt.getSingleton("SceneManager"),n.components=[],n.activeComponentsCache=[],n.activeChildrenCache=[],n.name=e,n.addComponent(Wt),n.parent=null!=i?i:null,n}return h(e,t),Object.defineProperty(e.prototype,"active",{get:function(){return this._active},set:function(t){this._active!==t&&(this._active=t,this.onActiveChange(),this.updateComponentsActiveStatus(),this.updateChildrenActiveStatus())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,this.transform.parent=null!==t?t.transform:null},enumerable:!1,configurable:!0}),e.prototype.updateComponentsActiveStatus=function(){var t=this;!1===this.active&&(this.activeComponentsCache=this.components.filter((function(t){return t.active}))),this.activeComponentsCache.forEach((function(e){return e.active=t.active})),!0===this.active&&(this.activeComponentsCache=[])},e.prototype.updateChildrenActiveStatus=function(){var t=this;!1===this.active&&(this.activeChildrenCache=this.getChildren().filter((function(t){return t.active}))),this.activeChildrenCache.forEach((function(e){return e.active=t.active})),!0===this.active&&(this.activeChildrenCache=[])},Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(Wt)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rigidBody",{get:function(){return this.getComponent(Yt)},enumerable:!1,configurable:!0}),e.prototype.onActiveChange=function(){},e.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},e.prototype.addComponent=function(t,e,i){var n="string"==typeof e?void 0:e,r=new t(this,"string"==typeof e?e:i);return this.checkMultipleComponent(r,t),this.components.push(r),r.dispatch(f.Init,n),r},e.prototype.checkMultipleComponent=function(t,e){if(!1===t.allowMultiple&&this.hasComponent(e))throw new y("GameObject only allows one component of type "+e.name)},e.prototype.getComponents=function(t){return t?this.components.filter((function(e){return e instanceof t})):this.components},e.prototype.getComponent=function(t){return"string"==typeof t?this.components.find((function(e){return e.name===t})):this.components.find((function(e){return e instanceof t}))},e.prototype.hasComponent=function(t){return"string"==typeof t?this.components.some((function(e){return e.name===t})):this.components.some((function(e){return e instanceof t}))},e.prototype.removeComponent=function(t){var e=this.components.indexOf(t);-1!==e&&this.components.splice(e,1)[0].dispatch(f.Destroy)},e.prototype.addChild=function(t,e,i){var n=this.gameObjectManager.addGameObject(t,e,this,i);return n.transform.innerPosition.set(0,0),n.transform.position.copy(this.transform.position),n},e.prototype.getChildren=function(){return this.gameObjectManager.findGameObjectsByParent(this)},e.prototype.getChild=function(t){return this.gameObjectManager.findGameObjectByParent(this,t)},e.prototype.destroyChildren=function(){var t=this;this.gameObjectManager.findGameObjectsByParent(this).forEach((function(e){return t.gameObjectManager.destroyGameObject(e)}))},e.prototype._destroy=function(){var t=this;this.destroyComponents(),Object.keys(this).forEach((function(e){return delete t[e]}))},e.prototype.destroyComponents=function(){for(var t=0;t<this.components.length;t++)this.components[t].dispatch(f.Destroy),delete this.components[t];this.components=[]},e}(Ft),Xt=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},qt=["Default"],Qt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowMultiple=!1,e.renderManager=Dt.getSingleton("RenderManager"),e._layers=qt,e._depth=0,e._zoom=1,e._originalViewportRect=new o(0,0,0,0),e._viewportRect=new o(0,0,0,0),e._worldSpaceRect=new o(0,0,0,0),e.canvas=Dt.getSingleton("DomManager").canvas,e.cameraData=new Xt,e}return h(e,t),Object.defineProperty(e.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=d(d([],qt,!0),t,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this._zoom},set:function(t){if(this.zoom<=0)throw new y("zoom must be greather than 0");this._zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalViewportRect",{get:function(){return this._originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"worldSpaceRect",{get:function(){return this._worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportRect",{get:function(){return this._viewportRect},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){this._layers.push(t)},e.prototype.update=function(){this.updateOriginalViewportRect(),this.updateViewportRect(),this.updateWorldSpaceRect(),this.updateCameraData()},e.prototype.updateOriginalViewportRect=function(){this._originalViewportRect.x=-this.canvas.width/2,this._originalViewportRect.y=-this.canvas.height/2,this._originalViewportRect.width=this.canvas.width,this._originalViewportRect.height=this.canvas.height},e.prototype.updateViewportRect=function(){var t=1/this._zoom;this._viewportRect.x=this._originalViewportRect.x*t,this._viewportRect.y=this._originalViewportRect.y*t,this._viewportRect.width=this._originalViewportRect.width*t,this._viewportRect.height=this._originalViewportRect.height*t},e.prototype.updateWorldSpaceRect=function(){this._worldSpaceRect.x=this.gameObject.transform.position.x-this._viewportRect.width/2,this._worldSpaceRect.y=this.gameObject.transform.position.y-this._viewportRect.height/2,this._worldSpaceRect.width=this._viewportRect.width,this._worldSpaceRect.height=this._viewportRect.height},e.prototype.updateCameraData=function(){this.cameraData.depth=this._depth,this.cameraData.layers=this._layers,this.cameraData.originalViewportRect=this._originalViewportRect,this.cameraData.viewportRect=this._viewportRect,this.cameraData.worldSpaceRect=this._worldSpaceRect,this.cameraData.zoom=this._zoom,this.renderManager.addCameraData(this.cameraData)},e}(kt),Kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.prototype.init=function(){this.transform.position.set(0,0),this.camera=this.addComponent(Qt)},Object.defineProperty(e.prototype,"layers",{get:function(){return this.camera.layers},set:function(t){this.camera.layers=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this.camera.depth},set:function(t){this.camera.depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this.camera.zoom},set:function(t){this.camera.zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalViewporRect",{get:function(){return this.camera.originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"worldSpaceRect",{get:function(){return this.camera.worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportRect",{get:function(){return this.camera.viewportRect},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){this.camera.layers.push(t)},e}(Nt),$t=function(t){function e(e,i){var n=t.call(this)||this;return n.name=e,n.game=i,n.game.config.headless||n.addGameObject(Kt),n}return h(e,t),Object.defineProperty(e.prototype,"gameCamera",{get:function(){return this.findGameObject(Kt)},enumerable:!1,configurable:!0}),e.prototype._destroy=function(){var t=this;this.gameObjectManager.destroyAllGameObjects(),Object.keys(this).forEach((function(e){return delete t[e]}))},e}(Ft),Jt=function(){function t(t,e,i,n,r,o){this.shape=t,this.layer=e,this.id=i,this.updateCollisions=n,this.physics=r,this.rigidBody=o}return Object.defineProperty(t.prototype,"x",{get:function(){return this.shape.boundingBox.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.shape.boundingBox.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x1",{get:function(){return this.shape.boundingBox.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y1",{get:function(){return this.shape.boundingBox.y1},enumerable:!1,configurable:!0}),t}(),Zt=function(){function e(e){this._type=tt.Polygon,this._vertices=[],this._boundingBox=new o(0,0,0,0),this._projectionAxes=[],this._position=new t,this._angle=0,this.boxMinX=Number.MAX_SAFE_INTEGER,this.boxMinY=Number.MAX_SAFE_INTEGER,this.boxMaxX=-Number.MAX_SAFE_INTEGER,this.boxMaxY=-Number.MAX_SAFE_INTEGER,this._vertexModel=e;for(var i=0;i<this._vertexModel.length;i++)this._vertices.push(new t),this._projectionAxes.push(new t)}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"boundingBox",{get:function(){return this._boundingBox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"projectionAxes",{get:function(){return this._projectionAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertexModel",{get:function(){return this._vertexModel},set:function(t){this._vertexModel=t},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},e.prototype.updateVertices=function(){for(var t=0;t<this._vertexModel.length;t++)this._vertices[t].set(this._vertexModel[t].x*Math.cos(this._angle)-this._vertexModel[t].y*Math.sin(this._angle)+this._position.x,this._vertexModel[t].x*Math.sin(this._angle)+this._vertexModel[t].y*Math.cos(this._angle)+this._position.y)},e.prototype.updateBoundingBox=function(){var t=this;this.boxMinX=this.vertices[0].x,this.boxMinY=this.vertices[0].y,this.boxMaxX=this.vertices[0].x,this.boxMaxY=this.vertices[0].y,this.vertices.forEach((function(e){t.boxMinX=Math.min(e.x,t.boxMinX),t.boxMinY=Math.min(e.y,t.boxMinY),t.boxMaxX=Math.max(e.x,t.boxMaxX),t.boxMaxY=Math.max(e.y,t.boxMaxY)})),this.boundingBox.set(this.boxMinX,this.boxMinY,this.boxMaxX-this.boxMinX,this.boxMaxY-this.boxMinY)},e.prototype.updateProjectionAxes=function(){for(var e,i=0;i<this._vertices.length;i++)t.normal(this.projectionAxes[i],t.subtract(this.projectionAxes[i],null!==(e=this._vertices[i+1])&&void 0!==e?e:this._vertices[0],this._vertices[i]))},e}(),te=function(e){function i(i,n,r){var o=e.call(this,[new t(-i/2,-n/2),new t(-i/2,n/2),new t(i/2,n/2),new t(i/2,-n/2)])||this;return o.width=i,o.height=n,o._position.copy(r),o._projectionAxes=[new t,new t],o.update(),o}return h(i,e),i.prototype.updateSize=function(t,e){this.width=t,this.height=e,this.vertexModel[0].set(-t/2,-e/2),this.vertexModel[1].set(-t/2,e/2),this.vertexModel[2].set(t/2,e/2),this.vertexModel[3].set(t/2,-e/2)},i.prototype.updateProjectionAxes=function(){t.unit(this._projectionAxes[0],t.subtract(this.projectionAxes[0],this._vertices[1],this._vertices[0])),t.normal(this._projectionAxes[1],this._projectionAxes[0])},i}(Zt),ee=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.offsetX=0,i.offsetY=0,i.realWidth=0,i.realHeight=0,i.realOffset=new t,i.realPosition=new t,i.realRotation=0,i.applyRotation=Dt.getConstant("GameConfig").collisions.method===exports.CollisionMethodConfig.SAT,i.innerPosition=new t,i}return h(i,e),i.prototype.init=function(t){var e,i,n,r,o;this.width=t.width,this.height=t.height,this.offsetX=null!==(e=t.offsetX)&&void 0!==e?e:this.offsetX,this.offsetY=null!==(i=t.offsetY)&&void 0!==i?i:this.offsetY,this.physics=null!==(n=t.physics)&&void 0!==n?n:this.physics,this.debug=(null!==(r=t.debug)&&void 0!==r?r:this.debug)&&Dt.getConstant("GameConfig").debugEnabled,this.rotation=null!==(o=t.rotation)&&void 0!==o?o:new s,this.layer=t.layer},i.prototype.start=function(){var t;this.colliders.push(new Jt(new te(this.realWidth,this.realHeight,this.realPosition),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Yt))),this.debug&&(this.renderer=this.gameObject.addComponent(ie,{collider:this.colliders[0]}))},i.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateRealSize=function(){this.realWidth=this.width*Math.abs(this.gameObject.transform.scale.x),this.realHeight=this.height*Math.abs(this.gameObject.transform.scale.y),this.realOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.realOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.realRotation=this.applyRotation?this.gameObject.transform.rotation.radians+this.rotation.radians:0},i.prototype.updatePosition=function(){t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.realPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.realPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.realPosition,this.colliders[0].shape.angle=this.realRotation,this.colliders[0].shape.updateSize(this.realWidth,this.realHeight),this.colliders[0].shape.update()},i}(Ht),ie=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=Dt.getSingleton("RenderManager"),e}return h(e,t),e.prototype.init=function(t){var e=t.collider;this.renderData=new et,this.renderData.debug=!0,this.renderData.color="#00FF00",this.collider=e},e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=H.Polygon,this.renderData.position=this.collider.shape.position,this.renderData.angle=this.collider.shape.angle,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},e}(zt),ne=function(){function e(e){this.type=tt.Circumference,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new o(0,0,0,0),this.angle=0,this.vertexModel=[],this.radius=0,this._position=new t,this.vertices=[new t,new t],this.radius=e}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.updateBoundingBox()},e.prototype.updateBoundingBox=function(){this.boundingBox.set(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},e}(),re=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.offsetX=0,i.offsetY=0,i.realRadius=0,i.realOffset=new t,i.realPosition=new t,i.innerPosition=new t,i}return h(i,e),i.prototype.init=function(t){var e,i,n,r;this.radius=t.radius,this.offsetX=null!==(e=t.offsetX)&&void 0!==e?e:this.offsetX,this.offsetY=null!==(i=t.offsetY)&&void 0!==i?i:this.offsetY,this.physics=null!==(n=t.physics)&&void 0!==n?n:this.physics,this.debug=(null!==(r=t.debug)&&void 0!==r?r:this.debug)&&Dt.getConstant("GameConfig").debugEnabled,this.layer=t.layer},i.prototype.start=function(){var t;this.colliders.push(new Jt(new ne(this.radius),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Yt))),this.debug&&(this.renderer=this.gameObject.addComponent(oe,{collider:this.colliders[0]}))},i.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateRealSize=function(){this.realRadius=this.radius*Math.max(Math.abs(this.gameObject.transform.scale.x),Math.abs(this.gameObject.transform.scale.y)),this.realOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.realOffset.y=this.offsetY*this.gameObject.transform.scale.y},i.prototype.updatePosition=function(){t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.realPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.realPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.realPosition,this.colliders[0].shape.radius=this.realRadius,this.colliders[0].shape.update()},i}(Ht),oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=Dt.getSingleton("RenderManager"),e}return h(e,t),e.prototype.init=function(t){var e=t.collider;this.renderData=new et,this.renderData.debug=!0,this.renderData.color="#00FF00",this.collider=e},e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=H.Circumference,this.renderData.position=this.collider.shape.position,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.radius=this.collider.shape.radius,this.renderManager.addRenderData(this.renderData)},e}(zt),se=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.debug=!1,t.needsCollider=function(e){t.cacheVertex[0].set(e.position.x,e.position.y+e.height),t.cacheVertex[1].set(e.position.x+e.width,e.position.y),t.cacheVertex[2].set(e.position.x,e.position.y-e.height),t.cacheVertex[3].set(e.position.x-e.width,e.position.y);for(var i=function(e){if(void 0===t.tilemapRenderer.tilesData.find((function(i){return i.position.equals(t.cacheVertex[e])})))return{value:!0}},n=0;n<t.cacheVertex.length;n++){var r=i(n);if("object"==typeof r)return r.value}return!1},t}return h(i,e),i.prototype.init=function(e){var i;this.tilemapRenderer=e.tilemapRenderer,this.layer=e.layer,this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&Dt.getConstant("GameConfig").debugEnabled,this.physics=!0,this.cacheVertex=[new t,new t,new t,new t]},i.prototype.start=function(){var t,e=this;this.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.tilemapRenderer.tilesData.filter(this.needsCollider).forEach((function(t){return e.colliders.push(new Jt(new te(t.width,t.height,t.position),e.layer,e.gameObject.id,!1,e.physics,e.hasComponent(Yt)))})),this.debug&&(this.renderer=this.gameObject.addComponent(ae,{colliders:this.colliders}))},i.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return e.layer=t.layer})),e.prototype.update.call(this)},i}(Ht),ae=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=Dt.getSingleton("RenderManager"),e.renderData=[],e.colliders=[],e}return h(e,t),e.prototype.init=function(t){var e=this,i=t.colliders;this.colliders=i,this.colliders.forEach((function(t,i){e.renderData[i]=new et,e.renderData[i].debug=!0,e.renderData[i].color="#00FF00"}))},e.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].shape=H.Polygon,t.renderData[i].position=e.shape.position,t.renderData[i].angle=e.shape.angle,t.renderData[i].boundingBox=e.shape.boundingBox,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},e}(zt),he=function(e){function i(i,n){var r=e.call(this,i,n)||this;if(r.debug=!1,r.offsetX=0,r.offsetY=0,r.scaledVertexModel=[],r.scaledOffset=new t,r.scaledPosition=new t,r.finalRotation=0,r.innerPosition=new t,Dt.getConstant("GameConfig").collisions.method!==exports.CollisionMethodConfig.SAT)throw new y("Polygon Colliders need SAT collision method.");return r}return h(i,e),i.prototype.init=function(e){var i,n,r,o,a;if(e.vertexModel.length<3)throw new y("Polygon Collider needs at least 3 vertices.");this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&Dt.getConstant("GameConfig").debugEnabled,this.vertexModel=e.vertexModel,this.offsetX=null!==(n=e.offsetX)&&void 0!==n?n:this.offsetX,this.offsetY=null!==(r=e.offsetY)&&void 0!==r?r:this.offsetY,this.physics=null!==(o=e.physics)&&void 0!==o?o:this.physics,this.rotation=null!==(a=e.rotation)&&void 0!==a?a:new s,this.layer=e.layer;for(var h=0;h<this.vertexModel.length;h++)this.scaledVertexModel.push(new t)},i.prototype.start=function(){var t;this.colliders.push(new Jt(new Zt(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Yt))),this.debug&&(this.renderer=this.gameObject.addComponent(ce,{collider:this.colliders[0]}))},i.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateSize=function(){var t=this;this.vertexModel.forEach((function(e,i){return t.scaledVertexModel[i].set(e.x*t.gameObject.transform.scale.x,e.y*t.gameObject.transform.scale.y)})),this.scaledOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.scaledOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.finalRotation=this.gameObject.transform.rotation.radians+this.rotation.radians},i.prototype.updatePosition=function(){t.add(this.scaledPosition,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.scaledPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.scaledPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.scaledPosition,this.colliders[0].shape.angle=this.finalRotation,this.colliders[0].shape.vertexModel=this.scaledVertexModel,this.colliders[0].shape.update()},i}(Ht),ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=Dt.getSingleton("RenderManager"),e}return h(e,t),e.prototype.init=function(t){var e=t.collider;this.renderData=new et,this.renderData.debug=!0,this.renderData.color="#00FF00",this.collider=e},e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=H.Polygon,this.renderData.position=this.collider.shape.position,this.renderData.angle=this.collider.shape.angle,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},e}(zt),le=function(){function e(e){this.vertexModel=e,this.type=tt.Polygon,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new o(0,0,0,0),this.angle=0,this._position=new t}return e.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),e.prototype.updateVertices=function(){for(var t=0;t<this.vertexModel.length;t++)this.vertices[t].set(this.vertexModel[t].x*Math.cos(this.angle)-this.vertexModel[t].y*Math.sin(this.angle)+this._position.x,this.vertexModel[t].x*Math.sin(this.angle)+this.vertexModel[t].y*Math.cos(this.angle)+this._position.y)},e.prototype.updateBoundingBox=function(){this.boundingBox.x=Math.min(this.vertices[0].x,this.vertices[1].x),this.boundingBox.y=Math.min(this.vertices[0].y,this.vertices[1].y),this.boundingBox.width=Math.max(this.vertices[0].x,this.vertices[1].x)-this.boundingBox.x,this.boundingBox.height=Math.max(this.vertices[0].y,this.vertices[1].y)-this.boundingBox.y},e.prototype.updateProjectionAxes=function(){t.normal(this.projectionAxes[0],t.subtract(this.projectionAxes[0],this.vertices[1],this.vertices[0]))},e}(),ue=function(e){function i(i,n){var r=e.call(this,i,n)||this;if(r.debug=!1,r.offsetX=0,r.offsetY=0,r.scaledVertexModel=[],r.scaledOffset=new t,r.scaledPosition=new t,r.finalRotation=0,r.innerPosition=new t,Dt.getConstant("GameConfig").collisions.method!==exports.CollisionMethodConfig.SAT)throw new y("Edge Colliders need SAT collision method.");return r}return h(i,e),i.prototype.config=function(e){var i,n,r,o,a;if(e.vertexModel.length<2)throw new y("Edge Collider needs at least 2 vertices.");this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&Dt.getConstant("GameConfig").debugEnabled,this.vertexModel=e.vertexModel,this.offsetX=null!==(n=e.offsetX)&&void 0!==n?n:this.offsetX,this.offsetY=null!==(r=e.offsetY)&&void 0!==r?r:this.offsetY,this.physics=null!==(o=e.physics)&&void 0!==o?o:this.physics,this.rotation=null!==(a=e.rotation)&&void 0!==a?a:new s,this.layer=e.layer;for(var h=0;h<this.vertexModel.length;h++)this.scaledVertexModel.push(new t)},i.prototype.start=function(){for(var t,e=0;e<this.scaledVertexModel.length-1;e++)this.colliders.push(new Jt(new le([this.scaledVertexModel[e],this.scaledVertexModel[e+1]]),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Yt)));this.debug&&(this.renderer=this.gameObject.addComponent(pe,{colliders:this.colliders}))},i.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateColliders(),e.prototype.update.call(this)},i.prototype.updateSize=function(){var t=this;this.vertexModel.forEach((function(e,i){return t.scaledVertexModel[i].set(e.x*t.gameObject.transform.scale.x,e.y*t.gameObject.transform.scale.y)})),this.scaledOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.scaledOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.finalRotation=this.gameObject.transform.rotation.radians+this.rotation.radians},i.prototype.updatePosition=function(){t.add(this.scaledPosition,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.scaledPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.scaledPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateColliders=function(){for(var t,e=0;e<this.scaledVertexModel.length-1;e++)this.colliders[e].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[e].shape.position=this.scaledPosition,this.colliders[e].shape.angle=this.finalRotation,this.colliders[e].shape.vertexModel=[this.scaledVertexModel[e],this.scaledVertexModel[e+1]],this.colliders[e].shape.update()},i}(Ht),pe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=Dt.getSingleton("RenderManager"),e.renderData=[],e.colliders=[],e}return h(e,t),e.prototype.init=function(t){var e=this,i=t.colliders;this.colliders=i,this.colliders.forEach((function(t,i){e.renderData[i]=new et,e.renderData[i].debug=!0,e.renderData[i].color="#00FF00",e.renderData[i].shape=H.Line}))},e.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].position=e.shape.position,t.renderData[i].angle=e.shape.angle,t.renderData[i].boundingBox=e.shape.boundingBox,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},e}(zt),de=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=M.Image,e}return h(e,t),e}(D),fe=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.renderManager=Dt.getSingleton("RenderManager"),i.sprite=null,i.offset=new t,i.flipHorizontal=!1,i.flipVertical=!1,i.rotation=new s,i.smooth=!1,i.opacity=1,i._tiled=new t(1,1),i.maskColor=null,i.maskColorMix=0,i.tintColor=null,i.renderData=[],i.innerPosition=new t,i.cachePosition=new t,i.cacheRenderPosition=new t,i.scaledOffset=new t,i}return h(i,e),i.prototype.init=function(t){var e,i,n,r,o,s,a,h,c,l,u,p;void 0===t&&(t={}),this.sprite=null!==(e=t.sprite)&&void 0!==e?e:this.sprite,this.offset=null!==(i=t.offset)&&void 0!==i?i:this.offset,this.smooth=null!==(n=t.smooth)&&void 0!==n?n:this.smooth,this.rotation=null!==(r=t.rotation)&&void 0!==r?r:this.rotation,this.flipHorizontal=null!==(o=t.flipHorizontal)&&void 0!==o?o:this.flipHorizontal,this.flipVertical=null!==(s=t.flipVertical)&&void 0!==s?s:this.flipVertical,this.opacity=null!==(a=t.opacity)&&void 0!==a?a:this.opacity,this.tiled=null!==(h=t.tiled)&&void 0!==h?h:this._tiled,this.maskColor=null!==(c=t.maskColor)&&void 0!==c?c:this.maskColor,this.maskColorMix=null!==(l=t.maskColorMix)&&void 0!==l?l:this.maskColorMix,this.tintColor=null!==(u=t.tintColor)&&void 0!==u?u:this.tintColor,this.layer=null!==(p=t.layer)&&void 0!==p?p:this.layer},Object.defineProperty(i.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new y("SpriteRenderer.tiled: Vector2 components must be integers");this._tiled.set(t.x,t.y)},enumerable:!1,configurable:!0}),i.prototype.update=function(){if(this.sprite&&!0===this.sprite.loaded){this.updateRenderDataArray();for(var t=0,e=0;e<this._tiled.x;e++)for(var i=0;i<this._tiled.y;i++)this.updateRenderData(t,e,i),t++}},i.prototype.updateRenderDataArray=function(){if(this.renderData.length!==this._tiled.x*this._tiled.y){this.renderData=[];for(var t=0;t<=this._tiled.x*this._tiled.y;t++)this.renderData[t]=new de}},i.prototype.updateRenderData=function(t,e,i){var n;this.renderData[t].ui=this.gameObject.ui,this.renderData[t].layer=null!==(n=this.layer)&&void 0!==n?n:this.gameObject.layer,this.renderData[t].image=this.sprite.image,this.renderData[t].width=this.sprite.width*Math.abs(this.gameObject.transform.scale.x),this.renderData[t].height=this.sprite.height*Math.abs(this.gameObject.transform.scale.y),this.renderData[t].slice=this.sprite.slice,this.renderData[t].flipHorizontal=this.flipHorizontal!==this.gameObject.transform.scale.x<0,this.renderData[t].flipVertical=this.flipVertical!==this.gameObject.transform.scale.y<0,this.renderData[t].rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData[t].smooth=this.sprite.smooth,this.renderData[t].alpha=this.opacity,this.renderData[t].maskColor=this.maskColor,this.renderData[t].maskColorMix=this.maskColorMix,this.renderData[t].tintColor=this.tintColor,this.calculateRenderPosition(t,e,i),this.renderManager.addRenderData(this.renderData[t])},i.prototype.calculateRenderPosition=function(e,i,n){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.cachePosition,this.gameObject.transform.position,this.scaledOffset),this.cacheRenderPosition.set(this.renderData[e].width/2*(this.tiled.x-1),this.renderData[e].height/2*(this.tiled.y-1)),t.subtract(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.cacheRenderPosition.set(i*this.renderData[e].width,n*this.renderData[e].height),t.add(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.renderData[e].position=this.cachePosition,0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition(e)},i.prototype.translateRenderPosition=function(e){t.subtract(this.innerPosition,this.renderData[e].position,this.gameObject.transform.position);var i=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData[e].position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(i),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(i))},i}(zt),ge=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=M.Text,e}return h(e,t),e}(D),me=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.fontFamily="Sans",i.fontUrl=null,i.fontSize=12,i.width=100,i.height=100,i.offset=new t,i.color="#000000",i.lineSeparation=0,i.letterSpacing=0,i.bitmapSize=64,i.charRanges=[32,126,161,255],i.smooth=!1,i.bitmapOffset=new t,i.rotation=new s,i.opacity=1,i.orientation="center",i.renderManager=Dt.getSingleton("RenderManager"),i.renderData=new ge,i.lastFrameText="",i}return h(i,e),i.prototype.init=function(t){var e,i,n,r,o,s,a,h,c,l,u,p,d,f,g;if(this.text=t.text,this.fontFamily=t.fontFamily,this.fontUrl=null!==(e=t.fontUrl)&&void 0!==e?e:this.fontUrl,this.fontSize=null!==(i=t.fontSize)&&void 0!==i?i:this.fontSize,this.width=null!==(n=t.width)&&void 0!==n?n:this.width,this.height=null!==(r=t.height)&&void 0!==r?r:this.height,this.offset=null!==(o=t.offset)&&void 0!==o?o:this.offset,this.color=null!==(s=t.color)&&void 0!==s?s:this.color,this.lineSeparation=null!==(a=t.lineSeparation)&&void 0!==a?a:this.lineSeparation,this.letterSpacing=null!==(h=t.letterSpacing)&&void 0!==h?h:this.letterSpacing,this.bitmapSize=null!==(c=t.bitmapSize)&&void 0!==c?c:this.bitmapSize,this.charRanges=null!==(l=t.charRanges)&&void 0!==l?l:this.charRanges,this.smooth=null!==(u=t.smooth)&&void 0!==u?u:this.smooth,this.bitmapOffset=null!==(p=t.bitmapOffset)&&void 0!==p?p:this.bitmapOffset,this.rotation=null!==(d=t.rotation)&&void 0!==d?d:this.rotation,this.opacity=null!==(f=t.opacity)&&void 0!==f?f:this.opacity,this.orientation=null!==(g=t.orientation)&&void 0!==g?g:this.orientation,this.charRanges.length%2!=0)throw new y("TextRenderer.charRanges must be a 2 column matrix");if(this.lineSeparation%2!=0)throw new y("TextRenderer.lineSeparation must be multiple of 2")},i.prototype.start=function(){this.renderData.layer=this.gameObject.layer,this.renderData.ui=this.gameObject.ui,this.renderData.fontFamily=this.fontFamily,this.renderData.fontUrl=this.fontUrl,this.renderData.fontSize=this.fontSize,this.renderData.lineSeparation=this.lineSeparation,this.renderData.letterSpacing=this.letterSpacing,this.renderData.bitmapSize=this.bitmapSize,this.renderData.charRanges=this.charRanges,this.renderData.smooth=this.smooth,this.renderData.bitmapOffset=this.bitmapOffset,this.renderData.orientation=this.orientation,this.renderData.width=this.width,this.renderData.height=this.height},i.prototype.update=function(){this.text&&(this.renderData.text=this.text!==this.lastFrameText?this.crop():this.renderData.text,this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.opacity=this.opacity,t.add(this.renderData.position,this.gameObject.transform.position,this.offset),this.renderManager.addRenderData(this.renderData),this.lastFrameText=this.text)},i.prototype.crop=function(){var t;if(this.fontSize>this.height)return"";for(var e=[],i=0,n=0,r=this.text.split("\n");n<r.length;n++)for(var o=0,s=null!==(t=r[n].match(new RegExp(".{1,"+Math.floor(this.width/(this.fontSize+this.letterSpacing))+"}","g")))&&void 0!==t?t:[""];o<s.length;o++){var a=s[o];if((i+=this.fontSize+this.lineSeparation)>this.height)return e.join("\n");e.push(a)}return e.join("\n")},i}(zt),ye=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=M.Mask,e}return h(e,t),e}(D),xe=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.renderManager=Dt.getSingleton("RenderManager"),i.offset=new t,i.rotation=new s,i.opacity=1,i.renderData=new ye,i.innerPosition=new t,i.scaledOffset=new t,i}return h(i,e),i.prototype.init=function(t){var e,i,n,r;this.width=t.width,this.height=t.height,this.color=t.color,this.offset=null!==(e=t.offset)&&void 0!==e?e:this.offset,this.rotation=null!==(i=t.rotation)&&void 0!==i?i:this.rotation,this.opacity=null!==(n=t.opacity)&&void 0!==n?n:this.opacity,this.layer=null!==(r=t.layer)&&void 0!==r?r:this.layer},i.prototype.update=function(){var t;this.renderData.ui=this.gameObject.ui,this.renderData.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.renderData.width=this.width*Math.abs(this.gameObject.transform.scale.x),this.renderData.height=this.height*Math.abs(this.gameObject.transform.scale.y),this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.alpha=this.opacity,this.calculateRenderPosition(),this.renderManager.addRenderData(this.renderData)},i.prototype.calculateRenderPosition=function(){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.renderData.position,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition()},i.prototype.translateRenderPosition=function(){t.subtract(this.innerPosition,this.renderData.position,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData.position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i}(zt),be=function(){function e(e,i,n){this.position=new t,this.position.set(e.x,e.y),this.width=i,this.height=n}return Object.defineProperty(e.prototype,"x",{get:function(){return this.position.x-this.halfWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this.position.x+this.halfWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this.position.y-this.halfHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this.position.y+this.halfHeight},enumerable:!1,configurable:!0}),e}(),ve=function(){this.position=new t,this.positionInViewport=new t},Me=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=M.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return h(e,t),e}(D),we=function(e){function i(){var i,n=e.apply(this,arguments)||this;return n.allowMultiple=!1,n.renderOrder="center",n.smooth=!1,n.textureCorrection=null,n.tileScale=null!==(i=Dt.getConstant("GameConfig").spriteDefaultScale)&&void 0!==i?i:new t(1,1),n.tileWidth=0,n.tileHeight=0,n.orientation=new t(1,1),n.renderManager=Dt.getSingleton("RenderManager"),n.tilemapProcessed=!1,n.renderData=new Map,n.cols=[],n.rows=[],n._width=0,n._height=0,n.tiles=[],n._realWidth=0,n._realHeight=0,n.cacheV2=new t,n}return h(i,e),i.prototype.init=function(t){var e,i,n,r;this.tileset=t.tileset,this.tileScale=null!==(e=t.tileScale)&&void 0!==e?e:this.tileScale,this.smooth=null!==(i=t.smooth)&&void 0!==i?i:this.smooth,this.renderOrder=null!==(n=t.renderOrder)&&void 0!==n?n:this.renderOrder,this.textureCorrection=null!==(r=t.textureCorrection)&&void 0!==r?r:this.textureCorrection},i.prototype.start=function(){this.tileWidth=this.tileset.tileWidth*this.tileScale.x*Math.abs(this.gameObject.transform.scale.x),this.tileHeight=this.tileset.tileHeight*this.tileScale.y*Math.abs(this.gameObject.transform.scale.y),this.orientation.set(Math.sign(this.gameObject.transform.scale.x),Math.sign(this.gameObject.transform.scale.y)),this.processTilemap(),this.updatePosition()},i.prototype.update=function(){var t=this;this.renderData.forEach((function(e){return t.renderManager.addRenderData(e)}))},i.prototype.processLayer=function(t){var e=new Me;e.ui=!1,e.alpha=t.alpha,e.image=this.tileset.image,e.layer=this.gameObject.layer,e.smooth=this.smooth,e.tileWidth=this.tileWidth,e.tileHeight=this.tileHeight,e.textureCorrection=this.textureCorrection,e.tintColor=t.tintColor,this.renderData.set(t.layer,e)},i.prototype.processTile=function(t){null!==t.tile&&this.addTileToRenderData(t),this.updateSizeInfo(t.col,t.row)},i.prototype.addTileToRenderData=function(t){if(this.renderData.has(t.layer)){var e=new ve;e.tile=t.tile,e.position.set(this.gameObject.transform.position.x+t.col*this.tileWidth*this.orientation.x+t.offset.x*Math.abs(this.gameObject.transform.scale.x)+this.tileWidth*this.orientation.x/2,this.gameObject.transform.position.y-t.row*this.tileHeight*this.orientation.y-t.offset.y*Math.abs(this.gameObject.transform.scale.y)-this.tileHeight*this.orientation.y/2),e.flipHorizontal=t.flip.h!==this.orientation.x<0,e.flipVertical=t.flip.v!==this.orientation.y<0,this.renderData.get(t.layer).tilesData.push(e)}},i.prototype.updateSizeInfo=function(t,e){this._width=!1===this.cols.includes(t)?this.cols.push(t):this._width,this._height=!1===this.rows.includes(e)?this.rows.push(e):this._height,this._realWidth=this._width*this.tileWidth,this._realHeight=this._height*this.tileHeight},i.prototype.updatePosition=function(){var e=this;this.cacheV2.set(("center"===this.renderOrder?-Math.round(this._realWidth/2):["left-down","left-up"].includes(this.renderOrder)?-this._realWidth:0)*this.orientation.x,("center"===this.renderOrder?Math.round(this._realHeight/2):["right-up","left-up"].includes(this.renderOrder)?this._realHeight:0)*this.orientation.y),this.renderData.forEach((function(i){return i.tilesData.forEach((function(i){t.add(i.position,i.position,e.cacheV2),e.addTileData(i)}))}))},i.prototype.addTileData=function(t){this.tiles.push(new be(t.position,this.tileWidth,this.tileHeight))},Object.defineProperty(i.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realWidth",{get:function(){return this._realWidth},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realHeight",{get:function(){return this._realHeight},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tilesData",{get:function(){return this.tiles},enumerable:!1,configurable:!0}),i}(zt),_e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.prototype.init=function(e){var i,n;e.renderOrder=null!==(i=e.renderOrder)&&void 0!==i?i:e.tilemapData.renderorder,t.prototype.init.call(this,e),this.tiledTilemap=e.tilemapData,this.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,this.tilesetTileIds=[]},e.prototype.processTilemap=function(){var t=this;this.tiledTilemap.layers.forEach((function(e){var i,n,r;!0!==e.visible||null!==t.layerName&&t.layerName!==e.name||(t.renderData.has(e.name)||t.processLayer({layer:e.name,alpha:e.opacity,tintColor:null!==(i=e.tintcolor)&&void 0!==i?i:null}),!0===t.tiledTilemap.infinite?e.chunks.forEach((function(i){var n,r;return t.processChunk(e.name,i,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0})})):t.processChunk(e.name,e,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0}))})),this.tilesetTileIds=[],this.tilemapProcessed=!0},e.prototype.processChunk=function(t,e,i){void 0===i&&(i={x:0,y:0});for(var n=0,r=0;r<e.height;r++)for(var o=0;o<e.width;o++){var s=this.tileset.getTile(this.getTilesetTileId(e.data[n]));this.processTile({layer:t,tile:s,col:o+e.x,row:r+e.y,flip:{h:!1,v:!1},offset:i}),n++}},e.prototype.getTilesetTileId=function(t){return this.tilesetTileIds[t]||(this.tilesetTileIds[t]=this.tiledTilemap.tilesets.reduce((function(e,i){return t>=i.firstgid?t-i.firstgid:e}),-1)),this.tilesetTileIds[t]},e}(we),Ce=1,Oe=2,je=3,Pe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.alpha=1,e.tintColor=null,e}return h(e,t),e.prototype.init=function(e){var i,n;t.prototype.init.call(this,e),this.tilemapData=e.tilemapData,this.alpha=null!==(i=e.alpha)&&void 0!==i?i:this.alpha,this.tintColor=null!==(n=e.tintColor)&&void 0!==n?n:this.tintColor},e.prototype.processTilemap=function(){var t=this;this.processLayer({layer:"csv",alpha:this.alpha,tintColor:this.tintColor}),this.tilemapData.trim().split("\n").forEach((function(e,i){e.split(",").forEach((function(e,n){var r=parseInt(e.trim()),o=null,s={h:!1,v:!1};if(!1===isNaN(r)){var a=r>999?r%1e3:r,h=Math.round(r/1e3);o=t.tileset.getTile(a),s.h=[Ce,je].includes(h),s.v=[Oe,je].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:s,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(we),Re=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},De=function(){function e(e){var i,n;this.image=null,this.offset=new t(0,0),this.tileSpacing=new t(0,0),this._tiles=[],this.image=e.image,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.gridWidth=e.gridWidth,this.gridHeight=e.gridHeight,this.offset=null!==(i=e.offset)&&void 0!==i?i:this.offset,this.tileSpacing=null!==(n=e.spacing)&&void 0!==n?n:this.tileSpacing,this.generateTiles()}return e.prototype.generateTiles=function(){for(var t=0,e=0;e<this.gridHeight;e++)for(var i=0;i<this.gridWidth;i++)this._tiles[t]=new Re(i*this.tileWidth+i*this.tileSpacing.x+this.offset.x,e*this.tileHeight+e*this.tileSpacing.y+this.offset.y,this.tileWidth,this.tileHeight),t++},e.prototype.getTile=function(t){return this._tiles[t]?this._tiles[t]:null},Object.defineProperty(e.prototype,"tiles",{get:function(){return this._tiles},enumerable:!1,configurable:!0}),e}(),Se=function(t){var e,i;this.sprites=[],this.framerate=10,this.loop=!1,this.sprites=t.sprites,this.framerate=null!==(e=t.framerate)&&void 0!==e?e:this.framerate,this.loop=null!==(i=t.loop)&&void 0!==i?i:this.loop},Ae=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeManager=Dt.getSingleton("TimeManager"),e.spriteRenderer=null,e.animations=new Map,e.currentAnimation=null,e.paused=!1,e}return h(e,t),e.prototype.init=function(t){var e=t.spriteRenderer;this.spriteRenderer=e},e.prototype.update=function(){null===this.currentAnimation||this.paused||(this.currentAnimation.playFrame(this.timeManager.deltaTime),!0===this.currentAnimation.restarted&&!1===this.currentAnimation.loop?this.currentAnimation=null:this.spriteRenderer.sprite=this.currentAnimation.sprite)},e.prototype.addAnimation=function(t,e,i){return void 0===e&&(e="default"),t.framerate=null!=i?i:t.framerate,this.animations.set(e,new Te(t)),this},e.prototype.playAnimation=function(t){if(void 0===t&&(t="default"),!1!==this.active){if(!1===this.animations.has(t))throw new y("Animation with name "+t+" does not exist.");this.stopAnimation(),this.currentAnimation=this.animations.get(t)}},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused=!1},e.prototype.stopAnimation=function(){null!==this.currentAnimation&&(this.currentAnimation.reset(),this.currentAnimation=null)},e.prototype.isPlayingAnimation=function(t){return this.animations.get(t)&&this.animations.get(t)===this.currentAnimation},e}(It),Te=function(){function t(t){this._sprite=null,this._restarted=!1,this.currentFrame=0,this.frameTime=0,this._animation=t}return Object.defineProperty(t.prototype,"sprite",{get:function(){return this._sprite},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"restarted",{get:function(){return this._restarted},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loop",{get:function(){return this._animation.loop},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animation",{get:function(){return this._animation},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this.currentFrame=0,this.frameTime=0,this._restarted=!0},t.prototype.playFrame=function(t){this._restarted=!1,this.frameTime>=1/this._animation.framerate&&(this.frameTime=0,this.currentFrame=this.currentFrame+1===this._animation.sprites.length?0:this.currentFrame+1,this._restarted=0===this.currentFrame),this._sprite=this._animation.sprites[this.currentFrame],this.frameTime+=t},t}(),Be=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],Fe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowMultiple=!1,e.volume=1,e.loop=!1,e.audio=null,e.clones=new Map,e._playing=!1,e._paused=!1,e.audioEventHandler=function(t){"ended"===t.type&&(e._playing=!1,e.audio.removeEventListener("ended",e.audioEventHandler))},e.userinputEventHandler=function(){Be.forEach((function(t){window.removeEventListener(t,e.userinputEventHandler)})),e.audio.play()},e}return h(e,t),e.prototype.init=function(t){var e,i,n;void 0===t&&(t={}),this.audio=null!==(e=t.audio)&&void 0!==e?e:this.audio,this.volume=null!==(i=t.volume)&&void 0!==i?i:this.volume,this.loop=null!==(n=t.loop)&&void 0!==n?n:this.loop},e.prototype.playAudio=function(t,e){void 0===e&&(e=null),!1===this.clones.has(Symbol.for(t.src))&&this.cloneAudio(t);var i=this.clones.get(Symbol.for(t.src));i.currentTime>0&&(i.currentTime=0),i.volume=null!=e?e:this.volume,i.play()},e.prototype.cloneAudio=function(t){var e=t.cloneNode();this.clones.set(Symbol.for(t.src),e)},e.prototype.play=function(){var t=this;if(null!==this.audio&&(!this._playing||!1!==this._paused)){if(this._paused)return this._paused=!1,void this.audio.play();this.audio.volume=this.volume,this.audio.loop=this.loop,this.audio.addEventListener("ended",this.audioEventHandler),this._playing=!0,this.audio.play().then((function(){})).catch((function(){return Be.forEach((function(e){return window.addEventListener(e,t.userinputEventHandler)}))}))}},e.prototype.stop=function(){this._playing&&(this.audio.pause(),this.audio.currentTime=0,this.audio.removeEventListener("ended",this.audioEventHandler),this._playing=!1,this._paused=!1)},e.prototype.pause=function(){this._playing&&!1===this._paused&&(this.audio.pause(),this._paused=!0)},e.prototype.onActiveChange=function(){!1===this.active&&this.stop()},e.prototype.onDestroy=function(){this.stop()},e}(It),Ee=function(){function e(e){var i,n,r,o,s=this;this._image=null,this._slice=null,this._scale=null!==(i=Dt.getConstant("GameConfig").spriteDefaultScale)&&void 0!==i?i:new t(1,1),this._smooth=!1,this._width=null,this._height=null,this._loaded=!1,this._image=e.image,this._slice=null!==(n=e.slice)&&void 0!==n?n:this._slice,null!==this._slice&&(this._width=this._slice.width,this._height=this._slice.height),this._scale=null!==(r=e.scale)&&void 0!==r?r:this._scale,this._smooth=null!==(o=e.smooth)&&void 0!==o?o:this._smooth,this._image.naturalWidth?this.onLoad():this._image.addEventListener("load",(function(){return s.onLoad()}))}return Object.defineProperty(e.prototype,"loaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"slice",{get:function(){return this._slice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"smooth",{get:function(){return this._smooth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e.prototype.onLoad=function(){var t,e;this._width=(null!==(t=this._width)&&void 0!==t?t:this._image.naturalWidth)*Math.abs(this._scale.x),this._height=(null!==(e=this._height)&&void 0!==e?e:this._image.naturalHeight)*Math.abs(this._scale.y),this._loaded=!0},e}();exports.ButtonType=void 0,(St=exports.ButtonType||(exports.ButtonType={}))[St.Rectangle=0]="Rectangle",St[St.Circumference=1]="Circumference";var Ie=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.allowMultiple=!1,i.width=100,i.height=100,i.radius=50,i.touchEnabled=!0,i._offset=new t,i.pressed=!1,i.mouse=Dt.getSingleton("InputManager").mouse,i.touch=Dt.getSingleton("InputManager").touch,i.position=new t,i.distance=new t,i.pressedLastFrame=!1,i.scaled={width:0,height:0,radius:0,offset:new t},i}return h(i,e),Object.defineProperty(i.prototype,"offset",{get:function(){return this._offset},set:function(t){this._offset=t},enumerable:!1,configurable:!0}),i.prototype.init=function(t){var e=t.type,i=t.height,n=t.radius,r=t.touchEnabled,o=t.width,s=t.offset;this.type=e,this.width=null!=o?o:this.width,this.height=null!=i?i:this.height,this.radius=null!=n?n:this.radius,this.touchEnabled=null!=r?r:this.touchEnabled,this._offset=null!=s?s:this._offset},i.prototype.update=function(){this.scale(),t.add(this.position,this.gameObject.transform.position,this.scaled.offset),this.pressedLastFrame=this.pressed,this.pressed=!1,this.mouse.leftButtonPressed&&(this.resolveMouseAndRectangle(),this.resolveMouseAndCircumference()),this.touchEnabled&&this.touch.touching&&(this.resolveTouchAndRectangle(),this.resolveTouchAndCircumference()),this.onClick&&!this.pressedLastFrame&&this.pressed&&this.onClick(),this.onPressed&&this.pressed&&this.onPressed()},i.prototype.scale=function(){this.scaled.width=this.width*this.gameObject.transform.scale.x,this.scaled.height=this.width*this.gameObject.transform.scale.y,this.scaled.offset.x=this._offset.x*this.gameObject.transform.scale.x,this.scaled.offset.y=this._offset.y*this.gameObject.transform.scale.y,this.scaled.radius=this.radius*this.gameObject.transform.scale.magnitude},i.prototype.resolveMouseAndRectangle=function(){this.type===exports.ButtonType.Rectangle&&(this.pressed||(this.pressed=r(this.mouse.positionInViewport.x,this.position.x-this.scaled.width/2,this.position.x+this.scaled.width/2)&&r(this.mouse.positionInViewport.y,this.position.y-this.scaled.height/2,this.position.y+this.scaled.height/2)))},i.prototype.resolveMouseAndCircumference=function(){this.type===exports.ButtonType.Circumference&&(t.subtract(this.distance,this.position,this.mouse.positionInViewport),this.pressed||(this.pressed=this.distance.magnitude<=this.scaled.radius))},i.prototype.resolveTouchAndRectangle=function(){this.type===exports.ButtonType.Rectangle&&(this.pressed||(this.pressed=this.position.x+this.scaled.width/2>=this.touch.positionInViewport.x-this.touch.radius.x&&this.position.x-this.scaled.width/2<=this.touch.positionInViewport.x+this.touch.radius.x&&this.position.y+this.scaled.height/2>=this.touch.positionInViewport.y-this.touch.radius.y&&this.position.y-this.scaled.height/2<=this.touch.positionInViewport.y+this.touch.radius.y))},i.prototype.resolveTouchAndCircumference=function(){this.type===exports.ButtonType.Circumference&&(t.subtract(this.distance,this.position,this.touch.positionInViewport),this.pressed||(this.pressed=this.distance.magnitude<=this.scaled.radius+this.touch.radius.x))},i}(Et),Ve=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return h(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){ut.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,ut.mouse.positionInViewport,1/this.camera.zoom),t.add(this.position,this.position,this.camera.worldSpaceRect.center),t.round(this.position,this.position),console.log("Space position: {x: "+this.position.x+", y: "+this.position.y+"}")),this.mousePressed=ut.mouse.leftButtonPressed},i}(Nt);exports.Animation=Se,exports.Animator=Ae,exports.AssetManager=ct,exports.AudioPlayer=Fe,exports.BallCollider=re,exports.BoxCollider=ee,exports.Button=Ie,exports.Camera=Qt,exports.ColliderData=Jt,exports.Component=Et,exports.CsvTilemapRenderer=Pe,exports.DomManager=lt,exports.EdgeCollider=ue,exports.Game=Tt,exports.GameCamera=Kt,exports.GameObject=Nt,exports.GameObjectManager=ft,exports.GamepadController=C,exports.GamepadData=O,exports.InputManager=ut,exports.KeyboardController=P,exports.LAYER_DEFAULT="Default",exports.MaskRenderer=xe,exports.MouseController=R,exports.PhysicsComponent=Ut,exports.PolygonCollider=he,exports.PreRenderComponent=Gt,exports.Rectangle=o,exports.RigidBody=Yt,exports.Rotation=s,exports.Scene=$t,exports.SceneManager=pt,exports.SpacePointer=Ve,exports.Sprite=Ee,exports.SpriteRenderer=fe,exports.TextRenderer=me,exports.TiledTilemapRenderer=_e,exports.TilemapCollider=se,exports.Tileset=De,exports.TimeManager=dt,exports.TouchController=ot,exports.Transform=Wt,exports.Vector2=t,exports.between=r,exports.clamp=e,exports.fixedRound=i,exports.randomFloat=function(t,e,n){return void 0===n&&(n=2),i(Math.random()*(e-t)+t,n)},exports.randomInt=function(t,e){return Math.round(Math.random()*(e-t))+t},exports.range=n;