excalibur 0.32.0-alpha.1560 → 0.32.0-alpha.1562
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/CHANGELOG.md +1 -0
- package/build/dist/Util/Clock.d.ts +1 -0
- package/build/dist/excalibur.development.js +14 -7
- package/build/dist/excalibur.js +14 -7
- package/build/dist/excalibur.min.development.js +3 -3
- package/build/dist/excalibur.min.js +3 -3
- package/build/esm/excalibur.development.js +14 -7
- package/build/esm/excalibur.js +14 -7
- package/build/esm/excalibur.min.development.js +9 -6
- package/build/esm/excalibur.min.js +9 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1562+c143e37 - 2025-11-23
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -783,7 +783,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
783
783
|
}`}),this._total=i}update(t){var e;this._started||(this._started=!0,this._total=this._duration,this._currentDuration=this._duration,this._entity.graphics.material=this._material),this._graphics&&(this._currentDuration-=t,this._graphics&&((e=this._material)==null||e.update(i=>{i.trySetUniformFloat("u_blend",this._currentDuration/this._total)})),this.isComplete()&&(this._entity.graphics.material=null))}isComplete(){return this._stopped||this._currentDuration<=0}stop(){this._graphics&&(this._graphics.isVisible=!0),this._stopped=!0}reset(){this._started=!1,this._stopped=!1}}class To{constructor(t,e){this.id=H(),this._started=!1,this._stopped=!1,this._mode="dynamic";var i;if(this._entity=t,this._tx=this._entity.get(A),!this._tx)throw new Error(`Entity ${t.name} has no TransformComponent, can only curveTo on Entities with TransformComponents.`);this._curve=new ii({controlPoints:[b(0,0),...e.controlPoints],quality:e.quality}),this._durationMs=e.duration,this._mode=(i=e.mode)!=null?i:this._mode,this._currentMs=this._durationMs}update(t){this._started||(this._curve.setControlPoint(0,this._tx.globalPos.clone()),this._started=!0),this._currentMs-=t;const e=B(Ht(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1);this._mode==="dynamic"?this._tx.pos=this._curve.getPoint(e):this._tx.pos=this._curve.getUniformPoint(e),this.isComplete(this._entity)&&(this._mode==="dynamic"?this._tx.pos=this._curve.getPoint(1):this._tx.pos=this._curve.getUniformPoint(1))}isComplete(t){return this._stopped||this._currentMs<0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}stop(){this._stopped=!0,this._currentMs=0}}class Po{constructor(t,e){this.id=H(),this._started=!1,this._stopped=!1,this._mode="dynamic";var i;if(this._entity=t,this._tx=this._entity.get(A),!this._tx)throw new Error(`Entity ${t.name} has no TransformComponent, can only curveTo on Entities with TransformComponents.`);this._curve=this._curve=new ii({controlPoints:[b(0,0),...e.controlPoints],quality:e.quality}),this._durationMs=e.duration,this._mode=(i=e.mode)!=null?i:this._mode,this._currentMs=this._durationMs}update(t){this._started||(this._curve.setControlPoint(0,this._tx.globalPos),this._curve.setControlPoint(1,this._curve.controlPoints[1].add(this._tx.globalPos)),this._curve.setControlPoint(2,this._curve.controlPoints[2].add(this._tx.globalPos)),this._curve.setControlPoint(3,this._curve.controlPoints[3].add(this._tx.globalPos)),this._started=!0),this._currentMs-=t;const e=B(Ht(0,this._durationMs,0,1,this._durationMs-this._currentMs),0,1);this._mode==="dynamic"?this._tx.pos=this._curve.getPoint(e):this._tx.pos=this._curve.getUniformPoint(e),this.isComplete(this._entity)&&(this._mode==="dynamic"?this._tx.pos=this._curve.getPoint(1):this._tx.pos=this._curve.getUniformPoint(1))}isComplete(t){return this._stopped||this._currentMs<0}reset(){this._currentMs=this._durationMs,this._started=!1,this._stopped=!1}stop(){this._stopped=!0}}class fi{constructor(t){this._entity=t,this._queue=new Kr(t)}getQueue(){return this._queue}update(t){this._queue.update(t)}clearActions(){this._queue.clearActions()}runAction(t){return t.reset(),this._queue.add(t),this}curveBy(t){return this._queue.add(new Po(this._entity,t)),this}curveTo(t){return this._queue.add(new To(this._entity,t)),this}easeTo(...t){var e,i;let s=0,n=0,o=0,a=It.Linear;return t[0]instanceof v?(s=t[0].x,n=t[0].y,o=t[1],a=(e=t[2])!=null?e:a):(s=t[0],n=t[1],o=t[2],a=(i=t[3])!=null?i:a),this._queue.add(new vo(this._entity,s,n,o,a)),this}easeBy(...t){var e,i;let s=0,n=0,o=0,a=It.Linear;return t[0]instanceof v?(s=t[0].x,n=t[0].y,o=t[1],a=(e=t[2])!=null?e:a):(s=t[0],n=t[1],o=t[2],a=(i=t[3])!=null?i:a),this._queue.add(new wo(this._entity,s,n,o,a)),this}moveTo(t,e,i){let s=0,n=0,o=0;return t instanceof v?(s=t.x,n=t.y,o=+(e!=null?e:0),this._queue.add(new Pn(this._entity,s,n,o))):typeof t=="number"&&typeof e=="number"&&typeof i=="number"?(s=t,n=e,o=i,this._queue.add(new Pn(this._entity,s,n,o))):no(t)&&this._queue.add(new ro(this._entity,t)),this}moveBy(t,e,i){let s=0,n=0,o=0;return t instanceof v&&typeof e=="number"?(s=t.x,n=t.y,o=e,this._queue.add(new Tn(this._entity,s,n,o))):typeof t=="number"&&typeof e=="number"&&typeof i=="number"?(s=t,n=e,o=i,this._queue.add(new Tn(this._entity,s,n,o))):io(t)&&this._queue.add(new so(this._entity,t)),this}rotateTo(t,e,i){return typeof t=="number"&&typeof e=="number"?this._queue.add(new ao(this._entity,t,e,i)):typeof t=="object"&&this._queue.add(new oo(this._entity,t)),this}rotateBy(t,e,i){return typeof t=="object"?this._queue.add(new ho(this._entity,t)):this._queue.add(new lo(this._entity,t,e,i)),this}scaleTo(t,e,i,s){let n=1,o=1,a=0,h=0;return co(t)?(this._queue.add(new uo(this._entity,t)),this):(t instanceof v&&e instanceof v&&(n=t.x,o=t.y,a=e.x,h=e.y),typeof t=="number"&&typeof e=="number"&&(n=t,o=e,a=i,h=s),this._queue.add(new _o(this._entity,n,o,a,h)),this)}scaleBy(t,e,i){if(fo(t))return this._queue.add(new go(this._entity,t)),this;let s=1,n=1;return t instanceof v&&(s=t.x,n=t.y,i=e),typeof t=="number"&&typeof e=="number"&&(s=t,n=e),this._queue.add(new po(this._entity,s,n,i)),this}blink(t,e,i=1){return this._queue.add(new xo(this._entity,t,e,i)),this}fade(t,e){return this._queue.add(new bo(this._entity,t,e)),this}flash(t,e=1e3){return this._queue.add(new So(this._entity,t,e)),this}delay(t){return this._queue.add(new yo(t)),this}die(){return this._queue.add(new Co(this._entity)),this}callMethod(t){return this._queue.add(new mo(t)),this}repeat(t,e){return e?(this._queue.add(new to(this._entity,t,e)),this):(this.repeatForever(t),this)}repeatForever(t){return this._queue.add(new eo(this._entity,t)),this}follow(t,e){return e===void 0?this._queue.add(new An(this._entity,t)):this._queue.add(new An(this._entity,t,e)),this}meet(t,e,i){return e===void 0&&i===void 0?this._queue.add(new $i(this._entity,t)):i===void 0?this._queue.add(new $i(this._entity,t,e)):this._queue.add(new $i(this._entity,t,e,i)),this}toPromise(){return new Promise(e=>{this._queue.add(new mo(()=>{e()}))})}}class je extends Dt{constructor(){super(...arguments),this.dependencies=[A,U],this._ctx=null}onAdd(t){this._ctx=new fi(t)}onRemove(){this._ctx=null}_getCtx(){if(!this._ctx)throw new Error("Actions component not attached to an entity, no context available");return this._ctx}getQueue(){if(!this._ctx)throw new Error("Actions component not attached to an entity, no queue available");return this._ctx.getQueue()}runAction(t){if(!this._ctx)throw new Error("Actions component not attached to an entity, cannot run action");return this._ctx.runAction(t)}update(t){var e;return(e=this._ctx)==null?void 0:e.update(t)}clearActions(){var t;(t=this._ctx)==null||t.clearActions()}curveBy(t){return this._getCtx().curveBy.apply(this._ctx,[t])}curveTo(t){return this._getCtx().curveTo.apply(this._ctx,[t])}easeTo(...t){return this._getCtx().easeTo.apply(this._ctx,t)}easeBy(...t){return this._getCtx().easeBy.apply(this._ctx,t)}moveTo(t,e,i){return this._getCtx().moveTo.apply(this._ctx,[t,e,i])}moveBy(t,e,i){return this._getCtx().moveBy.apply(this._ctx,[t,e,i])}rotateTo(t,e,i){return this._getCtx().rotateTo.apply(this._ctx,[t,e,i])}rotateBy(t,e,i){return this._getCtx().rotateBy.apply(this._ctx,[t,e,i])}scaleTo(t,e,i,s){return this._getCtx().scaleTo.apply(this._ctx,[t,e,i,s])}scaleBy(t,e,i){return this._getCtx().scaleBy.apply(this._ctx,[t,e,i])}blink(t,e,i){return this._getCtx().blink(t,e,i)}fade(t,e){return this._getCtx().fade(t,e)}flash(t,e=1e3){return this._getCtx().flash(t,e)}delay(t){return this._getCtx().delay(t)}die(){return this._getCtx().die()}callMethod(t){return this._getCtx().callMethod(t)}repeat(t,e){return this._getCtx().repeat(t,e)}repeatForever(t){return this._getCtx().repeatForever(t)}follow(t,e){return this._getCtx().follow(t,e)}meet(t,e){return this._getCtx().meet(t,e)}toPromise(){return this._getCtx().toPromise()}}function vl(r){return r instanceof Ft}const wl={CollisionStart:"collisionstart",CollisionEnd:"collisionend",PreCollision:"precollision",PostCollision:"postcollision",Kill:"kill",PreKill:"prekill",PostKill:"postkill",PreDraw:"predraw",PostDraw:"postdraw",PreTransformDraw:"pretransformdraw",PostTransformDraw:"posttransformdraw",PreDebugDraw:"predebugdraw",PostDebugDraw:"postdebugdraw",PointerUp:"pointerup",PointerDown:"pointerdown",PointerEnter:"pointerenter",PointerLeave:"pointerleave",PointerMove:"pointermove",PointerCancel:"pointercancel",Wheel:"pointerwheel",PointerDrag:"pointerdragstart",PointerDragEnd:"pointerdragend",PointerDragEnter:"pointerdragenter",PointerDragLeave:"pointerdragleave",PointerDragMove:"pointerdragmove",EnterViewPort:"enterviewport",ExitViewPort:"exitviewport",ActionStart:"actionstart",ActionComplete:"actioncomplete"},Ao=class rr extends Tt{constructor(t){super(),this.events=new X,this._anchor=Et(v.Half,F=>this._handleAnchorChange(F)),this._offset=Et(v.Zero,F=>this._handleOffsetChange(F)),this.logger=R.getInstance(),this._draggable=!1,this._dragging=!1,this._pointerDragStartHandler=()=>{this._dragging=!0},this._pointerDragEndHandler=()=>{this._dragging=!1},this._pointerDragMoveHandler=F=>{this._dragging&&(this.pos=F.worldPos)},this._pointerDragLeaveHandler=F=>{this._dragging&&(this.pos=F.worldPos)};const{name:e,x:i,y:s,pos:n,coordPlane:o,scale:a,width:h,height:l,radius:c,collider:u,vel:_,acc:f,rotation:g,angularVelocity:p,z:x,color:m,visible:w,opacity:S,anchor:C,offset:T,collisionType:I,collisionGroup:y}={...t};this.name=e!=null?e:this.name,this.anchor=C!=null?C:rr.defaults.anchor.clone(),this.offset=T!=null?T:v.Zero,this.transform=new A,this.addComponent(this.transform),this.pos=n!=null?n:b(i!=null?i:0,s!=null?s:0),this.rotation=g!=null?g:0,this.scale=a!=null?a:b(1,1),this.z=x!=null?x:0,this.transform.coordPlane=o!=null?o:rt.World,this.pointer=new ae,this.addComponent(this.pointer),this.graphics=new j({anchor:this.anchor,offset:this.offset,opacity:S}),this.addComponent(this.graphics),this.motion=new U,this.addComponent(this.motion),this.vel=_!=null?_:v.Zero,this.acc=f!=null?f:v.Zero,this.angularVelocity=p!=null?p:0,this.actions=new je,this.addComponent(this.actions),this.body=new N,this.addComponent(this.body),this.body.collisionType=I!=null?I:M.Passive,y&&(this.body.group=y),m&&(this.color=m),u?(this.collider=new tt(u),this.addComponent(this.collider)):c?(this.collider=new tt(ut.Circle(c)),this.addComponent(this.collider),m&&this.graphics.add(new Vi({color:m,radius:c}))):h>0&&l>0?(this.collider=new tt(ut.Box(h,l,this.anchor)),this.addComponent(this.collider),m&&h&&l&&this.graphics.add(new di({color:m,width:h,height:l}))):(this.collider=new tt,this.addComponent(this.collider)),this.graphics.isVisible=w!=null?w:!0}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t.clone()}get oldPos(){return this.body.oldPos}get oldGlobalPos(){return this.body.oldGlobalPos}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(A).scale}set scale(t){this.get(A).scale=t}get anchor(){return this._anchor}set anchor(t){this._anchor=Et(t,e=>this._handleAnchorChange(e)),this._handleAnchorChange(t)}_handleAnchorChange(t){this.graphics&&(this.graphics.anchor=t)}get offset(){return this._offset}set offset(t){this._offset=Et(t,e=>this._handleOffsetChange(e)),this._handleOffsetChange(t)}_handleOffsetChange(t){this.graphics&&(this.graphics.offset=t)}get isOffScreen(){return this.hasTag("ex.offscreen")}get draggable(){return this._draggable}set draggable(t){t&&(t&&!this._draggable?(this.events.on("pointerdragstart",this._pointerDragStartHandler),this.events.on("pointerdragend",this._pointerDragEndHandler),this.events.on("pointerdragmove",this._pointerDragMoveHandler),this.events.on("pointerdragleave",this._pointerDragLeaveHandler)):!t&&this._draggable&&(this.events.off("pointerdragstart",this._pointerDragStartHandler),this.events.off("pointerdragend",this._pointerDragEndHandler),this.events.off("pointerdragmove",this._pointerDragMoveHandler),this.events.off("pointerdragleave",this._pointerDragLeaveHandler)),this._draggable=t)}get color(){return this.graphics.color}set color(t){this.graphics.color=t}clone(){const t=new rr({color:this.color.clone(),anchor:this.anchor.clone(),offset:this.offset.clone()});t.clearComponents(),t.processComponentRemoval(),t.addComponent(t.transform=this.transform.clone(),!0),t.addComponent(t.pointer=this.pointer.clone(),!0),t.addComponent(t.graphics=this.graphics.clone(),!0),t.addComponent(t.motion=this.motion.clone(),!0),t.addComponent(t.actions=this.actions.clone(),!0),t.addComponent(t.body=this.body.clone(),!0),this.collider.get()&&t.addComponent(t.collider=this.collider.clone(),!0);const e=[this.transform,this.pointer,this.graphics,this.motion,this.actions,this.body,this.collider],i=this.getComponents();for(const s of i)e.includes(s)||t.addComponent(s.clone(),!0);return t}onInitialize(t){}_initialize(t){super._initialize(t);for(const e of this.children)e._initialize(t)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}_prekill(t){this.events.emit("prekill",new Ts(this)),this.onPreKill(t)}onPreKill(t){}_postkill(t){this.events.emit("postkill",new Ps(this)),this.onPostKill(t)}onPostKill(t){}kill(){this.scene?(this._prekill(this.scene),this.events.emit("kill",new Ai(this)),super.kill(),this._postkill(this.scene)):this.logger.warn(`Cannot kill actor named "${this.name}", it was never added to the Scene`)}unkill(){this.isActive=!0}isKilled(){return!this.isActive}get z(){return this.get(A).z}set z(t){this.get(A).z=t}get center(){const t=this.getGlobalPos();return new v(t.x+this.width/2-this.anchor.x*this.width,t.y+this.height/2-this.anchor.y*this.height)}get localCenter(){return new v(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(A).globalRotation}get globalRotation(){return this.get(A).globalRotation}getGlobalPos(){return this.get(A).globalPos}get globalPos(){return this.get(A).globalPos}getGlobalScale(){return this.get(A).globalScale}get globalScale(){return this.get(A).globalScale}get globalZ(){return this.get(A).globalZ}contains(t,e,i=!1){const s=b(t,e),n=this.get(tt);n.update();const o=n.get();if(!o)return!1;const a=o.contains(s);return i?a||this.children.some(h=>h.contains(t,e,!0)):a}within(t,e){const i=this.get(tt),s=t.get(tt),n=i.get(),o=s.get();return n&&o?n.getClosestLineBetween(o).getLength()<=e:!1}update(t,e){this._initialize(t),this._add(t),this._preupdate(t,e),this._postupdate(t,e),this._remove(t)}onPreUpdate(t,e){}onPostUpdate(t,e){}onPreCollisionResolve(t,e,i,s){}onPostCollisionResolve(t,e,i,s){}onCollisionStart(t,e,i,s){}onCollisionEnd(t,e,i,s){}_preupdate(t,e){this.events.emit("preupdate",new ne(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.events.emit("postupdate",new re(t,e,this)),this.onPostUpdate(t,e)}};Ao.defaults={anchor:v.Half};let Ft=Ao;class tt extends Dt{constructor(t){super(),this.events=new X,this.$colliderAdded=new gt,this.$colliderRemoved=new gt,this._collidersToRemove=[],this.set(t)}get(){return this._collider}set(t){return this.clear(),t&&(this._collider=t,this._collider.owner=this.owner,t.events.pipe(this.events),this.$colliderAdded.notifyAll(t),this.update()),t}clear(){this._collider&&(this._collidersToRemove.push(this._collider),this._collider=null)}processColliderRemoval(){for(const t of this._collidersToRemove)t.events.unpipe(this.events),this.$colliderRemoved.notifyAll(t),t.owner=null}clone(){return new tt(this._collider.clone())}get bounds(){var t,e;return(e=(t=this._collider)==null?void 0:t.bounds)!=null?e:new D}get localBounds(){var t,e;return(e=(t=this._collider)==null?void 0:t.localBounds)!=null?e:new D}update(){var t;const e=(t=this.owner)==null?void 0:t.get(A);this._collider&&(this._collider.owner=this.owner,e&&this._collider.update(e.get()))}collide(t){let e=this._collider,i=t._collider;if(!e||!i)return[];let s=!1;if(i instanceof at&&(e=i,i=this._collider,s=!0),this._collider){const n=e.collide(i);return n?(s&&n.forEach(o=>{o.mtv=o.mtv.negate(),o.normal=o.normal.negate(),o.tangent=o.normal.perpendicular(),o.colliderA=this._collider,o.colliderB=t._collider}),n):[]}return[]}onAdd(t){this._collider&&this.update(),this.events.on("precollision",e=>{const i=e;t.events.emit("precollision",new me(i.self,i.other,i.side,i.intersection,i.contact)),t instanceof Ft&&t.onPreCollisionResolve(i.self,i.other,i.side,i.contact)}),this.events.on("postcollision",e=>{const i=e;t.events.emit("postcollision",new ve(i.self,i.other,i.side,i.intersection,i.contact)),t instanceof Ft&&t.onPostCollisionResolve(i.self,i.other,i.side,i.contact)}),this.events.on("collisionstart",e=>{const i=e;t.events.emit("collisionstart",new si(i.self,i.other,i.side,i.contact)),t instanceof Ft&&t.onCollisionStart(i.self,i.other,i.side,i.contact)}),this.events.on("collisionend",e=>{const i=e;t.events.emit("collisionend",new ni(i.self,i.other,i.side,i.lastContact)),t instanceof Ft&&t.onCollisionEnd(i.self,i.other,i.side,i.lastContact)})}onRemove(){this.events.clear(),this.$colliderRemoved.notifyAll(this._collider)}useBoxCollider(t,e,i=v.Half,s=v.Zero){const n=ut.Box(t,e,i,s);return this.set(n)}usePolygonCollider(t,e=v.Zero){const i=ut.Polygon(t,e);return this.set(i)}useCircleCollider(t,e=v.Zero){const i=ut.Circle(t,e);return this.set(i)}useEdgeCollider(t,e){const i=ut.Edge(t,e);return this.set(i)}useCompositeCollider(t){return this.set(new at(t))}}var he=(r=>(r.Rotation="rotation",r.X="x",r.Y="y",r))(he||{});const En=class ds extends Dt{constructor(t){var e,i,s;super(),this.dependencies=[A,U],this.id=_e("body",ds._ID++),this.events=new X,this.oldTransform=new Qt,this.__oldTransformCaptured=!1,this.enableFixedUpdateInterpolate=!0,this.collisionType=M.PreventCollision,this.group=pe.All,this._sleeping=!1,this.bounciness=.2,this.friction=.99,this.useGravity=!0,this.limitDegreeOfFreedom=[],this._oldGlobalPos=v.Zero,this.oldVel=new v(0,0),this.oldAcc=v.Zero,this._impulseScratch=b(0,0),this._distanceFromCenterScratch=b(0,0),t?(this.collisionType=(e=t.type)!=null?e:this.collisionType,this.group=(i=t.group)!=null?i:this.group,this.useGravity=(s=t.useGravity)!=null?s:this.useGravity,this._bodyConfig={...Jt().bodies,...t.config}):this._bodyConfig={...Jt().bodies},this.updatePhysicsConfig(this._bodyConfig),this._mass=ds._DEFAULT_CONFIG.defaultMass}get matrix(){return this.transform.get().matrix}updatePhysicsConfig(t){this._bodyConfig={...Jt().bodies,...t},this.canSleep=this._bodyConfig.canSleepByDefault,this.sleepMotion=this._bodyConfig.sleepEpsilon*5,this.wakeThreshold=this._bodyConfig.wakeThreshold}static updateDefaultPhysicsConfig(t){ds._DEFAULT_CONFIG=t}get mass(){return this._mass}set mass(t){this._mass=t,this._cachedInertia=void 0,this._cachedInverseInertia=void 0}get inverseMass(){return this.collisionType===M.Fixed?0:1/this.mass}get sleeping(){return this.isSleeping}get isSleeping(){return this._sleeping}setSleeping(t){this.isSleeping=t}set isSleeping(t){this._sleeping=t,t?(this.vel=v.Zero,this.acc=v.Zero,this.angularVelocity=0,this.sleepMotion=0):this.sleepMotion=this._bodyConfig.sleepEpsilon*5}updateMotion(){this._sleeping&&(this.isSleeping=!0);const t=this.vel.magnitude*this.vel.magnitude+Math.abs(this.angularVelocity*this.angularVelocity),e=this._bodyConfig.sleepBias;this.sleepMotion=e*this.sleepMotion+(1-e)*t,this.sleepMotion=B(this.sleepMotion,0,10*this._bodyConfig.sleepEpsilon),this.canSleep&&this.sleepMotion<this._bodyConfig.sleepEpsilon&&(this.isSleeping=!0)}get inertia(){if(this._cachedInertia)return this._cachedInertia;const t=this.owner.get(tt);if(t){t.$colliderAdded.subscribe(()=>{this._cachedInertia=null}),t.$colliderRemoved.subscribe(()=>{this._cachedInertia=null});const e=t.get();if(e)return this._cachedInertia=e.getInertia(this.mass)}return 0}get inverseInertia(){return this._cachedInverseInertia?this._cachedInverseInertia:this._cachedInverseInertia=this.collisionType===M.Fixed?0:1/this.inertia}get active(){var t;return!!((t=this.owner)!=null&&t.isActive)}get isActive(){var t;return!!((t=this.owner)!=null&&t.isActive)}get center(){return this.globalPos}onAdd(t){var e,i;this.transform=(e=this.owner)==null?void 0:e.get(A),this.motion=(i=this.owner)==null?void 0:i.get(U)}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t}get globalPos(){return this.transform.globalPos}set globalPos(t){this.transform.globalPos=t}get oldPos(){return this.oldTransform.pos}get oldGlobalPos(){return this._oldGlobalPos}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 oldRotation(){return this.oldTransform.rotation}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 oldScale(){return this.oldTransform.scale}get scaleFactor(){return this.motion.scaleFactor}set scaleFactor(t){this.motion.scaleFactor=t}get angularVelocity(){return this.motion.angularVelocity}set angularVelocity(t){this.motion.angularVelocity=t}applyImpulse(t,e){if(this.collisionType!==M.Active)return;const i=e.scale(this.inverseMass,this._impulseScratch);if(this.limitDegreeOfFreedom.indexOf("x")>-1&&(i.x=0),this.limitDegreeOfFreedom.indexOf("y")>-1&&(i.y=0),this.vel.addEqual(i),!this.limitDegreeOfFreedom.includes("rotation")){const s=t.sub(this.globalPos,this._distanceFromCenterScratch);this.angularVelocity+=this.inverseInertia*s.cross(e)}}applyLinearImpulse(t){if(this.collisionType!==M.Active)return;const e=t.scale(this.inverseMass);this.limitDegreeOfFreedom.includes("x")&&(e.x=0),this.limitDegreeOfFreedom.includes("y")&&(e.y=0),this.vel=this.vel.add(e)}applyAngularImpulse(t,e){if(this.collisionType===M.Active&&!this.limitDegreeOfFreedom.includes("rotation")){const i=t.sub(this.globalPos);this.angularVelocity+=this.inverseInertia*i.cross(e)}}captureOldTransform(){this.__oldTransformCaptured=!0;const t=this.transform.get();t.clone(this.oldTransform),this.oldTransform.parent=t.parent,this.oldVel.setTo(this.vel.x,this.vel.y),this.oldAcc.setTo(this.acc.x,this.acc.y),this.oldGlobalPos.setTo(this.globalPos.x,this.globalPos.y)}clone(){return super.clone()}};En._ID=0,En._DEFAULT_CONFIG={...Jt().bodies};let N=En;class In{constructor(t,e){this.object=t,this.id=-1,this.cells=[],this.hasZeroBounds=!1,this.gridSize=e,this.bounds=t.bounds,this.hasZeroBounds=this.bounds.hasZeroDimensions(),this.leftX=Math.floor(this.bounds.left/this.gridSize),this.rightX=Math.floor(this.bounds.right/this.gridSize),this.bottomY=Math.floor(this.bounds.bottom/this.gridSize),this.topY=Math.floor(this.bounds.top/this.gridSize)}hasChanged(){const t=this.object.bounds,e=Math.floor(t.left/this.gridSize),i=Math.floor(t.right/this.gridSize),s=Math.floor(t.bottom/this.gridSize),n=Math.floor(t.top/this.gridSize);return this.leftX!==e||this.rightX!==i||this.bottomY!==s||this.topY!==n}clear(){for(const t of this.cells){const e=t.proxies.indexOf(this);e>-1&&t.proxies.splice(e,1)}}updateBounds(){this.bounds=this.object.bounds}update(){this.bounds=this.object.bounds,this.leftX=Math.floor(this.bounds.left/this.gridSize),this.rightX=Math.floor(this.bounds.right/this.gridSize),this.bottomY=Math.floor(this.bounds.bottom/this.gridSize),this.topY=Math.floor(this.bounds.top/this.gridSize),this.hasZeroBounds=this.object.bounds.hasZeroDimensions()}}class Yt{constructor(){this.proxies=[]}configure(t,e){this.x=t,this.y=e,this.key=Yt.calculateHashKey(t,e)}static calculateHashKey(t,e){return`${t}+${e}`}}class Rn{constructor(t){this.bounds=new D,this._hashGridCellPool=new Ve(()=>new Yt,e=>(e.configure(0,0),e.proxies.length=0,e),1e3),this.gridSize=t.size,this.sparseHashGrid=new Map,this.objectToProxy=new Map,t.proxyFactory?this._buildProxy=e=>t.proxyFactory(e,this.gridSize):this._buildProxy=e=>new In(e,this.gridSize)}query(t){const e=new Set;if(t instanceof D){const i=t,s=Math.floor(i.left/this.gridSize),n=Math.floor(i.right/this.gridSize),o=Math.floor(i.bottom/this.gridSize),a=Math.floor(i.top/this.gridSize);for(let h=s;h<=n;h++)for(let l=a;l<=o;l++){const c=Yt.calculateHashKey(h,l),u=this.sparseHashGrid.get(c);if(u)for(let _=0;_<u.proxies.length;_++)u.proxies[_].updateBounds(),u.proxies[_].bounds.intersect(i)&&e.add(u.proxies[_].object)}}else{const i=t,s=Yt.calculateHashKey(Math.floor(i.x/this.gridSize),Math.floor(i.y/this.gridSize)),n=this.sparseHashGrid.get(s);if(n)for(let o=0;o<n.proxies.length;o++)n.proxies[o].updateBounds(),n.proxies[o].bounds.contains(i)&&e.add(n.proxies[o].object)}return Array.from(e)}get(t,e){const i=Yt.calculateHashKey(t,e);return this.sparseHashGrid.get(i)}_insert(t,e,i){const s=Yt.calculateHashKey(t,e);let n=this.sparseHashGrid.get(s);n||(n=this._hashGridCellPool.rent(),n.configure(t,e),this.sparseHashGrid.set(n.key,n)),n.proxies.push(i),i.cells.push(n),this.bounds.combine(i.bounds,this.bounds)}_remove(t,e,i){const s=Yt.calculateHashKey(t,e),n=this.sparseHashGrid.get(s);if(n){const o=n.proxies.indexOf(i);o>-1&&n.proxies.splice(o,1);const a=i.cells.indexOf(n);a>-1&&i.cells.splice(a,1),n.proxies.length===0&&(this._hashGridCellPool.return(n),this.sparseHashGrid.delete(s))}}track(t){const e=this._buildProxy(t);this.objectToProxy.set(t,e);for(let i=e.leftX;i<=e.rightX;i++)for(let s=e.topY;s<=e.bottomY;s++)this._insert(i,s,e)}untrack(t){const e=this.objectToProxy.get(t);e&&(e.clear(),this.objectToProxy.delete(t))}update(t){let e=0;for(const i of t){const s=this.objectToProxy.get(i);if(s&&s.hasChanged()){for(let n=s.leftX;n<=s.rightX;n++)for(let o=s.topY;o<=s.bottomY;o++)this._remove(n,o,s);s.update();for(let n=s.leftX;n<=s.rightX;n++)for(let o=s.topY;o<=s.bottomY;o++)this._insert(n,o,s);e++}}return e}debug(t,e){const i=P.Transparent,s=P.White;for(const n of this.sparseHashGrid.values())t.drawRectangle(b(n.x*this.gridSize,n.y*this.gridSize),this.gridSize,this.gridSize,i,s,2)}}class Eo extends In{constructor(t,e){var i,s,n;super(t,e),this.collider=t,this.id=-1,this.hasZeroBounds=!1,this.cells=[],this.gridSize=e;const o=t.bounds;this.hasZeroBounds=o.hasZeroDimensions(),this.leftX=Math.floor(o.left/this.gridSize),this.rightX=Math.floor(o.right/this.gridSize),this.bottomY=Math.floor(o.bottom/this.gridSize),this.topY=Math.floor(o.top/this.gridSize),this.owner=t.owner,this.body=(i=this.owner)==null?void 0:i.get(N),this.collisionType=(n=(s=this.body)==null?void 0:s.collisionType)!=null?n:M.PreventCollision}update(){var t,e,i;super.update(),this.body=(t=this.owner)==null?void 0:t.get(N),this.collisionType=(i=(e=this.body)==null?void 0:e.collisionType)!=null?i:M.PreventCollision,this.hasZeroBounds=this.collider.localBounds.hasZeroDimensions()}}class Mn{constructor(t){this._pairs=new Set,this._nonPairs=new Set,this._pairPool=new zi(()=>new pt({id:_e("collider",0)},{id:_e("collider",0)}),e=>(e.colliderA=null,e.colliderB=null,e),200),this.gridSize=t.size,this.hashGrid=new Rn({size:this.gridSize,proxyFactory:(e,i)=>new Eo(e,i)}),this._pairPool.disableWarnings=!0}getColliders(){return Array.from(this.hashGrid.objectToProxy.keys())}query(t){return this.hashGrid.query(t)}rayCast(t,e){var i,s,n;const o=[],a=(i=e==null?void 0:e.maxDistance)!=null?i:1/0,h=e==null?void 0:e.collisionGroup,l=h?h.category:(s=e==null?void 0:e.collisionMask)!=null?s:pe.All.category,c=(n=e==null?void 0:e.searchAllColliders)!=null?n:!1,u=t.dir.normalize(),_=u.y/u.x,f=u.x/u.y,g=Math.sqrt(1+_*_)*this.gridSize,p=Math.sqrt(1+f*f)*this.gridSize,x=t.pos.x/this.gridSize,m=t.pos.y/this.gridSize,w=b(1,1);let S=~~x,C=~~m,T=0,I=0;u.x<0?(w.x=-1,T=(x-S)*g):(w.x=1,T=(S+1-x)*g),u.y<0?(w.y=-1,I=(m-C)*p):(w.y=1,I=(C+1-m)*p);const y=new Set;let F=!1,W=9999;for(;!F&&W>0&&(W--,!!this.hashGrid.bounds.contains(b(S*this.gridSize,C*this.gridSize)));){const q=Yt.calculateHashKey(S,C),Y=this.hashGrid.sparseHashGrid.get(q);if(Y){const ht=[];for(let $=0;$<Y.proxies.length;$++){const O=Y.proxies[$];if(!y.has(O.collider.id.value)){if(y.add(O.collider.id.value),O.body){if(e!=null&&e.ignoreCollisionGroupAll&&O.body.group===pe.All)continue;const ft=(l&O.body.group.category)!==0;if(O.body.group&&!ft)continue}const ct=O.collider.rayCast(t,a);ct&&ht.push(ct)}}ht.sort(($,O)=>$.distance-O.distance);for(let $=0;$<ht.length;$++){const O=ht[$];if(e!=null&&e.filter){if(e.filter(O)&&(o.push(O),!c)){F=!0;break}}else if(o.push(O),!c){F=!0;break}}}T<I?(S+=w.x,T+=g):(C+=w.y,I+=p)}return o.sort((q,Y)=>q.distance-Y.distance),!c&&o.length?[o[0]]:o}track(t){let e=[t];if(t instanceof at){const i=t.getColliders();for(const s of i)s.owner=t.owner;e=i}for(const i of e)this.hashGrid.track(i)}untrack(t){let e=[t];t instanceof at&&(e=t.getColliders());for(const i of e)this.hashGrid.untrack(i)}_canCollide(t,e){return!(t.collider.id===e.collider.id||t.owner&&e.owner&&t.owner.id===e.owner.id||t.hasZeroBounds||e.hasZeroBounds||t.body&&e.body&&!t.body.group.canCollide(e.body.group)||t.collisionType===M.Fixed&&e.collisionType===M.Fixed||t.collisionType===M.PreventCollision||e.collisionType===M.PreventCollision||!t.owner.isActive||!e.owner.isActive)}broadphase(t,e){const i=[];this._pairs.clear(),this._nonPairs.clear();let s=0;for(const n of this.hashGrid.objectToProxy.values())if(n.id=s++,!(!n.owner.isActive||n.collisionType===M.PreventCollision))for(let o=0;o<n.cells.length;o++){const a=n.cells[o];for(let h=0;h<a.proxies.length;h++){const l=a.proxies[h];if(l.id===n.id)continue;const c=pt.calculatePairHash(n.collider.id,l.collider.id);if(!this._nonPairs.has(c))if(!this._pairs.has(c)&&this._canCollide(n,l)&&n.object.bounds.overlaps(l.object.bounds)){const u=this._pairPool.get();u.colliderA=n.collider,u.colliderB=l.collider,u.id=c,this._pairs.add(c),i.push(u)}else this._nonPairs.add(c)}}return i}narrowphase(t,e){const i=[];for(let s=0;s<t.length;s++){const n=t[s].collide();for(let o=0;o<n.length;o++){const a=n[o];i.push(a),e&&e.physics.contacts.set(a.id,a)}}return this._pairPool.done(),e&&(e.physics.collisions+=i.length),i}update(t,e){return this.hashGrid.update(t)}debug(t,e){this.hashGrid.debug(t,e)}}class Ze{constructor(t,e){this.bounds=t,this.options=e,this._defaultOptions={maxDepth:10,capacity:10,level:0},this.items=[],this._isDivided=!1,this.topLeft=null,this.topRight=null,this.bottomLeft=null,this.bottomRight=null,this.options={...this._defaultOptions,...e},this.halfWidth=t.width/2,this.halfHeight=t.height/2}_split(){this._isDivided=!0;const t={maxDepth:this.options.maxDepth,capacity:this.options.capacity,level:this.options.level+1};this.topLeft=new Ze(new D({left:this.bounds.left,top:this.bounds.top,right:this.bounds.left+this.halfWidth,bottom:this.bounds.top+this.halfHeight}),t),this.topRight=new Ze(new D({left:this.bounds.left+this.halfWidth,top:this.bounds.top,right:this.bounds.right,bottom:this.bounds.top+this.halfHeight}),t),this.bottomLeft=new Ze(new D({left:this.bounds.left,top:this.bounds.top+this.halfHeight,right:this.bounds.left+this.halfWidth,bottom:this.bounds.bottom}),t),this.bottomRight=new Ze(new D({left:this.bounds.left+this.halfWidth,top:this.bounds.top+this.halfHeight,right:this.bounds.right,bottom:this.bounds.bottom}),t)}_insertIntoSubNodes(t){var e,i,s,n;(e=this.topLeft)!=null&&e.bounds.overlaps(t.bounds)&&this.topLeft.insert(t),(i=this.topRight)!=null&&i.bounds.overlaps(t.bounds)&&this.topRight.insert(t),(s=this.bottomLeft)!=null&&s.bounds.overlaps(t.bounds)&&this.bottomLeft.insert(t),(n=this.bottomRight)!=null&&n.bounds.overlaps(t.bounds)&&this.bottomRight.insert(t)}insert(t){if(this._isDivided){this._insertIntoSubNodes(t);return}if(this.items.push(t),this.items.length>this.options.capacity&&this.options.level<this.options.maxDepth){this._isDivided||this._split();for(const e of this.items)this._insertIntoSubNodes(e);this.items.length=0}}remove(t){var e,i,s,n;if(this.bounds.overlaps(t.bounds)){if(!this._isDivided){const o=this.items.indexOf(t);o>-1&&this.items.splice(o,1);return}(e=this.topLeft)!=null&&e.bounds.overlaps(t.bounds)&&this.topLeft.remove(t),(i=this.topRight)!=null&&i.bounds.overlaps(t.bounds)&&this.topRight.remove(t),(s=this.bottomLeft)!=null&&s.bounds.overlaps(t.bounds)&&this.bottomLeft.remove(t),(n=this.bottomRight)!=null&&n.bounds.overlaps(t.bounds)&&this.bottomRight.remove(t)}}query(t){let e=this.items;return this._isDivided&&(this.topLeft.bounds.overlaps(t)&&(e=e.concat(this.topLeft.query(t))),this.topRight.bounds.overlaps(t)&&(e=e.concat(this.topRight.query(t))),this.bottomLeft.bounds.overlaps(t)&&(e=e.concat(this.bottomLeft.query(t))),this.bottomRight.bounds.overlaps(t)&&(e=e.concat(this.bottomRight.query(t)))),e=e.filter((i,s)=>e.indexOf(i)>=s),e}clear(){this.items=[],this._isDivided=!1,this.topLeft=null,this.topRight=null,this.bottomLeft=null,this.bottomRight=null}getAllItems(){let t=this.items;return this._isDivided&&(t=t.concat(this.topLeft.getAllItems()),t=t.concat(this.topRight.getAllItems()),t=t.concat(this.bottomLeft.getAllItems()),t=t.concat(this.bottomRight.getAllItems())),t=t.filter((e,i)=>t.indexOf(e)>=i),t}getTreeDepth(){return this._isDivided?1+Math.max(this.topLeft.getTreeDepth(),this.topRight.getTreeDepth(),this.bottomLeft.getTreeDepth(),this.bottomRight.getTreeDepth()):0}debug(t){this.bounds.draw(t,P.Yellow),this._isDivided&&(this.topLeft.bounds.draw(t,P.Yellow),this.topRight.bounds.draw(t,P.Yellow),this.bottomLeft.bounds.draw(t,P.Yellow),this.bottomRight.bounds.draw(t,P.Yellow))}}class Dn{constructor(t){this.config=t,this.directionMap=new Map,this.distanceMap=new Map,this._compositeContactsIds=new Set}solve(t){this.preSolve(t),t=t.filter(i=>!i.isCanceled());let e;switch(this.config.contactSolveBias){case oe.HorizontalFirst:{e=en;break}case oe.VerticalFirst:{e=tn;break}default:e=sn}t.sort((i,s)=>{const n=this.directionMap.get(i.id),o=this.directionMap.get(s.id),a=this.distanceMap.get(i.id),h=this.distanceMap.get(s.id);return e[n]-e[o]||a-h});for(const i of t)this.solvePosition(i),this.solveVelocity(i);return this.postSolve(t),t}preSolve(t){for(let i=0;i<t.length;i++){const s=t[i],n=s.id.indexOf("|");if(n>0){const l=s.id.substring(n+1);if(this._compositeContactsIds.has(l)){s.cancel();continue}this._compositeContactsIds.add(l)}if(Math.abs(s.mtv.x)<1e-4&&Math.abs(s.mtv.y)<1e-4){s.cancel();continue}const o=d.Side.fromDirection(s.mtv),a=s.mtv.negate(),h=Math.abs(s.info.separation);this.distanceMap.set(s.id,h),this.directionMap.set(s.id,o===d.Side.Left||o===d.Side.Right?"horizontal":"vertical"),s.colliderA.events.emit("precollision",new me(s.colliderA,s.colliderB,o,a,s)),s.colliderB.events.emit("precollision",new me(s.colliderB,s.colliderA,d.Side.getOpposite(o),a.negate(),s))}this._compositeContactsIds.clear()}postSolve(t){var e,i;for(let s=0;s<t.length;s++){const n=t[s];if(n.isCanceled())continue;const o=n.colliderA,a=n.colliderB,h=(e=o.owner)==null?void 0:e.get(N),l=(i=a.owner)==null?void 0:i.get(N);if(h&&l&&(h.collisionType===M.Passive||l.collisionType===M.Passive))continue;const c=d.Side.fromDirection(n.mtv),u=n.mtv.negate();n.colliderA.events.emit("postcollision",new ve(n.colliderA,n.colliderB,c,u,n)),n.colliderB.events.emit("postcollision",new ve(n.colliderB,n.colliderA,d.Side.getOpposite(c),u.negate(),n))}}solvePosition(t){var e,i;if(!t.colliderA.bounds.overlaps(t.colliderB.bounds,1e-4)){t.cancel();return}if(Math.abs(t.mtv.x)<1e-4&&Math.abs(t.mtv.y)<1e-4){t.cancel();return}let n=t.mtv;const o=t.colliderA,a=t.colliderB,h=(e=o.owner)==null?void 0:e.get(N),l=(i=a.owner)==null?void 0:i.get(N);if(h&&l){if(h.collisionType===M.Passive||l.collisionType===M.Passive)return;h.collisionType===M.Active&&l.collisionType===M.Active&&(n=n.scale(.5)),h.collisionType===M.Active&&(h.globalPos.x-=n.x,h.globalPos.y-=n.y,o.update(h.transform.get())),l.collisionType===M.Active&&(l.globalPos.x+=n.x,l.globalPos.y+=n.y,a.update(l.transform.get()))}}solveVelocity(t){var e,i;if(t.isCanceled())return;const s=t.colliderA,n=t.colliderB,o=(e=s.owner)==null?void 0:e.get(N),a=(i=n.owner)==null?void 0:i.get(N);if(o&&a){if(o.collisionType===M.Passive||a.collisionType===M.Passive)return;const h=t.normal,l=h.negate();if(o.collisionType===M.Active&&o.vel.normalize().dot(l)<0){const c=h.scale(h.dot(o.vel.negate()));o.vel=o.vel.add(c)}if(a.collisionType===M.Active&&a.vel.normalize().dot(h)<0){const c=l.scale(l.dot(a.vel.negate()));a.vel=a.vel.add(c)}}}}class Io{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 v(0,0),this.bToContact=new v(0,0),this.originalVelocityAndRestitution=0,this.update()}update(){const t=this.contact.bodyA,e=this.contact.colliderA,i=this.contact.bodyB,s=this.contact.colliderB;if(t&&i){const n=this.contact.normal,o=this.contact.tangent;this.aToContact=this.point.sub(e.center),this.bToContact=this.point.sub(s.center);const a=this.aToContact.cross(n),h=this.bToContact.cross(n);this.normalMass=t.inverseMass+i.inverseMass+t.inverseInertia*a*a+i.inverseInertia*h*h;const l=this.aToContact.cross(o),c=this.bToContact.cross(o);this.tangentMass=t.inverseMass+i.inverseMass+t.inverseInertia*l*l+i.inverseInertia*c*c}return this}getRelativeVelocity(){const t=this.contact.bodyA,e=this.contact.bodyB;if(t&&e){const i=t.vel.add(v.cross(t.angularVelocity,this.aToContact));return e.vel.add(v.cross(e.angularVelocity,this.bToContact)).sub(i)}return v.Zero}}class Fn{constructor(t){this.config=t,this.directionMap=new Map,this.distanceMap=new Map,this.lastFrameContacts=new Map,this.idToContactConstraint=new Map}getContactConstraints(t){var e;return(e=this.idToContactConstraint.get(t))!=null?e:[]}solve(t){this.preSolve(t),t=t.filter(i=>!i.isCanceled());let e;switch(this.config.contactSolveBias){case oe.HorizontalFirst:{e=en;break}case oe.VerticalFirst:{e=tn;break}default:e=sn}return t.sort((i,s)=>{const n=this.directionMap.get(i.id),o=this.directionMap.get(s.id),a=this.distanceMap.get(i.id),h=this.distanceMap.get(s.id);return e[n]-e[o]||a-h}),this.solveVelocity(t),this.solvePosition(t),this.postSolve(t),t}preSolve(t){var e,i,s,n;for(let h=0;h<t.length;h++){const l=t[h];if(Math.abs(l.mtv.x)<1e-4&&Math.abs(l.mtv.y)<1e-4){l.cancel();continue}const c=d.Side.fromDirection(l.mtv),u=Math.abs(((e=l==null?void 0:l.info)==null?void 0:e.separation)||0);this.distanceMap.set(l.id,u),this.directionMap.set(l.id,c===d.Side.Left||c===d.Side.Right?"horizontal":"vertical"),l.colliderA.events.emit("precollision",new me(l.colliderA,l.colliderB,c,l.mtv,l)),l.colliderA.events.emit("beforecollisionresolve",new Ri(l.colliderA,l.colliderB,c,l.mtv,l)),l.colliderB.events.emit("precollision",new me(l.colliderB,l.colliderA,d.Side.getOpposite(c),l.mtv.negate(),l)),l.colliderB.events.emit("beforecollisionresolve",new Ri(l.colliderB,l.colliderA,d.Side.getOpposite(c),l.mtv.negate(),l)),l.matchAwake()}const a=Array.from(this.idToContactConstraint.keys());for(let h=0;h<t.length;h++){const l=t[h],c=a.indexOf(l.id);c>-1&&a.splice(c,1);const u=(i=this.idToContactConstraint.get(l.id))!=null?i:[];let _=0;const f=l.bodyA,g=l.colliderA,p=l.bodyB,x=l.colliderB;if(f&&p)for(let m=0;m<l.points.length;m++){const w=l.points[m],S=l.normal,C=l.tangent,T=w.sub(g.center),I=w.sub(x.center),y=T.cross(S),F=I.cross(S),W=f.inverseMass+p.inverseMass+f.inverseInertia*y*y+p.inverseInertia*F*F,q=T.cross(C),Y=I.cross(C),ht=f.inverseMass+p.inverseMass+f.inverseInertia*q*q+p.inverseInertia*Y*Y;u[_]&&((n=(s=u[_])==null?void 0:s.point)==null?void 0:n.squareDistance(w))<4?(u[_].point=w,u[_].local=l.localPoints[_]):u[_]=new Io(w,l.localPoints[_],l),u[_].aToContact=T,u[_].bToContact=I,u[_].normalMass=1/W,u[_].tangentMass=1/ht;const $=f.bounciness>p.bounciness?f.bounciness:p.bounciness,O=l.normal.dot(u[_].getRelativeVelocity());u[_].originalVelocityAndRestitution=0,O<-.1&&(u[_].originalVelocityAndRestitution=-$*O),_++}this.idToContactConstraint.set(l.id,u)}for(const h of a)this.idToContactConstraint.delete(h);if(this.config.warmStart)this.warmStart(t);else for(let h=0;h<t.length;h++){const l=t[h],c=this.getContactConstraints(l.id);for(const u of c)u.normalImpulse=0,u.tangentImpulse=0}}postSolve(t){for(let e=0;e<t.length;e++){const i=t[e],s=i.bodyA,n=i.bodyB;if(s&&n){if(s.collisionType===M.Passive||n.collisionType===M.Passive)continue;s.updateMotion(),n.updateMotion()}const o=d.Side.fromDirection(i.mtv);i.colliderA.events.emit("postcollision",new ve(i.colliderA,i.colliderB,o,i.mtv,i)),i.colliderA.events.emit("aftercollisionresolve",new Mi(i.colliderA,i.colliderB,o,i.mtv,i)),i.colliderB.events.emit("postcollision",new ve(i.colliderB,i.colliderA,d.Side.getOpposite(o),i.mtv.negate(),i)),i.colliderB.events.emit("aftercollisionresolve",new Mi(i.colliderB,i.colliderA,d.Side.getOpposite(o),i.mtv.negate(),i))}this.lastFrameContacts.clear();for(let e=0;e<t.length;e++){const i=t[e];this.lastFrameContacts.set(i.id,i)}}warmStart(t){var e;for(let i=0;i<t.length;i++){const s=t[i],n=s.bodyA,o=s.bodyB;if(n&&o){const a=(e=this.idToContactConstraint.get(s.id))!=null?e:[];for(const h of a)if(this.config.warmStart){const l=s.normal.scale(h.normalImpulse),c=s.tangent.scale(h.tangentImpulse),u=l.add(c);n.applyImpulse(h.point,u.negate()),o.applyImpulse(h.point,u)}else h.normalImpulse=0,h.tangentImpulse=0}}}solvePosition(t){var e;for(let i=0;i<this.config.positionIterations;i++)for(let s=0;s<t.length;s++){const n=t[s],o=n.bodyA,a=n.bodyB;if(o&&a){if(o.collisionType===M.Passive||a.collisionType===M.Passive)continue;const h=(e=this.idToContactConstraint.get(n.id))!=null?e:[];for(const l of h){const c=n.normal,u=Lt.FindContactSeparation(n,l.local),_=this.config.steeringFactor,f=-5,g=this.config.slop,p=B(_*(u+g),f,0),x=c.scale(-p*l.normalMass);if(o.collisionType===M.Active){const m=x.negate().scale(o.inverseMass);o.limitDegreeOfFreedom.includes(he.X)&&(m.x=0),o.limitDegreeOfFreedom.includes(he.Y)&&(m.y=0),o.globalPos=o.globalPos.add(m),o.limitDegreeOfFreedom.includes(he.Rotation)||(o.rotation-=l.aToContact.cross(x)*o.inverseInertia)}if(a.collisionType===M.Active){const m=x.scale(a.inverseMass);a.limitDegreeOfFreedom.includes(he.X)&&(m.x=0),a.limitDegreeOfFreedom.includes(he.Y)&&(m.y=0),a.globalPos=a.globalPos.add(m),a.limitDegreeOfFreedom.includes(he.Rotation)||(a.rotation+=l.bToContact.cross(x)*a.inverseInertia)}}}}}solveVelocity(t){var e;for(let i=0;i<this.config.velocityIterations;i++)for(let s=0;s<t.length;s++){const n=t[s],o=n.bodyA,a=n.bodyB;if(o&&a){if(o.collisionType===M.Passive||a.collisionType===M.Passive)continue;const h=Math.min(o.friction,a.friction),l=(e=this.idToContactConstraint.get(n.id))!=null?e:[];for(const c of l){let f=-c.getRelativeVelocity().dot(n.tangent)*c.tangentMass;const g=h*c.normalImpulse,p=B(c.tangentImpulse+f,-g,g);f=p-c.tangentImpulse,c.tangentImpulse=p;const x=n.tangent.scale(f);o.applyImpulse(c.point,x.negate()),a.applyImpulse(c.point,x)}for(const c of l){const _=c.getRelativeVelocity().dot(n.normal);let f=-c.normalMass*(_-c.originalVelocityAndRestitution);const g=Math.max(c.normalImpulse+f,0);f=g-c.normalImpulse,c.normalImpulse=g;const p=n.normal.scale(f);o.applyImpulse(c.point,p.negate()),a.applyImpulse(c.point,p)}}}}}class ji extends At{constructor(t,e){super(),this.world=t,this.physics=e,this.systemType=Pt.Update,this._physicsConfigDirty=!1,this.query=this.world.query({components:{all:[A,U]},tags:{not:this.physics.config.integration.onScreenOnly?["ex.offscreen"]:[]}}),e.$configUpdate.subscribe(()=>{this._physicsConfigDirty=!0})}update(t){let e,i;const s=this.query.entities,o=this.physics.config.substep;for(let a=0;a<s.length;a++){if(e=s[a].get(A),i=s[a].get(U),i.integration.onScreenOnly&&s[a].hasTag("ex.offscreen"))continue;const h=s[a].get(N);if(this._physicsConfigDirty&&h&&h.updatePhysicsConfig(this.physics.config.bodies),h!=null&&h.isSleeping)continue;const l=i.acc.clone();(h==null?void 0:h.collisionType)===M.Active&&(h!=null&&h.useGravity)&&l.addEqual(this.physics.config.gravity),s[a].parent||this.captureOldTransformWithChildren(s[a]),Yr.integrate(e,i,l,t/o)}this._physicsConfigDirty&&(this._physicsConfigDirty=!1,this.query=this.world.query({components:{all:[A,U]},tags:{not:this.physics.config.integration.onScreenOnly?["ex.offscreen"]:[]}}))}captureOldTransformWithChildren(t){var e;(e=t.get(N))==null||e.captureOldTransform();for(let i=0;i<t.children.length;i++)this.captureOldTransformWithChildren(t.children[i])}}ji.priority=Nt.Higher;class Zi extends At{constructor(t,e){super(),this._physics=e,this.systemType=Pt.Update,this._configDirty=!1,this._lastFrameContacts=new Map,this._currentFrameContacts=new Map,this._arcadeSolver=new Dn(e.config.arcade),this._realisticSolver=new Fn(e.config.realistic),this._physics.$configUpdate.subscribe(()=>this._configDirty=!0),this._trackCollider=i=>this._processor.track(i),this._untrackCollider=i=>this._processor.untrack(i),this.query=t.query([A,tt]),this.query.entityAdded$.subscribe(i=>{const s=i.get(tt);s.$colliderAdded.subscribe(this._trackCollider),s.$colliderRemoved.subscribe(this._untrackCollider);const n=s.get();n&&this._processor.track(n)}),this.query.entityRemoved$.subscribe(i=>{const s=i.get(tt),n=s.get();s&&n&&this._processor.untrack(n)}),this._motionSystem=t.get(ji)}get _processor(){return this._physics.collisionProcessor}initialize(t,e){this._engine=e.engine}update(t){var e,i,s,n;if(!this._physics.config.enabled)return;let o=[];for(let u=0;u<this.query.entities.length;u++){const f=this.query.entities[u].get(tt),g=f==null?void 0:f.get();if(f&&((e=f.owner)!=null&&e.isActive)&&g)if(f.update(),g instanceof at){const p=g.getColliders();g.compositeStrategy||(g.compositeStrategy=this._physics.config.colliders.compositeStrategy),o=o.concat(p)}else o.push(g)}this._processor.update(o,t);let a=this._processor.broadphase(o,t);this._currentFrameContacts.clear();let h=[];const l=this.getSolver(),c=this._physics.config.substep;for(let u=0;u<c;u++)if(u>0&&this._motionSystem.update(t),h.length&&(a=h.map(_=>new pt(_.colliderA,_.colliderB))),a.length){h=this._processor.narrowphase(a,(n=(s=(i=this._engine)==null?void 0:i.debug)==null?void 0:s.stats)==null?void 0:n.currFrame),h=l.solve(h);for(const _ of h){if(_.isCanceled())continue;const f=_.id.indexOf("|");if(f>0){const g=_.id.substring(f+1);this._currentFrameContacts.set(g,_)}else this._currentFrameContacts.set(_.id,_)}}this.runContactStartEnd(),this._lastFrameContacts.clear(),this._lastFrameContacts=new Map(this._currentFrameContacts);for(const u of this.query.entities){const _=u.get(tt);_&&_.processColliderRemoval()}}postupdate(){He.SeparationPool.done()}getSolver(){return this._configDirty&&(this._configDirty=!1,this._arcadeSolver=new Dn(this._physics.config.arcade),this._realisticSolver=new Fn(this._physics.config.realistic)),this._physics.config.solver===ki.Realistic?this._realisticSolver:this._arcadeSolver}debug(t){this._processor.debug(t,0)}runContactStartEnd(){for(const[t,e]of this._currentFrameContacts)if(!this._lastFrameContacts.has(t)){const i=e.colliderA,s=e.colliderB,n=d.Side.fromDirection(e.mtv),o=d.Side.getOpposite(n);i.events.emit("collisionstart",new si(i,s,n,e)),i.events.emit("contactstart",new Ei(i,s,n,e)),s.events.emit("collisionstart",new si(s,i,o,e)),s.events.emit("contactstart",new Ei(s,i,o,e))}for(const[t,e]of this._lastFrameContacts)if(!this._currentFrameContacts.has(t)){const i=e.colliderA,s=e.colliderB,n=d.Side.fromDirection(e.mtv),o=d.Side.getOpposite(n);i.events.emit("collisionend",new ni(i,s,n,e)),i.events.emit("contactend",new Ii(i,s,n,e)),s.events.emit("collisionend",new ni(s,i,o,e)),s.events.emit("contactend",new Ii(s,i,o,e))}}}Zi.priority=Nt.Higher;class Ro{constructor(t){this.$configUpdate=new gt,this._configDirty=!1,this.config=t,this.$configUpdate.subscribe(e=>{this._configDirty=!0,N.updateDefaultPhysicsConfig(e.bodies)}),this._config.spatialPartition===ai.SparseHashGrid?this._collisionProcessor=new Mn(this._config.sparseHashGrid):this._collisionProcessor=new Li(this._config)}get config(){return Eh(this._config,t=>{this.$configUpdate.notifyAll(t)})}set config(t){this._config=t,this.$configUpdate.notifyAll(t)}get collisionProcessor(){if(this._configDirty){this._configDirty=!1;const t=this._collisionProcessor.getColliders();this._config.spatialPartition===ai.SparseHashGrid?this._collisionProcessor=new Mn(this._config.sparseHashGrid):this._collisionProcessor=new Li(this._config);for(const e of t)this._collisionProcessor.track(e)}return this._collisionProcessor}rayCast(t,e){return this.collisionProcessor.rayCast(t,e)}query(t){return this._collisionProcessor.query(t)}}var gi=(r=>(r.Fixed="Fixed",r.FitContainerAndFill="FitContainerAndFill",r.FitScreenAndFill="FitScreenAndFill",r.FitContainerAndZoom="FitContainerAndZoom",r.FitScreenAndZoom="FitScreenAndZoom",r.FitScreen="FitScreen",r.FillScreen="FillScreen",r.FitContainer="FitContainer",r.FillContainer="FillContainer",r))(gi||{});class Bn{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}}}const xl={ScreenResize:"resize",PixelRatioChange:"pixelratio",FullScreenChange:"fullscreen"};class Ln{constructor(t){this.events=new X,this._antialiasing=!0,this._canvasImageRendering="auto",this._resolutionStack=[],this._viewportStack=[],this._pixelRatioOverride=null,this._isFullscreen=!1,this._isDisposed=!1,this._logger=R.getInstance(),this._fullscreenChangeHandler=()=>{this._isDisposed||(this._isFullscreen=!this._isFullscreen,this._logger.debug("Fullscreen Change",this._isFullscreen),this.events.emit("fullscreen",{fullscreen:this.isFullscreen}))},this._pixelRatioChangeHandler=()=>{this._isDisposed||(this._logger.debug("Pixel Ratio Change",window.devicePixelRatio),this._listenForPixelRatio(),this._devicePixelRatio=this._calculateDevicePixelRatio(),this.applyResolutionAndViewport(),this.events.emit("pixelratio",{pixelRatio:this.pixelRatio}))},this._resizeHandler=()=>{if(this._isDisposed)return;const o=this.parent;this._logger.debug("View port resized"),this._setResolutionAndViewportByDisplayMode(o),this.applyResolutionAndViewport(),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})},this._devicePixelRatio=this._calculateDevicePixelRatio(),this._contentArea=new D,this._unsafeArea=new D;var e,i,s,n;this.viewport=t.viewport,this.resolution=(e=t.resolution)!=null?e:{...this.viewport},this._contentResolution=this.resolution,this._displayMode=(i=t.displayMode)!=null?i:"Fixed",this._canvas=t.canvas,this.graphicsContext=t.context,this._antialiasing=(s=t.antialiasing)!=null?s:this._antialiasing,this._canvasImageRendering=(n=t.canvasImageRendering)!=null?n:this._canvasImageRendering,this._browser=t.browser,this._pixelRatioOverride=t.pixelRatio,this._applyDisplayMode(),this._listenForPixelRatio(),this._canvas.addEventListener("fullscreenchange",this._fullscreenChangeHandler),this.applyResolutionAndViewport()}_listenForPixelRatio(){this._mediaQueryList&&!this._mediaQueryList.addEventListener&&this._mediaQueryList.removeListener(this._pixelRatioChangeHandler),this._mediaQueryList=this._browser.window.nativeComponent.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._mediaQueryList.addEventListener?this._mediaQueryList.addEventListener("change",this._pixelRatioChangeHandler,{once:!0}):this._mediaQueryList.addListener(this._pixelRatioChangeHandler)}dispose(){this._isDisposed||(this._isDisposed=!0,this.events.clear(),this._browser.window.off("resize",this._resizeHandler),this._browser.window.clear(),this._resizeObserver&&this._resizeObserver.disconnect(),this.parent.removeEventListener("resize",this._resizeHandler),this._mediaQueryList.removeEventListener?this._mediaQueryList.removeEventListener("change",this._pixelRatioChangeHandler):this._mediaQueryList.removeListener(this._pixelRatioChangeHandler),this._canvas.removeEventListener("fullscreenchange",this._fullscreenChangeHandler),this._canvas=null)}_calculateDevicePixelRatio(){return window.devicePixelRatio<1?1:window.devicePixelRatio||1}get pixelRatio(){return this._pixelRatioOverride?this._pixelRatioOverride:this._devicePixelRatio}get worldToPagePixelRatio(){if(this._canvas){const t=this.worldToPageCoordinates(v.Zero);return this.worldToPageCoordinates(b(1,0)).sub(t).x}else return 1}get pixelRatioOverride(){return this._pixelRatioOverride}set pixelRatioOverride(t){this._pixelRatioOverride=t}get isHiDpi(){return this.pixelRatio!==1}get displayMode(){return this._displayMode}get canvas(){return this._canvas}get parent(){switch(this.displayMode){case"FillContainer":case"FitContainer":case"FitContainerAndFill":case"FitContainerAndZoom":return this.canvas.parentElement||document.body;default:return 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={...this.resolution},this.viewport={...this.viewport}}peekViewport(){return this._viewportStack[this._viewportStack.length-1]}peekResolution(){return this._resolutionStack[this._resolutionStack.length-1]}popResolutionAndViewport(){this._resolutionStack.length&&this._viewportStack.length&&(this.resolution=this._resolutionStack.pop(),this.viewport=this._viewportStack.pop())}applyResolutionAndViewport(){if(this.graphicsContext instanceof Xt&&!this.graphicsContext.checkIfResolutionSupported({width:this.scaledWidth,height:this.scaledHeight})&&(this._logger.warnOnce(`The currently configured resolution (${this.resolution.width}x${this.resolution.height}) and pixel ratio (${this.pixelRatio}) are 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.pixelRatioOverride)){let s=Math.max(1,this.pixelRatio-.5),n=!1;for(;s>1&&!n;){s=Math.max(1,s-.5);const o=this._resolution.width*s,a=this._resolution.height*s;n=this.graphicsContext.checkIfResolutionSupported({width:o,height:a})}this.pixelRatioOverride=s,this._logger.warnOnce(`Scaled resolution too big attempted recovery! Pixel ratio was automatically reduced to (${this.pixelRatio}) to avoid 4k texture limit. Setting \`ex.Engine({pixelRatio: ...}) will override any automatic recalculation, do so at your own risk.\` (read more here https://excaliburjs.com/docs/screens#understanding-viewport--resolution).`)}this._canvas.width=this.scaledWidth,this._canvas.height=this.scaledHeight,this._canvasImageRendering==="auto"?this._canvas.style.imageRendering="auto":(this._canvas.style.imageRendering="pixelated",this._canvas.style.imageRendering===""&&(this._canvas.style.imageRendering="crisp-edges"));const t=this.viewport.widthUnit==="percent"?"%":"px",e=this.viewport.heightUnit==="percent"?"%":"px";this._canvas.style.width=this.viewport.width+t,this._canvas.style.height=this.viewport.height+e,this.graphicsContext.updateViewport(this.resolution),this.graphicsContext.resetTransform(),this.graphicsContext.smoothing=this._antialiasing,this.graphicsContext instanceof Xi&&this.graphicsContext.scale(this.pixelRatio,this.pixelRatio),document.documentElement.style.setProperty("--ex-pixel-ratio",this.worldToPagePixelRatio.toString())}get antialiasing(){return this._antialiasing}set antialiasing(t){this._antialiasing=t,this.graphicsContext.smoothing=this._antialiasing}get isFullScreen(){return this._isFullscreen}get isFullscreen(){return this._isFullscreen}goFullScreen(t){return this.enterFullscreen(t)}enterFullscreen(t){var e,i,s,n,o,a;if(t){const h=document.getElementById(t);if(h!=null&&h.requestFullscreen||h!=null&&h.webkitRequestFullscreen){if(h.getAttribute("ex-fullscreen-listener")||(h.setAttribute("ex-fullscreen-listener","true"),h.addEventListener("fullscreenchange",this._fullscreenChangeHandler)),h.requestFullscreen)return(e=h.requestFullscreen())!=null?e:Promise.resolve();if(h.webkitRequestFullscreen)return(i=h.webkitRequestFullscreen())!=null?i:Promise.resolve()}}return(s=this._canvas)!=null&&s.requestFullscreen?(o=(n=this._canvas)==null?void 0:n.requestFullscreen())!=null?o:Promise.resolve():this._canvas.webkitRequestFullscreen?(a=this._canvas.webkitRequestFullscreen())!=null?a:Promise.resolve():(this._logger.warnOnce("Could not go fullscreen, is this an iPhone? Currently Apple does not support fullscreen on iPhones"),Promise.resolve())}exitFullScreen(){return this.exitFullscreen()}exitFullscreen(){return document.exitFullscreen()}_viewportToPixels(t){return{width:t.widthUnit==="percent"?this.canvas.offsetWidth:t.width,height:t.heightUnit==="percent"?this.canvas.offsetHeight:t.height}}pageToScreenCoordinates(t){let e=t.x,i=t.y;this._isFullscreen||(e-=ri(this._canvas).x,i-=ri(this._canvas).y);const s=this._viewportToPixels(this.viewport);if(this._isFullscreen)if(window.innerWidth/this.aspectRatio<window.innerHeight){const n=window.innerWidth/this.aspectRatio,o=(window.innerHeight-n)/2;i=(i-o)/n*s.height,e=e/window.innerWidth*s.width}else{const n=window.innerHeight*this.aspectRatio,o=(window.innerWidth-n)/2;e=(e-o)/n*s.width,i=i/window.innerHeight*s.height}return e=e/s.width*this.resolution.width,i=i/s.height*this.resolution.height,e=e-this.contentArea.left,i=i-this.contentArea.top,new v(e,i)}screenToPageCoordinates(t){let e=t.x,i=t.y;const s=this._viewportToPixels(this.viewport);if(e=e/this.resolution.width*s.width,i=i/this.resolution.height*s.height,this._isFullscreen)if(window.innerWidth/this.aspectRatio<window.innerHeight){const n=window.innerWidth/this.aspectRatio,o=(window.innerHeight-n)/2;i=i/s.height*n+o,e=e/s.width*window.innerWidth}else{const n=window.innerHeight*this.aspectRatio,o=(window.innerWidth-n)/2;e=e/s.width*n+o,i=i/s.height*window.innerHeight}return this._isFullscreen||(e+=ri(this._canvas).x,i+=ri(this._canvas).y),new v(e,i)}screenToWorldCoordinates(t){return t=t.add(b(this.contentArea.left,this.contentArea.top)),this._camera?this._camera.inverse.multiply(t):t.sub(b(this.resolution.width/2,this.resolution.height/2))}worldToScreenCoordinates(t){return this._camera?this._camera.transform.multiply(t):t.add(b(this.resolution.width/2,this.resolution.height/2))}pageToWorldCoordinates(t){const e=this.pageToScreenCoordinates(t);return this.screenToWorldCoordinates(e)}worldToPageCoordinates(t){const e=this.worldToScreenCoordinates(t);return this.screenToPageCoordinates(e)}getWorldBounds(){return D.fromDimension(this.resolution.width,this.resolution.height,v.Half).scale(b(1/this._camera.zoom,1/this._camera.zoom)).rotate(this._camera.rotation).translate(this._camera.drawPos)}getScreenBounds(){return D.fromDimension(this.resolution.width,this.resolution.height,v.Zero,v.Zero)}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 width(){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 height(){return this._camera?this.resolution.height/this._camera.zoom:this.resolution.height}get halfDrawHeight(){return this.drawHeight/2}get center(){return b(this.halfDrawWidth,this.halfDrawHeight)}get contentArea(){return this._contentArea}get unsafeArea(){return this._unsafeArea}_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},this._contentArea=D.fromDimension(this.resolution.width,this.resolution.height,v.Zero),this._unsafeArea=D.fromDimension(this.resolution.width,this.resolution.height,v.Zero),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})}_computeFitScreenAndFill(){document.body.style.margin="0px",document.body.style.overflow="hidden";const t=window.innerWidth,e=window.innerHeight;this._computeFitAndFill(t,e),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})}_computeFitContainerAndFill(){this.canvas.style.width="100%",this.canvas.style.height="100%",this._computeFitAndFill(this.canvas.offsetWidth,this.canvas.offsetHeight,{width:100,widthUnit:"percent",height:100,heightUnit:"percent"}),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})}_computeFitAndFill(t,e,i){if(this.viewport=i!=null?i:{width:t,height:e},t/e<=this._contentResolution.width/this._contentResolution.height){this.resolution={width:t*this._contentResolution.width/t,height:t*this._contentResolution.width/t*e/t};const s=(this.resolution.height-this._contentResolution.height)/2;this._contentArea=new D({top:s,left:0,right:this._contentResolution.width,bottom:this.resolution.height-s}),this._unsafeArea=new D({top:-s,left:0,right:this._contentResolution.width,bottom:this.resolution.height+s})}else{this.resolution={width:e*this._contentResolution.height/e*t/e,height:e*this._contentResolution.height/e};const s=(this.resolution.width-this._contentResolution.width)/2;this._contentArea=new D({top:0,left:s,right:this.resolution.width-s,bottom:this._contentResolution.height}),this._unsafeArea=new D({top:0,left:-s,right:this.resolution.width+s,bottom:this._contentResolution.height})}}_computeFitScreenAndZoom(){document.body.style.margin="0px",document.body.style.overflow="hidden",this.canvas.style.position="absolute";const t=window.innerWidth,e=window.innerHeight;this._computeFitAndZoom(t,e),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})}_computeFitContainerAndZoom(){this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="relative";const t=this.canvas.parentElement;t.style.overflow="hidden";const{offsetWidth:e,offsetHeight:i}=this.canvas;this._computeFitAndZoom(e,i),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})}_computeFitAndZoom(t,e){const i=this.aspectRatio;let s=0,n=0;t/i<e?(s=t,n=t/i):(s=e*i,n=e);const o=t/s,a=e/n,h=Math.max(o,a),l=s*h,c=n*h;l>t?this.canvas.style.left=-(l-t)/2+"px":this.canvas.style.left="",c>e?this.canvas.style.top=-(c-e)/2+"px":this.canvas.style.top="",this.viewport={width:l,height:c};const u=D.fromDimension(this.viewport.width,this.viewport.height,v.Zero);if(this.viewport.width>t){const _=(this.viewport.width-t)/this.viewport.width*this.resolution.width;u.top=0,u.left=_/2,u.right=this.resolution.width-_/2,u.bottom=this.resolution.height}if(this.viewport.height>e){const _=(this.viewport.height-e)/this.viewport.height*this.resolution.height;u.top=_/2,u.left=0,u.bottom=this.resolution.height-_/2,u.right=this.resolution.width}this._contentArea=u}_computeFitContainer(){const t=this.aspectRatio;let e=0,i=0,s="pixel",n="pixel";const o=this.canvas.parentElement;o.clientWidth/t<o.clientHeight?(this.canvas.style.width="100%",e=100,s="percent",i=this.canvas.offsetWidth/t):(this.canvas.style.height="100%",i=100,n="percent",e=this.canvas.offsetHeight*t),this.viewport={width:e,widthUnit:s,height:i,heightUnit:n},this._contentArea=D.fromDimension(this.resolution.width,this.resolution.height,v.Zero),this.events.emit("resize",{resolution:this.resolution,viewport:this.viewport})}_applyDisplayMode(){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==="FillContainer"&&(this.canvas.style.width="100%",this.canvas.style.height="100%",this.viewport={width:100,widthUnit:"percent",height:100,heightUnit:"percent"},this.resolution={width:this.canvas.offsetWidth,height:this.canvas.offsetHeight}),this.displayMode==="FillScreen"&&(document.body.style.margin="0px",document.body.style.overflow="hidden",this.resolution={width:t.innerWidth,height:t.innerHeight},this.viewport=this.resolution),this._contentArea=D.fromDimension(this.resolution.width,this.resolution.height,v.Zero),this.displayMode==="FitScreen"&&this._computeFit(),this.displayMode==="FitContainer"&&this._computeFitContainer(),this.displayMode==="FitScreenAndFill"&&this._computeFitScreenAndFill(),this.displayMode==="FitContainerAndFill"&&this._computeFitContainerAndFill(),this.displayMode==="FitScreenAndZoom"&&this._computeFitScreenAndZoom(),this.displayMode==="FitContainerAndZoom"&&this._computeFitContainerAndZoom()}}class pi{static create(){return this._INSTANCE||(window.AudioContext||window.webkitAudioContext)&&(this._INSTANCE=new AudioContext),this._INSTANCE}}function bl(r){return!!r.playbackState}const Mo=class us{static unlock(){return new Promise((e,i)=>{if(us._UNLOCKED||!pi.create())return e(!0);const s=setTimeout(()=>{R.getInstance().warn("Excalibur was unable to unlock the audio context, audio probably will not play in this browser."),e(!1)},200),n=pi.create();n.resume().then(()=>{const o=n.createBuffer(1,1,22050),a=n.createBufferSource();let h=!1;a.buffer=o,a.connect(n.destination),a.onended=()=>h=!0,a.start(0),setTimeout(()=>{bl(a)?(a.playbackState===a.PLAYING_STATE||a.playbackState===a.FINISHED_STATE)&&(us._UNLOCKED=!0):(n.currentTime>0||h)&&(us._UNLOCKED=!0)},0),clearTimeout(s),e(!0)},()=>{i()})})}static isUnlocked(){return this._UNLOCKED}};Mo._UNLOCKED=!1;let Do=Mo;class kn{}kn.type={any:"",blob:"blob",json:"json",text:"text",document:"document",arraybuffer:"arraybuffer"};class Qi{constructor(){this.states=new Map}get currentState(){return this._currentState}set currentState(t){this._currentState=t}static create(t,e){const i=new Qi;i.data=e;for(const s in t.states)i.states.set(s,{name:s,...t.states[s]});for(const s of i.states.values())for(const n of s.transitions)if(n!=="*"&&!i.states.has(n))throw Error(`Invalid state machine, state [${s.name}] has a transition to another state that doesn't exist [${n}]`);return i.currentState=i.startState=i.states.get(t.start),i}in(t){return this.currentState.name===t}go(t,e){var i,s;if(this.currentState.transitions.includes(t)||this.currentState.transitions.includes("*")){const n=this.states.get(t);return this.currentState.onExit&&((i=this.currentState)==null?void 0:i.onExit({to:n.name,data:this.data}))===!1||n!=null&&n.onEnter&&(n==null?void 0:n.onEnter({from:this.currentState.name,eventData:e,data:this.data}))===!1?!1:(this.currentState=n,(s=this.currentState)!=null&&s.onState&&this.currentState.onState(),!0)}return!1}update(t){this.currentState.onUpdate&&this.currentState.onUpdate(this.data,t)}save(t){localStorage.setItem(t,JSON.stringify({currentState:this.currentState.name,data:this.data}))}restore(t){const e=JSON.parse(localStorage.getItem(t));this.currentState=this.states.get(e.currentState),this.data=e.data}}class Fo{constructor(t){this._src=t,this._audioContext=pi.create(),this._volumeNode=this._audioContext.createGain(),this._playingFuture=new wt,this._stateMachine=Qi.create({start:"STOPPED",states:{PLAYING:{onEnter:({data:e})=>{this._createNewBufferSource(),this._handleEnd(),this.loop?this._instance.start(0,e.pausedAt*this._playbackRate):this._instance.start(0,e.pausedAt*this._playbackRate,this.duration),e.startedAt=this._audioContext.currentTime-e.pausedAt,e.pausedAt=0},onState:()=>this._playStarted(),onExit:({to:e})=>{e==="STOPPED"&&this._playingFuture.resolve(!0),this._instance.onended=null,this._instance.disconnect(),this._instance.stop(0),this._instance=null},transitions:["STOPPED","PAUSED","SEEK"]},SEEK:{onEnter:({eventData:e,data:i})=>{i.pausedAt=(e!=null?e:0)/this._playbackRate,i.startedAt=0},transitions:["*"]},STOPPED:{onEnter:({data:e})=>{e.pausedAt=0,e.startedAt=0,this._playingFuture.resolve(!0)},transitions:["PLAYING","PAUSED","SEEK"]},PAUSED:{onEnter:({data:e})=>{e.pausedAt=this._audioContext.currentTime-e.startedAt},transitions:["PLAYING","STOPPED","SEEK"]}}},{startedAt:0,pausedAt:0}),this._volume=1,this._loop=!1,this._playStarted=()=>{},this._playbackRate=1,this._createNewBufferSource()}_createNewBufferSource(){this._instance=this._audioContext.createBufferSource(),this._instance.buffer=this._src,this._instance.loop=this.loop,this._instance.playbackRate.value=this._playbackRate,this._instance.connect(this._volumeNode),this._volumeNode.connect(this._audioContext.destination)}_handleEnd(){this.loop||(this._instance.onended=()=>{this._playingFuture.resolve(!0)})}set loop(t){this._loop=t,this._instance&&(this._instance.loop=t,this.loop||(this._instance.onended=()=>{this._playingFuture.resolve(!0)}))}get loop(){return this._loop}set volume(t){t=B(t,0,1),this._volume=t,this._stateMachine.in("PLAYING")&&this._volumeNode.gain.setTargetAtTime?this._volumeNode.gain.setTargetAtTime(t,this._audioContext.currentTime,.1):this._volumeNode.gain.value=t}get volume(){return this._volume}get duration(){var t;return(t=this._duration)!=null?t:this.getTotalPlaybackDuration()}set duration(t){this._duration=t}isPlaying(){return this._stateMachine.in("PLAYING")}isPaused(){return this._stateMachine.in("PAUSED")||this._stateMachine.in("SEEK")}isStopped(){return this._stateMachine.in("STOPPED")}play(t=()=>{}){return this._playStarted=t,this._stateMachine.go("PLAYING"),this._playingFuture.promise}pause(){this._stateMachine.go("PAUSED")}stop(){this._stateMachine.go("STOPPED")}seek(t){this._stateMachine.go("PAUSED"),this._stateMachine.go("SEEK",t)}getTotalPlaybackDuration(){return this._src.duration}getPlaybackPosition(){const{pausedAt:t,startedAt:e}=this._stateMachine.data;return t?t*this._playbackRate:e?(this._audioContext.currentTime-e)*this._playbackRate:0}set playbackRate(t){this._instance.playbackRate.value=this._playbackRate=t}get playbackRate(){return this._instance.playbackRate.value}}class zn extends k{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 Te extends zn{constructor(t,e){super(t,"NativeSoundEvent"),this.track=e}}class Bo extends zn{constructor(t,e){super(t,"NativeSoundProcessedEvent"),this._processedData=e,this.data=this._processedData}}function yl(r){try{const t=new Audio,e=/.*\.([A-Za-z0-9]+)(?:(?:\?|\#).*)*$/,i=r.match(e)[1];return!!t.canPlayType("audio/"+i)}catch(t){return R.getInstance().warn("Cannot determine audio support, assuming no support for the Audio Tag",t),!1}}const Cl={VolumeChange:"volumechange",Processed:"processed",Pause:"pause",Stop:"stop",PlaybackEnd:"playbackend",Resume:"resume",PlaybackStart:"playbackstart"};function Sl(r){var t;return!!((t=r[0])!=null&&t.paths)}class Un{constructor(...t){this.events=new X,this.logger=R.getInstance(),this._loop=!1,this._volume=1,this._isStopped=!1,this._tracks=[],this._wasPlayingOnHidden=!1,this._playbackRate=1,this._audioContext=pi.create();let e;Sl(t)?e=t[0]:e={paths:t},this._resource=new hi("",kn.type.arraybuffer);const{volume:i,position:s,playbackRate:n,loop:o,bustCache:a,duration:h}=e;this.volume=i!=null?i:this.volume,this.playbackRate=n!=null?n:this.playbackRate,this.loop=o!=null?o:this.loop,this.duration=h!=null?h:this.duration,this.bustCache=a!=null?a:this.bustCache,this.position=s!=null?s:this.position;for(const l of e.paths)if(yl(l)){this.path=l;break}this.path||(this.logger.warn("This browser does not support any of the audio files specified:",e.paths.join(", ")),this.logger.warn("Attempting to use",e.paths[0]),this.path=e.paths[0])}set loop(t){this._loop=t;for(const e of this._tracks)e.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 e of this._tracks)e.volume=this._volume;this.events.emit("volumechange",new Te(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}set duration(t){this._duration=t}get instances(){return this._tracks}get path(){return this._resource.path}set path(t){this._resource.path=t}get bustCache(){return this._resource.bustCache}set bustCache(t){this._resource.bustCache=t}isLoaded(){return!!this.data}async load(){var t,e;if(this.data)return this.data;const i=await this._resource.load(),s=await this.decodeAudio(i.slice(0));return this._duration=(e=(t=this._duration)!=null?t:s==null?void 0:s.duration)!=null?e:void 0,this.events.emit("processed",new Bo(this,s)),this.data=s}async decodeAudio(t){try{return await this._audioContext.decodeAudioData(t.slice(0))}catch(e){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."),await 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())}isPaused(){return this._tracks.some(t=>t.isPaused())}isStopped(){return this._tracks.some(t=>t.isStopped())}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!=null?t:this.volume,this.isPaused()?this._resumePlayback():(this.position&&this.seek(this.position),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.events.emit("pause",new Te(this)),this.logger.debug("Paused all instances of sound",this.path)}}stop(){for(const t of this._tracks)t.stop();this.events.emit("stop",new Te(this)),this._tracks.length=0,this.logger.debug("Stopped all instances of sound",this.path)}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._tracks.forEach(e=>{e.playbackRate=this._playbackRate})}seek(t,e=0){this._tracks.length===0&&this._getTrackInstance(this.data),this._tracks[e].seek(t)}getTotalPlaybackDuration(){return this.isLoaded()?this.data.duration:(this.logger.warnOnce(`Sound from ${this.path} is not loaded, cannot return total playback duration.Did you forget to add Sound to a loader? https://excaliburjs.com/docs/loaders/`),0)}getPlaybackPosition(t=0){return this._tracks.length?this._tracks[t].getPlaybackPosition():0}getTrackId(t){return this._tracks.indexOf(t)}async _resumePlayback(){if(this.isPaused()){const t=[];for(const e of this._tracks)t.push(e.play().then(()=>(this._tracks.splice(this.getTrackId(e),1),!0)));this.events.emit("resume",new Te(this)),this.logger.debug("Resuming paused instances for sound",this.path,this._tracks),await Promise.all(t)}return!0}async _startPlayback(){const t=this._getTrackInstance(this.data),e=await t.play(()=>{this.events.emit("playbackstart",new Te(this,t)),this.logger.debug("Playing new instance for sound",this.path)});this.events.emit("playbackend",new Te(this,t));const i=this.getTrackId(t);return i!==-1&&this._tracks.splice(i,1),e}_getTrackInstance(t){var e;const i=new Fo(t);return i.loop=this.loop,i.volume=this.volume,i.duration=(e=this.duration)!=null?e:0,i.playbackRate=this._playbackRate,this._tracks.push(i),i}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}}const Tl={BeforeLoad:"beforeload",AfterLoad:"afterload",UserAction:"useraction",LoadResourceStart:"loadresourcestart",LoadResourceEnd:"loadresourceend"};function On(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class mi{constructor(t){this.events=new X,this.canvas=new qi({filtering:mt.Blended,smoothing:!0,cache:!1,draw:this.onDraw.bind(this)}),this._resources=[],this._numLoaded=0,this._loaded=!1,this._isLoading=!1,this._totalTimeMs=0,this._resourcesLoadedFuture=new wt,this._loaderCompleteFuture=new wt;var e;t&&((e=t.loadables)!=null&&e.length)&&this.addResources(t.loadables)}get resources(){return this._resources}onInitialize(t){this.engine=t,this.canvas.width=this.engine.screen.resolution.width,this.canvas.height=this.engine.screen.resolution.height}async onUserAction(){return await Promise.resolve()}async onBeforeLoad(){}async onAfterLoad(){await Di(500,this.engine.clock)}addResource(t){this._resources.push(t),this._loaded=!1}addResources(t){let e=0;const i=t.length;for(e;e<i;e++)this.addResource(t[e]);this._loaded=!1}markResourceComplete(){this._numLoaded++}get progress(){const t=this._resources.length;return t>0?B(this._numLoaded,0,t)/t:1}isLoaded(){return this._loaded||this._resources.length===0}onUpdate(t,e){this._totalTimeMs+=e}onDraw(t){const e=this._totalTimeMs/1e3;t.fillStyle=P.Black.toRGBA(),t.fillRect(0,0,this.engine.screen.resolution.width,this.engine.screen.resolution.height),t.save(),t.translate(this.engine.screen.resolution.width/2,this.engine.screen.resolution.height/2);const i=e*10;t.strokeStyle="white",t.lineWidth=10,t.lineCap="round",t.arc(0,0,40,i,i+Math.PI*3/2),t.stroke(),t.fillStyle="white",t.font="16px sans-serif";const s=(this.progress*100).toFixed(0)+"%",n=t.measureText(s),o=Math.abs(n.actualBoundingBoxLeft)+Math.abs(n.actualBoundingBoxRight),a=Math.abs(n.actualBoundingBoxAscent)+Math.abs(n.actualBoundingBoxDescent);t.fillText(s,-o/2,a/2),t.restore()}areResourcesLoaded(){return this._resources.length===0?Promise.resolve():this._resourcesLoadedFuture.promise}async load(){if(this._isLoading)return this._loaderCompleteFuture.promise;if(this.isLoaded())return this.data=this._resources;this._isLoading=!0,this._loaderCompleteFuture=new wt,await this.onBeforeLoad(),this.events.emit("beforeload"),this.canvas.flagDirty(),await Promise.all(this._resources.filter(t=>!t.isLoaded()).map(async t=>{this.events.emit("loadresourcestart",t),await t.load().finally(()=>{this._numLoaded++,this.canvas.flagDirty(),this.events.emit("loadresourceend",t)})}));for(const t of this._resources)t instanceof Un&&t.wireEngine(this.engine);return this._resourcesLoadedFuture.resolve(),this.canvas.flagDirty(),await this.onUserAction(),this.events.emit("useraction"),await Do.unlock(),await this.onAfterLoad(),this.events.emit("afterload"),this._isLoading=!1,this._loaded=!0,this._loaderCompleteFuture.resolve(this._resources),this.data=this._resources}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}}const Pl="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=",Al='button#excalibur-play{display:inline-block;position:relative;z-index:999;border-radius:6px;border:none;padding:1rem 1.5rem 1rem 4rem;margin:0;text-decoration:none;background:#00b233;color:#fff;font-family:sans-serif;font-size:2rem;white-space:nowrap;line-height:1;cursor:pointer;text-align:center;transition:background .25s ease-in-out,transform .15s ease;-webkit-appearance:none;-moz-appearance:none;-webkit-animation:excalibur-button-fadein .2s;-moz-animation:excalibur-button-fadein .2s;-ms-animation:excalibur-button-fadein .2s;-o-animation:excalibur-button-fadein .2s;animation:excalibur-button-fadein .2s}button#excalibur-play:after{position:absolute;content:"";border:8px solid;border-color:transparent transparent transparent white;left:35px;top:24px;width:0;height:0}button#excalibur-play:before{position:absolute;content:"";border:3px solid;left:19px;top:14px;border-radius:20px;width:30px;height:30px}button#excalibur-play:hover,button#excalibur-play:focus{background:#00982c}button#excalibur-play:focus{outline:1px solid #fff;outline-offset:-4px}button#excalibur-play:active{transform:scale(.99)}@keyframes excalibur-button-fadein{0%{opacity:0}to{opacity:1}}@-moz-keyframes excalibur-button-fadein{0%{opacity:0}to{opacity:1}}@-webkit-keyframes excalibur-button-fadein{0%{opacity:0}to{opacity:1}}@-ms-keyframes excalibur-button-fadein{0%{opacity:0}to{opacity:1}}@-o-keyframes excalibur-button-fadein{0%{opacity:0}to{opacity:1}}',Lo=class Fa extends mi{constructor(t){const e=Array.isArray(t)?{loadables:t}:t;super(e),this._logger=R.getInstance(),this._originalOptions={loadables:[]},this.events=new X,this._playButtonShown=!1,this.logo=Pl,this.logoWidth=468,this.logoHeight=118,this.loadingBarColor=P.White,this.backgroundColor="#176BAA",this._imageLoaded=new wt,this.suppressPlayButton=!1,this._playButtonStyles=Al,this.playButtonText="Play game",this.startButtonFactory=()=>{let i=document.getElementById("excalibur-play");return i||(i=document.createElement("button")),i.id="excalibur-play",i.textContent=this.playButtonText,i.style.display="none",i},this._originalOptions={...Fa._DEFAULT_LOADER_OPTIONS,...e}}get _image(){return this._imageElement||(this._imageElement=new Image,this._imageElement.onload=()=>this._imageLoaded.resolve(),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}onInitialize(t){this.engine=t,this.screen=t.screen,this.canvas.width=this.engine.canvas.width,this.canvas.height=this.engine.canvas.height,this.screen.events.on("resize",()=>{this.canvas.width=this.engine.canvas.width,this.canvas.height=this.engine.canvas.height})}async showPlayButton(){var t,e;if(this.suppressPlayButton)this.hidePlayButton(),await Di(500,(t=this.engine)==null?void 0:t.clock);else{const i=()=>{try{this._positionPlayButton()}catch(n){}};return(e=this.engine)!=null&&e.browser&&this.engine.browser.window.on("resize",i),this._playButtonShown=!0,this._playButton.style.display="block",document.body.addEventListener("keyup",n=>{n.key==="Enter"&&this._playButton.click()}),this._positionPlayButton(),await new Promise(n=>{const o=a=>{var h;if(a.stopPropagation(),this.hidePlayButton(),(h=this.engine)!=null&&h.browser&&this.engine.browser.window.off("resize",i),this._originalOptions.fullscreenAfterLoad)try{this._logger.info("requesting fullscreen"),this._originalOptions.fullscreenContainer instanceof HTMLElement?this._originalOptions.fullscreenContainer.requestFullscreen():this.engine.screen.enterFullscreen(this._originalOptions.fullscreenContainer)}catch(l){this._logger.error("could not go fullscreen",l)}n()};this._playButton.addEventListener("click",o),this._playButton.addEventListener("touchend",o),this._playButton.addEventListener("pointerup",o),this.engine&&this.engine.input.gamepads.once("button",()=>o(new Event("button")))})}}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)}async onUserAction(){var t;await Di(200,(t=this.engine)==null?void 0:t.clock),this.canvas.flagDirty(),await this.showPlayButton()}async onBeforeLoad(){this.screen.pushResolutionAndViewport(),this.screen.resolution={width:this.screen.resolution.width,height:this.screen.resolution.height},this.screen.applyResolutionAndViewport();const t=this._image;await this._imageLoaded.promise,await(t==null?void 0:t.decode())}async onAfterLoad(){this.screen.popResolutionAndViewport(),this.screen.applyResolutionAndViewport(),this.dispose()}_positionPlayButton(){if(this.engine){const{x:t,y:e,width:i,height:s}=this.engine.canvas.getBoundingClientRect();if(this._playButtonRootElement){const n=this._playButton.clientWidth,o=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-n/2}px`,this._playButtonRootElement.style.top=`${e+s/2-o/2+100}px`)}}}onDraw(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,i*.75);let o=i/2-n/2;this.logoPosition&&(o=this.logoPosition.x,s=this.logoPosition.y);const a=Math.floor(n*(this.logoHeight/this.logoWidth)),h=this.engine.screen.antialiasing;if(this.engine.screen.antialiasing=!0,this.logoPosition?t.drawImage(this._image,0,0,this.logoWidth,this.logoHeight,o,s,n,a):t.drawImage(this._image,0,0,this.logoWidth,this.logoHeight,o,s-a-20,n,a),!this.suppressPlayButton&&this._playButtonShown){this.engine.screen.antialiasing=h;return}let l=o,c=s;this.loadingBarPosition&&(l=this.loadingBarPosition.x,c=this.loadingBarPosition.y),t.lineWidth=2,dn(t,l,c,n,20,10,this.loadingBarColor);const u=n*this.progress,_=5,f=u-_*2,g=20-_*2;dn(t,l+_,c+_,f>10?f:10,g,5,null,this.loadingBarColor),this.engine.screen.antialiasing=h}};Lo._DEFAULT_LOADER_OPTIONS={loadables:[],fullscreenAfterLoad:!1,fullscreenContainer:void 0};let Ji=Lo;const ko={webgl:"WebGL",webaudio:"WebAudio",gamepadapi:"Gamepad API"};class zo{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(e){return!1}return t.responseType==="arraybuffer"},dataUrlSupport:function(){return document.createElement("canvas").toDataURL("image/png").indexOf("data:image/png")===0},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 this._features===null&&(this._features=this._loadBrowserFeatures()),this._features}logBrowserFeatures(){let t=`%cSUPPORTED BROWSER FEATURES
|
|
784
784
|
==========================%c
|
|
785
785
|
`;const e=["font-weight: bold; color: navy","font-weight: normal; color: inherit"],i=this.getBrowserFeatures();for(const s of Object.keys(ko))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+=" "+ko[s]+`
|
|
786
|
-
`;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),R.getInstance().error("Critical browser feature missing, Excalibur requires:",e),t=!0);if(t)return!1;for(const e in this._warningTest)this._warningTest[e]()||R.getInstance().warn("Warning browser feature missing, Excalibur will have reduced performance:",e);return!0}}function Uo(r){return r instanceof Hn}class Hn extends Ft{constructor(t){var e,i;super({...t}),this.get(A).coordPlane=rt.Screen,this.anchor=(e=t==null?void 0:t.anchor)!=null?e:b(0,0),this.body.collisionType=(i=t==null?void 0:t.collisionType)!=null?i:M.PreventCollision,this.pointer.useGraphicsBounds=!0,this.pointer.useColliderShape=!1,!(t!=null&&t.collider)&&(t==null?void 0:t.width)>0&&(t==null?void 0:t.height)>0&&this.collider.useBoxCollider(this.width,this.height,this.anchor)}_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 v(t,e));return super.contains(s.x,s.y)}}const Oo=class Ba{constructor(t){this._logger=R.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.randomRange=[0,0],this._baseInterval=10,this._generateRandomInterval=()=>this._baseInterval+this.random.integer(this.randomRange[0],this.randomRange[1]),this._complete=!1,this.scene=null;var e;const i=(e=t.action)!=null?e:t.fcn,s=t.interval,n=t.repeats,o=t.numberOfRepeats,a=t.randomRange,h=t.random;if(o&&o>=0&&(this.maxNumberOfRepeats=o,!n))throw new Error("repeats must be set to true if numberOfRepeats is set");if(this.id=Ba._MAX_ID++,this._callbacks=[],this._baseInterval=this.interval=s,a){if(a[0]>a[1])throw new Error("min value must be lower than max value for range");this.random=h!=null?h:new ie,this.randomRange=a,this.interval=this._generateRandomInterval(),this.on(()=>{this.interval=this._generateRandomInterval()})}this.repeats=n||this.repeats,i&&this.on(i)}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(e=>{e.call(this)}),this._numberOfTicks++,this.repeats?this._elapsedTime=0:(this._complete=!0,this._running=!1,this._elapsedTime=0)))}reset(t,e){if(t&&t>=0&&(this._baseInterval=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}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)}};Oo._MAX_ID=0;let Ki=Oo;function Ho(r){return r&&r._dispatchPointerEvents&&r._processPointerToObject}class El{get events(){return this.object.events}init(t,e,i){this.object=t,this.contains=e,this.active=i}}class Nn{constructor(){this._proxyPool=new Ve(()=>new El,t=>t,100),this._objectToProxy=new Map,this._proxies=[],this._lastFrameObjectToPointers=new Map,this._currentFrameObjectToPointers=new Map}addObject(t,e,i){const s=this._proxyPool.rent(!1);s.init(t,e,i),this._proxies.push(s),this._objectToProxy.set(t,s)}_getProxy(t){const e=this._objectToProxy.get(t);if(e)return e;throw new Error("No PointerTargetProxy for object")}removeObject(t){const e=this._objectToProxy.get(t);if(e){const i=this._proxies.indexOf(e);this._objectToProxy.delete(t),i>-1&&this._proxies.splice(i,1),this._proxyPool.return(e)}}_objectCurrentlyUnderPointer(t,e){return!!(this._currentFrameObjectToPointers.has(t)&&this._currentFrameObjectToPointers.get(t).includes(e))}_objectWasUnderPointer(t,e){return!!(this._lastFrameObjectToPointers.has(t)&&this._lastFrameObjectToPointers.get(t).includes(e))}_entered(t,e){return this._objectCurrentlyUnderPointer(t,e)&&!this._lastFrameObjectToPointers.has(t)}_left(t,e){return!this._currentFrameObjectToPointers.has(t)&&this._objectWasUnderPointer(t,e)}addPointerToObject(t,e){const i=this._objectToProxy.get(t);i&&this._addPointerToProxy(i,e)}_addPointerToProxy(t,e){if(!this._currentFrameObjectToPointers.has(t)){this._currentFrameObjectToPointers.set(t,[e]);return}const i=this._currentFrameObjectToPointers.get(t);this._currentFrameObjectToPointers.set(t,i.concat(e))}dispatchEvents(t,e){const i=new Set(this._lastFrameObjectToPointers.keys()),s=new Set(this._currentFrameObjectToPointers.keys());let n,o,a,h=[];if(e)for(let l=0;l<e.length;l++){const c=e[l],u=this._getProxy(c);h.push(u)}else{const l=new Set(i);for(const c of s)l.add(c);h=Array.from(l)}for(let l=0;l<h.length;l++){const c=h[l];if(Ho(c.object)&&c.object._dispatchPointerEvents(t),i.has(c)||s.has(c)){a=this._processDownAndEmit(t,c),o=this._processUpAndEmit(t,c),n=this._processMoveAndEmit(t,c);const u=[...n.values(),...a.values(),...o.values()];this._processEnterLeaveAndEmit(t,c,u),this._processCancelAndEmit(t,c),this._processWheelAndEmit(t,c)}}}processPointerToObject(t,e){for(let i=0;i<e.length;i++){const s=e[i],n=this._getProxy(s);Ho(s)&&s._processPointerToObject(t);for(const[o,a]of t.currentFramePointerCoords.entries())n.contains(a)&&this._addPointerToProxy(n,o)}}clear(){this._lastFrameObjectToPointers.clear(),this._lastFrameObjectToPointers=new Map(this._currentFrameObjectToPointers),this._currentFrameObjectToPointers.clear()}_processDownAndEmit(t,e){const i=new Map;for(const s of t.currentFrameDown)s.active&&this._objectCurrentlyUnderPointer(e,s.pointerId)&&(e.events.emit("pointerdown",s),t.isDragStart(s.pointerId)&&e.events.emit("pointerdragstart",s)),i.set(s.pointerId,s);return i}_processUpAndEmit(t,e){const i=new Map;for(const s of t.currentFrameUp)s.active&&this._objectCurrentlyUnderPointer(e,s.pointerId)&&(e.events.emit("pointerup",s),t.isDragEnd(s.pointerId)&&e.events.emit("pointerdragend",s)),i.set(s.pointerId,s);return i}_processMoveAndEmit(t,e){const i=new Map;for(const s of t.currentFrameMove)s.active&&e.active()&&this._objectCurrentlyUnderPointer(e,s.pointerId)&&(e.events.emit("pointermove",s),t.isDragging(s.pointerId)&&e.events.emit("pointerdragmove",s)),i.set(s.pointerId,s);return i}_processEnterLeaveAndEmit(t,e,i){for(const s of i){if(s.active&&e.active()&&this._entered(e,s.pointerId)){e.events.emit("pointerenter",s),t.isDragging(s.pointerId)&&e.events.emit("pointerdragenter",s);break}if(s.active&&e.active()&&(this._left(e,s.pointerId)||this._objectCurrentlyUnderPointer(e,s.pointerId)&&s.type==="up")){e.events.emit("pointerleave",s),t.isDragging(s.pointerId)&&e.events.emit("pointerdragleave",s);break}}}_processCancelAndEmit(t,e){for(const i of t.currentFrameCancel)i.active&&e.active()&&this._objectCurrentlyUnderPointer(e,i.pointerId)&&e.events.emit("pointercancel",i)}_processWheelAndEmit(t,e){for(const i of t.currentFrameWheel)i.active&&e.active()&&this._objectCurrentlyUnderPointer(e,0)&&e.events.emit("pointerwheel",i)}}const Il={PreUpdate:"preupdate",PostUpdate:"postupdate",PreDraw:"predraw",PostDraw:"postdraw",PointerUp:"pointerup",PointerDown:"pointerdown",PointerMove:"pointermove",PointerCancel:"pointercancel"};class No extends Tt{constructor(t){var e,i,s;super([],t.name),this.events=new X,this._token=0,this.logger=R.getInstance(),this.tiles=[],this._rows=[],this._cols=[],this.renderFromTopOfGraphic=!1,this.meshingLookBehind=10,this._collidersDirty=!0,this._oldRotation=0,this._originalOffsets=new WeakMap,this.meshingLookBehind=(e=t.meshingLookBehind)!=null?e:this.meshingLookBehind,this.addComponent(new A),this.addComponent(new U),this.addComponent(new N({type:M.Fixed})),this.addComponent(new j({onPostDraw:(o,a)=>this.draw(o,a)})),this.addComponent(new Ni((o,a)=>this.debug(o,a),!1)),this.addComponent(new tt),this.addComponent(new ae),this.pointer=this.get(ae),this._graphics=this.get(j),this.transform=this.get(A),this._motion=this.get(U),this.collider=this.get(tt),this._composite=this.collider.useCompositeCollider([]),this.transform.pos=(i=t.pos)!=null?i:v.Zero,this._oldPos=this.transform.pos.clone(),this._oldScale=this.transform.scale.clone(),this.renderFromTopOfGraphic=(s=t.renderFromTopOfGraphic)!=null?s:this.renderFromTopOfGraphic,this.tileWidth=t.tileWidth,this.tileHeight=t.tileHeight,this.rows=t.rows,this.columns=t.columns,this._pointerEventDispatcher=new Nn,this.tiles=new Array(this.rows*this.columns),this._rows=new Array(this.rows),this._cols=new Array(this.columns);let n=[];for(let o=0;o<this.columns;o++){for(let a=0;a<this.rows;a++){const h=new Wo({x:o,y:a,map:this});h.map=this,this.tiles[o+a*this.columns]=h,this._pointerEventDispatcher.addObject(h,l=>h.bounds.contains(l.worldPos),()=>!0),n.push(h),this._rows[a]||(this._rows[a]=[]),this._rows[a].push(h)}this._cols[o]=n,n=[]}this._graphics.localBounds=new D({left:0,top:0,right:this.columns*this.tileWidth*this.scale.x,bottom:this.rows*this.tileHeight*this.scale.y})}flagCollidersDirty(){this._collidersDirty=!0}flagTilesDirty(){for(let t=0;t<this.tiles.length;t++)this.tiles[t]&&this.tiles[t].flagDirty()}get x(){var t;return(t=this.transform.pos.x)!=null?t:0}set x(t){var e;(e=this.transform)!=null&&e.pos&&(this.get(A).pos=b(t,this.y))}get y(){var t,e;return(e=(t=this.transform)==null?void 0:t.pos.y)!=null?e:0}set y(t){var e;(e=this.transform)!=null&&e.pos&&(this.transform.pos=b(this.x,t))}get z(){var t;return(t=this.transform.z)!=null?t:0}set z(t){this.transform&&(this.transform.z=t)}get rotation(){var t,e;return(e=(t=this.transform)==null?void 0:t.rotation)!=null?e:0}set rotation(t){this.transform&&(t!==this.transform.rotation&&(this.flagCollidersDirty(),this.flagTilesDirty()),this.transform.rotation=t)}get scale(){var t,e;return(e=(t=this.transform)==null?void 0:t.scale)!=null?e:v.One}set scale(t){this.transform&&(t!=null&&t.equals(this.transform.scale)||(this.flagCollidersDirty(),this.flagTilesDirty()),this.transform.scale=t)}get pos(){return this.transform.pos}set pos(t){this.transform&&(t!=null&&t.equals(this.transform.pos)||(this.flagCollidersDirty(),this.flagTilesDirty()),this.transform.pos=t)}get vel(){return this._motion.vel}set vel(t){this._motion.vel=t}get width(){return this.tileWidth*this.columns*this.scale.x}get height(){return this.tileHeight*this.rows*this.scale.y}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}_initialize(t){super._initialize(t),this._engine=t}_getOrSetColliderOriginalOffset(t){var e;if(this._originalOffsets.has(t))return(e=this._originalOffsets.get(t))!=null?e:v.Zero;{const i=t.offset;return this._originalOffsets.set(t,i),i}}_updateColliders(){this.collider.$colliderRemoved.notifyAll(this._composite),this._composite.clearColliders();const t=[];this._composite=this.collider.useCompositeCollider([]);let e=null;const i=(n,o)=>n&&o?n.top===o.top&&n.bottom===o.bottom&&n.right===o.left:!1,s=(n,o,a=this.meshingLookBehind)=>{if(!n)return!1;for(let h=o.length-1;h>=0;h--){if(a--<0)return!1;const l=o[h];if(i(l,n))return o[h]=l.combine(n),!0}return!1};for(let n=0;n<this.columns;n++){for(let o=0;o<this.rows;o++){const a=this.tiles[n+o*this.columns];if(a.solid)if(a.getColliders().length>0){for(const h of a.getColliders()){const l=this._getOrSetColliderOriginalOffset(h);h.offset=b(a.x*this.tileWidth*this.scale.x,a.y*this.tileHeight*this.scale.y).add(l),h.owner=this,this._composite.addCollider(h)}e&&!s(e,t)&&t.push(e),e=null}else e?e=e.combine(a.defaultGeometry):e=a.defaultGeometry;else e&&!s(e,t)&&t.push(e),e=null}e&&!s(e,t)&&t.push(e),e=null}for(const n of t){const o=ut.Box(n.width,n.height,v.Zero,b(n.left-this.pos.x,n.top-this.pos.y));o.owner=this,this._composite.addCollider(o)}this.collider.update(),this.collider.$colliderAdded.notifyAll(this._composite)}getTileByIndex(t){var e;return(e=this.tiles[t])!=null?e:null}getTile(t,e){return t<0||e<0||t>=this.columns||e>=this.rows?null:this.tiles[t+e*this.columns]}getTileByPoint(t){const{x:e,y:i}=this._getTileCoordinates(t),s=this.getTile(e,i);return e>=0&&i>=0&&e<this.columns&&i<this.rows&&s?s:null}_getTileCoordinates(t){t=this.transform.applyInverse(t);const e=Math.floor(t.x/this.tileWidth),i=Math.floor(t.y/this.tileHeight);return{x:e,y:i}}getRows(){return this._rows}getColumns(){return this._cols}getOnScreenTiles(){const t=this._engine.screen.getWorldBounds();let e=b(0,0),i=this.transform.coordPlane===rt.Screen?this._engine.screen.getScreenBounds():t;const s=this.get(Wi);if(s&&this.isInitialized){const g=v.One.sub(s.parallaxFactor);e=this._engine.currentScene.camera.pos.scale(g),i=i.translate(e.negate())}const n=this._getTileCoordinates(i.topLeft),o=this._getTileCoordinates(i.topRight),a=this._getTileCoordinates(i.bottomRight),h=this._getTileCoordinates(i.bottomLeft),l=Math.min(B(n.x,0,this.columns-1),B(o.x,0,this.columns-1)),c=Math.min(B(n.y,0,this.rows-1),B(o.y,0,this.rows-1)),u=Math.max(B(a.x,0,this.columns-1),B(h.x,0,this.columns-1)),_=Math.max(B(a.y,0,this.rows-1),B(h.y,0,this.rows-1)),f=[];for(let g=l;g<=u;g++)for(let p=c;p<=_;p++)f.push(this.getTile(g,p));return f}_processPointerToObject(t){const e=Array.from(t.currentFramePointerCoords.entries());for(const[i,s]of e){const n=this.getTileByPoint(this.transform.coordPlane===rt.World?s.worldPos:s.screenPos);n&&this._pointerEventDispatcher.addPointerToObject(n,i)}}_dispatchPointerEvents(t){this._pointerEventDispatcher.dispatchEvents(t)}update(t,e){this._initialize(t),this.onPreUpdate(t,e),this.emit("preupdate",new ne(t,e,this)),(!this._oldPos.equals(this.pos)||this._oldRotation!==this.rotation||!this._oldScale.equals(this.scale))&&(this.flagCollidersDirty(),this.flagTilesDirty()),this._collidersDirty&&(this._collidersDirty=!1,this._updateColliders()),this._pointerEventDispatcher.clear(),this._token++,this.pos.clone(this._oldPos),this._oldRotation=this.rotation,this.scale.clone(this._oldScale),this.transform.pos=this.pos,this.onPostUpdate(t,e),this.emit("postupdate",new re(t,e,this))}draw(t,e){if(!this.isInitialized)return;this.emit("predraw",new ke(t,e,this));let i,s,n;const o=this.getOnScreenTiles();for(let a=0;a<o.length;a++){const h=o[a],l=h.getGraphicsOffsets();for(i=h.getGraphics(),s=0,n=i.length;s<n;s++){const c=i[s],u=l[s];if(c){Sn(c)&&(c==null||c.tick(e,this._token));const _=this.renderFromTopOfGraphic?0:c.height-this.tileHeight;c.draw(t,h.x*this.tileWidth+u.x,h.y*this.tileHeight-_+u.y)}}}this.emit("postdraw",new ze(t,e,this))}debug(t,e){const{showAll:i,showGrid:s,gridColor:n,gridWidth:o,showSolidBounds:a,solidBoundsColor:h,showColliderGeometry:l}=e.tilemap,{geometryColor:c,geometryLineWidth:u,geometryPointSize:_}=e.collider,f=this.tileWidth*this.columns*this.scale.x,g=this.tileHeight*this.rows*this.scale.y,p=this.pos;if(s||i){for(let x=0;x<this.rows+1;x++){const m=b(0,x*this.tileHeight*this.scale.y);t.drawLine(p.add(m),p.add(b(f,m.y)),n,o)}for(let x=0;x<this.columns+1;x++){const m=b(x*this.tileWidth*this.scale.x,0);t.drawLine(p.add(m),p.add(b(m.x,g)),n,o)}}if(i||a||l){const x=this._composite.getColliders();t.save(),t.translate(this.pos.x,this.pos.y),t.scale(this.scale.x,this.scale.y);for(const m of x){const w=m.localBounds,S=m.worldPos.sub(this.pos);a&&t.drawRectangle(S,w.width,w.height,h)}if(t.restore(),l)for(const m of x)m.debug(t,c,{lineWidth:u,pointSize:_})}if(i||a){if(t.save(),t.z=999,a)for(let x=0;x<this.tiles.length;x++)this.tiles[x].bounds.draw(t);t.restore()}}}class Wo{constructor(t){this._posDirty=!1,this.events=new X,this._solid=!1,this._graphics=[],this._offsets=[],this._colliders=[],this.data=new Map;var e,i;this.x=t.x,this.y=t.y,this.map=t.map,this._width=t.map.tileWidth*this.map.scale.x,this._height=t.map.tileHeight*this.map.scale.y,this.solid=(e=t.solid)!=null?e:this.solid,this._graphics=(i=t.graphics)!=null?i:[],this._recalculate()}get pos(){return this._posDirty&&(this._recalculate(),this._posDirty=!1),this._pos}get width(){return this._width}get height(){return this._height}get solid(){return this._solid}set solid(t){var e;(e=this.map)==null||e.flagCollidersDirty(),this._solid=t}getGraphics(){return this._graphics}getGraphicsOffsets(){return this._offsets}addGraphic(t,e){this._graphics.push(t),e!=null&&e.offset?this._offsets.push(e.offset):this._offsets.push(v.Zero)}removeGraphic(t){const e=this._graphics.indexOf(t);e>-1&&(this._graphics.splice(e,1),this._offsets.splice(e,1))}clearGraphics(){this._graphics.length=0,this._offsets.length=0}getColliders(){return this._colliders}addCollider(t){this._colliders.push(t),this.map.flagCollidersDirty()}removeCollider(t){const e=this._colliders.indexOf(t);e>-1&&this._colliders.splice(e,1),this.map.flagCollidersDirty()}clearColliders(){this._colliders.length=0,this.map.flagCollidersDirty()}flagDirty(){this._posDirty=!0}_recalculate(){const t=this.map.pos.add(b(this.x*this.map.tileWidth,this.y*this.map.tileHeight));this._geometry=new D(t.x,t.y,t.x+this.map.tileWidth,t.y+this.map.tileHeight),this._width=this.map.tileWidth*this.map.scale.x,this._height=this.map.tileHeight*this.map.scale.y,this._pos=this.map.pos.add(b(this.x*this._width,this.y*this._height)),this._bounds=new D(this._pos.x,this._pos.y,this._pos.x+this._width,this._pos.y+this._height),this.map.rotation&&(this._bounds=this._bounds.rotate(this.map.rotation,this.map.pos)),this._posDirty=!1}get bounds(){return this._posDirty&&this._recalculate(),this._bounds}get defaultGeometry(){return this._geometry}get center(){return this._posDirty&&this._recalculate(),new v(this._pos.x+this._width/2,this._pos.y+this._height/2)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){e?this.events.off(t,e):this.events.off(t)}}class vi extends Dt{constructor(t){super(),this.elevation=0,this.columns=t.columns,this.rows=t.rows,this.tileWidth=t.tileWidth,this.tileHeight=t.tileHeight}}class Go extends Tt{constructor(t,e,i,s){super([new A,new j({offset:i!=null?i:v.Zero,onPostDraw:(_,f)=>this.draw(_,f)}),new vi(s)]),this.solid=!1,this.events=new X,this._tileBounds=new D,this._graphics=[],this._colliders=[],this.data=new Map,this.x=t,this.y=e,this.map=s,this._transform=this.get(A),this._isometricEntityComponent=this.get(vi);const n=this.map.tileWidth/2,o=this.map.tileHeight/2,a=(this.x-this.y)*n,h=(this.x+this.y)*o;this._transform.pos=b(a,h),this._isometricEntityComponent.elevation=s.elevation,this._gfx=this.get(j),this._gfx.isVisible=!1;const l=this.map.tileWidth,c=this.map.tileHeight,u=b(0,this.map.renderFromTopOfGraphic?c:0);this._gfx.localBounds=this._tileBounds=new D({left:-l/2,top:-c,right:l/2,bottom:c}).translate(u)}getGraphics(){return this._graphics}addGraphic(t,e){this._graphics.push(t),this._gfx.isVisible=this.map.isVisible,this._gfx.opacity=this.map.opacity,e!=null&&e.offset&&(this._gfx.offset=e.offset),this._gfx.localBounds=this._recalculateBounds()}_recalculateBounds(){let t=this._tileBounds.clone();for(const e of this._graphics){const i=b(this.map.graphicsOffset.x-this.map.tileWidth/2,this.map.graphicsOffset.y-(this.map.renderFromTopOfGraphic?0:e.height-this.map.tileHeight));t=t.combine(e.localBounds.translate(i))}return t}removeGraphic(t){const e=this._graphics.indexOf(t);e>-1&&this._graphics.splice(e,1),this._gfx.localBounds=this._recalculateBounds()}clearGraphics(){this._graphics.length=0,this._gfx.isVisible=!1,this._gfx.localBounds=this._recalculateBounds()}getColliders(){return this._colliders}addCollider(t){this._colliders.push(t),this.map.flagCollidersDirty()}removeCollider(t){const e=this._colliders.indexOf(t);e>-1&&this._colliders.splice(e,1),this.map.flagCollidersDirty()}clearColliders(){this._colliders.length=0,this.map.flagCollidersDirty()}get pos(){return this.map.tileToWorld(b(this.x,this.y))}get center(){return this.pos.add(b(0,this.map.tileHeight/2))}draw(t,e){const i=this.map.tileWidth/2;t.save(),t.translate(-i,0);for(const s of this._graphics)s.draw(t,this.map.graphicsOffset.x,this.map.graphicsOffset.y-(this.map.renderFromTopOfGraphic?0:s.height-this.map.tileHeight));t.restore()}}class Rl extends Tt{constructor(t){super([new A,new N({type:M.Fixed}),new tt,new ae,new Ni((c,u)=>this.debug(c,u),!1)],t.name),this.elevation=0,this.isVisible=!0,this.opacity=1,this.renderFromTopOfGraphic=!1,this.graphicsOffset=b(0,0),this._collidersDirty=!1,this._originalOffsets=new WeakMap;const{pos:e,tileWidth:i,tileHeight:s,columns:n,rows:o,renderFromTopOfGraphic:a,graphicsOffset:h,elevation:l}=t;this.transform=this.get(A),e&&(this.transform.pos=e),this.collider=this.get(tt),this.collider&&this.collider.set(this._composite=new at([])),this.pointer=this.get(ae),this.renderFromTopOfGraphic=a!=null?a:this.renderFromTopOfGraphic,this.graphicsOffset=h!=null?h:this.graphicsOffset,this.elevation=l!=null?l:this.elevation,this.tileWidth=i,this.tileHeight=s,this.columns=n,this.rows=o,this._pointerEventDispatcher=new Nn,this.tiles=new Array(n*o);for(let c=0;c<o;c++)for(let u=0;u<n;u++){const _=new Go(u,c,this.graphicsOffset,this);this.tiles[u+c*n]=_,this.addChild(_),this._pointerEventDispatcher.addObject(_,f=>this.getTileByPoint(f.worldPos)===_,()=>!0)}this.pointer.localBounds=D.fromDimension(i*n*this.transform.scale.x,s*o*this.transform.scale.y,b(.5,0))}get visible(){return this.isVisible}set visible(t){this.isVisible=t}_processPointerToObject(t){const e=Array.from(t.currentFramePointerCoords.entries());for(const[i,s]of e){const n=this.getTileByPoint(this.transform.coordPlane===rt.World?s.worldPos:s.screenPos);n&&this._pointerEventDispatcher.addPointerToObject(n,i)}}_dispatchPointerEvents(t){this._pointerEventDispatcher.dispatchEvents(t,this.tiles)}update(){this._collidersDirty&&(this.updateColliders(),this._collidersDirty=!1),this._pointerEventDispatcher.clear()}flagCollidersDirty(){this._collidersDirty=!0}_getOrSetColliderOriginalOffset(t){var e;if(this._originalOffsets.has(t))return(e=this._originalOffsets.get(t))!=null?e:v.Zero;{const i=t.offset;return this._originalOffsets.set(t,i),i}}updateColliders(){this._composite.clearColliders();const t=this.get(A).pos;for(const e of this.tiles)if(e.solid)for(const i of e.getColliders()){const s=this._getOrSetColliderOriginalOffset(i);i.offset=this.tileToWorld(b(e.x,e.y)).sub(t).add(s).sub(b(this.tileWidth/2,this.tileHeight)),i.owner=this,this._composite.addCollider(i)}this.collider.update()}worldToTile(t){t=t.sub(this.transform.globalPos);const e=this.tileWidth/2,i=this.tileHeight/2;return b(~~((t.x/e+t.y/i)/2),~~((t.y/i-t.x/e)/2))}tileToWorld(t){const e=this.tileWidth/2,i=this.tileHeight/2,s=(t.x-t.y)*e,n=(t.x+t.y)*i;return b(s,n).add(this.transform.pos)}getTile(t,e){return t<0||e<0||t>=this.columns||e>=this.rows?null:this.tiles[t+e*this.columns]}getTileByPoint(t){const e=this.worldToTile(t);return this.getTile(e.x,e.y)}_getMaxZIndex(){let t=Number.NEGATIVE_INFINITY;for(const e of this.tiles){const i=e.get(A).z;i>t&&(t=i)}return t}debug(t,e){const{showAll:i,showPosition:s,positionColor:n,positionSize:o,showGrid:a,gridColor:h,gridWidth:l,showColliderGeometry:c}=e.isometric,{geometryColor:u,geometryLineWidth:_,geometryPointSize:f}=e.collider;if(t.save(),t.z=this._getMaxZIndex()+.5,i||a){for(let g=0;g<this.rows+1;g++){const p=this.tileToWorld(b(0,g)),x=this.tileToWorld(b(this.columns,g));t.drawLine(p,x,h,l)}for(let g=0;g<this.columns+1;g++){const p=this.tileToWorld(b(g,0)),x=this.tileToWorld(b(g,this.rows));t.drawLine(p,x,h,l)}}if(i||s)for(const g of this.tiles)t.drawCircle(this.tileToWorld(b(g.x,g.y)),o,n);if(i||c){for(const g of this.tiles)if(g.solid)for(const p of g.getColliders())p.debug(t,u,{lineWidth:_,pointSize:f})}t.restore()}}class Wn extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Update,this.query=this.world.query([A,vi])}update(){let t,e;for(let i=0;i<this.query.entities.length;i++){const s=this.query.entities[i];t=s.get(A),e=s.get(vi);const o=Math.max(e.columns*e.tileWidth,e.rows*e.tileHeight)*e.elevation+t.pos.y;t.z=o}}}Wn.priority=Nt.Lower;class Vo{constructor(t){this.camera=t}lockToActor(t){this.camera.addStrategy(new Xo(t))}lockToActorAxis(t,e){this.camera.addStrategy(new Yo(t,e))}elasticToActor(t,e,i){this.camera.addStrategy(new $o(t,e,i))}radiusAroundActor(t,e){this.camera.addStrategy(new jo(t,e))}limitCameraBounds(t){this.camera.addStrategy(new Zo(t))}}var qo=(r=>(r[r.X=0]="X",r[r.Y=1]="Y",r))(qo||{});class Xo{constructor(t){this.target=t,this.action=(e,i,s,n)=>e.center}}class Yo{constructor(t,e){this.target=t,this.axis=e,this.action=(i,s,n,o)=>{const a=i.center,h=s.getFocus();return this.axis===0?new v(a.x,h.y):new v(h.x,a.y)}}}class $o{constructor(t,e,i){this.target=t,this.cameraElasticity=e,this.cameraFriction=i,this.action=(s,n,o,a)=>{const h=s.center;let l=n.getFocus(),c=n.vel.clone();const u=h.sub(l).scale(this.cameraElasticity);c=c.add(u);const _=c.scale(-1).scale(this.cameraFriction);return c=c.add(_),l=l.add(c),l}}}class jo{constructor(t,e){this.target=t,this.radius=e,this.action=(i,s,n,o)=>{const a=i.center,h=s.getFocus(),l=a.sub(h),c=l.magnitude;if(c>=this.radius){const u=c-this.radius;return h.add(l.normalize().scale(u))}return h}}}class Zo{constructor(t){this.target=t,this.boundSizeChecked=!1,this.action=(e,i,s,n)=>{const o=i.getFocus();this.boundSizeChecked||((e.bottom-e.top<s.drawHeight||e.right-e.left<s.drawWidth)&&R.getInstance().warn("Camera bounds should not be smaller than the engine viewport"),this.boundSizeChecked=!0);let a=o.x,h=o.y;return o.x<e.left+s.halfDrawWidth?a=e.left+s.halfDrawWidth:o.x>e.right-s.halfDrawWidth&&(a=e.right-s.halfDrawWidth),o.y<e.top+s.halfDrawHeight?h=e.top+s.halfDrawHeight:o.y>e.bottom-s.halfDrawHeight&&(h=e.bottom-s.halfDrawHeight),b(a,h)}}}const Ml={Initialize:"initialize",PreUpdate:"preupdate",PostUpdate:"postupdate"};class Qo{constructor(){this.events=new X,this.transform=Q.identity(),this.inverse=Q.identity(),this._cameraStrategies=[],this.strategy=new Vo(this),this._z=1,this.dz=0,this.az=0,this.rotation=0,this._angularVelocity=0,this._posChanged=!1,this._pos=new se(v.Zero,()=>{this._posChanged=!0}),this.drawPos=this.pos.clone(),this._oldPos=this.pos.clone(),this.vel=v.Zero,this.acc=v.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._legacyZoomEasing=It.EaseInOutCubic,this._useLegacyZoom=!1,this._zoomEasing=xs,this._legacyEasing=It.EaseInOutCubic,this._useLegacyEasing=!1,this._easing=xs,this._halfWidth=0,this._halfHeight=0,this._viewport=null,this._isInitialized=!1,this._snapPos=b(0,0)}get strategies(){return this._cameraStrategies}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._angularVelocity}set angularVelocity(t){this._angularVelocity=t}get pos(){return this._pos}set pos(t){this._posChanged=!0,this._pos=new se(t,()=>{this._posChanged=!0})}hasChanged(){return this._posChanged}get x(){return this.pos.x}set x(t){!this._follow&&!this._cameraMoving&&(this.pos=b(t,this.pos.y))}get y(){return this.pos.y}set y(t){!this._follow&&!this._cameraMoving&&(this.pos=b(this.pos.x,t))}get dx(){return this.vel.x}set dx(t){this.vel=b(t,this.vel.y)}get dy(){return this.vel.y}set dy(t){this.vel=b(this.vel.x,t)}get ax(){return this.acc.x}set ax(t){this.acc=b(t,this.acc.y)}get ay(){return this.acc.y}set ay(t){this.acc=b(this.acc.x,t)}getFocus(){return this.pos}move(t,e,i=It.EaseInOutCubic){if(typeof i!="function")throw"Please specify an EasingFunction";return this._follow?Promise.reject(t):(this._lerpPromise&&this._lerpResolve&&this._lerpResolve(t),this._lerpPromise=new Promise(s=>{this._lerpResolve=s}),this._lerpStart=this.getFocus().clone(),this._lerpDuration=e,this._lerpEnd=t,this._currentLerpTime=0,this._cameraMoving=!0,Se(i)?this._legacyEasing=i: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=It.EaseInOutCubic){if(this._zoomPromise=new Promise(s=>{this._zoomResolve=s}),e)this._isZooming=!0,Se(i)?this._legacyZoomEasing=i:this._easing=i,this._currentZoomTime=0,this._zoomDuration=e,this._zoomStart=this.zoom,this._zoomEnd=t;else return this._isZooming=!1,this.zoom=t,Promise.resolve(!0);return this._zoomPromise}get viewport(){return this._viewport?this._viewport:new D(0,0,0,0)}addStrategy(...t){this._cameraStrategies.push(...t)}setStrategies(t){this._cameraStrategies=[...t]}removeStrategy(t){Oe(t,this._cameraStrategies)}clearAllStrategies(){this._cameraStrategies.length=0}_preupdate(t,e){this.events.emit("preupdate",new ne(t,e,this)),this.onPreUpdate(t,e)}onPreUpdate(t,e){}_postupdate(t,e){this.events.emit("postupdate",new re(t,e,this)),this.onPostUpdate(t,e)}onPostUpdate(t,e){}get isInitialized(){return this._isInitialized}_initialize(t){if(!this.isInitialized){this._engine=t,this._screen=t.screen;const e=this._screen.contentArea;let i=b(e.width/2,e.height/2);if(!this._engine.loadingComplete){const s=this._screen.peekResolution();s&&(i=b(s.width/2,s.height/2))}this._halfWidth=i.x,this._halfHeight=i.y,this._posChanged||(this.pos=i),this.pos.clone(this.drawPos),this.updateTransform(this.pos),this.runStrategies(t,t.clock.elapsed()),this.updateViewport(),this.updateTransform(this.pos),this.pos.clone(this._oldPos),this.onInitialize(t),this.events.emit("initialize",new Ue(t,this)),this._isInitialized=!0}}onInitialize(t){}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}runStrategies(t,e){for(const i of this._cameraStrategies)this.pos=i.action.call(i,i.target,this,t,e)}updateViewport(){this._viewport=new D(this.x-this._halfWidth,this.y-this._halfHeight,this.x+this._halfWidth,this.y+this._halfHeight)}update(t,e){if(this._initialize(t),this._preupdate(t,e),this.pos.clone(this._oldPos),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){let i=this.zoom;if(this._useLegacyZoom){const s=this._legacyZoomEasing;i=s(this._currentZoomTime,this._zoomStart,this._zoomEnd,this._zoomDuration)}else i=ot(this._zoomStart,this._zoomEnd,this._zoomEasing(this._currentZoomTime/this._zoomDuration));this.zoom=i,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){let i=this.pos;this._useLegacyEasing?i=It.CreateVectorEasingFunction(this._legacyEasing)(this._currentLerpTime,this._lerpStart,this._lerpEnd,this._lerpDuration):(i.x=ot(this._lerpStart.x,this._lerpEnd.x,this._easing(this._currentLerpTime/this._lerpDuration)),i.y=ot(this._lerpStart.y,this._lerpEnd.y,this._easing(this._currentLerpTime/this._lerpDuration))),this.pos=i,this._currentLerpTime+=e}else{this.pos=this._lerpEnd;const i=this._lerpEnd.clone();this._lerpStart=null,this._lerpEnd=null,this._currentLerpTime=0,this._cameraMoving=!1,this._lerpResolve(i)}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=(Math.random()*this._shakeMagnitudeX|0)+1,this._yShake=(Math.random()*this._shakeMagnitudeY|0)+1),this.runStrategies(t,e),this.updateViewport(),this.updateTransform(this.pos),this._postupdate(t,e),this._posChanged=!1}draw(t){if(this.pos.clone(this.drawPos),this._engine.fixedUpdateTimestep){const e=this._engine.currentFrameLagMs/this._engine.fixedUpdateTimestep,i=this.pos.scale(e).add(this._oldPos.scale(1-e));i.clone(this.drawPos),this.updateTransform(i)}if(t.snapToPixel){const e=this.drawPos.clone(this._snapPos);e.x=~~(e.x+L*G(e.x)),e.y=~~(e.y+L*G(e.y)),e.clone(this.drawPos),this.updateTransform(e)}t.multiply(this.transform)}updateTransform(t){const e=this._screen.resolution.width/this.zoom,i=this._screen.resolution.height/this.zoom,s=b(-t.x+e/2+this._xShake,-t.y+i/2+this._yShake);this.transform.reset(),this.transform.scale(this.zoom,this.zoom),this.transform.translate(e/2,i/2),this.transform.rotate(this.rotation),this.transform.translate(-e/2,-i/2),this.transform.translate(s.x,s.y),this.transform.inverse(this.inverse)}_isDoneShaking(){return!this._isShaking||this._elapsedShakeTime>=this._shakeDuration}}const Dl={ExitTrigger:"exit",EnterTrigger:"enter"};class Jo extends Ft{constructor(t){var e,i,s,n;super({...t}),this.events=new X,this.filter=(e=t.filter)!=null?e:()=>!0,this.repeat=(i=t.repeat)!=null?i:-1,this.action=(s=t.action)!=null?s:()=>{},this.target=t.target,this.graphics.isVisible=(n=t.visible)!=null?n:!1,this.body.collisionType=M.Passive,this.events.on("collisionstart",({other:o})=>{this._matchesTarget(o.owner)&&(this.events.emit("enter",new qs(this,o.owner)),this._dispatchAction(o.owner),this.repeat===0&&this.kill())}),this.events.on("collisionend",({other:o})=>{this._matchesTarget(o.owner)&&this.events.emit("exit",new Xs(this,o.owner))})}_matchesTarget(t){return this.filter(t)&&(this.target===void 0||this.target===t)}_dispatchAction(t){this.repeat!==0&&(this.action.call(this,t),this.repeat--)}}class Gn extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Draw,this.query=this.world.query([A])}initialize(t,e){this._graphicsContext=e.engine.graphicsContext,this._camera=e.camera,this._engine=e.engine,this._collisionSystem=t.systemManager.get(Zi)}update(){var t;if(!this._engine.isDebug)return;const e=this._engine.debug.filter;let i,s;const n=this._engine.debug.entity;let o;const a=this._engine.debug.transform;let h;const l=this._engine.debug.motion;let c;const u=this._engine.debug.collider,_=this._engine.debug.physics;let f;const g=this._engine.debug.graphics;let p,x;const m=this._engine.debug.body,w=this._engine.debug.camera;for(let S=0;S<this.query.entities.length;S++){const C=this.query.entities[S];if(C.hasTag("offscreen")||C instanceof Yi||e.useFilter&&(!(e.ids.length===0||e.ids.includes(C.id))||!(e.nameQuery===""||C.name.includes(e.nameQuery))))continue;let T=v.Zero;const I=b(0,16);if(i=C.id,s=C.name,o=C.get(A),this._pushCameraTransform(o),this._graphicsContext.save(),o.coordPlane===rt.Screen&&this._graphicsContext.translate(this._engine.screen.contentArea.left,this._engine.screen.contentArea.top),this._graphicsContext.z=a.debugZIndex,this._applyTransform(C),o&&((a.showAll||a.showPosition)&&this._graphicsContext.debug.drawPoint(v.Zero,{size:4,color:a.positionColor}),(a.showAll||a.showPositionLabel)&&(this._graphicsContext.debug.drawText(`pos${o.pos.toString(2)}`,T),T=T.add(I)),(a.showAll||a.showZIndex)&&(this._graphicsContext.debug.drawText(`z(${o.z.toFixed(1)})`,T),T=T.add(I)),(n.showAll||n.showId)&&(this._graphicsContext.debug.drawText(`id(${i}) ${C.parent?"child of id("+((t=C.parent)==null?void 0:t.id)+")":""}`,T),T=T.add(I)),(n.showAll||n.showName)&&(this._graphicsContext.debug.drawText(`name(${s})`,T),T=T.add(I)),(a.showAll||a.showRotation)&&(this._graphicsContext.drawLine(v.Zero,v.fromAngle(o.rotation).scale(50).add(v.Zero),a.rotationColor,2),this._graphicsContext.debug.drawText(`rot deg(${ar(o.rotation).toFixed(2)})`,T),T=T.add(I)),(a.showAll||a.showScale)&&this._graphicsContext.drawLine(v.Zero,o.scale.add(v.Zero),a.scaleColor,2)),f=C.get(j),f&&(g.showAll||g.showBounds)&&f.localBounds.draw(this._graphicsContext,g.boundsColor),p=C.get(Ni),p&&(p.useTransform||this._graphicsContext.restore(),p.draw(this._graphicsContext,this._engine.debug),p.useTransform||(this._graphicsContext.save(),this._applyTransform(C))),x=C.get(N),x&&((m.showAll||m.showCollisionGroup)&&(this._graphicsContext.debug.drawText(`collision group(${x.group.name})`,T),T=T.add(I)),(m.showAll||m.showCollisionType)&&(this._graphicsContext.debug.drawText(`collision type(${x.collisionType})`,T),T=T.add(I)),(m.showAll||m.showMass)&&(this._graphicsContext.debug.drawText(`mass(${x.mass})`,T),T=T.add(I)),(m.showAll||m.showMotion)&&(this._graphicsContext.debug.drawText(`motion(${x.sleepMotion})`,T),T=T.add(I)),(m.showAll||m.showSleeping)&&(this._graphicsContext.debug.drawText(`sleeping(${x.canSleep?x.isSleeping:"cant sleep"})`,T),T=T.add(I))),this._graphicsContext.restore(),this._graphicsContext.save(),o.coordPlane===rt.Screen&&this._graphicsContext.translate(this._engine.screen.contentArea.left,this._engine.screen.contentArea.top),this._graphicsContext.z=a.debugZIndex,h=C.get(U),h&&((l.showAll||l.showVelocity)&&(this._graphicsContext.debug.drawText(`vel${h.vel.toString(2)}`,T.add(o.globalPos)),this._graphicsContext.drawLine(o.globalPos,o.globalPos.add(h.vel),l.velocityColor,2),T=T.add(I)),(l.showAll||l.showAcceleration)&&this._graphicsContext.drawLine(o.globalPos,o.globalPos.add(h.acc),l.accelerationColor,2)),c=C.get(tt),c){const y=c.get();if((u.showAll||u.showGeometry)&&y&&y.debug(this._graphicsContext,u.geometryColor,{lineWidth:u.geometryLineWidth,pointSize:u.geometryPointSize}),u.showAll||u.showBounds){if(y instanceof at){const F=y.getColliders();for(const W of F){const q=W.bounds,Y=b(q.left,q.top);this._graphicsContext.debug.drawRect(Y.x,Y.y,q.width,q.height,{color:u.boundsColor}),(u.showAll||u.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${W.owner.id})`,Y)}c.bounds.draw(this._graphicsContext,u.boundsColor)}else if(y){const F=c.bounds,W=b(F.left,F.top);this._graphicsContext.debug.drawRect(W.x,W.y,F.width,F.height,{color:u.boundsColor}),(u.showAll||u.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${c.owner.id})`,W)}}}this._graphicsContext.restore(),this._popCameraTransform(o)}if(this._graphicsContext.save(),this._camera.draw(this._graphicsContext),(_.showAll||_.showBroadphaseSpacePartitionDebug)&&this._collisionSystem.debug(this._graphicsContext),_.showAll||_.showCollisionContacts||_.showCollisionNormals)for(const[S,C]of this._engine.debug.stats.currFrame.physics.contacts){if(_.showAll||_.showCollisionContacts)for(const T of C.points)this._graphicsContext.debug.drawPoint(T,{size:_.contactSize,color:_.collisionContactColor});if(_.showAll||_.showCollisionNormals)for(const T of C.points)this._graphicsContext.debug.drawLine(T,C.normal.scale(30).add(T),{color:_.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()}postupdate(t,e){this._engine.isDebug&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext),Cn.flush(this._graphicsContext),this._graphicsContext.restore())}_applyTransform(t){const e=t.getAncestors();for(const i of e){const s=i==null?void 0:i.get(A);s&&(this._graphicsContext.translate(s.pos.x,s.pos.y),this._graphicsContext.scale(s.scale.x,s.scale.y),this._graphicsContext.rotate(s.rotation))}}_pushCameraTransform(t){t.coordPlane===rt.World&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext))}_popCameraTransform(t){t.coordPlane===rt.World&&this._graphicsContext.restore()}}Gn.priority=Nt.Lowest;class ts extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Update,this._graphicsHashGrid=new Rn({size:100}),this._graphics=[],this._entityToPointer=new Map,this._pointerEventDispatcher=new Nn,this.overrideUseColliderShape=!1,this.overrideUseGraphicsBounds=!1,this._sortedTransforms=[],this._sortedEntities=[],this._zHasChanged=!1,this._zIndexUpdate=()=>{this._zHasChanged=!0},this.query=this.world.query([A,ae]),this.query.entityAdded$.subscribe(e=>{const i=e.get(A),s=e.get(ae);this._pointerEventDispatcher.addObject(e,o=>s&&s.localBounds?s.localBounds.transform(i.get().matrix).contains(i.coordPlane===rt.World?o.worldPos:o.screenPos):!1,()=>e.isActive),this._entityToPointer.set(e,s);const n=e.get(j);n&&(this._graphics.push(n),this._graphicsHashGrid.track(n)),this._sortedTransforms.push(i),this._sortedEntities.push(i.owner),i.zIndexChanged$.subscribe(this._zIndexUpdate),this._zHasChanged=!0}),this.query.entityRemoved$.subscribe(e=>{this._pointerEventDispatcher.removeObject(e);const i=e.get(A);this._entityToPointer.delete(e);const s=e.get(j);if(s){const o=this._graphics.indexOf(s);o>-1&&this._graphics.splice(o,1),this._graphicsHashGrid.untrack(s)}i.zIndexChanged$.unsubscribe(this._zIndexUpdate);const n=this._sortedTransforms.indexOf(i);n>-1&&(this._sortedTransforms.splice(n,1),this._sortedEntities.splice(n,1))})}initialize(t,e){this._engine=e.engine,this._scene=e}preupdate(){this._scene.camera.hasChanged()&&this._scene.camera.updateTransform(this._scene.camera.pos),this._receivers=[this._engine.input.pointers,this._scene.input.pointers],this._engineReceiver=this._engine.input.pointers,this._zHasChanged&&(this._sortedTransforms.sort((t,e)=>e.z-t.z),this._sortedEntities=this._sortedTransforms.map(t=>t.owner),this._zHasChanged=!1)}update(){this._graphicsHashGrid.update(this._graphics);for(const[t,e]of this._engineReceiver.currentFramePointerCoords.entries()){const i=this._scene.physics.query(e.worldPos);for(let n=0;n<i.length;n++){const o=i[n],a=this._entityToPointer.get(o.owner);a&&(a.useColliderShape||this.overrideUseColliderShape)&&this._pointerEventDispatcher.addPointerToObject(o.owner,t)}const s=this._graphicsHashGrid.query(e.worldPos);for(let n=0;n<s.length;n++){const o=s[n],a=this._entityToPointer.get(o.owner);a&&(a.useGraphicsBounds||this.overrideUseGraphicsBounds)&&this._pointerEventDispatcher.addPointerToObject(o.owner,t)}}this._pointerEventDispatcher.processPointerToObject(this._engineReceiver,this._sortedEntities),this._pointerEventDispatcher.dispatchEvents(this._engineReceiver,this._sortedEntities),this._receivers.forEach(t=>t.update()),this._pointerEventDispatcher.clear(),this._receivers.forEach(t=>t.clear())}}ts.priority=Nt.Higher;class Vn extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Update,this._actions=[],this.query=this.world.query([je]),this.query.entityAdded$.subscribe(e=>this._actions.push(e.get(je))),this.query.entityRemoved$.subscribe(e=>{const i=e.get(je),s=this._actions.indexOf(i);s>-1&&this._actions.splice(s,1)})}update(t){for(let e=0;e<this._actions.length;e++)this._actions[e].update(t)}}Vn.priority=Nt.Higher;class es{constructor(){this.events=new X,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,this._enabled=!0}init(){this.supported&&(this._initSuccess||(this._oldPads=this._clonePads(this._navigator.getGamepads()),this._oldPads.length&&this._oldPads[0]&&(this._initSuccess=!0)))}toggleEnabled(t){this._enabled=t}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(s=>typeof s!==void 0).length,i=t.buttons.filter(s=>typeof s!==void 0).length;return e>=this._minimumConfiguration.axis&&i>=this._minimumConfiguration.buttons&&t.connected}emit(t,e){this.events.emit(t,e)}on(t,e){return this._enableAndUpdate(),this.events.on(t,e)}once(t,e){return this._enableAndUpdate(),this.events.once(t,e)}off(t,e){this._enableAndUpdate(),this.events.off(t,e)}update(){var t,e;if(!this.enabled||!this.supported||!this._enabled)return;this.init();const i=this._navigator.getGamepads();for(let s=0;s<i.length;s++){if(i[s]){const o=this.at(s);!this.at(s).connected&&this._isGamepadValid(i[s])&&(o.events.pipe(this.events),this.events.emit("connect",new Ls(s,this.at(s)))),this.at(s).connected=!0}else{const o=this.at(s);o.connected&&(this.events.emit("disconnect",new ks(s,o)),o.events.unpipe(this.events)),o.connected=!1;continue}if(this.at(s).update(),i[s].timestamp&&i[s].timestamp===this._gamePadTimeStamps[s])continue;this._gamePadTimeStamps[s]=i[s].timestamp,this.at(s).navigatorGamepad=i[s];const n=i[s];if(n){for(let o=0;o<n.buttons.length;o++){const a=n.buttons[o],h=a==null?void 0:a.value;h!==((t=this._oldPads[s])==null?void 0:t.getButton(o))&&(a!=null&&a.pressed?(this.at(s).updateButton(o,h),this.at(s).events.emit("button",new zs(o in qn?o:-1,o,h,this.at(s)))):this.at(s).updateButton(o,0))}for(let o=0;o<n.axes.length;o++){const a=n.axes[o];a!==((e=this._oldPads[s])==null?void 0:e.getAxes(o))&&(this.at(s).updateAxes(o,a),this.at(s).events.emit("axis",new Us(o,a,this.at(s))))}}this._oldPads[s]=this._clonePad(i[s])}}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 is),this._oldPads.push(new is);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 is;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}}es.MinAxisMoveThreshold=.05;class is{constructor(){this.events=new X,this.connected=!1,this._axes=new Array(4),this._buttons=new Array(16),this._buttonsUp=new Array(16),this._buttonsDown=new Array(16);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}update(){this._buttonsDown=new Array(16),this._buttonsUp=new Array(16)}isButtonPressed(t,e=1){return this._buttons[t]>=e}isButtonHeld(t,e=1){return this._buttons[t]>=e}wasButtonPressed(t,e=1){return this._buttonsDown[t]>=e}wasButtonReleased(t){return!!this._buttonsUp[t]}getButton(t){return this._buttons[t]}getAxes(t){const e=this._axes[t];return Math.abs(e)<es.MinAxisMoveThreshold?0:e}updateButton(t,e){e===0&&this._buttons[t]?this._buttonsUp[t]=1:this._buttonsDown[t]=e,this._buttons[t]=e}updateAxes(t,e){this._axes[t]=e}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}}var qn=(r=>(r[r.Unknown=-1]="Unknown",r[r.Face1=0]="Face1",r[r.Face2=1]="Face2",r[r.Face3=2]="Face3",r[r.Face4=3]="Face4",r[r.LeftBumper=4]="LeftBumper",r[r.RightBumper=5]="RightBumper",r[r.LeftTrigger=6]="LeftTrigger",r[r.RightTrigger=7]="RightTrigger",r[r.Select=8]="Select",r[r.Start=9]="Start",r[r.LeftStick=10]="LeftStick",r[r.RightStick=11]="RightStick",r[r.DpadUp=12]="DpadUp",r[r.DpadDown=13]="DpadDown",r[r.DpadLeft=14]="DpadLeft",r[r.DpadRight=15]="DpadRight",r[r.CenterButton=16]="CenterButton",r[r.MiscButton1=17]="MiscButton1",r))(qn||{}),Ko=(r=>(r[r.LeftStickX=0]="LeftStickX",r[r.LeftStickY=1]="LeftStickY",r[r.RightStickX=2]="RightStickX",r[r.RightStickY=3]="RightStickY",r))(Ko||{});class ta{constructor(t){this.inputs=t,this._handlers=new Map}execute(){for(const[t,e]of this._handlers.entries()){const i=t(this.inputs);i&&e(i)}}on(t,e){this._handlers.set(t,e)}}function ea(){try{const r=()=>{};window.top.addEventListener("blur",r),window.top.removeEventListener("blur",r)}catch(r){return!0}return!1}function ia(){return window!==window.top}function sa(){let r;return ea()?(r=window,R.getInstance().warnOnce("Excalibur might be in a cross-origin iframe, in order to receive keyboard events it must be in focus")):ia()?(r=window,R.getInstance().warnOnce("Excalibur might be in a iframe, in order to receive keyboard events it must be in focus")):r=window.top,r}var na=(r=>(r.Backquote="Backquote",r.Backslash="Backslash",r.BracketLeft="BracketLeft",r.BracketRight="BracketRight",r.Comma="Comma",r.Key0="Digit0",r.Key1="Digit1",r.Key2="Digit2",r.Key3="Digit3",r.Key4="Digit4",r.Key5="Digit5",r.Key6="Digit6",r.Key7="Digit7",r.Key8="Digit8",r.Key9="Digit9",r.Digit0="Digit0",r.Digit1="Digit1",r.Digit2="Digit2",r.Digit3="Digit3",r.Digit4="Digit4",r.Digit5="Digit5",r.Digit6="Digit6",r.Digit7="Digit7",r.Digit8="Digit8",r.Digit9="Digit9",r.Equal="Equal",r.IntlBackslash="IntlBackslash",r.IntlRo="IntlRo",r.IntlYen="IntlYen",r.A="KeyA",r.B="KeyB",r.C="KeyC",r.D="KeyD",r.E="KeyE",r.F="KeyF",r.G="KeyG",r.H="KeyH",r.I="KeyI",r.J="KeyJ",r.K="KeyK",r.L="KeyL",r.M="KeyM",r.N="KeyN",r.O="KeyO",r.P="KeyP",r.Q="KeyQ",r.R="KeyR",r.S="KeyS",r.T="KeyT",r.U="KeyU",r.V="KeyV",r.W="KeyW",r.X="KeyX",r.Y="KeyY",r.Z="KeyZ",r.KeyA="KeyA",r.KeyB="KeyB",r.KeyC="KeyC",r.KeyD="KeyD",r.KeyE="KeyE",r.KeyF="KeyF",r.KeyG="KeyG",r.KeyH="KeyH",r.KeyI="KeyI",r.KeyJ="KeyJ",r.KeyK="KeyK",r.KeyL="KeyL",r.KeyM="KeyM",r.KeyN="KeyN",r.KeyO="KeyO",r.KeyP="KeyP",r.KeyQ="KeyQ",r.KeyR="KeyR",r.KeyS="KeyS",r.KeyT="KeyT",r.KeyU="KeyU",r.KeyV="KeyV",r.KeyW="KeyW",r.KeyX="KeyX",r.KeyY="KeyY",r.KeyZ="KeyZ",r.Minus="Minus",r.Period="Period",r.Quote="Quote",r.Semicolon="Semicolon",r.Slash="Slash",r.AltLeft="AltLeft",r.AltRight="AltRight",r.Alt="Alt",r.AltGraph="AltGraph",r.Backspace="Backspace",r.CapsLock="CapsLock",r.ContextMenu="ContextMenu",r.ControlLeft="ControlLeft",r.ControlRight="ControlRight",r.Enter="Enter",r.MetaLeft="MetaLeft",r.MetaRight="MetaRight",r.ShiftLeft="ShiftLeft",r.ShiftRight="ShiftRight",r.Space="Space",r.Tab="Tab",r.Convert="Convert",r.KanaMode="KanaMode",r.NonConvert="NonConvert",r.Delete="Delete",r.End="End",r.Help="Help",r.Home="Home",r.Insert="Insert",r.PageDown="PageDown",r.PageUp="PageUp",r.Up="ArrowUp",r.Down="ArrowDown",r.Left="ArrowLeft",r.Right="ArrowRight",r.ArrowUp="ArrowUp",r.ArrowDown="ArrowDown",r.ArrowLeft="ArrowLeft",r.ArrowRight="ArrowRight",r.NumLock="NumLock",r.Numpad0="Numpad0",r.Numpad1="Numpad1",r.Numpad2="Numpad2",r.Numpad3="Numpad3",r.Numpad4="Numpad4",r.Numpad5="Numpad5",r.Numpad6="Numpad6",r.Numpad7="Numpad7",r.Numpad8="Numpad8",r.Numpad9="Numpad9",r.Num0="Numpad0",r.Num1="Numpad1",r.Num2="Numpad2",r.Num3="Numpad3",r.Num4="Numpad4",r.Num5="Numpad5",r.Num6="Numpad6",r.Num7="Numpad7",r.Num8="Numpad8",r.Num9="Numpad9",r.NumAdd="NumpadAdd",r.NumpadAdd="NumpadAdd",r.NumDecimal="NumpadDecimal",r.NumpadDecimal="NumpadDecimal",r.NumDivide="NumpadDivide",r.NumpadDivide="NumpadDivide",r.NumEnter="NumpadEnter",r.NumpadEnter="NumpadEnter",r.NumMultiply="NumpadMultiply",r.NumpadMultiply="NumpadMultiply",r.NumSubtract="NumpadSubtract",r.NumpadSubtract="NumpadSubtract",r.Esc="Escape",r.Escape="Escape",r.F1="F1",r.F2="F2",r.F3="F3",r.F4="F4",r.F5="F5",r.F6="F6",r.F7="F7",r.F8="F8",r.F9="F9",r.F10="F10",r.F11="F11",r.F12="F12",r.F13="F13",r.F14="F14",r.F15="F15",r.F16="F16",r.F17="F17",r.F18="F18",r.F19="F19",r.F20="F20",r.PrintScreen="PrintScreen",r.ScrollLock="ScrollLock",r.Pause="Pause",r.Unidentified="Unidentified",r))(na||{});class wi extends k{constructor(t,e,i){super(),this.key=t,this.value=e,this.originalEvent=i}}class ra{constructor(){this.events=new X,this._enabled=!0,this._keys=[],this._keysUp=[],this._keysDown=[],this._releaseAllKeys=t=>{for(const e of this._keys){const i=new wi(e,t.key,t);this.events.emit("up",i),this.events.emit("release",i)}this._keysUp=Array.from(new Set(this._keys.concat(this._keysUp))),this._keys.length=0},this._handleKeyDown=t=>{if(!this._enabled)return;!t.metaKey&&(this._keys.includes("MetaLeft")||this._keys.includes("MetaRight"))&&this._releaseAllKeys(t);const e=t.code;if(this._keys.indexOf(e)===-1){this._keys.push(e),this._keysDown.push(e);const i=new wi(e,t.key,t);this.events.emit("down",i),this.events.emit("press",i)}},this._handleKeyUp=t=>{if(!this._enabled)return;const e=t.code,i=this._keys.indexOf(e);this._keys.splice(i,1),this._keysUp.push(e);const s=new wi(e,t.key,t);this.events.emit("up",s),this.events.emit("release",s),t.key==="Meta"&&this._releaseAllKeys(t)}}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}init(t){let{global:e}=t;const{grabWindowFocus:i}=t;e?typeof e=="function"&&(e=e()):e=sa(),i&&e.focus(),e.addEventListener("blur",()=>{this._keys.length=0}),e.addEventListener("keyup",this._handleKeyUp),e.addEventListener("keydown",this._handleKeyDown)}toggleEnabled(t){this._enabled=t}clear(){this._keysDown.length=0,this._keysUp.length=0,this._keys.length=0}update(){this._keysDown.length=0,this._keysUp.length=0;for(let t=0;t<this._keys.length;t++)this.events.emit("hold",new wi(this._keys[t]))}getKeys(){return this._keys}wasPressed(t){return this._enabled?this._keysDown.indexOf(t)>-1:!1}isHeld(t){return this._enabled?this._keys.indexOf(t)>-1:!1}wasReleased(t){return this._enabled?this._keysUp.indexOf(t)>-1:!1}triggerEvent(t,e,i){t==="down"&&this._handleKeyDown(new KeyboardEvent("keydown",{code:e,key:i!=null?i:null})),t==="up"&&this._handleKeyUp(new KeyboardEvent("keyup",{code:e,key:i!=null?i:null}))}}class xi{constructor(t,e,i,s,n,o){this.type=t,this.pointerId=e,this.button=i,this.pointerType=s,this.coordinates=n,this.nativeEvent=o,this.active=!0}cancel(){this.active=!1}get pagePos(){return this.coordinates.pagePos}get screenPos(){return this.coordinates.screenPos}get worldPos(){return this.coordinates.worldPos}}class oa{constructor(t,e,i,s,n,o,a,h,l,c,u,_){this.x=t,this.y=e,this.pageX=i,this.pageY=s,this.screenX=n,this.screenY=o,this.index=a,this.deltaX=h,this.deltaY=l,this.deltaZ=c,this.deltaMode=u,this.ev=_,this.active=!0}cancel(){this.active=!1}}class Xn{constructor(){this.events=new X,this.lastPagePos=v.Zero,this.lastScreenPos=v.Zero,this.lastWorldPos=v.Zero,this._onPointerMove=t=>{this.lastPagePos=new v(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new v(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new v(t.worldPos.x,t.worldPos.y)},this._onPointerDown=t=>{this.lastPagePos=new v(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new v(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new v(t.worldPos.x,t.worldPos.y)},this.on("move",this._onPointerMove),this.on("down",this._onPointerDown)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}_updateWorldPosition(t){const e=Be.fromPagePosition(this.lastPagePos,t);this.lastScreenPos=e.screenPos,this.lastWorldPos=e.worldPos}}var bi=(r=>(r.Pixel="Pixel",r.Line="Line",r.Page="Page",r))(bi||{}),Pe=(r=>(r[r.NoButton=-1]="NoButton",r[r.Left=0]="Left",r[r.Middle=1]="Middle",r[r.Right=2]="Right",r[r.Unknown=3]="Unknown",r))(Pe||{}),le=(r=>(r.Left="Left",r.Middle="Middle",r.Right="Right",r.Unknown="Unknown",r.NoButton="NoButton",r))(le||{}),ce=(r=>(r.Touch="Touch",r.Mouse="Mouse",r.Pen="Pen",r.Unknown="Unknown",r))(ce||{});function Fl(r){return globalThis.TouchEvent&&r instanceof globalThis.TouchEvent}function Bl(r){return globalThis.PointerEvent&&r instanceof globalThis.PointerEvent}class ss{constructor(t,e){this.target=t,this.engine=e,this.events=new X,this.primary=new Xn,this._activeNativePointerIdsToNormalized=new Map,this.lastFramePointerCoords=new Map,this.currentFramePointerCoords=new Map,this.currentFramePointerDown=new Map,this.lastFramePointerDown=new Map,this.currentFrameDown=[],this.currentFrameUp=[],this.currentFrameMove=[],this.currentFrameCancel=[],this.currentFrameWheel=[],this._enabled=!0,this._pointers=[this.primary],this._boundHandle=this._handle.bind(this),this._boundWheel=this._handleWheel.bind(this)}toggleEnabled(t){this._enabled=t}recreate(t,e){const i=new ss(t,e);return i.primary=this.primary,i._pointers=this._pointers,i}at(t){if(t>=this._pointers.length)for(let e=this._pointers.length-1,i=t;e<i;e++)this._pointers.push(new Xn);return this._pointers[t]}count(){return this._pointers.length}isDown(t){var e;return this._enabled&&(e=this.currentFramePointerDown.get(t))!=null?e:!1}wasDown(t){var e;return this._enabled&&(e=this.lastFramePointerDown.get(t))!=null?e:!1}isDragging(t){return this._enabled?this.isDown(t):!1}isDragStart(t){return this._enabled?this.isDown(t)&&!this.wasDown(t):!1}isDragEnd(t){return this._enabled?!this.isDown(t)&&this.wasDown(t):!1}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}update(){this.lastFramePointerDown=new Map(this.currentFramePointerDown),this.lastFramePointerCoords=new Map(this.currentFramePointerCoords);for(const t of this.currentFrameDown){if(!t.active)continue;this.emit("down",t),this.at(t.pointerId).emit("down",t),this.primary.emit("pointerdown",t)}for(const t of this.currentFrameUp){if(!t.active)continue;this.emit("up",t),this.at(t.pointerId).emit("up",t)}for(const t of this.currentFrameMove){if(!t.active)continue;this.emit("move",t),this.at(t.pointerId).emit("move",t)}for(const t of this.currentFrameCancel){if(!t.active)continue;this.emit("cancel",t),this.at(t.pointerId).emit("cancel",t)}for(const t of this.currentFrameWheel)t.active&&(this.emit("pointerwheel",t),this.emit("wheel",t),this.primary.emit("pointerwheel",t),this.primary.emit("wheel",t));if(this.engine.currentScene.camera.hasChanged())for(const t of this._pointers)t._updateWorldPosition(this.engine)}clear(){for(const t of this.currentFrameUp){this.currentFramePointerCoords.delete(t.pointerId);const e=this._activeNativePointerIdsToNormalized.entries();for(const[i,s]of e)s===t.pointerId&&this._activeNativePointerIdsToNormalized.delete(i)}this.currentFrameDown.length=0,this.currentFrameUp.length=0,this.currentFrameMove.length=0,this.currentFrameCancel.length=0,this.currentFrameWheel.length=0}init(t){var e;if(this.engine.isDisposed())return;this.target===this.engine.canvas?this.engine.canvas.style.touchAction="none":document.body.style.touchAction="none",window.PointerEvent?(this.target.addEventListener("pointerdown",this._boundHandle),this.target.addEventListener("pointerup",this._boundHandle),this.target.addEventListener("pointermove",this._boundHandle),this.target.addEventListener("pointercancel",this._boundHandle)):(this.target.addEventListener("touchstart",this._boundHandle),this.target.addEventListener("touchend",this._boundHandle),this.target.addEventListener("touchmove",this._boundHandle),this.target.addEventListener("touchcancel",this._boundHandle),this.target.addEventListener("mousedown",this._boundHandle),this.target.addEventListener("mouseup",this._boundHandle),this.target.addEventListener("mousemove",this._boundHandle));const i={passive:!(this.engine.pageScrollPreventionMode===Qe.All||this.engine.pageScrollPreventionMode===Qe.Canvas)};if("onwheel"in document.createElement("div")?this.target.addEventListener("wheel",this._boundWheel,i):document.onmousewheel!==void 0?this.target.addEventListener("mousewheel",this._boundWheel,i):this.target.addEventListener("MozMousePixelScroll",this._boundWheel,i),((e=t==null?void 0:t.grabWindowFocus)!=null?e:!0)&&(ea()||ia())){const n=()=>{window.focus()};window.PointerEvent?this.target.addEventListener("pointerdown",n):(this.target.addEventListener("touchstart",n),this.target.addEventListener("mousedown",n))}}detach(){window.PointerEvent?(this.target.removeEventListener("pointerdown",this._boundHandle),this.target.removeEventListener("pointerup",this._boundHandle),this.target.removeEventListener("pointermove",this._boundHandle),this.target.removeEventListener("pointercancel",this._boundHandle)):(this.target.removeEventListener("touchstart",this._boundHandle),this.target.removeEventListener("touchend",this._boundHandle),this.target.removeEventListener("touchmove",this._boundHandle),this.target.removeEventListener("touchcancel",this._boundHandle),this.target.removeEventListener("mousedown",this._boundHandle),this.target.removeEventListener("mouseup",this._boundHandle),this.target.removeEventListener("mousemove",this._boundHandle)),"onwheel"in document.createElement("div")?this.target.removeEventListener("wheel",this._boundWheel):document.onmousewheel!==void 0?this.target.addEventListener("mousewheel",this._boundWheel):this.target.addEventListener("MozMousePixelScroll",this._boundWheel)}_normalizePointerId(t){this._activeNativePointerIdsToNormalized.set(t,-1);const i=Array.from(this._activeNativePointerIdsToNormalized.keys()).sort((s,n)=>s-n).findIndex(s=>s===t);return this._activeNativePointerIdsToNormalized.set(t,i),i}_handle(t){if(!this._enabled)return;t.preventDefault();const e=new Map;let i,s;if(Fl(t)){i=le.Unknown,s=ce.Touch;for(let n=0;n<t.changedTouches.length;n++){const o=t.changedTouches[n],a=Be.fromPagePosition(o.pageX,o.pageY,this.engine),h=n+1,l=this._normalizePointerId(h);this.currentFramePointerCoords.set(l,a),e.set(l,a)}}else{i=this._nativeButtonToPointerButton(t.button),s=ce.Mouse;const n=Be.fromPagePosition(t.pageX,t.pageY,this.engine);let o=1;Bl(t)&&(o=t.pointerId,s=this._stringToPointerType(t.pointerType));const a=this._normalizePointerId(o);this.currentFramePointerCoords.set(a,n),e.set(a,n)}for(const[n,o]of e.entries())switch(t.type){case"mousedown":case"pointerdown":case"touchstart":this.currentFrameDown.push(new xi("down",n,i,s,o,t)),this.currentFramePointerDown.set(n,!0);break;case"mouseup":case"pointerup":case"touchend":this.currentFrameUp.push(new xi("up",n,i,s,o,t)),this.currentFramePointerDown.set(n,!1);break;case"mousemove":case"pointermove":case"touchmove":this.currentFrameMove.push(new xi("move",n,i,s,o,t));break;case"touchcancel":case"pointercancel":this.currentFrameCancel.push(new xi("cancel",n,i,s,o,t));break}}_handleWheel(t){if(!this._enabled)return;(this.engine.pageScrollPreventionMode===Qe.All||this.engine.pageScrollPreventionMode===Qe.Canvas&&t.target===this.engine.canvas)&&t.preventDefault();const e=this.engine.screen.pageToScreenCoordinates(b(t.pageX,t.pageY)),i=this.engine.screen.screenToWorldCoordinates(e),s=-1/40,n=t.deltaX||t.wheelDeltaX*s||0,o=t.deltaY||t.wheelDeltaY*s||t.wheelDelta*s||t.detail||0,a=t.deltaZ||0;let h=bi.Pixel;t.deltaMode&&(t.deltaMode===1?h=bi.Line:t.deltaMode===2&&(h=bi.Page));const l=new oa(i.x,i.y,t.pageX,t.pageY,e.x,e.y,0,n,o,a,h,t);this.currentFrameWheel.push(l)}triggerEvent(t,e){const i=this.engine.screen.worldToPageCoordinates(e);window.PointerEvent?this._handle(new window.PointerEvent("pointer"+t,{pointerId:0,clientX:i.x,clientY:i.y})):this._handle(new window.MouseEvent("mouse"+t,{clientX:i.x,clientY:i.y}));const s=this.engine.currentScene.world.get(ts);s.preupdate(this.engine.currentScene,1),s.update(1)}_nativeButtonToPointerButton(t){switch(t){case Pe.NoButton:return le.NoButton;case Pe.Left:return le.Left;case Pe.Middle:return le.Middle;case Pe.Right:return le.Right;case Pe.Unknown:return le.Unknown;default:return xr(t)}}_stringToPointerType(t){switch(t){case"touch":return ce.Touch;case"mouse":return ce.Mouse;case"pen":return ce.Pen;default:return ce.Unknown}}}class Yn{constructor(t){this._enabled=!0;const{pointerTarget:e,grabWindowFocus:i,engine:s,global:n}=t;this.keyboard=new ra,this.pointers=new ss(e,s),this.gamepads=new es,this.keyboard.init({global:n,grabWindowFocus:i}),this.pointers.init({grabWindowFocus:i}),this.gamepads.init(),this.inputMapper=new ta({keyboard:this.keyboard,pointers:this.pointers,gamepads:this.gamepads})}get enabled(){return this._enabled}toggleEnabled(t){this._enabled=t,this.keyboard.toggleEnabled(this._enabled),this.pointers.toggleEnabled(this._enabled),this.gamepads.toggleEnabled(this._enabled)}update(){this._enabled&&(this.inputMapper.execute(),this.keyboard.update(),this.gamepads.update())}clear(){this.keyboard.clear(),this.pointers.clear()}}class Ll{}const kl={Initialize:"initialize",Activate:"activate",Deactivate:"deactivate",PreUpdate:"preupdate",PostUpdate:"postupdate",PreDraw:"predraw",PostDraw:"postdraw",PreDebugDraw:"predebugdraw",PostDebugDraw:"postdebugdraw",PreLoad:"preload",TransitionStart:"transitionstart",TransitionEnd:"transitionend"};function $t(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class Rt{constructor(){this._logger=R.getInstance(),this.events=new X,this.camera=new Qo,this.world=new Ar(this),this.physics=new Ro(Jt()),this._isInitialized=!1,this._timers=[],this._cancelQueue=[],this.world.add(Vn),this.world.add(new ji(this.world,this.physics)),this.world.add(new Zi(this.world,this.physics)),this.world.add(ts),this.world.add(Wn),this.world.add(gn),this.world.add(fn),this.world.add(Gn)}get actors(){return this.world.entityManager.entities.filter(t=>t instanceof Ft)}get entities(){return this.world.entityManager.entities}get triggers(){return this.world.entityManager.entities.filter(t=>t instanceof Jo)}get tileMaps(){return this.world.entityManager.entities.filter(t=>t instanceof No)}get timers(){return this._timers}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}onPreLoad(t){}onTransition(t){}onInitialize(t){}onActivate(t){}onDeactivate(t){}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}async _initialize(t){var e;if(!this.isInitialized){try{this.engine=t,this.physics.config=this.engine.physics,this.input=new Yn({global:t.global,pointerTarget:t.pointerScope===Fe.Canvas?t.canvas:document,grabWindowFocus:t.grabWindowFocus,engine:t}),this.camera._initialize(t),this.world.systemManager.initialize(),await this.onInitialize(t),this._initializeChildren(),this._logger.debug("Scene.onInitialize",this,t),this.events.emit("initialize",new Ue(t,this))}catch(i){throw this._logger.error(`Error during scene initialization for scene ${(e=t.director)==null?void 0:e.getSceneName(this)}!`),i}this._isInitialized=!0}}async _activate(t){var e,i;try{this._logger.debug("Scene.onActivate",this),this.input.toggleEnabled(!0),await this.onActivate(t)}catch(s){throw this._logger.error(`Error during scene activation for scene ${(i=(e=this.engine)==null?void 0:e.director)==null?void 0:i.getSceneName(this)}!`),s}}async _deactivate(t){return this._logger.debug("Scene.onDeactivate",this),this.input.toggleEnabled(!1),await this.onDeactivate(t)}_preupdate(t,e){this.emit("preupdate",new ne(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new re(t,e,this)),this.onPostUpdate(t,e)}_predraw(t,e){this.emit("predraw",new ke(t,e,this)),this.onPreDraw(t,e)}_postdraw(t,e){this.emit("postdraw",new ze(t,e,this)),this.onPostDraw(t,e)}update(t,e){var i;if(!this.isInitialized){this._logger.warnOnce(`Scene update called before initialize for scene ${(i=t.director)==null?void 0:i.getSceneName(this)}!`);return}this._preupdate(t,e);let s,n;for(s=0,n=this._cancelQueue.length;s<n;s++)this.removeTimer(this._cancelQueue[s]);this._cancelQueue.length=0;for(const o of this._timers)o.update(e);this.world.update(Pt.Update,e),this.camera&&this.camera.update(t,e),this._collectActorStats(t),this._postupdate(t,e),this.input.update()}draw(t,e){var i;if(!this.isInitialized){this._logger.warnOnce("Scene draw called before initialize!");return}this._predraw(t,e),this.world.update(Pt.Draw,e),(i=this.engine)!=null&&i.isDebug&&this.debugDraw(t),this._postdraw(t,e)}debugDraw(t){this.emit("predebugdraw",new Ms(t,this)),this.emit("postdebugdraw",new Ds(t,this))}contains(t){return this.actors.indexOf(t)>-1}add(t){if(this.emit("entityadded",{target:t}),t instanceof Ki){wr(this._timers,t)||this.addTimer(t);return}this.world.add(t),t.scene=this}transfer(t){let e;t instanceof Tt&&t.scene&&t.scene!==this&&(e=t.scene,t.scene.world.remove(t,!1)),t instanceof Ki&&t.scene&&(e=t.scene,t.scene.removeTimer(t)),e==null||e.emit("entityremoved",{target:t}),this.add(t)}remove(t){this.emit("entityremoved",{target:t}),t instanceof Tt&&(t.isActive&&t.kill(),this.world.remove(t)),t instanceof Ki&&this.removeTimer(t)}clear(t=!0){for(let e=this.entities.length-1;e>=0;e--)this.world.remove(this.entities[e],t);for(let e=this.timers.length-1;e>=0;e--)this.removeTimer(this.timers[e])}addTimer(t){return this._timers.push(t),t.scene=this,t}removeTimer(t){const e=this._timers.indexOf(t);return e!==-1&&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:!1}_collectActorStats(t){const e=this.actors;for(let i=0;i<e.length;i++){const s=e[i];s instanceof Hn&&t.stats.currFrame.actors.ui++,t.stats.currFrame.actors.alive++;for(let n=0;n<s.children.length;n++){const o=s.children[n];Uo(o)?t.stats.currFrame.actors.ui++:t.stats.currFrame.actors.alive++}}}}class aa{constructor(t){this._engine=t,this._colorBlindPostProcessor=new Zr(Ye.Protanope)}correct(t){this._engine.graphicsContext instanceof Xt&&(this.clear(),this._colorBlindPostProcessor.colorBlindnessMode=t,this._colorBlindPostProcessor.simulate=!1,this._engine.graphicsContext.addPostProcessor(this._colorBlindPostProcessor))}simulate(t){this._engine.graphicsContext instanceof Xt&&(this.clear(),this._colorBlindPostProcessor.colorBlindnessMode=t,this._colorBlindPostProcessor.simulate=!0,this._engine.graphicsContext.addPostProcessor(this._colorBlindPostProcessor))}clear(){this._engine.graphicsContext.removePostProcessor(this._colorBlindPostProcessor)}}class ha{constructor(t){this.stats={currFrame:new yi,prevFrame:new yi},this.filter={useFilter:!1,nameQuery:"",ids:[]},this.entity={showAll:!1,showId:!1,showName:!1},this.transform={showAll:!1,debugZIndex:1e7,showPosition:!1,showPositionLabel:!1,positionColor:P.Yellow,showZIndex:!1,showScale:!1,scaleColor:P.Green,showRotation:!1,rotationColor:P.Blue},this.graphics={showAll:!1,showBounds:!1,boundsColor:P.Yellow},this.collider={showAll:!1,showBounds:!1,boundsColor:P.Blue,showOwner:!1,showGeometry:!0,geometryColor:P.Green,geometryLineWidth:1,geometryPointSize:.5},this.physics={showAll:!1,showBroadphaseSpacePartitionDebug:!1,showCollisionNormals:!1,collisionNormalColor:P.Cyan,showCollisionContacts:!0,contactSize:2,collisionContactColor:P.Red},this.motion={showAll:!1,showVelocity:!1,velocityColor:P.Yellow,showAcceleration:!1,accelerationColor:P.Red},this.body={showAll:!1,showCollisionGroup:!1,showCollisionType:!1,showSleeping:!1,showMotion:!1,showMass:!1},this.camera={showAll:!1,showFocus:!1,focusColor:P.Red,showZoom:!1},this.tilemap={showAll:!1,showGrid:!1,gridColor:P.Red,gridWidth:.5,showSolidBounds:!1,solidBoundsColor:P.fromHex("#8080807F"),showColliderGeometry:!0},this.isometric={showAll:!1,showPosition:!1,positionColor:P.Yellow,positionSize:1,showGrid:!1,gridColor:P.Red,gridWidth:1,showColliderGeometry:!0},this._engine=t,this.colorBlindMode=new aa(this._engine)}useTestClock(){const t=this._engine.clock,e=t.isRunning();t.stop();const i=t.toTestClock();return e&&i.start(),this._engine.clock=i,i}useStandardClock(){const t=this._engine.clock,e=t.isRunning();t.stop();const i=t.toStandardClock();return e&&i.start(),this._engine.clock=i,i}}class yi{constructor(){this._id=0,this._elapsedMs=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 ns,this._graphicsStats={drawCalls:0,drawnImages:0}}reset(t){t?(this.id=t.id,this.elapsedMs=t.elapsedMs,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.elapsedMs=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 yi;return t.reset(this),t}get id(){return this._id}set id(t){this._id=t}get elapsedMs(){return this._elapsedMs}set elapsedMs(t){this._elapsedMs=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 ns{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 ns;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}}class $n{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 la{constructor(t,e){this._windowGlobal=t,this._documentGlobal=e,this._windowComponent=new $n(this._windowGlobal),this._documentComponent=new $n(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 ca{constructor(t){this._samplePeriod=100,this._currentFrameTime=0,this._frames=0,this._previousSampleTime=0,this._beginFrameTime=0;var e;this._fps=t.initialFps,this._samplePeriod=(e=t.samplePeriod)!=null?e:this._samplePeriod,this._currentFrameTime=1e3/t.initialFps,this._nowFn=t.nowFn,this._previousSampleTime=this._nowFn()}start(){this._beginFrameTime=this._nowFn()}end(){this._frames++;const t=this._nowFn();this._currentFrameTime=t-this._beginFrameTime,t>=this._previousSampleTime+this._samplePeriod&&(this._fps=this._frames*1e3/(t-this._previousSampleTime),this._previousSampleTime=t,this._frames=0)}get fps(){return this._fps}get instant(){return 1e3/this._currentFrameTime}}class jn{constructor(t){this._onFatalException=()=>{},this._maxFps=1/0,this._lastTime=0,this._elapsed=1,this._scheduledCbs=[],this._totalElapsed=0,this._nextScheduleId=0;var e,i,s;this._options=t,this.tick=t.tick,this._lastTime=(e=this.now())!=null?e:0,this._maxFps=(i=t.maxFps)!=null?i:this._maxFps,this._onFatalException=(s=t.onFatalException)!=null?s:this._onFatalException,this.fpsSampler=new ca({initialFps:60,nowFn:()=>this.now()})}elapsed(){return this._elapsed}now(){return performance.now()}toTestClock(){return new da({...this._options,defaultUpdateMs:16.6})}toStandardClock(){return new Zn({...this._options})}setFatalExceptionHandler(t){this._onFatalException=t}schedule(t,e=0,i="preframe"){const s=this._totalElapsed+e,n=this._nextScheduleId++;return this._scheduledCbs.push([n,t,s,i]),n}clearSchedule(t){const e=this._scheduledCbs.findIndex(([i])=>i===t);e!==-1&&this._scheduledCbs.splice(e,1)}__runScheduledCbs(t="preframe"){for(let e=this._scheduledCbs.length-1;e>-1;e--){const[i,s,n,o]=this._scheduledCbs[e];t===o&&n<=this._totalElapsed&&(s(this._elapsed),this._scheduledCbs.splice(e,1))}}update(t){try{this.fpsSampler.start();const e=this.now();let i=e-this._lastTime||1;const s=1e3/this._maxFps;if(i>=s){let n=0;s!==0&&(n=i%s,i=i-n),i>200&&(i=1),this._elapsed=t||i,this._totalElapsed+=this._elapsed,this.__runScheduledCbs("preframe"),this.tick(t||i),this.__runScheduledCbs("postframe"),s!==0?this._lastTime=e-n:this._lastTime=e,this.fpsSampler.end()}}catch(e){this._onFatalException(e),this.stop()}}}class Zn extends jn{constructor(t){super(t),this._running=!1}isRunning(){return this._running}start(){if(this._running)return;this._running=!0;const t=()=>{if(this._running)try{this._requestId=window.requestAnimationFrame(t),this.update()}catch(e){throw window.cancelAnimationFrame(this._requestId),e}};t()}stop(){window.cancelAnimationFrame(this._requestId),this._running=!1}}class da extends jn{constructor(t){super({...t}),this._logger=R.getInstance(),this._running=!1,this._currentTime=0,this._updateMs=t.defaultUpdateMs}now(){var t;return(t=this._currentTime)!=null?t:0}isRunning(){return this._running}start(){this._running=!0}stop(){this._running=!1}step(t){const e=t!=null?t:this._updateMs;this._running?(this.update(e),this._currentTime+=e):this._logger.warn("The clock is not running, no step will be performed")}run(t,e){for(let i=0;i<t;i++)this.step(e!=null?e:this._updateMs)}}const zl="#ex-toast-container{position:absolute;height:0;min-width:50%;left:50%;top:0}.ex-toast-message{left:-50%;position:relative;display:flex;justify-content:space-between;padding:10px;margin-top:5px;font-size:18px;font-family:sans-serif;border-radius:6px;border:3px solid #b7b779;background-color:#fdfdc0}.ex-toast-message button{align-self:flex-start}";class ua{constructor(){this._toasterCss=zl,this._isInitialized=!1}_initialize(){this._isInitialized||(this._container=document.createElement("div"),this._container.id="ex-toast-container",document.body.appendChild(this._container),this._isInitialized=!0,this._styleBlock=document.createElement("style"),this._styleBlock.textContent=this._toasterCss,document.head.appendChild(this._styleBlock))}dispose(){this._container.parentElement.removeChild(this._container),this._styleBlock.parentElement.removeChild(this._styleBlock),this._isInitialized=!1}_createFragment(t){const e=document.createElement("span");return e.innerText=t,e}toast(t,e,i){this._initialize();const s=document.createElement("div");s.className="ex-toast-message";const n=t.split("[LINK]").map(c=>this._createFragment(c));if(e){const c=document.createElement("a");c.href=e,i?c.innerText=i:c.innerText=e,n.splice(1,0,c)}const o=document.createElement("div");n.forEach(c=>{o.appendChild(c)}),s.appendChild(o);const a=document.createElement("button");a.innerText="x",a.addEventListener("click",()=>{this._container.removeChild(s)}),s.appendChild(a);const h=c=>{if(c.key==="Escape")try{this._container.removeChild(s)}catch(u){}document.removeEventListener("keydown",h)};document.addEventListener("keydown",h);const l=this._container.firstChild;this._container.insertBefore(s,l)}}const _a={NavigationStart:"navigationstart",Navigation:"navigation",NavigationEnd:"navigationend"};class fa{constructor(t,e){this._engine=t,this.events=new X,this._logger=R.getInstance(),this._initialized=!1,this.scenes={},this._sceneToInstance=new Map,this._sceneToLoader=new Map,this._sceneToTransition=new Map,this._loadedScenes=new Set,this._isTransitioning=!1,this.rootScene=this.currentScene=new Rt,this.add("root",this.rootScene),this.currentScene=this.rootScene,this.currentSceneName="root";for(const i in e){const s=e[i];this.add(i,s),i==="root"&&(this.rootScene=this.getSceneInstance("root"),this.currentScene=this.rootScene)}}get isTransitioning(){return this._isTransitioning}async onInitialize(){if(!this._initialized)if(this._initialized=!0,this._deferredGoto){const t=this._deferredGoto;this._deferredGoto=void 0;const e=this._deferredTransition;this._deferredTransition=void 0;const i=this.getSceneInstance(t);i&&e&&e._addToTargetScene(this._engine,i);const s=this._getInTransition(t),n=s==null?void 0:s.hideLoader;this.maybeLoadScene(t,n),await this.swapScene(t),i&&e&&await this.playTransition(e,i)}else await this.swapScene("root")}get isInitialized(){return this._initialized}configureStart(t,e){var i,s;const n=e==null?void 0:e.loader;n instanceof mi?this.mainLoader=n:On(n)?this.mainLoader=new n:this.mainLoader=new Ji;let o;if(e!=null&&e.inTransition){const{inTransition:h}=e;o=h}this.startScene=t;const a=(s=(i=e==null?void 0:e.inTransition)==null?void 0:i.hideLoader)!=null?s:!1;if(this.maybeLoadScene(t,a),o){const h=this.getSceneInstance(t);h&&(o._addToTargetScene(this._engine,h),this.swapScene(t).then(()=>(h.onTransition("in"),this.playTransition(o,h))))}else this.swapScene(t);this.currentSceneName=this.startScene}_getLoader(t){return this._sceneToLoader.get(t)}_getInTransition(t){var e;const i=this.scenes[t];if(!(i instanceof Rt||$t(i)))return(e=i==null?void 0:i.transitions)==null?void 0:e.in}_getOutTransition(t){var e;const i=this.scenes[t];if(!(i instanceof Rt||$t(i)))return(e=i==null?void 0:i.transitions)==null?void 0:e.out}getDeferredScene(){const t=this.getSceneDefinition(this._deferredGoto);return this._deferredGoto&&t?t:null}getSceneDefinition(t){const e=this.scenes[t];if(e instanceof Rt||$t(e))return e;if(e)return e.scene}getSceneName(t){for(const[e,i]of Object.entries(this.scenes))if(i instanceof Rt){if(t===i)return e}else if(!$t(i)&&t===i.scene)return e;for(const[e,i]of Object.entries(this.scenes))if($t(i)){if(t.constructor===i)return e}else if(!(i instanceof Rt)&&t.constructor===i.scene)return e;return null}assertAdded(t){return this}assertRemoved(t){return this}add(t,e){if(!(e instanceof Rt)&&!$t(e)){const{loader:i,transitions:s}=e,{in:n,out:o}=s!=null?s:{};this._sceneToTransition.set(t,{in:n,out:o}),On(i)?this._sceneToLoader.set(t,new i):i&&this._sceneToLoader.set(t,i)}return this.scenes[t]&&this._logger.warn("Scene",t,"already exists overwriting"),this.scenes[t]=e,this.assertAdded(t)}remove(t){if(t instanceof Rt||$t(t)){const e=t;for(const i in this.scenes)if(this.scenes.hasOwnProperty(i)){const s=this.scenes[i];let n;if(s instanceof Rt||$t(s)?n=s:n=s.scene,n===e){if(i===this.currentSceneName)throw new Error(`Cannot remove a currently active scene: ${i}`);this._sceneToInstance.delete(i),this._sceneToTransition.delete(i),this._sceneToLoader.delete(i),delete this.scenes[i]}}}if(typeof t=="string"){if(t===this.currentSceneName)throw new Error(`Cannot remove a currently active scene: ${t}`);this._sceneToInstance.delete(t),this._sceneToTransition.delete(t),this._sceneToLoader.delete(t),delete this.scenes[t]}}async goToScene(t,e){var i,s,n,o,a,h;const l=this.getSceneInstance(t);if(!l){this._logger.warn(`Scene ${t} does not exist! Check the name, are you sure you added it?`);return}const c=this.currentScene,u=this.currentSceneName,_=(s=(i=this._engine.input)==null?void 0:i.enabled)!=null?s:!0;this._isTransitioning=!0;const f=(n=this.getSceneInstance(u))==null?void 0:n.onTransition("out"),g=l==null?void 0:l.onTransition("in");e={sourceOut:(o=this._getOutTransition(this.currentSceneName))!=null?o:f,destinationIn:(a=this._getInTransition(t))!=null?a:g,...e};const{sourceOut:p,destinationIn:x,sceneActivationData:m}=e,w=p!=null?p:this._getOutTransition(this.currentSceneName),S=x!=null?x:this._getInTransition(t),C=(w==null?void 0:w.hideLoader)||(S==null?void 0:S.hideLoader);C&&this.maybeLoadScene(t,C),this._emitEvent("navigationstart",u,t),w&&await this.playTransition(w,c),await this.maybeLoadScene(t,C),S&&await S.onPreviousSceneDeactivate(this.currentScene),S&&S._addToTargetScene(this._engine,l),await this.swapScene(t,m),this._emitEvent("navigation",u,t),S&&await this.playTransition(S,l),this._emitEvent("navigationend",u,t),(h=this._engine.input)==null||h.toggleEnabled(_),this._isTransitioning=!1}getSceneInstance(t){const e=this.getSceneDefinition(t);if(!e)return;if(this._sceneToInstance.has(t))return this._sceneToInstance.get(t);if(e instanceof Rt)return this._sceneToInstance.set(t,e),e;const i=new e;return this._sceneToInstance.set(t,i),i}async maybeLoadScene(t,e=!1){var i;const s=(i=this._getLoader(t))!=null?i:new mi,n=this.getSceneDefinition(t),o=this.getSceneInstance(t);n&&o&&!this._loadedScenes.has(o)&&(o.onPreLoad(s),o.events.emit("preload",{loader:s}),e?this._engine.load(s,e):await this._engine.load(s),this._loadedScenes.add(o))}async playTransition(t,e){var i,s,n,o,a,h,l;if(!this.isInitialized){this._deferredTransition=t;return}if(t){this.currentTransition=t;const c=(s=(i=e.input)==null?void 0:i.enabled)!=null?s:!0;(n=e.input)==null||n.toggleEnabled(!t.blockInput),(o=this._engine.input)==null||o.toggleEnabled(!t.blockInput),e.events.emit("transitionstart",t),this.currentTransition._addToTargetScene(this._engine,e),await this.currentTransition._play(),e.events.emit("transitionend",t),(a=e.input)==null||a.toggleEnabled(c)}(h=this.currentTransition)==null||h.kill(),(l=this.currentTransition)==null||l.reset(),this.currentTransition=void 0}async swapScene(t,e){const i=this._engine;if(!this.isInitialized){this._deferredGoto=t;return}const s=this.getSceneInstance(t);if(s){const n=this.currentScene,o=s;let a;if(this._logger.debug("Going to scene:",t),this.currentScene.isInitialized){const c={engine:i,previousScene:n,nextScene:o};a=await this.currentScene._deactivate(c),this.currentScene.events.emit("deactivate",new Ws(c,this.currentScene)),this.currentScene.input.clear()}const h=this._sceneToLoader.get(t);await(h==null?void 0:h.areResourcesLoaded()),this.currentScene=o,this.currentSceneName=t,i.screen.setCurrentCamera(o.camera),await this.currentScene._initialize(i);const l={engine:i,previousScene:n,previousSceneData:a,nextScene:o,data:e};await this.currentScene._activate(l),this.currentScene.events.emit("activate",new Ns(l,this.currentScene))}else this._logger.error("Scene",t,"does not exist!")}_emitEvent(t,e,i){const s=this.getSceneDefinition(e),n=this.getSceneDefinition(i);this.events.emit(t,{sourceScene:s,sourceName:e,destinationScene:n,destinationName:i})}}function ga(){const r={scope:(t,e)=>{const i=r.value;r.value=t;try{const s=e();return s&&typeof s.then=="function"?s.finally(()=>{r.value=i}):s}catch(s){throw s}finally{r.value=i}},value:void 0};return r}function pa(r){return r.value}const Qn={textureCollectInterval:6e4};class ma{constructor(t){this.options=t,this._running=!1,this._collectionMap=new Map,this._collectors=new Map,this.collectStaleResources=e=>{if(this._running){for(const[i,[s,n]]of this._collectors.entries()){const o=this.options.getTimestamp();for(const[a,[h,l]]of this._collectionMap.entries()){if(i!==h||l+n>=o)continue;s(a)&&this._collectionMap.delete(a)}}this._collectHandle=requestIdleCallback(this.collectStaleResources)}}}registerCollector(t,e,i){this._collectors.set(t,[i,e])}addCollectableResource(t,e){this._collectionMap.set(e,[t,this.options.getTimestamp()])}touch(t){const e=this._collectionMap.get(t);e&&this._collectionMap.set(t,[e[0],this.options.getTimestamp()])}forceCollectAll(){for(const[t,[e]]of this._collectors.entries())for(const[i]of this._collectionMap.entries())e(i)&&this._collectionMap.delete(i)}running(){return this._running}start(){this._running=!0,this.collectStaleResources()}stop(){this._running=!1,cancelIdleCallback(this._collectHandle)}}Me();const Ul={FallbackGraphicsContext:"fallbackgraphicscontext",Initialize:"initialize",Visible:"visible",Hidden:"hidden",Start:"start",Stop:"stop",PreUpdate:"preupdate",PostUpdate:"postupdate",PreFrame:"preframe",PostFrame:"postframe",PreDraw:"predraw",PostDraw:"postdraw",..._a};var Qe=(r=>(r[r.None=0]="None",r[r.Canvas=1]="Canvas",r[r.All=2]="All",r))(Qe||{});const rs=class ue{constructor(t){this.scope=T=>ue.Context.scope(this,T),this.version=er,this.events=new X,this.maxFps=Number.POSITIVE_INFINITY,this._inputEnabled=!0,this._suppressPlayButton=!1,this.pauseAudioWhenHidden=!0,this._isDebug=!1,this.enableCanvasTransparency=!0,this.onFatalException=T=>{R.getInstance().fatal(T,T.stack)},this._toaster=new ua,this._timescale=1,this._isInitialized=!1,this._hasCreatedCanvas=!1,this._originalOptions={},this._handleWebGLContextLost=T=>{var I;T.preventDefault(),this.clock.stop(),this._logger.fatalOnce("WebGL Graphics Lost",T);const y=document.createElement("div");y.id="ex-webgl-graphics-context-lost",y.style.position="absolute",y.style.zIndex="99",y.style.left="50%",y.style.top="50%",y.style.display="flex",y.style.flexDirection="column",y.style.transform="translate(-50%, -50%)",y.style.backgroundColor="white",y.style.padding="10px",y.style.borderStyle="solid 1px";const F=document.createElement("div");if(F.innerHTML=`
|
|
786
|
+
`;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),R.getInstance().error("Critical browser feature missing, Excalibur requires:",e),t=!0);if(t)return!1;for(const e in this._warningTest)this._warningTest[e]()||R.getInstance().warn("Warning browser feature missing, Excalibur will have reduced performance:",e);return!0}}function Uo(r){return r instanceof Hn}class Hn extends Ft{constructor(t){var e,i;super({...t}),this.get(A).coordPlane=rt.Screen,this.anchor=(e=t==null?void 0:t.anchor)!=null?e:b(0,0),this.body.collisionType=(i=t==null?void 0:t.collisionType)!=null?i:M.PreventCollision,this.pointer.useGraphicsBounds=!0,this.pointer.useColliderShape=!1,!(t!=null&&t.collider)&&(t==null?void 0:t.width)>0&&(t==null?void 0:t.height)>0&&this.collider.useBoxCollider(this.width,this.height,this.anchor)}_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 v(t,e));return super.contains(s.x,s.y)}}const Oo=class Ba{constructor(t){this._logger=R.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.randomRange=[0,0],this._baseInterval=10,this._generateRandomInterval=()=>this._baseInterval+this.random.integer(this.randomRange[0],this.randomRange[1]),this._complete=!1,this.scene=null;var e;const i=(e=t.action)!=null?e:t.fcn,s=t.interval,n=t.repeats,o=t.numberOfRepeats,a=t.randomRange,h=t.random;if(o&&o>=0&&(this.maxNumberOfRepeats=o,!n))throw new Error("repeats must be set to true if numberOfRepeats is set");if(this.id=Ba._MAX_ID++,this._callbacks=[],this._baseInterval=this.interval=s,a){if(a[0]>a[1])throw new Error("min value must be lower than max value for range");this.random=h!=null?h:new ie,this.randomRange=a,this.interval=this._generateRandomInterval(),this.on(()=>{this.interval=this._generateRandomInterval()})}this.repeats=n||this.repeats,i&&this.on(i)}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(e=>{e.call(this)}),this._numberOfTicks++,this.repeats?this._elapsedTime=0:(this._complete=!0,this._running=!1,this._elapsedTime=0)))}reset(t,e){if(t&&t>=0&&(this._baseInterval=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}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)}};Oo._MAX_ID=0;let Ki=Oo;function Ho(r){return r&&r._dispatchPointerEvents&&r._processPointerToObject}class El{get events(){return this.object.events}init(t,e,i){this.object=t,this.contains=e,this.active=i}}class Nn{constructor(){this._proxyPool=new Ve(()=>new El,t=>t,100),this._objectToProxy=new Map,this._proxies=[],this._lastFrameObjectToPointers=new Map,this._currentFrameObjectToPointers=new Map}addObject(t,e,i){const s=this._proxyPool.rent(!1);s.init(t,e,i),this._proxies.push(s),this._objectToProxy.set(t,s)}_getProxy(t){const e=this._objectToProxy.get(t);if(e)return e;throw new Error("No PointerTargetProxy for object")}removeObject(t){const e=this._objectToProxy.get(t);if(e){const i=this._proxies.indexOf(e);this._objectToProxy.delete(t),i>-1&&this._proxies.splice(i,1),this._proxyPool.return(e)}}_objectCurrentlyUnderPointer(t,e){return!!(this._currentFrameObjectToPointers.has(t)&&this._currentFrameObjectToPointers.get(t).includes(e))}_objectWasUnderPointer(t,e){return!!(this._lastFrameObjectToPointers.has(t)&&this._lastFrameObjectToPointers.get(t).includes(e))}_entered(t,e){return this._objectCurrentlyUnderPointer(t,e)&&!this._lastFrameObjectToPointers.has(t)}_left(t,e){return!this._currentFrameObjectToPointers.has(t)&&this._objectWasUnderPointer(t,e)}addPointerToObject(t,e){const i=this._objectToProxy.get(t);i&&this._addPointerToProxy(i,e)}_addPointerToProxy(t,e){if(!this._currentFrameObjectToPointers.has(t)){this._currentFrameObjectToPointers.set(t,[e]);return}const i=this._currentFrameObjectToPointers.get(t);this._currentFrameObjectToPointers.set(t,i.concat(e))}dispatchEvents(t,e){const i=new Set(this._lastFrameObjectToPointers.keys()),s=new Set(this._currentFrameObjectToPointers.keys());let n,o,a,h=[];if(e)for(let l=0;l<e.length;l++){const c=e[l],u=this._getProxy(c);h.push(u)}else{const l=new Set(i);for(const c of s)l.add(c);h=Array.from(l)}for(let l=0;l<h.length;l++){const c=h[l];if(Ho(c.object)&&c.object._dispatchPointerEvents(t),i.has(c)||s.has(c)){a=this._processDownAndEmit(t,c),o=this._processUpAndEmit(t,c),n=this._processMoveAndEmit(t,c);const u=[...n.values(),...a.values(),...o.values()];this._processEnterLeaveAndEmit(t,c,u),this._processCancelAndEmit(t,c),this._processWheelAndEmit(t,c)}}}processPointerToObject(t,e){for(let i=0;i<e.length;i++){const s=e[i],n=this._getProxy(s);Ho(s)&&s._processPointerToObject(t);for(const[o,a]of t.currentFramePointerCoords.entries())n.contains(a)&&this._addPointerToProxy(n,o)}}clear(){this._lastFrameObjectToPointers.clear(),this._lastFrameObjectToPointers=new Map(this._currentFrameObjectToPointers),this._currentFrameObjectToPointers.clear()}_processDownAndEmit(t,e){const i=new Map;for(const s of t.currentFrameDown)s.active&&this._objectCurrentlyUnderPointer(e,s.pointerId)&&(e.events.emit("pointerdown",s),t.isDragStart(s.pointerId)&&e.events.emit("pointerdragstart",s)),i.set(s.pointerId,s);return i}_processUpAndEmit(t,e){const i=new Map;for(const s of t.currentFrameUp)s.active&&this._objectCurrentlyUnderPointer(e,s.pointerId)&&(e.events.emit("pointerup",s),t.isDragEnd(s.pointerId)&&e.events.emit("pointerdragend",s)),i.set(s.pointerId,s);return i}_processMoveAndEmit(t,e){const i=new Map;for(const s of t.currentFrameMove)s.active&&e.active()&&this._objectCurrentlyUnderPointer(e,s.pointerId)&&(e.events.emit("pointermove",s),t.isDragging(s.pointerId)&&e.events.emit("pointerdragmove",s)),i.set(s.pointerId,s);return i}_processEnterLeaveAndEmit(t,e,i){for(const s of i){if(s.active&&e.active()&&this._entered(e,s.pointerId)){e.events.emit("pointerenter",s),t.isDragging(s.pointerId)&&e.events.emit("pointerdragenter",s);break}if(s.active&&e.active()&&(this._left(e,s.pointerId)||this._objectCurrentlyUnderPointer(e,s.pointerId)&&s.type==="up")){e.events.emit("pointerleave",s),t.isDragging(s.pointerId)&&e.events.emit("pointerdragleave",s);break}}}_processCancelAndEmit(t,e){for(const i of t.currentFrameCancel)i.active&&e.active()&&this._objectCurrentlyUnderPointer(e,i.pointerId)&&e.events.emit("pointercancel",i)}_processWheelAndEmit(t,e){for(const i of t.currentFrameWheel)i.active&&e.active()&&this._objectCurrentlyUnderPointer(e,0)&&e.events.emit("pointerwheel",i)}}const Il={PreUpdate:"preupdate",PostUpdate:"postupdate",PreDraw:"predraw",PostDraw:"postdraw",PointerUp:"pointerup",PointerDown:"pointerdown",PointerMove:"pointermove",PointerCancel:"pointercancel"};class No extends Tt{constructor(t){var e,i,s;super([],t.name),this.events=new X,this._token=0,this.logger=R.getInstance(),this.tiles=[],this._rows=[],this._cols=[],this.renderFromTopOfGraphic=!1,this.meshingLookBehind=10,this._collidersDirty=!0,this._oldRotation=0,this._originalOffsets=new WeakMap,this.meshingLookBehind=(e=t.meshingLookBehind)!=null?e:this.meshingLookBehind,this.addComponent(new A),this.addComponent(new U),this.addComponent(new N({type:M.Fixed})),this.addComponent(new j({onPostDraw:(o,a)=>this.draw(o,a)})),this.addComponent(new Ni((o,a)=>this.debug(o,a),!1)),this.addComponent(new tt),this.addComponent(new ae),this.pointer=this.get(ae),this._graphics=this.get(j),this.transform=this.get(A),this._motion=this.get(U),this.collider=this.get(tt),this._composite=this.collider.useCompositeCollider([]),this.transform.pos=(i=t.pos)!=null?i:v.Zero,this._oldPos=this.transform.pos.clone(),this._oldScale=this.transform.scale.clone(),this.renderFromTopOfGraphic=(s=t.renderFromTopOfGraphic)!=null?s:this.renderFromTopOfGraphic,this.tileWidth=t.tileWidth,this.tileHeight=t.tileHeight,this.rows=t.rows,this.columns=t.columns,this._pointerEventDispatcher=new Nn,this.tiles=new Array(this.rows*this.columns),this._rows=new Array(this.rows),this._cols=new Array(this.columns);let n=[];for(let o=0;o<this.columns;o++){for(let a=0;a<this.rows;a++){const h=new Wo({x:o,y:a,map:this});h.map=this,this.tiles[o+a*this.columns]=h,this._pointerEventDispatcher.addObject(h,l=>h.bounds.contains(l.worldPos),()=>!0),n.push(h),this._rows[a]||(this._rows[a]=[]),this._rows[a].push(h)}this._cols[o]=n,n=[]}this._graphics.localBounds=new D({left:0,top:0,right:this.columns*this.tileWidth*this.scale.x,bottom:this.rows*this.tileHeight*this.scale.y})}flagCollidersDirty(){this._collidersDirty=!0}flagTilesDirty(){for(let t=0;t<this.tiles.length;t++)this.tiles[t]&&this.tiles[t].flagDirty()}get x(){var t;return(t=this.transform.pos.x)!=null?t:0}set x(t){var e;(e=this.transform)!=null&&e.pos&&(this.get(A).pos=b(t,this.y))}get y(){var t,e;return(e=(t=this.transform)==null?void 0:t.pos.y)!=null?e:0}set y(t){var e;(e=this.transform)!=null&&e.pos&&(this.transform.pos=b(this.x,t))}get z(){var t;return(t=this.transform.z)!=null?t:0}set z(t){this.transform&&(this.transform.z=t)}get rotation(){var t,e;return(e=(t=this.transform)==null?void 0:t.rotation)!=null?e:0}set rotation(t){this.transform&&(t!==this.transform.rotation&&(this.flagCollidersDirty(),this.flagTilesDirty()),this.transform.rotation=t)}get scale(){var t,e;return(e=(t=this.transform)==null?void 0:t.scale)!=null?e:v.One}set scale(t){this.transform&&(t!=null&&t.equals(this.transform.scale)||(this.flagCollidersDirty(),this.flagTilesDirty()),this.transform.scale=t)}get pos(){return this.transform.pos}set pos(t){this.transform&&(t!=null&&t.equals(this.transform.pos)||(this.flagCollidersDirty(),this.flagTilesDirty()),this.transform.pos=t)}get vel(){return this._motion.vel}set vel(t){this._motion.vel=t}get width(){return this.tileWidth*this.columns*this.scale.x}get height(){return this.tileHeight*this.rows*this.scale.y}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}_initialize(t){super._initialize(t),this._engine=t}_getOrSetColliderOriginalOffset(t){var e;if(this._originalOffsets.has(t))return(e=this._originalOffsets.get(t))!=null?e:v.Zero;{const i=t.offset;return this._originalOffsets.set(t,i),i}}_updateColliders(){this.collider.$colliderRemoved.notifyAll(this._composite),this._composite.clearColliders();const t=[];this._composite=this.collider.useCompositeCollider([]);let e=null;const i=(n,o)=>n&&o?n.top===o.top&&n.bottom===o.bottom&&n.right===o.left:!1,s=(n,o,a=this.meshingLookBehind)=>{if(!n)return!1;for(let h=o.length-1;h>=0;h--){if(a--<0)return!1;const l=o[h];if(i(l,n))return o[h]=l.combine(n),!0}return!1};for(let n=0;n<this.columns;n++){for(let o=0;o<this.rows;o++){const a=this.tiles[n+o*this.columns];if(a.solid)if(a.getColliders().length>0){for(const h of a.getColliders()){const l=this._getOrSetColliderOriginalOffset(h);h.offset=b(a.x*this.tileWidth*this.scale.x,a.y*this.tileHeight*this.scale.y).add(l),h.owner=this,this._composite.addCollider(h)}e&&!s(e,t)&&t.push(e),e=null}else e?e=e.combine(a.defaultGeometry):e=a.defaultGeometry;else e&&!s(e,t)&&t.push(e),e=null}e&&!s(e,t)&&t.push(e),e=null}for(const n of t){const o=ut.Box(n.width,n.height,v.Zero,b(n.left-this.pos.x,n.top-this.pos.y));o.owner=this,this._composite.addCollider(o)}this.collider.update(),this.collider.$colliderAdded.notifyAll(this._composite)}getTileByIndex(t){var e;return(e=this.tiles[t])!=null?e:null}getTile(t,e){return t<0||e<0||t>=this.columns||e>=this.rows?null:this.tiles[t+e*this.columns]}getTileByPoint(t){const{x:e,y:i}=this._getTileCoordinates(t),s=this.getTile(e,i);return e>=0&&i>=0&&e<this.columns&&i<this.rows&&s?s:null}_getTileCoordinates(t){t=this.transform.applyInverse(t);const e=Math.floor(t.x/this.tileWidth),i=Math.floor(t.y/this.tileHeight);return{x:e,y:i}}getRows(){return this._rows}getColumns(){return this._cols}getOnScreenTiles(){const t=this._engine.screen.getWorldBounds();let e=b(0,0),i=this.transform.coordPlane===rt.Screen?this._engine.screen.getScreenBounds():t;const s=this.get(Wi);if(s&&this.isInitialized){const g=v.One.sub(s.parallaxFactor);e=this._engine.currentScene.camera.pos.scale(g),i=i.translate(e.negate())}const n=this._getTileCoordinates(i.topLeft),o=this._getTileCoordinates(i.topRight),a=this._getTileCoordinates(i.bottomRight),h=this._getTileCoordinates(i.bottomLeft),l=Math.min(B(n.x,0,this.columns-1),B(o.x,0,this.columns-1)),c=Math.min(B(n.y,0,this.rows-1),B(o.y,0,this.rows-1)),u=Math.max(B(a.x,0,this.columns-1),B(h.x,0,this.columns-1)),_=Math.max(B(a.y,0,this.rows-1),B(h.y,0,this.rows-1)),f=[];for(let g=l;g<=u;g++)for(let p=c;p<=_;p++)f.push(this.getTile(g,p));return f}_processPointerToObject(t){const e=Array.from(t.currentFramePointerCoords.entries());for(const[i,s]of e){const n=this.getTileByPoint(this.transform.coordPlane===rt.World?s.worldPos:s.screenPos);n&&this._pointerEventDispatcher.addPointerToObject(n,i)}}_dispatchPointerEvents(t){this._pointerEventDispatcher.dispatchEvents(t)}update(t,e){this._initialize(t),this.onPreUpdate(t,e),this.emit("preupdate",new ne(t,e,this)),(!this._oldPos.equals(this.pos)||this._oldRotation!==this.rotation||!this._oldScale.equals(this.scale))&&(this.flagCollidersDirty(),this.flagTilesDirty()),this._collidersDirty&&(this._collidersDirty=!1,this._updateColliders()),this._pointerEventDispatcher.clear(),this._token++,this.pos.clone(this._oldPos),this._oldRotation=this.rotation,this.scale.clone(this._oldScale),this.transform.pos=this.pos,this.onPostUpdate(t,e),this.emit("postupdate",new re(t,e,this))}draw(t,e){if(!this.isInitialized)return;this.emit("predraw",new ke(t,e,this));let i,s,n;const o=this.getOnScreenTiles();for(let a=0;a<o.length;a++){const h=o[a],l=h.getGraphicsOffsets();for(i=h.getGraphics(),s=0,n=i.length;s<n;s++){const c=i[s],u=l[s];if(c){Sn(c)&&(c==null||c.tick(e,this._token));const _=this.renderFromTopOfGraphic?0:c.height-this.tileHeight;c.draw(t,h.x*this.tileWidth+u.x,h.y*this.tileHeight-_+u.y)}}}this.emit("postdraw",new ze(t,e,this))}debug(t,e){const{showAll:i,showGrid:s,gridColor:n,gridWidth:o,showSolidBounds:a,solidBoundsColor:h,showColliderGeometry:l}=e.tilemap,{geometryColor:c,geometryLineWidth:u,geometryPointSize:_}=e.collider,f=this.tileWidth*this.columns*this.scale.x,g=this.tileHeight*this.rows*this.scale.y,p=this.pos;if(s||i){for(let x=0;x<this.rows+1;x++){const m=b(0,x*this.tileHeight*this.scale.y);t.drawLine(p.add(m),p.add(b(f,m.y)),n,o)}for(let x=0;x<this.columns+1;x++){const m=b(x*this.tileWidth*this.scale.x,0);t.drawLine(p.add(m),p.add(b(m.x,g)),n,o)}}if(i||a||l){const x=this._composite.getColliders();t.save(),t.translate(this.pos.x,this.pos.y),t.scale(this.scale.x,this.scale.y);for(const m of x){const w=m.localBounds,S=m.worldPos.sub(this.pos);a&&t.drawRectangle(S,w.width,w.height,h)}if(t.restore(),l)for(const m of x)m.debug(t,c,{lineWidth:u,pointSize:_})}if(i||a){if(t.save(),t.z=999,a)for(let x=0;x<this.tiles.length;x++)this.tiles[x].bounds.draw(t);t.restore()}}}class Wo{constructor(t){this._posDirty=!1,this.events=new X,this._solid=!1,this._graphics=[],this._offsets=[],this._colliders=[],this.data=new Map;var e,i;this.x=t.x,this.y=t.y,this.map=t.map,this._width=t.map.tileWidth*this.map.scale.x,this._height=t.map.tileHeight*this.map.scale.y,this.solid=(e=t.solid)!=null?e:this.solid,this._graphics=(i=t.graphics)!=null?i:[],this._recalculate()}get pos(){return this._posDirty&&(this._recalculate(),this._posDirty=!1),this._pos}get width(){return this._width}get height(){return this._height}get solid(){return this._solid}set solid(t){var e;(e=this.map)==null||e.flagCollidersDirty(),this._solid=t}getGraphics(){return this._graphics}getGraphicsOffsets(){return this._offsets}addGraphic(t,e){this._graphics.push(t),e!=null&&e.offset?this._offsets.push(e.offset):this._offsets.push(v.Zero)}removeGraphic(t){const e=this._graphics.indexOf(t);e>-1&&(this._graphics.splice(e,1),this._offsets.splice(e,1))}clearGraphics(){this._graphics.length=0,this._offsets.length=0}getColliders(){return this._colliders}addCollider(t){this._colliders.push(t),this.map.flagCollidersDirty()}removeCollider(t){const e=this._colliders.indexOf(t);e>-1&&this._colliders.splice(e,1),this.map.flagCollidersDirty()}clearColliders(){this._colliders.length=0,this.map.flagCollidersDirty()}flagDirty(){this._posDirty=!0}_recalculate(){const t=this.map.pos.add(b(this.x*this.map.tileWidth,this.y*this.map.tileHeight));this._geometry=new D(t.x,t.y,t.x+this.map.tileWidth,t.y+this.map.tileHeight),this._width=this.map.tileWidth*this.map.scale.x,this._height=this.map.tileHeight*this.map.scale.y,this._pos=this.map.pos.add(b(this.x*this._width,this.y*this._height)),this._bounds=new D(this._pos.x,this._pos.y,this._pos.x+this._width,this._pos.y+this._height),this.map.rotation&&(this._bounds=this._bounds.rotate(this.map.rotation,this.map.pos)),this._posDirty=!1}get bounds(){return this._posDirty&&this._recalculate(),this._bounds}get defaultGeometry(){return this._geometry}get center(){return this._posDirty&&this._recalculate(),new v(this._pos.x+this._width/2,this._pos.y+this._height/2)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){e?this.events.off(t,e):this.events.off(t)}}class vi extends Dt{constructor(t){super(),this.elevation=0,this.columns=t.columns,this.rows=t.rows,this.tileWidth=t.tileWidth,this.tileHeight=t.tileHeight}}class Go extends Tt{constructor(t,e,i,s){super([new A,new j({offset:i!=null?i:v.Zero,onPostDraw:(_,f)=>this.draw(_,f)}),new vi(s)]),this.solid=!1,this.events=new X,this._tileBounds=new D,this._graphics=[],this._colliders=[],this.data=new Map,this.x=t,this.y=e,this.map=s,this._transform=this.get(A),this._isometricEntityComponent=this.get(vi);const n=this.map.tileWidth/2,o=this.map.tileHeight/2,a=(this.x-this.y)*n,h=(this.x+this.y)*o;this._transform.pos=b(a,h),this._isometricEntityComponent.elevation=s.elevation,this._gfx=this.get(j),this._gfx.isVisible=!1;const l=this.map.tileWidth,c=this.map.tileHeight,u=b(0,this.map.renderFromTopOfGraphic?c:0);this._gfx.localBounds=this._tileBounds=new D({left:-l/2,top:-c,right:l/2,bottom:c}).translate(u)}getGraphics(){return this._graphics}addGraphic(t,e){this._graphics.push(t),this._gfx.isVisible=this.map.isVisible,this._gfx.opacity=this.map.opacity,e!=null&&e.offset&&(this._gfx.offset=e.offset),this._gfx.localBounds=this._recalculateBounds()}_recalculateBounds(){let t=this._tileBounds.clone();for(const e of this._graphics){const i=b(this.map.graphicsOffset.x-this.map.tileWidth/2,this.map.graphicsOffset.y-(this.map.renderFromTopOfGraphic?0:e.height-this.map.tileHeight));t=t.combine(e.localBounds.translate(i))}return t}removeGraphic(t){const e=this._graphics.indexOf(t);e>-1&&this._graphics.splice(e,1),this._gfx.localBounds=this._recalculateBounds()}clearGraphics(){this._graphics.length=0,this._gfx.isVisible=!1,this._gfx.localBounds=this._recalculateBounds()}getColliders(){return this._colliders}addCollider(t){this._colliders.push(t),this.map.flagCollidersDirty()}removeCollider(t){const e=this._colliders.indexOf(t);e>-1&&this._colliders.splice(e,1),this.map.flagCollidersDirty()}clearColliders(){this._colliders.length=0,this.map.flagCollidersDirty()}get pos(){return this.map.tileToWorld(b(this.x,this.y))}get center(){return this.pos.add(b(0,this.map.tileHeight/2))}draw(t,e){const i=this.map.tileWidth/2;t.save(),t.translate(-i,0);for(const s of this._graphics)s.draw(t,this.map.graphicsOffset.x,this.map.graphicsOffset.y-(this.map.renderFromTopOfGraphic?0:s.height-this.map.tileHeight));t.restore()}}class Rl extends Tt{constructor(t){super([new A,new N({type:M.Fixed}),new tt,new ae,new Ni((c,u)=>this.debug(c,u),!1)],t.name),this.elevation=0,this.isVisible=!0,this.opacity=1,this.renderFromTopOfGraphic=!1,this.graphicsOffset=b(0,0),this._collidersDirty=!1,this._originalOffsets=new WeakMap;const{pos:e,tileWidth:i,tileHeight:s,columns:n,rows:o,renderFromTopOfGraphic:a,graphicsOffset:h,elevation:l}=t;this.transform=this.get(A),e&&(this.transform.pos=e),this.collider=this.get(tt),this.collider&&this.collider.set(this._composite=new at([])),this.pointer=this.get(ae),this.renderFromTopOfGraphic=a!=null?a:this.renderFromTopOfGraphic,this.graphicsOffset=h!=null?h:this.graphicsOffset,this.elevation=l!=null?l:this.elevation,this.tileWidth=i,this.tileHeight=s,this.columns=n,this.rows=o,this._pointerEventDispatcher=new Nn,this.tiles=new Array(n*o);for(let c=0;c<o;c++)for(let u=0;u<n;u++){const _=new Go(u,c,this.graphicsOffset,this);this.tiles[u+c*n]=_,this.addChild(_),this._pointerEventDispatcher.addObject(_,f=>this.getTileByPoint(f.worldPos)===_,()=>!0)}this.pointer.localBounds=D.fromDimension(i*n*this.transform.scale.x,s*o*this.transform.scale.y,b(.5,0))}get visible(){return this.isVisible}set visible(t){this.isVisible=t}_processPointerToObject(t){const e=Array.from(t.currentFramePointerCoords.entries());for(const[i,s]of e){const n=this.getTileByPoint(this.transform.coordPlane===rt.World?s.worldPos:s.screenPos);n&&this._pointerEventDispatcher.addPointerToObject(n,i)}}_dispatchPointerEvents(t){this._pointerEventDispatcher.dispatchEvents(t,this.tiles)}update(){this._collidersDirty&&(this.updateColliders(),this._collidersDirty=!1),this._pointerEventDispatcher.clear()}flagCollidersDirty(){this._collidersDirty=!0}_getOrSetColliderOriginalOffset(t){var e;if(this._originalOffsets.has(t))return(e=this._originalOffsets.get(t))!=null?e:v.Zero;{const i=t.offset;return this._originalOffsets.set(t,i),i}}updateColliders(){this._composite.clearColliders();const t=this.get(A).pos;for(const e of this.tiles)if(e.solid)for(const i of e.getColliders()){const s=this._getOrSetColliderOriginalOffset(i);i.offset=this.tileToWorld(b(e.x,e.y)).sub(t).add(s).sub(b(this.tileWidth/2,this.tileHeight)),i.owner=this,this._composite.addCollider(i)}this.collider.update()}worldToTile(t){t=t.sub(this.transform.globalPos);const e=this.tileWidth/2,i=this.tileHeight/2;return b(~~((t.x/e+t.y/i)/2),~~((t.y/i-t.x/e)/2))}tileToWorld(t){const e=this.tileWidth/2,i=this.tileHeight/2,s=(t.x-t.y)*e,n=(t.x+t.y)*i;return b(s,n).add(this.transform.pos)}getTile(t,e){return t<0||e<0||t>=this.columns||e>=this.rows?null:this.tiles[t+e*this.columns]}getTileByPoint(t){const e=this.worldToTile(t);return this.getTile(e.x,e.y)}_getMaxZIndex(){let t=Number.NEGATIVE_INFINITY;for(const e of this.tiles){const i=e.get(A).z;i>t&&(t=i)}return t}debug(t,e){const{showAll:i,showPosition:s,positionColor:n,positionSize:o,showGrid:a,gridColor:h,gridWidth:l,showColliderGeometry:c}=e.isometric,{geometryColor:u,geometryLineWidth:_,geometryPointSize:f}=e.collider;if(t.save(),t.z=this._getMaxZIndex()+.5,i||a){for(let g=0;g<this.rows+1;g++){const p=this.tileToWorld(b(0,g)),x=this.tileToWorld(b(this.columns,g));t.drawLine(p,x,h,l)}for(let g=0;g<this.columns+1;g++){const p=this.tileToWorld(b(g,0)),x=this.tileToWorld(b(g,this.rows));t.drawLine(p,x,h,l)}}if(i||s)for(const g of this.tiles)t.drawCircle(this.tileToWorld(b(g.x,g.y)),o,n);if(i||c){for(const g of this.tiles)if(g.solid)for(const p of g.getColliders())p.debug(t,u,{lineWidth:_,pointSize:f})}t.restore()}}class Wn extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Update,this.query=this.world.query([A,vi])}update(){let t,e;for(let i=0;i<this.query.entities.length;i++){const s=this.query.entities[i];t=s.get(A),e=s.get(vi);const o=Math.max(e.columns*e.tileWidth,e.rows*e.tileHeight)*e.elevation+t.pos.y;t.z=o}}}Wn.priority=Nt.Lower;class Vo{constructor(t){this.camera=t}lockToActor(t){this.camera.addStrategy(new Xo(t))}lockToActorAxis(t,e){this.camera.addStrategy(new Yo(t,e))}elasticToActor(t,e,i){this.camera.addStrategy(new $o(t,e,i))}radiusAroundActor(t,e){this.camera.addStrategy(new jo(t,e))}limitCameraBounds(t){this.camera.addStrategy(new Zo(t))}}var qo=(r=>(r[r.X=0]="X",r[r.Y=1]="Y",r))(qo||{});class Xo{constructor(t){this.target=t,this.action=(e,i,s,n)=>e.center}}class Yo{constructor(t,e){this.target=t,this.axis=e,this.action=(i,s,n,o)=>{const a=i.center,h=s.getFocus();return this.axis===0?new v(a.x,h.y):new v(h.x,a.y)}}}class $o{constructor(t,e,i){this.target=t,this.cameraElasticity=e,this.cameraFriction=i,this.action=(s,n,o,a)=>{const h=s.center;let l=n.getFocus(),c=n.vel.clone();const u=h.sub(l).scale(this.cameraElasticity);c=c.add(u);const _=c.scale(-1).scale(this.cameraFriction);return c=c.add(_),l=l.add(c),l}}}class jo{constructor(t,e){this.target=t,this.radius=e,this.action=(i,s,n,o)=>{const a=i.center,h=s.getFocus(),l=a.sub(h),c=l.magnitude;if(c>=this.radius){const u=c-this.radius;return h.add(l.normalize().scale(u))}return h}}}class Zo{constructor(t){this.target=t,this.boundSizeChecked=!1,this.action=(e,i,s,n)=>{const o=i.getFocus();this.boundSizeChecked||((e.bottom-e.top<s.drawHeight||e.right-e.left<s.drawWidth)&&R.getInstance().warn("Camera bounds should not be smaller than the engine viewport"),this.boundSizeChecked=!0);let a=o.x,h=o.y;return o.x<e.left+s.halfDrawWidth?a=e.left+s.halfDrawWidth:o.x>e.right-s.halfDrawWidth&&(a=e.right-s.halfDrawWidth),o.y<e.top+s.halfDrawHeight?h=e.top+s.halfDrawHeight:o.y>e.bottom-s.halfDrawHeight&&(h=e.bottom-s.halfDrawHeight),b(a,h)}}}const Ml={Initialize:"initialize",PreUpdate:"preupdate",PostUpdate:"postupdate"};class Qo{constructor(){this.events=new X,this.transform=Q.identity(),this.inverse=Q.identity(),this._cameraStrategies=[],this.strategy=new Vo(this),this._z=1,this.dz=0,this.az=0,this.rotation=0,this._angularVelocity=0,this._posChanged=!1,this._pos=new se(v.Zero,()=>{this._posChanged=!0}),this.drawPos=this.pos.clone(),this._oldPos=this.pos.clone(),this.vel=v.Zero,this.acc=v.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._legacyZoomEasing=It.EaseInOutCubic,this._useLegacyZoom=!1,this._zoomEasing=xs,this._legacyEasing=It.EaseInOutCubic,this._useLegacyEasing=!1,this._easing=xs,this._halfWidth=0,this._halfHeight=0,this._viewport=null,this._isInitialized=!1,this._snapPos=b(0,0)}get strategies(){return this._cameraStrategies}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._angularVelocity}set angularVelocity(t){this._angularVelocity=t}get pos(){return this._pos}set pos(t){this._posChanged=!0,this._pos=new se(t,()=>{this._posChanged=!0})}hasChanged(){return this._posChanged}get x(){return this.pos.x}set x(t){!this._follow&&!this._cameraMoving&&(this.pos=b(t,this.pos.y))}get y(){return this.pos.y}set y(t){!this._follow&&!this._cameraMoving&&(this.pos=b(this.pos.x,t))}get dx(){return this.vel.x}set dx(t){this.vel=b(t,this.vel.y)}get dy(){return this.vel.y}set dy(t){this.vel=b(this.vel.x,t)}get ax(){return this.acc.x}set ax(t){this.acc=b(t,this.acc.y)}get ay(){return this.acc.y}set ay(t){this.acc=b(this.acc.x,t)}getFocus(){return this.pos}move(t,e,i=It.EaseInOutCubic){if(typeof i!="function")throw"Please specify an EasingFunction";return this._follow?Promise.reject(t):(this._lerpPromise&&this._lerpResolve&&this._lerpResolve(t),this._lerpPromise=new Promise(s=>{this._lerpResolve=s}),this._lerpStart=this.getFocus().clone(),this._lerpDuration=e,this._lerpEnd=t,this._currentLerpTime=0,this._cameraMoving=!0,Se(i)?this._legacyEasing=i: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=It.EaseInOutCubic){if(this._zoomPromise=new Promise(s=>{this._zoomResolve=s}),e)this._isZooming=!0,Se(i)?this._legacyZoomEasing=i:this._easing=i,this._currentZoomTime=0,this._zoomDuration=e,this._zoomStart=this.zoom,this._zoomEnd=t;else return this._isZooming=!1,this.zoom=t,Promise.resolve(!0);return this._zoomPromise}get viewport(){return this._viewport?this._viewport:new D(0,0,0,0)}addStrategy(...t){this._cameraStrategies.push(...t)}setStrategies(t){this._cameraStrategies=[...t]}removeStrategy(t){Oe(t,this._cameraStrategies)}clearAllStrategies(){this._cameraStrategies.length=0}_preupdate(t,e){this.events.emit("preupdate",new ne(t,e,this)),this.onPreUpdate(t,e)}onPreUpdate(t,e){}_postupdate(t,e){this.events.emit("postupdate",new re(t,e,this)),this.onPostUpdate(t,e)}onPostUpdate(t,e){}get isInitialized(){return this._isInitialized}_initialize(t){if(!this.isInitialized){this._engine=t,this._screen=t.screen;const e=this._screen.contentArea;let i=b(e.width/2,e.height/2);if(!this._engine.loadingComplete){const s=this._screen.peekResolution();s&&(i=b(s.width/2,s.height/2))}this._halfWidth=i.x,this._halfHeight=i.y,this._posChanged||(this.pos=i),this.pos.clone(this.drawPos),this.updateTransform(this.pos),this.runStrategies(t,t.clock.elapsed()),this.updateViewport(),this.updateTransform(this.pos),this.pos.clone(this._oldPos),this.onInitialize(t),this.events.emit("initialize",new Ue(t,this)),this._isInitialized=!0}}onInitialize(t){}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}runStrategies(t,e){for(const i of this._cameraStrategies)this.pos=i.action.call(i,i.target,this,t,e)}updateViewport(){this._viewport=new D(this.x-this._halfWidth,this.y-this._halfHeight,this.x+this._halfWidth,this.y+this._halfHeight)}update(t,e){if(this._initialize(t),this._preupdate(t,e),this.pos.clone(this._oldPos),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){let i=this.zoom;if(this._useLegacyZoom){const s=this._legacyZoomEasing;i=s(this._currentZoomTime,this._zoomStart,this._zoomEnd,this._zoomDuration)}else i=ot(this._zoomStart,this._zoomEnd,this._zoomEasing(this._currentZoomTime/this._zoomDuration));this.zoom=i,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){let i=this.pos;this._useLegacyEasing?i=It.CreateVectorEasingFunction(this._legacyEasing)(this._currentLerpTime,this._lerpStart,this._lerpEnd,this._lerpDuration):(i.x=ot(this._lerpStart.x,this._lerpEnd.x,this._easing(this._currentLerpTime/this._lerpDuration)),i.y=ot(this._lerpStart.y,this._lerpEnd.y,this._easing(this._currentLerpTime/this._lerpDuration))),this.pos=i,this._currentLerpTime+=e}else{this.pos=this._lerpEnd;const i=this._lerpEnd.clone();this._lerpStart=null,this._lerpEnd=null,this._currentLerpTime=0,this._cameraMoving=!1,this._lerpResolve(i)}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=(Math.random()*this._shakeMagnitudeX|0)+1,this._yShake=(Math.random()*this._shakeMagnitudeY|0)+1),this.runStrategies(t,e),this.updateViewport(),this.updateTransform(this.pos),this._postupdate(t,e),this._posChanged=!1}draw(t){if(this.pos.clone(this.drawPos),this._engine.fixedUpdateTimestep){const e=this._engine.currentFrameLagMs/this._engine.fixedUpdateTimestep,i=this.pos.scale(e).add(this._oldPos.scale(1-e));i.clone(this.drawPos),this.updateTransform(i)}if(t.snapToPixel){const e=this.drawPos.clone(this._snapPos);e.x=~~(e.x+L*G(e.x)),e.y=~~(e.y+L*G(e.y)),e.clone(this.drawPos),this.updateTransform(e)}t.multiply(this.transform)}updateTransform(t){const e=this._screen.resolution.width/this.zoom,i=this._screen.resolution.height/this.zoom,s=b(-t.x+e/2+this._xShake,-t.y+i/2+this._yShake);this.transform.reset(),this.transform.scale(this.zoom,this.zoom),this.transform.translate(e/2,i/2),this.transform.rotate(this.rotation),this.transform.translate(-e/2,-i/2),this.transform.translate(s.x,s.y),this.transform.inverse(this.inverse)}_isDoneShaking(){return!this._isShaking||this._elapsedShakeTime>=this._shakeDuration}}const Dl={ExitTrigger:"exit",EnterTrigger:"enter"};class Jo extends Ft{constructor(t){var e,i,s,n;super({...t}),this.events=new X,this.filter=(e=t.filter)!=null?e:()=>!0,this.repeat=(i=t.repeat)!=null?i:-1,this.action=(s=t.action)!=null?s:()=>{},this.target=t.target,this.graphics.isVisible=(n=t.visible)!=null?n:!1,this.body.collisionType=M.Passive,this.events.on("collisionstart",({other:o})=>{this._matchesTarget(o.owner)&&(this.events.emit("enter",new qs(this,o.owner)),this._dispatchAction(o.owner),this.repeat===0&&this.kill())}),this.events.on("collisionend",({other:o})=>{this._matchesTarget(o.owner)&&this.events.emit("exit",new Xs(this,o.owner))})}_matchesTarget(t){return this.filter(t)&&(this.target===void 0||this.target===t)}_dispatchAction(t){this.repeat!==0&&(this.action.call(this,t),this.repeat--)}}class Gn extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Draw,this.query=this.world.query([A])}initialize(t,e){this._graphicsContext=e.engine.graphicsContext,this._camera=e.camera,this._engine=e.engine,this._collisionSystem=t.systemManager.get(Zi)}update(){var t;if(!this._engine.isDebug)return;const e=this._engine.debug.filter;let i,s;const n=this._engine.debug.entity;let o;const a=this._engine.debug.transform;let h;const l=this._engine.debug.motion;let c;const u=this._engine.debug.collider,_=this._engine.debug.physics;let f;const g=this._engine.debug.graphics;let p,x;const m=this._engine.debug.body,w=this._engine.debug.camera;for(let S=0;S<this.query.entities.length;S++){const C=this.query.entities[S];if(C.hasTag("offscreen")||C instanceof Yi||e.useFilter&&(!(e.ids.length===0||e.ids.includes(C.id))||!(e.nameQuery===""||C.name.includes(e.nameQuery))))continue;let T=v.Zero;const I=b(0,16);if(i=C.id,s=C.name,o=C.get(A),this._pushCameraTransform(o),this._graphicsContext.save(),o.coordPlane===rt.Screen&&this._graphicsContext.translate(this._engine.screen.contentArea.left,this._engine.screen.contentArea.top),this._graphicsContext.z=a.debugZIndex,this._applyTransform(C),o&&((a.showAll||a.showPosition)&&this._graphicsContext.debug.drawPoint(v.Zero,{size:4,color:a.positionColor}),(a.showAll||a.showPositionLabel)&&(this._graphicsContext.debug.drawText(`pos${o.pos.toString(2)}`,T),T=T.add(I)),(a.showAll||a.showZIndex)&&(this._graphicsContext.debug.drawText(`z(${o.z.toFixed(1)})`,T),T=T.add(I)),(n.showAll||n.showId)&&(this._graphicsContext.debug.drawText(`id(${i}) ${C.parent?"child of id("+((t=C.parent)==null?void 0:t.id)+")":""}`,T),T=T.add(I)),(n.showAll||n.showName)&&(this._graphicsContext.debug.drawText(`name(${s})`,T),T=T.add(I)),(a.showAll||a.showRotation)&&(this._graphicsContext.drawLine(v.Zero,v.fromAngle(o.rotation).scale(50).add(v.Zero),a.rotationColor,2),this._graphicsContext.debug.drawText(`rot deg(${ar(o.rotation).toFixed(2)})`,T),T=T.add(I)),(a.showAll||a.showScale)&&this._graphicsContext.drawLine(v.Zero,o.scale.add(v.Zero),a.scaleColor,2)),f=C.get(j),f&&(g.showAll||g.showBounds)&&f.localBounds.draw(this._graphicsContext,g.boundsColor),p=C.get(Ni),p&&(p.useTransform||this._graphicsContext.restore(),p.draw(this._graphicsContext,this._engine.debug),p.useTransform||(this._graphicsContext.save(),this._applyTransform(C))),x=C.get(N),x&&((m.showAll||m.showCollisionGroup)&&(this._graphicsContext.debug.drawText(`collision group(${x.group.name})`,T),T=T.add(I)),(m.showAll||m.showCollisionType)&&(this._graphicsContext.debug.drawText(`collision type(${x.collisionType})`,T),T=T.add(I)),(m.showAll||m.showMass)&&(this._graphicsContext.debug.drawText(`mass(${x.mass})`,T),T=T.add(I)),(m.showAll||m.showMotion)&&(this._graphicsContext.debug.drawText(`motion(${x.sleepMotion})`,T),T=T.add(I)),(m.showAll||m.showSleeping)&&(this._graphicsContext.debug.drawText(`sleeping(${x.canSleep?x.isSleeping:"cant sleep"})`,T),T=T.add(I))),this._graphicsContext.restore(),this._graphicsContext.save(),o.coordPlane===rt.Screen&&this._graphicsContext.translate(this._engine.screen.contentArea.left,this._engine.screen.contentArea.top),this._graphicsContext.z=a.debugZIndex,h=C.get(U),h&&((l.showAll||l.showVelocity)&&(this._graphicsContext.debug.drawText(`vel${h.vel.toString(2)}`,T.add(o.globalPos)),this._graphicsContext.drawLine(o.globalPos,o.globalPos.add(h.vel),l.velocityColor,2),T=T.add(I)),(l.showAll||l.showAcceleration)&&this._graphicsContext.drawLine(o.globalPos,o.globalPos.add(h.acc),l.accelerationColor,2)),c=C.get(tt),c){const y=c.get();if((u.showAll||u.showGeometry)&&y&&y.debug(this._graphicsContext,u.geometryColor,{lineWidth:u.geometryLineWidth,pointSize:u.geometryPointSize}),u.showAll||u.showBounds){if(y instanceof at){const F=y.getColliders();for(const W of F){const q=W.bounds,Y=b(q.left,q.top);this._graphicsContext.debug.drawRect(Y.x,Y.y,q.width,q.height,{color:u.boundsColor}),(u.showAll||u.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${W.owner.id})`,Y)}c.bounds.draw(this._graphicsContext,u.boundsColor)}else if(y){const F=c.bounds,W=b(F.left,F.top);this._graphicsContext.debug.drawRect(W.x,W.y,F.width,F.height,{color:u.boundsColor}),(u.showAll||u.showOwner)&&this._graphicsContext.debug.drawText(`owner id(${c.owner.id})`,W)}}}this._graphicsContext.restore(),this._popCameraTransform(o)}if(this._graphicsContext.save(),this._camera.draw(this._graphicsContext),(_.showAll||_.showBroadphaseSpacePartitionDebug)&&this._collisionSystem.debug(this._graphicsContext),_.showAll||_.showCollisionContacts||_.showCollisionNormals)for(const[S,C]of this._engine.debug.stats.currFrame.physics.contacts){if(_.showAll||_.showCollisionContacts)for(const T of C.points)this._graphicsContext.debug.drawPoint(T,{size:_.contactSize,color:_.collisionContactColor});if(_.showAll||_.showCollisionNormals)for(const T of C.points)this._graphicsContext.debug.drawLine(T,C.normal.scale(30).add(T),{color:_.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()}postupdate(t,e){this._engine.isDebug&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext),Cn.flush(this._graphicsContext),this._graphicsContext.restore())}_applyTransform(t){const e=t.getAncestors();for(const i of e){const s=i==null?void 0:i.get(A);s&&(this._graphicsContext.translate(s.pos.x,s.pos.y),this._graphicsContext.scale(s.scale.x,s.scale.y),this._graphicsContext.rotate(s.rotation))}}_pushCameraTransform(t){t.coordPlane===rt.World&&(this._graphicsContext.save(),this._camera&&this._camera.draw(this._graphicsContext))}_popCameraTransform(t){t.coordPlane===rt.World&&this._graphicsContext.restore()}}Gn.priority=Nt.Lowest;class ts extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Update,this._graphicsHashGrid=new Rn({size:100}),this._graphics=[],this._entityToPointer=new Map,this._pointerEventDispatcher=new Nn,this.overrideUseColliderShape=!1,this.overrideUseGraphicsBounds=!1,this._sortedTransforms=[],this._sortedEntities=[],this._zHasChanged=!1,this._zIndexUpdate=()=>{this._zHasChanged=!0},this.query=this.world.query([A,ae]),this.query.entityAdded$.subscribe(e=>{const i=e.get(A),s=e.get(ae);this._pointerEventDispatcher.addObject(e,o=>s&&s.localBounds?s.localBounds.transform(i.get().matrix).contains(i.coordPlane===rt.World?o.worldPos:o.screenPos):!1,()=>e.isActive),this._entityToPointer.set(e,s);const n=e.get(j);n&&(this._graphics.push(n),this._graphicsHashGrid.track(n)),this._sortedTransforms.push(i),this._sortedEntities.push(i.owner),i.zIndexChanged$.subscribe(this._zIndexUpdate),this._zHasChanged=!0}),this.query.entityRemoved$.subscribe(e=>{this._pointerEventDispatcher.removeObject(e);const i=e.get(A);this._entityToPointer.delete(e);const s=e.get(j);if(s){const o=this._graphics.indexOf(s);o>-1&&this._graphics.splice(o,1),this._graphicsHashGrid.untrack(s)}i.zIndexChanged$.unsubscribe(this._zIndexUpdate);const n=this._sortedTransforms.indexOf(i);n>-1&&(this._sortedTransforms.splice(n,1),this._sortedEntities.splice(n,1))})}initialize(t,e){this._engine=e.engine,this._scene=e}preupdate(){this._scene.camera.hasChanged()&&this._scene.camera.updateTransform(this._scene.camera.pos),this._receivers=[this._engine.input.pointers,this._scene.input.pointers],this._engineReceiver=this._engine.input.pointers,this._zHasChanged&&(this._sortedTransforms.sort((t,e)=>e.z-t.z),this._sortedEntities=this._sortedTransforms.map(t=>t.owner),this._zHasChanged=!1)}update(){this._graphicsHashGrid.update(this._graphics);for(const[t,e]of this._engineReceiver.currentFramePointerCoords.entries()){const i=this._scene.physics.query(e.worldPos);for(let n=0;n<i.length;n++){const o=i[n],a=this._entityToPointer.get(o.owner);a&&(a.useColliderShape||this.overrideUseColliderShape)&&this._pointerEventDispatcher.addPointerToObject(o.owner,t)}const s=this._graphicsHashGrid.query(e.worldPos);for(let n=0;n<s.length;n++){const o=s[n],a=this._entityToPointer.get(o.owner);a&&(a.useGraphicsBounds||this.overrideUseGraphicsBounds)&&this._pointerEventDispatcher.addPointerToObject(o.owner,t)}}this._pointerEventDispatcher.processPointerToObject(this._engineReceiver,this._sortedEntities),this._pointerEventDispatcher.dispatchEvents(this._engineReceiver,this._sortedEntities),this._receivers.forEach(t=>t.update()),this._pointerEventDispatcher.clear(),this._receivers.forEach(t=>t.clear())}}ts.priority=Nt.Higher;class Vn extends At{constructor(t){super(),this.world=t,this.systemType=Pt.Update,this._actions=[],this.query=this.world.query([je]),this.query.entityAdded$.subscribe(e=>this._actions.push(e.get(je))),this.query.entityRemoved$.subscribe(e=>{const i=e.get(je),s=this._actions.indexOf(i);s>-1&&this._actions.splice(s,1)})}update(t){for(let e=0;e<this._actions.length;e++)this._actions[e].update(t)}}Vn.priority=Nt.Higher;class es{constructor(){this.events=new X,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,this._enabled=!0}init(){this.supported&&(this._initSuccess||(this._oldPads=this._clonePads(this._navigator.getGamepads()),this._oldPads.length&&this._oldPads[0]&&(this._initSuccess=!0)))}toggleEnabled(t){this._enabled=t}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(s=>typeof s!==void 0).length,i=t.buttons.filter(s=>typeof s!==void 0).length;return e>=this._minimumConfiguration.axis&&i>=this._minimumConfiguration.buttons&&t.connected}emit(t,e){this.events.emit(t,e)}on(t,e){return this._enableAndUpdate(),this.events.on(t,e)}once(t,e){return this._enableAndUpdate(),this.events.once(t,e)}off(t,e){this._enableAndUpdate(),this.events.off(t,e)}update(){var t,e;if(!this.enabled||!this.supported||!this._enabled)return;this.init();const i=this._navigator.getGamepads();for(let s=0;s<i.length;s++){if(i[s]){const o=this.at(s);!this.at(s).connected&&this._isGamepadValid(i[s])&&(o.events.pipe(this.events),this.events.emit("connect",new Ls(s,this.at(s)))),this.at(s).connected=!0}else{const o=this.at(s);o.connected&&(this.events.emit("disconnect",new ks(s,o)),o.events.unpipe(this.events)),o.connected=!1;continue}if(this.at(s).update(),i[s].timestamp&&i[s].timestamp===this._gamePadTimeStamps[s])continue;this._gamePadTimeStamps[s]=i[s].timestamp,this.at(s).navigatorGamepad=i[s];const n=i[s];if(n){for(let o=0;o<n.buttons.length;o++){const a=n.buttons[o],h=a==null?void 0:a.value;h!==((t=this._oldPads[s])==null?void 0:t.getButton(o))&&(a!=null&&a.pressed?(this.at(s).updateButton(o,h),this.at(s).events.emit("button",new zs(o in qn?o:-1,o,h,this.at(s)))):this.at(s).updateButton(o,0))}for(let o=0;o<n.axes.length;o++){const a=n.axes[o];a!==((e=this._oldPads[s])==null?void 0:e.getAxes(o))&&(this.at(s).updateAxes(o,a),this.at(s).events.emit("axis",new Us(o,a,this.at(s))))}}this._oldPads[s]=this._clonePad(i[s])}}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 is),this._oldPads.push(new is);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 is;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}}es.MinAxisMoveThreshold=.05;class is{constructor(){this.events=new X,this.connected=!1,this._axes=new Array(4),this._buttons=new Array(16),this._buttonsUp=new Array(16),this._buttonsDown=new Array(16);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}update(){this._buttonsDown=new Array(16),this._buttonsUp=new Array(16)}isButtonPressed(t,e=1){return this._buttons[t]>=e}isButtonHeld(t,e=1){return this._buttons[t]>=e}wasButtonPressed(t,e=1){return this._buttonsDown[t]>=e}wasButtonReleased(t){return!!this._buttonsUp[t]}getButton(t){return this._buttons[t]}getAxes(t){const e=this._axes[t];return Math.abs(e)<es.MinAxisMoveThreshold?0:e}updateButton(t,e){e===0&&this._buttons[t]?this._buttonsUp[t]=1:this._buttonsDown[t]=e,this._buttons[t]=e}updateAxes(t,e){this._axes[t]=e}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}}var qn=(r=>(r[r.Unknown=-1]="Unknown",r[r.Face1=0]="Face1",r[r.Face2=1]="Face2",r[r.Face3=2]="Face3",r[r.Face4=3]="Face4",r[r.LeftBumper=4]="LeftBumper",r[r.RightBumper=5]="RightBumper",r[r.LeftTrigger=6]="LeftTrigger",r[r.RightTrigger=7]="RightTrigger",r[r.Select=8]="Select",r[r.Start=9]="Start",r[r.LeftStick=10]="LeftStick",r[r.RightStick=11]="RightStick",r[r.DpadUp=12]="DpadUp",r[r.DpadDown=13]="DpadDown",r[r.DpadLeft=14]="DpadLeft",r[r.DpadRight=15]="DpadRight",r[r.CenterButton=16]="CenterButton",r[r.MiscButton1=17]="MiscButton1",r))(qn||{}),Ko=(r=>(r[r.LeftStickX=0]="LeftStickX",r[r.LeftStickY=1]="LeftStickY",r[r.RightStickX=2]="RightStickX",r[r.RightStickY=3]="RightStickY",r))(Ko||{});class ta{constructor(t){this.inputs=t,this._handlers=new Map}execute(){for(const[t,e]of this._handlers.entries()){const i=t(this.inputs);i&&e(i)}}on(t,e){this._handlers.set(t,e)}}function ea(){try{const r=()=>{};window.top.addEventListener("blur",r),window.top.removeEventListener("blur",r)}catch(r){return!0}return!1}function ia(){return window!==window.top}function sa(){let r;return ea()?(r=window,R.getInstance().warnOnce("Excalibur might be in a cross-origin iframe, in order to receive keyboard events it must be in focus")):ia()?(r=window,R.getInstance().warnOnce("Excalibur might be in a iframe, in order to receive keyboard events it must be in focus")):r=window.top,r}var na=(r=>(r.Backquote="Backquote",r.Backslash="Backslash",r.BracketLeft="BracketLeft",r.BracketRight="BracketRight",r.Comma="Comma",r.Key0="Digit0",r.Key1="Digit1",r.Key2="Digit2",r.Key3="Digit3",r.Key4="Digit4",r.Key5="Digit5",r.Key6="Digit6",r.Key7="Digit7",r.Key8="Digit8",r.Key9="Digit9",r.Digit0="Digit0",r.Digit1="Digit1",r.Digit2="Digit2",r.Digit3="Digit3",r.Digit4="Digit4",r.Digit5="Digit5",r.Digit6="Digit6",r.Digit7="Digit7",r.Digit8="Digit8",r.Digit9="Digit9",r.Equal="Equal",r.IntlBackslash="IntlBackslash",r.IntlRo="IntlRo",r.IntlYen="IntlYen",r.A="KeyA",r.B="KeyB",r.C="KeyC",r.D="KeyD",r.E="KeyE",r.F="KeyF",r.G="KeyG",r.H="KeyH",r.I="KeyI",r.J="KeyJ",r.K="KeyK",r.L="KeyL",r.M="KeyM",r.N="KeyN",r.O="KeyO",r.P="KeyP",r.Q="KeyQ",r.R="KeyR",r.S="KeyS",r.T="KeyT",r.U="KeyU",r.V="KeyV",r.W="KeyW",r.X="KeyX",r.Y="KeyY",r.Z="KeyZ",r.KeyA="KeyA",r.KeyB="KeyB",r.KeyC="KeyC",r.KeyD="KeyD",r.KeyE="KeyE",r.KeyF="KeyF",r.KeyG="KeyG",r.KeyH="KeyH",r.KeyI="KeyI",r.KeyJ="KeyJ",r.KeyK="KeyK",r.KeyL="KeyL",r.KeyM="KeyM",r.KeyN="KeyN",r.KeyO="KeyO",r.KeyP="KeyP",r.KeyQ="KeyQ",r.KeyR="KeyR",r.KeyS="KeyS",r.KeyT="KeyT",r.KeyU="KeyU",r.KeyV="KeyV",r.KeyW="KeyW",r.KeyX="KeyX",r.KeyY="KeyY",r.KeyZ="KeyZ",r.Minus="Minus",r.Period="Period",r.Quote="Quote",r.Semicolon="Semicolon",r.Slash="Slash",r.AltLeft="AltLeft",r.AltRight="AltRight",r.Alt="Alt",r.AltGraph="AltGraph",r.Backspace="Backspace",r.CapsLock="CapsLock",r.ContextMenu="ContextMenu",r.ControlLeft="ControlLeft",r.ControlRight="ControlRight",r.Enter="Enter",r.MetaLeft="MetaLeft",r.MetaRight="MetaRight",r.ShiftLeft="ShiftLeft",r.ShiftRight="ShiftRight",r.Space="Space",r.Tab="Tab",r.Convert="Convert",r.KanaMode="KanaMode",r.NonConvert="NonConvert",r.Delete="Delete",r.End="End",r.Help="Help",r.Home="Home",r.Insert="Insert",r.PageDown="PageDown",r.PageUp="PageUp",r.Up="ArrowUp",r.Down="ArrowDown",r.Left="ArrowLeft",r.Right="ArrowRight",r.ArrowUp="ArrowUp",r.ArrowDown="ArrowDown",r.ArrowLeft="ArrowLeft",r.ArrowRight="ArrowRight",r.NumLock="NumLock",r.Numpad0="Numpad0",r.Numpad1="Numpad1",r.Numpad2="Numpad2",r.Numpad3="Numpad3",r.Numpad4="Numpad4",r.Numpad5="Numpad5",r.Numpad6="Numpad6",r.Numpad7="Numpad7",r.Numpad8="Numpad8",r.Numpad9="Numpad9",r.Num0="Numpad0",r.Num1="Numpad1",r.Num2="Numpad2",r.Num3="Numpad3",r.Num4="Numpad4",r.Num5="Numpad5",r.Num6="Numpad6",r.Num7="Numpad7",r.Num8="Numpad8",r.Num9="Numpad9",r.NumAdd="NumpadAdd",r.NumpadAdd="NumpadAdd",r.NumDecimal="NumpadDecimal",r.NumpadDecimal="NumpadDecimal",r.NumDivide="NumpadDivide",r.NumpadDivide="NumpadDivide",r.NumEnter="NumpadEnter",r.NumpadEnter="NumpadEnter",r.NumMultiply="NumpadMultiply",r.NumpadMultiply="NumpadMultiply",r.NumSubtract="NumpadSubtract",r.NumpadSubtract="NumpadSubtract",r.Esc="Escape",r.Escape="Escape",r.F1="F1",r.F2="F2",r.F3="F3",r.F4="F4",r.F5="F5",r.F6="F6",r.F7="F7",r.F8="F8",r.F9="F9",r.F10="F10",r.F11="F11",r.F12="F12",r.F13="F13",r.F14="F14",r.F15="F15",r.F16="F16",r.F17="F17",r.F18="F18",r.F19="F19",r.F20="F20",r.PrintScreen="PrintScreen",r.ScrollLock="ScrollLock",r.Pause="Pause",r.Unidentified="Unidentified",r))(na||{});class wi extends k{constructor(t,e,i){super(),this.key=t,this.value=e,this.originalEvent=i}}class ra{constructor(){this.events=new X,this._enabled=!0,this._keys=[],this._keysUp=[],this._keysDown=[],this._releaseAllKeys=t=>{for(const e of this._keys){const i=new wi(e,t.key,t);this.events.emit("up",i),this.events.emit("release",i)}this._keysUp=Array.from(new Set(this._keys.concat(this._keysUp))),this._keys.length=0},this._handleKeyDown=t=>{if(!this._enabled)return;!t.metaKey&&(this._keys.includes("MetaLeft")||this._keys.includes("MetaRight"))&&this._releaseAllKeys(t);const e=t.code;if(this._keys.indexOf(e)===-1){this._keys.push(e),this._keysDown.push(e);const i=new wi(e,t.key,t);this.events.emit("down",i),this.events.emit("press",i)}},this._handleKeyUp=t=>{if(!this._enabled)return;const e=t.code,i=this._keys.indexOf(e);this._keys.splice(i,1),this._keysUp.push(e);const s=new wi(e,t.key,t);this.events.emit("up",s),this.events.emit("release",s),t.key==="Meta"&&this._releaseAllKeys(t)}}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}init(t){let{global:e}=t;const{grabWindowFocus:i}=t;e?typeof e=="function"&&(e=e()):e=sa(),i&&e.focus(),e.addEventListener("blur",()=>{this._keys.length=0}),e.addEventListener("keyup",this._handleKeyUp),e.addEventListener("keydown",this._handleKeyDown)}toggleEnabled(t){this._enabled=t}clear(){this._keysDown.length=0,this._keysUp.length=0,this._keys.length=0}update(){this._keysDown.length=0,this._keysUp.length=0;for(let t=0;t<this._keys.length;t++)this.events.emit("hold",new wi(this._keys[t]))}getKeys(){return this._keys}wasPressed(t){return this._enabled?this._keysDown.indexOf(t)>-1:!1}isHeld(t){return this._enabled?this._keys.indexOf(t)>-1:!1}wasReleased(t){return this._enabled?this._keysUp.indexOf(t)>-1:!1}triggerEvent(t,e,i){t==="down"&&this._handleKeyDown(new KeyboardEvent("keydown",{code:e,key:i!=null?i:null})),t==="up"&&this._handleKeyUp(new KeyboardEvent("keyup",{code:e,key:i!=null?i:null}))}}class xi{constructor(t,e,i,s,n,o){this.type=t,this.pointerId=e,this.button=i,this.pointerType=s,this.coordinates=n,this.nativeEvent=o,this.active=!0}cancel(){this.active=!1}get pagePos(){return this.coordinates.pagePos}get screenPos(){return this.coordinates.screenPos}get worldPos(){return this.coordinates.worldPos}}class oa{constructor(t,e,i,s,n,o,a,h,l,c,u,_){this.x=t,this.y=e,this.pageX=i,this.pageY=s,this.screenX=n,this.screenY=o,this.index=a,this.deltaX=h,this.deltaY=l,this.deltaZ=c,this.deltaMode=u,this.ev=_,this.active=!0}cancel(){this.active=!1}}class Xn{constructor(){this.events=new X,this.lastPagePos=v.Zero,this.lastScreenPos=v.Zero,this.lastWorldPos=v.Zero,this._onPointerMove=t=>{this.lastPagePos=new v(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new v(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new v(t.worldPos.x,t.worldPos.y)},this._onPointerDown=t=>{this.lastPagePos=new v(t.pagePos.x,t.pagePos.y),this.lastScreenPos=new v(t.screenPos.x,t.screenPos.y),this.lastWorldPos=new v(t.worldPos.x,t.worldPos.y)},this.on("move",this._onPointerMove),this.on("down",this._onPointerDown)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}_updateWorldPosition(t){const e=Be.fromPagePosition(this.lastPagePos,t);this.lastScreenPos=e.screenPos,this.lastWorldPos=e.worldPos}}var bi=(r=>(r.Pixel="Pixel",r.Line="Line",r.Page="Page",r))(bi||{}),Pe=(r=>(r[r.NoButton=-1]="NoButton",r[r.Left=0]="Left",r[r.Middle=1]="Middle",r[r.Right=2]="Right",r[r.Unknown=3]="Unknown",r))(Pe||{}),le=(r=>(r.Left="Left",r.Middle="Middle",r.Right="Right",r.Unknown="Unknown",r.NoButton="NoButton",r))(le||{}),ce=(r=>(r.Touch="Touch",r.Mouse="Mouse",r.Pen="Pen",r.Unknown="Unknown",r))(ce||{});function Fl(r){return globalThis.TouchEvent&&r instanceof globalThis.TouchEvent}function Bl(r){return globalThis.PointerEvent&&r instanceof globalThis.PointerEvent}class ss{constructor(t,e){this.target=t,this.engine=e,this.events=new X,this.primary=new Xn,this._activeNativePointerIdsToNormalized=new Map,this.lastFramePointerCoords=new Map,this.currentFramePointerCoords=new Map,this.currentFramePointerDown=new Map,this.lastFramePointerDown=new Map,this.currentFrameDown=[],this.currentFrameUp=[],this.currentFrameMove=[],this.currentFrameCancel=[],this.currentFrameWheel=[],this._enabled=!0,this._pointers=[this.primary],this._boundHandle=this._handle.bind(this),this._boundWheel=this._handleWheel.bind(this)}toggleEnabled(t){this._enabled=t}recreate(t,e){const i=new ss(t,e);return i.primary=this.primary,i._pointers=this._pointers,i}at(t){if(t>=this._pointers.length)for(let e=this._pointers.length-1,i=t;e<i;e++)this._pointers.push(new Xn);return this._pointers[t]}count(){return this._pointers.length}isDown(t){var e;return this._enabled&&(e=this.currentFramePointerDown.get(t))!=null?e:!1}wasDown(t){var e;return this._enabled&&(e=this.lastFramePointerDown.get(t))!=null?e:!1}isDragging(t){return this._enabled?this.isDown(t):!1}isDragStart(t){return this._enabled?this.isDown(t)&&!this.wasDown(t):!1}isDragEnd(t){return this._enabled?!this.isDown(t)&&this.wasDown(t):!1}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}update(){this.lastFramePointerDown=new Map(this.currentFramePointerDown),this.lastFramePointerCoords=new Map(this.currentFramePointerCoords);for(const t of this.currentFrameDown){if(!t.active)continue;this.emit("down",t),this.at(t.pointerId).emit("down",t),this.primary.emit("pointerdown",t)}for(const t of this.currentFrameUp){if(!t.active)continue;this.emit("up",t),this.at(t.pointerId).emit("up",t)}for(const t of this.currentFrameMove){if(!t.active)continue;this.emit("move",t),this.at(t.pointerId).emit("move",t)}for(const t of this.currentFrameCancel){if(!t.active)continue;this.emit("cancel",t),this.at(t.pointerId).emit("cancel",t)}for(const t of this.currentFrameWheel)t.active&&(this.emit("pointerwheel",t),this.emit("wheel",t),this.primary.emit("pointerwheel",t),this.primary.emit("wheel",t));if(this.engine.currentScene.camera.hasChanged())for(const t of this._pointers)t._updateWorldPosition(this.engine)}clear(){for(const t of this.currentFrameUp){this.currentFramePointerCoords.delete(t.pointerId);const e=this._activeNativePointerIdsToNormalized.entries();for(const[i,s]of e)s===t.pointerId&&this._activeNativePointerIdsToNormalized.delete(i)}this.currentFrameDown.length=0,this.currentFrameUp.length=0,this.currentFrameMove.length=0,this.currentFrameCancel.length=0,this.currentFrameWheel.length=0}init(t){var e;if(this.engine.isDisposed())return;this.target===this.engine.canvas?this.engine.canvas.style.touchAction="none":document.body.style.touchAction="none",window.PointerEvent?(this.target.addEventListener("pointerdown",this._boundHandle),this.target.addEventListener("pointerup",this._boundHandle),this.target.addEventListener("pointermove",this._boundHandle),this.target.addEventListener("pointercancel",this._boundHandle)):(this.target.addEventListener("touchstart",this._boundHandle),this.target.addEventListener("touchend",this._boundHandle),this.target.addEventListener("touchmove",this._boundHandle),this.target.addEventListener("touchcancel",this._boundHandle),this.target.addEventListener("mousedown",this._boundHandle),this.target.addEventListener("mouseup",this._boundHandle),this.target.addEventListener("mousemove",this._boundHandle));const i={passive:!(this.engine.pageScrollPreventionMode===Qe.All||this.engine.pageScrollPreventionMode===Qe.Canvas)};if("onwheel"in document.createElement("div")?this.target.addEventListener("wheel",this._boundWheel,i):document.onmousewheel!==void 0?this.target.addEventListener("mousewheel",this._boundWheel,i):this.target.addEventListener("MozMousePixelScroll",this._boundWheel,i),((e=t==null?void 0:t.grabWindowFocus)!=null?e:!0)&&(ea()||ia())){const n=()=>{window.focus()};window.PointerEvent?this.target.addEventListener("pointerdown",n):(this.target.addEventListener("touchstart",n),this.target.addEventListener("mousedown",n))}}detach(){window.PointerEvent?(this.target.removeEventListener("pointerdown",this._boundHandle),this.target.removeEventListener("pointerup",this._boundHandle),this.target.removeEventListener("pointermove",this._boundHandle),this.target.removeEventListener("pointercancel",this._boundHandle)):(this.target.removeEventListener("touchstart",this._boundHandle),this.target.removeEventListener("touchend",this._boundHandle),this.target.removeEventListener("touchmove",this._boundHandle),this.target.removeEventListener("touchcancel",this._boundHandle),this.target.removeEventListener("mousedown",this._boundHandle),this.target.removeEventListener("mouseup",this._boundHandle),this.target.removeEventListener("mousemove",this._boundHandle)),"onwheel"in document.createElement("div")?this.target.removeEventListener("wheel",this._boundWheel):document.onmousewheel!==void 0?this.target.addEventListener("mousewheel",this._boundWheel):this.target.addEventListener("MozMousePixelScroll",this._boundWheel)}_normalizePointerId(t){this._activeNativePointerIdsToNormalized.set(t,-1);const i=Array.from(this._activeNativePointerIdsToNormalized.keys()).sort((s,n)=>s-n).findIndex(s=>s===t);return this._activeNativePointerIdsToNormalized.set(t,i),i}_handle(t){if(!this._enabled)return;t.preventDefault();const e=new Map;let i,s;if(Fl(t)){i=le.Unknown,s=ce.Touch;for(let n=0;n<t.changedTouches.length;n++){const o=t.changedTouches[n],a=Be.fromPagePosition(o.pageX,o.pageY,this.engine),h=n+1,l=this._normalizePointerId(h);this.currentFramePointerCoords.set(l,a),e.set(l,a)}}else{i=this._nativeButtonToPointerButton(t.button),s=ce.Mouse;const n=Be.fromPagePosition(t.pageX,t.pageY,this.engine);let o=1;Bl(t)&&(o=t.pointerId,s=this._stringToPointerType(t.pointerType));const a=this._normalizePointerId(o);this.currentFramePointerCoords.set(a,n),e.set(a,n)}for(const[n,o]of e.entries())switch(t.type){case"mousedown":case"pointerdown":case"touchstart":this.currentFrameDown.push(new xi("down",n,i,s,o,t)),this.currentFramePointerDown.set(n,!0);break;case"mouseup":case"pointerup":case"touchend":this.currentFrameUp.push(new xi("up",n,i,s,o,t)),this.currentFramePointerDown.set(n,!1);break;case"mousemove":case"pointermove":case"touchmove":this.currentFrameMove.push(new xi("move",n,i,s,o,t));break;case"touchcancel":case"pointercancel":this.currentFrameCancel.push(new xi("cancel",n,i,s,o,t));break}}_handleWheel(t){if(!this._enabled)return;(this.engine.pageScrollPreventionMode===Qe.All||this.engine.pageScrollPreventionMode===Qe.Canvas&&t.target===this.engine.canvas)&&t.preventDefault();const e=this.engine.screen.pageToScreenCoordinates(b(t.pageX,t.pageY)),i=this.engine.screen.screenToWorldCoordinates(e),s=-1/40,n=t.deltaX||t.wheelDeltaX*s||0,o=t.deltaY||t.wheelDeltaY*s||t.wheelDelta*s||t.detail||0,a=t.deltaZ||0;let h=bi.Pixel;t.deltaMode&&(t.deltaMode===1?h=bi.Line:t.deltaMode===2&&(h=bi.Page));const l=new oa(i.x,i.y,t.pageX,t.pageY,e.x,e.y,0,n,o,a,h,t);this.currentFrameWheel.push(l)}triggerEvent(t,e){const i=this.engine.screen.worldToPageCoordinates(e);window.PointerEvent?this._handle(new window.PointerEvent("pointer"+t,{pointerId:0,clientX:i.x,clientY:i.y})):this._handle(new window.MouseEvent("mouse"+t,{clientX:i.x,clientY:i.y}));const s=this.engine.currentScene.world.get(ts);s.preupdate(this.engine.currentScene,1),s.update(1)}_nativeButtonToPointerButton(t){switch(t){case Pe.NoButton:return le.NoButton;case Pe.Left:return le.Left;case Pe.Middle:return le.Middle;case Pe.Right:return le.Right;case Pe.Unknown:return le.Unknown;default:return xr(t)}}_stringToPointerType(t){switch(t){case"touch":return ce.Touch;case"mouse":return ce.Mouse;case"pen":return ce.Pen;default:return ce.Unknown}}}class Yn{constructor(t){this._enabled=!0;const{pointerTarget:e,grabWindowFocus:i,engine:s,global:n}=t;this.keyboard=new ra,this.pointers=new ss(e,s),this.gamepads=new es,this.keyboard.init({global:n,grabWindowFocus:i}),this.pointers.init({grabWindowFocus:i}),this.gamepads.init(),this.inputMapper=new ta({keyboard:this.keyboard,pointers:this.pointers,gamepads:this.gamepads})}get enabled(){return this._enabled}toggleEnabled(t){this._enabled=t,this.keyboard.toggleEnabled(this._enabled),this.pointers.toggleEnabled(this._enabled),this.gamepads.toggleEnabled(this._enabled)}update(){this._enabled&&(this.inputMapper.execute(),this.keyboard.update(),this.gamepads.update())}clear(){this.keyboard.clear(),this.pointers.clear()}}class Ll{}const kl={Initialize:"initialize",Activate:"activate",Deactivate:"deactivate",PreUpdate:"preupdate",PostUpdate:"postupdate",PreDraw:"predraw",PostDraw:"postdraw",PreDebugDraw:"predebugdraw",PostDebugDraw:"postdebugdraw",PreLoad:"preload",TransitionStart:"transitionstart",TransitionEnd:"transitionend"};function $t(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class Rt{constructor(){this._logger=R.getInstance(),this.events=new X,this.camera=new Qo,this.world=new Ar(this),this.physics=new Ro(Jt()),this._isInitialized=!1,this._timers=[],this._cancelQueue=[],this.world.add(Vn),this.world.add(new ji(this.world,this.physics)),this.world.add(new Zi(this.world,this.physics)),this.world.add(ts),this.world.add(Wn),this.world.add(gn),this.world.add(fn),this.world.add(Gn)}get actors(){return this.world.entityManager.entities.filter(t=>t instanceof Ft)}get entities(){return this.world.entityManager.entities}get triggers(){return this.world.entityManager.entities.filter(t=>t instanceof Jo)}get tileMaps(){return this.world.entityManager.entities.filter(t=>t instanceof No)}get timers(){return this._timers}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){this.events.off(t,e)}onPreLoad(t){}onTransition(t){}onInitialize(t){}onActivate(t){}onDeactivate(t){}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}async _initialize(t){var e;if(!this.isInitialized){try{this.engine=t,this.physics.config=this.engine.physics,this.input=new Yn({global:t.global,pointerTarget:t.pointerScope===Fe.Canvas?t.canvas:document,grabWindowFocus:t.grabWindowFocus,engine:t}),this.camera._initialize(t),this.world.systemManager.initialize(),await this.onInitialize(t),this._initializeChildren(),this._logger.debug("Scene.onInitialize",this,t),this.events.emit("initialize",new Ue(t,this))}catch(i){throw this._logger.error(`Error during scene initialization for scene ${(e=t.director)==null?void 0:e.getSceneName(this)}!`),i}this._isInitialized=!0}}async _activate(t){var e,i;try{this._logger.debug("Scene.onActivate",this),this.input.toggleEnabled(!0),await this.onActivate(t)}catch(s){throw this._logger.error(`Error during scene activation for scene ${(i=(e=this.engine)==null?void 0:e.director)==null?void 0:i.getSceneName(this)}!`),s}}async _deactivate(t){return this._logger.debug("Scene.onDeactivate",this),this.input.toggleEnabled(!1),await this.onDeactivate(t)}_preupdate(t,e){this.emit("preupdate",new ne(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.emit("postupdate",new re(t,e,this)),this.onPostUpdate(t,e)}_predraw(t,e){this.emit("predraw",new ke(t,e,this)),this.onPreDraw(t,e)}_postdraw(t,e){this.emit("postdraw",new ze(t,e,this)),this.onPostDraw(t,e)}update(t,e){var i;if(!this.isInitialized){this._logger.warnOnce(`Scene update called before initialize for scene ${(i=t.director)==null?void 0:i.getSceneName(this)}!`);return}this._preupdate(t,e);let s,n;for(s=0,n=this._cancelQueue.length;s<n;s++)this.removeTimer(this._cancelQueue[s]);this._cancelQueue.length=0;for(const o of this._timers)o.update(e);this.world.update(Pt.Update,e),this.camera&&this.camera.update(t,e),this._collectActorStats(t),this._postupdate(t,e),this.input.update()}draw(t,e){var i;if(!this.isInitialized){this._logger.warnOnce("Scene draw called before initialize!");return}this._predraw(t,e),this.world.update(Pt.Draw,e),(i=this.engine)!=null&&i.isDebug&&this.debugDraw(t),this._postdraw(t,e)}debugDraw(t){this.emit("predebugdraw",new Ms(t,this)),this.emit("postdebugdraw",new Ds(t,this))}contains(t){return this.actors.indexOf(t)>-1}add(t){if(this.emit("entityadded",{target:t}),t instanceof Ki){wr(this._timers,t)||this.addTimer(t);return}this.world.add(t),t.scene=this}transfer(t){let e;t instanceof Tt&&t.scene&&t.scene!==this&&(e=t.scene,t.scene.world.remove(t,!1)),t instanceof Ki&&t.scene&&(e=t.scene,t.scene.removeTimer(t)),e==null||e.emit("entityremoved",{target:t}),this.add(t)}remove(t){this.emit("entityremoved",{target:t}),t instanceof Tt&&(t.isActive&&t.kill(),this.world.remove(t)),t instanceof Ki&&this.removeTimer(t)}clear(t=!0){for(let e=this.entities.length-1;e>=0;e--)this.world.remove(this.entities[e],t);for(let e=this.timers.length-1;e>=0;e--)this.removeTimer(this.timers[e])}addTimer(t){return this._timers.push(t),t.scene=this,t}removeTimer(t){const e=this._timers.indexOf(t);return e!==-1&&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:!1}_collectActorStats(t){const e=this.actors;for(let i=0;i<e.length;i++){const s=e[i];s instanceof Hn&&t.stats.currFrame.actors.ui++,t.stats.currFrame.actors.alive++;for(let n=0;n<s.children.length;n++){const o=s.children[n];Uo(o)?t.stats.currFrame.actors.ui++:t.stats.currFrame.actors.alive++}}}}class aa{constructor(t){this._engine=t,this._colorBlindPostProcessor=new Zr(Ye.Protanope)}correct(t){this._engine.graphicsContext instanceof Xt&&(this.clear(),this._colorBlindPostProcessor.colorBlindnessMode=t,this._colorBlindPostProcessor.simulate=!1,this._engine.graphicsContext.addPostProcessor(this._colorBlindPostProcessor))}simulate(t){this._engine.graphicsContext instanceof Xt&&(this.clear(),this._colorBlindPostProcessor.colorBlindnessMode=t,this._colorBlindPostProcessor.simulate=!0,this._engine.graphicsContext.addPostProcessor(this._colorBlindPostProcessor))}clear(){this._engine.graphicsContext.removePostProcessor(this._colorBlindPostProcessor)}}class ha{constructor(t){this.stats={currFrame:new yi,prevFrame:new yi},this.filter={useFilter:!1,nameQuery:"",ids:[]},this.entity={showAll:!1,showId:!1,showName:!1},this.transform={showAll:!1,debugZIndex:1e7,showPosition:!1,showPositionLabel:!1,positionColor:P.Yellow,showZIndex:!1,showScale:!1,scaleColor:P.Green,showRotation:!1,rotationColor:P.Blue},this.graphics={showAll:!1,showBounds:!1,boundsColor:P.Yellow},this.collider={showAll:!1,showBounds:!1,boundsColor:P.Blue,showOwner:!1,showGeometry:!0,geometryColor:P.Green,geometryLineWidth:1,geometryPointSize:.5},this.physics={showAll:!1,showBroadphaseSpacePartitionDebug:!1,showCollisionNormals:!1,collisionNormalColor:P.Cyan,showCollisionContacts:!0,contactSize:2,collisionContactColor:P.Red},this.motion={showAll:!1,showVelocity:!1,velocityColor:P.Yellow,showAcceleration:!1,accelerationColor:P.Red},this.body={showAll:!1,showCollisionGroup:!1,showCollisionType:!1,showSleeping:!1,showMotion:!1,showMass:!1},this.camera={showAll:!1,showFocus:!1,focusColor:P.Red,showZoom:!1},this.tilemap={showAll:!1,showGrid:!1,gridColor:P.Red,gridWidth:.5,showSolidBounds:!1,solidBoundsColor:P.fromHex("#8080807F"),showColliderGeometry:!0},this.isometric={showAll:!1,showPosition:!1,positionColor:P.Yellow,positionSize:1,showGrid:!1,gridColor:P.Red,gridWidth:1,showColliderGeometry:!0},this._engine=t,this.colorBlindMode=new aa(this._engine)}useTestClock(){const t=this._engine.clock,e=t.isRunning();t.stop();const i=t.toTestClock();return e&&i.start(),this._engine.clock=i,i}useStandardClock(){const t=this._engine.clock,e=t.isRunning();t.stop();const i=t.toStandardClock();return e&&i.start(),this._engine.clock=i,i}}class yi{constructor(){this._id=0,this._elapsedMs=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 ns,this._graphicsStats={drawCalls:0,drawnImages:0}}reset(t){t?(this.id=t.id,this.elapsedMs=t.elapsedMs,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.elapsedMs=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 yi;return t.reset(this),t}get id(){return this._id}set id(t){this._id=t}get elapsedMs(){return this._elapsedMs}set elapsedMs(t){this._elapsedMs=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 ns{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 ns;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}}class $n{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 la{constructor(t,e){this._windowGlobal=t,this._documentGlobal=e,this._windowComponent=new $n(this._windowGlobal),this._documentComponent=new $n(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 ca{constructor(t){this._samplePeriod=100,this._currentFrameTime=0,this._frames=0,this._previousSampleTime=0,this._beginFrameTime=0;var e;this._fps=t.initialFps,this._samplePeriod=(e=t.samplePeriod)!=null?e:this._samplePeriod,this._currentFrameTime=1e3/t.initialFps,this._nowFn=t.nowFn,this._previousSampleTime=this._nowFn()}start(){this._beginFrameTime=this._nowFn()}end(){this._frames++;const t=this._nowFn();this._currentFrameTime=t-this._beginFrameTime,t>=this._previousSampleTime+this._samplePeriod&&(this._fps=this._frames*1e3/(t-this._previousSampleTime),this._previousSampleTime=t,this._frames=0)}get fps(){return this._fps}get instant(){return 1e3/this._currentFrameTime}}class jn{constructor(t){this._onFatalException=()=>{},this._maxFps=1/0,this._lastTime=0,this._elapsed=1,this._scheduledCbs=[],this._totalElapsed=0,this._nextScheduleId=0,this._idsToRemove=[];var e,i,s;this._options=t,this.tick=t.tick,this._lastTime=(e=this.now())!=null?e:0,this._maxFps=(i=t.maxFps)!=null?i:this._maxFps,this._onFatalException=(s=t.onFatalException)!=null?s:this._onFatalException,this.fpsSampler=new ca({initialFps:60,nowFn:()=>this.now()})}elapsed(){return this._elapsed}now(){return performance.now()}toTestClock(){return new da({...this._options,defaultUpdateMs:16.6})}toStandardClock(){return new Zn({...this._options})}setFatalExceptionHandler(t){this._onFatalException=t}schedule(t,e=0,i="preframe"){const s=this._totalElapsed+e,n=this._nextScheduleId++;return this._scheduledCbs.push([n,t,s,i]),n}clearSchedule(t){this._idsToRemove.push(t)}__runScheduledCbs(t="preframe"){for(let e=this._scheduledCbs.length-1;e>-1;e--){const[i,s,n,o]=this._scheduledCbs[e];this._idsToRemove.includes(i)||t===o&&n<=this._totalElapsed&&(s(this._elapsed),this._scheduledCbs.splice(e,1))}for(const e of this._idsToRemove){const i=this._scheduledCbs.findIndex(([s])=>s===e);i!==-1&&this._scheduledCbs.splice(i,1)}}update(t){try{this.fpsSampler.start();const e=this.now();let i=e-this._lastTime||1;const s=1e3/this._maxFps;if(i>=s){let n=0;s!==0&&(n=i%s,i=i-n),i>200&&(i=1),this._elapsed=t||i,this._totalElapsed+=this._elapsed,this.__runScheduledCbs("preframe"),this.tick(t||i),this.__runScheduledCbs("postframe"),s!==0?this._lastTime=e-n:this._lastTime=e,this.fpsSampler.end()}}catch(e){this._onFatalException(e),this.stop()}}}class Zn extends jn{constructor(t){super(t),this._running=!1}isRunning(){return this._running}start(){if(this._running)return;this._running=!0;const t=()=>{if(this._running)try{this._requestId=window.requestAnimationFrame(t),this.update()}catch(e){throw window.cancelAnimationFrame(this._requestId),e}};t()}stop(){window.cancelAnimationFrame(this._requestId),this._running=!1}}class da extends jn{constructor(t){super({...t}),this._logger=R.getInstance(),this._running=!1,this._currentTime=0,this._updateMs=t.defaultUpdateMs}now(){var t;return(t=this._currentTime)!=null?t:0}isRunning(){return this._running}start(){this._running=!0}stop(){this._running=!1}step(t){const e=t!=null?t:this._updateMs;this._running?(this.update(e),this._currentTime+=e):this._logger.warn("The clock is not running, no step will be performed")}run(t,e){for(let i=0;i<t;i++)this.step(e!=null?e:this._updateMs)}}const zl="#ex-toast-container{position:absolute;height:0;min-width:50%;left:50%;top:0}.ex-toast-message{left:-50%;position:relative;display:flex;justify-content:space-between;padding:10px;margin-top:5px;font-size:18px;font-family:sans-serif;border-radius:6px;border:3px solid #b7b779;background-color:#fdfdc0}.ex-toast-message button{align-self:flex-start}";class ua{constructor(){this._toasterCss=zl,this._isInitialized=!1}_initialize(){this._isInitialized||(this._container=document.createElement("div"),this._container.id="ex-toast-container",document.body.appendChild(this._container),this._isInitialized=!0,this._styleBlock=document.createElement("style"),this._styleBlock.textContent=this._toasterCss,document.head.appendChild(this._styleBlock))}dispose(){this._container.parentElement.removeChild(this._container),this._styleBlock.parentElement.removeChild(this._styleBlock),this._isInitialized=!1}_createFragment(t){const e=document.createElement("span");return e.innerText=t,e}toast(t,e,i){this._initialize();const s=document.createElement("div");s.className="ex-toast-message";const n=t.split("[LINK]").map(c=>this._createFragment(c));if(e){const c=document.createElement("a");c.href=e,i?c.innerText=i:c.innerText=e,n.splice(1,0,c)}const o=document.createElement("div");n.forEach(c=>{o.appendChild(c)}),s.appendChild(o);const a=document.createElement("button");a.innerText="x",a.addEventListener("click",()=>{this._container.removeChild(s)}),s.appendChild(a);const h=c=>{if(c.key==="Escape")try{this._container.removeChild(s)}catch(u){}document.removeEventListener("keydown",h)};document.addEventListener("keydown",h);const l=this._container.firstChild;this._container.insertBefore(s,l)}}const _a={NavigationStart:"navigationstart",Navigation:"navigation",NavigationEnd:"navigationend"};class fa{constructor(t,e){this._engine=t,this.events=new X,this._logger=R.getInstance(),this._initialized=!1,this.scenes={},this._sceneToInstance=new Map,this._sceneToLoader=new Map,this._sceneToTransition=new Map,this._loadedScenes=new Set,this._isTransitioning=!1,this.rootScene=this.currentScene=new Rt,this.add("root",this.rootScene),this.currentScene=this.rootScene,this.currentSceneName="root";for(const i in e){const s=e[i];this.add(i,s),i==="root"&&(this.rootScene=this.getSceneInstance("root"),this.currentScene=this.rootScene)}}get isTransitioning(){return this._isTransitioning}async onInitialize(){if(!this._initialized)if(this._initialized=!0,this._deferredGoto){const t=this._deferredGoto;this._deferredGoto=void 0;const e=this._deferredTransition;this._deferredTransition=void 0;const i=this.getSceneInstance(t);i&&e&&e._addToTargetScene(this._engine,i);const s=this._getInTransition(t),n=s==null?void 0:s.hideLoader;this.maybeLoadScene(t,n),await this.swapScene(t),i&&e&&await this.playTransition(e,i)}else await this.swapScene("root")}get isInitialized(){return this._initialized}configureStart(t,e){var i,s;const n=e==null?void 0:e.loader;n instanceof mi?this.mainLoader=n:On(n)?this.mainLoader=new n:this.mainLoader=new Ji;let o;if(e!=null&&e.inTransition){const{inTransition:h}=e;o=h}this.startScene=t;const a=(s=(i=e==null?void 0:e.inTransition)==null?void 0:i.hideLoader)!=null?s:!1;if(this.maybeLoadScene(t,a),o){const h=this.getSceneInstance(t);h&&(o._addToTargetScene(this._engine,h),this.swapScene(t).then(()=>(h.onTransition("in"),this.playTransition(o,h))))}else this.swapScene(t);this.currentSceneName=this.startScene}_getLoader(t){return this._sceneToLoader.get(t)}_getInTransition(t){var e;const i=this.scenes[t];if(!(i instanceof Rt||$t(i)))return(e=i==null?void 0:i.transitions)==null?void 0:e.in}_getOutTransition(t){var e;const i=this.scenes[t];if(!(i instanceof Rt||$t(i)))return(e=i==null?void 0:i.transitions)==null?void 0:e.out}getDeferredScene(){const t=this.getSceneDefinition(this._deferredGoto);return this._deferredGoto&&t?t:null}getSceneDefinition(t){const e=this.scenes[t];if(e instanceof Rt||$t(e))return e;if(e)return e.scene}getSceneName(t){for(const[e,i]of Object.entries(this.scenes))if(i instanceof Rt){if(t===i)return e}else if(!$t(i)&&t===i.scene)return e;for(const[e,i]of Object.entries(this.scenes))if($t(i)){if(t.constructor===i)return e}else if(!(i instanceof Rt)&&t.constructor===i.scene)return e;return null}assertAdded(t){return this}assertRemoved(t){return this}add(t,e){if(!(e instanceof Rt)&&!$t(e)){const{loader:i,transitions:s}=e,{in:n,out:o}=s!=null?s:{};this._sceneToTransition.set(t,{in:n,out:o}),On(i)?this._sceneToLoader.set(t,new i):i&&this._sceneToLoader.set(t,i)}return this.scenes[t]&&this._logger.warn("Scene",t,"already exists overwriting"),this.scenes[t]=e,this.assertAdded(t)}remove(t){if(t instanceof Rt||$t(t)){const e=t;for(const i in this.scenes)if(this.scenes.hasOwnProperty(i)){const s=this.scenes[i];let n;if(s instanceof Rt||$t(s)?n=s:n=s.scene,n===e){if(i===this.currentSceneName)throw new Error(`Cannot remove a currently active scene: ${i}`);this._sceneToInstance.delete(i),this._sceneToTransition.delete(i),this._sceneToLoader.delete(i),delete this.scenes[i]}}}if(typeof t=="string"){if(t===this.currentSceneName)throw new Error(`Cannot remove a currently active scene: ${t}`);this._sceneToInstance.delete(t),this._sceneToTransition.delete(t),this._sceneToLoader.delete(t),delete this.scenes[t]}}async goToScene(t,e){var i,s,n,o,a,h;const l=this.getSceneInstance(t);if(!l){this._logger.warn(`Scene ${t} does not exist! Check the name, are you sure you added it?`);return}const c=this.currentScene,u=this.currentSceneName,_=(s=(i=this._engine.input)==null?void 0:i.enabled)!=null?s:!0;this._isTransitioning=!0;const f=(n=this.getSceneInstance(u))==null?void 0:n.onTransition("out"),g=l==null?void 0:l.onTransition("in");e={sourceOut:(o=this._getOutTransition(this.currentSceneName))!=null?o:f,destinationIn:(a=this._getInTransition(t))!=null?a:g,...e};const{sourceOut:p,destinationIn:x,sceneActivationData:m}=e,w=p!=null?p:this._getOutTransition(this.currentSceneName),S=x!=null?x:this._getInTransition(t),C=(w==null?void 0:w.hideLoader)||(S==null?void 0:S.hideLoader);C&&this.maybeLoadScene(t,C),this._emitEvent("navigationstart",u,t),w&&await this.playTransition(w,c),await this.maybeLoadScene(t,C),S&&await S.onPreviousSceneDeactivate(this.currentScene),S&&S._addToTargetScene(this._engine,l),await this.swapScene(t,m),this._emitEvent("navigation",u,t),S&&await this.playTransition(S,l),this._emitEvent("navigationend",u,t),(h=this._engine.input)==null||h.toggleEnabled(_),this._isTransitioning=!1}getSceneInstance(t){const e=this.getSceneDefinition(t);if(!e)return;if(this._sceneToInstance.has(t))return this._sceneToInstance.get(t);if(e instanceof Rt)return this._sceneToInstance.set(t,e),e;const i=new e;return this._sceneToInstance.set(t,i),i}async maybeLoadScene(t,e=!1){var i;const s=(i=this._getLoader(t))!=null?i:new mi,n=this.getSceneDefinition(t),o=this.getSceneInstance(t);n&&o&&!this._loadedScenes.has(o)&&(o.onPreLoad(s),o.events.emit("preload",{loader:s}),e?this._engine.load(s,e):await this._engine.load(s),this._loadedScenes.add(o))}async playTransition(t,e){var i,s,n,o,a,h,l;if(!this.isInitialized){this._deferredTransition=t;return}if(t){this.currentTransition=t;const c=(s=(i=e.input)==null?void 0:i.enabled)!=null?s:!0;(n=e.input)==null||n.toggleEnabled(!t.blockInput),(o=this._engine.input)==null||o.toggleEnabled(!t.blockInput),e.events.emit("transitionstart",t),this.currentTransition._addToTargetScene(this._engine,e),await this.currentTransition._play(),e.events.emit("transitionend",t),(a=e.input)==null||a.toggleEnabled(c)}(h=this.currentTransition)==null||h.kill(),(l=this.currentTransition)==null||l.reset(),this.currentTransition=void 0}async swapScene(t,e){const i=this._engine;if(!this.isInitialized){this._deferredGoto=t;return}const s=this.getSceneInstance(t);if(s){const n=this.currentScene,o=s;let a;if(this._logger.debug("Going to scene:",t),this.currentScene.isInitialized){const c={engine:i,previousScene:n,nextScene:o};a=await this.currentScene._deactivate(c),this.currentScene.events.emit("deactivate",new Ws(c,this.currentScene)),this.currentScene.input.clear()}const h=this._sceneToLoader.get(t);await(h==null?void 0:h.areResourcesLoaded()),this.currentScene=o,this.currentSceneName=t,i.screen.setCurrentCamera(o.camera),await this.currentScene._initialize(i);const l={engine:i,previousScene:n,previousSceneData:a,nextScene:o,data:e};await this.currentScene._activate(l),this.currentScene.events.emit("activate",new Ns(l,this.currentScene))}else this._logger.error("Scene",t,"does not exist!")}_emitEvent(t,e,i){const s=this.getSceneDefinition(e),n=this.getSceneDefinition(i);this.events.emit(t,{sourceScene:s,sourceName:e,destinationScene:n,destinationName:i})}}function ga(){const r={scope:(t,e)=>{const i=r.value;r.value=t;try{const s=e();return s&&typeof s.then=="function"?s.finally(()=>{r.value=i}):s}catch(s){throw s}finally{r.value=i}},value:void 0};return r}function pa(r){return r.value}const Qn={textureCollectInterval:6e4};class ma{constructor(t){this.options=t,this._running=!1,this._collectionMap=new Map,this._collectors=new Map,this.collectStaleResources=e=>{if(this._running){for(const[i,[s,n]]of this._collectors.entries()){const o=this.options.getTimestamp();for(const[a,[h,l]]of this._collectionMap.entries()){if(i!==h||l+n>=o)continue;s(a)&&this._collectionMap.delete(a)}}this._collectHandle=requestIdleCallback(this.collectStaleResources)}}}registerCollector(t,e,i){this._collectors.set(t,[i,e])}addCollectableResource(t,e){this._collectionMap.set(e,[t,this.options.getTimestamp()])}touch(t){const e=this._collectionMap.get(t);e&&this._collectionMap.set(t,[e[0],this.options.getTimestamp()])}forceCollectAll(){for(const[t,[e]]of this._collectors.entries())for(const[i]of this._collectionMap.entries())e(i)&&this._collectionMap.delete(i)}running(){return this._running}start(){this._running=!0,this.collectStaleResources()}stop(){this._running=!1,cancelIdleCallback(this._collectHandle)}}Me();const Ul={FallbackGraphicsContext:"fallbackgraphicscontext",Initialize:"initialize",Visible:"visible",Hidden:"hidden",Start:"start",Stop:"stop",PreUpdate:"preupdate",PostUpdate:"postupdate",PreFrame:"preframe",PostFrame:"postframe",PreDraw:"predraw",PostDraw:"postdraw",..._a};var Qe=(r=>(r[r.None=0]="None",r[r.Canvas=1]="Canvas",r[r.All=2]="All",r))(Qe||{});const rs=class ue{constructor(t){this.scope=T=>ue.Context.scope(this,T),this.version=er,this.events=new X,this.maxFps=Number.POSITIVE_INFINITY,this._inputEnabled=!0,this._suppressPlayButton=!1,this.pauseAudioWhenHidden=!0,this._isDebug=!1,this.enableCanvasTransparency=!0,this.onFatalException=T=>{R.getInstance().fatal(T,T.stack)},this._toaster=new ua,this._timescale=1,this._isInitialized=!1,this._hasCreatedCanvas=!1,this._originalOptions={},this._handleWebGLContextLost=T=>{var I;T.preventDefault(),this.clock.stop(),this._logger.fatalOnce("WebGL Graphics Lost",T);const y=document.createElement("div");y.id="ex-webgl-graphics-context-lost",y.style.position="absolute",y.style.zIndex="99",y.style.left="50%",y.style.top="50%",y.style.display="flex",y.style.flexDirection="column",y.style.transform="translate(-50%, -50%)",y.style.backgroundColor="white",y.style.padding="10px",y.style.borderStyle="solid 1px";const F=document.createElement("div");if(F.innerHTML=`
|
|
787
787
|
<h1>There was an issue rendering, please refresh the page.</h1>
|
|
788
788
|
<div>
|
|
789
789
|
<p>WebGL Graphics Context Lost</p>
|
|
@@ -817,4 +817,4 @@ If in Firefox, visit about:config
|
|
|
817
817
|
|
|
818
818
|
Read more about this issue at https://excaliburjs.com/docs/performance`),i&&this._toaster.toast("Excalibur is encountering performance issues. It's possible that your browser doesn't have hardware acceleration enabled. Visit [LINK] for more information and potential solutions.","https://excaliburjs.com/docs/performance"),this.useCanvas2DFallback(),this.emit("fallbackgraphicscontext",this.graphicsContext))}}useCanvas2DFallback(){var t,e,i;const s=this.canvas.cloneNode(!1);this.canvas.parentNode.replaceChild(s,this.canvas),this.canvas=s;const n={...this._originalOptions,antialiasing:this.screen.antialiasing},o=this._originalDisplayMode;this.graphicsContext=new Xi({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,antialiasing:n.antialiasing,backgroundColor:n.backgroundColor,snapToPixel:n.snapToPixel,useDrawSorting:n.useDrawSorting}),this.screen&&this.screen.dispose(),this.screen=new Ln({canvas:this.canvas,context:this.graphicsContext,antialiasing:(t=n.antialiasing)!=null?t:!0,browser:this.browser,viewport:(e=n.viewport)!=null?e:n.width&&n.height?{width:n.width,height:n.height}:Bn.SVGA,resolution:n.resolution,displayMode:o,pixelRatio:n.suppressHiDPIScaling?1:(i=n.pixelRatio)!=null?i:null}),this.screen.setCurrentCamera(this.currentScene.camera),this.input.pointers.detach();const a=n&&n.pointerScope===Fe.Document?document:this.canvas;this.input.pointers=this.input.pointers.recreate(a,this),this.input.pointers.init()}dispose(){this._disposed||(this._disposed=!0,this.stop(),this._garbageCollector.forceCollectAll(),this.input.toggleEnabled(!1),this._hasCreatedCanvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null,this.screen.dispose(),this.graphicsContext.dispose(),this.graphicsContext=null,ue.InstanceCount--)}isDisposed(){return this._disposed}getWorldBounds(){return this.screen.getWorldBounds()}get timescale(){return this._timescale}set timescale(t){if(t<0){R.getInstance().warnOnce("engine.timescale to a value less than 0 are ignored");return}this._timescale=t}addTimer(t){return this.currentScene.addTimer(t)}removeTimer(t){return this.currentScene.removeTimer(t)}addScene(t,e){return this.director.add(t,e),this}removeScene(t){this.director.remove(t)}add(t){if(arguments.length===2){this.director.add(arguments[0],arguments[1]);return}const e=this.director.getDeferredScene();e instanceof Rt?e.add(t):this.currentScene.add(t)}remove(t){t instanceof Tt&&this.currentScene.remove(t),(t instanceof Rt||$t(t))&&this.removeScene(t),typeof t=="string"&&this.removeScene(t)}async goToScene(t,e){await this.scope(async()=>{await this.director.goToScene(t,e)})}screenToWorldCoordinates(t){return this.screen.screenToWorldCoordinates(t)}worldToScreenCoordinates(t){return this.screen.worldToScreenCoordinates(t)}_initialize(t){var e,i;this.pageScrollPreventionMode=t.scrollPreventionMode;const s=t&&t.pointerScope===Fe.Document?document:this.canvas,n=(i=(e=this._originalOptions)==null?void 0:e.grabWindowFocus)!=null?i:!0;this.input=new Yn({global:this.global,pointerTarget:s,grabWindowFocus:n,engine:this}),this.inputMapper=this.input.inputMapper,this.browser.document.on("visibilitychange",()=>{document.visibilityState==="hidden"?(this.events.emit("hidden",new Hs(this)),this._logger.debug("Window hidden")):document.visibilityState==="visible"&&(this.events.emit("visible",new Os(this)),this._logger.debug("Window visible"))}),!this.canvasElementId&&!t.canvasElement&&document.body.appendChild(this.canvas)}toggleInputEnabled(t){this._inputEnabled=t,this.input.toggleEnabled(this._inputEnabled)}onInitialize(t){}get isInitialized(){return this._isInitialized}async _overrideInitialize(t){this.isInitialized||(await this.director.onInitialize(),await this.onInitialize(t),this.events.emit("initialize",new Ue(t,this)),this._isInitialized=!0)}_update(t){var e;if(this._isLoading){(e=this._loader)==null||e.onUpdate(this,t),this.input.update();return}this.clock.__runScheduledCbs("preupdate"),this._preupdate(t),this.currentScene.update(this,t),this.graphicsContext.updatePostProcessors(t),this.clock.__runScheduledCbs("postupdate"),this._postupdate(t),this.input.update()}_preupdate(t){this.emit("preupdate",new ne(this,t,this)),this.onPreUpdate(this,t)}onPreUpdate(t,e){}_postupdate(t){this.emit("postupdate",new re(this,t,this)),this.onPostUpdate(this,t)}onPostUpdate(t,e){}_draw(t){var e,i;if(this.graphicsContext.backgroundColor=(e=this.currentScene.backgroundColor)!=null?e:this.backgroundColor,this.graphicsContext.beginDrawLifecycle(),this.graphicsContext.clear(),this.clock.__runScheduledCbs("predraw"),this._predraw(this.graphicsContext,t),this._isLoading){this._hideLoader||((i=this._loader)==null||i.canvas.draw(this.graphicsContext,0,0),this.clock.__runScheduledCbs("postdraw"),this.graphicsContext.flush(),this.graphicsContext.endDrawLifecycle());return}this.currentScene.draw(this.graphicsContext,t),this.clock.__runScheduledCbs("postdraw"),this._postdraw(this.graphicsContext,t),this.graphicsContext.flush(),this.graphicsContext.endDrawLifecycle(),this._checkForScreenShots()}_predraw(t,e){this.emit("predraw",new ke(t,e,this)),this.onPreDraw(t,e)}onPreDraw(t,e){}_postdraw(t,e){this.emit("postdraw",new ze(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._isLoading}get ready(){return this._isReadyFuture.isCompleted}isReady(){return this._isReadyFuture.promise}async start(t,e){await this.scope(async()=>{if(!this._compatible)throw new Error("Excalibur is incompatible with your browser");this._isLoading=!0;let i;return t instanceof mi?i=t:typeof t=="string"&&(this.director.configureStart(t,e),i=this.director.mainLoader),this._logger.debug("Starting game clock..."),this.browser.resume(),this.clock.start(),this.garbageCollectorConfig&&this._garbageCollector.start(),this._logger.debug("Game clock started"),await this.load(i!=null?i:new Ji),await this._overrideInitialize(this),this._isReadyFuture.resolve(),this.emit("start",new As(this)),this._isReadyFuture.promise})}_mainloop(t){this.scope(()=>{this.emit("preframe",new Fs(this,this.stats.prevFrame));const e=t*this.timescale;this.currentFrameElapsedMs=e;const i=this.stats.prevFrame.id+1;this.stats.currFrame.reset(),this.stats.currFrame.id=i,this.stats.currFrame.elapsedMs=e,this.stats.currFrame.fps=this.clock.fpsSampler.fps,st.clear();const s=this.clock.now(),n=this.fixedUpdateTimestep;if(this.fixedUpdateTimestep)for(this._lagMs+=e;this._lagMs>=n;)this._update(n),this._lagMs-=n;else this._update(e);const o=this.clock.now();this.currentFrameLagMs=this._lagMs,this._draw(e);const a=this.clock.now();this.stats.currFrame.duration.update=o-s,this.stats.currFrame.duration.draw=a-o,this.stats.currFrame.graphics.drawnImages=st.DrawnImagesCount,this.stats.currFrame.graphics.drawCalls=st.DrawCallCount,this.emit("postframe",new Bs(this,this.stats.currFrame)),this.stats.prevFrame.reset(this.stats.currFrame),this._monitorPerformanceThresholdAndTriggerFallback()})}stop(){this.clock.isRunning()&&(this.emit("stop",new Es(this)),this.browser.pause(),this.clock.stop(),this._garbageCollector.stop(),this._logger.debug("Game stopped"))}isRunning(){return this.clock.isRunning()}screenshot(t=!1){return new Promise(i=>{this._screenShotRequests.push({preserveHiDPIResolution:t,resolve:i})})}_checkForScreenShots(){for(const t of this._screenShotRequests){const e=t.preserveHiDPIResolution?this.canvas.width:this.screen.resolution.width,i=t.preserveHiDPIResolution?this.canvas.height:this.screen.resolution.height,s=document.createElement("canvas");s.width=e,s.height=i;const n=s.getContext("2d");n.imageSmoothingEnabled=this.screen.antialiasing,n.drawImage(this.canvas,0,0,e,i);const o=new Image,a=s.toDataURL("image/png");o.onload=()=>{t.resolve(o)},o.src=a}this._screenShotRequests.length=0}async load(t,e=!1){await this.scope(async()=>{try{if(t.isLoaded())return;this._loader=t,this._isLoading=!0,this._hideLoader=e,t instanceof Ji&&(t.suppressPlayButton=t.suppressPlayButton||this._suppressPlayButton),this._loader.onInitialize(this),await t.load()}catch(i){this._logger.error("Error loading resources, things may not behave properly",i),await Promise.resolve()}finally{this._isLoading=!1,this._hideLoader=!1,this._loader=null}})}};rs.Context=ga(),rs.InstanceCount=0,rs._DEFAULT_ENGINE_OPTIONS={width:0,height:0,enableCanvasTransparency:!0,useDrawSorting:!0,configurePerformanceCanvas2DFallback:{allow:!1,showPlayerMessage:!1,threshold:{fps:20,numberOfFrames:100}},canvasElementId:"",canvasElement:void 0,enableCanvasContextMenu:!1,snapToPixel:!1,antialiasing:!0,pixelArt:!1,garbageCollection:!0,powerPreference:"high-performance",pointerScope:Fe.Canvas,suppressConsoleBootMessage:null,suppressMinimumBrowserFeatureDetection:null,suppressHiDPIScaling:null,suppressPlayButton:null,grabWindowFocus:!0,scrollPreventionMode:1,backgroundColor:P.fromHex("#2185d0")};let os=rs;class Ol extends Ft{constructor(t){super(t),this._font=new Ce,this._text=new _i({text:"",font:this._font});const{text:e,pos:i,x:s,y:n,spriteFont:o,font:a,color:h,maxWidth:l}={text:"",...t};this.pos=i!=null?i:s&&n?b(s,n):this.pos,this.text=e!=null?e:this.text,this.font=a!=null?a:this.font,this.maxWidth=l!=null?l:this.maxWidth,this.spriteFont=o!=null?o:this.spriteFont,this._text.color=h!=null?h:this.color;const c=this.get(j);c.anchor=v.Zero,c.use(this._text)}set maxWidth(t){this._text.maxWidth=t}get maxWidth(){return this._text.maxWidth}get font(){return this._font}set font(t){this._font=t,this._text.font=t}get text(){return this._text.text}set text(t){this._text.text=t}get color(){return this._text.color}set color(t){this._text&&(this._text.color=t)}get opacity(){return this.graphics.opacity}set opacity(t){this.graphics.opacity=t}get spriteFont(){return this._spriteFont}set spriteFont(t){t&&(this._spriteFont=t,this._text.font=this._spriteFont)}_initialize(t){super._initialize(t)}getTextWidth(){return this._text.width}}var Ae=(r=>(r.Circle="circle",r.Rectangle="rectangle",r))(Ae||{});class Hl extends Ft{constructor(t){var e,i;super({width:(e=t.width)!=null?e:0,height:(i=t.height)!=null?i:0}),this._particlesToEmit=0,this._particlePool=new Ve(()=>new Yi({}),g=>g,500),this.numParticles=0,this.isEmitting=!0,this.deadParticles=[],this.emitRate=1,this.emitterType=Ae.Rectangle,this.radius=0,this.particle={life:2e3,transform:Vt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this._activeParticles=[];const{particle:s,x:n,y:o,z:a,pos:h,isEmitting:l,emitRate:c,emitterType:u,radius:_,random:f}={...t};this.particle={...this.particle,...s},this.pos=h!=null?h:b(n!=null?n:0,o!=null?o:0),this.z=a!=null?a:0,this.isEmitting=l!=null?l:this.isEmitting,this.emitRate=c!=null?c:this.emitRate,this.emitterType=u!=null?u:this.emitterType,this.radius=_!=null?_:this.radius,this.body.collisionType=M.PreventCollision,this.random=f!=null?f:new ie}removeParticle(t){this.deadParticles.push(t)}emitParticles(t){var e;if(!(t<=0)){t=t|0;for(let i=0;i<t;i++){const s=this._createParticle();(e=this==null?void 0:this.scene)!=null&&e.world&&(this.particle.transform===Vt.Global?this.scene.world.add(s):this.addChild(s)),this._activeParticles.push(s)}}}clearParticles(){for(let t=0;t<this._activeParticles.length;t++)this.removeParticle(this._activeParticles[t])}_createParticle(){let t=0,e=0;const i=Ot(this.particle.minAngle||0,this.particle.maxAngle||Math.PI*2,this.random),s=Ot(this.particle.minSpeed||0,this.particle.maxSpeed||0,this.random),n=this.particle.startSize||Ot(this.particle.minSize||5,this.particle.maxSize||5,this.random),o=s*Math.cos(i),a=s*Math.sin(i);if(this.emitterType===Ae.Rectangle)t=Ot(0,this.width,this.random),e=Ot(0,this.height,this.random);else if(this.emitterType===Ae.Circle){const l=Ot(0,this.radius,this.random);t=l*Math.cos(i),e=l*Math.sin(i)}const h=this._particlePool.rent();return h.unparent(),h.configure({transform:this.particle.transform,life:this.particle.life,opacity:this.particle.opacity,beginColor:this.particle.beginColor,endColor:this.particle.endColor,pos:b(t,e),z:this.particle.transform===Vt.Global?this.z:void 0,vel:b(o,a),acc:this.particle.acc,angularVelocity:this.particle.angularVelocity,startSize:this.particle.startSize,endSize:this.particle.endSize,size:n,graphic:this.particle.graphic,fade:this.particle.fade}),h.registerEmitter(this),this.particle.randomRotation&&(h.transform.rotation=Ot(0,Math.PI*2,this.random)),this.particle.focus&&(h.focus=this.particle.focus.add(b(this.pos.x,this.pos.y)),h.focusAccel=this.particle.focusAccel),h}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 s=0;s<this.deadParticles.length;s++){(i=this==null?void 0:this.scene)!=null&&i.world&&(this.scene.world.remove(this.deadParticles[s],!1),this._particlePool.return(this.deadParticles[s]));const n=this._activeParticles.indexOf(this.deadParticles[s]);n>-1&&this._activeParticles.splice(n,1)}this.deadParticles.length=0}}function Jn(r,t){if(!t())throw new Error(r)}class as{constructor(t,e,i){this.emitRate=1,this._initialized=!1,this._vaos=[],this._buffers=[],this._drawIndex=0,this._numInputFloats=7,this._particleIndex=0,this._uploadIndex=0,this._wrappedLife=0,this._wrappedParticles=0,this._particleLife=0,this._clearRequested=!1,this._emitted=[];var s;this.emitter=t,this.particle=i,this._particleData=new Float32Array(this.emitter.maxParticles*this._numInputFloats),this._random=e,this._particleLife=(s=this.particle.life)!=null?s:2e3}get isInitialized(){return this._initialized}get maxParticles(){return this.emitter.maxParticles}initialize(t,e){if(this._initialized)return;const i=this.emitter.maxParticles,s=this._numInputFloats,n=this._particleData,o=4,a=t.createBuffer(),h=t.createVertexArray();t.bindVertexArray(h),t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,i*s*o,t.DYNAMIC_DRAW),t.bufferSubData(t.ARRAY_BUFFER,0,n);let l=0;t.vertexAttribPointer(0,2,t.FLOAT,!1,s*o,0),l+=o*2,t.vertexAttribPointer(1,2,t.FLOAT,!1,s*o,l),l+=o*2,t.vertexAttribPointer(2,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(3,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(4,1,t.FLOAT,!1,s*o,l),l+=o*1,t.enableVertexAttribArray(0),t.enableVertexAttribArray(1),t.enableVertexAttribArray(2),t.enableVertexAttribArray(3),t.enableVertexAttribArray(4),this._vaos.push(h),this._buffers.push(a),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null);const c=t.createBuffer(),u=t.createVertexArray();t.bindVertexArray(u),t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,i*s*o,t.DYNAMIC_DRAW),l=0,t.vertexAttribPointer(0,2,t.FLOAT,!1,s*o,0),l+=o*2,t.vertexAttribPointer(1,2,t.FLOAT,!1,s*o,l),l+=o*2,t.vertexAttribPointer(2,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(3,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(4,1,t.FLOAT,!1,s*o,l),l+=o*1,t.enableVertexAttribArray(0),t.enableVertexAttribArray(1),t.enableVertexAttribArray(2),t.enableVertexAttribArray(3),t.enableVertexAttribArray(4),this._vaos.push(u),this._buffers.push(c),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this._currentVao=this._vaos[this._drawIndex%2],this._currentBuffer=this._buffers[(this._drawIndex+1)%2],this._initialized=!0}clearParticles(){this._particleData.fill(0),this._clearRequested=!0}emitParticles(t){const e=this._particleIndex,i=this.maxParticles*this._numInputFloats,s=t*this._numInputFloats+e;for(let n=e;n<s;n+=this._numInputFloats){let o=this._random.floating(this.particle.minAngle||0,this.particle.maxAngle||et);o+=this.particle.transform===Vt.Local?this.emitter.transform.rotation:this.emitter.transform.globalRotation;const a=this._random.floating(this.particle.minSpeed||0,this.particle.maxSpeed||0),h=this._random.floating(this.particle.minSpeed||0,this.particle.maxSpeed||0),l=a*Math.cos(o),c=h*Math.sin(o);let u=0,_=0;if(this.emitter.emitterType===Ae.Rectangle)u=this._random.floating(-.5,.5)*this.emitter.width,_=this._random.floating(-.5,.5)*this.emitter.height;else{const p=this._random.floating(0,this.emitter.radius);u=p*Math.cos(o),_=p*Math.sin(o)}const f=this.emitter.transform.apply(b(u,_)),g=[this.particle.transform===Vt.Local?u:f.x,this.particle.transform===Vt.Local?_:f.y,l,c,this.particle.randomRotation?Ot(0,et,this._random):this.particle.rotation||0,this.particle.angularVelocity||0,this._particleLife];this._particleData.set(g,n%this._particleData.length)}s>=i?(this._wrappedParticles+=(s-i)/this._numInputFloats,this._wrappedLife=this._particleLife):this._wrappedLife>0&&(this._wrappedParticles+=t),this._particleIndex=s%i,this._emitted.push([this._particleLife,e])}_uploadEmitted(t){this._particleIndex!==this._uploadIndex&&(t.bindBuffer(t.ARRAY_BUFFER,this._buffers[(this._drawIndex+1)%2]),this._particleIndex>=this._uploadIndex?t.bufferSubData(t.ARRAY_BUFFER,this._uploadIndex*4,this._particleData,this._uploadIndex,this._particleIndex-this._uploadIndex):(t.bufferSubData(t.ARRAY_BUFFER,this._uploadIndex*4,this._particleData,this._uploadIndex,this._particleData.length-this._uploadIndex),this._wrappedParticles&&t.bufferSubData(t.ARRAY_BUFFER,0,this._particleData,0,this._wrappedParticles*this._numInputFloats),this._wrappedLife=this._particleLife),t.bindBuffer(t.ARRAY_BUFFER,null)),this._uploadIndex=this._particleIndex%(this.maxParticles*this._numInputFloats)}update(t){var e;if(this._particleLife=(e=this.particle.life)!=null?e:this._particleLife,this._wrappedLife>0?this._wrappedLife-=t:(this._wrappedLife=0,this._wrappedParticles=0),!!this._emitted.length){for(let i=this._emitted.length-1;i>=0;i--){const s=this._emitted[i];s[0]-=t,s[0]<=0&&this._emitted.splice(i,1)}this._emitted.sort((i,s)=>i[0]-s[0])}}draw(t){if(this._initialized){if(this._clearRequested?(t.bindBuffer(t.ARRAY_BUFFER,this._buffers[(this._drawIndex+1)%2]),t.bufferSubData(t.ARRAY_BUFFER,0,this._particleData),t.bindBuffer(t.ARRAY_BUFFER,null),this._clearRequested=!1):this._uploadEmitted(t),t.bindVertexArray(this._currentVao),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer),this._wrappedLife&&this._emitted[0]&&this._emitted[0][1]>0){const e=this._emitted[0][1]/this._numInputFloats;Jn(`midpoint greater than 0, actual: ${e}`,()=>e>0),Jn(`midpoint is less than max, actual: ${e}`,()=>e<this.maxParticles),t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,this._emitted[0][1]*4,(this.maxParticles-e)*this._numInputFloats*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,e,this.maxParticles-e),t.endTransformFeedback(),t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,0,this._emitted[0][1]*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,e),t.endTransformFeedback()}else t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,0,this._particleData.length*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,this.maxParticles),t.endTransformFeedback();t.bindVertexArray(null),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,null),this._currentVao=this._vaos[this._drawIndex%2],this._currentBuffer=this._buffers[(this._drawIndex+1)%2],this._drawIndex=(this._drawIndex+1)%2}}}as.GPU_MAX_PARTICLES=1e5;class Nl extends Ft{constructor(t){super({name:"GpuParticleEmitter",width:t.width,height:t.height}),this.particle={life:2e3,transform:Vt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this.graphics=new j,this.isEmitting=!1,this.emitRate=1,this.emitterType=Ae.Rectangle,this.radius=0,this.maxParticles=2e3,this._particlesToEmit=0,this.addComponent(this.graphics,!0),this.graphics.onPostDraw=this.draw.bind(this);const{particle:e,maxParticles:i,x:s,y:n,z:o,pos:a,isEmitting:h,emitRate:l,emitterType:c,radius:u,random:_}={...t};this.maxParticles=B(i!=null?i:this.maxParticles,0,as.GPU_MAX_PARTICLES),this.pos=a!=null?a:b(s!=null?s:0,n!=null?n:0),this.z=o!=null?o:0,this.isEmitting=h!=null?h:this.isEmitting,this.emitRate=l!=null?l:this.emitRate,this.emitterType=c!=null?c:this.emitterType,this.radius=u!=null?u:this.radius,this.particle={...this.particle,...e},this.random=_!=null?_:new ie,this.renderer=new as(this,this.random,this.particle)}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t}get z(){return this.transform.z}set z(t){this.transform.z=t}_initialize(t){super._initialize(t);const e=t.graphicsContext;this.renderer.initialize(e.__gl,e)}update(t,e){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))),this.renderer.update(e)}emitParticles(t){t<=0||this.renderer.emitParticles(t|0)}clearParticles(){this.renderer.clearParticles()}draw(t,e){t.draw("ex.particle",this.renderer,e)}}class Kn{constructor(t,e){this.id=H(),this._stopped=!1,this._sequenceBuilder=e,this._sequenceContext=new fi(t),this._actionQueue=this._sequenceContext.getQueue(),this._sequenceBuilder(this._sequenceContext)}update(t){this._actionQueue.update(t)}isComplete(){return this._stopped||this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._stopped=!1,this._actionQueue.reset()}clone(t){return new Kn(t,this._sequenceBuilder)}}class Wl{constructor(t){this.id=H(),this._actions=t}update(t){for(let e=0;e<this._actions.length;e++)this._actions[e].update(t)}isComplete(t){return this._actions.every(e=>e.isComplete(t))}reset(){this._actions.forEach(t=>t.reset())}stop(){this._actions.forEach(t=>t.stop())}}function Gl(r){return!!r._initialize}function Vl(r){return!!r.onAdd}function ql(r){return!!r.onRemove}function Xl(r){return!!r.onInitialize}function Yl(r){return!!r._preupdate}function $l(r){return!!r.onPreUpdate}function jl(r){return!!r.onPostUpdate}function Zl(r){return!!r.onPostUpdate}function Ql(r){return!!r.onAdd}function Jl(r){return!!r.onRemove}function Kl(r){return!!r.onPreDraw}function tc(r){return!!r.onPostDraw}class va{constructor(t,e){this.soundManager=e}stop(t){if(!t)return;const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)e[i].stop()}setVolume(t,e){const i=this.soundManager.getSoundsForChannel(t);for(const s of i)this.soundManager._isMuted(s)||this.soundManager.setVolume(t,e)}play(t,e){e!=null||(e=this.soundManager.defaultVolume);const i=[],s=new Set,n=this.soundManager.getSoundsForChannel(t);for(const o of n){if(s.has(o)||this.soundManager._isMuted(o))continue;const a=this.soundManager._getEffectiveVolume(o);i.push(o.play(a*e)),s.add(o)}return Promise.all(i)}mute(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._muted.add(e[i]),e[i].pause()}unmute(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._muted.has(e[i])&&(e[i].play(),this.soundManager._muted.delete(e[i]))}toggle(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._isMuted(e[i])?(e[i].play(),this.soundManager._muted.delete(e[i])):(this.soundManager._muted.add(e[i]),e[i].pause())}}class ec{constructor(t){this._channelToConfig=new Map,this._nameToConfig=new Map,this._mix=new Map,this._muted=new Set,this._all=new Set,this._defaultVolume=1;var e;if(this._defaultVolume=(e=t.volume)!=null?e:1,this.channel=new va(t,this),t.sounds)for(const[i,s]of Object.entries(t.sounds))this.track(i,s)}set defaultVolume(t){this._defaultVolume=B(t,0,1)}get defaultVolume(){return this._defaultVolume}getSounds(){return Array.from(this._all)}getSoundsForChannel(t){const e=this._channelToConfig.get(t);return e?e.sounds:[]}_isMuted(t){return this._muted.has(t)}_getEffectiveVolume(t){var e;if(this._isMuted(t))return 0;let i=this._defaultVolume;return this._mix.has(t)&&(i*=(e=this._mix.get(t))!=null?e:this._defaultVolume),i}play(t,e=this._defaultVolume){const i=this._nameToConfig.get(t);if(!i)return Promise.resolve();const{sound:s}=i;if(this._isMuted(s))return Promise.resolve();const n=e*this._getEffectiveVolume(s);return s.play(n)}getSound(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;return i}setVolume(t,e=this._defaultVolume){const i=this._nameToConfig.get(t);if(!i)return;const{sound:s}=i;this._setMix(s,e)}getVolume(t){var e;const i=this.getSound(t);return i&&(e=this._mix.get(i))!=null?e:0}_setMix(t,e){this._mix.set(t,e),t.volume=e}track(t,e){let i,s,n;e instanceof Un?(i=e,s=this._defaultVolume,n=[]):{sound:i,volume:s,channels:n}=e,this._nameToConfig.set(t,{sound:i,volume:s,channels:n}),this._mix.set(i,s!=null?s:this._defaultVolume),this._all.add(i),n&&this.addChannel(t,n)}untrack(t){this._nameToConfig.delete(t);const e=this.getSound(t);e&&(this._mix.delete(e),this._all.delete(e))}stop(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;i.stop();return}this._all.forEach(e=>e.stop())}mute(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;this._muted.add(i),i.pause();return}this._muted=new Set(this._all),this._muted.forEach(e=>e.pause())}unmute(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;i.play(),this._muted.delete(i);return}this._muted.forEach(e=>e.play()),this._muted.clear()}toggle(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;this._isMuted(i)?this.unmute(t):this.mute(t);return}this._muted.size>0?(this._muted.forEach(e=>e.play()),this._muted.clear()):(this._muted=new Set(this._all),this._muted.forEach(e=>e.pause()))}addChannel(t,e){const i=this.getSound(t);if(!i)return;const s=this._mix.get(i);this._mix.set(i,s!=null?s:this._defaultVolume),this._all.add(i);for(const n of e){let o=this._channelToConfig.get(n);o||(o={sounds:[i]}),o.sounds.indexOf(i)===-1&&o.sounds.push(i),this._channelToConfig.set(n,o)}}removeChannel(t,e){const i=this.getSound(t);if(i)for(const s of e){const n=this._channelToConfig.get(s);if(!n)return;const o=n.sounds.indexOf(i);o>=-1&&n.sounds.splice(o,1),this._channelToConfig.set(s,n)}}}class ic{constructor(t,e=!1){this.path=t,this.width=0,this.height=0,this._images=[],this.data=[],this._sprites=[],this._resource=new hi(t,"arraybuffer",e)}get bustCache(){return this._resource.bustCache}set bustCache(t){this._resource.bustCache=t}async load(){const t=await this._resource.load();this._stream=new wa(t),this._gif=new xa(this._stream);const e=this._gif.images.map(i=>new Gt(i.src,!1));return await Promise.all(e.map(i=>i.load())),this.data=this._images=e,this._sprites=this._images.map(i=>i.toSprite()),this.data}isLoaded(){return!!this.data}toSprite(t=0){var e;return(e=this._sprites[t])!=null?e:null}toSpriteSheet(){const t=this._sprites;return t.length?new be({sprites:t}):null}toAnimation(t){var e;const i=(e=this._gif)==null?void 0:e.images;if(i!=null&&i.length){const s=i.map((n,o)=>{var a;return{graphic:this._sprites[o],duration:((a=this._gif)==null?void 0:a.frames[o].delayMs)||void 0}});return this._animation=new Ui({frames:s,frameDuration:t}),this._animation}return null}get readCheckBytes(){var t,e;return(e=(t=this._gif)==null?void 0:t.checkBytes)!=null?e:[]}}const hs=r=>r.reduce(function(t,e){return t*2+e},0),tr=r=>{const t=[];for(let e=7;e>=0;e--)t.push(!!(r&1<<e));return t};class wa{constructor(t){if(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=e=>{const i=[];for(let s=0;s<e;s++)i.push(this.readByte());return i},this.read=e=>{let i="";for(let s=0;s<e;s++)i+=String.fromCharCode(this.readByte());return i},this.readUnsigned=()=>{const e=this.readBytes(2);return(e[1]<<8)+e[0]},this.data=new Uint8Array(t),this.len=this.data.byteLength,this.len===0)throw new Error("No data loaded from file")}}const sc=function(r,t){let e=0;const i=function(_){let f=0;for(let g=0;g<_;g++)t.charCodeAt(e>>3)&1<<(e&7)&&(f|=1<<g),e++;return f},s=[],n=1<<r,o=n+1;let a=r+1,h=[];const l=function(){h=[],a=r+1;for(let _=0;_<n;_++)h[_]=[_];h[n]=[],h[o]=null};let c=0,u=0;for(;;){if(u=c,c=i(a),c===n){l();continue}if(c===o)break;if(c<h.length)u!==n&&h.push(h[u].concat(h[c][0]));else{if(c!==h.length)throw new Error("Invalid LZW code.");h.push(h[u].concat(h[u][0]))}s.push.apply(s,h[c]),h.length===1<<a&&a<12&&a++}return s};class xa{constructor(t){this._handler={},this.frames=[],this.images=[],this.globalColorTableBytes=[],this.checkBytes=[],this.parseColorTableBytes=e=>{const i=[];for(let s=0;s<e;s++){const n=this._st.readBytes(3);i.push(n)}return i},this.readSubBlocks=()=>{let e,i;i="";do e=this._st.readByte(),i+=this._st.read(e);while(e!==0);return i},this.parseHeader=()=>{const e={sig:"",ver:"",width:0,height:0,colorResolution:0,globalColorTableSize:0,gctFlag:!1,sortedFlag:!1,globalColorTable:[],backgroundColorIndex:0,pixelAspectRatio:0};if(e.sig=this._st.read(3),e.ver=this._st.read(3),e.sig!=="GIF")throw new Error("Not a GIF file.");e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned(),this._currentFrameCanvas.width=e.width,this._currentFrameCanvas.height=e.height;const i=tr(this._st.readByte());e.gctFlag=i.shift(),e.colorResolution=hs(i.splice(0,3)),e.sortedFlag=i.shift(),e.globalColorTableSize=hs(i.splice(0,3)),e.backgroundColorIndex=this._st.readByte(),e.pixelAspectRatio=this._st.readByte(),e.gctFlag&&(this.globalColorTableBytes=this.parseColorTableBytes(1<<e.globalColorTableSize+1)),this._handler.hdr&&this._handler.hdr(e)&&this.checkBytes.push(this._handler.hdr)},this.parseExt=e=>{const i=h=>{this.checkBytes.push(this._st.readByte());const l=tr(this._st.readByte());return h.reserved=l.splice(0,3),h.disposalMethod=hs(l.splice(0,3)),h.userInputFlag=l.shift(),h.transparentColorFlag=l.shift(),h.delayTime=this._st.readUnsigned(),h.transparentColorIndex=this._st.readByte(),h.terminator=this._st.readByte(),this._handler.gce&&this._handler.gce(h)&&this.checkBytes.push(this._handler.gce),h},s=h=>{h.comment=this.readSubBlocks(),this._handler.com&&this._handler.com(h)&&this.checkBytes.push(this._handler.com)},n=h=>{this.checkBytes.push(this._st.readByte()),h.ptHeader=this._st.readBytes(12),h.ptData=this.readSubBlocks(),this._handler.pte&&this._handler.pte(h)&&this.checkBytes.push(this._handler.pte)},o=h=>{const l=u=>{this.checkBytes.push(this._st.readByte()),u.unknown=this._st.readByte(),u.iterations=this._st.readUnsigned(),u.terminator=this._st.readByte(),this._handler.app&&this._handler.app.NETSCAPE&&this._handler.app.NETSCAPE(u)&&this.checkBytes.push(this._handler.app)},c=u=>{u.appData=this.readSubBlocks(),this._handler.app&&this._handler.app[u.identifier]&&this._handler.app[u.identifier](u)&&this.checkBytes.push(this._handler.app[u.identifier])};switch(this.checkBytes.push(this._st.readByte()),h.identifier=this._st.read(8),h.authCode=this._st.read(3),h.identifier){case"NETSCAPE":l(h);break;default:c(h);break}},a=h=>{h.data=this.readSubBlocks(),this._handler.unknown&&this._handler.unknown(h)&&this.checkBytes.push(this._handler.unknown)};switch(e.label=this._st.readByte(),e.label){case 249:e.extType="gce",this._gce=i(e);break;case 254:e.extType="com",s(e);break;case 1:e.extType="pte",n(e);break;case 255:e.extType="app",o(e);break;default:e.extType="unknown",a(e);break}},this.parseImg=e=>{var i;const s=(a,h)=>{const l=new Array(a.length),c=a.length/h,u=(p,x)=>{const m=a.slice(x*h,(x+1)*h);l.splice.apply(l,[p*h,h].concat(m))},_=[0,4,2,1],f=[8,8,4,2];let g=0;for(let p=0;p<4;p++)for(let x=_[p];x<c;x+=f[p])u(x,g),g++;return l};e.leftPos=this._st.readUnsigned(),e.topPos=this._st.readUnsigned(),e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned();const n=tr(this._st.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=hs(n.splice(0,3)),e.lctFlag&&(e.lctBytes=this.parseColorTableBytes(1<<e.lctSize+1)),e.lzwMinCodeSize=this._st.readByte();const o=this.readSubBlocks();e.pixels=sc(e.lzwMinCodeSize,o),e.interlaced&&(e.pixels=s(e.pixels,e.width)),(i=this._gce)!=null&&i.delayTime&&(e.delayMs=this._gce.delayTime*10),this.frames.push(e),this.arrayToImage(e,e.lctFlag?e.lctBytes:this.globalColorTableBytes),this._handler.img&&this._handler.img(e)&&this.checkBytes.push(this._handler)},this.parseBlocks=()=>{const e={sentinel:this._st.readByte(),type:""};switch(String.fromCharCode(e.sentinel)){case"!":e.type="ext",this.parseExt(e);break;case",":e.type="img",this.parseImg(e);break;case";":e.type="eof",this._handler.eof&&this._handler.eof(e)&&this.checkBytes.push(this._handler.eof);break;default:throw new Error("Unknown block: 0x"+e.sentinel.toString(16))}e.type!=="eof"&&this.parseBlocks()},this.arrayToImage=(e,i)=>{var s,n,o,a;const h=document.createElement("canvas");h.width=e.width,h.height=e.height;const l=h.getContext("2d"),c=l.getImageData(0,0,h.width,h.height);let u=-1;(s=this._gce)!=null&&s.transparentColorFlag&&(u=this._gce.transparentColorIndex);for(let f=0;f<e.pixels.length;f++){const g=e.pixels[f],p=i[g];g===u?c.data.set([0,0,0,0],f*4):c.data.set([...p,255],f*4)}if(l.putImageData(c,0,0),((n=this._gce)==null?void 0:n.disposalMethod)===1&&this.images.length)this._currentFrameContext.drawImage(this.images[this.images.length-1],0,0);else if(((o=this._gce)==null?void 0:o.disposalMethod)===2&&((a=this._hdr)!=null&&a.gctFlag)){const f=i[this._hdr.backgroundColorIndex];this._currentFrameContext.fillStyle=`rgb(${f[0]}, ${f[1]}, ${f[2]})`,this._currentFrameContext.fillRect(0,0,this._hdr.width,this._hdr.height)}else this._currentFrameContext.clearRect(0,0,this._currentFrameCanvas.width,this._currentFrameCanvas.height);this._currentFrameContext.drawImage(h,e.leftPos,e.topPos,e.width,e.height);const _=new Image;_.src=this._currentFrameCanvas.toDataURL(),this.images.push(_)},this._st=t,this._handler={},this._currentFrameCanvas=document.createElement("canvas"),this._currentFrameContext=this._currentFrameCanvas.getContext("2d"),this.parseHeader(),this.parseBlocks()}}class nc{constructor(t,e,{bustCache:i,...s}={}){this.path=t,this.family=e,this._isLoaded=!1,this._resource=new hi(t,"blob",i),this._options=s}async load(){if(this.isLoaded())return this.data;try{const t=await this._resource.load(),e=URL.createObjectURL(t);this.data||(this.data=new FontFace(this.family,`url(${e})`),document.fonts.add(this.data)),await this.data.load(),this._isLoaded=!0}catch(t){throw`Error loading FontSource from path '${this.path}' with error [${t.message}]`}return this.data}isLoaded(){return this._isLoaded}toFont(t){return new Ce({family:this.family,...this._options,...t})}}const ba=ga(),rc=/^\s*(?:function)?\*/;function ya(r){return typeof r!="function"?!1:rc.test(Function.prototype.toString.call(r))?!0:Object.getPrototypeOf?Object.getPrototypeOf(r)===Object.getPrototypeOf(new Function("return function * () {}")()):!1}function Ca(...r){var t;const e=R.getInstance();let i,s,n,o;ya(r[0])&&(s=globalThis,i=r[0],n=r[1]),ya(r[1])&&(s=r[0],i=r[1],n=r[2]),r[1]instanceof os&&(s=r[0],o=r[1],i=r[2],n=r[3]),r[0]instanceof os&&(s=globalThis,o=r[0],i=r[1],n=r[2]);const a=pa(ba),h=n==null?void 0:n.timing,l=a?!1:(t=n==null?void 0:n.autostart)!=null?t:!0;let c;try{c=o!=null?o:os.useEngine()}catch(S){throw Error(`Cannot run coroutine without engine parameter outside of an excalibur lifecycle method.
|
|
819
819
|
Pass an engine parameter to ex.coroutine(engine, function * {...})`)}let u=!1,_=!1,f=!1;const g=i.bind(s),p=g();let x;const m=new Promise((S,C)=>{x=T=>{try{if(f){_=!0,S();return}const{done:I,value:y}=ba.scope(!0,()=>p.next(T));if(I||f){_=!0,S();return}y instanceof Promise?y.then(()=>{c.clock.schedule(x,0,h)}):y===void 0||y===void 0?c.clock.schedule(x,0,h):c.clock.schedule(x,y||0,h)}catch(I){C(I);return}},l&&(u=!0,x(c.clock.elapsed()))}),w={isRunning:()=>u&&!f&&!_,isComplete:()=>_,cancel:()=>{f=!0},start:()=>(u?e.warn(`.start() was called on a coroutine that was already started, this is probably a bug:
|
|
820
|
-
`,Function.prototype.toString.call(g)):(u=!0,x(c.clock.elapsed())),w),generator:p,done:m,then:m.then.bind(m),[Symbol.iterator]:()=>p};return w}class ls extends Tt{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new A,this.graphics=new j,this._completeFuture=new wt,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=t.duration,Se(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:It.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ti,this.direction=(s=t.direction)!=null?s:"out",this.hideLoader=(n=t.hideLoader)!=null?n:!1,this.blockInput=(o=t.blockInput)!=null?o:!1,this.transform.coordPlane=rt.Screen,this.transform.pos=v.Zero,this.transform.z=1/0,this.graphics.anchor=v.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction==="out"?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction==="out"?this.progress>=1:this.progress<=0}updateTransition(t,e){this.complete||(this._currentDistance+=B(e/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction==="out"?this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=B(ot(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=B(ot(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(t){}onStart(t){}onUpdate(t){}onEnd(t){}onReset(){}reset(){this.started=!1,this._completeFuture=new wt,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction==="out"?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(t,e){const i=e;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),i.world.entityManager.getById(this.id))return this._co;this._engine=t,i.add(this);const s=this;return this._co=Ca(t,function*(){for(;!s.complete;){const n=yield;s.updateTransition(s._engine,n),s._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}}class oc extends ls{constructor(t){var e,i;super({...t,duration:(e=t.duration)!=null?e:2e3}),this.name=`FadeInOut#${this.id}`,this.color=(i=t.color)!=null?i:P.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new di({width:t.screen.resolution.width,height:t.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=t}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class ac extends ls{constructor(t){super({direction:"in",...t}),this.name=`CrossFade#${this.id}`}async onPreviousSceneDeactivate(t){this.image=await t.engine.screenshot(!0),await this.image.decode()}onInitialize(t){this.engine=t,this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=Gt.fromHtmlImageElement(this.image).toSprite(),this.graphics.add(this.screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio),this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class hc extends ls{constructor(t){var e;super({direction:"in",...t}),this._easing=It.Linear,this._start=v.Zero,this._end=v.Zero,this.name=`Slide#${this.id}`,this.slideDirection=t.slideDirection,this.transform.coordPlane=rt.Screen,this.graphics.forceOnScreen=!0,this._easing=(e=t.easingFunction)!=null?e:this._easing}async onPreviousSceneDeactivate(t){this._image=await t.engine.screenshot(!0),await this._image.decode(),this._screenCover=Gt.fromHtmlImageElement(this._image).toSprite()}onInitialize(t){this._engine=t;let e=t.screen.unsafeArea;switch(e.hasZeroDimensions()&&(e=t.screen.contentArea),this.slideDirection){case"up":{this._directionOffset=b(0,-e.height);break}case"down":{this._directionOffset=b(0,e.height);break}case"left":{this._directionOffset=b(-e.width,0);break}case"right":{this._directionOffset=b(e.width,0);break}}this._camera=this._engine.currentScene.camera,this._destinationCameraPosition=this._camera.pos.clone(),this._camera.pos=this._camera.pos.add(this._directionOffset),this.transform.pos=this.transform.pos.add(this._directionOffset),this._startCameraPosition=this._camera.pos.clone(),this._start=e.topLeft,this._end=this._start.add(this._directionOffset),this.transform.pos=this._start,this.graphics.use(this._screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio)}onStart(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}onUpdate(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}}const lc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:ys,DrawUtil:Fh,EasingFunctions:It,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:pr,addItemToArray:wh,contains:wr,delay:Di,fail:xr,getMinIndex:vr,getPosition:ri,isLegacyEasing:Se,isObject:Fi,mergeDeep:Bi,omit:br,removeItemFromArray:Oe},Symbol.toStringTag,{value:"Module"})),Sa=5,Je={},cc=()=>{for(const r in Je)Je[r]=0},cs=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");Je[r]<Sa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),Je[r]++};function dc(r){return r={message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrace:!1,...r},function(t,e,i){if(i&&!(typeof i.value=="function"||typeof i.get=="function"||typeof i.set=="function"))throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${t.name||""}${t.name&&e?".":""}${e||""}`} is marked obsolete: ${r.message}`+(r.alternateMethod?` Use ${r.alternateMethod} instead`:"");Je[n]||(Je[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){cs(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return cs(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return cs(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return cs(n,r),i.set.apply(this,arguments)}),o)}}class uc{constructor(){this._queue=[]}get length(){return this._queue.length}enqueue(){const t=new wt;return this._queue.push(t),t.promise}dequeue(t){this._queue.shift().resolve(t)}}class _c{constructor(t){this._count=t,this._waitQueue=new uc}get count(){return this._count}get waiting(){return this._waitQueue.length}async enter(){return this._count!==0?(this._count--,Promise.resolve()):this._waitQueue.enqueue()}exit(t=1){if(t!==0){for(;t!==0&&this._waitQueue.length!==0;)this._waitQueue.dequeue(null),t--;this._count+=t}}}const er="0.32.0-alpha.1560+24fadc4";Me(),d.ActionCompleteEvent=$s,d.ActionContext=fi,d.ActionQueue=Kr,d.ActionSequence=Kn,d.ActionStartEvent=Ys,d.ActionsComponent=je,d.ActionsSystem=Vn,d.ActivateEvent=Ns,d.Actor=Ft,d.ActorEvents=wl,d.AddEvent=js,d.AddedComponent=xh,d.AffineMatrix=Q,d.Animation=Ui,d.AnimationDirection=Fr,d.AnimationEvents=Ih,d.AnimationStrategy=Br,d.ArcadeSolver=Dn,d.AudioContextFactory=pi,d.Axes=Ko,d.Axis=qo,d.BaseAlign=an,d.BezierCurve=ii,d.Blink=xo,d.BodyComponent=N,d.BoundingBox=D,d.BrowserComponent=$n,d.BrowserEvents=la,d.Buttons=qn,d.Camera=Qo,d.CameraEvents=Ml,d.Canvas=qi,d.ChannelCollection=va,d.Circle=Vi,d.CircleCollider=dt,d.Clock=jn,d.ClosestLineJumpTable=Wt,d.Collider=oi,d.ColliderComponent=tt,d.CollisionContact=we,d.CollisionEndEvent=ni,d.CollisionGroup=pe,d.CollisionGroupManager=Pi,d.CollisionJumpTable=Lt,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=si,d.CollisionSystem=Zi,d.CollisionType=M,d.Color=P,d.ColorBlindFlags=aa,d.ColorBlindnessMode=Ye,d.ColorBlindnessPostProcessor=Zr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=ys,d.ContactConstraintPoint=Io,d.ContactEndEvent=Ii,d.ContactSolveBias=oe,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=ac,d.CurveBy=Po,d.CurveTo=To,d.DeactivateEvent=Ws,d.Debug=Cn,d.DebugConfig=ha,d.DebugGraphicsComponent=Ni,d.DebugSystem=Gn,d.DebugText=un,d.DefaultAntialiasOptions=Ur,d.DefaultGarbageCollectionOptions=Qn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Or,d.DegreeOfFreedom=he,d.Delay=yo,d.Detector=zo,d.Die=Co,d.Direction=ln,d.Director=fa,d.DirectorEvents=_a,d.DisplayMode=gi,d.DynamicTree=Ks,d.DynamicTreeCollisionProcessor=Li,d.EX_VERSION=er,d.EaseBy=wo,d.EaseTo=vo,d.EasingFunctions=It,d.Edge=vs,d.EdgeCollider=Ct,d.ElasticToActorStrategy=$o,d.EmitterType=Ae,d.Engine=os,d.EngineEvents=Ul,d.EnterTriggerEvent=qs,d.EnterViewPortEvent=Vs,d.Entity=Tt,d.EntityEvents=Sh,d.EntityManager=Cr,d.EventEmitter=X,d.EventTypes=Ss,d.Events=vh,d.ExResponse=kn,d.ExcaliburGraphicsContext2DCanvas=Xi,d.ExcaliburGraphicsContextWebGL=Xt,d.ExitTriggerEvent=Xs,d.ExitViewPortEvent=Gs,d.Fade=bo,d.FadeInOut=oc,d.Flags=De,d.Flash=So,d.Follow=An,d.Font=Ce,d.FontCache=Gi,d.FontSource=nc,d.FontStyle=hn,d.FontUnit=rn,d.FpsSampler=ca,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=As,d.GameStopEvent=Es,d.Gamepad=is,d.GamepadAxisEvent=Us,d.GamepadButtonEvent=zs,d.GamepadConnectEvent=Ls,d.GamepadDisconnectEvent=ks,d.Gamepads=es,d.GarbageCollector=ma,d.Gif=ic,d.GifParser=xa,d.GlobalCoordinates=Be,d.GpuParticleEmitter=Nl,d.GpuParticleRenderer=as,d.Graph=ms,d.Graphic=it,d.GraphicsComponent=j,d.GraphicsGroup=Ne,d.GraphicsSystem=fn,d.HashColliderProxy=Eo,d.HashGridCell=Yt,d.HashGridProxy=In,d.HiddenEvent=Hs,d.HorizontalFirst=en,d.ImageFiltering=mt,d.ImageSource=Gt,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Ue,d.InputHost=Yn,d.InputMapper=ta,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Wn,d.IsometricMap=Rl,d.IsometricTile=Go,d.KeyEvent=wi,d.Keyboard=ra,d.Keys=na,d.KillEvent=Ai,d.Label=Ol,d.LimitCameraBoundsStrategy=Zo,d.Line=_n,d.LineSegment=J,d.Loader=Ji,d.LoaderEvents=Tl,d.LockCameraToActorAxisStrategy=Yo,d.LockCameraToActorStrategy=Xo,d.LogLevel=Le,d.Logger=R,d.Material=Qr,d.Matrix=yt,d.MatrixLocations=lr,d.MediaEvent=zn,d.Meet=$i,d.MotionComponent=U,d.MotionSystem=ji,d.MoveBy=Tn,d.MoveByWithOptions=so,d.MoveTo=Pn,d.MoveToWithOptions=ro,d.NativePointerButton=Pe,d.NativeSoundEvent=Te,d.NativeSoundProcessedEvent=Bo,d.NineSlice=mn,d.NineSliceStretch=zr,d.Node=Si,d.None=sn,d.Observable=gt,d.OffscreenSystem=gn,d.Pair=pt,d.ParallaxComponent=Wi,d.ParallelActions=Wl,d.Particle=Yi,d.ParticleEmitter=Hl,d.ParticleRenderer=$r,d.ParticleTransform=Vt,d.PhysicsStats=ns,d.PhysicsWorld=Ro,d.PointerAbstraction=Xn,d.PointerButton=le,d.PointerComponent=ae,d.PointerEvent=xi,d.PointerEventReceiver=ss,d.PointerScope=Fe,d.PointerSystem=ts,d.PointerType=ce,d.Polygon=pn,d.PolygonCollider=lt,d.Pool=zi,d.PositionNode=ur,d.PostCollisionEvent=ve,d.PostDebugDrawEvent=Ds,d.PostDrawEvent=ze,d.PostFrameEvent=Bs,d.PostKillEvent=Ps,d.PostTransformDrawEvent=Rs,d.PostUpdateEvent=re,d.PreCollisionEvent=me,d.PreDebugDrawEvent=Ms,d.PreDrawEvent=ke,d.PreFrameEvent=Fs,d.PreKillEvent=Ts,d.PreLoadEvent=Ll,d.PreTransformDrawEvent=Is,d.PreUpdateEvent=ne,d.Projection=ti,d.QuadIndexBuffer=ui,d.QuadTree=Ze,d.Query=Bt,d.QueryManager=Sr,d.RadiusAroundActorStrategy=jo,d.Random=ie,d.Raster=We,d.Ray=fe,d.RealisticSolver=Fn,d.Rectangle=di,d.RemoveEvent=Zs,d.RemovedComponent=yh,d.RentalPool=Ve,d.Repeat=to,d.RepeatForever=eo,d.Resolution=Bn,d.Resource=hi,d.ResourceEvents=kh,d.RotateBy=lo,d.RotateByWithOptions=ho,d.RotateTo=ao,d.RotateToWithOptions=oo,d.RotationType=Z,d.ScaleBy=po,d.ScaleByWithOptions=go,d.ScaleTo=_o,d.ScaleToWithOptions=uo,d.Scene=Rt,d.SceneEvents=kl,d.Screen=Ln,d.ScreenAppender=pr,d.ScreenElement=Hn,d.ScreenEvents=xl,d.ScreenShader=jr,d.ScrollPreventionMode=Qe,d.Semaphore=_c,d.SeparatingAxis=He,d.SeparationInfo=Rr,d.Shader=Ut,d.Shape=ut,d.Slide=hc,d.SolverStrategy=ki,d.Sound=Un,d.SoundEvents=Cl,d.SoundManager=ec,d.SparseHashGrid=Rn,d.SparseHashGridCollisionProcessor=Mn,d.SpatialPartitionStrategy=ai,d.Sprite=kt,d.SpriteFont=Oi,d.SpriteSheet=be,d.StandardClock=Zn,d.StateMachine=Qi,d.StrategyContainer=Vo,d.Stream=wa,d.System=At,d.SystemManager=Pr,d.SystemPriority=Nt,d.SystemType=Pt,d.TagQuery=Qs,d.TestClock=da,d.Text=_i,d.TextAlign=on,d.TextureLoader=qe,d.Tile=Wo,d.TileMap=No,d.TileMapEvents=Il,d.TiledAnimation=vn,d.TiledSprite=ci,d.Timer=Ki,d.Toaster=ua,d.Transform=Qt,d.TransformComponent=A,d.Transition=ls,d.TreeNode=Js,d.Trigger=Jo,d.TriggerEvents=Dl,d.TwoPI=et,d.UniformBuffer=Hr,d.Util=lc,d.Vector=v,d.VectorView=gs,d.VertexBuffer=qt,d.VertexLayout=Kt,d.VerticalFirst=tn,d.VisibleEvent=Os,d.WebAudio=Do,d.WebAudioInstance=Fo,d.WheelDeltaMode=bi,d.WheelEvent=oa,d.World=Ar,d.approximatelyEqual=or,d.assert=Jn,d.canonicalizeAngle=Zt,d.clamp=B,d.coroutine=Ca,d.createId=_e,d.easeInBack=ch,d.easeInBounce=fr,d.easeInCirc=ah,d.easeInCubic=Za,d.easeInElastic=_h,d.easeInExpo=nh,d.easeInOutBack=uh,d.easeInOutBounce=ph,d.easeInOutCirc=lh,d.easeInOutCubic=xs,d.easeInOutElastic=gh,d.easeInOutExpo=oh,d.easeInOutQuad=ja,d.easeInOutQuart=th,d.easeInOutQuint=sh,d.easeInOutSine=Xa,d.easeInQuad=Ya,d.easeInQuart=Ja,d.easeInQuint=eh,d.easeInSine=Va,d.easeOutBack=dh,d.easeOutBounce=bs,d.easeOutCirc=hh,d.easeOutCubic=Qa,d.easeOutElastic=fh,d.easeOutExpo=rh,d.easeOutQuad=$a,d.easeOutQuart=Ka,d.easeOutQuint=ih,d.easeOutSine=qa,d.frac=za,d.getDefaultPhysicsConfig=Jt,d.glTypeToUniformTypeName=qr,d.hasGraphicsTick=Sn,d.hasOnAdd=Ql,d.hasOnInitialize=Xl,d.hasOnPostUpdate=Zl,d.hasOnPreUpdate=$l,d.hasOnRemove=Jl,d.hasPostDraw=tc,d.hasPreDraw=Kl,d.has_add=Vl,d.has_initialize=Gl,d.has_postupdate=jl,d.has_preupdate=Yl,d.has_remove=ql,d.inverseLerp=cr,d.inverseLerpVector=dr,d.isActor=vl,d.isAddedComponent=bh,d.isComponentCtor=mr,d.isLegacyEasing=Se,d.isLoaderConstructor=On,d.isMoveByOptions=io,d.isMoveToOptions=no,d.isRemovedComponent=Ch,d.isRotateByOptions=ml,d.isRotateToOptions=pl,d.isScaleByOptions=fo,d.isScaleToOptions=co,d.isSceneConstructor=$t,d.isScreenElement=Uo,d.isSystemConstructor=Tr,d.lerp=ot,d.lerpAngle=ps,d.lerpVector=ei,d.linear=Ti,d.maxMessages=Sa,d.nextActionId=H,d.obsolete=dc,d.parseImageFiltering=Ge,d.parseImageWrapping=zt,d.pixelSnapEpsilon=L,d.randomInRange=Ot,d.randomIntInRange=Ha,d.range=Oa,d.remap=Ht,d.remapVector=Na,d.resetObsoleteCounter=cc,d.sign=G,d.smootherstep=Ga,d.smoothstep=Wa,d.toDegrees=ar,d.toRadians=Ua,d.vec=b,d.webgl=Gh,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
820
|
+
`,Function.prototype.toString.call(g)):(u=!0,x(c.clock.elapsed())),w),generator:p,done:m,then:m.then.bind(m),[Symbol.iterator]:()=>p};return w}class ls extends Tt{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new A,this.graphics=new j,this._completeFuture=new wt,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=t.duration,Se(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:It.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ti,this.direction=(s=t.direction)!=null?s:"out",this.hideLoader=(n=t.hideLoader)!=null?n:!1,this.blockInput=(o=t.blockInput)!=null?o:!1,this.transform.coordPlane=rt.Screen,this.transform.pos=v.Zero,this.transform.z=1/0,this.graphics.anchor=v.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction==="out"?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction==="out"?this.progress>=1:this.progress<=0}updateTransition(t,e){this.complete||(this._currentDistance+=B(e/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction==="out"?this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=B(ot(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=B(ot(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(t){}onStart(t){}onUpdate(t){}onEnd(t){}onReset(){}reset(){this.started=!1,this._completeFuture=new wt,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction==="out"?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(t,e){const i=e;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),i.world.entityManager.getById(this.id))return this._co;this._engine=t,i.add(this);const s=this;return this._co=Ca(t,function*(){for(;!s.complete;){const n=yield;s.updateTransition(s._engine,n),s._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}}class oc extends ls{constructor(t){var e,i;super({...t,duration:(e=t.duration)!=null?e:2e3}),this.name=`FadeInOut#${this.id}`,this.color=(i=t.color)!=null?i:P.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new di({width:t.screen.resolution.width,height:t.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=t}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class ac extends ls{constructor(t){super({direction:"in",...t}),this.name=`CrossFade#${this.id}`}async onPreviousSceneDeactivate(t){this.image=await t.engine.screenshot(!0),await this.image.decode()}onInitialize(t){this.engine=t,this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=Gt.fromHtmlImageElement(this.image).toSprite(),this.graphics.add(this.screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio),this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class hc extends ls{constructor(t){var e;super({direction:"in",...t}),this._easing=It.Linear,this._start=v.Zero,this._end=v.Zero,this.name=`Slide#${this.id}`,this.slideDirection=t.slideDirection,this.transform.coordPlane=rt.Screen,this.graphics.forceOnScreen=!0,this._easing=(e=t.easingFunction)!=null?e:this._easing}async onPreviousSceneDeactivate(t){this._image=await t.engine.screenshot(!0),await this._image.decode(),this._screenCover=Gt.fromHtmlImageElement(this._image).toSprite()}onInitialize(t){this._engine=t;let e=t.screen.unsafeArea;switch(e.hasZeroDimensions()&&(e=t.screen.contentArea),this.slideDirection){case"up":{this._directionOffset=b(0,-e.height);break}case"down":{this._directionOffset=b(0,e.height);break}case"left":{this._directionOffset=b(-e.width,0);break}case"right":{this._directionOffset=b(e.width,0);break}}this._camera=this._engine.currentScene.camera,this._destinationCameraPosition=this._camera.pos.clone(),this._camera.pos=this._camera.pos.add(this._directionOffset),this.transform.pos=this.transform.pos.add(this._directionOffset),this._startCameraPosition=this._camera.pos.clone(),this._start=e.topLeft,this._end=this._start.add(this._directionOffset),this.transform.pos=this._start,this.graphics.use(this._screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio)}onStart(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}onUpdate(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}}const lc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:ys,DrawUtil:Fh,EasingFunctions:It,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:pr,addItemToArray:wh,contains:wr,delay:Di,fail:xr,getMinIndex:vr,getPosition:ri,isLegacyEasing:Se,isObject:Fi,mergeDeep:Bi,omit:br,removeItemFromArray:Oe},Symbol.toStringTag,{value:"Module"})),Sa=5,Je={},cc=()=>{for(const r in Je)Je[r]=0},cs=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");Je[r]<Sa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),Je[r]++};function dc(r){return r={message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrace:!1,...r},function(t,e,i){if(i&&!(typeof i.value=="function"||typeof i.get=="function"||typeof i.set=="function"))throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${t.name||""}${t.name&&e?".":""}${e||""}`} is marked obsolete: ${r.message}`+(r.alternateMethod?` Use ${r.alternateMethod} instead`:"");Je[n]||(Je[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){cs(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return cs(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return cs(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return cs(n,r),i.set.apply(this,arguments)}),o)}}class uc{constructor(){this._queue=[]}get length(){return this._queue.length}enqueue(){const t=new wt;return this._queue.push(t),t.promise}dequeue(t){this._queue.shift().resolve(t)}}class _c{constructor(t){this._count=t,this._waitQueue=new uc}get count(){return this._count}get waiting(){return this._waitQueue.length}async enter(){return this._count!==0?(this._count--,Promise.resolve()):this._waitQueue.enqueue()}exit(t=1){if(t!==0){for(;t!==0&&this._waitQueue.length!==0;)this._waitQueue.dequeue(null),t--;this._count+=t}}}const er="0.32.0-alpha.1562+c143e37";Me(),d.ActionCompleteEvent=$s,d.ActionContext=fi,d.ActionQueue=Kr,d.ActionSequence=Kn,d.ActionStartEvent=Ys,d.ActionsComponent=je,d.ActionsSystem=Vn,d.ActivateEvent=Ns,d.Actor=Ft,d.ActorEvents=wl,d.AddEvent=js,d.AddedComponent=xh,d.AffineMatrix=Q,d.Animation=Ui,d.AnimationDirection=Fr,d.AnimationEvents=Ih,d.AnimationStrategy=Br,d.ArcadeSolver=Dn,d.AudioContextFactory=pi,d.Axes=Ko,d.Axis=qo,d.BaseAlign=an,d.BezierCurve=ii,d.Blink=xo,d.BodyComponent=N,d.BoundingBox=D,d.BrowserComponent=$n,d.BrowserEvents=la,d.Buttons=qn,d.Camera=Qo,d.CameraEvents=Ml,d.Canvas=qi,d.ChannelCollection=va,d.Circle=Vi,d.CircleCollider=dt,d.Clock=jn,d.ClosestLineJumpTable=Wt,d.Collider=oi,d.ColliderComponent=tt,d.CollisionContact=we,d.CollisionEndEvent=ni,d.CollisionGroup=pe,d.CollisionGroupManager=Pi,d.CollisionJumpTable=Lt,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=si,d.CollisionSystem=Zi,d.CollisionType=M,d.Color=P,d.ColorBlindFlags=aa,d.ColorBlindnessMode=Ye,d.ColorBlindnessPostProcessor=Zr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=ys,d.ContactConstraintPoint=Io,d.ContactEndEvent=Ii,d.ContactSolveBias=oe,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=ac,d.CurveBy=Po,d.CurveTo=To,d.DeactivateEvent=Ws,d.Debug=Cn,d.DebugConfig=ha,d.DebugGraphicsComponent=Ni,d.DebugSystem=Gn,d.DebugText=un,d.DefaultAntialiasOptions=Ur,d.DefaultGarbageCollectionOptions=Qn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Or,d.DegreeOfFreedom=he,d.Delay=yo,d.Detector=zo,d.Die=Co,d.Direction=ln,d.Director=fa,d.DirectorEvents=_a,d.DisplayMode=gi,d.DynamicTree=Ks,d.DynamicTreeCollisionProcessor=Li,d.EX_VERSION=er,d.EaseBy=wo,d.EaseTo=vo,d.EasingFunctions=It,d.Edge=vs,d.EdgeCollider=Ct,d.ElasticToActorStrategy=$o,d.EmitterType=Ae,d.Engine=os,d.EngineEvents=Ul,d.EnterTriggerEvent=qs,d.EnterViewPortEvent=Vs,d.Entity=Tt,d.EntityEvents=Sh,d.EntityManager=Cr,d.EventEmitter=X,d.EventTypes=Ss,d.Events=vh,d.ExResponse=kn,d.ExcaliburGraphicsContext2DCanvas=Xi,d.ExcaliburGraphicsContextWebGL=Xt,d.ExitTriggerEvent=Xs,d.ExitViewPortEvent=Gs,d.Fade=bo,d.FadeInOut=oc,d.Flags=De,d.Flash=So,d.Follow=An,d.Font=Ce,d.FontCache=Gi,d.FontSource=nc,d.FontStyle=hn,d.FontUnit=rn,d.FpsSampler=ca,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=As,d.GameStopEvent=Es,d.Gamepad=is,d.GamepadAxisEvent=Us,d.GamepadButtonEvent=zs,d.GamepadConnectEvent=Ls,d.GamepadDisconnectEvent=ks,d.Gamepads=es,d.GarbageCollector=ma,d.Gif=ic,d.GifParser=xa,d.GlobalCoordinates=Be,d.GpuParticleEmitter=Nl,d.GpuParticleRenderer=as,d.Graph=ms,d.Graphic=it,d.GraphicsComponent=j,d.GraphicsGroup=Ne,d.GraphicsSystem=fn,d.HashColliderProxy=Eo,d.HashGridCell=Yt,d.HashGridProxy=In,d.HiddenEvent=Hs,d.HorizontalFirst=en,d.ImageFiltering=mt,d.ImageSource=Gt,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Ue,d.InputHost=Yn,d.InputMapper=ta,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Wn,d.IsometricMap=Rl,d.IsometricTile=Go,d.KeyEvent=wi,d.Keyboard=ra,d.Keys=na,d.KillEvent=Ai,d.Label=Ol,d.LimitCameraBoundsStrategy=Zo,d.Line=_n,d.LineSegment=J,d.Loader=Ji,d.LoaderEvents=Tl,d.LockCameraToActorAxisStrategy=Yo,d.LockCameraToActorStrategy=Xo,d.LogLevel=Le,d.Logger=R,d.Material=Qr,d.Matrix=yt,d.MatrixLocations=lr,d.MediaEvent=zn,d.Meet=$i,d.MotionComponent=U,d.MotionSystem=ji,d.MoveBy=Tn,d.MoveByWithOptions=so,d.MoveTo=Pn,d.MoveToWithOptions=ro,d.NativePointerButton=Pe,d.NativeSoundEvent=Te,d.NativeSoundProcessedEvent=Bo,d.NineSlice=mn,d.NineSliceStretch=zr,d.Node=Si,d.None=sn,d.Observable=gt,d.OffscreenSystem=gn,d.Pair=pt,d.ParallaxComponent=Wi,d.ParallelActions=Wl,d.Particle=Yi,d.ParticleEmitter=Hl,d.ParticleRenderer=$r,d.ParticleTransform=Vt,d.PhysicsStats=ns,d.PhysicsWorld=Ro,d.PointerAbstraction=Xn,d.PointerButton=le,d.PointerComponent=ae,d.PointerEvent=xi,d.PointerEventReceiver=ss,d.PointerScope=Fe,d.PointerSystem=ts,d.PointerType=ce,d.Polygon=pn,d.PolygonCollider=lt,d.Pool=zi,d.PositionNode=ur,d.PostCollisionEvent=ve,d.PostDebugDrawEvent=Ds,d.PostDrawEvent=ze,d.PostFrameEvent=Bs,d.PostKillEvent=Ps,d.PostTransformDrawEvent=Rs,d.PostUpdateEvent=re,d.PreCollisionEvent=me,d.PreDebugDrawEvent=Ms,d.PreDrawEvent=ke,d.PreFrameEvent=Fs,d.PreKillEvent=Ts,d.PreLoadEvent=Ll,d.PreTransformDrawEvent=Is,d.PreUpdateEvent=ne,d.Projection=ti,d.QuadIndexBuffer=ui,d.QuadTree=Ze,d.Query=Bt,d.QueryManager=Sr,d.RadiusAroundActorStrategy=jo,d.Random=ie,d.Raster=We,d.Ray=fe,d.RealisticSolver=Fn,d.Rectangle=di,d.RemoveEvent=Zs,d.RemovedComponent=yh,d.RentalPool=Ve,d.Repeat=to,d.RepeatForever=eo,d.Resolution=Bn,d.Resource=hi,d.ResourceEvents=kh,d.RotateBy=lo,d.RotateByWithOptions=ho,d.RotateTo=ao,d.RotateToWithOptions=oo,d.RotationType=Z,d.ScaleBy=po,d.ScaleByWithOptions=go,d.ScaleTo=_o,d.ScaleToWithOptions=uo,d.Scene=Rt,d.SceneEvents=kl,d.Screen=Ln,d.ScreenAppender=pr,d.ScreenElement=Hn,d.ScreenEvents=xl,d.ScreenShader=jr,d.ScrollPreventionMode=Qe,d.Semaphore=_c,d.SeparatingAxis=He,d.SeparationInfo=Rr,d.Shader=Ut,d.Shape=ut,d.Slide=hc,d.SolverStrategy=ki,d.Sound=Un,d.SoundEvents=Cl,d.SoundManager=ec,d.SparseHashGrid=Rn,d.SparseHashGridCollisionProcessor=Mn,d.SpatialPartitionStrategy=ai,d.Sprite=kt,d.SpriteFont=Oi,d.SpriteSheet=be,d.StandardClock=Zn,d.StateMachine=Qi,d.StrategyContainer=Vo,d.Stream=wa,d.System=At,d.SystemManager=Pr,d.SystemPriority=Nt,d.SystemType=Pt,d.TagQuery=Qs,d.TestClock=da,d.Text=_i,d.TextAlign=on,d.TextureLoader=qe,d.Tile=Wo,d.TileMap=No,d.TileMapEvents=Il,d.TiledAnimation=vn,d.TiledSprite=ci,d.Timer=Ki,d.Toaster=ua,d.Transform=Qt,d.TransformComponent=A,d.Transition=ls,d.TreeNode=Js,d.Trigger=Jo,d.TriggerEvents=Dl,d.TwoPI=et,d.UniformBuffer=Hr,d.Util=lc,d.Vector=v,d.VectorView=gs,d.VertexBuffer=qt,d.VertexLayout=Kt,d.VerticalFirst=tn,d.VisibleEvent=Os,d.WebAudio=Do,d.WebAudioInstance=Fo,d.WheelDeltaMode=bi,d.WheelEvent=oa,d.World=Ar,d.approximatelyEqual=or,d.assert=Jn,d.canonicalizeAngle=Zt,d.clamp=B,d.coroutine=Ca,d.createId=_e,d.easeInBack=ch,d.easeInBounce=fr,d.easeInCirc=ah,d.easeInCubic=Za,d.easeInElastic=_h,d.easeInExpo=nh,d.easeInOutBack=uh,d.easeInOutBounce=ph,d.easeInOutCirc=lh,d.easeInOutCubic=xs,d.easeInOutElastic=gh,d.easeInOutExpo=oh,d.easeInOutQuad=ja,d.easeInOutQuart=th,d.easeInOutQuint=sh,d.easeInOutSine=Xa,d.easeInQuad=Ya,d.easeInQuart=Ja,d.easeInQuint=eh,d.easeInSine=Va,d.easeOutBack=dh,d.easeOutBounce=bs,d.easeOutCirc=hh,d.easeOutCubic=Qa,d.easeOutElastic=fh,d.easeOutExpo=rh,d.easeOutQuad=$a,d.easeOutQuart=Ka,d.easeOutQuint=ih,d.easeOutSine=qa,d.frac=za,d.getDefaultPhysicsConfig=Jt,d.glTypeToUniformTypeName=qr,d.hasGraphicsTick=Sn,d.hasOnAdd=Ql,d.hasOnInitialize=Xl,d.hasOnPostUpdate=Zl,d.hasOnPreUpdate=$l,d.hasOnRemove=Jl,d.hasPostDraw=tc,d.hasPreDraw=Kl,d.has_add=Vl,d.has_initialize=Gl,d.has_postupdate=jl,d.has_preupdate=Yl,d.has_remove=ql,d.inverseLerp=cr,d.inverseLerpVector=dr,d.isActor=vl,d.isAddedComponent=bh,d.isComponentCtor=mr,d.isLegacyEasing=Se,d.isLoaderConstructor=On,d.isMoveByOptions=io,d.isMoveToOptions=no,d.isRemovedComponent=Ch,d.isRotateByOptions=ml,d.isRotateToOptions=pl,d.isScaleByOptions=fo,d.isScaleToOptions=co,d.isSceneConstructor=$t,d.isScreenElement=Uo,d.isSystemConstructor=Tr,d.lerp=ot,d.lerpAngle=ps,d.lerpVector=ei,d.linear=Ti,d.maxMessages=Sa,d.nextActionId=H,d.obsolete=dc,d.parseImageFiltering=Ge,d.parseImageWrapping=zt,d.pixelSnapEpsilon=L,d.randomInRange=Ot,d.randomIntInRange=Ha,d.range=Oa,d.remap=Ht,d.remapVector=Na,d.resetObsoleteCounter=cc,d.sign=G,d.smootherstep=Ga,d.smoothstep=Wa,d.toDegrees=ar,d.toRadians=Ua,d.vec=b,d.webgl=Gh,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|