excalibur 0.32.0-alpha.1596 → 0.32.0-alpha.1598
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/excalibur.development.js +14 -6
- package/build/dist/excalibur.js +14 -6
- package/build/dist/excalibur.min.development.js +3 -3
- package/build/dist/excalibur.min.js +3 -3
- package/build/esm/excalibur.development.js +14 -6
- package/build/esm/excalibur.js +14 -6
- package/build/esm/excalibur.min.development.js +9 -7
- package/build/esm/excalibur.min.js +9 -7
- package/package.json +1 -1
- package/playground/index.html +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -91,6 +91,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
91
91
|
|
|
92
92
|
### Fixed
|
|
93
93
|
|
|
94
|
+
- Fixed issue where Animation fromSpriteSheet was ignoring repeated sprite sheet indices
|
|
94
95
|
- Fixed issue where setting the width/height of a ScreenElement was incorrectly scaled when supplied with a scale in the ctor
|
|
95
96
|
- Fixed issue where onRemove would sometimes not be called
|
|
96
97
|
- Fixed issue where pointer containment WAS NOT being uses on collision shape geometry, only their bounds
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1598+97bb68b - 2025-12-15
|
|
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
|
|
@@ -9567,15 +9567,23 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
|
|
|
9567
9567
|
*/
|
|
9568
9568
|
static fromSpriteSheet(spriteSheet, spriteSheetIndex, durationPerFrame, strategy = "loop", data) {
|
|
9569
9569
|
const maxIndex = spriteSheet.sprites.length - 1;
|
|
9570
|
-
const
|
|
9570
|
+
const validIndices = [];
|
|
9571
|
+
const invalidIndices = [];
|
|
9572
|
+
spriteSheetIndex.forEach((index) => {
|
|
9573
|
+
if (index < 0 || index > maxIndex) {
|
|
9574
|
+
invalidIndices.push(index);
|
|
9575
|
+
} else {
|
|
9576
|
+
validIndices.push(index);
|
|
9577
|
+
}
|
|
9578
|
+
});
|
|
9571
9579
|
if (invalidIndices.length) {
|
|
9572
9580
|
_Animation2._LOGGER.warn(
|
|
9573
|
-
`Indices into SpriteSheet were provided that don't exist: ${invalidIndices.join(",")}
|
|
9581
|
+
`Indices into SpriteSheet were provided that don't exist: frames ${invalidIndices.join(",")} will not be shown`
|
|
9574
9582
|
);
|
|
9575
9583
|
}
|
|
9576
9584
|
return new this({
|
|
9577
|
-
frames:
|
|
9578
|
-
graphic:
|
|
9585
|
+
frames: validIndices.map((validIndex) => ({
|
|
9586
|
+
graphic: spriteSheet.sprites[validIndex],
|
|
9579
9587
|
duration: durationPerFrame
|
|
9580
9588
|
})),
|
|
9581
9589
|
strategy,
|
|
@@ -33594,7 +33602,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33594
33602
|
this._count += count;
|
|
33595
33603
|
}
|
|
33596
33604
|
}
|
|
33597
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33605
|
+
const EX_VERSION = "0.32.0-alpha.1598+97bb68b";
|
|
33598
33606
|
polyfill();
|
|
33599
33607
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33600
33608
|
exports2.ActionContext = ActionContext;
|
package/build/dist/excalibur.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1598+97bb68b - 2025-12-15
|
|
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
|
|
@@ -9567,15 +9567,23 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
|
|
|
9567
9567
|
*/
|
|
9568
9568
|
static fromSpriteSheet(spriteSheet, spriteSheetIndex, durationPerFrame, strategy = "loop", data) {
|
|
9569
9569
|
const maxIndex = spriteSheet.sprites.length - 1;
|
|
9570
|
-
const
|
|
9570
|
+
const validIndices = [];
|
|
9571
|
+
const invalidIndices = [];
|
|
9572
|
+
spriteSheetIndex.forEach((index) => {
|
|
9573
|
+
if (index < 0 || index > maxIndex) {
|
|
9574
|
+
invalidIndices.push(index);
|
|
9575
|
+
} else {
|
|
9576
|
+
validIndices.push(index);
|
|
9577
|
+
}
|
|
9578
|
+
});
|
|
9571
9579
|
if (invalidIndices.length) {
|
|
9572
9580
|
_Animation2._LOGGER.warn(
|
|
9573
|
-
`Indices into SpriteSheet were provided that don't exist: ${invalidIndices.join(",")}
|
|
9581
|
+
`Indices into SpriteSheet were provided that don't exist: frames ${invalidIndices.join(",")} will not be shown`
|
|
9574
9582
|
);
|
|
9575
9583
|
}
|
|
9576
9584
|
return new this({
|
|
9577
|
-
frames:
|
|
9578
|
-
graphic:
|
|
9585
|
+
frames: validIndices.map((validIndex) => ({
|
|
9586
|
+
graphic: spriteSheet.sprites[validIndex],
|
|
9579
9587
|
duration: durationPerFrame
|
|
9580
9588
|
})),
|
|
9581
9589
|
strategy,
|
|
@@ -33594,7 +33602,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33594
33602
|
this._count += count;
|
|
33595
33603
|
}
|
|
33596
33604
|
}
|
|
33597
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33605
|
+
const EX_VERSION = "0.32.0-alpha.1598+97bb68b";
|
|
33598
33606
|
polyfill();
|
|
33599
33607
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33600
33608
|
exports2.ActionContext = ActionContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1598+97bb68b - 2025-12-15
|
|
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
|
|
@@ -23,7 +23,7 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
|
|
|
23
23
|
|
|
24
24
|
If this looks like an Excalibur type, this can be caused by 2 versions of excalibur being included on the page.
|
|
25
25
|
|
|
26
|
-
Check your bundler settings to make sure this is not the case! Excalibur has ESM & UMD bundles be sure one 1 is loaded.`)}get entities(){return this.entityManager.entities}clearEntities(){this.entityManager.clear()}clearSystems(){this.systemManager.clear()}}d.Side=(r=>(r.None="None",r.Top="Top",r.Bottom="Bottom",r.Left="Left",r.Right="Right",r))(d.Side||{}),(r=>{function t(i){return i==="Top"?"Bottom":i==="Bottom"?"Top":i==="Left"?"Right":i==="Right"?"Left":"None"}r.getOpposite=t;function e(i){return Math.abs(i.x)>=Math.abs(i.y)?i.x<=0?"Left":"Right":i.y<=0?"Top":"Bottom"}r.fromDirection=e})(d.Side||(d.Side={}));const Ir=class vt{constructor(t=0,e=0,i=0,s=0){this._points=[],typeof t=="object"?(this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom):typeof t=="number"&&(this.left=t,this.top=e,this.right=i,this.bottom=s)}clone(t){const e=t||new vt(0,0,0,0);return e.left=this.left,e.right=this.right,e.top=this.top,e.bottom=this.bottom,e}reset(){this.left=0,this.top=0,this.bottom=0,this.right=0}static getSideFromIntersection(t){return t&&t?Math.abs(t.x)>Math.abs(t.y)?t.x<0?d.Side.Right:d.Side.Left:t.y<0?d.Side.Bottom:d.Side.Top:d.Side.None}static fromPoints(t){let e=1/0,i=1/0,s=-1/0,n=-1/0;for(let o=0;o<t.length;o++)t[o].x<e&&(e=t[o].x),t[o].x>s&&(s=t[o].x),t[o].y<i&&(i=t[o].y),t[o].y>n&&(n=t[o].y);return new vt(e,i,s,n)}static fromDimension(t,e,i=w.Half,s=w.Zero){return new vt(-t*i.x+s.x,-e*i.y+s.y,t-t*i.x+s.x,e-e*i.y+s.y)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}hasZeroDimensions(){return this.width===0||this.height===0}get center(){return new w((this.left+this.right)/2,(this.top+this.bottom)/2)}get topLeft(){return new w(this.left,this.top)}get bottomRight(){return new w(this.right,this.bottom)}get topRight(){return new w(this.right,this.top)}get bottomLeft(){return new w(this.left,this.bottom)}translate(t){return new vt(this.left+t.x,this.top+t.y,this.right+t.x,this.bottom+t.y)}rotate(t,e=w.Zero){const i=this.getPoints().map(s=>s.rotate(t,e));return vt.fromPoints(i)}scale(t,e=w.Zero){const i=this.translate(e);return new vt(i.left*t.x,i.top*t.y,i.right*t.x,i.bottom*t.y)}transform(t){const e=t.data[0]*this.left,i=t.data[1]*this.left,s=t.data[0]*this.right,n=t.data[1]*this.right,o=t.data[2]*this.top,a=t.data[3]*this.top,h=t.data[2]*this.bottom,l=t.data[3]*this.bottom,c=t.getPosition(),u=Math.min(e,s)+Math.min(o,h)+c.x,_=Math.min(i,n)+Math.min(a,l)+c.y,f=Math.max(e,s)+Math.max(o,h)+c.x,m=Math.max(i,n)+Math.max(a,l)+c.y;return new vt({left:u,top:_,right:f,bottom:m})}getPerimeter(){const t=this.width,e=this.height;return 2*(t+e)}getPoints(){return(this._left!==this.left||this._right!==this.right||this._top!==this.top||this._bottom!==this.bottom)&&(this._points.length=0,this._points.push(new w(this.left,this.top)),this._points.push(new w(this.right,this.top)),this._points.push(new w(this.right,this.bottom)),this._points.push(new w(this.left,this.bottom)),this._left=this.left,this._right=this.right,this._top=this.top,this._bottom=this.bottom),this._points}rayCast(t,e=1/0){let i,s;const n=t.dir.x===0?Number.MAX_VALUE:1/t.dir.x,o=t.dir.y===0?Number.MAX_VALUE:1/t.dir.y,a=(this.left-t.pos.x)*n,h=(this.right-t.pos.x)*n;s=Math.min(a,h),i=Math.max(a,h);const l=(this.top-t.pos.y)*o,c=(this.bottom-t.pos.y)*o;return s=Math.max(s,Math.min(l,c)),i=Math.min(i,Math.max(l,c)),i>=0&&i>=s&&s<e}rayCastTime(t,e=1/0){let i,s;const n=t.dir.x===0?Number.MAX_VALUE:1/t.dir.x,o=t.dir.y===0?Number.MAX_VALUE:1/t.dir.y,a=(this.left-t.pos.x)*n,h=(this.right-t.pos.x)*n;s=Math.min(a,h),i=Math.max(a,h);const l=(this.top-t.pos.y)*o,c=(this.bottom-t.pos.y)*o;return s=Math.max(s,Math.min(l,c)),i=Math.min(i,Math.max(l,c)),i>=0&&i>=s&&s<e?s:-1}contains(t){return t instanceof w?this.left<=t.x&&this.top<=t.y&&t.y<=this.bottom&&t.x<=this.right:t instanceof vt?this.left<=t.left&&this.top<=t.top&&t.bottom<=this.bottom&&t.right<=this.right:!1}combine(t,e){const i=e||new vt(0,0,0,0),s=Math.min(this.left,t.left),n=Math.min(this.top,t.top),o=Math.max(this.right,t.right),a=Math.max(this.bottom,t.bottom);return i.left=s,i.top=n,i.right=o,i.bottom=a,i}get dimensions(){return new w(this.width,this.height)}overlaps(t,e){const i=e||0;if(t.hasZeroDimensions())return this.contains(t);if(this.hasZeroDimensions())return t.contains(this);const s=this.combine(t);return s.width+i<t.width+this.width&&s.height+i<t.height+this.height}intersect(t){if(this.bottom<=t.top||t.bottom<=this.top||this.right<=t.left||t.right<=this.left)return null;const e=this.bottom-t.top;vt._SCRATCH_INTERSECT[0]=e;const i=t.bottom-this.top;vt._SCRATCH_INTERSECT[1]=i;const s=this.right-t.left;vt._SCRATCH_INTERSECT[2]=s;const n=t.right-this.left;vt._SCRATCH_INTERSECT[3]=n;const o=wr(vt._SCRATCH_INTERSECT);switch(o){case 0:return new w(0,-e);case 1:return new w(0,i);case 2:return new w(-s,0);case 3:return new w(n,0);default:const a=o;throw new Error(`Unreachable index: [${a}] on bounding box intersection!`)}}intersectWithSide(t){const e=this.intersect(t);return vt.getSideFromIntersection(e)}draw(t,e={color:T.Yellow}){t.debug.drawRect(this.left,this.top,this.width,this.height,e)}debug(t,e={color:T.Yellow}){t.debug.drawRect(this.left,this.top,this.width,this.height,e)}};Ir._SCRATCH_INTERSECT=[0,0,0,0];let F=Ir;class pt{constructor(t,e){this.colliderA=t,this.colliderB=e,this.id=null,this.id=pt.calculatePairHash(t.id,e.id)}static canCollide(t,e){var i,s;if(t.id===e.id||t.owner&&e.owner&&t.owner.id===e.owner.id||t.localBounds.hasZeroDimensions()||e.localBounds.hasZeroDimensions())return!1;const n=(i=t==null?void 0:t.owner)==null?void 0:i.get(N),o=(s=e==null?void 0:e.owner)==null?void 0:s.get(N);return!(!n||!o||!n.group.canCollide(o.group)||n.collisionType===M.Fixed&&o.collisionType===M.Fixed||o.collisionType===M.PreventCollision||n.collisionType===M.PreventCollision||!n.isActive||!o.isActive)}get canCollide(){const t=this.colliderA,e=this.colliderB;return pt.canCollide(t,e)}collide(){return this.colliderA.collide(this.colliderB)}hasCollider(t){return t===this.colliderA||t===this.colliderB}static calculatePairHash(t,e){return t.value<e.value?`#${t.value}+${e.value}`:`#${e.value}+${t.value}`}}class sn{constructor(t){this.parent=t,this.parent=t||null,this.data=null,this.bounds=new F,this.left=null,this.right=null,this.height=0}isLeaf(){return!this.left&&!this.right}}class nn{constructor(t,e=new F(-Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)){this._config=t,this.worldBounds=e,this.root=null,this.nodes={}}_insert(t){if(this.root===null){this.root=t,this.root.parent=null;return}const e=t.bounds;let i=this.root;for(;!i.isLeaf();){const a=i.left,h=i.right,l=i.bounds.getPerimeter(),u=i.bounds.combine(e).getPerimeter(),_=2*u,f=2*(u-l);let m=0;const p=e.combine(a.bounds);let x,v;a.isLeaf()?m=p.getPerimeter()+f:(v=a.bounds.getPerimeter(),x=p.getPerimeter(),m=x-v+f);let g=0;const y=e.combine(h.bounds);if(h.isLeaf()?g=y.getPerimeter()+f:(v=h.bounds.getPerimeter(),x=y.getPerimeter(),g=x-v+f),_<m&&_<g)break;m<g?i=a:i=h}const s=i.parent,n=new sn(s);n.bounds=e.combine(i.bounds),n.height=i.height+1,s!==null?(s.left===i?s.left=n:s.right=n,n.left=i,n.right=t,i.parent=n,t.parent=n):(n.left=i,n.right=t,i.parent=n,t.parent=n,this.root=n);let o=t.parent;for(;o;){if(o=this._balance(o),!o.left)throw new Error("Parent of current leaf cannot have a null left child"+o);if(!o.right)throw new Error("Parent of current leaf cannot have a null right child"+o);o.height=1+Math.max(o.left.height,o.right.height),o.bounds=o.left.bounds.combine(o.right.bounds),o=o.parent}}_remove(t){if(t===this.root){this.root=null;return}const e=t.parent,i=e.parent;let s;if(e.left===t?s=e.right:s=e.left,i){i.left===e?i.left=s:i.right=s,s.parent=i;let n=i;for(;n;)n=this._balance(n),n.bounds=n.left.bounds.combine(n.right.bounds),n.height=1+Math.max(n.left.height,n.right.height),n=n.parent}else this.root=s,s.parent=null}trackCollider(t){const e=new sn;e.data=t,e.bounds=t.bounds,e.bounds.left-=2,e.bounds.top-=2,e.bounds.right+=2,e.bounds.bottom+=2,this.nodes[t.id.value]=e,this._insert(e)}updateCollider(t){var e;const i=this.nodes[t.id.value];if(!i)return!1;const s=t.bounds;if(!this.worldBounds.contains(s))return R.getInstance().warn("Collider with id "+t.id.value+" is outside the world bounds and will no longer be tracked for physics"),this.untrackCollider(t),!1;if(i.bounds.contains(s))return!1;if(this._remove(i),s.left-=this._config.boundsPadding,s.top-=this._config.boundsPadding,s.right+=this._config.boundsPadding,s.bottom+=this._config.boundsPadding,t.owner){const n=(e=t.owner)==null?void 0:e.get(N);if(n){const o=n.vel.x*32/1e3*this._config.velocityMultiplier,a=n.vel.y*32/1e3*this._config.velocityMultiplier;o<0?s.left+=o:s.right+=o,a<0?s.top+=a:s.bottom+=a}}return i.bounds=s,this._insert(i),!0}untrackCollider(t){const e=this.nodes[t.id.value];e&&(this._remove(e),this.nodes[t.id.value]=null,delete this.nodes[t.id.value])}_balance(t){if(t===null)throw new Error("Cannot balance at null node");if(t.isLeaf()||t.height<2)return t;const e=t.left,i=t.right,s=t,n=e,o=i,a=e.left,h=e.right,l=i.left,c=i.right,u=o.height-n.height;if(u>1)return o.left=s,o.parent=s.parent,s.parent=o,o.parent?o.parent.left===s?o.parent.left=o:o.parent.right=o:this.root=o,l.height>c.height?(o.right=l,s.right=c,c.parent=s,s.bounds=n.bounds.combine(c.bounds),o.bounds=s.bounds.combine(l.bounds),s.height=1+Math.max(n.height,c.height),o.height=1+Math.max(s.height,l.height)):(o.right=c,s.right=l,l.parent=s,s.bounds=n.bounds.combine(l.bounds),o.bounds=s.bounds.combine(c.bounds),s.height=1+Math.max(n.height,l.height),o.height=1+Math.max(s.height,c.height)),o;if(u<-1){if(n.left=s,n.parent=s.parent,s.parent=n,n.parent)if(n.parent.left===s)n.parent.left=n;else{if(n.parent.right!==s)throw"Error rotating Dynamic Tree";n.parent.right=n}else this.root=n;return a.height>h.height?(n.right=a,s.left=h,h.parent=s,s.bounds=o.bounds.combine(h.bounds),n.bounds=s.bounds.combine(a.bounds),s.height=1+Math.max(o.height,h.height),n.height=1+Math.max(s.height,a.height)):(n.right=h,s.left=a,a.parent=s,s.bounds=o.bounds.combine(a.bounds),n.bounds=s.bounds.combine(h.bounds),s.height=1+Math.max(o.height,a.height),n.height=1+Math.max(s.height,h.height)),n}return t}getHeight(){return this.root===null?0:this.root.height}query(t,e){const i=t.bounds,s=n=>{if(n&&n.bounds.overlaps(i))if(n.isLeaf()&&n.data!==t){if(e.call(t,n.data))return!0}else return s(n.left)||s(n.right);return!1};s(this.root)}rayCastQuery(t,e=1/0,i){const s=n=>{if(n&&n.bounds.rayCast(t,e))if(n.isLeaf()){if(i.call(t,n.data))return!0}else return s(n.left)||s(n.right);return!1};s(this.root)}getNodes(){const t=e=>e?[e].concat(t(e.left),t(e.right)):[];return t(this.root)}debug(t){const e=i=>{i&&(i.isLeaf()?i.bounds.debug(t,{color:T.Green}):i.bounds.debug(t,{color:T.White}),i.left&&e(i.left),i.right&&e(i.right))};e(this.root)}}class ki{constructor(t){this._config=t,this._pairs=new Set,this._collisionPairCache=[],this._colliders=[],this._dynamicCollisionTree=new nn(t.dynamicTree)}getColliders(){return this._colliders}query(t){const e=[];return t instanceof F?this._dynamicCollisionTree.query({id:fe("collider",-1),owner:null,bounds:t},i=>(e.push(i),!1)):this._dynamicCollisionTree.query({id:fe("collider",-1),owner:null,bounds:new F(t.x,t.y,t.x,t.y)},i=>(e.push(i),!1)),e}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:me.All.category,c=(n=e==null?void 0:e.searchAllColliders)!=null?n:!1;return this._dynamicCollisionTree.rayCastQuery(t,a,u=>{const f=u.owner.get(N);if(e!=null&&e.ignoreCollisionGroupAll&&f.group===me.All)return!1;const m=(l&f.group.category)!==0;if(f!=null&&f.group&&!m)return!1;const p=u.rayCast(t,a);if(p){if(e!=null&&e.filter){if(e.filter(p)&&(o.push(p),!c))return!0}else if(o.push(p),!c)return!0}return!1}),o}track(t){if(!t){R.getInstance().warn("Cannot track null collider");return}if(t instanceof at){const e=t.getColliders();for(const i of e)i.owner=t.owner,this._colliders.push(i),this._dynamicCollisionTree.trackCollider(i)}else this._colliders.push(t),this._dynamicCollisionTree.trackCollider(t)}untrack(t){if(!t){R.getInstance().warn("Cannot untrack a null collider");return}if(t instanceof at){const e=t.getColliders();for(const i of e){const s=this._colliders.indexOf(i);s!==-1&&this._colliders.splice(s,1),this._dynamicCollisionTree.untrackCollider(i)}}else{const e=this._colliders.indexOf(t);e!==-1&&this._colliders.splice(e,1),this._dynamicCollisionTree.untrackCollider(t)}}_pairExists(t,e){const i=pt.calculatePairHash(t.id,e.id);return this._pairs.has(i)}broadphase(t,e,i){const s=e/1e3,n=t.filter(a=>{var h,l;const c=(h=a.owner)==null?void 0:h.get(N);return((l=a.owner)==null?void 0:l.isActive)&&c.collisionType!==M.PreventCollision});this._collisionPairCache=[],this._pairs.clear();let o;for(let a=0,h=n.length;a<h;a++)o=n[a],this._dynamicCollisionTree.query(o,l=>{if(!this._pairExists(o,l)&&pt.canCollide(o,l)){const c=new pt(o,l);this._pairs.add(c.id),this._collisionPairCache.push(c)}return!1});if(i&&(i.physics.pairs=this._collisionPairCache.length),this._config.continuous.checkForFastBodies)for(const a of n){const h=a.owner.get(N);if((h==null?void 0:h.collisionType)!==M.Active)continue;const l=h.vel.magnitude*s+h.acc.magnitude*.5*s*s,c=Math.min(a.bounds.height,a.bounds.width);if(this._config.continuous.disableMinimumSpeedForFastBody||l>c/2){i&&i.physics.fastBodies++;const u=h.globalPos.sub(h.oldPos),_=a.center,f=a.getFurthestPoint(h.vel),m=f.sub(u),p=new ge(m,h.vel);p.pos=p.pos.add(p.dir.scale(-2*this._config.continuous.surfaceEpsilon));let x,v=new w(1/0,1/0);if(this._dynamicCollisionTree.rayCastQuery(p,l+this._config.continuous.surfaceEpsilon*2,g=>{if(!this._pairExists(a,g)&&pt.canCollide(a,g)){const y=g.rayCast(p,l+this._config.continuous.surfaceEpsilon*10);if(y){const S=y.point.sub(m);S.magnitude<v.magnitude&&(v=S,x=g)}}return!1}),x&&w.isValid(v)){const g=new pt(a,x);this._pairs.has(g.id)||(this._pairs.add(g.id),this._collisionPairCache.push(g));const y=_.sub(f);h.globalPos=m.add(y).add(v).add(p.dir.scale(10*this._config.continuous.surfaceEpsilon)),a.update(h.transform.get()),i&&i.physics.fastBodyCollisions++}}}return this._collisionPairCache}narrowphase(t,e){let i=[];for(let s=0;s<t.length;s++){const n=t[s].collide();if(i=i.concat(n),e&&n.length>0)for(const o of n)e.physics.contacts.set(o.id,o)}return e&&(e.physics.collisions+=i.length),i}update(t){let e=0;const i=t.length;for(let s=0;s<i;s++)this._dynamicCollisionTree.updateCollider(t[s])&&e++;return e}debug(t){this._dynamicCollisionTree.debug(t)}}const Rr=class Ba{constructor(){this.id=fe("collider",Ba._ID++),this.composite=null,this.events=new X,this.offset=w.Zero}touching(t){const e=this.collide(t);return!!(e&&e.length>0)}};Rr._ID=0;let ai=Rr;var Li=(r=>(r.Arcade="arcade",r.Realistic="realistic",r))(Li||{}),ae=(r=>(r.None="none",r.VerticalFirst="vertical-first",r.HorizontalFirst="horizontal-first",r))(ae||{});const rn={vertical:1,horizontal:2},on={horizontal:1,vertical:2},an={horizontal:0,vertical:0};var hi=(r=>(r.DynamicTree="dynamic-tree",r.SparseHashGrid="sparse-hash-grid",r))(hi||{});const te=()=>({enabled:!0,integration:{onScreenOnly:!1},gravity:b(0,0).clone(),solver:Li.Arcade,substep:1,colliders:{compositeStrategy:"together"},continuous:{checkForFastBodies:!0,disableMinimumSpeedForFastBody:!1,surfaceEpsilon:.1},bodies:{canSleepByDefault:!1,sleepEpsilon:.07,wakeThreshold:.07*3,sleepBias:.9,defaultMass:10},spatialPartition:hi.SparseHashGrid,sparseHashGrid:{size:100},dynamicTree:{boundsPadding:5,velocityMultiplier:2},arcade:{contactSolveBias:ae.None},realistic:{contactSolveBias:ae.None,positionIterations:3,velocityIterations:8,slop:1,steeringFactor:.2,warmStart:!0}});class at extends ai{constructor(t){super(),this._collisionProcessor=new ki({...te()}),this._dynamicAABBTree=new nn({boundsPadding:5,velocityMultiplier:2}),this._colliders=[];for(const e of t)this.addCollider(e)}set compositeStrategy(t){this._compositeStrategy=t}get compositeStrategy(){return this._compositeStrategy}clearColliders(){this._colliders=[]}addCollider(t){let e;t instanceof at?(e=t.getColliders(),e.forEach(i=>i.offset.addEqual(t.offset))):e=[t];for(const i of e)i.events.pipe(this.events),i.composite=this,this._colliders.push(i),this._collisionProcessor.track(i),this._dynamicAABBTree.trackCollider(i)}removeCollider(t){t.events.pipe(this.events),t.composite=null,He(t,this._colliders),this._collisionProcessor.untrack(t),this._dynamicAABBTree.untrackCollider(t)}getColliders(){return this._colliders}get worldPos(){var t,e;return((e=(t=this._transform)==null?void 0:t.pos)!=null?e:w.Zero).add(this.offset)}get center(){var t,e;return((e=(t=this._transform)==null?void 0:t.pos)!=null?e:w.Zero).add(this.offset)}get bounds(){var t,e;const i=this.getColliders();return i.reduce((n,o)=>n.combine(o.bounds),(e=(t=i[0])==null?void 0:t.bounds)!=null?e:new F().translate(this.worldPos)).translate(this.offset)}get localBounds(){var t,e;const i=this.getColliders();return i.reduce((n,o)=>n.combine(o.localBounds),(e=(t=i[0])==null?void 0:t.localBounds)!=null?e:new F)}get axes(){const t=this.getColliders();let e=[];for(const i of t)e=e.concat(i.axes);return e}getFurthestPoint(t){const e=this.getColliders(),i=[];for(const o of e)i.push(o.getFurthestPoint(t));let s=i[0],n=-Number.MAX_VALUE;for(const o of i){const a=o.dot(t);a>n&&(s=o,n=a)}return s}getInertia(t){const e=this.getColliders();let i=0;for(const s of e)i+=s.getInertia(t);return i}collide(t){let e=[t];t instanceof at&&(e=t.getColliders());const i=[];for(const n of e)this._dynamicAABBTree.query(n,o=>(i.push(new pt(n,o)),!1));let s=[];for(const n of i)s=s.concat(n.collide());return s}getClosestLineBetween(t){const e=this.getColliders(),i=[];if(t instanceof at){const s=t.getColliders();for(const n of e)for(const o of s){const a=n.getClosestLineBetween(o);a&&i.push(a)}}else for(const s of e){const n=t.getClosestLineBetween(s);n&&i.push(n)}if(i.length){let s=i[0].getLength(),n=i[0];for(const o of i){const a=o.getLength();a<s&&(s=a,n=o)}return n}return null}contains(t){const e=this.getColliders();for(const i of e)if(i.contains(t))return!0;return!1}rayCast(t,e){const i=this.getColliders(),s=[];for(const n of i){const o=n.rayCast(t,e);o&&s.push(o)}if(s.length){let n=s[0],o=n.point.dot(t.dir);for(const a of s){const h=t.dir.dot(a.point);h<o&&(n=a,o=h)}return n}return null}project(t){const e=this.getColliders(),i=[];for(const s of e){const n=s.project(t);n&&i.push(n)}if(i.length){const s=new ei(i[0].min,i[0].max);for(const n of i)s.min=Math.min(n.min,s.min),s.max=Math.max(n.max,s.max);return s}return null}update(t){if(t){const e=this.getColliders();for(const i of e)i.owner=this.owner,i.update(t)}}debug(t,e,i){const s=this.getColliders();t.save(),t.translate(this.offset.x,this.offset.y);for(const n of s)n.debug(t,e,i);t.restore()}clone(){const t=new at(this._colliders.map(e=>e.clone()));return t.offset=this.offset.clone(),t}}function hn(r,t){const i=r.dir(),s=t.dir(),n=i.dot(i),o=s.dot(s);if(n<1e-9&&o<1e-9)return new J(r.begin,t.begin);if(n<1e-9){const x=B(s.dot(r.begin.sub(t.begin))/o,0,1),v=t.begin.add(s.scale(x));return new J(r.begin,v)}if(o<1e-9){const x=B(i.dot(t.begin.sub(r.begin))/n,0,1),v=r.begin.add(i.scale(x));return new J(v,t.begin)}const a=r.begin.sub(t.begin),h=n,l=o,c=s.dot(a),u=h*l-Math.pow(i.dot(s),2);let _=0,f=0;Math.abs(u)>1e-9?_=B((i.dot(s)*c-l*i.dot(a))/u,0,1):_=B(i.dot(a)/h,0,1),Math.abs(l)>1e-9?f=B((i.dot(s)*_+c)/l,0,1):f=0;const m=r.begin.add(i.scale(_)),p=t.begin.add(s.scale(f));return new J(m,p)}const qt={PolygonPolygonClosestLine(r,t){const e=r.getSides(),i=t.getSides();let s=Number.MAX_VALUE,n=null;for(let o=0;o<e.length;o++)for(let a=0;a<i.length;a++){const h=hn(e[o],i[a]),l=h.getLength();l<s&&(s=l,n=h)}return n},PolygonEdgeClosestLine(r,t){const i=t.worldPos.sub(r.worldPos),s=new ge(r.worldPos,i),n=r.rayCast(s).point.add(s.dir.scale(.1)),o=r.getClosestFace(n),a=t.asLine();return hn(o.face,a)},PolygonCircleClosestLine(r,t){const e=t.worldPos,i=e.sub(r.worldPos),s=new ge(r.worldPos,i.normalize()),n=r.rayCast(s).point.add(s.dir.scale(.1)),o=r.getClosestFace(n),a=o.face.begin,h=o.face.getEdge();let l=(h.x*(e.x-a.x)+h.y*(e.y-a.y))/(h.x*h.x+h.y*h.y);l>1?l=1:l<0&&(l=0);const c=Math.sqrt(Math.pow(a.x+h.x*l-e.x,2)+Math.pow(a.y+h.y*l-e.y,2))-t.radius,u=(a.x+h.x*l-e.x)*t.radius/(t.radius+c),_=(a.y+h.y*l-e.y)*t.radius/(t.radius+c);return new J(h.scale(l).add(a),new w(e.x+u,e.y+_))},CircleCircleClosestLine(r,t){const i=t.worldPos.sub(r.worldPos),n=r.worldPos.sub(t.worldPos),o=new ge(r.worldPos,i),a=new ge(t.worldPos,n),h=r.rayCast(o),l=t.rayCast(a);return new J(h.point,l.point)},CircleEdgeClosestLine(r,t){const e=r.worldPos,i=t.asLine(),s=i.begin,n=i.getEdge(),o=s,a=n;let h=(a.x*(e.x-o.x)+a.y*(e.y-o.y))/(a.x*a.x+a.y*a.y);h>1?h=1:h<0&&(h=0);const l=Math.sqrt(Math.pow(o.x+a.x*h-e.x,2)+Math.pow(o.y+a.y*h-e.y,2))-r.radius,c=(o.x+a.x*h-e.x)*r.radius/(r.radius+l),u=(o.y+a.y*h-e.y)*r.radius/(r.radius+l);return new J(a.scale(h).add(o),new w(e.x+c,e.y+u))},EdgeEdgeClosestLine(r,t){const e=r.asLine(),i=t.asLine();return hn(e,i)}};class dt extends ai{constructor(t){super(),this.offset=w.Zero,this._globalMatrix=j.identity(),this._localBoundsDirty=!0,this.offset=t.offset||w.Zero,this.radius=t.radius||0,this._globalMatrix.translate(this.offset.x,this.offset.y)}get worldPos(){return this._globalMatrix.getPosition()}get radius(){var t;if(this._radius)return this._radius;const e=this._transform,i=(t=e==null?void 0:e.globalScale)!=null?t:w.One;return this._radius=this._naturalRadius*Math.min(i.x,i.y)}set radius(t){var e;const i=this._transform,s=(e=i==null?void 0:i.globalScale)!=null?e:w.One;this._naturalRadius=t/Math.min(s.x,s.y),this._localBoundsDirty=!0,this._radius=t}clone(){return new dt({offset:this.offset.clone(),radius:this.radius})}get center(){return this._globalMatrix.getPosition()}contains(t){var e,i;return((i=(e=this._transform)==null?void 0:e.pos)!=null?i:this.offset).distance(t)<=this.radius}rayCast(t,e=1/0){var i,s;const n=this.center,o=t.dir,a=t.pos,h=n.sub(a),l=o.scale(h.dot(o)),u=h.sub(l).magnitude;if(u>this.radius)return null;{let _=0;if(ar(u,this.radius,1e-4)){if(_=-o.dot(a.sub(n)),_>0&&_<e){const f=t.getPoint(_);return{point:f,normal:f.sub(n).normalize(),collider:this,body:(i=this.owner)==null?void 0:i.get(N),distance:_}}return null}else{const f=Math.sqrt(Math.pow(o.dot(a.sub(n)),2)-Math.pow(a.sub(n).distance(),2)+Math.pow(this.radius,2)),m=-o.dot(a.sub(n))+f,p=-o.dot(a.sub(n))-f,x=[];m>=0&&x.push(m),p>=0&&x.push(p);const v=Math.min(...x);if(v<=e){const g=t.getPoint(v);return{point:g,normal:g.sub(n).normalize(),collider:this,body:(s=this.owner)==null?void 0:s.get(N),distance:v}}return null}}}getClosestLineBetween(t){if(t instanceof dt)return qt.CircleCircleClosestLine(this,t);if(t instanceof lt)return qt.PolygonCircleClosestLine(t,this).flip();if(t instanceof St)return qt.CircleEdgeClosestLine(this,t).flip();throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}collide(t){if(t instanceof dt)return zt.CollideCircleCircle(this,t);if(t instanceof lt)return zt.CollideCirclePolygon(this,t);if(t instanceof St)return zt.CollideCircleEdge(this,t);throw new Error(`Circle could not collide with unknown CollisionShape ${typeof t}`)}getFurthestPoint(t){return this.center.add(t.normalize().scale(this.radius))}getFurthestLocalPoint(t){return t.normalize().scale(this.radius)}get bounds(){return this.localBounds.transform(this._globalMatrix)}get localBounds(){return this._localBoundsDirty&&(this._localBounds=new F(-this._naturalRadius,-this._naturalRadius,+this._naturalRadius,+this._naturalRadius),this._localBoundsDirty=!1),this._localBounds}get axes(){return[]}getInertia(t){return t*this.radius*this.radius/2}update(t){var e;this._transform=t,((e=t.matrix)!=null?e:this._globalMatrix).clone(this._globalMatrix),this._globalMatrix.translate(this.offset.x,this.offset.y),this._radius=void 0}project(t){const e=[],s=this.center.dot(t);return e.push(s),e.push(s+this.radius),e.push(s-this.radius),new ei(Math.min.apply(Math,e),Math.max.apply(Math,e))}debug(t,e,i){var s,n,o,a;const{lineWidth:h}={lineWidth:1,...i},l=this._transform,c=(s=l==null?void 0:l.globalScale)!=null?s:w.One,u=(n=l==null?void 0:l.globalRotation)!=null?n:0,_=(o=l==null?void 0:l.globalPos)!=null?o:w.Zero;t.save(),t.translate(_.x,_.y),t.rotate(u),t.scale(c.x,c.y),t.debug.drawCircle((a=this.offset)!=null?a:w.Zero,this._naturalRadius,T.Transparent,e,h),t.restore()}}class xe{constructor(t,e,i,s,n,o,a,h){this._canceled=!1,this.bodyA=null,this.bodyB=null;var l,c,u,_,f,m;if(this.colliderA=t,this.colliderB=e,this.mtv=i,this.normal=s,this.tangent=n,this.points=o,this.localPoints=a,this.info=h,this.id=pt.calculatePairHash(t.id,e.id),t.composite||e.composite){const p=((l=t.composite)==null?void 0:l.compositeStrategy)==="separate"?t.id:(u=(c=t.composite)==null?void 0:c.id)!=null?u:t.id,x=((_=e.composite)==null?void 0:_.compositeStrategy)==="separate"?e.id:(m=(f=e.composite)==null?void 0:f.id)!=null?m:e.id;this.id+="|"+pt.calculatePairHash(p,x)}this.colliderA.owner&&(this.bodyA=this.colliderA.owner.get(N)),this.colliderB.owner&&(this.bodyB=this.colliderB.owner.get(N))}matchAwake(){const t=this.bodyA,e=this.bodyB;t&&e&&t.isSleeping!==e.isSleeping&&(t.isSleeping&&t.collisionType!==M.Fixed&&e.sleepMotion>=t.wakeThreshold&&(t.isSleeping=!1),e.isSleeping&&e.collisionType!==M.Fixed&&t.sleepMotion>=e.wakeThreshold&&(e.isSleeping=!1))}isCanceled(){return this._canceled}cancel(){this._canceled=!0}bias(t){if(t!==this.colliderA&&t!==this.colliderB)throw new Error("Collider must be either colliderA or colliderB from this contact");if(t===this.colliderA)return this;const e=this.colliderA,i=this.colliderB;return this.colliderB=e,this.colliderA=i,this.mtv=this.mtv.negate(),this.normal=this.normal.negate(),this.tangent=this.tangent.negate(),this}}class Ui{constructor(t,e,i=100){this.builder=t,this.recycler=e,this.maxObjects=i,this.totalAllocations=0,this.index=0,this.objects=[],this.disableWarnings=!1,this._logger=R.getInstance()}dispose(){this.objects.length=0}preallocate(){for(let t=0;t<this.maxObjects;t++)this.objects[t]=this.builder()}using(t){const e=t(this);return e?this.done(...e):this.done()}borrow(t){const e=this.get();t(e),this.index--}get(){return this.index===this.maxObjects&&(this.disableWarnings||this._logger.warn("Max pooled objects reached, possible memory leak? Doubling"),this.maxObjects=this.maxObjects*2),this.objects[this.index]?this.recycler?this.recycler(this.objects[this.index++]):this.objects[this.index++]:(this.totalAllocations++,this.objects[this.index++]=this.builder())}done(...t){this.index=0;for(const e of t){const i=this.objects.indexOf(e);this.objects[i]=this.builder(),this.totalAllocations++}return t}}class Mr{constructor(){this.axis=b(0,0),this.localAxis=b(0,0),this.side=new J(b(0,0),b(0,0)),this.localSide=new J(b(0,0),b(0,0)),this.point=b(0,0),this.localPoint=b(0,0)}}const be=class ie{static findPolygonPolygonSeparation(t,e){if(e.transform.matrix.determinant()===0)return ie.findPolygonPolygonSeparationDegenerate(t,e);let i=-Number.MAX_VALUE,s=-1,n;const o=e.transform.inverse.multiply(t.transform.matrix,ie._SCRATCH_MATRIX),a=o.getRotation(),h=t.normals,l=t.points,c=e.points;for(let f=0;f<l.length;f++){const m=h[f].rotate(a,ie._ZERO,ie._SCRATCH_NORMAL),p=o.multiply(l[f],ie._SCRATCH_POINT);let x=Number.MAX_VALUE,v;for(let g=0;g<c.length;g++){const y=m.dot(c[g].sub(p,ie._SCRATCH_SUB_POINT));y<x&&(x=y,v=c[g])}x>i&&(i=x,s=f,n=v)}const u=(s+1)%l.length,_=ie.SeparationPool.get();return _.collider=t,_.separation=i,i>0||(h[s].clone(_.localAxis),h[s].rotate(t.transform.rotation,ie._ZERO,_.axis),t.transform.matrix.multiply(l[s],_.side.begin),t.transform.matrix.multiply(l[u],_.side.end),e.transform.matrix.multiply(n,_.point),_.sideId=s,n.clone(_.localPoint),l[s].clone(_.localSide.begin),l[u].clone(_.localSide.end)),_}static findCirclePolygonSeparation(t,e){const i=e.axes,n=e.center.sub(t.worldPos),o=e.getFurthestPoint(n.negate());i.push(o.sub(t.worldPos).normalize());let a=Number.MAX_VALUE,h=null,l=-1;for(let c=0;c<i.length;c++){const u=e.project(i[c]),_=t.project(i[c]),f=u.getOverlap(_);if(f<=0)return null;f<a&&(a=f,h=i[c],l=c)}return l<0?null:h.normalize().scale(a)}static findPolygonPolygonSeparationDegenerate(t,e){let i=-Number.MAX_VALUE,s=null,n=null,o=-1,a=null;const h=t.getSides(),l=t.getLocalSides();for(let c=0;c<h.length;c++){const u=h[c],_=u.normal(),f=e.getFurthestPoint(_.negate()),m=u.distanceToPoint(f,!0);m>i&&(i=m,s=u,n=_,o=c,a=f)}return{collider:t,separation:n?i:99,axis:n,side:s,localSide:l[o],sideId:o,point:a,localPoint:n?e.getFurthestLocalPoint(n.negate()):null}}};be.SeparationPool=new Ui(()=>new Mr,r=>r,500),be._ZERO=b(0,0),be._SCRATCH_POINT=b(0,0),be._SCRATCH_SUB_POINT=b(0,0),be._SCRATCH_NORMAL=b(0,0),be._SCRATCH_MATRIX=j.identity();let Ne=be;Ne.SeparationPool.disableWarnings=!0;const Ih=w.Zero,Rh=w.Zero,Mh=j.identity(),zt={CollideCircleCircle(r,t){const e=r.worldPos,i=t.worldPos,s=r.radius+t.radius,n=e.distance(i);if(n>s)return[];const o=s-n,a=i.sub(e).normalize(),h=a.perpendicular(),l=a.scale(o),c=r.getFurthestPoint(a),u=r.getFurthestLocalPoint(a),_={collider:r,separation:o,axis:a,point:c};return[new xe(r,t,l,a,h,[c],[u],_)]},CollideCirclePolygon(r,t){var e,i;let s=Ne.findCirclePolygonSeparation(r,t);if(!s)return[];s=s.dot(t.center.sub(r.center))<0?s.negate():s;const o=r.getFurthestPoint(s),h=((i=(e=r.owner)==null?void 0:e.get(P))!=null?i:new P).applyInverse(o),l=s.normalize(),c={collider:r,separation:-s.magnitude,axis:l,point:o,localPoint:h,side:t.findSide(l.negate()),localSide:t.findLocalSide(l.negate())};return[new xe(r,t,s,l,l.perpendicular(),[o],[h],c)]},CollideCircleEdge(r,t){const e=r.center,i=t.asLine(),s=i.end.sub(i.begin),n=s.dot(i.end.sub(e)),o=s.dot(e.sub(i.begin)),a=t.asLine(),h=t.asLocalLine();if(o<=0){const v=i.begin.sub(e),g=v.dot(v);if(g>r.radius*r.radius)return[];const y=v.normalize(),S=r.radius-Math.sqrt(g),A={collider:r,separation:S,axis:y,point:a.begin,side:a,localSide:h};return[new xe(r,t,y.scale(S),y,y.perpendicular(),[a.begin],[h.begin],A)]}if(n<=0){const v=i.end.sub(e),g=v.dot(v);if(g>r.radius*r.radius)return[];const y=v.normalize(),S=r.radius-Math.sqrt(g),A={collider:r,separation:S,axis:y,point:a.end,side:a,localSide:h};return[new xe(r,t,y.scale(S),y,y.perpendicular(),[a.end],[h.end],A)]}const l=s.dot(s),c=i.begin.scale(n).add(i.end.scale(o)).scale(1/l),u=e.sub(c),_=u.dot(u);if(_>r.radius*r.radius)return[];let f=s.perpendicular();f.dot(e.sub(i.begin))<0&&(f.x=-f.x,f.y=-f.y),f=f.normalize();const m=r.radius-Math.sqrt(_),p=f.scale(m),x={collider:r,separation:m,axis:f,point:c,side:a,localSide:h};return[new xe(r,t,p,f.negate(),f.negate().perpendicular(),[c],[c.sub(t.worldPos)],x)]},CollideEdgeEdge(){return[]},CollidePolygonEdge(r,t){var e;const i=r.center,n=t.center.sub(i).normalize(),o=new lt({points:[t.begin,t.end,t.end.add(n.scale(100)),t.begin.add(n.scale(100))],offset:t.offset});o.owner=t.owner,((e=t.owner)==null?void 0:e.get(P))&&o.update(t.owner.get(P).get());const h=this.CollidePolygonPolygon(r,o);return h.length&&(h[0].colliderB=t,h[0].id=pt.calculatePairHash(r.id,t.id)),h},CollidePolygonPolygon(r,t){const e=Ne.findPolygonPolygonSeparation(r,t);if(e.separation>0)return[];const i=Ne.findPolygonPolygonSeparation(t,r);if(i.separation>0)return[];const s=e.separation>i.separation?e:i,n=s.collider===r?t:r,o=s.collider===r?r:t,a=n.transform.inverse.multiply(o.transform.matrix,Mh),h=a.getRotation(),l=o.normals[s.sideId].rotate(h,Ih,Rh);let c=Number.MAX_VALUE,u=0;for(let v=0;v<n.normals.length;v++){const g=l.dot(n.normals[v]);g<c&&(c=g,u=v)}if(!s.localSide||!s.localAxis||!s.axis)return[];const _=s.localSide.transform(a),f=s.localAxis.perpendicular().negate().rotate(h),p=new J(n.points[u],n.points[(u+1)%n.points.length]).clip(f.negate(),-f.dot(_.begin),!1);let x=null;if(p&&(x=p.clip(f,f.dot(_.end),!1)),x){const v=[],g=[],y=x.getPoints();for(let I=0;I<y.length;I++){const C=y[I];_.below(C)&&(v.push(C),g.push(n.transform.apply(C)))}let S=s.axis,A=S.perpendicular();return t.center.sub(r.center).dot(S)<0&&(S=S.negate(),A=S.perpendicular()),[new xe(r,t,S.scale(-s.separation),S,A,g,v,s)]}return[]},FindContactSeparation(r,t){var e,i,s,n;const o=r.colliderA,a=(i=(e=r.bodyA)==null?void 0:e.transform)!=null?i:new P,h=r.colliderB,l=(n=(s=r.bodyB)==null?void 0:s.transform)!=null?n:new P;if(o instanceof dt&&h instanceof dt){const c=o.radius+h.radius,u=a.pos.distance(l.pos);return-(c-u)}if(o instanceof lt&&h instanceof lt&&r.info.localSide){let c,u;return r.info.collider===o?(c=new J(a.apply(r.info.localSide.begin).add(o.offset),a.apply(r.info.localSide.end).add(o.offset)),u=l.apply(t).add(h.offset)):(c=new J(l.apply(r.info.localSide.begin).add(h.offset),l.apply(r.info.localSide.end).add(h.offset)),u=a.apply(t).add(o.offset)),c.distanceToPoint(u,!0)}if(o instanceof lt&&h instanceof dt||h instanceof lt&&o instanceof dt){const c=a.apply(t);if(r.info.side)return r.info.side.distanceToPoint(c,!0)}if(o instanceof St&&h instanceof lt||h instanceof St&&o instanceof lt){let c;if(r.info.collider===o?c=l.apply(t):c=a.apply(t),r.info.side)return r.info.side.distanceToPoint(c,!0)}if(o instanceof dt&&h instanceof St||h instanceof dt&&o instanceof St){const c=l.apply(t);let u;o instanceof dt&&(u=o.getFurthestPoint(r.normal));const _=c.distance(u);if(r.info.side)return _>0?-_:0}return 0}};class St extends ai{constructor(t){var e;super(),this._globalMatrix=j.identity(),this.begin=t.begin||w.Zero,this.end=t.end||w.Zero,this.offset=(e=t.offset)!=null?e:w.Zero}clone(){return new St({begin:this.begin.clone(),end:this.end.clone()})}get worldPos(){var t;const e=this._transform;return(t=e==null?void 0:e.globalPos.add(this.offset))!=null?t:this.offset}get center(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return t.average(e)}_getTransformedBegin(){return this._globalMatrix.multiply(this.begin)}_getTransformedEnd(){return this._globalMatrix.multiply(this.end)}getSlope(){const t=this._getTransformedBegin(),e=this._getTransformedEnd(),i=t.distance(e);return e.sub(t).scale(1/i)}getLength(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return t.distance(e)}contains(){return!1}rayCast(t,e=1/0){var i;const s=this._getTransformedBegin().sub(t.pos);if(t.dir.cross(this.getSlope())===0&&s.cross(t.dir)!==0)return null;const n=t.dir.cross(this.getSlope());if(n===0)return null;const o=s.cross(this.getSlope())/n;if(o>=0&&o<=e){const a=s.cross(t.dir)/n/this.getLength();if(a>=0&&a<=1)return{distance:o,normal:this.asLine().normal(),collider:this,body:(i=this.owner)==null?void 0:i.get(N),point:t.getPoint(o)}}return null}getClosestLineBetween(t){if(t instanceof dt)return qt.CircleEdgeClosestLine(t,this);if(t instanceof lt)return qt.PolygonEdgeClosestLine(t,this).flip();if(t instanceof St)return qt.EdgeEdgeClosestLine(this,t);throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}collide(t){if(t instanceof dt)return zt.CollideCircleEdge(t,this);if(t instanceof lt)return zt.CollidePolygonEdge(t,this);if(t instanceof St)return zt.CollideEdgeEdge();throw new Error(`Edge could not collide with unknown CollisionShape ${typeof t}`)}getFurthestPoint(t){const e=this._getTransformedBegin(),i=this._getTransformedEnd();return t.dot(e)>0?e:i}_boundsFromBeginEnd(t,e,i=10){return new F(Math.min(t.x,e.x)-i,Math.min(t.y,e.y)-i,Math.max(t.x,e.x)+i,Math.max(t.y,e.y)+i)}get bounds(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return this._boundsFromBeginEnd(t,e)}get localBounds(){return this._boundsFromBeginEnd(this.begin,this.end)}asLine(){return new J(this._getTransformedBegin(),this._getTransformedEnd())}asLocalLine(){return new J(this.begin,this.end)}get axes(){const e=this._getTransformedEnd().sub(this._getTransformedBegin()).normal(),i=[];return i.push(e),i.push(e.negate()),i.push(e.normal()),i.push(e.normal().negate()),i}getInertia(t){const e=this.end.sub(this.begin).distance()/2;return t*e*e}update(t){var e;this._transform=t,((e=t.matrix)!=null?e:this._globalMatrix).clone(this._globalMatrix),this._globalMatrix.translate(this.offset.x,this.offset.y)}project(t){const e=[],i=[this._getTransformedBegin(),this._getTransformedEnd()],s=i.length;for(let n=0;n<s;n++)e.push(i[n].dot(t));return new ei(Math.min.apply(Math,e),Math.max.apply(Math,e))}debug(t,e){const i=this._getTransformedBegin(),s=this._getTransformedEnd();t.debug.drawLine(i,s,{color:e,lineWidth:2}),t.debug.drawCircle(i,2,e),t.debug.drawCircle(s,2,e)}}class lt extends ai{constructor(t){var e;super(),this._logger=R.getInstance(),this._transform=new Kt,this._transformedPoints=[],this._sides=[],this._localSides=[],this._transformedPointsDirty=!0,this._sidesDirty=!0,this._localSidesDirty=!0,this._localBoundsDirty=!0,this.offset=(e=t.offset)!=null?e:w.Zero,this._transform.pos.x+=this.offset.x,this._transform.pos.y+=this.offset.y,this.points=t.points,this.isConvex()||t.suppressConvexWarning||this._logger.warn("Excalibur only supports convex polygon colliders and will not behave properly.Call PolygonCollider.triangulate() to build a new collider composed of smaller convex triangles"),this._calculateTransformation()}flagDirty(){this._localBoundsDirty=!0,this._localSidesDirty=!0,this._transformedPointsDirty=!0,this._sidesDirty=!0}get normals(){return this._normals}set points(t){if(t.length<3)throw new Error("PolygonCollider cannot be created with less that 3 points");this._points=t,this._checkAndUpdateWinding(this._points),this._calculateNormals(),this.flagDirty()}_calculateNormals(){const t=[];for(let e=0;e<this._points.length;e++)t.push(this._points[(e+1)%this._points.length].sub(this._points[e]).normal());this._normals=t}get points(){return this._points}get transform(){return this._transform}_checkAndUpdateWinding(t){this._isCounterClockwiseWinding(t)||t.reverse()}_isCounterClockwiseWinding(t){let e=0;for(let i=0;i<t.length;i++)e+=(t[(i+1)%t.length].x-t[i].x)*(t[(i+1)%t.length].y+t[i].y);return e<0}isConvex(){if(this.points.length<3)return!1;let t=this.points[this.points.length-2],e=this.points[this.points.length-1],i=Math.atan2(e.y-t.y,e.x-t.x),s=0,n=0,o=0;for(const[a,h]of this.points.entries()){if(t=e,s=i,e=h,i=Math.atan2(e.y-t.y,e.x-t.x),t.equals(e))return!1;let l=i-s;if(l<=-Math.PI?l+=Math.PI*2:l>Math.PI&&(l-=Math.PI*2),a===0){if(l===0)return!1;n=l>0?1:-1}else if(n*l<=0)return!1;o+=l}return Math.abs(Math.round(o/(Math.PI*2)))===1}tessellate(){const t=[];for(let e=1;e<this.points.length-2;e++)t.push([this.points[0],this.points[e+1],this.points[e+2]]);return t.push([this.points[0],this.points[1],this.points[2]]),new at(t.map(e=>ut.Polygon(e)))}triangulate(){if(this.points.length<3)throw Error("Invalid polygon");const t=[],e=[...this.points].reverse();let i=e.length;function s(u){return u===0?i-1:u-1}function n(u){return u===i-1?0:u+1}function o(u){const _=s(u),f=n(u),m=e[_],p=e[u],x=e[f],v=m.sub(p),g=x.sub(p);return!(v.cross(g)<0)}const a=e.map((u,_)=>o(_));function h(u,_,f,m){const p=f.sub(_),x=m.sub(f),v=_.sub(m),g=u.sub(_),y=u.sub(f),S=u.sub(m),A=p.cross(g),I=x.cross(y),C=v.cross(S);return!(A>0||I>0||C>0)}function l(){for(let u=0;u<i;u++)if(a[u]){const _=s(u),f=n(u),m=e[_],p=e[u],x=e[f];let v=!0;for(let g=0;g<i;g++){if(g===u||g===_||g===f)continue;const y=e[g];if(h(y,m,p,x)){v=!1;break}}if(v)return u}for(let u=0;u<i;u++)if(a[u])return u;return 0}function c(u){const _=s(u),f=n(u),m=e[_],p=e[u],x=e[f];t.push([m,p,x]),e.splice(u,1),a.splice(u,1),i--}for(;i>3;){const u=l();c(u);for(let _=0;_<i;_++)a[_]=o(_)}return t.push([e[0],e[1],e[2]]),new at(t.map(u=>ut.Polygon(u,w.Zero,!0)))}clone(){return new lt({offset:this.offset.clone(),points:this.points.map(t=>t.clone())})}get worldPos(){return this._transform.pos}get center(){return this.bounds.center}_calculateTransformation(){const t=this.points,e=t.length;this._transformedPoints.length=0;for(let i=0;i<e;i++)this._transformedPoints[i]=this._transform.apply(t[i].clone())}getTransformedPoints(){return this._transformedPointsDirty&&(this._calculateTransformation(),this._transformedPointsDirty=!1),this._transformedPoints}getSides(){if(this._sidesDirty){const t=[],e=this.getTransformedPoints(),i=e.length;for(let s=0;s<i;s++)t.push(new J(e[s],e[(s+1)%i]));this._sides=t,this._sidesDirty=!1}return this._sides}getLocalSides(){if(this._localSidesDirty){const t=[],e=this.points,i=e.length;for(let s=0;s<i;s++)t.push(new J(e[s],e[(s+1)%i]));this._localSides=t,this._localSidesDirty=!1}return this._localSides}findSide(t){const e=this.getSides();let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=e[n],h=o.normal().dot(t);h>s&&(i=o,s=h)}return i}findLocalSide(t){const e=this.getLocalSides();let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=e[n],h=o.normal().dot(t);h>s&&(i=o,s=h)}return i}get axes(){const t=[],e=this.getSides();for(let i=0;i<e.length;i++)t.push(e[i].normal());return t}update(t){t&&(t.cloneWithParent(this._transform),this._transformedPointsDirty=!0,this._sidesDirty=!0,(this.offset.x!==0||this.offset.y!==0)&&(this._transform.pos.x+=this.offset.x,this._transform.pos.y+=this.offset.y),this._transform.isMirrored()&&(this.points=this.points.map(e=>b(e.x*G(this._transform.scale.x),e.y*G(this._transform.scale.y))),this._transform.scale.x=Math.abs(this._transform.scale.x),this._transform.scale.y=Math.abs(this._transform.scale.y)))}contains(t){const e=this._transform.applyInverse(t),i=new ge(e,new w(1,0));let s=0;const n=this.getLocalSides();for(let o=0;o<n.length;o++){const a=n[o];i.intersect(a)>=0&&s++}return s%2!==0}getClosestLineBetween(t){if(t instanceof dt)return qt.PolygonCircleClosestLine(this,t);if(t instanceof lt)return qt.PolygonPolygonClosestLine(this,t);if(t instanceof St)return qt.PolygonEdgeClosestLine(this,t);throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}collide(t){if(t instanceof dt)return zt.CollideCirclePolygon(t,this);if(t instanceof lt)return zt.CollidePolygonPolygon(this,t);if(t instanceof St)return zt.CollidePolygonEdge(this,t);throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}getFurthestPoint(t){const e=this.getTransformedPoints();let i=null,s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=t.dot(e[n]);o>s&&(s=o,i=e[n])}return i}getFurthestLocalPoint(t){const e=this.points;let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=t.dot(e[n]);o>s&&(s=o,i=e[n])}return i}getClosestFace(t){const e=this.getSides();let i=Number.POSITIVE_INFINITY,s=-1,n=-1;for(let o=0;o<e.length;o++){const a=e[o].distanceToPoint(t);a<i&&(i=a,s=o,n=a)}return s!==-1?{distance:e[s].normal().scale(n),face:e[s]}:null}get bounds(){return this.localBounds.transform(this._transform.matrix)}get localBounds(){return this._localBoundsDirty&&(this._localBounds=F.fromPoints(this.points),this._localBoundsDirty=!1),this._localBounds}getInertia(t){if(this._cachedMass===t&&this._cachedInertia)return this._cachedInertia;let e=0,i=0;const s=this.points;for(let n=0;n<s.length;n++){const o=(n+1)%s.length,a=s[o].cross(s[n]);e+=a*(s[n].dot(s[n])+s[n].dot(s[o])+s[o].dot(s[o])),i+=a}return this._cachedMass=t,this._cachedInertia=t/6*(e/i)}rayCast(t,e=1/0){var i;const s=this.getSides(),n=s.length;let o=Number.MAX_VALUE,a,h=-1;for(let l=0;l<n;l++){const c=t.intersect(s[l]);c>=0&&c<o&&c<=e&&(o=c,a=s[l],h=l)}return h>=0?{collider:this,distance:o,body:(i=this.owner)==null?void 0:i.get(N),point:t.getPoint(o),normal:a.normal()}:null}project(t){const e=this.getTransformedPoints(),i=e.length;let s=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let o=0;o<i;o++){const a=e[o].dot(t);s=Math.min(s,a),n=Math.max(n,a)}return new ei(s,n)}debug(t,e,i){const s=this.getTransformedPoints();Tt.drawPolygon(s,{color:e})}}class ut{static Box(t,e,i=w.Half,s=w.Zero){return new lt({points:new F(-t*i.x,-e*i.y,t-t*i.x,e-e*i.y).getPoints().slice(),offset:s})}static Polygon(t,e=w.Zero,i=!1){return new lt({points:t,offset:e,suppressConvexWarning:i})}static Circle(t,e=w.Zero){return new dt({radius:t,offset:e})}static Edge(t,e){return new St({begin:t,end:e})}static Capsule(t,e,i=w.Zero){const s=R.getInstance();if(t===e&&s.warn("A capsule collider with equal width and height is a circle, consider using a ex.Shape.Circle or ex.CircleCollider"),e>=t){const o=new at([ut.Circle(t/2,b(0,-e/2+t/2).add(i)),ut.Box(t,e-t,w.Half,i),ut.Circle(t/2,b(0,e/2-t/2).add(i))]);return o.compositeStrategy="together",o}else{const o=new at([ut.Circle(e/2,b(-t/2+e/2,0).add(i)),ut.Box(t-e,e,w.Half,i),ut.Circle(e/2,b(t/2-e/2,0).add(i))]);return o.compositeStrategy="together",o}}}function It(r,t){return r&&(r.__isProxy===void 0?new Proxy(r,{set:(e,i,s)=>(e[i]!==s&&(e[i]=s,typeof i=="string"&&i[0]!=="_"&&t(e)),!0),get:(e,i)=>i!=="__isProxy"?e[i]:!0}):r)}const Fr=(r=[],t,e)=>({get:(i,s)=>s==="__isProxy"?!0:typeof i[s]=="object"&&i[s]!=null?new Proxy(i[s],Fr([...r,s],t,e)):i[s],set:(i,s,n)=>(typeof s=="string"&&s[0]!=="_"&&t(e),i[s]=n,!0)});function Fh(r,t){return r&&(r.__isProxy===void 0?new Proxy(r,Fr([],t,r)):r)}const Dr=class ka{constructor(t){this.id=ka._ID++,this.transform=j.identity(),this._transformStale=!0,this.showDebug=!1,this._flipHorizontal=!1,this._flipVertical=!1,this._rotation=0,this.opacity=1,this._scale=w.One,this._width=0,this._height=0;var e,i,s,n,o,a,h;t&&(this.origin=(e=t.origin)!=null?e:this.origin,this.flipHorizontal=(i=t.flipHorizontal)!=null?i:this.flipHorizontal,this.flipVertical=(s=t.flipVertical)!=null?s:this.flipVertical,this.rotation=(n=t.rotation)!=null?n:this.rotation,this.opacity=(o=t.opacity)!=null?o:this.opacity,this.scale=(a=t.scale)!=null?a:this.scale,this.tint=(h=t.tint)!=null?h:this.tint,t.width&&(this._width=t.width),t.height&&(this._height=t.height))}isStale(){return this._transformStale}get flipHorizontal(){return this._flipHorizontal}set flipHorizontal(t){this._flipHorizontal=t,this._transformStale=!0}get flipVertical(){return this._flipVertical}set flipVertical(t){this._flipVertical=t,this._transformStale=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._transformStale=!0}get scale(){return this._scale}set scale(t){this._scale=It(t,()=>{this._transformStale=!0}),this._transformStale=!0}get origin(){return this._origin}set origin(t){t&&(this._origin=It(t,()=>{this._transformStale=!0})),this._transformStale=!0}cloneGraphicOptions(){return{width:this.width/this.scale.x,height:this.height/this.scale.y,origin:this.origin?this.origin.clone():void 0,flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical,rotation:this.rotation,opacity:this.opacity,scale:this.scale?this.scale.clone():void 0,tint:this.tint?this.tint.clone():void 0}}get width(){return Math.abs(this._width*this.scale.x)}get height(){return Math.abs(this._height*this.scale.y)}set width(t){this._width=t,this._transformStale=!0}set height(t){this._height=t,this._transformStale=!0}get localBounds(){return F.fromDimension(this.width,this.height,w.Zero)}draw(t,e,i){this._preDraw(t,e,i),this._drawImage(t,0,0),this._postDraw(t)}_preDraw(t,e,i){t.save(),t.translate(e,i),this._transformStale&&(this.transform.reset(),this.transform.scale(Math.abs(this.scale.x),Math.abs(this.scale.y)),this._rotate(this.transform),this._flip(this.transform),this._transformStale=!1),t.multiply(this.transform),t.opacity=t.opacity*this.opacity,this.tint&&(t.tint=this.tint)}_rotate(t){var e;const i=this.scale.x>0?1:-1,s=this.scale.y>0?1:-1,n=(e=this.origin)!=null?e:b(this.width/2,this.height/2);t.translate(n.x,n.y),t.rotate(this.rotation),t.scale(i,s),t.translate(-n.x,-n.y)}_flip(t){this.flipHorizontal&&(t.translate(this.width/this.scale.x,0),t.scale(-1,1)),this.flipVertical&&(t.translate(0,this.height/this.scale.y),t.scale(1,-1))}_postDraw(t){this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore()}};Dr._ID=0;let st=Dr;var Br=(r=>(r.Forward="forward",r.Backward="backward",r))(Br||{}),kr=(r=>(r.End="end",r.Loop="loop",r.PingPong="pingpong",r.Freeze="freeze",r))(kr||{});const Dh={Frame:"frame",Loop:"loop",End:"end"},Lr=class rr extends st{constructor(t){var e,i,s;super(t),this.events=new X,this.frames=[],this.strategy="loop",this.frameDuration=100,this._idempotencyToken=-1,this._firstTick=!0,this._currentFrame=0,this._timeLeftInFrame=0,this._pingPongDirection=1,this._done=!1,this._playing=!0,this._speed=1,this._wasResetDuringFrameCalc=!1,this._reversed=!1,this.frames=t.frames,this.speed=(e=t.speed)!=null?e:this.speed,this.strategy=(i=t.strategy)!=null?i:this.strategy,this.frameDuration=t.totalDuration?t.totalDuration/this.frames.length:(s=t.frameDuration)!=null?s:this.frameDuration,this.data=t.data?new Map(Object.entries(t.data)):new Map,t.reverse&&this.reverse(),this.goToFrame(0)}clone(){const t=this.constructor;return new t({frames:this.frames.map(e=>({...e})),frameDuration:this.frameDuration,speed:this.speed,reverse:this._reversed,strategy:this.strategy,...this.cloneGraphicOptions()})}get width(){const t=this.currentFrame;return t&&t.graphic?Math.abs(t.graphic.width*this.scale.x):0}get height(){const t=this.currentFrame;return t&&t.graphic?Math.abs(t.graphic.height*this.scale.y):0}static fromSpriteSheet(t,e,i,s="loop",n){const o=t.sprites.length-1,a=e.filter(h=>h<0||h>o);return a.length&&rr._LOGGER.warn(`Indices into SpriteSheet were provided that don't exist: ${a.join(",")} no frame will be shown`),new this({frames:t.sprites.filter((h,l)=>e.indexOf(l)>-1).map(h=>({graphic:h,duration:i})),strategy:s,data:n})}static fromSpriteSheetCoordinates(t){var e;const{spriteSheet:i,frameCoordinates:s,durationPerFrame:n,durationPerFrameMs:o,speed:a,strategy:h,reverse:l,data:c}=t,u=(e=n!=null?n:o)!=null?e:100,_=[];for(const f of s){const{x:m,y:p,duration:x,options:v}=f,g=i.getSprite(m,p,v);g?_.push({graphic:g,duration:x!=null?x:u}):rr._LOGGER.warn(`Skipping frame! SpriteSheet does not have coordinate (${m}, ${p}), please check your SpriteSheet to confirm that sprite exists`)}return new this({frames:_,strategy:h,speed:a,reverse:l,data:c})}get speed(){return this._speed}set speed(t){this._speed=B(Math.abs(t),0,1/0)}get currentFrame(){return this._currentFrame>=0&&this._currentFrame<this.frames.length?this.frames[this._currentFrame]:null}get currentFrameIndex(){return this._currentFrame}get currentFrameTimeLeft(){return this._timeLeftInFrame}get isPlaying(){return this._playing}get isReversed(){return this._reversed}reverse(){this.frames=this.frames.slice().reverse(),this._reversed=!this._reversed}get direction(){return!!(this._reversed&&this._pingPongDirection===1)?"backward":"forward"}play(){this._playing=!0}pause(){this._playing=!1,this._firstTick=!0}reset(){this._wasResetDuringFrameCalc=!0,this._done=!1,this._firstTick=!0,this._currentFrame=0,this._timeLeftInFrame=this.frameDuration;const t=this.frames[this._currentFrame];t&&(this._timeLeftInFrame=(t==null?void 0:t.duration)||this.frameDuration)}get canFinish(){switch(this.strategy){case"end":case"freeze":return!0;default:return!1}}get done(){return this._done}goToFrame(t,e){this._currentFrame=t,this._timeLeftInFrame=e!=null?e:this.frameDuration;const i=this.frames[this._currentFrame];i&&!this._done&&(this._timeLeftInFrame=e!=null?e:(i==null?void 0:i.duration)||this.frameDuration,this.events.emit("frame",{...i,frameIndex:this.currentFrameIndex}))}_nextFrame(){this._wasResetDuringFrameCalc=!1;const t=this._currentFrame;if(this._done)return t;let e=-1;switch(this.strategy){case"loop":{e=(t+1)%this.frames.length,e===0&&this.events.emit("loop",this);break}case"end":{e=t+1,e>=this.frames.length&&(this._done=!0,this._currentFrame=this.frames.length,this.events.emit("end",this));break}case"freeze":{e=B(t+1,0,this.frames.length-1),t+1>=this.frames.length&&(this._done=!0,this.events.emit("end",this));break}case"pingpong":{t+this._pingPongDirection>=this.frames.length&&(this._pingPongDirection=-1,this.events.emit("loop",this)),t+this._pingPongDirection<0&&(this._pingPongDirection=1,this.events.emit("loop",this)),e=t+this._pingPongDirection%this.frames.length;break}}return this._wasResetDuringFrameCalc?(this._wasResetDuringFrameCalc=!1,this._currentFrame):e}tick(t,e=0){this._idempotencyToken!==e&&(this._idempotencyToken=e,this._playing&&(this._firstTick&&(this._firstTick=!1,this.events.emit("frame",{...this.currentFrame,frameIndex:this.currentFrameIndex})),this._timeLeftInFrame-=t*this._speed,this._timeLeftInFrame<=0&&this.goToFrame(this._nextFrame())))}_drawImage(t,e,i){this.currentFrame&&this.currentFrame.graphic&&this.currentFrame.graphic.draw(t,e,i)}};Lr._LOGGER=R.getInstance();let zi=Lr;class We extends st{constructor(t){var e;super(t),this._logger=R.getInstance(),this.useAnchor=!0,this.members=[],this.members=t.members,this.useAnchor=(e=t.useAnchor)!=null?e:this.useAnchor,this._updateDimensions()}clone(){return new We({members:[...this.members],...this.cloneGraphicOptions()})}_updateDimensions(){const t=this.localBounds;return this.width=t.width,this.height=t.height,t}get localBounds(){const t=new F;for(const e of this.members)if(e instanceof st)e.localBounds.combine(t,t);else{const{graphic:i,offset:s,useBounds:n}=e;i?(n===void 0?!0:n)&&i.localBounds.translate(s).combine(t,t):this._logger.warnOnce(`Graphics group member has an null or undefined graphic, member definition: ${JSON.stringify(e)}.`)}return t}_isAnimationOrGroup(t){return t instanceof zi||t instanceof We}tick(t,e){for(const i of this.members){let s;i instanceof st?s=i:s=i.graphic,this._isAnimationOrGroup(s)&&s.tick(t,e)}}reset(){for(const t of this.members){let e;t instanceof st?e=t:e=t.graphic,this._isAnimationOrGroup(e)&&e.reset()}}_preDraw(t,e,i){this._updateDimensions(),super._preDraw(t,this.useAnchor?e:0,this.useAnchor?i:0)}_drawImage(t,e,i){const s=w.Zero;for(const n of this.members){let o;n instanceof st?o=n:(o=n.graphic,n.offset.clone(s)),o&&(t.save(),t.translate(e,i),o.draw(t,s.x,s.y),this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore())}}}class Ve extends st{constructor(t){var e,i,s,n,o,a,h,l,c,u;super(yr({...t},["width","height"])),this.lineCap="butt",this.quality=1,this._dirty=!0,this._smoothing=!1,this._color=It(T.Black,()=>this.flagDirty()),this._lineWidth=1,this._lineDash=[],this._padding=0,t&&(this.quality=(e=t.quality)!=null?e:this.quality,this.color=(i=t.color)!=null?i:T.Black,this.strokeColor=t==null?void 0:t.strokeColor,this.smoothing=(s=t.smoothing)!=null?s:this.smoothing,this.lineWidth=(n=t.lineWidth)!=null?n:this.lineWidth,this.lineDash=(o=t.lineDash)!=null?o:this.lineDash,this.lineCap=(a=t.lineCap)!=null?a:this.lineCap,this.padding=(h=t.padding)!=null?h:this.padding,this.filtering=(l=t.filtering)!=null?l:this.filtering),this._bitmap=document.createElement("canvas");const _=(c=t==null?void 0:t.width)!=null?c:this._bitmap.width,f=(u=t==null?void 0:t.height)!=null?u:this._bitmap.height;this.width=_,this.height=f;const m=this._bitmap.getContext("2d");if(m)this._ctx=m;else throw new Error("Browser does not support 2d canvas drawing, cannot create Raster graphic")}cloneRasterOptions(){return{color:this.color?this.color.clone():void 0,strokeColor:this.strokeColor?this.strokeColor.clone():void 0,smoothing:this.smoothing,lineWidth:this.lineWidth,lineDash:this.lineDash,lineCap:this.lineCap,quality:this.quality,padding:this.padding}}get dirty(){return this._dirty}flagDirty(){this._dirty=!0}get width(){return Math.abs(this._getTotalWidth()*this.scale.x)}set width(t){t/=Math.abs(this.scale.x),this._bitmap.width=t,this._originalWidth=t,this.flagDirty()}get height(){return Math.abs(this._getTotalHeight()*this.scale.y)}set height(t){t/=Math.abs(this.scale.y),this._bitmap.height=t,this._originalHeight=t,this.flagDirty()}_getTotalWidth(){var t;return(((t=this._originalWidth)!=null?t:this._bitmap.width)+this.padding*2)*1}_getTotalHeight(){var t;return(((t=this._originalHeight)!=null?t:this._bitmap.height)+this.padding*2)*1}get localBounds(){return F.fromDimension(this._getTotalWidth()*this.scale.x,this._getTotalHeight()*this.scale.y,w.Zero)}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this.flagDirty()}get color(){return this._color}set color(t){this.flagDirty(),this._color=It(t,()=>this.flagDirty())}get strokeColor(){return this._strokeColor}set strokeColor(t){this.flagDirty(),t&&(this._strokeColor=It(t,()=>this.flagDirty()))}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.flagDirty()}get lineDash(){return this._lineDash}set lineDash(t){this._lineDash=t,this.flagDirty()}get padding(){return this._padding}set padding(t){this._padding=t,this.flagDirty()}rasterize(){this._dirty=!1,this._ctx.clearRect(0,0,this._getTotalWidth(),this._getTotalHeight()),this._ctx.save(),this._applyRasterProperties(this._ctx),this.execute(this._ctx),this._ctx.restore()}_applyRasterProperties(t){var e,i,s,n;this._bitmap.width=this._getTotalWidth()*this.quality,this._bitmap.height=this._getTotalHeight()*this.quality,this._bitmap.setAttribute("filtering",this.filtering),this._bitmap.setAttribute("forceUpload","true"),t.scale(this.quality,this.quality),t.translate(this.padding,this.padding),t.imageSmoothingEnabled=this.smoothing,t.lineWidth=this.lineWidth,t.setLineDash((e=this.lineDash)!=null?e:t.getLineDash()),t.lineCap=this.lineCap,t.strokeStyle=(s=(i=this.strokeColor)==null?void 0:i.toString())!=null?s:"",t.fillStyle=(n=this.color)==null?void 0:n.toString()}_drawImage(t,e,i){this._dirty&&this.rasterize(),t.scale(1/this.quality,1/this.quality),t.drawImage(this._bitmap,e,i)}}var ln=(r=>(r.Em="em",r.Rem="rem",r.Px="px",r.Pt="pt",r.Percent="%",r))(ln||{}),cn=(r=>(r.Left="left",r.Right="right",r.Center="center",r.Start="start",r.End="end",r))(cn||{}),dn=(r=>(r.Top="top",r.Hanging="hanging",r.Middle="middle",r.Alphabetic="alphabetic",r.Ideographic="ideographic",r.Bottom="bottom",r))(dn||{}),un=(r=>(r.Normal="normal",r.Italic="italic",r.Oblique="oblique",r))(un||{}),_n=(r=>(r.LeftToRight="ltr",r.RightToLeft="rtl",r))(_n||{}),mt=(r=>(r.Pixel="Pixel",r.Blended="Blended",r))(mt||{});function Ge(r){switch(r){case"Pixel":return"Pixel";case"Blended":return"Blended";default:return}}function fn(r,t=T.Red,e,i,s,n,o=1,a="butt"){r.save(),r.beginPath(),r.lineWidth=o,r.lineCap=a,r.strokeStyle=t.toString(),r.moveTo(e,i),r.lineTo(s,n),r.closePath(),r.stroke(),r.restore()}function Bh(r,t=T.Red,e){r.beginPath(),r.strokeStyle=t.toString(),r.arc(e.x,e.y,5,0,Math.PI*2),r.closePath(),r.stroke()}function kh(r,t,e,i,s=1){const n=t?t.toString():"blue",o=i.scale(s);r.beginPath(),r.strokeStyle=n,r.moveTo(e.x,e.y),r.lineTo(e.x+o.x,e.y+o.y),r.closePath(),r.stroke()}function gn(r,t,e,i,s,n=5,o=T.White,a=null){let h;if(typeof n=="number")h={tl:n,tr:n,br:n,bl:n};else{const l={tl:0,tr:0,br:0,bl:0};for(const c in l)if(l.hasOwnProperty(c)){const u=c;h[u]=n[u]||l[u]}}r.beginPath(),r.moveTo(t+h.tl,e),r.lineTo(t+i-h.tr,e),r.quadraticCurveTo(t+i,e,t+i,e+h.tr),r.lineTo(t+i,e+s-h.br),r.quadraticCurveTo(t+i,e+s,t+i-h.br,e+s),r.lineTo(t+h.bl,e+s),r.quadraticCurveTo(t,e+s,t,e+s-h.bl),r.lineTo(t,e+h.tl),r.quadraticCurveTo(t,e,t+h.tl,e),r.closePath(),a&&(r.fillStyle=a.toString(),r.fill()),o&&(r.strokeStyle=o.toString(),r.stroke())}function Lh(r,t,e,i,s=T.White,n=null){r.beginPath(),r.arc(t,e,i,0,Math.PI*2),r.closePath(),n&&(r.fillStyle=n.toString(),r.fill()),s&&(r.strokeStyle=s.toString(),r.stroke())}const Uh=Object.freeze(Object.defineProperty({__proto__:null,circle:Lh,line:fn,point:Bh,roundRect:gn,vector:kh},Symbol.toStringTag,{value:"Module"}));class qe{constructor(t,e,i=1){this.builder=t,this.cleaner=e,this._pool=[],this._size=0,this.grow(i)}grow(t){if(t>0){this._size+=t;for(let e=0;e<t;e++)this._pool.push(this.builder())}}rent(t=!1){return this._pool.length===0&&this.grow(this._size),t?this.cleaner(this._pool.pop()):this._pool.pop()}return(t){this._pool.push(t)}}class zh{constructor(){this._pool=new qe(()=>j.identity(),t=>t.reset(),100),this._transforms=[],this._currentTransform=this._pool.rent(!0)}save(){this._transforms.push(this._currentTransform),this._currentTransform=this._currentTransform.clone(this._pool.rent())}restore(){this._pool.return(this._currentTransform),this._currentTransform=this._transforms.pop()}translate(t,e){return this._currentTransform.translate(t,e)}rotate(t){return this._currentTransform.rotate(t)}scale(t,e){return this._currentTransform.scale(t,e)}reset(){this._currentTransform.reset()}set current(t){this._currentTransform=t}get current(){return this._currentTransform}}class Oh{constructor(){this.opacity=1,this.z=0,this.tint=T.White,this.material=null}}class Ur{constructor(){this._pool=new qe(()=>new Oh,t=>(t.opacity=1,t.z=0,t.tint=T.White,t.material=null,t),100),this.current=this._pool.rent(!0),this._states=[]}_cloneState(t){var e;return t.opacity=this.current.opacity,t.z=this.current.z,t.tint=(e=this.current.tint)==null?void 0:e.clone(),t.material=this.current.material,t}save(){this._states.push(this.current),this.current=this._cloneState(this._pool.rent())}restore(){this._pool.return(this.current),this.current=this._states.pop()}}const Hh={Complete:"complete",Load:"load",LoadStart:"loadstart",Progress:"progress",Error:"error"};class li{constructor(t,e,i=!1){this.path=t,this.responseType=e,this.bustCache=i,this.data=null,this.logger=R.getInstance(),this.events=new X}isLoaded(){return this.data!==null}_cacheBust(t){return/\?\w*=\w*/.test(t)?t+="&__="+Date.now():t+="?__="+Date.now(),t}load(){return new Promise((t,e)=>{if(this.data!==null){this.logger.debug("Already have data for resource",this.path),this.events.emit("complete",this.data),t(this.data);return}const i=new XMLHttpRequest;i.open("GET",this.bustCache?this._cacheBust(this.path):this.path,!0),i.responseType=this.responseType,i.addEventListener("loadstart",s=>this.events.emit("loadstart",s)),i.addEventListener("progress",s=>this.events.emit("progress",s)),i.addEventListener("error",s=>this.events.emit("error",s)),i.addEventListener("load",s=>this.events.emit("load",s)),i.addEventListener("load",()=>{if(i.status!==0&&i.status!==200){this.logger.error("Failed to load resource ",this.path," server responded with error code",i.status),this.events.emit("error",i.response),e(new Error(i.statusText));return}if(i.response instanceof Blob&&i.response.type==="text/html"){const s=`Expected blob (usually image) data from the server when loading ${this.path}, but got HTML content instead!
|
|
26
|
+
Check your bundler settings to make sure this is not the case! Excalibur has ESM & UMD bundles be sure one 1 is loaded.`)}get entities(){return this.entityManager.entities}clearEntities(){this.entityManager.clear()}clearSystems(){this.systemManager.clear()}}d.Side=(r=>(r.None="None",r.Top="Top",r.Bottom="Bottom",r.Left="Left",r.Right="Right",r))(d.Side||{}),(r=>{function t(i){return i==="Top"?"Bottom":i==="Bottom"?"Top":i==="Left"?"Right":i==="Right"?"Left":"None"}r.getOpposite=t;function e(i){return Math.abs(i.x)>=Math.abs(i.y)?i.x<=0?"Left":"Right":i.y<=0?"Top":"Bottom"}r.fromDirection=e})(d.Side||(d.Side={}));const Ir=class vt{constructor(t=0,e=0,i=0,s=0){this._points=[],typeof t=="object"?(this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom):typeof t=="number"&&(this.left=t,this.top=e,this.right=i,this.bottom=s)}clone(t){const e=t||new vt(0,0,0,0);return e.left=this.left,e.right=this.right,e.top=this.top,e.bottom=this.bottom,e}reset(){this.left=0,this.top=0,this.bottom=0,this.right=0}static getSideFromIntersection(t){return t&&t?Math.abs(t.x)>Math.abs(t.y)?t.x<0?d.Side.Right:d.Side.Left:t.y<0?d.Side.Bottom:d.Side.Top:d.Side.None}static fromPoints(t){let e=1/0,i=1/0,s=-1/0,n=-1/0;for(let o=0;o<t.length;o++)t[o].x<e&&(e=t[o].x),t[o].x>s&&(s=t[o].x),t[o].y<i&&(i=t[o].y),t[o].y>n&&(n=t[o].y);return new vt(e,i,s,n)}static fromDimension(t,e,i=w.Half,s=w.Zero){return new vt(-t*i.x+s.x,-e*i.y+s.y,t-t*i.x+s.x,e-e*i.y+s.y)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}hasZeroDimensions(){return this.width===0||this.height===0}get center(){return new w((this.left+this.right)/2,(this.top+this.bottom)/2)}get topLeft(){return new w(this.left,this.top)}get bottomRight(){return new w(this.right,this.bottom)}get topRight(){return new w(this.right,this.top)}get bottomLeft(){return new w(this.left,this.bottom)}translate(t){return new vt(this.left+t.x,this.top+t.y,this.right+t.x,this.bottom+t.y)}rotate(t,e=w.Zero){const i=this.getPoints().map(s=>s.rotate(t,e));return vt.fromPoints(i)}scale(t,e=w.Zero){const i=this.translate(e);return new vt(i.left*t.x,i.top*t.y,i.right*t.x,i.bottom*t.y)}transform(t){const e=t.data[0]*this.left,i=t.data[1]*this.left,s=t.data[0]*this.right,n=t.data[1]*this.right,o=t.data[2]*this.top,a=t.data[3]*this.top,h=t.data[2]*this.bottom,l=t.data[3]*this.bottom,c=t.getPosition(),u=Math.min(e,s)+Math.min(o,h)+c.x,_=Math.min(i,n)+Math.min(a,l)+c.y,f=Math.max(e,s)+Math.max(o,h)+c.x,m=Math.max(i,n)+Math.max(a,l)+c.y;return new vt({left:u,top:_,right:f,bottom:m})}getPerimeter(){const t=this.width,e=this.height;return 2*(t+e)}getPoints(){return(this._left!==this.left||this._right!==this.right||this._top!==this.top||this._bottom!==this.bottom)&&(this._points.length=0,this._points.push(new w(this.left,this.top)),this._points.push(new w(this.right,this.top)),this._points.push(new w(this.right,this.bottom)),this._points.push(new w(this.left,this.bottom)),this._left=this.left,this._right=this.right,this._top=this.top,this._bottom=this.bottom),this._points}rayCast(t,e=1/0){let i,s;const n=t.dir.x===0?Number.MAX_VALUE:1/t.dir.x,o=t.dir.y===0?Number.MAX_VALUE:1/t.dir.y,a=(this.left-t.pos.x)*n,h=(this.right-t.pos.x)*n;s=Math.min(a,h),i=Math.max(a,h);const l=(this.top-t.pos.y)*o,c=(this.bottom-t.pos.y)*o;return s=Math.max(s,Math.min(l,c)),i=Math.min(i,Math.max(l,c)),i>=0&&i>=s&&s<e}rayCastTime(t,e=1/0){let i,s;const n=t.dir.x===0?Number.MAX_VALUE:1/t.dir.x,o=t.dir.y===0?Number.MAX_VALUE:1/t.dir.y,a=(this.left-t.pos.x)*n,h=(this.right-t.pos.x)*n;s=Math.min(a,h),i=Math.max(a,h);const l=(this.top-t.pos.y)*o,c=(this.bottom-t.pos.y)*o;return s=Math.max(s,Math.min(l,c)),i=Math.min(i,Math.max(l,c)),i>=0&&i>=s&&s<e?s:-1}contains(t){return t instanceof w?this.left<=t.x&&this.top<=t.y&&t.y<=this.bottom&&t.x<=this.right:t instanceof vt?this.left<=t.left&&this.top<=t.top&&t.bottom<=this.bottom&&t.right<=this.right:!1}combine(t,e){const i=e||new vt(0,0,0,0),s=Math.min(this.left,t.left),n=Math.min(this.top,t.top),o=Math.max(this.right,t.right),a=Math.max(this.bottom,t.bottom);return i.left=s,i.top=n,i.right=o,i.bottom=a,i}get dimensions(){return new w(this.width,this.height)}overlaps(t,e){const i=e||0;if(t.hasZeroDimensions())return this.contains(t);if(this.hasZeroDimensions())return t.contains(this);const s=this.combine(t);return s.width+i<t.width+this.width&&s.height+i<t.height+this.height}intersect(t){if(this.bottom<=t.top||t.bottom<=this.top||this.right<=t.left||t.right<=this.left)return null;const e=this.bottom-t.top;vt._SCRATCH_INTERSECT[0]=e;const i=t.bottom-this.top;vt._SCRATCH_INTERSECT[1]=i;const s=this.right-t.left;vt._SCRATCH_INTERSECT[2]=s;const n=t.right-this.left;vt._SCRATCH_INTERSECT[3]=n;const o=wr(vt._SCRATCH_INTERSECT);switch(o){case 0:return new w(0,-e);case 1:return new w(0,i);case 2:return new w(-s,0);case 3:return new w(n,0);default:const a=o;throw new Error(`Unreachable index: [${a}] on bounding box intersection!`)}}intersectWithSide(t){const e=this.intersect(t);return vt.getSideFromIntersection(e)}draw(t,e={color:T.Yellow}){t.debug.drawRect(this.left,this.top,this.width,this.height,e)}debug(t,e={color:T.Yellow}){t.debug.drawRect(this.left,this.top,this.width,this.height,e)}};Ir._SCRATCH_INTERSECT=[0,0,0,0];let F=Ir;class pt{constructor(t,e){this.colliderA=t,this.colliderB=e,this.id=null,this.id=pt.calculatePairHash(t.id,e.id)}static canCollide(t,e){var i,s;if(t.id===e.id||t.owner&&e.owner&&t.owner.id===e.owner.id||t.localBounds.hasZeroDimensions()||e.localBounds.hasZeroDimensions())return!1;const n=(i=t==null?void 0:t.owner)==null?void 0:i.get(N),o=(s=e==null?void 0:e.owner)==null?void 0:s.get(N);return!(!n||!o||!n.group.canCollide(o.group)||n.collisionType===M.Fixed&&o.collisionType===M.Fixed||o.collisionType===M.PreventCollision||n.collisionType===M.PreventCollision||!n.isActive||!o.isActive)}get canCollide(){const t=this.colliderA,e=this.colliderB;return pt.canCollide(t,e)}collide(){return this.colliderA.collide(this.colliderB)}hasCollider(t){return t===this.colliderA||t===this.colliderB}static calculatePairHash(t,e){return t.value<e.value?`#${t.value}+${e.value}`:`#${e.value}+${t.value}`}}class sn{constructor(t){this.parent=t,this.parent=t||null,this.data=null,this.bounds=new F,this.left=null,this.right=null,this.height=0}isLeaf(){return!this.left&&!this.right}}class nn{constructor(t,e=new F(-Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)){this._config=t,this.worldBounds=e,this.root=null,this.nodes={}}_insert(t){if(this.root===null){this.root=t,this.root.parent=null;return}const e=t.bounds;let i=this.root;for(;!i.isLeaf();){const a=i.left,h=i.right,l=i.bounds.getPerimeter(),u=i.bounds.combine(e).getPerimeter(),_=2*u,f=2*(u-l);let m=0;const p=e.combine(a.bounds);let x,v;a.isLeaf()?m=p.getPerimeter()+f:(v=a.bounds.getPerimeter(),x=p.getPerimeter(),m=x-v+f);let g=0;const y=e.combine(h.bounds);if(h.isLeaf()?g=y.getPerimeter()+f:(v=h.bounds.getPerimeter(),x=y.getPerimeter(),g=x-v+f),_<m&&_<g)break;m<g?i=a:i=h}const s=i.parent,n=new sn(s);n.bounds=e.combine(i.bounds),n.height=i.height+1,s!==null?(s.left===i?s.left=n:s.right=n,n.left=i,n.right=t,i.parent=n,t.parent=n):(n.left=i,n.right=t,i.parent=n,t.parent=n,this.root=n);let o=t.parent;for(;o;){if(o=this._balance(o),!o.left)throw new Error("Parent of current leaf cannot have a null left child"+o);if(!o.right)throw new Error("Parent of current leaf cannot have a null right child"+o);o.height=1+Math.max(o.left.height,o.right.height),o.bounds=o.left.bounds.combine(o.right.bounds),o=o.parent}}_remove(t){if(t===this.root){this.root=null;return}const e=t.parent,i=e.parent;let s;if(e.left===t?s=e.right:s=e.left,i){i.left===e?i.left=s:i.right=s,s.parent=i;let n=i;for(;n;)n=this._balance(n),n.bounds=n.left.bounds.combine(n.right.bounds),n.height=1+Math.max(n.left.height,n.right.height),n=n.parent}else this.root=s,s.parent=null}trackCollider(t){const e=new sn;e.data=t,e.bounds=t.bounds,e.bounds.left-=2,e.bounds.top-=2,e.bounds.right+=2,e.bounds.bottom+=2,this.nodes[t.id.value]=e,this._insert(e)}updateCollider(t){var e;const i=this.nodes[t.id.value];if(!i)return!1;const s=t.bounds;if(!this.worldBounds.contains(s))return R.getInstance().warn("Collider with id "+t.id.value+" is outside the world bounds and will no longer be tracked for physics"),this.untrackCollider(t),!1;if(i.bounds.contains(s))return!1;if(this._remove(i),s.left-=this._config.boundsPadding,s.top-=this._config.boundsPadding,s.right+=this._config.boundsPadding,s.bottom+=this._config.boundsPadding,t.owner){const n=(e=t.owner)==null?void 0:e.get(N);if(n){const o=n.vel.x*32/1e3*this._config.velocityMultiplier,a=n.vel.y*32/1e3*this._config.velocityMultiplier;o<0?s.left+=o:s.right+=o,a<0?s.top+=a:s.bottom+=a}}return i.bounds=s,this._insert(i),!0}untrackCollider(t){const e=this.nodes[t.id.value];e&&(this._remove(e),this.nodes[t.id.value]=null,delete this.nodes[t.id.value])}_balance(t){if(t===null)throw new Error("Cannot balance at null node");if(t.isLeaf()||t.height<2)return t;const e=t.left,i=t.right,s=t,n=e,o=i,a=e.left,h=e.right,l=i.left,c=i.right,u=o.height-n.height;if(u>1)return o.left=s,o.parent=s.parent,s.parent=o,o.parent?o.parent.left===s?o.parent.left=o:o.parent.right=o:this.root=o,l.height>c.height?(o.right=l,s.right=c,c.parent=s,s.bounds=n.bounds.combine(c.bounds),o.bounds=s.bounds.combine(l.bounds),s.height=1+Math.max(n.height,c.height),o.height=1+Math.max(s.height,l.height)):(o.right=c,s.right=l,l.parent=s,s.bounds=n.bounds.combine(l.bounds),o.bounds=s.bounds.combine(c.bounds),s.height=1+Math.max(n.height,l.height),o.height=1+Math.max(s.height,c.height)),o;if(u<-1){if(n.left=s,n.parent=s.parent,s.parent=n,n.parent)if(n.parent.left===s)n.parent.left=n;else{if(n.parent.right!==s)throw"Error rotating Dynamic Tree";n.parent.right=n}else this.root=n;return a.height>h.height?(n.right=a,s.left=h,h.parent=s,s.bounds=o.bounds.combine(h.bounds),n.bounds=s.bounds.combine(a.bounds),s.height=1+Math.max(o.height,h.height),n.height=1+Math.max(s.height,a.height)):(n.right=h,s.left=a,a.parent=s,s.bounds=o.bounds.combine(a.bounds),n.bounds=s.bounds.combine(h.bounds),s.height=1+Math.max(o.height,a.height),n.height=1+Math.max(s.height,h.height)),n}return t}getHeight(){return this.root===null?0:this.root.height}query(t,e){const i=t.bounds,s=n=>{if(n&&n.bounds.overlaps(i))if(n.isLeaf()&&n.data!==t){if(e.call(t,n.data))return!0}else return s(n.left)||s(n.right);return!1};s(this.root)}rayCastQuery(t,e=1/0,i){const s=n=>{if(n&&n.bounds.rayCast(t,e))if(n.isLeaf()){if(i.call(t,n.data))return!0}else return s(n.left)||s(n.right);return!1};s(this.root)}getNodes(){const t=e=>e?[e].concat(t(e.left),t(e.right)):[];return t(this.root)}debug(t){const e=i=>{i&&(i.isLeaf()?i.bounds.debug(t,{color:T.Green}):i.bounds.debug(t,{color:T.White}),i.left&&e(i.left),i.right&&e(i.right))};e(this.root)}}class ki{constructor(t){this._config=t,this._pairs=new Set,this._collisionPairCache=[],this._colliders=[],this._dynamicCollisionTree=new nn(t.dynamicTree)}getColliders(){return this._colliders}query(t){const e=[];return t instanceof F?this._dynamicCollisionTree.query({id:fe("collider",-1),owner:null,bounds:t},i=>(e.push(i),!1)):this._dynamicCollisionTree.query({id:fe("collider",-1),owner:null,bounds:new F(t.x,t.y,t.x,t.y)},i=>(e.push(i),!1)),e}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:me.All.category,c=(n=e==null?void 0:e.searchAllColliders)!=null?n:!1;return this._dynamicCollisionTree.rayCastQuery(t,a,u=>{const f=u.owner.get(N);if(e!=null&&e.ignoreCollisionGroupAll&&f.group===me.All)return!1;const m=(l&f.group.category)!==0;if(f!=null&&f.group&&!m)return!1;const p=u.rayCast(t,a);if(p){if(e!=null&&e.filter){if(e.filter(p)&&(o.push(p),!c))return!0}else if(o.push(p),!c)return!0}return!1}),o}track(t){if(!t){R.getInstance().warn("Cannot track null collider");return}if(t instanceof at){const e=t.getColliders();for(const i of e)i.owner=t.owner,this._colliders.push(i),this._dynamicCollisionTree.trackCollider(i)}else this._colliders.push(t),this._dynamicCollisionTree.trackCollider(t)}untrack(t){if(!t){R.getInstance().warn("Cannot untrack a null collider");return}if(t instanceof at){const e=t.getColliders();for(const i of e){const s=this._colliders.indexOf(i);s!==-1&&this._colliders.splice(s,1),this._dynamicCollisionTree.untrackCollider(i)}}else{const e=this._colliders.indexOf(t);e!==-1&&this._colliders.splice(e,1),this._dynamicCollisionTree.untrackCollider(t)}}_pairExists(t,e){const i=pt.calculatePairHash(t.id,e.id);return this._pairs.has(i)}broadphase(t,e,i){const s=e/1e3,n=t.filter(a=>{var h,l;const c=(h=a.owner)==null?void 0:h.get(N);return((l=a.owner)==null?void 0:l.isActive)&&c.collisionType!==M.PreventCollision});this._collisionPairCache=[],this._pairs.clear();let o;for(let a=0,h=n.length;a<h;a++)o=n[a],this._dynamicCollisionTree.query(o,l=>{if(!this._pairExists(o,l)&&pt.canCollide(o,l)){const c=new pt(o,l);this._pairs.add(c.id),this._collisionPairCache.push(c)}return!1});if(i&&(i.physics.pairs=this._collisionPairCache.length),this._config.continuous.checkForFastBodies)for(const a of n){const h=a.owner.get(N);if((h==null?void 0:h.collisionType)!==M.Active)continue;const l=h.vel.magnitude*s+h.acc.magnitude*.5*s*s,c=Math.min(a.bounds.height,a.bounds.width);if(this._config.continuous.disableMinimumSpeedForFastBody||l>c/2){i&&i.physics.fastBodies++;const u=h.globalPos.sub(h.oldPos),_=a.center,f=a.getFurthestPoint(h.vel),m=f.sub(u),p=new ge(m,h.vel);p.pos=p.pos.add(p.dir.scale(-2*this._config.continuous.surfaceEpsilon));let x,v=new w(1/0,1/0);if(this._dynamicCollisionTree.rayCastQuery(p,l+this._config.continuous.surfaceEpsilon*2,g=>{if(!this._pairExists(a,g)&&pt.canCollide(a,g)){const y=g.rayCast(p,l+this._config.continuous.surfaceEpsilon*10);if(y){const S=y.point.sub(m);S.magnitude<v.magnitude&&(v=S,x=g)}}return!1}),x&&w.isValid(v)){const g=new pt(a,x);this._pairs.has(g.id)||(this._pairs.add(g.id),this._collisionPairCache.push(g));const y=_.sub(f);h.globalPos=m.add(y).add(v).add(p.dir.scale(10*this._config.continuous.surfaceEpsilon)),a.update(h.transform.get()),i&&i.physics.fastBodyCollisions++}}}return this._collisionPairCache}narrowphase(t,e){let i=[];for(let s=0;s<t.length;s++){const n=t[s].collide();if(i=i.concat(n),e&&n.length>0)for(const o of n)e.physics.contacts.set(o.id,o)}return e&&(e.physics.collisions+=i.length),i}update(t){let e=0;const i=t.length;for(let s=0;s<i;s++)this._dynamicCollisionTree.updateCollider(t[s])&&e++;return e}debug(t){this._dynamicCollisionTree.debug(t)}}const Rr=class Ba{constructor(){this.id=fe("collider",Ba._ID++),this.composite=null,this.events=new X,this.offset=w.Zero}touching(t){const e=this.collide(t);return!!(e&&e.length>0)}};Rr._ID=0;let ai=Rr;var Li=(r=>(r.Arcade="arcade",r.Realistic="realistic",r))(Li||{}),ae=(r=>(r.None="none",r.VerticalFirst="vertical-first",r.HorizontalFirst="horizontal-first",r))(ae||{});const rn={vertical:1,horizontal:2},on={horizontal:1,vertical:2},an={horizontal:0,vertical:0};var hi=(r=>(r.DynamicTree="dynamic-tree",r.SparseHashGrid="sparse-hash-grid",r))(hi||{});const te=()=>({enabled:!0,integration:{onScreenOnly:!1},gravity:b(0,0).clone(),solver:Li.Arcade,substep:1,colliders:{compositeStrategy:"together"},continuous:{checkForFastBodies:!0,disableMinimumSpeedForFastBody:!1,surfaceEpsilon:.1},bodies:{canSleepByDefault:!1,sleepEpsilon:.07,wakeThreshold:.07*3,sleepBias:.9,defaultMass:10},spatialPartition:hi.SparseHashGrid,sparseHashGrid:{size:100},dynamicTree:{boundsPadding:5,velocityMultiplier:2},arcade:{contactSolveBias:ae.None},realistic:{contactSolveBias:ae.None,positionIterations:3,velocityIterations:8,slop:1,steeringFactor:.2,warmStart:!0}});class at extends ai{constructor(t){super(),this._collisionProcessor=new ki({...te()}),this._dynamicAABBTree=new nn({boundsPadding:5,velocityMultiplier:2}),this._colliders=[];for(const e of t)this.addCollider(e)}set compositeStrategy(t){this._compositeStrategy=t}get compositeStrategy(){return this._compositeStrategy}clearColliders(){this._colliders=[]}addCollider(t){let e;t instanceof at?(e=t.getColliders(),e.forEach(i=>i.offset.addEqual(t.offset))):e=[t];for(const i of e)i.events.pipe(this.events),i.composite=this,this._colliders.push(i),this._collisionProcessor.track(i),this._dynamicAABBTree.trackCollider(i)}removeCollider(t){t.events.pipe(this.events),t.composite=null,He(t,this._colliders),this._collisionProcessor.untrack(t),this._dynamicAABBTree.untrackCollider(t)}getColliders(){return this._colliders}get worldPos(){var t,e;return((e=(t=this._transform)==null?void 0:t.pos)!=null?e:w.Zero).add(this.offset)}get center(){var t,e;return((e=(t=this._transform)==null?void 0:t.pos)!=null?e:w.Zero).add(this.offset)}get bounds(){var t,e;const i=this.getColliders();return i.reduce((n,o)=>n.combine(o.bounds),(e=(t=i[0])==null?void 0:t.bounds)!=null?e:new F().translate(this.worldPos)).translate(this.offset)}get localBounds(){var t,e;const i=this.getColliders();return i.reduce((n,o)=>n.combine(o.localBounds),(e=(t=i[0])==null?void 0:t.localBounds)!=null?e:new F)}get axes(){const t=this.getColliders();let e=[];for(const i of t)e=e.concat(i.axes);return e}getFurthestPoint(t){const e=this.getColliders(),i=[];for(const o of e)i.push(o.getFurthestPoint(t));let s=i[0],n=-Number.MAX_VALUE;for(const o of i){const a=o.dot(t);a>n&&(s=o,n=a)}return s}getInertia(t){const e=this.getColliders();let i=0;for(const s of e)i+=s.getInertia(t);return i}collide(t){let e=[t];t instanceof at&&(e=t.getColliders());const i=[];for(const n of e)this._dynamicAABBTree.query(n,o=>(i.push(new pt(n,o)),!1));let s=[];for(const n of i)s=s.concat(n.collide());return s}getClosestLineBetween(t){const e=this.getColliders(),i=[];if(t instanceof at){const s=t.getColliders();for(const n of e)for(const o of s){const a=n.getClosestLineBetween(o);a&&i.push(a)}}else for(const s of e){const n=t.getClosestLineBetween(s);n&&i.push(n)}if(i.length){let s=i[0].getLength(),n=i[0];for(const o of i){const a=o.getLength();a<s&&(s=a,n=o)}return n}return null}contains(t){const e=this.getColliders();for(const i of e)if(i.contains(t))return!0;return!1}rayCast(t,e){const i=this.getColliders(),s=[];for(const n of i){const o=n.rayCast(t,e);o&&s.push(o)}if(s.length){let n=s[0],o=n.point.dot(t.dir);for(const a of s){const h=t.dir.dot(a.point);h<o&&(n=a,o=h)}return n}return null}project(t){const e=this.getColliders(),i=[];for(const s of e){const n=s.project(t);n&&i.push(n)}if(i.length){const s=new ei(i[0].min,i[0].max);for(const n of i)s.min=Math.min(n.min,s.min),s.max=Math.max(n.max,s.max);return s}return null}update(t){if(t){const e=this.getColliders();for(const i of e)i.owner=this.owner,i.update(t)}}debug(t,e,i){const s=this.getColliders();t.save(),t.translate(this.offset.x,this.offset.y);for(const n of s)n.debug(t,e,i);t.restore()}clone(){const t=new at(this._colliders.map(e=>e.clone()));return t.offset=this.offset.clone(),t}}function hn(r,t){const i=r.dir(),s=t.dir(),n=i.dot(i),o=s.dot(s);if(n<1e-9&&o<1e-9)return new J(r.begin,t.begin);if(n<1e-9){const x=B(s.dot(r.begin.sub(t.begin))/o,0,1),v=t.begin.add(s.scale(x));return new J(r.begin,v)}if(o<1e-9){const x=B(i.dot(t.begin.sub(r.begin))/n,0,1),v=r.begin.add(i.scale(x));return new J(v,t.begin)}const a=r.begin.sub(t.begin),h=n,l=o,c=s.dot(a),u=h*l-Math.pow(i.dot(s),2);let _=0,f=0;Math.abs(u)>1e-9?_=B((i.dot(s)*c-l*i.dot(a))/u,0,1):_=B(i.dot(a)/h,0,1),Math.abs(l)>1e-9?f=B((i.dot(s)*_+c)/l,0,1):f=0;const m=r.begin.add(i.scale(_)),p=t.begin.add(s.scale(f));return new J(m,p)}const qt={PolygonPolygonClosestLine(r,t){const e=r.getSides(),i=t.getSides();let s=Number.MAX_VALUE,n=null;for(let o=0;o<e.length;o++)for(let a=0;a<i.length;a++){const h=hn(e[o],i[a]),l=h.getLength();l<s&&(s=l,n=h)}return n},PolygonEdgeClosestLine(r,t){const i=t.worldPos.sub(r.worldPos),s=new ge(r.worldPos,i),n=r.rayCast(s).point.add(s.dir.scale(.1)),o=r.getClosestFace(n),a=t.asLine();return hn(o.face,a)},PolygonCircleClosestLine(r,t){const e=t.worldPos,i=e.sub(r.worldPos),s=new ge(r.worldPos,i.normalize()),n=r.rayCast(s).point.add(s.dir.scale(.1)),o=r.getClosestFace(n),a=o.face.begin,h=o.face.getEdge();let l=(h.x*(e.x-a.x)+h.y*(e.y-a.y))/(h.x*h.x+h.y*h.y);l>1?l=1:l<0&&(l=0);const c=Math.sqrt(Math.pow(a.x+h.x*l-e.x,2)+Math.pow(a.y+h.y*l-e.y,2))-t.radius,u=(a.x+h.x*l-e.x)*t.radius/(t.radius+c),_=(a.y+h.y*l-e.y)*t.radius/(t.radius+c);return new J(h.scale(l).add(a),new w(e.x+u,e.y+_))},CircleCircleClosestLine(r,t){const i=t.worldPos.sub(r.worldPos),n=r.worldPos.sub(t.worldPos),o=new ge(r.worldPos,i),a=new ge(t.worldPos,n),h=r.rayCast(o),l=t.rayCast(a);return new J(h.point,l.point)},CircleEdgeClosestLine(r,t){const e=r.worldPos,i=t.asLine(),s=i.begin,n=i.getEdge(),o=s,a=n;let h=(a.x*(e.x-o.x)+a.y*(e.y-o.y))/(a.x*a.x+a.y*a.y);h>1?h=1:h<0&&(h=0);const l=Math.sqrt(Math.pow(o.x+a.x*h-e.x,2)+Math.pow(o.y+a.y*h-e.y,2))-r.radius,c=(o.x+a.x*h-e.x)*r.radius/(r.radius+l),u=(o.y+a.y*h-e.y)*r.radius/(r.radius+l);return new J(a.scale(h).add(o),new w(e.x+c,e.y+u))},EdgeEdgeClosestLine(r,t){const e=r.asLine(),i=t.asLine();return hn(e,i)}};class dt extends ai{constructor(t){super(),this.offset=w.Zero,this._globalMatrix=j.identity(),this._localBoundsDirty=!0,this.offset=t.offset||w.Zero,this.radius=t.radius||0,this._globalMatrix.translate(this.offset.x,this.offset.y)}get worldPos(){return this._globalMatrix.getPosition()}get radius(){var t;if(this._radius)return this._radius;const e=this._transform,i=(t=e==null?void 0:e.globalScale)!=null?t:w.One;return this._radius=this._naturalRadius*Math.min(i.x,i.y)}set radius(t){var e;const i=this._transform,s=(e=i==null?void 0:i.globalScale)!=null?e:w.One;this._naturalRadius=t/Math.min(s.x,s.y),this._localBoundsDirty=!0,this._radius=t}clone(){return new dt({offset:this.offset.clone(),radius:this.radius})}get center(){return this._globalMatrix.getPosition()}contains(t){var e,i;return((i=(e=this._transform)==null?void 0:e.pos)!=null?i:this.offset).distance(t)<=this.radius}rayCast(t,e=1/0){var i,s;const n=this.center,o=t.dir,a=t.pos,h=n.sub(a),l=o.scale(h.dot(o)),u=h.sub(l).magnitude;if(u>this.radius)return null;{let _=0;if(ar(u,this.radius,1e-4)){if(_=-o.dot(a.sub(n)),_>0&&_<e){const f=t.getPoint(_);return{point:f,normal:f.sub(n).normalize(),collider:this,body:(i=this.owner)==null?void 0:i.get(N),distance:_}}return null}else{const f=Math.sqrt(Math.pow(o.dot(a.sub(n)),2)-Math.pow(a.sub(n).distance(),2)+Math.pow(this.radius,2)),m=-o.dot(a.sub(n))+f,p=-o.dot(a.sub(n))-f,x=[];m>=0&&x.push(m),p>=0&&x.push(p);const v=Math.min(...x);if(v<=e){const g=t.getPoint(v);return{point:g,normal:g.sub(n).normalize(),collider:this,body:(s=this.owner)==null?void 0:s.get(N),distance:v}}return null}}}getClosestLineBetween(t){if(t instanceof dt)return qt.CircleCircleClosestLine(this,t);if(t instanceof lt)return qt.PolygonCircleClosestLine(t,this).flip();if(t instanceof St)return qt.CircleEdgeClosestLine(this,t).flip();throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}collide(t){if(t instanceof dt)return zt.CollideCircleCircle(this,t);if(t instanceof lt)return zt.CollideCirclePolygon(this,t);if(t instanceof St)return zt.CollideCircleEdge(this,t);throw new Error(`Circle could not collide with unknown CollisionShape ${typeof t}`)}getFurthestPoint(t){return this.center.add(t.normalize().scale(this.radius))}getFurthestLocalPoint(t){return t.normalize().scale(this.radius)}get bounds(){return this.localBounds.transform(this._globalMatrix)}get localBounds(){return this._localBoundsDirty&&(this._localBounds=new F(-this._naturalRadius,-this._naturalRadius,+this._naturalRadius,+this._naturalRadius),this._localBoundsDirty=!1),this._localBounds}get axes(){return[]}getInertia(t){return t*this.radius*this.radius/2}update(t){var e;this._transform=t,((e=t.matrix)!=null?e:this._globalMatrix).clone(this._globalMatrix),this._globalMatrix.translate(this.offset.x,this.offset.y),this._radius=void 0}project(t){const e=[],s=this.center.dot(t);return e.push(s),e.push(s+this.radius),e.push(s-this.radius),new ei(Math.min.apply(Math,e),Math.max.apply(Math,e))}debug(t,e,i){var s,n,o,a;const{lineWidth:h}={lineWidth:1,...i},l=this._transform,c=(s=l==null?void 0:l.globalScale)!=null?s:w.One,u=(n=l==null?void 0:l.globalRotation)!=null?n:0,_=(o=l==null?void 0:l.globalPos)!=null?o:w.Zero;t.save(),t.translate(_.x,_.y),t.rotate(u),t.scale(c.x,c.y),t.debug.drawCircle((a=this.offset)!=null?a:w.Zero,this._naturalRadius,T.Transparent,e,h),t.restore()}}class xe{constructor(t,e,i,s,n,o,a,h){this._canceled=!1,this.bodyA=null,this.bodyB=null;var l,c,u,_,f,m;if(this.colliderA=t,this.colliderB=e,this.mtv=i,this.normal=s,this.tangent=n,this.points=o,this.localPoints=a,this.info=h,this.id=pt.calculatePairHash(t.id,e.id),t.composite||e.composite){const p=((l=t.composite)==null?void 0:l.compositeStrategy)==="separate"?t.id:(u=(c=t.composite)==null?void 0:c.id)!=null?u:t.id,x=((_=e.composite)==null?void 0:_.compositeStrategy)==="separate"?e.id:(m=(f=e.composite)==null?void 0:f.id)!=null?m:e.id;this.id+="|"+pt.calculatePairHash(p,x)}this.colliderA.owner&&(this.bodyA=this.colliderA.owner.get(N)),this.colliderB.owner&&(this.bodyB=this.colliderB.owner.get(N))}matchAwake(){const t=this.bodyA,e=this.bodyB;t&&e&&t.isSleeping!==e.isSleeping&&(t.isSleeping&&t.collisionType!==M.Fixed&&e.sleepMotion>=t.wakeThreshold&&(t.isSleeping=!1),e.isSleeping&&e.collisionType!==M.Fixed&&t.sleepMotion>=e.wakeThreshold&&(e.isSleeping=!1))}isCanceled(){return this._canceled}cancel(){this._canceled=!0}bias(t){if(t!==this.colliderA&&t!==this.colliderB)throw new Error("Collider must be either colliderA or colliderB from this contact");if(t===this.colliderA)return this;const e=this.colliderA,i=this.colliderB;return this.colliderB=e,this.colliderA=i,this.mtv=this.mtv.negate(),this.normal=this.normal.negate(),this.tangent=this.tangent.negate(),this}}class Ui{constructor(t,e,i=100){this.builder=t,this.recycler=e,this.maxObjects=i,this.totalAllocations=0,this.index=0,this.objects=[],this.disableWarnings=!1,this._logger=R.getInstance()}dispose(){this.objects.length=0}preallocate(){for(let t=0;t<this.maxObjects;t++)this.objects[t]=this.builder()}using(t){const e=t(this);return e?this.done(...e):this.done()}borrow(t){const e=this.get();t(e),this.index--}get(){return this.index===this.maxObjects&&(this.disableWarnings||this._logger.warn("Max pooled objects reached, possible memory leak? Doubling"),this.maxObjects=this.maxObjects*2),this.objects[this.index]?this.recycler?this.recycler(this.objects[this.index++]):this.objects[this.index++]:(this.totalAllocations++,this.objects[this.index++]=this.builder())}done(...t){this.index=0;for(const e of t){const i=this.objects.indexOf(e);this.objects[i]=this.builder(),this.totalAllocations++}return t}}class Mr{constructor(){this.axis=b(0,0),this.localAxis=b(0,0),this.side=new J(b(0,0),b(0,0)),this.localSide=new J(b(0,0),b(0,0)),this.point=b(0,0),this.localPoint=b(0,0)}}const be=class ie{static findPolygonPolygonSeparation(t,e){if(e.transform.matrix.determinant()===0)return ie.findPolygonPolygonSeparationDegenerate(t,e);let i=-Number.MAX_VALUE,s=-1,n;const o=e.transform.inverse.multiply(t.transform.matrix,ie._SCRATCH_MATRIX),a=o.getRotation(),h=t.normals,l=t.points,c=e.points;for(let f=0;f<l.length;f++){const m=h[f].rotate(a,ie._ZERO,ie._SCRATCH_NORMAL),p=o.multiply(l[f],ie._SCRATCH_POINT);let x=Number.MAX_VALUE,v;for(let g=0;g<c.length;g++){const y=m.dot(c[g].sub(p,ie._SCRATCH_SUB_POINT));y<x&&(x=y,v=c[g])}x>i&&(i=x,s=f,n=v)}const u=(s+1)%l.length,_=ie.SeparationPool.get();return _.collider=t,_.separation=i,i>0||(h[s].clone(_.localAxis),h[s].rotate(t.transform.rotation,ie._ZERO,_.axis),t.transform.matrix.multiply(l[s],_.side.begin),t.transform.matrix.multiply(l[u],_.side.end),e.transform.matrix.multiply(n,_.point),_.sideId=s,n.clone(_.localPoint),l[s].clone(_.localSide.begin),l[u].clone(_.localSide.end)),_}static findCirclePolygonSeparation(t,e){const i=e.axes,n=e.center.sub(t.worldPos),o=e.getFurthestPoint(n.negate());i.push(o.sub(t.worldPos).normalize());let a=Number.MAX_VALUE,h=null,l=-1;for(let c=0;c<i.length;c++){const u=e.project(i[c]),_=t.project(i[c]),f=u.getOverlap(_);if(f<=0)return null;f<a&&(a=f,h=i[c],l=c)}return l<0?null:h.normalize().scale(a)}static findPolygonPolygonSeparationDegenerate(t,e){let i=-Number.MAX_VALUE,s=null,n=null,o=-1,a=null;const h=t.getSides(),l=t.getLocalSides();for(let c=0;c<h.length;c++){const u=h[c],_=u.normal(),f=e.getFurthestPoint(_.negate()),m=u.distanceToPoint(f,!0);m>i&&(i=m,s=u,n=_,o=c,a=f)}return{collider:t,separation:n?i:99,axis:n,side:s,localSide:l[o],sideId:o,point:a,localPoint:n?e.getFurthestLocalPoint(n.negate()):null}}};be.SeparationPool=new Ui(()=>new Mr,r=>r,500),be._ZERO=b(0,0),be._SCRATCH_POINT=b(0,0),be._SCRATCH_SUB_POINT=b(0,0),be._SCRATCH_NORMAL=b(0,0),be._SCRATCH_MATRIX=j.identity();let Ne=be;Ne.SeparationPool.disableWarnings=!0;const Ih=w.Zero,Rh=w.Zero,Mh=j.identity(),zt={CollideCircleCircle(r,t){const e=r.worldPos,i=t.worldPos,s=r.radius+t.radius,n=e.distance(i);if(n>s)return[];const o=s-n,a=i.sub(e).normalize(),h=a.perpendicular(),l=a.scale(o),c=r.getFurthestPoint(a),u=r.getFurthestLocalPoint(a),_={collider:r,separation:o,axis:a,point:c};return[new xe(r,t,l,a,h,[c],[u],_)]},CollideCirclePolygon(r,t){var e,i;let s=Ne.findCirclePolygonSeparation(r,t);if(!s)return[];s=s.dot(t.center.sub(r.center))<0?s.negate():s;const o=r.getFurthestPoint(s),h=((i=(e=r.owner)==null?void 0:e.get(P))!=null?i:new P).applyInverse(o),l=s.normalize(),c={collider:r,separation:-s.magnitude,axis:l,point:o,localPoint:h,side:t.findSide(l.negate()),localSide:t.findLocalSide(l.negate())};return[new xe(r,t,s,l,l.perpendicular(),[o],[h],c)]},CollideCircleEdge(r,t){const e=r.center,i=t.asLine(),s=i.end.sub(i.begin),n=s.dot(i.end.sub(e)),o=s.dot(e.sub(i.begin)),a=t.asLine(),h=t.asLocalLine();if(o<=0){const v=i.begin.sub(e),g=v.dot(v);if(g>r.radius*r.radius)return[];const y=v.normalize(),S=r.radius-Math.sqrt(g),A={collider:r,separation:S,axis:y,point:a.begin,side:a,localSide:h};return[new xe(r,t,y.scale(S),y,y.perpendicular(),[a.begin],[h.begin],A)]}if(n<=0){const v=i.end.sub(e),g=v.dot(v);if(g>r.radius*r.radius)return[];const y=v.normalize(),S=r.radius-Math.sqrt(g),A={collider:r,separation:S,axis:y,point:a.end,side:a,localSide:h};return[new xe(r,t,y.scale(S),y,y.perpendicular(),[a.end],[h.end],A)]}const l=s.dot(s),c=i.begin.scale(n).add(i.end.scale(o)).scale(1/l),u=e.sub(c),_=u.dot(u);if(_>r.radius*r.radius)return[];let f=s.perpendicular();f.dot(e.sub(i.begin))<0&&(f.x=-f.x,f.y=-f.y),f=f.normalize();const m=r.radius-Math.sqrt(_),p=f.scale(m),x={collider:r,separation:m,axis:f,point:c,side:a,localSide:h};return[new xe(r,t,p,f.negate(),f.negate().perpendicular(),[c],[c.sub(t.worldPos)],x)]},CollideEdgeEdge(){return[]},CollidePolygonEdge(r,t){var e;const i=r.center,n=t.center.sub(i).normalize(),o=new lt({points:[t.begin,t.end,t.end.add(n.scale(100)),t.begin.add(n.scale(100))],offset:t.offset});o.owner=t.owner,((e=t.owner)==null?void 0:e.get(P))&&o.update(t.owner.get(P).get());const h=this.CollidePolygonPolygon(r,o);return h.length&&(h[0].colliderB=t,h[0].id=pt.calculatePairHash(r.id,t.id)),h},CollidePolygonPolygon(r,t){const e=Ne.findPolygonPolygonSeparation(r,t);if(e.separation>0)return[];const i=Ne.findPolygonPolygonSeparation(t,r);if(i.separation>0)return[];const s=e.separation>i.separation?e:i,n=s.collider===r?t:r,o=s.collider===r?r:t,a=n.transform.inverse.multiply(o.transform.matrix,Mh),h=a.getRotation(),l=o.normals[s.sideId].rotate(h,Ih,Rh);let c=Number.MAX_VALUE,u=0;for(let v=0;v<n.normals.length;v++){const g=l.dot(n.normals[v]);g<c&&(c=g,u=v)}if(!s.localSide||!s.localAxis||!s.axis)return[];const _=s.localSide.transform(a),f=s.localAxis.perpendicular().negate().rotate(h),p=new J(n.points[u],n.points[(u+1)%n.points.length]).clip(f.negate(),-f.dot(_.begin),!1);let x=null;if(p&&(x=p.clip(f,f.dot(_.end),!1)),x){const v=[],g=[],y=x.getPoints();for(let I=0;I<y.length;I++){const C=y[I];_.below(C)&&(v.push(C),g.push(n.transform.apply(C)))}let S=s.axis,A=S.perpendicular();return t.center.sub(r.center).dot(S)<0&&(S=S.negate(),A=S.perpendicular()),[new xe(r,t,S.scale(-s.separation),S,A,g,v,s)]}return[]},FindContactSeparation(r,t){var e,i,s,n;const o=r.colliderA,a=(i=(e=r.bodyA)==null?void 0:e.transform)!=null?i:new P,h=r.colliderB,l=(n=(s=r.bodyB)==null?void 0:s.transform)!=null?n:new P;if(o instanceof dt&&h instanceof dt){const c=o.radius+h.radius,u=a.pos.distance(l.pos);return-(c-u)}if(o instanceof lt&&h instanceof lt&&r.info.localSide){let c,u;return r.info.collider===o?(c=new J(a.apply(r.info.localSide.begin).add(o.offset),a.apply(r.info.localSide.end).add(o.offset)),u=l.apply(t).add(h.offset)):(c=new J(l.apply(r.info.localSide.begin).add(h.offset),l.apply(r.info.localSide.end).add(h.offset)),u=a.apply(t).add(o.offset)),c.distanceToPoint(u,!0)}if(o instanceof lt&&h instanceof dt||h instanceof lt&&o instanceof dt){const c=a.apply(t);if(r.info.side)return r.info.side.distanceToPoint(c,!0)}if(o instanceof St&&h instanceof lt||h instanceof St&&o instanceof lt){let c;if(r.info.collider===o?c=l.apply(t):c=a.apply(t),r.info.side)return r.info.side.distanceToPoint(c,!0)}if(o instanceof dt&&h instanceof St||h instanceof dt&&o instanceof St){const c=l.apply(t);let u;o instanceof dt&&(u=o.getFurthestPoint(r.normal));const _=c.distance(u);if(r.info.side)return _>0?-_:0}return 0}};class St extends ai{constructor(t){var e;super(),this._globalMatrix=j.identity(),this.begin=t.begin||w.Zero,this.end=t.end||w.Zero,this.offset=(e=t.offset)!=null?e:w.Zero}clone(){return new St({begin:this.begin.clone(),end:this.end.clone()})}get worldPos(){var t;const e=this._transform;return(t=e==null?void 0:e.globalPos.add(this.offset))!=null?t:this.offset}get center(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return t.average(e)}_getTransformedBegin(){return this._globalMatrix.multiply(this.begin)}_getTransformedEnd(){return this._globalMatrix.multiply(this.end)}getSlope(){const t=this._getTransformedBegin(),e=this._getTransformedEnd(),i=t.distance(e);return e.sub(t).scale(1/i)}getLength(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return t.distance(e)}contains(){return!1}rayCast(t,e=1/0){var i;const s=this._getTransformedBegin().sub(t.pos);if(t.dir.cross(this.getSlope())===0&&s.cross(t.dir)!==0)return null;const n=t.dir.cross(this.getSlope());if(n===0)return null;const o=s.cross(this.getSlope())/n;if(o>=0&&o<=e){const a=s.cross(t.dir)/n/this.getLength();if(a>=0&&a<=1)return{distance:o,normal:this.asLine().normal(),collider:this,body:(i=this.owner)==null?void 0:i.get(N),point:t.getPoint(o)}}return null}getClosestLineBetween(t){if(t instanceof dt)return qt.CircleEdgeClosestLine(t,this);if(t instanceof lt)return qt.PolygonEdgeClosestLine(t,this).flip();if(t instanceof St)return qt.EdgeEdgeClosestLine(this,t);throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}collide(t){if(t instanceof dt)return zt.CollideCircleEdge(t,this);if(t instanceof lt)return zt.CollidePolygonEdge(t,this);if(t instanceof St)return zt.CollideEdgeEdge();throw new Error(`Edge could not collide with unknown CollisionShape ${typeof t}`)}getFurthestPoint(t){const e=this._getTransformedBegin(),i=this._getTransformedEnd();return t.dot(e)>0?e:i}_boundsFromBeginEnd(t,e,i=10){return new F(Math.min(t.x,e.x)-i,Math.min(t.y,e.y)-i,Math.max(t.x,e.x)+i,Math.max(t.y,e.y)+i)}get bounds(){const t=this._getTransformedBegin(),e=this._getTransformedEnd();return this._boundsFromBeginEnd(t,e)}get localBounds(){return this._boundsFromBeginEnd(this.begin,this.end)}asLine(){return new J(this._getTransformedBegin(),this._getTransformedEnd())}asLocalLine(){return new J(this.begin,this.end)}get axes(){const e=this._getTransformedEnd().sub(this._getTransformedBegin()).normal(),i=[];return i.push(e),i.push(e.negate()),i.push(e.normal()),i.push(e.normal().negate()),i}getInertia(t){const e=this.end.sub(this.begin).distance()/2;return t*e*e}update(t){var e;this._transform=t,((e=t.matrix)!=null?e:this._globalMatrix).clone(this._globalMatrix),this._globalMatrix.translate(this.offset.x,this.offset.y)}project(t){const e=[],i=[this._getTransformedBegin(),this._getTransformedEnd()],s=i.length;for(let n=0;n<s;n++)e.push(i[n].dot(t));return new ei(Math.min.apply(Math,e),Math.max.apply(Math,e))}debug(t,e){const i=this._getTransformedBegin(),s=this._getTransformedEnd();t.debug.drawLine(i,s,{color:e,lineWidth:2}),t.debug.drawCircle(i,2,e),t.debug.drawCircle(s,2,e)}}class lt extends ai{constructor(t){var e;super(),this._logger=R.getInstance(),this._transform=new Kt,this._transformedPoints=[],this._sides=[],this._localSides=[],this._transformedPointsDirty=!0,this._sidesDirty=!0,this._localSidesDirty=!0,this._localBoundsDirty=!0,this.offset=(e=t.offset)!=null?e:w.Zero,this._transform.pos.x+=this.offset.x,this._transform.pos.y+=this.offset.y,this.points=t.points,this.isConvex()||t.suppressConvexWarning||this._logger.warn("Excalibur only supports convex polygon colliders and will not behave properly.Call PolygonCollider.triangulate() to build a new collider composed of smaller convex triangles"),this._calculateTransformation()}flagDirty(){this._localBoundsDirty=!0,this._localSidesDirty=!0,this._transformedPointsDirty=!0,this._sidesDirty=!0}get normals(){return this._normals}set points(t){if(t.length<3)throw new Error("PolygonCollider cannot be created with less that 3 points");this._points=t,this._checkAndUpdateWinding(this._points),this._calculateNormals(),this.flagDirty()}_calculateNormals(){const t=[];for(let e=0;e<this._points.length;e++)t.push(this._points[(e+1)%this._points.length].sub(this._points[e]).normal());this._normals=t}get points(){return this._points}get transform(){return this._transform}_checkAndUpdateWinding(t){this._isCounterClockwiseWinding(t)||t.reverse()}_isCounterClockwiseWinding(t){let e=0;for(let i=0;i<t.length;i++)e+=(t[(i+1)%t.length].x-t[i].x)*(t[(i+1)%t.length].y+t[i].y);return e<0}isConvex(){if(this.points.length<3)return!1;let t=this.points[this.points.length-2],e=this.points[this.points.length-1],i=Math.atan2(e.y-t.y,e.x-t.x),s=0,n=0,o=0;for(const[a,h]of this.points.entries()){if(t=e,s=i,e=h,i=Math.atan2(e.y-t.y,e.x-t.x),t.equals(e))return!1;let l=i-s;if(l<=-Math.PI?l+=Math.PI*2:l>Math.PI&&(l-=Math.PI*2),a===0){if(l===0)return!1;n=l>0?1:-1}else if(n*l<=0)return!1;o+=l}return Math.abs(Math.round(o/(Math.PI*2)))===1}tessellate(){const t=[];for(let e=1;e<this.points.length-2;e++)t.push([this.points[0],this.points[e+1],this.points[e+2]]);return t.push([this.points[0],this.points[1],this.points[2]]),new at(t.map(e=>ut.Polygon(e)))}triangulate(){if(this.points.length<3)throw Error("Invalid polygon");const t=[],e=[...this.points].reverse();let i=e.length;function s(u){return u===0?i-1:u-1}function n(u){return u===i-1?0:u+1}function o(u){const _=s(u),f=n(u),m=e[_],p=e[u],x=e[f],v=m.sub(p),g=x.sub(p);return!(v.cross(g)<0)}const a=e.map((u,_)=>o(_));function h(u,_,f,m){const p=f.sub(_),x=m.sub(f),v=_.sub(m),g=u.sub(_),y=u.sub(f),S=u.sub(m),A=p.cross(g),I=x.cross(y),C=v.cross(S);return!(A>0||I>0||C>0)}function l(){for(let u=0;u<i;u++)if(a[u]){const _=s(u),f=n(u),m=e[_],p=e[u],x=e[f];let v=!0;for(let g=0;g<i;g++){if(g===u||g===_||g===f)continue;const y=e[g];if(h(y,m,p,x)){v=!1;break}}if(v)return u}for(let u=0;u<i;u++)if(a[u])return u;return 0}function c(u){const _=s(u),f=n(u),m=e[_],p=e[u],x=e[f];t.push([m,p,x]),e.splice(u,1),a.splice(u,1),i--}for(;i>3;){const u=l();c(u);for(let _=0;_<i;_++)a[_]=o(_)}return t.push([e[0],e[1],e[2]]),new at(t.map(u=>ut.Polygon(u,w.Zero,!0)))}clone(){return new lt({offset:this.offset.clone(),points:this.points.map(t=>t.clone())})}get worldPos(){return this._transform.pos}get center(){return this.bounds.center}_calculateTransformation(){const t=this.points,e=t.length;this._transformedPoints.length=0;for(let i=0;i<e;i++)this._transformedPoints[i]=this._transform.apply(t[i].clone())}getTransformedPoints(){return this._transformedPointsDirty&&(this._calculateTransformation(),this._transformedPointsDirty=!1),this._transformedPoints}getSides(){if(this._sidesDirty){const t=[],e=this.getTransformedPoints(),i=e.length;for(let s=0;s<i;s++)t.push(new J(e[s],e[(s+1)%i]));this._sides=t,this._sidesDirty=!1}return this._sides}getLocalSides(){if(this._localSidesDirty){const t=[],e=this.points,i=e.length;for(let s=0;s<i;s++)t.push(new J(e[s],e[(s+1)%i]));this._localSides=t,this._localSidesDirty=!1}return this._localSides}findSide(t){const e=this.getSides();let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=e[n],h=o.normal().dot(t);h>s&&(i=o,s=h)}return i}findLocalSide(t){const e=this.getLocalSides();let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=e[n],h=o.normal().dot(t);h>s&&(i=o,s=h)}return i}get axes(){const t=[],e=this.getSides();for(let i=0;i<e.length;i++)t.push(e[i].normal());return t}update(t){t&&(t.cloneWithParent(this._transform),this._transformedPointsDirty=!0,this._sidesDirty=!0,(this.offset.x!==0||this.offset.y!==0)&&(this._transform.pos.x+=this.offset.x,this._transform.pos.y+=this.offset.y),this._transform.isMirrored()&&(this.points=this.points.map(e=>b(e.x*G(this._transform.scale.x),e.y*G(this._transform.scale.y))),this._transform.scale.x=Math.abs(this._transform.scale.x),this._transform.scale.y=Math.abs(this._transform.scale.y)))}contains(t){const e=this._transform.applyInverse(t),i=new ge(e,new w(1,0));let s=0;const n=this.getLocalSides();for(let o=0;o<n.length;o++){const a=n[o];i.intersect(a)>=0&&s++}return s%2!==0}getClosestLineBetween(t){if(t instanceof dt)return qt.PolygonCircleClosestLine(this,t);if(t instanceof lt)return qt.PolygonPolygonClosestLine(this,t);if(t instanceof St)return qt.PolygonEdgeClosestLine(this,t);throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}collide(t){if(t instanceof dt)return zt.CollideCirclePolygon(t,this);if(t instanceof lt)return zt.CollidePolygonPolygon(this,t);if(t instanceof St)return zt.CollidePolygonEdge(this,t);throw new Error(`Polygon could not collide with unknown CollisionShape ${typeof t}`)}getFurthestPoint(t){const e=this.getTransformedPoints();let i=null,s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=t.dot(e[n]);o>s&&(s=o,i=e[n])}return i}getFurthestLocalPoint(t){const e=this.points;let i=e[0],s=-Number.MAX_VALUE;for(let n=0;n<e.length;n++){const o=t.dot(e[n]);o>s&&(s=o,i=e[n])}return i}getClosestFace(t){const e=this.getSides();let i=Number.POSITIVE_INFINITY,s=-1,n=-1;for(let o=0;o<e.length;o++){const a=e[o].distanceToPoint(t);a<i&&(i=a,s=o,n=a)}return s!==-1?{distance:e[s].normal().scale(n),face:e[s]}:null}get bounds(){return this.localBounds.transform(this._transform.matrix)}get localBounds(){return this._localBoundsDirty&&(this._localBounds=F.fromPoints(this.points),this._localBoundsDirty=!1),this._localBounds}getInertia(t){if(this._cachedMass===t&&this._cachedInertia)return this._cachedInertia;let e=0,i=0;const s=this.points;for(let n=0;n<s.length;n++){const o=(n+1)%s.length,a=s[o].cross(s[n]);e+=a*(s[n].dot(s[n])+s[n].dot(s[o])+s[o].dot(s[o])),i+=a}return this._cachedMass=t,this._cachedInertia=t/6*(e/i)}rayCast(t,e=1/0){var i;const s=this.getSides(),n=s.length;let o=Number.MAX_VALUE,a,h=-1;for(let l=0;l<n;l++){const c=t.intersect(s[l]);c>=0&&c<o&&c<=e&&(o=c,a=s[l],h=l)}return h>=0?{collider:this,distance:o,body:(i=this.owner)==null?void 0:i.get(N),point:t.getPoint(o),normal:a.normal()}:null}project(t){const e=this.getTransformedPoints(),i=e.length;let s=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let o=0;o<i;o++){const a=e[o].dot(t);s=Math.min(s,a),n=Math.max(n,a)}return new ei(s,n)}debug(t,e,i){const s=this.getTransformedPoints();Tt.drawPolygon(s,{color:e})}}class ut{static Box(t,e,i=w.Half,s=w.Zero){return new lt({points:new F(-t*i.x,-e*i.y,t-t*i.x,e-e*i.y).getPoints().slice(),offset:s})}static Polygon(t,e=w.Zero,i=!1){return new lt({points:t,offset:e,suppressConvexWarning:i})}static Circle(t,e=w.Zero){return new dt({radius:t,offset:e})}static Edge(t,e){return new St({begin:t,end:e})}static Capsule(t,e,i=w.Zero){const s=R.getInstance();if(t===e&&s.warn("A capsule collider with equal width and height is a circle, consider using a ex.Shape.Circle or ex.CircleCollider"),e>=t){const o=new at([ut.Circle(t/2,b(0,-e/2+t/2).add(i)),ut.Box(t,e-t,w.Half,i),ut.Circle(t/2,b(0,e/2-t/2).add(i))]);return o.compositeStrategy="together",o}else{const o=new at([ut.Circle(e/2,b(-t/2+e/2,0).add(i)),ut.Box(t-e,e,w.Half,i),ut.Circle(e/2,b(t/2-e/2,0).add(i))]);return o.compositeStrategy="together",o}}}function It(r,t){return r&&(r.__isProxy===void 0?new Proxy(r,{set:(e,i,s)=>(e[i]!==s&&(e[i]=s,typeof i=="string"&&i[0]!=="_"&&t(e)),!0),get:(e,i)=>i!=="__isProxy"?e[i]:!0}):r)}const Fr=(r=[],t,e)=>({get:(i,s)=>s==="__isProxy"?!0:typeof i[s]=="object"&&i[s]!=null?new Proxy(i[s],Fr([...r,s],t,e)):i[s],set:(i,s,n)=>(typeof s=="string"&&s[0]!=="_"&&t(e),i[s]=n,!0)});function Fh(r,t){return r&&(r.__isProxy===void 0?new Proxy(r,Fr([],t,r)):r)}const Dr=class ka{constructor(t){this.id=ka._ID++,this.transform=j.identity(),this._transformStale=!0,this.showDebug=!1,this._flipHorizontal=!1,this._flipVertical=!1,this._rotation=0,this.opacity=1,this._scale=w.One,this._width=0,this._height=0;var e,i,s,n,o,a,h;t&&(this.origin=(e=t.origin)!=null?e:this.origin,this.flipHorizontal=(i=t.flipHorizontal)!=null?i:this.flipHorizontal,this.flipVertical=(s=t.flipVertical)!=null?s:this.flipVertical,this.rotation=(n=t.rotation)!=null?n:this.rotation,this.opacity=(o=t.opacity)!=null?o:this.opacity,this.scale=(a=t.scale)!=null?a:this.scale,this.tint=(h=t.tint)!=null?h:this.tint,t.width&&(this._width=t.width),t.height&&(this._height=t.height))}isStale(){return this._transformStale}get flipHorizontal(){return this._flipHorizontal}set flipHorizontal(t){this._flipHorizontal=t,this._transformStale=!0}get flipVertical(){return this._flipVertical}set flipVertical(t){this._flipVertical=t,this._transformStale=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._transformStale=!0}get scale(){return this._scale}set scale(t){this._scale=It(t,()=>{this._transformStale=!0}),this._transformStale=!0}get origin(){return this._origin}set origin(t){t&&(this._origin=It(t,()=>{this._transformStale=!0})),this._transformStale=!0}cloneGraphicOptions(){return{width:this.width/this.scale.x,height:this.height/this.scale.y,origin:this.origin?this.origin.clone():void 0,flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical,rotation:this.rotation,opacity:this.opacity,scale:this.scale?this.scale.clone():void 0,tint:this.tint?this.tint.clone():void 0}}get width(){return Math.abs(this._width*this.scale.x)}get height(){return Math.abs(this._height*this.scale.y)}set width(t){this._width=t,this._transformStale=!0}set height(t){this._height=t,this._transformStale=!0}get localBounds(){return F.fromDimension(this.width,this.height,w.Zero)}draw(t,e,i){this._preDraw(t,e,i),this._drawImage(t,0,0),this._postDraw(t)}_preDraw(t,e,i){t.save(),t.translate(e,i),this._transformStale&&(this.transform.reset(),this.transform.scale(Math.abs(this.scale.x),Math.abs(this.scale.y)),this._rotate(this.transform),this._flip(this.transform),this._transformStale=!1),t.multiply(this.transform),t.opacity=t.opacity*this.opacity,this.tint&&(t.tint=this.tint)}_rotate(t){var e;const i=this.scale.x>0?1:-1,s=this.scale.y>0?1:-1,n=(e=this.origin)!=null?e:b(this.width/2,this.height/2);t.translate(n.x,n.y),t.rotate(this.rotation),t.scale(i,s),t.translate(-n.x,-n.y)}_flip(t){this.flipHorizontal&&(t.translate(this.width/this.scale.x,0),t.scale(-1,1)),this.flipVertical&&(t.translate(0,this.height/this.scale.y),t.scale(1,-1))}_postDraw(t){this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore()}};Dr._ID=0;let st=Dr;var Br=(r=>(r.Forward="forward",r.Backward="backward",r))(Br||{}),kr=(r=>(r.End="end",r.Loop="loop",r.PingPong="pingpong",r.Freeze="freeze",r))(kr||{});const Dh={Frame:"frame",Loop:"loop",End:"end"},Lr=class rr extends st{constructor(t){var e,i,s;super(t),this.events=new X,this.frames=[],this.strategy="loop",this.frameDuration=100,this._idempotencyToken=-1,this._firstTick=!0,this._currentFrame=0,this._timeLeftInFrame=0,this._pingPongDirection=1,this._done=!1,this._playing=!0,this._speed=1,this._wasResetDuringFrameCalc=!1,this._reversed=!1,this.frames=t.frames,this.speed=(e=t.speed)!=null?e:this.speed,this.strategy=(i=t.strategy)!=null?i:this.strategy,this.frameDuration=t.totalDuration?t.totalDuration/this.frames.length:(s=t.frameDuration)!=null?s:this.frameDuration,this.data=t.data?new Map(Object.entries(t.data)):new Map,t.reverse&&this.reverse(),this.goToFrame(0)}clone(){const t=this.constructor;return new t({frames:this.frames.map(e=>({...e})),frameDuration:this.frameDuration,speed:this.speed,reverse:this._reversed,strategy:this.strategy,...this.cloneGraphicOptions()})}get width(){const t=this.currentFrame;return t&&t.graphic?Math.abs(t.graphic.width*this.scale.x):0}get height(){const t=this.currentFrame;return t&&t.graphic?Math.abs(t.graphic.height*this.scale.y):0}static fromSpriteSheet(t,e,i,s="loop",n){const o=t.sprites.length-1,a=[],h=[];return e.forEach(l=>{l<0||l>o?h.push(l):a.push(l)}),h.length&&rr._LOGGER.warn(`Indices into SpriteSheet were provided that don't exist: frames ${h.join(",")} will not be shown`),new this({frames:a.map(l=>({graphic:t.sprites[l],duration:i})),strategy:s,data:n})}static fromSpriteSheetCoordinates(t){var e;const{spriteSheet:i,frameCoordinates:s,durationPerFrame:n,durationPerFrameMs:o,speed:a,strategy:h,reverse:l,data:c}=t,u=(e=n!=null?n:o)!=null?e:100,_=[];for(const f of s){const{x:m,y:p,duration:x,options:v}=f,g=i.getSprite(m,p,v);g?_.push({graphic:g,duration:x!=null?x:u}):rr._LOGGER.warn(`Skipping frame! SpriteSheet does not have coordinate (${m}, ${p}), please check your SpriteSheet to confirm that sprite exists`)}return new this({frames:_,strategy:h,speed:a,reverse:l,data:c})}get speed(){return this._speed}set speed(t){this._speed=B(Math.abs(t),0,1/0)}get currentFrame(){return this._currentFrame>=0&&this._currentFrame<this.frames.length?this.frames[this._currentFrame]:null}get currentFrameIndex(){return this._currentFrame}get currentFrameTimeLeft(){return this._timeLeftInFrame}get isPlaying(){return this._playing}get isReversed(){return this._reversed}reverse(){this.frames=this.frames.slice().reverse(),this._reversed=!this._reversed}get direction(){return!!(this._reversed&&this._pingPongDirection===1)?"backward":"forward"}play(){this._playing=!0}pause(){this._playing=!1,this._firstTick=!0}reset(){this._wasResetDuringFrameCalc=!0,this._done=!1,this._firstTick=!0,this._currentFrame=0,this._timeLeftInFrame=this.frameDuration;const t=this.frames[this._currentFrame];t&&(this._timeLeftInFrame=(t==null?void 0:t.duration)||this.frameDuration)}get canFinish(){switch(this.strategy){case"end":case"freeze":return!0;default:return!1}}get done(){return this._done}goToFrame(t,e){this._currentFrame=t,this._timeLeftInFrame=e!=null?e:this.frameDuration;const i=this.frames[this._currentFrame];i&&!this._done&&(this._timeLeftInFrame=e!=null?e:(i==null?void 0:i.duration)||this.frameDuration,this.events.emit("frame",{...i,frameIndex:this.currentFrameIndex}))}_nextFrame(){this._wasResetDuringFrameCalc=!1;const t=this._currentFrame;if(this._done)return t;let e=-1;switch(this.strategy){case"loop":{e=(t+1)%this.frames.length,e===0&&this.events.emit("loop",this);break}case"end":{e=t+1,e>=this.frames.length&&(this._done=!0,this._currentFrame=this.frames.length,this.events.emit("end",this));break}case"freeze":{e=B(t+1,0,this.frames.length-1),t+1>=this.frames.length&&(this._done=!0,this.events.emit("end",this));break}case"pingpong":{t+this._pingPongDirection>=this.frames.length&&(this._pingPongDirection=-1,this.events.emit("loop",this)),t+this._pingPongDirection<0&&(this._pingPongDirection=1,this.events.emit("loop",this)),e=t+this._pingPongDirection%this.frames.length;break}}return this._wasResetDuringFrameCalc?(this._wasResetDuringFrameCalc=!1,this._currentFrame):e}tick(t,e=0){this._idempotencyToken!==e&&(this._idempotencyToken=e,this._playing&&(this._firstTick&&(this._firstTick=!1,this.events.emit("frame",{...this.currentFrame,frameIndex:this.currentFrameIndex})),this._timeLeftInFrame-=t*this._speed,this._timeLeftInFrame<=0&&this.goToFrame(this._nextFrame())))}_drawImage(t,e,i){this.currentFrame&&this.currentFrame.graphic&&this.currentFrame.graphic.draw(t,e,i)}};Lr._LOGGER=R.getInstance();let zi=Lr;class We extends st{constructor(t){var e;super(t),this._logger=R.getInstance(),this.useAnchor=!0,this.members=[],this.members=t.members,this.useAnchor=(e=t.useAnchor)!=null?e:this.useAnchor,this._updateDimensions()}clone(){return new We({members:[...this.members],...this.cloneGraphicOptions()})}_updateDimensions(){const t=this.localBounds;return this.width=t.width,this.height=t.height,t}get localBounds(){const t=new F;for(const e of this.members)if(e instanceof st)e.localBounds.combine(t,t);else{const{graphic:i,offset:s,useBounds:n}=e;i?(n===void 0?!0:n)&&i.localBounds.translate(s).combine(t,t):this._logger.warnOnce(`Graphics group member has an null or undefined graphic, member definition: ${JSON.stringify(e)}.`)}return t}_isAnimationOrGroup(t){return t instanceof zi||t instanceof We}tick(t,e){for(const i of this.members){let s;i instanceof st?s=i:s=i.graphic,this._isAnimationOrGroup(s)&&s.tick(t,e)}}reset(){for(const t of this.members){let e;t instanceof st?e=t:e=t.graphic,this._isAnimationOrGroup(e)&&e.reset()}}_preDraw(t,e,i){this._updateDimensions(),super._preDraw(t,this.useAnchor?e:0,this.useAnchor?i:0)}_drawImage(t,e,i){const s=w.Zero;for(const n of this.members){let o;n instanceof st?o=n:(o=n.graphic,n.offset.clone(s)),o&&(t.save(),t.translate(e,i),o.draw(t,s.x,s.y),this.showDebug&&t.debug.drawRect(0,0,this.width,this.height),t.restore())}}}class Ve extends st{constructor(t){var e,i,s,n,o,a,h,l,c,u;super(yr({...t},["width","height"])),this.lineCap="butt",this.quality=1,this._dirty=!0,this._smoothing=!1,this._color=It(T.Black,()=>this.flagDirty()),this._lineWidth=1,this._lineDash=[],this._padding=0,t&&(this.quality=(e=t.quality)!=null?e:this.quality,this.color=(i=t.color)!=null?i:T.Black,this.strokeColor=t==null?void 0:t.strokeColor,this.smoothing=(s=t.smoothing)!=null?s:this.smoothing,this.lineWidth=(n=t.lineWidth)!=null?n:this.lineWidth,this.lineDash=(o=t.lineDash)!=null?o:this.lineDash,this.lineCap=(a=t.lineCap)!=null?a:this.lineCap,this.padding=(h=t.padding)!=null?h:this.padding,this.filtering=(l=t.filtering)!=null?l:this.filtering),this._bitmap=document.createElement("canvas");const _=(c=t==null?void 0:t.width)!=null?c:this._bitmap.width,f=(u=t==null?void 0:t.height)!=null?u:this._bitmap.height;this.width=_,this.height=f;const m=this._bitmap.getContext("2d");if(m)this._ctx=m;else throw new Error("Browser does not support 2d canvas drawing, cannot create Raster graphic")}cloneRasterOptions(){return{color:this.color?this.color.clone():void 0,strokeColor:this.strokeColor?this.strokeColor.clone():void 0,smoothing:this.smoothing,lineWidth:this.lineWidth,lineDash:this.lineDash,lineCap:this.lineCap,quality:this.quality,padding:this.padding}}get dirty(){return this._dirty}flagDirty(){this._dirty=!0}get width(){return Math.abs(this._getTotalWidth()*this.scale.x)}set width(t){t/=Math.abs(this.scale.x),this._bitmap.width=t,this._originalWidth=t,this.flagDirty()}get height(){return Math.abs(this._getTotalHeight()*this.scale.y)}set height(t){t/=Math.abs(this.scale.y),this._bitmap.height=t,this._originalHeight=t,this.flagDirty()}_getTotalWidth(){var t;return(((t=this._originalWidth)!=null?t:this._bitmap.width)+this.padding*2)*1}_getTotalHeight(){var t;return(((t=this._originalHeight)!=null?t:this._bitmap.height)+this.padding*2)*1}get localBounds(){return F.fromDimension(this._getTotalWidth()*this.scale.x,this._getTotalHeight()*this.scale.y,w.Zero)}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this.flagDirty()}get color(){return this._color}set color(t){this.flagDirty(),this._color=It(t,()=>this.flagDirty())}get strokeColor(){return this._strokeColor}set strokeColor(t){this.flagDirty(),t&&(this._strokeColor=It(t,()=>this.flagDirty()))}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.flagDirty()}get lineDash(){return this._lineDash}set lineDash(t){this._lineDash=t,this.flagDirty()}get padding(){return this._padding}set padding(t){this._padding=t,this.flagDirty()}rasterize(){this._dirty=!1,this._ctx.clearRect(0,0,this._getTotalWidth(),this._getTotalHeight()),this._ctx.save(),this._applyRasterProperties(this._ctx),this.execute(this._ctx),this._ctx.restore()}_applyRasterProperties(t){var e,i,s,n;this._bitmap.width=this._getTotalWidth()*this.quality,this._bitmap.height=this._getTotalHeight()*this.quality,this._bitmap.setAttribute("filtering",this.filtering),this._bitmap.setAttribute("forceUpload","true"),t.scale(this.quality,this.quality),t.translate(this.padding,this.padding),t.imageSmoothingEnabled=this.smoothing,t.lineWidth=this.lineWidth,t.setLineDash((e=this.lineDash)!=null?e:t.getLineDash()),t.lineCap=this.lineCap,t.strokeStyle=(s=(i=this.strokeColor)==null?void 0:i.toString())!=null?s:"",t.fillStyle=(n=this.color)==null?void 0:n.toString()}_drawImage(t,e,i){this._dirty&&this.rasterize(),t.scale(1/this.quality,1/this.quality),t.drawImage(this._bitmap,e,i)}}var ln=(r=>(r.Em="em",r.Rem="rem",r.Px="px",r.Pt="pt",r.Percent="%",r))(ln||{}),cn=(r=>(r.Left="left",r.Right="right",r.Center="center",r.Start="start",r.End="end",r))(cn||{}),dn=(r=>(r.Top="top",r.Hanging="hanging",r.Middle="middle",r.Alphabetic="alphabetic",r.Ideographic="ideographic",r.Bottom="bottom",r))(dn||{}),un=(r=>(r.Normal="normal",r.Italic="italic",r.Oblique="oblique",r))(un||{}),_n=(r=>(r.LeftToRight="ltr",r.RightToLeft="rtl",r))(_n||{}),mt=(r=>(r.Pixel="Pixel",r.Blended="Blended",r))(mt||{});function Ge(r){switch(r){case"Pixel":return"Pixel";case"Blended":return"Blended";default:return}}function fn(r,t=T.Red,e,i,s,n,o=1,a="butt"){r.save(),r.beginPath(),r.lineWidth=o,r.lineCap=a,r.strokeStyle=t.toString(),r.moveTo(e,i),r.lineTo(s,n),r.closePath(),r.stroke(),r.restore()}function Bh(r,t=T.Red,e){r.beginPath(),r.strokeStyle=t.toString(),r.arc(e.x,e.y,5,0,Math.PI*2),r.closePath(),r.stroke()}function kh(r,t,e,i,s=1){const n=t?t.toString():"blue",o=i.scale(s);r.beginPath(),r.strokeStyle=n,r.moveTo(e.x,e.y),r.lineTo(e.x+o.x,e.y+o.y),r.closePath(),r.stroke()}function gn(r,t,e,i,s,n=5,o=T.White,a=null){let h;if(typeof n=="number")h={tl:n,tr:n,br:n,bl:n};else{const l={tl:0,tr:0,br:0,bl:0};for(const c in l)if(l.hasOwnProperty(c)){const u=c;h[u]=n[u]||l[u]}}r.beginPath(),r.moveTo(t+h.tl,e),r.lineTo(t+i-h.tr,e),r.quadraticCurveTo(t+i,e,t+i,e+h.tr),r.lineTo(t+i,e+s-h.br),r.quadraticCurveTo(t+i,e+s,t+i-h.br,e+s),r.lineTo(t+h.bl,e+s),r.quadraticCurveTo(t,e+s,t,e+s-h.bl),r.lineTo(t,e+h.tl),r.quadraticCurveTo(t,e,t+h.tl,e),r.closePath(),a&&(r.fillStyle=a.toString(),r.fill()),o&&(r.strokeStyle=o.toString(),r.stroke())}function Lh(r,t,e,i,s=T.White,n=null){r.beginPath(),r.arc(t,e,i,0,Math.PI*2),r.closePath(),n&&(r.fillStyle=n.toString(),r.fill()),s&&(r.strokeStyle=s.toString(),r.stroke())}const Uh=Object.freeze(Object.defineProperty({__proto__:null,circle:Lh,line:fn,point:Bh,roundRect:gn,vector:kh},Symbol.toStringTag,{value:"Module"}));class qe{constructor(t,e,i=1){this.builder=t,this.cleaner=e,this._pool=[],this._size=0,this.grow(i)}grow(t){if(t>0){this._size+=t;for(let e=0;e<t;e++)this._pool.push(this.builder())}}rent(t=!1){return this._pool.length===0&&this.grow(this._size),t?this.cleaner(this._pool.pop()):this._pool.pop()}return(t){this._pool.push(t)}}class zh{constructor(){this._pool=new qe(()=>j.identity(),t=>t.reset(),100),this._transforms=[],this._currentTransform=this._pool.rent(!0)}save(){this._transforms.push(this._currentTransform),this._currentTransform=this._currentTransform.clone(this._pool.rent())}restore(){this._pool.return(this._currentTransform),this._currentTransform=this._transforms.pop()}translate(t,e){return this._currentTransform.translate(t,e)}rotate(t){return this._currentTransform.rotate(t)}scale(t,e){return this._currentTransform.scale(t,e)}reset(){this._currentTransform.reset()}set current(t){this._currentTransform=t}get current(){return this._currentTransform}}class Oh{constructor(){this.opacity=1,this.z=0,this.tint=T.White,this.material=null}}class Ur{constructor(){this._pool=new qe(()=>new Oh,t=>(t.opacity=1,t.z=0,t.tint=T.White,t.material=null,t),100),this.current=this._pool.rent(!0),this._states=[]}_cloneState(t){var e;return t.opacity=this.current.opacity,t.z=this.current.z,t.tint=(e=this.current.tint)==null?void 0:e.clone(),t.material=this.current.material,t}save(){this._states.push(this.current),this.current=this._cloneState(this._pool.rent())}restore(){this._pool.return(this.current),this.current=this._states.pop()}}const Hh={Complete:"complete",Load:"load",LoadStart:"loadstart",Progress:"progress",Error:"error"};class li{constructor(t,e,i=!1){this.path=t,this.responseType=e,this.bustCache=i,this.data=null,this.logger=R.getInstance(),this.events=new X}isLoaded(){return this.data!==null}_cacheBust(t){return/\?\w*=\w*/.test(t)?t+="&__="+Date.now():t+="?__="+Date.now(),t}load(){return new Promise((t,e)=>{if(this.data!==null){this.logger.debug("Already have data for resource",this.path),this.events.emit("complete",this.data),t(this.data);return}const i=new XMLHttpRequest;i.open("GET",this.bustCache?this._cacheBust(this.path):this.path,!0),i.responseType=this.responseType,i.addEventListener("loadstart",s=>this.events.emit("loadstart",s)),i.addEventListener("progress",s=>this.events.emit("progress",s)),i.addEventListener("error",s=>this.events.emit("error",s)),i.addEventListener("load",s=>this.events.emit("load",s)),i.addEventListener("load",()=>{if(i.status!==0&&i.status!==200){this.logger.error("Failed to load resource ",this.path," server responded with error code",i.status),this.events.emit("error",i.response),e(new Error(i.statusText));return}if(i.response instanceof Blob&&i.response.type==="text/html"){const s=`Expected blob (usually image) data from the server when loading ${this.path}, but got HTML content instead!
|
|
27
27
|
|
|
28
28
|
Check your server configuration, for example Vite serves static files from the /public folder`;this.events.emit("error",i.response),e(new Error(s));return}this.data=i.response,this.events.emit("complete",this.data),this.logger.debug("Completed loading resource",this.path),t(this.data)}),i.send()})}}class Bt extends st{constructor(t){var e,i;super(t),this._logger=R.getInstance(),this._dirty=!0,this.image=t.image;const{width:s,height:n}=t;this.sourceView=(e=t.sourceView)!=null?e:{x:0,y:0,width:s!=null?s:0,height:n!=null?n:0},this.destSize=(i=t.destSize)!=null?i:{width:s!=null?s:0,height:n!=null?n:0},this._updateSpriteDimensions(),this.image.ready.then(()=>{this._updateSpriteDimensions()})}static from(t,e){return new Bt({image:t,...e})}get width(){return Math.abs(this.destSize.width*this.scale.x)}get height(){return Math.abs(this.destSize.height*this.scale.y)}set width(t){t/=Math.abs(this.scale.x),this.destSize.width=t,super.width=Math.ceil(this.destSize.width)}set height(t){t/=Math.abs(this.scale.y),this.destSize.height=t,super.height=Math.ceil(this.destSize.height)}_updateSpriteDimensions(){var t,e,i,s,n,o;const{width:a,height:h}=this.image;this.sourceView.width=((t=this.sourceView)==null?void 0:t.width)||a,this.sourceView.height=((e=this.sourceView)==null?void 0:e.height)||h,this.destSize.width=((i=this.destSize)==null?void 0:i.width)||((s=this.sourceView)==null?void 0:s.width)||a,this.destSize.height=((n=this.destSize)==null?void 0:n.height)||((o=this.sourceView)==null?void 0:o.height)||h,this.width=Math.ceil(this.destSize.width)*this.scale.x,this.height=Math.ceil(this.destSize.height)*this.scale.y}_preDraw(t,e,i){this.image.isLoaded()&&this._dirty&&(this._dirty=!1,this._updateSpriteDimensions()),super._preDraw(t,e,i)}_drawImage(t,e,i){this.image.isLoaded()?t.drawImage(this.image.image,this.sourceView.x,this.sourceView.y,this.sourceView.width,this.sourceView.height,e,i,this.destSize.width,this.destSize.height):this._logger.warnOnce(`ImageSource ${this.image.path} is not yet loaded and won't be drawn. Please call .load() or include in a Loader.
|
|
29
29
|
|
|
@@ -928,4 +928,4 @@ If in Firefox, visit about:config
|
|
|
928
928
|
|
|
929
929
|
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 Yi({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}:kn.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===Be.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,_e.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 Mt?e.add(t):this.currentScene.add(t)}remove(t){t instanceof At&&this.currentScene.remove(t),(t instanceof Mt||jt(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===Be.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 Gs(this)),this._logger.debug("Window hidden")):document.visibilityState==="visible"&&(this.events.emit("visible",new Vs(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 Oe(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 re(this,t,this)),this.onPreUpdate(this,t)}onPreUpdate(t,e){}_postupdate(t){this.emit("postupdate",new oe(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 Ue(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 ts),await this._overrideInitialize(this),this._isReadyFuture.resolve(),this.emit("start",new Ms(this)),this._isReadyFuture.promise})}_mainloop(t){this.scope(()=>{this.emit("preframe",new Us(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,$.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=$.DrawnImagesCount,this.stats.currFrame.graphics.drawCalls=$.DrawCallCount,this.stats.currFrame.graphics.rendererSwaps=$.RendererSwaps,this.emit("postframe",new zs(this,this.stats.currFrame)),this.stats.prevFrame.reset(this.stats.currFrame),this._monitorPerformanceThresholdAndTriggerFallback()})}stop(){this.clock.isRunning()&&(this.emit("stop",new Fs(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 ts&&(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}})}};as.Context=ma(),as.InstanceCount=0,as._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:Be.Canvas,suppressConsoleBootMessage:null,suppressMinimumBrowserFeatureDetection:null,suppressHiDPIScaling:null,suppressPlayButton:null,grabWindowFocus:!0,scrollPreventionMode:1,backgroundColor:T.fromHex("#2185d0")};let hs=as;class $l extends Lt{constructor(t){super(t),this._font=new Se,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(K);c.anchor=w.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 Ee=(r=>(r.Circle="circle",r.Rectangle="rectangle",r))(Ee||{});class Yl extends Lt{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 qe(()=>new Zi({}),m=>m,500),this.numParticles=0,this.isEmitting=!0,this.deadParticles=[],this.emitRate=1,this.emitterType=Ee.Rectangle,this.radius=0,this.particle={life:2e3,transform:Xt.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 se}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===Xt.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=Wt(this.particle.minAngle||0,this.particle.maxAngle||Math.PI*2,this.random),s=Wt(this.particle.minSpeed||0,this.particle.maxSpeed||0,this.random),n=this.particle.startSize||Wt(this.particle.minSize||5,this.particle.maxSize||5,this.random),o=s*Math.cos(i),a=s*Math.sin(i);if(this.emitterType===Ee.Rectangle)t=Wt(0,this.width,this.random),e=Wt(0,this.height,this.random);else if(this.emitterType===Ee.Circle){const l=Wt(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===Xt.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=Wt(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 Kn(r,t){if(!t())throw new Error(r)}class ls{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||it);o+=this.particle.transform===Xt.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===Ee.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,_)),m=[this.particle.transform===Xt.Local?u:f.x,this.particle.transform===Xt.Local?_:f.y,l,c,this.particle.randomRotation?Wt(0,it,this._random):this.particle.rotation||0,this.particle.angularVelocity||0,this._particleLife];this._particleData.set(m,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;Kn(`midpoint greater than 0, actual: ${e}`,()=>e>0),Kn(`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}}}ls.GPU_MAX_PARTICLES=1e5;class Zl extends Lt{constructor(t){super({name:"GpuParticleEmitter",width:t.width,height:t.height}),this.particle={life:2e3,transform:Xt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this.graphics=new K,this.isEmitting=!1,this.emitRate=1,this.emitterType=Ee.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,ls.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 se,this.renderer=new ls(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 tr{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 tr(t,this._sequenceBuilder)}}class jl{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 Ql(r){return!!r._initialize}function Jl(r){return!!r.onAdd}function Kl(r){return!!r.onRemove}function tc(r){return!!r.onInitialize}function ec(r){return!!r._preupdate}function ic(r){return!!r.onPreUpdate}function sc(r){return!!r.onPostUpdate}function nc(r){return!!r.onPostUpdate}function rc(r){return!!r.onAdd}function oc(r){return!!r.onRemove}function ac(r){return!!r.onPreDraw}function hc(r){return!!r.onPostDraw}class xa{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 lc{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 xa(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 On?(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 cc{constructor(t,e=!1){this.path=t,this.width=0,this.height=0,this._images=[],this.data=[],this._sprites=[],this._resource=new li(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 ba(t),this._gif=new ya(this._stream);const e=this._gif.images.map(i=>new Ht(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 ye({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 zi({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 cs=r=>r.reduce(function(t,e){return t*2+e},0),er=r=>{const t=[];for(let e=7;e>=0;e--)t.push(!!(r&1<<e));return t};class ba{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 dc=function(r,t){let e=0;const i=function(_){let f=0;for(let m=0;m<_;m++)t.charCodeAt(e>>3)&1<<(e&7)&&(f|=1<<m),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 ya{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=er(this._st.readByte());e.gctFlag=i.shift(),e.colorResolution=cs(i.splice(0,3)),e.sortedFlag=i.shift(),e.globalColorTableSize=cs(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=er(this._st.readByte());return h.reserved=l.splice(0,3),h.disposalMethod=cs(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 v=a.slice(x*h,(x+1)*h);l.splice.apply(l,[p*h,h].concat(v))},_=[0,4,2,1],f=[8,8,4,2];let m=0;for(let p=0;p<4;p++)for(let x=_[p];x<c;x+=f[p])u(x,m),m++;return l};e.leftPos=this._st.readUnsigned(),e.topPos=this._st.readUnsigned(),e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned();const n=er(this._st.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=cs(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=dc(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 m=e.pixels[f],p=i[m];m===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 uc{constructor(t,e,{bustCache:i,...s}={}){this.path=t,this.family=e,this._isLoaded=!1,this._resource=new li(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 Se({family:this.family,...this._options,...t})}}const Ca=ma(),_c=/^\s*(?:function)?\*/;function Sa(r){return typeof r!="function"?!1:_c.test(Function.prototype.toString.call(r))?!0:Object.getPrototypeOf?Object.getPrototypeOf(r)===Object.getPrototypeOf(new Function("return function * () {}")()):!1}function Ta(...r){var t;const e=R.getInstance();let i,s,n,o;Sa(r[0])&&(s=globalThis,i=r[0],n=r[1]),Sa(r[1])&&(s=r[0],i=r[1],n=r[2]),r[1]instanceof hs&&(s=r[0],o=r[1],i=r[2],n=r[3]),r[0]instanceof hs&&(s=globalThis,o=r[0],i=r[1],n=r[2]);const a=va(Ca),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:hs.useEngine()}catch(y){throw Error(`Cannot run coroutine without engine parameter outside of an excalibur lifecycle method.
|
|
930
930
|
Pass an engine parameter to ex.coroutine(engine, function * {...})`)}let u=!1,_=!1,f=!1;const m=i.bind(s),p=m();let x;const v=new Promise((y,S)=>{x=A=>{try{if(f){_=!0,y();return}const{done:I,value:C}=Ca.scope(!0,()=>p.next(A));if(I||f){_=!0,y();return}C instanceof Promise?C.then(()=>{c.clock.schedule(x,0,h)}):C===void 0||C===void 0?c.clock.schedule(x,0,h):c.clock.schedule(x,C||0,h)}catch(I){S(I);return}},l&&(u=!0,x(c.clock.elapsed()))}),g={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:
|
|
931
|
-
`,Function.prototype.toString.call(m)):(u=!0,x(c.clock.elapsed())),g),generator:p,done:v,then:v.then.bind(v),[Symbol.iterator]:()=>p};return g}class ds extends At{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new P,this.graphics=new K,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,Te(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:Rt.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ai,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=w.Zero,this.transform.z=1/0,this.graphics.anchor=w.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=Ta(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 fc extends ds{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:T.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new ui({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 gc extends ds{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=Ht.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 pc extends ds{constructor(t){var e;super({direction:"in",...t}),this._easing=Rt.Linear,this._start=w.Zero,this._end=w.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=Ht.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 mc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:Ts,DrawUtil:Uh,EasingFunctions:Rt,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:mr,addItemToArray:Ch,contains:xr,delay:Fi,fail:br,getMinIndex:wr,getPosition:oi,isLegacyEasing:Te,isObject:Di,mergeDeep:Bi,omit:yr,removeItemFromArray:He},Symbol.toStringTag,{value:"Module"})),Aa=5,ti={},vc=()=>{for(const r in ti)ti[r]=0},us=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");ti[r]<Aa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),ti[r]++};function wc(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`:"");ti[n]||(ti[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){us(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return us(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return us(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return us(n,r),i.set.apply(this,arguments)}),o)}}class xc{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 bc{constructor(t){this._count=t,this._waitQueue=new xc}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 ir="0.32.0-alpha.1596+548f5e4";Fe(),d.ActionCompleteEvent=Js,d.ActionContext=fi,d.ActionQueue=eo,d.ActionSequence=tr,d.ActionStartEvent=Qs,d.ActionsComponent=Qe,d.ActionsSystem=qn,d.ActivateEvent=qs,d.Actor=Lt,d.ActorEvents=Al,d.AddEvent=Ks,d.AddedComponent=Sh,d.AffineMatrix=j,d.Animation=zi,d.AnimationDirection=Br,d.AnimationEvents=Dh,d.AnimationStrategy=kr,d.ArcadeSolver=Dn,d.AudioContextFactory=pi,d.Axes=ea,d.Axis=$o,d.BaseAlign=dn,d.BezierCurve=si,d.Blink=yo,d.BodyComponent=N,d.BoundingBox=F,d.BrowserComponent=Zn,d.BrowserEvents=da,d.Buttons=Xn,d.Camera=Ko,d.CameraEvents=Ol,d.Canvas=Xi,d.ChannelCollection=xa,d.Circle=qi,d.CircleCollider=dt,d.Clock=jn,d.ClosestLineJumpTable=qt,d.Collider=ai,d.ColliderComponent=tt,d.CollisionContact=xe,d.CollisionEndEvent=ri,d.CollisionGroup=me,d.CollisionGroupManager=Pi,d.CollisionJumpTable=zt,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=ni,d.CollisionSystem=Ji,d.CollisionType=M,d.Color=T,d.ColorBlindFlags=la,d.ColorBlindnessMode=Ye,d.ColorBlindnessPostProcessor=Qr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=Ts,d.ContactConstraintPoint=Mo,d.ContactEndEvent=Ii,d.ContactSolveBias=ae,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=gc,d.CurveBy=Eo,d.CurveTo=Po,d.DeactivateEvent=Xs,d.Debug=Tt,d.DebugConfig=ca,d.DebugGraphicsComponent=Wi,d.DebugSystem=Gn,d.DebugText=pn,d.DefaultAntialiasOptions=Or,d.DefaultGarbageCollectionOptions=Jn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Hr,d.DegreeOfFreedom=le,d.Delay=So,d.Detector=Oo,d.Die=To,d.Direction=_n,d.Director=pa,d.DirectorEvents=ga,d.DisplayMode=gi,d.DynamicTree=nn,d.DynamicTreeCollisionProcessor=ki,d.EX_VERSION=ir,d.EaseBy=bo,d.EaseTo=xo,d.EasingFunctions=Rt,d.Edge=bs,d.EdgeCollider=St,d.ElasticToActorStrategy=jo,d.EmitterType=Ee,d.Engine=hs,d.EngineEvents=Xl,d.EnterTriggerEvent=Zs,d.EnterViewPortEvent=Ys,d.Entity=At,d.EntityEvents=Eh,d.EntityManager=Sr,d.EventEmitter=X,d.EventTypes=Ps,d.Events=yh,d.ExResponse=Un,d.ExcaliburGraphicsContext2DCanvas=Yi,d.ExcaliburGraphicsContextWebGL=Yt,d.ExitTriggerEvent=js,d.ExitViewPortEvent=$s,d.Fade=Co,d.FadeInOut=fc,d.Flags=De,d.Flash=Ao,d.Follow=En,d.Font=Se,d.FontCache=Gi,d.FontSource=uc,d.FontStyle=un,d.FontUnit=ln,d.FpsSampler=ua,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=Ms,d.GameStopEvent=Fs,d.Gamepad=ns,d.GamepadAxisEvent=Ws,d.GamepadButtonEvent=Ns,d.GamepadConnectEvent=Os,d.GamepadDisconnectEvent=Hs,d.Gamepads=ss,d.GarbageCollector=wa,d.Gif=cc,d.GifParser=ya,d.GlobalCoordinates=ke,d.GpuParticleEmitter=Zl,d.GpuParticleRenderer=ls,d.Graph=xs,d.Graphic=st,d.GraphicsComponent=K,d.GraphicsGroup=We,d.GraphicsSystem=vn,d.HashColliderProxy=Ro,d.HashGridCell=Zt,d.HashGridProxy=Rn,d.HiddenEvent=Gs,d.HorizontalFirst=on,d.ImageFiltering=mt,d.ImageSource=Ht,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Oe,d.InputHost=Yn,d.InputMapper=ia,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Vn,d.IsometricMap=zl,d.IsometricTile=qo,d.KeyEvent=wi,d.Keyboard=aa,d.Keys=oa,d.KillEvent=Es,d.Label=$l,d.LimitCameraBoundsStrategy=Jo,d.Line=mn,d.LineSegment=J,d.Loader=ts,d.LoaderEvents=Fl,d.LockCameraToActorAxisStrategy=Zo,d.LockCameraToActorStrategy=Yo,d.LogLevel=Le,d.Logger=R,d.Material=Kr,d.Matrix=Ct,d.MatrixLocations=cr,d.MediaEvent=zn,d.Meet=ji,d.MotionComponent=O,d.MotionSystem=Qi,d.MoveBy=An,d.MoveByWithOptions=ro,d.MoveTo=Pn,d.MoveToWithOptions=ao,d.NativePointerButton=Pe,d.NativeSoundEvent=Ae,d.NativeSoundProcessedEvent=Lo,d.NineSlice=bn,d.NineSliceStretch=zr,d.Node=Ti,d.None=an,d.Observable=gt,d.OffscreenSystem=wn,d.Pair=pt,d.ParallaxComponent=Vi,d.ParallelActions=jl,d.Particle=Zi,d.ParticleEmitter=Yl,d.ParticleRenderer=Zr,d.ParticleTransform=Xt,d.PhysicsStats=os,d.PhysicsWorld=Fo,d.PointerAbstraction=$n,d.PointerButton=ce,d.PointerComponent=he,d.PointerEvent=xi,d.PointerEventReceiver=rs,d.PointerScope=Be,d.PointerSystem=is,d.PointerType=de,d.Polygon=xn,d.PolygonCollider=lt,d.Pool=Ui,d.PositionNode=_r,d.PostCollisionEvent=we,d.PostDebugDrawEvent=Ls,d.PostDrawEvent=ze,d.PostFrameEvent=zs,d.PostKillEvent=Rs,d.PostTransformDrawEvent=Bs,d.PostUpdateEvent=oe,d.PreCollisionEvent=ve,d.PreDebugDrawEvent=ks,d.PreDrawEvent=Ue,d.PreFrameEvent=Us,d.PreKillEvent=Is,d.PreLoadEvent=Vl,d.PreTransformDrawEvent=Ds,d.PreUpdateEvent=re,d.Projection=ei,d.QuadIndexBuffer=Ze,d.QuadTree=Je,d.Query=Ut,d.QueryManager=Tr,d.RadiusAroundActorStrategy=Qo,d.Random=se,d.Raster=Ve,d.Ray=ge,d.RealisticSolver=Bn,d.Rectangle=ui,d.RemoveEvent=tn,d.RemovedComponent=Ah,d.RentalPool=qe,d.Repeat=io,d.RepeatForever=so,d.Resolution=kn,d.Resource=li,d.ResourceEvents=Hh,d.RotateBy=uo,d.RotateByWithOptions=co,d.RotateTo=lo,d.RotateToWithOptions=ho,d.RotationType=Q,d.ScaleBy=vo,d.ScaleByWithOptions=mo,d.ScaleTo=go,d.ScaleToWithOptions=fo,d.Scene=Mt,d.SceneEvents=Gl,d.Screen=Ln,d.ScreenAppender=mr,d.ScreenElement=Nn,d.ScreenEvents=Pl,d.ScreenShader=jr,d.ScrollPreventionMode=Ke,d.Semaphore=bc,d.SeparatingAxis=Ne,d.SeparationInfo=Mr,d.Shader=kt,d.Shape=ut,d.Slide=pc,d.SolverStrategy=Li,d.Sound=On,d.SoundEvents=Rl,d.SoundManager=lc,d.SparseHashGrid=Mn,d.SparseHashGridCollisionProcessor=Fn,d.SpatialPartitionStrategy=hi,d.Sprite=Bt,d.SpriteFont=Oi,d.SpriteSheet=ye,d.StandardClock=Qn,d.StateMachine=Ki,d.StrategyContainer=Xo,d.Stream=ba,d.System=Et,d.SystemManager=Pr,d.SystemPriority=Gt,d.SystemType=Pt,d.TagQuery=en,d.TestClock=_a,d.Text=_i,d.TextAlign=cn,d.TextureLoader=Xe,d.Tile=Go,d.TileMap=Vo,d.TileMapEvents=Ul,d.TiledAnimation=yn,d.TiledSprite=di,d.Timer=es,d.TimerEvents=kl,d.Toaster=fa,d.Transform=Kt,d.TransformComponent=P,d.Transition=ds,d.TreeNode=sn,d.Trigger=ta,d.TriggerEvents=Hl,d.TwoPI=it,d.UniformBuffer=Nr,d.Util=mc,d.Vector=w,d.VectorView=vs,d.VertexBuffer=Nt,d.VertexLayout=$t,d.VerticalFirst=rn,d.VisibleEvent=Vs,d.WebAudio=Bo,d.WebAudioInstance=ko,d.WheelDeltaMode=bi,d.WheelEvent=ha,d.World=Er,d.approximatelyEqual=ar,d.assert=Kn,d.canonicalizeAngle=Jt,d.clamp=B,d.coroutine=Ta,d.createId=fe,d.easeInBack=fh,d.easeInBounce=gr,d.easeInCirc=dh,d.easeInCubic=th,d.easeInElastic=mh,d.easeInExpo=hh,d.easeInOutBack=ph,d.easeInOutBounce=xh,d.easeInOutCirc=_h,d.easeInOutCubic=Cs,d.easeInOutElastic=wh,d.easeInOutExpo=ch,d.easeInOutQuad=Ka,d.easeInOutQuart=nh,d.easeInOutQuint=ah,d.easeInOutSine=ja,d.easeInQuad=Qa,d.easeInQuart=ih,d.easeInQuint=rh,d.easeInSine=Ya,d.easeOutBack=gh,d.easeOutBounce=Ss,d.easeOutCirc=uh,d.easeOutCubic=eh,d.easeOutElastic=vh,d.easeOutExpo=lh,d.easeOutQuad=Ja,d.easeOutQuart=sh,d.easeOutQuint=oh,d.easeOutSine=Za,d.frac=Na,d.getDefaultPhysicsConfig=te,d.glTypeToUniformTypeName=Xr,d.hasGraphicsTick=Tn,d.hasOnAdd=rc,d.hasOnInitialize=tc,d.hasOnPostUpdate=nc,d.hasOnPreUpdate=ic,d.hasOnRemove=oc,d.hasPostDraw=hc,d.hasPreDraw=ac,d.has_add=Jl,d.has_initialize=Ql,d.has_postupdate=sc,d.has_preupdate=ec,d.has_remove=Kl,d.inverseLerp=dr,d.inverseLerpVector=ur,d.isActor=Tl,d.isAddedComponent=Th,d.isComponentCtor=vr,d.isLegacyEasing=Te,d.isLoaderConstructor=Hn,d.isMoveByOptions=no,d.isMoveToOptions=oo,d.isRemovedComponent=Ph,d.isRotateByOptions=Sl,d.isRotateToOptions=Cl,d.isScaleByOptions=po,d.isScaleToOptions=_o,d.isSceneConstructor=jt,d.isScreenElement=Ho,d.isSystemConstructor=Ar,d.lerp=ot,d.lerpAngle=ws,d.lerpVector=ii,d.linear=Ai,d.maxMessages=Aa,d.nextActionId=H,d.obsolete=wc,d.parseImageFiltering=Ge,d.parseImageWrapping=Ot,d.pixelSnapEpsilon=D,d.randomInRange=Wt,d.randomIntInRange=Ga,d.range=Va,d.remap=Vt,d.remapVector=qa,d.resetObsoleteCounter=vc,d.sign=G,d.smootherstep=$a,d.smoothstep=Xa,d.toDegrees=hr,d.toRadians=Wa,d.vec=b,d.webgl=$h,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
931
|
+
`,Function.prototype.toString.call(m)):(u=!0,x(c.clock.elapsed())),g),generator:p,done:v,then:v.then.bind(v),[Symbol.iterator]:()=>p};return g}class ds extends At{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new P,this.graphics=new K,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,Te(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:Rt.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ai,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=w.Zero,this.transform.z=1/0,this.graphics.anchor=w.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=Ta(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 fc extends ds{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:T.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new ui({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 gc extends ds{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=Ht.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 pc extends ds{constructor(t){var e;super({direction:"in",...t}),this._easing=Rt.Linear,this._start=w.Zero,this._end=w.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=Ht.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 mc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:Ts,DrawUtil:Uh,EasingFunctions:Rt,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:mr,addItemToArray:Ch,contains:xr,delay:Fi,fail:br,getMinIndex:wr,getPosition:oi,isLegacyEasing:Te,isObject:Di,mergeDeep:Bi,omit:yr,removeItemFromArray:He},Symbol.toStringTag,{value:"Module"})),Aa=5,ti={},vc=()=>{for(const r in ti)ti[r]=0},us=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");ti[r]<Aa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),ti[r]++};function wc(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`:"");ti[n]||(ti[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){us(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return us(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return us(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return us(n,r),i.set.apply(this,arguments)}),o)}}class xc{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 bc{constructor(t){this._count=t,this._waitQueue=new xc}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 ir="0.32.0-alpha.1598+97bb68b";Fe(),d.ActionCompleteEvent=Js,d.ActionContext=fi,d.ActionQueue=eo,d.ActionSequence=tr,d.ActionStartEvent=Qs,d.ActionsComponent=Qe,d.ActionsSystem=qn,d.ActivateEvent=qs,d.Actor=Lt,d.ActorEvents=Al,d.AddEvent=Ks,d.AddedComponent=Sh,d.AffineMatrix=j,d.Animation=zi,d.AnimationDirection=Br,d.AnimationEvents=Dh,d.AnimationStrategy=kr,d.ArcadeSolver=Dn,d.AudioContextFactory=pi,d.Axes=ea,d.Axis=$o,d.BaseAlign=dn,d.BezierCurve=si,d.Blink=yo,d.BodyComponent=N,d.BoundingBox=F,d.BrowserComponent=Zn,d.BrowserEvents=da,d.Buttons=Xn,d.Camera=Ko,d.CameraEvents=Ol,d.Canvas=Xi,d.ChannelCollection=xa,d.Circle=qi,d.CircleCollider=dt,d.Clock=jn,d.ClosestLineJumpTable=qt,d.Collider=ai,d.ColliderComponent=tt,d.CollisionContact=xe,d.CollisionEndEvent=ri,d.CollisionGroup=me,d.CollisionGroupManager=Pi,d.CollisionJumpTable=zt,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=ni,d.CollisionSystem=Ji,d.CollisionType=M,d.Color=T,d.ColorBlindFlags=la,d.ColorBlindnessMode=Ye,d.ColorBlindnessPostProcessor=Qr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=Ts,d.ContactConstraintPoint=Mo,d.ContactEndEvent=Ii,d.ContactSolveBias=ae,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=gc,d.CurveBy=Eo,d.CurveTo=Po,d.DeactivateEvent=Xs,d.Debug=Tt,d.DebugConfig=ca,d.DebugGraphicsComponent=Wi,d.DebugSystem=Gn,d.DebugText=pn,d.DefaultAntialiasOptions=Or,d.DefaultGarbageCollectionOptions=Jn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Hr,d.DegreeOfFreedom=le,d.Delay=So,d.Detector=Oo,d.Die=To,d.Direction=_n,d.Director=pa,d.DirectorEvents=ga,d.DisplayMode=gi,d.DynamicTree=nn,d.DynamicTreeCollisionProcessor=ki,d.EX_VERSION=ir,d.EaseBy=bo,d.EaseTo=xo,d.EasingFunctions=Rt,d.Edge=bs,d.EdgeCollider=St,d.ElasticToActorStrategy=jo,d.EmitterType=Ee,d.Engine=hs,d.EngineEvents=Xl,d.EnterTriggerEvent=Zs,d.EnterViewPortEvent=Ys,d.Entity=At,d.EntityEvents=Eh,d.EntityManager=Sr,d.EventEmitter=X,d.EventTypes=Ps,d.Events=yh,d.ExResponse=Un,d.ExcaliburGraphicsContext2DCanvas=Yi,d.ExcaliburGraphicsContextWebGL=Yt,d.ExitTriggerEvent=js,d.ExitViewPortEvent=$s,d.Fade=Co,d.FadeInOut=fc,d.Flags=De,d.Flash=Ao,d.Follow=En,d.Font=Se,d.FontCache=Gi,d.FontSource=uc,d.FontStyle=un,d.FontUnit=ln,d.FpsSampler=ua,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=Ms,d.GameStopEvent=Fs,d.Gamepad=ns,d.GamepadAxisEvent=Ws,d.GamepadButtonEvent=Ns,d.GamepadConnectEvent=Os,d.GamepadDisconnectEvent=Hs,d.Gamepads=ss,d.GarbageCollector=wa,d.Gif=cc,d.GifParser=ya,d.GlobalCoordinates=ke,d.GpuParticleEmitter=Zl,d.GpuParticleRenderer=ls,d.Graph=xs,d.Graphic=st,d.GraphicsComponent=K,d.GraphicsGroup=We,d.GraphicsSystem=vn,d.HashColliderProxy=Ro,d.HashGridCell=Zt,d.HashGridProxy=Rn,d.HiddenEvent=Gs,d.HorizontalFirst=on,d.ImageFiltering=mt,d.ImageSource=Ht,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Oe,d.InputHost=Yn,d.InputMapper=ia,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Vn,d.IsometricMap=zl,d.IsometricTile=qo,d.KeyEvent=wi,d.Keyboard=aa,d.Keys=oa,d.KillEvent=Es,d.Label=$l,d.LimitCameraBoundsStrategy=Jo,d.Line=mn,d.LineSegment=J,d.Loader=ts,d.LoaderEvents=Fl,d.LockCameraToActorAxisStrategy=Zo,d.LockCameraToActorStrategy=Yo,d.LogLevel=Le,d.Logger=R,d.Material=Kr,d.Matrix=Ct,d.MatrixLocations=cr,d.MediaEvent=zn,d.Meet=ji,d.MotionComponent=O,d.MotionSystem=Qi,d.MoveBy=An,d.MoveByWithOptions=ro,d.MoveTo=Pn,d.MoveToWithOptions=ao,d.NativePointerButton=Pe,d.NativeSoundEvent=Ae,d.NativeSoundProcessedEvent=Lo,d.NineSlice=bn,d.NineSliceStretch=zr,d.Node=Ti,d.None=an,d.Observable=gt,d.OffscreenSystem=wn,d.Pair=pt,d.ParallaxComponent=Vi,d.ParallelActions=jl,d.Particle=Zi,d.ParticleEmitter=Yl,d.ParticleRenderer=Zr,d.ParticleTransform=Xt,d.PhysicsStats=os,d.PhysicsWorld=Fo,d.PointerAbstraction=$n,d.PointerButton=ce,d.PointerComponent=he,d.PointerEvent=xi,d.PointerEventReceiver=rs,d.PointerScope=Be,d.PointerSystem=is,d.PointerType=de,d.Polygon=xn,d.PolygonCollider=lt,d.Pool=Ui,d.PositionNode=_r,d.PostCollisionEvent=we,d.PostDebugDrawEvent=Ls,d.PostDrawEvent=ze,d.PostFrameEvent=zs,d.PostKillEvent=Rs,d.PostTransformDrawEvent=Bs,d.PostUpdateEvent=oe,d.PreCollisionEvent=ve,d.PreDebugDrawEvent=ks,d.PreDrawEvent=Ue,d.PreFrameEvent=Us,d.PreKillEvent=Is,d.PreLoadEvent=Vl,d.PreTransformDrawEvent=Ds,d.PreUpdateEvent=re,d.Projection=ei,d.QuadIndexBuffer=Ze,d.QuadTree=Je,d.Query=Ut,d.QueryManager=Tr,d.RadiusAroundActorStrategy=Qo,d.Random=se,d.Raster=Ve,d.Ray=ge,d.RealisticSolver=Bn,d.Rectangle=ui,d.RemoveEvent=tn,d.RemovedComponent=Ah,d.RentalPool=qe,d.Repeat=io,d.RepeatForever=so,d.Resolution=kn,d.Resource=li,d.ResourceEvents=Hh,d.RotateBy=uo,d.RotateByWithOptions=co,d.RotateTo=lo,d.RotateToWithOptions=ho,d.RotationType=Q,d.ScaleBy=vo,d.ScaleByWithOptions=mo,d.ScaleTo=go,d.ScaleToWithOptions=fo,d.Scene=Mt,d.SceneEvents=Gl,d.Screen=Ln,d.ScreenAppender=mr,d.ScreenElement=Nn,d.ScreenEvents=Pl,d.ScreenShader=jr,d.ScrollPreventionMode=Ke,d.Semaphore=bc,d.SeparatingAxis=Ne,d.SeparationInfo=Mr,d.Shader=kt,d.Shape=ut,d.Slide=pc,d.SolverStrategy=Li,d.Sound=On,d.SoundEvents=Rl,d.SoundManager=lc,d.SparseHashGrid=Mn,d.SparseHashGridCollisionProcessor=Fn,d.SpatialPartitionStrategy=hi,d.Sprite=Bt,d.SpriteFont=Oi,d.SpriteSheet=ye,d.StandardClock=Qn,d.StateMachine=Ki,d.StrategyContainer=Xo,d.Stream=ba,d.System=Et,d.SystemManager=Pr,d.SystemPriority=Gt,d.SystemType=Pt,d.TagQuery=en,d.TestClock=_a,d.Text=_i,d.TextAlign=cn,d.TextureLoader=Xe,d.Tile=Go,d.TileMap=Vo,d.TileMapEvents=Ul,d.TiledAnimation=yn,d.TiledSprite=di,d.Timer=es,d.TimerEvents=kl,d.Toaster=fa,d.Transform=Kt,d.TransformComponent=P,d.Transition=ds,d.TreeNode=sn,d.Trigger=ta,d.TriggerEvents=Hl,d.TwoPI=it,d.UniformBuffer=Nr,d.Util=mc,d.Vector=w,d.VectorView=vs,d.VertexBuffer=Nt,d.VertexLayout=$t,d.VerticalFirst=rn,d.VisibleEvent=Vs,d.WebAudio=Bo,d.WebAudioInstance=ko,d.WheelDeltaMode=bi,d.WheelEvent=ha,d.World=Er,d.approximatelyEqual=ar,d.assert=Kn,d.canonicalizeAngle=Jt,d.clamp=B,d.coroutine=Ta,d.createId=fe,d.easeInBack=fh,d.easeInBounce=gr,d.easeInCirc=dh,d.easeInCubic=th,d.easeInElastic=mh,d.easeInExpo=hh,d.easeInOutBack=ph,d.easeInOutBounce=xh,d.easeInOutCirc=_h,d.easeInOutCubic=Cs,d.easeInOutElastic=wh,d.easeInOutExpo=ch,d.easeInOutQuad=Ka,d.easeInOutQuart=nh,d.easeInOutQuint=ah,d.easeInOutSine=ja,d.easeInQuad=Qa,d.easeInQuart=ih,d.easeInQuint=rh,d.easeInSine=Ya,d.easeOutBack=gh,d.easeOutBounce=Ss,d.easeOutCirc=uh,d.easeOutCubic=eh,d.easeOutElastic=vh,d.easeOutExpo=lh,d.easeOutQuad=Ja,d.easeOutQuart=sh,d.easeOutQuint=oh,d.easeOutSine=Za,d.frac=Na,d.getDefaultPhysicsConfig=te,d.glTypeToUniformTypeName=Xr,d.hasGraphicsTick=Tn,d.hasOnAdd=rc,d.hasOnInitialize=tc,d.hasOnPostUpdate=nc,d.hasOnPreUpdate=ic,d.hasOnRemove=oc,d.hasPostDraw=hc,d.hasPreDraw=ac,d.has_add=Jl,d.has_initialize=Ql,d.has_postupdate=sc,d.has_preupdate=ec,d.has_remove=Kl,d.inverseLerp=dr,d.inverseLerpVector=ur,d.isActor=Tl,d.isAddedComponent=Th,d.isComponentCtor=vr,d.isLegacyEasing=Te,d.isLoaderConstructor=Hn,d.isMoveByOptions=no,d.isMoveToOptions=oo,d.isRemovedComponent=Ph,d.isRotateByOptions=Sl,d.isRotateToOptions=Cl,d.isScaleByOptions=po,d.isScaleToOptions=_o,d.isSceneConstructor=jt,d.isScreenElement=Ho,d.isSystemConstructor=Ar,d.lerp=ot,d.lerpAngle=ws,d.lerpVector=ii,d.linear=Ai,d.maxMessages=Aa,d.nextActionId=H,d.obsolete=wc,d.parseImageFiltering=Ge,d.parseImageWrapping=Ot,d.pixelSnapEpsilon=D,d.randomInRange=Wt,d.randomIntInRange=Ga,d.range=Va,d.remap=Vt,d.remapVector=qa,d.resetObsoleteCounter=vc,d.sign=G,d.smootherstep=$a,d.smoothstep=Xa,d.toDegrees=hr,d.toRadians=Wa,d.vec=b,d.webgl=$h,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|