excalibur 0.25.0 → 0.25.1
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.
- package/.nvmrc +1 -1
- package/CHANGELOG.md +49 -9
- package/LICENSE.md +1 -1
- package/README.md +8 -12
- package/build/dist/Actions/Action/Blink.d.ts +3 -3
- package/build/dist/Actions/Action/Delay.d.ts +1 -5
- package/build/dist/Actions/Action/Die.d.ts +3 -5
- package/build/dist/Actions/Action/EaseTo.d.ts +4 -2
- package/build/dist/Actions/Action/Fade.d.ts +3 -3
- package/build/dist/Actions/Action/Follow.d.ts +6 -4
- package/build/dist/Actions/Action/Meet.d.ts +6 -4
- package/build/dist/Actions/Action/MoveBy.d.ts +6 -4
- package/build/dist/Actions/Action/MoveTo.d.ts +6 -4
- package/build/dist/Actions/Action/Repeat.d.ts +2 -2
- package/build/dist/Actions/Action/RepeatForever.d.ts +2 -2
- package/build/dist/Actions/Action/RotateBy.d.ts +4 -3
- package/build/dist/Actions/Action/RotateTo.d.ts +4 -3
- package/build/dist/Actions/Action/ScaleBy.d.ts +4 -3
- package/build/dist/Actions/Action/ScaleTo.d.ts +4 -3
- package/build/dist/Actions/Action.d.ts +2 -2
- package/build/dist/Actions/ActionContext.d.ts +16 -10
- package/build/dist/Actions/ActionQueue.d.ts +3 -3
- package/build/dist/Actions/ActionsComponent.d.ts +236 -0
- package/build/dist/Actions/ActionsSystem.d.ts +9 -0
- package/build/dist/Actions/Index.d.ts +2 -0
- package/build/dist/Actor.d.ts +10 -8
- package/build/dist/Engine.d.ts +6 -1
- package/build/dist/EntityComponentSystem/EntityManager.d.ts +1 -0
- package/build/dist/Graphics/Animation.d.ts +64 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.d.ts +1 -1
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +6 -0
- package/build/dist/Graphics/GraphicsComponent.d.ts +2 -0
- package/build/dist/Loader.css +1 -0
- package/build/dist/Loader.d.ts +1 -0
- package/build/dist/Screen.d.ts +3 -0
- package/build/dist/excalibur.js +14369 -13942
- package/build/dist/excalibur.js.map +1 -1
- package/build/dist/excalibur.min.js +1 -1
- package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
- package/build/dist/excalibur.min.js.map +1 -1
- package/build/esm/Actions/Action/Blink.d.ts +17 -0
- package/build/esm/Actions/Action/CallMethod.d.ts +10 -0
- package/build/esm/Actions/Action/Delay.d.ts +12 -0
- package/build/esm/Actions/Action/Die.d.ts +11 -0
- package/build/esm/Actions/Action/EaseTo.d.ts +21 -0
- package/build/esm/Actions/Action/Fade.d.ts +17 -0
- package/build/esm/Actions/Action/Follow.d.ts +23 -0
- package/build/esm/Actions/Action/Meet.d.ts +23 -0
- package/build/esm/Actions/Action/MoveBy.d.ts +22 -0
- package/build/esm/Actions/Action/MoveTo.d.ts +21 -0
- package/build/esm/Actions/Action/Repeat.d.ts +16 -0
- package/build/esm/Actions/Action/RepeatForever.d.ts +20 -0
- package/build/esm/Actions/Action/RotateBy.d.ts +27 -0
- package/build/esm/Actions/Action/RotateTo.d.ts +26 -0
- package/build/esm/Actions/Action/ScaleBy.d.ts +24 -0
- package/build/esm/Actions/Action/ScaleTo.d.ts +23 -0
- package/build/esm/Actions/Action.d.ts +10 -0
- package/build/esm/Actions/ActionContext.d.ts +219 -0
- package/build/esm/Actions/ActionQueue.d.ts +56 -0
- package/build/esm/Actions/Actionable.d.ts +4 -0
- package/build/esm/Actions/ActionsComponent.d.ts +236 -0
- package/build/esm/Actions/ActionsSystem.d.ts +9 -0
- package/build/{dist/Actions/Index.js → esm/Actions/Index.d.ts} +2 -1
- package/build/{dist/Actions/RotationType.js → esm/Actions/RotationType.d.ts} +6 -8
- package/build/esm/Actor.d.ts +727 -0
- package/build/esm/Camera.d.ts +360 -0
- package/build/{dist/Class.js → esm/Class.d.ts} +12 -17
- package/build/esm/Collision/BodyComponent.d.ts +208 -0
- package/build/esm/Collision/BoundingBox.d.ts +109 -0
- package/build/esm/Collision/ColliderComponent.d.ts +98 -0
- package/build/esm/Collision/Colliders/CircleCollider.d.ts +92 -0
- package/build/esm/Collision/Colliders/ClosestLineJumpTable.d.ts +23 -0
- package/build/esm/Collision/Colliders/Collider.d.ts +94 -0
- package/build/esm/Collision/Colliders/CollisionJumpTable.d.ts +14 -0
- package/build/esm/Collision/Colliders/CompositeCollider.d.ts +38 -0
- package/build/esm/Collision/Colliders/EdgeCollider.d.ts +112 -0
- package/build/esm/Collision/Colliders/PolygonCollider.d.ts +138 -0
- package/build/esm/Collision/Colliders/SeparatingAxis.d.ts +46 -0
- package/build/esm/Collision/Colliders/Shape.d.ts +54 -0
- package/build/esm/Collision/CollisionSystem.d.ts +26 -0
- package/build/{dist/Collision/CollisionType.js → esm/Collision/CollisionType.d.ts} +6 -8
- package/build/esm/Collision/Detection/CollisionContact.d.ts +53 -0
- package/build/esm/Collision/Detection/CollisionProcessor.d.ts +28 -0
- package/build/esm/Collision/Detection/DynamicTree.d.ts +85 -0
- package/build/esm/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +40 -0
- package/build/esm/Collision/Detection/Pair.d.ts +31 -0
- package/build/{dist/Collision/Group/CollisionGroup.js → esm/Collision/Group/CollisionGroup.d.ts} +17 -36
- package/build/esm/Collision/Group/CollisionGroupManager.d.ts +30 -0
- package/build/{dist/Collision/Index.js → esm/Collision/Index.d.ts} +0 -1
- package/build/esm/Collision/Integrator.d.ts +6 -0
- package/build/esm/Collision/MotionSystem.d.ts +11 -0
- package/build/esm/Collision/Physics.d.ts +133 -0
- package/build/esm/Collision/Side.d.ts +21 -0
- package/build/esm/Collision/Solver/ArcadeSolver.d.ts +15 -0
- package/build/esm/Collision/Solver/ContactConstraintPoint.d.ts +43 -0
- package/build/esm/Collision/Solver/RealisticSolver.d.ts +21 -0
- package/build/esm/Collision/Solver/Solver.d.ts +50 -0
- package/build/esm/Color.d.ts +244 -0
- package/build/esm/Configurable.d.ts +9 -0
- package/build/esm/Debug/Debug.d.ts +327 -0
- package/build/esm/Debug/DebugFlags.d.ts +11 -0
- package/build/esm/Debug/DebugSystem.d.ts +29 -0
- package/build/{dist/Debug/index.js → esm/Debug/index.d.ts} +0 -1
- package/build/esm/Deprecated.d.ts +0 -0
- package/build/esm/Drawing/Animation.d.ts +196 -0
- package/build/esm/Drawing/CanvasDrawComponent.d.ts +10 -0
- package/build/esm/Drawing/CanvasDrawingSystem.d.ts +23 -0
- package/build/esm/Drawing/Index.d.ts +9 -0
- package/build/esm/Drawing/Polygon.d.ts +74 -0
- package/build/esm/Drawing/Sprite.d.ts +159 -0
- package/build/esm/Drawing/SpriteEffects.d.ts +120 -0
- package/build/esm/Drawing/SpriteSheet.d.ts +184 -0
- package/build/esm/Drawing/Texture.d.ts +44 -0
- package/build/esm/Engine.d.ts +586 -0
- package/build/esm/EntityComponentSystem/Component.d.ts +69 -0
- package/build/esm/EntityComponentSystem/Components/MotionComponent.d.ts +55 -0
- package/build/esm/EntityComponentSystem/Components/TransformComponent.d.ts +103 -0
- package/build/esm/EntityComponentSystem/Entity.d.ts +247 -0
- package/build/esm/EntityComponentSystem/EntityManager.d.ts +35 -0
- package/build/esm/EntityComponentSystem/Query.d.ts +51 -0
- package/build/esm/EntityComponentSystem/QueryManager.d.ts +48 -0
- package/build/esm/EntityComponentSystem/System.d.ts +107 -0
- package/build/esm/EntityComponentSystem/SystemManager.d.ts +45 -0
- package/build/esm/EntityComponentSystem/Util.d.ts +1 -0
- package/build/esm/EntityComponentSystem/World.d.ts +45 -0
- package/build/{dist/EntityComponentSystem/index.js → esm/EntityComponentSystem/index.d.ts} +0 -1
- package/build/esm/EventDispatcher.d.ts +51 -0
- package/build/esm/Events/MediaEvents.d.ts +47 -0
- package/build/esm/Events.d.ts +475 -0
- package/build/esm/Flags.d.ts +62 -0
- package/build/esm/Graphics/Animation.d.ts +189 -0
- package/build/esm/Graphics/Canvas.d.ts +24 -0
- package/build/esm/Graphics/Circle.d.ts +15 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContext.d.ts +155 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +87 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +111 -0
- package/build/esm/Graphics/Context/batch.d.ts +11 -0
- package/build/esm/Graphics/Context/debug-text.d.ts +24 -0
- package/build/esm/Graphics/Context/draw-image-command.d.ts +47 -0
- package/build/esm/Graphics/Context/image-renderer.d.ts +39 -0
- package/build/esm/Graphics/Context/line-renderer.d.ts +22 -0
- package/build/esm/Graphics/Context/point-renderer.d.ts +22 -0
- package/build/esm/Graphics/Context/renderer.d.ts +66 -0
- package/build/esm/Graphics/Context/shader.d.ts +81 -0
- package/build/esm/Graphics/Context/state-stack.d.ts +10 -0
- package/build/esm/Graphics/Context/texture-loader.d.ts +33 -0
- package/build/esm/Graphics/Context/transform-stack.d.ts +12 -0
- package/build/esm/Graphics/Context/webgl-util.d.ts +12 -0
- package/build/esm/Graphics/Font.d.ts +57 -0
- package/build/{dist/Graphics/FontCommon.js → esm/Graphics/FontCommon.d.ts} +54 -37
- package/build/esm/Graphics/Graphic.d.ts +129 -0
- package/build/esm/Graphics/GraphicsComponent.d.ts +224 -0
- package/build/esm/Graphics/GraphicsDiagnostics.d.ts +5 -0
- package/build/esm/Graphics/GraphicsGroup.d.ts +24 -0
- package/build/esm/Graphics/GraphicsSystem.d.ts +35 -0
- package/build/esm/Graphics/ImageSource.d.ts +53 -0
- package/build/esm/Graphics/Polygon.d.ts +17 -0
- package/build/esm/Graphics/Raster.d.ts +105 -0
- package/build/esm/Graphics/Rectangle.d.ts +13 -0
- package/build/esm/Graphics/Sprite.d.ts +59 -0
- package/build/esm/Graphics/SpriteFont.d.ts +53 -0
- package/build/esm/Graphics/SpriteSheet.d.ts +137 -0
- package/build/esm/Graphics/Text.d.ts +29 -0
- package/build/{dist/Graphics/index.js → esm/Graphics/index.d.ts} +0 -4
- package/build/esm/Id.d.ts +8 -0
- package/build/esm/Input/CapturePointerConfig.d.ts +13 -0
- package/build/esm/Input/EngineInput.d.ts +8 -0
- package/build/esm/Input/Gamepad.d.ts +227 -0
- package/build/{dist/Input/Index.js → esm/Input/Index.d.ts} +0 -1
- package/build/esm/Input/Keyboard.d.ts +187 -0
- package/build/esm/Input/Pointer.d.ts +134 -0
- package/build/esm/Input/PointerEvents.d.ts +170 -0
- package/build/esm/Input/Pointers.d.ts +78 -0
- package/build/esm/Interfaces/Audio.d.ts +29 -0
- package/build/esm/Interfaces/AudioImplementation.d.ts +25 -0
- package/build/esm/Interfaces/Clonable.d.ts +3 -0
- package/build/esm/Interfaces/Drawable.d.ts +97 -0
- package/build/esm/Interfaces/Evented.d.ts +31 -0
- package/build/{dist/Interfaces/Index.js → esm/Interfaces/Index.d.ts} +0 -1
- package/build/esm/Interfaces/LifecycleEvents.d.ts +167 -0
- package/build/esm/Interfaces/Loadable.d.ts +18 -0
- package/build/esm/Interfaces/PointerEventHandlers.d.ts +40 -0
- package/build/esm/Interfaces/Trait.d.ts +9 -0
- package/build/esm/Label.d.ts +146 -0
- package/build/esm/Loader.d.ts +174 -0
- package/build/{dist/Math/Index.js → esm/Math/Index.d.ts} +0 -1
- package/build/esm/Math/Random.d.ts +125 -0
- package/build/esm/Math/global-coordinates.d.ts +10 -0
- package/build/esm/Math/line.d.ts +95 -0
- package/build/esm/Math/matrix.d.ts +110 -0
- package/build/esm/Math/projection.d.ts +10 -0
- package/build/esm/Math/ray.d.ts +25 -0
- package/build/esm/Math/vector-view.d.ts +18 -0
- package/build/esm/Math/vector.d.ts +201 -0
- package/build/esm/Particles.d.ts +244 -0
- package/build/esm/Polyfill.d.ts +6 -0
- package/build/esm/PostProcessing/ColorBlindCorrector.d.ts +28 -0
- package/build/{dist/PostProcessing/Index.js → esm/PostProcessing/Index.d.ts} +0 -1
- package/build/esm/PostProcessing/PostProcessor.d.ts +6 -0
- package/build/esm/Promises.d.ts +87 -0
- package/build/esm/Resources/Gif.d.ts +117 -0
- package/build/{dist/Resources/Index.js → esm/Resources/Index.d.ts} +0 -1
- package/build/esm/Resources/Resource.d.ts +31 -0
- package/build/esm/Resources/Sound/AudioContext.d.ts +7 -0
- package/build/{dist/Resources/Sound/Index.js → esm/Resources/Sound/Index.d.ts} +0 -1
- package/build/esm/Resources/Sound/Sound.d.ts +79 -0
- package/build/esm/Resources/Sound/WebAudioInstance.d.ts +45 -0
- package/build/esm/Scene.d.ts +301 -0
- package/build/esm/Screen.d.ts +285 -0
- package/build/esm/ScreenElement.d.ts +13 -0
- package/build/esm/TileMap.d.ts +222 -0
- package/build/esm/Timer.d.ts +93 -0
- package/build/esm/Traits/CapturePointer.d.ts +10 -0
- package/build/{dist/Traits/Index.js → esm/Traits/Index.d.ts} +0 -1
- package/build/esm/Traits/OffscreenCulling.d.ts +11 -0
- package/build/esm/Trigger.d.ts +48 -0
- package/build/esm/Util/Actors.d.ts +12 -0
- package/build/esm/Util/Browser.d.ts +28 -0
- package/build/esm/Util/CullingBox.d.ts +23 -0
- package/build/esm/Util/Decorators.d.ts +15 -0
- package/build/esm/Util/Detector.d.ts +40 -0
- package/build/esm/Util/DrawUtil.d.ts +69 -0
- package/build/esm/Util/EasingFunctions.d.ts +59 -0
- package/build/{dist/Util/Index.js → esm/Util/Index.d.ts} +0 -1
- package/build/esm/Util/Log.d.ts +109 -0
- package/build/esm/Util/Observable.d.ts +55 -0
- package/build/esm/Util/Pool.d.ts +44 -0
- package/build/esm/Util/SortedList.d.ts +52 -0
- package/build/esm/Util/Sound.d.ts +4 -0
- package/build/esm/Util/Util.d.ts +196 -0
- package/build/esm/Util/Watch.d.ts +8 -0
- package/build/esm/Util/WebAudio.d.ts +15 -0
- package/build/esm/excalibur.d.ts +2 -0
- package/build/esm/excalibur.js +28874 -0
- package/build/esm/excalibur.js.map +1 -0
- package/build/esm/excalibur.min.js +3 -0
- package/build/esm/excalibur.min.js.LICENSE.txt +7 -0
- package/build/esm/excalibur.min.js.map +1 -0
- package/build/{dist/index.js → esm/index.d.ts} +4 -18
- package/package.json +31 -25
- package/wallaby.js +2 -0
- package/build/dist/Actions/Action/Blink.js +0 -45
- package/build/dist/Actions/Action/Blink.js.map +0 -1
- package/build/dist/Actions/Action/CallMethod.js +0 -21
- package/build/dist/Actions/Action/CallMethod.js.map +0 -1
- package/build/dist/Actions/Action/Delay.js +0 -28
- package/build/dist/Actions/Action/Delay.js.map +0 -1
- package/build/dist/Actions/Action/Die.js +0 -21
- package/build/dist/Actions/Action/Die.js.map +0 -1
- package/build/dist/Actions/Action/EaseTo.js +0 -66
- package/build/dist/Actions/Action/EaseTo.js.map +0 -1
- package/build/dist/Actions/Action/Fade.js +0 -42
- package/build/dist/Actions/Action/Fade.js.map +0 -1
- package/build/dist/Actions/Action/Follow.js +0 -51
- package/build/dist/Actions/Action/Follow.js.map +0 -1
- package/build/dist/Actions/Action/Meet.js +0 -48
- package/build/dist/Actions/Action/Meet.js.map +0 -1
- package/build/dist/Actions/Action/MoveBy.js +0 -42
- package/build/dist/Actions/Action/MoveBy.js.map +0 -1
- package/build/dist/Actions/Action/MoveTo.js +0 -35
- package/build/dist/Actions/Action/MoveTo.js.map +0 -1
- package/build/dist/Actions/Action/Repeat.js +0 -31
- package/build/dist/Actions/Action/Repeat.js.map +0 -1
- package/build/dist/Actions/Action/RepeatForever.js +0 -37
- package/build/dist/Actions/Action/RepeatForever.js.map +0 -1
- package/build/dist/Actions/Action/RotateBy.js +0 -88
- package/build/dist/Actions/Action/RotateBy.js.map +0 -1
- package/build/dist/Actions/Action/RotateTo.js +0 -87
- package/build/dist/Actions/Action/RotateTo.js.map +0 -1
- package/build/dist/Actions/Action/ScaleBy.js +0 -47
- package/build/dist/Actions/Action/ScaleBy.js.map +0 -1
- package/build/dist/Actions/Action/ScaleTo.js +0 -58
- package/build/dist/Actions/Action/ScaleTo.js.map +0 -1
- package/build/dist/Actions/Action.js +0 -2
- package/build/dist/Actions/Action.js.map +0 -1
- package/build/dist/Actions/ActionContext.js +0 -297
- package/build/dist/Actions/ActionContext.js.map +0 -1
- package/build/dist/Actions/ActionQueue.js +0 -87
- package/build/dist/Actions/ActionQueue.js.map +0 -1
- package/build/dist/Actions/Actionable.js +0 -2
- package/build/dist/Actions/Actionable.js.map +0 -1
- package/build/dist/Actions/Index.js.map +0 -1
- package/build/dist/Actions/RotationType.js.map +0 -1
- package/build/dist/Actor.js +0 -856
- package/build/dist/Actor.js.map +0 -1
- package/build/dist/Camera.js +0 -627
- package/build/dist/Camera.js.map +0 -1
- package/build/dist/Class.js.map +0 -1
- package/build/dist/Collision/BodyComponent.js +0 -347
- package/build/dist/Collision/BodyComponent.js.map +0 -1
- package/build/dist/Collision/BoundingBox.js +0 -355
- package/build/dist/Collision/BoundingBox.js.map +0 -1
- package/build/dist/Collision/ColliderComponent.js +0 -201
- package/build/dist/Collision/ColliderComponent.js.map +0 -1
- package/build/dist/Collision/Colliders/CircleCollider.js +0 -215
- package/build/dist/Collision/Colliders/CircleCollider.js.map +0 -1
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +0 -211
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +0 -1
- package/build/dist/Collision/Colliders/Collider.js +0 -26
- package/build/dist/Collision/Colliders/Collider.js.map +0 -1
- package/build/dist/Collision/Colliders/CollisionJumpTable.js +0 -301
- package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +0 -1
- package/build/dist/Collision/Colliders/CompositeCollider.js +0 -232
- package/build/dist/Collision/Colliders/CompositeCollider.js.map +0 -1
- package/build/dist/Collision/Colliders/EdgeCollider.js +0 -253
- package/build/dist/Collision/Colliders/EdgeCollider.js.map +0 -1
- package/build/dist/Collision/Colliders/PolygonCollider.js +0 -389
- package/build/dist/Collision/Colliders/PolygonCollider.js.map +0 -1
- package/build/dist/Collision/Colliders/SeparatingAxis.js +0 -67
- package/build/dist/Collision/Colliders/SeparatingAxis.js.map +0 -1
- package/build/dist/Collision/Colliders/Shape.js +0 -102
- package/build/dist/Collision/Colliders/Shape.js.map +0 -1
- package/build/dist/Collision/CollisionSystem.js +0 -116
- package/build/dist/Collision/CollisionSystem.js.map +0 -1
- package/build/dist/Collision/CollisionType.js.map +0 -1
- package/build/dist/Collision/Detection/CollisionContact.js +0 -46
- package/build/dist/Collision/Detection/CollisionContact.js.map +0 -1
- package/build/dist/Collision/Detection/CollisionProcessor.js +0 -2
- package/build/dist/Collision/Detection/CollisionProcessor.js.map +0 -1
- package/build/dist/Collision/Detection/DynamicTree.js +0 -442
- package/build/dist/Collision/Detection/DynamicTree.js.map +0 -1
- package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js +0 -228
- package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js.map +0 -1
- package/build/dist/Collision/Detection/Pair.js +0 -74
- package/build/dist/Collision/Detection/Pair.js.map +0 -1
- package/build/dist/Collision/Group/CollisionGroup.js.map +0 -1
- package/build/dist/Collision/Group/CollisionGroupManager.js +0 -52
- package/build/dist/Collision/Group/CollisionGroupManager.js.map +0 -1
- package/build/dist/Collision/Index.js.map +0 -1
- package/build/dist/Collision/Integrator.js +0 -11
- package/build/dist/Collision/Integrator.js.map +0 -1
- package/build/dist/Collision/MotionSystem.js +0 -38
- package/build/dist/Collision/MotionSystem.js.map +0 -1
- package/build/dist/Collision/Physics.js +0 -163
- package/build/dist/Collision/Physics.js.map +0 -1
- package/build/dist/Collision/Side.js +0 -51
- package/build/dist/Collision/Side.js.map +0 -1
- package/build/dist/Collision/Solver/ArcadeSolver.js +0 -96
- package/build/dist/Collision/Solver/ArcadeSolver.js.map +0 -1
- package/build/dist/Collision/Solver/ContactConstraintPoint.js +0 -83
- package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +0 -1
- package/build/dist/Collision/Solver/RealisticSolver.js +0 -248
- package/build/dist/Collision/Solver/RealisticSolver.js.map +0 -1
- package/build/dist/Collision/Solver/Solver.js +0 -37
- package/build/dist/Collision/Solver/Solver.js.map +0 -1
- package/build/dist/Color.js +0 -461
- package/build/dist/Color.js.map +0 -1
- package/build/dist/Configurable.js +0 -32
- package/build/dist/Configurable.js.map +0 -1
- package/build/dist/Debug/Debug.js +0 -339
- package/build/dist/Debug/Debug.js.map +0 -1
- package/build/dist/Debug/DebugFlags.js +0 -13
- package/build/dist/Debug/DebugFlags.js.map +0 -1
- package/build/dist/Debug/DebugSystem.js +0 -242
- package/build/dist/Debug/DebugSystem.js.map +0 -1
- package/build/dist/Debug/index.js.map +0 -1
- package/build/dist/Deprecated.js +0 -2
- package/build/dist/Deprecated.js.map +0 -1
- package/build/dist/Drawing/Animation.js +0 -285
- package/build/dist/Drawing/Animation.js.map +0 -1
- package/build/dist/Drawing/CanvasDrawComponent.js +0 -16
- package/build/dist/Drawing/CanvasDrawComponent.js.map +0 -1
- package/build/dist/Drawing/CanvasDrawingSystem.js +0 -95
- package/build/dist/Drawing/CanvasDrawingSystem.js.map +0 -1
- package/build/dist/Drawing/Index.js +0 -10
- package/build/dist/Drawing/Index.js.map +0 -1
- package/build/dist/Drawing/Polygon.js +0 -129
- package/build/dist/Drawing/Polygon.js.map +0 -1
- package/build/dist/Drawing/Sprite.js +0 -356
- package/build/dist/Drawing/Sprite.js.map +0 -1
- package/build/dist/Drawing/SpriteEffects.js +0 -246
- package/build/dist/Drawing/SpriteEffects.js.map +0 -1
- package/build/dist/Drawing/SpriteSheet.js +0 -413
- package/build/dist/Drawing/SpriteSheet.js.map +0 -1
- package/build/dist/Drawing/Texture.js +0 -80
- package/build/dist/Drawing/Texture.js.map +0 -1
- package/build/dist/Engine.js +0 -871
- package/build/dist/Engine.js.map +0 -1
- package/build/dist/EntityComponentSystem/Component.js +0 -65
- package/build/dist/EntityComponentSystem/Component.js.map +0 -1
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js +0 -33
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +0 -1
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js +0 -249
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +0 -1
- package/build/dist/EntityComponentSystem/Entity.js +0 -452
- package/build/dist/EntityComponentSystem/Entity.js.map +0 -1
- package/build/dist/EntityComponentSystem/EntityManager.js +0 -121
- package/build/dist/EntityComponentSystem/EntityManager.js.map +0 -1
- package/build/dist/EntityComponentSystem/Query.js +0 -91
- package/build/dist/EntityComponentSystem/Query.js.map +0 -1
- package/build/dist/EntityComponentSystem/QueryManager.js +0 -90
- package/build/dist/EntityComponentSystem/QueryManager.js.map +0 -1
- package/build/dist/EntityComponentSystem/System.js +0 -76
- package/build/dist/EntityComponentSystem/System.js.map +0 -1
- package/build/dist/EntityComponentSystem/SystemManager.js +0 -96
- package/build/dist/EntityComponentSystem/SystemManager.js.map +0 -1
- package/build/dist/EntityComponentSystem/Util.js +0 -5
- package/build/dist/EntityComponentSystem/Util.js.map +0 -1
- package/build/dist/EntityComponentSystem/World.js +0 -55
- package/build/dist/EntityComponentSystem/World.js.map +0 -1
- package/build/dist/EntityComponentSystem/index.js.map +0 -1
- package/build/dist/EventDispatcher.js +0 -133
- package/build/dist/EventDispatcher.js.map +0 -1
- package/build/dist/Events/MediaEvents.js +0 -75
- package/build/dist/Events/MediaEvents.js.map +0 -1
- package/build/dist/Events.js +0 -497
- package/build/dist/Events.js.map +0 -1
- package/build/dist/Flags.js +0 -90
- package/build/dist/Flags.js.map +0 -1
- package/build/dist/Graphics/Animation.js +0 -230
- package/build/dist/Graphics/Animation.js.map +0 -1
- package/build/dist/Graphics/Canvas.js +0 -34
- package/build/dist/Graphics/Canvas.js.map +0 -1
- package/build/dist/Graphics/Circle.js +0 -39
- package/build/dist/Graphics/Circle.js.map +0 -1
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +0 -2
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +0 -1
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +0 -177
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +0 -1
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +0 -188
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +0 -1
- package/build/dist/Graphics/Context/batch.js +0 -24
- package/build/dist/Graphics/Context/batch.js.map +0 -1
- package/build/dist/Graphics/Context/debug-text.js +0 -47
- package/build/dist/Graphics/Context/debug-text.js.map +0 -1
- package/build/dist/Graphics/Context/draw-image-command.js +0 -179
- package/build/dist/Graphics/Context/draw-image-command.js.map +0 -1
- package/build/dist/Graphics/Context/image-renderer.js +0 -295
- package/build/dist/Graphics/Context/image-renderer.js.map +0 -1
- package/build/dist/Graphics/Context/line-renderer.js +0 -70
- package/build/dist/Graphics/Context/line-renderer.js.map +0 -1
- package/build/dist/Graphics/Context/point-renderer.js +0 -67
- package/build/dist/Graphics/Context/point-renderer.js.map +0 -1
- package/build/dist/Graphics/Context/renderer.js +0 -75
- package/build/dist/Graphics/Context/renderer.js.map +0 -1
- package/build/dist/Graphics/Context/shader.js +0 -189
- package/build/dist/Graphics/Context/shader.js.map +0 -1
- package/build/dist/Graphics/Context/state-stack.js +0 -27
- package/build/dist/Graphics/Context/state-stack.js.map +0 -1
- package/build/dist/Graphics/Context/texture-loader.js +0 -84
- package/build/dist/Graphics/Context/texture-loader.js.map +0 -1
- package/build/dist/Graphics/Context/transform-stack.js +0 -30
- package/build/dist/Graphics/Context/transform-stack.js.map +0 -1
- package/build/dist/Graphics/Context/webgl-util.js +0 -26
- package/build/dist/Graphics/Context/webgl-util.js.map +0 -1
- package/build/dist/Graphics/Font.js +0 -209
- package/build/dist/Graphics/Font.js.map +0 -1
- package/build/dist/Graphics/FontCommon.js.map +0 -1
- package/build/dist/Graphics/Graphic.js +0 -147
- package/build/dist/Graphics/Graphic.js.map +0 -1
- package/build/dist/Graphics/GraphicsComponent.js +0 -276
- package/build/dist/Graphics/GraphicsComponent.js.map +0 -1
- package/build/dist/Graphics/GraphicsDiagnostics.js +0 -9
- package/build/dist/Graphics/GraphicsDiagnostics.js.map +0 -1
- package/build/dist/Graphics/GraphicsGroup.js +0 -66
- package/build/dist/Graphics/GraphicsGroup.js.map +0 -1
- package/build/dist/Graphics/GraphicsSystem.js +0 -161
- package/build/dist/Graphics/GraphicsSystem.js.map +0 -1
- package/build/dist/Graphics/ImageSource.js +0 -117
- package/build/dist/Graphics/ImageSource.js.map +0 -1
- package/build/dist/Graphics/Polygon.js +0 -51
- package/build/dist/Graphics/Polygon.js.map +0 -1
- package/build/dist/Graphics/Raster.js +0 -209
- package/build/dist/Graphics/Raster.js.map +0 -1
- package/build/dist/Graphics/Rectangle.js +0 -24
- package/build/dist/Graphics/Rectangle.js.map +0 -1
- package/build/dist/Graphics/Sprite.js +0 -81
- package/build/dist/Graphics/Sprite.js.map +0 -1
- package/build/dist/Graphics/SpriteFont.js +0 -116
- package/build/dist/Graphics/SpriteFont.js.map +0 -1
- package/build/dist/Graphics/SpriteSheet.js +0 -116
- package/build/dist/Graphics/SpriteSheet.js.map +0 -1
- package/build/dist/Graphics/Text.js +0 -82
- package/build/dist/Graphics/Text.js.map +0 -1
- package/build/dist/Graphics/index.js.map +0 -1
- package/build/dist/Id.js +0 -8
- package/build/dist/Id.js.map +0 -1
- package/build/dist/Input/CapturePointerConfig.js +0 -5
- package/build/dist/Input/CapturePointerConfig.js.map +0 -1
- package/build/dist/Input/EngineInput.js +0 -2
- package/build/dist/Input/EngineInput.js.map +0 -1
- package/build/dist/Input/Gamepad.js +0 -358
- package/build/dist/Input/Gamepad.js.map +0 -1
- package/build/dist/Input/Index.js.map +0 -1
- package/build/dist/Input/Keyboard.js +0 -267
- package/build/dist/Input/Keyboard.js.map +0 -1
- package/build/dist/Input/Pointer.js +0 -205
- package/build/dist/Input/Pointer.js.map +0 -1
- package/build/dist/Input/PointerEvents.js +0 -309
- package/build/dist/Input/PointerEvents.js.map +0 -1
- package/build/dist/Input/Pointers.js +0 -405
- package/build/dist/Input/Pointers.js.map +0 -1
- package/build/dist/Interfaces/Audio.js +0 -2
- package/build/dist/Interfaces/Audio.js.map +0 -1
- package/build/dist/Interfaces/AudioImplementation.js +0 -11
- package/build/dist/Interfaces/AudioImplementation.js.map +0 -1
- package/build/dist/Interfaces/Clonable.js +0 -2
- package/build/dist/Interfaces/Clonable.js.map +0 -1
- package/build/dist/Interfaces/Drawable.js +0 -2
- package/build/dist/Interfaces/Drawable.js.map +0 -1
- package/build/dist/Interfaces/Evented.js +0 -2
- package/build/dist/Interfaces/Evented.js.map +0 -1
- package/build/dist/Interfaces/Index.js.map +0 -1
- package/build/dist/Interfaces/LifecycleEvents.js +0 -51
- package/build/dist/Interfaces/LifecycleEvents.js.map +0 -1
- package/build/dist/Interfaces/Loadable.js +0 -2
- package/build/dist/Interfaces/Loadable.js.map +0 -1
- package/build/dist/Interfaces/PointerEventHandlers.js +0 -2
- package/build/dist/Interfaces/PointerEventHandlers.js.map +0 -1
- package/build/dist/Interfaces/Trait.js +0 -2
- package/build/dist/Interfaces/Trait.js.map +0 -1
- package/build/dist/Label.js +0 -262
- package/build/dist/Label.js.map +0 -1
- package/build/dist/Loader.js +0 -344
- package/build/dist/Loader.js.map +0 -1
- package/build/dist/Math/Index.js.map +0 -1
- package/build/dist/Math/Random.js +0 -239
- package/build/dist/Math/Random.js.map +0 -1
- package/build/dist/Math/global-coordinates.js +0 -30
- package/build/dist/Math/global-coordinates.js.map +0 -1
- package/build/dist/Math/line.js +0 -194
- package/build/dist/Math/line.js.map +0 -1
- package/build/dist/Math/matrix.js +0 -425
- package/build/dist/Math/matrix.js.map +0 -1
- package/build/dist/Math/projection.js +0 -24
- package/build/dist/Math/projection.js.map +0 -1
- package/build/dist/Math/ray.js +0 -52
- package/build/dist/Math/ray.js.map +0 -1
- package/build/dist/Math/vector-view.js +0 -25
- package/build/dist/Math/vector-view.js.map +0 -1
- package/build/dist/Math/vector.js +0 -326
- package/build/dist/Math/vector.js.map +0 -1
- package/build/dist/Particles.js +0 -436
- package/build/dist/Particles.js.map +0 -1
- package/build/dist/Polyfill.js +0 -56
- package/build/dist/Polyfill.js.map +0 -1
- package/build/dist/PostProcessing/ColorBlindCorrector.js +0 -193
- package/build/dist/PostProcessing/ColorBlindCorrector.js.map +0 -1
- package/build/dist/PostProcessing/Index.js.map +0 -1
- package/build/dist/PostProcessing/PostProcessor.js +0 -2
- package/build/dist/PostProcessing/PostProcessor.js.map +0 -1
- package/build/dist/Promises.js +0 -205
- package/build/dist/Promises.js.map +0 -1
- package/build/dist/Resources/Gif.js +0 -490
- package/build/dist/Resources/Gif.js.map +0 -1
- package/build/dist/Resources/Index.js.map +0 -1
- package/build/dist/Resources/Resource.js +0 -74
- package/build/dist/Resources/Resource.js.map +0 -1
- package/build/dist/Resources/Sound/AudioContext.js +0 -16
- package/build/dist/Resources/Sound/AudioContext.js.map +0 -1
- package/build/dist/Resources/Sound/Index.js.map +0 -1
- package/build/dist/Resources/Sound/Sound.js +0 -257
- package/build/dist/Resources/Sound/Sound.js.map +0 -1
- package/build/dist/Resources/Sound/WebAudioInstance.js +0 -160
- package/build/dist/Resources/Sound/WebAudioInstance.js.map +0 -1
- package/build/dist/Scene.js +0 -443
- package/build/dist/Scene.js.map +0 -1
- package/build/dist/Screen.js +0 -611
- package/build/dist/Screen.js.map +0 -1
- package/build/dist/ScreenElement.js +0 -33
- package/build/dist/ScreenElement.js.map +0 -1
- package/build/dist/TileMap.js +0 -465
- package/build/dist/TileMap.js.map +0 -1
- package/build/dist/Timer.js +0 -198
- package/build/dist/Timer.js.map +0 -1
- package/build/dist/Traits/CapturePointer.js +0 -16
- package/build/dist/Traits/CapturePointer.js.map +0 -1
- package/build/dist/Traits/Index.js.map +0 -1
- package/build/dist/Traits/OffscreenCulling.js +0 -35
- package/build/dist/Traits/OffscreenCulling.js.map +0 -1
- package/build/dist/Trigger.js +0 -107
- package/build/dist/Trigger.js.map +0 -1
- package/build/dist/Util/Actors.js +0 -19
- package/build/dist/Util/Actors.js.map +0 -1
- package/build/dist/Util/Browser.js +0 -66
- package/build/dist/Util/Browser.js.map +0 -1
- package/build/dist/Util/CullingBox.js +0 -104
- package/build/dist/Util/CullingBox.js.map +0 -1
- package/build/dist/Util/Decorators.js +0 -78
- package/build/dist/Util/Decorators.js.map +0 -1
- package/build/dist/Util/Detector.js +0 -167
- package/build/dist/Util/Detector.js.map +0 -1
- package/build/dist/Util/DrawUtil.js +0 -115
- package/build/dist/Util/DrawUtil.js.map +0 -1
- package/build/dist/Util/EasingFunctions.js +0 -118
- package/build/dist/Util/EasingFunctions.js.map +0 -1
- package/build/dist/Util/Index.js.map +0 -1
- package/build/dist/Util/Log.js +0 -195
- package/build/dist/Util/Log.js.map +0 -1
- package/build/dist/Util/Observable.js +0 -60
- package/build/dist/Util/Observable.js.map +0 -1
- package/build/dist/Util/Pool.js +0 -72
- package/build/dist/Util/Pool.js.map +0 -1
- package/build/dist/Util/SortedList.js +0 -261
- package/build/dist/Util/SortedList.js.map +0 -1
- package/build/dist/Util/Sound.js +0 -22
- package/build/dist/Util/Sound.js.map +0 -1
- package/build/dist/Util/Util.js +0 -401
- package/build/dist/Util/Util.js.map +0 -1
- package/build/dist/Util/Watch.js +0 -67
- package/build/dist/Util/Watch.js.map +0 -1
- package/build/dist/Util/WebAudio.js +0 -62
- package/build/dist/Util/WebAudio.js.map +0 -1
- package/build/dist/index.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see excalibur.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ex=e():t.ex=e()}(self,(function(){return(()=>{var t={4662:(t,e,i)=>{i(3430);var s=i(8791);t.exports=s("Array","sort")},8343:(t,e,i)=>{i(4769);var s=i(9276);t.exports=s.Object.keys},7111:(t,e,i)=>{var s=i(6733),r=i(9821);t.exports=function(t){if(s(t))return t;throw TypeError(r(t)+" is not a function")}},1176:(t,e,i)=>{var s=i(5052);t.exports=function(t){if(s(t))return t;throw TypeError(String(t)+" is not an object")}},9540:(t,e,i)=>{var s=i(905),r=i(4237),n=i(3231),o=function(t){return function(e,i,o){var a,h=s(e),l=r(h.length),c=n(o,l);if(t&&i!=i){for(;l>c;)if((a=h[c++])!=a)return!0}else for(;l>c;c++)if((t||c in h)&&h[c]===i)return t||c||0;return!t&&-1}};t.exports={includes:o(!0),indexOf:o(!1)}},6038:(t,e,i)=>{"use strict";var s=i(4229);t.exports=function(t,e){var i=[][t];return!!i&&s((function(){i.call(null,e||function(){throw 1},1)}))}},3867:t=>{var e=Math.floor,i=function(t,n){var o=t.length,a=e(o/2);return o<8?s(t,n):r(i(t.slice(0,a),n),i(t.slice(a),n),n)},s=function(t,e){for(var i,s,r=t.length,n=1;n<r;){for(s=n,i=t[n];s&&e(t[s-1],i)>0;)t[s]=t[--s];s!==n++&&(t[s]=i)}return t},r=function(t,e,i){for(var s=t.length,r=e.length,n=0,o=0,a=[];n<s||o<r;)n<s&&o<r?a.push(i(t[n],e[o])<=0?t[n++]:e[o++]):a.push(n<s?t[n++]:e[o++]);return a};t.exports=i},7079:t=>{var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},1589:(t,e,i)=>{var s=i(1601),r=i(6733),n=i(7079),o=i(95)("toStringTag"),a="Arguments"==n(function(){return arguments}());t.exports=s?n:function(t){var e,i,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),o))?i:a?n(e):"Object"==(s=n(e))&&r(e.callee)?"Arguments":s}},7081:(t,e,i)=>{var s=i(816),r=i(4826),n=i(7933),o=i(1787);t.exports=function(t,e){for(var i=r(e),a=o.f,h=n.f,l=0;l<i.length;l++){var c=i[l];s(t,c)||a(t,c,h(e,c))}}},5762:(t,e,i)=>{var s=i(7400),r=i(1787),n=i(5358);t.exports=s?function(t,e,i){return r.f(t,e,n(1,i))}:function(t,e,i){return t[e]=i,t}},5358:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},7400:(t,e,i)=>{var s=i(4229);t.exports=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},2635:(t,e,i)=>{var s=i(9859),r=i(5052),n=s.document,o=r(n)&&r(n.createElement);t.exports=function(t){return o?n.createElement(t):{}}},2671:(t,e,i)=>{var s=i(598).match(/firefox\/(\d+)/i);t.exports=!!s&&+s[1]},8506:(t,e,i)=>{var s=i(598);t.exports=/MSIE|Trident/.test(s)},598:(t,e,i)=>{var s=i(1333);t.exports=s("navigator","userAgent")||""},6358:(t,e,i)=>{var s,r,n=i(9859),o=i(598),a=n.process,h=n.Deno,l=a&&a.versions||h&&h.version,c=l&&l.v8;c?r=(s=c.split("."))[0]<4?1:s[0]+s[1]:o&&(!(s=o.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=o.match(/Chrome\/(\d+)/))&&(r=s[1]),t.exports=r&&+r},9811:(t,e,i)=>{var s=i(598).match(/AppleWebKit\/(\d+)\./);t.exports=!!s&&+s[1]},8791:(t,e,i)=>{var s=i(9859),r=i(7636),n=Function.call;t.exports=function(t,e,i){return r(n,s[t].prototype[e],i)}},3837:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3103:(t,e,i)=>{var s=i(9859),r=i(7933).f,n=i(5762),o=i(7487),a=i(2079),h=i(7081),l=i(6541);t.exports=function(t,e){var i,c,d,u,p,g=t.target,_=t.global,f=t.stat;if(i=_?s:f?s[g]||a(g,{}):(s[g]||{}).prototype)for(c in e){if(u=e[c],d=t.noTargetGet?(p=r(i,c))&&p.value:i[c],!l(_?c:g+(f?".":"#")+c,t.forced)&&void 0!==d){if(typeof u==typeof d)continue;h(u,d)}(t.sham||d&&d.sham)&&n(u,"sham",!0),o(i,c,u,t)}}},4229:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},7636:(t,e,i)=>{var s=i(7111);t.exports=function(t,e,i){if(s(t),void 0===e)return t;switch(i){case 0:return function(){return t.call(e)};case 1:return function(i){return t.call(e,i)};case 2:return function(i,s){return t.call(e,i,s)};case 3:return function(i,s,r){return t.call(e,i,s,r)}}return function(){return t.apply(e,arguments)}}},1805:(t,e,i)=>{var s=i(7400),r=i(816),n=Function.prototype,o=s&&Object.getOwnPropertyDescriptor,a=r(n,"name"),h=a&&"something"===function(){}.name,l=a&&(!s||s&&o(n,"name").configurable);t.exports={EXISTS:a,PROPER:h,CONFIGURABLE:l}},1333:(t,e,i)=>{var s=i(9859),r=i(6733),n=function(t){return r(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?n(s[t]):s[t]&&s[t][e]}},5300:(t,e,i)=>{var s=i(7111);t.exports=function(t,e){var i=t[e];return null==i?void 0:s(i)}},9859:(t,e,i)=>{var s=function(t){return t&&t.Math==Math&&t};t.exports=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof i.g&&i.g)||function(){return this}()||Function("return this")()},816:(t,e,i)=>{var s=i(2991),r={}.hasOwnProperty;t.exports=Object.hasOwn||function(t,e){return r.call(s(t),e)}},5977:t=>{t.exports={}},4394:(t,e,i)=>{var s=i(7400),r=i(4229),n=i(2635);t.exports=!s&&!r((function(){return 7!=Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))},9337:(t,e,i)=>{var s=i(4229),r=i(7079),n="".split;t.exports=s((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==r(t)?n.call(t,""):Object(t)}:Object},8511:(t,e,i)=>{var s=i(6733),r=i(5353),n=Function.toString;s(r.inspectSource)||(r.inspectSource=function(t){return n.call(t)}),t.exports=r.inspectSource},6407:(t,e,i)=>{var s,r,n,o=i(8694),a=i(9859),h=i(5052),l=i(5762),c=i(816),d=i(5353),u=i(4399),p=i(5977),g=a.WeakMap;if(o||d.state){var _=d.state||(d.state=new g),f=_.get,m=_.has,w=_.set;s=function(t,e){if(m.call(_,t))throw new TypeError("Object already initialized");return e.facade=t,w.call(_,t,e),e},r=function(t){return f.call(_,t)||{}},n=function(t){return m.call(_,t)}}else{var y=u("state");p[y]=!0,s=function(t,e){if(c(t,y))throw new TypeError("Object already initialized");return e.facade=t,l(t,y,e),e},r=function(t){return c(t,y)?t[y]:{}},n=function(t){return c(t,y)}}t.exports={set:s,get:r,has:n,enforce:function(t){return n(t)?r(t):s(t,{})},getterFor:function(t){return function(e){var i;if(!h(e)||(i=r(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return i}}}},6733:t=>{t.exports=function(t){return"function"==typeof t}},6541:(t,e,i)=>{var s=i(4229),r=i(6733),n=/#|\.prototype\./,o=function(t,e){var i=h[a(t)];return i==c||i!=l&&(r(e)?s(e):!!e)},a=o.normalize=function(t){return String(t).replace(n,".").toLowerCase()},h=o.data={},l=o.NATIVE="N",c=o.POLYFILL="P";t.exports=o},5052:(t,e,i)=>{var s=i(6733);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},4231:t=>{t.exports=!1},9395:(t,e,i)=>{var s=i(6733),r=i(1333),n=i(6969);t.exports=n?function(t){return"symbol"==typeof t}:function(t){var e=r("Symbol");return s(e)&&Object(t)instanceof e}},3839:(t,e,i)=>{var s=i(6358),r=i(4229);t.exports=!!Object.getOwnPropertySymbols&&!r((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))},8694:(t,e,i)=>{var s=i(9859),r=i(6733),n=i(8511),o=s.WeakMap;t.exports=r(o)&&/native code/.test(n(o))},1787:(t,e,i)=>{var s=i(7400),r=i(4394),n=i(1176),o=i(9310),a=Object.defineProperty;e.f=s?a:function(t,e,i){if(n(t),e=o(e),n(i),r)try{return a(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},7933:(t,e,i)=>{var s=i(7400),r=i(9195),n=i(5358),o=i(905),a=i(9310),h=i(816),l=i(4394),c=Object.getOwnPropertyDescriptor;e.f=s?c:function(t,e){if(t=o(t),e=a(e),l)try{return c(t,e)}catch(t){}if(h(t,e))return n(!r.f.call(t,e),t[e])}},8151:(t,e,i)=>{var s=i(140),r=i(3837).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,r)}},894:(t,e)=>{e.f=Object.getOwnPropertySymbols},140:(t,e,i)=>{var s=i(816),r=i(905),n=i(9540).indexOf,o=i(5977);t.exports=function(t,e){var i,a=r(t),h=0,l=[];for(i in a)!s(o,i)&&s(a,i)&&l.push(i);for(;e.length>h;)s(a,i=e[h++])&&(~n(l,i)||l.push(i));return l}},5632:(t,e,i)=>{var s=i(140),r=i(3837);t.exports=Object.keys||function(t){return s(t,r)}},9195:(t,e)=>{"use strict";var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,r=s&&!i.call({1:2},1);e.f=r?function(t){var e=s(this,t);return!!e&&e.enumerable}:i},2914:(t,e,i)=>{var s=i(6733),r=i(5052);t.exports=function(t,e){var i,n;if("string"===e&&s(i=t.toString)&&!r(n=i.call(t)))return n;if(s(i=t.valueOf)&&!r(n=i.call(t)))return n;if("string"!==e&&s(i=t.toString)&&!r(n=i.call(t)))return n;throw TypeError("Can't convert object to primitive value")}},4826:(t,e,i)=>{var s=i(1333),r=i(8151),n=i(894),o=i(1176);t.exports=s("Reflect","ownKeys")||function(t){var e=r.f(o(t)),i=n.f;return i?e.concat(i(t)):e}},9276:(t,e,i)=>{var s=i(9859);t.exports=s},7487:(t,e,i)=>{var s=i(9859),r=i(6733),n=i(816),o=i(5762),a=i(2079),h=i(8511),l=i(6407),c=i(1805).CONFIGURABLE,d=l.get,u=l.enforce,p=String(String).split("String");(t.exports=function(t,e,i,h){var l,d=!!h&&!!h.unsafe,g=!!h&&!!h.enumerable,_=!!h&&!!h.noTargetGet,f=h&&void 0!==h.name?h.name:e;r(i)&&("Symbol("===String(f).slice(0,7)&&(f="["+String(f).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!n(i,"name")||c&&i.name!==f)&&o(i,"name",f),(l=u(i)).source||(l.source=p.join("string"==typeof f?f:""))),t!==s?(d?!_&&t[e]&&(g=!0):delete t[e],g?t[e]=i:o(t,e,i)):g?t[e]=i:a(e,i)})(Function.prototype,"toString",(function(){return r(this)&&d(this).source||h(this)}))},8885:t=>{t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},2079:(t,e,i)=>{var s=i(9859);t.exports=function(t,e){try{Object.defineProperty(s,t,{value:e,configurable:!0,writable:!0})}catch(i){s[t]=e}return e}},4399:(t,e,i)=>{var s=i(3036),r=i(1441),n=s("keys");t.exports=function(t){return n[t]||(n[t]=r(t))}},5353:(t,e,i)=>{var s=i(9859),r=i(2079),n=s["__core-js_shared__"]||r("__core-js_shared__",{});t.exports=n},3036:(t,e,i)=>{var s=i(4231),r=i(5353);(t.exports=function(t,e){return r[t]||(r[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.18.1",mode:s?"pure":"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})},3231:(t,e,i)=>{var s=i(6051),r=Math.max,n=Math.min;t.exports=function(t,e){var i=s(t);return i<0?r(i+e,0):n(i,e)}},905:(t,e,i)=>{var s=i(9337),r=i(8885);t.exports=function(t){return s(r(t))}},6051:t=>{var e=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:e)(t)}},4237:(t,e,i)=>{var s=i(6051),r=Math.min;t.exports=function(t){return t>0?r(s(t),9007199254740991):0}},2991:(t,e,i)=>{var s=i(8885);t.exports=function(t){return Object(s(t))}},2066:(t,e,i)=>{var s=i(5052),r=i(9395),n=i(5300),o=i(2914),a=i(95)("toPrimitive");t.exports=function(t,e){if(!s(t)||r(t))return t;var i,h=n(t,a);if(h){if(void 0===e&&(e="default"),i=h.call(t,e),!s(i)||r(i))return i;throw TypeError("Can't convert object to primitive value")}return void 0===e&&(e="number"),o(t,e)}},9310:(t,e,i)=>{var s=i(2066),r=i(9395);t.exports=function(t){var e=s(t,"string");return r(e)?e:String(e)}},1601:(t,e,i)=>{var s={};s[i(95)("toStringTag")]="z",t.exports="[object z]"===String(s)},3326:(t,e,i)=>{var s=i(1589);t.exports=function(t){if("Symbol"===s(t))throw TypeError("Cannot convert a Symbol value to a string");return String(t)}},9821:t=>{t.exports=function(t){try{return String(t)}catch(t){return"Object"}}},1441:t=>{var e=0,i=Math.random();t.exports=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++e+i).toString(36)}},6969:(t,e,i)=>{var s=i(3839);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},95:(t,e,i)=>{var s=i(9859),r=i(3036),n=i(816),o=i(1441),a=i(3839),h=i(6969),l=r("wks"),c=s.Symbol,d=h?c:c&&c.withoutSetter||o;t.exports=function(t){return n(l,t)&&(a||"string"==typeof l[t])||(a&&n(c,t)?l[t]=c[t]:l[t]=d("Symbol."+t)),l[t]}},3430:(t,e,i)=>{"use strict";var s=i(3103),r=i(7111),n=i(2991),o=i(4237),a=i(3326),h=i(4229),l=i(3867),c=i(6038),d=i(2671),u=i(8506),p=i(6358),g=i(9811),_=[],f=_.sort,m=h((function(){_.sort(void 0)})),w=h((function(){_.sort(null)})),y=c("sort"),v=!h((function(){if(p)return p<70;if(!(d&&d>3)){if(u)return!0;if(g)return g<603;var t,e,i,s,r="";for(t=65;t<76;t++){switch(e=String.fromCharCode(t),t){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(s=0;s<47;s++)_.push({k:e+s,v:i})}for(_.sort((function(t,e){return e.v-t.v})),s=0;s<_.length;s++)e=_[s].k.charAt(0),r.charAt(r.length-1)!==e&&(r+=e);return"DGBEFHACIJK"!==r}}));s({target:"Array",proto:!0,forced:m||!w||!y||!v},{sort:function(t){void 0!==t&&r(t);var e=n(this);if(v)return void 0===t?f.call(e):f.call(e,t);var i,s,h=[],c=o(e.length);for(s=0;s<c;s++)s in e&&h.push(e[s]);for(i=(h=l(h,function(t){return function(e,i){return void 0===i?-1:void 0===e?1:void 0!==t?+t(e,i)||0:a(e)>a(i)?1:-1}}(t))).length,s=0;s<i;)e[s]=h[s++];for(;s<c;)delete e[s++];return e}})},4769:(t,e,i)=>{var s=i(3103),r=i(2991),n=i(5632);s({target:"Object",stat:!0,forced:i(4229)((function(){n(1)}))},{keys:function(t){return n(r(t))}})},1388:(t,e,i)=>{"use strict";i.d(e,{Z:()=>a});var s=i(272),r=i.n(s),n=i(2609),o=i.n(n)()(r());o.push([t.id,"/* Buttons styles start */\r\n\r\nbutton#excalibur-play {\r\n display: inline-block;\r\n position: relative;\r\n z-index: 999;\r\n border-radius: 6px;\r\n border: none;\r\n /*border: 3px solid;\r\n border-color: white;\r\n box-shadow: 0 0 10px #ccc;*/\r\n padding: 1rem 1.5rem 1rem 4rem;\r\n margin: 0;\r\n text-decoration: none;\r\n background: #00b233;\r\n color: #ffffff;\r\n font-family: sans-serif;\r\n font-size: 2rem;\r\n line-height: 1;\r\n cursor: pointer;\r\n text-align: center;\r\n transition: background 250ms ease-in-out, transform 150ms ease;\r\n -webkit-appearance: none;\r\n -moz-appearance: none;\r\n\r\n -webkit-animation: excalibur-button-fadein 200ms; /* Safari, Chrome and Opera > 12.1 */\r\n -moz-animation: excalibur-button-fadein 200ms; /* Firefox < 16 */\r\n -ms-animation: excalibur-button-fadein 200ms; /* Internet Explorer */\r\n -o-animation: excalibur-button-fadein 200ms; /* Opera < 12.1 */\r\n animation: excalibur-button-fadein 200ms;\r\n}\r\n\r\n/*\r\nbutton#excalibur-play {\r\n display: none;\r\n}*/\r\n\r\nbutton#excalibur-play:after {\r\n position: absolute;\r\n content: '';\r\n border: 8px solid;\r\n border-color: transparent transparent transparent white;\r\n left: 35px;\r\n top: 24px;\r\n width: 0;\r\n height: 0;\r\n}\r\n\r\nbutton#excalibur-play:before {\r\n position: absolute;\r\n content: '';\r\n border: 3px solid;\r\n left: 19px;\r\n top: 14px;\r\n border-radius: 20px;\r\n width: 30px;\r\n height: 30px;\r\n}\r\n\r\nbutton#excalibur-play:hover,\r\nbutton#excalibur-play:focus {\r\n background: #00982c;\r\n}\r\n\r\nbutton#excalibur-play:focus {\r\n outline: 1px solid #fff;\r\n outline-offset: -4px;\r\n}\r\n\r\nbutton#excalibur-play:active {\r\n transform: scale(0.99);\r\n}\r\n\r\n@keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Firefox < 16 */\r\n@-moz-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Safari, Chrome and Opera > 12.1 */\r\n@-webkit-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Internet Explorer */\r\n@-ms-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Opera < 12.1 */\r\n@-o-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n","",{version:3,sources:["webpack://./Loader.css"],names:[],mappings:"AAAA,yBAAyB;;AAEzB;EACE,qBAAqB;EACrB,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,YAAY;EACZ;;+BAE6B;EAC7B,8BAA8B;EAC9B,SAAS;EACT,qBAAqB;EACrB,mBAAmB;EACnB,cAAc;EACd,uBAAuB;EACvB,eAAe;EACf,cAAc;EACd,eAAe;EACf,kBAAkB;EAClB,8DAA8D;EAC9D,wBAAwB;EACxB,qBAAqB;;EAErB,gDAAgD,EAAE,oCAAoC;EACtF,6CAA6C,EAAE,iBAAiB;EAChE,4CAA4C,EAAE,sBAAsB;EACpE,2CAA2C,EAAE,iBAAiB;EAC9D,wCAAwC;AAC1C;;AAEA;;;EAGE;;AAEF;EACE,kBAAkB;EAClB,WAAW;EACX,iBAAiB;EACjB,uDAAuD;EACvD,UAAU;EACV,SAAS;EACT,QAAQ;EACR,SAAS;AACX;;AAEA;EACE,kBAAkB;EAClB,WAAW;EACX,iBAAiB;EACjB,UAAU;EACV,SAAS;EACT,mBAAmB;EACnB,WAAW;EACX,YAAY;AACd;;AAEA;;EAEE,mBAAmB;AACrB;;AAEA;EACE,uBAAuB;EACvB,oBAAoB;AACtB;;AAEA;EACE,sBAAsB;AACxB;;AAEA;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,iBAAiB;AACjB;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,oCAAoC;AACpC;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,sBAAsB;AACtB;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,iBAAiB;AACjB;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF",sourcesContent:["/* Buttons styles start */\r\n\r\nbutton#excalibur-play {\r\n display: inline-block;\r\n position: relative;\r\n z-index: 999;\r\n border-radius: 6px;\r\n border: none;\r\n /*border: 3px solid;\r\n border-color: white;\r\n box-shadow: 0 0 10px #ccc;*/\r\n padding: 1rem 1.5rem 1rem 4rem;\r\n margin: 0;\r\n text-decoration: none;\r\n background: #00b233;\r\n color: #ffffff;\r\n font-family: sans-serif;\r\n font-size: 2rem;\r\n line-height: 1;\r\n cursor: pointer;\r\n text-align: center;\r\n transition: background 250ms ease-in-out, transform 150ms ease;\r\n -webkit-appearance: none;\r\n -moz-appearance: none;\r\n\r\n -webkit-animation: excalibur-button-fadein 200ms; /* Safari, Chrome and Opera > 12.1 */\r\n -moz-animation: excalibur-button-fadein 200ms; /* Firefox < 16 */\r\n -ms-animation: excalibur-button-fadein 200ms; /* Internet Explorer */\r\n -o-animation: excalibur-button-fadein 200ms; /* Opera < 12.1 */\r\n animation: excalibur-button-fadein 200ms;\r\n}\r\n\r\n/*\r\nbutton#excalibur-play {\r\n display: none;\r\n}*/\r\n\r\nbutton#excalibur-play:after {\r\n position: absolute;\r\n content: '';\r\n border: 8px solid;\r\n border-color: transparent transparent transparent white;\r\n left: 35px;\r\n top: 24px;\r\n width: 0;\r\n height: 0;\r\n}\r\n\r\nbutton#excalibur-play:before {\r\n position: absolute;\r\n content: '';\r\n border: 3px solid;\r\n left: 19px;\r\n top: 14px;\r\n border-radius: 20px;\r\n width: 30px;\r\n height: 30px;\r\n}\r\n\r\nbutton#excalibur-play:hover,\r\nbutton#excalibur-play:focus {\r\n background: #00982c;\r\n}\r\n\r\nbutton#excalibur-play:focus {\r\n outline: 1px solid #fff;\r\n outline-offset: -4px;\r\n}\r\n\r\nbutton#excalibur-play:active {\r\n transform: scale(0.99);\r\n}\r\n\r\n@keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Firefox < 16 */\r\n@-moz-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Safari, Chrome and Opera > 12.1 */\r\n@-webkit-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Internet Explorer */\r\n@-ms-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Opera < 12.1 */\r\n@-o-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n"],sourceRoot:""}]);const a=o},2609:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i="",s=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),s&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),s&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i})).join("")},e.i=function(t,i,s,r,n){"string"==typeof t&&(t=[[null,t,void 0]]);var o={};if(s)for(var a=0;a<this.length;a++){var h=this[a][0];null!=h&&(o[h]=!0)}for(var l=0;l<t.length;l++){var c=[].concat(t[l]);s&&o[c[0]]||(void 0!==n&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=n),i&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=i):c[2]=i),r&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=r):c[4]="".concat(r)),e.push(c))}},e}},272:t=>{"use strict";t.exports=function(t){var e=t[1],i=t[3];if(!i)return e;if("function"==typeof btoa){var s=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),n="/*# ".concat(r," */"),o=i.sources.map((function(t){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(t," */")}));return[e].concat(o).concat([n]).join("\n")}return[e].join("\n")}}},e={};function i(s){var r=e[s];if(void 0!==r)return r.exports;var n=e[s]={id:s,exports:{}};return t[s](n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{"use strict";i.r(s),i.d(s,{ActionContext:()=>ri,ActionQueue:()=>Be,ActivateEvent:()=>Lt,Actor:()=>Zi,AddedComponent:()=>Ii,AddedEntity:()=>Rs,Animation:()=>Zs,AnimationStrategy:()=>qs,ArcadeSolver:()=>Ws,AudioContextFactory:()=>it,Axis:()=>ds,BaseAlign:()=>es,BinaryTreeNode:()=>Wn,Blink:()=>$e,BodyComponent:()=>Bi,BoundingBox:()=>J,BroadphaseStrategy:()=>oi,BrowserComponent:()=>Or,BrowserEvents:()=>zr,Camera:()=>Cs,Canvas:()=>ie,Cell:()=>fs,Circle:()=>qi,CircleCollider:()=>Ci,Class:()=>Wt,ClosestLine:()=>xi,ClosestLineJumpTable:()=>bi,Collider:()=>wi,ColliderComponent:()=>Di,CollisionContact:()=>Ai,CollisionEndEvent:()=>kt,CollisionGroup:()=>ci,CollisionGroupManager:()=>mn,CollisionJumpTable:()=>Pi,CollisionPostSolveEvent:()=>Mt,CollisionPreSolveEvent:()=>Dt,CollisionResolutionStrategy:()=>ni,CollisionSolver:()=>Ns,CollisionStartEvent:()=>Bt,CollisionSystem:()=>js,CollisionType:()=>Xe,Color:()=>Q,ColorBlindCorrector:()=>ur,ColorBlindFlags:()=>pr,ColorBlindness:()=>sr,Component:()=>Ue,CompositeCollider:()=>yi,Configurable:()=>we,ConsoleAppender:()=>f,ContactConstraintPoint:()=>Vs,ContactEndEvent:()=>Rt,ContactStartEvent:()=>Tt,CoordPlane:()=>je,CullingBox:()=>ki,DeactivateEvent:()=>It,Debug:()=>gr,DebugSystem:()=>ir,DebugText:()=>Nr,DegreeOfFreedom:()=>Mi,Detector:()=>oe,Die:()=>ei,Direction:()=>ss,DisplayMode:()=>K,DynamicTree:()=>_i,DynamicTreeCollisionProcessor:()=>mi,EX_VERSION:()=>Kn,EaseTo:()=>Qe,EasingFunctions:()=>Me,EdgeCollider:()=>Ei,ElasticToActorStrategy:()=>vs,EmitterType:()=>Ks,Engine:()=>hn,EnterTriggerEvent:()=>Ut,EnterViewPortEvent:()=>zt,Entity:()=>Hi,EntityManager:()=>ks,EventDispatcher:()=>Nt,EventTypes:()=>Z,Events:()=>t,ExResponse:()=>vn,ExcaliburGraphicsContext2DCanvas:()=>Vr,ExcaliburGraphicsContextWebGL:()=>nn,ExitTriggerEvent:()=>Ht,ExitViewPortEvent:()=>Ot,Experiments:()=>l,Fade:()=>Je,Flags:()=>p,Follow:()=>ii,Font:()=>pn,FontStyle:()=>is,FontUnit:()=>Ji,FrameStats:()=>_r,GameEvent:()=>rt,GameStartEvent:()=>ht,GameStopEvent:()=>lt,GamepadAxisEvent:()=>xt,GamepadButtonEvent:()=>vt,GamepadConnectEvent:()=>wt,GamepadDisconnectEvent:()=>yt,Gif:()=>Fn,GlobalCoordinates:()=>Mr,Graphic:()=>Zt,GraphicsComponent:()=>ji,GraphicsGroup:()=>Ys,GraphicsLayer:()=>Vi,GraphicsLayers:()=>Gi,GraphicsSystem:()=>tr,HiddenEvent:()=>St,ImageSource:()=>ns,InitializeEvent:()=>Ft,Input:()=>o,Integrator:()=>ai,KillEvent:()=>nt,Label:()=>fn,Legacy:()=>c,LegacyDrawing:()=>n,LimitCameraBoundsStrategy:()=>bs,Line:()=>vi,Loader:()=>re,LockCameraToActorAxisStrategy:()=>ys,LockCameraToActorStrategy:()=>ws,LogLevel:()=>d,Logger:()=>_,Matrix:()=>Ve,MatrixLocations:()=>Re,MediaEvent:()=>cn,Meet:()=>si,MockedElement:()=>Vn,MotionComponent:()=>Ne,MotionSystem:()=>Hs,MoveBy:()=>Le,MoveTo:()=>Ie,NativeSoundEvent:()=>dn,NativeSoundProcessedEvent:()=>un,Observable:()=>di,Pair:()=>ui,ParseGif:()=>zn,Particle:()=>$s,ParticleEmitter:()=>Js,Physics:()=>li,PhysicsStats:()=>fr,Polygon:()=>Un,PolygonCollider:()=>Ti,Pool:()=>qr,PostCollisionEvent:()=>Et,PostDebugDrawEvent:()=>pt,PostDrawEvent:()=>dt,PostFrameEvent:()=>mt,PostKillEvent:()=>at,PostUpdateEvent:()=>_t,PreCollisionEvent:()=>Pt,PreDebugDrawEvent:()=>ut,PreDrawEvent:()=>ct,PreFrameEvent:()=>ft,PreKillEvent:()=>ot,PreUpdateEvent:()=>gt,Projection:()=>pi,Promise:()=>qn,PromiseState:()=>jn,Query:()=>Ls,QueryManager:()=>Is,RadiusAroundActorStrategy:()=>xs,Random:()=>w,Raster:()=>ee,Ray:()=>fi,RealisticSolver:()=>Gs,Rectangle:()=>Xi,RemovedComponent:()=>zi,RemovedEntity:()=>Ms,Repeat:()=>ke,RepeatForever:()=>Fe,Resolution:()=>tt,Resource:()=>ae,RotateBy:()=>ze,RotateTo:()=>Oe,RotationType:()=>Te,ScaleBy:()=>Ze,ScaleTo:()=>Ke,Scene:()=>dr,Screen:()=>et,ScreenAppender:()=>m,ScreenElement:()=>Yi,ScrollPreventionMode:()=>on,Shape:()=>Ri,Side:()=>y,SortedList:()=>Nn,Sound:()=>Bn,Sprite:()=>os,SpriteFont:()=>Hr,SpriteSheet:()=>cs,StrategyContainer:()=>ms,Stream:()=>On,SubscribeEvent:()=>bt,System:()=>Ts,SystemManager:()=>Os,SystemType:()=>Es,TagComponent:()=>He,Text:()=>gn,TextAlign:()=>ts,TileMap:()=>gs,Timer:()=>$i,Traits:()=>a,TransformComponent:()=>qe,TreeNode:()=>gi,Trigger:()=>Ps,UnsubscribeEvent:()=>Ct,Util:()=>h,Vector:()=>X,VectorView:()=>Ge,VisibleEvent:()=>At,WebAudioInstance:()=>Rn,World:()=>zs,canonicalizeAngle:()=>E,clamp:()=>A,createId:()=>g,hasGraphicsTick:()=>Wi,hasOnInitialize:()=>bn,hasOnPostUpdate:()=>Pn,hasOnPreUpdate:()=>An,hasPostDraw:()=>Tn,hasPreDraw:()=>En,has_initialize:()=>xn,has_postupdate:()=>Sn,has_preupdate:()=>Cn,isAddedComponent:()=>Oi,isAddedSystemEntity:()=>Ds,isRemoveSystemEntity:()=>Bs,isRemovedComponent:()=>Ui,maxMessages:()=>H,obsolete:()=>G,randomInRange:()=>S,randomIntInRange:()=>P,range:()=>z,resetObsoleteCounter:()=>W,toDegrees:()=>T,toRadians:()=>R,vec:()=>q});var t={};i.r(t),i.d(t,{ActivateEvent:()=>Lt,CollisionEndEvent:()=>kt,CollisionPostSolveEvent:()=>Mt,CollisionPreSolveEvent:()=>Dt,CollisionStartEvent:()=>Bt,ContactEndEvent:()=>Rt,ContactStartEvent:()=>Tt,DeactivateEvent:()=>It,EnterTriggerEvent:()=>Ut,EnterViewPortEvent:()=>zt,EventTypes:()=>Z,ExitTriggerEvent:()=>Ht,ExitViewPortEvent:()=>Ot,GameEvent:()=>rt,GameStartEvent:()=>ht,GameStopEvent:()=>lt,GamepadAxisEvent:()=>xt,GamepadButtonEvent:()=>vt,GamepadConnectEvent:()=>wt,GamepadDisconnectEvent:()=>yt,HiddenEvent:()=>St,InitializeEvent:()=>Ft,KillEvent:()=>nt,PostCollisionEvent:()=>Et,PostDebugDrawEvent:()=>pt,PostDrawEvent:()=>dt,PostFrameEvent:()=>mt,PostKillEvent:()=>at,PostUpdateEvent:()=>_t,PreCollisionEvent:()=>Pt,PreDebugDrawEvent:()=>ut,PreDrawEvent:()=>ct,PreFrameEvent:()=>ft,PreKillEvent:()=>ot,PreUpdateEvent:()=>gt,SubscribeEvent:()=>bt,UnsubscribeEvent:()=>Ct,VisibleEvent:()=>At});var e={};i.r(e),i.d(e,{circle:()=>qt,line:()=>Vt,point:()=>Gt,roundRect:()=>Xt,vector:()=>jt});var r={};i.r(r),i.d(r,{Colorize:()=>ue,Darken:()=>ge,Desaturate:()=>fe,Fill:()=>me,Grayscale:()=>le,Invert:()=>ce,Lighten:()=>pe,Opacity:()=>de,Saturate:()=>_e});var n={};i.r(n),i.d(n,{Animation:()=>Ee,CanvasDrawComponent:()=>Ni,CanvasDrawingSystem:()=>er,Effects:()=>r,Polygon:()=>yn,Sprite:()=>be,SpriteFont:()=>ls,SpriteSheet:()=>hs,Texture:()=>Ae});var o={};i.r(o),i.d(o,{Axes:()=>Ir,Buttons:()=>Lr,Gamepad:()=>Fr,Gamepads:()=>kr,KeyEvent:()=>mr,Keyboard:()=>wr,Keys:()=>rr,NativePointerButton:()=>ar,Pointer:()=>yr,PointerButton:()=>hr,PointerCancelEvent:()=>Tr,PointerDownEvent:()=>Ar,PointerDragEvent:()=>br,PointerEnterEvent:()=>Pr,PointerEvent:()=>vr,PointerEventFactory:()=>xr,PointerLeaveEvent:()=>Er,PointerMoveEvent:()=>Sr,PointerScope:()=>or,PointerType:()=>nr,PointerUpEvent:()=>Cr,Pointers:()=>Br,WheelDeltaMode:()=>lr,WheelEvent:()=>Rr,createPointerEventByName:()=>Dr});var a={};i.r(a),i.d(a,{CapturePointer:()=>Li,OffscreenCulling:()=>Fi});var h={};i.r(h),i.d(h,{Collection:()=>I,ConsoleAppender:()=>f,DrawUtil:()=>e,EasingFunctions:()=>Me,LogLevel:()=>d,Logger:()=>_,Observable:()=>di,ScreenAppender:()=>m,TwoPI:()=>v,addItemToArray:()=>M,base64Encode:()=>b,canonicalizeAngle:()=>E,clamp:()=>A,contains:()=>k,delay:()=>U,extend:()=>x,fail:()=>O,getOppositeSide:()=>F,getPosition:()=>D,getSideFromDirection:()=>L,nullish:()=>C,randomInRange:()=>S,randomIntInRange:()=>P,range:()=>z,removeItemFromArray:()=>B,toDegrees:()=>T,toRadians:()=>R});var l,c,d;i(4662),i(8343);function u(){if("undefined"==typeof window&&(window={audioContext:function(){}}),"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setInterval(t,1e3/60)}),"undefined"==typeof window||window.cancelAnimationFrame||(window.cancelAnimationFrame=window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(){}),"undefined"!=typeof window&&!window.AudioContext){if(window.webkitAudioContext){const t=window.webkitAudioContext.prototype.decodeAudioData;window.webkitAudioContext.prototype.decodeAudioData=function(e){return new Promise((i,s)=>{t.call(this,e,i,s)})}}window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext}"undefined"==typeof window||window.devicePixelRatio||(window.devicePixelRatio=window.devicePixelRatio||1)}!function(t){t.WebGL="use-webgl"}(l||(l={})),function(t){t.Canvas="use-canvas-context",t.LegacyDrawing="use-legacy-drawing"}(c||(c={}));class p{static freeze(){p._FROZEN=!0}static _reset(){p._FROZEN=!1,p._FLAGS={}}static useWebGL(){p.enable(l.WebGL)}static useCanvasGraphicsContext(){p.enable(c.Canvas)}static useLegacyDrawing(){p.enable(c.LegacyDrawing)}static enable(t){if(this._FROZEN)throw Error("Feature flags can only be enabled before Engine constructor time");p._FLAGS[t]=!0}static disable(t){if(this._FROZEN)throw Error("Feature flags can only be disabled before Engine constructor time");p._FLAGS[t]=!1}static isEnabled(t){return!!p._FLAGS[t]}static show(){return Object.keys(p._FLAGS)}}function g(t,e){return{type:t,value:e}}p._FROZEN=!1,p._FLAGS={},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error",t[t.Fatal=4]="Fatal"}(d||(d={}));class _{constructor(){if(this._appenders=[],this.defaultLevel=d.Info,_._INSTANCE)throw new Error("Logger is a singleton");return _._INSTANCE=this,_._INSTANCE.addAppender(new f),_._INSTANCE}static getInstance(){return null==_._INSTANCE&&(_._INSTANCE=new _),_._INSTANCE}addAppender(t){this._appenders.push(t)}clearAppenders(){this._appenders.length=0}_log(t,e){null==t&&(t=this.defaultLevel);const i=this._appenders.length;for(let s=0;s<i;s++)t>=this.defaultLevel&&this._appenders[s].log(t,e)}debug(...t){this._log(d.Debug,t)}info(...t){this._log(d.Info,t)}warn(...t){this._log(d.Warn,t)}error(...t){this._log(d.Error,t)}fatal(...t){this._log(d.Fatal,t)}}_._INSTANCE=null;class f{log(t,e){if(!console&&!console.log&&console.warn&&console.error)return;const i=[];i.unshift.apply(i,e),i.unshift("["+d[t]+"] : "),t<d.Warn?console.log.apply?console.log.apply(console,i):console.log(i.join(" ")):t<d.Error?console.warn.apply?console.warn.apply(console,i):console.warn(i.join(" ")):console.error.apply?console.error.apply(console,i):console.error(i.join(" "))}}class m{constructor(t,e){this._messages=[],this._canvas=document.createElement("canvas"),this._canvas.width=t||window.innerWidth,this._canvas.height=e||window.innerHeight,this._canvas.style.position="absolute",this._ctx=this._canvas.getContext("2d"),document.body.appendChild(this._canvas)}log(t,e){const i=e.join(",");this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._messages.unshift("["+d[t]+"] : "+i);let s=10,r=1;for(let t=0;t<this._messages.length;t++)this._ctx.fillStyle="rgba(255,255,255,"+r.toFixed(2)+")",this._ctx.fillText(this._messages[t],200,s),s+=10,r=r>0?r-.05:0}}class w{constructor(t){this.seed=t,this._lowerMask=2147483647,this._upperMask=2147483648,this._w=32,this._n=624,this._m=397,this._a=2567483615,this._u=11,this._s=7,this._b=2636928640,this._t=15,this._c=4022730752,this._l=18,this._f=1812433253,this._mt=new Array(this._n),this._mt[0]=(t||Date.now())>>>0;for(let t=1;t<this._n;t++){const e=this._mt[t-1]^this._mt[t-1]>>>this._w-2;this._mt[t]=(this._f*((4294901760&e)>>>16)<<16)+this._f*(65535&e)+t>>>0}this._index=this._n}_twist(){const t=[0,this._a];let e=0,i=0;for(;i<this._n-this._m;i++)e=this._mt[i]&this._upperMask|this._mt[i+1]&this._lowerMask,this._mt[i]=this._mt[i+this._m]^e>>>1^4294967295&t[1&e];for(;i<this._n-1;i++)e=this._mt[i]&this._upperMask|this._mt[i+1]&this._lowerMask,this._mt[i]=this._mt[i+(this._m-this._n)]^e>>>1^4294967295&t[1&e];e=this._mt[this._n-1]&this._upperMask|this._mt[0]&this._lowerMask,this._mt[this._n-1]=this._mt[this._m-1]^e>>>1^4294967295&t[1&e],this._index=0}nextInt(){this._index>=this._n&&this._twist();let t=this._mt[this._index++];return t^=t>>>this._u,t^=t<<this._s&this._b,t^=t<<this._t&this._c,t^=t>>>this._l,t>>>0}next(){return this.nextInt()*(1/4294967296)}floating(t,e){return(e-t)*this.next()+t}integer(t,e){return Math.floor((e-t+1)*this.next()+t)}bool(t=.5){return this.next()<=t}pickOne(t){return t[this.integer(0,t.length-1)]}pickSet(t,e,i=!1){return i?this._pickSetWithDuplicates(t,e):this._pickSetWithoutDuplicates(t,e)}_pickSetWithoutDuplicates(t,e){if(e>t.length||e<0)throw new Error("Invalid number of elements to pick, must pick a value 0 < n <= length");if(e===t.length)return t;const i=new Array(e);let s=0;const r=t.slice(0);for(;s<e;){const t=this.integer(0,r.length-1);i[s++]=r[t],r.splice(t,1)}return i}_pickSetWithDuplicates(t,e){if(e<0)throw new Error("Invalid number of elements to pick, must pick a value 0 <= n < MAX_INT");const i=new Array(e);for(let s=0;s<e;s++)i[s]=this.pickOne(t);return i}shuffle(t){const e=t.slice(0);let i=null;for(let t=0;t<e.length-2;t++){const s=this.integer(t,e.length-1);i=e[t],e[t]=e[s],e[s]=i}return e}range(t,e,i){const s=new Array(t);for(let r=0;r<t;r++)s[r]=this.integer(e,i);return s}d4(){return this.integer(1,4)}d6(){return this.integer(1,6)}d8(){return this.integer(1,8)}d10(){return this.integer(1,10)}d12(){return this.integer(1,12)}d20(){return this.integer(1,20)}}var y;!function(t){t.None="None",t.Top="Top",t.Bottom="Bottom",t.Left="Left",t.Right="Right"}(y||(y={})),function(t){t.getOpposite=function(e){return e===t.Top?t.Bottom:e===t.Bottom?t.Top:e===t.Left?t.Right:e===t.Right?t.Left:t.None},t.fromDirection=function(e){const i=[X.Left,X.Right,X.Up,X.Down],s=[t.Left,t.Right,t.Top,t.Bottom];let r=-Number.MAX_VALUE,n=-1;for(let t=0;t<i.length;t++)i[t].dot(e)>r&&(r=i[t].dot(e),n=t);return s[n]}}(y||(y={}));const v=2*Math.PI;function x(){const t={};let e=!1,i=0;const s=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);const r="function"==typeof Object.assign;let n=null;for(n=r?Object.assign:function(i){for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e&&"[object Object]"===Object.prototype.toString.call(i[s])?t[s]=x(!0,t[s],i[s]):t[s]=i[s])};i<s;i++){const e=arguments[i];r?n(t,e):n(e)}return t}function b(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i="",s=0;for(;s<t.length;){const r=255&t.charCodeAt(s++),n=255&t.charCodeAt(s++),o=255&t.charCodeAt(s++),a=r>>2,h=(3&r)<<4|n>>4;let l,c;isNaN(n)?l=c=64:(l=(15&n)<<2|o>>6,c=isNaN(o)?64:63&o),i+=e.charAt(a)+e.charAt(h)+e.charAt(l)+e.charAt(c)}return i}function C(t,e){return null!=t?t:e}function A(t,e,i){return Math.min(Math.max(e,t),i)}function S(t,e,i=new w){return i?i.floating(t,e):t+Math.random()*(e-t)}function P(t,e,i=new w){return i?i.integer(t,e):Math.round(S(t,e))}function E(t){let e=t;if(t>v)for(;e>v;)e-=v;if(t<0)for(;e<0;)e+=v;return e}function T(t){return 180/Math.PI*t}function R(t){return t/180*Math.PI}function D(t){let e=0,i=0;const s=t=>{e+=t.offsetLeft,t.offsetParent&&s(t.offsetParent)},r=t=>{i+=t.offsetTop,t.offsetParent&&r(t.offsetParent)};return s(t),r(t),new X(e,i)}function M(t,e){return-1===e.indexOf(t)&&(e.push(t),!0)}function B(t,e){let i=-1;return(i=e.indexOf(t))>-1&&(e.splice(i,1),!0)}function k(t,e){for(let i=0;i<t.length;i++)if(t[i]===e)return!0;return!1}function F(t){return t===y.Top?y.Bottom:t===y.Bottom?y.Top:t===y.Left?y.Right:t===y.Right?y.Left:y.None}function L(t){const e=[X.Left,X.Right,X.Up,X.Down],i=[y.Left,y.Right,y.Top,y.Bottom];let s=-Number.MAX_VALUE,r=-1;for(let i=0;i<e.length;i++)e[i].dot(t)>s&&(s=e[i].dot(t),r=i);return i[r]}class I{constructor(t=I.DefaultSize){this._internalArray=null,this._endPointer=0,this._internalArray=new Array(t)}_resize(){const t=2*this._internalArray.length,e=new Array(t),i=this.count();for(let t=0;t<i;t++)e[t]=this._internalArray[t];delete this._internalArray,this._internalArray=e}push(t){return this._endPointer===this._internalArray.length&&this._resize(),this._internalArray[this._endPointer++]=t}pop(){return this._endPointer=this._endPointer-1<0?0:this._endPointer-1,this._internalArray[this._endPointer]}count(){return this._endPointer}clear(){this._endPointer=0}internalSize(){return this._internalArray.length}elementAt(t){if(t>=this.count())throw new Error("Invalid index "+t);return this._internalArray[t]}insert(t,e){return t>=this.count()&&this._resize(),this._internalArray[t]=e}remove(t){const e=this.count();if(0===e)throw new Error("Invalid parameter "+t);const i=this._internalArray[t];for(let i=t;i<e;i++)this._internalArray[i]=this._internalArray[i+1];return this._endPointer--,i}removeElement(t){const e=this._internalArray.indexOf(t);this.remove(e)}toArray(){return this._internalArray.slice(0,this._endPointer)}forEach(t){let e=0;const i=this.count();for(;e<i;e++)t.call(this,this._internalArray[e],e)}map(t){const e=this.count();for(let i=0;i<e;i++)this._internalArray[i]=t.call(this,this._internalArray[i],i)}}function O(t){throw new Error(t)}I.DefaultSize=200;const z=(t,e)=>Array.from(new Array(e-t+1),(e,i)=>i+t);function U(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}const H=5,N={},W=()=>{for(const t in N)N[t]=0},V=(t,e)=>{const i=p.isEnabled("suppress-obsolete-message");N[t]<H&&!i&&(_.getInstance().warn(t),console.trace&&e.showStackTrace&&console.trace()),N[t]++};function G(t){return t=x({},{message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrack:!1},t),function(e,i,s){if(s&&"function"!=typeof s.value&&"function"!=typeof s.get&&"function"!=typeof s.set)throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const r=`${`${e.name||""}${e.name&&i?".":""}${i||""}`} is marked obsolete: ${t.message}`+(t.alternateMethod?` Use ${t.alternateMethod} instead`:"");N[r]||(N[r]=0);const n=s?Object.assign({},s):e;if(!s){class e extends n{constructor(...e){V(r,t),super(...e)}}return e}return s&&s.value?(n.value=function(){return V(r,t),s.value.apply(this,arguments)},n):(s&&s.get&&(n.get=function(){return V(r,t),s.get.apply(this,arguments)}),s&&s.set&&(n.set=function(){return V(r,t),s.set.apply(this,arguments)}),n)}}var j=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class X{constructor(t,e){this._x=0,this._y=0,this._x=t,this._y=e}static get Zero(){return new X(0,0)}static get One(){return new X(1,1)}static get Half(){return new X(.5,.5)}static get Up(){return new X(0,-1)}static get Down(){return new X(0,1)}static get Left(){return new X(-1,0)}static get Right(){return new X(1,0)}static fromAngle(t){return new X(Math.cos(t),Math.sin(t))}static isValid(t){return null!=t&&(!isNaN(t.x)&&!isNaN(t.y)&&(t.x!==1/0&&t.y!==1/0&&t.x!==-1/0&&t.y!==-1/0))}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}get x(){return this._x}set x(t){this._x=t}get y(){return this._y}set y(t){this._y=t}setTo(t,e){this.x=t,this.y=e}equals(t,e=.001){return Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e}distance(t){return t||(t=X.Zero),Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))}squareDistance(t){return t||(t=X.Zero),Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2)}magnitude(){return this.distance()}get size(){return this.distance()}set size(t){const e=this.normalize().scale(t);this.setTo(e.x,e.y)}normalize(){const t=this.distance();return t>0?new X(this.x/t,this.y/t):new X(0,1)}average(t){return this.add(t).scale(.5)}scale(t){return t instanceof X?new X(this.x*t.x,this.y*t.y):new X(this.x*t,this.y*t)}add(t){return new X(this.x+t.x,this.y+t.y)}sub(t){return new X(this.x-t.x,this.y-t.y)}addEqual(t){return this.setTo(this.x+t.x,this.y+t.y),this}subEqual(t){return this.setTo(this.x-t.x,this.y-t.y),this}scaleEqual(t){return this.setTo(this.x*t,this.y*t),this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return t instanceof X?this.x*t.y-this.y*t.x:"number"==typeof t?new X(t*this.y,-t*this.x):void 0}static cross(t,e){return new X(-t*e.y,t*e.x)}perpendicular(){return new X(this.y,-this.x)}normal(){return this.perpendicular().normalize()}negate(){return this.scale(-1)}toAngle(){return Math.atan2(this.y,this.x)}rotate(t,e){e||(e=new X(0,0));const i=Math.sin(t),s=Math.cos(t),r=s*(this.x-e.x)-i*(this.y-e.y)+e.x,n=i*(this.x-e.x)+s*(this.y-e.y)+e.y;return new X(r,n)}clone(){return new X(this.x,this.y)}toString(t){return t?`(${this.x.toFixed(t)}, ${this.y.toFixed(t)})`:`(${this.x}, ${this.y})`}}function q(t,e){return new X(t,e)}j([G({message:"will be removed in favour of `.size` in version 0.25.0"})],X.prototype,"magnitude",null);var K,Z,Y=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class Q{constructor(t,e,i,s){this.r=t,this.g=e,this.b=i,this.a=null!=s?s:1}static fromRGB(t,e,i,s){return new Q(t,e,i,s)}static fromRGBString(t){let e=null;if(e=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i)){const t=parseInt(e[1],10),i=parseInt(e[2],10),s=parseInt(e[3],10);let r=1;return e[4]&&(r=parseFloat(e[4])),new Q(t,i,s,r)}throw new Error("Invalid rgb/a string: "+t)}static fromHex(t){let e=null;if(e=t.match(/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i)){const t=parseInt(e[1],16),i=parseInt(e[2],16),s=parseInt(e[3],16);let r=1;return e[4]&&(r=parseInt(e[4],16)/255),new Q(t,i,s,r)}throw new Error("Invalid hex string: "+t)}static fromHSL(t,e,i,s=1){return new $(t,e,i,s).toRGBA()}lighten(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.l+=(1-e.l)*t,e.toRGBA()}darken(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.l-=e.l*t,e.toRGBA()}saturate(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.s+=e.s*t,e.toRGBA()}desaturate(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.s-=e.s*t,e.toRGBA()}multiply(t){const e=t.r/255*this.r/255*255,i=t.g/255*this.g/255*255,s=t.b/255*this.b/255*255,r=t.a*this.a;return new Q(e,i,s,r)}mulitiply(t){return this.multiply(t)}screen(t){const e=t.invert(),i=t.invert();return e.multiply(i).invert()}invert(){return new Q(255-this.r,255-this.g,255-this.b,1-this.a)}average(t){const e=(t.r+this.r)/2,i=(t.g+this.g)/2,s=(t.b+this.b)/2,r=(t.a+this.a)/2;return new Q(e,i,s,r)}equal(t){return this.toString()===t.toString()}toString(t="rgb"){switch(t){case"rgb":return this.toRGBA();case"hsl":return this.toHSLA();case"hex":return this.toHex();default:throw new Error("Invalid Color format")}}_componentToHex(t){const e=t.toString(16);return 1===e.length?"0"+e:e}toHex(){return"#"+this._componentToHex(this.r)+this._componentToHex(this.g)+this._componentToHex(this.b)}toRGBA(){const t=String(this.r.toFixed(0))+", "+String(this.g.toFixed(0))+", "+String(this.b.toFixed(0));return void 0!==this.a||null!==this.a?"rgba("+t+", "+String(this.a)+")":"rgb("+t+")"}toHSLA(){return $.fromRGBA(this.r,this.g,this.b,this.a).toString()}fillStyle(){return this.toString()}clone(){return new Q(this.r,this.g,this.b,this.a)}static get Black(){return Q.fromHex("#000000")}static get White(){return Q.fromHex("#FFFFFF")}static get Gray(){return Q.fromHex("#808080")}static get LightGray(){return Q.fromHex("#D3D3D3")}static get DarkGray(){return Q.fromHex("#A9A9A9")}static get Yellow(){return Q.fromHex("#FFFF00")}static get Orange(){return Q.fromHex("#FFA500")}static get Red(){return Q.fromHex("#FF0000")}static get Vermilion(){return Q.fromHex("#FF5B31")}static get Vermillion(){return Q.Vermilion}static get Rose(){return Q.fromHex("#FF007F")}static get Magenta(){return Q.fromHex("#FF00FF")}static get Violet(){return Q.fromHex("#7F00FF")}static get Blue(){return Q.fromHex("#0000FF")}static get Azure(){return Q.fromHex("#007FFF")}static get Cyan(){return Q.fromHex("#00FFFF")}static get Viridian(){return Q.fromHex("#59978F")}static get Green(){return Q.fromHex("#00FF00")}static get Chartreuse(){return Q.fromHex("#7FFF00")}static get Transparent(){return Q.fromHex("#FFFFFF00")}static get ExcaliburBlue(){return Q.fromHex("#176BAA")}}Y([G({message:"Alias for incorrect spelling used in older versions, use multiply instead, will be removed in v0.25.0"})],Q.prototype,"mulitiply",null),Y([G({message:"Alias for incorrect spelling used in older versions",alternateMethod:"Vermilion"})],Q,"Vermillion",null);class ${constructor(t,e,i,s){this.h=t,this.s=e,this.l=i,this.a=s}static hue2rgb(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}static fromRGBA(t,e,i,s){t/=255,e/=255,i/=255;const r=Math.max(t,e,i),n=Math.min(t,e,i);let o,a;const h=(r+n)/2;if(r===n)o=a=0;else{const s=r-n;switch(a=h>.5?s/(2-r-n):s/(r+n),r){case t:o=(e-i)/s+(e<i?6:0);break;case e:o=(i-t)/s+2;break;case i:o=(t-e)/s+4}o/=6}return new $(o,a,h,s)}toRGBA(){let t,e,i;if(0===this.s)t=e=i=this.l;else{const s=this.l<.5?this.l*(1+this.s):this.l+this.s-this.l*this.s,r=2*this.l-s;t=$.hue2rgb(r,s,this.h+1/3),e=$.hue2rgb(r,s,this.h),i=$.hue2rgb(r,s,this.h-1/3)}return new Q(255*t,255*e,255*i,this.a)}toString(){return`hsla(${this.h.toFixed(0)}, ${this.s.toFixed(0)}, ${this.l.toFixed(0)}, ${this.a.toFixed(0)})`}}class J{constructor(t=0,e=0,i=0,s=0){"object"==typeof t?(this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom):"number"==typeof t&&(this.left=t,this.top=e,this.right=i,this.bottom=s)}static getSideFromIntersection(t){return t&&t?Math.abs(t.x)>Math.abs(t.y)?t.x<0?y.Right:y.Left:t.y<0?y.Bottom:y.Top:y.None}static fromPoints(t){let e=1/0,i=1/0,s=-1/0,r=-1/0;for(let n=0;n<t.length;n++)t[n].x<e&&(e=t[n].x),t[n].x>s&&(s=t[n].x),t[n].y<i&&(i=t[n].y),t[n].y>r&&(r=t[n].y);return new J(e,i,s,r)}static fromDimension(t,e,i=X.Half,s=X.Zero){return new J(-t*i.x+s.x,-e*i.y+s.y,t-t*i.x+s.x,e-e*i.y+s.y)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}hasZeroDimensions(){return 0===this.width||0===this.height}get center(){return new X((this.left+this.right)/2,(this.top+this.bottom)/2)}translate(t){return new J(this.left+t.x,this.top+t.y,this.right+t.x,this.bottom+t.y)}rotate(t,e=X.Zero){const i=this.getPoints().map(i=>i.rotate(t,e));return J.fromPoints(i)}scale(t,e=X.Zero){const i=this.translate(e);return new J(i.left*t.x,i.top*t.y,i.right*t.x,i.bottom*t.y)}transform(t){const e=this.getPoints().map(e=>t.multv(e));return J.fromPoints(e)}getPerimeter(){return 2*(this.width+this.height)}getPoints(){const t=[];return t.push(new X(this.left,this.top)),t.push(new X(this.right,this.top)),t.push(new X(this.right,this.bottom)),t.push(new X(this.left,this.bottom)),t}rayCast(t,e=1/0){let i=-1/0,s=1/0;const r=0===t.dir.x?Number.MAX_VALUE:1/t.dir.x,n=0===t.dir.y?Number.MAX_VALUE:1/t.dir.y,o=(this.left-t.pos.x)*r,a=(this.right-t.pos.x)*r;i=Math.min(o,a),s=Math.max(o,a);const h=(this.top-t.pos.y)*n,l=(this.bottom-t.pos.y)*n;return i=Math.max(i,Math.min(h,l)),s=Math.min(s,Math.max(h,l)),s>=Math.max(0,i)&&i<e}rayCastTime(t,e=1/0){let i=-1/0,s=1/0;const r=0===t.dir.x?Number.MAX_VALUE:1/t.dir.x,n=0===t.dir.y?Number.MAX_VALUE:1/t.dir.y,o=(this.left-t.pos.x)*r,a=(this.right-t.pos.x)*r;i=Math.min(o,a),s=Math.max(o,a);const h=(this.top-t.pos.y)*n,l=(this.bottom-t.pos.y)*n;return i=Math.max(i,Math.min(h,l)),s=Math.min(s,Math.max(h,l)),s>=Math.max(0,i)&&i<e?i:-1}contains(t){return t instanceof X?this.left<=t.x&&this.top<=t.y&&this.bottom>=t.y&&this.right>=t.x:t instanceof J&&(this.left<t.left&&this.top<t.top&&t.bottom<this.bottom&&t.right<this.right)}combine(t){return new J(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom))}get dimensions(){return new X(this.width,this.height)}intersect(t){const e=this.combine(t);if(e.width<t.width+this.width&&e.height<t.height+this.height&&!e.dimensions.equals(t.dimensions)&&!e.dimensions.equals(this.dimensions)){let e=0;e=this.right>=t.left&&this.right<=t.right?t.left-this.right:t.right-this.left;let i=0;return i=this.top<=t.bottom&&this.top>=t.top?t.bottom-this.top:t.top-this.bottom,Math.abs(e)<Math.abs(i)?new X(e,0):new X(0,i)}if(e.dimensions.equals(t.dimensions)||e.dimensions.equals(this.dimensions)){let e=0;e=this.width-t.width>=0?this.right-t.right<=t.left-this.left?t.left-this.right:t.right-this.left:t.right-this.right<=this.left-t.left?this.left-t.right:this.right-t.left;let i=0;return i=this.height-t.height>=0?this.bottom-t.bottom<=t.top-this.top?t.top-this.bottom:t.bottom-this.top:t.bottom-this.bottom<=this.top-t.top?this.top-t.bottom:this.bottom-t.top,Math.abs(e)<Math.abs(i)?new X(e,0):new X(0,i)}return null}intersectWithSide(t){const e=this.intersect(t);return J.getSideFromIntersection(e)}debugDraw(t,e=Q.Yellow){t.strokeStyle=e.toString(),t.strokeRect(this.left,this.top,this.width,this.height)}draw(t,e=Q.Yellow){t.debug.drawRect(this.left,this.top,this.width,this.height,{color:e})}}!function(t){t.Fixed="Fixed",t.FitScreen="FitScreen",t.FillScreen="FillScreen",t.FitContainer="FitContainer",t.FillContainer="FillContainer",t.Position="Position"}(K||(K={}));class tt{static get SVGA(){return{width:800,height:600}}static get Standard(){return{width:1920,height:1080}}static get Atari2600(){return{width:160,height:192}}static get GameBoy(){return{width:160,height:144}}static get GameBoyAdvance(){return{width:240,height:160}}static get NintendoDS(){return{width:256,height:192}}static get NES(){return{width:256,height:224}}static get SNES(){return{width:256,height:244}}}class et{constructor(t){var e,i,s;this._antialiasing=!0,this._resolutionStack=[],this._viewportStack=[],this._pixelRatioOverride=null,this._isFullScreen=!1,this._isDisposed=!1,this._logger=_.getInstance(),this._fullscreenChangeHandler=()=>{this._isFullScreen=!this._isFullScreen,this._logger.debug("Fullscreen Change",this._isFullScreen)},this._pixelRatioChangeHandler=()=>{this._logger.debug("Pixel Ratio Change",window.devicePixelRatio),this._devicePixelRatio=this._calculateDevicePixelRatio(),this.applyResolutionAndViewport()},this._resizeHandler=()=>{const t=this.parent;this._logger.debug("View port resized"),this._setResolutionAndViewportByDisplayMode(t),this.applyResolutionAndViewport()},this._devicePixelRatio=this._calculateDevicePixelRatio(),this.viewport=t.viewport,this.resolution=null!==(e=t.resolution)&&void 0!==e?e:Object.assign({},this.viewport),this._displayMode=null!==(i=t.displayMode)&&void 0!==i?i:K.Fixed,this._canvas=t.canvas,this._ctx=t.context,this._antialiasing=null!==(s=t.antialiasing)&&void 0!==s?s:this._antialiasing,this._browser=t.browser,this._position=t.position,this._pixelRatioOverride=t.pixelRatio,this._applyDisplayMode(),this._mediaQueryList=this._browser.window.nativeComponent.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._mediaQueryList.addEventListener("change",this._pixelRatioChangeHandler),this._canvas.addEventListener("fullscreenchange",this._fullscreenChangeHandler)}dispose(){this._isDisposed||(this._isDisposed=!0,this._browser.window.off("resize",this._resizeHandler),this._resizeObserver&&this._resizeObserver.disconnect(),this.parent.removeEventListener("resize",this._resizeHandler),this._mediaQueryList.removeEventListener("change",this._pixelRatioChangeHandler),this._canvas.removeEventListener("fullscreenchange",this._fullscreenChangeHandler))}_calculateDevicePixelRatio(){if(window.devicePixelRatio<1)return 1;return window.devicePixelRatio||1}get pixelRatio(){return this._pixelRatioOverride?this._pixelRatioOverride:this._devicePixelRatio}get isHiDpi(){return 1!==this.pixelRatio}get displayMode(){return this._displayMode}get canvas(){return this._canvas}get parent(){return this.displayMode===K.FillContainer||this.displayMode===K.FitContainer?this.canvas.parentElement||document.body:window}get resolution(){return this._resolution}set resolution(t){this._resolution=t}get viewport(){return this._viewport?this._viewport:this._resolution}set viewport(t){this._viewport=t}get aspectRatio(){return this._resolution.width/this._resolution.height}get scaledWidth(){return this._resolution.width*this.pixelRatio}get scaledHeight(){return this._resolution.height*this.pixelRatio}setCurrentCamera(t){this._camera=t}pushResolutionAndViewport(){this._resolutionStack.push(this.resolution),this._viewportStack.push(this.viewport),this.resolution=Object.assign({},this.resolution),this.viewport=Object.assign({},this.viewport)}popResolutionAndViewport(){this.resolution=this._resolutionStack.pop(),this.viewport=this._viewportStack.pop()}applyResolutionAndViewport(){this._canvas.width=this.scaledWidth,this._canvas.height=this.scaledHeight,this._antialiasing?this._canvas.style.imageRendering="auto":(this._canvas.style.imageRendering="pixelated",""===this._canvas.style.imageRendering&&(this._canvas.style.imageRendering="crisp-edges")),this._canvas.style.width=this.viewport.width+"px",this._canvas.style.height=this.viewport.height+"px",this._ctx.updateViewport(),this._ctx.resetTransform(),this._ctx.scale(this.pixelRatio,this.pixelRatio),this._ctx.smoothing=this._antialiasing}get antialiasing(){return this._antialiasing}set antialiasing(t){this._antialiasing=t,this._ctx.smoothing=this._antialiasing}get isFullScreen(){return this._isFullScreen}goFullScreen(){return this._canvas.requestFullscreen()}exitFullScreen(){return document.exitFullscreen()}pageToScreenCoordinates(t){let e=t.x,i=t.y;if(this._isFullScreen||(e-=D(this._canvas).x,i-=D(this._canvas).y),this._isFullScreen)if(window.innerWidth/this.aspectRatio<window.innerHeight){const t=window.innerWidth/this.aspectRatio;i=(i-(window.innerHeight-t)/2)/t*this.viewport.height,e=e/window.innerWidth*this.viewport.width}else{const t=window.innerHeight*this.aspectRatio;e=(e-(window.innerWidth-t)/2)/t*this.viewport.width,i=i/window.innerHeight*this.viewport.height}return e=e/this.viewport.width*this.resolution.width,i=i/this.viewport.height*this.resolution.height,new X(e,i)}screenToPageCoordinates(t){let e=t.x,i=t.y;if(e=e/this.resolution.width*this.viewport.width,i=i/this.resolution.height*this.viewport.height,this._isFullScreen)if(window.innerWidth/this.aspectRatio<window.innerHeight){const t=window.innerWidth/this.aspectRatio,s=(window.innerHeight-t)/2;i=i/this.viewport.height*t+s,e=e/this.viewport.width*window.innerWidth}else{const t=window.innerHeight*this.aspectRatio,s=(window.innerWidth-t)/2;e=e/this.viewport.width*t+s,i=i/this.viewport.height*window.innerHeight}return this._isFullScreen||(e+=D(this._canvas).x,i+=D(this._canvas).y),new X(e,i)}screenToWorldCoordinates(t){var e,i,s,r;let n=t.x,o=t.y;return n=n/this.resolution.width*this.drawWidth,o=o/this.resolution.height*this.drawHeight,n-=this.halfDrawWidth,o-=this.halfDrawHeight,n+=null!==(i=null===(e=this._camera)||void 0===e?void 0:e.x)&&void 0!==i?i:0,o+=null!==(r=null===(s=this._camera)||void 0===s?void 0:s.y)&&void 0!==r?r:0,new X(n,o)}worldToScreenCoordinates(t){var e,i,s,r;let n=t.x,o=t.y;return n-=null!==(i=null===(e=this._camera)||void 0===e?void 0:e.x)&&void 0!==i?i:0,o-=null!==(r=null===(s=this._camera)||void 0===s?void 0:s.y)&&void 0!==r?r:0,n+=this.halfDrawWidth,o+=this.halfDrawHeight,n=n/this.drawWidth*this.resolution.width,o=o/this.drawHeight*this.resolution.height,new X(n,o)}pageToWorldCoordinates(t){const e=this.pageToScreenCoordinates(t);return this.screenToWorldCoordinates(e)}worldToPageCoordinates(t){const e=this.worldToScreenCoordinates(t);return this.screenToPageCoordinates(e)}getWorldBounds(){const t=this.screenToWorldCoordinates(X.Zero).x,e=this.screenToWorldCoordinates(X.Zero).y,i=t+this.drawWidth,s=e+this.drawHeight;return new J(t,e,i,s)}get canvasWidth(){return this.canvas.width}get halfCanvasWidth(){return this.canvas.width/2}get canvasHeight(){return this.canvas.height}get halfCanvasHeight(){return this.canvas.height/2}get drawWidth(){return this._camera?this.scaledWidth/this._camera.zoom/this.pixelRatio:this.scaledWidth/this.pixelRatio}get halfDrawWidth(){return this.drawWidth/2}get drawHeight(){return this._camera?this.scaledHeight/this._camera.zoom/this.pixelRatio:this.scaledHeight/this.pixelRatio}get halfDrawHeight(){return this.drawHeight/2}get center(){return q(this.halfDrawWidth,this.halfDrawHeight)}_computeFit(){document.body.style.margin="0px",document.body.style.overflow="hidden";const t=this.aspectRatio;let e=0,i=0;window.innerWidth/t<window.innerHeight?(e=window.innerWidth,i=window.innerWidth/t):(e=window.innerHeight*t,i=window.innerHeight),this.viewport={width:e,height:i}}_computeFitContainer(){const t=this.aspectRatio;let e=0,i=0;const s=this.canvas.parentElement;s.clientWidth/t<s.clientHeight?(e=s.clientWidth,i=s.clientWidth/t):(e=s.clientHeight*t,i=s.clientHeight),this.viewport={width:e,height:i}}_applyDisplayMode(){this.displayMode===K.Position?this._initializeDisplayModePosition(this._position):(this._setResolutionAndViewportByDisplayMode(this.parent),this.parent instanceof Window?this._browser.window.on("resize",this._resizeHandler):(this._resizeObserver=new ResizeObserver(()=>{this._resizeHandler()}),this._resizeObserver.observe(this.parent)),this.parent.addEventListener("resize",this._resizeHandler))}_setResolutionAndViewportByDisplayMode(t){this.displayMode===K.FillContainer&&(this.resolution={width:t.clientWidth,height:t.clientHeight},this.viewport=this.resolution),this.displayMode===K.FillScreen&&(document.body.style.margin="0px",document.body.style.overflow="hidden",this.resolution={width:t.innerWidth,height:t.innerHeight},this.viewport=this.resolution),this.displayMode===K.FitScreen&&this._computeFit(),this.displayMode===K.FitContainer&&this._computeFitContainer()}_initializeDisplayModePosition(t){if(!t)throw new Error("DisplayMode of Position was selected but no position option was given");if(this.canvas.style.display="block",this.canvas.style.position="absolute","string"==typeof t){const e=t.split(" ");switch(e[0]){case"top":this.canvas.style.top="0px";break;case"bottom":this.canvas.style.bottom="0px";break;case"middle":this.canvas.style.top="50%";const t=-this.halfDrawHeight;this.canvas.style.marginTop=t.toString();break;default:throw new Error("Invalid Position Given")}if(e[1])switch(e[1]){case"left":this.canvas.style.left="0px";break;case"right":this.canvas.style.right="0px";break;case"center":this.canvas.style.left="50%";const t=-this.halfDrawWidth;this.canvas.style.marginLeft=t.toString();break;default:throw new Error("Invalid Position Given")}}else t.top&&("number"==typeof t.top?this.canvas.style.top=t.top.toString()+"px":this.canvas.style.top=t.top),t.right&&("number"==typeof t.right?this.canvas.style.right=t.right.toString()+"px":this.canvas.style.right=t.right),t.bottom&&("number"==typeof t.bottom?this.canvas.style.bottom=t.bottom.toString()+"px":this.canvas.style.bottom=t.bottom),t.left&&("number"==typeof t.left?this.canvas.style.left=t.left.toString()+"px":this.canvas.style.left=t.left)}}class it{static create(){return this._INSTANCE||(window.AudioContext||window.webkitAudioContext)&&(this._INSTANCE=new AudioContext),this._INSTANCE}}it._INSTANCE=null;class st{static unlock(){return new Promise((t,e)=>{if(st._UNLOCKED||!it.create())return t(!0);const i=setTimeout(()=>{_.getInstance().warn("Excalibur was unable to unlock the audio context, audio probably will not play in this browser."),t(!1)},200),s=it.create();s.resume().then(()=>{const e=s.createBuffer(1,1,22050),r=s.createBufferSource();let n=!1;r.buffer=e,r.connect(s.destination),r.onended=()=>n=!0,r.start(0),setTimeout(()=>{!function(t){return!!t.playbackState}(r)?(s.currentTime>0||n)&&(st._UNLOCKED=!0):r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(st._UNLOCKED=!0)},0),clearTimeout(i),t(!0)},()=>{e()})})}static isUnlocked(){return this._UNLOCKED}}st._UNLOCKED=!1,function(t){t.Kill="kill",t.PreKill="prekill",t.PostKill="postkill",t.PreDraw="predraw",t.PostDraw="postdraw",t.PreDebugDraw="predebugdraw",t.PostDebugDraw="postdebugdraw",t.PreUpdate="preupdate",t.PostUpdate="postupdate",t.PreFrame="preframe",t.PostFrame="postframe",t.PreCollision="precollision",t.CollisionStart="collisionstart",t.CollisionEnd="collisionend",t.PostCollision="postcollision",t.Initialize="initialize",t.Activate="activate",t.Deactivate="deactivate",t.ExitViewport="exitviewport",t.EnterViewport="enterviewport",t.ExitTrigger="exit",t.EnterTrigger="enter",t.Connect="connect",t.Disconnect="disconnect",t.Button="button",t.Axis="axis",t.Subscribe="subscribe",t.Unsubscribe="unsubscribe",t.Visible="visible",t.Hidden="hidden",t.Start="start",t.Stop="stop",t.PointerUp="pointerup",t.PointerDown="pointerdown",t.PointerMove="pointermove",t.PointerEnter="pointerenter",t.PointerLeave="pointerleave",t.PointerCancel="pointercancel",t.PointerWheel="pointerwheel",t.Up="up",t.Down="down",t.Move="move",t.Enter="enter",t.Leave="leave",t.Cancel="cancel",t.Wheel="wheel",t.Press="press",t.Release="release",t.Hold="hold",t.PointerDragStart="pointerdragstart",t.PointerDragEnd="pointerdragend",t.PointerDragEnter="pointerdragenter",t.PointerDragLeave="pointerdragleave",t.PointerDragMove="pointerdragmove"}(Z||(Z={}));class rt{constructor(){this._bubbles=!0}get bubbles(){return this._bubbles}set bubbles(t){this._bubbles=t}stopPropagation(){this.bubbles=!1}}class nt extends rt{constructor(t){super(),this.target=t}}class ot extends rt{constructor(t){super(),this.target=t}}class at extends rt{constructor(t){super(),this.target=t}}class ht extends rt{constructor(t){super(),this.target=t}}class lt extends rt{constructor(t){super(),this.target=t}}class ct extends rt{constructor(t,e,i){super(),this.ctx=t,this.delta=e,this.target=i}}class dt extends rt{constructor(t,e,i){super(),this.ctx=t,this.delta=e,this.target=i}}class ut extends rt{constructor(t,e){super(),this.ctx=t,this.target=e}}class pt extends rt{constructor(t,e){super(),this.ctx=t,this.target=e}}class gt extends rt{constructor(t,e,i){super(),this.engine=t,this.delta=e,this.target=i}}class _t extends rt{constructor(t,e,i){super(),this.engine=t,this.delta=e,this.target=i}}class ft extends rt{constructor(t,e){super(),this.engine=t,this.prevStats=e,this.target=t}}class mt extends rt{constructor(t,e){super(),this.engine=t,this.stats=e,this.target=t}}class wt extends rt{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class yt extends rt{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class vt extends rt{constructor(t,e,i){super(),this.button=t,this.value=e,this.target=i}}class xt extends rt{constructor(t,e,i){super(),this.axis=t,this.value=e,this.target=i}}class bt extends rt{constructor(t,e){super(),this.topic=t,this.handler=e}}class Ct extends rt{constructor(t,e){super(),this.topic=t,this.handler=e}}class At extends rt{constructor(t){super(),this.target=t}}class St extends rt{constructor(t){super(),this.target=t}}class Pt extends rt{constructor(t,e,i,s){super(),this.other=e,this.side=i,this.intersection=s,this.target=t}}class Et extends rt{constructor(t,e,i,s){super(),this.other=e,this.side=i,this.intersection=s,this.target=t}get actor(){return this.target}set actor(t){this.target=t}}class Tt{constructor(t,e,i){this.target=t,this.other=e,this.contact=i}}class Rt{constructor(t,e){this.target=t,this.other=e}}class Dt{constructor(t,e,i,s,r){this.target=t,this.other=e,this.side=i,this.intersection=s,this.contact=r}}class Mt{constructor(t,e,i,s,r){this.target=t,this.other=e,this.side=i,this.intersection=s,this.contact=r}}class Bt extends rt{constructor(t,e,i){super(),this.other=e,this.contact=i,this.target=t}get actor(){return this.target}set actor(t){this.target=t}}class kt extends rt{constructor(t,e){super(),this.other=e,this.target=t}get actor(){return this.target}set actor(t){this.target=t}}class Ft extends rt{constructor(t,e){super(),this.engine=t,this.target=e}}class Lt extends rt{constructor(t,e){super(),this.oldScene=t,this.target=e}}class It extends rt{constructor(t,e){super(),this.newScene=t,this.target=e}}class Ot extends rt{constructor(t){super(),this.target=t}}class zt extends rt{constructor(t){super(),this.target=t}}class Ut extends rt{constructor(t,e){super(),this.target=t,this.actor=e}}class Ht extends rt{constructor(t,e){super(),this.target=t,this.actor=e}}class Nt{constructor(t){this._handlers={},this._wiredEventDispatchers=[],this._target=t}clear(){this._handlers={},this._wiredEventDispatchers=[]}emit(t,e){if(!t)return;t=t.toLowerCase();const i=this._target;e||(e=new rt);try{e.target||(e.target=i)}catch(t){}let s,r;if(this._handlers[t])for(s=0,r=this._handlers[t].length;s<r;s++)this._handlers[t][s].call(i,e);for(s=0,r=this._wiredEventDispatchers.length;s<r;s++)this._wiredEventDispatchers[s].emit(t,e)}on(t,e){t=t.toLowerCase(),this._handlers[t]||(this._handlers[t]=[]),this._handlers[t].push(e),"unsubscribe"!==t&&"subscribe"!==t&&this.emit("subscribe",new bt(t,e))}off(t,e){t=t.toLowerCase();const i=this._handlers[t];if(i)if(e){const s=i.indexOf(e);this._handlers[t].splice(s,1)}else this._handlers[t].length=0;"unsubscribe"!==t&&"subscribe"!==t&&this.emit("unsubscribe",new Ct(t,e))}once(t,e){this.on(t,i=>{const s=i||new rt;try{s.target=s.target||this._target}catch(t){}this.off(t,e),e.call(s.target,s)})}wire(t){t._wiredEventDispatchers.push(this)}unwire(t){const e=t._wiredEventDispatchers.indexOf(this);e>-1&&t._wiredEventDispatchers.splice(e,1)}}class Wt{constructor(){this.eventDispatcher=new Nt(this)}on(t,e){this.eventDispatcher.on(t,e)}off(t,e){this.eventDispatcher.off(t,e)}emit(t,e){this.eventDispatcher.emit(t,e)}once(t,e){this.eventDispatcher.once(t,e)}}function Vt(t,e=Q.Red,i,s,r,n,o=1,a="butt"){t.beginPath(),t.lineWidth=o,t.lineCap=a,t.strokeStyle=e.toString(),t.moveTo(i,s),t.lineTo(r,n),t.closePath(),t.stroke()}function Gt(t,e=Q.Red,i){t.beginPath(),t.strokeStyle=e.toString(),t.arc(i.x,i.y,5,0,2*Math.PI),t.closePath(),t.stroke()}function jt(t,e,i,s,r=1){const n=e?e.toString():"blue",o=s.scale(r);t.beginPath(),t.strokeStyle=n,t.moveTo(i.x,i.y),t.lineTo(i.x+o.x,i.y+o.y),t.closePath(),t.stroke()}function Xt(t,e,i,s,r,n=5,o=Q.White,a=null){let h;if("number"==typeof n)h={tl:n,tr:n,br:n,bl:n};else{const t={tl:0,tr:0,br:0,bl:0};for(const e in t)if(t.hasOwnProperty(e)){const i=e;h[i]=n[i]||t[i]}}t.beginPath(),t.moveTo(e+h.tl,i),t.lineTo(e+s-h.tr,i),t.quadraticCurveTo(e+s,i,e+s,i+h.tr),t.lineTo(e+s,i+r-h.br),t.quadraticCurveTo(e+s,i+r,e+s-h.br,i+r),t.lineTo(e+h.bl,i+r),t.quadraticCurveTo(e,i+r,e,i+r-h.bl),t.lineTo(e,i+h.tl),t.quadraticCurveTo(e,i,e+h.tl,i),t.closePath(),a&&(t.fillStyle=a.toString(),t.fill()),o&&(t.strokeStyle=o.toString(),t.stroke())}function qt(t,e,i,s,r=Q.White,n=null){t.beginPath(),t.arc(e,i,s,0,2*Math.PI),t.closePath(),n&&(t.fillStyle=n.toString(),t.fill()),r&&(t.strokeStyle=r.toString(),t.stroke())}var Kt=i(1388);class Zt{constructor(t){var e,i,s,r,n,o;this.id=Zt._ID++,this.showDebug=!1,this.flipHorizontal=!1,this.flipVertical=!1,this.rotation=0,this.opacity=1,this.scale=X.One,this.origin=null,this._width=0,this._height=0,t&&(this.origin=null!==(e=t.origin)&&void 0!==e?e:this.origin,this.flipHorizontal=null!==(i=t.flipHorizontal)&&void 0!==i?i:this.flipHorizontal,this.flipVertical=null!==(s=t.flipVertical)&&void 0!==s?s:this.flipVertical,this.rotation=null!==(r=t.rotation)&&void 0!==r?r:this.rotation,this.opacity=null!==(n=t.opacity)&&void 0!==n?n:this.opacity,this.scale=null!==(o=t.scale)&&void 0!==o?o:this.scale)}cloneGraphicOptions(){return{origin:this.origin?this.origin.clone():null,flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical,rotation:this.rotation,opacity:this.opacity,scale:this.scale?this.scale.clone():null}}get width(){return Math.abs(this._width*this.scale.x)}get height(){return Math.abs(this._height*this.scale.y)}set width(t){this._width=t}set height(t){this._height=t}get localBounds(){return J.fromDimension(this.width,this.height,X.Zero)}draw(t,e,i){this._preDraw(t,e,i),this._drawImage(t,0,0),this._postDraw(t)}_preDraw(t,e,i){t.save(),t.translate(e,i),t.scale(Math.abs(this.scale.x),Math.abs(this.scale.y)),this._rotate(t),this._flip(t),t.opacity=t.opacity*this.opacity}_rotate(t){var e;const i=this.scale.x>0?1:-1,s=this.scale.y>0?1:-1,r=null!==(e=this.origin)&&void 0!==e?e:q(this.width/2,this.height/2);t.translate(r.x,r.y),t.rotate(this.rotation),t.scale(i,s),t.translate(-r.x,-r.y)}_flip(t){this.flipHorizontal&&(t.translate(this.width/this.scale.x,0),t.scale(-1,1)),this.flipVertical&&(t.translate(0,this.height/this.scale.y),t.scale(1,-1))}_postDraw(t){this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore()}}function Yt(t){return 0==(t&t-1)}function Qt(t){return Yt(t)?t:function(t){--t;for(let e=1;e<32;e<<=1)t|=t>>e;return t+1}(t)}function $t(t,e){return t&&void 0===t.__isProxy?new Proxy(t,{set:(t,i,s)=>(t[i]!==s&&(t[i]=s,"string"==typeof i&&"_"!==i[0]&&e(t)),!0),get:(t,e)=>"__isProxy"===e||t[e]}):t}function Jt(t,e){return t&&void 0===t.__isProxy?new Proxy(t,{set:(t,i,s)=>(t[i]=s,"string"==typeof i&&"_"!==i[0]&&e(t),!0),get:(t,e)=>"__isProxy"===e||t[e]}):t}Zt._ID=0;class te{static registerContext(t){te._GL=t}static get(t){return te._TEXTURE_MAP.get(t)}static has(t){return te._TEXTURE_MAP.has(t)}static load(t,e=!1){const i=te._GL;if(!i)return null;let s=null;if(te.has(t)&&(s=te.get(t)),s){if(e){i.bindTexture(i.TEXTURE_2D,s);const e=te.toPowerOfTwoImage(t);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e)}return s}s=i.createTexture();const r=te.toPowerOfTwoImage(t);return i.bindTexture(i.TEXTURE_2D,s),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,r),te._TEXTURE_MAP.set(t,s),s}static toPowerOfTwoImage(t){const e=te._POT_CANVAS,i=te._POT_CTX;return Yt(t.width)&&Yt(t.height)||(e.width=Qt(t.width),e.height=Qt(t.height),i.imageSmoothingEnabled=!1,i.clearRect(0,0,e.width,e.height),i.drawImage(t,0,0,t.width,t.height),t=e),t}}te._POT_CANVAS=document.createElement("canvas"),te._POT_CTX=te._POT_CANVAS.getContext("2d"),te._TEXTURE_MAP=new Map;class ee extends Zt{constructor(t){var e,i,s,r,n,o,a;super(t),this._dirty=!0,this._smoothing=!1,this._color=$t(Q.Black,()=>this.flagDirty()),this._lineWidth=1,this._lineDash=[],this._padding=0,t&&(this.color=null!==(e=t.color)&&void 0!==e?e:Q.Black,this.strokeColor=null==t?void 0:t.strokeColor,this.smoothing=null!==(i=t.smoothing)&&void 0!==i?i:this.smoothing,this.lineWidth=null!==(s=t.lineWidth)&&void 0!==s?s:this.lineWidth,this.lineDash=null!==(r=t.lineDash)&&void 0!==r?r:this.lineDash,this.padding=null!==(n=t.padding)&&void 0!==n?n:this.padding),this._bitmap=document.createElement("canvas");const h=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:this._bitmap.width,l=null!==(a=null==t?void 0:t.height)&&void 0!==a?a:this._bitmap.height;this.width=Qt(h),this.height=Qt(l);const c=this._bitmap.getContext("2d");if(!c)throw new Error("Browser does not support 2d canvas drawing, cannot create Raster graphic");this._ctx=c}cloneRasterOptions(){return{color:this.color?this.color.clone():null,strokeColor:this.strokeColor?this.strokeColor.clone():null,smoothing:this.smoothing,lineWidth:this.lineWidth,lineDash:this.lineDash,padding:this.padding}}get dirty(){return this._dirty}flagDirty(){this._dirty=!0}get width(){return this._getTotalWidth()}set width(t){this._bitmap.width=t,this._originalWidth=t,this.flagDirty()}get height(){return this._getTotalHeight()}set height(t){this._bitmap.height=t,this._originalHeight=t,this.flagDirty()}_getTotalWidth(){var t;return(null!==(t=this._originalWidth)&&void 0!==t?t:this._bitmap.width)+2*this.padding}_getTotalHeight(){var t;return(null!==(t=this._originalHeight)&&void 0!==t?t:this._bitmap.height)+2*this.padding}get localBounds(){return J.fromDimension(this._getTotalWidth()*this.scale.x,this._getTotalHeight()*this.scale.y,X.Zero)}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this.flagDirty()}get color(){return this._color}set color(t){var e;(null===(e=this._color)||void 0===e?void 0:e.equal(t))||this.flagDirty(),this._color=$t(t,()=>this.flagDirty())}get strokeColor(){return this._strokeColor}set strokeColor(t){var e;(null===(e=this._strokeColor)||void 0===e?void 0:e.equal(t))||this.flagDirty(),this._strokeColor=$t(t,()=>this.flagDirty())}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.flagDirty()}get lineDash(){return this._lineDash}set lineDash(t){this._lineDash=t,this.flagDirty()}get padding(){return this._padding}set padding(t){this._padding=t,this.flagDirty()}rasterize(){this._dirty=!1,this._ctx.clearRect(0,0,this._getTotalWidth(),this._getTotalHeight()),this._ctx.save(),this._applyRasterProperites(this._ctx),this.execute(this._ctx),this._ctx.restore(),te.load(this._bitmap,!0)}_applyRasterProperites(t){var e,i,s;this._bitmap.width=this._getTotalWidth(),this._bitmap.height=this._getTotalHeight(),t.translate(this.padding,this.padding),t.imageSmoothingEnabled=this.smoothing,t.lineWidth=this.lineWidth,t.setLineDash(null!==(e=this.lineDash)&&void 0!==e?e:t.getLineDash()),t.strokeStyle=null===(i=this.strokeColor)||void 0===i?void 0:i.toString(),t.fillStyle=null===(s=this.color)||void 0===s?void 0:s.toString()}_drawImage(t,e,i){this._dirty&&this.rasterize(),t.drawImage(this._bitmap,e,i)}}class ie extends ee{constructor(t){super(t),this._options=t}get ctx(){return this._ctx}clone(){return new ie(Object.assign(Object.assign(Object.assign({},this._options),this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){var e,i;(null===(e=this._options)||void 0===e?void 0:e.draw)&&(null===(i=this._options)||void 0===i||i.draw(t)),this._options.cache||this.flagDirty()}}var se=function(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(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(o,a)}h((s=s.apply(t,e||[])).next())}))};class re extends Wt{constructor(t){super(),this.canvas=new ie({smoothing:!0,draw:this.draw.bind(this)}),this._resourceList=[],this._index=0,this._playButtonShown=!1,this._resourceCount=0,this._numLoaded=0,this._progressCounts={},this._totalCounts={},this.logo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdQAAAB2CAYAAABxhGI9AAAACXBIWXMAAAsSAAALEgHS3X78AAAKnUlEQVR42u3dP2wjSx0H8N8hJIonIRmJjsq0SBR+BQ1dcqKhe0lD77SvSwpKkJKGPulpktfRIMUdEqKIqV57rpAokM4dbSiyq7ONPTP7x39ifz7SFbnEnp3xer47O7uzH15fXwMA6OYHmgAABCoACFQAEKgAgEAFAIEKAAIVAAQqACBQAUCgAoBABQCBCgAIVAAQqAAgUAFAoAIAAhUABCoACFQAEKgAgECFLbmOiNeFf2PbAyz68Pr6qhUgbRwR92v+/zwiJrYHMEKFMmcN///UtgcQqFBk1PD/97U9Qx8VCFSgu4EmAIEKAAIVAAQqACBQ4Z25jojP8eX+0WtNAgIVaOY+Im5j+eKh24h41jQgUIEyZ7F5NaPU7wCBCiwYd/w9cOB+qAlgJ3KLLow0EV198803RWvJfvfddx+0lhEqHKu5JgAjVCBvlhmFzjQRXUekHz9+TP79y8uLRjNChXfvoePvAYEKxNtj1e42/O5JoIJABcrdRMRVLM+X3kTEpaaB988cKuzWg9EobTWdMx0Oly8uN4dqhAoARqgnaN3arHfqu7OyH8ItKLVB/P+CEfMTHyGPY3npx1m8zWGDEeoBfUk/xdti57dr/r1Wv2+6EPow3tZ5rRdS72s1neuF97xvWd+XTH0/V+UMttDWqbI/r2nrxfp+jv2uSjSO7S+OXy/A/3lN+9xX5T5HxEUPZZ0tfB71+w57eJ/HFu+z+jkv1u92YX9fbI/HhX3JA9rp5MPr66tWaG9UfUGbrHIzi7cLUyYFf/tpTady03EEeL8mUJ6i7MKYNvWNqr4Pe2jradXO60LrvPAz2PQ5RPX684ah8dxD+2zantnCgVipSVV+m/tgB9W2DDq2Sx/vM95wcHhZhWVJm8yrv58cSgfTdc70+++/X/r522+/tUKSEepBqo+om4ZLPerMjUwuNnQCtx1GWJtee1FwdD5uWd86xLs8UaVt2aNEO1/saZ/Z5rYMW4zq6v34rGV9Bg3q2eZ9SkeNm9qwyUh30OPIHYFKx5FG03C7znSOqYBq+qW/zpQ3anH037TNHluG6f0WPsPhHvab4QFty7ogOeuxDYcNy2/zu2214WNYWxmBurNO8bGn97pNBOO8xy/9uCorZZ4I2r4C7aJgO7ZV9iE49Dm6NvOWx+pWE9CUq3zbdTp9doz38TbXtzqH9RT5CyWe422OaZoZGeZCabrhPQY9HjwsjpTvCg4YtlE2+Ta/j2bzn8fqrDqgm+6yUHOmAvWUjAtGhbNYvsBknDnqH1Qhc7VmxHgeb/NbudA5j/UXlYwif2p6luhAc9teu1npiHKnDs8if6tCm7JLX3NKpgttXe9ruc9mHMd7a83iwdxF5vt8tutARaCeklRnNK9C8WnNF7geJQ4T4XG3JhSnVdilQrG+yOnrlVHfsEGYzhNBn7Lu6tS7+HJafJQ4EMiNlNqWXZ9WPvVgnVYHG5M1ByDXkT6leX2EgTqJtyt45yv7S2qO3sEZjZhDLXeR+YKdJ0Zdk8QocvH9N732KrNtq+FZ/zzIHABcJrYpd+Xv14lOd5ap76SgrduW/VTQ1qcQpqnbgu4ifZvUMNpd9XuoZmvCtPaQ2Y/BCHVLgbrJTeRPDdVf6pfMKDU2fOkHmVFFfXr3MsouLsnNvV5kRoe5+s431PeuoKPqWnaurY/ZPBEeqwceN4l96iwO6H7Mjq4y7VGPVNe10VaZMzVCPVWpI/Z6FZbcv5fMqGCU+dLfFGzj58jP8+bCdJCo7yzKTwdOF0bu9Ug7V4c+yz7FJfYeGoysUss0HssIdVZwYLDujMqlESoCdTtGsZtbHnJBeNdDSJSs0jTKdMJN1HNX54Wv7bvsU9NkVJVa13dX+/wuArV0X/l5RHyo/lnfF4G6p6DrS0kHdtXhy35TGErDPYZUn2WfWqDOo/lVqdMD2O/hKJhD7S/odukymq9s02QN4EEPR/zbaOumZc+r15zK1Zqznl9jsfiemTM1QmV3HUuTkedlg9HIQzRbUD93dfC+2tpj2fIHEH2+RqCCQH13gZq7hWXTNpVu19OB1fc9nQ0AKOKUb5lU0P1kDyOneoWk0lOZ9cIP0x7qu8+2BhCoR2wYu1+e7DmaXzBSsu5vaX1ne2zrpmUPTmxf7PM1Dm4y/vC7ny7Nif7+z/9ZmtM0Z3panPLtPmra9f16bcK0Dpbnwk43Vd/RHtu6zfNQTy1QBy3aqG2g9nVmxml+BOoJyT3NpWmn9xhfFnu4bvDa+44BXhqqfdf3uUF9+yz77AT31Yue2mjecYQ62NLfgkA9ghHqLNEhNem4H1c6vdyDxhf/bpz5m4coW/c39wi6VH2bPtHlcaV9cvXts+zxCe6rTeqc2ndL7uGd93QwM9bFcAzMoZZ7SgTBbWx+asui61h/iq1+RmjqdbnQXQ3T1DNQ63V/U9ucqm/pMzPb1rePsk/1iTOjgvatR4W3Lc8ULB78pELyrnAfeTcj1NU509/86mfJ33/8+Mf00a05UyPUEw7UVCeWG/WNEiExyHRMt5ltW30izUPk18ytt7lNfc8i//DvtvXto+ySA5BjljsLUF8lPkqMPEtW1JomDsiGBZ9Byb4NAvUITSN9GuwsIj6t6UTOqk7jJREkmzqli8xIs96udSO20sX0H1vW92IL9e1a9rgqVyf91gbPsTy9UD9n9lOkT8k+RfkFR5PMNqxOcdSf32PBvg3vilO+zdxE+okx9Wm0ph36XYsRZCpMF993GOk5qvqB3Dct6jvssb67KvuUNJ3frw92bhr8/STSF0JdRPMLpUCgnsgo9S76PZ246ZFk1wWvK5m3vVoYvW1Sz7nN91jfXbQ1ZQc7TW6HeaoOalypG/8/p/rP1aNAc6ZHzSnfdqPUPhdy2PQw6Nz9gSVhuhiqueUHR3uu7y7K3rdDX4u46ZrPbUa0IFBZ0seKQ3XQTRt2vm3W/a2DbNKys++rvm3ep6+y1x2UdP3bWU9lzra47U1GmlctX/sQ23t+aOlByLTh/4NAPaCRxtcdO5HLSJ/6vNtCwGx67VPmPbvWd1q9frKHtp4kAqRJ2HR9j762JfX3bZ//elPtj13PPDx1+D5tqk/Xi6NO8SHz7MmH19dXrdBNfVFP6T2PT1UHNit87/t4m5+aRH+nQBdvqyhZDKJLfZs8h7XPsqdV2ZOV+tanKB8aln0dyxdAXbV4j4gvt4oMOrbP6vbU73NW7TMlbdTnPrWpfqXfh9HKZ9vke7KuTeZRNtXRSe6+1FV//ce/ln5eXfsXgcqXzr6+9261M3moOoa7E6nvTZTfy7iNsmfb7kjfgXGsvxe0vihsEts9HTquPpt1q1vtahu2TqAiUAEEKj0zhwoARqgAu/OnX/442WH+9xc/Wvr58re/Tr7f41/+ZsRqhAoACFQAEKgAcHjMoQJskJsz/eqrr5Z+vvr7v5fmQFevAl5lztQIFQAQqAAgUAHgIJlDBdhgdQ41N2eKESoAIFABQKACwFEwhwoARqgAIFABQKACAAIVAAQqAAhUABCoAIBABQCBCgACFQAEKgAgUAFAoAKAQAUAgQoACFQAEKgAIFABQKACAAIVAAQqAAhUABCoAIBABQCBCgACFQAQqAAgUAFAoAKAQAUAlvwPcFDns1DsH4sAAAAASUVORK5CYII=",this.logoWidth=468,this.logoHeight=118,this.loadingBarColor=Q.White,this.backgroundColor="#176BAA",this.suppressPlayButton=!1,this._playButtonStyles=Kt.Z.toString(),this.playButtonText="Play game",this.startButtonFactory=()=>{let t=document.getElementById("excalibur-play");return t||(t=document.createElement("button")),t.id="excalibur-play",t.textContent=this.playButtonText,t.style.display="none",t},t&&this.addResources(t)}get _image(){return this._imageElement||(this._imageElement=new Image,this._imageElement.src=this.logo),this._imageElement}get playButtonRootElement(){return this._playButtonRootElement}get playButtonElement(){return this._playButtonElement}get _playButton(){const t=document.getElementById("excalibur-play-root");return t&&(this._playButtonRootElement=t),this._playButtonRootElement||(this._playButtonRootElement=document.createElement("div"),this._playButtonRootElement.id="excalibur-play-root",this._playButtonRootElement.style.position="absolute",document.body.appendChild(this._playButtonRootElement)),this._styleBlock||(this._styleBlock=document.createElement("style"),this._styleBlock.textContent=this._playButtonStyles,document.head.appendChild(this._styleBlock)),this._playButtonElement||(this._playButtonElement=this.startButtonFactory(),this._playButtonRootElement.appendChild(this._playButtonElement)),this._playButtonElement}wireEngine(t){this._engine=t,this.canvas.width=this._engine.canvas.width,this.canvas.height=this._engine.canvas.height}addResource(t){const e=this._index++;this._resourceList.push(t),this._progressCounts[e]=0,this._totalCounts[e]=1,this._resourceCount++}addResources(t){let e=0;const i=t.length;for(;e<i;e++)this.addResource(t[e])}isLoaded(){return this._numLoaded===this._resourceCount}showPlayButton(){if(this.suppressPlayButton)return Promise.resolve();this._playButtonShown=!0,this._playButton.style.display="block",document.body.addEventListener("keyup",t=>{"Enter"===t.key&&this._playButton.click()});return new Promise(t=>{const e=e=>{e.stopPropagation(),t()};this._playButton.addEventListener("click",e),this._playButton.addEventListener("touchend",e),this._playButton.addEventListener("pointerup",e)})}hidePlayButton(){this._playButtonShown=!1,this._playButton.style.display="none"}dispose(){this._playButtonRootElement.parentElement&&(this._playButtonRootElement.removeChild(this._playButtonElement),document.body.removeChild(this._playButtonRootElement),document.head.removeChild(this._styleBlock),this._playButtonRootElement=null,this._playButtonElement=null,this._styleBlock=null)}update(t,e){}load(){return se(this,void 0,void 0,(function*(){return yield Promise.all(this._resourceList.map(t=>t.load().finally(()=>{this._numLoaded++}))),yield U(200),yield this.showPlayButton(),yield st.unlock(),this.hidePlayButton(),this.data=this._resourceList}))}markResourceComplete(){this._numLoaded++}get progress(){return this._resourceCount>0?A(this._numLoaded,0,this._resourceCount)/this._resourceCount:1}draw(t){const e=this._engine.canvasHeight/this._engine.pixelRatio,i=this._engine.canvasWidth/this._engine.pixelRatio;if(this._playButtonRootElement){const t=this._engine.canvas.offsetLeft,s=this._engine.canvas.offsetTop,r=this._playButton.clientWidth,n=this._playButton.clientHeight;this.playButtonPosition?(this._playButtonRootElement.style.left=this.playButtonPosition.x+"px",this._playButtonRootElement.style.top=this.playButtonPosition.y+"px"):(this._playButtonRootElement.style.left=t+i/2-r/2+"px",this._playButtonRootElement.style.top=s+e/2-n/2+100+"px")}t.fillStyle=this.backgroundColor,t.fillRect(0,0,i,e);let s=e/2;const r=Math.min(this.logoWidth,.75*i);let n=i/2-r/2;this.logoPosition&&(n=this.logoPosition.x,s=this.logoPosition.y);const o=Math.floor(r*(this.logoHeight/this.logoWidth)),a=this._engine.getAntialiasing();if(this._engine.setAntialiasing(!0),this.logoPosition?t.drawImage(this._image,0,0,this.logoWidth,this.logoHeight,n,s,r,o):t.drawImage(this._image,0,0,this.logoWidth,this.logoHeight,n,s-o-20,r,o),!this.suppressPlayButton&&this._playButtonShown)return void this._engine.setAntialiasing(a);let h=n,l=s;this.loadingBarPosition&&(h=this.loadingBarPosition.x,l=this.loadingBarPosition.y),t.lineWidth=2,Xt(t,h,l,r,20,10,this.loadingBarColor);const c=r*this.progress-10;Xt(t,h+5,l+5,c>10?c:10,10,5,null,this.loadingBarColor),this._engine.setAntialiasing(a)}}const ne={webgl:"WebGL",webaudio:"WebAudio",gamepadapi:"Gamepad API"};class oe{constructor(){this._features=null,this.failedTests=[],this._criticalTests={canvasSupport:function(){const t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))},arrayBufferSupport:function(){const t=new XMLHttpRequest;t.open("GET","/");try{t.responseType="arraybuffer"}catch(t){return!1}return"arraybuffer"===t.responseType},dataUrlSupport:function(){return 0===document.createElement("canvas").toDataURL("image/png").indexOf("data:image/png")},objectUrlSupport:function(){return"URL"in window&&"revokeObjectURL"in URL&&"createObjectURL"in URL},rgbaSupport:function(){const t=document.createElement("a").style;return t.cssText="background-color:rgba(150,255,150,.5)",(""+t.backgroundColor).indexOf("rgba")>-1}},this._warningTest={webAudioSupport:function(){return!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext)},webglSupport:function(){const t=document.createElement("canvas");return!(!t.getContext||!t.getContext("webgl"))}},this._features=this._loadBrowserFeatures()}getBrowserFeatures(){return null===this._features&&(this._features=this._loadBrowserFeatures()),this._features}logBrowserFeatures(){let t="%cSUPPORTED BROWSER FEATURES\n==========================%c\n";const e=["font-weight: bold; color: navy","font-weight: normal; color: inherit"],i=this.getBrowserFeatures();for(const s of Object.keys(ne))i[s]?(t+="(%c✓%c)",e.push("font-weight: bold; color: green"),e.push("font-weight: normal; color: inherit")):(t+="(%c✗%c)",e.push("font-weight: bold; color: red"),e.push("font-weight: normal; color: inherit")),t+=" "+ne[s]+"\n";e.unshift(t),console.log.apply(console,e)}_loadBrowserFeatures(){return{canvas:(()=>this._criticalTests.canvasSupport())(),arraybuffer:(()=>this._criticalTests.arrayBufferSupport())(),dataurl:(()=>this._criticalTests.dataUrlSupport())(),objecturl:(()=>this._criticalTests.objectUrlSupport())(),rgba:(()=>this._criticalTests.rgbaSupport())(),webaudio:(()=>this._warningTest.webAudioSupport())(),webgl:(()=>this._warningTest.webglSupport())(),gamepadapi:!!navigator.getGamepads}}test(){let t=!1;for(const e in this._criticalTests)this._criticalTests[e].call(this)||(this.failedTests.push(e),_.getInstance().error("Critical browser feature missing, Excalibur requires:",e),t=!0);if(t)return!1;for(const t in this._warningTest)this._warningTest[t]()||_.getInstance().warn("Warning browser feature missing, Excalibur will have reduced performance:",t);return!0}}class ae{constructor(t,e,i=!0){this.path=t,this.responseType=e,this.bustCache=i,this.data=null,this.logger=_.getInstance(),this.events=new Nt(this)}isLoaded(){return null!==this.data}_cacheBust(t){return/\?\w*=\w*/.test(t)?t+="&__="+Date.now():t+="?__="+Date.now(),t}load(){return new Promise((t,e)=>{if(null!==this.data)return this.logger.debug("Already have data for resource",this.path),this.events.emit("complete",this.data),void t(this.data);const i=new XMLHttpRequest;i.open("GET",this.bustCache?this._cacheBust(this.path):this.path,!0),i.responseType=this.responseType,i.addEventListener("loadstart",t=>this.events.emit("loadstart",t)),i.addEventListener("progress",t=>this.events.emit("progress",t)),i.addEventListener("error",t=>this.events.emit("error",t)),i.addEventListener("load",t=>this.events.emit("load",t)),i.addEventListener("load",()=>{if(0!==i.status&&200!==i.status)return this.logger.error("Failed to load resource ",this.path," server responded with error code",i.status),this.events.emit("error",i.response),void e(i.response);this.data=i.response,this.events.emit("complete",this.data),this.logger.debug("Completed loading resource",this.path),t(this.data)}),i.send()})}}var he=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};let le=class{updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data,n=(r[s+0]+r[s+1]+r[s+2])/3;r[s+0]=n,r[s+1]=n,r[s+2]=n}};le=he([G({message:"Grayscale will be removed in v0.26.0"})],le);let ce=class{updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data;r[s+0]=255-r[s+0],r[s+1]=255-r[s+1],r[s+2]=255-r[s+2]}};ce=he([G({message:"Invert will be removed in v0.26.0"})],ce);let de=class{constructor(t){this.opacity=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data;0!==r[s+3]&&(r[s+3]=Math.round(this.opacity*r[s+3]))}};de=he([G({message:"Opacity will be removed in v0.26.0"})],de);let ue=class{constructor(t){this.color=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data;0!==r[s+3]&&(r[s+0]=(r[s+0]+this.color.r)/2,r[s+1]=(r[s+1]+this.color.g)/2,r[s+2]=(r[s+2]+this.color.b)/2)}};ue=he([G({message:"Colorize will be removed in v0.26.0"})],ue);let pe=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data,n=Q.fromRGB(r[s+0],r[s+1],r[s+2],r[s+3]).lighten(this.factor);r[s+0]=n.r,r[s+1]=n.g,r[s+2]=n.b,r[s+3]=n.a}};pe=he([G({message:"Lighten will be removed in v0.26.0"})],pe);let ge=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data,n=Q.fromRGB(r[s+0],r[s+1],r[s+2],r[s+3]).darken(this.factor);r[s+0]=n.r,r[s+1]=n.g,r[s+2]=n.b,r[s+3]=n.a}};ge=he([G({message:"Darken will be removed v0.26.0"})],ge);let _e=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data,n=Q.fromRGB(r[s+0],r[s+1],r[s+2],r[s+3]).saturate(this.factor);r[s+0]=n.r,r[s+1]=n.g,r[s+2]=n.b,r[s+3]=n.a}};_e=he([G({message:"Saturate will be removed in v0.26.0"})],_e);let fe=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data,n=Q.fromRGB(r[s+0],r[s+1],r[s+2],r[s+3]).desaturate(this.factor);r[s+0]=n.r,r[s+1]=n.g,r[s+2]=n.b,r[s+3]=n.a}};fe=he([G({message:"Desaturate will be removed in v0.26.0"})],fe);let me=class{constructor(t){this.color=t}updatePixel(t,e,i){const s=4*(t+e*i.width),r=i.data;0!==r[s+3]&&(r[s+0]=this.color.r,r[s+1]=this.color.g,r[s+2]=this.color.b)}};function we(t){return class extends t{assign(t){for(const e in t)"function"!=typeof this[e]&&(this[e]=t[e])}constructor(...t){super(...t);1!==t.filter((function(t){return void 0!==t})).length||!t[0]||"object"!=typeof t[0]||t[0]instanceof Array||this.assign(t[0])}}}me=he([G({message:"Fill will be removed in v0.26.0"})],me);var ye=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o},ve=function(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(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(o,a)}h((s=s.apply(t,e||[])).next())}))};class xe{constructor(t,e,i,s,r){this.x=0,this.y=0,this.rotation=0,this.anchor=X.Half,this.offset=X.Zero,this.scale=X.One,this.drawAroundAnchor=!1,this.logger=_.getInstance(),this.flipVertical=!1,this.flipHorizontal=!1,this.effects=[],this.width=0,this.height=0,this._spriteCanvas=null,this._spriteCtx=null,this._pixelData=null,this._pixelsLoaded=!1,this._dirtyEffect=!0,this._opacity=1;let n=t;if(t&&!(t instanceof Ae)&&(e=0|t.x,i=0|t.y,s=0|t.width,r=0|t.height,n=t.image,!n)){throw new Error("An image texture is required to construct a sprite")}this.x=e||0,this.y=i||0,this.texture=n,this._spriteCanvas=document.createElement("canvas"),this._spriteCanvas.width=s,this._spriteCanvas.height=r,this._spriteCtx=this._spriteCanvas.getContext("2d"),this._initPixelsFromTexture(),this.width=s,this.height=r}get drawWidth(){return Math.abs(this.width*this.scale.x)}get drawHeight(){return Math.abs(this.height*this.scale.y)}_initPixelsFromTexture(){return ve(this,void 0,void 0,(function*(){try{const t=yield this.texture.loaded;this.width=this.width||t.naturalWidth,this.height=this.height||t.naturalHeight,this._spriteCanvas.width=this._spriteCanvas.width||t.naturalWidth,this._spriteCanvas.height=this._spriteCanvas.height||t.naturalHeight,this._loadPixels(),this._dirtyEffect=!0}catch(t){this.logger.error("Error loading texture ",this.texture.path,t)}}))}_loadPixels(){if(this.texture.isLoaded()&&!this._pixelsLoaded){const t=this.texture.image.naturalWidth||0,e=this.texture.image.naturalHeight||0;if(this.width>t&&this.logger.warn(`The sprite width ${this.width} exceeds the width \n ${t} of the backing texture ${this.texture.path}`),this.width<=0||t<=0)throw new Error(`The width of a sprite cannot be 0 or negative, sprite width: ${this.width}, original width: ${t}`);if(this.height>e&&this.logger.warn(`The sprite height ${this.height} exceeds the height \n ${e} of the backing texture ${this.texture.path}`),this.height<=0||e<=0)throw new Error(`The height of a sprite cannot be 0 or negative, sprite height: ${this.height}, original height: ${e}`);this._flushTexture(),this._pixelsLoaded=!0}}_flushTexture(){const t=this.texture.image.naturalWidth||0,e=this.texture.image.naturalHeight||0;this._spriteCtx.clearRect(0,0,this.width,this.height),this._spriteCtx.drawImage(this.texture.image,A(this.x,0,t),A(this.y,0,e),A(this.width,0,t),A(this.height,0,e),0,0,this.width,this.height)}opacity(t){this._opacity=t}grayscale(){this.addEffect(new le)}invert(){this.addEffect(new ce)}fill(t){this.addEffect(new me(t))}colorize(t){this.addEffect(new ue(t))}lighten(t=.1){this.addEffect(new pe(t))}darken(t=.1){this.addEffect(new ge(t))}saturate(t=.1){this.addEffect(new _e(t))}desaturate(t=.1){this.addEffect(new fe(t))}addEffect(t){this.effects.push(t),this.texture.isLoaded()&&this._pixelsLoaded?this._applyEffects():this._dirtyEffect=!0}removeEffect(t){let e=-1;e="number"==typeof t?t:this.effects.indexOf(t),e<0||e>=this.effects.length||(this.effects.splice(e,1),this.texture.isLoaded()&&this._pixelsLoaded?this._applyEffects():this._dirtyEffect=!0)}_applyEffects(){if(this._flushTexture(),this.effects.length>0){this._pixelData=this._spriteCtx.getImageData(0,0,this.width,this.height);const t=this.effects.length;for(let e=0;e<t;e++)for(let t=0;t<this.height;t++)for(let i=0;i<this.width;i++)this.effects[e].updatePixel(i,t,this._pixelData);this._spriteCtx.clearRect(0,0,this.width,this.height),this._spriteCtx.putImageData(this._pixelData,0,0)}this._dirtyEffect=!1}clearEffects(){this.effects.length=0,this._applyEffects()}reset(){}debugDraw(t,e,i){t.save(),t.translate(e,i),t.rotate(this.rotation);const s=this.drawWidth*this.anchor.x,r=this.drawHeight*this.anchor.y;t.strokeStyle=Q.Black.toString(),t.strokeRect(-s,-r,this.drawWidth,this.drawHeight),t.restore()}draw(t,e,i){t instanceof CanvasRenderingContext2D?this._drawWithOptions({ctx:t,x:e,y:i}):this._drawWithOptions(t)}_drawWithOptions(t){var e,i,s,r,n,o,a,h,l;const{ctx:c,x:d,y:u,rotation:p,drawWidth:g,drawHeight:_,anchor:f,offset:m,opacity:w,flipHorizontal:y,flipVertical:v}=Object.assign(Object.assign({},t),{rotation:null!==(e=t.rotation)&&void 0!==e?e:this.rotation,drawWidth:null!==(i=t.drawWidth)&&void 0!==i?i:this.width,drawHeight:null!==(s=t.drawHeight)&&void 0!==s?s:this.height,flipHorizontal:null!==(r=t.flipHorizontal)&&void 0!==r?r:this.flipHorizontal,flipVertical:null!==(n=t.flipVertical)&&void 0!==n?n:this.flipVertical,anchor:null!==(o=t.anchor)&&void 0!==o?o:this.anchor,offset:null!==(a=t.offset)&&void 0!==a?a:this.offset,opacity:(null!==(h=t.opacity)&&void 0!==h?h:1)*(null!==(l=this._opacity)&&void 0!==l?l:1)});this._dirtyEffect&&this._applyEffects();const x=g*f.x+m.x,b=_*f.y+m.y,C=this.scale.x>0?1:-1,A=this.scale.y>0?1:-1;c.save(),c.translate(d,u),c.scale(Math.abs(this.scale.x),Math.abs(this.scale.y)),this.drawAroundAnchor&&c.translate(-x,-b),c.translate(x,b),c.rotate(p),c.scale(C,A),c.translate(-x,-b),y&&(c.translate(g,0),c.scale(-1,1)),v&&(c.translate(0,_),c.scale(1,-1));const S=c.globalAlpha;c.globalAlpha=w,c.drawImage(this._spriteCanvas,0,0,this.width,this.height,0,0,this.width,this.height),c.globalAlpha=S,c.restore()}clone(){const t=new be(this.texture,this.x,this.y,this.width,this.height);t.anchor=this.anchor.clone(),t.scale=this.scale.clone(),t.rotation=this.rotation,t.flipHorizontal=this.flipHorizontal,t.flipVertical=this.flipVertical;const e=this.effects.length;for(let i=0;i<e;i++)t.addEffect(this.effects[i]);return t}}let be=class extends(we(xe)){constructor(t,e,i,s,r){super(t,e,i,s,r)}};be=ye([G({message:"Label.clearTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],be);var Ce=function(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(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(o,a)}h((s=s.apply(t,e||[])).next())}))};class Ae{constructor(t,e=!0){this.path=t,this.bustCache=e,this._sprite=null,this.loaded=new Promise(t=>{this._loadedResolve=t}),this._resource=new ae(t,"blob",e),this._sprite=new be(this,0,0,0,0)}get image(){return this.data}isLoaded(){return!!this.data}load(){return Ce(this,void 0,void 0,(function*(){try{let t;if(this.path.includes("data:image/"))t=this.path;else{const e=yield this._resource.load();t=URL.createObjectURL(e)}const e=new Image;e.src=t,yield e.decode(),this.data=e,this.width=this._sprite.width=e.naturalWidth,this.height=this._sprite.height=e.naturalHeight,this._sprite=new be(this,0,0,this.width,this.height)}catch(t){yield Promise.reject("Error loading texture")}return this._loadedResolve(this.data),this.data}))}asSprite(){return this._sprite}}var Se=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class Pe{constructor(t,e,i,s){this.sprites=[],this.currentFrame=0,this._timeLeftInFrame=0,this._idempotencyToken=-1,this.anchor=X.Zero,this.rotation=0,this.scale=X.One,this.loop=!0,this.freezeFrame=-1,this.flipVertical=!1,this.flipHorizontal=!1,this.drawWidth=0,this.drawHeight=0,this.width=0,this.height=0,this._opacity=1;let r=t;if(t&&!(t instanceof hn)){const n=t;r=n.engine,e=n.sprites,i=n.speed,s=n.loop}this.sprites=e,this.speed=i,this._engine=r,this._timeLeftInFrame=this.speed,null!=s&&(this.loop=s),e&&e[0]&&(this.drawHeight=e[0]?e[0].drawHeight:0,this.drawWidth=e[0]?e[0].drawWidth:0,this.width=e[0]?e[0].width:0,this.height=e[0]?e[0].height:0,this.freezeFrame=e.length-1)}opacity(t){this._opacity=t}grayscale(){this.addEffect(new le)}invert(){this.addEffect(new ce)}fill(t){this.addEffect(new me(t))}colorize(t){this.addEffect(new ue(t))}lighten(t=.1){this.addEffect(new pe(t))}darken(t=.1){this.addEffect(new ge(t))}saturate(t=.1){this.addEffect(new _e(t))}desaturate(t=.1){this.addEffect(new fe(t))}addEffect(t){for(const e in this.sprites)this.sprites[e].addEffect(t)}removeEffect(t){for(const e in this.sprites)this.sprites[e].removeEffect(t)}clearEffects(){for(const t in this.sprites)this.sprites[t].clearEffects()}_setAnchor(t){for(const e in this.sprites)this.sprites[e].anchor.setTo(t.x,t.y)}_setRotation(t){for(const e in this.sprites)this.sprites[e].rotation=t}_setScale(t){for(const e in this.sprites)this.sprites[e].scale=t}reset(){this.currentFrame=0}isDone(){return!this.loop&&this.currentFrame>=this.sprites.length}tick(t,e){if(this._idempotencyToken===e)return;this._idempotencyToken=e,this._timeLeftInFrame-=t,this._timeLeftInFrame<=0&&(this.currentFrame=this.loop?(this.currentFrame+1)%this.sprites.length:this.currentFrame+1,this._timeLeftInFrame=this.speed),this._updateValues();const i=this.sprites[this.currentFrame];i&&(this.width=i.width,this.height=i.height,this.drawWidth=i.drawWidth,this.drawHeight=i.drawHeight)}_updateValues(){this._setAnchor(this.anchor),this._setRotation(this.rotation),this._setScale(this.scale)}skip(t){this.currentFrame=(this.currentFrame+t)%this.sprites.length}draw(t,e,i){t instanceof CanvasRenderingContext2D?this._drawWithOptions({ctx:t,x:e,y:i}):this._drawWithOptions(t)}_drawWithOptions(t){var e,i,s,r,n,o,a,h;const l=Object.assign(Object.assign({},t),{rotation:null!==(e=t.rotation)&&void 0!==e?e:this.rotation,drawWidth:null!==(i=t.drawWidth)&&void 0!==i?i:this.drawWidth,drawHeight:null!==(s=t.drawHeight)&&void 0!==s?s:this.drawHeight,flipHorizontal:null!==(r=t.flipHorizontal)&&void 0!==r?r:this.flipHorizontal,flipVertical:null!==(n=t.flipVertical)&&void 0!==n?n:this.flipVertical,anchor:null!==(o=t.anchor)&&void 0!==o?o:this.anchor,opacity:(null!==(a=t.opacity)&&void 0!==a?a:1)*(null!==(h=this._opacity)&&void 0!==h?h:1)});let c;this._updateValues(),this.currentFrame<this.sprites.length&&(c=this.sprites[this.currentFrame],c.draw(l)),-1!==this.freezeFrame&&this.currentFrame>=this.sprites.length&&(c=this.sprites[A(this.freezeFrame,0,this.sprites.length-1)],c.draw(l)),c&&(this.drawWidth=c.drawWidth,this.drawHeight=c.drawHeight)}play(t,e){this.reset(),this._engine.playAnimation(this,t,e)}}let Ee=class extends(we(Pe)){constructor(t,e,i,s){super(t,e,i,s)}};Ee=Se([G({message:"Animation will be removed in v0.26.0",alternateMethod:"Use Graphics.Animation"})],Ee);var Te,Re,De=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class Me{static CreateReversibleEasingFunction(t){return(e,i,s,r)=>s<i?i-(t(e,s,i,r)-s):t(e,i,s,r)}static CreateReversableEasingFunction(t){return Me.CreateReversibleEasingFunction(t)}static CreateVectorEasingFunction(t){return(e,i,s,r)=>new X(t(e,i.x,s.x,r),t(e,i.y,s.y,r))}}Me.Linear=Me.CreateReversibleEasingFunction((t,e,i,s)=>(i-=e)*t/s+e),Me.EaseInQuad=Me.CreateReversibleEasingFunction((t,e,i,s)=>(i-=e)*(t/=s)*t+e),Me.EaseOutQuad=Me.CreateReversibleEasingFunction((t,e,i,s)=>-(i-=e)*(t/=s)*(t-2)+e),Me.EaseInOutQuad=Me.CreateReversibleEasingFunction((t,e,i,s)=>(i-=e,(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e)),Me.EaseInCubic=Me.CreateReversibleEasingFunction((t,e,i,s)=>(i-=e)*(t/=s)*t*t+e),Me.EaseOutCubic=Me.CreateReversibleEasingFunction((t,e,i,s)=>(t/=s,(i-=e)*(--t*t*t+1)+e)),Me.EaseInOutCubic=Me.CreateReversibleEasingFunction((t,e,i,s)=>(i-=e,(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e)),De([G({message:"Alias for incorrect spelling used in older versions, will be removed in v0.25.0",alternateMethod:"CreateReversibleEasingFunction"})],Me,"CreateReversableEasingFunction",null);class Be{constructor(t){this._actions=[],this._completedActions=[],this._actor=t}add(t){this._actions.push(t)}remove(t){const e=this._actions.indexOf(t);this._actions.splice(e,1)}clearActions(){this._actions.length=0,this._completedActions.length=0,this._currentAction&&this._currentAction.stop()}getActions(){return this._actions.concat(this._completedActions)}hasNext(){return this._actions.length>0}isComplete(){return 0===this._actions.length}reset(){this._actions=this.getActions();const t=this._actions.length;for(let e=0;e<t;e++)this._actions[e].reset();this._completedActions=[]}update(t){this._actions.length>0&&(this._currentAction=this._actions[0],this._currentAction.update(t),this._currentAction.isComplete(this._actor)&&this._completedActions.push(this._actions.shift()))}}class ke{constructor(t,e,i){this._stopped=!1,this._repeatBuilder=e,this._repeatContext=new ri(t),this._actionQueue=this._repeatContext.getQueue(),this._repeat=i,this._originalRepeat=i,this._repeatBuilder(this._repeatContext),this._repeat--}update(t){this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext),this._repeat--),this._actionQueue.update(t)}isComplete(){return this._stopped||this._repeat<=0&&this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._repeat=this._originalRepeat}}class Fe{constructor(t,e){this._stopped=!1,this._repeatBuilder=e,this._repeatContext=new ri(t),this._actionQueue=this._repeatContext.getQueue(),this._repeatBuilder(this._repeatContext)}update(t){this._stopped||(this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext)),this._actionQueue.update(t))}isComplete(){return this._stopped}stop(){this._stopped=!0,this._actionQueue.clearActions()}reset(){}}class Le{constructor(t,e,i,s){if(this._started=!1,this._stopped=!1,this._actor=t,this._speed=s,this._offset=new X(e,i),s<=0)throw _.getInstance().error("Attempted to moveBy with speed less than or equal to zero : "+s),new Error("Speed must be greater than 0 pixels per second")}update(t){this._started||(this._started=!0,this._start=new X(this._actor.pos.x,this._actor.pos.y),this._end=this._start.add(this._offset),this._distance=this._offset.size,this._dir=this._end.sub(this._start).normalize()),this.isComplete(this._actor)?(this._actor.pos=q(this._end.x,this._end.y),this._actor.vel=q(0,0)):this._actor.vel=this._dir.scale(this._speed)}isComplete(t){return this._stopped||t.pos.distance(this._start)>=this._distance}stop(){this._actor.vel=q(0,0),this._stopped=!0}reset(){this._started=!1}}class Ie{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._actor=t,this._end=new X(e,i),this._speed=s}update(t){this._started||(this._started=!0,this._start=new X(this._actor.pos.x,this._actor.pos.y),this._distance=this._start.distance(this._end),this._dir=this._end.sub(this._start).normalize());const e=this._dir.scale(this._speed);this._actor.vel=q(e.x,e.y),this.isComplete(this._actor)&&(this._actor.pos=q(this._end.x,this._end.y),this._actor.vel=q(0,0))}isComplete(t){return this._stopped||new X(t.pos.x,t.pos.y).distance(this._start)>=this._distance}stop(){this._actor.vel=q(0,0),this._stopped=!0}reset(){this._started=!1}}!function(t){t[t.ShortestPath=0]="ShortestPath",t[t.LongestPath=1]="LongestPath",t[t.Clockwise=2]="Clockwise",t[t.CounterClockwise=3]="CounterClockwise"}(Te||(Te={}));class Oe{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._actor=t,this._end=e,this._speed=i,this._rotationType=s||Te.ShortestPath}update(t){if(!this._started){this._started=!0,this._start=this._actor.rotation,this._currentNonCannonAngle=this._actor.rotation;const t=Math.abs(this._end-this._start),e=v-t;switch(t>e?(this._shortDistance=e,this._longDistance=t):(this._shortDistance=t,this._longDistance=e),this._shortestPathIsPositive=(this._start-this._end+v)%v>=Math.PI,this._rotationType){case Te.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case Te.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case Te.Clockwise:this._direction=1,this._shortestPathIsPositive?this._distance=this._shortDistance:this._distance=this._longDistance;break;case Te.CounterClockwise:this._direction=-1,this._shortestPathIsPositive?this._distance=this._longDistance:this._distance=this._shortDistance}}this._actor.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(t/1e3),this.isComplete()&&(this._actor.rotation=this._end,this._actor.angularVelocity=0,this._stopped=!0)}isComplete(){const t=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||t>=Math.abs(this._distance)}stop(){this._actor.angularVelocity=0,this._stopped=!0}reset(){this._started=!1}}class ze{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._actor=t,this._speed=i,this._offset=e,this._rotationType=s||Te.ShortestPath}update(t){if(!this._started){this._started=!0,this._start=this._actor.rotation,this._currentNonCannonAngle=this._actor.rotation,this._end=this._start+this._offset;const t=Math.abs(this._end-this._start),e=v-t;switch(t>e?(this._shortDistance=e,this._longDistance=t):(this._shortDistance=t,this._longDistance=e),this._shortestPathIsPositive=(this._start-this._end+v)%v>=Math.PI,this._rotationType){case Te.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case Te.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case Te.Clockwise:this._direction=1,this._shortDistance>=0?this._distance=this._shortDistance:this._distance=this._longDistance;break;case Te.CounterClockwise:this._direction=-1,this._shortDistance<=0?this._distance=this._shortDistance:this._distance=this._longDistance}}this._actor.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(t/1e3),this.isComplete()&&(this._actor.rotation=this._end,this._actor.angularVelocity=0,this._stopped=!0)}isComplete(){const t=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||t>=Math.abs(this._distance)}stop(){this._actor.angularVelocity=0,this._stopped=!0}reset(){this._started=!1}}class Ue{constructor(){this.owner=null}clone(){const t=new this.constructor;for(const i in this)if(this.hasOwnProperty(i)){const s=this[i];(null==(e=s)?void 0:e.clone)&&"owner"!==i&&"clone"!==i?t[i]=s.clone():t[i]=s}var e;return t}}class He extends Ue{constructor(t,e){super(),this.type=t,this.value=e}}class Ne extends Ue{constructor(){super(...arguments),this.type="ex.motion",this.vel=X.Zero,this.acc=X.Zero,this.scaleFactor=X.Zero,this.angularVelocity=0,this.torque=0,this.inertia=1}}!function(t){t[t.X=12]="X",t[t.Y=13]="Y"}(Re||(Re={}));const We=t=>0===t?0:t<0?-1:1;class Ve{constructor(){this.data=new Float32Array(16),this._scaleSignX=1,this._scaleSignY=1}static ortho(t,e,i,s,r,n){const o=new Ve;return o.data[0]=2/(e-t),o.data[1]=0,o.data[2]=0,o.data[3]=0,o.data[4]=0,o.data[5]=2/(s-i),o.data[6]=0,o.data[7]=0,o.data[8]=0,o.data[9]=0,o.data[10]=-2/(n-r),o.data[11]=0,o.data[12]=-(e+t)/(e-t),o.data[13]=-(s+i)/(s-i),o.data[14]=-(n+r)/(n-r),o.data[15]=1,o}clone(){const t=new Ve;return t.data[0]=this.data[0],t.data[1]=this.data[1],t.data[2]=this.data[2],t.data[3]=this.data[3],t.data[4]=this.data[4],t.data[5]=this.data[5],t.data[6]=this.data[6],t.data[7]=this.data[7],t.data[8]=this.data[8],t.data[9]=this.data[9],t.data[10]=this.data[10],t.data[11]=this.data[11],t.data[12]=this.data[12],t.data[13]=this.data[13],t.data[14]=this.data[14],t.data[15]=this.data[15],t}static identity(){const t=new Ve;return t.data[0]=1,t.data[1]=0,t.data[2]=0,t.data[3]=0,t.data[4]=0,t.data[5]=1,t.data[6]=0,t.data[7]=0,t.data[8]=0,t.data[9]=0,t.data[10]=1,t.data[11]=0,t.data[12]=0,t.data[13]=0,t.data[14]=0,t.data[15]=1,t}static translation(t,e){const i=Ve.identity();return i.data[12]=t,i.data[13]=e,i}static scale(t,e){const i=Ve.identity();return i.data[0]=t,i.data[5]=e,i.data[10]=1,i.data[15]=1,i}static rotation(t){const e=Ve.identity();return e.data[0]=Math.cos(t),e.data[4]=-Math.sin(t),e.data[1]=Math.sin(t),e.data[5]=Math.cos(t),e}multv(t){if(t instanceof X)return new X(t.x*this.data[0]+t.y*this.data[4]+0*this.data[6]+1*this.data[12],t.x*this.data[1]+t.y*this.data[5]+0*this.data[9]+1*this.data[13]);return[t[0]*this.data[0]+t[1]*this.data[4]+0*this.data[6]+1*this.data[12],t[0]*this.data[1]+t[1]*this.data[5]+0*this.data[9]+1*this.data[13]]}multm(t){const e=new Ve,i=this.data[0],s=this.data[1],r=this.data[2],n=this.data[3],o=this.data[4],a=this.data[5],h=this.data[6],l=this.data[7],c=this.data[8],d=this.data[9],u=this.data[10],p=this.data[11],g=this.data[12],_=this.data[13],f=this.data[14],m=this.data[15],w=t.data[0],y=t.data[1],v=t.data[2],x=t.data[3],b=t.data[4],C=t.data[5],A=t.data[6],S=t.data[7],P=t.data[8],E=t.data[9],T=t.data[10],R=t.data[11],D=t.data[12],M=t.data[13],B=t.data[14],k=t.data[15];e.data[0]=i*w+o*y+c*v+g*x,e.data[1]=s*w+a*y+d*v+_*x,e.data[2]=r*w+h*y+u*v+f*x,e.data[3]=n*w+l*y+p*v+m*x,e.data[4]=i*b+o*C+c*A+g*S,e.data[5]=s*b+a*C+d*A+_*S,e.data[6]=r*b+h*C+u*A+f*S,e.data[7]=n*b+l*C+p*A+m*S,e.data[8]=i*P+o*E+c*T+g*R,e.data[9]=s*P+a*E+d*T+_*R,e.data[10]=r*P+h*E+u*T+f*R,e.data[11]=n*P+l*E+p*T+m*R,e.data[12]=i*D+o*M+c*B+g*k,e.data[13]=s*D+a*M+d*B+_*k,e.data[14]=r*D+h*M+u*B+f*k,e.data[15]=n*D+l*M+p*B+m*k;const F=this.getScale();return e._scaleSignX=We(F.x)*We(e._scaleSignX),e._scaleSignY=We(F.y)*We(e._scaleSignY),e}translate(t,e){const i=this.data[0],s=this.data[1],r=this.data[2],n=this.data[3],o=this.data[4],a=this.data[5],h=this.data[6],l=this.data[7],c=this.data[8],d=this.data[9],u=this.data[10],p=this.data[11],g=this.data[12],_=this.data[13],f=this.data[14],m=this.data[15];return this.data[12]=i*t+o*e+0*c+1*g,this.data[13]=s*t+a*e+0*d+1*_,this.data[14]=r*t+h*e+0*u+1*f,this.data[15]=n*t+l*e+0*p+1*m,this}setPosition(t,e){this.data[12]=t,this.data[13]=e}getPosition(){return q(this.data[12],this.data[13])}rotate(t){const e=this.data[0],i=this.data[1],s=this.data[2],r=this.data[3],n=this.data[4],o=this.data[5],a=this.data[6],h=this.data[7],l=Math.sin(t),c=Math.cos(t);return this.data[0]=c*e+l*n,this.data[1]=c*i+l*o,this.data[2]=c*s+l*a,this.data[3]=c*r+l*h,this.data[4]=c*n-l*e,this.data[5]=c*o-l*i,this.data[6]=c*a-l*s,this.data[7]=c*h-l*r,this}scale(t,e){const i=this.data[0],s=this.data[1],r=this.data[2],n=this.data[3],o=this.data[4],a=this.data[5],h=this.data[6],l=this.data[7];return this.data[0]=i*t,this.data[1]=s*t,this.data[2]=r*t,this.data[3]=n*t,this.data[4]=o*e,this.data[5]=a*e,this.data[6]=h*e,this.data[7]=l*e,this}setRotation(t){const e=this.getScale(),i=Math.sin(t),s=Math.cos(t);this.data[0]=s*e.x,this.data[1]=i*e.y,this.data[4]=-i*e.x,this.data[5]=s*e.y}getRotation(){return E(Math.atan2(this.data[1]/this.getScaleY(),this.data[0]/this.getScaleX()))}getScaleX(){const t=q(this.data[0],this.data[4]).size;return this._scaleSignX*t}getScaleY(){const t=q(this.data[1],this.data[5]).size;return this._scaleSignY*t}getScale(){return q(this.getScaleX(),this.getScaleY())}setScaleX(t){this._scaleSignX=We(t);const e=q(this.data[0]*this._scaleSignX,this.data[4]*this._scaleSignX).normalize();this.data[0]=e.x*t,this.data[4]=e.y*t}setScaleY(t){this._scaleSignY=We(t);const e=q(this.data[1]*this._scaleSignY,this.data[5]*this._scaleSignY).normalize();this.data[1]=e.x*t,this.data[5]=e.y*t}setScale(t){this.setScaleX(t.x),this.setScaleY(t.y)}getBasisDeterminant(){return this.data[0]*this.data[5]-this.data[1]*this.data[4]}getAffineInverse(){const t=1/this.getBasisDeterminant(),e=this.data[0],i=this.data[4],s=this.data[1],r=this.data[5],n=Ve.identity();n.data[0]=r*t,n.data[1]=-s*t,n.data[4]=-i*t,n.data[5]=e*t;const o=this.data[12],a=this.data[13];return n.data[12]=-(o*n.data[0]+a*n.data[4]),n.data[13]=-(o*n.data[1]+a*n.data[5]),n}isIdentity(){return 1===this.data[0]&&0===this.data[1]&&0===this.data[2]&&0===this.data[3]&&0===this.data[4]&&1===this.data[5]&&0===this.data[6]&&0===this.data[7]&&0===this.data[8]&&0===this.data[9]&&1===this.data[10]&&0===this.data[11]&&0===this.data[12]&&0===this.data[13]&&0===this.data[14]&&1===this.data[15]}toString(){return`\n[${this.data[0]} ${this.data[4]} ${this.data[8]} ${this.data[12]}]\n[${this.data[1]} ${this.data[5]} ${this.data[9]} ${this.data[13]}]\n[${this.data[2]} ${this.data[6]} ${this.data[10]} ${this.data[14]}]\n[${this.data[3]} ${this.data[7]} ${this.data[11]} ${this.data[15]}]\n`}}class Ge extends X{constructor(t){super(0,0),this._getX=t.getX,this._getY=t.getY,this._setX=t.setX,this._setY=t.setY}get x(){return this._x=this._getX()}set x(t){this._setX(t),this._x=t}get y(){return this._y=this._getY()}set y(t){this._setY(t),this._y=t}}var je,Xe;!function(t){t.World="world",t.Screen="screen"}(je||(je={}));class qe extends Ue{constructor(){super(...arguments),this.type="ex.transform",this._dirty=!1,this.matrix=Ve.identity().translate(0,0).rotate(0).scale(1,1),this._position=(t=>{const e=t;return new Ge({setX:t=>{e.data[Re.X]=t},setY:t=>{e.data[Re.Y]=t},getX:()=>e.data[Re.X],getY:()=>e.data[Re.Y]})})(this.matrix),this._rotation=0,this._scale=(t=>{const e=t;return new Ge({setX:t=>{e.setScaleX(t)},setY:t=>{e.setScaleY(t)},getX:()=>e.getScaleX(),getY:()=>e.getScaleY()})})(this.matrix),this.coordPlane=je.World,this.z=0}_recalculate(){this._rotation=this.matrix.getRotation(),this._dirty=!1}getGlobalMatrix(){return this.parent?this.parent.getGlobalMatrix().multm(this.matrix):this.matrix}getGlobalTransform(){return{pos:this.globalPos,scale:this.globalScale,rotation:this.globalRotation,z:this.z,coordPlane:this.coordPlane}}get parent(){var t,e;return null===(e=null===(t=null==this?void 0:this.owner)||void 0===t?void 0:t.parent)||void 0===e?void 0:e.get(qe)}get pos(){return this._dirty&&this._recalculate(),this._position}set pos(t){this.matrix.setPosition(t.x,t.y),this._dirty=!0}get dirty(){var t;if(null===(t=null==this?void 0:this.owner)||void 0===t?void 0:t.parent){return this.parent.dirty||this._dirty}return this._dirty}get globalPos(){const t=this.getGlobalMatrix();return new Ge({getX:()=>t.data[Re.X],getY:()=>t.data[Re.Y],setX:e=>{var i;if(this.parent){const[s]=null===(i=this.parent)||void 0===i?void 0:i.getGlobalMatrix().getAffineInverse().multv([e,t.data[Re.Y]]);this.matrix.data[Re.X]=s}else this.matrix.data[Re.X]=e},setY:e=>{var i;if(this.parent){const[,s]=null===(i=this.parent)||void 0===i?void 0:i.getGlobalMatrix().getAffineInverse().multv([t.data[Re.X],e]);this.matrix.data[Re.Y]=s}else this.matrix.data[Re.Y]=e}})}set globalPos(t){const e=this.parent;this.pos=e?e.getGlobalMatrix().getAffineInverse().multv(t):t}get rotation(){return this._dirty&&this._recalculate(),this._rotation}set rotation(t){this.matrix.setRotation(t),this._dirty=!0}get globalRotation(){return this.getGlobalMatrix().getRotation()}set globalRotation(t){const e=this.parent;this.rotation=e?t-e.globalRotation:t}get scale(){return this._dirty&&this._recalculate(),this._scale}set scale(t){this.matrix.setScale(t),this._dirty=!0}get globalScale(){const t=this.getGlobalMatrix();return new Ge({getX:()=>t.getScaleX(),getY:()=>t.getScaleY(),setX:t=>{if(this.parent){const e=this.parent.globalScale.x;this.matrix.setScaleX(t/e)}else this.matrix.setScaleX(t)},setY:t=>{if(this.parent){const e=this.parent.globalScale.y;this.matrix.setScaleY(t/e)}else this.matrix.setScaleY(t)}})}set globalScale(t){const e=this.parent;this.scale=e?q(t.x/e.globalScale.x,t.y/e.globalScale.y):t}apply(t){return this.matrix.multv(t)}applyInverse(t){return this.matrix.getAffineInverse().multv(t)}}class Ke{constructor(t,e,i,s,r){this._started=!1,this._stopped=!1,this._actor=t,this._endX=e,this._endY=i,this._speedX=s,this._speedY=r}update(t){const e=this._actor.get(qe),i=this._actor.get(Ne);if(this._started||(this._started=!0,this._startX=e.scale.x,this._startY=e.scale.y,this._distanceX=Math.abs(this._endX-this._startX),this._distanceY=Math.abs(this._endY-this._startY)),Math.abs(e.scale.x-this._startX)>=this._distanceX)i.scaleFactor.x=0;else{const t=this._endY<this._startY?-1:1;i.scaleFactor.x=this._speedX*t}if(Math.abs(e.scale.y-this._startY)>=this._distanceY)i.scaleFactor.y=0;else{const t=this._endY<this._startY?-1:1;i.scaleFactor.y=this._speedY*t}this.isComplete()&&(this._actor.scale=q(this._endX,this._endY),i.scaleFactor.x=0,i.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._actor.scale.y-this._startX)>=this._distanceX&&Math.abs(this._actor.scale.y-this._startY)>=this._distanceY}stop(){const t=this._actor.get(Ne);t.scaleFactor.x=0,t.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1}}class Ze{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._actor=t,this._offset=new X(e,i),this._speedX=this._speedY=s}update(t){const e=this._actor.get(qe),i=this._actor.get(Ne);this._started||(this._started=!0,this._startScale=e.scale.clone(),this._endScale=this._startScale.add(this._offset),this._distanceX=Math.abs(this._endScale.x-this._startScale.x),this._distanceY=Math.abs(this._endScale.y-this._startScale.y),this._directionX=this._endScale.x<this._startScale.x?-1:1,this._directionY=this._endScale.y<this._startScale.y?-1:1),i.scaleFactor.x=this._speedX*this._directionX,i.scaleFactor.y=this._speedY*this._directionY,this.isComplete()&&(e.scale=this._endScale,i.scaleFactor.x=0,i.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._actor.scale.x-this._startScale.x)>=this._distanceX&&Math.abs(this._actor.scale.y-this._startScale.y)>=this._distanceY}stop(){const t=this._actor.get(Ne);t.scaleFactor.x=0,t.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1}}class Ye{constructor(t){this._method=null,this._hasBeenCalled=!1,this._method=t}update(t){this._method(),this._hasBeenCalled=!0}isComplete(){return this._hasBeenCalled}reset(){this._hasBeenCalled=!1}stop(){this._hasBeenCalled=!0}}class Qe{constructor(t,e,i,s,r){this.actor=t,this.easingFcn=r,this._currentLerpTime=0,this._lerpDuration=1e3,this._lerpStart=new X(0,0),this._lerpEnd=new X(0,0),this._initialized=!1,this._stopped=!1,this._distance=0,this._lerpDuration=s,this._lerpEnd=new X(e,i)}_initialize(){this._lerpStart=new X(this.actor.pos.x,this.actor.pos.y),this._currentLerpTime=0,this._distance=this._lerpStart.distance(this._lerpEnd)}update(t){this._initialized||(this._initialize(),this._initialized=!0),this._currentLerpTime+=t;let e=this.actor.pos.x,i=this.actor.pos.y;this._currentLerpTime<this._lerpDuration?(e=this._lerpEnd.x<this._lerpStart.x?this._lerpStart.x-(this.easingFcn(this._currentLerpTime,this._lerpEnd.x,this._lerpStart.x,this._lerpDuration)-this._lerpEnd.x):this.easingFcn(this._currentLerpTime,this._lerpStart.x,this._lerpEnd.x,this._lerpDuration),i=this._lerpEnd.y<this._lerpStart.y?this._lerpStart.y-(this.easingFcn(this._currentLerpTime,this._lerpEnd.y,this._lerpStart.y,this._lerpDuration)-this._lerpEnd.y):this.easingFcn(this._currentLerpTime,this._lerpStart.y,this._lerpEnd.y,this._lerpDuration),this.actor.vel=q((e-this.actor.pos.x)/(t/1e3),(i-this.actor.pos.y)/(t/1e3))):(this.actor.pos=q(this._lerpEnd.x,this._lerpEnd.y),this.actor.vel=X.Zero)}isComplete(t){return this._stopped||new X(t.pos.x,t.pos.y).distance(this._lerpStart)>=this._distance}reset(){this._initialized=!1}stop(){this.actor.vel=q(0,0),this._stopped=!0}}class $e{constructor(t,e,i,s=1){this._timeVisible=0,this._timeNotVisible=0,this._elapsedTime=0,this._totalTime=0,this._stopped=!1,this._started=!1,this._actor=t,this._timeVisible=e,this._timeNotVisible=i,this._duration=(e+i)*s}update(t){this._started||(this._started=!0),this._elapsedTime+=t,this._totalTime+=t,this._actor.graphics.visible&&this._elapsedTime>=this._timeVisible&&(this._actor.graphics.visible=!1,this._elapsedTime=0),!this._actor.graphics.visible&&this._elapsedTime>=this._timeNotVisible&&(this._actor.graphics.visible=!0,this._elapsedTime=0),this.isComplete()&&(this._actor.graphics.visible=!0)}isComplete(){return this._stopped||this._totalTime>=this._duration}stop(){this._actor.graphics.visible=!0,this._stopped=!0}reset(){this._started=!1,this._elapsedTime=0,this._totalTime=0}}class Je{constructor(t,e,i){this._multiplier=1,this._started=!1,this._stopped=!1,this._actor=t,this._endOpacity=e,this._speed=i}update(t){this._started||(this._started=!0,this._endOpacity<this._actor.graphics.opacity?this._multiplier=-1:this._multiplier=1),this._speed>0&&(this._actor.graphics.opacity+=this._multiplier*(Math.abs(this._actor.graphics.opacity-this._endOpacity)*t)/this._speed),this._speed-=t,this.isComplete()&&(this._actor.graphics.opacity=this._endOpacity),_.getInstance().debug("[Action fade] Actor opacity:",this._actor.graphics.opacity)}isComplete(){return this._stopped||Math.abs(this._actor.graphics.opacity-this._endOpacity)<.05}stop(){this._stopped=!0}reset(){this._started=!1}}class ti{constructor(t,e){this._elapsedTime=0,this._started=!1,this._stopped=!1,this._actor=t,this._delay=e}update(t){this._started||(this._started=!0),this.x=this._actor.pos.x,this.y=this._actor.pos.y,this._elapsedTime+=t}isComplete(){return this._stopped||this._elapsedTime>=this._delay}stop(){this._stopped=!0}reset(){this._elapsedTime=0,this._started=!1}}class ei{constructor(t){this._stopped=!1,this._actor=t}update(t){this._actor.actions.clearActions(),this._actor.kill(),this._stopped=!0}isComplete(){return this._stopped}stop(){}reset(){}}class ii{constructor(t,e,i){this._started=!1,this._stopped=!1,this._actor=t,this._actorToFollow=e,this._current=new X(this._actor.pos.x,this._actor.pos.y),this._end=new X(e.pos.x,e.pos.y),this._maximumDistance=void 0!==i?i:this._current.distance(this._end),this._speed=0}update(t){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());const e=Math.sqrt(Math.pow(this._actorToFollow.vel.x,2)+Math.pow(this._actorToFollow.vel.y,2));if(0!==e&&(this._speed=e),this._current=q(this._actor.pos.x,this._actor.pos.y),this._end=q(this._actorToFollow.pos.x,this._actorToFollow.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize(),this._distanceBetween>=this._maximumDistance){const t=this._dir.scale(this._speed);this._actor.vel=q(t.x,t.y)}else this._actor.vel=q(0,0);this.isComplete()&&(this._actor.pos=q(this._end.x,this._end.y),this._actor.vel=q(0,0))}stop(){this._actor.vel=q(0,0),this._stopped=!0}isComplete(){return this._stopped}reset(){this._started=!1}}class si{constructor(t,e,i){this._started=!1,this._stopped=!1,this._speedWasSpecified=!1,this._actor=t,this._actorToMeet=e,this._current=new X(this._actor.pos.x,this._actor.pos.y),this._end=new X(e.pos.x,e.pos.y),this._speed=i||0,void 0!==i&&(this._speedWasSpecified=!0)}update(t){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());const e=Math.sqrt(Math.pow(this._actorToMeet.vel.x,2)+Math.pow(this._actorToMeet.vel.y,2));0===e||this._speedWasSpecified||(this._speed=e),this._current=q(this._actor.pos.x,this._actor.pos.y),this._end=q(this._actorToMeet.pos.x,this._actorToMeet.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize();const i=this._dir.scale(this._speed);this._actor.vel=q(i.x,i.y),this.isComplete()&&(this._actor.pos=q(this._end.x,this._end.y),this._actor.vel=q(0,0))}isComplete(){return this._stopped||this._distanceBetween<=1}stop(){this._actor.vel=q(0,0),this._stopped=!0}reset(){this._started=!1}}class ri{constructor(t){this._actor=t,this._queue=new Be(t)}getQueue(){return this._queue}update(t){this._queue.update(t)}clearActions(){this._queue.clearActions()}easeTo(...t){var e,i;let s=0,r=0,n=0,o=Me.Linear;return t[0]instanceof X?(s=t[0].x,r=t[0].y,n=t[1],o=null!==(e=t[2])&&void 0!==e?e:o):(s=t[0],r=t[1],n=t[2],o=null!==(i=t[3])&&void 0!==i?i:o),this._queue.add(new Qe(this._actor,s,r,n,o)),this}moveTo(t,e,i){let s=0,r=0,n=0;return t instanceof X?(s=t.x,r=t.y,n=e):(s=t,r=e,n=i),this._queue.add(new Ie(this._actor,s,r,n)),this}moveBy(t,e,i){let s=0,r=0,n=0;return t instanceof X?(s=t.x,r=t.y,n=e):(s=t,r=e,n=i),this._queue.add(new Le(this._actor,s,r,n)),this}rotateTo(t,e,i){return this._queue.add(new Oe(this._actor,t,e,i)),this}rotateBy(t,e,i){return this._queue.add(new ze(this._actor,t,e,i)),this}scaleTo(t,e,i,s){let r=1,n=1,o=0,a=0;return t instanceof X&&e instanceof X&&(r=t.x,n=t.y,o=e.x,a=e.y),"number"==typeof t&&"number"==typeof e&&(r=t,n=e,o=i,a=s),this._queue.add(new Ke(this._actor,r,n,o,a)),this}scaleBy(t,e,i){let s=1,r=1;return t instanceof X&&(s=t.x,r=t.y,i=e),"number"==typeof t&&"number"==typeof e&&(s=t,r=e),this._queue.add(new Ze(this._actor,s,r,i)),this}blink(t,e,i=1){return this._queue.add(new $e(this._actor,t,e,i)),this}fade(t,e){return this._queue.add(new Je(this._actor,t,e)),this}delay(t){return this._queue.add(new ti(this._actor,t)),this}die(){return this._queue.add(new ei(this._actor)),this}callMethod(t){return this._queue.add(new Ye(t)),this}repeat(t,e){return e?(this._queue.add(new ke(this._actor,t,e)),this):(this.repeatForever(t),this)}repeatForever(t){return this._queue.add(new Fe(this._actor,t)),this}follow(t,e){return void 0===e?this._queue.add(new ii(this._actor,t)):this._queue.add(new ii(this._actor,t,e)),this}meet(t,e){return void 0===e?this._queue.add(new si(this._actor,t)):this._queue.add(new si(this._actor,t,e)),this}asPromise(){return new Promise(t=>{this._queue.add(new Ye(()=>{t()}))})}}!function(t){t.PreventCollision="PreventCollision",t.Passive="Passive",t.Active="Active",t.Fixed="Fixed"}(Xe||(Xe={}));var ni,oi,ai,hi=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};!function(t){t.Arcade="arcade",t.Realistic="realistic"}(ni||(ni={})),function(t){t[t.DynamicAABBTree=0]="DynamicAABBTree"}(oi||(oi={})),function(t){t[t.Euler=0]="Euler"}(ai||(ai={}));class li{static get gravity(){return li.acc}static set gravity(t){li.acc=t}static useArcadePhysics(){li.collisionResolutionStrategy=ni.Arcade}static useRealisticPhysics(){li.collisionResolutionStrategy=ni.Realistic}static get dynamicTreeVelocityMultiplyer(){return li.dynamicTreeVelocityMultiplier}static set dynamicTreeVelocityMultiplyer(t){li.dynamicTreeVelocityMultiplier=t}}li.acc=new X(0,0),li.enabled=!0,li.broadphaseStrategy=oi.DynamicAABBTree,li.collisionResolutionStrategy=ni.Arcade,li.defaultMass=10,li.integrator=ai.Euler,li.dynamicTreeVelocityMultiplier=2,li.boundsPadding=5,li.positionIterations=3,li.velocityIterations=8,li.slop=1,li.steeringFactor=.2,li.warmStart=!0,li.bodiesCanSleepByDefault=!1,li.surfaceEpsilon=.1,li.sleepEpsilon=.07,li.wakeThreshold=3*li.sleepEpsilon,li.sleepBias=.9,li.checkForFastBodies=!0,li.disableMinimumSpeedForFastBody=!1,hi([G({message:"Alias for incorrect spelling used in older versions, will be removed in v0.25.0",alternateMethod:"dynamicTreeVelocityMultiplier"})],li,"dynamicTreeVelocityMultiplyer",null);class ci{constructor(t,e,i){this._name=t,this._category=e,this._mask=i}get name(){return this._name}get category(){return this._category}get mask(){return this._mask}canCollide(t){return 0!=(this.category&t.mask)&&0!=(t.category&this.mask)}invert(){return new ci("~("+this.name+")",~this.category,~this.mask)}static combine(t){const e=t.map(t=>t.name).join("+"),i=t.reduce((t,e)=>e.category|t,0);return new ci(e,i,~i)}static collidesWith(t){return ci.combine(t).invert()}}ci.All=new ci("Collide with all groups",-1,-1);class di{constructor(){this.observers=[],this.subscriptions=[]}register(t){this.observers.push(t)}subscribe(t){this.subscriptions.push(t)}unregister(t){const e=this.observers.indexOf(t);-1!==e&&this.observers.splice(e,1)}unsubscribe(t){const e=this.subscriptions.indexOf(t);-1!==e&&this.subscriptions.splice(e,1)}notifyAll(t){this.observers.forEach(e=>e.notify(t)),this.subscriptions.forEach(e=>e(t))}clear(){this.observers.length=0,this.subscriptions.length=0}}class ui{constructor(t,e){this.colliderA=t,this.colliderB=e,this.id=null,this.id=ui.calculatePairHash(t.id,e.id)}static canCollide(t,e){var i,s;const r=null===(i=null==t?void 0:t.owner)||void 0===i?void 0:i.get(Bi),n=null===(s=null==e?void 0:e.owner)||void 0===s?void 0:s.get(Bi);return!(!r||!n)&&(!!r.group.canCollide(n.group)&&((r.collisionType!==Xe.Fixed||n.collisionType!==Xe.Fixed)&&(n.collisionType!==Xe.PreventCollision&&r.collisionType!==Xe.PreventCollision&&!(!r.active||!n.active))))}get canCollide(){const t=this.colliderA,e=this.colliderB;return ui.canCollide(t,e)}collide(){return this.colliderA.collide(this.colliderB)}hasCollider(t){return t===this.colliderA||t===this.colliderB}static calculatePairHash(t,e){return t.value<e.value?`#${t.value}+${e.value}`:`#${e.value}+${t.value}`}}class pi{constructor(t,e){this.min=t,this.max=e}overlaps(t){return this.max>t.min&&t.max>this.min}getOverlap(t){return this.overlaps(t)?this.max>t.max?t.max-this.min:this.max-t.min:0}}class gi{constructor(t){this.parent=t,this.parent=t||null,this.data=null,this.bounds=new J,this.left=null,this.right=null,this.height=0}isLeaf(){return!this.left&&!this.right}}class _i{constructor(t=new J(-Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)){this.worldBounds=t,this.root=null,this.nodes={}}_insert(t){if(null===this.root)return this.root=t,void(this.root.parent=null);const e=t.bounds;let i=this.root;for(;!i.isLeaf();){const t=i.left,s=i.right,r=i.bounds.getPerimeter(),n=i.bounds.combine(e).getPerimeter(),o=2*n,a=2*(n-r);let h=0;const l=e.combine(t.bounds);let c,d;t.isLeaf()?h=l.getPerimeter()+a:(d=t.bounds.getPerimeter(),c=l.getPerimeter(),h=c-d+a);let u=0;const p=e.combine(s.bounds);if(s.isLeaf()?u=p.getPerimeter()+a:(d=s.bounds.getPerimeter(),c=p.getPerimeter(),u=c-d+a),o<h&&o<u)break;i=h<u?t:s}const s=i.parent,r=new gi(s);r.bounds=e.combine(i.bounds),r.height=i.height+1,null!==s?(s.left===i?s.left=r:s.right=r,r.left=i,r.right=t,i.parent=r,t.parent=r):(r.left=i,r.right=t,i.parent=r,t.parent=r,this.root=r);let n=t.parent;for(;n;){if(n=this._balance(n),!n.left)throw new Error("Parent of current leaf cannot have a null left child"+n);if(!n.right)throw new Error("Parent of current leaf cannot have a null right child"+n);n.height=1+Math.max(n.left.height,n.right.height),n.bounds=n.left.bounds.combine(n.right.bounds),n=n.parent}}_remove(t){if(t===this.root)return void(this.root=null);const e=t.parent,i=e.parent;let s;if(s=e.left===t?e.right:e.left,i){i.left===e?i.left=s:i.right=s,s.parent=i;let t=i;for(;t;)t=this._balance(t),t.bounds=t.left.bounds.combine(t.right.bounds),t.height=1+Math.max(t.left.height,t.right.height),t=t.parent}else this.root=s,s.parent=null}trackCollider(t){const e=new gi;e.data=t,e.bounds=t.bounds,e.bounds.left-=2,e.bounds.top-=2,e.bounds.right+=2,e.bounds.bottom+=2,this.nodes[t.id.value]=e,this._insert(e)}updateCollider(t){var e;const i=this.nodes[t.id.value];if(!i)return!1;const s=t.bounds;if(!this.worldBounds.contains(s))return _.getInstance().warn("Collider with id "+t.id.value+" is outside the world bounds and will no longer be tracked for physics"),this.untrackCollider(t),!1;if(i.bounds.contains(s))return!1;if(this._remove(i),s.left-=li.boundsPadding,s.top-=li.boundsPadding,s.right+=li.boundsPadding,s.bottom+=li.boundsPadding,t.owner){const i=null===(e=t.owner)||void 0===e?void 0:e.get(Bi);if(i){const t=32*i.vel.x/1e3*li.dynamicTreeVelocityMultiplier,e=32*i.vel.y/1e3*li.dynamicTreeVelocityMultiplier;t<0?s.left+=t:s.right+=t,e<0?s.top+=e:s.bottom+=e}}return i.bounds=s,this._insert(i),!0}untrackCollider(t){const e=this.nodes[t.id.value];e&&(this._remove(e),this.nodes[t.id.value]=null,delete this.nodes[t.id.value])}_balance(t){if(null===t)throw new Error("Cannot balance at null node");if(t.isLeaf()||t.height<2)return t;const e=t.left,i=t.right,s=t,r=e,n=i,o=e.left,a=e.right,h=i.left,l=i.right,c=n.height-r.height;if(c>1)return n.left=s,n.parent=s.parent,s.parent=n,n.parent?n.parent.left===s?n.parent.left=n:n.parent.right=n:this.root=n,h.height>l.height?(n.right=h,s.right=l,l.parent=s,s.bounds=r.bounds.combine(l.bounds),n.bounds=s.bounds.combine(h.bounds),s.height=1+Math.max(r.height,l.height),n.height=1+Math.max(s.height,h.height)):(n.right=l,s.right=h,h.parent=s,s.bounds=r.bounds.combine(h.bounds),n.bounds=s.bounds.combine(l.bounds),s.height=1+Math.max(r.height,h.height),n.height=1+Math.max(s.height,l.height)),n;if(c<-1){if(r.left=s,r.parent=s.parent,s.parent=r,r.parent)if(r.parent.left===s)r.parent.left=r;else{if(r.parent.right!==s)throw"Error rotating Dynamic Tree";r.parent.right=r}else this.root=r;return o.height>a.height?(r.right=o,s.left=a,a.parent=s,s.bounds=n.bounds.combine(a.bounds),r.bounds=s.bounds.combine(o.bounds),s.height=1+Math.max(n.height,a.height),r.height=1+Math.max(s.height,o.height)):(r.right=a,s.left=o,o.parent=s,s.bounds=n.bounds.combine(o.bounds),r.bounds=s.bounds.combine(a.bounds),s.height=1+Math.max(n.height,o.height),r.height=1+Math.max(s.height,a.height)),r}return t}getHeight(){return null===this.root?0:this.root.height}query(t,e){const i=t.bounds,s=r=>{if(r&&r.bounds.intersect(i)){if(!r.isLeaf()||r.data===t)return s(r.left)||s(r.right);if(e.call(t,r.data))return!0}return!1};s(this.root)}rayCastQuery(t,e=1/0,i){const s=r=>{if(r&&r.bounds.rayCast(t,e)){if(!r.isLeaf())return s(r.left)||s(r.right);if(i.call(t,r.data))return!0}return!1};s(this.root)}getNodes(){const t=e=>e?[e].concat(t(e.left),t(e.right)):[];return t(this.root)}debug(t){const e=i=>{i&&(i.isLeaf()?i.bounds.draw(t,Q.Green):i.bounds.draw(t,Q.White),i.left&&e(i.left),i.right&&e(i.right))};e(this.root)}}class fi{constructor(t,e){this.pos=t,this.dir=e.normalize()}intersect(t){const e=t.begin.sub(this.pos);if(0===this.dir.cross(t.getSlope())&&0!==e.cross(this.dir))return-1;const i=this.dir.cross(t.getSlope());if(0===i)return-1;const s=e.cross(t.getSlope())/i;if(s>=0){const r=e.cross(this.dir)/i/t.getLength();if(r>=0&&r<=1)return s}return-1}intersectPoint(t){const e=this.intersect(t);return e<0?null:this.getPoint(e)}getPoint(t){return this.pos.add(this.dir.scale(t))}}class mi{constructor(){this._dynamicCollisionTree=new _i,this._collisions=new Set,this._collisionPairCache=[],this._colliders=[]}getColliders(){return this._colliders}track(t){if(t)if(t instanceof yi){const e=t.getColliders();for(const i of e)i.owner=t.owner,this._colliders.push(i),this._dynamicCollisionTree.trackCollider(i)}else this._colliders.push(t),this._dynamicCollisionTree.trackCollider(t);else _.getInstance().warn("Cannot track null collider")}untrack(t){if(t)if(t instanceof yi){const e=t.getColliders();for(const t of e){const e=this._colliders.indexOf(t);-1!==e&&this._colliders.splice(e,1),this._dynamicCollisionTree.untrackCollider(t)}}else{const e=this._colliders.indexOf(t);-1!==e&&this._colliders.splice(e,1),this._dynamicCollisionTree.untrackCollider(t)}else _.getInstance().warn("Cannot untrack a null collider")}_shouldGenerateCollisionPair(t,e){if(null!==t.id&&null!==e.id&&t.id===e.id||null!==t.owner&&null!==e.owner&&t.owner===e.owner)return!1;const i=ui.calculatePairHash(t.id,e.id);return!this._collisions.has(i)&&(!t.localBounds.hasZeroDimensions()&&!e.localBounds.hasZeroDimensions()&&ui.canCollide(t,e))}broadphase(t,e,i){const s=e/1e3,r=t.filter(t=>{var e,i;const s=null===(e=t.owner)||void 0===e?void 0:e.get(Bi);return(null===(i=t.owner)||void 0===i?void 0:i.active)&&s.collisionType!==Xe.PreventCollision});let n;this._collisionPairCache=[],this._collisions.clear();for(let t=0,e=r.length;t<e;t++)n=r[t],this._dynamicCollisionTree.query(n,t=>{if(this._shouldGenerateCollisionPair(n,t)){const e=new ui(n,t);this._collisions.add(e.id),this._collisionPairCache.push(e)}return!1});if(i&&(i.physics.pairs=this._collisionPairCache.length),li.checkForFastBodies)for(const t of r){const e=t.owner.get(Bi);if(e.collisionType!==Xe.Active)continue;const r=e.vel.size*s+.5*e.acc.size*s*s,n=Math.min(t.bounds.height,t.bounds.width);if(li.disableMinimumSpeedForFastBody||r>n/2){i&&i.physics.fastBodies++;const s=e.pos.sub(e.oldPos),n=t.center,o=t.getFurthestPoint(e.vel),a=o.sub(s),h=new fi(a,e.vel);let l;h.pos=h.pos.add(h.dir.scale(-2*li.surfaceEpsilon));let c=new X(1/0,1/0);if(this._dynamicCollisionTree.rayCastQuery(h,r+2*li.surfaceEpsilon,e=>{if(t!==e&&ui.canCollide(t,e)){const t=e.rayCast(h,r+10*li.surfaceEpsilon);if(t){const i=t.sub(a);i.size<c.size&&(c=i,l=e)}}return!1}),l&&X.isValid(c)){const s=new ui(t,l);this._collisions.has(s.id)||(this._collisions.add(s.id),this._collisionPairCache.push(s));const r=n.sub(o);e.pos=a.add(r).add(c).add(h.dir.scale(10*li.surfaceEpsilon)),t.update(e.transform),i&&i.physics.fastBodyCollisions++}}}return this._collisionPairCache}narrowphase(t,e){let i=[];for(let s=0;s<t.length;s++){const r=t[s].collide();if(i=i.concat(r),e&&r.length>0)for(const t of r)e.physics.contacts.set(t.id,t)}return e&&(e.physics.collisions+=i.length),i}update(t){let e=0;const i=t.length;for(let s=0;s<i;s++)this._dynamicCollisionTree.updateCollider(t[s])&&e++;return e}debug(t){this._dynamicCollisionTree.debug(t)}}class wi{constructor(){this.id=g("collider",wi._ID++),this.events=new Nt(this)}touching(t){return!!this.collide(t)}}wi._ID=0;class yi extends wi{constructor(t){super(),this._collisionProcessor=new mi,this._dynamicAABBTree=new _i,this._colliders=[];for(const e of t)this.addCollider(e)}clearColliders(){this._colliders=[]}addCollider(t){this.events.wire(t.events),this._colliders.push(t),this._collisionProcessor.track(t),this._dynamicAABBTree.trackCollider(t)}removeCollider(t){this.events.unwire(t.events),B(t,this._colliders),this._collisionProcessor.untrack(t),this._dynamicAABBTree.untrackCollider(t)}getColliders(){return this._colliders}get worldPos(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:X.Zero}get center(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:X.Zero}get bounds(){var t,e;const i=this.getColliders();return i.reduce((t,e)=>t.combine(e.bounds),null!==(e=null===(t=i[0])||void 0===t?void 0:t.bounds)&&void 0!==e?e:(new J).translate(this.worldPos))}get localBounds(){var t,e;const i=this.getColliders();return i.reduce((t,e)=>t.combine(e.localBounds),null!==(e=null===(t=i[0])||void 0===t?void 0:t.localBounds)&&void 0!==e?e:new J)}get axes(){const t=this.getColliders();let e=[];for(const i of t)e=e.concat(i.axes);return e}getFurthestPoint(t){const e=this.getColliders(),i=[];for(const s of e)i.push(s.getFurthestPoint(t));let s=i[0],r=-Number.MAX_VALUE;for(const e of i){const i=e.dot(t);i>r&&(s=e,r=i)}return s}getInertia(t){const e=this.getColliders();let i=0;for(const s of e)i+=s.getInertia(t);return i}collide(t){let e=[t];t instanceof yi&&(e=t.getColliders());const i=[];for(const t of e)this._dynamicAABBTree.query(t,e=>(i.push(new ui(t,e)),!1));let s=[];for(const t of i)s=s.concat(t.collide());return s}getClosestLineBetween(t){const e=this.getColliders(),i=[];if(t instanceof yi){const s=t.getColliders();for(const t of e)for(const e of s){const s=t.getClosestLineBetween(e);s&&i.push(s)}}else for(const s of e){const e=t.getClosestLineBetween(s);e&&i.push(e)}if(i.length){let t=i[0].getLength(),e=i[0];for(const s of i){const i=s.getLength();i<t&&(t=i,e=s)}return e}return null}contains(t){const e=this.getColliders();for(const i of e)if(i.contains(t))return!0;return!1}rayCast(t,e){const i=this.getColliders(),s=[];for(const r of i){const i=r.rayCast(t,e);i&&s.push(i)}if(s.length){let e=s[0],i=e.dot(t.dir);for(const r of s){const s=t.dir.dot(r);s<i&&(e=r,i=s)}return e}return null}project(t){const e=this.getColliders(),i=[];for(const s of e){const e=s.project(t);e&&i.push(e)}if(i.length){const t=new pi(i[0].min,i[0].max);for(const e of i)t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max);return t}return null}update(t){if(t){const e=this.getColliders();for(const i of e)i.owner=this.owner,i.update(t)}}draw(t,e,i){const s=this.getColliders();for(const r of s)r.draw(t,e,i)}debug(t,e){const i=this.getColliders();for(const s of i)s.debug(t,e)}debugDraw(t,e){const i=this.getColliders();for(const s of i)s.draw(t,e)}clone(){return new yi(this._colliders.map(t=>t.clone()))}}class vi{constructor(t,e){this.begin=t,this.end=e}get slope(){return(this.end.y-this.begin.y)/(this.end.x-this.begin.x)}get intercept(){return this.begin.y-this.slope*this.begin.x}normal(){return this.end.sub(this.begin).normal()}dir(){return this.end.sub(this.begin)}getPoints(){return[this.begin,this.end]}getSlope(){const t=this.begin,e=this.end,i=t.distance(e);return e.sub(t).scale(1/i)}getEdge(){const t=this.begin;return this.end.sub(t)}getLength(){const t=this.begin,e=this.end;return t.distance(e)}get midpoint(){return this.begin.add(this.end).scale(.5)}flip(){return new vi(this.end,this.begin)}below(t){return(this.end.x-this.begin.x)*(t.y-this.begin.y)-(this.end.y-this.begin.y)*(t.x-this.begin.x)>=0}clip(t,e){let i=t;i=i.normalize();const s=i.dot(this.begin)-e,r=i.dot(this.end)-e,n=[];if(s<=0&&n.push(this.begin),r<=0&&n.push(this.end),s*r<0){const t=s/(s-r);n.push(this.begin.add(this.end.sub(this.begin).scale(t)))}return 2!==n.length?null:new vi(n[0],n[1])}distanceToPoint(t,e=!1){const i=t.x,s=t.y,r=this.getLength(),n=((this.end.y-this.begin.y)*i-(this.end.x-this.begin.x)*s+this.end.x*this.begin.y-this.end.y*this.begin.x)/r;return e?n:Math.abs(n)}findVectorToPoint(t){const e=this.begin.sub(t),i=this.getSlope();return e.sub(i.scale(e.dot(i)))}findPoint(t=null,e=null){const i=this.slope,s=this.intercept;if(null!==t)return new X(t,i*t+s);if(null!==e)return new X((e-s)/i,e);throw new Error("You must provide an X or a Y value")}hasPoint(){let t,e=0;if("number"==typeof arguments[0]&&"number"==typeof arguments[1])t=new X(arguments[0],arguments[1]),e=arguments[2]||0;else{if(!(arguments[0]instanceof X))throw"Could not determine the arguments for Vector.hasPoint";t=arguments[0],e=arguments[1]||0}const i=t.x-this.begin.x,s=t.y-this.begin.y,r=this.end.x-this.begin.x,n=this.end.y-this.begin.y,o=i*n-s*r;return!(Math.abs(o)>e)&&(Math.abs(r)>=Math.abs(n)?r>0?this.begin.x<=t.x&&t.x<=this.end.x:this.end.x<=t.x&&t.x<=this.begin.x:n>0?this.begin.y<=t.y&&t.y<=this.end.y:this.end.y<=t.y&&t.y<=this.begin.y)}}function xi(t,e,i,s){const r=t.sub(i),n=e.dot(e),o=e.dot(s),a=s.dot(s),h=e.dot(r),l=s.dot(r),c=n*a-o*o;let d=c,u=c;if(0===c||c<=.01){const e=h/o;return new vi(t,i.add(s.scale(e)))}let p=o*l-a*h,g=n*l-o*h;return p<0?(p=0,g=l,u=a):p>d&&(p=d,g=l+o,u=a),g<0?(g=0,-h<0?p=0:-h>n?p=d:(p=-h,d=n)):g>u&&(g=u,-h+o<0?p=0:-h+o>n?p=d:(p=-h+o,d=n)),p=Math.abs(p)<.001?0:p/d,g=Math.abs(g)<.001?0:g/u,new vi(t.add(e.scale(p)),i.add(s.scale(g)))}const bi={PolygonPolygonClosestLine(t,e){const i=e.worldPos,s=i.sub(t.worldPos),r=s.negate(),n=new fi(t.worldPos,s),o=new fi(i,r),a=t.rayCast(n).add(n.dir.scale(.1)),h=e.rayCast(o).add(o.dir.scale(.1)),l=t.getClosestFace(a),c=e.getClosestFace(h);return xi(l.face.begin,l.face.getEdge(),c.face.begin,c.face.getEdge())},PolygonEdgeClosestLine(t,e){const i=e.worldPos.sub(t.worldPos),s=new fi(t.worldPos,i),r=t.rayCast(s).add(s.dir.scale(.1)),n=t.getClosestFace(r),o=n.face.begin,a=n.face.getEdge(),h=e.asLine();return xi(o,a,h.begin,h.getEdge())},PolygonCircleClosestLine(t,e){const i=e.worldPos,s=i.sub(t.worldPos),r=new fi(t.worldPos,s.normalize()),n=t.rayCast(r).add(r.dir.scale(.1)),o=t.getClosestFace(n),a=o.face.begin,h=o.face.getEdge();let l=(h.x*(i.x-a.x)+h.y*(i.y-a.y))/(h.x*h.x+h.y*h.y);l>1?l=1:l<0&&(l=0);const c=Math.sqrt(Math.pow(a.x+h.x*l-i.x,2)+Math.pow(a.y+h.y*l-i.y,2))-e.radius,d=(a.x+h.x*l-i.x)*e.radius/(e.radius+c),u=(a.y+h.y*l-i.y)*e.radius/(e.radius+c);return new vi(h.scale(l).add(a),new X(i.x+d,i.y+u))},CircleCircleClosestLine(t,e){const i=e.worldPos.sub(t.worldPos),s=t.worldPos.sub(e.worldPos),r=new fi(t.worldPos,i),n=new fi(e.worldPos,s),o=t.rayCast(r),a=e.rayCast(n);return new vi(o,a)},CircleEdgeClosestLine(t,e){const i=t.worldPos,s=e.asLine(),r=s.begin,n=s.getEdge();let o=(n.x*(i.x-r.x)+n.y*(i.y-r.y))/(n.x*n.x+n.y*n.y);o>1?o=1:o<0&&(o=0);const a=Math.sqrt(Math.pow(r.x+n.x*o-i.x,2)+Math.pow(r.y+n.y*o-i.y,2))-t.radius,h=(r.x+n.x*o-i.x)*t.radius/(t.radius+a),l=(r.y+n.y*o-i.y)*t.radius/(t.radius+a);return new vi(n.scale(o).add(r),new X(i.x+h,i.y+l))},EdgeEdgeClosestLine(t,e){const i=t.asLine(),s=i.begin,r=i.getEdge(),n=e.asLine();return xi(s,r,n.begin,n.getEdge())}};class Ci extends wi{constructor(t){super(),this.offset=X.Zero,this.offset=t.offset||X.Zero,this.radius=t.radius||0}get worldPos(){var t,e;return this.offset.add(null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:X.Zero)}clone(){return new Ci({offset:this.offset.clone(),radius:this.radius})}get center(){var t,e;return this.offset.add(null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:X.Zero)}contains(t){var e,i;return(null!==(i=null===(e=this._transform)||void 0===e?void 0:e.pos)&&void 0!==i?i:this.offset).distance(t)<=this.radius}rayCast(t,e=1/0){const i=this.center,s=t.dir,r=t.pos,n=Math.sqrt(Math.pow(s.dot(r.sub(i)),2)-Math.pow(r.sub(i).distance(),2)+Math.pow(this.radius,2));if(n<0)return null;{let o=0;if(0===n)return o=-s.dot(r.sub(i)),o>0&&o<e?t.getPoint(o):null;{const o=-s.dot(r.sub(i))+n,a=-s.dot(r.sub(i))-n,h=[];o>=0&&h.push(o),a>=0&&h.push(a);const l=Math.min(...h);return l<=e?t.getPoint(l):null}}}getClosestLineBetween(t){if(t instanceof Ci)return bi.CircleCircleClosestLine(this,t);if(t instanceof Ti)return bi.PolygonCircleClosestLine(t,this).flip();if(t instanceof Ei)return bi.CircleEdgeClosestLine(this,t).flip();throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}collide(t){if(t instanceof Ci)return Pi.CollideCircleCircle(this,t);if(t instanceof Ti)return Pi.CollideCirclePolygon(this,t);if(t instanceof Ei)return Pi.CollideCircleEdge(this,t);throw new Error("Circle could not collide with unknown CollisionShape "+typeof t)}getFurthestPoint(t){return this.center.add(t.normalize().scale(this.radius))}getFurthestLocalPoint(t){return t.normalize().scale(this.radius)}get bounds(){var t;const e=this._transform,i=null!==(t=null==e?void 0:e.globalPos)&&void 0!==t?t:X.Zero;return new J(this.offset.x+i.x-this.radius,this.offset.y+i.y-this.radius,this.offset.x+i.x+this.radius,this.offset.y+i.y+this.radius)}get localBounds(){return new J(this.offset.x-this.radius,this.offset.y-this.radius,this.offset.x+this.radius,this.offset.y+this.radius)}get axes(){return[]}getInertia(t){return t*this.radius*this.radius/2}update(t){this._transform=t}project(t){const e=[],i=this.center.dot(t);return e.push(i),e.push(i+this.radius),e.push(i-this.radius),new pi(Math.min.apply(Math,e),Math.max.apply(Math,e))}draw(t,e=Q.Green,i=X.Zero){const s=i.add(this.offset);t.beginPath(),t.fillStyle=e.toString(),t.arc(s.x,s.y,this.radius,0,2*Math.PI),t.closePath(),t.fill()}debug(t,e){const i=this._transform,s=(null==i?void 0:i.globalPos)?null==i?void 0:i.globalPos.add(this.offset):this.offset;t.drawCircle(s,this.radius,e)}debugDraw(t,e=Q.Green){const i=this._transform,s=i?i.pos.add(this.offset):this.offset,r=i?i.rotation:0;t.beginPath(),t.strokeStyle=e.toString(),t.arc(s.x,s.y,this.radius,0,2*Math.PI),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(Math.cos(r)*this.radius+s.x,Math.sin(r)*this.radius+s.y),t.closePath(),t.stroke()}}class Ai{constructor(t,e,i,s,r,n,o,a){this._canceled=!1,this.colliderA=t,this.colliderB=e,this.mtv=i,this.normal=s,this.tangent=r,this.points=n,this.localPoints=o,this.info=a,this.id=ui.calculatePairHash(t.id,e.id)}matchAwake(){const t=this.colliderA.owner.get(Bi),e=this.colliderB.owner.get(Bi);t&&e&&t.sleeping!==e.sleeping&&(t.sleeping&&t.collisionType!==Xe.Fixed&&e.sleepMotion>=li.wakeThreshold&&t.setSleeping(!1),e.sleeping&&e.collisionType!==Xe.Fixed&&t.sleepMotion>=li.wakeThreshold&&e.setSleeping(!1))}isCanceled(){return this._canceled}cancel(){this._canceled=!0}}class Si{static findPolygonPolygonSeparation(t,e){let i=-Number.MAX_VALUE,s=null,r=null,n=-1,o=null;const a=t.getSides(),h=t.getLocalSides();for(let t=0;t<a.length;t++){const h=a[t],l=h.normal(),c=e.getFurthestPoint(l.negate()),d=h.distanceToPoint(c,!0);d>i&&(i=d,s=h,r=l,n=t,o=c)}return{collider:t,separation:r?i:99,axis:r,side:s,localSide:h[n],sideId:n,point:o,localPoint:r?e.getFurthestLocalPoint(r.negate()):null}}static findCirclePolygonSeparation(t,e){const i=e.axes,s=e.center.sub(t.worldPos),r=e.getFurthestPoint(s.negate());i.push(r.sub(t.worldPos).normalize());let n=Number.MAX_VALUE,o=null,a=-1;for(let s=0;s<i.length;s++){const r=e.project(i[s]),h=t.project(i[s]),l=r.getOverlap(h);if(l<=0)return null;l<n&&(n=l,o=i[s],a=s)}return a<0?null:o.normalize().scale(n)}}const Pi={CollideCircleCircle(t,e){const i=t.worldPos,s=e.worldPos,r=t.radius+e.radius,n=i.distance(s);if(n>r)return[];const o=r-n,a=s.sub(i).normalize(),h=a.perpendicular(),l=a.scale(o),c=t.getFurthestPoint(a),d=t.getFurthestLocalPoint(a);return[new Ai(t,e,l,a,h,[c],[d],{collider:t,separation:o,axis:a,point:c})]},CollideCirclePolygon(t,e){var i,s;let r=Si.findCirclePolygonSeparation(t,e);if(!r)return[];const n=r.dot(e.center.sub(t.center));r=n<0?r.negate():r;const o=t.getFurthestPoint(r),a=(null!==(s=null===(i=t.owner)||void 0===i?void 0:i.get(qe))&&void 0!==s?s:new qe).applyInverse(o),h=r.normalize(),l={collider:t,separation:-r.size,axis:h,point:o,localPoint:a,side:e.findSide(h.negate()),localSide:e.findLocalSide(h.negate())};return[new Ai(t,e,r,h,h.perpendicular(),[o],[a],l)]},CollideCircleEdge(t,e){const i=t.center,s=e.asLine(),r=s.end.sub(s.begin),n=r.dot(s.end.sub(i)),o=r.dot(i.sub(s.begin)),a=e.asLine(),h=e.asLocalLine();if(o<=0){const r=s.begin.sub(i),n=r.dot(r);if(n>t.radius*t.radius)return[];const o=r.normalize(),l=t.radius-Math.sqrt(n),c={collider:t,separation:l,axis:o,point:a.begin,side:a,localSide:h};return[new Ai(t,e,o.scale(l),o,o.perpendicular(),[a.begin],[h.begin],c)]}if(n<=0){const r=s.end.sub(i),n=r.dot(r);if(n>t.radius*t.radius)return[];const o=r.normalize(),l=t.radius-Math.sqrt(n),c={collider:t,separation:l,axis:o,point:a.end,side:a,localSide:h};return[new Ai(t,e,o.scale(l),o,o.perpendicular(),[a.end],[h.end],c)]}const l=r.dot(r),c=s.begin.scale(n).add(s.end.scale(o)).scale(1/l),d=i.sub(c),u=d.dot(d);if(u>t.radius*t.radius)return[];let p=r.perpendicular();p.dot(i.sub(s.begin))<0&&(p.x=-p.x,p.y=-p.y),p=p.normalize();const g=t.radius-Math.sqrt(u),_=p.scale(g),f={collider:t,separation:g,axis:p,point:c,side:a,localSide:h};return[new Ai(t,e,_,p.negate(),p.negate().perpendicular(),[c],[c.sub(e.worldPos)],f)]},CollideEdgeEdge:()=>[],CollidePolygonEdge(t,e){var i;const s=t.center,r=e.center.sub(s).normalize(),n=new Ti({points:[e.begin,e.end,e.end.add(r.scale(100)),e.begin.add(r.scale(100))],offset:e.offset});n.owner=e.owner;(null===(i=e.owner)||void 0===i?void 0:i.get(qe))&&n.update(e.owner.get(qe));const o=this.CollidePolygonPolygon(t,n);return o.length&&(o[0].colliderB=e,o[0].id=ui.calculatePairHash(t.id,e.id)),o},CollidePolygonPolygon(t,e){var i,s,r,n;const o=Si.findPolygonPolygonSeparation(t,e);if(o.separation>0)return[];const a=Si.findPolygonPolygonSeparation(e,t);if(a.separation>0)return[];const h=o.separation>a.separation?o:a,l=(h.collider===t?e:t).findSide(h.axis.negate()),c=h.side,d=c.dir().normalize(),u=l.clip(d.negate(),-d.dot(c.begin));let p=null;if(u&&(p=u.clip(d,d.dot(c.end))),p){const o=p.getPoints().filter(t=>c.below(t));let a=h.axis,l=a.perpendicular();e.worldPos.sub(t.worldPos).dot(a)<0&&(a=a.negate(),l=a.perpendicular());let d=[];if(h.collider===t){const t=null!==(s=null===(i=e.owner)||void 0===i?void 0:i.get(qe))&&void 0!==s?s:new qe;d=o.map(e=>t.applyInverse(e))}else{const e=null!==(n=null===(r=t.owner)||void 0===r?void 0:r.get(qe))&&void 0!==n?n:new qe;d=o.map(t=>e.applyInverse(t))}return[new Ai(t,e,a.scale(-h.separation),a,l,o,d,h)]}return[]},FindContactSeparation(t,e){var i,s,r,n;const o=t.colliderA,a=null!==(s=null===(i=t.colliderA.owner)||void 0===i?void 0:i.get(qe))&&void 0!==s?s:new qe,h=t.colliderB,l=null!==(n=null===(r=t.colliderB.owner)||void 0===r?void 0:r.get(qe))&&void 0!==n?n:new qe;if(o instanceof Ci&&h instanceof Ci){return-(o.radius+h.radius-a.pos.distance(l.pos))}if(o instanceof Ti&&h instanceof Ti&&t.info.localSide){let i,s;return t.info.collider===o?(i=new vi(a.apply(t.info.localSide.begin),a.apply(t.info.localSide.end)),s=l.apply(e)):(i=new vi(l.apply(t.info.localSide.begin),l.apply(t.info.localSide.end)),s=a.apply(e)),i.distanceToPoint(s,!0)}if(o instanceof Ti&&h instanceof Ci||h instanceof Ti&&o instanceof Ci){const i=a.apply(e);if(t.info.side)return t.info.side.distanceToPoint(i,!0)}if(o instanceof Ei&&h instanceof Ti||h instanceof Ei&&o instanceof Ti){let i;if(i=t.info.collider===o?l.apply(e):a.apply(e),t.info.side)return t.info.side.distanceToPoint(i,!0)}if(o instanceof Ci&&h instanceof Ei||h instanceof Ci&&o instanceof Ei){const i=l.apply(e);let s;o instanceof Ci&&(s=o.getFurthestPoint(t.normal));const r=i.distance(s);if(t.info.side)return r>0?-r:0}return 0}};class Ei extends wi{constructor(t){var e;super(),this.begin=t.begin||X.Zero,this.end=t.end||X.Zero,this.offset=null!==(e=t.offset)&&void 0!==e?e:X.Zero}clone(){return new Ei({begin:this.begin.clone(),end:this.end.clone()})}get worldPos(){var t;const e=this._transform;return null!==(t=null==e?void 0:e.globalPos.add(this.offset))&&void 0!==t?t:this.offset}get center(){return this.begin.average(this.end).add(this._getBodyPos())}_getBodyPos(){var t;const e=this._transform;return null!==(t=null==e?void 0:e.globalPos)&&void 0!==t?t:X.Zero}_getTransformedBegin(){const t=this._transform,e=t?t.globalRotation:0;return this.begin.rotate(e).add(this._getBodyPos())}_getTransformedEnd(){const t=this._transform,e=t?t.globalRotation:0;return this.end.rotate(e).add(this._getBodyPos())}getSlope(){const t=this._getTransformedBegin(),e=this._getTransformedEnd(),i=t.distance(e);return e.sub(t).scale(1/i)}getLength(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return t.distance(e)}contains(){return!1}rayCast(t,e=1/0){const i=this._getTransformedBegin().sub(t.pos);if(0===t.dir.cross(this.getSlope())&&0!==i.cross(t.dir))return null;const s=t.dir.cross(this.getSlope());if(0===s)return null;const r=i.cross(this.getSlope())/s;if(r>=0&&r<=e){const e=i.cross(t.dir)/s/this.getLength();if(e>=0&&e<=1)return t.getPoint(r)}return null}getClosestLineBetween(t){if(t instanceof Ci)return bi.CircleEdgeClosestLine(t,this);if(t instanceof Ti)return bi.PolygonEdgeClosestLine(t,this).flip();if(t instanceof Ei)return bi.EdgeEdgeClosestLine(this,t);throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}collide(t){if(t instanceof Ci)return Pi.CollideCircleEdge(t,this);if(t instanceof Ti)return Pi.CollidePolygonEdge(t,this);if(t instanceof Ei)return Pi.CollideEdgeEdge();throw new Error("Edge could not collide with unknown CollisionShape "+typeof t)}getFurthestPoint(t){const e=this._getTransformedBegin(),i=this._getTransformedEnd();return t.dot(e)>0?e:i}_boundsFromBeginEnd(t,e,i=10){return new J(Math.min(t.x,e.x)-i,Math.min(t.y,e.y)-i,Math.max(t.x,e.x)+i,Math.max(t.y,e.y)+i)}get bounds(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return this._boundsFromBeginEnd(t,e)}get localBounds(){return this._boundsFromBeginEnd(this.begin,this.end)}asLine(){return new vi(this._getTransformedBegin(),this._getTransformedEnd())}asLocalLine(){return new vi(this.begin,this.end)}get axes(){const t=this._getTransformedEnd().sub(this._getTransformedBegin()).normal(),e=[];return e.push(t),e.push(t.negate()),e.push(t.normal()),e.push(t.normal().negate()),e}getInertia(t){const e=this.end.sub(this.begin).distance()/2;return t*e*e}update(t){this._transform=t}project(t){const e=[],i=[this._getTransformedBegin(),this._getTransformedEnd()],s=i.length;for(let r=0;r<s;r++)e.push(i[r].dot(t));return new pi(Math.min.apply(Math,e),Math.max.apply(Math,e))}draw(t,e=Q.Green,i=X.Zero){const s=this.begin.add(i),r=this.end.add(i);t.strokeStyle=e.toString(),t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(r.x,r.y),t.closePath(),t.stroke()}debug(t,e){const i=this._getTransformedBegin(),s=this._getTransformedEnd();t.drawLine(i,s,e,2),t.drawCircle(i,2,e),t.drawCircle(s,2,e)}debugDraw(t,e=Q.Red){const i=this._getTransformedBegin(),s=this._getTransformedEnd();t.strokeStyle=e.toString(),t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(s.x,s.y),t.closePath(),t.stroke()}}class Ti extends wi{constructor(t){var e;super(),this._transformedPoints=[],this._axes=[],this._sides=[],this._localSides=[],this.offset=null!==(e=t.offset)&&void 0!==e?e:X.Zero;const i=!!t.clockwiseWinding;this.points=(i?t.points.reverse():t.points)||[],this._calculateTransformation()}clone(){return new Ti({offset:this.offset.clone(),points:this.points.map(t=>t.clone())})}get worldPos(){return this._transform?this._transform.pos.add(this.offset):this.offset}get center(){return this.bounds.center}_calculateTransformation(){const t=this._transform,e=t?t.globalPos.add(this.offset):this.offset,i=t?t.globalRotation:0,s=t?t.globalScale:X.One,r=this.points.length;this._transformedPoints.length=0;for(let t=0;t<r;t++)this._transformedPoints[t]=this.points[t].scale(s).rotate(i).add(e)}getTransformedPoints(){return this._calculateTransformation(),this._transformedPoints}getSides(){if(this._sides.length)return this._sides;const t=[],e=this.getTransformedPoints(),i=e.length;for(let s=0;s<i;s++)t.push(new vi(e[s],e[(s+1)%i]));return this._sides=t,this._sides}getLocalSides(){if(this._localSides.length)return this._localSides;const t=[],e=this.points,i=e.length;for(let s=0;s<i;s++)t.push(new vi(e[s],e[(s+1)%i]));return this._localSides=t,this._localSides}findSide(t){const e=this.getSides();let i=e[0],s=-Number.MAX_VALUE;for(let r=0;r<e.length;r++){const n=e[r],o=n.normal().dot(t);o>s&&(i=n,s=o)}return i}findLocalSide(t){const e=this.getLocalSides();let i=e[0],s=-Number.MAX_VALUE;for(let r=0;r<e.length;r++){const n=e[r],o=n.normal().dot(t);o>s&&(i=n,s=o)}return i}get axes(){if(this._axes.length)return this._axes;const t=this.getSides().map(t=>t.normal());return this._axes=t,this._axes}update(t){this._transform=t,this._sides.length=0,this._localSides.length=0,this._axes.length=0,this._transformedPoints.length=0,this.getTransformedPoints(),this.getSides(),this.getLocalSides()}contains(t){const e=new fi(t,new X(1,0));return this.getSides().reduce((function(t,i){return e.intersect(i)>=0?t+1:t}),0)%2!=0}getClosestLineBetween(t){if(t instanceof Ci)return bi.PolygonCircleClosestLine(this,t);if(t instanceof Ti)return bi.PolygonPolygonClosestLine(this,t);if(t instanceof Ei)return bi.PolygonEdgeClosestLine(this,t);throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}collide(t){if(t instanceof Ci)return Pi.CollideCirclePolygon(t,this);if(t instanceof Ti)return Pi.CollidePolygonPolygon(this,t);if(t instanceof Ei)return Pi.CollidePolygonEdge(this,t);throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}getFurthestPoint(t){const e=this.getTransformedPoints();let i=null,s=-Number.MAX_VALUE;for(let r=0;r<e.length;r++){const n=t.dot(e[r]);n>s&&(s=n,i=e[r])}return i}getFurthestLocalPoint(t){const e=this.points;let i=e[0],s=-Number.MAX_VALUE;for(let r=0;r<e.length;r++){const n=t.dot(e[r]);n>s&&(s=n,i=e[r])}return i}getClosestFace(t){const e=this.getSides();let i=Number.POSITIVE_INFINITY,s=-1,r=-1;for(let n=0;n<e.length;n++){const o=e[n].distanceToPoint(t);o<i&&(i=o,s=n,r=o)}return-1!==s?{distance:e[s].normal().scale(r),face:e[s]}:null}get bounds(){var t,e,i;const s=this._transform,r=null!==(t=null==s?void 0:s.globalScale)&&void 0!==t?t:X.One,n=null!==(e=null==s?void 0:s.globalRotation)&&void 0!==e?e:0,o=(null!==(i=null==s?void 0:s.globalPos)&&void 0!==i?i:X.Zero).add(this.offset);return this.localBounds.scale(r).rotate(n).translate(o)}get localBounds(){return J.fromPoints(this.points)}getInertia(t){let e=0,i=0;for(let t=0;t<this.points.length;t++){const s=(t+1)%this.points.length,r=this.points[s].cross(this.points[t]);e+=r*(this.points[t].dot(this.points[t])+this.points[t].dot(this.points[s])+this.points[s].dot(this.points[s])),i+=r}return t/6*(e/i)}rayCast(t,e=1/0){const i=this.getSides(),s=i.length;let r=Number.MAX_VALUE,n=-1;for(let o=0;o<s;o++){const s=t.intersect(i[o]);s>=0&&s<r&&s<=e&&(r=s,n=o)}return n>=0?t.getPoint(r):null}project(t){const e=this.getTransformedPoints(),i=e.length;let s=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<i;n++){const i=e[n].dot(t);s=Math.min(s,i),r=Math.max(r,i)}return new pi(s,r)}draw(t,e=Q.Green,i=X.Zero){const s=i.add(this.offset);t.beginPath(),t.fillStyle=e.toString();const r=this.points[0].add(s);t.moveTo(r.x,r.y),this.points.map(t=>t.add(s)).forEach((function(e){t.lineTo(e.x,e.y)})),t.lineTo(r.x,r.y),t.closePath(),t.fill()}debug(t,e){const i=this.getTransformedPoints()[0],s=[i,...this.getTransformedPoints(),i];for(let i=0;i<s.length-1;i++)t.drawLine(s[i],s[i+1],e,2),t.drawCircle(s[i],2,e),t.drawCircle(s[i+1],2,e)}debugDraw(t,e=Q.Red){t.beginPath(),t.strokeStyle=e.toString();const i=this.getTransformedPoints()[0];t.moveTo(i.x,i.y),this.getTransformedPoints().forEach((function(e){t.lineTo(e.x,e.y)})),t.lineTo(i.x,i.y),t.closePath(),t.stroke()}}class Ri{static Box(t,e,i=X.Half,s=X.Zero){return new Ti({points:new J(-t*i.x,-e*i.y,t-t*i.x,e-e*i.y).getPoints(),offset:s})}static Polygon(t,e=!1,i=X.Zero){return new Ti({points:t,offset:i,clockwiseWinding:e})}static Circle(t,e=X.Zero){return new Ci({radius:t,offset:e})}static Edge(t,e){return new Ei({begin:t,end:e})}static Capsule(t,e,i=X.Zero){const s=_.getInstance();t===e&&s.warn("A capsule collider with equal width and height is a circle, consider using a ex.Shape.Circle or ex.CircleCollider");if(e>=t){return new yi([Ri.Circle(t/2,q(0,-e/2+t/2).add(i)),Ri.Box(t,e-t,X.Half,i),Ri.Circle(t/2,q(0,e/2-t/2).add(i))])}return new yi([Ri.Circle(e/2,q(-t/2+e/2,0).add(i)),Ri.Box(t-e,e,X.Half,i),Ri.Circle(e/2,q(t/2-e/2,0).add(i))])}}class Di extends Ue{constructor(t){super(),this.type="ex.collider",this.events=new Nt(this),this.$colliderAdded=new di,this.$colliderRemoved=new di,this.set(t)}get(){return this._collider}set(t){return this.clear(),t&&(this._collider=t,this._collider.owner=this.owner,this.events.wire(t.events),this.$colliderAdded.notifyAll(t),this.update()),t}clear(){this._collider&&(this.events.unwire(this._collider.events),this.$colliderRemoved.notifyAll(this._collider),this._collider.owner=null,this._collider=null)}get bounds(){var t,e;return null!==(e=null===(t=this._collider)||void 0===t?void 0:t.bounds)&&void 0!==e?e:new J}get localBounds(){var t,e;return null!==(e=null===(t=this._collider)||void 0===t?void 0:t.localBounds)&&void 0!==e?e:new J}update(){var t;const e=null===(t=this.owner)||void 0===t?void 0:t.get(qe);this._collider&&(this._collider.owner=this.owner,e&&this._collider.update(e))}collide(t){let e=this._collider,i=t._collider;if(!e||!i)return[];let s=!1;if(i instanceof yi&&(e=i,i=this._collider,s=!0),this._collider){const r=e.collide(i);return r?(s&&r.forEach(e=>{e.mtv=e.mtv.negate(),e.normal=e.normal.negate(),e.tangent=e.normal.perpendicular(),e.colliderA=this._collider,e.colliderB=t._collider}),r):[]}return[]}onAdd(t){this._collider&&this.update(),this.events.on("precollision",e=>{const i=e;t.events.emit("precollision",new Pt(i.target.owner,i.other.owner,i.side,i.intersection))}),this.events.on("postcollision",e=>{const i=e;t.events.emit("postcollision",new Et(i.target.owner,i.other.owner,i.side,i.intersection))}),this.events.on("collisionstart",e=>{const i=e;t.events.emit("collisionstart",new Bt(i.target.owner,i.other.owner,i.contact))}),this.events.on("collisionend",e=>{const i=e;t.events.emit("collisionend",new kt(i.target.owner,i.other.owner))})}onRemove(){this.events.clear(),this.$colliderRemoved.notifyAll(this._collider)}useBoxCollider(t,e,i=X.Half,s=X.Zero){const r=Ri.Box(t,e,i,s);return this.set(r)}usePolygonCollider(t,e=X.Zero){const i=Ri.Polygon(t,!1,e);return this.set(i)}useCircleCollider(t,e=X.Zero){const i=Ri.Circle(t,e);return this.set(i)}useEdgeCollider(t,e){const i=Ri.Edge(t,e);return this.set(i)}useCompositeCollider(t){return this.set(new yi(t))}}var Mi;!function(t){t.Rotation="rotation",t.X="x",t.Y="y"}(Mi||(Mi={}));class Bi extends Ue{constructor(t){var e,i,s;super(),this.type="ex.body",this.dependencies=[qe,Ne],this.id=g("body",Bi._ID++),this.events=new Nt(this),this.collisionType=Xe.PreventCollision,this.group=ci.All,this.mass=li.defaultMass,this.sleepMotion=5*li.sleepEpsilon,this.canSleep=li.bodiesCanSleepByDefault,this._sleeping=!1,this.bounciness=.2,this.friction=.99,this.useGravity=!0,this.limitDegreeOfFreedom=[],this.oldPos=new X(0,0),this.oldVel=new X(0,0),this.oldAcc=X.Zero,this.oldRotation=0,this.oldScale=X.One,t&&(this.collisionType=null!==(e=t.type)&&void 0!==e?e:this.collisionType,this.group=null!==(i=t.group)&&void 0!==i?i:this.group,this.useGravity=null!==(s=t.useGravity)&&void 0!==s?s:this.useGravity)}get inverseMass(){return this.collisionType===Xe.Fixed?0:1/this.mass}get sleeping(){return this._sleeping}setSleeping(t){this._sleeping=t,t?(this.vel=X.Zero,this.acc=X.Zero,this.angularVelocity=0,this.sleepMotion=0):this.sleepMotion=5*li.sleepEpsilon}updateMotion(){this._sleeping&&this.setSleeping(!0);const t=this.vel.size*this.vel.size+Math.abs(this.angularVelocity*this.angularVelocity),e=li.sleepBias;this.sleepMotion=e*this.sleepMotion+(1-e)*t,this.sleepMotion=A(this.sleepMotion,0,10*li.sleepEpsilon),this.canSleep&&this.sleepMotion<li.sleepEpsilon&&this.setSleeping(!0)}get inertia(){const t=this.owner.get(Di);return(null==t?void 0:t.get())?t.get().getInertia(this.mass):0}get inverseInertia(){return this.collisionType===Xe.Fixed?0:1/this.inertia}get active(){var t;return!!(null===(t=this.owner)||void 0===t?void 0:t.active)}get center(){return this.pos}get transform(){var t;return null===(t=this.owner)||void 0===t?void 0:t.get(qe)}get motion(){var t;return null===(t=this.owner)||void 0===t?void 0:t.get(Ne)}get pos(){return this.transform.globalPos}set pos(t){this.transform.globalPos=t}get vel(){return this.motion.vel}set vel(t){this.motion.vel=t}get acc(){return this.motion.acc}set acc(t){this.motion.acc=t}get torque(){return this.motion.torque}set torque(t){this.motion.torque=t}get rotation(){return this.transform.globalRotation}set rotation(t){this.transform.globalRotation=t}get scale(){return this.transform.globalScale}set scale(t){this.transform.globalScale=t}get sx(){return this.motion.scaleFactor.x}set sx(t){this.motion.scaleFactor.x=t}get sy(){return this.motion.scaleFactor.y}set sy(t){this.motion.scaleFactor.y=t}get rx(){return this.motion.angularVelocity}set rx(t){this.motion.angularVelocity=t}get angularVelocity(){return this.motion.angularVelocity}set angularVelocity(t){this.motion.angularVelocity=t}applyImpulse(t,e){if(this.collisionType!==Xe.Active)return;const i=e.scale(this.inverseMass);if(this.limitDegreeOfFreedom.includes(Mi.X)&&(i.x=0),this.limitDegreeOfFreedom.includes(Mi.Y)&&(i.y=0),this.vel.addEqual(i),!this.limitDegreeOfFreedom.includes(Mi.Rotation)){const i=t.sub(this.pos);this.angularVelocity+=this.inverseInertia*i.cross(e)}}applyLinearImpulse(t){if(this.collisionType!==Xe.Active)return;const e=t.scale(this.inverseMass);this.limitDegreeOfFreedom.includes(Mi.X)&&(e.x=0),this.limitDegreeOfFreedom.includes(Mi.Y)&&(e.y=0),this.vel=this.vel.add(e)}applyAngularImpulse(t,e){if(this.collisionType===Xe.Active&&!this.limitDegreeOfFreedom.includes(Mi.Rotation)){const i=t.sub(this.pos);this.angularVelocity+=this.inverseInertia*i.cross(e)}}captureOldTransform(){this.oldVel.setTo(this.vel.x,this.vel.y),this.oldPos.setTo(this.pos.x,this.pos.y),this.oldAcc.setTo(this.acc.x,this.acc.y),this.oldScale.setTo(this.scale.x,this.scale.y),this.oldRotation=this.rotation}debugDraw(t){}}Bi._ID=0;class ki{constructor(){this._topLeft=new X(0,0),this._topRight=new X(0,0),this._bottomLeft=new X(0,0),this._bottomRight=new X(0,0)}isSpriteOffScreen(t,e){const i=t.currentDrawing.drawWidth,s=t.currentDrawing.drawHeight,r=t.rotation,n=t.center,o=t.getGlobalPos();this._topLeft=q(o.x-i/2,o.y-s/2),this._topLeft=this._topLeft.rotate(r,n),this._topRight=q(o.x+i/2,o.y-s/2),this._topRight=this._topRight.rotate(r,n),this._bottomLeft=q(o.x-i/2,o.y+s/2),this._bottomLeft=this._bottomLeft.rotate(r,n),this._bottomRight=q(o.x+i/2,o.y+s/2),this._bottomRight=this._bottomRight.rotate(r,n);const a=e.worldToScreenCoordinates(this._topLeft),h=e.worldToScreenCoordinates(this._topRight),l=e.worldToScreenCoordinates(this._bottomLeft),c=e.worldToScreenCoordinates(this._bottomRight);this._xCoords=[],this._yCoords=[],this._xCoords.push(a.x,h.x,l.x,c.x),this._yCoords.push(a.y,h.y,l.y,c.y),this._xMin=Math.min.apply(null,this._xCoords),this._yMin=Math.min.apply(null,this._yCoords),this._xMax=Math.max.apply(null,this._xCoords),this._yMax=Math.max.apply(null,this._yCoords);const d=e.screenToWorldCoordinates(new X(this._xMin,this._yMin)),u=e.screenToWorldCoordinates(new X(this._xMax,this._yMax));this._xMinWorld=d.x,this._yMinWorld=d.y,this._xMaxWorld=u.x,this._yMaxWorld=u.y;const p=[new X(this._xMin,this._yMin),new X(this._xMax,this._yMin),new X(this._xMin,this._yMax),new X(this._xMax,this._yMax)];if(p[0].x<0&&p[1].x>e.canvas.clientWidth&&(p[0].y>0||p[2].y<e.canvas.clientHeight))return!1;if(p[0].y<0&&p[2].y>e.canvas.clientHeight&&(p[1].x>0||p[0].x<e.canvas.clientWidth))return!1;for(let t=0;t<p.length;t++)if(p[t].x>0&&p[t].y>0&&p[t].x<e.canvas.clientWidth&&p[t].y<e.canvas.clientHeight)return!1;return!0}debugDraw(t){t.beginPath(),t.strokeStyle=Q.White.toString(),t.rect(this._xMinWorld,this._yMinWorld,this._xMaxWorld-this._xMinWorld,this._yMaxWorld-this._yMinWorld),t.stroke(),t.fillStyle=Q.Red.toString(),t.beginPath(),t.arc(this._topLeft.x,this._topLeft.y,5,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle=Q.Green.toString(),t.beginPath(),t.arc(this._topRight.x,this._topRight.y,5,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle=Q.Blue.toString(),t.beginPath(),t.arc(this._bottomLeft.x,this._bottomLeft.y,5,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle=Q.Magenta.toString(),t.beginPath(),t.arc(this._bottomRight.x,this._bottomRight.y,5,0,2*Math.PI),t.closePath(),t.fill()}}class Fi{constructor(){this.cullingBox=new ki}update(t,e){const i=t.eventDispatcher;let s=!0;null!=t.currentDrawing&&(s=this.cullingBox.isSpriteOffScreen(t,e));let r=!1;e&&e.currentScene&&e.currentScene.camera&&e.currentScene.camera.viewport&&!t.parent&&(r=!e.currentScene.camera.viewport.intersect(t.collider.bounds)),t.isOffScreen?r&&s||(i.emit("enterviewport",new zt(t)),t.removeComponent("offscreen")):r&&s&&(i.emit("exitviewport",new Ot(t)),t.addComponent(new He("offscreen")))}}class Li{update(t,e){t.enableCapturePointer&&(t.isKilled()||e.input.pointers.checkAndUpdateActorUnderPointer(t))}}class Ii{constructor(t){this.data=t,this.type="Component Added"}}function Oi(t){return!!t&&"Component Added"===t.type}class zi{constructor(t){this.data=t,this.type="Component Removed"}}function Ui(t){return!!t&&"Component Removed"===t.type}class Hi extends Wt{constructor(t,e){if(super(),this.id=Hi._ID++,this._name="anonymous",this.active=!0,this._componentsToRemove=[],this._componentTypeToInstance=new Map,this._componentStringToInstance=new Map,this._tagsMemo=[],this._typesMemo=[],this.componentAdded$=new di,this.componentRemoved$=new di,this._parent=null,this.childrenAdded$=new di,this.childrenRemoved$=new di,this._children=[],this._isInitialized=!1,this._setName(e),t)for(const e of t)this.addComponent(e)}_setName(t){t&&(this._name=t)}get name(){return this._name}get events(){return this.eventDispatcher}kill(){this.active=!1}isKilled(){return!this.active}get tags(){return this._tagsMemo}hasTag(t){return this.tags.includes(t)}addTag(t){return this.addComponent(new He(t))}removeTag(t,e=!1){return this.removeComponent(t,e)}get types(){return this._typesMemo}_rebuildMemos(){this._tagsMemo=Array.from(this._componentStringToInstance.values()).filter(t=>t instanceof He).map(t=>t.type),this._typesMemo=Array.from(this._componentStringToInstance.keys())}getComponents(){return Array.from(this._componentStringToInstance.values())}_notifyAddComponent(t){this._rebuildMemos();const e=new Ii({component:t,entity:this});this.componentAdded$.notifyAll(e)}_notifyRemoveComponent(t){const e=new zi({component:t,entity:this});this.componentRemoved$.notifyAll(e),this._rebuildMemos()}get parent(){return this._parent}get children(){return this._children}unparent(){this._parent&&(this._parent.removeChild(this),this._parent=null)}addChild(t){if(null!==t.parent)throw new Error("Entity already has a parent, cannot add without unparenting");if(this.getAncestors().includes(t))throw new Error("Cycle detected, cannot add entity");return this._children.push(t),t._parent=this,this.childrenAdded$.notifyAll(t),this}removeChild(t){return t.parent===this&&(B(t,this._children),t._parent=null,this.childrenRemoved$.notifyAll(t)),this}removeAllChildren(){return this.children.forEach(t=>{this.removeChild(t)}),this}getAncestors(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;return t.reverse()}getDescendants(){let t=[this],e=[this];for(;e.length>0;){const i=e.pop();e=e.concat(i.children),t=t.concat(i.children)}return t}clone(){const t=new Hi;for(const e of this.types)t.addComponent(this.get(e).clone());for(const e of this.children)t.addChild(e.clone());return t}addTemplate(t,e=!1){for(const i of t.getComponents())this.addComponent(i.clone(),e);for(const e of t.children)this.addChild(e.clone().addTemplate(e));return this}addComponent(t,e=!1){if(this.has(t.type)){if(!e)return this;this.removeComponent(t)}if(t.dependencies&&t.dependencies.length)for(const e of t.dependencies)this.addComponent(new e);t.owner=this;const i=t.constructor;return this._componentTypeToInstance.set(i,t),this._componentStringToInstance.set(t.type,t),t.onAdd&&t.onAdd(this),this._notifyAddComponent(t),this}removeComponent(t,e=!1){return e?"string"==typeof t?this._removeComponentByType(t):t instanceof Ue&&this._removeComponentByType(t.type):this._componentsToRemove.push(t),this}_removeComponentByType(t){if(this.has(t)){const e=this.get(t);e.owner=null,e.onRemove&&e.onRemove(this);const i=e.constructor;this._componentTypeToInstance.delete(i),this._componentStringToInstance.delete(e.type),this._notifyRemoveComponent(e)}}processComponentRemoval(){for(const t of this._componentsToRemove){const e="string"==typeof t?t:t.type;this._removeComponentByType(e)}this._componentsToRemove.length=0}has(t){return"string"==typeof t?this._componentStringToInstance.has(t):this._componentTypeToInstance.has(t)}get(t){return"string"==typeof t?this._componentStringToInstance.get(t):this._componentTypeToInstance.get(t)}get isInitialized(){return this._isInitialized}_initialize(t){this.isInitialized||(this.onInitialize(t),super.emit("initialize",new Ft(t,this)),this._isInitialized=!0)}_preupdate(t,e){this.emit("preupdate",new gt(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new _t(t,e,this)),this.onPostUpdate(t,e)}onInitialize(t){}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this._initialize(t),this._preupdate(t,e);for(const i of this.children)i.update(t,e);this._postupdate(t,e)}}Hi._ID=0;class Ni extends Ue{constructor(t){var e;super(),this.draw=t,this.type="ex.canvas",this.draw=null!==(e=this.draw)&&void 0!==e?e:()=>{}}}function Wi(t){return!!t.tick}class Vi{constructor(t,e){this._options=t,this._graphics=e,this.graphics=[]}get name(){return this._options.name}hide(t){if(t){let e=null;e=t instanceof Zt?t:this._graphics.getGraphic(t),this.graphics=this.graphics.filter(t=>t.graphic!==e)}else this.graphics.length=0}show(t,e){let i;return e=Object.assign({},e),t instanceof Zt?i=this._graphics.copyGraphics?t.clone():t:(i=this._graphics.getGraphic(t),i||_.getInstance().error(`No such graphic added to component named ${t}. These named graphics are available: `,this._graphics.getNames())),i?(this.graphics.push({graphic:i,options:e}),i):null}use(t,e){return e=Object.assign({},e),this.hide(),this.show(t,e)}get order(){return this._options.order}set order(t){this._options.order=t}get offset(){var t;return null!==(t=this._options.offset)&&void 0!==t?t:X.Zero}set offset(t){this._options.offset=t}}class Gi{constructor(t){this._component=t,this._layers=[],this._layerMap={},this.default=new Vi({name:"default",order:0},t),this._maybeAddLayer(this.default)}create(t){const e=new Vi(t,this._component);return this._maybeAddLayer(e)}get(t){return t?this._getLayer(t):this._layers}has(t){return t in this._layerMap}_maybeAddLayer(t){return this._layerMap[t.name]?this._layerMap[t.name]:(this._layerMap[t.name]=t,this._layers.push(t),this._layers.sort((t,e)=>t.order-e.order),t)}_getLayer(t){return this._layerMap[t]}}class ji extends Ue{constructor(t){super(),this.type="ex.graphics",this._graphics={},this.visible=!0,this.opacity=1,this.offset=X.Zero,this.anchor=X.Half,this.copyGraphics=!1,this._bounds=null,t=Object.assign({visible:this.visible},t);const{current:e,anchor:i,opacity:s,visible:r,graphics:n,offset:o,copyGraphics:a,onPreDraw:h,onPostDraw:l}=t;this._graphics=n||{},this.offset=null!=o?o:this.offset,this.opacity=null!=s?s:this.opacity,this.anchor=null!=i?i:this.anchor,this.copyGraphics=null!=a?a:this.copyGraphics,this.onPreDraw=null!=h?h:this.onPreDraw,this.onPostDraw=null!=l?l:this.onPostDraw,this.visible=!!r,this.layers=new Gi(this),e&&this._graphics[e]&&this.show(this._graphics[e])}getGraphic(t){return this._graphics[t]}getNames(){return Object.keys(this._graphics)}get current(){return this.layers.default.graphics}get graphics(){return this._graphics}add(t,e){let i="default",s=null;return"string"==typeof t?(i=t,s=e):s=t,this._graphics[i]=this.copyGraphics?s.clone():s,"default"===i&&this.show("default"),s}show(t,e){return this.layers.default.show(t,e)}use(t,e){return this.layers.default.use(t,e)}hide(t){this.layers.default.hide(t)}set localBounds(t){this._bounds=t}get localBounds(){if(this._bounds)return this._bounds;let t=new J;for(const e of this.layers.get())for(const{graphic:i,options:s}of e.graphics){let r=this.anchor,n=this.offset;(null==s?void 0:s.anchor)&&(r=s.anchor),(null==s?void 0:s.offset)&&(n=s.offset);const o=i.localBounds,a=-o.width*i.scale.x*r.x+n.x,h=-o.height*i.scale.y*r.y+n.y;t=null==i?void 0:i.localBounds.translate(q(a+e.offset.x,h+e.offset.y)).combine(t)}return t}update(t,e=0){for(const i of this.layers.get())for(const{graphic:s}of i.graphics)Wi(s)&&(null==s||s.tick(t,e))}}class Xi extends ee{constructor(t){super(t),this.width=t.width,this.height=t.height,this.rasterize()}clone(){return new Xi(Object.assign(Object.assign({width:this.width,height:this.height},this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){this.color&&t.fillRect(0,0,this.width,this.height),this.strokeColor&&t.strokeRect(0,0,this.width,this.height)}}class qi extends ee{constructor(t){var e;super(t),this._radius=0,this.padding=null!==(e=t.padding)&&void 0!==e?e:2,this.radius=t.radius,this.rasterize()}get radius(){return this._radius}set radius(t){this._radius=t,this.width=2*this._radius,this.height=2*this._radius,this.flagDirty()}clone(){return new qi(Object.assign(Object.assign({radius:this.radius},this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){this.radius>0&&(t.beginPath(),t.arc(this.radius,this.radius,this.radius,0,2*Math.PI),this.color&&t.fill(),this.strokeColor&&t.stroke())}}var Ki=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class Zi extends Hi{constructor(t){super(),this._anchor=$t(X.Half,t=>this._handleAnchorChange(t)),this.logger=_.getInstance(),this.scene=null,this.frames={},this.currentDrawing=null,this._draggable=!1,this._dragging=!1,this._pointerDragStartHandler=()=>{this._dragging=!0},this._pointerDragEndHandler=()=>{this._dragging=!1},this._pointerDragMoveHandler=t=>{this._dragging&&(this.pos=t.pointer.lastWorldPos)},this._pointerDragLeaveHandler=t=>{this._dragging&&(this.pos=t.pointer.lastWorldPos)},this.traits=[],this.enableCapturePointer=!1,this.capturePointer={captureMoveEvents:!1,captureDragEvents:!1},this._capturePointerEvents=["pointerup","pointerdown","pointermove","pointerenter","pointerleave","pointerdragstart","pointerdragend","pointerdragmove","pointerdragenter","pointerdragleave"],this._captureMoveEvents=["pointermove","pointerenter","pointerleave","pointerdragmove","pointerdragenter","pointerdragleave"],this._captureDragEvents=["pointerdragstart","pointerdragend","pointerdragmove","pointerdragenter","pointerdragleave"];const{name:e,x:i,y:s,pos:r,scale:n,width:o,height:a,radius:h,collider:l,vel:d,acc:u,rotation:g,angularVelocity:f,z:m,color:w,visible:y,anchor:v,collisionType:x,collisionGroup:b}=Object.assign({},t);this._setName(e),this.anchor=null!=v?v:Zi.defaults.anchor.clone(),this.addComponent(new qe),this.pos=null!=r?r:q(null!=i?i:0,null!=s?s:0),this.rotation=null!=g?g:0,this.scale=null!=n?n:q(1,1),this.z=null!=m?m:0,this.addComponent(new ji),this.addComponent(new Ni((t,e)=>this.draw(t,e))),this.addComponent(new Ne),this.vel=null!=d?d:X.Zero,this.acc=null!=u?u:X.Zero,this.angularVelocity=null!=f?f:0,this.addComponent(new Bi),this.body.collisionType=null!=x?x:Xe.Passive,b&&(this.body.group=b),l?this.addComponent(new Di(l)):h?this.addComponent(new Di(Ri.Circle(h,this.anchor))):o>0&&a>0?this.addComponent(new Di(Ri.Box(o,a,this.anchor))):this.addComponent(new Di),this.graphics.visible=null==y||y,w&&(this.color=w,o&&a?this.graphics.add(new Xi({color:w,width:o,height:a})):h&&this.graphics.add(new qi({color:w,radius:h}))),p.isEnabled(c.LegacyDrawing)&&this.traits.push(new Fi),this.traits.push(new Li),this.actions=new ri(this)}get body(){return this.get(Bi)}get transform(){return this.get(qe)}get motion(){return this.get(Ne)}get graphics(){return this.get(ji)}get collider(){return this.get(Di)}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t.clone()}get oldPos(){return this.body.oldPos}set oldPos(t){this.body.oldPos.setTo(t.x,t.y)}get vel(){return this.motion.vel}set vel(t){this.motion.vel=t.clone()}get oldVel(){return this.body.oldVel}set oldVel(t){this.body.oldVel.setTo(t.x,t.y)}get acc(){return this.motion.acc}set acc(t){this.motion.acc=t.clone()}set oldAcc(t){this.body.oldAcc.setTo(t.x,t.y)}get oldAcc(){return this.body.oldAcc}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angularVelocity(){return this.motion.angularVelocity}set angularVelocity(t){this.motion.angularVelocity=t}get scale(){return this.get(qe).scale}set scale(t){this.get(qe).scale=t}get anchor(){return this._anchor}set anchor(t){this._anchor=$t(t,t=>this._handleAnchorChange(t)),this._handleAnchorChange(t)}_handleAnchorChange(t){this.graphics&&(this.graphics.anchor=t)}get isOffScreen(){return this.hasTag("offscreen")}get visible(){return this.graphics.visible}set visible(t){this.graphics.visible=t}get opacity(){return this.graphics.opacity}set opacity(t){this.graphics.opacity=t}get draggable(){return this._draggable}set draggable(t){t&&(t&&!this._draggable?(this.on("pointerdragstart",this._pointerDragStartHandler),this.on("pointerdragend",this._pointerDragEndHandler),this.on("pointerdragmove",this._pointerDragMoveHandler),this.on("pointerdragleave",this._pointerDragLeaveHandler)):!t&&this._draggable&&(this.off("pointerdragstart",this._pointerDragStartHandler),this.off("pointerdragend",this._pointerDragEndHandler),this.off("pointerdragmove",this._pointerDragMoveHandler),this.off("pointerdragleave",this._pointerDragLeaveHandler)),this._draggable=t)}get color(){return this._color}set color(t){this._color=t.clone()}onInitialize(t){}_initialize(t){super._initialize(t);for(const e of this.children)e._initialize(t)}_checkForPointerOptIn(t){if(t){const e=t.toLowerCase();-1!==this._capturePointerEvents.indexOf(e)&&(this.enableCapturePointer=!0,-1!==this._captureMoveEvents.indexOf(e)&&(this.capturePointer.captureMoveEvents=!0),-1!==this._captureDragEvents.indexOf(e)&&(this.capturePointer.captureDragEvents=!0))}}on(t,e){this._checkForPointerOptIn(t),super.on(t,e)}once(t,e){this._checkForPointerOptIn(t),super.once(t,e)}off(t,e){super.off(t,e)}_prekill(t){super.emit("prekill",new ot(this)),this.onPreKill(t)}onPreKill(t){}_postkill(t){super.emit("postkill",new at(this)),this.onPostKill(t)}onPostKill(t){}kill(){this.scene?(this._prekill(this.scene),this.emit("kill",new nt(this)),super.kill(),this._postkill(this.scene)):this.logger.warn("Cannot kill actor, it was never added to the Scene")}unkill(){this.active=!0}isKilled(){return!this.active}setDrawing(t){t=t.toString(),this.currentDrawing!==this.frames[t]&&(null!=this.frames[t]?(this.frames[t].reset(),this.currentDrawing=this.frames[t]):_.getInstance().error(`the specified drawing key ${t} does not exist`)),this.currentDrawing&&this.currentDrawing instanceof Ee&&this.currentDrawing.tick(0)}addDrawing(){2===arguments.length?(this.frames[arguments[0]]=arguments[1],this.currentDrawing||(this.currentDrawing=arguments[1])):(arguments[0]instanceof be&&this.addDrawing("default",arguments[0]),arguments[0]instanceof Ae&&this.addDrawing("default",arguments[0].asSprite()))}get z(){return this.get(qe).z}getZIndex(){return this.get(qe).z}set z(t){this.get(qe).z=t}setZIndex(t){this.get(qe).z=t}get center(){return new X(this.pos.x+this.width/2-this.anchor.x*this.width,this.pos.y+this.height/2-this.anchor.y*this.height)}get width(){return this.collider.localBounds.width*this.getGlobalScale().x}get height(){return this.collider.localBounds.height*this.getGlobalScale().y}getGlobalRotation(){return this.get(qe).globalRotation}getGlobalPos(){return this.get(qe).globalPos}getGlobalScale(){return this.get(qe).globalScale}contains(t,e,i=!1){const s=q(t,e),r=this.get(Di);r.update();const n=r.get();if(!n)return!1;const o=n.contains(s);return i?o||this.children.some(i=>i.contains(t,e,!0)):o}within(t,e){const i=this.get(Di),s=t.get(Di),r=i.get(),n=s.get();return!(!r||!n)&&r.getClosestLineBetween(n).getLength()<=e}update(t,e){this._initialize(t),this._preupdate(t,e);const i=this.currentDrawing;i&&i instanceof Ee&&i.tick(e,t.stats.currFrame.id),this.actions.update(e);for(const i of this.traits)i.update(this,t,e);this._postupdate(t,e)}onPreUpdate(t,e){}onPostUpdate(t,e){}_preupdate(t,e){this.emit("preupdate",new gt(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new gt(t,e,this)),this.onPostUpdate(t,e)}draw(t,e){var i;if(t.save(),this.currentDrawing){t.translate(-this.width*this.anchor.x,-this.height*this.anchor.y),this._predraw(t,e);const i=this.currentDrawing,s=(this.width-i.width*i.scale.x)*this.anchor.x,r=(this.height-i.height*i.scale.y)*this.anchor.y;this.currentDrawing.draw({ctx:t,x:s,y:r,opacity:this.graphics.opacity})}else if(this._predraw(t,e),this.color&&this.collider){const e=this.get(Di);e.update(),e&&!e.bounds.hasZeroDimensions()&&(t.globalAlpha=this.graphics.opacity,null===(i=e.get())||void 0===i||i.draw(t,this.color,q(0,0)))}t.restore(),this._postdraw(t,e)}onPreDraw(t,e){}onPostDraw(t,e){}_predraw(t,e){this.emit("predraw",new ct(t,e,this)),this.onPreDraw(t,e)}_postdraw(t,e){this.emit("postdraw",new ct(t,e,this)),this.onPostDraw(t,e)}debugDraw(t){}}Zi.defaults={anchor:X.Half},Ki([G({message:"Actor.visible will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.visible"})],Zi.prototype,"visible",null),Ki([G({message:"Actor.opacity will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.opacity"})],Zi.prototype,"opacity",null),Ki([G({message:"Actor.setDrawing will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.show() or Actor.graphics.use()"})],Zi.prototype,"setDrawing",null),Ki([G({message:"Actor.addDrawing will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.add()"})],Zi.prototype,"addDrawing",null),Ki([G({message:"Actor.getZIndex will be removed in v0.26.0",alternateMethod:"Use Actor.transform.z or Actor.z"})],Zi.prototype,"getZIndex",null),Ki([G({message:"Actor.setZIndex will be removed in v0.26.0",alternateMethod:"Use Actor.transform.z or Actor.z"})],Zi.prototype,"setZIndex",null);class Yi extends Zi{constructor(t){super(Object.assign({},t)),this.get(qe).coordPlane=je.Screen,this.traits=[],this.traits.push(new Li),this.anchor=q(0,0),this.body.collisionType=Xe.PreventCollision,this.collider.useBoxCollider(this.width,this.height,this.anchor),this.enableCapturePointer=!0}_initialize(t){this._engine=t,super._initialize(t)}contains(t,e,i=!0){if(i)return super.contains(t,e);const s=this._engine.worldToScreenCoordinates(new X(t,e));return super.contains(s.x,s.y)}}var Qi=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class $i{constructor(t,e,i,s){if(this._logger=_.getInstance(),this.id=0,this._elapsedTime=0,this._totalTimeAlive=0,this._running=!1,this._numberOfTicks=0,this.interval=10,this.repeats=!1,this.maxNumberOfRepeats=-1,this._complete=!1,this.scene=null,"function"!=typeof t){const r=t;t=r.fcn,e=r.interval,i=r.repeats,s=r.numberOfRepeats}if(s&&s>=0&&(this.maxNumberOfRepeats=s,!i))throw new Error("repeats must be set to true if numberOfRepeats is set");this.id=$i._MAX_ID++,this.interval=e||this.interval,this.repeats=i||this.repeats,this._callbacks=[],t&&this.on(t)}get complete(){return this._complete}on(t){this._callbacks.push(t)}off(t){const e=this._callbacks.indexOf(t);this._callbacks.splice(e,1)}update(t){this._running&&(this._totalTimeAlive+=t,this._elapsedTime+=t,this.maxNumberOfRepeats>-1&&this._numberOfTicks>=this.maxNumberOfRepeats&&(this._complete=!0,this._running=!1,this._elapsedTime=0),!this.complete&&this._elapsedTime>=this.interval&&(this._callbacks.forEach(t=>{t.call(this)}),this._numberOfTicks++,this.repeats||(this._complete=!0,this._running=!1),this._elapsedTime=0))}reset(t,e){if(t&&t>=0&&(this.interval=t),this.maxNumberOfRepeats&&this.maxNumberOfRepeats>=0&&(this.maxNumberOfRepeats=e,!this.repeats))throw new Error("repeats must be set to true if numberOfRepeats is set");this._complete=!1,this._elapsedTime=0,this._numberOfTicks=0}get timesRepeated(){return this._numberOfTicks}getTimeRunning(){return this._totalTimeAlive}get timeToNextAction(){return this.complete?0:this.interval-this._elapsedTime}get timeElapsedTowardNextAction(){return this._elapsedTime}get isRunning(){return this._running}pause(){return this._running=!1,this}unpause(){this._running=!0}resume(){return this._running=!0,this}start(){return this.scene||this._logger.warn("Cannot start a timer not part of a scene, timer wont start until added"),this._running=!0,this.complete&&(this._complete=!1,this._elapsedTime=0,this._numberOfTicks=0),this}stop(){return this._running=!1,this._elapsedTime=0,this._numberOfTicks=0,this}cancel(){this.pause(),this.scene&&this.scene.cancelTimer(this)}}$i._MAX_ID=0,Qi([G({message:"Will be removed in v0.26.0",alternateMethod:"Use Timer.resume()"})],$i.prototype,"unpause",null);var Ji,ts,es,is,ss,rs=function(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(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(o,a)}h((s=s.apply(t,e||[])).next())}))};class ns{constructor(t,e=!1){this.path=t,this._logger=_.getInstance(),this.data=new Image,this._resource=new ae(t,"blob",e),(t.endsWith(".svg")||t.endsWith(".gif"))&&this._logger.warn(`Image type is not fully supported, you may have mixed results ${t}. Fully supported: jpg, bmp, and png`),this.ready=new Promise(t=>{this._loadedResolve=t})}get width(){return this.image.naturalWidth}get height(){return this.image.naturalHeight}isLoaded(){return!!this.data.src}get image(){return this.data}load(){return rs(this,void 0,void 0,(function*(){if(this.isLoaded())return this.data;try{let t;if(this.path.includes("data:image/"))t=this.path;else{const e=yield this._resource.load();t=URL.createObjectURL(e)}const e=new Image;e.src=t,yield e.decode(),this.data=e}catch(t){yield Promise.reject("Error loading texture")}return this._loadedResolve(this.data),this.data}))}toSprite(){return os.from(this)}static fromLegacyTexture(t){const e=new ns(t.path);return t.isLoaded()?e.data=t.data:t.loaded.then(()=>{e.data=t.data}),e}unload(){this.data=new Image}}class os extends Zt{constructor(t){var e,i;super(t),this.image=t.image;const{width:s,height:r}=t;this.sourceView=null!==(e=t.sourceView)&&void 0!==e?e:{x:0,y:0,width:null!=s?s:0,height:null!=r?r:0},this.destSize=null!==(i=t.destSize)&&void 0!==i?i:{width:null!=s?s:0,height:null!=r?r:0},this._updateSpriteDimensions(),this.image.ready.then(()=>{this._updateSpriteDimensions()})}static from(t){return new os({image:t})}_updateSpriteDimensions(){var t,e,i,s,r,n;const{width:o,height:a}=this.image;this.sourceView.width=(null===(t=this.sourceView)||void 0===t?void 0:t.width)||o,this.sourceView.height=(null===(e=this.sourceView)||void 0===e?void 0:e.height)||a,this.destSize.width=(null===(i=this.destSize)||void 0===i?void 0:i.width)||(null===(s=this.sourceView)||void 0===s?void 0:s.width)||o,this.destSize.height=(null===(r=this.destSize)||void 0===r?void 0:r.height)||(null===(n=this.sourceView)||void 0===n?void 0:n.height)||a,this.width=Math.ceil(this.destSize.width),this.height=Math.ceil(this.destSize.height)}_preDraw(t,e,i){this.image.isLoaded()&&this._updateSpriteDimensions(),super._preDraw(t,e,i)}_drawImage(t,e,i){this.image.isLoaded()&&(this._updateSpriteDimensions(),t.drawImage(this.image.image,this.sourceView.x,this.sourceView.y,this.sourceView.width,this.sourceView.height,e,i,this.destSize.width,this.destSize.height))}static fromLegacySprite(t){const e=t.texture,i=ns.fromLegacyTexture(e);return new os({image:i,sourceView:{x:t.x,y:t.y,width:t.width,height:t.height}})}static toLegacySprite(t){const e=t.image,i=new Ae(e.path);return i.data=e.image,new be(i,t.sourceView.x,t.sourceView.y,t.sourceView.width,t.sourceView.height)}clone(){return new os(Object.assign({image:this.image,sourceView:Object.assign({},this.sourceView),destSize:Object.assign({},this.destSize)},this.cloneGraphicOptions()))}}!function(t){t.Em="em",t.Rem="rem",t.Px="px",t.Pt="pt",t.Percent="%"}(Ji||(Ji={})),function(t){t.Left="left",t.Right="right",t.Center="center",t.Start="start",t.End="end"}(ts||(ts={})),function(t){t.Top="top",t.Hanging="hanging",t.Middle="middle",t.Alphabetic="alphabetic",t.Ideographic="ideographic",t.Bottom="bottom"}(es||(es={})),function(t){t.Normal="normal",t.Italic="italic",t.Oblique="oblique"}(is||(is={})),function(t){t.LeftToRight="ltr",t.RightToLeft="rtl"}(ss||(ss={}));var as=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class hs{constructor(t,e,i,s,r,n){this._sprites=[],this._image=null,this._columns=0,this._rows=0,this._spWidth=0,this._spHeight=0,this._spacing=0;let o=!1;if(t instanceof Array?this._sprites=t:(!t||t instanceof Ae?(this._image=t,this._columns=e,this._rows=i,this._spWidth=s,this._spHeight=r,this._spacing=n||0):(this._columns=t.columns,this._rows=t.rows,this._spWidth=t.spWidth,this._spHeight=t.spHeight,this._image=t.image,this._spacing=t.spacing||0),this._sprites=new Array(this._columns*this._rows),o=!0),this.image instanceof Ae){let t=!1,e=!1;if(this.image.isLoaded()){if(t=this.spWidth*this.columns>this.image.image.naturalWidth,e=this.spHeight*this.rows>this.image.image.naturalHeight,t)throw new RangeError(`SpriteSheet specified is wider, ${this.columns} cols x ${this.spWidth} pixels > ${this.image.image.naturalWidth} pixels than image width`);if(e)throw new RangeError(`SpriteSheet specified is taller, ${this.rows} rows x ${this.spHeight} pixels > ${this.image.image.naturalHeight} pixels than image height`)}}if(o){const t=this.getSpacingDimensions();for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this._sprites[i+e*this.columns]=new be(this.image,i*this.spWidth+t.margin*i+t.left,e*this.spHeight+t.margin*e+t.top,this.spWidth,this.spHeight)}}get spacing(){return this._spacing}get sprites(){return[...this._sprites]}get image(){return this._image}get columns(){return this._columns}get rows(){return this._rows}get spWidth(){return this._spWidth}get spHeight(){return this._spHeight}getSpacingDimensions(){var t,e,i;return"number"==typeof this.spacing?{left:this.spacing,top:this.spacing,margin:this.spacing}:{left:null!==(t=this.spacing.left)&&void 0!==t?t:0,top:null!==(e=this.spacing.top)&&void 0!==e?e:0,margin:null!==(i=this.spacing.margin)&&void 0!==i?i:0}}getAnimationByIndices(t,e,i){let s=e.map(t=>this.sprites[t]);return s=s.map((function(t){return t.clone()})),new Ee(t,s,i)}getAnimationBetween(t,e,i,s){let r=this.sprites.slice(e,i);return r=r.map((function(t){return t.clone()})),new Ee(t,r,s)}getAnimationForAll(t,e){const i=this.sprites.map((function(t){return t.clone()}));return new Ee(t,i,e)}getSprite(t){if(t>=0&&t<this.sprites.length)return this.sprites[t];throw new Error("Invalid index: "+t)}getAnimationByCoords(t,e,i){let s=0,r=0;const n=new Array(e.length);for(let t=0;t<e.length;t++){const i=e[t];i.image=i.image||this.image,s=Math.max(s,i.drawWidth),r=Math.max(r,i.drawHeight),n[t]=new be(i)}const o=new Ee(t,n,i);return o.drawWidth=s,o.drawHeight=r,o}}let ls=class extends hs{constructor(t,e,i,s,r,n,o,a){super(t instanceof Ae?{image:t,spWidth:n,spHeight:o,rows:r,columns:s,spacing:a||0}:t),this._currentColor=Q.Black,this._currentOpacity=1,this._spriteRecord={},this._textShadowOn=!1,this._textShadowDirty=!0,this._textShadowColor=Q.Black,this._textShadowSprites={},this._shadowOffsetX=5,this._shadowOffsetY=5,!t||t instanceof Ae||(e=t.alphabet,i=t.caseInsensitive),this.alphabet=e,this.caseInsensitive=i,this._spriteRecord=this.getTextSprites()}getTextSprites(){const t={};for(let e=0;e<this.alphabet.length;e++){let i=this.alphabet[e];this.caseInsensitive&&(i=i.toLowerCase()),t[i]=this.sprites[e].clone()}return t}setTextShadow(t,e,i){this._textShadowOn=!0,this._shadowOffsetX=t,this._shadowOffsetY=e,this._textShadowColor=i.clone(),this._textShadowDirty=!0;for(const t in this._spriteRecord)this._textShadowSprites[t]=this._spriteRecord[t].clone()}useTextShadow(t){this._textShadowOn=t,t&&this.setTextShadow(5,5,this._textShadowColor)}draw(t,e,i,s,r){if(r=this._parseOptions(r),this._currentColor.toString()!==r.color.toString()||this._currentOpacity!==r.opacity){this._currentOpacity=r.opacity,this._currentColor=r.color;for(const t in this._spriteRecord)this._spriteRecord[t].clearEffects(),this._spriteRecord[t].fill(r.color),this._spriteRecord[t].opacity(r.opacity)}if(this._textShadowOn&&this._textShadowDirty&&this._textShadowColor){for(const t in this._textShadowSprites)this._textShadowSprites[t].clearEffects(),this._textShadowSprites[t].addEffect(new me(this._textShadowColor.clone()));this._textShadowDirty=!1}const n=this.sprites[0],o=n.height,a=r.fontSize/o,h=e.length*n.width*a+e.length*r.letterSpacing;let l=i;r.textAlign===ts.Left||r.textAlign===ts.Start?l=i:r.textAlign===ts.Right||r.textAlign===ts.End?l=i-h:r.textAlign===ts.Center&&(l=i-h/2);let c=s-o*a;r.baseAlign===es.Top||r.baseAlign===es.Hanging?c=s:r.baseAlign===es.Ideographic||r.baseAlign===es.Bottom||r.baseAlign===es.Alphabetic?c=s-o*a:r.baseAlign===es.Middle&&(c=s-o*a/2);for(let i=0;i<e.length;i++){let s=e[i];this.caseInsensitive&&(s=s.toLowerCase());try{this._textShadowOn&&(this._textShadowSprites[s].drawAroundAnchor=!1,this._textShadowSprites[s].scale=q(a,a),this._textShadowSprites[s].draw(t,l+this._shadowOffsetX,c+this._shadowOffsetY));const e=this._spriteRecord[s];e.drawAroundAnchor=!1,e.scale=q(a,a),e.draw(t,l,c),l+=e.drawWidth+r.letterSpacing}catch(t){_.getInstance().error("SpriteFont Error drawing char "+s)}}}_parseOptions(t){return{fontSize:t.fontSize||10,letterSpacing:t.letterSpacing||0,color:t.color||Q.Black,textAlign:void 0===typeof t.textAlign?ts.Left:t.textAlign,baseAlign:void 0===typeof t.baseAlign?es.Bottom:t.baseAlign,maxWidth:t.maxWidth||-1,opacity:t.opacity||0}}};ls=as([G({message:"SpriteSheet will be removed in v0.26.0",alternateMethod:"Use Graphics.SpriteSheet"})],ls);class cs{constructor(t){this._logger=_.getInstance(),this.sprites=[];const{sprites:e,rows:i,columns:s}=t;this.sprites=e,this.rows=null!=i?i:1,this.columns=null!=s?s:this.sprites.length}getSprite(t,e){if(t>=this.columns||t<0)return this._logger.warn(`No sprite exists in the SpriteSheet at (${t}, ${e}), x: ${t} should be between 0 and ${this.columns-1}`),null;if(e>=this.rows||e<0)return this._logger.warn(`No sprite exists in the SpriteSheet at (${t}, ${e}), y: ${e} should be between 0 and ${this.rows-1}`),null;const i=t+e*this.columns;return this.sprites[i]}static fromLegacySpriteSheet(t){const e=t.sprites.map(t=>os.fromLegacySprite(t));return new cs({sprites:e})}static toLegacySpriteSheet(t){const e=t.sprites.map(t=>os.toLegacySprite(t));return new hs(e)}static fromImageSource(t){var e;const i=[];t.spacing=null!==(e=t.spacing)&&void 0!==e?e:{};const{image:s,grid:{rows:r,columns:n,spriteWidth:o,spriteHeight:a},spacing:{originOffset:h,margin:l}}=t,c=Object.assign({x:0,y:0},h),d=Object.assign({x:0,y:0},l);for(let t=0;t<n;t++)for(let e=0;e<r;e++)i[t+e*n]=new os({image:s,sourceView:{x:t*o+d.x*t+c.x,y:e*a+d.y*e+c.y,width:o,height:a},destSize:{height:a,width:o}});return new cs({sprites:i,rows:r,columns:n})}}var ds,us=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class ps extends Hi{constructor(t,e,i,s,r,n){if(super(),this._token=0,this._onScreenXStart=0,this._onScreenXEnd=9999,this._onScreenYStart=0,this._onScreenYEnd=9999,this._spriteSheets={},this._legacySpriteMap=new Map,this.logger=_.getInstance(),this.data=[],this._rows=[],this._cols=[],this.visible=!0,this.isOffscreen=!1,this._dirty=!0,t&&"object"==typeof t){const o=t;t=o.x,e=o.y,i=o.cellWidth,s=o.cellHeight,r=o.rows,n=o.cols}this.addComponent(new qe),this.addComponent(new Ne),this.addComponent(new Bi({type:Xe.Fixed})),this.addComponent(new Ni((t,e)=>this.draw(t,e))),this.addComponent(new ji({onPostDraw:(t,e)=>this.draw(t,e)})),this.addComponent(new Di),this._transform=this.get(qe),this._motion=this.get(Ne),this._collider=this.get(Di),this._composite=this._collider.useCompositeCollider([]),this.x=t,this.y=e,this.cellWidth=i,this.cellHeight=s,this.rows=r,this.cols=n,this.data=new Array(r*n),this._rows=new Array(r),this._cols=new Array(n);let o=[];for(let a=0;a<n;a++){for(let h=0;h<r;h++){const r=new fs(a*i+t,h*s+e,i,s,a+h*n);r.map=this,this.data[a+h*n]=r,o.push(r),this._rows[h]||(this._rows[h]=[]),this._rows[h].push(r)}this._cols[a]=o,o=[]}this.get(ji).localBounds=new J({left:0,top:0,right:this.cols*this.cellWidth,bottom:this.rows*this.cellHeight})}flagDirty(){this._dirty=!0}get x(){var t;return null!==(t=this._transform.pos.x)&&void 0!==t?t:0}set x(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.pos)&&(this.get(qe).pos=q(t,this.y))}get y(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos.y)&&void 0!==e?e:0}set y(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.pos)&&(this._transform.pos=q(this.x,t))}get z(){var t;return null!==(t=this._transform.z)&&void 0!==t?t:0}set z(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.z)&&(this._transform.z=t)}get rotation(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.rotation)&&void 0!==e?e:0}set rotation(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.rotation)&&(this._transform.rotation=t)}get scale(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.scale)&&void 0!==e?e:X.One}set scale(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.scale)&&(this._transform.scale=t)}get pos(){return this._transform.pos}set pos(t){this._transform.pos=t}get vel(){return this._motion.vel}set vel(t){this._motion.vel=t}on(t,e){super.on(t,e)}_initialize(t){super._initialize(t)}registerSpriteSheet(t,e){this._spriteSheets[t]=e instanceof cs?e:cs.fromLegacySpriteSheet(e)}_updateColliders(){this._composite.clearColliders();const t=[];let e;for(let i=0;i<this.cols;i++){for(let s=0;s<this.rows;s++){0===s&&(e=null);const r=this.data[i+s*this.cols];r.solid?e=e?e.combine(r.bounds):r.bounds:(e&&t.push(e),e=null)}if(e){const i=t[t.length-1];i&&i.top===e.top&&i.bottom===e.bottom?t[t.length-1]=i.combine(e):t.push(e)}}this._composite=this._collider.useCompositeCollider([]);for(const e of t){const t=Ri.Box(e.width,e.height,X.Zero,q(e.left-this.pos.x,e.top-this.pos.y));t.owner=this,this._composite.addCollider(t)}this._collider.update()}getCellByIndex(t){return this.data[t]}getCell(t,e){return t<0||e<0||t>=this.cols||e>=this.rows?null:this.data[t+e*this.cols]}getCellByPoint(t,e){t=Math.floor((t-this.pos.x)/this.cellWidth),e=Math.floor((e-this.pos.y)/this.cellHeight);const i=this.getCell(t,e);return t>=0&&e>=0&&t<this.cols&&e<this.rows&&i?i:null}getRows(){return this._rows}getColumns(){return this._cols}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this.onPreUpdate(t,e),this.emit("preupdate",new gt(t,e,this)),this._dirty&&(this._dirty=!1,this._updateColliders()),this._token++;const i=t.getWorldBounds(),s=q(i.left,i.top),r=q(i.right,i.bottom);this._onScreenXStart=Math.max(Math.floor((s.x-this.x)/this.cellWidth)-2,0),this._onScreenYStart=Math.max(Math.floor((s.y-this.y)/this.cellHeight)-2,0),this._onScreenXEnd=Math.max(Math.floor((r.x-this.x)/this.cellWidth)+2,0),this._onScreenYEnd=Math.max(Math.floor((r.y-this.y)/this.cellHeight)+2,0),this._transform.pos=q(this.x,this.y),this.onPostUpdate(t,e),this.emit("postupdate",new _t(t,e,this))}draw(t,e){this.emit("predraw",new ct(t,e,this));let i=this._onScreenXStart;const s=Math.min(this._onScreenXEnd,this.cols);let r=this._onScreenYStart;const n=Math.min(this._onScreenYEnd,this.rows);let o,a,h;for(;i<s;i++){for(;r<n;r++)for(o=this.getCell(i,r).graphics,a=0,h=o.length;a<h;a++){const s=o[a];s&&(t instanceof CanvasRenderingContext2D?s instanceof os&&(this._legacySpriteMap.has(s)||this._legacySpriteMap.set(s,os.toLegacySprite(s)),this._legacySpriteMap.get(s).draw(t,i*this.cellWidth,r*this.cellHeight)):(Wi(s)&&(null==s||s.tick(e,this._token)),s.draw(t,i*this.cellWidth,r*this.cellHeight)))}r=this._onScreenYStart}this.emit("postdraw",new dt(t,e,this))}}us([G({message:"No longer used, will be removed in v0.26.0"})],ps.prototype,"registerSpriteSheet",null);class gs extends(we(ps)){constructor(t,e,i,s,r,n){super(t,e,i,s,r,n)}}class _s extends Hi{constructor(t,e,i,s,r,n=!1,o=[]){if(super(),this._solid=!1,this.graphics=[],this.data=new Map,t&&"object"==typeof t){const a=t;t=a.x,e=a.y,i=a.width,s=a.height,r=a.index,n=a.solid,o=a.sprites}this.x=t,this.y=e,this.width=i,this.height=s,this.index=r,this.solid=n,this.graphics=o,this._bounds=new J(this.x,this.y,this.x+this.width,this.y+this.height)}get solid(){return this._solid}set solid(t){var e;null===(e=this.map)||void 0===e||e.flagDirty(),this._solid=t}get bounds(){return this._bounds}get center(){return new X(this.x+this.width/2,this.y+this.height/2)}pushSprite(t){this.addGraphic(t)}addGraphic(t){t instanceof be?this.graphics.push(os.fromLegacySprite(t)):this.graphics.push(t)}removeGraphic(t){B(t,this.graphics)}clearGraphics(){this.graphics.length=0}}us([G({message:"Will be removed in v0.26.0",alternateMethod:"addSprite"})],_s.prototype,"pushSprite",null);class fs extends(we(_s)){constructor(t,e,i,s,r,n,o){super(t,e,i,s,r,n,o)}}class ms{constructor(t){this.camera=t}lockToActor(t){this.camera.addStrategy(new ws(t))}lockToActorAxis(t,e){this.camera.addStrategy(new ys(t,e))}elasticToActor(t,e,i){this.camera.addStrategy(new vs(t,e,i))}radiusAroundActor(t,e){this.camera.addStrategy(new xs(t,e))}limitCameraBounds(t){this.camera.addStrategy(new bs(t))}}!function(t){t[t.X=0]="X",t[t.Y=1]="Y"}(ds||(ds={}));class ws{constructor(t){this.target=t,this.action=(t,e,i,s)=>t.center}}class ys{constructor(t,e){this.target=t,this.axis=e,this.action=(t,e,i,s)=>{const r=t.center,n=e.getFocus();return this.axis===ds.X?new X(r.x,n.y):new X(n.x,r.y)}}}class vs{constructor(t,e,i){this.target=t,this.cameraElasticity=e,this.cameraFriction=i,this.action=(t,e,i,s)=>{const r=t.center;let n=e.getFocus(),o=e.vel.clone();const a=r.sub(n).scale(this.cameraElasticity);o=o.add(a);const h=o.scale(-1).scale(this.cameraFriction);return o=o.add(h),n=n.add(o),n}}}class xs{constructor(t,e){this.target=t,this.radius=e,this.action=(t,e,i,s)=>{const r=t.center,n=e.getFocus(),o=r.sub(n),a=o.size;if(a>=this.radius){const t=a-this.radius;return n.add(o.normalize().scale(t))}return n}}}class bs{constructor(t){this.target=t,this.boundSizeChecked=!1,this.action=(t,e,i,s)=>{const r=e.getFocus();this.boundSizeChecked||((t.bottom-t.top<i.drawHeight||t.right-t.left<i.drawWidth)&&_.getInstance().warn("Camera bounds should not be smaller than the engine viewport"),this.boundSizeChecked=!0);let n=r.x,o=r.y;return r.x<t.left+i.halfDrawWidth?n=t.left+i.halfDrawWidth:r.x>t.right-i.halfDrawWidth&&(n=t.right-i.halfDrawWidth),r.y<t.top+i.halfDrawHeight?o=t.top+i.halfDrawHeight:r.y>t.bottom-i.halfDrawHeight&&(o=t.bottom-i.halfDrawHeight),q(n,o)}}}class Cs extends Wt{constructor(){super(...arguments),this._cameraStrategies=[],this.strategy=new ms(this),this._z=1,this.dz=0,this.az=0,this.rotation=0,this.rx=0,this._posChanged=!1,this._pos=Jt(X.Zero,()=>this._posChanged=!0),this.vel=X.Zero,this.acc=X.Zero,this._cameraMoving=!1,this._currentLerpTime=0,this._lerpDuration=1e3,this._lerpStart=null,this._lerpEnd=null,this._isShaking=!1,this._shakeMagnitudeX=0,this._shakeMagnitudeY=0,this._shakeDuration=0,this._elapsedShakeTime=0,this._xShake=0,this._yShake=0,this._isZooming=!1,this._zoomStart=1,this._zoomEnd=1,this._currentZoomTime=0,this._zoomDuration=0,this._zoomEasing=Me.EaseInOutCubic,this._easing=Me.EaseInOutCubic,this._halfWidth=0,this._halfHeight=0,this._viewport=null,this._isInitialized=!1}get zoom(){return this._z}set zoom(t){this._z=t,this._engine&&(this._halfWidth=this._engine.halfDrawWidth,this._halfHeight=this._engine.halfDrawHeight)}get angularVelocity(){return this.rx}set angularVelocity(t){this.rx=t}get pos(){return this._pos}set pos(t){this._pos=Jt(t,()=>this._posChanged=!0),this._posChanged=!0}get x(){return this.pos.x}set x(t){this._follow||this._cameraMoving||(this.pos=q(t,this.pos.y))}get y(){return this.pos.y}set y(t){this._follow||this._cameraMoving||(this.pos=q(this.pos.x,t))}get dx(){return this.vel.x}set dx(t){this.vel=q(t,this.vel.y)}get dy(){return this.vel.y}set dy(t){this.vel=q(this.vel.x,t)}get ax(){return this.acc.x}set ax(t){this.acc=q(t,this.acc.y)}get ay(){return this.acc.y}set ay(t){this.acc=q(this.acc.x,t)}getFocus(){return this.pos}move(t,e,i=Me.EaseInOutCubic){if("function"!=typeof i)throw"Please specify an EasingFunction";return this._follow?Promise.reject(t):(this._lerpPromise&&this._lerpResolve&&this._lerpResolve(t),this._lerpPromise=new Promise(t=>{this._lerpResolve=t}),this._lerpStart=this.getFocus().clone(),this._lerpDuration=e,this._lerpEnd=t,this._currentLerpTime=0,this._cameraMoving=!0,this._easing=i,this._lerpPromise)}shake(t,e,i){this._isShaking=!0,this._shakeMagnitudeX=t,this._shakeMagnitudeY=e,this._shakeDuration=i}zoomOverTime(t,e=0,i=Me.EaseInOutCubic){return this._zoomPromise=new Promise(t=>{this._zoomResolve=t}),e?(this._isZooming=!0,this._zoomEasing=i,this._currentZoomTime=0,this._zoomDuration=e,this._zoomStart=this.zoom,this._zoomEnd=t,this._zoomPromise):(this._isZooming=!1,this.zoom=t,Promise.resolve(!0))}get viewport(){return this._viewport?this._viewport:new J(0,0,0,0)}addStrategy(t){this._cameraStrategies.push(t)}removeStrategy(t){B(t,this._cameraStrategies)}clearAllStrategies(){this._cameraStrategies.length=0}_preupdate(t,e){this.emit("preupdate",new gt(t,e,this)),this.onPreUpdate(t,e)}onPreUpdate(t,e){}_postupdate(t,e){this.emit("postupdate",new _t(t,e,this)),this.onPostUpdate(t,e)}onPostUpdate(t,e){}get isInitialized(){return this._isInitialized}_initialize(t){this.isInitialized||(this._engine=t,this._halfWidth=t.halfDrawWidth,this._halfHeight=t.halfDrawHeight,this._posChanged||(this.pos.x=t.halfDrawWidth,this.pos.y=t.halfDrawHeight),this.onInitialize(t),super.emit("initialize",new Ft(t,this)),this._isInitialized=!0)}onInitialize(t){}on(t,e){super.on(t,e)}off(t,e){super.off(t,e)}once(t,e){super.once(t,e)}update(t,e){if(this._initialize(t),this._preupdate(t,e),this.pos=this.pos.add(this.vel.scale(e/1e3)),this.zoom+=this.dz*e/1e3,this.vel=this.vel.add(this.acc.scale(e/1e3)),this.dz+=this.az*e/1e3,this.rotation+=this.angularVelocity*e/1e3,this._isZooming)if(this._currentZoomTime<this._zoomDuration){const t=(0,this._zoomEasing)(this._currentZoomTime,this._zoomStart,this._zoomEnd,this._zoomDuration);this.zoom=t,this._currentZoomTime+=e}else this._isZooming=!1,this.zoom=this._zoomEnd,this._currentZoomTime=0,this._zoomResolve(!0);if(this._cameraMoving)if(this._currentLerpTime<this._lerpDuration){const t=Me.CreateVectorEasingFunction(this._easing)(this._currentLerpTime,this._lerpStart,this._lerpEnd,this._lerpDuration);this.pos=t,this._currentLerpTime+=e}else{this.pos=this._lerpEnd;const t=this._lerpEnd.clone();this._lerpStart=null,this._lerpEnd=null,this._currentLerpTime=0,this._cameraMoving=!1,this._lerpResolve(t)}this._isDoneShaking()?(this._isShaking=!1,this._elapsedShakeTime=0,this._shakeMagnitudeX=0,this._shakeMagnitudeY=0,this._shakeDuration=0,this._xShake=0,this._yShake=0):(this._elapsedShakeTime+=e,this._xShake=1+(Math.random()*this._shakeMagnitudeX|0),this._yShake=1+(Math.random()*this._shakeMagnitudeY|0));for(const i of this._cameraStrategies)this.pos=i.action.call(i,i.target,this,t,e);this._viewport=new J(this.x-this._halfWidth,this.y-this._halfHeight,this.x+this._halfWidth,this.y+this._halfHeight),this._postupdate(t,e)}draw(t){let e=0,i=0;t instanceof CanvasRenderingContext2D?(e=t.canvas.width,i=t.canvas.height):(e=t.width,i=t.height);const s=this.getFocus(),r=this._engine?this._engine.pixelRatio:1,n=this.zoom,o=e/n/r,a=i/n/r;t.scale(n,n),t.translate(-s.x+o/2+this._xShake,-s.y+a/2+this._yShake)}debugDraw(t){}_isDoneShaking(){return!this._isShaking||this._elapsedShakeTime>=this._shakeDuration}}function As(t){return t instanceof Yi}const Ss={pos:X.Zero,width:10,height:10,visible:!1,action:()=>{},filter:()=>!0,repeat:-1};class Ps extends Zi{constructor(t){super({x:t.pos.x,y:t.pos.y,width:t.width,height:t.height}),this.action=()=>{},this.filter=()=>!0,this.repeat=-1,t=x({},Ss,t),this.filter=t.filter||this.filter,this.repeat=t.repeat||this.repeat,this.action=t.action||this.action,t.target&&(this.target=t.target),this.graphics.visible=t.visible,this.body.collisionType=Xe.Passive,this.eventDispatcher=new Nt(this),this.events.on("collisionstart",t=>{this.filter(t.other)&&(this.emit("enter",new Ut(this,t.other)),this._dispatchAction(),0===this.repeat&&this.kill())}),this.events.on("collisionend",t=>{this.filter(t.other)&&this.emit("exit",new Ht(this,t.other))})}set target(t){this._target=t,this.filter=e=>e===t}get target(){return this._target}_initialize(t){super._initialize(t)}_dispatchAction(){0!==this.repeat&&(this.action.call(this),this.repeat--)}debugDraw(t){super.debugDraw(t),t.save(),t.translate(this.pos.x,this.pos.y);const e=this.collider.bounds,i=this.getGlobalPos();e.left=e.left-i.x,e.right=e.right-i.x,e.top=e.top-i.y,e.bottom=e.bottom-i.y,t.fillStyle=Q.Violet.toString(),t.strokeStyle=Q.Violet.toString(),t.fillText("Trigger",10,10),e.debugDraw(t),t.restore()}}var Es;!function(t){t.Update="update",t.Draw="draw"}(Es||(Es={}));class Ts{constructor(){this.priority=0}notify(t){}}class Rs{constructor(t){this.data=t,this.type="Entity Added"}}function Ds(t){return!!t&&"Entity Added"===t.type}class Ms{constructor(t){this.data=t,this.type="Entity Removed"}}function Bs(t){return!!t&&"Entity Removed"===t.type}class ks{constructor(t){this._world=t,this.entities=[],this._entityIndex={},this._entitiesToRemove=[]}updateEntities(t,e){for(const i of this.entities)i.update(t.engine,e),i.active||this.removeEntity(i)}notify(t){Oi(t)&&this._world.queryManager.addEntity(t.data.entity),Ui(t)&&this._world.queryManager.removeComponent(t.data.entity,t.data.component)}addEntity(t){t.active=!0,t&&!this._entityIndex[t.id]&&(this._entityIndex[t.id]=t,this.entities.push(t),this._world.queryManager.addEntity(t),t.componentAdded$.register(this),t.componentRemoved$.register(this),t.children.forEach(t=>this.addEntity(t)),t.childrenAdded$.register({notify:t=>{this.addEntity(t)}}),t.childrenRemoved$.register({notify:t=>{this.removeEntity(t,!1)}}))}removeEntity(t,e=!0){var i;let s=0;s=t instanceof Hi?t.id:t;const r=this._entityIndex[s];r&&r.active&&r.kill(),r&&e?this._entitiesToRemove.push(r):(delete this._entityIndex[s],r&&(B(r,this.entities),this._world.queryManager.removeEntity(r),r.componentAdded$.unregister(this),r.componentRemoved$.unregister(this),r.children.forEach(t=>this.removeEntity(t,e)),r.childrenAdded$.clear(),r.childrenRemoved$.clear(),(null===(i=this._world.context)||void 0===i?void 0:i.engine)&&this._world.context.engine.stats.currFrame.actors.killed++))}processEntityRemovals(){for(const t of this._entitiesToRemove)t.active||this.removeEntity(t,!1)}processComponentRemovals(){for(const t of this.entities)t.processComponentRemoval()}getById(t){return this._entityIndex[t]}getByName(t){return this.entities.filter(e=>e.name===t)}clear(){for(const t of this.entities)this.removeEntity(t)}}const Fs=t=>[...t].sort((t,e)=>t.localeCompare(e)).join("+");class Ls extends di{constructor(t){super(),this._entities=[],t[0]instanceof Function?this.types=t.map(t=>(new t).type):this.types=t}get key(){return this._key?this._key:this._key=Fs(this.types)}getEntities(t){return t&&this._entities.sort(t),this._entities}addEntity(t){!k(this._entities,t)&&this.matches(t)&&(this._entities.push(t),this.notifyAll(new Rs(t)))}removeEntity(t){B(t,this._entities)&&this.notifyAll(new Ms(t))}clear(){this._entities.length=0;for(const t of this.observers)this.unregister(t)}matches(t){let e=[];e=t instanceof Hi?t.types:t;let i=!0;for(const t of this.types)if(i=i&&e.indexOf(t)>-1,!i)return!1;return i}contain(t){return this.types.indexOf(t)>-1}}class Is{constructor(t){this._world=t,this._queries={}}_addQuery(t){this._queries[Fs(t.types)]=t;for(const e of this._world.entityManager.entities)t.addEntity(e)}maybeRemoveQuery(t){0===t.observers.length&&(t.clear(),delete this._queries[Fs(t.types)])}addEntity(t){for(const e in this._queries)this._queries[e]&&this._queries[e].addEntity(t)}removeComponent(t,e){for(const i in this._queries)this._queries[i].contain(e.type)&&this._queries[i].removeEntity(t)}removeEntity(t){for(const e in this._queries)this._queries[e].removeEntity(t)}createQuery(t){const e=this.getQuery(t);if(e)return e;const i=new Ls(t);return this._addQuery(i),i}getQuery(t){const e=Fs(t);return this._queries[e]?this._queries[e]:null}}class Os{constructor(t){this._world=t,this.systems=[],this.initialized=!1}get(t){return this.systems.find(e=>e instanceof t)}addSystem(t){if(!t.types||0===t.types.length)throw new Error("Attempted to add a System without any types");const e=this._world.queryManager.createQuery(t.types);this.systems.push(t),this.systems.sort((t,e)=>t.priority-e.priority),e.register(t),this.initialized&&t.initialize&&t.initialize(this._world.context)}removeSystem(t){B(t,this.systems);const e=this._world.queryManager.getQuery(t.types);e&&(e.unregister(t),this._world.queryManager.maybeRemoveQuery(e))}updateSystems(t,e,i){if(!this.initialized){this.initialized=!0;for(const t of this.systems)t.initialize&&t.initialize(this._world.context)}const s=this.systems.filter(e=>e.systemType===t);for(const t of s)t.preupdate&&t.preupdate(e,i);for(const t of s){const s=this._world.queryManager.getQuery(t.types).getEntities(t.sort);if(e instanceof dr)for(const t of s)t._initialize(null==e?void 0:e.engine);t.update(s,i)}for(const t of s)t.postupdate&&t.postupdate(e,i)}clear(){for(const t of this.systems)this.removeSystem(t)}}class zs{constructor(t){this.context=t,this.queryManager=new Is(this),this.entityManager=new ks(this),this.systemManager=new Os(this)}update(t,e){t===Es.Update&&this.entityManager.updateEntities(this.context,e),this.systemManager.updateSystems(t,this.context,e),this.entityManager.processComponentRemovals(),this.entityManager.processEntityRemovals()}add(t){t instanceof Hi&&this.entityManager.addEntity(t),t instanceof Ts&&this.systemManager.addSystem(t)}remove(t,e=!0){t instanceof Hi&&this.entityManager.removeEntity(t,e),t instanceof Ts&&this.systemManager.removeSystem(t)}clearEntities(){this.entityManager.clear()}clearSystems(){this.systemManager.clear()}}class Us{static integrate(t,e,i,s){const r=s/1e3;e.vel.addEqual(i.scale(r)),t.pos.addEqual(e.vel.scale(r)).addEqual(i.scale(.5*r*r)),e.angularVelocity+=e.torque*(1/e.inertia)*r,t.rotation+=e.angularVelocity*r,t.scale.addEqual(e.scaleFactor.scale(r))}}class Hs extends Ts{constructor(){super(...arguments),this.types=["ex.transform","ex.motion"],this.systemType=Es.Update,this.priority=-1}update(t,e){let i,s;for(const r of t){i=r.get(qe),s=r.get(Ne);const t=r.get(Bi);if(null==t?void 0:t.sleeping)continue;const n=s.acc.clone();(null==t?void 0:t.collisionType)===Xe.Active&&(null==t?void 0:t.useGravity)&&n.addEqual(li.gravity),null==t||t.captureOldTransform(),Us.integrate(i,s,n,e)}}debugDraw(t){}}class Ns{solve(t){return this.preSolve(t),t=t.filter(t=>!t.isCanceled()),this.solveVelocity(t),this.solvePosition(t),this.postSolve(t),t}}class Ws extends Ns{preSolve(t){for(const e of t){const t=y.fromDirection(e.mtv),i=e.mtv.negate();e.colliderA.events.emit("precollision",new Pt(e.colliderA,e.colliderB,t,i)),e.colliderB.events.emit("precollision",new Pt(e.colliderB,e.colliderA,y.getOpposite(t),i.negate()))}}postSolve(t){var e,i;for(const s of t){const t=s.colliderA,r=s.colliderB,n=null===(e=t.owner)||void 0===e?void 0:e.get(Bi),o=null===(i=r.owner)||void 0===i?void 0:i.get(Bi);if(n&&o&&(n.collisionType===Xe.Passive||o.collisionType===Xe.Passive))continue;const a=y.fromDirection(s.mtv),h=s.mtv.negate();s.colliderA.events.emit("postcollision",new Et(s.colliderA,s.colliderB,a,h)),s.colliderB.events.emit("postcollision",new Et(s.colliderB,s.colliderA,y.getOpposite(a),h.negate()))}}solvePosition(t){var e,i;for(const s of t){let t=s.mtv;const r=s.colliderA,n=s.colliderB,o=null===(e=r.owner)||void 0===e?void 0:e.get(Bi),a=null===(i=n.owner)||void 0===i?void 0:i.get(Bi);if(o&&a){if(o.collisionType===Xe.Passive||a.collisionType===Xe.Passive)continue;o.collisionType===Xe.Active&&a.collisionType===Xe.Active&&(t=t.scale(.5)),o.collisionType===Xe.Active&&(o.pos.x-=t.x,o.pos.y-=t.y),a.collisionType===Xe.Active&&(a.pos.x+=t.x,a.pos.y+=t.y)}}}solveVelocity(t){var e,i;for(const s of t){const t=s.colliderA,r=s.colliderB,n=null===(e=t.owner)||void 0===e?void 0:e.get(Bi),o=null===(i=r.owner)||void 0===i?void 0:i.get(Bi);if(n&&o){if(n.collisionType===Xe.Passive||o.collisionType===Xe.Passive)continue;const t=s.normal,e=t.negate();if(n.collisionType===Xe.Active){const e=t.scale(t.dot(n.vel.negate()));n.vel=n.vel.add(e)}if(o.collisionType===Xe.Active){const t=e.scale(e.dot(o.vel.negate()));o.vel=o.vel.add(t)}}}}}class Vs{constructor(t,e,i){this.point=t,this.local=e,this.contact=i,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.aToContact=new X(0,0),this.bToContact=new X(0,0),this.update()}update(){var t,e;const i=null===(t=this.contact.colliderA.owner)||void 0===t?void 0:t.get(Bi),s=null===(e=this.contact.colliderB.owner)||void 0===e?void 0:e.get(Bi);if(i&&s){const t=this.contact.normal,e=this.contact.tangent;this.aToContact=this.point.sub(i.pos),this.bToContact=this.point.sub(s.pos);const r=this.aToContact.cross(t),n=this.bToContact.cross(t);this.normalMass=i.inverseMass+s.inverseMass+i.inverseInertia*r*r+s.inverseInertia*n*n;const o=this.aToContact.cross(e),a=this.bToContact.cross(e);this.tangentMass=i.inverseMass+s.inverseMass+i.inverseInertia*o*o+s.inverseInertia*a*a}return this}getRelativeVelocity(){var t,e;const i=null===(t=this.contact.colliderA.owner)||void 0===t?void 0:t.get(Bi),s=null===(e=this.contact.colliderB.owner)||void 0===e?void 0:e.get(Bi);if(i&&s){const t=i.vel.add(X.cross(i.angularVelocity,this.aToContact));return s.vel.add(X.cross(s.angularVelocity,this.bToContact)).sub(t)}return X.Zero}}class Gs extends Ns{constructor(){super(...arguments),this.lastFrameContacts=new Map,this.idToContactConstraint=new Map}getContactConstraints(t){var e;return null!==(e=this.idToContactConstraint.get(t))&&void 0!==e?e:[]}preSolve(t){var e,i,s;for(const e of t){const t=y.fromDirection(e.mtv);e.colliderA.events.emit("precollision",new Pt(e.colliderA,e.colliderB,t,e.mtv)),e.colliderA.events.emit("beforecollisionresolve",new Dt(e.colliderA,e.colliderB,t,e.mtv,e)),e.colliderB.events.emit("precollision",new Pt(e.colliderB,e.colliderA,y.getOpposite(t),e.mtv.negate())),e.colliderB.events.emit("beforecollisionresolve",new Dt(e.colliderB,e.colliderA,y.getOpposite(t),e.mtv.negate(),e)),e.matchAwake()}const r=Array.from(this.idToContactConstraint.keys());for(const n of t){const t=r.indexOf(n.id);t>-1&&r.splice(t,1);const o=null!==(e=this.idToContactConstraint.get(n.id))&&void 0!==e?e:[];let a=0;const h=n.colliderA.owner.get(Bi),l=n.colliderB.owner.get(Bi);if(h&&l)for(const t of n.points){const e=n.normal,r=n.tangent,c=t.sub(h.pos),d=t.sub(l.pos),u=c.cross(e),p=d.cross(e),g=h.inverseMass+l.inverseMass+h.inverseInertia*u*u+l.inverseInertia*p*p,_=c.cross(r),f=d.cross(r),m=h.inverseMass+l.inverseMass+h.inverseInertia*_*_+l.inverseInertia*f*f;o[a]&&(null===(s=null===(i=o[a])||void 0===i?void 0:i.point)||void 0===s?void 0:s.squareDistance(t))<4?(o[a].point=t,o[a].local=n.localPoints[a]):o[a]=new Vs(t,n.localPoints[a],n),o[a].aToContact=c,o[a].bToContact=d,o[a].normalMass=g,o[a].tangentMass=m,a++}this.idToContactConstraint.set(n.id,o)}for(const t of r)this.idToContactConstraint.delete(t);if(li.warmStart)this.warmStart(t);else for(const e of t){const t=this.getContactConstraints(e.id);for(const e of t)e.normalImpulse=0,e.tangentImpulse=0}}postSolve(t){for(const e of t){const t=e.colliderA.owner.get(Bi),i=e.colliderB.owner.get(Bi);if(t&&i){if(t.collisionType===Xe.Passive||i.collisionType===Xe.Passive)continue;t.updateMotion(),i.updateMotion()}const s=y.fromDirection(e.mtv);e.colliderA.events.emit("postcollision",new Et(e.colliderA,e.colliderB,s,e.mtv)),e.colliderA.events.emit("aftercollisionresolve",new Mt(e.colliderA,e.colliderB,s,e.mtv,e)),e.colliderB.events.emit("postcollision",new Et(e.colliderB,e.colliderA,y.getOpposite(s),e.mtv.negate())),e.colliderB.events.emit("aftercollisionresolve",new Mt(e.colliderB,e.colliderA,y.getOpposite(s),e.mtv.negate(),e))}this.lastFrameContacts.clear();for(const e of t)this.lastFrameContacts.set(e.id,e)}warmStart(t){var e,i,s;for(const r of t){const t=null===(e=r.colliderA.owner)||void 0===e?void 0:e.get(Bi),n=null===(i=r.colliderB.owner)||void 0===i?void 0:i.get(Bi);if(t&&n){const e=null!==(s=this.idToContactConstraint.get(r.id))&&void 0!==s?s:[];for(const i of e)if(li.warmStart){const e=r.normal.scale(i.normalImpulse),s=r.tangent.scale(i.tangentImpulse),o=e.add(s);t.applyImpulse(i.point,o.negate()),n.applyImpulse(i.point,o)}else i.normalImpulse=0,i.tangentImpulse=0}}}solvePosition(t){var e,i,s;for(let r=0;r<li.positionIterations;r++)for(const r of t){const t=null===(e=r.colliderA.owner)||void 0===e?void 0:e.get(Bi),n=null===(i=r.colliderB.owner)||void 0===i?void 0:i.get(Bi);if(t&&n){if(t.collisionType===Xe.Passive||n.collisionType===Xe.Passive)continue;const e=null!==(s=this.idToContactConstraint.get(r.id))&&void 0!==s?s:[];for(const i of e){const e=r.normal,s=Pi.FindContactSeparation(r,i.local),o=-5,a=A(li.steeringFactor*(s+li.slop),o,0),h=e.scale(-a/i.normalMass);t.collisionType===Xe.Active&&(t.pos=t.pos.add(h.negate().scale(t.inverseMass)),t.rotation-=i.aToContact.cross(h)*t.inverseInertia),n.collisionType===Xe.Active&&(n.pos=n.pos.add(h.scale(n.inverseMass)),n.rotation+=i.bToContact.cross(h)*n.inverseInertia)}}}}solveVelocity(t){var e,i,s;for(let r=0;r<li.velocityIterations;r++)for(const r of t){const t=null===(e=r.colliderA.owner)||void 0===e?void 0:e.get(Bi),n=null===(i=r.colliderB.owner)||void 0===i?void 0:i.get(Bi);if(t&&n){if(t.collisionType===Xe.Passive||n.collisionType===Xe.Passive)continue;const e=t.bounciness*n.bounciness,i=Math.min(t.friction,n.friction),o=null!==(s=this.idToContactConstraint.get(r.id))&&void 0!==s?s:[];for(const e of o){let s=-e.getRelativeVelocity().dot(r.tangent)/e.tangentMass;const o=i*e.normalImpulse,a=A(e.tangentImpulse+s,-o,o);s=a-e.tangentImpulse,e.tangentImpulse=a;const h=r.tangent.scale(s);t.applyImpulse(e.point,h.negate()),n.applyImpulse(e.point,h)}for(const i of o){let s=-(1+e)*i.getRelativeVelocity().dot(r.normal)/i.normalMass;const o=Math.max(i.normalImpulse+s,0);s=o-i.normalImpulse,i.normalImpulse=o;const a=r.normal.scale(s);t.applyImpulse(i.point,a.negate()),n.applyImpulse(i.point,a)}}}}}class js extends Ts{constructor(){super(...arguments),this.types=["ex.transform","ex.motion","ex.collider"],this.systemType=Es.Update,this.priority=-1,this._realisticSolver=new Gs,this._arcadeSolver=new Ws,this._processor=new mi,this._lastFrameContacts=new Map,this._currentFrameContacts=new Map,this._trackCollider=t=>this._processor.track(t),this._untrackCollider=t=>this._processor.untrack(t)}notify(t){if(Ds(t)){const e=t.data.get(Di);e.$colliderAdded.subscribe(this._trackCollider),e.$colliderRemoved.subscribe(this._untrackCollider);const i=e.get();i&&this._processor.track(i)}else{const e=t.data.get(Di),i=e.get();e&&i&&this._processor.untrack(i)}}initialize(t){this._engine=t.engine}update(t,e){var i;if(!li.enabled)return;let s=[];for(const e of t){const t=e.get(Di),r=null==t?void 0:t.get();t&&(null===(i=t.owner)||void 0===i?void 0:i.active)&&r&&(t.update(),r instanceof yi?s=s.concat(r.getColliders()):s.push(r))}this._processor.update(s);const r=this._processor.broadphase(s,e);this._currentFrameContacts.clear();let n=this._processor.narrowphase(r,this._engine.debug.stats.currFrame);n=this.getSolver().solve(n),n.forEach(t=>this._currentFrameContacts.set(t.id,t)),this.runContactStartEnd(),this._lastFrameContacts.clear(),this._lastFrameContacts=new Map(this._currentFrameContacts)}getSolver(){return li.collisionResolutionStrategy===ni.Realistic?this._realisticSolver:this._arcadeSolver}debug(t){this._processor.debug(t)}runContactStartEnd(){for(const[t,e]of this._currentFrameContacts)if(!this._lastFrameContacts.has(t)){const t=e.colliderA,i=e.colliderB;t.events.emit("collisionstart",new Bt(t,i,e)),t.events.emit("contactstart",new Tt(t,i,e)),i.events.emit("collisionstart",new Bt(i,t,e)),i.events.emit("contactstart",new Tt(i,t,e))}for(const[t,e]of this._lastFrameContacts)if(!this._currentFrameContacts.has(t)){const t=e.colliderA,i=e.colliderB;t.events.emit("collisionend",new kt(t,i)),t.events.emit("contactend",new Rt(t,i)),i.events.emit("collisionend",new kt(i,t)),i.events.emit("contactend",new Rt(i,t))}}}class Xs{static clear(){Xs.DrawCallCount=0,Xs.DrawnImagesCount=0}}var qs,Ks;Xs.DrawCallCount=0,Xs.DrawnImagesCount=0,function(t){t.End="end",t.Loop="loop",t.PingPong="pingpong",t.Freeze="freeze"}(qs||(qs={}));class Zs extends Zt{constructor(t){var e,i;super(t),this.events=new Nt(this),this.frames=[],this.strategy=qs.Loop,this.frameDuration=100,this.timeScale=1,this._idempotencyToken=-1,this._firstTick=!0,this._currentFrame=0,this._timeLeftInFrame=0,this._direction=1,this._done=!1,this._playing=!0,this.frames=t.frames,this.strategy=null!==(e=t.strategy)&&void 0!==e?e:this.strategy,this.frameDuration=null!==(i=t.frameDuration)&&void 0!==i?i:this.frameDuration,this.goToFrame(0)}clone(){return new Zs(Object.assign({frames:this.frames.map(t=>Object.assign({},t)),frameDuration:this.frameDuration,strategy:this.strategy},this.cloneGraphicOptions()))}static fromSpriteSheet(t,e,i,s=qs.Loop){const r=t.sprites.length-1,n=e.filter(t=>t<0||t>r);return n.length&&Zs._LOGGER.warn(`Indices into SpriteSheet were provided that don't exist: ${n.join(",")} no frame will be shown`),new Zs({frames:t.sprites.filter((t,i)=>e.indexOf(i)>-1).map(t=>({graphic:t,duration:i})),strategy:s})}static toLegacyAnimation(t,e){const i=e.frames.map(t=>os.toLegacySprite(t.graphic));return new Ee({sprites:i,loop:e.strategy===qs.Loop,freezeFrame:e.strategy===qs.Freeze?i.length-1:void 0,speed:e.frameDuration,engine:t})}get currentFrame(){return this._currentFrame>=0&&this._currentFrame<this.frames.length?this.frames[this._currentFrame]:null}get isPlaying(){return this._playing}play(){this._playing=!0}pause(){this._playing=!1,this._firstTick=!0}reset(){this._done=!1,this._firstTick=!0,this._currentFrame=0}get canFinish(){switch(this.strategy){case qs.End:case qs.Freeze:return!0;default:return!1}}get done(){return this._done}goToFrame(t){var e,i;this._currentFrame=t,this._timeLeftInFrame=this.frameDuration;const s=this.frames[this._currentFrame];s&&!this._done&&(this._timeLeftInFrame=(null==s?void 0:s.duration)||this.frameDuration,this.width=null===(e=s.graphic)||void 0===e?void 0:e.width,this.height=null===(i=s.graphic)||void 0===i?void 0:i.height,this.events.emit("frame",s))}_nextFrame(){const t=this._currentFrame;if(this._done)return t;let e=-1;switch(this.strategy){case qs.Loop:e=(t+1)%this.frames.length,0===e&&this.events.emit("loop",this);break;case qs.End:e=t+1,e>=this.frames.length&&(this._done=!0,this._currentFrame=this.frames.length,this.events.emit("end",this));break;case qs.Freeze:e=A(t+1,0,this.frames.length-1),e>=this.frames.length-1&&(this._done=!0,this.events.emit("end",this));break;case qs.PingPong:t+this._direction>=this.frames.length&&(this._direction=-1,this.events.emit("loop",this)),t+this._direction<0&&(this._direction=1,this.events.emit("loop",this)),e=t+this._direction%this.frames.length}return e}tick(t,e=0){this._idempotencyToken!==e&&(this._idempotencyToken=e,this._playing&&(this._firstTick&&(this._firstTick=!1,this.events.emit("frame",this.currentFrame)),this._timeLeftInFrame-=t*this.timeScale,this._timeLeftInFrame<=0&&this.goToFrame(this._nextFrame()),this._updateDimensions()))}_updateDimensions(){var t,e;this.currentFrame&&(this.width=null===(t=this.currentFrame.graphic)||void 0===t?void 0:t.width,this.height=null===(e=this.currentFrame.graphic)||void 0===e?void 0:e.height)}_drawImage(t,e,i){this.currentFrame&&this.currentFrame.graphic.draw(t,e,i)}}Zs._LOGGER=_.getInstance();class Ys extends Zt{constructor(t){super(t),this.members=[],this.members=t.members,this._updateDimensions()}clone(){return new Ys(Object.assign({members:[...this.members]},this.cloneGraphicOptions()))}_updateDimensions(){let t=new J;for(const{graphic:e,pos:i}of this.members)t=e.localBounds.translate(i).combine(t);return this.width=t.width,this.height=t.height,t}get localBounds(){let t=new J;for(const{graphic:e,pos:i}of this.members)t=e.localBounds.translate(i).combine(t);return t}_isAnimationOrGroup(t){return t instanceof Zs||t instanceof Ys}tick(t,e){for(const i of this.members){const s=i.graphic;this._isAnimationOrGroup(s)&&s.tick(t,e)}}reset(){for(const t of this.members){const e=t.graphic;this._isAnimationOrGroup(e)&&e.reset()}}_preDraw(t,e,i){this._updateDimensions(),super._preDraw(t,e,i)}_drawImage(t,e,i){for(const s of this.members)t.save(),t.translate(e,i),s.graphic.draw(t,s.pos.x,s.pos.y),this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore()}}!function(t){t[t.Circle=0]="Circle",t[t.Rectangle=1]="Rectangle"}(Ks||(Ks={}));class Qs extends Hi{constructor(t,e,i,s,r,n,o,a,h,l){super(),this.position=new X(0,0),this.velocity=new X(0,0),this.acceleration=new X(0,0),this.particleRotationalVelocity=0,this.currentRotation=0,this.focus=null,this.focusAccel=0,this.opacity=1,this.beginColor=Q.White,this.endColor=Q.White,this.life=300,this.fadeFlag=!1,this._rRate=1,this._gRate=1,this._bRate=1,this._aRate=0,this._currentColor=Q.White,this.emitter=null,this.particleSize=5,this.particleSprite=null,this.sizeRate=0,this.elapsedMultiplier=0,this.visible=!0,this.isOffscreen=!1;let c=t;if(c&&!(t instanceof Js)){const d=t;c=d.emitter,e=d.life,i=d.opacity,r=d.endColor,s=d.beginColor,n=d.position,o=d.velocity,a=d.acceleration,h=d.startSize,l=d.endSize}this.emitter=c,this.life=e||this.life,this.opacity=i||this.opacity,this.endColor=r||this.endColor.clone(),this.beginColor=s||this.beginColor.clone(),this._currentColor=this.beginColor.clone(),this.position=(n||this.position).add(this.emitter.pos),this.velocity=o||this.velocity,this.acceleration=a||this.acceleration,this._rRate=(this.endColor.r-this.beginColor.r)/this.life,this._gRate=(this.endColor.g-this.beginColor.g)/this.life,this._bRate=(this.endColor.b-this.beginColor.b)/this.life,this._aRate=this.opacity/this.life,this.startSize=h||0,this.endSize=l||0,this.endSize>0&&this.startSize>0&&(this.sizeRate=(this.endSize-this.startSize)/this.life,this.particleSize=this.startSize),this.addComponent(this.transform=new qe),this.addComponent(new Ni(t=>this.draw(t))),this.addComponent(this.graphics=new ji),this.transform.pos=this.position,this.transform.rotation=this.currentRotation,this.transform.scale=q(1,1),this.particleSprite?(this.graphics.opacity=this.opacity,this.graphics.use(os.fromLegacySprite(this.particleSprite))):this.graphics.onPostDraw=t=>{t.save(),this.graphics.opacity=this.opacity;const e=this._currentColor.clone();e.a=1,t.debug.drawPoint(q(0,0),{color:e,size:this.particleSize}),t.restore()}}kill(){this.emitter.removeParticle(this)}update(t,e){if(this.life=this.life-e,this.elapsedMultiplier=this.elapsedMultiplier+e,this.life<0&&this.kill(),this.fadeFlag&&(this.opacity=A(this._aRate*this.life,1e-4,1)),this.startSize>0&&this.endSize>0&&(this.particleSize=A(this.sizeRate*e+this.particleSize,Math.min(this.startSize,this.endSize),Math.max(this.startSize,this.endSize))),this._currentColor.r=A(this._currentColor.r+this._rRate*e,0,255),this._currentColor.g=A(this._currentColor.g+this._gRate*e,0,255),this._currentColor.b=A(this._currentColor.b+this._bRate*e,0,255),this._currentColor.a=A(this.opacity,1e-4,1),this.focus){const t=this.focus.sub(this.position).normalize().scale(this.focusAccel).scale(e/1e3);this.velocity=this.velocity.add(t)}else this.velocity=this.velocity.add(this.acceleration.scale(e/1e3));this.position=this.position.add(this.velocity.scale(e/1e3)),this.particleRotationalVelocity&&(this.currentRotation=(this.currentRotation+this.particleRotationalVelocity*e/1e3)%(2*Math.PI)),this.transform.pos=this.position,this.transform.rotation=this.currentRotation,this.transform.scale=q(1,1),this.graphics.opacity=this.opacity}draw(t){if(this.particleSprite)return this.particleSprite.opacity(this.opacity),void this.particleSprite.draw(t,0,0);t.save(),this._currentColor.a=A(this.opacity,1e-4,1),t.fillStyle=this._currentColor.toString(),t.beginPath(),t.arc(0,0,this.particleSize,0,2*Math.PI),t.fill(),t.closePath(),t.restore()}}class $s extends(we(Qs)){constructor(t,e,i,s,r,n,o,a,h,l){super(t,e,i,s,r,n,o,a,h,l)}}class Js extends Zi{constructor(t){var e,i;super({width:null!==(e=t.width)&&void 0!==e?e:0,height:null!==(i=t.height)&&void 0!==i?i:0}),this._particlesToEmit=0,this.numParticles=0,this.isEmitting=!0,this.particles=[],this.deadParticles=[],this.minVel=0,this.maxVel=0,this.acceleration=new X(0,0),this.minAngle=0,this.maxAngle=0,this.emitRate=1,this.particleLife=2e3,this.fadeFlag=!1,this.focus=null,this.focusAccel=null,this.startSize=null,this.endSize=null,this.minSize=5,this.maxSize=5,this.beginColor=Q.White,this.endColor=Q.White,this._og=null,this._sprite=null,this.emitterType=Ks.Rectangle,this.radius=0,this.particleRotationalVelocity=0,this.randomRotation=!1;const{x:s,y:r,pos:n,isEmitting:o,minVel:a,maxVel:h,acceleration:l,minAngle:c,maxAngle:d,emitRate:u,particleLife:p,opacity:g,fadeFlag:_,focus:f,focusAccel:m,startSize:y,endSize:v,minSize:x,maxSize:b,beginColor:C,endColor:A,particleSprite:S,emitterType:P,radius:E,particleRotationalVelocity:T,randomRotation:R,random:D}=Object.assign({},t);this.pos=null!=n?n:q(null!=s?s:0,null!=r?r:0),this.isEmitting=null!=o?o:this.isEmitting,this.minVel=null!=a?a:this.minVel,this.maxVel=null!=h?h:this.maxVel,this.acceleration=null!=l?l:this.acceleration,this.minAngle=null!=c?c:this.minAngle,this.maxAngle=null!=d?d:this.maxAngle,this.emitRate=null!=u?u:this.emitRate,this.particleLife=null!=p?p:this.particleLife,this.opacity=null!=g?g:this.opacity,this.fadeFlag=null!=_?_:this.fadeFlag,this.focus=null!=f?f:this.focus,this.focusAccel=null!=m?m:this.focusAccel,this.startSize=null!=y?y:this.startSize,this.endSize=null!=v?v:this.endSize,this.minSize=null!=x?x:this.minSize,this.maxSize=null!=b?b:this.maxSize,this.beginColor=null!=C?C:this.beginColor,this.endColor=null!=A?A:this.endColor,this.particleSprite=null!=S?S:this.particleSprite,this.emitterType=null!=P?P:this.emitterType,this.radius=null!=E?E:this.radius,this.particleRotationalVelocity=null!=T?T:this.particleRotationalVelocity,this.randomRotation=null!=R?R:this.randomRotation,this.body.collisionType=Xe.PreventCollision,this.random=null!=D?D:new w;for(let t=0;t<this.traits.length;t++)this.traits[t]instanceof Fi&&this.traits.splice(t,1)}get opacity(){return super.graphics.opacity}set opacity(t){super.graphics.opacity=t}get particleSprite(){return this._og}set particleSprite(t){this._og=t,t&&(this._sprite=os.fromLegacySprite(t))}removeParticle(t){this.deadParticles.push(t)}emitParticles(t){var e;for(let i=0;i<t;i++){const t=this._createParticle();this.particles.push(t),(null===(e=null==this?void 0:this.scene)||void 0===e?void 0:e.world)&&this.scene.world.add(t)}}clearParticles(){this.particles.length=0}_createParticle(){let t=0,e=0;const i=S(this.minAngle,this.maxAngle,this.random),s=S(this.minVel,this.maxVel,this.random),r=this.startSize||S(this.minSize,this.maxSize,this.random),n=s*Math.cos(i),o=s*Math.sin(i);if(this.emitterType===Ks.Rectangle)t=S(0,this.width,this.random),e=S(0,this.height,this.random);else if(this.emitterType===Ks.Circle){const s=S(0,this.radius,this.random);t=s*Math.cos(i),e=s*Math.sin(i)}const a=new $s(this,this.particleLife,this.opacity,this.beginColor,this.endColor,new X(t,e),new X(n,o),this.acceleration,this.startSize,this.endSize);return a.fadeFlag=this.fadeFlag,a.particleSize=r,this.particleSprite&&(a.particleSprite=this.particleSprite,a.graphics.opacity=this.opacity,a.graphics.use(this._sprite)),a.particleRotationalVelocity=this.particleRotationalVelocity,this.randomRotation&&(a.currentRotation=S(0,2*Math.PI,this.random)),this.focus&&(a.focus=this.focus.add(new X(this.pos.x,this.pos.y)),a.focusAccel=this.focusAccel),a}update(t,e){var i;super.update(t,e),this.isEmitting&&(this._particlesToEmit+=this.emitRate*(e/1e3),this._particlesToEmit>1&&(this.emitParticles(Math.floor(this._particlesToEmit)),this._particlesToEmit=this._particlesToEmit-Math.floor(this._particlesToEmit)));for(let t=0;t<this.deadParticles.length;t++)B(this.deadParticles[t],this.particles),(null===(i=null==this?void 0:this.scene)||void 0===i?void 0:i.world)&&this.scene.world.remove(this.deadParticles[t],!1);this.deadParticles.length=0}draw(t){this.particles.forEach(e=>e.draw(t))}debugDraw(t){super.debugDraw(t),t.fillStyle=Q.Black.toString(),t.fillText("Particles: "+this.particles.length,this.pos.x,this.pos.y+20),this.focus&&(t.fillRect(this.focus.x+this.pos.x,this.focus.y+this.pos.y,3,3),Vt(t,Q.Yellow,this.focus.x+this.pos.x,this.focus.y+this.pos.y,this.center.x,this.center.y),t.fillText("Focus",this.focus.x+this.pos.x,this.focus.y+this.pos.y))}}class tr extends Ts{constructor(){super(...arguments),this.types=["ex.transform","ex.graphics"],this.systemType=Es.Draw,this.priority=0,this._token=0}initialize(t){this._graphicsContext=t.engine.graphicsContext,this._camera=t.camera,this._engine=t.engine}sort(t,e){return t.get(qe).z-e.get(qe).z}update(t,e){let i,s;this._clearScreen(),this._token++;for(const r of t){i=r.get(qe),s=r.get(ji);const t=this._isOffscreen(i,s);if(t&&!r.hasTag("offscreen")&&(r.eventDispatcher.emit("exitviewport",new Ot(r)),r.addComponent(new He("offscreen"))),!t&&r.hasTag("offscreen")&&(r.eventDispatcher.emit("enterviewport",new zt(r)),r.removeComponent("offscreen")),t)continue;this._pushCameraTransform(i),this._graphicsContext.save(),s.update(e,this._token),this._applyTransform(r),s.onPreDraw&&s.onPreDraw(this._graphicsContext,e);const n=r instanceof $s?r.opacity:1;this._graphicsContext.opacity=s.opacity*n,this._drawGraphicsComponent(s),s.onPostDraw&&s.onPostDraw(this._graphicsContext,e),this._graphicsContext.restore(),this._popCameraTransform(i)}this._graphicsContext.flush(),this._engine.stats.currFrame.graphics.drawnImages=Xs.DrawnImagesCount,this._engine.stats.currFrame.graphics.drawCalls=Xs.DrawCallCount}_clearScreen(){this._graphicsContext.clear()}_isOffscreen(t,e){if(t.coordPlane===je.World){return!this._camera.viewport.intersect(e.localBounds.transform(t.getGlobalMatrix()))}return!1}_drawGraphicsComponent(t){var e,i;if(t.visible)for(const s of t.layers.get())for(const{graphic:r,options:n}of s.graphics){let o=t.anchor,a=t.offset;(null==n?void 0:n.anchor)&&(o=n.anchor),(null==n?void 0:n.offset)&&(a=n.offset);const h=-r.width*o.x+a.x,l=-r.height*o.y+a.y;if(null==r||r.draw(this._graphicsContext,h+s.offset.x,l+s.offset.y),(null===(e=this._engine)||void 0===e?void 0:e.isDebug)&&this._engine.debug.graphics.showBounds){const t=q(h+s.offset.x,l+s.offset.y);if(r instanceof Ys)for(const e of r.members)null===(i=e.graphic)||void 0===i||i.localBounds.translate(t.add(e.pos)).draw(this._graphicsContext,this._engine.debug.graphics.boundsColor);else null==r||r.localBounds.translate(t).draw(this._graphicsContext,this._engine.debug.graphics.boundsColor)}}}_applyTransform(t){const e=t.getAncestors();for(const t of e){const e=null==t?void 0:t.get(qe);e&&(this._graphicsContext.translate(e.pos.x,e.pos.y),this._graphicsContext.scale(e.scale.x,e.scale.y),this._graphicsContext.rotate(e.rotation))}}_pushCameraTransform(t){t.coordPlane===je.World&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext))}_popCameraTransform(t){t.coordPlane===je.World&&this._graphicsContext.restore()}}class er extends Ts{constructor(){super(...arguments),this.types=["ex.transform","ex.canvas"],this.systemType=Es.Draw,this.priority=-1}initialize(t){this._ctx=t.engine.ctx,this._engine=t.engine,this._camera=t.camera}sort(t,e){return t.get(qe).z-e.get(qe).z}update(t,e){var i,s,r;let n,o;this._clearScreen();const a=t.length;for(let h=0;h<a;h++){const a=null===(r=null===(s=null===(i=t[h])||void 0===i?void 0:i.graphics)||void 0===s?void 0:s.visible)||void 0===r||r,l=t[h].isOffScreen;a&&!l&&(n=t[h].get(qe),o=t[h].get(Ni),this._ctx.save(),this._pushCameraTransform(n),this._ctx.save(),this._applyTransform(t[h]),o.draw(this._ctx,e),this._ctx.restore(),this._popCameraTransform(n),this._ctx.restore()),this._engine.isDebug&&(this._ctx.save(),this._pushCameraTransform(n),this._ctx.strokeStyle="yellow",t[h].debugDraw(this._ctx),this._popCameraTransform(n),this._ctx.restore())}this._engine.isDebug&&(this._ctx.save(),this._camera.draw(this._ctx),this._camera.debugDraw(this._ctx),this._ctx.restore()),this._engine.stats.currFrame.graphics.drawnImages=Xs.DrawnImagesCount,this._engine.stats.currFrame.graphics.drawCalls=Xs.DrawCallCount}_applyTransform(t){const e=t.getAncestors();for(const t of e){const e=null==t?void 0:t.get(qe);e&&(this._ctx.translate(e.pos.x,e.pos.y),this._ctx.rotate(e.rotation),this._ctx.scale(e.scale.x,e.scale.y))}}_clearScreen(){this._ctx.clearRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height),this._ctx.fillStyle=this._engine.backgroundColor.toString(),this._ctx.fillRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height)}_pushCameraTransform(t){t.coordPlane===je.World&&(this._ctx.save(),this._camera&&this._camera.draw(this._ctx))}_popCameraTransform(t){t.coordPlane===je.World&&this._ctx.restore()}}class ir extends Ts{constructor(){super(...arguments),this.types=["ex.transform"],this.systemType=Es.Draw,this.priority=999}initialize(t){this._graphicsContext=t.engine.graphicsContext,this._camera=t.camera,this._engine=t.engine,this._collisionSystem=t.world.systemManager.get(js)}update(t,e){var i,s;if(!this._engine.isDebug)return;const r=this._engine.debug.filter;let n,o;const a=this._engine.debug.entity;let h;const l=this._engine.debug.transform;let c;const d=this._engine.debug.motion;let u;const p=this._engine.debug.collider,g=this._engine.debug.physics;let _;const f=this._engine.debug.graphics;let m;const w=this._engine.debug.body,y=this._engine.debug.camera;for(const e of t){if(e.hasTag("offscreen"))continue;if(e instanceof $s)continue;if(r.useFilter){if(!(0===r.ids.length||r.ids.includes(e.id)))continue;if(!(""===r.nameQuery||e.name.includes(r.nameQuery)))continue}let t=X.Zero;const g=q(0,16);if(n=e.id,o=e.name,h=e.get(qe),this._pushCameraTransform(h),this._graphicsContext.save(),this._applyTransform(e),h&&((l.showAll||l.showPosition)&&(this._graphicsContext.debug.drawPoint(X.Zero,{size:2,color:l.positionColor}),this._graphicsContext.debug.drawText("pos"+h.pos.toString(2),t),t=t.add(g)),(a.showAll||a.showId)&&(this._graphicsContext.debug.drawText(`id(${n}) ${h.parent?"child of id("+(null===(s=null===(i=h.parent)||void 0===i?void 0:i.owner)||void 0===s?void 0:s.id)+")":""}`,t),t=t.add(g)),(a.showAll||a.showName)&&(this._graphicsContext.debug.drawText(`name(${o})`,t),t=t.add(g)),(l.showAll||l.showRotation)&&(this._graphicsContext.drawLine(X.Zero,X.fromAngle(h.rotation).scale(50).add(X.Zero),l.rotationColor,2),this._graphicsContext.debug.drawText(`rot deg(${T(h.rotation).toFixed(2)})`,t),t=t.add(g)),(l.showAll||l.showScale)&&this._graphicsContext.drawLine(X.Zero,h.scale.add(X.Zero),l.scaleColor,2)),_=e.get(ji),_&&(f.showAll||f.showBounds)){_.localBounds.draw(this._graphicsContext,f.boundsColor)}if(m=e.get(Bi),m&&((w.showAll||w.showCollisionGroup)&&(this._graphicsContext.debug.drawText(`collision group(${m.group.name})`,t),t=t.add(g)),(w.showAll||w.showCollisionType)&&(this._graphicsContext.debug.drawText(`collision type(${m.collisionType})`,t),t=t.add(g)),(w.showAll||w.showMass)&&(this._graphicsContext.debug.drawText(`mass(${m.mass})`,t),t=t.add(g)),(w.showAll||w.showMotion)&&(this._graphicsContext.debug.drawText(`motion(${m.sleepMotion})`,t),t=t.add(g)),(w.showAll||w.showSleeping)&&(this._graphicsContext.debug.drawText(`sleeping(${m.canSleep?m.sleeping:"cant sleep"})`,t),t=t.add(g))),this._graphicsContext.restore(),c=e.get(Ne),c&&((d.showAll||d.showVelocity)&&(this._graphicsContext.debug.drawText("vel"+c.vel.toString(2),t.add(h.globalPos)),this._graphicsContext.drawLine(h.globalPos,h.globalPos.add(c.vel),d.velocityColor,2),t=t.add(g)),(d.showAll||d.showAcceleration)&&this._graphicsContext.drawLine(h.globalPos,h.globalPos.add(c.acc),d.accelerationColor,2)),u=e.get(Di),u){const t=u.get();if((p.showAll||p.showGeometry)&&t.debug(this._graphicsContext,p.geometryColor),p.showAll||p.showBounds)if(t instanceof yi){const e=t.getColliders();for(const t of e){const e=t.bounds,i=q(e.left,e.top);this._graphicsContext.debug.drawRect(i.x,i.y,e.width,e.height,{color:p.boundsColor}),(p.showAll||p.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${t.owner.id})`,i)}u.bounds.draw(this._graphicsContext,p.boundsColor)}else if(t){const t=u.bounds,e=q(t.left,t.top);this._graphicsContext.debug.drawRect(e.x,e.y,t.width,t.height,{color:p.boundsColor}),(p.showAll||p.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${u.owner.id})`,e)}}this._popCameraTransform(h)}if(this._graphicsContext.save(),this._camera.draw(this._graphicsContext),(g.showAll||g.showBroadphaseSpacePartitionDebug)&&this._collisionSystem.debug(this._graphicsContext),g.showAll||g.showCollisionContacts||g.showCollisionNormals)for(const[t,e]of this._engine.debug.stats.currFrame.physics.contacts){if(g.showAll||g.showCollisionContacts)for(const t of e.points)this._graphicsContext.debug.drawPoint(t,{size:5,color:g.collisionContactColor});if(g.showAll||g.showCollisionNormals)for(const t of e.points)this._graphicsContext.debug.drawLine(t,e.normal.scale(30).add(t),{color:g.collisionNormalColor})}this._graphicsContext.restore(),y&&(this._graphicsContext.save(),this._camera.draw(this._graphicsContext),(y.showAll||y.showFocus)&&this._graphicsContext.drawCircle(this._camera.pos,4,y.focusColor),(y.showAll||y.showZoom)&&this._graphicsContext.debug.drawText(`zoom(${this._camera.zoom})`,this._camera.pos),this._graphicsContext.restore()),this._graphicsContext.flush()}_applyTransform(t){const e=t.getAncestors();for(const t of e){const e=null==t?void 0:t.get(qe);e&&(this._graphicsContext.translate(e.pos.x,e.pos.y),this._graphicsContext.scale(e.scale.x,e.scale.y),this._graphicsContext.rotate(e.rotation))}}_pushCameraTransform(t){t.coordPlane===je.World&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext))}_popCameraTransform(t){t.coordPlane===je.World&&this._graphicsContext.restore()}}var sr,rr,nr,or,ar,hr,lr,cr=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class dr extends Wt{constructor(){super(),this._logger=_.getInstance(),this.camera=new Cs,this.world=new zs(this),this._isInitialized=!1,this._timers=[],this._cancelQueue=[],this.world.add(new Hs),this.world.add(new js),p.isEnabled(c.LegacyDrawing)?this.world.add(new er):this.world.add(new tr),this.world.add(new ir)}get actors(){return this.world.entityManager.entities.filter(t=>t instanceof Zi)}get entities(){return this.world.entityManager.entities}get triggers(){return this.world.entityManager.entities.filter(t=>t instanceof Ps)}get tileMaps(){return this.world.entityManager.entities.filter(t=>t instanceof gs)}get screenElements(){return this.actors.filter(t=>t instanceof Yi)}on(t,e){super.on(t,e)}once(t,e){super.once(t,e)}off(t,e){super.off(t,e)}onInitialize(t){}onActivate(t,e){}onDeactivate(t,e){}onPreUpdate(t,e){}onPostUpdate(t,e){}onPreDraw(t,e){}onPostDraw(t,e){}_initializeChildren(){for(const t of this.entities)t._initialize(this.engine)}get isInitialized(){return this._isInitialized}_initialize(t){this.isInitialized||(this.engine=t,this.camera._initialize(t),this.onInitialize.call(this,t),this._initializeChildren(),this._logger.debug("Scene.onInitialize",this,t),this.eventDispatcher.emit("initialize",new Ft(t,this)),this._isInitialized=!0)}_activate(t,e){this._logger.debug("Scene.onActivate",this),this.onActivate(t,e)}_deactivate(t,e){this._logger.debug("Scene.onDeactivate",this),this.onDeactivate(t,e)}_preupdate(t,e){this.emit("preupdate",new gt(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new _t(t,e,this)),this.onPostUpdate(t,e)}_predraw(t,e){this.emit("predraw",new ct(t,e,this)),this.onPreDraw(t,e)}_postdraw(t,e){this.emit("postdraw",new dt(t,e,this)),this.onPostDraw(t,e)}update(t,e){let i,s;for(this._preupdate(t,e),this.camera&&this.camera.update(t,e),i=0,s=this._cancelQueue.length;i<s;i++)this.removeTimer(this._cancelQueue[i]);this._cancelQueue.length=0;for(const t of this._timers)t.update(e);this.world.update(Es.Update,e),this._collectActorStats(t),t.input.pointers.dispatchPointerEvents(),this._postupdate(t,e)}draw(t,e){var i;this._predraw(t,e),this.world.update(Es.Draw,e),(null===(i=this.engine)||void 0===i?void 0:i.isDebug)&&this.debugDraw(t),this._postdraw(t,e)}debugDraw(t){this.emit("predebugdraw",new ut(t,this)),this.emit("postdebugdraw",new pt(t,this))}contains(t){return this.actors.indexOf(t)>-1}add(t){this.emit("entityadded",{target:t}),this.world.add(t),t.scene=this,t instanceof $i&&(k(this._timers,t)||this.addTimer(t))}remove(t){t instanceof Hi&&(this.emit("entityremoved",{target:t}),this.world.remove(t)),t instanceof $i&&this.removeTimer(t)}addScreenElement(t){this.add(t)}removeScreenElement(t){this.remove(t)}addTileMap(t){this.world.add(t)}removeTileMap(t){this.world.remove(t)}addTimer(t){return this._timers.push(t),t.scene=this,t}removeTimer(t){const e=this._timers.indexOf(t);return-1!==e&&this._timers.splice(e,1),t}cancelTimer(t){return this._cancelQueue.push(t),t}isTimerActive(t){return this._timers.indexOf(t)>-1&&!t.complete}isCurrentScene(){return!!this.engine&&this.engine.currentScene===this}_collectActorStats(t){const e=this.actors.filter(t=>t instanceof Yi);for(const i of e)t.stats.currFrame.actors.ui++;for(const e of this.actors){t.stats.currFrame.actors.alive++;for(const i of e.children)As(i)?t.stats.currFrame.actors.ui++:t.stats.currFrame.actors.alive++}}}cr([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"ScreenElements now are normal actors with a Transform Coordinate Plane of Screen"})],dr.prototype,"screenElements",null),cr([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.add"})],dr.prototype,"addScreenElement",null),cr([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.remove"})],dr.prototype,"removeScreenElement",null),cr([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.add"})],dr.prototype,"addTileMap",null),cr([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.remove"})],dr.prototype,"removeTileMap",null),function(t){t[t.Protanope=0]="Protanope",t[t.Deuteranope=1]="Deuteranope",t[t.Tritanope=2]="Tritanope"}(sr||(sr={}));class ur{constructor(t,e=!1,i=sr.Protanope){this.engine=t,this.simulate=e,this.colorMode=i,this._vertexShader="attribute vec2 a_position;attribute vec2 a_texCoord;uniform vec2 u_resolution;varying vec2 v_texCoord;void main() {vec2 zeroToOne = a_position / u_resolution;vec2 zeroToTwo = zeroToOne * 2.0;vec2 clipSpace = zeroToTwo - 1.0;gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);v_texCoord = a_texCoord;}",this._fragmentShader="precision mediump float;uniform sampler2D u_image;varying vec2 v_texCoord;void main() {vec4 o = texture2D(u_image, v_texCoord);float L = (17.8824 * o.r) + (43.5161 * o.g) + (4.11935 * o.b);float M = (3.45565 * o.r) + (27.1554 * o.g) + (3.86714 * o.b);float S = (0.0299566 * o.r) + (0.184309 * o.g) + (1.46709 * o.b);//MODE CODE//vec4 error;error.r = (0.0809444479 * l) + (-0.130504409 * m) + (0.116721066 * s);error.g = (-0.0102485335 * l) + (0.0540193266 * m) + (-0.113614708 * s);error.b = (-0.000365296938 * l) + (-0.00412161469 * m) + (0.693511405 * s);error.a = 1.0;vec4 diff = o - error;vec4 correction;correction.r = 0.0;correction.g = (diff.r * 0.7) + (diff.g * 1.0);correction.b = (diff.r * 0.7) + (diff.b * 1.0);correction = o + correction;correction.a = o.a;//SIMULATE//}",this._internalCanvas=document.createElement("canvas"),this._internalCanvas.width=t.drawWidth,this._internalCanvas.height=t.drawHeight,this._gl=this._internalCanvas.getContext("webgl",{preserveDrawingBuffer:!0}),this._program=this._gl.createProgram();const s=this._getShader("Fragment",this._getFragmentShaderByMode(i)),r=this._getShader("Vertex",this._vertexShader);this._gl.attachShader(this._program,r),this._gl.attachShader(this._program,s),this._gl.linkProgram(this._program),this._gl.getProgramParameter(this._program,this._gl.LINK_STATUS)||_.getInstance().error("Unable to link shader program!"),this._gl.useProgram(this._program)}_getFragmentShaderByMode(t){let e="";return t===sr.Protanope?e="float l = 0.0 * L + 2.02344 * M + -2.52581 * S;float m = 0.0 * L + 1.0 * M + 0.0 * S;float s = 0.0 * L + 0.0 * M + 1.0 * S;":t===sr.Deuteranope?e="float l = 1.0 * L + 0.0 * M + 0.0 * S;float m = 0.494207 * L + 0.0 * M + 1.24827 * S;float s = 0.0 * L + 0.0 * M + 1.0 * S;":t===sr.Tritanope&&(e="float l = 1.0 * L + 0.0 * M + 0.0 * S;float m = 0.0 * L + 1.0 * M + 0.0 * S;float s = -0.395913 * L + 0.801109 * M + 0.0 * S;"),this.simulate?this._fragmentShader=this._fragmentShader.replace("//SIMULATE//","gl_FragColor = error.rgba;"):this._fragmentShader=this._fragmentShader.replace("//SIMULATE//","gl_FragColor = correction.rgba;"),this._fragmentShader.replace("//MODE CODE//",e)}_setRectangle(t,e,i,s){const r=t,n=t+i,o=e,a=e+s;this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array([r,o,n,o,r,a,r,a,n,o,n,a]),this._gl.STATIC_DRAW)}_getShader(t,e){let i;return"Fragment"===t?i=this._gl.createShader(this._gl.FRAGMENT_SHADER):"Vertex"===t?i=this._gl.createShader(this._gl.VERTEX_SHADER):_.getInstance().error("Error unknown shader type",t),this._gl.shaderSource(i,e),this._gl.compileShader(i),this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS)?i:(_.getInstance().error("Unable to compile shader!",this._gl.getShaderInfoLog(i)),null)}process(t,e){const i=this._gl.getAttribLocation(this._program,"a_position"),s=this._gl.getAttribLocation(this._program,"a_texCoord"),r=this._gl.createBuffer();this._gl.bindBuffer(this._gl.ARRAY_BUFFER,r),this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),this._gl.STATIC_DRAW),this._gl.enableVertexAttribArray(s),this._gl.vertexAttribPointer(s,2,this._gl.FLOAT,!1,0,0);const n=this._gl.createTexture();this._gl.bindTexture(this._gl.TEXTURE_2D,n),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),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.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,1),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);const o=this._gl.getUniformLocation(this._program,"u_resolution");this._gl.uniform2f(o,this._internalCanvas.width,this._internalCanvas.height);const a=this._gl.createBuffer();this._gl.bindBuffer(this._gl.ARRAY_BUFFER,a),this._gl.enableVertexAttribArray(i),this._gl.vertexAttribPointer(i,2,this._gl.FLOAT,!1,0,0),this._setRectangle(0,0,t.width,t.height),this._gl.drawArrays(this._gl.TRIANGLES,0,6);const h=new Uint8Array(t.width*t.height*4);this._gl.readPixels(0,0,t.width,t.height,this._gl.RGBA,this._gl.UNSIGNED_BYTE,h),t.data.set(h),e.putImageData(t,0,0)}}class pr{constructor(t){this._engine=t}correct(t){this._engine.postProcessors.push(new ur(this._engine,!1,t))}simulate(t){this._engine.postProcessors.push(new ur(this._engine,!0,t))}}class gr{constructor(t){this.stats={currFrame:new _r,prevFrame:new _r},this.filter={useFilter:!1,nameQuery:"",ids:[]},this.entity={showAll:!1,showId:!0,showName:!1},this.transform={showAll:!1,showPosition:!1,positionColor:Q.Yellow,showScale:!1,scaleColor:Q.Green,showRotation:!1,rotationColor:Q.Blue},this.graphics={showAll:!1,showBounds:!0,boundsColor:Q.Yellow},this.collider={showAll:!1,showBounds:!0,boundsColor:Q.Blue,showOwner:!1,showGeometry:!0,geometryColor:Q.Green},this.physics={showAll:!1,showBroadphaseSpacePartitionDebug:!1,showCollisionNormals:!1,collisionNormalColor:Q.Cyan,showCollisionContacts:!0,collisionContactColor:Q.Red},this.motion={showAll:!1,showVelocity:!1,velocityColor:Q.Yellow,showAcceleration:!1,accelerationColor:Q.Red},this.body={showAll:!1,showCollisionGroup:!1,showCollisionType:!1,showSleeping:!1,showMotion:!1,showMass:!1},this.camera={showAll:!1,showFocus:!1,focusColor:Q.Red,showZoom:!1},this._engine=t,this.colorBlindMode=new pr(this._engine)}}class _r{constructor(){this._id=0,this._delta=0,this._fps=0,this._actorStats={alive:0,killed:0,ui:0,get remaining(){return this.alive-this.killed},get total(){return this.remaining+this.ui}},this._durationStats={update:0,draw:0,get total(){return this.update+this.draw}},this._physicsStats=new fr,this._graphicsStats={drawCalls:0,drawnImages:0}}reset(t){t?(this.id=t.id,this.delta=t.delta,this.fps=t.fps,this.actors.alive=t.actors.alive,this.actors.killed=t.actors.killed,this.actors.ui=t.actors.ui,this.duration.update=t.duration.update,this.duration.draw=t.duration.draw,this._physicsStats.reset(t.physics),this.graphics.drawCalls=t.graphics.drawCalls,this.graphics.drawnImages=t.graphics.drawnImages):(this.id=this.delta=this.fps=0,this.actors.alive=this.actors.killed=this.actors.ui=0,this.duration.update=this.duration.draw=0,this._physicsStats.reset(),this.graphics.drawnImages=this.graphics.drawCalls=0)}clone(){const t=new _r;return t.reset(this),t}get id(){return this._id}set id(t){this._id=t}get delta(){return this._delta}set delta(t){this._delta=t}get fps(){return this._fps}set fps(t){this._fps=t}get actors(){return this._actorStats}get duration(){return this._durationStats}get physics(){return this._physicsStats}get graphics(){return this._graphicsStats}}class fr{constructor(){this._pairs=0,this._collisions=0,this._contacts=new Map,this._fastBodies=0,this._fastBodyCollisions=0,this._broadphase=0,this._narrowphase=0}reset(t){t?(this.pairs=t.pairs,this.collisions=t.collisions,this.contacts=t.contacts,this.fastBodies=t.fastBodies,this.fastBodyCollisions=t.fastBodyCollisions,this.broadphase=t.broadphase,this.narrowphase=t.narrowphase):(this.pairs=this.collisions=this.fastBodies=0,this.fastBodyCollisions=this.broadphase=this.narrowphase=0,this.contacts.clear())}clone(){const t=new fr;return t.reset(this),t}get pairs(){return this._pairs}set pairs(t){this._pairs=t}get collisions(){return this._collisions}set collisions(t){this._collisions=t}get contacts(){return this._contacts}set contacts(t){this._contacts=t}get fastBodies(){return this._fastBodies}set fastBodies(t){this._fastBodies=t}get fastBodyCollisions(){return this._fastBodyCollisions}set fastBodyCollisions(t){this._fastBodyCollisions=t}get broadphase(){return this._broadphase}set broadphase(t){this._broadphase=t}get narrowphase(){return this._narrowphase}set narrowphase(t){this._narrowphase=t}}!function(t){t.Num0="Numpad0",t.Num1="Numpad1",t.Num2="Numpad2",t.Num3="Numpad3",t.Num4="Numpad4",t.Num5="Numpad5",t.Num6="Numpad6",t.Num7="Numpad7",t.Num8="Numpad8",t.Num9="Numpad9",t.NumAdd="NumpadAdd",t.NumSubtract="NumpadSubtract",t.NumMultiply="NumpadMultiply",t.NumDivide="NumpadDivide",t.NumDecimal="NumpadDecimal",t.Numpad0="Numpad0",t.Numpad1="Numpad1",t.Numpad2="Numpad2",t.Numpad3="Numpad3",t.Numpad4="Numpad4",t.Numpad5="Numpad5",t.Numpad6="Numpad6",t.Numpad7="Numpad7",t.Numpad8="Numpad8",t.Numpad9="Numpad9",t.NumpadAdd="NumpadAdd",t.NumpadSubtract="NumpadSubtract",t.NumpadMultiply="NumpadMultiply",t.NumpadDivide="NumpadDivide",t.NumpadDecimal="NumpadDecimal",t.NumLock="NumLock",t.ShiftLeft="ShiftLeft",t.ShiftRight="ShiftRight",t.AltLeft="AltLeft",t.AltRight="AltRight",t.Key0="Digit0",t.Key1="Digit1",t.Key2="Digit2",t.Key3="Digit3",t.Key4="Digit4",t.Key5="Digit5",t.Key6="Digit6",t.Key7="Digit7",t.Key8="Digit8",t.Key9="Digit9",t.Digit0="Digit0",t.Digit1="Digit1",t.Digit2="Digit2",t.Digit3="Digit3",t.Digit4="Digit4",t.Digit5="Digit5",t.Digit6="Digit6",t.Digit7="Digit7",t.Digit8="Digit8",t.Digit9="Digit9",t.A="KeyA",t.B="KeyB",t.C="KeyC",t.D="KeyD",t.E="KeyE",t.F="KeyF",t.G="KeyG",t.H="KeyH",t.I="KeyI",t.J="KeyJ",t.K="KeyK",t.L="KeyL",t.M="KeyM",t.N="KeyN",t.O="KeyO",t.P="KeyP",t.Q="KeyQ",t.R="KeyR",t.S="KeyS",t.T="KeyT",t.U="KeyU",t.V="KeyV",t.W="KeyW",t.X="KeyX",t.Y="KeyY",t.Z="KeyZ",t.KeyA="KeyA",t.KeyB="KeyB",t.KeyC="KeyC",t.KeyD="KeyD",t.KeyE="KeyE",t.KeyF="KeyF",t.KeyG="KeyG",t.KeyH="KeyH",t.KeyI="KeyI",t.KeyJ="KeyJ",t.KeyK="KeyK",t.KeyL="KeyL",t.KeyM="KeyM",t.KeyN="KeyN",t.KeyO="KeyO",t.KeyP="KeyP",t.KeyQ="KeyQ",t.KeyR="KeyR",t.KeyS="KeyS",t.KeyT="KeyT",t.KeyU="KeyU",t.KeyV="KeyV",t.KeyW="KeyW",t.KeyX="KeyX",t.KeyY="KeyY",t.KeyZ="KeyZ",t.Semicolon="Semicolon",t.Quote="Quote",t.Comma="Comma",t.Minus="Minus",t.Period="Period",t.Slash="Slash",t.Equal="Equal",t.BracketLeft="BracketLeft",t.Backslash="Backslash",t.BracketRight="BracketRight",t.Backquote="Backquote",t.Up="ArrowUp",t.Down="ArrowDown",t.Left="ArrowLeft",t.Right="ArrowRight",t.ArrowUp="ArrowUp",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.Space="Space",t.Esc="Escape",t.Escape="Escape"}(rr||(rr={}));class mr extends rt{constructor(t,e,i){super(),this.key=t,this.value=e,this.originalEvent=i}}class wr extends Wt{constructor(){super(),this._keys=[],this._keysUp=[],this._keysDown=[]}on(t,e){super.on(t,e)}init(t){if(!t)try{const e=()=>{};window.top.addEventListener("blur",e),window.top.removeEventListener("blur",e),t=window.top}catch(e){t=window,_.getInstance().warn("Failed to bind to keyboard events to top frame. If you are trying to embed Excalibur in a cross-origin iframe, keyboard events will not fire.")}t.addEventListener("blur",()=>{this._keys.length=0}),t.addEventListener("keyup",t=>{const e=t.code,i=this._keys.indexOf(e);this._keys.splice(i,1),this._keysUp.push(e);const s=new mr(e,t.key,t);this.eventDispatcher.emit("up",s),this.eventDispatcher.emit("release",s)}),t.addEventListener("keydown",t=>{const e=t.code;if(-1===this._keys.indexOf(e)){this._keys.push(e),this._keysDown.push(e);const i=new mr(e,t.key,t);this.eventDispatcher.emit("down",i),this.eventDispatcher.emit("press",i)}})}update(){this._keysDown.length=0,this._keysUp.length=0;for(let t=0;t<this._keys.length;t++)this.eventDispatcher.emit("hold",new mr(this._keys[t]))}getKeys(){return this._keys}wasPressed(t){return this._keysDown.indexOf(t)>-1}isHeld(t){return this._keys.indexOf(t)>-1}wasReleased(t){return this._keysUp.indexOf(t)>-1}}!function(t){t.Touch="Touch",t.Mouse="Mouse",t.Pen="Pen",t.Unknown="Unknown"}(nr||(nr={})),function(t){t.Canvas="Canvas",t.Document="Document"}(or||(or={}));class yr extends Wt{constructor(){super(),this.id=yr._MAX_ID++,this._isDown=!1,this._wasDown=!1,this._actorsUnderPointer={length:0},this._actors=[],this._actorsLastFrame=[],this._actorsNoLongerUnderPointer=[],this._actorSortingFcn=(t,e)=>t.z===e.z?e.id-t.id:e.z-t.z,this.lastPagePos=null,this.lastScreenPos=null,this.lastWorldPos=null,this.dragTarget=null,this.on("move",this._onPointerMove),this.on("down",this._onPointerDown),this.on("up",this._onPointerUp)}get isDragging(){return this._isDown}get isDragStart(){return!this._wasDown&&this._isDown}get isDragEnd(){return this._wasDown&&!this._isDown}get hasActorsUnderPointer(){return!!this._actorsUnderPointer.length}on(t,e){super.on(t,e)}once(t,e){super.once(t,e)}off(t,e){super.off(t,e)}update(){this._wasDown&&!this._isDown?this._wasDown=!1:!this._wasDown&&this._isDown&&(this._wasDown=!0),this._actorsLastFrame=[...this._actors],this._actorsNoLongerUnderPointer=[]}addActorUnderPointer(t){this.isActorAliveUnderPointer(t)||(this._actorsUnderPointer[t.id]=t,this._actorsUnderPointer.length+=1,this._actors.push(t)),this._actors.sort(this._actorSortingFcn)}removeActorUnderPointer(t){this.isActorAliveUnderPointer(t)&&(delete this._actorsUnderPointer[t.id],this._actorsUnderPointer.length-=1,B(t,this._actors),this._actorsNoLongerUnderPointer.push(t))}getActorsUnderPointer(){return this._actors}getActorsUnderPointerLastFrame(){return this._actorsLastFrame}getActorsForEvents(){return this._actors.concat(this._actorsLastFrame).filter((t,e,i)=>i.indexOf(t)===e).sort(this._actorSortingFcn)}checkActorUnderPointer(t){return!!this.lastWorldPos&&t.contains(this.lastWorldPos.x,this.lastWorldPos.y,!As(t))}wasActorUnderPointer(t){return this._actorsLastFrame.indexOf(t)>-1}isActorAliveUnderPointer(t){return!(t.isKilled()||!t.scene||!this._actorsUnderPointer.hasOwnProperty(t.id.toString()))}_onPointerMove(t){this.lastPagePos=new X(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new X(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new X(t.worldPos.x,t.worldPos.y)}_onPointerDown(t){this.lastPagePos=new X(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new X(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new X(t.worldPos.x,t.worldPos.y),this._isDown=!0}_onPointerUp(t){this._isDown=!1,this.dragTarget=null}}yr._MAX_ID=0,function(t){t[t.NoButton=-1]="NoButton",t[t.Left=0]="Left",t[t.Middle=1]="Middle",t[t.Right=2]="Right",t[t.Unknown=3]="Unknown"}(ar||(ar={})),function(t){t.Left="Left",t.Middle="Middle",t.Right="Right",t.Unknown="Unknown",t.NoButton="NoButton"}(hr||(hr={})),function(t){t.Pixel="Pixel",t.Line="Line",t.Page="Page"}(lr||(lr={}));class vr extends rt{constructor(t,e,i,s,r,n){super(),this.coordinates=t,this.pointer=e,this.index=i,this.pointerType=s,this.button=r,this.ev=n,this._canceled=!1}get name(){return this._name}get worldPos(){return this.coordinates.worldPos.clone()}get pagePos(){return this.coordinates.pagePos.clone()}get screenPos(){return this.coordinates.screenPos.clone()}get pos(){return this.coordinates.worldPos.clone()}cancel(){this._canceled=!0}isCanceled(){return this._canceled}propagate(t){this.doAction(t),this.bubbles&&!this.isCanceled()&&t.parent&&this.propagate(t.parent)}doAction(t){t&&(this._onActionStart(t),t.emit(this._name,this),this._onActionEnd(t))}_onActionStart(t){}_onActionEnd(t){}}class xr{constructor(t){this._pointerEventType=t}create(t,e,i,s,r,n){return new this._pointerEventType(t,e,i,s,r,n)}}class br extends vr{}class Cr extends vr{constructor(){super(...arguments),this._name="pointerup"}_onActionEnd(t){this.pointer.isDragEnd&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragend",this)}}class Ar extends vr{constructor(){super(...arguments),this._name="pointerdown"}_onActionEnd(t){this.pointer.isDragStart&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragstart",this)}}class Sr extends vr{constructor(){super(...arguments),this._name="pointermove"}propagate(t){this.pointer.isActorAliveUnderPointer(t)&&(this.doAction(t),this.bubbles&&!this.isCanceled()&&t.parent&&this.propagate(t.parent))}_onActionStart(t){t.capturePointer.captureMoveEvents&&this.pointer.isDragging&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragmove",this)}}class Pr extends vr{constructor(){super(...arguments),this._name="pointerenter"}_onActionStart(t){t.capturePointer.captureMoveEvents}_onActionEnd(t){this.pointer.isDragging&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragenter",this)}}class Er extends vr{constructor(){super(...arguments),this._name="pointerleave"}_onActionStart(t){t.capturePointer.captureMoveEvents}_onActionEnd(t){this.pointer.isDragging&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragleave",this)}}class Tr extends vr{constructor(){super(...arguments),this._name="pointercancel"}}class Rr extends rt{constructor(t,e,i,s,r,n,o,a,h,l,c,d){super(),this.x=t,this.y=e,this.pageX=i,this.pageY=s,this.screenX=r,this.screenY=n,this.index=o,this.deltaX=a,this.deltaY=h,this.deltaZ=l,this.deltaMode=c,this.ev=d,this._isCanceled=!1}cancel(){this._isCanceled=!0}isCanceled(){return this._isCanceled}}function Dr(t,e,i,s,r,n,o){let a;switch(t){case"up":a=new xr(Cr);break;case"down":a=new xr(Ar);break;case"move":a=new xr(Sr);break;case"cancel":a=new xr(Tr);break;case"enter":a=new xr(Pr);break;case"leave":a=new xr(Er)}return a.create(e,i,s,r,n,o)}class Mr{constructor(t,e,i){this.worldPos=t,this.pagePos=e,this.screenPos=i}static fromPagePosition(t,e,i){let s,r,n,o;3===arguments.length?(s=t,r=e,n=new X(s,r),o=i):(n=t,s=n.x,r=n.y,o=e);const a=o.screen.pageToScreenCoordinates(n),h=o.screen.screenToWorldCoordinates(a);return new Mr(h,n,a)}}class Br extends Wt{constructor(t){super(),this._pointerDown=[],this._pointerUp=[],this._pointerMove=[],this._pointerCancel=[],this._wheel=[],this._pointers=[],this._activePointers=[],this._engine=t,this._pointers.push(new yr),this._activePointers=[-1],this.primary=this._pointers[0]}on(t,e){super.on(t,e)}init(t){(t=t||this._engine.canvas).addEventListener("touchstart",this._handleTouchEvent("down",this._pointerDown)),t.addEventListener("touchend",this._handleTouchEvent("up",this._pointerUp)),t.addEventListener("touchmove",this._handleTouchEvent("move",this._pointerMove)),t.addEventListener("touchcancel",this._handleTouchEvent("cancel",this._pointerCancel)),window.PointerEvent?(this._engine.canvas.style.touchAction="none",t.addEventListener("pointerdown",this._handlePointerEvent("down",this._pointerDown)),t.addEventListener("pointerup",this._handlePointerEvent("up",this._pointerUp)),t.addEventListener("pointermove",this._handlePointerEvent("move",this._pointerMove)),t.addEventListener("pointercancel",this._handlePointerEvent("cancel",this._pointerCancel))):window.MSPointerEvent?(this._engine.canvas.style.msTouchAction="none",t.addEventListener("MSPointerDown",this._handlePointerEvent("down",this._pointerDown)),t.addEventListener("MSPointerUp",this._handlePointerEvent("up",this._pointerUp)),t.addEventListener("MSPointerMove",this._handlePointerEvent("move",this._pointerMove)),t.addEventListener("MSPointerCancel",this._handlePointerEvent("cancel",this._pointerCancel))):(t.addEventListener("mousedown",this._handleMouseEvent("down",this._pointerDown)),t.addEventListener("mouseup",this._handleMouseEvent("up",this._pointerUp)),t.addEventListener("mousemove",this._handleMouseEvent("move",this._pointerMove)));const e={passive:!(this._engine.pageScrollPreventionMode===on.All||this._engine.pageScrollPreventionMode===on.Canvas)};"onwheel"in document.createElement("div")?t.addEventListener("wheel",this._handleWheelEvent("wheel",this._wheel),e):void 0!==document.onmousewheel?t.addEventListener("mousewheel",this._handleWheelEvent("wheel",this._wheel),e):t.addEventListener("MozMousePixelScroll",this._handleWheelEvent("wheel",this._wheel),e)}triggerEvent(t,e,i=ar.Left,s="mouse",r=0){let n,o=0,a=0;e instanceof Mr?(o=e.pagePos.x,a=e.pagePos.y,n=e):(o=e.x,a=e.y,n=new Mr(e.clone(),e.clone(),e.clone()));const h={pageX:o,pageY:a,pointerId:r,pointerType:s,button:i,preventDefault:()=>{}};switch(t){case"move":this._handlePointerEvent(t,this._pointerMove,n)(h);break;case"down":this._handlePointerEvent(t,this._pointerDown,n)(h);break;case"up":this._handlePointerEvent(t,this._pointerUp,n)(h);break;case"cancel":this._handlePointerEvent(t,this._pointerCancel,n)(h)}for(const t of this._engine.currentScene.actors){const e=t.traits.filter(t=>t instanceof Li)[0];e&&e.update(t,this._engine,1)}this.dispatchPointerEvents(),this.update()}update(){this._pointerUp.length=0,this._pointerDown.length=0,this._pointerMove.length=0,this._pointerCancel.length=0,this._wheel.length=0;for(let t=0;t<this._pointers.length;t++)this._pointers[t].update()}at(t){if(t>=this._pointers.length)for(let e=this._pointers.length-1,i=t;e<i;e++)this._pointers.push(new yr),this._activePointers.push(-1);return this._pointers[t]}count(){return this._pointers.length}checkAndUpdateActorUnderPointer(t){for(const e of this._pointers)e.checkActorUnderPointer(t)?e.addActorUnderPointer(t):e.removeActorUnderPointer(t)}_dispatchWithBubble(t){for(const e of t)for(const t of e.pointer.getActorsForEvents())if(e.isCanceled()||e.propagate(t),!e.bubbles||e.isCanceled())break}_dispatchPointerLeaveEvents(){const t={},e=[];for(const i of this._pointerMove)for(const s of i.pointer.getActorsForEvents())if(!t[i.pointer.id+"+"+s.id]&&i.pointer.wasActorUnderPointer(s)&&!i.pointer.isActorAliveUnderPointer(s)&&!i.isCanceled()){t[i.pointer.id+"+"+s.id]=i;const r=Dr("leave",new Mr(i.worldPos,i.pagePos,i.screenPos),i.pointer,i.index,i.pointerType,i.button,i.ev);r.propagate(s),e.push(r)}return e}_dispatchPointerEnterEvents(){const t={},e=[];for(const i of this._pointerMove)for(const s of i.pointer.getActorsForEvents())if(!t[i.pointer.id]&&!i.pointer.wasActorUnderPointer(s)&&i.pointer.isActorAliveUnderPointer(s)&&!i.isCanceled()){t[i.pointer.id]=i;const r=Dr("enter",new Mr(i.worldPos,i.pagePos,i.screenPos),i.pointer,i.index,i.pointerType,i.button,i.ev);r.propagate(s),e.push(r),i.pointer.isDragging&&(i.pointer.dragTarget=s)}return e}dispatchPointerEvents(){this._dispatchWithBubble(this._pointerDown),this._dispatchWithBubble(this._pointerUp),this._dispatchWithBubble(this._pointerMove),this._dispatchPointerLeaveEvents(),this._dispatchPointerEnterEvents(),this._dispatchWithBubble(this._pointerCancel);for(const t of this._wheel)for(const e of this._pointers[t.index].getActorsUnderPointer())if(this._propagateWheelPointerEvent(e,t),!t.bubbles||t.isCanceled())break}_propagateWheelPointerEvent(t,e){t.emit("pointerwheel",e),e.bubbles&&!e.isCanceled()&&t.parent&&this._propagateWheelPointerEvent(t.parent,e)}_handleMouseEvent(t,e){return i=>{i.preventDefault();const s=this.at(0),r=Mr.fromPagePosition(i.pageX,i.pageY,this._engine),n=Dr(t,r,s,0,nr.Mouse,this._nativeButtonToPointerButton(i.button),i);e.push(n),s.eventDispatcher.emit(t,n)}}_handleTouchEvent(t,e){return i=>{i.preventDefault();for(let s=0,r=i.changedTouches.length;s<r;s++){const r=this._pointers.length>1?this._getPointerIndex(i.changedTouches[s].identifier):0;if(-1===r)continue;const n=this.at(r),o=Mr.fromPagePosition(i.changedTouches[s].pageX,i.changedTouches[s].pageY,this._engine),a=Dr(t,o,n,r,nr.Touch,hr.Unknown,i);e.push(a),n.eventDispatcher.emit(t,a),this.emit(t,a),this._pointers.length>1&&("up"===t?this._activePointers[r]=-1:"down"===t&&(this._activePointers[r]=i.changedTouches[s].identifier))}}}_handlePointerEvent(t,e,i){return s=>{s.preventDefault();const r=this._pointers.length>1?this._getPointerIndex(s.pointerId):0;if(-1===r)return;const n=this.at(r),o=i||Mr.fromPagePosition(s.pageX,s.pageY,this._engine),a=Dr(t,o,n,r,this._stringToPointerType(s.pointerType),this._nativeButtonToPointerButton(s.button),s);e.push(a),n.eventDispatcher.emit(t,a),this.emit(t,a),this._pointers.length>1&&("up"===t?this._activePointers[r]=-1:"down"===t&&(this._activePointers[r]=s.pointerId))}}_handleWheelEvent(t,e){return i=>{(this._engine.pageScrollPreventionMode===on.All||this._engine.pageScrollPreventionMode===on.Canvas&&i.target===this._engine.canvas)&&i.preventDefault();const s=this._engine.screen.pageToScreenCoordinates(q(i.pageX,i.pageY)),r=this._engine.screen.screenToWorldCoordinates(s),n=i.deltaX||i.wheelDeltaX*(-1/40)||0,o=i.deltaY||i.wheelDeltaY*(-1/40)||i.wheelDelta*(-1/40)||i.detail||0,a=i.deltaZ||0;let h=lr.Pixel;i.deltaMode&&(1===i.deltaMode?h=lr.Line:2===i.deltaMode&&(h=lr.Page));const l=new Rr(r.x,r.y,i.pageX,i.pageY,s.x,s.y,0,n,o,a,h,i);e.push(l),this.at(0).eventDispatcher.emit(t,l),this.emit(t,l)}}_getPointerIndex(t){let e;if((e=this._activePointers.indexOf(t))>-1)return e;for(let t=0;t<this._activePointers.length;t++)if(-1===this._activePointers[t])return t;return-1}_nativeButtonToPointerButton(t){switch(t){case ar.NoButton:return hr.NoButton;case ar.Left:return hr.Left;case ar.Middle:return hr.Middle;case ar.Right:return hr.Right;case ar.Unknown:return hr.Unknown;default:return O(t)}}_stringToPointerType(t){switch(t){case"touch":return nr.Touch;case"mouse":return nr.Mouse;case"pen":return nr.Pen;default:return nr.Unknown}}}class kr extends Wt{constructor(){super(),this.enabled=!1,this.supported=!!navigator.getGamepads,this._gamePadTimeStamps=[0,0,0,0],this._oldPads=[],this._pads=[],this._initSuccess=!1,this._navigator=navigator,this._minimumConfiguration=null}init(){this.supported&&(this._initSuccess||(this._oldPads=this._clonePads(this._navigator.getGamepads()),this._oldPads.length&&this._oldPads[0]&&(this._initSuccess=!0)))}setMinimumGamepadConfiguration(t){this._enableAndUpdate(),this._minimumConfiguration=t}_enableAndUpdate(){this.enabled||(this.enabled=!0,this.update())}_isGamepadValid(t){if(!this._minimumConfiguration)return!0;if(!t)return!1;const e=t.axes.filter(t=>void 0!==typeof t).length,i=t.buttons.filter(t=>void 0!==typeof t).length;return e>=this._minimumConfiguration.axis&&i>=this._minimumConfiguration.buttons&&t.connected}on(t,e){this._enableAndUpdate(),super.on(t,e)}off(t,e){this._enableAndUpdate(),super.off(t,e)}update(){if(!this.enabled||!this.supported)return;this.init();const t=this._navigator.getGamepads();for(let e=0;e<t.length;e++){if(!t[e]){const t=this.at(e);t.connected&&this.eventDispatcher.emit("disconnect",new yt(e,t)),t.connected=!1;continue}if(!this.at(e).connected&&this._isGamepadValid(t[e])&&this.eventDispatcher.emit("connect",new wt(e,this.at(e))),this.at(e).connected=!0,t[e].timestamp&&t[e].timestamp===this._gamePadTimeStamps[e])continue;let i,s,r,n,o;for(i in this._gamePadTimeStamps[e]=t[e].timestamp,this.at(e).navigatorGamepad=t[e],Lr)s=Lr[i],"number"==typeof s&&t[e].buttons[s]&&(o=t[e].buttons[s].value,o!==this._oldPads[e].getButton(s)&&(t[e].buttons[s].pressed?(this.at(e).updateButton(s,o),this.at(e).eventDispatcher.emit("button",new vt(s,o,this.at(e)))):this.at(e).updateButton(s,0)));for(r in Ir)n=Ir[r],"number"==typeof n&&(o=t[e].axes[n],o!==this._oldPads[e].getAxes(n)&&(this.at(e).updateAxes(n,o),this.at(e).eventDispatcher.emit("axis",new xt(n,o,this.at(e)))));this._oldPads[e]=this._clonePad(t[e])}}at(t){if(this._enableAndUpdate(),t>=this._pads.length)for(let e=this._pads.length-1,i=t;e<i;e++)this._pads.push(new Fr),this._oldPads.push(new Fr);return this._pads[t]}getValidGamepads(){this._enableAndUpdate();const t=[];for(let e=0;e<this._pads.length;e++)this._isGamepadValid(this.at(e).navigatorGamepad)&&this.at(e).connected&&t.push(this.at(e));return t}count(){return this._pads.filter(t=>t.connected).length}_clonePads(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(this._clonePad(t[i]));return e}_clonePad(t){let e,i;const s=new Fr;if(!t)return s;for(e=0,i=t.buttons.length;e<i;e++)t.buttons[e]&&s.updateButton(e,t.buttons[e].value);for(e=0,i=t.axes.length;e<i;e++)s.updateAxes(e,t.axes[e]);return s}}kr.MinAxisMoveThreshold=.05;class Fr extends Wt{constructor(){super(),this.connected=!1,this._buttons=new Array(16),this._axes=new Array(4);for(let t=0;t<this._buttons.length;t++)this._buttons[t]=0;for(let t=0;t<this._axes.length;t++)this._axes[t]=0}isButtonPressed(t,e=1){return this._buttons[t]>=e}getButton(t){return this._buttons[t]}getAxes(t){const e=this._axes[t];return Math.abs(e)<kr.MinAxisMoveThreshold?0:e}updateButton(t,e){this._buttons[t]=e}updateAxes(t,e){this._axes[t]=e}}var Lr,Ir;!function(t){t[t.Face1=0]="Face1",t[t.Face2=1]="Face2",t[t.Face3=2]="Face3",t[t.Face4=3]="Face4",t[t.LeftBumper=4]="LeftBumper",t[t.RightBumper=5]="RightBumper",t[t.LeftTrigger=6]="LeftTrigger",t[t.RightTrigger=7]="RightTrigger",t[t.Select=8]="Select",t[t.Start=9]="Start",t[t.LeftStick=10]="LeftStick",t[t.RightStick=11]="RightStick",t[t.DpadUp=12]="DpadUp",t[t.DpadDown=13]="DpadDown",t[t.DpadLeft=14]="DpadLeft",t[t.DpadRight=15]="DpadRight"}(Lr||(Lr={})),function(t){t[t.LeftStickX=0]="LeftStickX",t[t.LeftStickY=1]="LeftStickY",t[t.RightStickX=2]="RightStickX",t[t.RightStickY=3]="RightStickY"}(Ir||(Ir={}));class Or{constructor(t){this.nativeComponent=t,this._paused=!1,this._nativeHandlers={}}on(t,e){this._nativeHandlers[t]&&this.off(t,this._nativeHandlers[t]),this._nativeHandlers[t]=this._decorate(e),this.nativeComponent.addEventListener(t,this._nativeHandlers[t])}off(t,e){e||(e=this._nativeHandlers[t]),this.nativeComponent.removeEventListener(t,e),this._nativeHandlers[t]=null}_decorate(t){return e=>{this._paused||t(e)}}pause(){this._paused=!0}resume(){this._paused=!1}clear(){for(const t in this._nativeHandlers)this.off(t)}}class zr{constructor(t,e){this._windowGlobal=t,this._documentGlobal=e,this._windowComponent=new Or(this._windowGlobal),this._documentComponent=new Or(this._documentGlobal)}get window(){return this._windowComponent}get document(){return this._documentComponent}pause(){this.window.pause(),this.document.pause()}resume(){this.window.resume(),this.document.resume()}clear(){this.window.clear(),this.document.clear()}}class Ur{constructor(){this._states=[],this._currentState=this._getDefaultState()}_getDefaultState(){return{opacity:1}}_cloneState(){return{opacity:this._currentState.opacity}}save(){this._states.push(this._currentState),this._currentState=this._cloneState()}restore(){this._currentState=this._states.pop()}get current(){return this._currentState}}class Hr extends Zt{constructor(t){super(t),this._text="",this._dirty=!0,this.alphabet="",this.shadow=null,this.caseInsensitive=!1,this.spacing=0,this._logger=_.getInstance(),this._sprites=[];const{alphabet:e,spriteSheet:i,caseInsensitive:s,spacing:r,shadow:n}=t;this.alphabet=e,this.spriteSheet=i,this.caseInsensitive=null!=s?s:this.caseInsensitive,this.spacing=null!=r?r:this.spacing,this.shadow=null!=n?n:this.shadow,this.spriteSheet.sprites[0].image.ready.then(()=>{this._updateDimensions()})}static fromLegacySpriteFont(t){const e=t.sprites.map(os.fromLegacySprite);return new Hr({alphabet:t.alphabet,spacing:0,caseInsensitive:t.caseInsensitive,spriteSheet:new cs({sprites:e})})}_getCharacterSprites(t){if(!this._dirty)return this._sprites;const e=[],i=this.caseInsensitive?t.toLocaleLowerCase():t,s=this.caseInsensitive?this.alphabet.toLocaleLowerCase():this.alphabet;for(let t=0;t<i.length;t++){const r=i[t];let n=s.indexOf(r);-1===n&&(n=0,this._logger.warn(`SpriteFont - Cannot find letter '${r}' in configured alphabet '${s}'`));const o=this.spriteSheet.sprites[n];o?e.push(o):this._logger.warn(`SpriteFont - Cannot find sprite for '${r}' at index '${n}' in configured SpriteSheet`)}return this._dirty=!1,this._sprites=e}_updateDimensions(){const t=this._getCharacterSprites(this._text);let e=0,i=0;for(const s of t)e+=s.width+this.spacing,i=Math.max(i,s.height);this.width=e,this.height=i}updateText(t){this._text!==t&&(this._dirty=!0,this._text=t,this._updateDimensions())}_preDraw(t,e,i){this._updateDimensions(),super._preDraw(t,e,i)}_drawImage(t,e,i){let s=0;for(const r of this._getCharacterSprites(this._text))r.draw(t,e+s,i),s+=r.width+this.spacing}render(t,e,i,s){this._text!==e&&(this._dirty=!0,this._text=e),this.shadow&&(t.save(),t.translate(this.shadow.offset.x,this.shadow.offset.y),this.draw(t,i,s),t.restore()),this.draw(t,i,s)}clone(){return new Hr({alphabet:this.alphabet,spriteSheet:this.spriteSheet,spacing:this.spacing})}}class Nr{constructor(){this.fontSheet="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAwCAYAAAD+f6R/AAAAAXNSR0IArs4c6QAABcJJREFUeJztnemu7CgMhGE07//KmT9NhrAFVzkQndQntXRP3/bCZkwCSQhCCCGEEEIIIYQQQog/TRz953Ecx/nDGIe/vdNhlc9tIz605Fk/ZmWfsO1hn9Gxuv1KHbvb3iL/VN+d1WORbyr7yR/5b9M4vjNeqko6jPJHq5wGHU151o9J2Udse9hndCxuv0rH7rY3yD/Wdyf13MrnQeDfkZIUSGKM4ff3cWN82pEZuTyQGX2IxeyR63va//8VNCYCq+1yEkLtWyagXv1P1r1H+110gP3PzT4gT8uW/mdQ8mUG8E9DqOz4MS9ICKGbXpS2BpnIrRzYeS96cll08INlCMl2/glzdcfazuuPqQO03lmqrBHsf272Q6NODXj6zzZIJd/LAHYTg3Mays5gBi7ZR27fOgs0yj8rm36DLMFiPgkAdXHKOwUQeMCQ/adSh/qBQrT/tPxbAwA9+DOZEILPAATSuHMgTv7+Auk/df2lHPCZLvMSLJe34LkEQ9PwXF1SRTllMYgvIaflqyVAjLGbsiCDcOK76jflxZ+sINPyROc5071yKWK5CJTV3dMp6+tBlyCtNlhAq/+XbWoBDcRNXYBMzD4VvQygSuPYC2jGGaSSOxXfy3dTUEsanIvNeepm38N/hssSALTPZnAXfwIYRJn2b7UBcw0FKX+nDdAMpm2j9WVnxrUa7TXaVAca/B+TgaAVh6R/rH0P/5m01dt/RLYViJn+w/bhVX2P7f/duqom5qb02pRLCLGIMgBU1wCEEN9BAUCID6MAIMSHUQAQ4sMoAAjxYRQAhPgwd1uB0fuZ7H3cnn2P+9mr/Pe4B8/eB/fwP4eRtci/0f6OfTCPt/9oHwC6G6y19RHZDumxmwzR4eE/s/2Tte/q/+XLdc9DeJ19diesQc/j7Z8fCe4tAS4CxZ7sp7eiJi7HiZmjmOTGJs+93CbS3nP0XIPH3vW8/qz6QPnX2QdsV/1uw/iZYvg8ACeHd28rpPzfNfhL+7vkw/4Ou9s+Onhbv91elpKZ48Dl6bzpwwibHigRArf+Ptk9+L3Y1Q5OB4LgCeSBw1iuB3GeJh1/HrX/zF0A9Mk+u45zMkc3r4rWPomma5+p/514LB+Zo93MErJ1JHxXPzByGa/licRYVKbpeQCoQ6Q8yxuCwJF9IPsoDkHAo/3Tx26cvA4EtJ/n04w8QOq/mrR7ddfLAC5BYFNlVI/0CnOVUflOpvJUQMx9AIMIW/nWDM67/qw0+95v9goBqD9j+72u/KD9U89IbnQbMIR2Zbneh5zUY7Hdk7XIP3UffVb+r+wDYAZLq+1n1+C7y3/ny2r7p5yeByDEh9HzAIQQJwoAQnwYBQAhPowCgBBjoNu3hNxSFACE6INuKvPajPZ4EFEAEKINcybGYzOd247WEd3TgA2jlmjEyrd+j9hvfVbD2PWQ3ZmGlu2HyO8og8eBuNUvNYWoDgMVpwHTJoLWdz1Y+ZYOy5uF7t6PPruZxANrud1lQXkP0jsGz/Yz+vGGMuygFyhSPcJnc1pMnQZElc+cRnoAlxdTvoDuK7puqF7uCQy+3fyFMiA02/vJQHh7DQDogMPTSGFNA56HTzbZ9yAfBOb1Zyo3qGM3MfMZ3f76huXf6xlmAHknMlLNXsBBBvbljIz9Uyz5Y5TzIBLR/qy/rNyrZ8+L/0BZ0m+tgXD0OK5XZxC/9P7I/g4hVFvzXf1/6i5A7+3AlijMPBLMZfCvuAp7A9rY56ApHitmLQc7c8bOv6ftAxlM9Xp35nkEK7nJetBsaMhtAAAuOLQGXwhh2dXQnn1rZ/a42BI3dL7L+jkFAbQddwdA9Ah35yMKhgEgVT46EFh5D4jz+OgavNKxeBCd1wDSJ/97oR8eoJkLi9t9/BDgDHTJ5NE7Dnzechh914OVv9M1K9PCqsfqb88XVg9qN9lm6nG176UPu+zn17GOxuO0vOWEEC/j+LFKTgghlvEfYJaLS+SA2O0AAAAASUVORK5CYII=",this.size=16,this.load()}load(){return this._imageSource=new ns(this.fontSheet),this._imageSource.load().then(()=>{this._spriteSheet=cs.fromImageSource({image:this._imageSource,grid:{rows:3,columns:16,spriteWidth:16,spriteHeight:16}}),this._spriteFont=new Hr({alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,!'&.\"?-()+ ",caseInsensitive:!0,spriteSheet:this._spriteSheet,spacing:-6})})}write(t,e,i){this._imageSource.isLoaded()&&this._spriteFont.render(t,e,i.x,i.y)}}class Wr{constructor(t){this._ex=t,this._debugText=new Nr}drawRect(t,e,i,s){this._ex.__ctx.save(),this._ex.__ctx.strokeStyle="red",this._ex.__ctx.strokeRect(this._ex.snapToPixel?~~t:t,this._ex.snapToPixel?~~e:e,this._ex.snapToPixel?~~i:i,this._ex.snapToPixel?~~s:s),this._ex.__ctx.restore()}drawLine(t,e,i={color:Q.Black}){this._ex.__ctx.save(),this._ex.__ctx.beginPath(),this._ex.__ctx.strokeStyle=i.color.toString(),this._ex.__ctx.moveTo(this._ex.snapToPixel?~~t.x:t.x,this._ex.snapToPixel?~~t.y:t.y),this._ex.__ctx.lineTo(this._ex.snapToPixel?~~e.x:e.x,this._ex.snapToPixel?~~e.y:e.y),this._ex.__ctx.lineWidth=2,this._ex.__ctx.stroke(),this._ex.__ctx.closePath(),this._ex.__ctx.restore()}drawPoint(t,e={color:Q.Black,size:5}){this._ex.__ctx.save(),this._ex.__ctx.beginPath(),this._ex.__ctx.fillStyle=e.color.toString(),this._ex.__ctx.arc(this._ex.snapToPixel?~~t.x:t.x,this._ex.snapToPixel?~~t.y:t.y,e.size,0,2*Math.PI),this._ex.__ctx.fill(),this._ex.__ctx.closePath(),this._ex.__ctx.restore()}drawText(t,e){this._debugText.write(this._ex,t,e)}}class Vr{constructor(t){this.backgroundColor=Q.ExcaliburBlue,this._state=new Ur,this.snapToPixel=!0,this.debug=new Wr(this);const{canvasElement:e,enableTransparency:i,snapToPixel:s,smoothing:r,backgroundColor:n}=t;this.__ctx=e.getContext("2d",{alpha:null==i||i}),this.backgroundColor=null!=n?n:this.backgroundColor,this.snapToPixel=null!=s?s:this.snapToPixel,this.smoothing=null!=r?r:this.smoothing}get width(){return this.__ctx.canvas.width}get height(){return this.__ctx.canvas.height}get opacity(){return this._state.current.opacity}set opacity(t){this._state.current.opacity=t}get smoothing(){return this.__ctx.imageSmoothingEnabled}set smoothing(t){this.__ctx.imageSmoothingEnabled=t}resetTransform(){this.__ctx.resetTransform()}updateViewport(){}drawImage(t,e,i,s,r,n,o,a,h){if(0===s||0===r)return;if(0===a||0===h)return;if(0===t.width||0===t.height)return;this.__ctx.globalAlpha=this.opacity;const l=[t,e,i,s,r,n,o,a,h].filter(t=>void 0!==t).map(t=>"number"==typeof t&&this.snapToPixel?~~t:t);this.__ctx.drawImage.apply(this.__ctx,l),Xs.DrawCallCount++,Xs.DrawnImagesCount=1}drawLine(t,e,i,s=1){this.__ctx.save(),this.__ctx.beginPath(),this.__ctx.strokeStyle=i.toString(),this.__ctx.moveTo(this.snapToPixel?~~t.x:t.x,this.snapToPixel?~~t.y:t.y),this.__ctx.lineTo(this.snapToPixel?~~e.x:e.x,this.snapToPixel?~~e.y:e.y),this.__ctx.lineWidth=s,this.__ctx.stroke(),this.__ctx.closePath(),this.__ctx.restore()}drawRectangle(t,e,i,s){this.__ctx.save(),this.__ctx.fillStyle=s.toString(),this.__ctx.fillRect(this.snapToPixel?~~t.x:t.x,this.snapToPixel?~~t.y:t.y,this.snapToPixel?~~e:e,this.snapToPixel?~~i:i),this.__ctx.restore()}drawCircle(t,e,i){this.__ctx.save(),this.__ctx.beginPath(),this.__ctx.fillStyle=i.toString(),this.__ctx.arc(this.snapToPixel?~~t.x:t.x,this.snapToPixel?~~t.y:t.y,e,0,2*Math.PI),this.__ctx.fill(),this.__ctx.closePath(),this.__ctx.restore()}save(){this.__ctx.save()}restore(){this.__ctx.restore()}translate(t,e){this.__ctx.translate(this.snapToPixel?~~t:t,this.snapToPixel?~~e:e)}rotate(t){this.__ctx.rotate(t)}scale(t,e){this.__ctx.scale(t,e)}clear(){this.__ctx.clearRect(0,0,this.width,this.height),this.__ctx.fillStyle=this.backgroundColor.toString(),this.__ctx.fillRect(0,0,this.width,this.height),Xs.clear()}flush(){}}class Gr{constructor(){this._transforms=[],this._currentTransform=Ve.identity()}save(){this._transforms.push(this._currentTransform),this._currentTransform=this._currentTransform.clone()}restore(){this._currentTransform=this._transforms.pop()}translate(t,e){return this._currentTransform.translate(t,e)}rotate(t){return this._currentTransform.rotate(t)}scale(t,e){return this._currentTransform.scale(t,e)}set current(t){this._currentTransform=t}get current(){return this._currentTransform}}class jr{constructor(t,e,i){this._gl=t,this._vertexSource=e,this._fragmentSource=i,this.program=null,this.uniforms={},this.attributes={},this.layout=[],this.compile(t)}_createProgram(t,e,i){const s=t.createProgram();if(null===s)throw Error("Could not create graphics shader program");t.attachShader(s,e),t.attachShader(s,i),t.linkProgram(s);if(!t.getProgramParameter(s,t.LINK_STATUS))throw Error(`Could not link the program: [${t.getProgramInfoLog(s)}]`);return s}_compileShader(t,e,i){const s=t.createShader(i);if(null===s)throw Error(`Could not build shader: [${e}]`);t.shaderSource(s,e),t.compileShader(s);if(!t.getShaderParameter(s,t.COMPILE_STATUS))throw Error(`Could not compile shader [${t.getShaderInfoLog(s)}]`);return s}compile(t){const e=this._compileShader(t,this._vertexSource,t.VERTEX_SHADER),i=this._compileShader(t,this._fragmentSource,t.FRAGMENT_SHADER),s=this._createProgram(t,e,i);return this.program=s}addUniformMatrix(t,e){if(!e)throw Error(`Shader Uniform Matrix '${t}' was set to null or undefined`);const i=this._gl;this.uniforms[t]={name:t,type:"matrix",location:i.getUniformLocation(this.program,t),data:e}}addUniformIntegerArray(t,e){if(!e)throw Error(`Shader Uniform Integery Array '${t}' was set to null or undefined`);const i=this._gl;this.uniforms[t]={name:t,type:"numbers",location:i.getUniformLocation(this.program,t),data:e}}addAttribute(t,e,i,s=!1){const r=this._gl.getAttribLocation(this.program,t);this.attributes[t]={name:t,size:e,glType:i,normalized:s,location:r},this.layout.push(this.attributes[t])}get vertexAttributeSize(){let t=0;for(const e of this.layout)t+=e.size;return t}get totalVertexSizeBytes(){let t=0;for(const e of this.layout){let i=1;switch(e.glType){case this._gl.FLOAT:i=4;break;default:i=1}t+=i*e.size}return t}getAttributeSize(t){let e=1;switch(this.attributes[t].glType){case this._gl.FLOAT:e=4;break;default:e=1}return e*this.attributes[t].size}use(){const t=this._gl;t.useProgram(this.program);let e=0;for(const i of this.layout)t.vertexAttribPointer(i.location,i.size,i.glType,i.normalized,this.totalVertexSizeBytes,e),t.enableVertexAttribArray(i.location),e+=this.getAttributeSize(i.name);for(const e in this.uniforms){const i=this.uniforms[e];switch(i.type){case"matrix":t.uniformMatrix4fv(i.location,!1,i.data);break;case"numbers":t.uniform1iv(i.location,i.data)}}}}class Xr{constructor(t){this.max=t,this._pool=void 0,this.commands=[]}isFull(){return this.commands.length>=this.max}canAdd(){return!this.isFull()}add(t){this.commands.push(t)}dispose(){return this.commands.length=0,this}}class qr{constructor(t,e,i=100){this.builder=t,this.recycler=e,this.maxObjects=i,this.totalAllocations=0,this.index=0,this.objects=[],this._logger=_.getInstance()}using(t){const e=t(this);return e?this.done(...e):this.done()}borrow(t){t(this.get()),this.index--}get(...t){if(this.index===this.maxObjects&&(this._logger.warn("Max pooled objects reached, possible memory leak? Doubling"),this.maxObjects=2*this.maxObjects),this.objects[this.index])return this.recycler(this.objects[this.index++],...t);{this.totalAllocations++;const e=this.objects[this.index++]=this.builder(...t);return e._pool=this,e}}done(...t){this.index=0;for(const e of t){const t=this.objects.indexOf(e);this.objects[t]=this.builder(),this.objects[t]._pool=this,this.totalAllocations++,e._pool=void 0}return t}}class Kr{constructor(t){var e,i,s;this.priority=0,this._buffer=null,this._maxCommandsPerBatch=2e3,this._batches=[],this._gl=t.gl;const r=t.command;this._verticesPerCommand=null!==(e=null==t?void 0:t.verticesPerCommand)&&void 0!==e?e:1,this._maxCommandsPerBatch=null!==(i=null==t?void 0:t.maxCommandsPerBatch)&&void 0!==i?i:this._maxCommandsPerBatch;const n=null!==(s=null==t?void 0:t.batchFactory)&&void 0!==s?s:()=>new Xr(this._maxCommandsPerBatch);this.commands=new qr(()=>new r,t=>t.dispose(),this._maxCommandsPerBatch),this._batchPool=new qr(n,t=>t.dispose(),100)}init(){const t=this._gl;this.shader=this.buildShader(t),this._vertices=new Float32Array(this.shader.vertexAttributeSize*this._verticesPerCommand*this._maxCommandsPerBatch),this._buffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._buffer),t.bufferData(t.ARRAY_BUFFER,this._vertices,t.DYNAMIC_DRAW)}get vertexSize(){return this.shader.vertexAttributeSize}addCommand(t){0===this._batches.length&&this._batches.push(this._batchPool.get());const e=this._batches[this._batches.length-1];if(e.canAdd())e.add(t);else{const e=this._batchPool.get();e.add(t),this._batches.push(e)}}render(){const t=this._gl;t.bindBuffer(t.ARRAY_BUFFER,this._buffer),this.shader.use();let e=0,i=0;for(const s of this._batches){const r=this.buildBatchVertices(this._vertices,s);t.bufferSubData(t.ARRAY_BUFFER,0,this._vertices),this.renderBatch(t,s,r),i+=s.commands.length,e++}this.commands.done(),this._batchPool.done(),this._batches.length=0,Xs.DrawCallCount+=e,Xs.DrawnImagesCount+=i}}class Zr{constructor(){this.color=Q.Black,this.start=X.Zero,this.end=X.Zero}dispose(){return this.color.r=0,this.color.g=0,this.color.b=0,this.color.a=1,this.start.setTo(0,0),this.end.setTo(0,0),this}}class Yr extends Kr{constructor(t,e){super({gl:t,command:Zr,verticesPerCommand:2}),this._contextInfo=e,this.init()}buildShader(t){const e=new jr(t,"attribute vec4 a_position;\r\nattribute vec4 a_color;\r\n\r\nvarying lowp vec4 v_color;\r\n\r\nuniform mat4 u_matrix;\r\n\r\n\r\nvoid main() {\r\n // Set the vertex position using the ortho transform matrix\r\n gl_Position = u_matrix * a_position;\r\n\r\n // Passthrough the color\r\n v_color = a_color;\r\n}","precision mediump float;\r\n\r\n// Color\r\nvarying lowp vec4 v_color;\r\n\r\n\r\nvoid main() {\r\n gl_FragColor = v_color;\r\n}");return e.addAttribute("a_position",2,t.FLOAT),e.addAttribute("a_color",4,t.FLOAT),e.addUniformMatrix("u_matrix",this._contextInfo.matrix.data),e}addLine(t,e,i){const s=this.commands.get();s.start=this._contextInfo.transform.current.multv(t),s.end=this._contextInfo.transform.current.multv(e),s.color.r=i.r,s.color.g=i.g,s.color.b=i.b,s.color.a=s.color.a*this._contextInfo.state.current.opacity,this.addCommand(s)}buildBatchVertices(t,e){let i=0;for(const s of e.commands)t[i++]=s.start.x,t[i++]=s.start.y,t[i++]=s.color.r/255,t[i++]=s.color.g/255,t[i++]=s.color.b/255,t[i++]=s.color.a,t[i++]=s.end.x,t[i++]=s.end.y,t[i++]=s.color.r/255,t[i++]=s.color.g/255,t[i++]=s.color.b/255,t[i++]=s.color.a;return i/this.vertexSize}renderBatch(t,e,i){t.drawArrays(t.LINES,0,i)}}var Qr;!function(t){t.Image="image",t.Line="line",t.Rectangle="rectangle",t.Circle="circle"}(Qr||(Qr={}));class $r{constructor(t,e,i,s,r,n,o,a,h){this._pool=void 0,this.snapToPixel=!0,this.type=Qr.Image,this.opacity=1,this.width=0,this.height=0,this.dest=[0,0],this.view=[0,0,0,0],this._geom=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],this.init(t,e,i,s,r,n,o,a,h)}init(t,e,i,s,r,n,o,a,h){this.type=Qr.Image,this.image=t,this.width=(null==t?void 0:t.width)||s||0,this.height=(null==t?void 0:t.height)||r||0,this.view=[0,0,null!=s?s:null==t?void 0:t.width,null!=r?r:null==t?void 0:t.height],this.dest=[e,i],void 0!==n&&void 0!==o&&void 0!==a&&void 0!==h&&(this.view=[e,i,null!=s?s:null==t?void 0:t.width,null!=r?r:null==t?void 0:t.height],this.dest=[n,o],this.width=a,this.height=h);let l=0;if(this._geom[l++]=[this.dest[0],this.dest[1]],this._geom[l++]=[this.dest[0],this.dest[1]+this.height],this._geom[l++]=[this.dest[0]+this.width,this.dest[1]],this._geom[l++]=[this.dest[0]+this.width,this.dest[1]],this._geom[l++]=[this.dest[0],this.dest[1]+this.height],this._geom[l++]=[this.dest[0]+this.width,this.dest[1]+this.height],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}initRect(t,e,i,s){this.type=Qr.Rectangle,this.color=t,this.width=i,this.height=s;let r=0;if(this._geom[r++]=[e.x,e.y],this._geom[r++]=[e.x,e.y+this.height],this._geom[r++]=[e.x+this.width,e.y],this._geom[r++]=[e.x+this.width,e.y],this._geom[r++]=[e.x,e.y+this.height],this._geom[r++]=[e.x+this.width,e.y+this.height],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}initLine(t,e,i,s){this.type=Qr.Line,this.color=t;const r=i.sub(e).normalize().perpendicular(),n=s/2,o=r.scale(n).add(e),a=r.scale(-n).add(e),h=r.scale(n).add(i),l=r.scale(-n).add(i);let c=0;if(this._geom[c++]=[o.x,o.y],this._geom[c++]=[h.x,h.y],this._geom[c++]=[a.x,a.y],this._geom[c++]=[a.x,a.y],this._geom[c++]=[h.x,h.y],this._geom[c++]=[l.x,l.y],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}initCircle(t,e,i){this.type=Qr.Circle,this.color=i;const s=t.add(q(-e,-e)),r=t.add(q(e,-e)),n=t.add(q(e,e)),o=t.add(q(-e,e));let a=0;if(this._geom[a++]=[s.x,s.y],this._geom[a++]=[r.x,r.y],this._geom[a++]=[o.x,o.y],this._geom[a++]=[o.x,o.y],this._geom[a++]=[r.x,r.y],this._geom[a++]=[n.x,n.y],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}dispose(){this.image=null,this.width=0,this.height=0,this.view=[0,0,0,0],this.dest=[0,0];let t=0;return this._geom[t++]=[this.dest[0],this.dest[1]],this._geom[t++]=[this.dest[0],this.dest[1]+this.height],this._geom[t++]=[this.dest[0]+this.width,this.dest[1]],this._geom[t++]=[this.dest[0]+this.width,this.dest[1]],this._geom[t++]=[this.dest[0],this.dest[1]+this.height],this._geom[t++]=[this.dest[0]+this.width,this.dest[1]+this.height],this}applyTransform(t,e){if(t)for(let e=0;e<this._geom.length;e++)this._geom[e]=t.multv(this._geom[e]),this.snapToPixel&&(this._geom[e]=[~~this._geom[e][0],~~this._geom[e][1]]);this.opacity=e}get geometry(){return this._geom}}class Jr extends Xr{constructor(t,e){super(t),this.maxDraws=t,this.maxTextures=e,this.textures=[],this.commands=[],this._graphicMap={}}isFull(){return this.commands.length>=this.maxDraws||this.textures.length>=this.maxTextures}canAdd(){return!(this.commands.length>=this.maxDraws)&&this.textures.length<this.maxTextures}_isCommandFull(){return this.commands.length>=this.maxDraws}_isTextureFull(){return this.textures.length>=this.maxTextures}_wouldAddTexture(t){return!this._graphicMap[t.image.id]}maybeAdd(t){return(!this._isCommandFull()&&!this._isTextureFull()||!this._wouldAddTexture(t))&&(this.add(t),!0)}add(t){if(t.type===Qr.Image){const e=te.load(t.image);-1===this.textures.indexOf(e)&&this.textures.push(e)}this.commands.push(t)}bindTextures(t){for(let e=0;e<this.maxTextures;e++)t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,this.textures[e]||this.textures[0])}getBatchTextureId(t){return t.image?this.textures.indexOf(te.get(t.image)):-1}dispose(){return this.clear(),this}clear(){this.commands.length=0,this.textures.length=0,this._graphicMap={}}}class tn extends Kr{constructor(t,e){super({gl:t,command:$r,verticesPerCommand:6,maxCommandsPerBatch:2e3,batchFactory:()=>new Jr(2e3,t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS))}),this._contextInfo=e,te.registerContext(t),this.init()}buildShader(t){const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),i=new jr(t,"attribute vec4 a_position;\r\n\r\n// Opacity \r\nattribute float a_opacity;\r\nvarying float v_opacity;\r\n\r\nattribute vec4 a_color;\r\nvarying vec4 v_color;\r\n\r\n// UV coordinate\r\nattribute vec2 a_texcoord;\r\nvarying vec2 v_texcoord;\r\n\r\n// Texture number\r\nattribute lowp float a_textureIndex;\r\nvarying lowp float v_textureIndex;\r\n\r\nuniform mat4 u_matrix;\r\n\r\n\r\nvoid main() {\r\n // Set the vertex position using the ortho transform matrix\r\n gl_Position = u_matrix * a_position;\r\n\r\n // Pass through the Opacity to the fragment shader\r\n v_opacity = a_opacity;\r\n // Pass through the UV coord to the fragment shader\r\n v_texcoord = a_texcoord;\r\n // Pass through the texture number to the fragment shader\r\n v_textureIndex = a_textureIndex;\r\n // Pass through the color to the fragment shader\r\n v_color = a_color;\r\n}",this._transformFragmentSource("#ifdef GL_OES_standard_derivatives\r\n#extension GL_OES_standard_derivatives : enable\r\n#endif\r\nprecision mediump float;\r\n\r\n// UV coord\r\nvarying vec2 v_texcoord;\r\n\r\n// Texture index\r\nvarying lowp float v_textureIndex;\r\n\r\n// Color coord to blend with image\r\nvarying lowp vec4 v_color;\r\n\r\n// Opacity\r\nvarying float v_opacity;\r\n\r\nuniform sampler2D u_textures[%%count%%];\r\n\r\nfloat circle(in vec2 st, in float radius) {\r\n vec2 dist = st - vec2(0.5);\r\n float r = dot(dist, dist) * 4.0;\r\n float delta = fwidth(r);\r\n return 1.0 - smoothstep(radius - delta, radius + delta, r);\r\n}\r\n\r\nvoid main() {\r\n float r = 0.0, delta = 0.0, alpha = 1.0;\r\n // In order to support the most efficient sprite batching, we have multiple\r\n // textures loaded into the gpu (usually 8) this picker logic skips over textures\r\n // that do not apply to a particular sprite.\r\n\r\n vec4 color;\r\n // -1 If there is no texture to sample we are drawing a solid geometry (rectangles)\r\n if (v_textureIndex == -1.0) {\r\n color = v_color;\r\n color.w = color.w * v_opacity;\r\n // -2 If there is no texture we are drawing a circle\r\n } else if (v_textureIndex == -2.0) {\r\n color = v_color;\r\n color.a = color.a * circle(v_texcoord, .95);\r\n } else {\r\n // GLSL is templated out to pick the right texture and set the vec4 color\r\n %%texture_picker%%\r\n }\r\n color.w = color.w * v_opacity;\r\n gl_FragColor = color;\r\n}",e));return i.addAttribute("a_position",3,t.FLOAT),i.addAttribute("a_texcoord",2,t.FLOAT),i.addAttribute("a_textureIndex",1,t.FLOAT),i.addAttribute("a_opacity",1,t.FLOAT),i.addAttribute("a_color",4,t.FLOAT),i.addUniformMatrix("u_matrix",this._contextInfo.matrix.data),i.addUniformIntegerArray("u_textures",[...Array(e)].map((t,e)=>e)),i}_transformFragmentSource(t,e){let i=t.replace("%%count%%",e.toString()),s="";for(let t=0;t<e;t++)s+=0===t?`if (v_textureIndex <= ${t}.5) {\n`:` else if (v_textureIndex <= ${t}.5) {\n`,s+=` color = texture2D(u_textures[${t}], v_texcoord);\n`,s+=" }\n";return i=i.replace("%%texture_picker%%",s),i}addCircle(t,e,i){const s=this.commands.get().initCircle(t,e,i);s.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(s)}addRectangle(t,e,i,s){const r=this.commands.get().initRect(t,e,i,s);r.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(r)}addLine(t,e,i,s=1){const r=this.commands.get().initLine(t,e,i,s);r.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(r)}addImage(t,e,i,s,r,n,o,a,h){const l=this.commands.get().init(t,e,i,s,r,n,o,a,h);l.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(l)}renderBatch(t,e,i){e.bindTextures(t),t.drawArrays(t.TRIANGLES,0,i)}buildBatchVertices(t,e){var i,s;let r=0,n=0,o=0,a=0,h=0,l=1,c=1,d=0,u=Q.Transparent;for(const p of e.commands){n=p.view[0],o=p.view[1],a=p.view[2],h=p.view[3],l=Qt((null===(i=p.image)||void 0===i?void 0:i.width)||p.width),c=Qt((null===(s=p.image)||void 0===s?void 0:s.height)||p.height),d=e.getBatchTextureId(p),p.type!==Qr.Line&&p.type!==Qr.Rectangle||(d=-1,u=p.color),p.type===Qr.Circle&&(d=-2,u=p.color);let g=n/l,_=o/c,f=(n+a)/l,m=(o+h)/c;-2===d&&(g=0,_=0,f=1,m=1),t[r++]=p.geometry[0][0],t[r++]=p.geometry[0][1],t[r++]=0,t[r++]=g,t[r++]=_,t[r++]=d,t[r++]=p.opacity,t[r++]=u.r/255,t[r++]=u.g/255,t[r++]=u.b/255,t[r++]=u.a,t[r++]=p.geometry[1][0],t[r++]=p.geometry[1][1],t[r++]=0,t[r++]=g,t[r++]=m,t[r++]=d,t[r++]=p.opacity,t[r++]=u.r/255,t[r++]=u.g/255,t[r++]=u.b/255,t[r++]=u.a,t[r++]=p.geometry[2][0],t[r++]=p.geometry[2][1],t[r++]=0,t[r++]=f,t[r++]=_,t[r++]=d,t[r++]=p.opacity,t[r++]=u.r/255,t[r++]=u.g/255,t[r++]=u.b/255,t[r++]=u.a,t[r++]=p.geometry[3][0],t[r++]=p.geometry[3][1],t[r++]=0,t[r++]=f,t[r++]=_,t[r++]=d,t[r++]=p.opacity,t[r++]=u.r/255,t[r++]=u.g/255,t[r++]=u.b/255,t[r++]=u.a,t[r++]=p.geometry[4][0],t[r++]=p.geometry[4][1],t[r++]=0,t[r++]=g,t[r++]=m,t[r++]=d,t[r++]=p.opacity,t[r++]=u.r/255,t[r++]=u.g/255,t[r++]=u.b/255,t[r++]=u.a,t[r++]=p.geometry[5][0],t[r++]=p.geometry[5][1],t[r++]=0,t[r++]=f,t[r++]=m,t[r++]=d,t[r++]=p.opacity,t[r++]=u.r/255,t[r++]=u.g/255,t[r++]=u.b/255,t[r++]=u.a}return r/this.vertexSize}}class en{constructor(){this.point=X.Zero,this.color=Q.Black,this.size=1}dispose(){return this.point.setTo(0,0),this.color.r=0,this.color.g=0,this.color.b=0,this.color.a=1,this.size=1,this}}class sn extends Kr{constructor(t,e){super({gl:t,command:en,verticesPerCommand:1}),this._contextInfo=e,this.init()}buildShader(t){t.getExtension("OES_standard_derivatives");const e=new jr(t,"attribute vec4 a_position;\r\nattribute vec4 a_color;\r\nattribute float a_size;\r\nvarying lowp vec4 v_color;\r\nuniform mat4 u_matrix;\r\n\r\nvoid main() {\r\n gl_Position = u_matrix * a_position;\r\n gl_PointSize = a_size * 2.0;\r\n v_color = a_color;\r\n}","#ifdef GL_OES_standard_derivatives\r\n#extension GL_OES_standard_derivatives : enable\r\n#endif\r\n\r\nprecision mediump float;\r\nvarying lowp vec4 v_color;\r\n\r\nvoid main() {\r\n float r = 0.0, delta = 0.0, alpha = 1.0;\r\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\r\n r = dot(cxy, cxy);\r\n \r\n#ifdef GL_OES_standard_derivatives\r\n delta = fwidth(r);\r\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\r\n#else\r\n if (r > 1.0) {\r\n discard;\r\n }\r\n#endif\r\n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\r\n}");return e.addAttribute("a_position",2,t.FLOAT),e.addAttribute("a_color",4,t.FLOAT),e.addAttribute("a_size",1,t.FLOAT),e.addUniformMatrix("u_matrix",this._contextInfo.matrix.data),e}addPoint(t,e,i){const s=this.commands.get();s.point=this._contextInfo.transform.current.multv(t),s.color.r=e.r,s.color.g=e.g,s.color.b=e.b,s.color.a=e.a*this._contextInfo.state.current.opacity,s.size=i*Math.max(this._contextInfo.transform.current.getScaleX(),this._contextInfo.transform.current.getScaleY()),this.addCommand(s)}buildBatchVertices(t,e){let i=0;for(const s of e.commands)t[i++]=s.point.x,t[i++]=s.point.y,t[i++]=s.color.r/255,t[i++]=s.color.g/255,t[i++]=s.color.b/255,t[i++]=s.color.a,t[i++]=s.size;return i/this.vertexSize}renderBatch(t,e,i){t.drawArrays(t.POINTS,0,i)}}class rn{constructor(t){this._webglCtx=t,this._debugText=new Nr}drawRect(t,e,i,s,r={color:Q.Black}){this.drawLine(q(t,e),q(t+i,e),Object.assign({},r)),this.drawLine(q(t+i,e),q(t+i,e+s),Object.assign({},r)),this.drawLine(q(t+i,e+s),q(t,e+s),Object.assign({},r)),this.drawLine(q(t,e+s),q(t,e),Object.assign({},r))}drawLine(t,e,i={color:Q.Black}){this._webglCtx.__lineRenderer.addLine(t,e,i.color)}drawPoint(t,e={color:Q.Black,size:5}){this._webglCtx.__pointRenderer.addPoint(t,e.color,e.size)}drawText(t,e){this._debugText.write(this._webglCtx,t,e)}}class nn{constructor(t){this._transform=new Gr,this._state=new Ur,this.snapToPixel=!0,this.smoothing=!1,this.backgroundColor=Q.ExcaliburBlue,this.debug=new rn(this);const{canvasElement:e,enableTransparency:i,smoothing:s,snapToPixel:r,backgroundColor:n}=t;this.__gl=e.getContext("webgl",{antialias:null!=s?s:this.smoothing,premultipliedAlpha:!1,alpha:null==i||i,depth:!0,powerPreference:"high-performance"}),this.snapToPixel=null!=r?r:this.snapToPixel,this.smoothing=null!=s?s:this.smoothing,this.backgroundColor=null!=n?n:this.backgroundColor,this._init()}get opacity(){return this._state.current.opacity}set opacity(t){this._state.current.opacity=t}get width(){return this.__gl.canvas.width}get height(){return this.__gl.canvas.height}_init(){const t=this.__gl;this._ortho=Ve.ortho(0,t.canvas.width,t.canvas.height,0,400,-400),t.viewport(0,0,t.canvas.width,t.canvas.height),t.clearColor(this.backgroundColor.r/255,this.backgroundColor.g/255,this.backgroundColor.b/255,this.backgroundColor.a),t.clear(t.COLOR_BUFFER_BIT),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.__pointRenderer=new sn(t,{matrix:this._ortho,transform:this._transform,state:this._state}),this.__lineRenderer=new Yr(t,{matrix:this._ortho,transform:this._transform,state:this._state}),this.__imageRenderer=new tn(t,{matrix:this._ortho,transform:this._transform,state:this._state}),this._canvas=new ie({width:t.canvas.width,height:t.canvas.height}),this.__ctx=this._canvas.ctx}resetTransform(){this._transform.current=Ve.identity()}updateViewport(){const t=this.__gl;this._ortho=this._ortho=Ve.ortho(0,t.canvas.width,t.canvas.height,0,400,-400),this.__pointRenderer.shader.addUniformMatrix("u_matrix",this._ortho.data),this.__lineRenderer.shader.addUniformMatrix("u_matrix",this._ortho.data),this.__imageRenderer.shader.addUniformMatrix("u_matrix",this._ortho.data),this._canvas.width=t.canvas.width,this._canvas.height=t.canvas.height}drawImage(t,e,i,s,r,n,o,a,h){if(0!==s&&0!==r&&0!==a&&0!==h&&0!==t.width&&0!==t.height)return t?void this.__imageRenderer.addImage(t,e,i,s,r,n,o,a,h):(_.getInstance().warn("Cannot draw a null or undefined image"),void(console.trace&&console.trace()))}drawLine(t,e,i,s=1){this.__imageRenderer.addLine(i,t,e,s)}drawRectangle(t,e,i,s){this.__imageRenderer.addRectangle(s,t,e,i)}drawCircle(t,e,i){this.__imageRenderer.addCircle(t,e,i)}save(){this._transform.save(),this._state.save()}restore(){this._transform.restore(),this._state.restore()}translate(t,e){this._transform.translate(this.snapToPixel?~~t:t,this.snapToPixel?~~e:e)}rotate(t){this._transform.rotate(t)}scale(t,e){this._transform.scale(t,e)}transform(t){this._transform.current=t}clear(){const t=this.__gl;t.clearColor(this.backgroundColor.r/255,this.backgroundColor.g/255,this.backgroundColor.b/255,this.backgroundColor.a),t.clear(t.COLOR_BUFFER_BIT),Xs.clear()}flush(){const t=this.__gl;t.viewport(0,0,t.canvas.width,t.canvas.height),this.__imageRenderer.render(),this.__lineRenderer.render(),this.__pointRenderer.render()}}var on,an=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};u(),function(t){t[t.None=0]="None",t[t.Canvas=1]="Canvas",t[t.All=2]="All"}(on||(on={}));class hn extends Wt{constructor(t){var e,i,s;super(),this._hasStarted=!1,this.postProcessors=[],this.scenes={},this._animations=[],this._suppressPlayButton=!1,this.pauseAudioWhenHidden=!0,this._isDebug=!1,this.debugColor=new Q(255,255,255),this.enableCanvasTransparency=!0,this.onFatalException=t=>{_.getInstance().fatal(t)},this._timescale=1,this._isLoading=!1,this._isInitialized=!1,this._deferredGoTo=null,t=Object.assign(Object.assign({},hn._DEFAULT_ENGINE_OPTIONS),t),p.freeze(),this.browser=new zr(window,document);const r=new oe;if(!t.suppressMinimumBrowserFeatureDetection&&!(this._compatible=r.test())){const e=document.createElement("div");if(e.innerText="Sorry, your browser does not support all the features needed for Excalibur",document.body.appendChild(e),r.failedTests.forEach((function(t){const e=document.createElement("div");e.innerText="Browser feature missing "+t,document.body.appendChild(e)})),t.canvasElementId){const e=document.getElementById(t.canvasElementId);e&&e.parentElement.removeChild(e)}return}this._compatible=!0,console.log&&!t.suppressConsoleBootMessage&&(console.log(`%cPowered by Excalibur.js (v${Kn})`,"background: #176BAA; color: white; border-radius: 5px; padding: 15px; font-size: 1.5em; line-height: 80px;"),console.log("\n /| ________________\nO|===|* >________________>\n \\|"),console.log("Visit","http://excaliburjs.com","for more information")),t.suppressPlayButton&&(this._suppressPlayButton=!0),this._logger=_.getInstance(),this._logger.defaultLevel===d.Debug&&r.logBrowserFeatures(),this._logger.debug("Building engine..."),this.canvasElementId=t.canvasElementId,t.canvasElementId?(this._logger.debug("Using Canvas element specified: "+t.canvasElementId),this.canvas=document.getElementById(t.canvasElementId)):t.canvasElement?(this._logger.debug("Using Canvas element specified:",t.canvasElement),this.canvas=t.canvasElement):(this._logger.debug("Using generated canvas element"),this.canvas=document.createElement("canvas"));let n=null!==(e=t.displayMode)&&void 0!==e?e:K.Fixed;if(t.width&&t.height||t.viewport?(void 0===t.displayMode&&(n=K.Fixed),this._logger.debug("Engine viewport is size "+t.width+" x "+t.height)):t.displayMode||(this._logger.debug("Engine viewport is fit"),n=K.FitScreen),p.isEnabled(c.Canvas)){const e=new Vr({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,smoothing:t.antialiasing,backgroundColor:t.backgroundColor,snapToPixel:t.snapToPixel});this.graphicsContext=e,this.ctx=e.__ctx}else{const e=new nn({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,smoothing:t.antialiasing,backgroundColor:t.backgroundColor,snapToPixel:t.snapToPixel});this.graphicsContext=e,this.ctx=e.__ctx}this.screen=new et({canvas:this.canvas,context:this.graphicsContext,antialiasing:null===(i=t.antialiasing)||void 0===i||i,browser:this.browser,viewport:null!==(s=t.viewport)&&void 0!==s?s:t.width&&t.height?{width:t.width,height:t.height}:tt.SVGA,resolution:t.resolution,displayMode:n,position:t.position,pixelRatio:t.suppressHiDPIScaling?1:null}),this.screen.applyResolutionAndViewport(),t.backgroundColor&&(this.backgroundColor=t.backgroundColor.clone()),this.enableCanvasTransparency=t.enableCanvasTransparency,this._loader=new re,this.debug=new gr(this),this._initialize(t),this.rootScene=this.currentScene=new dr,this.addScene("root",this.rootScene)}get canvasWidth(){return this.screen.canvasWidth}get halfCanvasWidth(){return this.screen.halfCanvasWidth}get canvasHeight(){return this.screen.canvasHeight}get halfCanvasHeight(){return this.screen.halfCanvasHeight}get drawWidth(){return this.screen.drawWidth}get halfDrawWidth(){return this.screen.halfDrawWidth}get drawHeight(){return this.screen.drawHeight}get halfDrawHeight(){return this.screen.halfDrawHeight}get isHiDpi(){return this.screen.isHiDpi}get stats(){return this.debug.stats}get isFullscreen(){return this.screen.isFullScreen}get displayMode(){return this.screen.displayMode}get pixelRatio(){return this.screen.pixelRatio}get isDebug(){return this._isDebug}on(t,e){super.on(t,e)}once(t,e){super.once(t,e)}off(t,e){super.off(t,e)}getWorldBounds(){return this.screen.getWorldBounds()}get timescale(){return this._timescale}set timescale(t){t<=0?_.getInstance().error("Cannot set engine.timescale to a value of 0 or less than 0."):this._timescale=t}playAnimation(t,e,i){this._animations.push(new ln(t,e,i))}addTileMap(t){this.currentScene.addTileMap(t)}removeTileMap(t){this.currentScene.removeTileMap(t)}addTimer(t){return this.currentScene.addTimer(t)}removeTimer(t){return this.currentScene.removeTimer(t)}addScene(t,e){this.scenes[t]&&this._logger.warn("Scene",t,"already exists overwriting"),this.scenes[t]=e}removeScene(t){if(t instanceof dr)for(const e in this.scenes)this.scenes.hasOwnProperty(e)&&this.scenes[e]===t&&delete this.scenes[e];"string"==typeof t&&delete this.scenes[t]}add(t){2!==arguments.length?this._deferredGoTo&&this.scenes[this._deferredGoTo]?this.scenes[this._deferredGoTo].add(t):this.currentScene.add(t):this.addScene(arguments[0],arguments[1])}remove(t){t instanceof Hi&&this.currentScene.remove(t),t instanceof dr&&this.removeScene(t),"string"==typeof t&&this.removeScene(t)}goToScene(t){if(this.isInitialized)if(this.scenes[t]){const e=this.currentScene,i=this.scenes[t];this._logger.debug("Going to scene:",t),this.currentScene.isInitialized&&(this.currentScene._deactivate.apply(this.currentScene,[e,i]),this.currentScene.eventDispatcher.emit("deactivate",new It(i,this.currentScene))),this.currentScene=i,this.screen.setCurrentCamera(i.camera),this.currentScene._initialize(this),this.currentScene._activate.apply(this.currentScene,[e,i]),this.currentScene.eventDispatcher.emit("activate",new Lt(e,this.currentScene))}else this._logger.error("Scene",t,"does not exist!");else this._deferredGoTo=t}screenToWorldCoordinates(t){return this.screen.screenToWorldCoordinates(t)}worldToScreenCoordinates(t){return this.screen.worldToScreenCoordinates(t)}_initialize(t){let e,i;this.pageScrollPreventionMode=t.scrollPreventionMode,this.input={keyboard:new wr,pointers:new Br(this),gamepads:new kr},this.input.keyboard.init(),this.input.pointers.init(t&&t.pointerScope===or.Document?document:this.canvas),this.input.gamepads.init(),void 0!==document.hidden?(e="hidden",i="visibilitychange"):"msHidden"in document?(e="msHidden",i="msvisibilitychange"):"webkitHidden"in document&&(e="webkitHidden",i="webkitvisibilitychange"),this.browser.document.on(i,()=>{document[e]?(this.eventDispatcher.emit("hidden",new St(this)),this._logger.debug("Window hidden")):(this.eventDispatcher.emit("visible",new At(this)),this._logger.debug("Window visible"))}),this.canvasElementId||t.canvasElement||document.body.appendChild(this.canvas)}onInitialize(t){}setAntialiasing(t){this.screen.antialiasing=t}getAntialiasing(){return this.screen.antialiasing}get isInitialized(){return this._isInitialized}_overrideInitialize(t){this.isInitialized||(this.onInitialize(t),super.emit("initialize",new Ft(t,this)),this._isInitialized=!0,this._deferredGoTo?this.goToScene(this._deferredGoTo):this.goToScene("root"))}_update(t){if(this._isLoading)return this._loader.update(this,t),this.input.keyboard.update(),this.input.pointers.update(),void this.input.gamepads.update();this._overrideInitialize(this),this._preupdate(t),this.currentScene.update(this,t),this._animations=this._animations.filter((function(t){return!t.animation.isDone()})),this.input.keyboard.update(),this.input.pointers.update(),this.input.gamepads.update(),this._postupdate(t)}_preupdate(t){this.emit("preupdate",new gt(this,t,this)),this.onPreUpdate(this,t)}onPreUpdate(t,e){}_postupdate(t){this.emit("postupdate",new _t(this,t,this)),this.onPostUpdate(this,t)}onPostUpdate(t,e){}_draw(t){const e=this.ctx;if(this._predraw(e,t),this._isLoading)return this._loader.canvas.draw(this.graphicsContext,0,0),void this.graphicsContext.flush();this.graphicsContext.backgroundColor=this.backgroundColor,this.currentScene.draw(this.ctx,t);let i=0;const s=this._animations.length;for(;i<s;i++)this._animations[i].animation.draw(e,this._animations[i].x,this._animations[i].y);if(this.isDebug){this.ctx.font="Consolas",this.ctx.fillStyle=this.debugColor.toString();const t=this.input.keyboard.getKeys();for(let e=0;e<t.length;e++)this.ctx.fillText(t[e].toString()+" : "+(rr[t[e]]?rr[t[e]]:"Not Mapped"),100,10*e+10);this.ctx.fillText("FPS:"+this.stats.currFrame.fps.toFixed(2).toString(),10,10)}for(let t=0;t<this.postProcessors.length;t++)this.postProcessors[t].process(this.ctx.getImageData(0,0,this.canvasWidth,this.canvasHeight),this.ctx);this._postdraw(e,t)}_predraw(t,e){this.emit("predraw",new ct(t,e,this)),this.onPreDraw(t,e)}onPreDraw(t,e){}_postdraw(t,e){this.emit("postdraw",new dt(t,e,this)),this.onPostDraw(t,e)}onPostDraw(t,e){}showDebug(t){this._isDebug=t}toggleDebug(){return this._isDebug=!this._isDebug,this._isDebug}start(t){if(!this._compatible)return Promise.reject("Excalibur is incompatible with your browser");let e;return this.screen.pushResolutionAndViewport(),this.screen.resolution=this.screen.viewport,this.screen.applyResolutionAndViewport(),this.graphicsContext.updateViewport(),t?(this._loader=t,this._loader.suppressPlayButton=this._suppressPlayButton||this._loader.suppressPlayButton,this._loader.wireEngine(this),e=this.load(this._loader)):e=Promise.resolve(),e.then(()=>{this.screen.popResolutionAndViewport(),this.screen.applyResolutionAndViewport(),this.graphicsContext.updateViewport(),this.emit("start",new ht(this))}),this._hasStarted||(this._hasStarted=!0,this._logger.debug("Starting game..."),this.browser.resume(),hn.createMainLoop(this,window.requestAnimationFrame,Date.now)(),this._logger.debug("Game started")),e}static createMainLoop(t,e,i){let s=i();return function r(){if(t._hasStarted)try{t._requestId=e(r),t.emit("preframe",new ft(t,t.stats.prevFrame));const n=i();let o=Math.floor(n-s)||1;o>200&&(o=1);const a=o*t.timescale,h=t.stats.prevFrame.id+1;t.stats.currFrame.reset(),t.stats.currFrame.id=h,t.stats.currFrame.delta=a,t.stats.currFrame.fps=1/(a/1e3);const l=i();t._update(a);const c=i();t._draw(a);const d=i();t.stats.currFrame.duration.update=c-l,t.stats.currFrame.duration.draw=d-c,s=n,t.emit("postframe",new mt(t,t.stats.currFrame)),t.stats.prevFrame.reset(t.stats.currFrame)}catch(e){window.cancelAnimationFrame(t._requestId),t.stop(),t.onFatalException(e)}}}stop(){this._hasStarted&&(this.emit("stop",new lt(this)),this.browser.pause(),this._hasStarted=!1,this._logger.debug("Game stopped"))}isPaused(){return!this._hasStarted}screenshot(){const t=new Image,e=this.canvas.toDataURL("image/png");return t.src=e,t}load(t){return new Promise(e=>{this._isLoading=!0,t.load().then(()=>{this._suppressPlayButton?setTimeout(()=>{this._isLoading=!1,e()},500):(this._isLoading=!1,e())})})}}hn._DEFAULT_ENGINE_OPTIONS={width:0,height:0,enableCanvasTransparency:!0,canvasElementId:"",canvasElement:void 0,snapToPixel:!1,pointerScope:or.Canvas,suppressConsoleBootMessage:null,suppressMinimumBrowserFeatureDetection:null,suppressHiDPIScaling:null,suppressPlayButton:null,scrollPreventionMode:on.Canvas,backgroundColor:Q.fromHex("#2185d0")},an([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Actor.graphics"})],hn.prototype,"playAnimation",null);let ln=class{constructor(t,e,i){this.animation=t,this.x=e,this.y=i}};ln=an([G({message:"Will be removed in excalibur v0.26.0"})],ln);class cn extends rt{constructor(t,e="MediaEvent"){super(),this.target=t,this._name=e}set bubbles(t){}get bubbles(){return!1}get _path(){return null}set _path(t){}stopPropagation(){}action(){}propagate(){}layPath(t){}}class dn extends cn{constructor(t,e){super(t,"NativeSoundEvent"),this.track=e}}class un extends cn{constructor(t,e){super(t,"NativeSoundProcessedEvent"),this._processedData=e,this.data=this._processedData}}class pn extends ee{constructor(t={}){var e,i,s,r,n,o,a,h,l,c,d,u;super(t),this.quality=2,this.family="sans-serif",this.style=is.Normal,this.bold=!1,this.unit=Ji.Px,this.textAlign=ts.Left,this.baseAlign=es.Alphabetic,this.direction=ss.LeftToRight,this.size=10,this.shadow=null,this._textBounds=new J,this._textWidth=0,this._textHeight=0,this.family=null!==(e=null==t?void 0:t.family)&&void 0!==e?e:this.family,this.style=null!==(i=null==t?void 0:t.style)&&void 0!==i?i:this.style,this.bold=null!==(s=null==t?void 0:t.bold)&&void 0!==s?s:this.bold,this.size=null!==(r=null==t?void 0:t.size)&&void 0!==r?r:this.size,this.unit=null!==(n=null==t?void 0:t.unit)&&void 0!==n?n:this.unit,this.textAlign=null!==(o=null==t?void 0:t.textAlign)&&void 0!==o?o:this.textAlign,this.baseAlign=null!==(a=null==t?void 0:t.baseAlign)&&void 0!==a?a:this.baseAlign,this.direction=null!==(h=null==t?void 0:t.direction)&&void 0!==h?h:this.direction,this.quality=null!==(l=null==t?void 0:t.quality)&&void 0!==l?l:this.quality,(null==t?void 0:t.shadow)&&(this.shadow={},this.shadow.blur=null!==(c=t.shadow.blur)&&void 0!==c?c:this.shadow.blur,this.shadow.offset=null!==(d=t.shadow.offset)&&void 0!==d?d:this.shadow.offset,this.shadow.color=null!==(u=t.shadow.color)&&void 0!==u?u:this.shadow.color),this.flagDirty()}clone(){return new pn(Object.assign(Object.assign(Object.assign({},this.cloneGraphicOptions()),this.cloneRasterOptions()),{size:this.size,unit:this.unit,family:this.family,style:this.style,bold:this.bold,textAlign:this.textAlign,baseAlign:this.baseAlign,direction:this.direction,shadow:this.shadow?{blur:this.shadow.blur,offset:this.shadow.offset,color:this.shadow.color}:null}))}get fontString(){return`${this.style} ${this.bold?"bold":""} ${this.size}${this.unit} ${this.family}`}get width(){return this._textWidth}set width(t){this._textWidth=t}get height(){var t,e;const i=null!==(e=null===(t=this._lines)||void 0===t?void 0:t.length)&&void 0!==e?e:1;return this._textHeight*i}set height(t){var e,i;const s=null!==(i=null===(e=this._lines)||void 0===e?void 0:e.length)&&void 0!==i?i:1;this._textHeight=t/s}get _rasterWidth(){return this._bitmap.width}get _rasterHeight(){return this._bitmap.height}get _halfRasterWidth(){return Math.floor(this._bitmap.width/2)}get _halfRasterHeight(){return Math.floor(this._bitmap.height/2)}get localBounds(){return this._textBounds}_drawImage(t,e,i){this.dirty&&this.rasterize(),t.drawImage(this._bitmap,0,0,this._rasterWidth,this._rasterHeight,e-this._rasterWidth/this.quality/2,i-this._rasterHeight/this.quality/2,this._rasterWidth/this.quality,this._rasterHeight/this.quality)}_rotate(t){var e;const i=null!==(e=this.origin)&&void 0!==e?e:this._textBounds.center;t.translate(i.x,i.y),t.rotate(this.rotation),t.translate(-i.x,-i.y)}_flip(t){this.flipHorizontal&&(t.translate(this._textBounds.width/this.scale.x,0),t.scale(-1,1)),this.flipVertical&&(t.translate(0,-this._textBounds.height/2/this.scale.y),t.scale(1,-1))}updateText(t){this._text!==t&&(this._text=t,this._lines=this._text.split("\n"),this._updateDimensions(),this.flagDirty())}_updateDimensions(){if(this._text){this._applyFont(this._ctx);const t=this._lines.reduce((t,e)=>t.length>e.length?t:e),e=this._ctx.measureText(t);this._textWidth=Math.abs(e.actualBoundingBoxLeft)+Math.abs(e.actualBoundingBoxRight),this._textHeight=Math.abs(e.actualBoundingBoxAscent)+Math.abs(e.actualBoundingBoxDescent);const i=this._textHeight*this._lines.length;this._bitmap.width=2*(this._textWidth+2*this.padding)*this.quality,this._bitmap.height=2*(i+2*this.padding)*this.quality;const s=0,r=0,n=i-Math.abs(e.actualBoundingBoxAscent);this._textBounds=new J({left:s-Math.abs(e.actualBoundingBoxLeft)-this.padding,top:r-Math.abs(e.actualBoundingBoxAscent)-this.padding,bottom:r+n+this.padding,right:s+Math.abs(e.actualBoundingBoxRight)+this.padding})}}_preDraw(t,e,i){this.dirty&&this._updateDimensions(),super._preDraw(t,e,i)}_postDraw(t){this.showDebug&&t.debug.drawRect(-this._halfRasterWidth,-this._halfRasterHeight,this._rasterWidth,this._rasterHeight),t.restore()}_applyFont(t){t.translate(this.padding+this._halfRasterWidth,this.padding+this._halfRasterHeight),t.scale(this.quality,this.quality),t.textAlign=this.textAlign,t.textBaseline=this.baseAlign,t.font=this.fontString,t.direction=this.direction,this.shadow&&(t.shadowColor=this.shadow.color.toString(),t.shadowBlur=this.shadow.blur,t.shadowOffsetX=this.shadow.offset.x,t.shadowOffsetY=this.shadow.offset.y)}execute(t){if(this._text){this._applyRasterProperites(t),this._applyFont(t);const e=this._textHeight;for(let i=0;i<this._lines.length;i++){const s=this._lines[i];this.color&&t.fillText(s,0,i*e),this.strokeColor&&t.strokeText(s,0,i*e)}this.showDebug&&(Vt(t,Q.Red,-this._halfRasterWidth,0,this._halfRasterWidth,0,2),Vt(t,Q.Red,0,-this._halfRasterHeight,0,this._halfRasterHeight,2))}}render(t,e,i,s){this.updateText(e),this.draw(t,i,s)}}class gn extends Zt{constructor(t){var e,i;super(t),this._text="",this.font=null!==(e=t.font)&&void 0!==e?e:new pn,this.color=null!==(i=t.color)&&void 0!==i?i:this.color,this.text=t.text}clone(){return new gn({text:this.text.slice(),color:this.color.clone(),font:this.font.clone()})}get text(){return this._text}set text(t){this._text=t,this.font.updateText(t)}get color(){return this.font instanceof pn?this.font.color:Q.Black}set color(t){this.font instanceof pn&&(this.font.color=t)}get font(){return this._font}set font(t){this._font=t instanceof pn?$t(t,t=>t.flagDirty()):t}get width(){return this.font.width}get height(){return this.font.height}get localBounds(){return this.font.localBounds}_rotate(t){}_flip(t){}_drawImage(t,e,i){this.font instanceof pn&&(this.font.color=this.color),this.font.flipHorizontal=this.flipHorizontal,this.font.flipVertical=this.flipVertical,this.font.scale=this.scale,this.font.rotation=this.rotation,this.font.origin=this.origin,this.font.opacity=this.opacity,this.font.render(t,this._text,e,i)}}var _n=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};class fn extends Zi{constructor(t){super(t),this.font=new pn,this._text=new gn({text:"",font:this.font}),this.letterSpacing=0,this.caseInsensitive=!0;const{text:e,pos:i,x:s,y:r,spriteFont:n,font:o,color:a}=t;this.pos=null!=i?i:s&&r?q(s,r):this.pos,this.text=null!=e?e:this.text,this.spriteFont=null!=n?n:this.spriteFont,this.font=null!=o?o:this.font,this.color=null!=a?a:this.color;const h=this.get(ji);h.anchor=X.Zero,h.use(this._text)}get text(){return this._text.text}set text(t){this._text.text=t}get color(){return this._text.color}set color(t){this._text.color=t}get opacity(){return this._text.opacity}set opacity(t){this._text.opacity=t}get bold(){return this.font.bold}set bold(t){this.font.bold=t}get fontFamily(){return this.font.family}set fontFamily(t){this.font.family=t}get fontSize(){return this.font.size}set fontSize(t){this.font.size=t}get fontStyle(){return this.font.style}set fontStyle(t){this.font.style=t}get fontUnit(){return this.font.unit}set fontUnit(t){this.font.unit=t}get textAlign(){return this.font.textAlign}set textAlign(t){this.font.textAlign=t}get baseAlign(){return this.font.baseAlign}set baseAlign(t){this.font.baseAlign=t}get spriteFont(){return this._legacySpriteFont}set spriteFont(t){if(t){if(t instanceof ls)return this._legacySpriteFont=t,this._spriteFont=Hr.fromLegacySpriteFont(t),void(this._text.font=this._spriteFont);this._spriteFont=t,this._text.font=this._spriteFont}}_initialize(t){super._initialize(t),this._graphicsContext=t.graphicsContext}getTextWidth(){return this._text.width}setTextShadow(t,e,i){this.font.shadow={offset:q(t,e),blur:2,color:i}}useTextShadow(t){this.spriteFont&&this.spriteFont.useTextShadow(t)}clearTextShadow(){this.font.shadow=null}draw(t,e){const i=this._graphicsContext;this._text.draw(i,0,0)}}_n([G({message:"Label.bold will be removed in v0.26.0",alternateMethod:"Use Label.font.bold"})],fn.prototype,"bold",null),_n([G({message:"Label.fontFamily will be removed in v0.26.0",alternateMethod:"Use Label.font.family"})],fn.prototype,"fontFamily",null),_n([G({message:"Label.fontSize will be removed in v0.26.0",alternateMethod:"Use Label.font.size"})],fn.prototype,"fontSize",null),_n([G({message:"Label.fontStyle will be removed in v0.26.0",alternateMethod:"Use Lable.font.style"})],fn.prototype,"fontStyle",null),_n([G({message:"Label.fontUnit will be removed in v0.26.0",alternateMethod:"Use Label.font.unit"})],fn.prototype,"fontUnit",null),_n([G({message:"Label.textAlign will be removed in v0.26.0",alternateMethod:"Use Label.font.textAlign"})],fn.prototype,"textAlign",null),_n([G({message:"Label.baseAlign will be removed in v0.26.0",alternateMethod:"Use Label.font.baseAlign"})],fn.prototype,"baseAlign",null),_n([G()],fn.prototype,"spriteFont",null),_n([G({message:"Label.setTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],fn.prototype,"setTextShadow",null),_n([G({message:"Label.useTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],fn.prototype,"useTextShadow",null),_n([G({message:"Label.clearTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],fn.prototype,"clearTextShadow",null);class mn{static create(t,e){if(this._CURRENT_GROUP>this._MAX_GROUPS)throw new Error(`Cannot have more than ${this._MAX_GROUPS} collision groups`);if(this._GROUPS.get(t))throw new Error(`Collision group ${t} already exists`);const i=new ci(t,this._CURRENT_BIT,void 0!==e?e:~this._CURRENT_BIT);return this._CURRENT_BIT=this._CURRENT_BIT<<1|0,this._CURRENT_GROUP++,this._GROUPS.set(t,i),i}static get groups(){return Array.from(this._GROUPS.values())}static groupByName(t){return this._GROUPS.get(t)}static reset(){this._GROUPS=new Map,this._CURRENT_BIT=this._STARTING_BIT,this._CURRENT_GROUP=1}}mn._STARTING_BIT=1,mn._MAX_GROUPS=32,mn._CURRENT_GROUP=1,mn._CURRENT_BIT=mn._STARTING_BIT,mn._GROUPS=new Map;var wn=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};let yn=class{constructor(t){this.lineWidth=5,this.filled=!1,this._points=[],this.anchor=X.Zero,this.offset=X.Zero,this.rotation=0,this.scale=X.One,this.opacity=1,this._points=t;const e=this._points.reduce((t,e)=>Math.min(t,e.x),0),i=this._points.reduce((t,e)=>Math.max(t,e.x),0);this.drawWidth=i-e;const s=this._points.reduce((t,e)=>Math.min(t,e.y),0),r=this._points.reduce((t,e)=>Math.max(t,e.y),0);this.drawHeight=r-s,this.height=this.drawHeight,this.width=this.drawWidth}addEffect(){}removeEffect(){}clearEffects(){}reset(){}draw(t,e,i){t instanceof CanvasRenderingContext2D?this._drawWithOptions({ctx:t,x:e,y:i}):this._drawWithOptions(t)}_drawWithOptions(t){var e,i,s,r,n,o,a,h,l;const{ctx:c,x:d,y:u,rotation:p,drawWidth:g,drawHeight:_,anchor:f,offset:m,opacity:w,flipHorizontal:y,flipVertical:v}=Object.assign(Object.assign({},t),{rotation:null!==(e=t.rotation)&&void 0!==e?e:this.rotation,drawWidth:null!==(i=t.drawWidth)&&void 0!==i?i:this.drawWidth,drawHeight:null!==(s=t.drawHeight)&&void 0!==s?s:this.drawHeight,flipHorizontal:null!==(r=t.flipHorizontal)&&void 0!==r?r:this.flipHorizontal,flipVertical:null!==(n=t.flipVertical)&&void 0!==n?n:this.flipVertical,anchor:null!==(o=t.anchor)&&void 0!==o?o:this.anchor,offset:null!==(a=t.offset)&&void 0!==a?a:this.offset,opacity:(null!==(h=t.opacity)&&void 0!==h?h:1)*(null!==(l=this.opacity)&&void 0!==l?l:1)}),x=g*f.x+m.x+d,b=_*f.y+m.y+u;c.save(),c.translate(x,b),c.scale(this.scale.x,this.scale.y),c.rotate(p),c.beginPath(),c.lineWidth=this.lineWidth;const C=this._points[0];c.moveTo(C.x,C.y);let A=0;const S=this._points.length;for(;A<S;A++)c.lineTo(this._points[A].x,this._points[A].y);c.lineTo(C.x,C.y),c.closePath(),this.filled&&(c.fillStyle=this.fillColor.toString(),c.fill()),c.strokeStyle=this.lineColor.toString(),y&&(c.translate(g,0),c.scale(-1,1)),v&&(c.translate(0,_),c.scale(1,-1));const P=c.globalAlpha;c.globalAlpha=w,c.stroke(),c.globalAlpha=P,c.restore()}};yn=wn([G({message:"Polygon will be removed in v0.26.0",alternateMethod:"Use Graphics.Polygon"})],yn);class vn{}function xn(t){return!!t._initialize}function bn(t){return!!t.onInitialize}function Cn(t){return!!t._preupdate}function An(t){return!!t.onPreUpdate}function Sn(t){return!!t.onPostUpdate}function Pn(t){return!!t.onPostUpdate}function En(t){return!!t.onPreDraw}function Tn(t){return!!t.onPostDraw}vn.type={any:"",blob:"blob",json:"json",text:"text",document:"document",arraybuffer:"arraybuffer"};class Rn{constructor(t){this._src=t,this._volume=1,this._duration=void 0,this._loop=!1,this._isPlaying=!1,this._isPaused=!1,this._audioContext=it.create(),this._volumeNode=this._audioContext.createGain(),this._currentOffset=0,this._createNewBufferSource()}set loop(t){this._loop=t,this._instance&&(this._instance.loop=t,this._wireUpOnEnded())}get loop(){return this._loop}set volume(t){t=A(t,0,1),this._volume=t,this._isPlaying&&this._volumeNode.gain.setTargetAtTime?this._volumeNode.gain.setTargetAtTime(t,this._audioContext.currentTime,.1):this._volumeNode.gain.value=t}get volume(){return this._volume}set duration(t){this._duration=t}get duration(){return this._duration}get _playbackRate(){return this._instance?1/(this._instance.playbackRate.value||1):null}isPlaying(){return this._isPlaying}play(t=(()=>{})){return this._isPaused&&(this._resumePlayBack(),t()),this._isPlaying||(this._startPlayBack(),t()),this._playingPromise}pause(){this._isPlaying&&(this._isPaused=!0,this._isPlaying=!1,this._instance.stop(0),this._setPauseOffset())}stop(){this._isPlaying&&(this._isPlaying=!1,this._isPaused=!1,this._currentOffset=0,this._instance.stop(0),this._instance.onended||this._handleOnEnded())}_startPlayBack(){this._isPlaying=!0,this._isPaused=!1,this._playingPromise=new Promise(t=>{this._playingResolve=t}),this._instance||this._createNewBufferSource(),this._rememberStartTime(),this._volumeNode.connect(this._audioContext.destination),this._instance.start(0,0),this._currentOffset=0,this._wireUpOnEnded()}_resumePlayBack(){if(!this._isPaused)return;this._isPaused=!1,this._isPlaying=!0,this._instance.onended=null,this._createNewBufferSource();const t=this._playbackRate*this._src.duration,e=this._currentOffset%t;this._rememberStartTime(-1e3*e),this._instance.start(0,e),this._wireUpOnEnded()}_wireUpOnEnded(){this.loop||(this._instance.onended=()=>this._handleOnEnded())}_handleOnEnded(){this._isPaused||(this._isPlaying=!1,this._playingResolve(!0))}_rememberStartTime(t){this._startTime=(new Date).getTime()+(0|t)}_setPauseOffset(){this._currentOffset=((new Date).getTime()-this._startTime)*this._playbackRate/1e3}_createNewBufferSource(){this._instance=this._audioContext.createBufferSource(),this._instance.buffer=this._src,this._instance.loop=this.loop,this._instance.playbackRate.setValueAtTime(1,0),this._instance.connect(this._volumeNode)}}function Dn(t){try{const e=new Audio,i=/.*\.([A-Za-z0-9]+)$/,s=t.match(i)[1];return!!e.canPlayType("audio/"+s)}catch(t){return _.getInstance().warn("Cannot determine audio support, assuming no support for the Audio Tag",t),!1}}var Mn=function(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(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(o,a)}h((s=s.apply(t,e||[])).next())}))};class Bn extends Wt{constructor(...t){super(),this.logger=_.getInstance(),this._loop=!1,this._volume=1,this._duration=void 0,this._isStopped=!1,this._isPaused=!1,this._tracks=[],this._wasPlayingOnHidden=!1,this._audioContext=it.create(),this._resource=new ae("",vn.type.arraybuffer);for(const e of t)if(Dn(e)){this.path=e;break}this.path||(this.logger.warn("This browser does not support any of the audio files specified:",t.join(", ")),this.logger.warn("Attempting to use",t[0]),this.path=t[0])}set loop(t){this._loop=t;for(const t of this._tracks)t.loop=this._loop;this.logger.debug("Set loop for all instances of sound",this.path,"to",this._loop)}get loop(){return this._loop}set volume(t){this._volume=t;for(const t of this._tracks)t.volume=this._volume;this.emit("volumechange",new dn(this)),this.logger.debug("Set loop for all instances of sound",this.path,"to",this._volume)}get volume(){return this._volume}get duration(){return this._duration}get instances(){return this._tracks}get path(){return this._resource.path}set path(t){this._resource.path=t}isLoaded(){return!!this.data}load(){return Mn(this,void 0,void 0,(function*(){if(this.data)return this.data;const t=yield this._resource.load(),e=yield this.decodeAudio(t.slice(0));return this._duration="object"==typeof e?e.duration:void 0,this.emit("processed",new un(this,e)),this.data=e}))}decodeAudio(t){return Mn(this,void 0,void 0,(function*(){try{return yield this._audioContext.decodeAudioData(t.slice(0))}catch(t){return this.logger.error("Unable to decode this browser may not fully support this format, or the file may be corrupt, if this is an mp3 try removing id3 tags and album art from the file."),yield Promise.reject()}}))}wireEngine(t){t&&(this._engine=t,this._engine.on("hidden",()=>{t.pauseAudioWhenHidden&&this.isPlaying()&&(this._wasPlayingOnHidden=!0,this.pause())}),this._engine.on("visible",()=>{t.pauseAudioWhenHidden&&this._wasPlayingOnHidden&&(this.play(),this._wasPlayingOnHidden=!1)}),this._engine.on("start",()=>{this._isStopped=!1}),this._engine.on("stop",()=>{this.stop(),this._isStopped=!0}))}instanceCount(){return this._tracks.length}isPlaying(){return this._tracks.some(t=>t.isPlaying())}play(t){return this.isLoaded()?this._isStopped?(this.logger.warn("Cannot start playing. Engine is in a stopped state."),Promise.resolve(!1)):(this.volume=t||this.volume,this._isPaused?this._resumePlayback():this._startPlayback()):(this.logger.warn("Cannot start playing. Resource",this.path,"is not loaded yet"),Promise.resolve(!0))}pause(){if(this.isPlaying()){for(const t of this._tracks)t.pause();this._isPaused=!0,this.emit("pause",new dn(this)),this.logger.debug("Paused all instances of sound",this.path)}}stop(){for(const t of this._tracks)t.stop();this.emit("stop",new dn(this)),this._isPaused=!1,this._tracks.length=0,this.logger.debug("Stopped all instances of sound",this.path)}getTrackId(t){return this._tracks.indexOf(t)}_resumePlayback(){return Mn(this,void 0,void 0,(function*(){if(this._isPaused){const t=[];for(const e of this._tracks)t.push(e.play());this._isPaused=!1,this.emit("resume",new dn(this)),this.logger.debug("Resuming paused instances for sound",this.path,this._tracks),yield Promise.all(t)}return!0}))}_startPlayback(){return Mn(this,void 0,void 0,(function*(){const t=yield this._getTrackInstance(this.data),e=yield t.play(()=>{this.emit("playbackstart",new dn(this,t)),this.logger.debug("Playing new instance for sound",this.path)});return this.emit("playbackend",new dn(this,t)),this._tracks.splice(this.getTrackId(t),1),e}))}_getTrackInstance(t){const e=new Rn(t);return e.loop=this.loop,e.volume=this.volume,e.duration=this.duration,this._tracks.push(e),e}}var kn=function(t,e,i,s){return new(i||(i=Promise))((function(r,n){function o(t){try{h(s.next(t))}catch(t){n(t)}}function a(t){try{h(s.throw(t))}catch(t){n(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(o,a)}h((s=s.apply(t,e||[])).next())}))};class Fn{constructor(t,e=Q.Magenta,i=!0){this.path=t,this.color=e,this.bustCache=i,this._stream=null,this._gif=null,this._textures=[],this._animation=null,this._transparentColor=null,this._resource=new ae(t,"arraybuffer",i),this._transparentColor=e}load(){return kn(this,void 0,void 0,(function*(){const t=yield this._resource.load();this._stream=new On(t),this._gif=new zn(this._stream,this._transparentColor);const e=this._gif.images.map(t=>new ns(t.src,!1));return yield Promise.all(e.map(t=>t.load())),this.data=this._textures=e}))}isLoaded(){return!!this.data}toLegacySprite(t=0){return os.toLegacySprite(this.toSprite(t))}toLegacySpriteSheet(){return cs.toLegacySpriteSheet(this.toSpriteSheet())}toLegacyAnimation(t,e){return Zs.toLegacyAnimation(t,this.toAnimation(e))}toSprite(t=0){return this._textures[t].toSprite()}toSpriteSheet(){const t=this._textures.map(t=>t.toSprite());return new cs({sprites:t})}toAnimation(t){const e=this.toSpriteSheet(),i=e.sprites.length;return this._animation=Zs.fromSpriteSheet(e,z(0,i),t),this._animation}get readCheckBytes(){return this._gif.checkBytes}}const Ln=t=>t.reduce((function(t,e){return 2*t+e}),0),In=t=>{const e=[];for(let i=7;i>=0;i--)e.push(!!(t&1<<i));return e};class On{constructor(t){if(this.data=null,this.len=0,this.position=0,this.readByte=()=>{if(this.position>=this.data.byteLength)throw new Error("Attempted to read past end of stream.");return this.data[this.position++]},this.readBytes=t=>{const e=[];for(let i=0;i<t;i++)e.push(this.readByte());return e},this.read=t=>{let e="";for(let i=0;i<t;i++)e+=String.fromCharCode(this.readByte());return e},this.readUnsigned=()=>{const t=this.readBytes(2);return(t[1]<<8)+t[0]},this.data=new Uint8Array(t),this.len=this.data.byteLength,0===this.len)throw new Error("No data loaded from file")}}class zn{constructor(t,e=Q.Magenta){this._st=null,this._handler={},this._transparentColor=null,this.frames=[],this.images=[],this.globalColorTable=[],this.checkBytes=[],this.parseColorTable=t=>{const e=[];for(let i=0;i<t;i++){const t="#"+this._st.readBytes(3).map(t=>{const e=t.toString(16);return 1===e.length?"0"+e:e}).join("");e.push(t)}return e},this.readSubBlocks=()=>{let t,e;e="";do{t=this._st.readByte(),e+=this._st.read(t)}while(0!==t);return e},this.parseHeader=()=>{const t={sig:null,ver:null,width:null,height:null,colorRes:null,globalColorTableSize:null,gctFlag:null,sorted:null,globalColorTable:[],bgColor:null,pixelAspectRatio:null};if(t.sig=this._st.read(3),t.ver=this._st.read(3),"GIF"!==t.sig)throw new Error("Not a GIF file.");t.width=this._st.readUnsigned(),t.height=this._st.readUnsigned();const e=In(this._st.readByte());t.gctFlag=e.shift(),t.colorRes=Ln(e.splice(0,3)),t.sorted=e.shift(),t.globalColorTableSize=Ln(e.splice(0,3)),t.bgColor=this._st.readByte(),t.pixelAspectRatio=this._st.readByte(),t.gctFlag&&(t.globalColorTable=this.parseColorTable(1<<t.globalColorTableSize+1),this.globalColorTable=t.globalColorTable),this._handler.hdr&&this._handler.hdr(t)&&this.checkBytes.push(this._handler.hdr)},this.parseExt=t=>{const e=t=>{this.checkBytes.push(this._st.readByte());const e=In(this._st.readByte());t.reserved=e.splice(0,3),t.disposalMethod=Ln(e.splice(0,3)),t.userInput=e.shift(),t.transparencyGiven=e.shift(),t.delayTime=this._st.readUnsigned(),t.transparencyIndex=this._st.readByte(),t.terminator=this._st.readByte(),this._handler.gce&&this._handler.gce(t)&&this.checkBytes.push(this._handler.gce)},i=t=>{t.comment=this.readSubBlocks(),this._handler.com&&this._handler.com(t)&&this.checkBytes.push(this._handler.com)},s=t=>{this.checkBytes.push(this._st.readByte()),t.ptHeader=this._st.readBytes(12),t.ptData=this.readSubBlocks(),this._handler.pte&&this._handler.pte(t)&&this.checkBytes.push(this._handler.pte)},r=t=>{const e=t=>{this.checkBytes.push(this._st.readByte()),t.unknown=this._st.readByte(),t.iterations=this._st.readUnsigned(),t.terminator=this._st.readByte(),this._handler.app&&this._handler.app.NETSCAPE&&this._handler.app.NETSCAPE(t)&&this.checkBytes.push(this._handler.app)},i=t=>{t.appData=this.readSubBlocks(),this._handler.app&&this._handler.app[t.identifier]&&this._handler.app[t.identifier](t)&&this.checkBytes.push(this._handler.app[t.identifier])};switch(this.checkBytes.push(this._st.readByte()),t.identifier=this._st.read(8),t.authCode=this._st.read(3),t.identifier){case"NETSCAPE":e(t);break;default:i(t)}},n=t=>{t.data=this.readSubBlocks(),this._handler.unknown&&this._handler.unknown(t)&&this.checkBytes.push(this._handler.unknown)};switch(t.label=this._st.readByte(),t.label){case 249:t.extType="gce",e(t);break;case 254:t.extType="com",i(t);break;case 1:t.extType="pte",s(t);break;case 255:t.extType="app",r(t);break;default:t.extType="unknown",n(t)}},this.parseImg=t=>{t.leftPos=this._st.readUnsigned(),t.topPos=this._st.readUnsigned(),t.width=this._st.readUnsigned(),t.height=this._st.readUnsigned();const e=In(this._st.readByte());t.lctFlag=e.shift(),t.interlaced=e.shift(),t.sorted=e.shift(),t.reserved=e.splice(0,2),t.lctSize=Ln(e.splice(0,3)),t.lctFlag&&(t.lct=this.parseColorTable(1<<t.lctSize+1)),t.lzwMinCodeSize=this._st.readByte();const i=this.readSubBlocks();t.pixels=function(t,e){let i=0;const s=function(t){let s=0;for(let r=0;r<t;r++)e.charCodeAt(i>>3)&1<<(7&i)&&(s|=1<<r),i++;return s},r=[],n=1<<t,o=n+1;let a=t+1,h=[];const l=function(){h=[],a=t+1;for(let t=0;t<n;t++)h[t]=[t];h[n]=[],h[o]=null};let c,d;for(;;)if(d=c,c=s(a),c!==n){if(c===o)break;if(c<h.length)d!==n&&h.push(h[d].concat(h[c][0]));else{if(c!==h.length)throw new Error("Invalid LZW code.");h.push(h[d].concat(h[d][0]))}r.push.apply(r,h[c]),h.length===1<<a&&a<12&&a++}else l();return r}(t.lzwMinCodeSize,i),t.interlaced&&(t.pixels=((t,e)=>{const i=new Array(t.length),s=t.length/e,r=(s,r)=>{const n=t.slice(r*e,(r+1)*e);i.splice.apply(i,[s*e,e].concat(n))},n=[0,4,2,1],o=[8,8,4,2];let a=0;for(let t=0;t<4;t++)for(let e=n[t];e<s;e+=o[t])r(e,a),a++;return i})(t.pixels,t.width)),this.frames.push(t),this.arrayToImage(t),this._handler.img&&this._handler.img(t)&&this.checkBytes.push(this._handler)},this.parseBlock=()=>{const t={sentinel:this._st.readByte(),type:""};switch(String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this._handler.eof&&this._handler.eof(t)&&this.checkBytes.push(this._handler.eof);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&this.parseBlock()},this.arrayToImage=t=>{let e=0;const i=document.createElement("canvas");i.id=e.toString(),i.width=t.width,i.height=t.height,e++;const s=i.getContext("2d");let r=0,n=0;for(let e=0;e<t.pixels.length;e++)n%t.width==0&&(r++,n=0),this.globalColorTable[t.pixels[e]]===this._transparentColor.toHex()?s.fillStyle="rgba(0, 0, 0, 0)":s.fillStyle=this.globalColorTable[t.pixels[e]],s.fillRect(n,r,1,1),n++;const o=new Image;o.src=i.toDataURL(),this.images.push(o)},this._st=t,this._handler={},this._transparentColor=e,this.parseHeader(),this.parseBlock()}}class Un extends ee{constructor(t){super(t),this.points=t.points,this.rasterize()}get points(){return this._points}set points(t){this._points=t;const e=this.minPoint;this.width=this._points.reduce((t,e)=>Math.max(e.x,t),0)-e.x,this.height=this._points.reduce((t,e)=>Math.max(e.y,t),0)-e.y,this.flagDirty()}get minPoint(){return q(this._points.reduce((t,e)=>Math.min(e.x,t),1/0),this._points.reduce((t,e)=>Math.min(e.y,t),1/0))}clone(){return new Un(Object.assign(Object.assign({points:this.points.map(t=>t.clone())},this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){if(this.points&&this.points.length){t.beginPath();const e=this.minPoint.negate(),i=this.points[0].add(e);t.moveTo(i.x,i.y),this.points.forEach(i=>{t.lineTo(i.x+e.x,i.y+e.y)}),t.lineTo(i.x,i.y),t.closePath(),this.color&&t.fill(),this.strokeColor&&t.stroke()}}}var Hn=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};let Nn=class{constructor(t){this._getComparable=t}find(t){return this._find(this._root,t)}_find(t,e){return null!=t&&(this._getComparable(e)===t.getKey()?t.getData().indexOf(e)>-1:this._getComparable(e)<t.getKey()?this._find(t.getLeft(),e):this._find(t.getRight(),e))}get(t){return this._get(this._root,t)}_get(t,e){return null==t?[]:e===t.getKey()?t.getData():e<t.getKey()?this._get(t.getLeft(),e):this._get(t.getRight(),e)}add(t){return null==this._root?(this._root=new Wn(this._getComparable(t),[t],null,null),!0):this._insert(this._root,t)}_insert(t,e){return null!=t&&(this._getComparable(e)===t.getKey()?!(t.getData().indexOf(e)>-1)&&(t.getData().push(e),!0):this._getComparable(e)<t.getKey()?null==t.getLeft()?(t.setLeft(new Wn(this._getComparable(e),[e],null,null)),!0):this._insert(t.getLeft(),e):null==t.getRight()?(t.setRight(new Wn(this._getComparable(e),[e],null,null)),!0):this._insert(t.getRight(),e))}removeByComparable(t){this._root=this._remove(this._root,t)}_remove(t,e){if(null==t)return null;if(this._getComparable(e)!==t.getKey())return this._getComparable(e)<t.getKey()?(t.setLeft(this._remove(t.getLeft(),e)),t):(t.setRight(this._remove(t.getRight(),e)),t);{const i=t.getData().indexOf(e);if(i>-1){if(t.getData().splice(i,1),0===t.getData().length){if(null==t.getLeft()&&null==t.getRight())return null;if(null==t.getLeft())return t.getRight();if(null==t.getRight())return t.getLeft();const e=this._findMinNode(t.getRight());return t.setKey(e.getKey()),t.setData(e.getData()),t.setRight(this._cleanup(t.getRight(),e)),t}return t}}return null}_cleanup(t,e){const i=e.getKey();if(null==t)return null;if(i===t.getKey()){if(null==t.getLeft()&&null==t.getRight())return null;if(null==t.getLeft())return t.getRight();if(null==t.getRight())return t.getLeft();const e=this._findMinNode(t.getRight());return t.setKey(e.getKey()),t.setData(e.getData()),t.setRight(this._cleanup(t.getRight(),e)),t}return e.getKey()<t.getKey()?(t.setLeft(this._cleanup(t.getLeft(),e)),t):(t.setRight(this._cleanup(t.getRight(),e)),t)}_findMinNode(t){let e=t;for(;null!=e.getLeft();)e=e.getLeft();return e}list(){const t=new Array;return this._list(this._root,t),t}_list(t,e){null!=t&&(this._list(t.getLeft(),e),t.getData().forEach(t=>{e.push(t)}),this._list(t.getRight(),e))}};Nn=Hn([G({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use built in JS array.sort"})],Nn);let Wn=class{constructor(t,e,i,s){this._key=t,this._data=e,this._left=i,this._right=s}getKey(){return this._key}setKey(t){this._key=t}getData(){return this._data}setData(t){this._data=t}getLeft(){return this._left}setLeft(t){this._left=t}getRight(){return this._right}setRight(t){this._right=t}};Wn=Hn([G({message:"Will be removed in excalibur v0.26.0"})],Wn);class Vn{constructor(t){this._key=0,this._key=t}getTheKey(){return this._key}setKey(t){this._key=t}}var Gn,jn,Xn=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};!function(t){t[t.Resolved=0]="Resolved",t[t.Rejected=1]="Rejected",t[t.Pending=2]="Pending"}(jn||(jn={}));let qn=Gn=class{constructor(){this._state=jn.Pending,this._successCallbacks=[],this._rejectCallback=()=>{}}static resolve(t){return(new Gn).resolve(t)}static reject(t){return(new Gn).reject(t)}static join(){let t=[];if(arguments.length>0&&!Array.isArray(arguments[0]))for(let e=0;e<arguments.length;e++)t[e-0]=arguments[e];else 1===arguments.length&&Array.isArray(arguments[0])&&(t=arguments[0]);const e=new Gn;if(!t||!t.length)return e.resolve();const i=t.length;let s=0,r=0;const n=[];return t.forEach(t=>{t.then(()=>{s+=1,s===i?e.resolve():s+r+n.length===i&&e.reject(n)},()=>{r+=1,s+r+n.length===i&&e.reject(n)}).error(t=>{n.push(t),n.length+s+r===i&&e.reject(n)})}),e}then(t,e){if(t&&(this._successCallbacks.push(t),this.state()===jn.Resolved))try{t.call(this,this._value)}catch(t){this._handleError(t)}if(e&&(this._rejectCallback=e,this.state()===jn.Rejected))try{e.call(this,this._value)}catch(t){this._handleError(t)}return this}error(t){return t&&(this._errorCallback=t),this}resolve(t){if(this._state!==jn.Pending)throw new Error("Cannot resolve a promise that is not in a pending state!");this._value=t;try{this._state=jn.Resolved,this._successCallbacks.forEach(t=>{t.call(this,this._value)})}catch(t){this._handleError(t)}return this}reject(t){if(this._state!==jn.Pending)throw new Error("Cannot reject a promise that is not in a pending state!");this._value=t;try{this._state=jn.Rejected,this._rejectCallback.call(this,this._value)}catch(t){this._handleError(t)}return this}state(){return this._state}_handleError(t){if(!this._errorCallback)throw t;this._errorCallback.call(this,t)}};qn=Gn=Xn([G({message:"ex.Promises are being replaced by native browser promises in v0.26.0",alternateMethod:"Use browser native promises"})],qn);const Kn="0.25.0";u()})(),s})()}));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ex=e():t.ex=e()}(self,(function(){return(()=>{var t={4662:(t,e,i)=>{i(3430);var s=i(8791);t.exports=s("Array","sort")},8343:(t,e,i)=>{i(4769);var s=i(9276);t.exports=s.Object.keys},7111:(t,e,i)=>{var s=i(6733),n=i(9821);t.exports=function(t){if(s(t))return t;throw TypeError(n(t)+" is not a function")}},1176:(t,e,i)=>{var s=i(5052);t.exports=function(t){if(s(t))return t;throw TypeError(String(t)+" is not an object")}},9540:(t,e,i)=>{var s=i(905),n=i(4237),r=i(3231),o=function(t){return function(e,i,o){var a,h=s(e),l=n(h.length),c=r(o,l);if(t&&i!=i){for(;l>c;)if((a=h[c++])!=a)return!0}else for(;l>c;c++)if((t||c in h)&&h[c]===i)return t||c||0;return!t&&-1}};t.exports={includes:o(!0),indexOf:o(!1)}},6038:(t,e,i)=>{"use strict";var s=i(4229);t.exports=function(t,e){var i=[][t];return!!i&&s((function(){i.call(null,e||function(){throw 1},1)}))}},3867:t=>{var e=Math.floor,i=function(t,r){var o=t.length,a=e(o/2);return o<8?s(t,r):n(i(t.slice(0,a),r),i(t.slice(a),r),r)},s=function(t,e){for(var i,s,n=t.length,r=1;r<n;){for(s=r,i=t[r];s&&e(t[s-1],i)>0;)t[s]=t[--s];s!==r++&&(t[s]=i)}return t},n=function(t,e,i){for(var s=t.length,n=e.length,r=0,o=0,a=[];r<s||o<n;)r<s&&o<n?a.push(i(t[r],e[o])<=0?t[r++]:e[o++]):a.push(r<s?t[r++]:e[o++]);return a};t.exports=i},7079:t=>{var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},1589:(t,e,i)=>{var s=i(1601),n=i(6733),r=i(7079),o=i(95)("toStringTag"),a="Arguments"==r(function(){return arguments}());t.exports=s?r:function(t){var e,i,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),o))?i:a?r(e):"Object"==(s=r(e))&&n(e.callee)?"Arguments":s}},7081:(t,e,i)=>{var s=i(816),n=i(4826),r=i(7933),o=i(1787);t.exports=function(t,e){for(var i=n(e),a=o.f,h=r.f,l=0;l<i.length;l++){var c=i[l];s(t,c)||a(t,c,h(e,c))}}},5762:(t,e,i)=>{var s=i(7400),n=i(1787),r=i(5358);t.exports=s?function(t,e,i){return n.f(t,e,r(1,i))}:function(t,e,i){return t[e]=i,t}},5358:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},7400:(t,e,i)=>{var s=i(4229);t.exports=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},2635:(t,e,i)=>{var s=i(9859),n=i(5052),r=s.document,o=n(r)&&n(r.createElement);t.exports=function(t){return o?r.createElement(t):{}}},2671:(t,e,i)=>{var s=i(598).match(/firefox\/(\d+)/i);t.exports=!!s&&+s[1]},8506:(t,e,i)=>{var s=i(598);t.exports=/MSIE|Trident/.test(s)},598:(t,e,i)=>{var s=i(1333);t.exports=s("navigator","userAgent")||""},6358:(t,e,i)=>{var s,n,r=i(9859),o=i(598),a=r.process,h=r.Deno,l=a&&a.versions||h&&h.version,c=l&&l.v8;c?n=(s=c.split("."))[0]<4?1:s[0]+s[1]:o&&(!(s=o.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=o.match(/Chrome\/(\d+)/))&&(n=s[1]),t.exports=n&&+n},9811:(t,e,i)=>{var s=i(598).match(/AppleWebKit\/(\d+)\./);t.exports=!!s&&+s[1]},8791:(t,e,i)=>{var s=i(9859),n=i(7636),r=Function.call;t.exports=function(t,e,i){return n(r,s[t].prototype[e],i)}},3837:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3103:(t,e,i)=>{var s=i(9859),n=i(7933).f,r=i(5762),o=i(7487),a=i(2079),h=i(7081),l=i(6541);t.exports=function(t,e){var i,c,d,u,p,g=t.target,_=t.global,f=t.stat;if(i=_?s:f?s[g]||a(g,{}):(s[g]||{}).prototype)for(c in e){if(u=e[c],d=t.noTargetGet?(p=n(i,c))&&p.value:i[c],!l(_?c:g+(f?".":"#")+c,t.forced)&&void 0!==d){if(typeof u==typeof d)continue;h(u,d)}(t.sham||d&&d.sham)&&r(u,"sham",!0),o(i,c,u,t)}}},4229:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},7636:(t,e,i)=>{var s=i(7111);t.exports=function(t,e,i){if(s(t),void 0===e)return t;switch(i){case 0:return function(){return t.call(e)};case 1:return function(i){return t.call(e,i)};case 2:return function(i,s){return t.call(e,i,s)};case 3:return function(i,s,n){return t.call(e,i,s,n)}}return function(){return t.apply(e,arguments)}}},1805:(t,e,i)=>{var s=i(7400),n=i(816),r=Function.prototype,o=s&&Object.getOwnPropertyDescriptor,a=n(r,"name"),h=a&&"something"===function(){}.name,l=a&&(!s||s&&o(r,"name").configurable);t.exports={EXISTS:a,PROPER:h,CONFIGURABLE:l}},1333:(t,e,i)=>{var s=i(9859),n=i(6733),r=function(t){return n(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?r(s[t]):s[t]&&s[t][e]}},5300:(t,e,i)=>{var s=i(7111);t.exports=function(t,e){var i=t[e];return null==i?void 0:s(i)}},9859:(t,e,i)=>{var s=function(t){return t&&t.Math==Math&&t};t.exports=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof i.g&&i.g)||function(){return this}()||Function("return this")()},816:(t,e,i)=>{var s=i(2991),n={}.hasOwnProperty;t.exports=Object.hasOwn||function(t,e){return n.call(s(t),e)}},5977:t=>{t.exports={}},4394:(t,e,i)=>{var s=i(7400),n=i(4229),r=i(2635);t.exports=!s&&!n((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))},9337:(t,e,i)=>{var s=i(4229),n=i(7079),r="".split;t.exports=s((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==n(t)?r.call(t,""):Object(t)}:Object},8511:(t,e,i)=>{var s=i(6733),n=i(5353),r=Function.toString;s(n.inspectSource)||(n.inspectSource=function(t){return r.call(t)}),t.exports=n.inspectSource},6407:(t,e,i)=>{var s,n,r,o=i(8694),a=i(9859),h=i(5052),l=i(5762),c=i(816),d=i(5353),u=i(4399),p=i(5977),g="Object already initialized",_=a.WeakMap;if(o||d.state){var f=d.state||(d.state=new _),m=f.get,y=f.has,w=f.set;s=function(t,e){if(y.call(f,t))throw new TypeError(g);return e.facade=t,w.call(f,t,e),e},n=function(t){return m.call(f,t)||{}},r=function(t){return y.call(f,t)}}else{var v=u("state");p[v]=!0,s=function(t,e){if(c(t,v))throw new TypeError(g);return e.facade=t,l(t,v,e),e},n=function(t){return c(t,v)?t[v]:{}},r=function(t){return c(t,v)}}t.exports={set:s,get:n,has:r,enforce:function(t){return r(t)?n(t):s(t,{})},getterFor:function(t){return function(e){var i;if(!h(e)||(i=n(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return i}}}},6733:t=>{t.exports=function(t){return"function"==typeof t}},6541:(t,e,i)=>{var s=i(4229),n=i(6733),r=/#|\.prototype\./,o=function(t,e){var i=h[a(t)];return i==c||i!=l&&(n(e)?s(e):!!e)},a=o.normalize=function(t){return String(t).replace(r,".").toLowerCase()},h=o.data={},l=o.NATIVE="N",c=o.POLYFILL="P";t.exports=o},5052:(t,e,i)=>{var s=i(6733);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},4231:t=>{t.exports=!1},9395:(t,e,i)=>{var s=i(6733),n=i(1333),r=i(6969);t.exports=r?function(t){return"symbol"==typeof t}:function(t){var e=n("Symbol");return s(e)&&Object(t)instanceof e}},3839:(t,e,i)=>{var s=i(6358),n=i(4229);t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))},8694:(t,e,i)=>{var s=i(9859),n=i(6733),r=i(8511),o=s.WeakMap;t.exports=n(o)&&/native code/.test(r(o))},1787:(t,e,i)=>{var s=i(7400),n=i(4394),r=i(1176),o=i(9310),a=Object.defineProperty;e.f=s?a:function(t,e,i){if(r(t),e=o(e),r(i),n)try{return a(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},7933:(t,e,i)=>{var s=i(7400),n=i(9195),r=i(5358),o=i(905),a=i(9310),h=i(816),l=i(4394),c=Object.getOwnPropertyDescriptor;e.f=s?c:function(t,e){if(t=o(t),e=a(e),l)try{return c(t,e)}catch(t){}if(h(t,e))return r(!n.f.call(t,e),t[e])}},8151:(t,e,i)=>{var s=i(140),n=i(3837).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,n)}},894:(t,e)=>{e.f=Object.getOwnPropertySymbols},140:(t,e,i)=>{var s=i(816),n=i(905),r=i(9540).indexOf,o=i(5977);t.exports=function(t,e){var i,a=n(t),h=0,l=[];for(i in a)!s(o,i)&&s(a,i)&&l.push(i);for(;e.length>h;)s(a,i=e[h++])&&(~r(l,i)||l.push(i));return l}},5632:(t,e,i)=>{var s=i(140),n=i(3837);t.exports=Object.keys||function(t){return s(t,n)}},9195:(t,e)=>{"use strict";var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,n=s&&!i.call({1:2},1);e.f=n?function(t){var e=s(this,t);return!!e&&e.enumerable}:i},2914:(t,e,i)=>{var s=i(6733),n=i(5052);t.exports=function(t,e){var i,r;if("string"===e&&s(i=t.toString)&&!n(r=i.call(t)))return r;if(s(i=t.valueOf)&&!n(r=i.call(t)))return r;if("string"!==e&&s(i=t.toString)&&!n(r=i.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},4826:(t,e,i)=>{var s=i(1333),n=i(8151),r=i(894),o=i(1176);t.exports=s("Reflect","ownKeys")||function(t){var e=n.f(o(t)),i=r.f;return i?e.concat(i(t)):e}},9276:(t,e,i)=>{var s=i(9859);t.exports=s},7487:(t,e,i)=>{var s=i(9859),n=i(6733),r=i(816),o=i(5762),a=i(2079),h=i(8511),l=i(6407),c=i(1805).CONFIGURABLE,d=l.get,u=l.enforce,p=String(String).split("String");(t.exports=function(t,e,i,h){var l,d=!!h&&!!h.unsafe,g=!!h&&!!h.enumerable,_=!!h&&!!h.noTargetGet,f=h&&void 0!==h.name?h.name:e;n(i)&&("Symbol("===String(f).slice(0,7)&&(f="["+String(f).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!r(i,"name")||c&&i.name!==f)&&o(i,"name",f),(l=u(i)).source||(l.source=p.join("string"==typeof f?f:""))),t!==s?(d?!_&&t[e]&&(g=!0):delete t[e],g?t[e]=i:o(t,e,i)):g?t[e]=i:a(e,i)})(Function.prototype,"toString",(function(){return n(this)&&d(this).source||h(this)}))},8885:t=>{t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},2079:(t,e,i)=>{var s=i(9859);t.exports=function(t,e){try{Object.defineProperty(s,t,{value:e,configurable:!0,writable:!0})}catch(i){s[t]=e}return e}},4399:(t,e,i)=>{var s=i(3036),n=i(1441),r=s("keys");t.exports=function(t){return r[t]||(r[t]=n(t))}},5353:(t,e,i)=>{var s=i(9859),n=i(2079),r="__core-js_shared__",o=s[r]||n(r,{});t.exports=o},3036:(t,e,i)=>{var s=i(4231),n=i(5353);(t.exports=function(t,e){return n[t]||(n[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.18.1",mode:s?"pure":"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})},3231:(t,e,i)=>{var s=i(6051),n=Math.max,r=Math.min;t.exports=function(t,e){var i=s(t);return i<0?n(i+e,0):r(i,e)}},905:(t,e,i)=>{var s=i(9337),n=i(8885);t.exports=function(t){return s(n(t))}},6051:t=>{var e=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:e)(t)}},4237:(t,e,i)=>{var s=i(6051),n=Math.min;t.exports=function(t){return t>0?n(s(t),9007199254740991):0}},2991:(t,e,i)=>{var s=i(8885);t.exports=function(t){return Object(s(t))}},2066:(t,e,i)=>{var s=i(5052),n=i(9395),r=i(5300),o=i(2914),a=i(95)("toPrimitive");t.exports=function(t,e){if(!s(t)||n(t))return t;var i,h=r(t,a);if(h){if(void 0===e&&(e="default"),i=h.call(t,e),!s(i)||n(i))return i;throw TypeError("Can't convert object to primitive value")}return void 0===e&&(e="number"),o(t,e)}},9310:(t,e,i)=>{var s=i(2066),n=i(9395);t.exports=function(t){var e=s(t,"string");return n(e)?e:String(e)}},1601:(t,e,i)=>{var s={};s[i(95)("toStringTag")]="z",t.exports="[object z]"===String(s)},3326:(t,e,i)=>{var s=i(1589);t.exports=function(t){if("Symbol"===s(t))throw TypeError("Cannot convert a Symbol value to a string");return String(t)}},9821:t=>{t.exports=function(t){try{return String(t)}catch(t){return"Object"}}},1441:t=>{var e=0,i=Math.random();t.exports=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++e+i).toString(36)}},6969:(t,e,i)=>{var s=i(3839);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},95:(t,e,i)=>{var s=i(9859),n=i(3036),r=i(816),o=i(1441),a=i(3839),h=i(6969),l=n("wks"),c=s.Symbol,d=h?c:c&&c.withoutSetter||o;t.exports=function(t){return r(l,t)&&(a||"string"==typeof l[t])||(a&&r(c,t)?l[t]=c[t]:l[t]=d("Symbol."+t)),l[t]}},3430:(t,e,i)=>{"use strict";var s=i(3103),n=i(7111),r=i(2991),o=i(4237),a=i(3326),h=i(4229),l=i(3867),c=i(6038),d=i(2671),u=i(8506),p=i(6358),g=i(9811),_=[],f=_.sort,m=h((function(){_.sort(void 0)})),y=h((function(){_.sort(null)})),w=c("sort"),v=!h((function(){if(p)return p<70;if(!(d&&d>3)){if(u)return!0;if(g)return g<603;var t,e,i,s,n="";for(t=65;t<76;t++){switch(e=String.fromCharCode(t),t){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(s=0;s<47;s++)_.push({k:e+s,v:i})}for(_.sort((function(t,e){return e.v-t.v})),s=0;s<_.length;s++)e=_[s].k.charAt(0),n.charAt(n.length-1)!==e&&(n+=e);return"DGBEFHACIJK"!==n}}));s({target:"Array",proto:!0,forced:m||!y||!w||!v},{sort:function(t){void 0!==t&&n(t);var e=r(this);if(v)return void 0===t?f.call(e):f.call(e,t);var i,s,h=[],c=o(e.length);for(s=0;s<c;s++)s in e&&h.push(e[s]);for(h=l(h,function(t){return function(e,i){return void 0===i?-1:void 0===e?1:void 0!==t?+t(e,i)||0:a(e)>a(i)?1:-1}}(t)),i=h.length,s=0;s<i;)e[s]=h[s++];for(;s<c;)delete e[s++];return e}})},4769:(t,e,i)=>{var s=i(3103),n=i(2991),r=i(5632);s({target:"Object",stat:!0,forced:i(4229)((function(){r(1)}))},{keys:function(t){return r(n(t))}})},1388:(t,e,i)=>{"use strict";i.d(e,{Z:()=>a});var s=i(272),n=i.n(s),r=i(2609),o=i.n(r)()(n());o.push([t.id,"/* Buttons styles start */\r\n\r\nbutton#excalibur-play {\r\n display: inline-block;\r\n position: relative;\r\n z-index: 999;\r\n border-radius: 6px;\r\n border: none;\r\n /*border: 3px solid;\r\n border-color: white;\r\n box-shadow: 0 0 10px #ccc;*/\r\n padding: 1rem 1.5rem 1rem 4rem;\r\n margin: 0;\r\n text-decoration: none;\r\n background: #00b233;\r\n color: #ffffff;\r\n font-family: sans-serif;\r\n font-size: 2rem;\r\n white-space: nowrap;\r\n line-height: 1;\r\n cursor: pointer;\r\n text-align: center;\r\n transition: background 250ms ease-in-out, transform 150ms ease;\r\n -webkit-appearance: none;\r\n -moz-appearance: none;\r\n\r\n -webkit-animation: excalibur-button-fadein 200ms; /* Safari, Chrome and Opera > 12.1 */\r\n -moz-animation: excalibur-button-fadein 200ms; /* Firefox < 16 */\r\n -ms-animation: excalibur-button-fadein 200ms; /* Internet Explorer */\r\n -o-animation: excalibur-button-fadein 200ms; /* Opera < 12.1 */\r\n animation: excalibur-button-fadein 200ms;\r\n}\r\n\r\n/*\r\nbutton#excalibur-play {\r\n display: none;\r\n}*/\r\n\r\nbutton#excalibur-play:after {\r\n position: absolute;\r\n content: '';\r\n border: 8px solid;\r\n border-color: transparent transparent transparent white;\r\n left: 35px;\r\n top: 24px;\r\n width: 0;\r\n height: 0;\r\n}\r\n\r\nbutton#excalibur-play:before {\r\n position: absolute;\r\n content: '';\r\n border: 3px solid;\r\n left: 19px;\r\n top: 14px;\r\n border-radius: 20px;\r\n width: 30px;\r\n height: 30px;\r\n}\r\n\r\nbutton#excalibur-play:hover,\r\nbutton#excalibur-play:focus {\r\n background: #00982c;\r\n}\r\n\r\nbutton#excalibur-play:focus {\r\n outline: 1px solid #fff;\r\n outline-offset: -4px;\r\n}\r\n\r\nbutton#excalibur-play:active {\r\n transform: scale(0.99);\r\n}\r\n\r\n@keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Firefox < 16 */\r\n@-moz-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Safari, Chrome and Opera > 12.1 */\r\n@-webkit-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Internet Explorer */\r\n@-ms-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Opera < 12.1 */\r\n@-o-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n","",{version:3,sources:["webpack://./Loader.css"],names:[],mappings:"AAAA,yBAAyB;;AAEzB;EACE,qBAAqB;EACrB,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,YAAY;EACZ;;+BAE6B;EAC7B,8BAA8B;EAC9B,SAAS;EACT,qBAAqB;EACrB,mBAAmB;EACnB,cAAc;EACd,uBAAuB;EACvB,eAAe;EACf,mBAAmB;EACnB,cAAc;EACd,eAAe;EACf,kBAAkB;EAClB,8DAA8D;EAC9D,wBAAwB;EACxB,qBAAqB;;EAErB,gDAAgD,EAAE,oCAAoC;EACtF,6CAA6C,EAAE,iBAAiB;EAChE,4CAA4C,EAAE,sBAAsB;EACpE,2CAA2C,EAAE,iBAAiB;EAC9D,wCAAwC;AAC1C;;AAEA;;;EAGE;;AAEF;EACE,kBAAkB;EAClB,WAAW;EACX,iBAAiB;EACjB,uDAAuD;EACvD,UAAU;EACV,SAAS;EACT,QAAQ;EACR,SAAS;AACX;;AAEA;EACE,kBAAkB;EAClB,WAAW;EACX,iBAAiB;EACjB,UAAU;EACV,SAAS;EACT,mBAAmB;EACnB,WAAW;EACX,YAAY;AACd;;AAEA;;EAEE,mBAAmB;AACrB;;AAEA;EACE,uBAAuB;EACvB,oBAAoB;AACtB;;AAEA;EACE,sBAAsB;AACxB;;AAEA;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,iBAAiB;AACjB;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,oCAAoC;AACpC;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,sBAAsB;AACtB;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA,iBAAiB;AACjB;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF",sourcesContent:["/* Buttons styles start */\r\n\r\nbutton#excalibur-play {\r\n display: inline-block;\r\n position: relative;\r\n z-index: 999;\r\n border-radius: 6px;\r\n border: none;\r\n /*border: 3px solid;\r\n border-color: white;\r\n box-shadow: 0 0 10px #ccc;*/\r\n padding: 1rem 1.5rem 1rem 4rem;\r\n margin: 0;\r\n text-decoration: none;\r\n background: #00b233;\r\n color: #ffffff;\r\n font-family: sans-serif;\r\n font-size: 2rem;\r\n white-space: nowrap;\r\n line-height: 1;\r\n cursor: pointer;\r\n text-align: center;\r\n transition: background 250ms ease-in-out, transform 150ms ease;\r\n -webkit-appearance: none;\r\n -moz-appearance: none;\r\n\r\n -webkit-animation: excalibur-button-fadein 200ms; /* Safari, Chrome and Opera > 12.1 */\r\n -moz-animation: excalibur-button-fadein 200ms; /* Firefox < 16 */\r\n -ms-animation: excalibur-button-fadein 200ms; /* Internet Explorer */\r\n -o-animation: excalibur-button-fadein 200ms; /* Opera < 12.1 */\r\n animation: excalibur-button-fadein 200ms;\r\n}\r\n\r\n/*\r\nbutton#excalibur-play {\r\n display: none;\r\n}*/\r\n\r\nbutton#excalibur-play:after {\r\n position: absolute;\r\n content: '';\r\n border: 8px solid;\r\n border-color: transparent transparent transparent white;\r\n left: 35px;\r\n top: 24px;\r\n width: 0;\r\n height: 0;\r\n}\r\n\r\nbutton#excalibur-play:before {\r\n position: absolute;\r\n content: '';\r\n border: 3px solid;\r\n left: 19px;\r\n top: 14px;\r\n border-radius: 20px;\r\n width: 30px;\r\n height: 30px;\r\n}\r\n\r\nbutton#excalibur-play:hover,\r\nbutton#excalibur-play:focus {\r\n background: #00982c;\r\n}\r\n\r\nbutton#excalibur-play:focus {\r\n outline: 1px solid #fff;\r\n outline-offset: -4px;\r\n}\r\n\r\nbutton#excalibur-play:active {\r\n transform: scale(0.99);\r\n}\r\n\r\n@keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Firefox < 16 */\r\n@-moz-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Safari, Chrome and Opera > 12.1 */\r\n@-webkit-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Internet Explorer */\r\n@-ms-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n\r\n/* Opera < 12.1 */\r\n@-o-keyframes excalibur-button-fadein {\r\n from {\r\n opacity: 0;\r\n }\r\n to {\r\n opacity: 1;\r\n }\r\n}\r\n"],sourceRoot:""}]);const a=o},2609:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i="",s=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),s&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),s&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i})).join("")},e.i=function(t,i,s,n,r){"string"==typeof t&&(t=[[null,t,void 0]]);var o={};if(s)for(var a=0;a<this.length;a++){var h=this[a][0];null!=h&&(o[h]=!0)}for(var l=0;l<t.length;l++){var c=[].concat(t[l]);s&&o[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),i&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=i):c[2]=i),n&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=n):c[4]="".concat(n)),e.push(c))}},e}},272:t=>{"use strict";t.exports=function(t){var e=t[1],i=t[3];if(!i)return e;if("function"==typeof btoa){var s=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),r="/*# ".concat(n," */"),o=i.sources.map((function(t){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(t," */")}));return[e].concat(o).concat([r]).join("\n")}return[e].join("\n")}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={id:s,exports:{}};return t[s](r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{"use strict";i.r(s),i.d(s,{ActionContext:()=>Ss,ActionQueue:()=>hs,ActionsComponent:()=>Ps,ActionsSystem:()=>Sn,ActivateEvent:()=>se,Actor:()=>Ts,AddedComponent:()=>qi,AddedEntity:()=>Ys,Animation:()=>mn,AnimationDirection:()=>gn,AnimationStrategy:()=>_n,ArcadeSolver:()=>cn,AudioContextFactory:()=>Ye,Axis:()=>Ms,BaseAlign:()=>Ie,BinaryTreeNode:()=>qr,Blink:()=>ws,BodyComponent:()=>Vi,BoundingBox:()=>J,BroadphaseStrategy:()=>di,BrowserComponent:()=>ar,BrowserEvents:()=>hr,Camera:()=>Gs,Canvas:()=>At,Cell:()=>Os,Circle:()=>ns,CircleCollider:()=>Fi,Class:()=>$e,ClosestLine:()=>Mi,ClosestLineJumpTable:()=>ki,Collider:()=>Ri,ColliderComponent:()=>Wi,CollisionContact:()=>Li,CollisionEndEvent:()=>ee,CollisionGroup:()=>xi,CollisionGroupManager:()=>br,CollisionJumpTable:()=>Oi,CollisionPostSolveEvent:()=>Jt,CollisionPreSolveEvent:()=>$t,CollisionResolutionStrategy:()=>ci,CollisionSolver:()=>ln,CollisionStartEvent:()=>te,CollisionSystem:()=>pn,CollisionType:()=>li,Color:()=>Q,ColorBlindCorrector:()=>Ln,ColorBlindFlags:()=>In,ColorBlindness:()=>Pn,Component:()=>fi,CompositeCollider:()=>Di,Configurable:()=>Ce,ConsoleAppender:()=>f,ContactConstraintPoint:()=>dn,ContactEndEvent:()=>Qt,ContactStartEvent:()=>Yt,CoordPlane:()=>yi,CullingBox:()=>Gi,DeactivateEvent:()=>ne,Debug:()=>On,DebugSystem:()=>An,DebugText:()=>Ge,DegreeOfFreedom:()=>Ni,Detector:()=>hi,Die:()=>bs,Direction:()=>ze,DisplayMode:()=>qe,DynamicTree:()=>Pi,DynamicTreeCollisionProcessor:()=>Ti,EX_VERSION:()=>Jr,EaseTo:()=>ys,EasingFunctions:()=>as,EdgeCollider:()=>zi,ElasticToActorStrategy:()=>Ws,EmitterType:()=>fn,Engine:()=>pr,EnterTriggerEvent:()=>ae,EnterViewPortEvent:()=>oe,Entity:()=>Qi,EntityManager:()=>tn,EventDispatcher:()=>le,EventTypes:()=>St,Events:()=>t,ExResponse:()=>Sr,ExcaliburGraphicsContext2DCanvas:()=>cr,ExcaliburGraphicsContextWebGL:()=>Xe,ExitTriggerEvent:()=>he,ExitViewPortEvent:()=>re,Experiments:()=>l,Fade:()=>vs,Flags:()=>p,Follow:()=>Cs,Font:()=>yr,FontStyle:()=>Oe,FontUnit:()=>Fe,FrameStats:()=>zn,GameEvent:()=>Pt,GameStartEvent:()=>Dt,GameStopEvent:()=>Bt,GamepadAxisEvent:()=>Vt,GamepadButtonEvent:()=>Nt,GamepadConnectEvent:()=>Ht,GamepadDisconnectEvent:()=>Wt,Gif:()=>Ur,GlobalCoordinates:()=>tr,Graphic:()=>vt,GraphicsComponent:()=>is,GraphicsGroup:()=>yn,GraphicsLayer:()=>ts,GraphicsLayers:()=>es,GraphicsSystem:()=>bn,HiddenEvent:()=>qt,ImageSource:()=>De,InitializeEvent:()=>ie,Input:()=>o,Integrator:()=>ui,KillEvent:()=>Et,Label:()=>xr,Legacy:()=>c,LegacyDrawing:()=>r,LimitCameraBoundsStrategy:()=>Vs,Line:()=>Bi,Loader:()=>oi,LockCameraToActorAxisStrategy:()=>Hs,LockCameraToActorStrategy:()=>Us,LogLevel:()=>d,Logger:()=>_,Matrix:()=>et,MatrixLocations:()=>Z,MediaEvent:()=>_r,Meet:()=>As,MockedElement:()=>Kr,MotionComponent:()=>vi,MotionSystem:()=>hn,MoveBy:()=>ds,MoveTo:()=>us,NativeSoundEvent:()=>fr,NativeSoundProcessedEvent:()=>mr,Observable:()=>bi,Pair:()=>Ci,ParseGif:()=>Vr,Particle:()=>vn,ParticleEmitter:()=>xn,Physics:()=>gi,PhysicsStats:()=>Un,Polygon:()=>Gr,PolygonCollider:()=>Ui,Pool:()=>at,PostCollisionEvent:()=>Zt,PostDebugDrawEvent:()=>Lt,PostDrawEvent:()=>kt,PostFrameEvent:()=>Ut,PostKillEvent:()=>Rt,PostUpdateEvent:()=>Ot,PreCollisionEvent:()=>Kt,PreDebugDrawEvent:()=>Ft,PreDrawEvent:()=>Mt,PreFrameEvent:()=>zt,PreKillEvent:()=>Tt,PreUpdateEvent:()=>It,Projection:()=>Ai,Promise:()=>$r,PromiseState:()=>Yr,Query:()=>sn,QueryManager:()=>nn,RadiusAroundActorStrategy:()=>Ns,Random:()=>w,Raster:()=>Ct,Ray:()=>Ei,RealisticSolver:()=>un,Rectangle:()=>ss,RemovedComponent:()=>Zi,RemovedEntity:()=>$s,Repeat:()=>ls,RepeatForever:()=>cs,Resolution:()=>Ke,Resource:()=>ce,RotateBy:()=>gs,RotateTo:()=>ps,RotationType:()=>rs,ScaleBy:()=>fs,ScaleTo:()=>_s,Scene:()=>Fn,Screen:()=>Ze,ScreenAppender:()=>m,ScreenElement:()=>Rs,ScrollPreventionMode:()=>dr,Shape:()=>Hi,Side:()=>v,SortedList:()=>Xr,Sound:()=>Or,Sprite:()=>Te,SpriteFont:()=>Ve,SpriteSheet:()=>Ne,StrategyContainer:()=>zs,Stream:()=>Nr,SubscribeEvent:()=>Gt,System:()=>Zs,SystemManager:()=>rn,SystemType:()=>Ks,TagComponent:()=>mi,Text:()=>wr,TextAlign:()=>Le,TileMap:()=>Ls,Timer:()=>Bs,Traits:()=>a,TransformComponent:()=>wi,TreeNode:()=>Si,Trigger:()=>qs,UnsubscribeEvent:()=>jt,Util:()=>h,Vector:()=>q,VectorView:()=>_i,VisibleEvent:()=>Xt,WebAudioInstance:()=>Fr,World:()=>on,canonicalizeAngle:()=>T,clamp:()=>S,createId:()=>g,hasGraphicsTick:()=>Ji,hasOnInitialize:()=>Er,hasOnPostUpdate:()=>Br,hasOnPreUpdate:()=>Rr,hasPostDraw:()=>kr,hasPreDraw:()=>Mr,has_initialize:()=>Pr,has_postupdate:()=>Dr,has_preupdate:()=>Tr,isAddedComponent:()=>Ki,isAddedSystemEntity:()=>Qs,isRemoveSystemEntity:()=>Js,isRemovedComponent:()=>Yi,maxMessages:()=>W,obsolete:()=>j,randomInRange:()=>P,randomIntInRange:()=>E,range:()=>U,resetObsoleteCounter:()=>V,toDegrees:()=>R,toRadians:()=>D,vec:()=>K});var t={};i.r(t),i.d(t,{ActivateEvent:()=>se,CollisionEndEvent:()=>ee,CollisionPostSolveEvent:()=>Jt,CollisionPreSolveEvent:()=>$t,CollisionStartEvent:()=>te,ContactEndEvent:()=>Qt,ContactStartEvent:()=>Yt,DeactivateEvent:()=>ne,EnterTriggerEvent:()=>ae,EnterViewPortEvent:()=>oe,EventTypes:()=>St,ExitTriggerEvent:()=>he,ExitViewPortEvent:()=>re,GameEvent:()=>Pt,GameStartEvent:()=>Dt,GameStopEvent:()=>Bt,GamepadAxisEvent:()=>Vt,GamepadButtonEvent:()=>Nt,GamepadConnectEvent:()=>Ht,GamepadDisconnectEvent:()=>Wt,HiddenEvent:()=>qt,InitializeEvent:()=>ie,KillEvent:()=>Et,PostCollisionEvent:()=>Zt,PostDebugDrawEvent:()=>Lt,PostDrawEvent:()=>kt,PostFrameEvent:()=>Ut,PostKillEvent:()=>Rt,PostUpdateEvent:()=>Ot,PreCollisionEvent:()=>Kt,PreDebugDrawEvent:()=>Ft,PreDrawEvent:()=>Mt,PreFrameEvent:()=>zt,PreKillEvent:()=>Tt,PreUpdateEvent:()=>It,SubscribeEvent:()=>Gt,UnsubscribeEvent:()=>jt,VisibleEvent:()=>Xt});var e={};i.r(e),i.d(e,{Colorize:()=>_e,Darken:()=>me,Desaturate:()=>we,Fill:()=>ve,Grayscale:()=>ue,Invert:()=>pe,Lighten:()=>fe,Opacity:()=>ge,Saturate:()=>ye});var n={};i.r(n),i.d(n,{circle:()=>si,line:()=>Je,point:()=>ti,roundRect:()=>ii,vector:()=>ei});var r={};i.r(r),i.d(r,{Animation:()=>ke,CanvasDrawComponent:()=>$i,CanvasDrawingSystem:()=>Cn,Effects:()=>e,Polygon:()=>Ar,Sprite:()=>Ee,SpriteFont:()=>We,SpriteSheet:()=>He,Texture:()=>be});var o={};i.r(o),i.d(o,{Axes:()=>or,Buttons:()=>rr,Gamepad:()=>nr,Gamepads:()=>sr,KeyEvent:()=>Hn,Keyboard:()=>Wn,Keys:()=>En,NativePointerButton:()=>Dn,Pointer:()=>Nn,PointerButton:()=>Bn,PointerCancelEvent:()=>Qn,PointerDownEvent:()=>qn,PointerDragEvent:()=>jn,PointerEnterEvent:()=>Zn,PointerEvent:()=>Vn,PointerEventFactory:()=>Gn,PointerLeaveEvent:()=>Yn,PointerMoveEvent:()=>Kn,PointerScope:()=>Rn,PointerType:()=>Tn,PointerUpEvent:()=>Xn,Pointers:()=>ir,WheelDeltaMode:()=>Mn,WheelEvent:()=>$n,createPointerEventByName:()=>Jn});var a={};i.r(a),i.d(a,{CapturePointer:()=>Xi,OffscreenCulling:()=>ji});var h={};i.r(h),i.d(h,{Collection:()=>O,ConsoleAppender:()=>f,DrawUtil:()=>n,EasingFunctions:()=>as,LogLevel:()=>d,Logger:()=>_,Observable:()=>bi,ScreenAppender:()=>m,TwoPI:()=>x,addItemToArray:()=>M,base64Encode:()=>C,canonicalizeAngle:()=>T,clamp:()=>S,contains:()=>F,delay:()=>H,extend:()=>b,fail:()=>z,getOppositeSide:()=>L,getPosition:()=>B,getSideFromDirection:()=>I,nullish:()=>A,randomInRange:()=>P,randomIntInRange:()=>E,range:()=>U,removeItemFromArray:()=>k,toDegrees:()=>R,toRadians:()=>D});var l,c,d;i(4662),i(8343);function u(){if("undefined"==typeof window&&(window={audioContext:function(){}}),"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setInterval(t,1e3/60)}),"undefined"==typeof window||window.cancelAnimationFrame||(window.cancelAnimationFrame=window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(){}),"undefined"!=typeof window&&!window.AudioContext){if(window.webkitAudioContext){const t=window.webkitAudioContext.prototype.decodeAudioData;window.webkitAudioContext.prototype.decodeAudioData=function(e){return new Promise(((i,s)=>{t.call(this,e,i,s)}))}}window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext}"undefined"==typeof window||window.devicePixelRatio||(window.devicePixelRatio=window.devicePixelRatio||1)}!function(t){t.WebGL="use-webgl"}(l||(l={})),function(t){t.Canvas="use-canvas-context",t.LegacyDrawing="use-legacy-drawing"}(c||(c={}));class p{static freeze(){p._FROZEN=!0}static _reset(){p._FROZEN=!1,p._FLAGS={}}static useWebGL(){p.enable(l.WebGL)}static useCanvasGraphicsContext(){p.enable(c.Canvas)}static useLegacyDrawing(){p.enable(c.LegacyDrawing)}static enable(t){if(this._FROZEN)throw Error("Feature flags can only be enabled before Engine constructor time");p._FLAGS[t]=!0}static disable(t){if(this._FROZEN)throw Error("Feature flags can only be disabled before Engine constructor time");p._FLAGS[t]=!1}static isEnabled(t){return!!p._FLAGS[t]}static show(){return Object.keys(p._FLAGS)}}function g(t,e){return{type:t,value:e}}p._FROZEN=!1,p._FLAGS={},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error",t[t.Fatal=4]="Fatal"}(d||(d={}));class _{constructor(){if(this._appenders=[],this.defaultLevel=d.Info,_._INSTANCE)throw new Error("Logger is a singleton");return _._INSTANCE=this,_._INSTANCE.addAppender(new f),_._INSTANCE}static getInstance(){return null==_._INSTANCE&&(_._INSTANCE=new _),_._INSTANCE}addAppender(t){this._appenders.push(t)}clearAppenders(){this._appenders.length=0}_log(t,e){null==t&&(t=this.defaultLevel);const i=this._appenders.length;for(let s=0;s<i;s++)t>=this.defaultLevel&&this._appenders[s].log(t,e)}debug(...t){this._log(d.Debug,t)}info(...t){this._log(d.Info,t)}warn(...t){this._log(d.Warn,t)}error(...t){this._log(d.Error,t)}fatal(...t){this._log(d.Fatal,t)}}_._INSTANCE=null;class f{log(t,e){if(!console&&!console.log&&console.warn&&console.error)return;const i=[];i.unshift.apply(i,e),i.unshift("["+d[t]+"] : "),t<d.Warn?console.log.apply?console.log.apply(console,i):console.log(i.join(" ")):t<d.Error?console.warn.apply?console.warn.apply(console,i):console.warn(i.join(" ")):console.error.apply?console.error.apply(console,i):console.error(i.join(" "))}}class m{constructor(t,e){this._messages=[],this._canvas=document.createElement("canvas"),this._canvas.width=t||window.innerWidth,this._canvas.height=e||window.innerHeight,this._canvas.style.position="absolute",this._ctx=this._canvas.getContext("2d"),document.body.appendChild(this._canvas)}log(t,e){const i=e.join(",");this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._messages.unshift("["+d[t]+"] : "+i);let s=10,n=1;for(let t=0;t<this._messages.length;t++)this._ctx.fillStyle="rgba(255,255,255,"+n.toFixed(2)+")",this._ctx.fillText(this._messages[t],200,s),s+=10,n=n>0?n-.05:0}}const y=4294967295;class w{constructor(t){this.seed=t,this._lowerMask=2147483647,this._upperMask=2147483648,this._w=32,this._n=624,this._m=397,this._a=2567483615,this._u=11,this._s=7,this._b=2636928640,this._t=15,this._c=4022730752,this._l=18,this._f=1812433253,this._mt=new Array(this._n),this._mt[0]=(t||Date.now())>>>0;for(let t=1;t<this._n;t++){const e=this._mt[t-1]^this._mt[t-1]>>>this._w-2;this._mt[t]=(this._f*((4294901760&e)>>>16)<<16)+this._f*(65535&e)+t>>>0}this._index=this._n}_twist(){const t=[0,this._a];let e=0,i=0;for(;i<this._n-this._m;i++)e=this._mt[i]&this._upperMask|this._mt[i+1]&this._lowerMask,this._mt[i]=this._mt[i+this._m]^e>>>1^t[1&e]&y;for(;i<this._n-1;i++)e=this._mt[i]&this._upperMask|this._mt[i+1]&this._lowerMask,this._mt[i]=this._mt[i+(this._m-this._n)]^e>>>1^t[1&e]&y;e=this._mt[this._n-1]&this._upperMask|this._mt[0]&this._lowerMask,this._mt[this._n-1]=this._mt[this._m-1]^e>>>1^t[1&e]&y,this._index=0}nextInt(){this._index>=this._n&&this._twist();let t=this._mt[this._index++];return t^=t>>>this._u,t^=t<<this._s&this._b,t^=t<<this._t&this._c,t^=t>>>this._l,t>>>0}next(){return this.nextInt()*(1/4294967296)}floating(t,e){return(e-t)*this.next()+t}integer(t,e){return Math.floor((e-t+1)*this.next()+t)}bool(t=.5){return this.next()<=t}pickOne(t){return t[this.integer(0,t.length-1)]}pickSet(t,e,i=!1){return i?this._pickSetWithDuplicates(t,e):this._pickSetWithoutDuplicates(t,e)}_pickSetWithoutDuplicates(t,e){if(e>t.length||e<0)throw new Error("Invalid number of elements to pick, must pick a value 0 < n <= length");if(e===t.length)return t;const i=new Array(e);let s=0;const n=t.slice(0);for(;s<e;){const t=this.integer(0,n.length-1);i[s++]=n[t],n.splice(t,1)}return i}_pickSetWithDuplicates(t,e){if(e<0)throw new Error("Invalid number of elements to pick, must pick a value 0 <= n < MAX_INT");const i=new Array(e);for(let s=0;s<e;s++)i[s]=this.pickOne(t);return i}shuffle(t){const e=t.slice(0);let i=null;for(let t=0;t<e.length-2;t++){const s=this.integer(t,e.length-1);i=e[t],e[t]=e[s],e[s]=i}return e}range(t,e,i){const s=new Array(t);for(let n=0;n<t;n++)s[n]=this.integer(e,i);return s}d4(){return this.integer(1,4)}d6(){return this.integer(1,6)}d8(){return this.integer(1,8)}d10(){return this.integer(1,10)}d12(){return this.integer(1,12)}d20(){return this.integer(1,20)}}var v;!function(t){t.None="None",t.Top="Top",t.Bottom="Bottom",t.Left="Left",t.Right="Right"}(v||(v={})),function(t){t.getOpposite=function(e){return e===t.Top?t.Bottom:e===t.Bottom?t.Top:e===t.Left?t.Right:e===t.Right?t.Left:t.None},t.fromDirection=function(e){const i=[q.Left,q.Right,q.Up,q.Down],s=[t.Left,t.Right,t.Top,t.Bottom];let n=-Number.MAX_VALUE,r=-1;for(let t=0;t<i.length;t++)i[t].dot(e)>n&&(n=i[t].dot(e),r=t);return s[r]}}(v||(v={}));const x=2*Math.PI;function b(){const t={};let e=!1,i=0;const s=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);const n="function"==typeof Object.assign;let r=null;for(r=n?Object.assign:function(i){for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e&&"[object Object]"===Object.prototype.toString.call(i[s])?t[s]=b(!0,t[s],i[s]):t[s]=i[s])};i<s;i++){const e=arguments[i];n?r(t,e):r(e)}return t}function C(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i="",s=0;for(;s<t.length;){const n=255&t.charCodeAt(s++),r=255&t.charCodeAt(s++),o=255&t.charCodeAt(s++),a=n>>2,h=(3&n)<<4|r>>4;let l,c;isNaN(r)?l=c=64:(l=(15&r)<<2|o>>6,c=isNaN(o)?64:63&o),i+=e.charAt(a)+e.charAt(h)+e.charAt(l)+e.charAt(c)}return i}function A(t,e){return null!=t?t:e}function S(t,e,i){return Math.min(Math.max(e,t),i)}function P(t,e,i=new w){return i?i.floating(t,e):t+Math.random()*(e-t)}function E(t,e,i=new w){return i?i.integer(t,e):Math.round(P(t,e))}function T(t){let e=t;if(t>x)for(;e>x;)e-=x;if(t<0)for(;e<0;)e+=x;return e}function R(t){return 180/Math.PI*t}function D(t){return t/180*Math.PI}function B(t){let e=0,i=0;const s=t=>{e+=t.offsetLeft,t.offsetParent&&s(t.offsetParent)},n=t=>{i+=t.offsetTop,t.offsetParent&&n(t.offsetParent)};return s(t),n(t),new q(e,i)}function M(t,e){return-1===e.indexOf(t)&&(e.push(t),!0)}function k(t,e){let i=-1;return(i=e.indexOf(t))>-1&&(e.splice(i,1),!0)}function F(t,e){for(let i=0;i<t.length;i++)if(t[i]===e)return!0;return!1}function L(t){return t===v.Top?v.Bottom:t===v.Bottom?v.Top:t===v.Left?v.Right:t===v.Right?v.Left:v.None}function I(t){const e=[q.Left,q.Right,q.Up,q.Down],i=[v.Left,v.Right,v.Top,v.Bottom];let s=-Number.MAX_VALUE,n=-1;for(let i=0;i<e.length;i++)e[i].dot(t)>s&&(s=e[i].dot(t),n=i);return i[n]}class O{constructor(t=O.DefaultSize){this._internalArray=null,this._endPointer=0,this._internalArray=new Array(t)}_resize(){const t=2*this._internalArray.length,e=new Array(t),i=this.count();for(let t=0;t<i;t++)e[t]=this._internalArray[t];delete this._internalArray,this._internalArray=e}push(t){return this._endPointer===this._internalArray.length&&this._resize(),this._internalArray[this._endPointer++]=t}pop(){return this._endPointer=this._endPointer-1<0?0:this._endPointer-1,this._internalArray[this._endPointer]}count(){return this._endPointer}clear(){this._endPointer=0}internalSize(){return this._internalArray.length}elementAt(t){if(t>=this.count())throw new Error("Invalid index "+t);return this._internalArray[t]}insert(t,e){return t>=this.count()&&this._resize(),this._internalArray[t]=e}remove(t){const e=this.count();if(0===e)throw new Error("Invalid parameter "+t);const i=this._internalArray[t];for(let i=t;i<e;i++)this._internalArray[i]=this._internalArray[i+1];return this._endPointer--,i}removeElement(t){const e=this._internalArray.indexOf(t);this.remove(e)}toArray(){return this._internalArray.slice(0,this._endPointer)}forEach(t){let e=0;const i=this.count();for(;e<i;e++)t.call(this,this._internalArray[e],e)}map(t){const e=this.count();for(let i=0;i<e;i++)this._internalArray[i]=t.call(this,this._internalArray[i],i)}}function z(t){throw new Error(t)}O.DefaultSize=200;const U=(t,e)=>Array.from(new Array(e-t+1),((e,i)=>i+t));function H(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}const W=5,N={},V=()=>{for(const t in N)N[t]=0},G=(t,e)=>{const i=p.isEnabled("suppress-obsolete-message");N[t]<W&&!i&&(_.getInstance().warn(t),console.trace&&e.showStackTrace&&console.trace()),N[t]++};function j(t){return t=b({},{message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrack:!1},t),function(e,i,s){if(s&&"function"!=typeof s.value&&"function"!=typeof s.get&&"function"!=typeof s.set)throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${e.name||""}${e.name&&i?".":""}${i||""}`} is marked obsolete: ${t.message}`+(t.alternateMethod?` Use ${t.alternateMethod} instead`:"");N[n]||(N[n]=0);const r=s?Object.assign({},s):e;if(!s){class e extends r{constructor(...e){G(n,t),super(...e)}}return e}return s&&s.value?(r.value=function(){return G(n,t),s.value.apply(this,arguments)},r):(s&&s.get&&(r.get=function(){return G(n,t),s.get.apply(this,arguments)}),s&&s.set&&(r.set=function(){return G(n,t),s.set.apply(this,arguments)}),r)}}var X=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class q{constructor(t,e){this._x=0,this._y=0,this._x=t,this._y=e}static get Zero(){return new q(0,0)}static get One(){return new q(1,1)}static get Half(){return new q(.5,.5)}static get Up(){return new q(0,-1)}static get Down(){return new q(0,1)}static get Left(){return new q(-1,0)}static get Right(){return new q(1,0)}static fromAngle(t){return new q(Math.cos(t),Math.sin(t))}static isValid(t){return null!=t&&(!isNaN(t.x)&&!isNaN(t.y)&&(t.x!==1/0&&t.y!==1/0&&t.x!==-1/0&&t.y!==-1/0))}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}get x(){return this._x}set x(t){this._x=t}get y(){return this._y}set y(t){this._y=t}setTo(t,e){this.x=t,this.y=e}equals(t,e=.001){return Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e}distance(t){return t||(t=q.Zero),Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))}squareDistance(t){return t||(t=q.Zero),Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2)}magnitude(){return this.distance()}get size(){return this.distance()}set size(t){const e=this.normalize().scale(t);this.setTo(e.x,e.y)}normalize(){const t=this.distance();return t>0?new q(this.x/t,this.y/t):new q(0,1)}average(t){return this.add(t).scale(.5)}scale(t){return t instanceof q?new q(this.x*t.x,this.y*t.y):new q(this.x*t,this.y*t)}add(t){return new q(this.x+t.x,this.y+t.y)}sub(t){return new q(this.x-t.x,this.y-t.y)}addEqual(t){return this.setTo(this.x+t.x,this.y+t.y),this}subEqual(t){return this.setTo(this.x-t.x,this.y-t.y),this}scaleEqual(t){return this.setTo(this.x*t,this.y*t),this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return t instanceof q?this.x*t.y-this.y*t.x:"number"==typeof t?new q(t*this.y,-t*this.x):void 0}static cross(t,e){return new q(-t*e.y,t*e.x)}perpendicular(){return new q(this.y,-this.x)}normal(){return this.perpendicular().normalize()}negate(){return this.scale(-1)}toAngle(){return Math.atan2(this.y,this.x)}rotate(t,e){e||(e=new q(0,0));const i=Math.sin(t),s=Math.cos(t),n=s*(this.x-e.x)-i*(this.y-e.y)+e.x,r=i*(this.x-e.x)+s*(this.y-e.y)+e.y;return new q(n,r)}clone(){return new q(this.x,this.y)}toString(t){return t?`(${this.x.toFixed(t)}, ${this.y.toFixed(t)})`:`(${this.x}, ${this.y})`}}function K(t,e){return new q(t,e)}X([j({message:"will be removed in favour of `.size` in version 0.25.0"})],q.prototype,"magnitude",null);var Z,Y=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class Q{constructor(t,e,i,s){this.r=t,this.g=e,this.b=i,this.a=null!=s?s:1}static fromRGB(t,e,i,s){return new Q(t,e,i,s)}static fromRGBString(t){let e=null;if(e=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i)){const t=parseInt(e[1],10),i=parseInt(e[2],10),s=parseInt(e[3],10);let n=1;return e[4]&&(n=parseFloat(e[4])),new Q(t,i,s,n)}throw new Error("Invalid rgb/a string: "+t)}static fromHex(t){let e=null;if(e=t.match(/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i)){const t=parseInt(e[1],16),i=parseInt(e[2],16),s=parseInt(e[3],16);let n=1;return e[4]&&(n=parseInt(e[4],16)/255),new Q(t,i,s,n)}throw new Error("Invalid hex string: "+t)}static fromHSL(t,e,i,s=1){return new $(t,e,i,s).toRGBA()}lighten(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.l+=(1-e.l)*t,e.toRGBA()}darken(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.l-=e.l*t,e.toRGBA()}saturate(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.s+=e.s*t,e.toRGBA()}desaturate(t=.1){const e=$.fromRGBA(this.r,this.g,this.b,this.a);return e.s-=e.s*t,e.toRGBA()}multiply(t){const e=t.r/255*this.r/255*255,i=t.g/255*this.g/255*255,s=t.b/255*this.b/255*255,n=t.a*this.a;return new Q(e,i,s,n)}mulitiply(t){return this.multiply(t)}screen(t){const e=t.invert(),i=t.invert();return e.multiply(i).invert()}invert(){return new Q(255-this.r,255-this.g,255-this.b,1-this.a)}average(t){const e=(t.r+this.r)/2,i=(t.g+this.g)/2,s=(t.b+this.b)/2,n=(t.a+this.a)/2;return new Q(e,i,s,n)}equal(t){return this.toString()===t.toString()}toString(t="rgb"){switch(t){case"rgb":return this.toRGBA();case"hsl":return this.toHSLA();case"hex":return this.toHex();default:throw new Error("Invalid Color format")}}_componentToHex(t){const e=t.toString(16);return 1===e.length?"0"+e:e}toHex(){return"#"+this._componentToHex(this.r)+this._componentToHex(this.g)+this._componentToHex(this.b)}toRGBA(){const t=String(this.r.toFixed(0))+", "+String(this.g.toFixed(0))+", "+String(this.b.toFixed(0));return void 0!==this.a||null!==this.a?"rgba("+t+", "+String(this.a)+")":"rgb("+t+")"}toHSLA(){return $.fromRGBA(this.r,this.g,this.b,this.a).toString()}fillStyle(){return this.toString()}clone(){return new Q(this.r,this.g,this.b,this.a)}static get Black(){return Q.fromHex("#000000")}static get White(){return Q.fromHex("#FFFFFF")}static get Gray(){return Q.fromHex("#808080")}static get LightGray(){return Q.fromHex("#D3D3D3")}static get DarkGray(){return Q.fromHex("#A9A9A9")}static get Yellow(){return Q.fromHex("#FFFF00")}static get Orange(){return Q.fromHex("#FFA500")}static get Red(){return Q.fromHex("#FF0000")}static get Vermilion(){return Q.fromHex("#FF5B31")}static get Vermillion(){return Q.Vermilion}static get Rose(){return Q.fromHex("#FF007F")}static get Magenta(){return Q.fromHex("#FF00FF")}static get Violet(){return Q.fromHex("#7F00FF")}static get Blue(){return Q.fromHex("#0000FF")}static get Azure(){return Q.fromHex("#007FFF")}static get Cyan(){return Q.fromHex("#00FFFF")}static get Viridian(){return Q.fromHex("#59978F")}static get Green(){return Q.fromHex("#00FF00")}static get Chartreuse(){return Q.fromHex("#7FFF00")}static get Transparent(){return Q.fromHex("#FFFFFF00")}static get ExcaliburBlue(){return Q.fromHex("#176BAA")}}Y([j({message:"Alias for incorrect spelling used in older versions, use multiply instead, will be removed in v0.25.0"})],Q.prototype,"mulitiply",null),Y([j({message:"Alias for incorrect spelling used in older versions",alternateMethod:"Vermilion"})],Q,"Vermillion",null);class ${constructor(t,e,i,s){this.h=t,this.s=e,this.l=i,this.a=s}static hue2rgb(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}static fromRGBA(t,e,i,s){t/=255,e/=255,i/=255;const n=Math.max(t,e,i),r=Math.min(t,e,i);let o,a;const h=(n+r)/2;if(n===r)o=a=0;else{const s=n-r;switch(a=h>.5?s/(2-n-r):s/(n+r),n){case t:o=(e-i)/s+(e<i?6:0);break;case e:o=(i-t)/s+2;break;case i:o=(t-e)/s+4}o/=6}return new $(o,a,h,s)}toRGBA(){let t,e,i;if(0===this.s)t=e=i=this.l;else{const s=this.l<.5?this.l*(1+this.s):this.l+this.s-this.l*this.s,n=2*this.l-s;t=$.hue2rgb(n,s,this.h+1/3),e=$.hue2rgb(n,s,this.h),i=$.hue2rgb(n,s,this.h-1/3)}return new Q(255*t,255*e,255*i,this.a)}toString(){return`hsla(${this.h.toFixed(0)}, ${this.s.toFixed(0)}, ${this.l.toFixed(0)}, ${this.a.toFixed(0)})`}}class J{constructor(t=0,e=0,i=0,s=0){"object"==typeof t?(this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom):"number"==typeof t&&(this.left=t,this.top=e,this.right=i,this.bottom=s)}static getSideFromIntersection(t){return t&&t?Math.abs(t.x)>Math.abs(t.y)?t.x<0?v.Right:v.Left:t.y<0?v.Bottom:v.Top:v.None}static fromPoints(t){let e=1/0,i=1/0,s=-1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r].x<e&&(e=t[r].x),t[r].x>s&&(s=t[r].x),t[r].y<i&&(i=t[r].y),t[r].y>n&&(n=t[r].y);return new J(e,i,s,n)}static fromDimension(t,e,i=q.Half,s=q.Zero){return new J(-t*i.x+s.x,-e*i.y+s.y,t-t*i.x+s.x,e-e*i.y+s.y)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}hasZeroDimensions(){return 0===this.width||0===this.height}get center(){return new q((this.left+this.right)/2,(this.top+this.bottom)/2)}translate(t){return new J(this.left+t.x,this.top+t.y,this.right+t.x,this.bottom+t.y)}rotate(t,e=q.Zero){const i=this.getPoints().map((i=>i.rotate(t,e)));return J.fromPoints(i)}scale(t,e=q.Zero){const i=this.translate(e);return new J(i.left*t.x,i.top*t.y,i.right*t.x,i.bottom*t.y)}transform(t){const e=this.getPoints().map((e=>t.multv(e)));return J.fromPoints(e)}getPerimeter(){return 2*(this.width+this.height)}getPoints(){const t=[];return t.push(new q(this.left,this.top)),t.push(new q(this.right,this.top)),t.push(new q(this.right,this.bottom)),t.push(new q(this.left,this.bottom)),t}rayCast(t,e=1/0){let i=-1/0,s=1/0;const n=0===t.dir.x?Number.MAX_VALUE:1/t.dir.x,r=0===t.dir.y?Number.MAX_VALUE:1/t.dir.y,o=(this.left-t.pos.x)*n,a=(this.right-t.pos.x)*n;i=Math.min(o,a),s=Math.max(o,a);const h=(this.top-t.pos.y)*r,l=(this.bottom-t.pos.y)*r;return i=Math.max(i,Math.min(h,l)),s=Math.min(s,Math.max(h,l)),s>=Math.max(0,i)&&i<e}rayCastTime(t,e=1/0){let i=-1/0,s=1/0;const n=0===t.dir.x?Number.MAX_VALUE:1/t.dir.x,r=0===t.dir.y?Number.MAX_VALUE:1/t.dir.y,o=(this.left-t.pos.x)*n,a=(this.right-t.pos.x)*n;i=Math.min(o,a),s=Math.max(o,a);const h=(this.top-t.pos.y)*r,l=(this.bottom-t.pos.y)*r;return i=Math.max(i,Math.min(h,l)),s=Math.min(s,Math.max(h,l)),s>=Math.max(0,i)&&i<e?i:-1}contains(t){return t instanceof q?this.left<=t.x&&this.top<=t.y&&this.bottom>=t.y&&this.right>=t.x:t instanceof J&&(this.left<t.left&&this.top<t.top&&t.bottom<this.bottom&&t.right<this.right)}combine(t){return new J(Math.min(this.left,t.left),Math.min(this.top,t.top),Math.max(this.right,t.right),Math.max(this.bottom,t.bottom))}get dimensions(){return new q(this.width,this.height)}intersect(t){const e=this.combine(t);if(e.width<t.width+this.width&&e.height<t.height+this.height&&!e.dimensions.equals(t.dimensions)&&!e.dimensions.equals(this.dimensions)){let e=0;e=this.right>=t.left&&this.right<=t.right?t.left-this.right:t.right-this.left;let i=0;return i=this.top<=t.bottom&&this.top>=t.top?t.bottom-this.top:t.top-this.bottom,Math.abs(e)<Math.abs(i)?new q(e,0):new q(0,i)}if(e.dimensions.equals(t.dimensions)||e.dimensions.equals(this.dimensions)){let e=0;e=this.width-t.width>=0?this.right-t.right<=t.left-this.left?t.left-this.right:t.right-this.left:t.right-this.right<=this.left-t.left?this.left-t.right:this.right-t.left;let i=0;return i=this.height-t.height>=0?this.bottom-t.bottom<=t.top-this.top?t.top-this.bottom:t.bottom-this.top:t.bottom-this.bottom<=this.top-t.top?this.top-t.bottom:this.bottom-t.top,Math.abs(e)<Math.abs(i)?new q(e,0):new q(0,i)}return null}intersectWithSide(t){const e=this.intersect(t);return J.getSideFromIntersection(e)}debugDraw(t,e=Q.Yellow){t.strokeStyle=e.toString(),t.strokeRect(this.left,this.top,this.width,this.height)}draw(t,e=Q.Yellow){t.debug.drawRect(this.left,this.top,this.width,this.height,{color:e})}}!function(t){t[t.X=12]="X",t[t.Y=13]="Y"}(Z||(Z={}));const tt=t=>0===t?0:t<0?-1:1;class et{constructor(){this.data=new Float32Array(16),this._scaleSignX=1,this._scaleSignY=1}static ortho(t,e,i,s,n,r){const o=new et;return o.data[0]=2/(e-t),o.data[1]=0,o.data[2]=0,o.data[3]=0,o.data[4]=0,o.data[5]=2/(s-i),o.data[6]=0,o.data[7]=0,o.data[8]=0,o.data[9]=0,o.data[10]=-2/(r-n),o.data[11]=0,o.data[12]=-(e+t)/(e-t),o.data[13]=-(s+i)/(s-i),o.data[14]=-(r+n)/(r-n),o.data[15]=1,o}clone(){const t=new et;return t.data[0]=this.data[0],t.data[1]=this.data[1],t.data[2]=this.data[2],t.data[3]=this.data[3],t.data[4]=this.data[4],t.data[5]=this.data[5],t.data[6]=this.data[6],t.data[7]=this.data[7],t.data[8]=this.data[8],t.data[9]=this.data[9],t.data[10]=this.data[10],t.data[11]=this.data[11],t.data[12]=this.data[12],t.data[13]=this.data[13],t.data[14]=this.data[14],t.data[15]=this.data[15],t}static identity(){const t=new et;return t.data[0]=1,t.data[1]=0,t.data[2]=0,t.data[3]=0,t.data[4]=0,t.data[5]=1,t.data[6]=0,t.data[7]=0,t.data[8]=0,t.data[9]=0,t.data[10]=1,t.data[11]=0,t.data[12]=0,t.data[13]=0,t.data[14]=0,t.data[15]=1,t}static translation(t,e){const i=et.identity();return i.data[12]=t,i.data[13]=e,i}static scale(t,e){const i=et.identity();return i.data[0]=t,i.data[5]=e,i.data[10]=1,i.data[15]=1,i}static rotation(t){const e=et.identity();return e.data[0]=Math.cos(t),e.data[4]=-Math.sin(t),e.data[1]=Math.sin(t),e.data[5]=Math.cos(t),e}multv(t){if(t instanceof q)return new q(t.x*this.data[0]+t.y*this.data[4]+0*this.data[6]+1*this.data[12],t.x*this.data[1]+t.y*this.data[5]+0*this.data[9]+1*this.data[13]);return[t[0]*this.data[0]+t[1]*this.data[4]+0*this.data[6]+1*this.data[12],t[0]*this.data[1]+t[1]*this.data[5]+0*this.data[9]+1*this.data[13]]}multm(t){const e=new et,i=this.data[0],s=this.data[1],n=this.data[2],r=this.data[3],o=this.data[4],a=this.data[5],h=this.data[6],l=this.data[7],c=this.data[8],d=this.data[9],u=this.data[10],p=this.data[11],g=this.data[12],_=this.data[13],f=this.data[14],m=this.data[15],y=t.data[0],w=t.data[1],v=t.data[2],x=t.data[3],b=t.data[4],C=t.data[5],A=t.data[6],S=t.data[7],P=t.data[8],E=t.data[9],T=t.data[10],R=t.data[11],D=t.data[12],B=t.data[13],M=t.data[14],k=t.data[15];e.data[0]=i*y+o*w+c*v+g*x,e.data[1]=s*y+a*w+d*v+_*x,e.data[2]=n*y+h*w+u*v+f*x,e.data[3]=r*y+l*w+p*v+m*x,e.data[4]=i*b+o*C+c*A+g*S,e.data[5]=s*b+a*C+d*A+_*S,e.data[6]=n*b+h*C+u*A+f*S,e.data[7]=r*b+l*C+p*A+m*S,e.data[8]=i*P+o*E+c*T+g*R,e.data[9]=s*P+a*E+d*T+_*R,e.data[10]=n*P+h*E+u*T+f*R,e.data[11]=r*P+l*E+p*T+m*R,e.data[12]=i*D+o*B+c*M+g*k,e.data[13]=s*D+a*B+d*M+_*k,e.data[14]=n*D+h*B+u*M+f*k,e.data[15]=r*D+l*B+p*M+m*k;const F=this.getScale();return e._scaleSignX=tt(F.x)*tt(e._scaleSignX),e._scaleSignY=tt(F.y)*tt(e._scaleSignY),e}translate(t,e){const i=this.data[0],s=this.data[1],n=this.data[2],r=this.data[3],o=this.data[4],a=this.data[5],h=this.data[6],l=this.data[7],c=this.data[8],d=this.data[9],u=this.data[10],p=this.data[11],g=this.data[12],_=this.data[13],f=this.data[14],m=this.data[15];return this.data[12]=i*t+o*e+0*c+1*g,this.data[13]=s*t+a*e+0*d+1*_,this.data[14]=n*t+h*e+0*u+1*f,this.data[15]=r*t+l*e+0*p+1*m,this}setPosition(t,e){this.data[12]=t,this.data[13]=e}getPosition(){return K(this.data[12],this.data[13])}rotate(t){const e=this.data[0],i=this.data[1],s=this.data[2],n=this.data[3],r=this.data[4],o=this.data[5],a=this.data[6],h=this.data[7],l=Math.sin(t),c=Math.cos(t);return this.data[0]=c*e+l*r,this.data[1]=c*i+l*o,this.data[2]=c*s+l*a,this.data[3]=c*n+l*h,this.data[4]=c*r-l*e,this.data[5]=c*o-l*i,this.data[6]=c*a-l*s,this.data[7]=c*h-l*n,this}scale(t,e){const i=this.data[0],s=this.data[1],n=this.data[2],r=this.data[3],o=this.data[4],a=this.data[5],h=this.data[6],l=this.data[7];return this.data[0]=i*t,this.data[1]=s*t,this.data[2]=n*t,this.data[3]=r*t,this.data[4]=o*e,this.data[5]=a*e,this.data[6]=h*e,this.data[7]=l*e,this}setRotation(t){const e=this.getScale(),i=Math.sin(t),s=Math.cos(t);this.data[0]=s*e.x,this.data[1]=i*e.y,this.data[4]=-i*e.x,this.data[5]=s*e.y}getRotation(){return T(Math.atan2(this.data[1]/this.getScaleY(),this.data[0]/this.getScaleX()))}getScaleX(){const t=K(this.data[0],this.data[4]).size;return this._scaleSignX*t}getScaleY(){const t=K(this.data[1],this.data[5]).size;return this._scaleSignY*t}getScale(){return K(this.getScaleX(),this.getScaleY())}setScaleX(t){this._scaleSignX=tt(t);const e=K(this.data[0]*this._scaleSignX,this.data[4]*this._scaleSignX).normalize();this.data[0]=e.x*t,this.data[4]=e.y*t}setScaleY(t){this._scaleSignY=tt(t);const e=K(this.data[1]*this._scaleSignY,this.data[5]*this._scaleSignY).normalize();this.data[1]=e.x*t,this.data[5]=e.y*t}setScale(t){this.setScaleX(t.x),this.setScaleY(t.y)}getBasisDeterminant(){return this.data[0]*this.data[5]-this.data[1]*this.data[4]}getAffineInverse(){const t=1/this.getBasisDeterminant(),e=this.data[0],i=this.data[4],s=this.data[1],n=this.data[5],r=et.identity();r.data[0]=n*t,r.data[1]=-s*t,r.data[4]=-i*t,r.data[5]=e*t;const o=this.data[12],a=this.data[13];return r.data[12]=-(o*r.data[0]+a*r.data[4]),r.data[13]=-(o*r.data[1]+a*r.data[5]),r}isIdentity(){return 1===this.data[0]&&0===this.data[1]&&0===this.data[2]&&0===this.data[3]&&0===this.data[4]&&1===this.data[5]&&0===this.data[6]&&0===this.data[7]&&0===this.data[8]&&0===this.data[9]&&1===this.data[10]&&0===this.data[11]&&0===this.data[12]&&0===this.data[13]&&0===this.data[14]&&1===this.data[15]}toString(){return`\n[${this.data[0]} ${this.data[4]} ${this.data[8]} ${this.data[12]}]\n[${this.data[1]} ${this.data[5]} ${this.data[9]} ${this.data[13]}]\n[${this.data[2]} ${this.data[6]} ${this.data[10]} ${this.data[14]}]\n[${this.data[3]} ${this.data[7]} ${this.data[11]} ${this.data[15]}]\n`}}class it{constructor(){this._transforms=[],this._currentTransform=et.identity()}save(){this._transforms.push(this._currentTransform),this._currentTransform=this._currentTransform.clone()}restore(){this._currentTransform=this._transforms.pop()}translate(t,e){return this._currentTransform.translate(t,e)}rotate(t){return this._currentTransform.rotate(t)}scale(t,e){return this._currentTransform.scale(t,e)}set current(t){this._currentTransform=t}get current(){return this._currentTransform}}class st{constructor(){this._states=[],this._currentState=this._getDefaultState()}_getDefaultState(){return{opacity:1}}_cloneState(){return{opacity:this._currentState.opacity}}save(){this._states.push(this._currentState),this._currentState=this._cloneState()}restore(){this._currentState=this._states.pop()}get current(){return this._currentState}}class nt{constructor(t,e,i){this._gl=t,this._vertexSource=e,this._fragmentSource=i,this.program=null,this.uniforms={},this.attributes={},this.layout=[],this.compile(t)}_createProgram(t,e,i){const s=t.createProgram();if(null===s)throw Error("Could not create graphics shader program");t.attachShader(s,e),t.attachShader(s,i),t.linkProgram(s);if(!t.getProgramParameter(s,t.LINK_STATUS))throw Error(`Could not link the program: [${t.getProgramInfoLog(s)}]`);return s}_compileShader(t,e,i){const s=t.createShader(i);if(null===s)throw Error(`Could not build shader: [${e}]`);t.shaderSource(s,e),t.compileShader(s);if(!t.getShaderParameter(s,t.COMPILE_STATUS))throw Error(`Could not compile shader [${t.getShaderInfoLog(s)}]`);return s}compile(t){const e=this._compileShader(t,this._vertexSource,t.VERTEX_SHADER),i=this._compileShader(t,this._fragmentSource,t.FRAGMENT_SHADER),s=this._createProgram(t,e,i);return this.program=s}addUniformMatrix(t,e){if(!e)throw Error(`Shader Uniform Matrix '${t}' was set to null or undefined`);const i=this._gl;this.uniforms[t]={name:t,type:"matrix",location:i.getUniformLocation(this.program,t),data:e}}addUniformIntegerArray(t,e){if(!e)throw Error(`Shader Uniform Integery Array '${t}' was set to null or undefined`);const i=this._gl;this.uniforms[t]={name:t,type:"numbers",location:i.getUniformLocation(this.program,t),data:e}}addAttribute(t,e,i,s=!1){const n=this._gl.getAttribLocation(this.program,t);this.attributes[t]={name:t,size:e,glType:i,normalized:s,location:n},this.layout.push(this.attributes[t])}get vertexAttributeSize(){let t=0;for(const e of this.layout)t+=e.size;return t}get totalVertexSizeBytes(){let t=0;for(const e of this.layout){let i=1;if(e.glType===this._gl.FLOAT)i=4;else i=1;t+=i*e.size}return t}getAttributeSize(t){let e=1;if(this.attributes[t].glType===this._gl.FLOAT)e=4;else e=1;return e*this.attributes[t].size}use(){const t=this._gl;t.useProgram(this.program);let e=0;for(const i of this.layout)t.vertexAttribPointer(i.location,i.size,i.glType,i.normalized,this.totalVertexSizeBytes,e),t.enableVertexAttribArray(i.location),e+=this.getAttributeSize(i.name);for(const e in this.uniforms){const i=this.uniforms[e];switch(i.type){case"matrix":t.uniformMatrix4fv(i.location,!1,i.data);break;case"numbers":t.uniform1iv(i.location,i.data)}}}}class rt{constructor(t){this.max=t,this._pool=void 0,this.commands=[]}isFull(){return this.commands.length>=this.max}canAdd(){return!this.isFull()}add(t){this.commands.push(t)}dispose(){return this.commands.length=0,this}}class ot{static clear(){ot.DrawCallCount=0,ot.DrawnImagesCount=0}}ot.DrawCallCount=0,ot.DrawnImagesCount=0;class at{constructor(t,e,i=100){this.builder=t,this.recycler=e,this.maxObjects=i,this.totalAllocations=0,this.index=0,this.objects=[],this._logger=_.getInstance()}using(t){const e=t(this);return e?this.done(...e):this.done()}borrow(t){t(this.get()),this.index--}get(...t){if(this.index===this.maxObjects&&(this._logger.warn("Max pooled objects reached, possible memory leak? Doubling"),this.maxObjects=2*this.maxObjects),this.objects[this.index])return this.recycler(this.objects[this.index++],...t);{this.totalAllocations++;const e=this.objects[this.index++]=this.builder(...t);return e._pool=this,e}}done(...t){this.index=0;for(const e of t){const t=this.objects.indexOf(e);this.objects[t]=this.builder(),this.objects[t]._pool=this,this.totalAllocations++,e._pool=void 0}return t}}class ht{constructor(t){var e,i,s;this.priority=0,this._buffer=null,this._maxCommandsPerBatch=2e3,this._batches=[],this._gl=t.gl;const n=t.command;this._verticesPerCommand=null!==(e=null==t?void 0:t.verticesPerCommand)&&void 0!==e?e:1,this._maxCommandsPerBatch=null!==(i=null==t?void 0:t.maxCommandsPerBatch)&&void 0!==i?i:this._maxCommandsPerBatch;const r=null!==(s=null==t?void 0:t.batchFactory)&&void 0!==s?s:()=>new rt(this._maxCommandsPerBatch);this.commands=new at((()=>new n),(t=>t.dispose()),this._maxCommandsPerBatch),this._batchPool=new at(r,(t=>t.dispose()),100)}init(){const t=this._gl;this.shader=this.buildShader(t),this._vertices=new Float32Array(this.shader.vertexAttributeSize*this._verticesPerCommand*this._maxCommandsPerBatch),this._buffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._buffer),t.bufferData(t.ARRAY_BUFFER,this._vertices,t.DYNAMIC_DRAW)}get vertexSize(){return this.shader.vertexAttributeSize}addCommand(t){0===this._batches.length&&this._batches.push(this._batchPool.get());const e=this._batches[this._batches.length-1];if(e.canAdd())e.add(t);else{const e=this._batchPool.get();e.add(t),this._batches.push(e)}}render(){const t=this._gl;t.bindBuffer(t.ARRAY_BUFFER,this._buffer),this.shader.use();let e=0,i=0;for(const s of this._batches){const n=this.buildBatchVertices(this._vertices,s);t.bufferSubData(t.ARRAY_BUFFER,0,this._vertices),this.renderBatch(t,s,n),i+=s.commands.length,e++}this.commands.done(),this._batchPool.done(),this._batches.length=0,ot.DrawCallCount+=e,ot.DrawnImagesCount+=i}}class lt{constructor(){this.color=Q.Black,this.start=q.Zero,this.end=q.Zero}dispose(){return this.color.r=0,this.color.g=0,this.color.b=0,this.color.a=1,this.start.setTo(0,0),this.end.setTo(0,0),this}}class ct extends ht{constructor(t,e){super({gl:t,command:lt,verticesPerCommand:2}),this._contextInfo=e,this.init()}buildShader(t){const e=new nt(t,"attribute vec4 a_position;\r\nattribute vec4 a_color;\r\n\r\nvarying lowp vec4 v_color;\r\n\r\nuniform mat4 u_matrix;\r\n\r\n\r\nvoid main() {\r\n // Set the vertex position using the ortho transform matrix\r\n gl_Position = u_matrix * a_position;\r\n\r\n // Passthrough the color\r\n v_color = a_color;\r\n}","precision mediump float;\r\n\r\n// Color\r\nvarying lowp vec4 v_color;\r\n\r\n\r\nvoid main() {\r\n gl_FragColor = v_color;\r\n}");return e.addAttribute("a_position",2,t.FLOAT),e.addAttribute("a_color",4,t.FLOAT),e.addUniformMatrix("u_matrix",this._contextInfo.matrix.data),e}addLine(t,e,i){const s=this.commands.get();s.start=this._contextInfo.transform.current.multv(t),s.end=this._contextInfo.transform.current.multv(e),s.color.r=i.r,s.color.g=i.g,s.color.b=i.b,s.color.a=s.color.a*this._contextInfo.state.current.opacity,this.addCommand(s)}buildBatchVertices(t,e){let i=0;for(const s of e.commands)t[i++]=s.start.x,t[i++]=s.start.y,t[i++]=s.color.r/255,t[i++]=s.color.g/255,t[i++]=s.color.b/255,t[i++]=s.color.a,t[i++]=s.end.x,t[i++]=s.end.y,t[i++]=s.color.r/255,t[i++]=s.color.g/255,t[i++]=s.color.b/255,t[i++]=s.color.a;return i/this.vertexSize}renderBatch(t,e,i){t.drawArrays(t.LINES,0,i)}}var dt;!function(t){t.Image="image",t.Line="line",t.Rectangle="rectangle",t.Circle="circle"}(dt||(dt={}));class ut{constructor(t,e,i,s,n,r,o,a,h){this._pool=void 0,this.snapToPixel=!0,this.type=dt.Image,this.opacity=1,this.width=0,this.height=0,this.dest=[0,0],this.view=[0,0,0,0],this._geom=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],this.init(t,e,i,s,n,r,o,a,h)}init(t,e,i,s,n,r,o,a,h){this.type=dt.Image,this.image=t,this.width=(null==t?void 0:t.width)||s||0,this.height=(null==t?void 0:t.height)||n||0,this.view=[0,0,null!=s?s:null==t?void 0:t.width,null!=n?n:null==t?void 0:t.height],this.dest=[e,i],void 0!==r&&void 0!==o&&void 0!==a&&void 0!==h&&(this.view=[e,i,null!=s?s:null==t?void 0:t.width,null!=n?n:null==t?void 0:t.height],this.dest=[r,o],this.width=a,this.height=h);let l=0;if(this._geom[l++]=[this.dest[0],this.dest[1]],this._geom[l++]=[this.dest[0],this.dest[1]+this.height],this._geom[l++]=[this.dest[0]+this.width,this.dest[1]],this._geom[l++]=[this.dest[0]+this.width,this.dest[1]],this._geom[l++]=[this.dest[0],this.dest[1]+this.height],this._geom[l++]=[this.dest[0]+this.width,this.dest[1]+this.height],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}initRect(t,e,i,s){this.type=dt.Rectangle,this.color=t,this.width=i,this.height=s;let n=0;if(this._geom[n++]=[e.x,e.y],this._geom[n++]=[e.x,e.y+this.height],this._geom[n++]=[e.x+this.width,e.y],this._geom[n++]=[e.x+this.width,e.y],this._geom[n++]=[e.x,e.y+this.height],this._geom[n++]=[e.x+this.width,e.y+this.height],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}initLine(t,e,i,s){this.type=dt.Line,this.color=t;const n=i.sub(e).normalize().perpendicular(),r=s/2,o=n.scale(r).add(e),a=n.scale(-r).add(e),h=n.scale(r).add(i),l=n.scale(-r).add(i);let c=0;if(this._geom[c++]=[o.x,o.y],this._geom[c++]=[h.x,h.y],this._geom[c++]=[a.x,a.y],this._geom[c++]=[a.x,a.y],this._geom[c++]=[h.x,h.y],this._geom[c++]=[l.x,l.y],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}initCircle(t,e,i){this.type=dt.Circle,this.color=i;const s=t.add(K(-e,-e)),n=t.add(K(e,-e)),r=t.add(K(e,e)),o=t.add(K(-e,e));let a=0;if(this._geom[a++]=[s.x,s.y],this._geom[a++]=[n.x,n.y],this._geom[a++]=[o.x,o.y],this._geom[a++]=[o.x,o.y],this._geom[a++]=[n.x,n.y],this._geom[a++]=[r.x,r.y],this.snapToPixel)for(const t of this._geom)t[0]=~~t[0],t[1]=~~t[1];return this}dispose(){this.image=null,this.width=0,this.height=0,this.view=[0,0,0,0],this.dest=[0,0];let t=0;return this._geom[t++]=[this.dest[0],this.dest[1]],this._geom[t++]=[this.dest[0],this.dest[1]+this.height],this._geom[t++]=[this.dest[0]+this.width,this.dest[1]],this._geom[t++]=[this.dest[0]+this.width,this.dest[1]],this._geom[t++]=[this.dest[0],this.dest[1]+this.height],this._geom[t++]=[this.dest[0]+this.width,this.dest[1]+this.height],this}applyTransform(t,e){if(t)for(let e=0;e<this._geom.length;e++)this._geom[e]=t.multv(this._geom[e]),this.snapToPixel&&(this._geom[e]=[~~this._geom[e][0],~~this._geom[e][1]]);this.opacity=e}get geometry(){return this._geom}}function pt(t){return 0==(t&t-1)}function gt(t){return pt(t)?t:function(t){--t;for(let e=1;e<32;e<<=1)t|=t>>e;return t+1}(t)}class _t{static registerContext(t){_t._GL=t}static get(t){return _t._TEXTURE_MAP.get(t)}static has(t){return _t._TEXTURE_MAP.has(t)}static load(t,e=!1){const i=_t._GL;if(!i)return null;let s=null;if(_t.has(t)&&(s=_t.get(t)),s){if(e){i.bindTexture(i.TEXTURE_2D,s);const e=_t.toPowerOfTwoImage(t);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e)}return s}s=i.createTexture();const n=_t.toPowerOfTwoImage(t);return i.bindTexture(i.TEXTURE_2D,s),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),_t._TEXTURE_MAP.set(t,s),s}static toPowerOfTwoImage(t){const e=_t._POT_CANVAS,i=_t._POT_CTX;return pt(t.width)&&pt(t.height)||(e.width=gt(t.width),e.height=gt(t.height),i.imageSmoothingEnabled=!1,i.clearRect(0,0,e.width,e.height),i.drawImage(t,0,0,t.width,t.height),t=e),t}}_t._POT_CANVAS=document.createElement("canvas"),_t._POT_CTX=_t._POT_CANVAS.getContext("2d"),_t._TEXTURE_MAP=new Map;class ft extends rt{constructor(t,e){super(t),this.maxDraws=t,this.maxTextures=e,this.textures=[],this.commands=[],this._graphicMap={}}isFull(){return this.commands.length>=this.maxDraws||this.textures.length>=this.maxTextures}canAdd(){return!(this.commands.length>=this.maxDraws)&&this.textures.length<this.maxTextures}_isCommandFull(){return this.commands.length>=this.maxDraws}_isTextureFull(){return this.textures.length>=this.maxTextures}_wouldAddTexture(t){return!this._graphicMap[t.image.id]}maybeAdd(t){return(!this._isCommandFull()&&!this._isTextureFull()||!this._wouldAddTexture(t))&&(this.add(t),!0)}add(t){if(t.type===dt.Image){const e=_t.load(t.image);-1===this.textures.indexOf(e)&&this.textures.push(e)}this.commands.push(t)}bindTextures(t){for(let e=0;e<this.maxTextures;e++)t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,this.textures[e]||this.textures[0])}getBatchTextureId(t){return t.image?this.textures.indexOf(_t.get(t.image)):-1}dispose(){return this.clear(),this}clear(){this.commands.length=0,this.textures.length=0,this._graphicMap={}}}class mt extends ht{constructor(t,e){super({gl:t,command:ut,verticesPerCommand:6,maxCommandsPerBatch:2e3,batchFactory:()=>new ft(2e3,t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS))}),this._contextInfo=e,_t.registerContext(t),this.init()}buildShader(t){const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),i=new nt(t,"attribute vec4 a_position;\r\n\r\n// Opacity \r\nattribute float a_opacity;\r\nvarying float v_opacity;\r\n\r\nattribute vec4 a_color;\r\nvarying vec4 v_color;\r\n\r\n// UV coordinate\r\nattribute vec2 a_texcoord;\r\nvarying vec2 v_texcoord;\r\n\r\n// Texture number\r\nattribute lowp float a_textureIndex;\r\nvarying lowp float v_textureIndex;\r\n\r\nuniform mat4 u_matrix;\r\n\r\n\r\nvoid main() {\r\n // Set the vertex position using the ortho transform matrix\r\n gl_Position = u_matrix * a_position;\r\n\r\n // Pass through the Opacity to the fragment shader\r\n v_opacity = a_opacity;\r\n // Pass through the UV coord to the fragment shader\r\n v_texcoord = a_texcoord;\r\n // Pass through the texture number to the fragment shader\r\n v_textureIndex = a_textureIndex;\r\n // Pass through the color to the fragment shader\r\n v_color = a_color;\r\n}",this._transformFragmentSource("#ifdef GL_OES_standard_derivatives\r\n#extension GL_OES_standard_derivatives : enable\r\n#endif\r\nprecision mediump float;\r\n\r\n// UV coord\r\nvarying vec2 v_texcoord;\r\n\r\n// Texture index\r\nvarying lowp float v_textureIndex;\r\n\r\n// Color coord to blend with image\r\nvarying lowp vec4 v_color;\r\n\r\n// Opacity\r\nvarying float v_opacity;\r\n\r\nuniform sampler2D u_textures[%%count%%];\r\n\r\nfloat circle(in vec2 st, in float radius) {\r\n vec2 dist = st - vec2(0.5);\r\n float r = dot(dist, dist) * 4.0;\r\n float delta = fwidth(r);\r\n return 1.0 - smoothstep(radius - delta, radius + delta, r);\r\n}\r\n\r\nvoid main() {\r\n float r = 0.0, delta = 0.0, alpha = 1.0;\r\n // In order to support the most efficient sprite batching, we have multiple\r\n // textures loaded into the gpu (usually 8) this picker logic skips over textures\r\n // that do not apply to a particular sprite.\r\n\r\n vec4 color;\r\n // -1 If there is no texture to sample we are drawing a solid geometry (rectangles)\r\n if (v_textureIndex == -1.0) {\r\n color = v_color;\r\n color.w = color.w * v_opacity;\r\n // -2 If there is no texture we are drawing a circle\r\n } else if (v_textureIndex == -2.0) {\r\n color = v_color;\r\n color.a = color.a * circle(v_texcoord, .95);\r\n } else {\r\n // GLSL is templated out to pick the right texture and set the vec4 color\r\n %%texture_picker%%\r\n }\r\n color.w = color.w * v_opacity;\r\n gl_FragColor = color;\r\n}",e));return i.addAttribute("a_position",3,t.FLOAT),i.addAttribute("a_texcoord",2,t.FLOAT),i.addAttribute("a_textureIndex",1,t.FLOAT),i.addAttribute("a_opacity",1,t.FLOAT),i.addAttribute("a_color",4,t.FLOAT),i.addUniformMatrix("u_matrix",this._contextInfo.matrix.data),i.addUniformIntegerArray("u_textures",[...Array(e)].map(((t,e)=>e))),i}_transformFragmentSource(t,e){let i=t.replace("%%count%%",e.toString()),s="";for(let t=0;t<e;t++)s+=0===t?`if (v_textureIndex <= ${t}.5) {\n`:` else if (v_textureIndex <= ${t}.5) {\n`,s+=` color = texture2D(u_textures[${t}], v_texcoord);\n`,s+=" }\n";return i=i.replace("%%texture_picker%%",s),i}addCircle(t,e,i){const s=this.commands.get().initCircle(t,e,i);s.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(s)}addRectangle(t,e,i,s){const n=this.commands.get().initRect(t,e,i,s);n.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(n)}addLine(t,e,i,s=1){const n=this.commands.get().initLine(t,e,i,s);n.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(n)}addImage(t,e,i,s,n,r,o,a,h){const l=this.commands.get().init(t,e,i,s,n,r,o,a,h);l.applyTransform(this._contextInfo.transform.current,this._contextInfo.state.current.opacity),this.addCommand(l)}renderBatch(t,e,i){e.bindTextures(t),t.drawArrays(t.TRIANGLES,0,i)}buildBatchVertices(t,e){var i,s;let n=0,r=0,o=0,a=0,h=0,l=1,c=1,d=0,u=Q.Transparent;for(const p of e.commands){r=p.view[0],o=p.view[1],a=p.view[2],h=p.view[3],l=gt((null===(i=p.image)||void 0===i?void 0:i.width)||p.width),c=gt((null===(s=p.image)||void 0===s?void 0:s.height)||p.height),d=e.getBatchTextureId(p),p.type!==dt.Line&&p.type!==dt.Rectangle||(d=-1,u=p.color),p.type===dt.Circle&&(d=-2,u=p.color);let g=r/l,_=o/c,f=(r+a)/l,m=(o+h)/c;-2===d&&(g=0,_=0,f=1,m=1),t[n++]=p.geometry[0][0],t[n++]=p.geometry[0][1],t[n++]=0,t[n++]=g,t[n++]=_,t[n++]=d,t[n++]=p.opacity,t[n++]=u.r/255,t[n++]=u.g/255,t[n++]=u.b/255,t[n++]=u.a,t[n++]=p.geometry[1][0],t[n++]=p.geometry[1][1],t[n++]=0,t[n++]=g,t[n++]=m,t[n++]=d,t[n++]=p.opacity,t[n++]=u.r/255,t[n++]=u.g/255,t[n++]=u.b/255,t[n++]=u.a,t[n++]=p.geometry[2][0],t[n++]=p.geometry[2][1],t[n++]=0,t[n++]=f,t[n++]=_,t[n++]=d,t[n++]=p.opacity,t[n++]=u.r/255,t[n++]=u.g/255,t[n++]=u.b/255,t[n++]=u.a,t[n++]=p.geometry[3][0],t[n++]=p.geometry[3][1],t[n++]=0,t[n++]=f,t[n++]=_,t[n++]=d,t[n++]=p.opacity,t[n++]=u.r/255,t[n++]=u.g/255,t[n++]=u.b/255,t[n++]=u.a,t[n++]=p.geometry[4][0],t[n++]=p.geometry[4][1],t[n++]=0,t[n++]=g,t[n++]=m,t[n++]=d,t[n++]=p.opacity,t[n++]=u.r/255,t[n++]=u.g/255,t[n++]=u.b/255,t[n++]=u.a,t[n++]=p.geometry[5][0],t[n++]=p.geometry[5][1],t[n++]=0,t[n++]=f,t[n++]=m,t[n++]=d,t[n++]=p.opacity,t[n++]=u.r/255,t[n++]=u.g/255,t[n++]=u.b/255,t[n++]=u.a}return n/this.vertexSize}}class yt{constructor(){this.point=q.Zero,this.color=Q.Black,this.size=1}dispose(){return this.point.setTo(0,0),this.color.r=0,this.color.g=0,this.color.b=0,this.color.a=1,this.size=1,this}}class wt extends ht{constructor(t,e){super({gl:t,command:yt,verticesPerCommand:1}),this._contextInfo=e,this.init()}buildShader(t){t.getExtension("OES_standard_derivatives");const e=new nt(t,"attribute vec4 a_position;\r\nattribute vec4 a_color;\r\nattribute float a_size;\r\nvarying lowp vec4 v_color;\r\nuniform mat4 u_matrix;\r\n\r\nvoid main() {\r\n gl_Position = u_matrix * a_position;\r\n gl_PointSize = a_size * 2.0;\r\n v_color = a_color;\r\n}","#ifdef GL_OES_standard_derivatives\r\n#extension GL_OES_standard_derivatives : enable\r\n#endif\r\n\r\nprecision mediump float;\r\nvarying lowp vec4 v_color;\r\n\r\nvoid main() {\r\n float r = 0.0, delta = 0.0, alpha = 1.0;\r\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\r\n r = dot(cxy, cxy);\r\n \r\n#ifdef GL_OES_standard_derivatives\r\n delta = fwidth(r);\r\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\r\n#else\r\n if (r > 1.0) {\r\n discard;\r\n }\r\n#endif\r\n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\r\n}");return e.addAttribute("a_position",2,t.FLOAT),e.addAttribute("a_color",4,t.FLOAT),e.addAttribute("a_size",1,t.FLOAT),e.addUniformMatrix("u_matrix",this._contextInfo.matrix.data),e}addPoint(t,e,i){const s=this.commands.get();s.point=this._contextInfo.transform.current.multv(t),s.color.r=e.r,s.color.g=e.g,s.color.b=e.b,s.color.a=e.a*this._contextInfo.state.current.opacity,s.size=i*Math.max(this._contextInfo.transform.current.getScaleX(),this._contextInfo.transform.current.getScaleY()),this.addCommand(s)}buildBatchVertices(t,e){let i=0;for(const s of e.commands)t[i++]=s.point.x,t[i++]=s.point.y,t[i++]=s.color.r/255,t[i++]=s.color.g/255,t[i++]=s.color.b/255,t[i++]=s.color.a,t[i++]=s.size;return i/this.vertexSize}renderBatch(t,e,i){t.drawArrays(t.POINTS,0,i)}}class vt{constructor(t){var e,i,s,n,r,o;this.id=vt._ID++,this.showDebug=!1,this.flipHorizontal=!1,this.flipVertical=!1,this.rotation=0,this.opacity=1,this.scale=q.One,this.origin=null,this._width=0,this._height=0,t&&(this.origin=null!==(e=t.origin)&&void 0!==e?e:this.origin,this.flipHorizontal=null!==(i=t.flipHorizontal)&&void 0!==i?i:this.flipHorizontal,this.flipVertical=null!==(s=t.flipVertical)&&void 0!==s?s:this.flipVertical,this.rotation=null!==(n=t.rotation)&&void 0!==n?n:this.rotation,this.opacity=null!==(r=t.opacity)&&void 0!==r?r:this.opacity,this.scale=null!==(o=t.scale)&&void 0!==o?o:this.scale)}cloneGraphicOptions(){return{origin:this.origin?this.origin.clone():null,flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical,rotation:this.rotation,opacity:this.opacity,scale:this.scale?this.scale.clone():null}}get width(){return Math.abs(this._width*this.scale.x)}get height(){return Math.abs(this._height*this.scale.y)}set width(t){this._width=t}set height(t){this._height=t}get localBounds(){return J.fromDimension(this.width,this.height,q.Zero)}draw(t,e,i){this._preDraw(t,e,i),this._drawImage(t,0,0),this._postDraw(t)}_preDraw(t,e,i){t.save(),t.translate(e,i),t.scale(Math.abs(this.scale.x),Math.abs(this.scale.y)),this._rotate(t),this._flip(t),t.opacity=t.opacity*this.opacity}_rotate(t){var e;const i=this.scale.x>0?1:-1,s=this.scale.y>0?1:-1,n=null!==(e=this.origin)&&void 0!==e?e:K(this.width/2,this.height/2);t.translate(n.x,n.y),t.rotate(this.rotation),t.scale(i,s),t.translate(-n.x,-n.y)}_flip(t){this.flipHorizontal&&(t.translate(this.width/this.scale.x,0),t.scale(-1,1)),this.flipVertical&&(t.translate(0,this.height/this.scale.y),t.scale(1,-1))}_postDraw(t){this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore()}}function xt(t,e){return t&&void 0===t.__isProxy?new Proxy(t,{set:(t,i,s)=>(t[i]!==s&&(t[i]=s,"string"==typeof i&&"_"!==i[0]&&e(t)),!0),get:(t,e)=>"__isProxy"===e||t[e]}):t}function bt(t,e){return t&&void 0===t.__isProxy?new Proxy(t,{set:(t,i,s)=>(t[i]=s,"string"==typeof i&&"_"!==i[0]&&e(t),!0),get:(t,e)=>"__isProxy"===e||t[e]}):t}vt._ID=0;class Ct extends vt{constructor(t){var e,i,s,n,r,o,a;super(t),this._dirty=!0,this._smoothing=!1,this._color=xt(Q.Black,(()=>this.flagDirty())),this._lineWidth=1,this._lineDash=[],this._padding=0,t&&(this.color=null!==(e=t.color)&&void 0!==e?e:Q.Black,this.strokeColor=null==t?void 0:t.strokeColor,this.smoothing=null!==(i=t.smoothing)&&void 0!==i?i:this.smoothing,this.lineWidth=null!==(s=t.lineWidth)&&void 0!==s?s:this.lineWidth,this.lineDash=null!==(n=t.lineDash)&&void 0!==n?n:this.lineDash,this.padding=null!==(r=t.padding)&&void 0!==r?r:this.padding),this._bitmap=document.createElement("canvas");const h=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:this._bitmap.width,l=null!==(a=null==t?void 0:t.height)&&void 0!==a?a:this._bitmap.height;this.width=gt(h),this.height=gt(l);const c=this._bitmap.getContext("2d");if(!c)throw new Error("Browser does not support 2d canvas drawing, cannot create Raster graphic");this._ctx=c}cloneRasterOptions(){return{color:this.color?this.color.clone():null,strokeColor:this.strokeColor?this.strokeColor.clone():null,smoothing:this.smoothing,lineWidth:this.lineWidth,lineDash:this.lineDash,padding:this.padding}}get dirty(){return this._dirty}flagDirty(){this._dirty=!0}get width(){return this._getTotalWidth()}set width(t){this._bitmap.width=t,this._originalWidth=t,this.flagDirty()}get height(){return this._getTotalHeight()}set height(t){this._bitmap.height=t,this._originalHeight=t,this.flagDirty()}_getTotalWidth(){var t;return(null!==(t=this._originalWidth)&&void 0!==t?t:this._bitmap.width)+2*this.padding}_getTotalHeight(){var t;return(null!==(t=this._originalHeight)&&void 0!==t?t:this._bitmap.height)+2*this.padding}get localBounds(){return J.fromDimension(this._getTotalWidth()*this.scale.x,this._getTotalHeight()*this.scale.y,q.Zero)}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this.flagDirty()}get color(){return this._color}set color(t){var e;(null===(e=this._color)||void 0===e?void 0:e.equal(t))||this.flagDirty(),this._color=xt(t,(()=>this.flagDirty()))}get strokeColor(){return this._strokeColor}set strokeColor(t){var e;(null===(e=this._strokeColor)||void 0===e?void 0:e.equal(t))||this.flagDirty(),this._strokeColor=xt(t,(()=>this.flagDirty()))}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.flagDirty()}get lineDash(){return this._lineDash}set lineDash(t){this._lineDash=t,this.flagDirty()}get padding(){return this._padding}set padding(t){this._padding=t,this.flagDirty()}rasterize(){this._dirty=!1,this._ctx.clearRect(0,0,this._getTotalWidth(),this._getTotalHeight()),this._ctx.save(),this._applyRasterProperites(this._ctx),this.execute(this._ctx),this._ctx.restore(),_t.load(this._bitmap,!0)}_applyRasterProperites(t){var e,i,s;this._bitmap.width=this._getTotalWidth(),this._bitmap.height=this._getTotalHeight(),t.translate(this.padding,this.padding),t.imageSmoothingEnabled=this.smoothing,t.lineWidth=this.lineWidth,t.setLineDash(null!==(e=this.lineDash)&&void 0!==e?e:t.getLineDash()),t.strokeStyle=null===(i=this.strokeColor)||void 0===i?void 0:i.toString(),t.fillStyle=null===(s=this.color)||void 0===s?void 0:s.toString()}_drawImage(t,e,i){this._dirty&&this.rasterize(),t.drawImage(this._bitmap,e,i)}}class At extends Ct{constructor(t){super(t),this._options=t}get ctx(){return this._ctx}clone(){return new At(Object.assign(Object.assign(Object.assign({},this._options),this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){var e,i;(null===(e=this._options)||void 0===e?void 0:e.draw)&&(null===(i=this._options)||void 0===i||i.draw(t)),this._options.cache||this.flagDirty()}}var St;!function(t){t.Kill="kill",t.PreKill="prekill",t.PostKill="postkill",t.PreDraw="predraw",t.PostDraw="postdraw",t.PreDebugDraw="predebugdraw",t.PostDebugDraw="postdebugdraw",t.PreUpdate="preupdate",t.PostUpdate="postupdate",t.PreFrame="preframe",t.PostFrame="postframe",t.PreCollision="precollision",t.CollisionStart="collisionstart",t.CollisionEnd="collisionend",t.PostCollision="postcollision",t.Initialize="initialize",t.Activate="activate",t.Deactivate="deactivate",t.ExitViewport="exitviewport",t.EnterViewport="enterviewport",t.ExitTrigger="exit",t.EnterTrigger="enter",t.Connect="connect",t.Disconnect="disconnect",t.Button="button",t.Axis="axis",t.Subscribe="subscribe",t.Unsubscribe="unsubscribe",t.Visible="visible",t.Hidden="hidden",t.Start="start",t.Stop="stop",t.PointerUp="pointerup",t.PointerDown="pointerdown",t.PointerMove="pointermove",t.PointerEnter="pointerenter",t.PointerLeave="pointerleave",t.PointerCancel="pointercancel",t.PointerWheel="pointerwheel",t.Up="up",t.Down="down",t.Move="move",t.Enter="enter",t.Leave="leave",t.Cancel="cancel",t.Wheel="wheel",t.Press="press",t.Release="release",t.Hold="hold",t.PointerDragStart="pointerdragstart",t.PointerDragEnd="pointerdragend",t.PointerDragEnter="pointerdragenter",t.PointerDragLeave="pointerdragleave",t.PointerDragMove="pointerdragmove"}(St||(St={}));class Pt{constructor(){this._bubbles=!0}get bubbles(){return this._bubbles}set bubbles(t){this._bubbles=t}stopPropagation(){this.bubbles=!1}}class Et extends Pt{constructor(t){super(),this.target=t}}class Tt extends Pt{constructor(t){super(),this.target=t}}class Rt extends Pt{constructor(t){super(),this.target=t}}class Dt extends Pt{constructor(t){super(),this.target=t}}class Bt extends Pt{constructor(t){super(),this.target=t}}class Mt extends Pt{constructor(t,e,i){super(),this.ctx=t,this.delta=e,this.target=i}}class kt extends Pt{constructor(t,e,i){super(),this.ctx=t,this.delta=e,this.target=i}}class Ft extends Pt{constructor(t,e){super(),this.ctx=t,this.target=e}}class Lt extends Pt{constructor(t,e){super(),this.ctx=t,this.target=e}}class It extends Pt{constructor(t,e,i){super(),this.engine=t,this.delta=e,this.target=i}}class Ot extends Pt{constructor(t,e,i){super(),this.engine=t,this.delta=e,this.target=i}}class zt extends Pt{constructor(t,e){super(),this.engine=t,this.prevStats=e,this.target=t}}class Ut extends Pt{constructor(t,e){super(),this.engine=t,this.stats=e,this.target=t}}class Ht extends Pt{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class Wt extends Pt{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class Nt extends Pt{constructor(t,e,i){super(),this.button=t,this.value=e,this.target=i}}class Vt extends Pt{constructor(t,e,i){super(),this.axis=t,this.value=e,this.target=i}}class Gt extends Pt{constructor(t,e){super(),this.topic=t,this.handler=e}}class jt extends Pt{constructor(t,e){super(),this.topic=t,this.handler=e}}class Xt extends Pt{constructor(t){super(),this.target=t}}class qt extends Pt{constructor(t){super(),this.target=t}}class Kt extends Pt{constructor(t,e,i,s){super(),this.other=e,this.side=i,this.intersection=s,this.target=t}}class Zt extends Pt{constructor(t,e,i,s){super(),this.other=e,this.side=i,this.intersection=s,this.target=t}get actor(){return this.target}set actor(t){this.target=t}}class Yt{constructor(t,e,i){this.target=t,this.other=e,this.contact=i}}class Qt{constructor(t,e){this.target=t,this.other=e}}class $t{constructor(t,e,i,s,n){this.target=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class Jt{constructor(t,e,i,s,n){this.target=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class te extends Pt{constructor(t,e,i){super(),this.other=e,this.contact=i,this.target=t}get actor(){return this.target}set actor(t){this.target=t}}class ee extends Pt{constructor(t,e){super(),this.other=e,this.target=t}get actor(){return this.target}set actor(t){this.target=t}}class ie extends Pt{constructor(t,e){super(),this.engine=t,this.target=e}}class se extends Pt{constructor(t,e){super(),this.oldScene=t,this.target=e}}class ne extends Pt{constructor(t,e){super(),this.newScene=t,this.target=e}}class re extends Pt{constructor(t){super(),this.target=t}}class oe extends Pt{constructor(t){super(),this.target=t}}class ae extends Pt{constructor(t,e){super(),this.target=t,this.actor=e}}class he extends Pt{constructor(t,e){super(),this.target=t,this.actor=e}}class le{constructor(t){this._handlers={},this._wiredEventDispatchers=[],this._target=t}clear(){this._handlers={},this._wiredEventDispatchers=[]}emit(t,e){if(!t)return;t=t.toLowerCase();const i=this._target;e||(e=new Pt);try{e.target||(e.target=i)}catch(t){}let s,n;if(this._handlers[t])for(s=0,n=this._handlers[t].length;s<n;s++)this._handlers[t][s].call(i,e);for(s=0,n=this._wiredEventDispatchers.length;s<n;s++)this._wiredEventDispatchers[s].emit(t,e)}on(t,e){t=t.toLowerCase(),this._handlers[t]||(this._handlers[t]=[]),this._handlers[t].push(e),"unsubscribe"!==t&&"subscribe"!==t&&this.emit("subscribe",new Gt(t,e))}off(t,e){t=t.toLowerCase();const i=this._handlers[t];if(i)if(e){const s=i.indexOf(e);this._handlers[t].splice(s,1)}else this._handlers[t].length=0;"unsubscribe"!==t&&"subscribe"!==t&&this.emit("unsubscribe",new jt(t,e))}once(t,e){this.on(t,(i=>{const s=i||new Pt;try{s.target=s.target||this._target}catch(t){}this.off(t,e),e.call(s.target,s)}))}wire(t){t._wiredEventDispatchers.push(this)}unwire(t){const e=t._wiredEventDispatchers.indexOf(this);e>-1&&t._wiredEventDispatchers.splice(e,1)}}class ce{constructor(t,e,i=!0){this.path=t,this.responseType=e,this.bustCache=i,this.data=null,this.logger=_.getInstance(),this.events=new le(this)}isLoaded(){return null!==this.data}_cacheBust(t){return/\?\w*=\w*/.test(t)?t+="&__="+Date.now():t+="?__="+Date.now(),t}load(){return new Promise(((t,e)=>{if(null!==this.data)return this.logger.debug("Already have data for resource",this.path),this.events.emit("complete",this.data),void t(this.data);const i=new XMLHttpRequest;i.open("GET",this.bustCache?this._cacheBust(this.path):this.path,!0),i.responseType=this.responseType,i.addEventListener("loadstart",(t=>this.events.emit("loadstart",t))),i.addEventListener("progress",(t=>this.events.emit("progress",t))),i.addEventListener("error",(t=>this.events.emit("error",t))),i.addEventListener("load",(t=>this.events.emit("load",t))),i.addEventListener("load",(()=>{if(0!==i.status&&200!==i.status)return this.logger.error("Failed to load resource ",this.path," server responded with error code",i.status),this.events.emit("error",i.response),void e(new Error(i.statusText));this.data=i.response,this.events.emit("complete",this.data),this.logger.debug("Completed loading resource",this.path),t(this.data)})),i.send()}))}}var de=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};let ue=class{updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data,r=(n[s+0]+n[s+1]+n[s+2])/3;n[s+0]=r,n[s+1]=r,n[s+2]=r}};ue=de([j({message:"Grayscale will be removed in v0.26.0"})],ue);let pe=class{updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data;n[s+0]=255-n[s+0],n[s+1]=255-n[s+1],n[s+2]=255-n[s+2]}};pe=de([j({message:"Invert will be removed in v0.26.0"})],pe);let ge=class{constructor(t){this.opacity=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data;0!==n[s+3]&&(n[s+3]=Math.round(this.opacity*n[s+3]))}};ge=de([j({message:"Opacity will be removed in v0.26.0"})],ge);let _e=class{constructor(t){this.color=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data;0!==n[s+3]&&(n[s+0]=(n[s+0]+this.color.r)/2,n[s+1]=(n[s+1]+this.color.g)/2,n[s+2]=(n[s+2]+this.color.b)/2)}};_e=de([j({message:"Colorize will be removed in v0.26.0"})],_e);let fe=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data,r=Q.fromRGB(n[s+0],n[s+1],n[s+2],n[s+3]).lighten(this.factor);n[s+0]=r.r,n[s+1]=r.g,n[s+2]=r.b,n[s+3]=r.a}};fe=de([j({message:"Lighten will be removed in v0.26.0"})],fe);let me=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data,r=Q.fromRGB(n[s+0],n[s+1],n[s+2],n[s+3]).darken(this.factor);n[s+0]=r.r,n[s+1]=r.g,n[s+2]=r.b,n[s+3]=r.a}};me=de([j({message:"Darken will be removed v0.26.0"})],me);let ye=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data,r=Q.fromRGB(n[s+0],n[s+1],n[s+2],n[s+3]).saturate(this.factor);n[s+0]=r.r,n[s+1]=r.g,n[s+2]=r.b,n[s+3]=r.a}};ye=de([j({message:"Saturate will be removed in v0.26.0"})],ye);let we=class{constructor(t=.1){this.factor=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data,r=Q.fromRGB(n[s+0],n[s+1],n[s+2],n[s+3]).desaturate(this.factor);n[s+0]=r.r,n[s+1]=r.g,n[s+2]=r.b,n[s+3]=r.a}};we=de([j({message:"Desaturate will be removed in v0.26.0"})],we);let ve=class{constructor(t){this.color=t}updatePixel(t,e,i){const s=4*(t+e*i.width),n=i.data;0!==n[s+3]&&(n[s+0]=this.color.r,n[s+1]=this.color.g,n[s+2]=this.color.b)}};ve=de([j({message:"Fill will be removed in v0.26.0"})],ve);var xe=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))};class be{constructor(t,e=!0){this.path=t,this.bustCache=e,this._sprite=null,this.loaded=new Promise((t=>{this._loadedResolve=t})),this._resource=new ce(t,"blob",e),this._sprite=new Ee(this,0,0,0,0)}get image(){return this.data}isLoaded(){return!!this.data}load(){return xe(this,void 0,void 0,(function*(){try{let t;if(this.path.includes("data:image/"))t=this.path;else{const e=yield this._resource.load();t=URL.createObjectURL(e)}const e=new Image;e.src=t,yield e.decode(),this.data=e,this.width=this._sprite.width=e.naturalWidth,this.height=this._sprite.height=e.naturalHeight,this._sprite=new Ee(this,0,0,this.width,this.height)}catch(t){yield Promise.reject("Error loading texture")}return this._loadedResolve(this.data),this.data}))}asSprite(){return this._sprite}}function Ce(t){return class extends t{assign(t){for(const e in t)"function"!=typeof this[e]&&(this[e]=t[e])}constructor(...t){super(...t);1!==t.filter((function(t){return void 0!==t})).length||!t[0]||"object"!=typeof t[0]||t[0]instanceof Array||this.assign(t[0])}}}var Ae=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o},Se=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))};class Pe{constructor(t,e,i,s,n){this.x=0,this.y=0,this.rotation=0,this.anchor=q.Half,this.offset=q.Zero,this.scale=q.One,this.drawAroundAnchor=!1,this.logger=_.getInstance(),this.flipVertical=!1,this.flipHorizontal=!1,this.effects=[],this.width=0,this.height=0,this._spriteCanvas=null,this._spriteCtx=null,this._pixelData=null,this._pixelsLoaded=!1,this._dirtyEffect=!0,this._opacity=1;let r=t;if(t&&!(t instanceof be)&&(e=0|t.x,i=0|t.y,s=0|t.width,n=0|t.height,r=t.image,!r)){throw new Error("An image texture is required to construct a sprite")}this.x=e||0,this.y=i||0,this.texture=r,this._spriteCanvas=document.createElement("canvas"),this._spriteCanvas.width=s,this._spriteCanvas.height=n,this._spriteCtx=this._spriteCanvas.getContext("2d"),this._initPixelsFromTexture(),this.width=s,this.height=n}get drawWidth(){return Math.abs(this.width*this.scale.x)}get drawHeight(){return Math.abs(this.height*this.scale.y)}_initPixelsFromTexture(){return Se(this,void 0,void 0,(function*(){try{const t=yield this.texture.loaded;this.width=this.width||t.naturalWidth,this.height=this.height||t.naturalHeight,this._spriteCanvas.width=this._spriteCanvas.width||t.naturalWidth,this._spriteCanvas.height=this._spriteCanvas.height||t.naturalHeight,this._loadPixels(),this._dirtyEffect=!0}catch(t){this.logger.error("Error loading texture ",this.texture.path,t)}}))}_loadPixels(){if(this.texture.isLoaded()&&!this._pixelsLoaded){const t=this.texture.image.naturalWidth||0,e=this.texture.image.naturalHeight||0;if(this.width>t&&this.logger.warn(`The sprite width ${this.width} exceeds the width \n ${t} of the backing texture ${this.texture.path}`),this.width<=0||t<=0)throw new Error(`The width of a sprite cannot be 0 or negative, sprite width: ${this.width}, original width: ${t}`);if(this.height>e&&this.logger.warn(`The sprite height ${this.height} exceeds the height \n ${e} of the backing texture ${this.texture.path}`),this.height<=0||e<=0)throw new Error(`The height of a sprite cannot be 0 or negative, sprite height: ${this.height}, original height: ${e}`);this._flushTexture(),this._pixelsLoaded=!0}}_flushTexture(){const t=this.texture.image.naturalWidth||0,e=this.texture.image.naturalHeight||0;this._spriteCtx.clearRect(0,0,this.width,this.height),this._spriteCtx.drawImage(this.texture.image,S(this.x,0,t),S(this.y,0,e),S(this.width,0,t),S(this.height,0,e),0,0,this.width,this.height)}opacity(t){this._opacity=t}grayscale(){this.addEffect(new ue)}invert(){this.addEffect(new pe)}fill(t){this.addEffect(new ve(t))}colorize(t){this.addEffect(new _e(t))}lighten(t=.1){this.addEffect(new fe(t))}darken(t=.1){this.addEffect(new me(t))}saturate(t=.1){this.addEffect(new ye(t))}desaturate(t=.1){this.addEffect(new we(t))}addEffect(t){this.effects.push(t),this.texture.isLoaded()&&this._pixelsLoaded?this._applyEffects():this._dirtyEffect=!0}removeEffect(t){let e=-1;e="number"==typeof t?t:this.effects.indexOf(t),e<0||e>=this.effects.length||(this.effects.splice(e,1),this.texture.isLoaded()&&this._pixelsLoaded?this._applyEffects():this._dirtyEffect=!0)}_applyEffects(){if(this._flushTexture(),this.effects.length>0){this._pixelData=this._spriteCtx.getImageData(0,0,this.width,this.height);const t=this.effects.length;for(let e=0;e<t;e++)for(let t=0;t<this.height;t++)for(let i=0;i<this.width;i++)this.effects[e].updatePixel(i,t,this._pixelData);this._spriteCtx.clearRect(0,0,this.width,this.height),this._spriteCtx.putImageData(this._pixelData,0,0)}this._dirtyEffect=!1}clearEffects(){this.effects.length=0,this._applyEffects()}reset(){}debugDraw(t,e,i){t.save(),t.translate(e,i),t.rotate(this.rotation);const s=this.drawWidth*this.anchor.x,n=this.drawHeight*this.anchor.y;t.strokeStyle=Q.Black.toString(),t.strokeRect(-s,-n,this.drawWidth,this.drawHeight),t.restore()}draw(t,e,i){t instanceof CanvasRenderingContext2D?this._drawWithOptions({ctx:t,x:e,y:i}):this._drawWithOptions(t)}_drawWithOptions(t){var e,i,s,n,r,o,a,h,l;const{ctx:c,x:d,y:u,rotation:p,drawWidth:g,drawHeight:_,anchor:f,offset:m,opacity:y,flipHorizontal:w,flipVertical:v}=Object.assign(Object.assign({},t),{rotation:null!==(e=t.rotation)&&void 0!==e?e:this.rotation,drawWidth:null!==(i=t.drawWidth)&&void 0!==i?i:this.width,drawHeight:null!==(s=t.drawHeight)&&void 0!==s?s:this.height,flipHorizontal:null!==(n=t.flipHorizontal)&&void 0!==n?n:this.flipHorizontal,flipVertical:null!==(r=t.flipVertical)&&void 0!==r?r:this.flipVertical,anchor:null!==(o=t.anchor)&&void 0!==o?o:this.anchor,offset:null!==(a=t.offset)&&void 0!==a?a:this.offset,opacity:(null!==(h=t.opacity)&&void 0!==h?h:1)*(null!==(l=this._opacity)&&void 0!==l?l:1)});this._dirtyEffect&&this._applyEffects();const x=g*f.x+m.x,b=_*f.y+m.y,C=this.scale.x>0?1:-1,A=this.scale.y>0?1:-1;c.save(),c.translate(d,u),c.scale(Math.abs(this.scale.x),Math.abs(this.scale.y)),this.drawAroundAnchor&&c.translate(-x,-b),c.translate(x,b),c.rotate(p),c.scale(C,A),c.translate(-x,-b),w&&(c.translate(g,0),c.scale(-1,1)),v&&(c.translate(0,_),c.scale(1,-1));const S=c.globalAlpha;c.globalAlpha=y,c.drawImage(this._spriteCanvas,0,0,this.width,this.height,0,0,this.width,this.height),c.globalAlpha=S,c.restore()}clone(){const t=new Ee(this.texture,this.x,this.y,this.width,this.height);t.anchor=this.anchor.clone(),t.scale=this.scale.clone(),t.rotation=this.rotation,t.flipHorizontal=this.flipHorizontal,t.flipVertical=this.flipVertical;const e=this.effects.length;for(let i=0;i<e;i++)t.addEffect(this.effects[i]);return t}}let Ee=class extends(Ce(Pe)){constructor(t,e,i,s,n){super(t,e,i,s,n)}};Ee=Ae([j({message:"Label.clearTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],Ee);class Te extends vt{constructor(t){var e,i;super(t),this.image=t.image;const{width:s,height:n}=t;this.sourceView=null!==(e=t.sourceView)&&void 0!==e?e:{x:0,y:0,width:null!=s?s:0,height:null!=n?n:0},this.destSize=null!==(i=t.destSize)&&void 0!==i?i:{width:null!=s?s:0,height:null!=n?n:0},this._updateSpriteDimensions(),this.image.ready.then((()=>{this._updateSpriteDimensions()}))}static from(t){return new Te({image:t})}_updateSpriteDimensions(){var t,e,i,s,n,r;const{width:o,height:a}=this.image;this.sourceView.width=(null===(t=this.sourceView)||void 0===t?void 0:t.width)||o,this.sourceView.height=(null===(e=this.sourceView)||void 0===e?void 0:e.height)||a,this.destSize.width=(null===(i=this.destSize)||void 0===i?void 0:i.width)||(null===(s=this.sourceView)||void 0===s?void 0:s.width)||o,this.destSize.height=(null===(n=this.destSize)||void 0===n?void 0:n.height)||(null===(r=this.sourceView)||void 0===r?void 0:r.height)||a,this.width=Math.ceil(this.destSize.width),this.height=Math.ceil(this.destSize.height)}_preDraw(t,e,i){this.image.isLoaded()&&this._updateSpriteDimensions(),super._preDraw(t,e,i)}_drawImage(t,e,i){this.image.isLoaded()&&(this._updateSpriteDimensions(),t.drawImage(this.image.image,this.sourceView.x,this.sourceView.y,this.sourceView.width,this.sourceView.height,e,i,this.destSize.width,this.destSize.height))}static fromLegacySprite(t){const e=t.texture,i=De.fromLegacyTexture(e);return new Te({image:i,sourceView:{x:t.x,y:t.y,width:t.width,height:t.height}})}static toLegacySprite(t){const e=t.image,i=new be(e.path);return i.data=e.image,new Ee(i,t.sourceView.x,t.sourceView.y,t.sourceView.width,t.sourceView.height)}clone(){return new Te(Object.assign({image:this.image,sourceView:Object.assign({},this.sourceView),destSize:Object.assign({},this.destSize)},this.cloneGraphicOptions()))}}var Re=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))};class De{constructor(t,e=!1){this.path=t,this._logger=_.getInstance(),this.data=new Image,this._resource=new ce(t,"blob",e),(t.endsWith(".svg")||t.endsWith(".gif"))&&this._logger.warn(`Image type is not fully supported, you may have mixed results ${t}. Fully supported: jpg, bmp, and png`),this.ready=new Promise((t=>{this._loadedResolve=t}))}get width(){return this.image.naturalWidth}get height(){return this.image.naturalHeight}isLoaded(){return!!this.data.src}get image(){return this.data}load(){return Re(this,void 0,void 0,(function*(){if(this.isLoaded())return this.data;try{let t;if(this.path.includes("data:image/"))t=this.path;else{const e=yield this._resource.load();t=URL.createObjectURL(e)}const e=new Image;e.src=t,yield e.decode(),this.data=e}catch(t){throw`Error loading ImageSource from path '${this.path}' with error [${t.message}]`}return this._loadedResolve(this.data),this.data}))}toSprite(){return Te.from(this)}static fromLegacyTexture(t){const e=new De(t.path);return t.isLoaded()?e.data=t.data:t.loaded.then((()=>{e.data=t.data})),e}unload(){this.data=new Image}}var Be=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class Me{constructor(t,e,i,s){this.sprites=[],this.currentFrame=0,this._timeLeftInFrame=0,this._idempotencyToken=-1,this.anchor=q.Zero,this.rotation=0,this.scale=q.One,this.loop=!0,this.freezeFrame=-1,this.flipVertical=!1,this.flipHorizontal=!1,this.drawWidth=0,this.drawHeight=0,this.width=0,this.height=0,this._opacity=1;let n=t;if(t&&!(t instanceof pr)){const r=t;n=r.engine,e=r.sprites,i=r.speed,s=r.loop}this.sprites=e,this.speed=i,this._engine=n,this._timeLeftInFrame=this.speed,null!=s&&(this.loop=s),e&&e[0]&&(this.drawHeight=e[0]?e[0].drawHeight:0,this.drawWidth=e[0]?e[0].drawWidth:0,this.width=e[0]?e[0].width:0,this.height=e[0]?e[0].height:0,this.freezeFrame=e.length-1)}opacity(t){this._opacity=t}grayscale(){this.addEffect(new ue)}invert(){this.addEffect(new pe)}fill(t){this.addEffect(new ve(t))}colorize(t){this.addEffect(new _e(t))}lighten(t=.1){this.addEffect(new fe(t))}darken(t=.1){this.addEffect(new me(t))}saturate(t=.1){this.addEffect(new ye(t))}desaturate(t=.1){this.addEffect(new we(t))}addEffect(t){for(const e in this.sprites)this.sprites[e].addEffect(t)}removeEffect(t){for(const e in this.sprites)this.sprites[e].removeEffect(t)}clearEffects(){for(const t in this.sprites)this.sprites[t].clearEffects()}_setAnchor(t){for(const e in this.sprites)this.sprites[e].anchor.setTo(t.x,t.y)}_setRotation(t){for(const e in this.sprites)this.sprites[e].rotation=t}_setScale(t){for(const e in this.sprites)this.sprites[e].scale=t}reset(){this.currentFrame=0}isDone(){return!this.loop&&this.currentFrame>=this.sprites.length}tick(t,e){if(this._idempotencyToken===e)return;this._idempotencyToken=e,this._timeLeftInFrame-=t,this._timeLeftInFrame<=0&&(this.currentFrame=this.loop?(this.currentFrame+1)%this.sprites.length:this.currentFrame+1,this._timeLeftInFrame=this.speed),this._updateValues();const i=this.sprites[this.currentFrame];i&&(this.width=i.width,this.height=i.height,this.drawWidth=i.drawWidth,this.drawHeight=i.drawHeight)}_updateValues(){this._setAnchor(this.anchor),this._setRotation(this.rotation),this._setScale(this.scale)}skip(t){this.currentFrame=(this.currentFrame+t)%this.sprites.length}draw(t,e,i){t instanceof CanvasRenderingContext2D?this._drawWithOptions({ctx:t,x:e,y:i}):this._drawWithOptions(t)}_drawWithOptions(t){var e,i,s,n,r,o,a,h;const l=Object.assign(Object.assign({},t),{rotation:null!==(e=t.rotation)&&void 0!==e?e:this.rotation,drawWidth:null!==(i=t.drawWidth)&&void 0!==i?i:this.drawWidth,drawHeight:null!==(s=t.drawHeight)&&void 0!==s?s:this.drawHeight,flipHorizontal:null!==(n=t.flipHorizontal)&&void 0!==n?n:this.flipHorizontal,flipVertical:null!==(r=t.flipVertical)&&void 0!==r?r:this.flipVertical,anchor:null!==(o=t.anchor)&&void 0!==o?o:this.anchor,opacity:(null!==(a=t.opacity)&&void 0!==a?a:1)*(null!==(h=this._opacity)&&void 0!==h?h:1)});let c;this._updateValues(),this.currentFrame<this.sprites.length&&(c=this.sprites[this.currentFrame],c.draw(l)),-1!==this.freezeFrame&&this.currentFrame>=this.sprites.length&&(c=this.sprites[S(this.freezeFrame,0,this.sprites.length-1)],c.draw(l)),c&&(this.drawWidth=c.drawWidth,this.drawHeight=c.drawHeight)}play(t,e){this.reset(),this._engine.playAnimation(this,t,e)}}let ke=class extends(Ce(Me)){constructor(t,e,i,s){super(t,e,i,s)}};var Fe,Le,Ie,Oe,ze;ke=Be([j({message:"Animation will be removed in v0.26.0",alternateMethod:"Use Graphics.Animation"})],ke),function(t){t.Em="em",t.Rem="rem",t.Px="px",t.Pt="pt",t.Percent="%"}(Fe||(Fe={})),function(t){t.Left="left",t.Right="right",t.Center="center",t.Start="start",t.End="end"}(Le||(Le={})),function(t){t.Top="top",t.Hanging="hanging",t.Middle="middle",t.Alphabetic="alphabetic",t.Ideographic="ideographic",t.Bottom="bottom"}(Ie||(Ie={})),function(t){t.Normal="normal",t.Italic="italic",t.Oblique="oblique"}(Oe||(Oe={})),function(t){t.LeftToRight="ltr",t.RightToLeft="rtl"}(ze||(ze={}));var Ue=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class He{constructor(t,e,i,s,n,r){this._sprites=[],this._image=null,this._columns=0,this._rows=0,this._spWidth=0,this._spHeight=0,this._spacing=0;let o=!1;if(t instanceof Array?this._sprites=t:(!t||t instanceof be?(this._image=t,this._columns=e,this._rows=i,this._spWidth=s,this._spHeight=n,this._spacing=r||0):(this._columns=t.columns,this._rows=t.rows,this._spWidth=t.spWidth,this._spHeight=t.spHeight,this._image=t.image,this._spacing=t.spacing||0),this._sprites=new Array(this._columns*this._rows),o=!0),this.image instanceof be){let t=!1,e=!1;if(this.image.isLoaded()){if(t=this.spWidth*this.columns>this.image.image.naturalWidth,e=this.spHeight*this.rows>this.image.image.naturalHeight,t)throw new RangeError(`SpriteSheet specified is wider, ${this.columns} cols x ${this.spWidth} pixels > ${this.image.image.naturalWidth} pixels than image width`);if(e)throw new RangeError(`SpriteSheet specified is taller, ${this.rows} rows x ${this.spHeight} pixels > ${this.image.image.naturalHeight} pixels than image height`)}}if(o){const t=this.getSpacingDimensions();for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this._sprites[i+e*this.columns]=new Ee(this.image,i*this.spWidth+t.margin*i+t.left,e*this.spHeight+t.margin*e+t.top,this.spWidth,this.spHeight)}}get spacing(){return this._spacing}get sprites(){return[...this._sprites]}get image(){return this._image}get columns(){return this._columns}get rows(){return this._rows}get spWidth(){return this._spWidth}get spHeight(){return this._spHeight}getSpacingDimensions(){var t,e,i;return"number"==typeof this.spacing?{left:this.spacing,top:this.spacing,margin:this.spacing}:{left:null!==(t=this.spacing.left)&&void 0!==t?t:0,top:null!==(e=this.spacing.top)&&void 0!==e?e:0,margin:null!==(i=this.spacing.margin)&&void 0!==i?i:0}}getAnimationByIndices(t,e,i){let s=e.map((t=>this.sprites[t]));return s=s.map((function(t){return t.clone()})),new ke(t,s,i)}getAnimationBetween(t,e,i,s){let n=this.sprites.slice(e,i);return n=n.map((function(t){return t.clone()})),new ke(t,n,s)}getAnimationForAll(t,e){const i=this.sprites.map((function(t){return t.clone()}));return new ke(t,i,e)}getSprite(t){if(t>=0&&t<this.sprites.length)return this.sprites[t];throw new Error("Invalid index: "+t)}getAnimationByCoords(t,e,i){let s=0,n=0;const r=new Array(e.length);for(let t=0;t<e.length;t++){const i=e[t];i.image=i.image||this.image,s=Math.max(s,i.drawWidth),n=Math.max(n,i.drawHeight),r[t]=new Ee(i)}const o=new ke(t,r,i);return o.drawWidth=s,o.drawHeight=n,o}}let We=class extends He{constructor(t,e,i,s,n,r,o,a){super(t instanceof be?{image:t,spWidth:r,spHeight:o,rows:n,columns:s,spacing:a||0}:t),this._currentColor=Q.Black,this._currentOpacity=1,this._spriteRecord={},this._textShadowOn=!1,this._textShadowDirty=!0,this._textShadowColor=Q.Black,this._textShadowSprites={},this._shadowOffsetX=5,this._shadowOffsetY=5,!t||t instanceof be||(e=t.alphabet,i=t.caseInsensitive),this.alphabet=e,this.caseInsensitive=i,this._spriteRecord=this.getTextSprites()}getTextSprites(){const t={};for(let e=0;e<this.alphabet.length;e++){let i=this.alphabet[e];this.caseInsensitive&&(i=i.toLowerCase()),t[i]=this.sprites[e].clone()}return t}setTextShadow(t,e,i){this._textShadowOn=!0,this._shadowOffsetX=t,this._shadowOffsetY=e,this._textShadowColor=i.clone(),this._textShadowDirty=!0;for(const t in this._spriteRecord)this._textShadowSprites[t]=this._spriteRecord[t].clone()}useTextShadow(t){this._textShadowOn=t,t&&this.setTextShadow(5,5,this._textShadowColor)}draw(t,e,i,s,n){if(n=this._parseOptions(n),this._currentColor.toString()!==n.color.toString()||this._currentOpacity!==n.opacity){this._currentOpacity=n.opacity,this._currentColor=n.color;for(const t in this._spriteRecord)this._spriteRecord[t].clearEffects(),this._spriteRecord[t].fill(n.color),this._spriteRecord[t].opacity(n.opacity)}if(this._textShadowOn&&this._textShadowDirty&&this._textShadowColor){for(const t in this._textShadowSprites)this._textShadowSprites[t].clearEffects(),this._textShadowSprites[t].addEffect(new ve(this._textShadowColor.clone()));this._textShadowDirty=!1}const r=this.sprites[0],o=r.height,a=n.fontSize/o,h=e.length*r.width*a+e.length*n.letterSpacing;let l=i;n.textAlign===Le.Left||n.textAlign===Le.Start?l=i:n.textAlign===Le.Right||n.textAlign===Le.End?l=i-h:n.textAlign===Le.Center&&(l=i-h/2);let c=s-o*a;n.baseAlign===Ie.Top||n.baseAlign===Ie.Hanging?c=s:n.baseAlign===Ie.Ideographic||n.baseAlign===Ie.Bottom||n.baseAlign===Ie.Alphabetic?c=s-o*a:n.baseAlign===Ie.Middle&&(c=s-o*a/2);for(let i=0;i<e.length;i++){let s=e[i];this.caseInsensitive&&(s=s.toLowerCase());try{this._textShadowOn&&(this._textShadowSprites[s].drawAroundAnchor=!1,this._textShadowSprites[s].scale=K(a,a),this._textShadowSprites[s].draw(t,l+this._shadowOffsetX,c+this._shadowOffsetY));const e=this._spriteRecord[s];e.drawAroundAnchor=!1,e.scale=K(a,a),e.draw(t,l,c),l+=e.drawWidth+n.letterSpacing}catch(t){_.getInstance().error(`SpriteFont Error drawing char ${s}`)}}}_parseOptions(t){return{fontSize:t.fontSize||10,letterSpacing:t.letterSpacing||0,color:t.color||Q.Black,textAlign:void 0===typeof t.textAlign?Le.Left:t.textAlign,baseAlign:void 0===typeof t.baseAlign?Ie.Bottom:t.baseAlign,maxWidth:t.maxWidth||-1,opacity:t.opacity||0}}};We=Ue([j({message:"SpriteSheet will be removed in v0.26.0",alternateMethod:"Use Graphics.SpriteSheet"})],We);class Ne{constructor(t){this._logger=_.getInstance(),this.sprites=[];const{sprites:e,rows:i,columns:s}=t;this.sprites=e,this.rows=null!=i?i:1,this.columns=null!=s?s:this.sprites.length}getSprite(t,e){if(t>=this.columns||t<0)return this._logger.warn(`No sprite exists in the SpriteSheet at (${t}, ${e}), x: ${t} should be between 0 and ${this.columns-1}`),null;if(e>=this.rows||e<0)return this._logger.warn(`No sprite exists in the SpriteSheet at (${t}, ${e}), y: ${e} should be between 0 and ${this.rows-1}`),null;const i=t+e*this.columns;return this.sprites[i]}static fromLegacySpriteSheet(t){const e=t.sprites.map((t=>Te.fromLegacySprite(t)));return new Ne({sprites:e})}static toLegacySpriteSheet(t){const e=t.sprites.map((t=>Te.toLegacySprite(t)));return new He(e)}static fromImageSource(t){var e;const i=[];t.spacing=null!==(e=t.spacing)&&void 0!==e?e:{};const{image:s,grid:{rows:n,columns:r,spriteWidth:o,spriteHeight:a},spacing:{originOffset:h,margin:l}}=t,c=Object.assign({x:0,y:0},h),d=Object.assign({x:0,y:0},l);for(let t=0;t<r;t++)for(let e=0;e<n;e++)i[t+e*r]=new Te({image:s,sourceView:{x:t*o+d.x*t+c.x,y:e*a+d.y*e+c.y,width:o,height:a},destSize:{height:a,width:o}});return new Ne({sprites:i,rows:n,columns:r})}}class Ve extends vt{constructor(t){super(t),this._text="",this._dirty=!0,this.alphabet="",this.shadow=null,this.caseInsensitive=!1,this.spacing=0,this._logger=_.getInstance(),this._sprites=[];const{alphabet:e,spriteSheet:i,caseInsensitive:s,spacing:n,shadow:r}=t;this.alphabet=e,this.spriteSheet=i,this.caseInsensitive=null!=s?s:this.caseInsensitive,this.spacing=null!=n?n:this.spacing,this.shadow=null!=r?r:this.shadow,this.spriteSheet.sprites[0].image.ready.then((()=>{this._updateDimensions()}))}static fromLegacySpriteFont(t){const e=t.sprites.map(Te.fromLegacySprite);return new Ve({alphabet:t.alphabet,spacing:0,caseInsensitive:t.caseInsensitive,spriteSheet:new Ne({sprites:e})})}_getCharacterSprites(t){if(!this._dirty)return this._sprites;const e=[],i=this.caseInsensitive?t.toLocaleLowerCase():t,s=this.caseInsensitive?this.alphabet.toLocaleLowerCase():this.alphabet;for(let t=0;t<i.length;t++){const n=i[t];let r=s.indexOf(n);-1===r&&(r=0,this._logger.warn(`SpriteFont - Cannot find letter '${n}' in configured alphabet '${s}'`));const o=this.spriteSheet.sprites[r];o?e.push(o):this._logger.warn(`SpriteFont - Cannot find sprite for '${n}' at index '${r}' in configured SpriteSheet`)}return this._dirty=!1,this._sprites=e}_updateDimensions(){const t=this._getCharacterSprites(this._text);let e=0,i=0;for(const s of t)e+=s.width+this.spacing,i=Math.max(i,s.height);this.width=e,this.height=i}updateText(t){this._text!==t&&(this._dirty=!0,this._text=t,this._updateDimensions())}_preDraw(t,e,i){this._updateDimensions(),super._preDraw(t,e,i)}_drawImage(t,e,i){let s=0;for(const n of this._getCharacterSprites(this._text))n.draw(t,e+s,i),s+=n.width+this.spacing}render(t,e,i,s){this._text!==e&&(this._dirty=!0,this._text=e),this.shadow&&(t.save(),t.translate(this.shadow.offset.x,this.shadow.offset.y),this.draw(t,i,s),t.restore()),this.draw(t,i,s)}clone(){return new Ve({alphabet:this.alphabet,spriteSheet:this.spriteSheet,spacing:this.spacing})}}class Ge{constructor(){this.fontSheet="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAwCAYAAAD+f6R/AAAAAXNSR0IArs4c6QAABcJJREFUeJztnemu7CgMhGE07//KmT9NhrAFVzkQndQntXRP3/bCZkwCSQhCCCGEEEIIIYQQQog/TRz953Ecx/nDGIe/vdNhlc9tIz605Fk/ZmWfsO1hn9Gxuv1KHbvb3iL/VN+d1WORbyr7yR/5b9M4vjNeqko6jPJHq5wGHU151o9J2Udse9hndCxuv0rH7rY3yD/Wdyf13MrnQeDfkZIUSGKM4ff3cWN82pEZuTyQGX2IxeyR63va//8VNCYCq+1yEkLtWyagXv1P1r1H+110gP3PzT4gT8uW/mdQ8mUG8E9DqOz4MS9ICKGbXpS2BpnIrRzYeS96cll08INlCMl2/glzdcfazuuPqQO03lmqrBHsf272Q6NODXj6zzZIJd/LAHYTg3Mays5gBi7ZR27fOgs0yj8rm36DLMFiPgkAdXHKOwUQeMCQ/adSh/qBQrT/tPxbAwA9+DOZEILPAATSuHMgTv7+Auk/df2lHPCZLvMSLJe34LkEQ9PwXF1SRTllMYgvIaflqyVAjLGbsiCDcOK76jflxZ+sINPyROc5071yKWK5CJTV3dMp6+tBlyCtNlhAq/+XbWoBDcRNXYBMzD4VvQygSuPYC2jGGaSSOxXfy3dTUEsanIvNeepm38N/hssSALTPZnAXfwIYRJn2b7UBcw0FKX+nDdAMpm2j9WVnxrUa7TXaVAca/B+TgaAVh6R/rH0P/5m01dt/RLYViJn+w/bhVX2P7f/duqom5qb02pRLCLGIMgBU1wCEEN9BAUCID6MAIMSHUQAQ4sMoAAjxYRQAhPgwd1uB0fuZ7H3cnn2P+9mr/Pe4B8/eB/fwP4eRtci/0f6OfTCPt/9oHwC6G6y19RHZDumxmwzR4eE/s/2Tte/q/+XLdc9DeJ19diesQc/j7Z8fCe4tAS4CxZ7sp7eiJi7HiZmjmOTGJs+93CbS3nP0XIPH3vW8/qz6QPnX2QdsV/1uw/iZYvg8ACeHd28rpPzfNfhL+7vkw/4Ou9s+Onhbv91elpKZ48Dl6bzpwwibHigRArf+Ptk9+L3Y1Q5OB4LgCeSBw1iuB3GeJh1/HrX/zF0A9Mk+u45zMkc3r4rWPomma5+p/514LB+Zo93MErJ1JHxXPzByGa/licRYVKbpeQCoQ6Q8yxuCwJF9IPsoDkHAo/3Tx26cvA4EtJ/n04w8QOq/mrR7ddfLAC5BYFNlVI/0CnOVUflOpvJUQMx9AIMIW/nWDM67/qw0+95v9goBqD9j+72u/KD9U89IbnQbMIR2Zbneh5zUY7Hdk7XIP3UffVb+r+wDYAZLq+1n1+C7y3/ny2r7p5yeByDEh9HzAIQQJwoAQnwYBQAhPowCgBBjoNu3hNxSFACE6INuKvPajPZ4EFEAEKINcybGYzOd247WEd3TgA2jlmjEyrd+j9hvfVbD2PWQ3ZmGlu2HyO8og8eBuNUvNYWoDgMVpwHTJoLWdz1Y+ZYOy5uF7t6PPruZxANrud1lQXkP0jsGz/Yz+vGGMuygFyhSPcJnc1pMnQZElc+cRnoAlxdTvoDuK7puqF7uCQy+3fyFMiA02/vJQHh7DQDogMPTSGFNA56HTzbZ9yAfBOb1Zyo3qGM3MfMZ3f76huXf6xlmAHknMlLNXsBBBvbljIz9Uyz5Y5TzIBLR/qy/rNyrZ8+L/0BZ0m+tgXD0OK5XZxC/9P7I/g4hVFvzXf1/6i5A7+3AlijMPBLMZfCvuAp7A9rY56ApHitmLQc7c8bOv6ftAxlM9Xp35nkEK7nJetBsaMhtAAAuOLQGXwhh2dXQnn1rZ/a42BI3dL7L+jkFAbQddwdA9Ah35yMKhgEgVT46EFh5D4jz+OgavNKxeBCd1wDSJ/97oR8eoJkLi9t9/BDgDHTJ5NE7Dnzechh914OVv9M1K9PCqsfqb88XVg9qN9lm6nG176UPu+zn17GOxuO0vOWEEC/j+LFKTgghlvEfYJaLS+SA2O0AAAAASUVORK5CYII=",this.size=16,this.load()}load(){return this._imageSource=new De(this.fontSheet),this._imageSource.load().then((()=>{this._spriteSheet=Ne.fromImageSource({image:this._imageSource,grid:{rows:3,columns:16,spriteWidth:16,spriteHeight:16}}),this._spriteFont=new Ve({alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,!'&.\"?-()+ ",caseInsensitive:!0,spriteSheet:this._spriteSheet,spacing:-6})}))}write(t,e,i){this._imageSource.isLoaded()&&this._spriteFont.render(t,e,i.x,i.y)}}class je{constructor(t){this._webglCtx=t,this._debugText=new Ge}drawRect(t,e,i,s,n={color:Q.Black}){this.drawLine(K(t,e),K(t+i,e),Object.assign({},n)),this.drawLine(K(t+i,e),K(t+i,e+s),Object.assign({},n)),this.drawLine(K(t+i,e+s),K(t,e+s),Object.assign({},n)),this.drawLine(K(t,e+s),K(t,e),Object.assign({},n))}drawLine(t,e,i={color:Q.Black}){this._webglCtx.__lineRenderer.addLine(t,e,i.color)}drawPoint(t,e={color:Q.Black,size:5}){this._webglCtx.__pointRenderer.addPoint(t,e.color,e.size)}drawText(t,e){this._debugText.write(this._webglCtx,t,e)}}class Xe{constructor(t){this._transform=new it,this._state=new st,this.snapToPixel=!0,this.smoothing=!1,this.backgroundColor=Q.ExcaliburBlue,this.debug=new je(this);const{canvasElement:e,enableTransparency:i,smoothing:s,snapToPixel:n,backgroundColor:r}=t;this.__gl=e.getContext("webgl",{antialias:null!=s?s:this.smoothing,premultipliedAlpha:!1,alpha:null==i||i,depth:!0,powerPreference:"high-performance"}),this.snapToPixel=null!=n?n:this.snapToPixel,this.smoothing=null!=s?s:this.smoothing,this.backgroundColor=null!=r?r:this.backgroundColor,this._init()}get opacity(){return this._state.current.opacity}set opacity(t){this._state.current.opacity=t}get width(){return this.__gl.canvas.width}get height(){return this.__gl.canvas.height}checkIfResolutionSupported(t){const e=this.__gl,i=e.getParameter(e.MAX_TEXTURE_SIZE)/4;let s=!0;return(t.width>i||t.height>i)&&(s=!1),s}_init(){const t=this.__gl;this._ortho=et.ortho(0,t.canvas.width,t.canvas.height,0,400,-400),t.viewport(0,0,t.canvas.width,t.canvas.height),t.clearColor(this.backgroundColor.r/255,this.backgroundColor.g/255,this.backgroundColor.b/255,this.backgroundColor.a),t.clear(t.COLOR_BUFFER_BIT),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.__pointRenderer=new wt(t,{matrix:this._ortho,transform:this._transform,state:this._state}),this.__lineRenderer=new ct(t,{matrix:this._ortho,transform:this._transform,state:this._state}),this.__imageRenderer=new mt(t,{matrix:this._ortho,transform:this._transform,state:this._state}),this._canvas=new At({width:t.canvas.width,height:t.canvas.height}),this.__ctx=this._canvas.ctx}resetTransform(){this._transform.current=et.identity()}updateViewport(){const t=this.__gl;this._ortho=this._ortho=et.ortho(0,t.canvas.width,t.canvas.height,0,400,-400),this.__pointRenderer.shader.addUniformMatrix("u_matrix",this._ortho.data),this.__lineRenderer.shader.addUniformMatrix("u_matrix",this._ortho.data),this.__imageRenderer.shader.addUniformMatrix("u_matrix",this._ortho.data),this._canvas.width=t.canvas.width,this._canvas.height=t.canvas.height}drawImage(t,e,i,s,n,r,o,a,h){if(0!==s&&0!==n&&0!==a&&0!==h&&0!==t.width&&0!==t.height)return t?void this.__imageRenderer.addImage(t,e,i,s,n,r,o,a,h):(_.getInstance().warn("Cannot draw a null or undefined image"),void(console.trace&&console.trace()))}drawLine(t,e,i,s=1){this.__imageRenderer.addLine(i,t,e,s)}drawRectangle(t,e,i,s){this.__imageRenderer.addRectangle(s,t,e,i)}drawCircle(t,e,i){this.__imageRenderer.addCircle(t,e,i)}save(){this._transform.save(),this._state.save()}restore(){this._transform.restore(),this._state.restore()}translate(t,e){this._transform.translate(this.snapToPixel?~~t:t,this.snapToPixel?~~e:e)}rotate(t){this._transform.rotate(t)}scale(t,e){this._transform.scale(t,e)}transform(t){this._transform.current=t}clear(){const t=this.__gl;t.clearColor(this.backgroundColor.r/255,this.backgroundColor.g/255,this.backgroundColor.b/255,this.backgroundColor.a),t.clear(t.COLOR_BUFFER_BIT),ot.clear()}flush(){const t=this.__gl;t.viewport(0,0,t.canvas.width,t.canvas.height),this.__imageRenderer.render(),this.__lineRenderer.render(),this.__pointRenderer.render()}}var qe;!function(t){t.Fixed="Fixed",t.FitScreen="FitScreen",t.FillScreen="FillScreen",t.FitContainer="FitContainer",t.FillContainer="FillContainer",t.Position="Position"}(qe||(qe={}));class Ke{static get SVGA(){return{width:800,height:600}}static get Standard(){return{width:1920,height:1080}}static get Atari2600(){return{width:160,height:192}}static get GameBoy(){return{width:160,height:144}}static get GameBoyAdvance(){return{width:240,height:160}}static get NintendoDS(){return{width:256,height:192}}static get NES(){return{width:256,height:224}}static get SNES(){return{width:256,height:244}}}class Ze{constructor(t){var e,i,s;this._antialiasing=!0,this._resolutionStack=[],this._viewportStack=[],this._pixelRatioOverride=null,this._isFullScreen=!1,this._isDisposed=!1,this._logger=_.getInstance(),this._fullscreenChangeHandler=()=>{this._isFullScreen=!this._isFullScreen,this._logger.debug("Fullscreen Change",this._isFullScreen)},this._pixelRatioChangeHandler=()=>{this._logger.debug("Pixel Ratio Change",window.devicePixelRatio),this._devicePixelRatio=this._calculateDevicePixelRatio(),this.applyResolutionAndViewport()},this._resizeHandler=()=>{const t=this.parent;this._logger.debug("View port resized"),this._setResolutionAndViewportByDisplayMode(t),this.applyResolutionAndViewport()},this._devicePixelRatio=this._calculateDevicePixelRatio(),this._alreadyWarned=!1,this.viewport=t.viewport,this.resolution=null!==(e=t.resolution)&&void 0!==e?e:Object.assign({},this.viewport),this._displayMode=null!==(i=t.displayMode)&&void 0!==i?i:qe.Fixed,this._canvas=t.canvas,this._ctx=t.context,this._antialiasing=null!==(s=t.antialiasing)&&void 0!==s?s:this._antialiasing,this._browser=t.browser,this._position=t.position,this._pixelRatioOverride=t.pixelRatio,this._applyDisplayMode(),this._mediaQueryList=this._browser.window.nativeComponent.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._mediaQueryList.addEventListener("change",this._pixelRatioChangeHandler),this._canvas.addEventListener("fullscreenchange",this._fullscreenChangeHandler),this.applyResolutionAndViewport()}dispose(){this._isDisposed||(this._isDisposed=!0,this._browser.window.off("resize",this._resizeHandler),this._resizeObserver&&this._resizeObserver.disconnect(),this.parent.removeEventListener("resize",this._resizeHandler),this._mediaQueryList.removeEventListener("change",this._pixelRatioChangeHandler),this._canvas.removeEventListener("fullscreenchange",this._fullscreenChangeHandler))}_calculateDevicePixelRatio(){if(window.devicePixelRatio<1)return 1;return window.devicePixelRatio||1}get pixelRatio(){return this._pixelRatioOverride?this._pixelRatioOverride:this._devicePixelRatio}get isHiDpi(){return 1!==this.pixelRatio}get displayMode(){return this._displayMode}get canvas(){return this._canvas}get parent(){return this.displayMode===qe.FillContainer||this.displayMode===qe.FitContainer?this.canvas.parentElement||document.body:window}get resolution(){return this._resolution}set resolution(t){this._resolution=t}get viewport(){return this._viewport?this._viewport:this._resolution}set viewport(t){this._viewport=t}get aspectRatio(){return this._resolution.width/this._resolution.height}get scaledWidth(){return this._resolution.width*this.pixelRatio}get scaledHeight(){return this._resolution.height*this.pixelRatio}setCurrentCamera(t){this._camera=t}pushResolutionAndViewport(){this._resolutionStack.push(this.resolution),this._viewportStack.push(this.viewport),this.resolution=Object.assign({},this.resolution),this.viewport=Object.assign({},this.viewport)}peekViewport(){return this._viewportStack[this._viewportStack.length-1]}peekResolution(){return this._resolutionStack[this._resolutionStack.length-1]}popResolutionAndViewport(){this.resolution=this._resolutionStack.pop(),this.viewport=this._viewportStack.pop()}applyResolutionAndViewport(){if(this._canvas.width=this.scaledWidth,this._canvas.height=this.scaledHeight,this._ctx instanceof Xe){this._ctx.checkIfResolutionSupported({width:this.scaledWidth,height:this.scaledHeight})||this._alreadyWarned||(this._alreadyWarned=!0,this._logger.warn(`The currently configured resolution (${this.resolution.width}x${this.resolution.height}) is too large for the platform WebGL implementation, this may work but cause WebGL rendering to behave oddly. Try reducing the resolution or disabling Hi DPI scaling to avoid this (read more here https://excaliburjs.com/docs/screens#understanding-viewport--resolution).`))}this._antialiasing?this._canvas.style.imageRendering="auto":(this._canvas.style.imageRendering="pixelated",""===this._canvas.style.imageRendering&&(this._canvas.style.imageRendering="crisp-edges")),this._canvas.style.width=this.viewport.width+"px",this._canvas.style.height=this.viewport.height+"px",this._ctx.updateViewport(),this._ctx.resetTransform(),this._ctx.scale(this.pixelRatio,this.pixelRatio),this._ctx.smoothing=this._antialiasing}get antialiasing(){return this._antialiasing}set antialiasing(t){this._antialiasing=t,this._ctx.smoothing=this._antialiasing}get isFullScreen(){return this._isFullScreen}goFullScreen(){return this._canvas.requestFullscreen()}exitFullScreen(){return document.exitFullscreen()}pageToScreenCoordinates(t){let e=t.x,i=t.y;if(this._isFullScreen||(e-=B(this._canvas).x,i-=B(this._canvas).y),this._isFullScreen)if(window.innerWidth/this.aspectRatio<window.innerHeight){const t=window.innerWidth/this.aspectRatio;i=(i-(window.innerHeight-t)/2)/t*this.viewport.height,e=e/window.innerWidth*this.viewport.width}else{const t=window.innerHeight*this.aspectRatio;e=(e-(window.innerWidth-t)/2)/t*this.viewport.width,i=i/window.innerHeight*this.viewport.height}return e=e/this.viewport.width*this.resolution.width,i=i/this.viewport.height*this.resolution.height,new q(e,i)}screenToPageCoordinates(t){let e=t.x,i=t.y;if(e=e/this.resolution.width*this.viewport.width,i=i/this.resolution.height*this.viewport.height,this._isFullScreen)if(window.innerWidth/this.aspectRatio<window.innerHeight){const t=window.innerWidth/this.aspectRatio,s=(window.innerHeight-t)/2;i=i/this.viewport.height*t+s,e=e/this.viewport.width*window.innerWidth}else{const t=window.innerHeight*this.aspectRatio,s=(window.innerWidth-t)/2;e=e/this.viewport.width*t+s,i=i/this.viewport.height*window.innerHeight}return this._isFullScreen||(e+=B(this._canvas).x,i+=B(this._canvas).y),new q(e,i)}screenToWorldCoordinates(t){var e,i,s,n;let r=t.x,o=t.y;return r=r/this.resolution.width*this.drawWidth,o=o/this.resolution.height*this.drawHeight,r-=this.halfDrawWidth,o-=this.halfDrawHeight,r+=null!==(i=null===(e=this._camera)||void 0===e?void 0:e.x)&&void 0!==i?i:0,o+=null!==(n=null===(s=this._camera)||void 0===s?void 0:s.y)&&void 0!==n?n:0,new q(r,o)}worldToScreenCoordinates(t){var e,i,s,n;let r=t.x,o=t.y;return r-=null!==(i=null===(e=this._camera)||void 0===e?void 0:e.x)&&void 0!==i?i:0,o-=null!==(n=null===(s=this._camera)||void 0===s?void 0:s.y)&&void 0!==n?n:0,r+=this.halfDrawWidth,o+=this.halfDrawHeight,r=r/this.drawWidth*this.resolution.width,o=o/this.drawHeight*this.resolution.height,new q(r,o)}pageToWorldCoordinates(t){const e=this.pageToScreenCoordinates(t);return this.screenToWorldCoordinates(e)}worldToPageCoordinates(t){const e=this.worldToScreenCoordinates(t);return this.screenToPageCoordinates(e)}getWorldBounds(){const t=this.screenToWorldCoordinates(q.Zero).x,e=this.screenToWorldCoordinates(q.Zero).y,i=t+this.drawWidth,s=e+this.drawHeight;return new J(t,e,i,s)}get canvasWidth(){return this.canvas.width}get halfCanvasWidth(){return this.canvas.width/2}get canvasHeight(){return this.canvas.height}get halfCanvasHeight(){return this.canvas.height/2}get drawWidth(){return this._camera?this.resolution.width/this._camera.zoom:this.resolution.width}get halfDrawWidth(){return this.drawWidth/2}get drawHeight(){return this._camera?this.resolution.height/this._camera.zoom:this.resolution.height}get halfDrawHeight(){return this.drawHeight/2}get center(){return K(this.halfDrawWidth,this.halfDrawHeight)}_computeFit(){document.body.style.margin="0px",document.body.style.overflow="hidden";const t=this.aspectRatio;let e=0,i=0;window.innerWidth/t<window.innerHeight?(e=window.innerWidth,i=window.innerWidth/t):(e=window.innerHeight*t,i=window.innerHeight),this.viewport={width:e,height:i}}_computeFitContainer(){const t=this.aspectRatio;let e=0,i=0;const s=this.canvas.parentElement;s.clientWidth/t<s.clientHeight?(e=s.clientWidth,i=s.clientWidth/t):(e=s.clientHeight*t,i=s.clientHeight),this.viewport={width:e,height:i}}_applyDisplayMode(){this.displayMode===qe.Position?this._initializeDisplayModePosition(this._position):(this._setResolutionAndViewportByDisplayMode(this.parent),this.parent instanceof Window?this._browser.window.on("resize",this._resizeHandler):(this._resizeObserver=new ResizeObserver((()=>{this._resizeHandler()})),this._resizeObserver.observe(this.parent)),this.parent.addEventListener("resize",this._resizeHandler))}_setResolutionAndViewportByDisplayMode(t){this.displayMode===qe.FillContainer&&(this.resolution={width:t.clientWidth,height:t.clientHeight},this.viewport=this.resolution),this.displayMode===qe.FillScreen&&(document.body.style.margin="0px",document.body.style.overflow="hidden",this.resolution={width:t.innerWidth,height:t.innerHeight},this.viewport=this.resolution),this.displayMode===qe.FitScreen&&this._computeFit(),this.displayMode===qe.FitContainer&&this._computeFitContainer()}_initializeDisplayModePosition(t){if(!t)throw new Error("DisplayMode of Position was selected but no position option was given");if(this.canvas.style.display="block",this.canvas.style.position="absolute","string"==typeof t){const e=t.split(" ");switch(e[0]){case"top":this.canvas.style.top="0px";break;case"bottom":this.canvas.style.bottom="0px";break;case"middle":this.canvas.style.top="50%";const t=-this.halfDrawHeight;this.canvas.style.marginTop=t.toString();break;default:throw new Error("Invalid Position Given")}if(e[1])switch(e[1]){case"left":this.canvas.style.left="0px";break;case"right":this.canvas.style.right="0px";break;case"center":this.canvas.style.left="50%";const t=-this.halfDrawWidth;this.canvas.style.marginLeft=t.toString();break;default:throw new Error("Invalid Position Given")}}else t.top&&("number"==typeof t.top?this.canvas.style.top=t.top.toString()+"px":this.canvas.style.top=t.top),t.right&&("number"==typeof t.right?this.canvas.style.right=t.right.toString()+"px":this.canvas.style.right=t.right),t.bottom&&("number"==typeof t.bottom?this.canvas.style.bottom=t.bottom.toString()+"px":this.canvas.style.bottom=t.bottom),t.left&&("number"==typeof t.left?this.canvas.style.left=t.left.toString()+"px":this.canvas.style.left=t.left)}}class Ye{static create(){return this._INSTANCE||(window.AudioContext||window.webkitAudioContext)&&(this._INSTANCE=new AudioContext),this._INSTANCE}}Ye._INSTANCE=null;class Qe{static unlock(){return new Promise(((t,e)=>{if(Qe._UNLOCKED||!Ye.create())return t(!0);const i=setTimeout((()=>{_.getInstance().warn("Excalibur was unable to unlock the audio context, audio probably will not play in this browser."),t(!1)}),200),s=Ye.create();s.resume().then((()=>{const e=s.createBuffer(1,1,22050),n=s.createBufferSource();let r=!1;n.buffer=e,n.connect(s.destination),n.onended=()=>r=!0,n.start(0),setTimeout((()=>{!function(t){return!!t.playbackState}(n)?(s.currentTime>0||r)&&(Qe._UNLOCKED=!0):n.playbackState!==n.PLAYING_STATE&&n.playbackState!==n.FINISHED_STATE||(Qe._UNLOCKED=!0)}),0),clearTimeout(i),t(!0)}),(()=>{e()}))}))}static isUnlocked(){return this._UNLOCKED}}Qe._UNLOCKED=!1;class $e{constructor(){this.eventDispatcher=new le(this)}on(t,e){this.eventDispatcher.on(t,e)}off(t,e){this.eventDispatcher.off(t,e)}emit(t,e){this.eventDispatcher.emit(t,e)}once(t,e){this.eventDispatcher.once(t,e)}}function Je(t,e=Q.Red,i,s,n,r,o=1,a="butt"){t.beginPath(),t.lineWidth=o,t.lineCap=a,t.strokeStyle=e.toString(),t.moveTo(i,s),t.lineTo(n,r),t.closePath(),t.stroke()}function ti(t,e=Q.Red,i){t.beginPath(),t.strokeStyle=e.toString(),t.arc(i.x,i.y,5,0,2*Math.PI),t.closePath(),t.stroke()}function ei(t,e,i,s,n=1){const r=e?e.toString():"blue",o=s.scale(n);t.beginPath(),t.strokeStyle=r,t.moveTo(i.x,i.y),t.lineTo(i.x+o.x,i.y+o.y),t.closePath(),t.stroke()}function ii(t,e,i,s,n,r=5,o=Q.White,a=null){let h;if("number"==typeof r)h={tl:r,tr:r,br:r,bl:r};else{const t={tl:0,tr:0,br:0,bl:0};for(const e in t)if(t.hasOwnProperty(e)){const i=e;h[i]=r[i]||t[i]}}t.beginPath(),t.moveTo(e+h.tl,i),t.lineTo(e+s-h.tr,i),t.quadraticCurveTo(e+s,i,e+s,i+h.tr),t.lineTo(e+s,i+n-h.br),t.quadraticCurveTo(e+s,i+n,e+s-h.br,i+n),t.lineTo(e+h.bl,i+n),t.quadraticCurveTo(e,i+n,e,i+n-h.bl),t.lineTo(e,i+h.tl),t.quadraticCurveTo(e,i,e+h.tl,i),t.closePath(),a&&(t.fillStyle=a.toString(),t.fill()),o&&(t.strokeStyle=o.toString(),t.stroke())}function si(t,e,i,s,n=Q.White,r=null){t.beginPath(),t.arc(e,i,s,0,2*Math.PI),t.closePath(),r&&(t.fillStyle=r.toString(),t.fill()),n&&(t.strokeStyle=n.toString(),t.stroke())}var ni=i(1388),ri=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))};class oi extends $e{constructor(t){super(),this.canvas=new At({smoothing:!0,draw:this.draw.bind(this)}),this._resourceList=[],this._index=0,this._playButtonShown=!1,this._resourceCount=0,this._numLoaded=0,this._progressCounts={},this._totalCounts={},this.logo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdQAAAB2CAYAAABxhGI9AAAACXBIWXMAAAsSAAALEgHS3X78AAAKnUlEQVR42u3dP2wjSx0H8N8hJIonIRmJjsq0SBR+BQ1dcqKhe0lD77SvSwpKkJKGPulpktfRIMUdEqKIqV57rpAokM4dbSiyq7ONPTP7x39ifz7SFbnEnp3xer47O7uzH15fXwMA6OYHmgAABCoACFQAEKgAgEAFAIEKAAIVAAQqACBQAUCgAoBABQCBCgAIVAAQqAAgUAFAoAIAAhUABCoACFQAEKgAgECFLbmOiNeFf2PbAyz68Pr6qhUgbRwR92v+/zwiJrYHMEKFMmcN///UtgcQqFBk1PD/97U9Qx8VCFSgu4EmAIEKAAIVAAQqACBQ4Z25jojP8eX+0WtNAgIVaOY+Im5j+eKh24h41jQgUIEyZ7F5NaPU7wCBCiwYd/w9cOB+qAlgJ3KLLow0EV198803RWvJfvfddx+0lhEqHKu5JgAjVCBvlhmFzjQRXUekHz9+TP79y8uLRjNChXfvoePvAYEKxNtj1e42/O5JoIJABcrdRMRVLM+X3kTEpaaB988cKuzWg9EobTWdMx0Oly8uN4dqhAoARqgnaN3arHfqu7OyH8ItKLVB/P+CEfMTHyGPY3npx1m8zWGDEeoBfUk/xdti57dr/r1Wv2+6EPow3tZ5rRdS72s1neuF97xvWd+XTH0/V+UMttDWqbI/r2nrxfp+jv2uSjSO7S+OXy/A/3lN+9xX5T5HxEUPZZ0tfB71+w57eJ/HFu+z+jkv1u92YX9fbI/HhX3JA9rp5MPr66tWaG9UfUGbrHIzi7cLUyYFf/tpTady03EEeL8mUJ6i7MKYNvWNqr4Pe2jradXO60LrvPAz2PQ5RPX684ah8dxD+2zantnCgVipSVV+m/tgB9W2DDq2Sx/vM95wcHhZhWVJm8yrv58cSgfTdc70+++/X/r522+/tUKSEepBqo+om4ZLPerMjUwuNnQCtx1GWJtee1FwdD5uWd86xLs8UaVt2aNEO1/saZ/Z5rYMW4zq6v34rGV9Bg3q2eZ9SkeNm9qwyUh30OPIHYFKx5FG03C7znSOqYBq+qW/zpQ3anH037TNHluG6f0WPsPhHvab4QFty7ogOeuxDYcNy2/zu2214WNYWxmBurNO8bGn97pNBOO8xy/9uCorZZ4I2r4C7aJgO7ZV9iE49Dm6NvOWx+pWE9CUq3zbdTp9doz38TbXtzqH9RT5CyWe422OaZoZGeZCabrhPQY9HjwsjpTvCg4YtlE2+Ta/j2bzn8fqrDqgm+6yUHOmAvWUjAtGhbNYvsBknDnqH1Qhc7VmxHgeb/NbudA5j/UXlYwif2p6luhAc9teu1npiHKnDs8if6tCm7JLX3NKpgttXe9ruc9mHMd7a83iwdxF5vt8tutARaCeklRnNK9C8WnNF7geJQ4T4XG3JhSnVdilQrG+yOnrlVHfsEGYzhNBn7Lu6tS7+HJafJQ4EMiNlNqWXZ9WPvVgnVYHG5M1ByDXkT6leX2EgTqJtyt45yv7S2qO3sEZjZhDLXeR+YKdJ0Zdk8QocvH9N732KrNtq+FZ/zzIHABcJrYpd+Xv14lOd5ap76SgrduW/VTQ1qcQpqnbgu4ifZvUMNpd9XuoZmvCtPaQ2Y/BCHVLgbrJTeRPDdVf6pfMKDU2fOkHmVFFfXr3MsouLsnNvV5kRoe5+s431PeuoKPqWnaurY/ZPBEeqwceN4l96iwO6H7Mjq4y7VGPVNe10VaZMzVCPVWpI/Z6FZbcv5fMqGCU+dLfFGzj58jP8+bCdJCo7yzKTwdOF0bu9Ug7V4c+yz7FJfYeGoysUss0HssIdVZwYLDujMqlESoCdTtGsZtbHnJBeNdDSJSs0jTKdMJN1HNX54Wv7bvsU9NkVJVa13dX+/wuArV0X/l5RHyo/lnfF4G6p6DrS0kHdtXhy35TGErDPYZUn2WfWqDOo/lVqdMD2O/hKJhD7S/odukymq9s02QN4EEPR/zbaOumZc+r15zK1Zqznl9jsfiemTM1QmV3HUuTkedlg9HIQzRbUD93dfC+2tpj2fIHEH2+RqCCQH13gZq7hWXTNpVu19OB1fc9nQ0AKOKUb5lU0P1kDyOneoWk0lOZ9cIP0x7qu8+2BhCoR2wYu1+e7DmaXzBSsu5vaX1ne2zrpmUPTmxf7PM1Dm4y/vC7ny7Nif7+z/9ZmtM0Z3panPLtPmra9f16bcK0Dpbnwk43Vd/RHtu6zfNQTy1QBy3aqG2g9nVmxml+BOoJyT3NpWmn9xhfFnu4bvDa+44BXhqqfdf3uUF9+yz77AT31Yue2mjecYQ62NLfgkA9ghHqLNEhNem4H1c6vdyDxhf/bpz5m4coW/c39wi6VH2bPtHlcaV9cvXts+zxCe6rTeqc2ndL7uGd93QwM9bFcAzMoZZ7SgTBbWx+asui61h/iq1+RmjqdbnQXQ3T1DNQ63V/U9ucqm/pMzPb1rePsk/1iTOjgvatR4W3Lc8ULB78pELyrnAfeTcj1NU509/86mfJ33/8+Mf00a05UyPUEw7UVCeWG/WNEiExyHRMt5ltW30izUPk18ytt7lNfc8i//DvtvXto+ySA5BjljsLUF8lPkqMPEtW1JomDsiGBZ9Byb4NAvUITSN9GuwsIj6t6UTOqk7jJREkmzqli8xIs96udSO20sX0H1vW92IL9e1a9rgqVyf91gbPsTy9UD9n9lOkT8k+RfkFR5PMNqxOcdSf32PBvg3vilO+zdxE+okx9Wm0ph36XYsRZCpMF993GOk5qvqB3Dct6jvssb67KvuUNJ3frw92bhr8/STSF0JdRPMLpUCgnsgo9S76PZ246ZFk1wWvK5m3vVoYvW1Sz7nN91jfXbQ1ZQc7TW6HeaoOalypG/8/p/rP1aNAc6ZHzSnfdqPUPhdy2PQw6Nz9gSVhuhiqueUHR3uu7y7K3rdDX4u46ZrPbUa0IFBZ0seKQ3XQTRt2vm3W/a2DbNKys++rvm3ep6+y1x2UdP3bWU9lzra47U1GmlctX/sQ23t+aOlByLTh/4NAPaCRxtcdO5HLSJ/6vNtCwGx67VPmPbvWd1q9frKHtp4kAqRJ2HR9j762JfX3bZ//elPtj13PPDx1+D5tqk/Xi6NO8SHz7MmH19dXrdBNfVFP6T2PT1UHNit87/t4m5+aRH+nQBdvqyhZDKJLfZs8h7XPsqdV2ZOV+tanKB8aln0dyxdAXbV4j4gvt4oMOrbP6vbU73NW7TMlbdTnPrWpfqXfh9HKZ9vke7KuTeZRNtXRSe6+1FV//ce/ln5eXfsXgcqXzr6+9261M3moOoa7E6nvTZTfy7iNsmfb7kjfgXGsvxe0vihsEts9HTquPpt1q1vtahu2TqAiUAEEKj0zhwoARqgAu/OnX/442WH+9xc/Wvr58re/Tr7f41/+ZsRqhAoACFQAEKgAcHjMoQJskJsz/eqrr5Z+vvr7v5fmQFevAl5lztQIFQAQqAAgUAHgIJlDBdhgdQ41N2eKESoAIFABQKACwFEwhwoARqgAIFABQKACAAIVAAQqAAhUABCoAIBABQCBCgACFQAEKgAgUAFAoAKAQAUAgQoACFQAEKgAIFABQKACAAIVAAQqAAhUABCoAIBABQCBCgACFQAQqAAgUAFAoAKAQAUAlvwPcFDns1DsH4sAAAAASUVORK5CYII=",this.logoWidth=468,this.logoHeight=118,this.loadingBarColor=Q.White,this.backgroundColor="#176BAA",this.suppressPlayButton=!1,this._playButtonStyles=ni.Z.toString(),this.playButtonText="Play game",this.startButtonFactory=()=>{let t=document.getElementById("excalibur-play");return t||(t=document.createElement("button")),t.id="excalibur-play",t.textContent=this.playButtonText,t.style.display="none",t},t&&this.addResources(t)}get _image(){return this._imageElement||(this._imageElement=new Image,this._imageElement.src=this.logo),this._imageElement}get playButtonRootElement(){return this._playButtonRootElement}get playButtonElement(){return this._playButtonElement}get _playButton(){const t=document.getElementById("excalibur-play-root");return t&&(this._playButtonRootElement=t),this._playButtonRootElement||(this._playButtonRootElement=document.createElement("div"),this._playButtonRootElement.id="excalibur-play-root",this._playButtonRootElement.style.position="absolute",document.body.appendChild(this._playButtonRootElement)),this._styleBlock||(this._styleBlock=document.createElement("style"),this._styleBlock.textContent=this._playButtonStyles,document.head.appendChild(this._styleBlock)),this._playButtonElement||(this._playButtonElement=this.startButtonFactory(),this._playButtonRootElement.appendChild(this._playButtonElement)),this._playButtonElement}wireEngine(t){this._engine=t,this.canvas.width=this._engine.canvas.width,this.canvas.height=this._engine.canvas.height}addResource(t){const e=this._index++;this._resourceList.push(t),this._progressCounts[e]=0,this._totalCounts[e]=1,this._resourceCount++}addResources(t){let e=0;const i=t.length;for(;e<i;e++)this.addResource(t[e])}isLoaded(){return this._numLoaded===this._resourceCount}showPlayButton(){var t;if(this.suppressPlayButton)return this.hidePlayButton(),Promise.resolve();{const e=()=>{this._positionPlayButton()};(null===(t=this._engine)||void 0===t?void 0:t.browser)&&this._engine.browser.window.on("resize",e),this._playButtonShown=!0,this._playButton.style.display="block",document.body.addEventListener("keyup",(t=>{"Enter"===t.key&&this._playButton.click()}));const i=new Promise((t=>{const i=i=>{var s;i.stopPropagation(),this.hidePlayButton(),(null===(s=this._engine)||void 0===s?void 0:s.browser)&&this._engine.browser.window.off("resize",e),t()};this._playButton.addEventListener("click",i),this._playButton.addEventListener("touchend",i),this._playButton.addEventListener("pointerup",i)}));return i}}hidePlayButton(){this._playButtonShown=!1,this._playButton.style.display="none"}dispose(){this._playButtonRootElement.parentElement&&(this._playButtonRootElement.removeChild(this._playButtonElement),document.body.removeChild(this._playButtonRootElement),document.head.removeChild(this._styleBlock),this._playButtonRootElement=null,this._playButtonElement=null,this._styleBlock=null)}update(t,e){}load(){return ri(this,void 0,void 0,(function*(){return yield Promise.all(this._resourceList.map((t=>t.load().finally((()=>{this._numLoaded++}))))),yield H(200),yield this.showPlayButton(),yield Qe.unlock(),this.data=this._resourceList}))}markResourceComplete(){this._numLoaded++}get progress(){return this._resourceCount>0?S(this._numLoaded,0,this._resourceCount)/this._resourceCount:1}_positionPlayButton(){const t=this._engine.screen.viewport.height,e=this._engine.screen.viewport.width;if(this._playButtonRootElement){const i=this._engine.canvas.offsetLeft,s=this._engine.canvas.offsetTop,n=this._playButton.clientWidth,r=this._playButton.clientHeight;this.playButtonPosition?(this._playButtonRootElement.style.left=`${this.playButtonPosition.x}px`,this._playButtonRootElement.style.top=`${this.playButtonPosition.y}px`):(this._playButtonRootElement.style.left=i+e/2-n/2+"px",this._playButtonRootElement.style.top=s+t/2-r/2+100+"px")}}draw(t){const e=this._engine.canvasHeight/this._engine.pixelRatio,i=this._engine.canvasWidth/this._engine.pixelRatio;this._positionPlayButton(),t.fillStyle=this.backgroundColor,t.fillRect(0,0,i,e);let s=e/2;const n=Math.min(this.logoWidth,.75*i);let r=i/2-n/2;this.logoPosition&&(r=this.logoPosition.x,s=this.logoPosition.y);const o=Math.floor(n*(this.logoHeight/this.logoWidth)),a=this._engine.getAntialiasing();if(this._engine.setAntialiasing(!0),this.logoPosition?t.drawImage(this._image,0,0,this.logoWidth,this.logoHeight,r,s,n,o):t.drawImage(this._image,0,0,this.logoWidth,this.logoHeight,r,s-o-20,n,o),!this.suppressPlayButton&&this._playButtonShown)return void this._engine.setAntialiasing(a);let h=r,l=s;this.loadingBarPosition&&(h=this.loadingBarPosition.x,l=this.loadingBarPosition.y),t.lineWidth=2,ii(t,h,l,n,20,10,this.loadingBarColor);const c=n*this.progress-10;ii(t,h+5,l+5,c>10?c:10,10,5,null,this.loadingBarColor),this._engine.setAntialiasing(a)}}const ai={webgl:"WebGL",webaudio:"WebAudio",gamepadapi:"Gamepad API"};class hi{constructor(){this._features=null,this.failedTests=[],this._criticalTests={canvasSupport:function(){const t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))},arrayBufferSupport:function(){const t=new XMLHttpRequest;t.open("GET","/");try{t.responseType="arraybuffer"}catch(t){return!1}return"arraybuffer"===t.responseType},dataUrlSupport:function(){return 0===document.createElement("canvas").toDataURL("image/png").indexOf("data:image/png")},objectUrlSupport:function(){return"URL"in window&&"revokeObjectURL"in URL&&"createObjectURL"in URL},rgbaSupport:function(){const t=document.createElement("a").style;return t.cssText="background-color:rgba(150,255,150,.5)",(""+t.backgroundColor).indexOf("rgba")>-1}},this._warningTest={webAudioSupport:function(){return!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext)},webglSupport:function(){const t=document.createElement("canvas");return!(!t.getContext||!t.getContext("webgl"))}},this._features=this._loadBrowserFeatures()}getBrowserFeatures(){return null===this._features&&(this._features=this._loadBrowserFeatures()),this._features}logBrowserFeatures(){let t="%cSUPPORTED BROWSER FEATURES\n==========================%c\n";const e=["font-weight: bold; color: navy","font-weight: normal; color: inherit"],i=this.getBrowserFeatures();for(const s of Object.keys(ai))i[s]?(t+="(%c✓%c)",e.push("font-weight: bold; color: green"),e.push("font-weight: normal; color: inherit")):(t+="(%c✗%c)",e.push("font-weight: bold; color: red"),e.push("font-weight: normal; color: inherit")),t+=" "+ai[s]+"\n";e.unshift(t),console.log.apply(console,e)}_loadBrowserFeatures(){return{canvas:(()=>this._criticalTests.canvasSupport())(),arraybuffer:(()=>this._criticalTests.arrayBufferSupport())(),dataurl:(()=>this._criticalTests.dataUrlSupport())(),objecturl:(()=>this._criticalTests.objectUrlSupport())(),rgba:(()=>this._criticalTests.rgbaSupport())(),webaudio:(()=>this._warningTest.webAudioSupport())(),webgl:(()=>this._warningTest.webglSupport())(),gamepadapi:!!navigator.getGamepads}}test(){let t=!1;for(const e in this._criticalTests)this._criticalTests[e].call(this)||(this.failedTests.push(e),_.getInstance().error("Critical browser feature missing, Excalibur requires:",e),t=!0);if(t)return!1;for(const t in this._warningTest)this._warningTest[t]()||_.getInstance().warn("Warning browser feature missing, Excalibur will have reduced performance:",t);return!0}}var li;!function(t){t.PreventCollision="PreventCollision",t.Passive="Passive",t.Active="Active",t.Fixed="Fixed"}(li||(li={}));var ci,di,ui,pi=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};!function(t){t.Arcade="arcade",t.Realistic="realistic"}(ci||(ci={})),function(t){t[t.DynamicAABBTree=0]="DynamicAABBTree"}(di||(di={})),function(t){t[t.Euler=0]="Euler"}(ui||(ui={}));class gi{static get gravity(){return gi.acc}static set gravity(t){gi.acc=t}static useArcadePhysics(){gi.collisionResolutionStrategy=ci.Arcade}static useRealisticPhysics(){gi.collisionResolutionStrategy=ci.Realistic}static get dynamicTreeVelocityMultiplyer(){return gi.dynamicTreeVelocityMultiplier}static set dynamicTreeVelocityMultiplyer(t){gi.dynamicTreeVelocityMultiplier=t}}gi.acc=new q(0,0),gi.enabled=!0,gi.broadphaseStrategy=di.DynamicAABBTree,gi.collisionResolutionStrategy=ci.Arcade,gi.defaultMass=10,gi.integrator=ui.Euler,gi.dynamicTreeVelocityMultiplier=2,gi.boundsPadding=5,gi.positionIterations=3,gi.velocityIterations=8,gi.slop=1,gi.steeringFactor=.2,gi.warmStart=!0,gi.bodiesCanSleepByDefault=!1,gi.surfaceEpsilon=.1,gi.sleepEpsilon=.07,gi.wakeThreshold=3*gi.sleepEpsilon,gi.sleepBias=.9,gi.checkForFastBodies=!0,gi.disableMinimumSpeedForFastBody=!1,pi([j({message:"Alias for incorrect spelling used in older versions, will be removed in v0.25.0",alternateMethod:"dynamicTreeVelocityMultiplier"})],gi,"dynamicTreeVelocityMultiplyer",null);class _i extends q{constructor(t){super(0,0),this._getX=t.getX,this._getY=t.getY,this._setX=t.setX,this._setY=t.setY}get x(){return this._x=this._getX()}set x(t){this._setX(t),this._x=t}get y(){return this._y=this._getY()}set y(t){this._setY(t),this._y=t}}class fi{constructor(){this.owner=null}clone(){const t=new this.constructor;for(const i in this)if(this.hasOwnProperty(i)){const s=this[i];(null==(e=s)?void 0:e.clone)&&"owner"!==i&&"clone"!==i?t[i]=s.clone():t[i]=s}var e;return t}}class mi extends fi{constructor(t,e){super(),this.type=t,this.value=e}}var yi;!function(t){t.World="world",t.Screen="screen"}(yi||(yi={}));class wi extends fi{constructor(){super(...arguments),this.type="ex.transform",this._dirty=!1,this.matrix=et.identity().translate(0,0).rotate(0).scale(1,1),this._position=(t=>{const e=t;return new _i({setX:t=>{e.data[Z.X]=t},setY:t=>{e.data[Z.Y]=t},getX:()=>e.data[Z.X],getY:()=>e.data[Z.Y]})})(this.matrix),this._rotation=0,this._scale=(t=>{const e=t;return new _i({setX:t=>{e.setScaleX(t)},setY:t=>{e.setScaleY(t)},getX:()=>e.getScaleX(),getY:()=>e.getScaleY()})})(this.matrix),this.coordPlane=yi.World,this.z=0}_recalculate(){this._rotation=this.matrix.getRotation(),this._dirty=!1}getGlobalMatrix(){return this.parent?this.parent.getGlobalMatrix().multm(this.matrix):this.matrix}getGlobalTransform(){return{pos:this.globalPos,scale:this.globalScale,rotation:this.globalRotation,z:this.z,coordPlane:this.coordPlane}}get parent(){var t,e;return null===(e=null===(t=null==this?void 0:this.owner)||void 0===t?void 0:t.parent)||void 0===e?void 0:e.get(wi)}get pos(){return this._dirty&&this._recalculate(),this._position}set pos(t){this.matrix.setPosition(t.x,t.y),this._dirty=!0}get dirty(){var t;if(null===(t=null==this?void 0:this.owner)||void 0===t?void 0:t.parent){return this.parent.dirty||this._dirty}return this._dirty}get globalPos(){const t=this.getGlobalMatrix();return new _i({getX:()=>t.data[Z.X],getY:()=>t.data[Z.Y],setX:e=>{var i;if(this.parent){const[s]=null===(i=this.parent)||void 0===i?void 0:i.getGlobalMatrix().getAffineInverse().multv([e,t.data[Z.Y]]);this.matrix.data[Z.X]=s}else this.matrix.data[Z.X]=e},setY:e=>{var i;if(this.parent){const[,s]=null===(i=this.parent)||void 0===i?void 0:i.getGlobalMatrix().getAffineInverse().multv([t.data[Z.X],e]);this.matrix.data[Z.Y]=s}else this.matrix.data[Z.Y]=e}})}set globalPos(t){const e=this.parent;this.pos=e?e.getGlobalMatrix().getAffineInverse().multv(t):t}get rotation(){return this._dirty&&this._recalculate(),this._rotation}set rotation(t){this.matrix.setRotation(t),this._dirty=!0}get globalRotation(){return this.getGlobalMatrix().getRotation()}set globalRotation(t){const e=this.parent;this.rotation=e?t-e.globalRotation:t}get scale(){return this._dirty&&this._recalculate(),this._scale}set scale(t){this.matrix.setScale(t),this._dirty=!0}get globalScale(){const t=this.getGlobalMatrix();return new _i({getX:()=>t.getScaleX(),getY:()=>t.getScaleY(),setX:t=>{if(this.parent){const e=this.parent.globalScale.x;this.matrix.setScaleX(t/e)}else this.matrix.setScaleX(t)},setY:t=>{if(this.parent){const e=this.parent.globalScale.y;this.matrix.setScaleY(t/e)}else this.matrix.setScaleY(t)}})}set globalScale(t){const e=this.parent;this.scale=e?K(t.x/e.globalScale.x,t.y/e.globalScale.y):t}apply(t){return this.matrix.multv(t)}applyInverse(t){return this.matrix.getAffineInverse().multv(t)}}class vi extends fi{constructor(){super(...arguments),this.type="ex.motion",this.vel=q.Zero,this.acc=q.Zero,this.scaleFactor=q.Zero,this.angularVelocity=0,this.torque=0,this.inertia=1}}class xi{constructor(t,e,i){this._name=t,this._category=e,this._mask=i}get name(){return this._name}get category(){return this._category}get mask(){return this._mask}canCollide(t){return 0!=(this.category&t.mask)&&0!=(t.category&this.mask)}invert(){return new xi("~("+this.name+")",~this.category,~this.mask)}static combine(t){const e=t.map((t=>t.name)).join("+"),i=t.reduce(((t,e)=>e.category|t),0);return new xi(e,i,~i)}static collidesWith(t){return xi.combine(t).invert()}}xi.All=new xi("Collide with all groups",-1,-1);class bi{constructor(){this.observers=[],this.subscriptions=[]}register(t){this.observers.push(t)}subscribe(t){this.subscriptions.push(t)}unregister(t){const e=this.observers.indexOf(t);-1!==e&&this.observers.splice(e,1)}unsubscribe(t){const e=this.subscriptions.indexOf(t);-1!==e&&this.subscriptions.splice(e,1)}notifyAll(t){this.observers.forEach((e=>e.notify(t))),this.subscriptions.forEach((e=>e(t)))}clear(){this.observers.length=0,this.subscriptions.length=0}}class Ci{constructor(t,e){this.colliderA=t,this.colliderB=e,this.id=null,this.id=Ci.calculatePairHash(t.id,e.id)}static canCollide(t,e){var i,s;const n=null===(i=null==t?void 0:t.owner)||void 0===i?void 0:i.get(Vi),r=null===(s=null==e?void 0:e.owner)||void 0===s?void 0:s.get(Vi);return!(!n||!r)&&(!!n.group.canCollide(r.group)&&((n.collisionType!==li.Fixed||r.collisionType!==li.Fixed)&&(r.collisionType!==li.PreventCollision&&n.collisionType!==li.PreventCollision&&!(!n.active||!r.active))))}get canCollide(){const t=this.colliderA,e=this.colliderB;return Ci.canCollide(t,e)}collide(){return this.colliderA.collide(this.colliderB)}hasCollider(t){return t===this.colliderA||t===this.colliderB}static calculatePairHash(t,e){return t.value<e.value?`#${t.value}+${e.value}`:`#${e.value}+${t.value}`}}class Ai{constructor(t,e){this.min=t,this.max=e}overlaps(t){return this.max>t.min&&t.max>this.min}getOverlap(t){return this.overlaps(t)?this.max>t.max?t.max-this.min:this.max-t.min:0}}class Si{constructor(t){this.parent=t,this.parent=t||null,this.data=null,this.bounds=new J,this.left=null,this.right=null,this.height=0}isLeaf(){return!this.left&&!this.right}}class Pi{constructor(t=new J(-Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)){this.worldBounds=t,this.root=null,this.nodes={}}_insert(t){if(null===this.root)return this.root=t,void(this.root.parent=null);const e=t.bounds;let i=this.root;for(;!i.isLeaf();){const t=i.left,s=i.right,n=i.bounds.getPerimeter(),r=i.bounds.combine(e).getPerimeter(),o=2*r,a=2*(r-n);let h=0;const l=e.combine(t.bounds);let c,d;t.isLeaf()?h=l.getPerimeter()+a:(d=t.bounds.getPerimeter(),c=l.getPerimeter(),h=c-d+a);let u=0;const p=e.combine(s.bounds);if(s.isLeaf()?u=p.getPerimeter()+a:(d=s.bounds.getPerimeter(),c=p.getPerimeter(),u=c-d+a),o<h&&o<u)break;i=h<u?t:s}const s=i.parent,n=new Si(s);n.bounds=e.combine(i.bounds),n.height=i.height+1,null!==s?(s.left===i?s.left=n:s.right=n,n.left=i,n.right=t,i.parent=n,t.parent=n):(n.left=i,n.right=t,i.parent=n,t.parent=n,this.root=n);let r=t.parent;for(;r;){if(r=this._balance(r),!r.left)throw new Error("Parent of current leaf cannot have a null left child"+r);if(!r.right)throw new Error("Parent of current leaf cannot have a null right child"+r);r.height=1+Math.max(r.left.height,r.right.height),r.bounds=r.left.bounds.combine(r.right.bounds),r=r.parent}}_remove(t){if(t===this.root)return void(this.root=null);const e=t.parent,i=e.parent;let s;if(s=e.left===t?e.right:e.left,i){i.left===e?i.left=s:i.right=s,s.parent=i;let t=i;for(;t;)t=this._balance(t),t.bounds=t.left.bounds.combine(t.right.bounds),t.height=1+Math.max(t.left.height,t.right.height),t=t.parent}else this.root=s,s.parent=null}trackCollider(t){const e=new Si;e.data=t,e.bounds=t.bounds,e.bounds.left-=2,e.bounds.top-=2,e.bounds.right+=2,e.bounds.bottom+=2,this.nodes[t.id.value]=e,this._insert(e)}updateCollider(t){var e;const i=this.nodes[t.id.value];if(!i)return!1;const s=t.bounds;if(!this.worldBounds.contains(s))return _.getInstance().warn("Collider with id "+t.id.value+" is outside the world bounds and will no longer be tracked for physics"),this.untrackCollider(t),!1;if(i.bounds.contains(s))return!1;if(this._remove(i),s.left-=gi.boundsPadding,s.top-=gi.boundsPadding,s.right+=gi.boundsPadding,s.bottom+=gi.boundsPadding,t.owner){const i=null===(e=t.owner)||void 0===e?void 0:e.get(Vi);if(i){const t=32*i.vel.x/1e3*gi.dynamicTreeVelocityMultiplier,e=32*i.vel.y/1e3*gi.dynamicTreeVelocityMultiplier;t<0?s.left+=t:s.right+=t,e<0?s.top+=e:s.bottom+=e}}return i.bounds=s,this._insert(i),!0}untrackCollider(t){const e=this.nodes[t.id.value];e&&(this._remove(e),this.nodes[t.id.value]=null,delete this.nodes[t.id.value])}_balance(t){if(null===t)throw new Error("Cannot balance at null node");if(t.isLeaf()||t.height<2)return t;const e=t.left,i=t.right,s=t,n=e,r=i,o=e.left,a=e.right,h=i.left,l=i.right,c=r.height-n.height;if(c>1)return r.left=s,r.parent=s.parent,s.parent=r,r.parent?r.parent.left===s?r.parent.left=r:r.parent.right=r:this.root=r,h.height>l.height?(r.right=h,s.right=l,l.parent=s,s.bounds=n.bounds.combine(l.bounds),r.bounds=s.bounds.combine(h.bounds),s.height=1+Math.max(n.height,l.height),r.height=1+Math.max(s.height,h.height)):(r.right=l,s.right=h,h.parent=s,s.bounds=n.bounds.combine(h.bounds),r.bounds=s.bounds.combine(l.bounds),s.height=1+Math.max(n.height,h.height),r.height=1+Math.max(s.height,l.height)),r;if(c<-1){if(n.left=s,n.parent=s.parent,s.parent=n,n.parent)if(n.parent.left===s)n.parent.left=n;else{if(n.parent.right!==s)throw"Error rotating Dynamic Tree";n.parent.right=n}else this.root=n;return o.height>a.height?(n.right=o,s.left=a,a.parent=s,s.bounds=r.bounds.combine(a.bounds),n.bounds=s.bounds.combine(o.bounds),s.height=1+Math.max(r.height,a.height),n.height=1+Math.max(s.height,o.height)):(n.right=a,s.left=o,o.parent=s,s.bounds=r.bounds.combine(o.bounds),n.bounds=s.bounds.combine(a.bounds),s.height=1+Math.max(r.height,o.height),n.height=1+Math.max(s.height,a.height)),n}return t}getHeight(){return null===this.root?0:this.root.height}query(t,e){const i=t.bounds,s=n=>{if(n&&n.bounds.intersect(i)){if(!n.isLeaf()||n.data===t)return s(n.left)||s(n.right);if(e.call(t,n.data))return!0}return!1};s(this.root)}rayCastQuery(t,e=1/0,i){const s=n=>{if(n&&n.bounds.rayCast(t,e)){if(!n.isLeaf())return s(n.left)||s(n.right);if(i.call(t,n.data))return!0}return!1};s(this.root)}getNodes(){const t=e=>e?[e].concat(t(e.left),t(e.right)):[];return t(this.root)}debug(t){const e=i=>{i&&(i.isLeaf()?i.bounds.draw(t,Q.Green):i.bounds.draw(t,Q.White),i.left&&e(i.left),i.right&&e(i.right))};e(this.root)}}class Ei{constructor(t,e){this.pos=t,this.dir=e.normalize()}intersect(t){const e=t.begin.sub(this.pos);if(0===this.dir.cross(t.getSlope())&&0!==e.cross(this.dir))return-1;const i=this.dir.cross(t.getSlope());if(0===i)return-1;const s=e.cross(t.getSlope())/i;if(s>=0){const n=e.cross(this.dir)/i/t.getLength();if(n>=0&&n<=1)return s}return-1}intersectPoint(t){const e=this.intersect(t);return e<0?null:this.getPoint(e)}getPoint(t){return this.pos.add(this.dir.scale(t))}}class Ti{constructor(){this._dynamicCollisionTree=new Pi,this._collisions=new Set,this._collisionPairCache=[],this._colliders=[]}getColliders(){return this._colliders}track(t){if(t)if(t instanceof Di){const e=t.getColliders();for(const i of e)i.owner=t.owner,this._colliders.push(i),this._dynamicCollisionTree.trackCollider(i)}else this._colliders.push(t),this._dynamicCollisionTree.trackCollider(t);else _.getInstance().warn("Cannot track null collider")}untrack(t){if(t)if(t instanceof Di){const e=t.getColliders();for(const t of e){const e=this._colliders.indexOf(t);-1!==e&&this._colliders.splice(e,1),this._dynamicCollisionTree.untrackCollider(t)}}else{const e=this._colliders.indexOf(t);-1!==e&&this._colliders.splice(e,1),this._dynamicCollisionTree.untrackCollider(t)}else _.getInstance().warn("Cannot untrack a null collider")}_shouldGenerateCollisionPair(t,e){if(null!==t.id&&null!==e.id&&t.id===e.id||null!==t.owner&&null!==e.owner&&t.owner===e.owner)return!1;const i=Ci.calculatePairHash(t.id,e.id);return!this._collisions.has(i)&&(!t.localBounds.hasZeroDimensions()&&!e.localBounds.hasZeroDimensions()&&Ci.canCollide(t,e))}broadphase(t,e,i){const s=e/1e3,n=t.filter((t=>{var e,i;const s=null===(e=t.owner)||void 0===e?void 0:e.get(Vi);return(null===(i=t.owner)||void 0===i?void 0:i.active)&&s.collisionType!==li.PreventCollision}));let r;this._collisionPairCache=[],this._collisions.clear();for(let t=0,e=n.length;t<e;t++)r=n[t],this._dynamicCollisionTree.query(r,(t=>{if(this._shouldGenerateCollisionPair(r,t)){const e=new Ci(r,t);this._collisions.add(e.id),this._collisionPairCache.push(e)}return!1}));if(i&&(i.physics.pairs=this._collisionPairCache.length),gi.checkForFastBodies)for(const t of n){const e=t.owner.get(Vi);if(e.collisionType!==li.Active)continue;const n=e.vel.size*s+.5*e.acc.size*s*s,r=Math.min(t.bounds.height,t.bounds.width);if(gi.disableMinimumSpeedForFastBody||n>r/2){i&&i.physics.fastBodies++;const s=e.pos.sub(e.oldPos),r=t.center,o=t.getFurthestPoint(e.vel),a=o.sub(s),h=new Ei(a,e.vel);let l;h.pos=h.pos.add(h.dir.scale(-2*gi.surfaceEpsilon));let c=new q(1/0,1/0);if(this._dynamicCollisionTree.rayCastQuery(h,n+2*gi.surfaceEpsilon,(e=>{if(t!==e&&Ci.canCollide(t,e)){const t=e.rayCast(h,n+10*gi.surfaceEpsilon);if(t){const i=t.sub(a);i.size<c.size&&(c=i,l=e)}}return!1})),l&&q.isValid(c)){const s=new Ci(t,l);this._collisions.has(s.id)||(this._collisions.add(s.id),this._collisionPairCache.push(s));const n=r.sub(o);e.pos=a.add(n).add(c).add(h.dir.scale(10*gi.surfaceEpsilon)),t.update(e.transform),i&&i.physics.fastBodyCollisions++}}}return this._collisionPairCache}narrowphase(t,e){let i=[];for(let s=0;s<t.length;s++){const n=t[s].collide();if(i=i.concat(n),e&&n.length>0)for(const t of n)e.physics.contacts.set(t.id,t)}return e&&(e.physics.collisions+=i.length),i}update(t){let e=0;const i=t.length;for(let s=0;s<i;s++)this._dynamicCollisionTree.updateCollider(t[s])&&e++;return e}debug(t){this._dynamicCollisionTree.debug(t)}}class Ri{constructor(){this.id=g("collider",Ri._ID++),this.events=new le(this)}touching(t){return!!this.collide(t)}}Ri._ID=0;class Di extends Ri{constructor(t){super(),this._collisionProcessor=new Ti,this._dynamicAABBTree=new Pi,this._colliders=[];for(const e of t)this.addCollider(e)}clearColliders(){this._colliders=[]}addCollider(t){this.events.wire(t.events),this._colliders.push(t),this._collisionProcessor.track(t),this._dynamicAABBTree.trackCollider(t)}removeCollider(t){this.events.unwire(t.events),k(t,this._colliders),this._collisionProcessor.untrack(t),this._dynamicAABBTree.untrackCollider(t)}getColliders(){return this._colliders}get worldPos(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:q.Zero}get center(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:q.Zero}get bounds(){var t,e;const i=this.getColliders();return i.reduce(((t,e)=>t.combine(e.bounds)),null!==(e=null===(t=i[0])||void 0===t?void 0:t.bounds)&&void 0!==e?e:(new J).translate(this.worldPos))}get localBounds(){var t,e;const i=this.getColliders();return i.reduce(((t,e)=>t.combine(e.localBounds)),null!==(e=null===(t=i[0])||void 0===t?void 0:t.localBounds)&&void 0!==e?e:new J)}get axes(){const t=this.getColliders();let e=[];for(const i of t)e=e.concat(i.axes);return e}getFurthestPoint(t){const e=this.getColliders(),i=[];for(const s of e)i.push(s.getFurthestPoint(t));let s=i[0],n=-Number.MAX_VALUE;for(const e of i){const i=e.dot(t);i>n&&(s=e,n=i)}return s}getInertia(t){const e=this.getColliders();let i=0;for(const s of e)i+=s.getInertia(t);return i}collide(t){let e=[t];t instanceof Di&&(e=t.getColliders());const i=[];for(const t of e)this._dynamicAABBTree.query(t,(e=>(i.push(new Ci(t,e)),!1)));let s=[];for(const t of i)s=s.concat(t.collide());return s}getClosestLineBetween(t){const e=this.getColliders(),i=[];if(t instanceof Di){const s=t.getColliders();for(const t of e)for(const e of s){const s=t.getClosestLineBetween(e);s&&i.push(s)}}else for(const s of e){const e=t.getClosestLineBetween(s);e&&i.push(e)}if(i.length){let t=i[0].getLength(),e=i[0];for(const s of i){const i=s.getLength();i<t&&(t=i,e=s)}return e}return null}contains(t){const e=this.getColliders();for(const i of e)if(i.contains(t))return!0;return!1}rayCast(t,e){const i=this.getColliders(),s=[];for(const n of i){const i=n.rayCast(t,e);i&&s.push(i)}if(s.length){let e=s[0],i=e.dot(t.dir);for(const n of s){const s=t.dir.dot(n);s<i&&(e=n,i=s)}return e}return null}project(t){const e=this.getColliders(),i=[];for(const s of e){const e=s.project(t);e&&i.push(e)}if(i.length){const t=new Ai(i[0].min,i[0].max);for(const e of i)t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max);return t}return null}update(t){if(t){const e=this.getColliders();for(const i of e)i.owner=this.owner,i.update(t)}}draw(t,e,i){const s=this.getColliders();for(const n of s)n.draw(t,e,i)}debug(t,e){const i=this.getColliders();for(const s of i)s.debug(t,e)}debugDraw(t,e){const i=this.getColliders();for(const s of i)s.draw(t,e)}clone(){return new Di(this._colliders.map((t=>t.clone())))}}class Bi{constructor(t,e){this.begin=t,this.end=e}get slope(){return(this.end.y-this.begin.y)/(this.end.x-this.begin.x)}get intercept(){return this.begin.y-this.slope*this.begin.x}normal(){return this.end.sub(this.begin).normal()}dir(){return this.end.sub(this.begin)}getPoints(){return[this.begin,this.end]}getSlope(){const t=this.begin,e=this.end,i=t.distance(e);return e.sub(t).scale(1/i)}getEdge(){const t=this.begin;return this.end.sub(t)}getLength(){const t=this.begin,e=this.end;return t.distance(e)}get midpoint(){return this.begin.add(this.end).scale(.5)}flip(){return new Bi(this.end,this.begin)}below(t){return(this.end.x-this.begin.x)*(t.y-this.begin.y)-(this.end.y-this.begin.y)*(t.x-this.begin.x)>=0}clip(t,e){let i=t;i=i.normalize();const s=i.dot(this.begin)-e,n=i.dot(this.end)-e,r=[];if(s<=0&&r.push(this.begin),n<=0&&r.push(this.end),s*n<0){const t=s/(s-n);r.push(this.begin.add(this.end.sub(this.begin).scale(t)))}return 2!==r.length?null:new Bi(r[0],r[1])}distanceToPoint(t,e=!1){const i=t.x,s=t.y,n=this.getLength(),r=((this.end.y-this.begin.y)*i-(this.end.x-this.begin.x)*s+this.end.x*this.begin.y-this.end.y*this.begin.x)/n;return e?r:Math.abs(r)}findVectorToPoint(t){const e=this.begin.sub(t),i=this.getSlope();return e.sub(i.scale(e.dot(i)))}findPoint(t=null,e=null){const i=this.slope,s=this.intercept;if(null!==t)return new q(t,i*t+s);if(null!==e)return new q((e-s)/i,e);throw new Error("You must provide an X or a Y value")}hasPoint(){let t,e=0;if("number"==typeof arguments[0]&&"number"==typeof arguments[1])t=new q(arguments[0],arguments[1]),e=arguments[2]||0;else{if(!(arguments[0]instanceof q))throw"Could not determine the arguments for Vector.hasPoint";t=arguments[0],e=arguments[1]||0}const i=t.x-this.begin.x,s=t.y-this.begin.y,n=this.end.x-this.begin.x,r=this.end.y-this.begin.y,o=i*r-s*n;return!(Math.abs(o)>e)&&(Math.abs(n)>=Math.abs(r)?n>0?this.begin.x<=t.x&&t.x<=this.end.x:this.end.x<=t.x&&t.x<=this.begin.x:r>0?this.begin.y<=t.y&&t.y<=this.end.y:this.end.y<=t.y&&t.y<=this.begin.y)}}function Mi(t,e,i,s){const n=t.sub(i),r=e.dot(e),o=e.dot(s),a=s.dot(s),h=e.dot(n),l=s.dot(n),c=r*a-o*o;let d=c,u=c;if(0===c||c<=.01){const e=h/o;return new Bi(t,i.add(s.scale(e)))}let p=o*l-a*h,g=r*l-o*h;return p<0?(p=0,g=l,u=a):p>d&&(p=d,g=l+o,u=a),g<0?(g=0,-h<0?p=0:-h>r?p=d:(p=-h,d=r)):g>u&&(g=u,-h+o<0?p=0:-h+o>r?p=d:(p=-h+o,d=r)),p=Math.abs(p)<.001?0:p/d,g=Math.abs(g)<.001?0:g/u,new Bi(t.add(e.scale(p)),i.add(s.scale(g)))}const ki={PolygonPolygonClosestLine(t,e){const i=e.worldPos,s=i.sub(t.worldPos),n=s.negate(),r=new Ei(t.worldPos,s),o=new Ei(i,n),a=t.rayCast(r).add(r.dir.scale(.1)),h=e.rayCast(o).add(o.dir.scale(.1)),l=t.getClosestFace(a),c=e.getClosestFace(h);return Mi(l.face.begin,l.face.getEdge(),c.face.begin,c.face.getEdge())},PolygonEdgeClosestLine(t,e){const i=e.worldPos.sub(t.worldPos),s=new Ei(t.worldPos,i),n=t.rayCast(s).add(s.dir.scale(.1)),r=t.getClosestFace(n),o=r.face.begin,a=r.face.getEdge(),h=e.asLine();return Mi(o,a,h.begin,h.getEdge())},PolygonCircleClosestLine(t,e){const i=e.worldPos,s=i.sub(t.worldPos),n=new Ei(t.worldPos,s.normalize()),r=t.rayCast(n).add(n.dir.scale(.1)),o=t.getClosestFace(r),a=o.face.begin,h=o.face.getEdge();let l=(h.x*(i.x-a.x)+h.y*(i.y-a.y))/(h.x*h.x+h.y*h.y);l>1?l=1:l<0&&(l=0);const c=Math.sqrt(Math.pow(a.x+h.x*l-i.x,2)+Math.pow(a.y+h.y*l-i.y,2))-e.radius,d=(a.x+h.x*l-i.x)*e.radius/(e.radius+c),u=(a.y+h.y*l-i.y)*e.radius/(e.radius+c);return new Bi(h.scale(l).add(a),new q(i.x+d,i.y+u))},CircleCircleClosestLine(t,e){const i=e.worldPos.sub(t.worldPos),s=t.worldPos.sub(e.worldPos),n=new Ei(t.worldPos,i),r=new Ei(e.worldPos,s),o=t.rayCast(n),a=e.rayCast(r);return new Bi(o,a)},CircleEdgeClosestLine(t,e){const i=t.worldPos,s=e.asLine(),n=s.begin,r=s.getEdge();let o=(r.x*(i.x-n.x)+r.y*(i.y-n.y))/(r.x*r.x+r.y*r.y);o>1?o=1:o<0&&(o=0);const a=Math.sqrt(Math.pow(n.x+r.x*o-i.x,2)+Math.pow(n.y+r.y*o-i.y,2))-t.radius,h=(n.x+r.x*o-i.x)*t.radius/(t.radius+a),l=(n.y+r.y*o-i.y)*t.radius/(t.radius+a);return new Bi(r.scale(o).add(n),new q(i.x+h,i.y+l))},EdgeEdgeClosestLine(t,e){const i=t.asLine(),s=i.begin,n=i.getEdge(),r=e.asLine();return Mi(s,n,r.begin,r.getEdge())}};class Fi extends Ri{constructor(t){super(),this.offset=q.Zero,this.offset=t.offset||q.Zero,this.radius=t.radius||0}get worldPos(){var t,e;return this.offset.add(null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:q.Zero)}clone(){return new Fi({offset:this.offset.clone(),radius:this.radius})}get center(){var t,e;return this.offset.add(null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos)&&void 0!==e?e:q.Zero)}contains(t){var e,i;return(null!==(i=null===(e=this._transform)||void 0===e?void 0:e.pos)&&void 0!==i?i:this.offset).distance(t)<=this.radius}rayCast(t,e=1/0){const i=this.center,s=t.dir,n=t.pos,r=Math.sqrt(Math.pow(s.dot(n.sub(i)),2)-Math.pow(n.sub(i).distance(),2)+Math.pow(this.radius,2));if(r<0)return null;{let o=0;if(0===r)return o=-s.dot(n.sub(i)),o>0&&o<e?t.getPoint(o):null;{const o=-s.dot(n.sub(i))+r,a=-s.dot(n.sub(i))-r,h=[];o>=0&&h.push(o),a>=0&&h.push(a);const l=Math.min(...h);return l<=e?t.getPoint(l):null}}}getClosestLineBetween(t){if(t instanceof Fi)return ki.CircleCircleClosestLine(this,t);if(t instanceof Ui)return ki.PolygonCircleClosestLine(t,this).flip();if(t instanceof zi)return ki.CircleEdgeClosestLine(this,t).flip();throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}collide(t){if(t instanceof Fi)return Oi.CollideCircleCircle(this,t);if(t instanceof Ui)return Oi.CollideCirclePolygon(this,t);if(t instanceof zi)return Oi.CollideCircleEdge(this,t);throw new Error("Circle could not collide with unknown CollisionShape "+typeof t)}getFurthestPoint(t){return this.center.add(t.normalize().scale(this.radius))}getFurthestLocalPoint(t){return t.normalize().scale(this.radius)}get bounds(){var t;const e=this._transform,i=null!==(t=null==e?void 0:e.globalPos)&&void 0!==t?t:q.Zero;return new J(this.offset.x+i.x-this.radius,this.offset.y+i.y-this.radius,this.offset.x+i.x+this.radius,this.offset.y+i.y+this.radius)}get localBounds(){return new J(this.offset.x-this.radius,this.offset.y-this.radius,this.offset.x+this.radius,this.offset.y+this.radius)}get axes(){return[]}getInertia(t){return t*this.radius*this.radius/2}update(t){this._transform=t}project(t){const e=[],i=this.center.dot(t);return e.push(i),e.push(i+this.radius),e.push(i-this.radius),new Ai(Math.min.apply(Math,e),Math.max.apply(Math,e))}draw(t,e=Q.Green,i=q.Zero){const s=i.add(this.offset);t.beginPath(),t.fillStyle=e.toString(),t.arc(s.x,s.y,this.radius,0,2*Math.PI),t.closePath(),t.fill()}debug(t,e){const i=this._transform,s=(null==i?void 0:i.globalPos)?null==i?void 0:i.globalPos.add(this.offset):this.offset;t.drawCircle(s,this.radius,e)}debugDraw(t,e=Q.Green){const i=this._transform,s=i?i.pos.add(this.offset):this.offset,n=i?i.rotation:0;t.beginPath(),t.strokeStyle=e.toString(),t.arc(s.x,s.y,this.radius,0,2*Math.PI),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(Math.cos(n)*this.radius+s.x,Math.sin(n)*this.radius+s.y),t.closePath(),t.stroke()}}class Li{constructor(t,e,i,s,n,r,o,a){this._canceled=!1,this.colliderA=t,this.colliderB=e,this.mtv=i,this.normal=s,this.tangent=n,this.points=r,this.localPoints=o,this.info=a,this.id=Ci.calculatePairHash(t.id,e.id)}matchAwake(){const t=this.colliderA.owner.get(Vi),e=this.colliderB.owner.get(Vi);t&&e&&t.sleeping!==e.sleeping&&(t.sleeping&&t.collisionType!==li.Fixed&&e.sleepMotion>=gi.wakeThreshold&&t.setSleeping(!1),e.sleeping&&e.collisionType!==li.Fixed&&t.sleepMotion>=gi.wakeThreshold&&e.setSleeping(!1))}isCanceled(){return this._canceled}cancel(){this._canceled=!0}}class Ii{static findPolygonPolygonSeparation(t,e){let i=-Number.MAX_VALUE,s=null,n=null,r=-1,o=null;const a=t.getSides(),h=t.getLocalSides();for(let t=0;t<a.length;t++){const h=a[t],l=h.normal(),c=e.getFurthestPoint(l.negate()),d=h.distanceToPoint(c,!0);d>i&&(i=d,s=h,n=l,r=t,o=c)}return{collider:t,separation:n?i:99,axis:n,side:s,localSide:h[r],sideId:r,point:o,localPoint:n?e.getFurthestLocalPoint(n.negate()):null}}static findCirclePolygonSeparation(t,e){const i=e.axes,s=e.center.sub(t.worldPos),n=e.getFurthestPoint(s.negate());i.push(n.sub(t.worldPos).normalize());let r=Number.MAX_VALUE,o=null,a=-1;for(let s=0;s<i.length;s++){const n=e.project(i[s]),h=t.project(i[s]),l=n.getOverlap(h);if(l<=0)return null;l<r&&(r=l,o=i[s],a=s)}return a<0?null:o.normalize().scale(r)}}const Oi={CollideCircleCircle(t,e){const i=t.worldPos,s=e.worldPos,n=t.radius+e.radius,r=i.distance(s);if(r>n)return[];const o=n-r,a=s.sub(i).normalize(),h=a.perpendicular(),l=a.scale(o),c=t.getFurthestPoint(a),d=t.getFurthestLocalPoint(a);return[new Li(t,e,l,a,h,[c],[d],{collider:t,separation:o,axis:a,point:c})]},CollideCirclePolygon(t,e){var i,s;let n=Ii.findCirclePolygonSeparation(t,e);if(!n)return[];const r=n.dot(e.center.sub(t.center));n=r<0?n.negate():n;const o=t.getFurthestPoint(n),a=(null!==(s=null===(i=t.owner)||void 0===i?void 0:i.get(wi))&&void 0!==s?s:new wi).applyInverse(o),h=n.normalize(),l={collider:t,separation:-n.size,axis:h,point:o,localPoint:a,side:e.findSide(h.negate()),localSide:e.findLocalSide(h.negate())};return[new Li(t,e,n,h,h.perpendicular(),[o],[a],l)]},CollideCircleEdge(t,e){const i=t.center,s=e.asLine(),n=s.end.sub(s.begin),r=n.dot(s.end.sub(i)),o=n.dot(i.sub(s.begin)),a=e.asLine(),h=e.asLocalLine();if(o<=0){const n=s.begin.sub(i),r=n.dot(n);if(r>t.radius*t.radius)return[];const o=n.normalize(),l=t.radius-Math.sqrt(r),c={collider:t,separation:l,axis:o,point:a.begin,side:a,localSide:h};return[new Li(t,e,o.scale(l),o,o.perpendicular(),[a.begin],[h.begin],c)]}if(r<=0){const n=s.end.sub(i),r=n.dot(n);if(r>t.radius*t.radius)return[];const o=n.normalize(),l=t.radius-Math.sqrt(r),c={collider:t,separation:l,axis:o,point:a.end,side:a,localSide:h};return[new Li(t,e,o.scale(l),o,o.perpendicular(),[a.end],[h.end],c)]}const l=n.dot(n),c=s.begin.scale(r).add(s.end.scale(o)).scale(1/l),d=i.sub(c),u=d.dot(d);if(u>t.radius*t.radius)return[];let p=n.perpendicular();p.dot(i.sub(s.begin))<0&&(p.x=-p.x,p.y=-p.y),p=p.normalize();const g=t.radius-Math.sqrt(u),_=p.scale(g),f={collider:t,separation:g,axis:p,point:c,side:a,localSide:h};return[new Li(t,e,_,p.negate(),p.negate().perpendicular(),[c],[c.sub(e.worldPos)],f)]},CollideEdgeEdge:()=>[],CollidePolygonEdge(t,e){var i;const s=t.center,n=e.center.sub(s).normalize(),r=new Ui({points:[e.begin,e.end,e.end.add(n.scale(100)),e.begin.add(n.scale(100))],offset:e.offset});r.owner=e.owner;(null===(i=e.owner)||void 0===i?void 0:i.get(wi))&&r.update(e.owner.get(wi));const o=this.CollidePolygonPolygon(t,r);return o.length&&(o[0].colliderB=e,o[0].id=Ci.calculatePairHash(t.id,e.id)),o},CollidePolygonPolygon(t,e){var i,s,n,r;const o=Ii.findPolygonPolygonSeparation(t,e);if(o.separation>0)return[];const a=Ii.findPolygonPolygonSeparation(e,t);if(a.separation>0)return[];const h=o.separation>a.separation?o:a,l=(h.collider===t?e:t).findSide(h.axis.negate()),c=h.side,d=c.dir().normalize(),u=l.clip(d.negate(),-d.dot(c.begin));let p=null;if(u&&(p=u.clip(d,d.dot(c.end))),p){const o=p.getPoints().filter((t=>c.below(t)));let a=h.axis,l=a.perpendicular();e.worldPos.sub(t.worldPos).dot(a)<0&&(a=a.negate(),l=a.perpendicular());let d=[];if(h.collider===t){const t=null!==(s=null===(i=e.owner)||void 0===i?void 0:i.get(wi))&&void 0!==s?s:new wi;d=o.map((e=>t.applyInverse(e)))}else{const e=null!==(r=null===(n=t.owner)||void 0===n?void 0:n.get(wi))&&void 0!==r?r:new wi;d=o.map((t=>e.applyInverse(t)))}return[new Li(t,e,a.scale(-h.separation),a,l,o,d,h)]}return[]},FindContactSeparation(t,e){var i,s,n,r;const o=t.colliderA,a=null!==(s=null===(i=t.colliderA.owner)||void 0===i?void 0:i.get(wi))&&void 0!==s?s:new wi,h=t.colliderB,l=null!==(r=null===(n=t.colliderB.owner)||void 0===n?void 0:n.get(wi))&&void 0!==r?r:new wi;if(o instanceof Fi&&h instanceof Fi){return-(o.radius+h.radius-a.pos.distance(l.pos))}if(o instanceof Ui&&h instanceof Ui&&t.info.localSide){let i,s;return t.info.collider===o?(i=new Bi(a.apply(t.info.localSide.begin),a.apply(t.info.localSide.end)),s=l.apply(e)):(i=new Bi(l.apply(t.info.localSide.begin),l.apply(t.info.localSide.end)),s=a.apply(e)),i.distanceToPoint(s,!0)}if(o instanceof Ui&&h instanceof Fi||h instanceof Ui&&o instanceof Fi){const i=a.apply(e);if(t.info.side)return t.info.side.distanceToPoint(i,!0)}if(o instanceof zi&&h instanceof Ui||h instanceof zi&&o instanceof Ui){let i;if(i=t.info.collider===o?l.apply(e):a.apply(e),t.info.side)return t.info.side.distanceToPoint(i,!0)}if(o instanceof Fi&&h instanceof zi||h instanceof Fi&&o instanceof zi){const i=l.apply(e);let s;o instanceof Fi&&(s=o.getFurthestPoint(t.normal));const n=i.distance(s);if(t.info.side)return n>0?-n:0}return 0}};class zi extends Ri{constructor(t){var e;super(),this.begin=t.begin||q.Zero,this.end=t.end||q.Zero,this.offset=null!==(e=t.offset)&&void 0!==e?e:q.Zero}clone(){return new zi({begin:this.begin.clone(),end:this.end.clone()})}get worldPos(){var t;const e=this._transform;return null!==(t=null==e?void 0:e.globalPos.add(this.offset))&&void 0!==t?t:this.offset}get center(){return this.begin.average(this.end).add(this._getBodyPos())}_getBodyPos(){var t;const e=this._transform;return null!==(t=null==e?void 0:e.globalPos)&&void 0!==t?t:q.Zero}_getTransformedBegin(){const t=this._transform,e=t?t.globalRotation:0;return this.begin.rotate(e).add(this._getBodyPos())}_getTransformedEnd(){const t=this._transform,e=t?t.globalRotation:0;return this.end.rotate(e).add(this._getBodyPos())}getSlope(){const t=this._getTransformedBegin(),e=this._getTransformedEnd(),i=t.distance(e);return e.sub(t).scale(1/i)}getLength(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return t.distance(e)}contains(){return!1}rayCast(t,e=1/0){const i=this._getTransformedBegin().sub(t.pos);if(0===t.dir.cross(this.getSlope())&&0!==i.cross(t.dir))return null;const s=t.dir.cross(this.getSlope());if(0===s)return null;const n=i.cross(this.getSlope())/s;if(n>=0&&n<=e){const e=i.cross(t.dir)/s/this.getLength();if(e>=0&&e<=1)return t.getPoint(n)}return null}getClosestLineBetween(t){if(t instanceof Fi)return ki.CircleEdgeClosestLine(t,this);if(t instanceof Ui)return ki.PolygonEdgeClosestLine(t,this).flip();if(t instanceof zi)return ki.EdgeEdgeClosestLine(this,t);throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}collide(t){if(t instanceof Fi)return Oi.CollideCircleEdge(t,this);if(t instanceof Ui)return Oi.CollidePolygonEdge(t,this);if(t instanceof zi)return Oi.CollideEdgeEdge();throw new Error("Edge could not collide with unknown CollisionShape "+typeof t)}getFurthestPoint(t){const e=this._getTransformedBegin(),i=this._getTransformedEnd();return t.dot(e)>0?e:i}_boundsFromBeginEnd(t,e,i=10){return new J(Math.min(t.x,e.x)-i,Math.min(t.y,e.y)-i,Math.max(t.x,e.x)+i,Math.max(t.y,e.y)+i)}get bounds(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return this._boundsFromBeginEnd(t,e)}get localBounds(){return this._boundsFromBeginEnd(this.begin,this.end)}asLine(){return new Bi(this._getTransformedBegin(),this._getTransformedEnd())}asLocalLine(){return new Bi(this.begin,this.end)}get axes(){const t=this._getTransformedEnd().sub(this._getTransformedBegin()).normal(),e=[];return e.push(t),e.push(t.negate()),e.push(t.normal()),e.push(t.normal().negate()),e}getInertia(t){const e=this.end.sub(this.begin).distance()/2;return t*e*e}update(t){this._transform=t}project(t){const e=[],i=[this._getTransformedBegin(),this._getTransformedEnd()],s=i.length;for(let n=0;n<s;n++)e.push(i[n].dot(t));return new Ai(Math.min.apply(Math,e),Math.max.apply(Math,e))}draw(t,e=Q.Green,i=q.Zero){const s=this.begin.add(i),n=this.end.add(i);t.strokeStyle=e.toString(),t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(n.x,n.y),t.closePath(),t.stroke()}debug(t,e){const i=this._getTransformedBegin(),s=this._getTransformedEnd();t.drawLine(i,s,e,2),t.drawCircle(i,2,e),t.drawCircle(s,2,e)}debugDraw(t,e=Q.Red){const i=this._getTransformedBegin(),s=this._getTransformedEnd();t.strokeStyle=e.toString(),t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(s.x,s.y),t.closePath(),t.stroke()}}class Ui extends Ri{constructor(t){var e;super(),this._transformedPoints=[],this._axes=[],this._sides=[],this._localSides=[],this.offset=null!==(e=t.offset)&&void 0!==e?e:q.Zero;const i=!!t.clockwiseWinding;this.points=(i?t.points.reverse():t.points)||[],this._calculateTransformation()}clone(){return new Ui({offset:this.offset.clone(),points:this.points.map((t=>t.clone()))})}get worldPos(){return this._transform?this._transform.pos.add(this.offset):this.offset}get center(){return this.bounds.center}_calculateTransformation(){const t=this._transform,e=t?t.globalPos.add(this.offset):this.offset,i=t?t.globalRotation:0,s=t?t.globalScale:q.One,n=this.points.length;this._transformedPoints.length=0;for(let t=0;t<n;t++)this._transformedPoints[t]=this.points[t].scale(s).rotate(i).add(e)}getTransformedPoints(){return this._calculateTransformation(),this._transformedPoints}getSides(){if(this._sides.length)return this._sides;const t=[],e=this.getTransformedPoints(),i=e.length;for(let s=0;s<i;s++)t.push(new Bi(e[s],e[(s+1)%i]));return this._sides=t,this._sides}getLocalSides(){if(this._localSides.length)return this._localSides;const t=[],e=this.points,i=e.length;for(let s=0;s<i;s++)t.push(new Bi(e[s],e[(s+1)%i]));return this._localSides=t,this._localSides}findSide(t){const e=this.getSides();let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const r=e[n],o=r.normal().dot(t);o>s&&(i=r,s=o)}return i}findLocalSide(t){const e=this.getLocalSides();let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const r=e[n],o=r.normal().dot(t);o>s&&(i=r,s=o)}return i}get axes(){if(this._axes.length)return this._axes;const t=this.getSides().map((t=>t.normal()));return this._axes=t,this._axes}update(t){this._transform=t,this._sides.length=0,this._localSides.length=0,this._axes.length=0,this._transformedPoints.length=0,this.getTransformedPoints(),this.getSides(),this.getLocalSides()}contains(t){const e=new Ei(t,new q(1,0));return this.getSides().reduce((function(t,i){return e.intersect(i)>=0?t+1:t}),0)%2!=0}getClosestLineBetween(t){if(t instanceof Fi)return ki.PolygonCircleClosestLine(this,t);if(t instanceof Ui)return ki.PolygonPolygonClosestLine(this,t);if(t instanceof zi)return ki.PolygonEdgeClosestLine(this,t);throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}collide(t){if(t instanceof Fi)return Oi.CollideCirclePolygon(t,this);if(t instanceof Ui)return Oi.CollidePolygonPolygon(this,t);if(t instanceof zi)return Oi.CollidePolygonEdge(this,t);throw new Error("Polygon could not collide with unknown CollisionShape "+typeof t)}getFurthestPoint(t){const e=this.getTransformedPoints();let i=null,s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const r=t.dot(e[n]);r>s&&(s=r,i=e[n])}return i}getFurthestLocalPoint(t){const e=this.points;let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const r=t.dot(e[n]);r>s&&(s=r,i=e[n])}return i}getClosestFace(t){const e=this.getSides();let i=Number.POSITIVE_INFINITY,s=-1,n=-1;for(let r=0;r<e.length;r++){const o=e[r].distanceToPoint(t);o<i&&(i=o,s=r,n=o)}return-1!==s?{distance:e[s].normal().scale(n),face:e[s]}:null}get bounds(){var t,e,i;const s=this._transform,n=null!==(t=null==s?void 0:s.globalScale)&&void 0!==t?t:q.One,r=null!==(e=null==s?void 0:s.globalRotation)&&void 0!==e?e:0,o=(null!==(i=null==s?void 0:s.globalPos)&&void 0!==i?i:q.Zero).add(this.offset);return this.localBounds.scale(n).rotate(r).translate(o)}get localBounds(){return J.fromPoints(this.points)}getInertia(t){let e=0,i=0;for(let t=0;t<this.points.length;t++){const s=(t+1)%this.points.length,n=this.points[s].cross(this.points[t]);e+=n*(this.points[t].dot(this.points[t])+this.points[t].dot(this.points[s])+this.points[s].dot(this.points[s])),i+=n}return t/6*(e/i)}rayCast(t,e=1/0){const i=this.getSides(),s=i.length;let n=Number.MAX_VALUE,r=-1;for(let o=0;o<s;o++){const s=t.intersect(i[o]);s>=0&&s<n&&s<=e&&(n=s,r=o)}return r>=0?t.getPoint(n):null}project(t){const e=this.getTransformedPoints(),i=e.length;let s=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;r<i;r++){const i=e[r].dot(t);s=Math.min(s,i),n=Math.max(n,i)}return new Ai(s,n)}draw(t,e=Q.Green,i=q.Zero){const s=i.add(this.offset);t.beginPath(),t.fillStyle=e.toString();const n=this.points[0].add(s);t.moveTo(n.x,n.y),this.points.map((t=>t.add(s))).forEach((function(e){t.lineTo(e.x,e.y)})),t.lineTo(n.x,n.y),t.closePath(),t.fill()}debug(t,e){const i=this.getTransformedPoints()[0],s=[i,...this.getTransformedPoints(),i];for(let i=0;i<s.length-1;i++)t.drawLine(s[i],s[i+1],e,2),t.drawCircle(s[i],2,e),t.drawCircle(s[i+1],2,e)}debugDraw(t,e=Q.Red){t.beginPath(),t.strokeStyle=e.toString();const i=this.getTransformedPoints()[0];t.moveTo(i.x,i.y),this.getTransformedPoints().forEach((function(e){t.lineTo(e.x,e.y)})),t.lineTo(i.x,i.y),t.closePath(),t.stroke()}}class Hi{static Box(t,e,i=q.Half,s=q.Zero){return new Ui({points:new J(-t*i.x,-e*i.y,t-t*i.x,e-e*i.y).getPoints(),offset:s})}static Polygon(t,e=!1,i=q.Zero){return new Ui({points:t,offset:i,clockwiseWinding:e})}static Circle(t,e=q.Zero){return new Fi({radius:t,offset:e})}static Edge(t,e){return new zi({begin:t,end:e})}static Capsule(t,e,i=q.Zero){const s=_.getInstance();t===e&&s.warn("A capsule collider with equal width and height is a circle, consider using a ex.Shape.Circle or ex.CircleCollider");if(e>=t){return new Di([Hi.Circle(t/2,K(0,-e/2+t/2).add(i)),Hi.Box(t,e-t,q.Half,i),Hi.Circle(t/2,K(0,e/2-t/2).add(i))])}return new Di([Hi.Circle(e/2,K(-t/2+e/2,0).add(i)),Hi.Box(t-e,e,q.Half,i),Hi.Circle(e/2,K(t/2-e/2,0).add(i))])}}class Wi extends fi{constructor(t){super(),this.type="ex.collider",this.events=new le(this),this.$colliderAdded=new bi,this.$colliderRemoved=new bi,this.set(t)}get(){return this._collider}set(t){return this.clear(),t&&(this._collider=t,this._collider.owner=this.owner,this.events.wire(t.events),this.$colliderAdded.notifyAll(t),this.update()),t}clear(){this._collider&&(this.events.unwire(this._collider.events),this.$colliderRemoved.notifyAll(this._collider),this._collider.owner=null,this._collider=null)}get bounds(){var t,e;return null!==(e=null===(t=this._collider)||void 0===t?void 0:t.bounds)&&void 0!==e?e:new J}get localBounds(){var t,e;return null!==(e=null===(t=this._collider)||void 0===t?void 0:t.localBounds)&&void 0!==e?e:new J}update(){var t;const e=null===(t=this.owner)||void 0===t?void 0:t.get(wi);this._collider&&(this._collider.owner=this.owner,e&&this._collider.update(e))}collide(t){let e=this._collider,i=t._collider;if(!e||!i)return[];let s=!1;if(i instanceof Di&&(e=i,i=this._collider,s=!0),this._collider){const n=e.collide(i);return n?(s&&n.forEach((e=>{e.mtv=e.mtv.negate(),e.normal=e.normal.negate(),e.tangent=e.normal.perpendicular(),e.colliderA=this._collider,e.colliderB=t._collider})),n):[]}return[]}onAdd(t){this._collider&&this.update(),this.events.on("precollision",(e=>{const i=e;t.events.emit("precollision",new Kt(i.target.owner,i.other.owner,i.side,i.intersection))})),this.events.on("postcollision",(e=>{const i=e;t.events.emit("postcollision",new Zt(i.target.owner,i.other.owner,i.side,i.intersection))})),this.events.on("collisionstart",(e=>{const i=e;t.events.emit("collisionstart",new te(i.target.owner,i.other.owner,i.contact))})),this.events.on("collisionend",(e=>{const i=e;t.events.emit("collisionend",new ee(i.target.owner,i.other.owner))}))}onRemove(){this.events.clear(),this.$colliderRemoved.notifyAll(this._collider)}useBoxCollider(t,e,i=q.Half,s=q.Zero){const n=Hi.Box(t,e,i,s);return this.set(n)}usePolygonCollider(t,e=q.Zero){const i=Hi.Polygon(t,!1,e);return this.set(i)}useCircleCollider(t,e=q.Zero){const i=Hi.Circle(t,e);return this.set(i)}useEdgeCollider(t,e){const i=Hi.Edge(t,e);return this.set(i)}useCompositeCollider(t){return this.set(new Di(t))}}var Ni;!function(t){t.Rotation="rotation",t.X="x",t.Y="y"}(Ni||(Ni={}));class Vi extends fi{constructor(t){var e,i,s;super(),this.type="ex.body",this.dependencies=[wi,vi],this.id=g("body",Vi._ID++),this.events=new le(this),this.collisionType=li.PreventCollision,this.group=xi.All,this.mass=gi.defaultMass,this.sleepMotion=5*gi.sleepEpsilon,this.canSleep=gi.bodiesCanSleepByDefault,this._sleeping=!1,this.bounciness=.2,this.friction=.99,this.useGravity=!0,this.limitDegreeOfFreedom=[],this.oldPos=new q(0,0),this.oldVel=new q(0,0),this.oldAcc=q.Zero,this.oldRotation=0,this.oldScale=q.One,t&&(this.collisionType=null!==(e=t.type)&&void 0!==e?e:this.collisionType,this.group=null!==(i=t.group)&&void 0!==i?i:this.group,this.useGravity=null!==(s=t.useGravity)&&void 0!==s?s:this.useGravity)}get inverseMass(){return this.collisionType===li.Fixed?0:1/this.mass}get sleeping(){return this._sleeping}setSleeping(t){this._sleeping=t,t?(this.vel=q.Zero,this.acc=q.Zero,this.angularVelocity=0,this.sleepMotion=0):this.sleepMotion=5*gi.sleepEpsilon}updateMotion(){this._sleeping&&this.setSleeping(!0);const t=this.vel.size*this.vel.size+Math.abs(this.angularVelocity*this.angularVelocity),e=gi.sleepBias;this.sleepMotion=e*this.sleepMotion+(1-e)*t,this.sleepMotion=S(this.sleepMotion,0,10*gi.sleepEpsilon),this.canSleep&&this.sleepMotion<gi.sleepEpsilon&&this.setSleeping(!0)}get inertia(){const t=this.owner.get(Wi);return(null==t?void 0:t.get())?t.get().getInertia(this.mass):0}get inverseInertia(){return this.collisionType===li.Fixed?0:1/this.inertia}get active(){var t;return!!(null===(t=this.owner)||void 0===t?void 0:t.active)}get center(){return this.pos}get transform(){var t;return null===(t=this.owner)||void 0===t?void 0:t.get(wi)}get motion(){var t;return null===(t=this.owner)||void 0===t?void 0:t.get(vi)}get pos(){return this.transform.globalPos}set pos(t){this.transform.globalPos=t}get vel(){return this.motion.vel}set vel(t){this.motion.vel=t}get acc(){return this.motion.acc}set acc(t){this.motion.acc=t}get torque(){return this.motion.torque}set torque(t){this.motion.torque=t}get rotation(){return this.transform.globalRotation}set rotation(t){this.transform.globalRotation=t}get scale(){return this.transform.globalScale}set scale(t){this.transform.globalScale=t}get sx(){return this.motion.scaleFactor.x}set sx(t){this.motion.scaleFactor.x=t}get sy(){return this.motion.scaleFactor.y}set sy(t){this.motion.scaleFactor.y=t}get rx(){return this.motion.angularVelocity}set rx(t){this.motion.angularVelocity=t}get angularVelocity(){return this.motion.angularVelocity}set angularVelocity(t){this.motion.angularVelocity=t}applyImpulse(t,e){if(this.collisionType!==li.Active)return;const i=e.scale(this.inverseMass);if(this.limitDegreeOfFreedom.includes(Ni.X)&&(i.x=0),this.limitDegreeOfFreedom.includes(Ni.Y)&&(i.y=0),this.vel.addEqual(i),!this.limitDegreeOfFreedom.includes(Ni.Rotation)){const i=t.sub(this.pos);this.angularVelocity+=this.inverseInertia*i.cross(e)}}applyLinearImpulse(t){if(this.collisionType!==li.Active)return;const e=t.scale(this.inverseMass);this.limitDegreeOfFreedom.includes(Ni.X)&&(e.x=0),this.limitDegreeOfFreedom.includes(Ni.Y)&&(e.y=0),this.vel=this.vel.add(e)}applyAngularImpulse(t,e){if(this.collisionType===li.Active&&!this.limitDegreeOfFreedom.includes(Ni.Rotation)){const i=t.sub(this.pos);this.angularVelocity+=this.inverseInertia*i.cross(e)}}captureOldTransform(){this.oldVel.setTo(this.vel.x,this.vel.y),this.oldPos.setTo(this.pos.x,this.pos.y),this.oldAcc.setTo(this.acc.x,this.acc.y),this.oldScale.setTo(this.scale.x,this.scale.y),this.oldRotation=this.rotation}debugDraw(t){}}Vi._ID=0;class Gi{constructor(){this._topLeft=new q(0,0),this._topRight=new q(0,0),this._bottomLeft=new q(0,0),this._bottomRight=new q(0,0)}isSpriteOffScreen(t,e){const i=t.currentDrawing.drawWidth,s=t.currentDrawing.drawHeight,n=t.rotation,r=t.center,o=t.getGlobalPos();this._topLeft=K(o.x-i/2,o.y-s/2),this._topLeft=this._topLeft.rotate(n,r),this._topRight=K(o.x+i/2,o.y-s/2),this._topRight=this._topRight.rotate(n,r),this._bottomLeft=K(o.x-i/2,o.y+s/2),this._bottomLeft=this._bottomLeft.rotate(n,r),this._bottomRight=K(o.x+i/2,o.y+s/2),this._bottomRight=this._bottomRight.rotate(n,r);const a=e.worldToScreenCoordinates(this._topLeft),h=e.worldToScreenCoordinates(this._topRight),l=e.worldToScreenCoordinates(this._bottomLeft),c=e.worldToScreenCoordinates(this._bottomRight);this._xCoords=[],this._yCoords=[],this._xCoords.push(a.x,h.x,l.x,c.x),this._yCoords.push(a.y,h.y,l.y,c.y),this._xMin=Math.min.apply(null,this._xCoords),this._yMin=Math.min.apply(null,this._yCoords),this._xMax=Math.max.apply(null,this._xCoords),this._yMax=Math.max.apply(null,this._yCoords);const d=e.screenToWorldCoordinates(new q(this._xMin,this._yMin)),u=e.screenToWorldCoordinates(new q(this._xMax,this._yMax));this._xMinWorld=d.x,this._yMinWorld=d.y,this._xMaxWorld=u.x,this._yMaxWorld=u.y;const p=[new q(this._xMin,this._yMin),new q(this._xMax,this._yMin),new q(this._xMin,this._yMax),new q(this._xMax,this._yMax)];if(p[0].x<0&&p[1].x>e.canvas.clientWidth&&(p[0].y>0||p[2].y<e.canvas.clientHeight))return!1;if(p[0].y<0&&p[2].y>e.canvas.clientHeight&&(p[1].x>0||p[0].x<e.canvas.clientWidth))return!1;for(let t=0;t<p.length;t++)if(p[t].x>0&&p[t].y>0&&p[t].x<e.canvas.clientWidth&&p[t].y<e.canvas.clientHeight)return!1;return!0}debugDraw(t){t.beginPath(),t.strokeStyle=Q.White.toString(),t.rect(this._xMinWorld,this._yMinWorld,this._xMaxWorld-this._xMinWorld,this._yMaxWorld-this._yMinWorld),t.stroke(),t.fillStyle=Q.Red.toString(),t.beginPath(),t.arc(this._topLeft.x,this._topLeft.y,5,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle=Q.Green.toString(),t.beginPath(),t.arc(this._topRight.x,this._topRight.y,5,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle=Q.Blue.toString(),t.beginPath(),t.arc(this._bottomLeft.x,this._bottomLeft.y,5,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle=Q.Magenta.toString(),t.beginPath(),t.arc(this._bottomRight.x,this._bottomRight.y,5,0,2*Math.PI),t.closePath(),t.fill()}}class ji{constructor(){this.cullingBox=new Gi}update(t,e){const i=t.eventDispatcher;let s=!0;null!=t.currentDrawing&&(s=this.cullingBox.isSpriteOffScreen(t,e));let n=!1;e&&e.currentScene&&e.currentScene.camera&&e.currentScene.camera.viewport&&!t.parent&&(n=!e.currentScene.camera.viewport.intersect(t.collider.bounds)),t.isOffScreen?n&&s||(i.emit("enterviewport",new oe(t)),t.removeComponent("offscreen")):n&&s&&(i.emit("exitviewport",new re(t)),t.addComponent(new mi("offscreen")))}}class Xi{update(t,e){t.enableCapturePointer&&(t.isKilled()||e.input.pointers.checkAndUpdateActorUnderPointer(t))}}class qi{constructor(t){this.data=t,this.type="Component Added"}}function Ki(t){return!!t&&"Component Added"===t.type}class Zi{constructor(t){this.data=t,this.type="Component Removed"}}function Yi(t){return!!t&&"Component Removed"===t.type}class Qi extends $e{constructor(t,e){if(super(),this.id=Qi._ID++,this._name="anonymous",this.active=!0,this._componentsToRemove=[],this._componentTypeToInstance=new Map,this._componentStringToInstance=new Map,this._tagsMemo=[],this._typesMemo=[],this.componentAdded$=new bi,this.componentRemoved$=new bi,this._parent=null,this.childrenAdded$=new bi,this.childrenRemoved$=new bi,this._children=[],this._isInitialized=!1,this._setName(e),t)for(const e of t)this.addComponent(e)}_setName(t){t&&(this._name=t)}get name(){return this._name}get events(){return this.eventDispatcher}kill(){this.active=!1}isKilled(){return!this.active}get tags(){return this._tagsMemo}hasTag(t){return this.tags.includes(t)}addTag(t){return this.addComponent(new mi(t))}removeTag(t,e=!1){return this.removeComponent(t,e)}get types(){return this._typesMemo}_rebuildMemos(){this._tagsMemo=Array.from(this._componentStringToInstance.values()).filter((t=>t instanceof mi)).map((t=>t.type)),this._typesMemo=Array.from(this._componentStringToInstance.keys())}getComponents(){return Array.from(this._componentStringToInstance.values())}_notifyAddComponent(t){this._rebuildMemos();const e=new qi({component:t,entity:this});this.componentAdded$.notifyAll(e)}_notifyRemoveComponent(t){const e=new Zi({component:t,entity:this});this.componentRemoved$.notifyAll(e),this._rebuildMemos()}get parent(){return this._parent}get children(){return this._children}unparent(){this._parent&&(this._parent.removeChild(this),this._parent=null)}addChild(t){if(null!==t.parent)throw new Error("Entity already has a parent, cannot add without unparenting");if(this.getAncestors().includes(t))throw new Error("Cycle detected, cannot add entity");return this._children.push(t),t._parent=this,this.childrenAdded$.notifyAll(t),this}removeChild(t){return t.parent===this&&(k(t,this._children),t._parent=null,this.childrenRemoved$.notifyAll(t)),this}removeAllChildren(){return this.children.forEach((t=>{this.removeChild(t)})),this}getAncestors(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;return t.reverse()}getDescendants(){let t=[this],e=[this];for(;e.length>0;){const i=e.pop();e=e.concat(i.children),t=t.concat(i.children)}return t}clone(){const t=new Qi;for(const e of this.types)t.addComponent(this.get(e).clone());for(const e of this.children)t.addChild(e.clone());return t}addTemplate(t,e=!1){for(const i of t.getComponents())this.addComponent(i.clone(),e);for(const e of t.children)this.addChild(e.clone().addTemplate(e));return this}addComponent(t,e=!1){if(this.has(t.type)){if(!e)return this;this.removeComponent(t)}if(t.dependencies&&t.dependencies.length)for(const e of t.dependencies)this.addComponent(new e);t.owner=this;const i=t.constructor;return this._componentTypeToInstance.set(i,t),this._componentStringToInstance.set(t.type,t),t.onAdd&&t.onAdd(this),this._notifyAddComponent(t),this}removeComponent(t,e=!1){return e?"string"==typeof t?this._removeComponentByType(t):t instanceof fi&&this._removeComponentByType(t.type):this._componentsToRemove.push(t),this}_removeComponentByType(t){if(this.has(t)){const e=this.get(t);e.owner=null,e.onRemove&&e.onRemove(this);const i=e.constructor;this._componentTypeToInstance.delete(i),this._componentStringToInstance.delete(e.type),this._notifyRemoveComponent(e)}}processComponentRemoval(){for(const t of this._componentsToRemove){const e="string"==typeof t?t:t.type;this._removeComponentByType(e)}this._componentsToRemove.length=0}has(t){return"string"==typeof t?this._componentStringToInstance.has(t):this._componentTypeToInstance.has(t)}get(t){return"string"==typeof t?this._componentStringToInstance.get(t):this._componentTypeToInstance.get(t)}get isInitialized(){return this._isInitialized}_initialize(t){this.isInitialized||(this.onInitialize(t),super.emit("initialize",new ie(t,this)),this._isInitialized=!0)}_preupdate(t,e){this.emit("preupdate",new It(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new Ot(t,e,this)),this.onPostUpdate(t,e)}onInitialize(t){}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this._initialize(t),this._preupdate(t,e);for(const i of this.children)i.update(t,e);this._postupdate(t,e)}}Qi._ID=0;class $i extends fi{constructor(t){var e;super(),this.draw=t,this.type="ex.canvas",this.draw=null!==(e=this.draw)&&void 0!==e?e:()=>{}}}function Ji(t){return!!t.tick}class ts{constructor(t,e){this._options=t,this._graphics=e,this.graphics=[]}get name(){return this._options.name}hide(t){if(t){let e=null;e=t instanceof vt?t:this._graphics.getGraphic(t),this.graphics=this.graphics.filter((t=>t.graphic!==e))}else this.graphics.length=0}show(t,e){let i;return e=Object.assign({},e),t instanceof vt?i=this._graphics.copyGraphics?t.clone():t:(i=this._graphics.getGraphic(t),i||_.getInstance().error(`No such graphic added to component named ${t}. These named graphics are available: `,this._graphics.getNames())),i?(this.graphics.push({graphic:i,options:e}),i):null}use(t,e){return e=Object.assign({},e),this.hide(),this.show(t,e)}get order(){return this._options.order}set order(t){this._options.order=t}get offset(){var t;return null!==(t=this._options.offset)&&void 0!==t?t:q.Zero}set offset(t){this._options.offset=t}get currentKeys(){var t;return null!==(t=this.name)&&void 0!==t?t:"anonymous"}}class es{constructor(t){this._component=t,this._layers=[],this._layerMap={},this.default=new ts({name:"default",order:0},t),this._maybeAddLayer(this.default)}create(t){const e=new ts(t,this._component);return this._maybeAddLayer(e)}get(t){return t?this._getLayer(t):this._layers}currentKeys(){const t=[];for(const e of this._layers)t.push(e.currentKeys);return t}has(t){return t in this._layerMap}_maybeAddLayer(t){return this._layerMap[t.name]?this._layerMap[t.name]:(this._layerMap[t.name]=t,this._layers.push(t),this._layers.sort(((t,e)=>t.order-e.order)),t)}_getLayer(t){return this._layerMap[t]}}class is extends fi{constructor(t){super(),this.type="ex.graphics",this._graphics={},this.visible=!0,this.opacity=1,this.offset=q.Zero,this.anchor=q.Half,this.copyGraphics=!1,this._bounds=null,t=Object.assign({visible:this.visible},t);const{current:e,anchor:i,opacity:s,visible:n,graphics:r,offset:o,copyGraphics:a,onPreDraw:h,onPostDraw:l}=t;this._graphics=r||{},this.offset=null!=o?o:this.offset,this.opacity=null!=s?s:this.opacity,this.anchor=null!=i?i:this.anchor,this.copyGraphics=null!=a?a:this.copyGraphics,this.onPreDraw=null!=h?h:this.onPreDraw,this.onPostDraw=null!=l?l:this.onPostDraw,this.visible=!!n,this.layers=new es(this),e&&this._graphics[e]&&this.show(this._graphics[e])}getGraphic(t){return this._graphics[t]}getNames(){return Object.keys(this._graphics)}get current(){return this.layers.default.graphics}get graphics(){return this._graphics}add(t,e){let i="default",s=null;return"string"==typeof t?(i=t,s=e):s=t,this._graphics[i]=this.copyGraphics?s.clone():s,"default"===i&&this.show("default"),s}show(t,e){return this.layers.default.show(t,e)}use(t,e){return this.layers.default.use(t,e)}hide(t){this.layers.default.hide(t)}set localBounds(t){this._bounds=t}get localBounds(){if(this._bounds)return this._bounds;let t=new J;for(const e of this.layers.get())for(const{graphic:i,options:s}of e.graphics){let n=this.anchor,r=this.offset;(null==s?void 0:s.anchor)&&(n=s.anchor),(null==s?void 0:s.offset)&&(r=s.offset);const o=i.localBounds,a=-o.width*i.scale.x*n.x+r.x,h=-o.height*i.scale.y*n.y+r.y;t=null==i?void 0:i.localBounds.translate(K(a+e.offset.x,h+e.offset.y)).combine(t)}return t}update(t,e=0){for(const i of this.layers.get())for(const{graphic:s}of i.graphics)Ji(s)&&(null==s||s.tick(t,e))}}class ss extends Ct{constructor(t){super(t),this.width=t.width,this.height=t.height,this.rasterize()}clone(){return new ss(Object.assign(Object.assign({width:this.width,height:this.height},this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){this.color&&t.fillRect(0,0,this.width,this.height),this.strokeColor&&t.strokeRect(0,0,this.width,this.height)}}class ns extends Ct{constructor(t){var e;super(t),this._radius=0,this.padding=null!==(e=t.padding)&&void 0!==e?e:2,this.radius=t.radius,this.rasterize()}get radius(){return this._radius}set radius(t){this._radius=t,this.width=2*this._radius,this.height=2*this._radius,this.flagDirty()}clone(){return new ns(Object.assign(Object.assign({radius:this.radius},this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){this.radius>0&&(t.beginPath(),t.arc(this.radius,this.radius,this.radius,0,2*Math.PI),this.color&&t.fill(),this.strokeColor&&t.stroke())}}var rs,os=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class as{static CreateReversibleEasingFunction(t){return(e,i,s,n)=>s<i?i-(t(e,s,i,n)-s):t(e,i,s,n)}static CreateReversableEasingFunction(t){return as.CreateReversibleEasingFunction(t)}static CreateVectorEasingFunction(t){return(e,i,s,n)=>new q(t(e,i.x,s.x,n),t(e,i.y,s.y,n))}}as.Linear=as.CreateReversibleEasingFunction(((t,e,i,s)=>(i-=e)*t/s+e)),as.EaseInQuad=as.CreateReversibleEasingFunction(((t,e,i,s)=>(i-=e)*(t/=s)*t+e)),as.EaseOutQuad=as.CreateReversibleEasingFunction(((t,e,i,s)=>-(i-=e)*(t/=s)*(t-2)+e)),as.EaseInOutQuad=as.CreateReversibleEasingFunction(((t,e,i,s)=>(i-=e,(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e))),as.EaseInCubic=as.CreateReversibleEasingFunction(((t,e,i,s)=>(i-=e)*(t/=s)*t*t+e)),as.EaseOutCubic=as.CreateReversibleEasingFunction(((t,e,i,s)=>(t/=s,(i-=e)*(--t*t*t+1)+e))),as.EaseInOutCubic=as.CreateReversibleEasingFunction(((t,e,i,s)=>(i-=e,(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e))),os([j({message:"Alias for incorrect spelling used in older versions, will be removed in v0.25.0",alternateMethod:"CreateReversibleEasingFunction"})],as,"CreateReversableEasingFunction",null);class hs{constructor(t){this._actions=[],this._completedActions=[],this._entity=t}add(t){this._actions.push(t)}remove(t){const e=this._actions.indexOf(t);this._actions.splice(e,1)}clearActions(){this._actions.length=0,this._completedActions.length=0,this._currentAction&&this._currentAction.stop()}getActions(){return this._actions.concat(this._completedActions)}hasNext(){return this._actions.length>0}isComplete(){return 0===this._actions.length}reset(){this._actions=this.getActions();const t=this._actions.length;for(let e=0;e<t;e++)this._actions[e].reset();this._completedActions=[]}update(t){this._actions.length>0&&(this._currentAction=this._actions[0],this._currentAction.update(t),this._currentAction.isComplete(this._entity)&&this._completedActions.push(this._actions.shift()))}}class ls{constructor(t,e,i){this._stopped=!1,this._repeatBuilder=e,this._repeatContext=new Ss(t),this._actionQueue=this._repeatContext.getQueue(),this._repeat=i,this._originalRepeat=i,this._repeatBuilder(this._repeatContext),this._repeat--}update(t){this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext),this._repeat--),this._actionQueue.update(t)}isComplete(){return this._stopped||this._repeat<=0&&this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._repeat=this._originalRepeat}}class cs{constructor(t,e){this._stopped=!1,this._repeatBuilder=e,this._repeatContext=new Ss(t),this._actionQueue=this._repeatContext.getQueue(),this._repeatBuilder(this._repeatContext)}update(t){this._stopped||(this._actionQueue.isComplete()&&(this._actionQueue.clearActions(),this._repeatBuilder(this._repeatContext)),this._actionQueue.update(t))}isComplete(){return this._stopped}stop(){this._stopped=!0,this._actionQueue.clearActions()}reset(){}}class ds{constructor(t,e,i,s){if(this._started=!1,this._stopped=!1,this._entity=t,this._tx=t.get(wi),this._motion=t.get(vi),this._speed=s,this._offset=new q(e,i),s<=0)throw _.getInstance().error("Attempted to moveBy with speed less than or equal to zero : "+s),new Error("Speed must be greater than 0 pixels per second")}update(t){this._started||(this._started=!0,this._start=new q(this._tx.pos.x,this._tx.pos.y),this._end=this._start.add(this._offset),this._distance=this._offset.size,this._dir=this._end.sub(this._start).normalize()),this.isComplete(this._entity)?(this._tx.pos=K(this._end.x,this._end.y),this._motion.vel=K(0,0)):this._motion.vel=this._dir.scale(this._speed)}isComplete(t){const e=t.get(wi);return this._stopped||e.pos.distance(this._start)>=this._distance}stop(){this._motion.vel=K(0,0),this._stopped=!0}reset(){this._started=!1}}class us{constructor(t,e,i,s){this.entity=t,this._started=!1,this._stopped=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._end=new q(e,i),this._speed=s}update(t){this._started||(this._started=!0,this._start=new q(this._tx.pos.x,this._tx.pos.y),this._distance=this._start.distance(this._end),this._dir=this._end.sub(this._start).normalize());const e=this._dir.scale(this._speed);this._motion.vel=K(e.x,e.y),this.isComplete(this.entity)&&(this._tx.pos=K(this._end.x,this._end.y),this._motion.vel=K(0,0))}isComplete(t){const e=t.get(wi);return this._stopped||new q(e.pos.x,e.pos.y).distance(this._start)>=this._distance}stop(){this._motion.vel=K(0,0),this._stopped=!0}reset(){this._started=!1}}!function(t){t[t.ShortestPath=0]="ShortestPath",t[t.LongestPath=1]="LongestPath",t[t.Clockwise=2]="Clockwise",t[t.CounterClockwise=3]="CounterClockwise"}(rs||(rs={}));class ps{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._end=e,this._speed=i,this._rotationType=s||rs.ShortestPath}update(t){if(!this._started){this._started=!0,this._start=this._tx.rotation,this._currentNonCannonAngle=this._tx.rotation;const t=Math.abs(this._end-this._start),e=x-t;switch(t>e?(this._shortDistance=e,this._longDistance=t):(this._shortDistance=t,this._longDistance=e),this._shortestPathIsPositive=(this._start-this._end+x)%x>=Math.PI,this._rotationType){case rs.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case rs.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case rs.Clockwise:this._direction=1,this._shortestPathIsPositive?this._distance=this._shortDistance:this._distance=this._longDistance;break;case rs.CounterClockwise:this._direction=-1,this._shortestPathIsPositive?this._distance=this._longDistance:this._distance=this._shortDistance}}this._motion.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(t/1e3),this.isComplete()&&(this._tx.rotation=this._end,this._motion.angularVelocity=0,this._stopped=!0)}isComplete(){const t=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||t>=Math.abs(this._distance)}stop(){this._motion.angularVelocity=0,this._stopped=!0}reset(){this._started=!1}}class gs{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._speed=i,this._offset=e,this._rotationType=s||rs.ShortestPath}update(t){if(!this._started){this._started=!0,this._start=this._tx.rotation,this._currentNonCannonAngle=this._tx.rotation,this._end=this._start+this._offset;const t=Math.abs(this._end-this._start),e=x-t;switch(t>e?(this._shortDistance=e,this._longDistance=t):(this._shortDistance=t,this._longDistance=e),this._shortestPathIsPositive=(this._start-this._end+x)%x>=Math.PI,this._rotationType){case rs.ShortestPath:this._distance=this._shortDistance,this._shortestPathIsPositive?this._direction=1:this._direction=-1;break;case rs.LongestPath:this._distance=this._longDistance,this._shortestPathIsPositive?this._direction=-1:this._direction=1;break;case rs.Clockwise:this._direction=1,this._shortDistance>=0?this._distance=this._shortDistance:this._distance=this._longDistance;break;case rs.CounterClockwise:this._direction=-1,this._shortDistance<=0?this._distance=this._shortDistance:this._distance=this._longDistance}}this._motion.angularVelocity=this._direction*this._speed,this._currentNonCannonAngle+=this._direction*this._speed*(t/1e3),this.isComplete()&&(this._tx.rotation=this._end,this._motion.angularVelocity=0,this._stopped=!0)}isComplete(){const t=Math.abs(this._currentNonCannonAngle-this._start);return this._stopped||t>=Math.abs(this._distance)}stop(){this._motion.angularVelocity=0,this._stopped=!0}reset(){this._started=!1}}class _s{constructor(t,e,i,s,n){this._started=!1,this._stopped=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._endX=e,this._endY=i,this._speedX=s,this._speedY=n}update(t){if(this._started||(this._started=!0,this._startX=this._tx.scale.x,this._startY=this._tx.scale.y,this._distanceX=Math.abs(this._endX-this._startX),this._distanceY=Math.abs(this._endY-this._startY)),Math.abs(this._tx.scale.x-this._startX)>=this._distanceX)this._motion.scaleFactor.x=0;else{const t=this._endY<this._startY?-1:1;this._motion.scaleFactor.x=this._speedX*t}if(Math.abs(this._tx.scale.y-this._startY)>=this._distanceY)this._motion.scaleFactor.y=0;else{const t=this._endY<this._startY?-1:1;this._motion.scaleFactor.y=this._speedY*t}this.isComplete()&&(this._tx.scale=K(this._endX,this._endY),this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._tx.scale.y-this._startX)>=this._distanceX&&Math.abs(this._tx.scale.y-this._startY)>=this._distanceY}stop(){this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1}}class fs{constructor(t,e,i,s){this._started=!1,this._stopped=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._offset=new q(e,i),this._speedX=this._speedY=s}update(t){this._started||(this._started=!0,this._startScale=this._tx.scale.clone(),this._endScale=this._startScale.add(this._offset),this._distanceX=Math.abs(this._endScale.x-this._startScale.x),this._distanceY=Math.abs(this._endScale.y-this._startScale.y),this._directionX=this._endScale.x<this._startScale.x?-1:1,this._directionY=this._endScale.y<this._startScale.y?-1:1),this._motion.scaleFactor.x=this._speedX*this._directionX,this._motion.scaleFactor.y=this._speedY*this._directionY,this.isComplete()&&(this._tx.scale=this._endScale,this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0)}isComplete(){return this._stopped||Math.abs(this._tx.scale.x-this._startScale.x)>=this._distanceX&&Math.abs(this._tx.scale.y-this._startScale.y)>=this._distanceY}stop(){this._motion.scaleFactor.x=0,this._motion.scaleFactor.y=0,this._stopped=!0}reset(){this._started=!1}}class ms{constructor(t){this._method=null,this._hasBeenCalled=!1,this._method=t}update(t){this._method(),this._hasBeenCalled=!0}isComplete(){return this._hasBeenCalled}reset(){this._hasBeenCalled=!1}stop(){this._hasBeenCalled=!0}}class ys{constructor(t,e,i,s,n){this.easingFcn=n,this._currentLerpTime=0,this._lerpDuration=1e3,this._lerpStart=new q(0,0),this._lerpEnd=new q(0,0),this._initialized=!1,this._stopped=!1,this._distance=0,this._tx=t.get(wi),this._motion=t.get(vi),this._lerpDuration=s,this._lerpEnd=new q(e,i)}_initialize(){this._lerpStart=new q(this._tx.pos.x,this._tx.pos.y),this._currentLerpTime=0,this._distance=this._lerpStart.distance(this._lerpEnd)}update(t){this._initialized||(this._initialize(),this._initialized=!0),this._currentLerpTime+=t;let e=this._tx.pos.x,i=this._tx.pos.y;this._currentLerpTime<this._lerpDuration?(e=this._lerpEnd.x<this._lerpStart.x?this._lerpStart.x-(this.easingFcn(this._currentLerpTime,this._lerpEnd.x,this._lerpStart.x,this._lerpDuration)-this._lerpEnd.x):this.easingFcn(this._currentLerpTime,this._lerpStart.x,this._lerpEnd.x,this._lerpDuration),i=this._lerpEnd.y<this._lerpStart.y?this._lerpStart.y-(this.easingFcn(this._currentLerpTime,this._lerpEnd.y,this._lerpStart.y,this._lerpDuration)-this._lerpEnd.y):this.easingFcn(this._currentLerpTime,this._lerpStart.y,this._lerpEnd.y,this._lerpDuration),this._motion.vel=K((e-this._tx.pos.x)/(t/1e3),(i-this._tx.pos.y)/(t/1e3))):(this._tx.pos=K(this._lerpEnd.x,this._lerpEnd.y),this._motion.vel=q.Zero)}isComplete(t){return this._stopped||new q(t.pos.x,t.pos.y).distance(this._lerpStart)>=this._distance}reset(){this._initialized=!1}stop(){this._motion.vel=K(0,0),this._stopped=!0}}class ws{constructor(t,e,i,s=1){this._timeVisible=0,this._timeNotVisible=0,this._elapsedTime=0,this._totalTime=0,this._stopped=!1,this._started=!1,this._graphics=t.get(is),this._timeVisible=e,this._timeNotVisible=i,this._duration=(e+i)*s}update(t){this._started||(this._started=!0),this._graphics&&(this._elapsedTime+=t,this._totalTime+=t,this._graphics.visible&&this._elapsedTime>=this._timeVisible&&(this._graphics.visible=!1,this._elapsedTime=0),!this._graphics.visible&&this._elapsedTime>=this._timeNotVisible&&(this._graphics.visible=!0,this._elapsedTime=0),this.isComplete()&&(this._graphics.visible=!0))}isComplete(){return this._stopped||this._totalTime>=this._duration}stop(){this._graphics&&(this._graphics.visible=!0),this._stopped=!0}reset(){this._started=!1,this._elapsedTime=0,this._totalTime=0}}class vs{constructor(t,e,i){this._multiplier=1,this._started=!1,this._stopped=!1,this._graphics=t.get(is),this._endOpacity=e,this._speed=i}update(t){this._graphics&&(this._started||(this._started=!0,this._endOpacity<this._graphics.opacity?this._multiplier=-1:this._multiplier=1),this._speed>0&&(this._graphics.opacity+=this._multiplier*(Math.abs(this._graphics.opacity-this._endOpacity)*t)/this._speed),this._speed-=t,this.isComplete()&&(this._graphics.opacity=this._endOpacity),_.getInstance().debug("[Action fade] Actor opacity:",this._graphics.opacity))}isComplete(){return this._stopped||Math.abs(this._graphics.opacity-this._endOpacity)<.05}stop(){this._stopped=!0}reset(){this._started=!1}}class xs{constructor(t){this._elapsedTime=0,this._started=!1,this._stopped=!1,this._delay=t}update(t){this._started||(this._started=!0),this._elapsedTime+=t}isComplete(){return this._stopped||this._elapsedTime>=this._delay}stop(){this._stopped=!0}reset(){this._elapsedTime=0,this._started=!1}}class bs{constructor(t){this._stopped=!1,this._entity=t}update(t){this._entity.get(Ps).clearActions(),this._entity.kill(),this._stopped=!0}isComplete(){return this._stopped}stop(){}reset(){}}class Cs{constructor(t,e,i){this._started=!1,this._stopped=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._followTx=e.get(wi),this._followMotion=e.get(vi),this._current=new q(this._tx.pos.x,this._tx.pos.y),this._end=new q(this._followTx.pos.x,this._followTx.pos.y),this._maximumDistance=void 0!==i?i:this._current.distance(this._end),this._speed=0}update(t){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());const e=Math.sqrt(Math.pow(this._followMotion.vel.x,2)+Math.pow(this._followMotion.vel.y,2));if(0!==e&&(this._speed=e),this._current=K(this._tx.pos.x,this._tx.pos.y),this._end=K(this._followTx.pos.x,this._followTx.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize(),this._distanceBetween>=this._maximumDistance){const t=this._dir.scale(this._speed);this._motion.vel=K(t.x,t.y)}else this._motion.vel=K(0,0);this.isComplete()&&(this._tx.pos=K(this._end.x,this._end.y),this._motion.vel=K(0,0))}stop(){this._motion.vel=K(0,0),this._stopped=!0}isComplete(){return this._stopped}reset(){this._started=!1}}class As{constructor(t,e,i){this._started=!1,this._stopped=!1,this._speedWasSpecified=!1,this._tx=t.get(wi),this._motion=t.get(vi),this._meetTx=e.get(wi),this._meetMotion=e.get(vi),this._current=new q(this._tx.pos.x,this._tx.pos.y),this._end=new q(this._meetTx.pos.x,this._meetTx.pos.y),this._speed=i||0,void 0!==i&&(this._speedWasSpecified=!0)}update(t){this._started||(this._started=!0,this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize());const e=Math.sqrt(Math.pow(this._meetMotion.vel.x,2)+Math.pow(this._meetMotion.vel.y,2));0===e||this._speedWasSpecified||(this._speed=e),this._current=K(this._tx.pos.x,this._tx.pos.y),this._end=K(this._meetTx.pos.x,this._meetTx.pos.y),this._distanceBetween=this._current.distance(this._end),this._dir=this._end.sub(this._current).normalize();const i=this._dir.scale(this._speed);this._motion.vel=K(i.x,i.y),this.isComplete()&&(this._tx.pos=K(this._end.x,this._end.y),this._motion.vel=K(0,0))}isComplete(){return this._stopped||this._distanceBetween<=1}stop(){this._motion.vel=K(0,0),this._stopped=!0}reset(){this._started=!1}}class Ss{constructor(t){this._entity=t,this._queue=new hs(t)}getQueue(){return this._queue}update(t){this._queue.update(t)}clearActions(){this._queue.clearActions()}easeTo(...t){var e,i;let s=0,n=0,r=0,o=as.Linear;return t[0]instanceof q?(s=t[0].x,n=t[0].y,r=t[1],o=null!==(e=t[2])&&void 0!==e?e:o):(s=t[0],n=t[1],r=t[2],o=null!==(i=t[3])&&void 0!==i?i:o),this._queue.add(new ys(this._entity,s,n,r,o)),this}moveTo(t,e,i){let s=0,n=0,r=0;return t instanceof q?(s=t.x,n=t.y,r=e):(s=t,n=e,r=i),this._queue.add(new us(this._entity,s,n,r)),this}moveBy(t,e,i){let s=0,n=0,r=0;return t instanceof q?(s=t.x,n=t.y,r=e):(s=t,n=e,r=i),this._queue.add(new ds(this._entity,s,n,r)),this}rotateTo(t,e,i){return this._queue.add(new ps(this._entity,t,e,i)),this}rotateBy(t,e,i){return this._queue.add(new gs(this._entity,t,e,i)),this}scaleTo(t,e,i,s){let n=1,r=1,o=0,a=0;return t instanceof q&&e instanceof q&&(n=t.x,r=t.y,o=e.x,a=e.y),"number"==typeof t&&"number"==typeof e&&(n=t,r=e,o=i,a=s),this._queue.add(new _s(this._entity,n,r,o,a)),this}scaleBy(t,e,i){let s=1,n=1;return t instanceof q&&(s=t.x,n=t.y,i=e),"number"==typeof t&&"number"==typeof e&&(s=t,n=e),this._queue.add(new fs(this._entity,s,n,i)),this}blink(t,e,i=1){return this._queue.add(new ws(this._entity,t,e,i)),this}fade(t,e){return this._queue.add(new vs(this._entity,t,e)),this}delay(t){return this._queue.add(new xs(t)),this}die(){return this._queue.add(new bs(this._entity)),this}callMethod(t){return this._queue.add(new ms(t)),this}repeat(t,e){return e?(this._queue.add(new ls(this._entity,t,e)),this):(this.repeatForever(t),this)}repeatForever(t){return this._queue.add(new cs(this._entity,t)),this}follow(t,e){return void 0===e?this._queue.add(new Cs(this._entity,t)):this._queue.add(new Cs(this._entity,t,e)),this}meet(t,e){return void 0===e?this._queue.add(new As(this._entity,t)):this._queue.add(new As(this._entity,t,e)),this}asPromise(){return this.toPromise()}toPromise(){return new Promise((t=>{this._queue.add(new ms((()=>{t()})))}))}}class Ps extends fi{constructor(){super(...arguments),this.type="ex.actions",this.dependencies=[wi,vi]}onAdd(t){this._ctx=new Ss(t)}onRemove(){this._ctx=null}getQueue(){var t;return null===(t=this._ctx)||void 0===t?void 0:t.getQueue()}update(t){var e;return null===(e=this._ctx)||void 0===e?void 0:e.update(t)}clearActions(){var t;null===(t=this._ctx)||void 0===t||t.clearActions()}easeTo(...t){return this._ctx.easeTo.apply(this._ctx,t)}moveTo(t,e,i){return this._ctx.moveTo.apply(this._ctx,[t,e,i])}moveBy(t,e,i){return this._ctx.moveBy.apply(this._ctx,[t,e,i])}rotateTo(t,e,i){return this._ctx.rotateTo(t,e,i)}rotateBy(t,e,i){return this._ctx.rotateBy(t,e,i)}scaleTo(t,e,i,s){return this._ctx.scaleTo.apply(this._ctx,[t,e,i,s])}scaleBy(t,e,i){return this._ctx.scaleBy.apply(this._ctx,[t,e,i])}blink(t,e,i){return this._ctx.blink(t,e,i)}fade(t,e){return this._ctx.fade(t,e)}delay(t){return this._ctx.delay(t)}die(){return this._ctx.die()}callMethod(t){return this._ctx.callMethod(t)}repeat(t,e){return this._ctx.repeat(t,e)}repeatForever(t){return this._ctx.repeatForever(t)}follow(t,e){return this._ctx.follow(t,e)}meet(t,e){return this._ctx.meet(t,e)}asPromise(){return this.toPromise()}toPromise(){return this._ctx.toPromise()}}var Es=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class Ts extends Qi{constructor(t){super(),this._anchor=xt(q.Half,(t=>this._handleAnchorChange(t))),this.logger=_.getInstance(),this.scene=null,this.frames={},this.currentDrawing=null,this._draggable=!1,this._dragging=!1,this._pointerDragStartHandler=()=>{this._dragging=!0},this._pointerDragEndHandler=()=>{this._dragging=!1},this._pointerDragMoveHandler=t=>{this._dragging&&(this.pos=t.pointer.lastWorldPos)},this._pointerDragLeaveHandler=t=>{this._dragging&&(this.pos=t.pointer.lastWorldPos)},this.traits=[],this.enableCapturePointer=!1,this.capturePointer={captureMoveEvents:!1,captureDragEvents:!1},this._capturePointerEvents=["pointerup","pointerdown","pointermove","pointerenter","pointerleave","pointerdragstart","pointerdragend","pointerdragmove","pointerdragenter","pointerdragleave"],this._captureMoveEvents=["pointermove","pointerenter","pointerleave","pointerdragmove","pointerdragenter","pointerdragleave"],this._captureDragEvents=["pointerdragstart","pointerdragend","pointerdragmove","pointerdragenter","pointerdragleave"];const{name:e,x:i,y:s,pos:n,scale:r,width:o,height:a,radius:h,collider:l,vel:d,acc:u,rotation:g,angularVelocity:f,z:m,color:y,visible:w,anchor:v,collisionType:x,collisionGroup:b}=Object.assign({},t);this._setName(e),this.anchor=null!=v?v:Ts.defaults.anchor.clone(),this.addComponent(new wi),this.pos=null!=n?n:K(null!=i?i:0,null!=s?s:0),this.rotation=null!=g?g:0,this.scale=null!=r?r:K(1,1),this.z=null!=m?m:0,this.addComponent(new is),this.addComponent(new $i(((t,e)=>this.draw(t,e)))),this.addComponent(new vi),this.vel=null!=d?d:q.Zero,this.acc=null!=u?u:q.Zero,this.angularVelocity=null!=f?f:0,this.addComponent(new Ps),this.addComponent(new Vi),this.body.collisionType=null!=x?x:li.Passive,b&&(this.body.group=b),l?this.addComponent(new Wi(l)):h?this.addComponent(new Wi(Hi.Circle(h,this.anchor))):o>0&&a>0?this.addComponent(new Wi(Hi.Box(o,a,this.anchor))):this.addComponent(new Wi),this.graphics.visible=null==w||w,y&&(this.color=y,o&&a?this.graphics.add(new ss({color:y,width:o,height:a})):h&&this.graphics.add(new ns({color:y,radius:h}))),p.isEnabled(c.LegacyDrawing)&&this.traits.push(new ji),this.traits.push(new Xi)}get body(){return this.get(Vi)}get transform(){return this.get(wi)}get motion(){return this.get(vi)}get graphics(){return this.get(is)}get collider(){return this.get(Wi)}get actions(){return this.get(Ps)}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t.clone()}get oldPos(){return this.body.oldPos}set oldPos(t){this.body.oldPos.setTo(t.x,t.y)}get vel(){return this.motion.vel}set vel(t){this.motion.vel=t.clone()}get oldVel(){return this.body.oldVel}set oldVel(t){this.body.oldVel.setTo(t.x,t.y)}get acc(){return this.motion.acc}set acc(t){this.motion.acc=t.clone()}set oldAcc(t){this.body.oldAcc.setTo(t.x,t.y)}get oldAcc(){return this.body.oldAcc}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angularVelocity(){return this.motion.angularVelocity}set angularVelocity(t){this.motion.angularVelocity=t}get scale(){return this.get(wi).scale}set scale(t){this.get(wi).scale=t}get anchor(){return this._anchor}set anchor(t){this._anchor=xt(t,(t=>this._handleAnchorChange(t))),this._handleAnchorChange(t)}_handleAnchorChange(t){this.graphics&&(this.graphics.anchor=t)}get isOffScreen(){return this.hasTag("offscreen")}get visible(){return this.graphics.visible}set visible(t){this.graphics.visible=t}get opacity(){return this.graphics.opacity}set opacity(t){this.graphics.opacity=t}get draggable(){return this._draggable}set draggable(t){t&&(t&&!this._draggable?(this.on("pointerdragstart",this._pointerDragStartHandler),this.on("pointerdragend",this._pointerDragEndHandler),this.on("pointerdragmove",this._pointerDragMoveHandler),this.on("pointerdragleave",this._pointerDragLeaveHandler)):!t&&this._draggable&&(this.off("pointerdragstart",this._pointerDragStartHandler),this.off("pointerdragend",this._pointerDragEndHandler),this.off("pointerdragmove",this._pointerDragMoveHandler),this.off("pointerdragleave",this._pointerDragLeaveHandler)),this._draggable=t)}get color(){return this._color}set color(t){this._color=t.clone()}onInitialize(t){}_initialize(t){super._initialize(t);for(const e of this.children)e._initialize(t)}_checkForPointerOptIn(t){if(t){const e=t.toLowerCase();-1!==this._capturePointerEvents.indexOf(e)&&(this.enableCapturePointer=!0,-1!==this._captureMoveEvents.indexOf(e)&&(this.capturePointer.captureMoveEvents=!0),-1!==this._captureDragEvents.indexOf(e)&&(this.capturePointer.captureDragEvents=!0))}}on(t,e){this._checkForPointerOptIn(t),super.on(t,e)}once(t,e){this._checkForPointerOptIn(t),super.once(t,e)}off(t,e){super.off(t,e)}_prekill(t){super.emit("prekill",new Tt(this)),this.onPreKill(t)}onPreKill(t){}_postkill(t){super.emit("postkill",new Rt(this)),this.onPostKill(t)}onPostKill(t){}kill(){this.scene?(this._prekill(this.scene),this.emit("kill",new Et(this)),super.kill(),this._postkill(this.scene)):this.logger.warn("Cannot kill actor, it was never added to the Scene")}unkill(){this.active=!0}isKilled(){return!this.active}setDrawing(t){t=t.toString(),this.currentDrawing!==this.frames[t]&&(null!=this.frames[t]?(this.frames[t].reset(),this.currentDrawing=this.frames[t]):_.getInstance().error(`the specified drawing key ${t} does not exist`)),this.currentDrawing&&this.currentDrawing instanceof ke&&this.currentDrawing.tick(0)}addDrawing(){2===arguments.length?(this.frames[arguments[0]]=arguments[1],this.currentDrawing||(this.currentDrawing=arguments[1])):(arguments[0]instanceof Ee&&this.addDrawing("default",arguments[0]),arguments[0]instanceof be&&this.addDrawing("default",arguments[0].asSprite()))}get z(){return this.get(wi).z}getZIndex(){return this.get(wi).z}set z(t){this.get(wi).z=t}setZIndex(t){this.get(wi).z=t}get center(){return new q(this.pos.x+this.width/2-this.anchor.x*this.width,this.pos.y+this.height/2-this.anchor.y*this.height)}get width(){return this.collider.localBounds.width*this.getGlobalScale().x}get height(){return this.collider.localBounds.height*this.getGlobalScale().y}getGlobalRotation(){return this.get(wi).globalRotation}getGlobalPos(){return this.get(wi).globalPos}getGlobalScale(){return this.get(wi).globalScale}contains(t,e,i=!1){const s=K(t,e),n=this.get(Wi);n.update();const r=n.get();if(!r)return!1;const o=r.contains(s);return i?o||this.children.some((i=>i.contains(t,e,!0))):o}within(t,e){const i=this.get(Wi),s=t.get(Wi),n=i.get(),r=s.get();return!(!n||!r)&&n.getClosestLineBetween(r).getLength()<=e}update(t,e){this._initialize(t),this._preupdate(t,e);const i=this.currentDrawing;i&&i instanceof ke&&i.tick(e,t.stats.currFrame.id);for(const i of this.traits)i.update(this,t,e);this._postupdate(t,e)}onPreUpdate(t,e){}onPostUpdate(t,e){}_preupdate(t,e){this.emit("preupdate",new It(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new It(t,e,this)),this.onPostUpdate(t,e)}draw(t,e){var i;if(t.save(),this.currentDrawing){t.translate(-this.width*this.anchor.x,-this.height*this.anchor.y),this._predraw(t,e);const i=this.currentDrawing,s=(this.width-i.width*i.scale.x)*this.anchor.x,n=(this.height-i.height*i.scale.y)*this.anchor.y;this.currentDrawing.draw({ctx:t,x:s,y:n,opacity:this.graphics.opacity})}else if(this._predraw(t,e),this.color&&this.collider){const e=this.get(Wi);e.update(),e&&!e.bounds.hasZeroDimensions()&&(t.globalAlpha=this.graphics.opacity,null===(i=e.get())||void 0===i||i.draw(t,this.color,K(0,0)))}t.restore(),this._postdraw(t,e)}onPreDraw(t,e){}onPostDraw(t,e){}_predraw(t,e){this.emit("predraw",new Mt(t,e,this)),this.onPreDraw(t,e)}_postdraw(t,e){this.emit("postdraw",new Mt(t,e,this)),this.onPostDraw(t,e)}debugDraw(t){}}Ts.defaults={anchor:q.Half},Es([j({message:"Actor.visible will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.visible"})],Ts.prototype,"visible",null),Es([j({message:"Actor.opacity will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.opacity"})],Ts.prototype,"opacity",null),Es([j({message:"Actor.setDrawing will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.show() or Actor.graphics.use()"})],Ts.prototype,"setDrawing",null),Es([j({message:"Actor.addDrawing will be removed in v0.26.0",alternateMethod:"Use Actor.graphics.add()"})],Ts.prototype,"addDrawing",null),Es([j({message:"Actor.getZIndex will be removed in v0.26.0",alternateMethod:"Use Actor.transform.z or Actor.z"})],Ts.prototype,"getZIndex",null),Es([j({message:"Actor.setZIndex will be removed in v0.26.0",alternateMethod:"Use Actor.transform.z or Actor.z"})],Ts.prototype,"setZIndex",null);class Rs extends Ts{constructor(t){super(Object.assign({},t)),this.get(wi).coordPlane=yi.Screen,this.traits=[],this.traits.push(new Xi),this.anchor=K(0,0),this.body.collisionType=li.PreventCollision,this.collider.useBoxCollider(this.width,this.height,this.anchor),this.enableCapturePointer=!0}_initialize(t){this._engine=t,super._initialize(t)}contains(t,e,i=!0){if(i)return super.contains(t,e);const s=this._engine.worldToScreenCoordinates(new q(t,e));return super.contains(s.x,s.y)}}var Ds=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class Bs{constructor(t,e,i,s){if(this._logger=_.getInstance(),this.id=0,this._elapsedTime=0,this._totalTimeAlive=0,this._running=!1,this._numberOfTicks=0,this.interval=10,this.repeats=!1,this.maxNumberOfRepeats=-1,this._complete=!1,this.scene=null,"function"!=typeof t){const n=t;t=n.fcn,e=n.interval,i=n.repeats,s=n.numberOfRepeats}if(s&&s>=0&&(this.maxNumberOfRepeats=s,!i))throw new Error("repeats must be set to true if numberOfRepeats is set");this.id=Bs._MAX_ID++,this.interval=e||this.interval,this.repeats=i||this.repeats,this._callbacks=[],t&&this.on(t)}get complete(){return this._complete}on(t){this._callbacks.push(t)}off(t){const e=this._callbacks.indexOf(t);this._callbacks.splice(e,1)}update(t){this._running&&(this._totalTimeAlive+=t,this._elapsedTime+=t,this.maxNumberOfRepeats>-1&&this._numberOfTicks>=this.maxNumberOfRepeats&&(this._complete=!0,this._running=!1,this._elapsedTime=0),!this.complete&&this._elapsedTime>=this.interval&&(this._callbacks.forEach((t=>{t.call(this)})),this._numberOfTicks++,this.repeats||(this._complete=!0,this._running=!1),this._elapsedTime=0))}reset(t,e){if(t&&t>=0&&(this.interval=t),this.maxNumberOfRepeats&&this.maxNumberOfRepeats>=0&&(this.maxNumberOfRepeats=e,!this.repeats))throw new Error("repeats must be set to true if numberOfRepeats is set");this._complete=!1,this._elapsedTime=0,this._numberOfTicks=0}get timesRepeated(){return this._numberOfTicks}getTimeRunning(){return this._totalTimeAlive}get timeToNextAction(){return this.complete?0:this.interval-this._elapsedTime}get timeElapsedTowardNextAction(){return this._elapsedTime}get isRunning(){return this._running}pause(){return this._running=!1,this}unpause(){this._running=!0}resume(){return this._running=!0,this}start(){return this.scene||this._logger.warn("Cannot start a timer not part of a scene, timer wont start until added"),this._running=!0,this.complete&&(this._complete=!1,this._elapsedTime=0,this._numberOfTicks=0),this}stop(){return this._running=!1,this._elapsedTime=0,this._numberOfTicks=0,this}cancel(){this.pause(),this.scene&&this.scene.cancelTimer(this)}}Bs._MAX_ID=0,Ds([j({message:"Will be removed in v0.26.0",alternateMethod:"Use Timer.resume()"})],Bs.prototype,"unpause",null);var Ms,ks=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class Fs extends Qi{constructor(t,e,i,s,n,r){if(super(),this._token=0,this._onScreenXStart=0,this._onScreenXEnd=9999,this._onScreenYStart=0,this._onScreenYEnd=9999,this._spriteSheets={},this._legacySpriteMap=new Map,this.logger=_.getInstance(),this.data=[],this._rows=[],this._cols=[],this.visible=!0,this.isOffscreen=!1,this._dirty=!0,t&&"object"==typeof t){const o=t;t=o.x,e=o.y,i=o.cellWidth,s=o.cellHeight,n=o.rows,r=o.cols}this.addComponent(new wi),this.addComponent(new vi),this.addComponent(new Vi({type:li.Fixed})),this.addComponent(new $i(((t,e)=>this.draw(t,e)))),this.addComponent(new is({onPostDraw:(t,e)=>this.draw(t,e)})),this.addComponent(new Wi),this._transform=this.get(wi),this._motion=this.get(vi),this._collider=this.get(Wi),this._composite=this._collider.useCompositeCollider([]),this.x=t,this.y=e,this.cellWidth=i,this.cellHeight=s,this.rows=n,this.cols=r,this.data=new Array(n*r),this._rows=new Array(n),this._cols=new Array(r);let o=[];for(let a=0;a<r;a++){for(let h=0;h<n;h++){const n=new Os(a*i+t,h*s+e,i,s,a+h*r);n.map=this,this.data[a+h*r]=n,o.push(n),this._rows[h]||(this._rows[h]=[]),this._rows[h].push(n)}this._cols[a]=o,o=[]}this.get(is).localBounds=new J({left:0,top:0,right:this.cols*this.cellWidth,bottom:this.rows*this.cellHeight})}flagDirty(){this._dirty=!0}get x(){var t;return null!==(t=this._transform.pos.x)&&void 0!==t?t:0}set x(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.pos)&&(this.get(wi).pos=K(t,this.y))}get y(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.pos.y)&&void 0!==e?e:0}set y(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.pos)&&(this._transform.pos=K(this.x,t))}get z(){var t;return null!==(t=this._transform.z)&&void 0!==t?t:0}set z(t){this._transform&&(this._transform.z=t)}get rotation(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.rotation)&&void 0!==e?e:0}set rotation(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.rotation)&&(this._transform.rotation=t)}get scale(){var t,e;return null!==(e=null===(t=this._transform)||void 0===t?void 0:t.scale)&&void 0!==e?e:q.One}set scale(t){var e;(null===(e=this._transform)||void 0===e?void 0:e.scale)&&(this._transform.scale=t)}get pos(){return this._transform.pos}set pos(t){this._transform.pos=t}get vel(){return this._motion.vel}set vel(t){this._motion.vel=t}on(t,e){super.on(t,e)}_initialize(t){super._initialize(t)}registerSpriteSheet(t,e){this._spriteSheets[t]=e instanceof Ne?e:Ne.fromLegacySpriteSheet(e)}_updateColliders(){this._composite.clearColliders();const t=[];let e;for(let i=0;i<this.cols;i++){for(let s=0;s<this.rows;s++){0===s&&(e=null);const n=this.data[i+s*this.cols];n.solid?e=e?e.combine(n.bounds):n.bounds:(e&&t.push(e),e=null)}if(e){const i=t[t.length-1];i&&i.top===e.top&&i.bottom===e.bottom?t[t.length-1]=i.combine(e):t.push(e)}}this._composite=this._collider.useCompositeCollider([]);for(const e of t){const t=Hi.Box(e.width,e.height,q.Zero,K(e.left-this.pos.x,e.top-this.pos.y));t.owner=this,this._composite.addCollider(t)}this._collider.update()}getCellByIndex(t){return this.data[t]}getCell(t,e){return t<0||e<0||t>=this.cols||e>=this.rows?null:this.data[t+e*this.cols]}getCellByPoint(t,e){t=Math.floor((t-this.pos.x)/this.cellWidth),e=Math.floor((e-this.pos.y)/this.cellHeight);const i=this.getCell(t,e);return t>=0&&e>=0&&t<this.cols&&e<this.rows&&i?i:null}getRows(){return this._rows}getColumns(){return this._cols}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this.onPreUpdate(t,e),this.emit("preupdate",new It(t,e,this)),this._dirty&&(this._dirty=!1,this._updateColliders()),this._token++;const i=t.getWorldBounds(),s=K(i.left,i.top),n=K(i.right,i.bottom);this._onScreenXStart=Math.max(Math.floor((s.x-this.x)/this.cellWidth)-2,0),this._onScreenYStart=Math.max(Math.floor((s.y-this.y)/this.cellHeight)-2,0),this._onScreenXEnd=Math.max(Math.floor((n.x-this.x)/this.cellWidth)+2,0),this._onScreenYEnd=Math.max(Math.floor((n.y-this.y)/this.cellHeight)+2,0),this._transform.pos=K(this.x,this.y),this.onPostUpdate(t,e),this.emit("postupdate",new Ot(t,e,this))}draw(t,e){this.emit("predraw",new Mt(t,e,this));let i=this._onScreenXStart;const s=Math.min(this._onScreenXEnd,this.cols);let n=this._onScreenYStart;const r=Math.min(this._onScreenYEnd,this.rows);let o,a,h;for(;i<s;i++){for(;n<r;n++)for(o=this.getCell(i,n).graphics,a=0,h=o.length;a<h;a++){const s=o[a];s&&(t instanceof CanvasRenderingContext2D?s instanceof Te&&(this._legacySpriteMap.has(s)||this._legacySpriteMap.set(s,Te.toLegacySprite(s)),this._legacySpriteMap.get(s).draw(t,i*this.cellWidth,n*this.cellHeight)):(Ji(s)&&(null==s||s.tick(e,this._token)),s.draw(t,i*this.cellWidth,n*this.cellHeight)))}n=this._onScreenYStart}this.emit("postdraw",new kt(t,e,this))}}ks([j({message:"No longer used, will be removed in v0.26.0"})],Fs.prototype,"registerSpriteSheet",null);class Ls extends(Ce(Fs)){constructor(t,e,i,s,n,r){super(t,e,i,s,n,r)}}class Is extends Qi{constructor(t,e,i,s,n,r=!1,o=[]){if(super(),this._solid=!1,this.graphics=[],this.data=new Map,t&&"object"==typeof t){const a=t;t=a.x,e=a.y,i=a.width,s=a.height,n=a.index,r=a.solid,o=a.sprites}this.x=t,this.y=e,this.width=i,this.height=s,this.index=n,this.solid=r,this.graphics=o,this._bounds=new J(this.x,this.y,this.x+this.width,this.y+this.height)}get solid(){return this._solid}set solid(t){var e;null===(e=this.map)||void 0===e||e.flagDirty(),this._solid=t}get bounds(){return this._bounds}get center(){return new q(this.x+this.width/2,this.y+this.height/2)}pushSprite(t){this.addGraphic(t)}addGraphic(t){t instanceof Ee?this.graphics.push(Te.fromLegacySprite(t)):this.graphics.push(t)}removeGraphic(t){k(t,this.graphics)}clearGraphics(){this.graphics.length=0}}ks([j({message:"Will be removed in v0.26.0",alternateMethod:"addSprite"})],Is.prototype,"pushSprite",null);class Os extends(Ce(Is)){constructor(t,e,i,s,n,r,o){super(t,e,i,s,n,r,o)}}class zs{constructor(t){this.camera=t}lockToActor(t){this.camera.addStrategy(new Us(t))}lockToActorAxis(t,e){this.camera.addStrategy(new Hs(t,e))}elasticToActor(t,e,i){this.camera.addStrategy(new Ws(t,e,i))}radiusAroundActor(t,e){this.camera.addStrategy(new Ns(t,e))}limitCameraBounds(t){this.camera.addStrategy(new Vs(t))}}!function(t){t[t.X=0]="X",t[t.Y=1]="Y"}(Ms||(Ms={}));class Us{constructor(t){this.target=t,this.action=(t,e,i,s)=>t.center}}class Hs{constructor(t,e){this.target=t,this.axis=e,this.action=(t,e,i,s)=>{const n=t.center,r=e.getFocus();return this.axis===Ms.X?new q(n.x,r.y):new q(r.x,n.y)}}}class Ws{constructor(t,e,i){this.target=t,this.cameraElasticity=e,this.cameraFriction=i,this.action=(t,e,i,s)=>{const n=t.center;let r=e.getFocus(),o=e.vel.clone();const a=n.sub(r).scale(this.cameraElasticity);o=o.add(a);const h=o.scale(-1).scale(this.cameraFriction);return o=o.add(h),r=r.add(o),r}}}class Ns{constructor(t,e){this.target=t,this.radius=e,this.action=(t,e,i,s)=>{const n=t.center,r=e.getFocus(),o=n.sub(r),a=o.size;if(a>=this.radius){const t=a-this.radius;return r.add(o.normalize().scale(t))}return r}}}class Vs{constructor(t){this.target=t,this.boundSizeChecked=!1,this.action=(t,e,i,s)=>{const n=e.getFocus();this.boundSizeChecked||((t.bottom-t.top<i.drawHeight||t.right-t.left<i.drawWidth)&&_.getInstance().warn("Camera bounds should not be smaller than the engine viewport"),this.boundSizeChecked=!0);let r=n.x,o=n.y;return n.x<t.left+i.halfDrawWidth?r=t.left+i.halfDrawWidth:n.x>t.right-i.halfDrawWidth&&(r=t.right-i.halfDrawWidth),n.y<t.top+i.halfDrawHeight?o=t.top+i.halfDrawHeight:n.y>t.bottom-i.halfDrawHeight&&(o=t.bottom-i.halfDrawHeight),K(r,o)}}}class Gs extends $e{constructor(){super(...arguments),this._cameraStrategies=[],this.strategy=new zs(this),this._z=1,this.dz=0,this.az=0,this.rotation=0,this.rx=0,this._posChanged=!1,this._pos=bt(q.Zero,(()=>this._posChanged=!0)),this.vel=q.Zero,this.acc=q.Zero,this._cameraMoving=!1,this._currentLerpTime=0,this._lerpDuration=1e3,this._lerpStart=null,this._lerpEnd=null,this._isShaking=!1,this._shakeMagnitudeX=0,this._shakeMagnitudeY=0,this._shakeDuration=0,this._elapsedShakeTime=0,this._xShake=0,this._yShake=0,this._isZooming=!1,this._zoomStart=1,this._zoomEnd=1,this._currentZoomTime=0,this._zoomDuration=0,this._zoomEasing=as.EaseInOutCubic,this._easing=as.EaseInOutCubic,this._halfWidth=0,this._halfHeight=0,this._viewport=null,this._isInitialized=!1}get zoom(){return this._z}set zoom(t){this._z=t,this._engine&&(this._halfWidth=this._engine.halfDrawWidth,this._halfHeight=this._engine.halfDrawHeight)}get angularVelocity(){return this.rx}set angularVelocity(t){this.rx=t}get pos(){return this._pos}set pos(t){this._pos=bt(t,(()=>this._posChanged=!0)),this._posChanged=!0}get x(){return this.pos.x}set x(t){this._follow||this._cameraMoving||(this.pos=K(t,this.pos.y))}get y(){return this.pos.y}set y(t){this._follow||this._cameraMoving||(this.pos=K(this.pos.x,t))}get dx(){return this.vel.x}set dx(t){this.vel=K(t,this.vel.y)}get dy(){return this.vel.y}set dy(t){this.vel=K(this.vel.x,t)}get ax(){return this.acc.x}set ax(t){this.acc=K(t,this.acc.y)}get ay(){return this.acc.y}set ay(t){this.acc=K(this.acc.x,t)}getFocus(){return this.pos}move(t,e,i=as.EaseInOutCubic){if("function"!=typeof i)throw"Please specify an EasingFunction";return this._follow?Promise.reject(t):(this._lerpPromise&&this._lerpResolve&&this._lerpResolve(t),this._lerpPromise=new Promise((t=>{this._lerpResolve=t})),this._lerpStart=this.getFocus().clone(),this._lerpDuration=e,this._lerpEnd=t,this._currentLerpTime=0,this._cameraMoving=!0,this._easing=i,this._lerpPromise)}shake(t,e,i){this._isShaking=!0,this._shakeMagnitudeX=t,this._shakeMagnitudeY=e,this._shakeDuration=i}zoomOverTime(t,e=0,i=as.EaseInOutCubic){return this._zoomPromise=new Promise((t=>{this._zoomResolve=t})),e?(this._isZooming=!0,this._zoomEasing=i,this._currentZoomTime=0,this._zoomDuration=e,this._zoomStart=this.zoom,this._zoomEnd=t,this._zoomPromise):(this._isZooming=!1,this.zoom=t,Promise.resolve(!0))}get viewport(){return this._viewport?this._viewport:new J(0,0,0,0)}addStrategy(t){this._cameraStrategies.push(t)}removeStrategy(t){k(t,this._cameraStrategies)}clearAllStrategies(){this._cameraStrategies.length=0}_preupdate(t,e){this.emit("preupdate",new It(t,e,this)),this.onPreUpdate(t,e)}onPreUpdate(t,e){}_postupdate(t,e){this.emit("postupdate",new Ot(t,e,this)),this.onPostUpdate(t,e)}onPostUpdate(t,e){}get isInitialized(){return this._isInitialized}_initialize(t){if(!this.isInitialized){this._engine=t;const e=this._engine.screen.resolution;let i=K(e.width/2,e.height/2);if(!this._engine.loadingComplete){const t=this._engine.screen.peekResolution();t&&(i=K(t.width/2,t.height/2))}this._halfWidth=i.x,this._halfHeight=i.x,this._posChanged||(this.pos=i),this.onInitialize(t),super.emit("initialize",new ie(t,this)),this._isInitialized=!0}}onInitialize(t){}on(t,e){super.on(t,e)}off(t,e){super.off(t,e)}once(t,e){super.once(t,e)}update(t,e){if(this._initialize(t),this._preupdate(t,e),this.pos=this.pos.add(this.vel.scale(e/1e3)),this.zoom+=this.dz*e/1e3,this.vel=this.vel.add(this.acc.scale(e/1e3)),this.dz+=this.az*e/1e3,this.rotation+=this.angularVelocity*e/1e3,this._isZooming)if(this._currentZoomTime<this._zoomDuration){const t=(0,this._zoomEasing)(this._currentZoomTime,this._zoomStart,this._zoomEnd,this._zoomDuration);this.zoom=t,this._currentZoomTime+=e}else this._isZooming=!1,this.zoom=this._zoomEnd,this._currentZoomTime=0,this._zoomResolve(!0);if(this._cameraMoving)if(this._currentLerpTime<this._lerpDuration){const t=as.CreateVectorEasingFunction(this._easing)(this._currentLerpTime,this._lerpStart,this._lerpEnd,this._lerpDuration);this.pos=t,this._currentLerpTime+=e}else{this.pos=this._lerpEnd;const t=this._lerpEnd.clone();this._lerpStart=null,this._lerpEnd=null,this._currentLerpTime=0,this._cameraMoving=!1,this._lerpResolve(t)}this._isDoneShaking()?(this._isShaking=!1,this._elapsedShakeTime=0,this._shakeMagnitudeX=0,this._shakeMagnitudeY=0,this._shakeDuration=0,this._xShake=0,this._yShake=0):(this._elapsedShakeTime+=e,this._xShake=1+(Math.random()*this._shakeMagnitudeX|0),this._yShake=1+(Math.random()*this._shakeMagnitudeY|0));for(const i of this._cameraStrategies)this.pos=i.action.call(i,i.target,this,t,e);this._viewport=new J(this.x-this._halfWidth,this.y-this._halfHeight,this.x+this._halfWidth,this.y+this._halfHeight),this._postupdate(t,e)}draw(t){let e=0,i=0;t instanceof CanvasRenderingContext2D?(e=t.canvas.width,i=t.canvas.height):(e=t.width,i=t.height);const s=this.getFocus(),n=this._engine?this._engine.pixelRatio:1,r=this.zoom,o=e/r/n,a=i/r/n;t.scale(r,r),t.translate(-s.x+o/2+this._xShake,-s.y+a/2+this._yShake)}debugDraw(t){}_isDoneShaking(){return!this._isShaking||this._elapsedShakeTime>=this._shakeDuration}}function js(t){return t instanceof Rs}const Xs={pos:q.Zero,width:10,height:10,visible:!1,action:()=>{},filter:()=>!0,repeat:-1};class qs extends Ts{constructor(t){super({x:t.pos.x,y:t.pos.y,width:t.width,height:t.height}),this.action=()=>{},this.filter=()=>!0,this.repeat=-1,t=b({},Xs,t),this.filter=t.filter||this.filter,this.repeat=t.repeat||this.repeat,this.action=t.action||this.action,t.target&&(this.target=t.target),this.graphics.visible=t.visible,this.body.collisionType=li.Passive,this.eventDispatcher=new le(this),this.events.on("collisionstart",(t=>{this.filter(t.other)&&(this.emit("enter",new ae(this,t.other)),this._dispatchAction(),0===this.repeat&&this.kill())})),this.events.on("collisionend",(t=>{this.filter(t.other)&&this.emit("exit",new he(this,t.other))}))}set target(t){this._target=t,this.filter=e=>e===t}get target(){return this._target}_initialize(t){super._initialize(t)}_dispatchAction(){0!==this.repeat&&(this.action.call(this),this.repeat--)}debugDraw(t){super.debugDraw(t),t.save(),t.translate(this.pos.x,this.pos.y);const e=this.collider.bounds,i=this.getGlobalPos();e.left=e.left-i.x,e.right=e.right-i.x,e.top=e.top-i.y,e.bottom=e.bottom-i.y,t.fillStyle=Q.Violet.toString(),t.strokeStyle=Q.Violet.toString(),t.fillText("Trigger",10,10),e.debugDraw(t),t.restore()}}var Ks;!function(t){t.Update="update",t.Draw="draw"}(Ks||(Ks={}));class Zs{constructor(){this.priority=0}notify(t){}}class Ys{constructor(t){this.data=t,this.type="Entity Added"}}function Qs(t){return!!t&&"Entity Added"===t.type}class $s{constructor(t){this.data=t,this.type="Entity Removed"}}function Js(t){return!!t&&"Entity Removed"===t.type}class tn{constructor(t){this._world=t,this.entities=[],this._entityIndex={},this._entitiesToRemove=[]}updateEntities(t,e){for(const i of this.entities)i.update(t.engine,e),i.active||this.removeEntity(i)}findEntitiesForRemoval(){for(const t of this.entities)t.active||this.removeEntity(t)}notify(t){Ki(t)&&this._world.queryManager.addEntity(t.data.entity),Yi(t)&&this._world.queryManager.removeComponent(t.data.entity,t.data.component)}addEntity(t){t.active=!0,t&&!this._entityIndex[t.id]&&(this._entityIndex[t.id]=t,this.entities.push(t),this._world.queryManager.addEntity(t),t.componentAdded$.register(this),t.componentRemoved$.register(this),t.children.forEach((t=>this.addEntity(t))),t.childrenAdded$.register({notify:t=>{this.addEntity(t)}}),t.childrenRemoved$.register({notify:t=>{this.removeEntity(t,!1)}}))}removeEntity(t,e=!0){var i;let s=0;s=t instanceof Qi?t.id:t;const n=this._entityIndex[s];n&&n.active&&n.kill(),n&&e?this._entitiesToRemove.push(n):(delete this._entityIndex[s],n&&(k(n,this.entities),this._world.queryManager.removeEntity(n),n.componentAdded$.unregister(this),n.componentRemoved$.unregister(this),n.children.forEach((t=>this.removeEntity(t,e))),n.childrenAdded$.clear(),n.childrenRemoved$.clear(),(null===(i=this._world.context)||void 0===i?void 0:i.engine)&&this._world.context.engine.stats.currFrame.actors.killed++))}processEntityRemovals(){for(const t of this._entitiesToRemove)t.active||this.removeEntity(t,!1)}processComponentRemovals(){for(const t of this.entities)t.processComponentRemoval()}getById(t){return this._entityIndex[t]}getByName(t){return this.entities.filter((e=>e.name===t))}clear(){for(const t of this.entities)this.removeEntity(t)}}const en=t=>[...t].sort(((t,e)=>t.localeCompare(e))).join("+");class sn extends bi{constructor(t){super(),this._entities=[],t[0]instanceof Function?this.types=t.map((t=>(new t).type)):this.types=t}get key(){return this._key?this._key:this._key=en(this.types)}getEntities(t){return t&&this._entities.sort(t),this._entities}addEntity(t){!F(this._entities,t)&&this.matches(t)&&(this._entities.push(t),this.notifyAll(new Ys(t)))}removeEntity(t){k(t,this._entities)&&this.notifyAll(new $s(t))}clear(){this._entities.length=0;for(const t of this.observers)this.unregister(t)}matches(t){let e=[];e=t instanceof Qi?t.types:t;let i=!0;for(const t of this.types)if(i=i&&e.indexOf(t)>-1,!i)return!1;return i}contain(t){return this.types.indexOf(t)>-1}}class nn{constructor(t){this._world=t,this._queries={}}_addQuery(t){this._queries[en(t.types)]=t;for(const e of this._world.entityManager.entities)t.addEntity(e)}maybeRemoveQuery(t){0===t.observers.length&&(t.clear(),delete this._queries[en(t.types)])}addEntity(t){for(const e in this._queries)this._queries[e]&&this._queries[e].addEntity(t)}removeComponent(t,e){for(const i in this._queries)this._queries[i].contain(e.type)&&this._queries[i].removeEntity(t)}removeEntity(t){for(const e in this._queries)this._queries[e].removeEntity(t)}createQuery(t){const e=this.getQuery(t);if(e)return e;const i=new sn(t);return this._addQuery(i),i}getQuery(t){const e=en(t);return this._queries[e]?this._queries[e]:null}}class rn{constructor(t){this._world=t,this.systems=[],this.initialized=!1}get(t){return this.systems.find((e=>e instanceof t))}addSystem(t){if(!t.types||0===t.types.length)throw new Error("Attempted to add a System without any types");const e=this._world.queryManager.createQuery(t.types);this.systems.push(t),this.systems.sort(((t,e)=>t.priority-e.priority)),e.register(t),this.initialized&&t.initialize&&t.initialize(this._world.context)}removeSystem(t){k(t,this.systems);const e=this._world.queryManager.getQuery(t.types);e&&(e.unregister(t),this._world.queryManager.maybeRemoveQuery(e))}updateSystems(t,e,i){if(!this.initialized){this.initialized=!0;for(const t of this.systems)t.initialize&&t.initialize(this._world.context)}const s=this.systems.filter((e=>e.systemType===t));for(const t of s)t.preupdate&&t.preupdate(e,i);for(const t of s){const s=this._world.queryManager.getQuery(t.types).getEntities(t.sort);if(e instanceof Fn)for(const t of s)t._initialize(null==e?void 0:e.engine);t.update(s,i)}for(const t of s)t.postupdate&&t.postupdate(e,i)}clear(){for(const t of this.systems)this.removeSystem(t)}}class on{constructor(t){this.context=t,this.queryManager=new nn(this),this.entityManager=new tn(this),this.systemManager=new rn(this)}update(t,e){t===Ks.Update&&this.entityManager.updateEntities(this.context,e),this.systemManager.updateSystems(t,this.context,e),this.entityManager.findEntitiesForRemoval(),this.entityManager.processComponentRemovals(),this.entityManager.processEntityRemovals()}add(t){t instanceof Qi&&this.entityManager.addEntity(t),t instanceof Zs&&this.systemManager.addSystem(t)}remove(t,e=!0){t instanceof Qi&&this.entityManager.removeEntity(t,e),t instanceof Zs&&this.systemManager.removeSystem(t)}clearEntities(){this.entityManager.clear()}clearSystems(){this.systemManager.clear()}}class an{static integrate(t,e,i,s){const n=s/1e3;e.vel.addEqual(i.scale(n)),t.pos.addEqual(e.vel.scale(n)).addEqual(i.scale(.5*n*n)),e.angularVelocity+=e.torque*(1/e.inertia)*n,t.rotation+=e.angularVelocity*n,t.scale.addEqual(e.scaleFactor.scale(n))}}class hn extends Zs{constructor(){super(...arguments),this.types=["ex.transform","ex.motion"],this.systemType=Ks.Update,this.priority=-1}update(t,e){let i,s;for(const n of t){i=n.get(wi),s=n.get(vi);const t=n.get(Vi);if(null==t?void 0:t.sleeping)continue;const r=s.acc.clone();(null==t?void 0:t.collisionType)===li.Active&&(null==t?void 0:t.useGravity)&&r.addEqual(gi.gravity),null==t||t.captureOldTransform(),an.integrate(i,s,r,e)}}debugDraw(t){}}class ln{solve(t){return this.preSolve(t),t=t.filter((t=>!t.isCanceled())),this.solveVelocity(t),this.solvePosition(t),this.postSolve(t),t}}class cn extends ln{preSolve(t){for(const e of t){const t=v.fromDirection(e.mtv),i=e.mtv.negate();e.colliderA.events.emit("precollision",new Kt(e.colliderA,e.colliderB,t,i)),e.colliderB.events.emit("precollision",new Kt(e.colliderB,e.colliderA,v.getOpposite(t),i.negate()))}}postSolve(t){var e,i;for(const s of t){const t=s.colliderA,n=s.colliderB,r=null===(e=t.owner)||void 0===e?void 0:e.get(Vi),o=null===(i=n.owner)||void 0===i?void 0:i.get(Vi);if(r&&o&&(r.collisionType===li.Passive||o.collisionType===li.Passive))continue;const a=v.fromDirection(s.mtv),h=s.mtv.negate();s.colliderA.events.emit("postcollision",new Zt(s.colliderA,s.colliderB,a,h)),s.colliderB.events.emit("postcollision",new Zt(s.colliderB,s.colliderA,v.getOpposite(a),h.negate()))}}solvePosition(t){var e,i;for(const s of t){let t=s.mtv;const n=s.colliderA,r=s.colliderB,o=null===(e=n.owner)||void 0===e?void 0:e.get(Vi),a=null===(i=r.owner)||void 0===i?void 0:i.get(Vi);if(o&&a){if(o.collisionType===li.Passive||a.collisionType===li.Passive)continue;o.collisionType===li.Active&&a.collisionType===li.Active&&(t=t.scale(.5)),o.collisionType===li.Active&&(o.pos.x-=t.x,o.pos.y-=t.y),a.collisionType===li.Active&&(a.pos.x+=t.x,a.pos.y+=t.y)}}}solveVelocity(t){var e,i;for(const s of t){const t=s.colliderA,n=s.colliderB,r=null===(e=t.owner)||void 0===e?void 0:e.get(Vi),o=null===(i=n.owner)||void 0===i?void 0:i.get(Vi);if(r&&o){if(r.collisionType===li.Passive||o.collisionType===li.Passive)continue;const t=s.normal,e=t.negate();if(r.collisionType===li.Active){const e=t.scale(t.dot(r.vel.negate()));r.vel=r.vel.add(e)}if(o.collisionType===li.Active){const t=e.scale(e.dot(o.vel.negate()));o.vel=o.vel.add(t)}}}}}class dn{constructor(t,e,i){this.point=t,this.local=e,this.contact=i,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.aToContact=new q(0,0),this.bToContact=new q(0,0),this.update()}update(){var t,e;const i=null===(t=this.contact.colliderA.owner)||void 0===t?void 0:t.get(Vi),s=null===(e=this.contact.colliderB.owner)||void 0===e?void 0:e.get(Vi);if(i&&s){const t=this.contact.normal,e=this.contact.tangent;this.aToContact=this.point.sub(i.pos),this.bToContact=this.point.sub(s.pos);const n=this.aToContact.cross(t),r=this.bToContact.cross(t);this.normalMass=i.inverseMass+s.inverseMass+i.inverseInertia*n*n+s.inverseInertia*r*r;const o=this.aToContact.cross(e),a=this.bToContact.cross(e);this.tangentMass=i.inverseMass+s.inverseMass+i.inverseInertia*o*o+s.inverseInertia*a*a}return this}getRelativeVelocity(){var t,e;const i=null===(t=this.contact.colliderA.owner)||void 0===t?void 0:t.get(Vi),s=null===(e=this.contact.colliderB.owner)||void 0===e?void 0:e.get(Vi);if(i&&s){const t=i.vel.add(q.cross(i.angularVelocity,this.aToContact));return s.vel.add(q.cross(s.angularVelocity,this.bToContact)).sub(t)}return q.Zero}}class un extends ln{constructor(){super(...arguments),this.lastFrameContacts=new Map,this.idToContactConstraint=new Map}getContactConstraints(t){var e;return null!==(e=this.idToContactConstraint.get(t))&&void 0!==e?e:[]}preSolve(t){var e,i,s;for(const e of t){const t=v.fromDirection(e.mtv);e.colliderA.events.emit("precollision",new Kt(e.colliderA,e.colliderB,t,e.mtv)),e.colliderA.events.emit("beforecollisionresolve",new $t(e.colliderA,e.colliderB,t,e.mtv,e)),e.colliderB.events.emit("precollision",new Kt(e.colliderB,e.colliderA,v.getOpposite(t),e.mtv.negate())),e.colliderB.events.emit("beforecollisionresolve",new $t(e.colliderB,e.colliderA,v.getOpposite(t),e.mtv.negate(),e)),e.matchAwake()}const n=Array.from(this.idToContactConstraint.keys());for(const r of t){const t=n.indexOf(r.id);t>-1&&n.splice(t,1);const o=null!==(e=this.idToContactConstraint.get(r.id))&&void 0!==e?e:[];let a=0;const h=r.colliderA.owner.get(Vi),l=r.colliderB.owner.get(Vi);if(h&&l)for(const t of r.points){const e=r.normal,n=r.tangent,c=t.sub(h.pos),d=t.sub(l.pos),u=c.cross(e),p=d.cross(e),g=h.inverseMass+l.inverseMass+h.inverseInertia*u*u+l.inverseInertia*p*p,_=c.cross(n),f=d.cross(n),m=h.inverseMass+l.inverseMass+h.inverseInertia*_*_+l.inverseInertia*f*f;o[a]&&(null===(s=null===(i=o[a])||void 0===i?void 0:i.point)||void 0===s?void 0:s.squareDistance(t))<4?(o[a].point=t,o[a].local=r.localPoints[a]):o[a]=new dn(t,r.localPoints[a],r),o[a].aToContact=c,o[a].bToContact=d,o[a].normalMass=g,o[a].tangentMass=m,a++}this.idToContactConstraint.set(r.id,o)}for(const t of n)this.idToContactConstraint.delete(t);if(gi.warmStart)this.warmStart(t);else for(const e of t){const t=this.getContactConstraints(e.id);for(const e of t)e.normalImpulse=0,e.tangentImpulse=0}}postSolve(t){for(const e of t){const t=e.colliderA.owner.get(Vi),i=e.colliderB.owner.get(Vi);if(t&&i){if(t.collisionType===li.Passive||i.collisionType===li.Passive)continue;t.updateMotion(),i.updateMotion()}const s=v.fromDirection(e.mtv);e.colliderA.events.emit("postcollision",new Zt(e.colliderA,e.colliderB,s,e.mtv)),e.colliderA.events.emit("aftercollisionresolve",new Jt(e.colliderA,e.colliderB,s,e.mtv,e)),e.colliderB.events.emit("postcollision",new Zt(e.colliderB,e.colliderA,v.getOpposite(s),e.mtv.negate())),e.colliderB.events.emit("aftercollisionresolve",new Jt(e.colliderB,e.colliderA,v.getOpposite(s),e.mtv.negate(),e))}this.lastFrameContacts.clear();for(const e of t)this.lastFrameContacts.set(e.id,e)}warmStart(t){var e,i,s;for(const n of t){const t=null===(e=n.colliderA.owner)||void 0===e?void 0:e.get(Vi),r=null===(i=n.colliderB.owner)||void 0===i?void 0:i.get(Vi);if(t&&r){const e=null!==(s=this.idToContactConstraint.get(n.id))&&void 0!==s?s:[];for(const i of e)if(gi.warmStart){const e=n.normal.scale(i.normalImpulse),s=n.tangent.scale(i.tangentImpulse),o=e.add(s);t.applyImpulse(i.point,o.negate()),r.applyImpulse(i.point,o)}else i.normalImpulse=0,i.tangentImpulse=0}}}solvePosition(t){var e,i,s;for(let n=0;n<gi.positionIterations;n++)for(const n of t){const t=null===(e=n.colliderA.owner)||void 0===e?void 0:e.get(Vi),r=null===(i=n.colliderB.owner)||void 0===i?void 0:i.get(Vi);if(t&&r){if(t.collisionType===li.Passive||r.collisionType===li.Passive)continue;const e=null!==(s=this.idToContactConstraint.get(n.id))&&void 0!==s?s:[];for(const i of e){const e=n.normal,s=Oi.FindContactSeparation(n,i.local),o=-5,a=S(gi.steeringFactor*(s+gi.slop),o,0),h=e.scale(-a/i.normalMass);t.collisionType===li.Active&&(t.pos=t.pos.add(h.negate().scale(t.inverseMass)),t.rotation-=i.aToContact.cross(h)*t.inverseInertia),r.collisionType===li.Active&&(r.pos=r.pos.add(h.scale(r.inverseMass)),r.rotation+=i.bToContact.cross(h)*r.inverseInertia)}}}}solveVelocity(t){var e,i,s;for(let n=0;n<gi.velocityIterations;n++)for(const n of t){const t=null===(e=n.colliderA.owner)||void 0===e?void 0:e.get(Vi),r=null===(i=n.colliderB.owner)||void 0===i?void 0:i.get(Vi);if(t&&r){if(t.collisionType===li.Passive||r.collisionType===li.Passive)continue;const e=t.bounciness*r.bounciness,i=Math.min(t.friction,r.friction),o=null!==(s=this.idToContactConstraint.get(n.id))&&void 0!==s?s:[];for(const e of o){let s=-e.getRelativeVelocity().dot(n.tangent)/e.tangentMass;const o=i*e.normalImpulse,a=S(e.tangentImpulse+s,-o,o);s=a-e.tangentImpulse,e.tangentImpulse=a;const h=n.tangent.scale(s);t.applyImpulse(e.point,h.negate()),r.applyImpulse(e.point,h)}for(const i of o){let s=-(1+e)*i.getRelativeVelocity().dot(n.normal)/i.normalMass;const o=Math.max(i.normalImpulse+s,0);s=o-i.normalImpulse,i.normalImpulse=o;const a=n.normal.scale(s);t.applyImpulse(i.point,a.negate()),r.applyImpulse(i.point,a)}}}}}class pn extends Zs{constructor(){super(...arguments),this.types=["ex.transform","ex.motion","ex.collider"],this.systemType=Ks.Update,this.priority=-1,this._realisticSolver=new un,this._arcadeSolver=new cn,this._processor=new Ti,this._lastFrameContacts=new Map,this._currentFrameContacts=new Map,this._trackCollider=t=>this._processor.track(t),this._untrackCollider=t=>this._processor.untrack(t)}notify(t){if(Qs(t)){const e=t.data.get(Wi);e.$colliderAdded.subscribe(this._trackCollider),e.$colliderRemoved.subscribe(this._untrackCollider);const i=e.get();i&&this._processor.track(i)}else{const e=t.data.get(Wi),i=e.get();e&&i&&this._processor.untrack(i)}}initialize(t){this._engine=t.engine}update(t,e){var i;if(!gi.enabled)return;let s=[];for(const e of t){const t=e.get(Wi),n=null==t?void 0:t.get();t&&(null===(i=t.owner)||void 0===i?void 0:i.active)&&n&&(t.update(),n instanceof Di?s=s.concat(n.getColliders()):s.push(n))}this._processor.update(s);const n=this._processor.broadphase(s,e);this._currentFrameContacts.clear();let r=this._processor.narrowphase(n,this._engine.debug.stats.currFrame);r=this.getSolver().solve(r),r.forEach((t=>this._currentFrameContacts.set(t.id,t))),this.runContactStartEnd(),this._lastFrameContacts.clear(),this._lastFrameContacts=new Map(this._currentFrameContacts)}getSolver(){return gi.collisionResolutionStrategy===ci.Realistic?this._realisticSolver:this._arcadeSolver}debug(t){this._processor.debug(t)}runContactStartEnd(){for(const[t,e]of this._currentFrameContacts)if(!this._lastFrameContacts.has(t)){const t=e.colliderA,i=e.colliderB;t.events.emit("collisionstart",new te(t,i,e)),t.events.emit("contactstart",new Yt(t,i,e)),i.events.emit("collisionstart",new te(i,t,e)),i.events.emit("contactstart",new Yt(i,t,e))}for(const[t,e]of this._lastFrameContacts)if(!this._currentFrameContacts.has(t)){const t=e.colliderA,i=e.colliderB;t.events.emit("collisionend",new ee(t,i)),t.events.emit("contactend",new Qt(t,i)),i.events.emit("collisionend",new ee(i,t)),i.events.emit("contactend",new Qt(i,t))}}}var gn,_n,fn;!function(t){t.Forward="forward",t.Backward="backward"}(gn||(gn={})),function(t){t.End="end",t.Loop="loop",t.PingPong="pingpong",t.Freeze="freeze"}(_n||(_n={}));class mn extends vt{constructor(t){var e,i;super(t),this.events=new le(this),this.frames=[],this.strategy=_n.Loop,this.frameDuration=100,this.timeScale=1,this._idempotencyToken=-1,this._firstTick=!0,this._currentFrame=0,this._timeLeftInFrame=0,this._direction=1,this._done=!1,this._playing=!0,this._reversed=!1,this.frames=t.frames,this.strategy=null!==(e=t.strategy)&&void 0!==e?e:this.strategy,this.frameDuration=t.totalDuration?t.totalDuration/this.frames.length:null!==(i=t.frameDuration)&&void 0!==i?i:this.frameDuration,t.reverse&&this.reverse(),this.goToFrame(0)}clone(){return new mn(Object.assign({frames:this.frames.map((t=>Object.assign({},t))),frameDuration:this.frameDuration,reverse:this._reversed,strategy:this.strategy},this.cloneGraphicOptions()))}static fromSpriteSheet(t,e,i,s=_n.Loop){const n=t.sprites.length-1,r=e.filter((t=>t<0||t>n));return r.length&&mn._LOGGER.warn(`Indices into SpriteSheet were provided that don't exist: ${r.join(",")} no frame will be shown`),new mn({frames:t.sprites.filter(((t,i)=>e.indexOf(i)>-1)).map((t=>({graphic:t,duration:i}))),strategy:s})}static toLegacyAnimation(t,e){const i=e.frames.map((t=>Te.toLegacySprite(t.graphic)));return new ke({sprites:i,loop:e.strategy===_n.Loop,freezeFrame:e.strategy===_n.Freeze?i.length-1:void 0,speed:e.frameDuration,engine:t})}get currentFrame(){return this._currentFrame>=0&&this._currentFrame<this.frames.length?this.frames[this._currentFrame]:null}get currentFrameIndex(){return this._currentFrame}get isPlaying(){return this._playing}reverse(){this.frames=this.frames.slice().reverse(),this._reversed=!this._reversed}get direction(){return!(!this._reversed||1!==this._direction)?gn.Backward:gn.Forward}play(){this._playing=!0}pause(){this._playing=!1,this._firstTick=!0}reset(){this._done=!1,this._firstTick=!0,this._currentFrame=0}get canFinish(){switch(this.strategy){case _n.End:case _n.Freeze:return!0;default:return!1}}get done(){return this._done}goToFrame(t){var e,i;this._currentFrame=t,this._timeLeftInFrame=this.frameDuration;const s=this.frames[this._currentFrame];s&&!this._done&&(this._timeLeftInFrame=(null==s?void 0:s.duration)||this.frameDuration,this.width=null===(e=s.graphic)||void 0===e?void 0:e.width,this.height=null===(i=s.graphic)||void 0===i?void 0:i.height,this.events.emit("frame",s))}_nextFrame(){const t=this._currentFrame;if(this._done)return t;let e=-1;switch(this.strategy){case _n.Loop:e=(t+1)%this.frames.length,0===e&&this.events.emit("loop",this);break;case _n.End:e=t+1,e>=this.frames.length&&(this._done=!0,this._currentFrame=this.frames.length,this.events.emit("end",this));break;case _n.Freeze:e=S(t+1,0,this.frames.length-1),e>=this.frames.length-1&&(this._done=!0,this.events.emit("end",this));break;case _n.PingPong:t+this._direction>=this.frames.length&&(this._direction=-1,this.events.emit("loop",this)),t+this._direction<0&&(this._direction=1,this.events.emit("loop",this)),e=t+this._direction%this.frames.length}return e}tick(t,e=0){this._idempotencyToken!==e&&(this._idempotencyToken=e,this._playing&&(this._firstTick&&(this._firstTick=!1,this.events.emit("frame",this.currentFrame)),this._timeLeftInFrame-=t*this.timeScale,this._timeLeftInFrame<=0&&this.goToFrame(this._nextFrame()),this._updateDimensions()))}_updateDimensions(){var t,e;this.currentFrame&&(this.width=null===(t=this.currentFrame.graphic)||void 0===t?void 0:t.width,this.height=null===(e=this.currentFrame.graphic)||void 0===e?void 0:e.height)}_drawImage(t,e,i){this.currentFrame&&this.currentFrame.graphic.draw(t,e,i)}}mn._LOGGER=_.getInstance();class yn extends vt{constructor(t){super(t),this.members=[],this.members=t.members,this._updateDimensions()}clone(){return new yn(Object.assign({members:[...this.members]},this.cloneGraphicOptions()))}_updateDimensions(){let t=new J;for(const{graphic:e,pos:i}of this.members)t=e.localBounds.translate(i).combine(t);return this.width=t.width,this.height=t.height,t}get localBounds(){let t=new J;for(const{graphic:e,pos:i}of this.members)t=e.localBounds.translate(i).combine(t);return t}_isAnimationOrGroup(t){return t instanceof mn||t instanceof yn}tick(t,e){for(const i of this.members){const s=i.graphic;this._isAnimationOrGroup(s)&&s.tick(t,e)}}reset(){for(const t of this.members){const e=t.graphic;this._isAnimationOrGroup(e)&&e.reset()}}_preDraw(t,e,i){this._updateDimensions(),super._preDraw(t,e,i)}_drawImage(t,e,i){for(const s of this.members)t.save(),t.translate(e,i),s.graphic.draw(t,s.pos.x,s.pos.y),this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore()}}!function(t){t[t.Circle=0]="Circle",t[t.Rectangle=1]="Rectangle"}(fn||(fn={}));class wn extends Qi{constructor(t,e,i,s,n,r,o,a,h,l){super(),this.position=new q(0,0),this.velocity=new q(0,0),this.acceleration=new q(0,0),this.particleRotationalVelocity=0,this.currentRotation=0,this.focus=null,this.focusAccel=0,this.opacity=1,this.beginColor=Q.White,this.endColor=Q.White,this.life=300,this.fadeFlag=!1,this._rRate=1,this._gRate=1,this._bRate=1,this._aRate=0,this._currentColor=Q.White,this.emitter=null,this.particleSize=5,this.particleSprite=null,this.sizeRate=0,this.elapsedMultiplier=0,this.visible=!0,this.isOffscreen=!1;let c=t;if(c&&!(t instanceof xn)){const d=t;c=d.emitter,e=d.life,i=d.opacity,n=d.endColor,s=d.beginColor,r=d.position,o=d.velocity,a=d.acceleration,h=d.startSize,l=d.endSize}this.emitter=c,this.life=e||this.life,this.opacity=i||this.opacity,this.endColor=n||this.endColor.clone(),this.beginColor=s||this.beginColor.clone(),this._currentColor=this.beginColor.clone(),this.position=(r||this.position).add(this.emitter.pos),this.velocity=o||this.velocity,this.acceleration=a||this.acceleration,this._rRate=(this.endColor.r-this.beginColor.r)/this.life,this._gRate=(this.endColor.g-this.beginColor.g)/this.life,this._bRate=(this.endColor.b-this.beginColor.b)/this.life,this._aRate=this.opacity/this.life,this.startSize=h||0,this.endSize=l||0,this.endSize>0&&this.startSize>0&&(this.sizeRate=(this.endSize-this.startSize)/this.life,this.particleSize=this.startSize),this.addComponent(this.transform=new wi),this.addComponent(new $i((t=>this.draw(t)))),this.addComponent(this.graphics=new is),this.transform.pos=this.position,this.transform.rotation=this.currentRotation,this.transform.scale=K(1,1),this.particleSprite?(this.graphics.opacity=this.opacity,this.graphics.use(Te.fromLegacySprite(this.particleSprite))):this.graphics.onPostDraw=t=>{t.save(),this.graphics.opacity=this.opacity;const e=this._currentColor.clone();e.a=1,t.debug.drawPoint(K(0,0),{color:e,size:this.particleSize}),t.restore()}}kill(){this.emitter.removeParticle(this)}update(t,e){if(this.life=this.life-e,this.elapsedMultiplier=this.elapsedMultiplier+e,this.life<0&&this.kill(),this.fadeFlag&&(this.opacity=S(this._aRate*this.life,1e-4,1)),this.startSize>0&&this.endSize>0&&(this.particleSize=S(this.sizeRate*e+this.particleSize,Math.min(this.startSize,this.endSize),Math.max(this.startSize,this.endSize))),this._currentColor.r=S(this._currentColor.r+this._rRate*e,0,255),this._currentColor.g=S(this._currentColor.g+this._gRate*e,0,255),this._currentColor.b=S(this._currentColor.b+this._bRate*e,0,255),this._currentColor.a=S(this.opacity,1e-4,1),this.focus){const t=this.focus.sub(this.position).normalize().scale(this.focusAccel).scale(e/1e3);this.velocity=this.velocity.add(t)}else this.velocity=this.velocity.add(this.acceleration.scale(e/1e3));this.position=this.position.add(this.velocity.scale(e/1e3)),this.particleRotationalVelocity&&(this.currentRotation=(this.currentRotation+this.particleRotationalVelocity*e/1e3)%(2*Math.PI)),this.transform.pos=this.position,this.transform.rotation=this.currentRotation,this.transform.scale=K(1,1),this.graphics.opacity=this.opacity}draw(t){if(this.particleSprite)return this.particleSprite.opacity(this.opacity),void this.particleSprite.draw(t,0,0);t.save(),this._currentColor.a=S(this.opacity,1e-4,1),t.fillStyle=this._currentColor.toString(),t.beginPath(),t.arc(0,0,this.particleSize,0,2*Math.PI),t.fill(),t.closePath(),t.restore()}}class vn extends(Ce(wn)){constructor(t,e,i,s,n,r,o,a,h,l){super(t,e,i,s,n,r,o,a,h,l)}}class xn extends Ts{constructor(t){var e,i;super({width:null!==(e=t.width)&&void 0!==e?e:0,height:null!==(i=t.height)&&void 0!==i?i:0}),this._particlesToEmit=0,this.numParticles=0,this.isEmitting=!0,this.particles=[],this.deadParticles=[],this.minVel=0,this.maxVel=0,this.acceleration=new q(0,0),this.minAngle=0,this.maxAngle=0,this.emitRate=1,this.particleLife=2e3,this.fadeFlag=!1,this.focus=null,this.focusAccel=null,this.startSize=null,this.endSize=null,this.minSize=5,this.maxSize=5,this.beginColor=Q.White,this.endColor=Q.White,this._og=null,this._sprite=null,this.emitterType=fn.Rectangle,this.radius=0,this.particleRotationalVelocity=0,this.randomRotation=!1;const{x:s,y:n,pos:r,isEmitting:o,minVel:a,maxVel:h,acceleration:l,minAngle:c,maxAngle:d,emitRate:u,particleLife:p,opacity:g,fadeFlag:_,focus:f,focusAccel:m,startSize:y,endSize:v,minSize:x,maxSize:b,beginColor:C,endColor:A,particleSprite:S,emitterType:P,radius:E,particleRotationalVelocity:T,randomRotation:R,random:D}=Object.assign({},t);this.pos=null!=r?r:K(null!=s?s:0,null!=n?n:0),this.isEmitting=null!=o?o:this.isEmitting,this.minVel=null!=a?a:this.minVel,this.maxVel=null!=h?h:this.maxVel,this.acceleration=null!=l?l:this.acceleration,this.minAngle=null!=c?c:this.minAngle,this.maxAngle=null!=d?d:this.maxAngle,this.emitRate=null!=u?u:this.emitRate,this.particleLife=null!=p?p:this.particleLife,this.opacity=null!=g?g:this.opacity,this.fadeFlag=null!=_?_:this.fadeFlag,this.focus=null!=f?f:this.focus,this.focusAccel=null!=m?m:this.focusAccel,this.startSize=null!=y?y:this.startSize,this.endSize=null!=v?v:this.endSize,this.minSize=null!=x?x:this.minSize,this.maxSize=null!=b?b:this.maxSize,this.beginColor=null!=C?C:this.beginColor,this.endColor=null!=A?A:this.endColor,this.particleSprite=null!=S?S:this.particleSprite,this.emitterType=null!=P?P:this.emitterType,this.radius=null!=E?E:this.radius,this.particleRotationalVelocity=null!=T?T:this.particleRotationalVelocity,this.randomRotation=null!=R?R:this.randomRotation,this.body.collisionType=li.PreventCollision,this.random=null!=D?D:new w;for(let t=0;t<this.traits.length;t++)this.traits[t]instanceof ji&&this.traits.splice(t,1)}get opacity(){return super.graphics.opacity}set opacity(t){super.graphics.opacity=t}get particleSprite(){return this._og}set particleSprite(t){this._og=t,t&&(this._sprite=Te.fromLegacySprite(t))}removeParticle(t){this.deadParticles.push(t)}emitParticles(t){var e;for(let i=0;i<t;i++){const t=this._createParticle();this.particles.push(t),(null===(e=null==this?void 0:this.scene)||void 0===e?void 0:e.world)&&this.scene.world.add(t)}}clearParticles(){this.particles.length=0}_createParticle(){let t=0,e=0;const i=P(this.minAngle,this.maxAngle,this.random),s=P(this.minVel,this.maxVel,this.random),n=this.startSize||P(this.minSize,this.maxSize,this.random),r=s*Math.cos(i),o=s*Math.sin(i);if(this.emitterType===fn.Rectangle)t=P(0,this.width,this.random),e=P(0,this.height,this.random);else if(this.emitterType===fn.Circle){const s=P(0,this.radius,this.random);t=s*Math.cos(i),e=s*Math.sin(i)}const a=new vn(this,this.particleLife,this.opacity,this.beginColor,this.endColor,new q(t,e),new q(r,o),this.acceleration,this.startSize,this.endSize);return a.fadeFlag=this.fadeFlag,a.particleSize=n,this.particleSprite&&(a.particleSprite=this.particleSprite,a.graphics.opacity=this.opacity,a.graphics.use(this._sprite)),a.particleRotationalVelocity=this.particleRotationalVelocity,this.randomRotation&&(a.currentRotation=P(0,2*Math.PI,this.random)),this.focus&&(a.focus=this.focus.add(new q(this.pos.x,this.pos.y)),a.focusAccel=this.focusAccel),a}update(t,e){var i;super.update(t,e),this.isEmitting&&(this._particlesToEmit+=this.emitRate*(e/1e3),this._particlesToEmit>1&&(this.emitParticles(Math.floor(this._particlesToEmit)),this._particlesToEmit=this._particlesToEmit-Math.floor(this._particlesToEmit)));for(let t=0;t<this.deadParticles.length;t++)k(this.deadParticles[t],this.particles),(null===(i=null==this?void 0:this.scene)||void 0===i?void 0:i.world)&&this.scene.world.remove(this.deadParticles[t],!1);this.deadParticles.length=0}draw(t){this.particles.forEach((e=>e.draw(t)))}debugDraw(t){super.debugDraw(t),t.fillStyle=Q.Black.toString(),t.fillText("Particles: "+this.particles.length,this.pos.x,this.pos.y+20),this.focus&&(t.fillRect(this.focus.x+this.pos.x,this.focus.y+this.pos.y,3,3),Je(t,Q.Yellow,this.focus.x+this.pos.x,this.focus.y+this.pos.y,this.center.x,this.center.y),t.fillText("Focus",this.focus.x+this.pos.x,this.focus.y+this.pos.y))}}class bn extends Zs{constructor(){super(...arguments),this.types=["ex.transform","ex.graphics"],this.systemType=Ks.Draw,this.priority=0,this._token=0}initialize(t){this._graphicsContext=t.engine.graphicsContext,this._camera=t.camera,this._engine=t.engine}sort(t,e){return t.get(wi).z-e.get(wi).z}update(t,e){let i,s;this._clearScreen(),this._token++;for(const n of t){i=n.get(wi),s=n.get(is);const t=this._isOffscreen(i,s);if(t&&!n.hasTag("offscreen")&&(n.eventDispatcher.emit("exitviewport",new re(n)),n.addComponent(new mi("offscreen"))),!t&&n.hasTag("offscreen")&&(n.eventDispatcher.emit("enterviewport",new oe(n)),n.removeComponent("offscreen")),t)continue;this._pushCameraTransform(i),this._graphicsContext.save(),s.update(e,this._token),this._applyTransform(n),s.onPreDraw&&s.onPreDraw(this._graphicsContext,e);const r=n instanceof vn?n.opacity:1;this._graphicsContext.opacity=s.opacity*r,this._drawGraphicsComponent(s),s.onPostDraw&&s.onPostDraw(this._graphicsContext,e),this._graphicsContext.restore(),this._popCameraTransform(i)}this._graphicsContext.flush(),this._engine.stats.currFrame.graphics.drawnImages=ot.DrawnImagesCount,this._engine.stats.currFrame.graphics.drawCalls=ot.DrawCallCount}_clearScreen(){this._graphicsContext.clear()}_isOffscreen(t,e){if(t.coordPlane===yi.World){return!this._camera.viewport.intersect(e.localBounds.transform(t.getGlobalMatrix()))}return!1}_drawGraphicsComponent(t){var e,i;if(t.visible)for(const s of t.layers.get())for(const{graphic:n,options:r}of s.graphics){let o=t.anchor,a=t.offset;(null==r?void 0:r.anchor)&&(o=r.anchor),(null==r?void 0:r.offset)&&(a=r.offset);const h=-n.width*o.x+a.x,l=-n.height*o.y+a.y;if(null==n||n.draw(this._graphicsContext,h+s.offset.x,l+s.offset.y),(null===(e=this._engine)||void 0===e?void 0:e.isDebug)&&this._engine.debug.graphics.showBounds){const t=K(h+s.offset.x,l+s.offset.y);if(n instanceof yn)for(const e of n.members)null===(i=e.graphic)||void 0===i||i.localBounds.translate(t.add(e.pos)).draw(this._graphicsContext,this._engine.debug.graphics.boundsColor);else null==n||n.localBounds.translate(t).draw(this._graphicsContext,this._engine.debug.graphics.boundsColor)}}}_applyTransform(t){const e=t.getAncestors();for(const t of e){const e=null==t?void 0:t.get(wi);e&&(this._graphicsContext.translate(e.pos.x,e.pos.y),this._graphicsContext.scale(e.scale.x,e.scale.y),this._graphicsContext.rotate(e.rotation))}}_pushCameraTransform(t){t.coordPlane===yi.World&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext))}_popCameraTransform(t){t.coordPlane===yi.World&&this._graphicsContext.restore()}}class Cn extends Zs{constructor(){super(...arguments),this.types=["ex.transform","ex.canvas"],this.systemType=Ks.Draw,this.priority=-1}initialize(t){this._ctx=t.engine.ctx,this._engine=t.engine,this._camera=t.camera}sort(t,e){return t.get(wi).z-e.get(wi).z}update(t,e){var i,s,n;let r,o;this._clearScreen();const a=t.length;for(let h=0;h<a;h++){const a=null===(n=null===(s=null===(i=t[h])||void 0===i?void 0:i.graphics)||void 0===s?void 0:s.visible)||void 0===n||n,l=t[h].isOffScreen;a&&!l&&(r=t[h].get(wi),o=t[h].get($i),this._ctx.save(),this._pushCameraTransform(r),this._ctx.save(),this._applyTransform(t[h]),o.draw(this._ctx,e),this._ctx.restore(),this._popCameraTransform(r),this._ctx.restore()),this._engine.isDebug&&(this._ctx.save(),this._pushCameraTransform(r),this._ctx.strokeStyle="yellow",t[h].debugDraw(this._ctx),this._popCameraTransform(r),this._ctx.restore())}this._engine.isDebug&&(this._ctx.save(),this._camera.draw(this._ctx),this._camera.debugDraw(this._ctx),this._ctx.restore()),this._engine.stats.currFrame.graphics.drawnImages=ot.DrawnImagesCount,this._engine.stats.currFrame.graphics.drawCalls=ot.DrawCallCount}_applyTransform(t){const e=t.getAncestors();for(const t of e){const e=null==t?void 0:t.get(wi);e&&(this._ctx.translate(e.pos.x,e.pos.y),this._ctx.rotate(e.rotation),this._ctx.scale(e.scale.x,e.scale.y))}}_clearScreen(){this._ctx.clearRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height),this._ctx.fillStyle=this._engine.backgroundColor.toString(),this._ctx.fillRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height)}_pushCameraTransform(t){t.coordPlane===yi.World&&(this._ctx.save(),this._camera&&this._camera.draw(this._ctx))}_popCameraTransform(t){t.coordPlane===yi.World&&this._ctx.restore()}}class An extends Zs{constructor(){super(...arguments),this.types=["ex.transform"],this.systemType=Ks.Draw,this.priority=999}initialize(t){this._graphicsContext=t.engine.graphicsContext,this._camera=t.camera,this._engine=t.engine,this._collisionSystem=t.world.systemManager.get(pn)}update(t,e){var i,s;if(!this._engine.isDebug)return;const n=this._engine.debug.filter;let r,o;const a=this._engine.debug.entity;let h;const l=this._engine.debug.transform;let c;const d=this._engine.debug.motion;let u;const p=this._engine.debug.collider,g=this._engine.debug.physics;let _;const f=this._engine.debug.graphics;let m;const y=this._engine.debug.body,w=this._engine.debug.camera;for(const e of t){if(e.hasTag("offscreen"))continue;if(e instanceof vn)continue;if(n.useFilter){if(!(0===n.ids.length||n.ids.includes(e.id)))continue;if(!(""===n.nameQuery||e.name.includes(n.nameQuery)))continue}let t=q.Zero;const g=K(0,16);if(r=e.id,o=e.name,h=e.get(wi),this._pushCameraTransform(h),this._graphicsContext.save(),this._applyTransform(e),h&&((l.showAll||l.showPosition)&&(this._graphicsContext.debug.drawPoint(q.Zero,{size:2,color:l.positionColor}),this._graphicsContext.debug.drawText(`pos${h.pos.toString(2)}`,t),t=t.add(g)),(a.showAll||a.showId)&&(this._graphicsContext.debug.drawText(`id(${r}) ${h.parent?"child of id("+(null===(s=null===(i=h.parent)||void 0===i?void 0:i.owner)||void 0===s?void 0:s.id)+")":""}`,t),t=t.add(g)),(a.showAll||a.showName)&&(this._graphicsContext.debug.drawText(`name(${o})`,t),t=t.add(g)),(l.showAll||l.showRotation)&&(this._graphicsContext.drawLine(q.Zero,q.fromAngle(h.rotation).scale(50).add(q.Zero),l.rotationColor,2),this._graphicsContext.debug.drawText(`rot deg(${R(h.rotation).toFixed(2)})`,t),t=t.add(g)),(l.showAll||l.showScale)&&this._graphicsContext.drawLine(q.Zero,h.scale.add(q.Zero),l.scaleColor,2)),_=e.get(is),_&&(f.showAll||f.showBounds)){_.localBounds.draw(this._graphicsContext,f.boundsColor)}if(m=e.get(Vi),m&&((y.showAll||y.showCollisionGroup)&&(this._graphicsContext.debug.drawText(`collision group(${m.group.name})`,t),t=t.add(g)),(y.showAll||y.showCollisionType)&&(this._graphicsContext.debug.drawText(`collision type(${m.collisionType})`,t),t=t.add(g)),(y.showAll||y.showMass)&&(this._graphicsContext.debug.drawText(`mass(${m.mass})`,t),t=t.add(g)),(y.showAll||y.showMotion)&&(this._graphicsContext.debug.drawText(`motion(${m.sleepMotion})`,t),t=t.add(g)),(y.showAll||y.showSleeping)&&(this._graphicsContext.debug.drawText(`sleeping(${m.canSleep?m.sleeping:"cant sleep"})`,t),t=t.add(g))),this._graphicsContext.restore(),c=e.get(vi),c&&((d.showAll||d.showVelocity)&&(this._graphicsContext.debug.drawText(`vel${c.vel.toString(2)}`,t.add(h.globalPos)),this._graphicsContext.drawLine(h.globalPos,h.globalPos.add(c.vel),d.velocityColor,2),t=t.add(g)),(d.showAll||d.showAcceleration)&&this._graphicsContext.drawLine(h.globalPos,h.globalPos.add(c.acc),d.accelerationColor,2)),u=e.get(Wi),u){const t=u.get();if((p.showAll||p.showGeometry)&&t&&t.debug(this._graphicsContext,p.geometryColor),p.showAll||p.showBounds)if(t instanceof Di){const e=t.getColliders();for(const t of e){const e=t.bounds,i=K(e.left,e.top);this._graphicsContext.debug.drawRect(i.x,i.y,e.width,e.height,{color:p.boundsColor}),(p.showAll||p.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${t.owner.id})`,i)}u.bounds.draw(this._graphicsContext,p.boundsColor)}else if(t){const t=u.bounds,e=K(t.left,t.top);this._graphicsContext.debug.drawRect(e.x,e.y,t.width,t.height,{color:p.boundsColor}),(p.showAll||p.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${u.owner.id})`,e)}}this._popCameraTransform(h)}if(this._graphicsContext.save(),this._camera.draw(this._graphicsContext),(g.showAll||g.showBroadphaseSpacePartitionDebug)&&this._collisionSystem.debug(this._graphicsContext),g.showAll||g.showCollisionContacts||g.showCollisionNormals)for(const[t,e]of this._engine.debug.stats.currFrame.physics.contacts){if(g.showAll||g.showCollisionContacts)for(const t of e.points)this._graphicsContext.debug.drawPoint(t,{size:5,color:g.collisionContactColor});if(g.showAll||g.showCollisionNormals)for(const t of e.points)this._graphicsContext.debug.drawLine(t,e.normal.scale(30).add(t),{color:g.collisionNormalColor})}this._graphicsContext.restore(),w&&(this._graphicsContext.save(),this._camera.draw(this._graphicsContext),(w.showAll||w.showFocus)&&this._graphicsContext.drawCircle(this._camera.pos,4,w.focusColor),(w.showAll||w.showZoom)&&this._graphicsContext.debug.drawText(`zoom(${this._camera.zoom})`,this._camera.pos),this._graphicsContext.restore()),this._graphicsContext.flush()}_applyTransform(t){const e=t.getAncestors();for(const t of e){const e=null==t?void 0:t.get(wi);e&&(this._graphicsContext.translate(e.pos.x,e.pos.y),this._graphicsContext.scale(e.scale.x,e.scale.y),this._graphicsContext.rotate(e.rotation))}}_pushCameraTransform(t){t.coordPlane===yi.World&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext))}_popCameraTransform(t){t.coordPlane===yi.World&&this._graphicsContext.restore()}}class Sn extends Zs{constructor(){super(...arguments),this.types=["ex.actions"],this.systemType=Ks.Update,this.priority=-1}update(t,e){let i;for(const s of t)i=s.get(Ps),i.update(e)}}var Pn,En,Tn,Rn,Dn,Bn,Mn,kn=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class Fn extends $e{constructor(){super(),this._logger=_.getInstance(),this.camera=new Gs,this.world=new on(this),this._isInitialized=!1,this._timers=[],this._cancelQueue=[],this.world.add(new Sn),this.world.add(new hn),this.world.add(new pn),p.isEnabled(c.LegacyDrawing)?this.world.add(new Cn):this.world.add(new bn),this.world.add(new An)}get actors(){return this.world.entityManager.entities.filter((t=>t instanceof Ts))}get entities(){return this.world.entityManager.entities}get triggers(){return this.world.entityManager.entities.filter((t=>t instanceof qs))}get tileMaps(){return this.world.entityManager.entities.filter((t=>t instanceof Ls))}get screenElements(){return this.actors.filter((t=>t instanceof Rs))}on(t,e){super.on(t,e)}once(t,e){super.once(t,e)}off(t,e){super.off(t,e)}onInitialize(t){}onActivate(t,e){}onDeactivate(t,e){}onPreUpdate(t,e){}onPostUpdate(t,e){}onPreDraw(t,e){}onPostDraw(t,e){}_initializeChildren(){for(const t of this.entities)t._initialize(this.engine)}get isInitialized(){return this._isInitialized}_initialize(t){this.isInitialized||(this.engine=t,this.camera._initialize(t),this.onInitialize.call(this,t),this._initializeChildren(),this._logger.debug("Scene.onInitialize",this,t),this.eventDispatcher.emit("initialize",new ie(t,this)),this._isInitialized=!0)}_activate(t,e){this._logger.debug("Scene.onActivate",this),this.onActivate(t,e)}_deactivate(t,e){this._logger.debug("Scene.onDeactivate",this),this.onDeactivate(t,e)}_preupdate(t,e){this.emit("preupdate",new It(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new Ot(t,e,this)),this.onPostUpdate(t,e)}_predraw(t,e){this.emit("predraw",new Mt(t,e,this)),this.onPreDraw(t,e)}_postdraw(t,e){this.emit("postdraw",new kt(t,e,this)),this.onPostDraw(t,e)}update(t,e){let i,s;for(this._preupdate(t,e),this.camera&&this.camera.update(t,e),i=0,s=this._cancelQueue.length;i<s;i++)this.removeTimer(this._cancelQueue[i]);this._cancelQueue.length=0;for(const t of this._timers)t.update(e);this.world.update(Ks.Update,e),this._collectActorStats(t),t.input.pointers.dispatchPointerEvents(),this._postupdate(t,e)}draw(t,e){var i;this._predraw(t,e),this.world.update(Ks.Draw,e),(null===(i=this.engine)||void 0===i?void 0:i.isDebug)&&this.debugDraw(t),this._postdraw(t,e)}debugDraw(t){this.emit("predebugdraw",new Ft(t,this)),this.emit("postdebugdraw",new Lt(t,this))}contains(t){return this.actors.indexOf(t)>-1}add(t){this.emit("entityadded",{target:t}),this.world.add(t),t.scene=this,t instanceof Bs&&(F(this._timers,t)||this.addTimer(t))}remove(t){t instanceof Qi&&(this.emit("entityremoved",{target:t}),this.world.remove(t)),t instanceof Bs&&this.removeTimer(t)}addScreenElement(t){this.add(t)}removeScreenElement(t){this.remove(t)}addTileMap(t){this.world.add(t)}removeTileMap(t){this.world.remove(t)}addTimer(t){return this._timers.push(t),t.scene=this,t}removeTimer(t){const e=this._timers.indexOf(t);return-1!==e&&this._timers.splice(e,1),t}cancelTimer(t){return this._cancelQueue.push(t),t}isTimerActive(t){return this._timers.indexOf(t)>-1&&!t.complete}isCurrentScene(){return!!this.engine&&this.engine.currentScene===this}_collectActorStats(t){const e=this.actors.filter((t=>t instanceof Rs));for(const i of e)t.stats.currFrame.actors.ui++;for(const e of this.actors){t.stats.currFrame.actors.alive++;for(const i of e.children)js(i)?t.stats.currFrame.actors.ui++:t.stats.currFrame.actors.alive++}}}kn([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"ScreenElements now are normal actors with a Transform Coordinate Plane of Screen"})],Fn.prototype,"screenElements",null),kn([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.add"})],Fn.prototype,"addScreenElement",null),kn([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.remove"})],Fn.prototype,"removeScreenElement",null),kn([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.add"})],Fn.prototype,"addTileMap",null),kn([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Scene.remove"})],Fn.prototype,"removeTileMap",null),function(t){t[t.Protanope=0]="Protanope",t[t.Deuteranope=1]="Deuteranope",t[t.Tritanope=2]="Tritanope"}(Pn||(Pn={}));class Ln{constructor(t,e=!1,i=Pn.Protanope){this.engine=t,this.simulate=e,this.colorMode=i,this._vertexShader="attribute vec2 a_position;attribute vec2 a_texCoord;uniform vec2 u_resolution;varying vec2 v_texCoord;void main() {vec2 zeroToOne = a_position / u_resolution;vec2 zeroToTwo = zeroToOne * 2.0;vec2 clipSpace = zeroToTwo - 1.0;gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);v_texCoord = a_texCoord;}",this._fragmentShader="precision mediump float;uniform sampler2D u_image;varying vec2 v_texCoord;void main() {vec4 o = texture2D(u_image, v_texCoord);float L = (17.8824 * o.r) + (43.5161 * o.g) + (4.11935 * o.b);float M = (3.45565 * o.r) + (27.1554 * o.g) + (3.86714 * o.b);float S = (0.0299566 * o.r) + (0.184309 * o.g) + (1.46709 * o.b);//MODE CODE//vec4 error;error.r = (0.0809444479 * l) + (-0.130504409 * m) + (0.116721066 * s);error.g = (-0.0102485335 * l) + (0.0540193266 * m) + (-0.113614708 * s);error.b = (-0.000365296938 * l) + (-0.00412161469 * m) + (0.693511405 * s);error.a = 1.0;vec4 diff = o - error;vec4 correction;correction.r = 0.0;correction.g = (diff.r * 0.7) + (diff.g * 1.0);correction.b = (diff.r * 0.7) + (diff.b * 1.0);correction = o + correction;correction.a = o.a;//SIMULATE//}",this._internalCanvas=document.createElement("canvas"),this._internalCanvas.width=t.drawWidth,this._internalCanvas.height=t.drawHeight,this._gl=this._internalCanvas.getContext("webgl",{preserveDrawingBuffer:!0}),this._program=this._gl.createProgram();const s=this._getShader("Fragment",this._getFragmentShaderByMode(i)),n=this._getShader("Vertex",this._vertexShader);this._gl.attachShader(this._program,n),this._gl.attachShader(this._program,s),this._gl.linkProgram(this._program),this._gl.getProgramParameter(this._program,this._gl.LINK_STATUS)||_.getInstance().error("Unable to link shader program!"),this._gl.useProgram(this._program)}_getFragmentShaderByMode(t){let e="";return t===Pn.Protanope?e="float l = 0.0 * L + 2.02344 * M + -2.52581 * S;float m = 0.0 * L + 1.0 * M + 0.0 * S;float s = 0.0 * L + 0.0 * M + 1.0 * S;":t===Pn.Deuteranope?e="float l = 1.0 * L + 0.0 * M + 0.0 * S;float m = 0.494207 * L + 0.0 * M + 1.24827 * S;float s = 0.0 * L + 0.0 * M + 1.0 * S;":t===Pn.Tritanope&&(e="float l = 1.0 * L + 0.0 * M + 0.0 * S;float m = 0.0 * L + 1.0 * M + 0.0 * S;float s = -0.395913 * L + 0.801109 * M + 0.0 * S;"),this.simulate?this._fragmentShader=this._fragmentShader.replace("//SIMULATE//","gl_FragColor = error.rgba;"):this._fragmentShader=this._fragmentShader.replace("//SIMULATE//","gl_FragColor = correction.rgba;"),this._fragmentShader.replace("//MODE CODE//",e)}_setRectangle(t,e,i,s){const n=t,r=t+i,o=e,a=e+s;this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array([n,o,r,o,n,a,n,a,r,o,r,a]),this._gl.STATIC_DRAW)}_getShader(t,e){let i;return"Fragment"===t?i=this._gl.createShader(this._gl.FRAGMENT_SHADER):"Vertex"===t?i=this._gl.createShader(this._gl.VERTEX_SHADER):_.getInstance().error("Error unknown shader type",t),this._gl.shaderSource(i,e),this._gl.compileShader(i),this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS)?i:(_.getInstance().error("Unable to compile shader!",this._gl.getShaderInfoLog(i)),null)}process(t,e){const i=this._gl.getAttribLocation(this._program,"a_position"),s=this._gl.getAttribLocation(this._program,"a_texCoord"),n=this._gl.createBuffer();this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n),this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),this._gl.STATIC_DRAW),this._gl.enableVertexAttribArray(s),this._gl.vertexAttribPointer(s,2,this._gl.FLOAT,!1,0,0);const r=this._gl.createTexture();this._gl.bindTexture(this._gl.TEXTURE_2D,r),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),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.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,1),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);const o=this._gl.getUniformLocation(this._program,"u_resolution");this._gl.uniform2f(o,this._internalCanvas.width,this._internalCanvas.height);const a=this._gl.createBuffer();this._gl.bindBuffer(this._gl.ARRAY_BUFFER,a),this._gl.enableVertexAttribArray(i),this._gl.vertexAttribPointer(i,2,this._gl.FLOAT,!1,0,0),this._setRectangle(0,0,t.width,t.height),this._gl.drawArrays(this._gl.TRIANGLES,0,6);const h=new Uint8Array(t.width*t.height*4);this._gl.readPixels(0,0,t.width,t.height,this._gl.RGBA,this._gl.UNSIGNED_BYTE,h),t.data.set(h),e.putImageData(t,0,0)}}class In{constructor(t){this._engine=t}correct(t){this._engine.postProcessors.push(new Ln(this._engine,!1,t))}simulate(t){this._engine.postProcessors.push(new Ln(this._engine,!0,t))}}class On{constructor(t){this.stats={currFrame:new zn,prevFrame:new zn},this.filter={useFilter:!1,nameQuery:"",ids:[]},this.entity={showAll:!1,showId:!0,showName:!1},this.transform={showAll:!1,showPosition:!1,positionColor:Q.Yellow,showScale:!1,scaleColor:Q.Green,showRotation:!1,rotationColor:Q.Blue},this.graphics={showAll:!1,showBounds:!0,boundsColor:Q.Yellow},this.collider={showAll:!1,showBounds:!0,boundsColor:Q.Blue,showOwner:!1,showGeometry:!0,geometryColor:Q.Green},this.physics={showAll:!1,showBroadphaseSpacePartitionDebug:!1,showCollisionNormals:!1,collisionNormalColor:Q.Cyan,showCollisionContacts:!0,collisionContactColor:Q.Red},this.motion={showAll:!1,showVelocity:!1,velocityColor:Q.Yellow,showAcceleration:!1,accelerationColor:Q.Red},this.body={showAll:!1,showCollisionGroup:!1,showCollisionType:!1,showSleeping:!1,showMotion:!1,showMass:!1},this.camera={showAll:!1,showFocus:!1,focusColor:Q.Red,showZoom:!1},this._engine=t,this.colorBlindMode=new In(this._engine)}}class zn{constructor(){this._id=0,this._delta=0,this._fps=0,this._actorStats={alive:0,killed:0,ui:0,get remaining(){return this.alive-this.killed},get total(){return this.remaining+this.ui}},this._durationStats={update:0,draw:0,get total(){return this.update+this.draw}},this._physicsStats=new Un,this._graphicsStats={drawCalls:0,drawnImages:0}}reset(t){t?(this.id=t.id,this.delta=t.delta,this.fps=t.fps,this.actors.alive=t.actors.alive,this.actors.killed=t.actors.killed,this.actors.ui=t.actors.ui,this.duration.update=t.duration.update,this.duration.draw=t.duration.draw,this._physicsStats.reset(t.physics),this.graphics.drawCalls=t.graphics.drawCalls,this.graphics.drawnImages=t.graphics.drawnImages):(this.id=this.delta=this.fps=0,this.actors.alive=this.actors.killed=this.actors.ui=0,this.duration.update=this.duration.draw=0,this._physicsStats.reset(),this.graphics.drawnImages=this.graphics.drawCalls=0)}clone(){const t=new zn;return t.reset(this),t}get id(){return this._id}set id(t){this._id=t}get delta(){return this._delta}set delta(t){this._delta=t}get fps(){return this._fps}set fps(t){this._fps=t}get actors(){return this._actorStats}get duration(){return this._durationStats}get physics(){return this._physicsStats}get graphics(){return this._graphicsStats}}class Un{constructor(){this._pairs=0,this._collisions=0,this._contacts=new Map,this._fastBodies=0,this._fastBodyCollisions=0,this._broadphase=0,this._narrowphase=0}reset(t){t?(this.pairs=t.pairs,this.collisions=t.collisions,this.contacts=t.contacts,this.fastBodies=t.fastBodies,this.fastBodyCollisions=t.fastBodyCollisions,this.broadphase=t.broadphase,this.narrowphase=t.narrowphase):(this.pairs=this.collisions=this.fastBodies=0,this.fastBodyCollisions=this.broadphase=this.narrowphase=0,this.contacts.clear())}clone(){const t=new Un;return t.reset(this),t}get pairs(){return this._pairs}set pairs(t){this._pairs=t}get collisions(){return this._collisions}set collisions(t){this._collisions=t}get contacts(){return this._contacts}set contacts(t){this._contacts=t}get fastBodies(){return this._fastBodies}set fastBodies(t){this._fastBodies=t}get fastBodyCollisions(){return this._fastBodyCollisions}set fastBodyCollisions(t){this._fastBodyCollisions=t}get broadphase(){return this._broadphase}set broadphase(t){this._broadphase=t}get narrowphase(){return this._narrowphase}set narrowphase(t){this._narrowphase=t}}!function(t){t.Num0="Numpad0",t.Num1="Numpad1",t.Num2="Numpad2",t.Num3="Numpad3",t.Num4="Numpad4",t.Num5="Numpad5",t.Num6="Numpad6",t.Num7="Numpad7",t.Num8="Numpad8",t.Num9="Numpad9",t.NumAdd="NumpadAdd",t.NumSubtract="NumpadSubtract",t.NumMultiply="NumpadMultiply",t.NumDivide="NumpadDivide",t.NumDecimal="NumpadDecimal",t.Numpad0="Numpad0",t.Numpad1="Numpad1",t.Numpad2="Numpad2",t.Numpad3="Numpad3",t.Numpad4="Numpad4",t.Numpad5="Numpad5",t.Numpad6="Numpad6",t.Numpad7="Numpad7",t.Numpad8="Numpad8",t.Numpad9="Numpad9",t.NumpadAdd="NumpadAdd",t.NumpadSubtract="NumpadSubtract",t.NumpadMultiply="NumpadMultiply",t.NumpadDivide="NumpadDivide",t.NumpadDecimal="NumpadDecimal",t.NumLock="NumLock",t.ShiftLeft="ShiftLeft",t.ShiftRight="ShiftRight",t.AltLeft="AltLeft",t.AltRight="AltRight",t.Key0="Digit0",t.Key1="Digit1",t.Key2="Digit2",t.Key3="Digit3",t.Key4="Digit4",t.Key5="Digit5",t.Key6="Digit6",t.Key7="Digit7",t.Key8="Digit8",t.Key9="Digit9",t.Digit0="Digit0",t.Digit1="Digit1",t.Digit2="Digit2",t.Digit3="Digit3",t.Digit4="Digit4",t.Digit5="Digit5",t.Digit6="Digit6",t.Digit7="Digit7",t.Digit8="Digit8",t.Digit9="Digit9",t.A="KeyA",t.B="KeyB",t.C="KeyC",t.D="KeyD",t.E="KeyE",t.F="KeyF",t.G="KeyG",t.H="KeyH",t.I="KeyI",t.J="KeyJ",t.K="KeyK",t.L="KeyL",t.M="KeyM",t.N="KeyN",t.O="KeyO",t.P="KeyP",t.Q="KeyQ",t.R="KeyR",t.S="KeyS",t.T="KeyT",t.U="KeyU",t.V="KeyV",t.W="KeyW",t.X="KeyX",t.Y="KeyY",t.Z="KeyZ",t.KeyA="KeyA",t.KeyB="KeyB",t.KeyC="KeyC",t.KeyD="KeyD",t.KeyE="KeyE",t.KeyF="KeyF",t.KeyG="KeyG",t.KeyH="KeyH",t.KeyI="KeyI",t.KeyJ="KeyJ",t.KeyK="KeyK",t.KeyL="KeyL",t.KeyM="KeyM",t.KeyN="KeyN",t.KeyO="KeyO",t.KeyP="KeyP",t.KeyQ="KeyQ",t.KeyR="KeyR",t.KeyS="KeyS",t.KeyT="KeyT",t.KeyU="KeyU",t.KeyV="KeyV",t.KeyW="KeyW",t.KeyX="KeyX",t.KeyY="KeyY",t.KeyZ="KeyZ",t.Semicolon="Semicolon",t.Quote="Quote",t.Comma="Comma",t.Minus="Minus",t.Period="Period",t.Slash="Slash",t.Equal="Equal",t.BracketLeft="BracketLeft",t.Backslash="Backslash",t.BracketRight="BracketRight",t.Backquote="Backquote",t.Up="ArrowUp",t.Down="ArrowDown",t.Left="ArrowLeft",t.Right="ArrowRight",t.ArrowUp="ArrowUp",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.Space="Space",t.Esc="Escape",t.Escape="Escape"}(En||(En={}));class Hn extends Pt{constructor(t,e,i){super(),this.key=t,this.value=e,this.originalEvent=i}}class Wn extends $e{constructor(){super(),this._keys=[],this._keysUp=[],this._keysDown=[]}on(t,e){super.on(t,e)}init(t){if(!t)try{const e=()=>{};window.top.addEventListener("blur",e),window.top.removeEventListener("blur",e),t=window.top}catch(e){t=window,_.getInstance().warn("Failed to bind to keyboard events to top frame. If you are trying to embed Excalibur in a cross-origin iframe, keyboard events will not fire.")}t.addEventListener("blur",(()=>{this._keys.length=0})),t.addEventListener("keyup",(t=>{const e=t.code,i=this._keys.indexOf(e);this._keys.splice(i,1),this._keysUp.push(e);const s=new Hn(e,t.key,t);this.eventDispatcher.emit("up",s),this.eventDispatcher.emit("release",s)})),t.addEventListener("keydown",(t=>{const e=t.code;if(-1===this._keys.indexOf(e)){this._keys.push(e),this._keysDown.push(e);const i=new Hn(e,t.key,t);this.eventDispatcher.emit("down",i),this.eventDispatcher.emit("press",i)}}))}update(){this._keysDown.length=0,this._keysUp.length=0;for(let t=0;t<this._keys.length;t++)this.eventDispatcher.emit("hold",new Hn(this._keys[t]))}getKeys(){return this._keys}wasPressed(t){return this._keysDown.indexOf(t)>-1}isHeld(t){return this._keys.indexOf(t)>-1}wasReleased(t){return this._keysUp.indexOf(t)>-1}}!function(t){t.Touch="Touch",t.Mouse="Mouse",t.Pen="Pen",t.Unknown="Unknown"}(Tn||(Tn={})),function(t){t.Canvas="Canvas",t.Document="Document"}(Rn||(Rn={}));class Nn extends $e{constructor(){super(),this.id=Nn._MAX_ID++,this._isDown=!1,this._wasDown=!1,this._actorsUnderPointer={length:0},this._actors=[],this._actorsLastFrame=[],this._actorsNoLongerUnderPointer=[],this._actorSortingFcn=(t,e)=>t.z===e.z?e.id-t.id:e.z-t.z,this.lastPagePos=null,this.lastScreenPos=null,this.lastWorldPos=null,this.dragTarget=null,this.on("move",this._onPointerMove),this.on("down",this._onPointerDown),this.on("up",this._onPointerUp)}get isDragging(){return this._isDown}get isDragStart(){return!this._wasDown&&this._isDown}get isDragEnd(){return this._wasDown&&!this._isDown}get hasActorsUnderPointer(){return!!this._actorsUnderPointer.length}on(t,e){super.on(t,e)}once(t,e){super.once(t,e)}off(t,e){super.off(t,e)}update(){this._wasDown&&!this._isDown?this._wasDown=!1:!this._wasDown&&this._isDown&&(this._wasDown=!0),this._actorsLastFrame=[...this._actors],this._actorsNoLongerUnderPointer=[]}addActorUnderPointer(t){this.isActorAliveUnderPointer(t)||(this._actorsUnderPointer[t.id]=t,this._actorsUnderPointer.length+=1,this._actors.push(t)),this._actors.sort(this._actorSortingFcn)}removeActorUnderPointer(t){this.isActorAliveUnderPointer(t)&&(delete this._actorsUnderPointer[t.id],this._actorsUnderPointer.length-=1,k(t,this._actors),this._actorsNoLongerUnderPointer.push(t))}getActorsUnderPointer(){return this._actors}getActorsUnderPointerLastFrame(){return this._actorsLastFrame}getActorsForEvents(){return this._actors.concat(this._actorsLastFrame).filter(((t,e,i)=>i.indexOf(t)===e)).sort(this._actorSortingFcn)}checkActorUnderPointer(t){return!!this.lastWorldPos&&t.contains(this.lastWorldPos.x,this.lastWorldPos.y,!js(t))}wasActorUnderPointer(t){return this._actorsLastFrame.indexOf(t)>-1}isActorAliveUnderPointer(t){return!(t.isKilled()||!t.scene||!this._actorsUnderPointer.hasOwnProperty(t.id.toString()))}_onPointerMove(t){this.lastPagePos=new q(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new q(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new q(t.worldPos.x,t.worldPos.y)}_onPointerDown(t){this.lastPagePos=new q(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new q(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new q(t.worldPos.x,t.worldPos.y),this._isDown=!0}_onPointerUp(t){this._isDown=!1,this.dragTarget=null}}Nn._MAX_ID=0,function(t){t[t.NoButton=-1]="NoButton",t[t.Left=0]="Left",t[t.Middle=1]="Middle",t[t.Right=2]="Right",t[t.Unknown=3]="Unknown"}(Dn||(Dn={})),function(t){t.Left="Left",t.Middle="Middle",t.Right="Right",t.Unknown="Unknown",t.NoButton="NoButton"}(Bn||(Bn={})),function(t){t.Pixel="Pixel",t.Line="Line",t.Page="Page"}(Mn||(Mn={}));class Vn extends Pt{constructor(t,e,i,s,n,r){super(),this.coordinates=t,this.pointer=e,this.index=i,this.pointerType=s,this.button=n,this.ev=r,this._canceled=!1}get name(){return this._name}get worldPos(){return this.coordinates.worldPos.clone()}get pagePos(){return this.coordinates.pagePos.clone()}get screenPos(){return this.coordinates.screenPos.clone()}get pos(){return this.coordinates.worldPos.clone()}cancel(){this._canceled=!0}isCanceled(){return this._canceled}propagate(t){this.doAction(t),this.bubbles&&!this.isCanceled()&&t.parent&&this.propagate(t.parent)}doAction(t){t&&(this._onActionStart(t),t.emit(this._name,this),this._onActionEnd(t))}_onActionStart(t){}_onActionEnd(t){}}class Gn{constructor(t){this._pointerEventType=t}create(t,e,i,s,n,r){return new this._pointerEventType(t,e,i,s,n,r)}}class jn extends Vn{}class Xn extends Vn{constructor(){super(...arguments),this._name="pointerup"}_onActionEnd(t){this.pointer.isDragEnd&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragend",this)}}class qn extends Vn{constructor(){super(...arguments),this._name="pointerdown"}_onActionEnd(t){this.pointer.isDragStart&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragstart",this)}}class Kn extends Vn{constructor(){super(...arguments),this._name="pointermove"}propagate(t){this.pointer.isActorAliveUnderPointer(t)&&(this.doAction(t),this.bubbles&&!this.isCanceled()&&t.parent&&this.propagate(t.parent))}_onActionStart(t){t.capturePointer.captureMoveEvents&&this.pointer.isDragging&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragmove",this)}}class Zn extends Vn{constructor(){super(...arguments),this._name="pointerenter"}_onActionStart(t){t.capturePointer.captureMoveEvents}_onActionEnd(t){this.pointer.isDragging&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragenter",this)}}class Yn extends Vn{constructor(){super(...arguments),this._name="pointerleave"}_onActionStart(t){t.capturePointer.captureMoveEvents}_onActionEnd(t){this.pointer.isDragging&&t.capturePointer.captureDragEvents&&t.eventDispatcher.emit("pointerdragleave",this)}}class Qn extends Vn{constructor(){super(...arguments),this._name="pointercancel"}}class $n extends Pt{constructor(t,e,i,s,n,r,o,a,h,l,c,d){super(),this.x=t,this.y=e,this.pageX=i,this.pageY=s,this.screenX=n,this.screenY=r,this.index=o,this.deltaX=a,this.deltaY=h,this.deltaZ=l,this.deltaMode=c,this.ev=d,this._isCanceled=!1}cancel(){this._isCanceled=!0}isCanceled(){return this._isCanceled}}function Jn(t,e,i,s,n,r,o){let a;switch(t){case"up":a=new Gn(Xn);break;case"down":a=new Gn(qn);break;case"move":a=new Gn(Kn);break;case"cancel":a=new Gn(Qn);break;case"enter":a=new Gn(Zn);break;case"leave":a=new Gn(Yn)}return a.create(e,i,s,n,r,o)}class tr{constructor(t,e,i){this.worldPos=t,this.pagePos=e,this.screenPos=i}static fromPagePosition(t,e,i){let s,n,r,o;3===arguments.length?(s=t,n=e,r=new q(s,n),o=i):(r=t,s=r.x,n=r.y,o=e);const a=o.screen.pageToScreenCoordinates(r),h=o.screen.screenToWorldCoordinates(a);return new tr(h,r,a)}}const er=-1/40;class ir extends $e{constructor(t){super(),this._pointerDown=[],this._pointerUp=[],this._pointerMove=[],this._pointerCancel=[],this._wheel=[],this._pointers=[],this._activePointers=[],this._engine=t,this._pointers.push(new Nn),this._activePointers=[-1],this.primary=this._pointers[0]}on(t,e){super.on(t,e)}init(t){(t=t||this._engine.canvas).addEventListener("touchstart",this._handleTouchEvent("down",this._pointerDown)),t.addEventListener("touchend",this._handleTouchEvent("up",this._pointerUp)),t.addEventListener("touchmove",this._handleTouchEvent("move",this._pointerMove)),t.addEventListener("touchcancel",this._handleTouchEvent("cancel",this._pointerCancel)),window.PointerEvent?(this._engine.canvas.style.touchAction="none",t.addEventListener("pointerdown",this._handlePointerEvent("down",this._pointerDown)),t.addEventListener("pointerup",this._handlePointerEvent("up",this._pointerUp)),t.addEventListener("pointermove",this._handlePointerEvent("move",this._pointerMove)),t.addEventListener("pointercancel",this._handlePointerEvent("cancel",this._pointerCancel))):window.MSPointerEvent?(this._engine.canvas.style.msTouchAction="none",t.addEventListener("MSPointerDown",this._handlePointerEvent("down",this._pointerDown)),t.addEventListener("MSPointerUp",this._handlePointerEvent("up",this._pointerUp)),t.addEventListener("MSPointerMove",this._handlePointerEvent("move",this._pointerMove)),t.addEventListener("MSPointerCancel",this._handlePointerEvent("cancel",this._pointerCancel))):(t.addEventListener("mousedown",this._handleMouseEvent("down",this._pointerDown)),t.addEventListener("mouseup",this._handleMouseEvent("up",this._pointerUp)),t.addEventListener("mousemove",this._handleMouseEvent("move",this._pointerMove)));const e={passive:!(this._engine.pageScrollPreventionMode===dr.All||this._engine.pageScrollPreventionMode===dr.Canvas)};"onwheel"in document.createElement("div")?t.addEventListener("wheel",this._handleWheelEvent("wheel",this._wheel),e):void 0!==document.onmousewheel?t.addEventListener("mousewheel",this._handleWheelEvent("wheel",this._wheel),e):t.addEventListener("MozMousePixelScroll",this._handleWheelEvent("wheel",this._wheel),e)}triggerEvent(t,e,i=Dn.Left,s="mouse",n=0){let r,o=0,a=0;e instanceof tr?(o=e.pagePos.x,a=e.pagePos.y,r=e):(o=e.x,a=e.y,r=new tr(e.clone(),e.clone(),e.clone()));const h={pageX:o,pageY:a,pointerId:n,pointerType:s,button:i,preventDefault:()=>{}};switch(t){case"move":this._handlePointerEvent(t,this._pointerMove,r)(h);break;case"down":this._handlePointerEvent(t,this._pointerDown,r)(h);break;case"up":this._handlePointerEvent(t,this._pointerUp,r)(h);break;case"cancel":this._handlePointerEvent(t,this._pointerCancel,r)(h)}for(const t of this._engine.currentScene.actors){const e=t.traits.filter((t=>t instanceof Xi))[0];e&&e.update(t,this._engine,1)}this.dispatchPointerEvents(),this.update()}update(){this._pointerUp.length=0,this._pointerDown.length=0,this._pointerMove.length=0,this._pointerCancel.length=0,this._wheel.length=0;for(let t=0;t<this._pointers.length;t++)this._pointers[t].update()}at(t){if(t>=this._pointers.length)for(let e=this._pointers.length-1,i=t;e<i;e++)this._pointers.push(new Nn),this._activePointers.push(-1);return this._pointers[t]}count(){return this._pointers.length}checkAndUpdateActorUnderPointer(t){for(const e of this._pointers)e.checkActorUnderPointer(t)?e.addActorUnderPointer(t):e.removeActorUnderPointer(t)}_dispatchWithBubble(t){for(const e of t)for(const t of e.pointer.getActorsForEvents())if(e.isCanceled()||e.propagate(t),!e.bubbles||e.isCanceled())break}_dispatchPointerLeaveEvents(){const t={},e=[];for(const i of this._pointerMove)for(const s of i.pointer.getActorsForEvents())if(!t[i.pointer.id+"+"+s.id]&&i.pointer.wasActorUnderPointer(s)&&!i.pointer.isActorAliveUnderPointer(s)&&!i.isCanceled()){t[i.pointer.id+"+"+s.id]=i;const n=Jn("leave",new tr(i.worldPos,i.pagePos,i.screenPos),i.pointer,i.index,i.pointerType,i.button,i.ev);n.propagate(s),e.push(n)}return e}_dispatchPointerEnterEvents(){const t={},e=[];for(const i of this._pointerMove)for(const s of i.pointer.getActorsForEvents())if(!t[i.pointer.id]&&!i.pointer.wasActorUnderPointer(s)&&i.pointer.isActorAliveUnderPointer(s)&&!i.isCanceled()){t[i.pointer.id]=i;const n=Jn("enter",new tr(i.worldPos,i.pagePos,i.screenPos),i.pointer,i.index,i.pointerType,i.button,i.ev);n.propagate(s),e.push(n),i.pointer.isDragging&&(i.pointer.dragTarget=s)}return e}dispatchPointerEvents(){this._dispatchWithBubble(this._pointerDown),this._dispatchWithBubble(this._pointerUp),this._dispatchWithBubble(this._pointerMove),this._dispatchPointerLeaveEvents(),this._dispatchPointerEnterEvents(),this._dispatchWithBubble(this._pointerCancel);for(const t of this._wheel)for(const e of this._pointers[t.index].getActorsUnderPointer())if(this._propagateWheelPointerEvent(e,t),!t.bubbles||t.isCanceled())break}_propagateWheelPointerEvent(t,e){t.emit("pointerwheel",e),e.bubbles&&!e.isCanceled()&&t.parent&&this._propagateWheelPointerEvent(t.parent,e)}_handleMouseEvent(t,e){return i=>{i.preventDefault();const s=this.at(0),n=tr.fromPagePosition(i.pageX,i.pageY,this._engine),r=Jn(t,n,s,0,Tn.Mouse,this._nativeButtonToPointerButton(i.button),i);e.push(r),s.eventDispatcher.emit(t,r)}}_handleTouchEvent(t,e){return i=>{i.preventDefault();for(let s=0,n=i.changedTouches.length;s<n;s++){const n=this._pointers.length>1?this._getPointerIndex(i.changedTouches[s].identifier):0;if(-1===n)continue;const r=this.at(n),o=tr.fromPagePosition(i.changedTouches[s].pageX,i.changedTouches[s].pageY,this._engine),a=Jn(t,o,r,n,Tn.Touch,Bn.Unknown,i);e.push(a),r.eventDispatcher.emit(t,a),this.emit(t,a),this._pointers.length>1&&("up"===t?this._activePointers[n]=-1:"down"===t&&(this._activePointers[n]=i.changedTouches[s].identifier))}}}_handlePointerEvent(t,e,i){return s=>{s.preventDefault();const n=this._pointers.length>1?this._getPointerIndex(s.pointerId):0;if(-1===n)return;const r=this.at(n),o=i||tr.fromPagePosition(s.pageX,s.pageY,this._engine),a=Jn(t,o,r,n,this._stringToPointerType(s.pointerType),this._nativeButtonToPointerButton(s.button),s);e.push(a),r.eventDispatcher.emit(t,a),this.emit(t,a),this._pointers.length>1&&("up"===t?this._activePointers[n]=-1:"down"===t&&(this._activePointers[n]=s.pointerId))}}_handleWheelEvent(t,e){return i=>{(this._engine.pageScrollPreventionMode===dr.All||this._engine.pageScrollPreventionMode===dr.Canvas&&i.target===this._engine.canvas)&&i.preventDefault();const s=this._engine.screen.pageToScreenCoordinates(K(i.pageX,i.pageY)),n=this._engine.screen.screenToWorldCoordinates(s),r=i.deltaX||i.wheelDeltaX*er||0,o=i.deltaY||i.wheelDeltaY*er||i.wheelDelta*er||i.detail||0,a=i.deltaZ||0;let h=Mn.Pixel;i.deltaMode&&(1===i.deltaMode?h=Mn.Line:2===i.deltaMode&&(h=Mn.Page));const l=new $n(n.x,n.y,i.pageX,i.pageY,s.x,s.y,0,r,o,a,h,i);e.push(l),this.at(0).eventDispatcher.emit(t,l),this.emit(t,l)}}_getPointerIndex(t){let e;if((e=this._activePointers.indexOf(t))>-1)return e;for(let t=0;t<this._activePointers.length;t++)if(-1===this._activePointers[t])return t;return-1}_nativeButtonToPointerButton(t){switch(t){case Dn.NoButton:return Bn.NoButton;case Dn.Left:return Bn.Left;case Dn.Middle:return Bn.Middle;case Dn.Right:return Bn.Right;case Dn.Unknown:return Bn.Unknown;default:return z(t)}}_stringToPointerType(t){switch(t){case"touch":return Tn.Touch;case"mouse":return Tn.Mouse;case"pen":return Tn.Pen;default:return Tn.Unknown}}}class sr extends $e{constructor(){super(),this.enabled=!1,this.supported=!!navigator.getGamepads,this._gamePadTimeStamps=[0,0,0,0],this._oldPads=[],this._pads=[],this._initSuccess=!1,this._navigator=navigator,this._minimumConfiguration=null}init(){this.supported&&(this._initSuccess||(this._oldPads=this._clonePads(this._navigator.getGamepads()),this._oldPads.length&&this._oldPads[0]&&(this._initSuccess=!0)))}setMinimumGamepadConfiguration(t){this._enableAndUpdate(),this._minimumConfiguration=t}_enableAndUpdate(){this.enabled||(this.enabled=!0,this.update())}_isGamepadValid(t){if(!this._minimumConfiguration)return!0;if(!t)return!1;const e=t.axes.filter((t=>void 0!==typeof t)).length,i=t.buttons.filter((t=>void 0!==typeof t)).length;return e>=this._minimumConfiguration.axis&&i>=this._minimumConfiguration.buttons&&t.connected}on(t,e){this._enableAndUpdate(),super.on(t,e)}off(t,e){this._enableAndUpdate(),super.off(t,e)}update(){if(!this.enabled||!this.supported)return;this.init();const t=this._navigator.getGamepads();for(let e=0;e<t.length;e++){if(!t[e]){const t=this.at(e);t.connected&&this.eventDispatcher.emit("disconnect",new Wt(e,t)),t.connected=!1;continue}if(!this.at(e).connected&&this._isGamepadValid(t[e])&&this.eventDispatcher.emit("connect",new Ht(e,this.at(e))),this.at(e).connected=!0,t[e].timestamp&&t[e].timestamp===this._gamePadTimeStamps[e])continue;let i,s,n,r,o;for(i in this._gamePadTimeStamps[e]=t[e].timestamp,this.at(e).navigatorGamepad=t[e],rr)s=rr[i],"number"==typeof s&&t[e].buttons[s]&&(o=t[e].buttons[s].value,o!==this._oldPads[e].getButton(s)&&(t[e].buttons[s].pressed?(this.at(e).updateButton(s,o),this.at(e).eventDispatcher.emit("button",new Nt(s,o,this.at(e)))):this.at(e).updateButton(s,0)));for(n in or)r=or[n],"number"==typeof r&&(o=t[e].axes[r],o!==this._oldPads[e].getAxes(r)&&(this.at(e).updateAxes(r,o),this.at(e).eventDispatcher.emit("axis",new Vt(r,o,this.at(e)))));this._oldPads[e]=this._clonePad(t[e])}}at(t){if(this._enableAndUpdate(),t>=this._pads.length)for(let e=this._pads.length-1,i=t;e<i;e++)this._pads.push(new nr),this._oldPads.push(new nr);return this._pads[t]}getValidGamepads(){this._enableAndUpdate();const t=[];for(let e=0;e<this._pads.length;e++)this._isGamepadValid(this.at(e).navigatorGamepad)&&this.at(e).connected&&t.push(this.at(e));return t}count(){return this._pads.filter((t=>t.connected)).length}_clonePads(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(this._clonePad(t[i]));return e}_clonePad(t){let e,i;const s=new nr;if(!t)return s;for(e=0,i=t.buttons.length;e<i;e++)t.buttons[e]&&s.updateButton(e,t.buttons[e].value);for(e=0,i=t.axes.length;e<i;e++)s.updateAxes(e,t.axes[e]);return s}}sr.MinAxisMoveThreshold=.05;class nr extends $e{constructor(){super(),this.connected=!1,this._buttons=new Array(16),this._axes=new Array(4);for(let t=0;t<this._buttons.length;t++)this._buttons[t]=0;for(let t=0;t<this._axes.length;t++)this._axes[t]=0}isButtonPressed(t,e=1){return this._buttons[t]>=e}getButton(t){return this._buttons[t]}getAxes(t){const e=this._axes[t];return Math.abs(e)<sr.MinAxisMoveThreshold?0:e}updateButton(t,e){this._buttons[t]=e}updateAxes(t,e){this._axes[t]=e}}var rr,or;!function(t){t[t.Face1=0]="Face1",t[t.Face2=1]="Face2",t[t.Face3=2]="Face3",t[t.Face4=3]="Face4",t[t.LeftBumper=4]="LeftBumper",t[t.RightBumper=5]="RightBumper",t[t.LeftTrigger=6]="LeftTrigger",t[t.RightTrigger=7]="RightTrigger",t[t.Select=8]="Select",t[t.Start=9]="Start",t[t.LeftStick=10]="LeftStick",t[t.RightStick=11]="RightStick",t[t.DpadUp=12]="DpadUp",t[t.DpadDown=13]="DpadDown",t[t.DpadLeft=14]="DpadLeft",t[t.DpadRight=15]="DpadRight"}(rr||(rr={})),function(t){t[t.LeftStickX=0]="LeftStickX",t[t.LeftStickY=1]="LeftStickY",t[t.RightStickX=2]="RightStickX",t[t.RightStickY=3]="RightStickY"}(or||(or={}));class ar{constructor(t){this.nativeComponent=t,this._paused=!1,this._nativeHandlers={}}on(t,e){this._nativeHandlers[t]&&this.off(t,this._nativeHandlers[t]),this._nativeHandlers[t]=this._decorate(e),this.nativeComponent.addEventListener(t,this._nativeHandlers[t])}off(t,e){e||(e=this._nativeHandlers[t]),this.nativeComponent.removeEventListener(t,e),this._nativeHandlers[t]=null}_decorate(t){return e=>{this._paused||t(e)}}pause(){this._paused=!0}resume(){this._paused=!1}clear(){for(const t in this._nativeHandlers)this.off(t)}}class hr{constructor(t,e){this._windowGlobal=t,this._documentGlobal=e,this._windowComponent=new ar(this._windowGlobal),this._documentComponent=new ar(this._documentGlobal)}get window(){return this._windowComponent}get document(){return this._documentComponent}pause(){this.window.pause(),this.document.pause()}resume(){this.window.resume(),this.document.resume()}clear(){this.window.clear(),this.document.clear()}}class lr{constructor(t){this._ex=t,this._debugText=new Ge}drawRect(t,e,i,s){this._ex.__ctx.save(),this._ex.__ctx.strokeStyle="red",this._ex.__ctx.strokeRect(this._ex.snapToPixel?~~t:t,this._ex.snapToPixel?~~e:e,this._ex.snapToPixel?~~i:i,this._ex.snapToPixel?~~s:s),this._ex.__ctx.restore()}drawLine(t,e,i={color:Q.Black}){this._ex.__ctx.save(),this._ex.__ctx.beginPath(),this._ex.__ctx.strokeStyle=i.color.toString(),this._ex.__ctx.moveTo(this._ex.snapToPixel?~~t.x:t.x,this._ex.snapToPixel?~~t.y:t.y),this._ex.__ctx.lineTo(this._ex.snapToPixel?~~e.x:e.x,this._ex.snapToPixel?~~e.y:e.y),this._ex.__ctx.lineWidth=2,this._ex.__ctx.stroke(),this._ex.__ctx.closePath(),this._ex.__ctx.restore()}drawPoint(t,e={color:Q.Black,size:5}){this._ex.__ctx.save(),this._ex.__ctx.beginPath(),this._ex.__ctx.fillStyle=e.color.toString(),this._ex.__ctx.arc(this._ex.snapToPixel?~~t.x:t.x,this._ex.snapToPixel?~~t.y:t.y,e.size,0,2*Math.PI),this._ex.__ctx.fill(),this._ex.__ctx.closePath(),this._ex.__ctx.restore()}drawText(t,e){this._debugText.write(this._ex,t,e)}}class cr{constructor(t){this.backgroundColor=Q.ExcaliburBlue,this._state=new st,this.snapToPixel=!0,this.debug=new lr(this);const{canvasElement:e,enableTransparency:i,snapToPixel:s,smoothing:n,backgroundColor:r}=t;this.__ctx=e.getContext("2d",{alpha:null==i||i}),this.backgroundColor=null!=r?r:this.backgroundColor,this.snapToPixel=null!=s?s:this.snapToPixel,this.smoothing=null!=n?n:this.smoothing}get width(){return this.__ctx.canvas.width}get height(){return this.__ctx.canvas.height}get opacity(){return this._state.current.opacity}set opacity(t){this._state.current.opacity=t}get smoothing(){return this.__ctx.imageSmoothingEnabled}set smoothing(t){this.__ctx.imageSmoothingEnabled=t}resetTransform(){this.__ctx.resetTransform()}updateViewport(){}drawImage(t,e,i,s,n,r,o,a,h){if(0===s||0===n)return;if(0===a||0===h)return;if(0===t.width||0===t.height)return;this.__ctx.globalAlpha=this.opacity;const l=[t,e,i,s,n,r,o,a,h].filter((t=>void 0!==t)).map((t=>"number"==typeof t&&this.snapToPixel?~~t:t));this.__ctx.drawImage.apply(this.__ctx,l),ot.DrawCallCount++,ot.DrawnImagesCount=1}drawLine(t,e,i,s=1){this.__ctx.save(),this.__ctx.beginPath(),this.__ctx.strokeStyle=i.toString(),this.__ctx.moveTo(this.snapToPixel?~~t.x:t.x,this.snapToPixel?~~t.y:t.y),this.__ctx.lineTo(this.snapToPixel?~~e.x:e.x,this.snapToPixel?~~e.y:e.y),this.__ctx.lineWidth=s,this.__ctx.stroke(),this.__ctx.closePath(),this.__ctx.restore()}drawRectangle(t,e,i,s){this.__ctx.save(),this.__ctx.fillStyle=s.toString(),this.__ctx.fillRect(this.snapToPixel?~~t.x:t.x,this.snapToPixel?~~t.y:t.y,this.snapToPixel?~~e:e,this.snapToPixel?~~i:i),this.__ctx.restore()}drawCircle(t,e,i){this.__ctx.save(),this.__ctx.beginPath(),this.__ctx.fillStyle=i.toString(),this.__ctx.arc(this.snapToPixel?~~t.x:t.x,this.snapToPixel?~~t.y:t.y,e,0,2*Math.PI),this.__ctx.fill(),this.__ctx.closePath(),this.__ctx.restore()}save(){this.__ctx.save()}restore(){this.__ctx.restore()}translate(t,e){this.__ctx.translate(this.snapToPixel?~~t:t,this.snapToPixel?~~e:e)}rotate(t){this.__ctx.rotate(t)}scale(t,e){this.__ctx.scale(t,e)}clear(){this.__ctx.clearRect(0,0,this.width,this.height),this.__ctx.fillStyle=this.backgroundColor.toString(),this.__ctx.fillRect(0,0,this.width,this.height),ot.clear()}flush(){}}var dr,ur=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};u(),function(t){t[t.None=0]="None",t[t.Canvas=1]="Canvas",t[t.All=2]="All"}(dr||(dr={}));class pr extends $e{constructor(t){var e,i,s;super(),this._hasStarted=!1,this.postProcessors=[],this.scenes={},this._animations=[],this._suppressPlayButton=!1,this.pauseAudioWhenHidden=!0,this._isDebug=!1,this.debugColor=new Q(255,255,255),this.enableCanvasTransparency=!0,this.onFatalException=t=>{_.getInstance().fatal(t)},this._timescale=1,this._isLoading=!1,this._isInitialized=!1,this._deferredGoTo=null,this._loadingComplete=!1,t=Object.assign(Object.assign({},pr._DEFAULT_ENGINE_OPTIONS),t),p.freeze(),this.browser=new hr(window,document);const n=new hi;if(!t.suppressMinimumBrowserFeatureDetection&&!(this._compatible=n.test())){const e=document.createElement("div");if(e.innerText="Sorry, your browser does not support all the features needed for Excalibur",document.body.appendChild(e),n.failedTests.forEach((function(t){const e=document.createElement("div");e.innerText="Browser feature missing "+t,document.body.appendChild(e)})),t.canvasElementId){const e=document.getElementById(t.canvasElementId);e&&e.parentElement.removeChild(e)}return}this._compatible=!0,console.log&&!t.suppressConsoleBootMessage&&(console.log(`%cPowered by Excalibur.js (v${Jr})`,"background: #176BAA; color: white; border-radius: 5px; padding: 15px; font-size: 1.5em; line-height: 80px;"),console.log("\n /| ________________\nO|===|* >________________>\n \\|"),console.log("Visit","http://excaliburjs.com","for more information")),t.suppressPlayButton&&(this._suppressPlayButton=!0),this._logger=_.getInstance(),this._logger.defaultLevel===d.Debug&&n.logBrowserFeatures(),this._logger.debug("Building engine..."),this.canvasElementId=t.canvasElementId,t.canvasElementId?(this._logger.debug("Using Canvas element specified: "+t.canvasElementId),this.canvas=document.getElementById(t.canvasElementId)):t.canvasElement?(this._logger.debug("Using Canvas element specified:",t.canvasElement),this.canvas=t.canvasElement):(this._logger.debug("Using generated canvas element"),this.canvas=document.createElement("canvas"));let r=null!==(e=t.displayMode)&&void 0!==e?e:qe.Fixed;if(t.width&&t.height||t.viewport?(void 0===t.displayMode&&(r=qe.Fixed),this._logger.debug("Engine viewport is size "+t.width+" x "+t.height)):t.displayMode||(this._logger.debug("Engine viewport is fit"),r=qe.FitScreen),p.isEnabled(c.Canvas)){const e=new cr({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,smoothing:t.antialiasing,backgroundColor:t.backgroundColor,snapToPixel:t.snapToPixel});this.graphicsContext=e,this.ctx=e.__ctx}else{const e=new Xe({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,smoothing:t.antialiasing,backgroundColor:t.backgroundColor,snapToPixel:t.snapToPixel});this.graphicsContext=e,this.ctx=e.__ctx}this.screen=new Ze({canvas:this.canvas,context:this.graphicsContext,antialiasing:null===(i=t.antialiasing)||void 0===i||i,browser:this.browser,viewport:null!==(s=t.viewport)&&void 0!==s?s:t.width&&t.height?{width:t.width,height:t.height}:Ke.SVGA,resolution:t.resolution,displayMode:r,position:t.position,pixelRatio:t.suppressHiDPIScaling?1:null}),t.backgroundColor&&(this.backgroundColor=t.backgroundColor.clone()),this.enableCanvasTransparency=t.enableCanvasTransparency,this._loader=new oi,this.debug=new On(this),this._initialize(t),this.rootScene=this.currentScene=new Fn,this.addScene("root",this.rootScene)}get canvasWidth(){return this.screen.canvasWidth}get halfCanvasWidth(){return this.screen.halfCanvasWidth}get canvasHeight(){return this.screen.canvasHeight}get halfCanvasHeight(){return this.screen.halfCanvasHeight}get drawWidth(){return this.screen.drawWidth}get halfDrawWidth(){return this.screen.halfDrawWidth}get drawHeight(){return this.screen.drawHeight}get halfDrawHeight(){return this.screen.halfDrawHeight}get isHiDpi(){return this.screen.isHiDpi}get stats(){return this.debug.stats}get isFullscreen(){return this.screen.isFullScreen}get displayMode(){return this.screen.displayMode}get pixelRatio(){return this.screen.pixelRatio}get isDebug(){return this._isDebug}on(t,e){super.on(t,e)}once(t,e){super.once(t,e)}off(t,e){super.off(t,e)}getWorldBounds(){return this.screen.getWorldBounds()}get timescale(){return this._timescale}set timescale(t){t<=0?_.getInstance().error("Cannot set engine.timescale to a value of 0 or less than 0."):this._timescale=t}playAnimation(t,e,i){this._animations.push(new gr(t,e,i))}addTileMap(t){this.currentScene.addTileMap(t)}removeTileMap(t){this.currentScene.removeTileMap(t)}addTimer(t){return this.currentScene.addTimer(t)}removeTimer(t){return this.currentScene.removeTimer(t)}addScene(t,e){this.scenes[t]&&this._logger.warn("Scene",t,"already exists overwriting"),this.scenes[t]=e}removeScene(t){if(t instanceof Fn)for(const e in this.scenes)this.scenes.hasOwnProperty(e)&&this.scenes[e]===t&&delete this.scenes[e];"string"==typeof t&&delete this.scenes[t]}add(t){2!==arguments.length?this._deferredGoTo&&this.scenes[this._deferredGoTo]?this.scenes[this._deferredGoTo].add(t):this.currentScene.add(t):this.addScene(arguments[0],arguments[1])}remove(t){t instanceof Qi&&this.currentScene.remove(t),t instanceof Fn&&this.removeScene(t),"string"==typeof t&&this.removeScene(t)}goToScene(t){if(this.isInitialized)if(this.scenes[t]){const e=this.currentScene,i=this.scenes[t];this._logger.debug("Going to scene:",t),this.currentScene.isInitialized&&(this.currentScene._deactivate.apply(this.currentScene,[e,i]),this.currentScene.eventDispatcher.emit("deactivate",new ne(i,this.currentScene))),this.currentScene=i,this.screen.setCurrentCamera(i.camera),this.currentScene._initialize(this),this.currentScene._activate.apply(this.currentScene,[e,i]),this.currentScene.eventDispatcher.emit("activate",new se(e,this.currentScene))}else this._logger.error("Scene",t,"does not exist!");else this._deferredGoTo=t}screenToWorldCoordinates(t){return this.screen.screenToWorldCoordinates(t)}worldToScreenCoordinates(t){return this.screen.worldToScreenCoordinates(t)}_initialize(t){let e,i;this.pageScrollPreventionMode=t.scrollPreventionMode,this.input={keyboard:new Wn,pointers:new ir(this),gamepads:new sr},this.input.keyboard.init(),this.input.pointers.init(t&&t.pointerScope===Rn.Document?document:this.canvas),this.input.gamepads.init(),void 0!==document.hidden?(e="hidden",i="visibilitychange"):"msHidden"in document?(e="msHidden",i="msvisibilitychange"):"webkitHidden"in document&&(e="webkitHidden",i="webkitvisibilitychange"),this.browser.document.on(i,(()=>{document[e]?(this.eventDispatcher.emit("hidden",new qt(this)),this._logger.debug("Window hidden")):(this.eventDispatcher.emit("visible",new Xt(this)),this._logger.debug("Window visible"))})),this.canvasElementId||t.canvasElement||document.body.appendChild(this.canvas)}onInitialize(t){}setAntialiasing(t){this.screen.antialiasing=t}getAntialiasing(){return this.screen.antialiasing}get isInitialized(){return this._isInitialized}_overrideInitialize(t){this.isInitialized||(this.onInitialize(t),super.emit("initialize",new ie(t,this)),this._isInitialized=!0,this._deferredGoTo?this.goToScene(this._deferredGoTo):this.goToScene("root"))}_update(t){if(this._isLoading)return this._loader.update(this,t),this.input.keyboard.update(),this.input.pointers.update(),void this.input.gamepads.update();this._overrideInitialize(this),this._preupdate(t),this.currentScene.update(this,t),this._animations=this._animations.filter((function(t){return!t.animation.isDone()})),this.input.keyboard.update(),this.input.pointers.update(),this.input.gamepads.update(),this._postupdate(t)}_preupdate(t){this.emit("preupdate",new It(this,t,this)),this.onPreUpdate(this,t)}onPreUpdate(t,e){}_postupdate(t){this.emit("postupdate",new Ot(this,t,this)),this.onPostUpdate(this,t)}onPostUpdate(t,e){}_draw(t){const e=this.ctx;if(this._predraw(e,t),this._isLoading)return this._loader.canvas.draw(this.graphicsContext,0,0),void this.graphicsContext.flush();this.graphicsContext.backgroundColor=this.backgroundColor,this.currentScene.draw(this.ctx,t);let i=0;const s=this._animations.length;for(;i<s;i++)this._animations[i].animation.draw(e,this._animations[i].x,this._animations[i].y);if(this.isDebug){this.ctx.font="Consolas",this.ctx.fillStyle=this.debugColor.toString();const t=this.input.keyboard.getKeys();for(let e=0;e<t.length;e++)this.ctx.fillText(t[e].toString()+" : "+(En[t[e]]?En[t[e]]:"Not Mapped"),100,10*e+10);this.ctx.fillText("FPS:"+this.stats.currFrame.fps.toFixed(2).toString(),10,10)}for(let t=0;t<this.postProcessors.length;t++)this.postProcessors[t].process(this.ctx.getImageData(0,0,this.canvasWidth,this.canvasHeight),this.ctx);this._postdraw(e,t)}_predraw(t,e){this.emit("predraw",new Mt(t,e,this)),this.onPreDraw(t,e)}onPreDraw(t,e){}_postdraw(t,e){this.emit("postdraw",new kt(t,e,this)),this.onPostDraw(t,e)}onPostDraw(t,e){}showDebug(t){this._isDebug=t}toggleDebug(){return this._isDebug=!this._isDebug,this._isDebug}get loadingComplete(){return this._loadingComplete}start(t){if(!this._compatible)return Promise.reject("Excalibur is incompatible with your browser");let e;return this.screen.pushResolutionAndViewport(),this.screen.resolution=this.screen.viewport,this.screen.applyResolutionAndViewport(),this.graphicsContext.updateViewport(),t?(this._loader=t,this._loader.suppressPlayButton=this._suppressPlayButton||this._loader.suppressPlayButton,this._loader.wireEngine(this),e=this.load(this._loader)):e=Promise.resolve(),e.then((()=>{this.screen.popResolutionAndViewport(),this.screen.applyResolutionAndViewport(),this.graphicsContext.updateViewport(),this.emit("start",new Dt(this)),this._loadingComplete=!0})),this._hasStarted||(this._hasStarted=!0,this._logger.debug("Starting game..."),this.browser.resume(),pr.createMainLoop(this,window.requestAnimationFrame,Date.now)(),this._logger.debug("Game started")),e}static createMainLoop(t,e,i){let s=i();return function n(){if(t._hasStarted)try{t._requestId=e(n),t.emit("preframe",new zt(t,t.stats.prevFrame));const r=i();let o=Math.floor(r-s)||1;o>200&&(o=1);const a=o*t.timescale,h=t.stats.prevFrame.id+1;t.stats.currFrame.reset(),t.stats.currFrame.id=h,t.stats.currFrame.delta=a,t.stats.currFrame.fps=1/(a/1e3);const l=i();t._update(a);const c=i();t._draw(a);const d=i();t.stats.currFrame.duration.update=c-l,t.stats.currFrame.duration.draw=d-c,s=r,t.emit("postframe",new Ut(t,t.stats.currFrame)),t.stats.prevFrame.reset(t.stats.currFrame)}catch(e){window.cancelAnimationFrame(t._requestId),t.stop(),t.onFatalException(e)}}}stop(){this._hasStarted&&(this.emit("stop",new Bt(this)),this.browser.pause(),this._hasStarted=!1,this._logger.debug("Game stopped"))}isPaused(){return!this._hasStarted}screenshot(){const t=new Image,e=this.canvas.toDataURL("image/png");return t.src=e,t}load(t){return new Promise((e=>{this._isLoading=!0,t.load().then((()=>{this._suppressPlayButton?setTimeout((()=>{this._isLoading=!1,e()}),500):(this._isLoading=!1,e())}))}))}}pr._DEFAULT_ENGINE_OPTIONS={width:0,height:0,enableCanvasTransparency:!0,canvasElementId:"",canvasElement:void 0,snapToPixel:!1,pointerScope:Rn.Canvas,suppressConsoleBootMessage:null,suppressMinimumBrowserFeatureDetection:null,suppressHiDPIScaling:null,suppressPlayButton:null,scrollPreventionMode:dr.Canvas,backgroundColor:Q.fromHex("#2185d0")},ur([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use Actor.graphics"})],pr.prototype,"playAnimation",null);let gr=class{constructor(t,e,i){this.animation=t,this.x=e,this.y=i}};gr=ur([j({message:"Will be removed in excalibur v0.26.0"})],gr);class _r extends Pt{constructor(t,e="MediaEvent"){super(),this.target=t,this._name=e}set bubbles(t){}get bubbles(){return!1}get _path(){return null}set _path(t){}stopPropagation(){}action(){}propagate(){}layPath(t){}}class fr extends _r{constructor(t,e){super(t,"NativeSoundEvent"),this.track=e}}class mr extends _r{constructor(t,e){super(t,"NativeSoundProcessedEvent"),this._processedData=e,this.data=this._processedData}}class yr extends Ct{constructor(t={}){var e,i,s,n,r,o,a,h,l,c,d,u;super(t),this.quality=2,this.family="sans-serif",this.style=Oe.Normal,this.bold=!1,this.unit=Fe.Px,this.textAlign=Le.Left,this.baseAlign=Ie.Alphabetic,this.direction=ze.LeftToRight,this.size=10,this.shadow=null,this._textBounds=new J,this._textWidth=0,this._textHeight=0,this.family=null!==(e=null==t?void 0:t.family)&&void 0!==e?e:this.family,this.style=null!==(i=null==t?void 0:t.style)&&void 0!==i?i:this.style,this.bold=null!==(s=null==t?void 0:t.bold)&&void 0!==s?s:this.bold,this.size=null!==(n=null==t?void 0:t.size)&&void 0!==n?n:this.size,this.unit=null!==(r=null==t?void 0:t.unit)&&void 0!==r?r:this.unit,this.textAlign=null!==(o=null==t?void 0:t.textAlign)&&void 0!==o?o:this.textAlign,this.baseAlign=null!==(a=null==t?void 0:t.baseAlign)&&void 0!==a?a:this.baseAlign,this.direction=null!==(h=null==t?void 0:t.direction)&&void 0!==h?h:this.direction,this.quality=null!==(l=null==t?void 0:t.quality)&&void 0!==l?l:this.quality,(null==t?void 0:t.shadow)&&(this.shadow={},this.shadow.blur=null!==(c=t.shadow.blur)&&void 0!==c?c:this.shadow.blur,this.shadow.offset=null!==(d=t.shadow.offset)&&void 0!==d?d:this.shadow.offset,this.shadow.color=null!==(u=t.shadow.color)&&void 0!==u?u:this.shadow.color),this.flagDirty()}clone(){return new yr(Object.assign(Object.assign(Object.assign({},this.cloneGraphicOptions()),this.cloneRasterOptions()),{size:this.size,unit:this.unit,family:this.family,style:this.style,bold:this.bold,textAlign:this.textAlign,baseAlign:this.baseAlign,direction:this.direction,shadow:this.shadow?{blur:this.shadow.blur,offset:this.shadow.offset,color:this.shadow.color}:null}))}get fontString(){return`${this.style} ${this.bold?"bold":""} ${this.size}${this.unit} ${this.family}`}get width(){return this._textWidth}set width(t){this._textWidth=t}get height(){var t,e;const i=null!==(e=null===(t=this._lines)||void 0===t?void 0:t.length)&&void 0!==e?e:1;return this._textHeight*i}set height(t){var e,i;const s=null!==(i=null===(e=this._lines)||void 0===e?void 0:e.length)&&void 0!==i?i:1;this._textHeight=t/s}get _rasterWidth(){return this._bitmap.width}get _rasterHeight(){return this._bitmap.height}get _halfRasterWidth(){return Math.floor(this._bitmap.width/2)}get _halfRasterHeight(){return Math.floor(this._bitmap.height/2)}get localBounds(){return this._textBounds}_drawImage(t,e,i){this.dirty&&this.rasterize(),t.drawImage(this._bitmap,0,0,this._rasterWidth,this._rasterHeight,e-this._rasterWidth/this.quality/2,i-this._rasterHeight/this.quality/2,this._rasterWidth/this.quality,this._rasterHeight/this.quality)}_rotate(t){var e;const i=null!==(e=this.origin)&&void 0!==e?e:this._textBounds.center;t.translate(i.x,i.y),t.rotate(this.rotation),t.translate(-i.x,-i.y)}_flip(t){this.flipHorizontal&&(t.translate(this._textBounds.width/this.scale.x,0),t.scale(-1,1)),this.flipVertical&&(t.translate(0,-this._textBounds.height/2/this.scale.y),t.scale(1,-1))}updateText(t){this._text!==t&&(this._text=t,this._lines=this._text.split("\n"),this._updateDimensions(),this.flagDirty())}_updateDimensions(){if(this._text){this._applyFont(this._ctx);const t=this._lines.reduce(((t,e)=>t.length>e.length?t:e)),e=this._ctx.measureText(t);this._textWidth=Math.abs(e.actualBoundingBoxLeft)+Math.abs(e.actualBoundingBoxRight),this._textHeight=Math.abs(e.actualBoundingBoxAscent)+Math.abs(e.actualBoundingBoxDescent);const i=this._textHeight*this._lines.length;this._bitmap.width=2*(this._textWidth+2*this.padding)*this.quality,this._bitmap.height=2*(i+2*this.padding)*this.quality;const s=0,n=0,r=i-Math.abs(e.actualBoundingBoxAscent);this._textBounds=new J({left:s-Math.abs(e.actualBoundingBoxLeft)-this.padding,top:n-Math.abs(e.actualBoundingBoxAscent)-this.padding,bottom:n+r+this.padding,right:s+Math.abs(e.actualBoundingBoxRight)+this.padding})}}_preDraw(t,e,i){this.dirty&&this._updateDimensions(),super._preDraw(t,e,i)}_postDraw(t){this.showDebug&&t.debug.drawRect(-this._halfRasterWidth,-this._halfRasterHeight,this._rasterWidth,this._rasterHeight),t.restore()}_applyFont(t){t.translate(this.padding+this._halfRasterWidth,this.padding+this._halfRasterHeight),t.scale(this.quality,this.quality),t.textAlign=this.textAlign,t.textBaseline=this.baseAlign,t.font=this.fontString,t.direction=this.direction,this.shadow&&(t.shadowColor=this.shadow.color.toString(),t.shadowBlur=this.shadow.blur,t.shadowOffsetX=this.shadow.offset.x,t.shadowOffsetY=this.shadow.offset.y)}execute(t){if(this._text){this._applyRasterProperites(t),this._applyFont(t);const e=this._textHeight;for(let i=0;i<this._lines.length;i++){const s=this._lines[i];this.color&&t.fillText(s,0,i*e),this.strokeColor&&t.strokeText(s,0,i*e)}this.showDebug&&(Je(t,Q.Red,-this._halfRasterWidth,0,this._halfRasterWidth,0,2),Je(t,Q.Red,0,-this._halfRasterHeight,0,this._halfRasterHeight,2))}}render(t,e,i,s){this.updateText(e),this.draw(t,i,s)}}class wr extends vt{constructor(t){var e,i;super(t),this._text="",this.font=null!==(e=t.font)&&void 0!==e?e:new yr,this.color=null!==(i=t.color)&&void 0!==i?i:this.color,this.text=t.text}clone(){return new wr({text:this.text.slice(),color:this.color.clone(),font:this.font.clone()})}get text(){return this._text}set text(t){this._text=t,this.font.updateText(t)}get color(){return this.font instanceof yr?this.font.color:Q.Black}set color(t){this.font instanceof yr&&(this.font.color=t)}get font(){return this._font}set font(t){this._font=t instanceof yr?xt(t,(t=>t.flagDirty())):t}get width(){return this.font.width}get height(){return this.font.height}get localBounds(){return this.font.localBounds}_rotate(t){}_flip(t){}_drawImage(t,e,i){this.font instanceof yr&&(this.font.color=this.color),this.font.flipHorizontal=this.flipHorizontal,this.font.flipVertical=this.flipVertical,this.font.scale=this.scale,this.font.rotation=this.rotation,this.font.origin=this.origin,this.font.opacity=this.opacity,this.font.render(t,this._text,e,i)}}var vr=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};class xr extends Ts{constructor(t){super(t),this.font=new yr,this._text=new wr({text:"",font:this.font}),this.letterSpacing=0,this.caseInsensitive=!0;const{text:e,pos:i,x:s,y:n,spriteFont:r,font:o,color:a}=t;this.pos=null!=i?i:s&&n?K(s,n):this.pos,this.text=null!=e?e:this.text,this.spriteFont=null!=r?r:this.spriteFont,this.font=null!=o?o:this.font,this.color=null!=a?a:this.color;const h=this.get(is);h.anchor=q.Zero,h.use(this._text)}get text(){return this._text.text}set text(t){this._text.text=t}get color(){return this._text.color}set color(t){this._text.color=t}get opacity(){return this._text.opacity}set opacity(t){this._text.opacity=t}get bold(){return this.font.bold}set bold(t){this.font.bold=t}get fontFamily(){return this.font.family}set fontFamily(t){this.font.family=t}get fontSize(){return this.font.size}set fontSize(t){this.font.size=t}get fontStyle(){return this.font.style}set fontStyle(t){this.font.style=t}get fontUnit(){return this.font.unit}set fontUnit(t){this.font.unit=t}get textAlign(){return this.font.textAlign}set textAlign(t){this.font.textAlign=t}get baseAlign(){return this.font.baseAlign}set baseAlign(t){this.font.baseAlign=t}get spriteFont(){return this._legacySpriteFont}set spriteFont(t){if(t){if(t instanceof We)return this._legacySpriteFont=t,this._spriteFont=Ve.fromLegacySpriteFont(t),void(this._text.font=this._spriteFont);this._spriteFont=t,this._text.font=this._spriteFont}}_initialize(t){super._initialize(t),this._graphicsContext=t.graphicsContext}getTextWidth(){return this._text.width}setTextShadow(t,e,i){this.font.shadow={offset:K(t,e),blur:2,color:i}}useTextShadow(t){this.spriteFont&&this.spriteFont.useTextShadow(t)}clearTextShadow(){this.font.shadow=null}draw(t,e){const i=this._graphicsContext;this._text.draw(i,0,0)}}vr([j({message:"Label.bold will be removed in v0.26.0",alternateMethod:"Use Label.font.bold"})],xr.prototype,"bold",null),vr([j({message:"Label.fontFamily will be removed in v0.26.0",alternateMethod:"Use Label.font.family"})],xr.prototype,"fontFamily",null),vr([j({message:"Label.fontSize will be removed in v0.26.0",alternateMethod:"Use Label.font.size"})],xr.prototype,"fontSize",null),vr([j({message:"Label.fontStyle will be removed in v0.26.0",alternateMethod:"Use Lable.font.style"})],xr.prototype,"fontStyle",null),vr([j({message:"Label.fontUnit will be removed in v0.26.0",alternateMethod:"Use Label.font.unit"})],xr.prototype,"fontUnit",null),vr([j({message:"Label.textAlign will be removed in v0.26.0",alternateMethod:"Use Label.font.textAlign"})],xr.prototype,"textAlign",null),vr([j({message:"Label.baseAlign will be removed in v0.26.0",alternateMethod:"Use Label.font.baseAlign"})],xr.prototype,"baseAlign",null),vr([j()],xr.prototype,"spriteFont",null),vr([j({message:"Label.setTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],xr.prototype,"setTextShadow",null),vr([j({message:"Label.useTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],xr.prototype,"useTextShadow",null),vr([j({message:"Label.clearTextShadow will be removed in v0.26.0",alternateMethod:"Use Label.font.shadow"})],xr.prototype,"clearTextShadow",null);class br{static create(t,e){if(this._CURRENT_GROUP>this._MAX_GROUPS)throw new Error(`Cannot have more than ${this._MAX_GROUPS} collision groups`);if(this._GROUPS.get(t))throw new Error(`Collision group ${t} already exists`);const i=new xi(t,this._CURRENT_BIT,void 0!==e?e:~this._CURRENT_BIT);return this._CURRENT_BIT=this._CURRENT_BIT<<1|0,this._CURRENT_GROUP++,this._GROUPS.set(t,i),i}static get groups(){return Array.from(this._GROUPS.values())}static groupByName(t){return this._GROUPS.get(t)}static reset(){this._GROUPS=new Map,this._CURRENT_BIT=this._STARTING_BIT,this._CURRENT_GROUP=1}}br._STARTING_BIT=1,br._MAX_GROUPS=32,br._CURRENT_GROUP=1,br._CURRENT_BIT=br._STARTING_BIT,br._GROUPS=new Map;var Cr=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};let Ar=class{constructor(t){this.lineWidth=5,this.filled=!1,this._points=[],this.anchor=q.Zero,this.offset=q.Zero,this.rotation=0,this.scale=q.One,this.opacity=1,this._points=t;const e=this._points.reduce(((t,e)=>Math.min(t,e.x)),0),i=this._points.reduce(((t,e)=>Math.max(t,e.x)),0);this.drawWidth=i-e;const s=this._points.reduce(((t,e)=>Math.min(t,e.y)),0),n=this._points.reduce(((t,e)=>Math.max(t,e.y)),0);this.drawHeight=n-s,this.height=this.drawHeight,this.width=this.drawWidth}addEffect(){}removeEffect(){}clearEffects(){}reset(){}draw(t,e,i){t instanceof CanvasRenderingContext2D?this._drawWithOptions({ctx:t,x:e,y:i}):this._drawWithOptions(t)}_drawWithOptions(t){var e,i,s,n,r,o,a,h,l;const{ctx:c,x:d,y:u,rotation:p,drawWidth:g,drawHeight:_,anchor:f,offset:m,opacity:y,flipHorizontal:w,flipVertical:v}=Object.assign(Object.assign({},t),{rotation:null!==(e=t.rotation)&&void 0!==e?e:this.rotation,drawWidth:null!==(i=t.drawWidth)&&void 0!==i?i:this.drawWidth,drawHeight:null!==(s=t.drawHeight)&&void 0!==s?s:this.drawHeight,flipHorizontal:null!==(n=t.flipHorizontal)&&void 0!==n?n:this.flipHorizontal,flipVertical:null!==(r=t.flipVertical)&&void 0!==r?r:this.flipVertical,anchor:null!==(o=t.anchor)&&void 0!==o?o:this.anchor,offset:null!==(a=t.offset)&&void 0!==a?a:this.offset,opacity:(null!==(h=t.opacity)&&void 0!==h?h:1)*(null!==(l=this.opacity)&&void 0!==l?l:1)}),x=g*f.x+m.x+d,b=_*f.y+m.y+u;c.save(),c.translate(x,b),c.scale(this.scale.x,this.scale.y),c.rotate(p),c.beginPath(),c.lineWidth=this.lineWidth;const C=this._points[0];c.moveTo(C.x,C.y);let A=0;const S=this._points.length;for(;A<S;A++)c.lineTo(this._points[A].x,this._points[A].y);c.lineTo(C.x,C.y),c.closePath(),this.filled&&(c.fillStyle=this.fillColor.toString(),c.fill()),c.strokeStyle=this.lineColor.toString(),w&&(c.translate(g,0),c.scale(-1,1)),v&&(c.translate(0,_),c.scale(1,-1));const P=c.globalAlpha;c.globalAlpha=y,c.stroke(),c.globalAlpha=P,c.restore()}};Ar=Cr([j({message:"Polygon will be removed in v0.26.0",alternateMethod:"Use Graphics.Polygon"})],Ar);class Sr{}function Pr(t){return!!t._initialize}function Er(t){return!!t.onInitialize}function Tr(t){return!!t._preupdate}function Rr(t){return!!t.onPreUpdate}function Dr(t){return!!t.onPostUpdate}function Br(t){return!!t.onPostUpdate}function Mr(t){return!!t.onPreDraw}function kr(t){return!!t.onPostDraw}Sr.type={any:"",blob:"blob",json:"json",text:"text",document:"document",arraybuffer:"arraybuffer"};class Fr{constructor(t){this._src=t,this._volume=1,this._duration=void 0,this._loop=!1,this._isPlaying=!1,this._isPaused=!1,this._audioContext=Ye.create(),this._volumeNode=this._audioContext.createGain(),this._currentOffset=0,this._createNewBufferSource()}set loop(t){this._loop=t,this._instance&&(this._instance.loop=t,this._wireUpOnEnded())}get loop(){return this._loop}set volume(t){t=S(t,0,1),this._volume=t,this._isPlaying&&this._volumeNode.gain.setTargetAtTime?this._volumeNode.gain.setTargetAtTime(t,this._audioContext.currentTime,.1):this._volumeNode.gain.value=t}get volume(){return this._volume}set duration(t){this._duration=t}get duration(){return this._duration}get _playbackRate(){return this._instance?1/(this._instance.playbackRate.value||1):null}isPlaying(){return this._isPlaying}play(t=(()=>{})){return this._isPaused&&(this._resumePlayBack(),t()),this._isPlaying||(this._startPlayBack(),t()),this._playingPromise}pause(){this._isPlaying&&(this._isPaused=!0,this._isPlaying=!1,this._instance.stop(0),this._setPauseOffset())}stop(){this._isPlaying&&(this._isPlaying=!1,this._isPaused=!1,this._currentOffset=0,this._instance.stop(0),this._instance.onended||this._handleOnEnded())}_startPlayBack(){this._isPlaying=!0,this._isPaused=!1,this._playingPromise=new Promise((t=>{this._playingResolve=t})),this._instance||this._createNewBufferSource(),this._rememberStartTime(),this._volumeNode.connect(this._audioContext.destination),this._instance.start(0,0),this._currentOffset=0,this._wireUpOnEnded()}_resumePlayBack(){if(!this._isPaused)return;this._isPaused=!1,this._isPlaying=!0,this._instance.onended=null,this._createNewBufferSource();const t=this._playbackRate*this._src.duration,e=this._currentOffset%t;this._rememberStartTime(-1e3*e),this._instance.start(0,e),this._wireUpOnEnded()}_wireUpOnEnded(){this.loop||(this._instance.onended=()=>this._handleOnEnded())}_handleOnEnded(){this._isPaused||(this._isPlaying=!1,this._playingResolve(!0))}_rememberStartTime(t){this._startTime=(new Date).getTime()+(0|t)}_setPauseOffset(){this._currentOffset=((new Date).getTime()-this._startTime)*this._playbackRate/1e3}_createNewBufferSource(){this._instance=this._audioContext.createBufferSource(),this._instance.buffer=this._src,this._instance.loop=this.loop,this._instance.playbackRate.setValueAtTime(1,0),this._instance.connect(this._volumeNode)}}function Lr(t){try{const e=new Audio,i=/.*\.([A-Za-z0-9]+)$/,s=t.match(i)[1];return!!e.canPlayType("audio/"+s)}catch(t){return _.getInstance().warn("Cannot determine audio support, assuming no support for the Audio Tag",t),!1}}var Ir=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))};class Or extends $e{constructor(...t){super(),this.logger=_.getInstance(),this._loop=!1,this._volume=1,this._duration=void 0,this._isStopped=!1,this._isPaused=!1,this._tracks=[],this._wasPlayingOnHidden=!1,this._audioContext=Ye.create(),this._resource=new ce("",Sr.type.arraybuffer);for(const e of t)if(Lr(e)){this.path=e;break}this.path||(this.logger.warn("This browser does not support any of the audio files specified:",t.join(", ")),this.logger.warn("Attempting to use",t[0]),this.path=t[0])}set loop(t){this._loop=t;for(const t of this._tracks)t.loop=this._loop;this.logger.debug("Set loop for all instances of sound",this.path,"to",this._loop)}get loop(){return this._loop}set volume(t){this._volume=t;for(const t of this._tracks)t.volume=this._volume;this.emit("volumechange",new fr(this)),this.logger.debug("Set loop for all instances of sound",this.path,"to",this._volume)}get volume(){return this._volume}get duration(){return this._duration}get instances(){return this._tracks}get path(){return this._resource.path}set path(t){this._resource.path=t}isLoaded(){return!!this.data}load(){return Ir(this,void 0,void 0,(function*(){if(this.data)return this.data;const t=yield this._resource.load(),e=yield this.decodeAudio(t.slice(0));return this._duration="object"==typeof e?e.duration:void 0,this.emit("processed",new mr(this,e)),this.data=e}))}decodeAudio(t){return Ir(this,void 0,void 0,(function*(){try{return yield this._audioContext.decodeAudioData(t.slice(0))}catch(t){return this.logger.error("Unable to decode this browser may not fully support this format, or the file may be corrupt, if this is an mp3 try removing id3 tags and album art from the file."),yield Promise.reject()}}))}wireEngine(t){t&&(this._engine=t,this._engine.on("hidden",(()=>{t.pauseAudioWhenHidden&&this.isPlaying()&&(this._wasPlayingOnHidden=!0,this.pause())})),this._engine.on("visible",(()=>{t.pauseAudioWhenHidden&&this._wasPlayingOnHidden&&(this.play(),this._wasPlayingOnHidden=!1)})),this._engine.on("start",(()=>{this._isStopped=!1})),this._engine.on("stop",(()=>{this.stop(),this._isStopped=!0})))}instanceCount(){return this._tracks.length}isPlaying(){return this._tracks.some((t=>t.isPlaying()))}play(t){return this.isLoaded()?this._isStopped?(this.logger.warn("Cannot start playing. Engine is in a stopped state."),Promise.resolve(!1)):(this.volume=t||this.volume,this._isPaused?this._resumePlayback():this._startPlayback()):(this.logger.warn("Cannot start playing. Resource",this.path,"is not loaded yet"),Promise.resolve(!0))}pause(){if(this.isPlaying()){for(const t of this._tracks)t.pause();this._isPaused=!0,this.emit("pause",new fr(this)),this.logger.debug("Paused all instances of sound",this.path)}}stop(){for(const t of this._tracks)t.stop();this.emit("stop",new fr(this)),this._isPaused=!1,this._tracks.length=0,this.logger.debug("Stopped all instances of sound",this.path)}getTrackId(t){return this._tracks.indexOf(t)}_resumePlayback(){return Ir(this,void 0,void 0,(function*(){if(this._isPaused){const t=[];for(const e of this._tracks)t.push(e.play());this._isPaused=!1,this.emit("resume",new fr(this)),this.logger.debug("Resuming paused instances for sound",this.path,this._tracks),yield Promise.all(t)}return!0}))}_startPlayback(){return Ir(this,void 0,void 0,(function*(){const t=yield this._getTrackInstance(this.data),e=yield t.play((()=>{this.emit("playbackstart",new fr(this,t)),this.logger.debug("Playing new instance for sound",this.path)}));return this.emit("playbackend",new fr(this,t)),this._tracks.splice(this.getTrackId(t),1),e}))}_getTrackInstance(t){const e=new Fr(t);return e.loop=this.loop,e.volume=this.volume,e.duration=this.duration,this._tracks.push(e),e}}var zr=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))};class Ur{constructor(t,e=Q.Magenta,i=!0){this.path=t,this.color=e,this.bustCache=i,this._stream=null,this._gif=null,this._textures=[],this._animation=null,this._transparentColor=null,this._resource=new ce(t,"arraybuffer",i),this._transparentColor=e}load(){return zr(this,void 0,void 0,(function*(){const t=yield this._resource.load();this._stream=new Nr(t),this._gif=new Vr(this._stream,this._transparentColor);const e=this._gif.images.map((t=>new De(t.src,!1)));return yield Promise.all(e.map((t=>t.load()))),this.data=this._textures=e}))}isLoaded(){return!!this.data}toLegacySprite(t=0){return Te.toLegacySprite(this.toSprite(t))}toLegacySpriteSheet(){return Ne.toLegacySpriteSheet(this.toSpriteSheet())}toLegacyAnimation(t,e){return mn.toLegacyAnimation(t,this.toAnimation(e))}toSprite(t=0){return this._textures[t].toSprite()}toSpriteSheet(){const t=this._textures.map((t=>t.toSprite()));return new Ne({sprites:t})}toAnimation(t){const e=this.toSpriteSheet(),i=e.sprites.length;return this._animation=mn.fromSpriteSheet(e,U(0,i),t),this._animation}get readCheckBytes(){return this._gif.checkBytes}}const Hr=t=>t.reduce((function(t,e){return 2*t+e}),0),Wr=t=>{const e=[];for(let i=7;i>=0;i--)e.push(!!(t&1<<i));return e};class Nr{constructor(t){if(this.data=null,this.len=0,this.position=0,this.readByte=()=>{if(this.position>=this.data.byteLength)throw new Error("Attempted to read past end of stream.");return this.data[this.position++]},this.readBytes=t=>{const e=[];for(let i=0;i<t;i++)e.push(this.readByte());return e},this.read=t=>{let e="";for(let i=0;i<t;i++)e+=String.fromCharCode(this.readByte());return e},this.readUnsigned=()=>{const t=this.readBytes(2);return(t[1]<<8)+t[0]},this.data=new Uint8Array(t),this.len=this.data.byteLength,0===this.len)throw new Error("No data loaded from file")}}class Vr{constructor(t,e=Q.Magenta){this._st=null,this._handler={},this._transparentColor=null,this.frames=[],this.images=[],this.globalColorTable=[],this.checkBytes=[],this.parseColorTable=t=>{const e=[];for(let i=0;i<t;i++){const t="#"+this._st.readBytes(3).map((t=>{const e=t.toString(16);return 1===e.length?"0"+e:e})).join("");e.push(t)}return e},this.readSubBlocks=()=>{let t,e;e="";do{t=this._st.readByte(),e+=this._st.read(t)}while(0!==t);return e},this.parseHeader=()=>{const t={sig:null,ver:null,width:null,height:null,colorRes:null,globalColorTableSize:null,gctFlag:null,sorted:null,globalColorTable:[],bgColor:null,pixelAspectRatio:null};if(t.sig=this._st.read(3),t.ver=this._st.read(3),"GIF"!==t.sig)throw new Error("Not a GIF file.");t.width=this._st.readUnsigned(),t.height=this._st.readUnsigned();const e=Wr(this._st.readByte());t.gctFlag=e.shift(),t.colorRes=Hr(e.splice(0,3)),t.sorted=e.shift(),t.globalColorTableSize=Hr(e.splice(0,3)),t.bgColor=this._st.readByte(),t.pixelAspectRatio=this._st.readByte(),t.gctFlag&&(t.globalColorTable=this.parseColorTable(1<<t.globalColorTableSize+1),this.globalColorTable=t.globalColorTable),this._handler.hdr&&this._handler.hdr(t)&&this.checkBytes.push(this._handler.hdr)},this.parseExt=t=>{const e=t=>{this.checkBytes.push(this._st.readByte());const e=Wr(this._st.readByte());t.reserved=e.splice(0,3),t.disposalMethod=Hr(e.splice(0,3)),t.userInput=e.shift(),t.transparencyGiven=e.shift(),t.delayTime=this._st.readUnsigned(),t.transparencyIndex=this._st.readByte(),t.terminator=this._st.readByte(),this._handler.gce&&this._handler.gce(t)&&this.checkBytes.push(this._handler.gce)},i=t=>{t.comment=this.readSubBlocks(),this._handler.com&&this._handler.com(t)&&this.checkBytes.push(this._handler.com)},s=t=>{this.checkBytes.push(this._st.readByte()),t.ptHeader=this._st.readBytes(12),t.ptData=this.readSubBlocks(),this._handler.pte&&this._handler.pte(t)&&this.checkBytes.push(this._handler.pte)},n=t=>{const e=t=>{this.checkBytes.push(this._st.readByte()),t.unknown=this._st.readByte(),t.iterations=this._st.readUnsigned(),t.terminator=this._st.readByte(),this._handler.app&&this._handler.app.NETSCAPE&&this._handler.app.NETSCAPE(t)&&this.checkBytes.push(this._handler.app)},i=t=>{t.appData=this.readSubBlocks(),this._handler.app&&this._handler.app[t.identifier]&&this._handler.app[t.identifier](t)&&this.checkBytes.push(this._handler.app[t.identifier])};if(this.checkBytes.push(this._st.readByte()),t.identifier=this._st.read(8),t.authCode=this._st.read(3),"NETSCAPE"===t.identifier)e(t);else i(t)},r=t=>{t.data=this.readSubBlocks(),this._handler.unknown&&this._handler.unknown(t)&&this.checkBytes.push(this._handler.unknown)};switch(t.label=this._st.readByte(),t.label){case 249:t.extType="gce",e(t);break;case 254:t.extType="com",i(t);break;case 1:t.extType="pte",s(t);break;case 255:t.extType="app",n(t);break;default:t.extType="unknown",r(t)}},this.parseImg=t=>{t.leftPos=this._st.readUnsigned(),t.topPos=this._st.readUnsigned(),t.width=this._st.readUnsigned(),t.height=this._st.readUnsigned();const e=Wr(this._st.readByte());t.lctFlag=e.shift(),t.interlaced=e.shift(),t.sorted=e.shift(),t.reserved=e.splice(0,2),t.lctSize=Hr(e.splice(0,3)),t.lctFlag&&(t.lct=this.parseColorTable(1<<t.lctSize+1)),t.lzwMinCodeSize=this._st.readByte();const i=this.readSubBlocks();t.pixels=function(t,e){let i=0;const s=function(t){let s=0;for(let n=0;n<t;n++)e.charCodeAt(i>>3)&1<<(7&i)&&(s|=1<<n),i++;return s},n=[],r=1<<t,o=r+1;let a=t+1,h=[];const l=function(){h=[],a=t+1;for(let t=0;t<r;t++)h[t]=[t];h[r]=[],h[o]=null};let c,d;for(;;)if(d=c,c=s(a),c!==r){if(c===o)break;if(c<h.length)d!==r&&h.push(h[d].concat(h[c][0]));else{if(c!==h.length)throw new Error("Invalid LZW code.");h.push(h[d].concat(h[d][0]))}n.push.apply(n,h[c]),h.length===1<<a&&a<12&&a++}else l();return n}(t.lzwMinCodeSize,i),t.interlaced&&(t.pixels=((t,e)=>{const i=new Array(t.length),s=t.length/e,n=(s,n)=>{const r=t.slice(n*e,(n+1)*e);i.splice.apply(i,[s*e,e].concat(r))},r=[0,4,2,1],o=[8,8,4,2];let a=0;for(let t=0;t<4;t++)for(let e=r[t];e<s;e+=o[t])n(e,a),a++;return i})(t.pixels,t.width)),this.frames.push(t),this.arrayToImage(t),this._handler.img&&this._handler.img(t)&&this.checkBytes.push(this._handler)},this.parseBlock=()=>{const t={sentinel:this._st.readByte(),type:""};switch(String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this._handler.eof&&this._handler.eof(t)&&this.checkBytes.push(this._handler.eof);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&this.parseBlock()},this.arrayToImage=t=>{let e=0;const i=document.createElement("canvas");i.id=e.toString(),i.width=t.width,i.height=t.height,e++;const s=i.getContext("2d");let n=0,r=0;for(let e=0;e<t.pixels.length;e++)r%t.width==0&&(n++,r=0),this.globalColorTable[t.pixels[e]]===this._transparentColor.toHex()?s.fillStyle="rgba(0, 0, 0, 0)":s.fillStyle=this.globalColorTable[t.pixels[e]],s.fillRect(r,n,1,1),r++;const o=new Image;o.src=i.toDataURL(),this.images.push(o)},this._st=t,this._handler={},this._transparentColor=e,this.parseHeader(),this.parseBlock()}}class Gr extends Ct{constructor(t){super(t),this.points=t.points,this.rasterize()}get points(){return this._points}set points(t){this._points=t;const e=this.minPoint;this.width=this._points.reduce(((t,e)=>Math.max(e.x,t)),0)-e.x,this.height=this._points.reduce(((t,e)=>Math.max(e.y,t)),0)-e.y,this.flagDirty()}get minPoint(){return K(this._points.reduce(((t,e)=>Math.min(e.x,t)),1/0),this._points.reduce(((t,e)=>Math.min(e.y,t)),1/0))}clone(){return new Gr(Object.assign(Object.assign({points:this.points.map((t=>t.clone()))},this.cloneGraphicOptions()),this.cloneRasterOptions()))}execute(t){if(this.points&&this.points.length){t.beginPath();const e=this.minPoint.negate(),i=this.points[0].add(e);t.moveTo(i.x,i.y),this.points.forEach((i=>{t.lineTo(i.x+e.x,i.y+e.y)})),t.lineTo(i.x,i.y),t.closePath(),this.color&&t.fill(),this.strokeColor&&t.stroke()}}}var jr=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};let Xr=class{constructor(t){this._getComparable=t}find(t){return this._find(this._root,t)}_find(t,e){return null!=t&&(this._getComparable(e)===t.getKey()?t.getData().indexOf(e)>-1:this._getComparable(e)<t.getKey()?this._find(t.getLeft(),e):this._find(t.getRight(),e))}get(t){return this._get(this._root,t)}_get(t,e){return null==t?[]:e===t.getKey()?t.getData():e<t.getKey()?this._get(t.getLeft(),e):this._get(t.getRight(),e)}add(t){return null==this._root?(this._root=new qr(this._getComparable(t),[t],null,null),!0):this._insert(this._root,t)}_insert(t,e){return null!=t&&(this._getComparable(e)===t.getKey()?!(t.getData().indexOf(e)>-1)&&(t.getData().push(e),!0):this._getComparable(e)<t.getKey()?null==t.getLeft()?(t.setLeft(new qr(this._getComparable(e),[e],null,null)),!0):this._insert(t.getLeft(),e):null==t.getRight()?(t.setRight(new qr(this._getComparable(e),[e],null,null)),!0):this._insert(t.getRight(),e))}removeByComparable(t){this._root=this._remove(this._root,t)}_remove(t,e){if(null==t)return null;if(this._getComparable(e)!==t.getKey())return this._getComparable(e)<t.getKey()?(t.setLeft(this._remove(t.getLeft(),e)),t):(t.setRight(this._remove(t.getRight(),e)),t);{const i=t.getData().indexOf(e);if(i>-1){if(t.getData().splice(i,1),0===t.getData().length){if(null==t.getLeft()&&null==t.getRight())return null;if(null==t.getLeft())return t.getRight();if(null==t.getRight())return t.getLeft();const e=this._findMinNode(t.getRight());return t.setKey(e.getKey()),t.setData(e.getData()),t.setRight(this._cleanup(t.getRight(),e)),t}return t}}return null}_cleanup(t,e){const i=e.getKey();if(null==t)return null;if(i===t.getKey()){if(null==t.getLeft()&&null==t.getRight())return null;if(null==t.getLeft())return t.getRight();if(null==t.getRight())return t.getLeft();const e=this._findMinNode(t.getRight());return t.setKey(e.getKey()),t.setData(e.getData()),t.setRight(this._cleanup(t.getRight(),e)),t}return e.getKey()<t.getKey()?(t.setLeft(this._cleanup(t.getLeft(),e)),t):(t.setRight(this._cleanup(t.getRight(),e)),t)}_findMinNode(t){let e=t;for(;null!=e.getLeft();)e=e.getLeft();return e}list(){const t=new Array;return this._list(this._root,t),t}_list(t,e){null!=t&&(this._list(t.getLeft(),e),t.getData().forEach((t=>{e.push(t)})),this._list(t.getRight(),e))}};Xr=jr([j({message:"Will be removed in excalibur v0.26.0",alternateMethod:"Use built in JS array.sort"})],Xr);let qr=class{constructor(t,e,i,s){this._key=t,this._data=e,this._left=i,this._right=s}getKey(){return this._key}setKey(t){this._key=t}getData(){return this._data}setData(t){this._data=t}getLeft(){return this._left}setLeft(t){this._left=t}getRight(){return this._right}setRight(t){this._right=t}};qr=jr([j({message:"Will be removed in excalibur v0.26.0"})],qr);class Kr{constructor(t){this._key=0,this._key=t}getTheKey(){return this._key}setKey(t){this._key=t}}var Zr,Yr,Qr=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o};!function(t){t[t.Resolved=0]="Resolved",t[t.Rejected=1]="Rejected",t[t.Pending=2]="Pending"}(Yr||(Yr={}));let $r=Zr=class{constructor(){this._state=Yr.Pending,this._successCallbacks=[],this._rejectCallback=()=>{}}static resolve(t){return(new Zr).resolve(t)}static reject(t){return(new Zr).reject(t)}static join(){let t=[];if(arguments.length>0&&!Array.isArray(arguments[0]))for(let e=0;e<arguments.length;e++)t[e-0]=arguments[e];else 1===arguments.length&&Array.isArray(arguments[0])&&(t=arguments[0]);const e=new Zr;if(!t||!t.length)return e.resolve();const i=t.length;let s=0,n=0;const r=[];return t.forEach((t=>{t.then((()=>{s+=1,s===i?e.resolve():s+n+r.length===i&&e.reject(r)}),(()=>{n+=1,s+n+r.length===i&&e.reject(r)})).error((t=>{r.push(t),r.length+s+n===i&&e.reject(r)}))})),e}then(t,e){if(t&&(this._successCallbacks.push(t),this.state()===Yr.Resolved))try{t.call(this,this._value)}catch(t){this._handleError(t)}if(e&&(this._rejectCallback=e,this.state()===Yr.Rejected))try{e.call(this,this._value)}catch(t){this._handleError(t)}return this}error(t){return t&&(this._errorCallback=t),this}resolve(t){if(this._state!==Yr.Pending)throw new Error("Cannot resolve a promise that is not in a pending state!");this._value=t;try{this._state=Yr.Resolved,this._successCallbacks.forEach((t=>{t.call(this,this._value)}))}catch(t){this._handleError(t)}return this}reject(t){if(this._state!==Yr.Pending)throw new Error("Cannot reject a promise that is not in a pending state!");this._value=t;try{this._state=Yr.Rejected,this._rejectCallback.call(this,this._value)}catch(t){this._handleError(t)}return this}state(){return this._state}_handleError(t){if(!this._errorCallback)throw t;this._errorCallback.call(this,t)}};$r=Zr=Qr([j({message:"ex.Promises are being replaced by native browser promises in v0.26.0",alternateMethod:"Use browser native promises"})],$r);const Jr="0.25.1";u()})(),s})()}));
|
|
3
3
|
//# sourceMappingURL=excalibur.min.js.map
|