@newkrok/nape-js 3.20.0 → 3.21.0
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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkKHH45HMB_cjs=require('./chunk-KHH45HMB.cjs');var Pt={epsilon:1e-8,fluidAngularDragFriction:2.5,fluidAngularDrag:100,fluidVacuumDrag:.5,fluidLinearDrag:.5,collisionSlop:.2,collisionSlopCCD:.5,distanceThresholdCCD:.05,staticCCDLinearThreshold:.05,staticCCDAngularThreshold:.005,bulletCCDLinearThreshold:.125,bulletCCDAngularThreshold:.0125,dynamicSweepLinearThreshold:17,dynamicSweepAngularThreshold:.6,angularCCDSlipScale:.75,arbiterExpirationDelay:6,staticFrictionThreshold:2,elasticThreshold:20,sleepDelay:60,linearSleepThreshold:.2,angularSleepThreshold:.4,contactBiasCoef:.3,contactStaticBiasCoef:.6,contactContinuousBiasCoef:.4,contactContinuousStaticBiasCoef:.5,constraintLinearSlop:.1,constraintAngularSlop:.001,illConditionedThreshold:2e8},jt=chunkKHH45HMB_cjs.E();jt.Config=Object.assign(jt.Config||{},Pt);function l(n,e,t){for(;n[e]!=null;){let r=n[e][t];n[e][t]=null,n[e]=r;}}var Xe=class{static version(){return "Nape 2.0.19"}static clearObjectPools(){let e=chunkKHH45HMB_cjs.E(),t=e.__zpp;l(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),l(e.phys.InteractorIterator,"zpp_pool","zpp_next"),l(e.phys.BodyIterator,"zpp_pool","zpp_next"),l(e.phys.CompoundIterator,"zpp_pool","zpp_next"),l(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),l(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),l(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),l(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),l(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),l(e.geom.RayResultIterator,"zpp_pool","zpp_next"),l(e.shape.ShapeIterator,"zpp_pool","zpp_next"),l(e.shape.EdgeIterator,"zpp_pool","zpp_next"),l(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),l(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),l(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),l(t.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Body,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Component,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),l(t.util.ZNPNode_ConvexResult,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),l(t.util.ZNPNode_RayResult,"zpp_pool","next"),l(t.phys.ZPP_Material,"zpp_pool","next"),l(t.phys.ZPP_FluidProperties,"zpp_pool","next"),l(t.callbacks.ZPP_CbSetPair,"zpp_pool","next"),l(t.callbacks.ZPP_Callback,"zpp_pool","next"),l(t.callbacks.ZPP_CbSet,"zpp_pool","next"),l(t.geom.ZPP_GeomVert,"zpp_pool","next"),l(t.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),l(t.geom.ZPP_Mat23,"zpp_pool","next"),l(t.geom.ZPP_CutVert,"zpp_pool","next"),l(t.geom.ZPP_CutInt,"zpp_pool","next"),l(t.geom.ZPP_Vec2,"zpp_pool","next"),l(t.geom.ZPP_PartitionVertex,"zpp_pool","next"),l(t.geom.ZPP_SimplifyV,"zpp_pool","next"),l(t.geom.ZPP_SimplifyP,"zpp_pool","next"),l(t.geom.ZPP_PartitionedPoly,"zpp_pool","next"),l(t.geom.ZPP_PartitionPair,"zpp_pool","next"),l(t.geom.ZPP_AABB,"zpp_pool","next"),l(t.geom.ZPP_SimpleVert,"zpp_pool","next"),l(t.geom.ZPP_SimpleSeg,"zpp_pool","next"),l(t.geom.ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.Hashable2_Boolfalse,"zpp_pool","next"),l(t.geom.ZPP_ToiEvent,"zpp_pool","next"),l(t.geom.ZPP_MarchSpan,"zpp_pool","next"),l(t.geom.ZPP_MarchPair,"zpp_pool","next"),l(t.shape.ZPP_Edge,"zpp_pool","next"),l(t.space.ZPP_SweepData,"zpp_pool","next"),l(t.space.ZPP_AABBNode,"zpp_pool","next"),l(t.space.ZPP_AABBPair,"zpp_pool","next"),l(t.dynamics.ZPP_Contact,"zpp_pool","next"),l(t.space.ZPP_Island,"zpp_pool","next"),l(t.space.ZPP_Component,"zpp_pool","next"),l(t.space.ZPP_CallbackSet,"zpp_pool","next"),l(t.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_ColArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec2","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec3","zpp_pool");}};var fe=class n{get _inner(){return this}constructor(e=1,t=0,r=0,i=1,p=0,s=0){let a=chunkKHH45HMB_cjs.A.get();this.zpp_inner=a,a.outer=this;let c=["a","b","tx","c","d","ty"],f=[e,t,p,r,i,s];for(let u=0;u<f.length;u++)if(f[u]!==f[u])throw new Error("Error: Mat23::"+c[u]+" cannot be NaN");a.setas(e,t,r,i,p,s);}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let t=Math.cos(e),r=Math.sin(e);return new n(t,-r,r,t,0,0)}static translation(e,t){return new n(1,0,0,1,e,t)}static scale(e,t){return new n(e,0,0,t,0,0)}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.A?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}_setProp(e,t){if(t!==t)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=t,this.zpp_inner.invalidate();}get a(){return this.zpp_inner.a}set a(e){this._setProp("a",e);}get b(){return this.zpp_inner.b}set b(e){this._setProp("b",e);}get c(){return this.zpp_inner.c}set c(e){this._setProp("c",e);}get d(){return this.zpp_inner.d}set d(e){this._setProp("d",e);}get tx(){return this.zpp_inner.tx}set tx(e){this._setProp("tx",e);}get ty(){return this.zpp_inner.ty}set ty(e){this._setProp("ty",e);}get determinant(){return this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c}clone(){return this.copy()}equals(e,t=0){if(e==null)return false;let r=this.zpp_inner,i=e.zpp_inner,p=r.a-i.a,s=r.b-i.b,a=r.c-i.c,c=r.d-i.d,f=r.tx-i.tx,u=r.ty-i.ty;return (p<0?-p:p)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(c<0?-c:c)<=t&&(f<0?-f:f)<=t&&(u<0?-u:u)<=t}copy(){return new n(this.zpp_inner.a,this.zpp_inner.b,this.zpp_inner.c,this.zpp_inner.d,this.zpp_inner.tx,this.zpp_inner.ty)}set(e){if(e==null)throw new Error("Error: Cannot set form null matrix");let t=e.zpp_inner;return this.zpp_inner.setas(t.a,t.b,t.c,t.d,t.tx,t.ty),this.zpp_inner.invalidate(),this}setAs(e=1,t=0,r=0,i=1,p=0,s=0){return this.zpp_inner.setas(e,t,r,i,p,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=e*e+t*t+r*r+i*i,s=e*i-t*r;s<0&&(s=-s);let a=chunkKHH45HMB_cjs.E();return p>a.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner,a=1/(e*i-t*r);return new n(i*a,-t*a,-r*a,e*a,(t*s-i*p)*a,(r*p-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return new n(e,r,t,i,-e*p-r*s,-t*p-i*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let t=e.zpp_inner,r=this.zpp_inner;return new n(t.a*r.a+t.b*r.c,t.a*r.b+t.b*r.d,t.c*r.a+t.d*r.c,t.c*r.b+t.d*r.d,t.a*r.tx+t.b*r.ty+t.tx,t.c*r.tx+t.d*r.ty+t.ty)}transform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");e.zpp_inner.validate();let i=e.zpp_inner.x,p=e.zpp_inner.y,{a:s,b:a,c,d:f,tx:u,ty:m}=this.zpp_inner,y,g;t?(y=i*s+p*a,g=i*c+p*f):(y=i*s+p*a+u,g=i*c+p*f+m);let R=chunkKHH45HMB_cjs.H.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");if(this.singular())throw new Error("Error: Matrix is singular and inverse transformation cannot be performed");let{a:i,b:p,c:s,d:a,tx:c,ty:f}=this.zpp_inner,u=1/(i*a-p*s);e.zpp_inner.validate();let m=e.zpp_inner.x,y=e.zpp_inner.y,g,R;if(t)g=(m*a-y*p)*u,R=(y*i-m*s)*u;else {let _=m-c,h=y-f;g=(_*a-h*p)*u,R=(h*i-_*s)*u;}let J=chunkKHH45HMB_cjs.H.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),J}equiorthogonal(){if(this.singular())return false;let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=chunkKHH45HMB_cjs.E(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-r*r-i*i;return a*a<p.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=chunkKHH45HMB_cjs.E(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-1,c=r*r+i*i-1;return a*a<p.Config.epsilon&&c*c<p.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:i,d:p}=this.zpp_inner,s=chunkKHH45HMB_cjs.E(),a=Math.sqrt(t*t+i*i),c=Math.sqrt(r*r+p*p);if(a*a<s.Config.epsilon||c*c<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let f=e?(a+c)/2:1;a=f/a,c=f/c,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*c,this.d=this.zpp_inner.d*c;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(u/(f*f));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let y=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*y,J=this.zpp_inner.b*g+this.zpp_inner.d*y,_=this.zpp_inner.c*g+this.zpp_inner.a*y,h=this.zpp_inner.d*g-this.zpp_inner.b*y;return this.c=_,this.a=R,this.d=h,this.b=J,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(true)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(false)}toString(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return "{ a: "+e+" b: "+t+" c: "+r+" d: "+i+" tx: "+p+" ty: "+s+" }"}};chunkKHH45HMB_cjs.A._wrapFn=n=>chunkKHH45HMB_cjs.G(n,e=>{let t=Object.create(fe.prototype);return t.zpp_inner=e,e.outer=t,t});function et(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.x}function tt(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.y}function me(n){n.zpp_inner.weak&&n.dispose();}var q=class n{get _inner(){return this}constructor(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::direction cannot be null");let r=new chunkKHH45HMB_cjs.B;this.zpp_inner=r;let i=et(e),p=tt(e);r.origin.zpp_inner.x=i,r.origin.zpp_inner.y=p,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),me(e);let s=et(t),a=tt(t);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=a,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),me(t),r.zip_dir=true,r.maxdist=1/0;}static _wrap(e){return e==null?null:e instanceof n?e:chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r})}static fromSegment(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::fromSegment::start is null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::fromSegment::end is null");let r=t.sub(e,true),i=new n(e,r),p=et(e),s=tt(e),a=et(t),c=tt(t),f=a-p,u=c-s,m=Math.sqrt(f*f+u*u);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return i.zpp_inner.maxdist=m,me(e),me(t),i}get origin(){return this.zpp_inner.origin}set origin(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");this.zpp_inner.origin.set(e),me(e);}get direction(){return this.zpp_inner.direction}set direction(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::direction cannot be null");this.zpp_inner.direction.set(e),this.zpp_inner.zip_dir=true,me(e);}get maxDistance(){return this.zpp_inner.maxdist}set maxDistance(e){if(e!==e)throw new Error("Error: maxDistance cannot be NaN");this.zpp_inner.maxdist=e;}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}aabb(){return chunkKHH45HMB_cjs.K._wrap(this.zpp_inner.rayAABB())}at(e,t=false){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let i=r.x,p=r.y,s=i+e*this.zpp_inner.dirx,a=p+e*this.zpp_inner.diry;return chunkKHH45HMB_cjs.H.get(s,a,t)}clone(){return this.copy()}copy(){let e=new n(this.zpp_inner.origin,this.zpp_inner.direction),t=this.zpp_inner.maxdist;if(t!==t)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=t,e}};var ze=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.x.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return chunkKHH45HMB_cjs.G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.position)}get toi(){return this._disposed(),this.zpp_inner.toiDistance}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" toi: "+this.zpp_inner.toiDistance+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};chunkKHH45HMB_cjs.x._createConvexResult=()=>new ze;var de=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.x.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return chunkKHH45HMB_cjs.G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.normal)}get distance(){return this._disposed(),this.zpp_inner.toiDistance}get inner(){return this._disposed(),this.zpp_inner.inner}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" distance: "+this.zpp_inner.toiDistance+" ?inner: "+String(this.zpp_inner.inner)+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};chunkKHH45HMB_cjs.x._createRayResult=()=>new de;function ie(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function rt(n,e){if(n!=null&&n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let t=n.zpp_inner;if(t._immutable)throw new Error("Error: Vec2 is immutable");t._isimmutable!=null&&t._isimmutable();}function ye(n,e){if(ie(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Se=class{static distanceBody(e,t,r,i){rt(r),rt(i);let p=nt(e),s=nt(t);if(p.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=p.shapes.head;for(;a!=null;)chunkKHH45HMB_cjs.y.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)chunkKHH45HMB_cjs.y.validateShape(a.elt),a=a.next;return chunkKHH45HMB_cjs.C.distanceBody(p,s,r.zpp_inner,i.zpp_inner)}static distance(e,t,r,i){rt(r),rt(i),ye(e,"distances"),ye(t,"distances");let p=ie(e),s=ie(t);chunkKHH45HMB_cjs.y.validateShape(p),chunkKHH45HMB_cjs.y.validateShape(s);let a;chunkKHH45HMB_cjs.l.zpp_pool==null?a=new chunkKHH45HMB_cjs.l:(a=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=a.next,a.next=null),a.weak=false;let c=chunkKHH45HMB_cjs.C.distance(p,s,r.zpp_inner,i.zpp_inner,a,1e100);return a.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=a,c}static intersectsBody(e,t){let r=nt(e),i=nt(t);if(r.shapes.head==null||i.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let p=r.shapes.head;for(;p!=null;)chunkKHH45HMB_cjs.y.validateShape(p.elt),p=p.next;for(p=i.shapes.head;p!=null;)chunkKHH45HMB_cjs.y.validateShape(p.elt),p=p.next;let s=r.aabb,a=i.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return false;let c=r.shapes.head;for(;c!=null;){let f=i.shapes.head;for(;f!=null;){if(chunkKHH45HMB_cjs.w.testCollide_safe(c.elt,f.elt))return true;f=f.next;}c=c.next;}return false}static intersects(e,t){ye(e,"intersection"),ye(t,"intersection");let r=ie(e),i=ie(t);chunkKHH45HMB_cjs.y.validateShape(r),chunkKHH45HMB_cjs.y.validateShape(i);let p=r.aabb,s=i.aabb;return p.minx>s.maxx||p.maxx<s.minx||p.miny>s.maxy||p.maxy<s.miny?false:chunkKHH45HMB_cjs.w.testCollide_safe(r,i)}static contains(e,t){ye(e,"containment"),ye(t,"containment");let r=ie(e),i=ie(t);return chunkKHH45HMB_cjs.y.validateShape(r),chunkKHH45HMB_cjs.y.validateShape(i),chunkKHH45HMB_cjs.w.containTest(r,i)}};var Ze=class{static run(e,t,r,i=2,p=null,s=true,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: MarchingSquares requires an iso function to operate");if(t==null)throw new Error("Error: MarchingSquares requires an AABB to define bounds of surface extraction");if(r==null)throw new Error("Error: MarchingSquares requires a Vec2 to define cell size for surface extraction");let c=r.zpp_inner;if(c._validate!=null&&c._validate(),c.x<=0||c.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(i<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(p!=null){let g=p.zpp_inner;if(g._validate!=null&&g._validate(),g.x<=0||g.y<=0)throw new Error("Error: MarchingSquares cannot with non-positive sub-grid dimensions")}let f=chunkKHH45HMB_cjs.E(),u=a??new f.geom.GeomPolyList,m=chunkKHH45HMB_cjs.z,y=t.zpp_inner;if(y._validate!=null&&y._validate(),p==null){let g=y.minx,R=y.miny,J=y.maxx,_=y.maxy;m.run(e,g,R,J,_,r,i,s,u);}else {let g=p.zpp_inner;g._validate!=null&&g._validate();let R=y.maxx-y.minx,J=y.maxy-y.miny,_=R/g.x,h=J/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let vt=y.minx+g.x*Ye,Kt=Ye===b-1?y.maxx:vt+g.x;for(let je=0;je<G;je++){let Nt=y.miny+g.y*je,Jt=je===G-1?y.maxy:Nt+g.y;m.run(e,vt,Nt,Kt,Jt,r,i,s,u);}}}return c.weak&&r.dispose(),p!=null&&p.zpp_inner.weak&&p.dispose(),u}};var Q=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new chunkKHH45HMB_cjs.c,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=chunkKHH45HMB_cjs.E(),i=new r.geom.Vec2List;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Q.internal=false;function oe(n){if(n.outer==null){let e=chunkKHH45HMB_cjs.E();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function I(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Q.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}I.zpp_pool=null;I.get=function(n){let e;return I.zpp_pool==null?(Q.internal=true,e=new I,Q.internal=false):(e=I.zpp_pool,I.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};I.prototype.zpp_inner=null;I.prototype.zpp_i=null;I.prototype.zpp_critical=null;I.prototype.zpp_next=null;I.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=I.zpp_pool,I.zpp_pool=this,this.zpp_inner=null,false)};I.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function E(){this.zpp_inner=null,this.zpp_inner=new Q,this.zpp_inner.outer=this;}E.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=chunkKHH45HMB_cjs.E(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};E.prototype.zpp_inner=null;Object.defineProperty(E.prototype,"length",{get:function(){return this.zpp_gl()}});E.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};E.prototype.zpp_vm=function(){this.zpp_inner.valmod();};E.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};E.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=n,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(n);else for(;this.zpp_inner.at_index!=n;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return oe(this.zpp_inner.at_ite.elt)};E.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(n.zpp_inner):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)):this.zpp_inner.inner.add(n.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}return this.zpp_inner.invalidate(),oe(n)};E.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}else {n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),oe(n)};E.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};E.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};E.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};E.prototype.empty=function(){return this.zpp_gl()==0};E.prototype.iterator=function(){return this.zpp_vm(),I.get(this)};E.prototype.copy=function(n){n==null&&(n=false);let e=chunkKHH45HMB_cjs.E(),t=new e.geom.Vec2List,r=I.get(this);for(;r.hasNext();){let i=r.next(),p;if(n){if(i!=null&&i.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=i.zpp_inner;s._validate!=null&&s._validate();let a=i.zpp_inner.x,c=i.zpp_inner;c._validate!=null&&c._validate();let f=i.zpp_inner.y,u;if(chunkKHH45HMB_cjs.b.poolVec2==null?u=new e.geom.Vec2:(u=chunkKHH45HMB_cjs.b.poolVec2,chunkKHH45HMB_cjs.b.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=false,u==chunkKHH45HMB_cjs.b.nextVec2&&(chunkKHH45HMB_cjs.b.nextVec2=null)),u.zpp_inner==null){let m;chunkKHH45HMB_cjs.l.zpp_pool==null?m=new chunkKHH45HMB_cjs.l:(m=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=m.next,m.next=null),m.weak=false,m._immutable=false,m.x=a,m.y=f,u.zpp_inner=m,u.zpp_inner.outer=u;}else u.zpp_inner.x=a,u.zpp_inner.y=f,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=false,p=u;}else p=i;t.push(p);}return t};E.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");let e=n.iterator();for(;e.hasNext();){let t=e.next();this.has(t)||this.add(t);}};E.prototype.toString=function(){let n="[",e=true,t=I.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};E.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=I.zpp_pool,I.zpp_pool=e,e.zpp_inner=null;break}return this};E.prototype[Symbol.iterator]=function(){let n=I.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};E.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let t=this.at(e);try{n(t)?++e:this.remove(t);}catch{break}}return this};function pe(){if(!chunkKHH45HMB_cjs.M.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}pe.prototype.zpp_inner=null;pe.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=false,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=chunkKHH45HMB_cjs.M.zpp_pool,chunkKHH45HMB_cjs.M.zpp_pool=e;}return n};pe.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr;if(n.wrap==null){let t=n.x,r=n.y;if(t!==t||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let i=chunkKHH45HMB_cjs.E(),p;if(chunkKHH45HMB_cjs.b.poolVec2==null?p=new i.geom.Vec2:(p=chunkKHH45HMB_cjs.b.poolVec2,chunkKHH45HMB_cjs.b.poolVec2=p.zpp_pool,p.zpp_pool=null,p.zpp_disp=false,p==chunkKHH45HMB_cjs.b.nextVec2&&(chunkKHH45HMB_cjs.b.nextVec2=null)),p.zpp_inner==null){let s;chunkKHH45HMB_cjs.l.zpp_pool==null?s=new chunkKHH45HMB_cjs.l:(s=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=s.next,s.next=null),s.weak=false,s._immutable=false,s.x=t,s.y=r,p.zpp_inner=s,p.zpp_inner.outer=p;}else {if(p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;if(s._immutable)throw new Error("Error: Vec2 is immutable");s._isimmutable!=null&&s._isimmutable(),s.x==t&&s.y==r||(s.x=t,s.y=r,s._invalidate!=null&&s._invalidate(s));}p.zpp_inner.weak=false,n.wrap=p,n.wrap.zpp_inner._inuse=true,n.wrap.zpp_inner._invalidate=s=>n.modwrap(s),n.wrap.zpp_inner._validate=()=>n.getwrap();}let e=n.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};pe.prototype[Symbol.iterator]=function(){return {_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};var $t=chunkKHH45HMB_cjs.E();$t.geom.GeomVertexIterator=pe;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new chunkKHH45HMB_cjs.u,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=chunkKHH45HMB_cjs.E(),i=new r.dynamics.ContactList;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Y.internal=false;var be=class n{constructor(){if(!chunkKHH45HMB_cjs.D.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof chunkKHH45HMB_cjs.D?chunkKHH45HMB_cjs.G(e,t=>{chunkKHH45HMB_cjs.D.internal=true;let r=new n;return chunkKHH45HMB_cjs.D.internal=false,r.zpp_inner=t,t.outer=r,r}):null:null}get polygon(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.outer_zn}get localNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_lnorm==null&&e.getlnorm(),e.wrap_lnorm}get worldNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_gnorm==null&&e.getgnorm(),e.wrap_gnorm}get length(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.length}get localProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.lprojection}get worldProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");if(e.polygon.body==null)throw new Error("Error: Edge world projection only makes sense for Polygons contained within a rigid body");return e.polygon.validate_gaxi(),e.gprojection}get localVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp0)}get localVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp1)}get worldVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp0)}get worldVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp1)}toString(){let e=this.zpp_inner;return e.polygon==null?"Edge(object-pooled)":e.polygon.body==null?(e.polygon.validate_laxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } }"):(e.polygon.validate_gaxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } worldNormal : { x: "+e.gnormx+" y: "+e.gnormy+" } }")}_wrapVert(e){let t=chunkKHH45HMB_cjs.E();if(e.outer==null){e.outer=new t.geom.Vec2;let r=e.outer.zpp_inner;r.outer!=null&&(r.outer.zpp_inner=null,r.outer=null),r._isimmutable=null,r._validate=null,r._invalidate=null,r.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=r,e.outer.zpp_inner=e;}return e.outer}};chunkKHH45HMB_cjs.D._wrapFn=n=>chunkKHH45HMB_cjs.G(n,e=>{chunkKHH45HMB_cjs.D.internal=true;let t=new be;return chunkKHH45HMB_cjs.D.internal=false,t.zpp_inner=e,e.outer=t,t});var ge=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return chunkKHH45HMB_cjs.a.ValidationResult_VALID==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_VALID=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_VALID}static get DEGENERATE(){return chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE}static get CONCAVE(){return chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING}toString(){return this===chunkKHH45HMB_cjs.a.ValidationResult_VALID?"VALID":this===chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE?"DEGENERATE":this===chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE?"CONCAVE":this===chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Qt=chunkKHH45HMB_cjs.E();Qt.shape.ValidationResult=ge;var we=class n{get _inner(){return this}constructor(e=false){let t=new chunkKHH45HMB_cjs.v;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(true),t.ignore=e);}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.v?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}get group(){return this.zpp_inner.group==null?null:this.zpp_inner.group.outer}set group(e){if(e===this)throw new Error("Error: Cannot assign InteractionGroup to itself");this.zpp_inner.setGroup(e==null?null:e.zpp_inner);}get ignore(){return this.zpp_inner.ignore}set ignore(e){this.zpp_inner.ignore!=e&&(this.zpp_inner.invalidate(true),this.zpp_inner.ignore=e);}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=chunkKHH45HMB_cjs.E();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,true);}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=chunkKHH45HMB_cjs.E();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,true);}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};chunkKHH45HMB_cjs.v._wrapFn=n=>chunkKHH45HMB_cjs.G(n,e=>{let t=Object.create(we.prototype);return t.zpp_inner=e,e.outer=t,t});var Ee=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return chunkKHH45HMB_cjs.a.ArbiterType_COLLISION==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ArbiterType_COLLISION=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ArbiterType_COLLISION}static get SENSOR(){return chunkKHH45HMB_cjs.a.ArbiterType_SENSOR==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ArbiterType_SENSOR=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ArbiterType_SENSOR}static get FLUID(){return chunkKHH45HMB_cjs.a.ArbiterType_FLUID==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ArbiterType_FLUID=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ArbiterType_FLUID}toString(){return this===chunkKHH45HMB_cjs.a.ArbiterType_COLLISION?"COLLISION":this===chunkKHH45HMB_cjs.a.ArbiterType_SENSOR?"SENSOR":this===chunkKHH45HMB_cjs.a.ArbiterType_FLUID?"FLUID":""}},Xt=chunkKHH45HMB_cjs.E();Xt.dynamics.ArbiterType=Ee;chunkKHH45HMB_cjs.F();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.t.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return chunkKHH45HMB_cjs.t.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.FLUID?this.zpp_inner.fluidarb.outer_zn:null}get shape1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer}get shape2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer}get body1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b2.outer:this.zpp_inner.b1.outer}get body2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b1.outer:this.zpp_inner.b2.outer}get state(){this._activeCheck();let e=chunkKHH45HMB_cjs.E(),t=this.zpp_inner.immState;return t==5?(chunkKHH45HMB_cjs.a.PreFlag_ACCEPT==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT):t==1?(chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE):t==6?(chunkKHH45HMB_cjs.a.PreFlag_IGNORE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE):(chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL}isFluidArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.FLUID}isSensorArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.SENSOR}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),chunkKHH45HMB_cjs.I.get(0,0,0)}toString(){let e=this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL?"CollisionArbiter":this.zpp_inner.type==chunkKHH45HMB_cjs.t.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer,r=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer,i=e+"("+t.toString()+"|"+r.toString()+")";return this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL&&(i+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),i+="<-"+this.state.toString(),i}_activeCheck(){if(!this.zpp_inner.active)throw new Error("Error: Arbiter not currently in use")}_checkBody(e){let t=this.zpp_inner,r=t.ws1.id>t.ws2.id?t.b2.outer:t.b1.outer,i=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=i)throw new Error("Error: Arbiter does not relate to body")}},en=chunkKHH45HMB_cjs.E();en.dynamics.Arbiter=j;var Ve=class extends j{constructor(){super();}get contacts(){return this._activeCheck(),this.zpp_inner.colarb.wrap_contacts==null&&this.zpp_inner.colarb.setupcontacts(),this.zpp_inner.colarb.wrap_contacts}get normal(){return this._activeCheck(),this.zpp_inner.colarb.wrap_normal==null&&this.zpp_inner.colarb.getnormal(),this.zpp_inner.colarb.wrap_normal}get radius(){return this._activeCheck(),this.zpp_inner.colarb.radius}get referenceEdge1(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get referenceEdge2(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get elasticity(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.restitution}set elasticity(e){if(this._mutableCheck("elasticity"),e!==e)throw new Error("Error: CollisionArbiter::elasticity cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::elasticity cannot be negative");this.zpp_inner.colarb.restitution=e,this.zpp_inner.colarb.userdef_restitution=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get dynamicFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.dyn_fric}set dynamicFriction(e){if(this._mutableCheck("dynamicFriction"),e!==e)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be negative");this.zpp_inner.colarb.dyn_fric=e,this.zpp_inner.colarb.userdef_dyn_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get staticFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.stat_fric}set staticFriction(e){if(this._mutableCheck("staticFriction"),e!==e)throw new Error("Error: CollisionArbiter::staticFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::staticFriction cannot be negative");this.zpp_inner.colarb.stat_fric=e,this.zpp_inner.colarb.userdef_stat_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get rollingFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.rfric}set rollingFriction(e){if(this._mutableCheck("rollingFriction"),e!==e)throw new Error("Error: CollisionArbiter::rollingFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::rollingFriction cannot be negative");this.zpp_inner.colarb.rfric=e,this.zpp_inner.colarb.userdef_rfric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}firstVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==-1:false}secondVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==1:false}normalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return !t||r.oc1.fresh?r.oc1.wrapper().rollingImpulse(e):0}_mutableCheck(e){if(!this.zpp_inner.colarb.mutable)throw new Error("Error: CollisionArbiter::"+e+" is only mutable during a pre-handler")}_accumulateImpulse(e,t,r){let i=0,p=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let c=a.oc1.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}if(a.hc2&&(!r||a.oc2.fresh)){let c=a.oc2.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}return chunkKHH45HMB_cjs.I.get(i,p,s)}};var Oe=class extends j{constructor(){super();}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.fluidarb.wrap_position)}set position(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e==null)throw new Error("Error: FluidArbiter::position cannot be null");this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),this.zpp_inner.fluidarb.wrap_position.set(e);}get overlap(){return this._activeCheck(),this.zpp_inner.fluidarb.overlap}set overlap(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e!==e)throw new Error("Error: FluidArbiter::overlap cannot be NaN");if(e<=0||e==1/0)throw new Error("Error: FluidArbiter::overlap must be strictly positive and non infinite");this.zpp_inner.fluidarb.overlap=e;}buoyancyImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb;return e==null?chunkKHH45HMB_cjs.I.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?chunkKHH45HMB_cjs.I.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):chunkKHH45HMB_cjs.I.get(-t.buoyx,-t.buoyy,-(t.buoyy*t.r1x-t.buoyx*t.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return chunkKHH45HMB_cjs.I.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),i=this.dragImpulse(e),p=r.zpp_inner,s=i.zpp_inner;return p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.x=s.x+p.x,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.y=s.y+p.y,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.z=s.z+p.z,r.dispose(),i}};var Pe=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.u.internal)throw new Error("Error: Cannot instantiate Contact derp!")}get arbiter(){if(this.zpp_inner.arbiter==null)return null;let e=this.zpp_inner.arbiter.outer;return e.zpp_inner.type==chunkKHH45HMB_cjs.t.COL?e.zpp_inner.colarb.outer_zn:null}get penetration(){return this._inactiveCheck(),-this.zpp_inner.dist}get position(){return this._inactiveCheck(),this.zpp_inner.wrap_position==null&&this.zpp_inner.getposition(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.wrap_position)}get fresh(){return this._inactiveCheck(),this.zpp_inner.fresh}get friction(){return this._inactiveCheck(),this.zpp_inner.inner.friction}normalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc;return e==null?chunkKHH45HMB_cjs.I.get(t.nx*i,t.ny*i):(this._checkBody(e,t),e==t.b1.outer?chunkKHH45HMB_cjs.I.get(t.nx*-i,t.ny*-i,-(t.ny*r.r1x-t.nx*r.r1y)*i):chunkKHH45HMB_cjs.I.get(t.nx*i,t.ny*i,(t.ny*r.r2x-t.nx*r.r2y)*i))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jtAcc;return e==null?chunkKHH45HMB_cjs.I.get(-t.ny*i,t.nx*i):(this._checkBody(e,t),e==t.b1.outer?chunkKHH45HMB_cjs.I.get(t.ny*i,-t.nx*i,-(r.r1x*t.nx+r.r1y*t.ny)*i):chunkKHH45HMB_cjs.I.get(-t.ny*i,t.nx*i,(r.r2x*t.nx+r.r2y*t.ny)*i))}rollingImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=t.jrAcc;return e==null?r:(this._checkBody(e,t),e==t.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc,p=r.jtAcc,s=t.jrAcc;if(e==null)return chunkKHH45HMB_cjs.I.get(t.nx*i-t.ny*p,t.ny*i+t.nx*p,s);this._checkBody(e,t);let a=t.nx*i-t.ny*p,c=t.ny*i+t.nx*p;return e==t.b1.outer?chunkKHH45HMB_cjs.I.get(-a,-c,-(c*r.r1x-a*r.r1y)-s):chunkKHH45HMB_cjs.I.get(a,c,c*r.r2x-a*r.r2y+s)}toString(){return this.zpp_inner.arbiter==null||this.zpp_inner.arbiter.cleared?"{object-pooled}":"{Contact}"}_inactiveCheck(){if(this.zpp_inner.inactiveme())throw new Error("Error: Contact not currently in use")}_checkBody(e,t){if(e!=t.b1.outer&&e!=t.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};chunkKHH45HMB_cjs.u._wrapFn=n=>{chunkKHH45HMB_cjs.u.internal=true;let e=new Pe;return chunkKHH45HMB_cjs.u.internal=false,e.zpp_inner=n,n.outer=e,e};function tn(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function V(n){return n.valmod(),n.zip_length&&(n.zip_length=false,n.user_length=tn(n)),n.user_length}function v(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}v.zpp_pool=null;v.get=function(n){let e;return v.zpp_pool==null?(Y.internal=true,e=new v,Y.internal=false):(e=v.zpp_pool,v.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};v.prototype.zpp_inner=null;v.prototype.zpp_i=null;v.prototype.zpp_critical=null;v.prototype.zpp_next=null;v.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=V(this.zpp_inner.zpp_inner);return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=v.zpp_pool,v.zpp_pool=this,this.zpp_inner=null,false)};v.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function A(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this;}A.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=chunkKHH45HMB_cjs.E(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};A.prototype.zpp_inner=null;Object.defineProperty(A.prototype,"length",{get:function(){return V(this.zpp_inner)}});A.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};A.prototype.at=function(n){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=V(this.zpp_inner)-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)for(this.zpp_inner.at_index=0,this.zpp_inner.at_ite=this.zpp_inner.inner.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}for(;this.zpp_inner.at_index!=n;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}return this.zpp_inner.at_ite.wrapper()};A.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(n.zpp_inner);else {if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}else this.zpp_inner.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}else {e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};A.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=false,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};A.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift();};A.prototype.empty=function(){return V(this.zpp_inner)==0};A.prototype.iterator=function(){return this.zpp_inner.valmod(),v.get(this)};A.prototype.copy=function(n){n==null&&(n=false);let e=chunkKHH45HMB_cjs.E(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=v.get(this);for(;r.hasNext();){let i=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(i);}return t};A.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=v.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t));}};A.prototype.toString=function(){let n="[",e=true;this.zpp_inner.valmod();let t=v.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};A.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=v.get(this);for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=v.zpp_pool,v.zpp_pool=e,e.zpp_inner=null;break}return this};A.prototype[Symbol.iterator]=function(){let n=v.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};A.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=V(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r);}catch{break}}return this};var C=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return chunkKHH45HMB_cjs.a.CbEvent_BEGIN==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_BEGIN=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_BEGIN}static get ONGOING(){return chunkKHH45HMB_cjs.a.CbEvent_ONGOING==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_ONGOING=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_ONGOING}static get END(){return chunkKHH45HMB_cjs.a.CbEvent_END==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_END=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_END}static get WAKE(){return chunkKHH45HMB_cjs.a.CbEvent_WAKE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_WAKE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_WAKE}static get SLEEP(){return chunkKHH45HMB_cjs.a.CbEvent_SLEEP==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_SLEEP=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_SLEEP}static get BREAK(){return chunkKHH45HMB_cjs.a.CbEvent_BREAK==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_BREAK=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_BREAK}static get PRE(){return chunkKHH45HMB_cjs.a.CbEvent_PRE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_PRE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_PRE}toString(){return this===chunkKHH45HMB_cjs.a.CbEvent_BEGIN?"BEGIN":this===chunkKHH45HMB_cjs.a.CbEvent_ONGOING?"ONGOING":this===chunkKHH45HMB_cjs.a.CbEvent_END?"END":this===chunkKHH45HMB_cjs.a.CbEvent_WAKE?"WAKE":this===chunkKHH45HMB_cjs.a.CbEvent_SLEEP?"SLEEP":this===chunkKHH45HMB_cjs.a.CbEvent_BREAK?"BREAK":this===chunkKHH45HMB_cjs.a.CbEvent_PRE?"PRE":""}},nn=chunkKHH45HMB_cjs.E();nn.callbacks.CbEvent=C;chunkKHH45HMB_cjs.F();var Ce=class n{get _inner(){return this}constructor(){this.zpp_inner=new chunkKHH45HMB_cjs.e,this.zpp_inner.outer=this;}static get ANY_BODY(){return chunkKHH45HMB_cjs.e.ANY_BODY}static get ANY_CONSTRAINT(){return chunkKHH45HMB_cjs.e.ANY_CONSTRAINT}static get ANY_SHAPE(){return chunkKHH45HMB_cjs.e.ANY_SHAPE}static get ANY_COMPOUND(){return chunkKHH45HMB_cjs.e.ANY_COMPOUND}get id(){return this.zpp_inner.id}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}get interactors(){return this.zpp_inner.wrap_interactors==null&&(this.zpp_inner.wrap_interactors=chunkKHH45HMB_cjs.Z.get(this.zpp_inner.interactors,true)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=chunkKHH45HMB_cjs.Y.get(this.zpp_inner.constraints,true)),this.zpp_inner.wrap_constraints}including(e){return new(chunkKHH45HMB_cjs.E()).callbacks.OptionType(this).including(e)}excluding(e){return new(chunkKHH45HMB_cjs.E()).callbacks.OptionType(this).excluding(e)}toString(){return this===chunkKHH45HMB_cjs.e.ANY_BODY?"ANY_BODY":this===chunkKHH45HMB_cjs.e.ANY_SHAPE?"ANY_SHAPE":this===chunkKHH45HMB_cjs.e.ANY_COMPOUND?"ANY_COMPOUND":this===chunkKHH45HMB_cjs.e.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.e?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},rn=chunkKHH45HMB_cjs.E();rn.callbacks.CbType=Ce;chunkKHH45HMB_cjs.F();var Z=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return chunkKHH45HMB_cjs.a.InteractionType_COLLISION==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_COLLISION=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_COLLISION}static get SENSOR(){return chunkKHH45HMB_cjs.a.InteractionType_SENSOR==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_SENSOR=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_SENSOR}static get FLUID(){return chunkKHH45HMB_cjs.a.InteractionType_FLUID==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_FLUID=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_FLUID}static get ANY(){return chunkKHH45HMB_cjs.a.InteractionType_ANY==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_ANY=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_ANY}toString(){return this===chunkKHH45HMB_cjs.a.InteractionType_COLLISION?"COLLISION":this===chunkKHH45HMB_cjs.a.InteractionType_SENSOR?"SENSOR":this===chunkKHH45HMB_cjs.a.InteractionType_FLUID?"FLUID":this===chunkKHH45HMB_cjs.a.InteractionType_ANY?"ANY":""}},on=chunkKHH45HMB_cjs.E();on.callbacks.InteractionType=Z;var W=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return chunkKHH45HMB_cjs.a.PreFlag_ACCEPT==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT}static get IGNORE(){return chunkKHH45HMB_cjs.a.PreFlag_IGNORE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE}static get ACCEPT_ONCE(){return chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE}toString(){return this===chunkKHH45HMB_cjs.a.PreFlag_ACCEPT?"ACCEPT":this===chunkKHH45HMB_cjs.a.PreFlag_IGNORE?"IGNORE":this===chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},pn=chunkKHH45HMB_cjs.E();pn.callbacks.PreFlag=W;var xe=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new chunkKHH45HMB_cjs.j,this.zpp_inner.outer=this,e!=null&&this.including(e),t!=null&&this.excluding(t);}get includes(){return this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes(),this.zpp_inner.wrap_includes}get excludes(){return this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes(),this.zpp_inner.wrap_excludes}including(e){return this.zpp_inner.append(this.zpp_inner.includes,e),this}excluding(e){return this.zpp_inner.append(this.zpp_inner.excludes,e),this}toString(){this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes();let e=this.zpp_inner.wrap_includes.toString();this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes();let t=this.zpp_inner.wrap_excludes.toString();return "@{"+e+" excluding "+t+"}"}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.j?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},sn=chunkKHH45HMB_cjs.E();sn.callbacks.OptionType=xe;function an(n){return n===C.BEGIN?0:n===C.END?1:n===C.WAKE?2:n===C.SLEEP?3:n===C.BREAK?4:n===C.PRE?5:n===C.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!chunkKHH45HMB_cjs.f.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null;}static _wrap(e){return e instanceof n?e:e&&e instanceof chunkKHH45HMB_cjs.f?chunkKHH45HMB_cjs.G(e,t=>{if(t.outer)return t.outer;let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):null}get type(){return chunkKHH45HMB_cjs.f.types[this.zpp_inner.type]}get event(){return chunkKHH45HMB_cjs.f.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(chunkKHH45HMB_cjs.f.events[this.zpp_inner.event]!=e){let t=an(e);this.zpp_inner.swapEvent(t);}}get precedence(){return this.zpp_inner.precedence}set precedence(e){this.zpp_inner.precedence!=e&&(this.zpp_inner.precedence=e,this.zpp_inner.invalidate_precedence());}get space(){return this.zpp_inner.space==null?null:chunkKHH45HMB_cjs.X._wrap(this.zpp_inner.space.outer)}set space(e){let t=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=t)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),t!=null){let i=t.zpp_inner.wrap_listeners;i.zpp_inner.reverse_flag?i.push(this):i.unshift(this);}else this.zpp_inner.space=null;}toString(){let t=["BEGIN","END","WAKE","SLEEP","BREAK","PRE","ONGOING"][this.zpp_inner.event];if(this.zpp_inner.type==0){let r=this.zpp_inner.body;return "BodyListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return "ConstraintListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else {let r=this.zpp_inner.interaction,i;switch(r.itype){case 1:i="COLLISION";break;case 2:i="SENSOR";break;case 4:i="FLUID";break;default:i="ALL";}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+i+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+i+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var ve=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return chunkKHH45HMB_cjs.a.ListenerType_BODY==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_BODY=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_BODY}static get CONSTRAINT(){return chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT}static get INTERACTION(){return chunkKHH45HMB_cjs.a.ListenerType_INTERACTION==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_INTERACTION=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_INTERACTION}static get PRE(){return chunkKHH45HMB_cjs.a.ListenerType_PRE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_PRE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_PRE}toString(){return this===chunkKHH45HMB_cjs.a.ListenerType_BODY?"BODY":this===chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT?"CONSTRAINT":this===chunkKHH45HMB_cjs.a.ListenerType_INTERACTION?"INTERACTION":this===chunkKHH45HMB_cjs.a.ListenerType_PRE?"PRE":""}},ln=chunkKHH45HMB_cjs.E();ln.callbacks.ListenerType=ve;chunkKHH45HMB_cjs.F();var F=class{constructor(){this.zpp_inner=null;if(!chunkKHH45HMB_cjs.d.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return chunkKHH45HMB_cjs.f.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return ""}};var Re=class extends F{get body(){return this.zpp_inner.body.outer}toString(){return "Cb:"+["WAKE","SLEEP"][this.zpp_inner.event-2]+":"+this.zpp_inner.body.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var ke=class extends F{get constraint(){return this.zpp_inner.constraint.outer}toString(){return "Cb:"+["WAKE","SLEEP","BREAK"][this.zpp_inner.event-2]+":"+this.zpp_inner.constraint.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Be=class extends F{get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get arbiters(){return this.zpp_inner.wrap_arbiters}toString(){return "Cb:"+["BEGIN","END","","","","","ONGOING"][this.zpp_inner.event]+":"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.wrap_arbiters.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Fe=class extends F{get arbiter(){return this.zpp_inner.pre_arbiter.wrapper()}get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get swapped(){return this.zpp_inner.pre_swapped}toString(){return "Cb:PRE::"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.pre_arbiter.wrapper().toString()+" : listnener: "+String(this.zpp_inner.listener.outer)}};var Ge=class extends B{constructor(e,t,r,i=0){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,r==null)throw new Error("Error: BodyListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new chunkKHH45HMB_cjs.g(chunkKHH45HMB_cjs.j.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: BodyListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};var De=class extends B{constructor(e,t,r,i=0){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else if(e===C.BREAK)p=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new chunkKHH45HMB_cjs.h(chunkKHH45HMB_cjs.j.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: ConstraintListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};function Me(n){return n===Z.COLLISION?1:n===Z.SENSOR?2:n===Z.FLUID?4:7}function se(n){return n==1?Z.COLLISION:n==2?Z.SENSOR:n==4?Z.FLUID:n==7?Z.ANY:null}var Ue=class extends B{constructor(e,t,r,i,p,s=0){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,p==null)throw new Error("Error: InteractionListener::handler cannot be null");if(e==null)throw new Error("Error: CbEvent cannot be null for InteractionListener");let a;if(e===C.BEGIN)a=0;else if(e===C.END)a=1;else if(e===C.ONGOING)a=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new chunkKHH45HMB_cjs.i(chunkKHH45HMB_cjs.j.argument(r),chunkKHH45HMB_cjs.j.argument(i),a,2),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zni=this,this.zpp_inner.precedence=s,this.zpp_inner_zn.handleri=p,t==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Me(t));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handleri}set handler(e){if(e==null)throw new Error("Error: InteractionListener::handler cannot be null");this.zpp_inner_zn.handleri=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e;}};var ae=class extends B{constructor(e,t,r,i,p=0,s=false){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,i==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new chunkKHH45HMB_cjs.i(chunkKHH45HMB_cjs.j.argument(t),chunkKHH45HMB_cjs.j.argument(r),5,3),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_znp=this,this.zpp_inner.precedence=p,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=i,e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handlerp}set handler(e){if(e==null)throw new Error("Error: PreListener must take a non-null handler!");this.zpp_inner_zn.handlerp=e,this.zpp_inner_zn.wake();}get pure(){return this.zpp_inner_zn.pure}set pure(e){e||this.zpp_inner_zn.wake(),this.zpp_inner_zn.pure=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}};var We=class n extends chunkKHH45HMB_cjs.ka{constructor(e,t=false){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r=new chunkKHH45HMB_cjs.r(e,t);this.zpp_inner=r,r.outer=this,r.outer_zn=this;}static _wrap(e){return e==null?null:e instanceof n?e:e.zpp_inner?.outer instanceof n?e.zpp_inner.outer:chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new chunkKHH45HMB_cjs.H;return e.zpp_inner._inuse=true,e.zpp_inner._invalidate=this.zpp_inner.bindVec2_invalidate.bind(this.zpp_inner),e}__copy(){throw new Error("Error: UserConstraint::__copy must be overriden")}__broken(){}__validate(){}__draw(e){}__prepare(){}__position(e){throw new Error("Error: UserConstraint::__position must be overriden")}__velocity(e){throw new Error("Error: Userconstraint::__velocity must be overriden")}__eff_mass(e){throw new Error("Error: UserConstraint::__eff_mass must be overriden")}__clamp(e){}__impulse(e,t,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,t=new chunkKHH45HMB_cjs.J(e,1);for(let r=0;r<e;r++){if(r<0||r>=t.zpp_inner.m||0>=t.zpp_inner.n)throw new Error("Error: MatMN indices out of range");t.zpp_inner.x[r*t.zpp_inner.n]=this.zpp_inner.jAcc[r];}return t}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let t=false;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=true;break}if(!t)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):chunkKHH45HMB_cjs.I.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let i=this.zpp_inner.bodies[r];if(i.body!=null){let p=false;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==i.body){p=true;break}p||e(i.body.outer);}++r;}}__invalidate(){this.zpp_inner.immutable_midstep("UserConstraint::invalidate()"),this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&this.zpp_inner.wake();}__registerBody(e,t){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=t){if(e!=null){if(!this.zpp_inner.remBody(e.zpp_inner))throw new Error("Error: oldBody is not registered to the cosntraint");this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&e.zpp_inner.wake();}t!=null&&this.zpp_inner.addBody(t.zpp_inner),this.zpp_inner.wake(),t?.zpp_inner.wake();}return t}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e;}};function O(n){let{typeName:e,namespaceParts:t,zppListClass:r,wrapElement:i,unwrapElement:p}=n,s=chunkKHH45HMB_cjs.E(),a=s.__zpp,c=()=>a.util[r],f=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!c().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=c();return u.zpp_pool==null?(b.internal=true,h=new u,b.internal=false):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=false,h},u.prototype.zpp_inner=null,u.prototype.zpp_i=null,u.prototype.zpp_critical=null,u.prototype.zpp_next=null,u.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let _=this.zpp_inner;_.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=true,this.zpp_i<h?true:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,false)},u.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(c()),this.zpp_inner.outer=this;}m.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new m;for(let b=0;b<_.length;b++)h.push(_[b]);return h},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function y(_){return _.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return y(this)}}),m.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(p(_))},m.prototype.at=function(_){if(this.zpp_inner.valmod(),_<0||_>=y(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(_=y(this)-1-_),_<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=_,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(_);else for(;this.zpp_inner.at_index!=_;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return i(this.zpp_inner.at_ite.elt)},m.prototype.push=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(p(_)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.unshift=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))):this.zpp_inner.inner.add(p(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}return this.zpp_inner.invalidate(),i(_)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}else {_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),i(_)},m.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},m.prototype.remove=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=false,b=this.zpp_inner.inner.head,G=p(_);for(;b!=null;){if(b.elt==G){h=true;break}b=b.next;}return h&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(_),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(G),this.zpp_inner.invalidate()),h},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift();},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},m.prototype.copy=function(_){_==null&&(_=false);let h=new m,b=u.get(this);for(;b.hasNext();){let G=b.next();if(_)throw new Error("Error: "+e+" is not a copyable type");h.push(G);}return h},m.prototype.merge=function(_){if(_==null)throw new Error("Error: Cannot merge with null list");let h=u.get(_);for(;h.hasNext();){let b=h.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b));}},m.prototype.toString=function(){let _="[",h=true,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=false;}return _+"]"},m.prototype.foreach=function(_){if(_==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let h=u.get(this);for(;h.hasNext();)try{_(h.next());}catch{h.zpp_next=u.zpp_pool,u.zpp_pool=h,h.zpp_inner=null;break}return this},m.prototype.filter=function(_){if(_==null)throw new Error("Error: Cannot select elements of list with null");let h=0;for(;h<y(this);){let b=this.at(h);try{_(b)?++h:this.remove(b);}catch{break}}return this},m.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},m.prototype[Symbol.iterator]=function(){let _=u.get(this);return {next(){return _.hasNext()?{value:_.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};let g=f(),R=e+"Iterator",J=e+"List";return g[R]=u,g[J]=m,{Iterator:u,List:m}}var X=n=>n.outer,K=n=>n.zpp_inner??(n._inner?n._inner.zpp_inner??n._inner:n);O({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:X,unwrapElement:K});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:X,unwrapElement:K});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:X,unwrapElement:K});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:X,unwrapElement:K});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:X,unwrapElement:K});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:X,unwrapElement:K});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:X,unwrapElement:K});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:X,unwrapElement:K});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:n=>n.outer_i,unwrapElement:n=>n.zpp_inner_i});function le(n){if(n.outer==null){let e=chunkKHH45HMB_cjs.E();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=false,this._length=0,this.inner=null,E.call(this),this.at_ite=null,this.at_index=0,this.zip_length=true,this._length=0;}for(let n in E.prototype)L.prototype[n]=E.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:true});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=false;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=false);let t=new L;return t.inner=n,t.zpp_inner.immutable=e,t};L.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let n=this.inner.next;for(;n!=null;)this._length++,n=n.next;this.zip_length=false;}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=true,this._length=0,this.at_ite=null);};L.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),(n<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==n;)this.at_index++,this.at_ite=this.at_ite.next;return le(this.at_ite)};L.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(n.zpp_inner);else {let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}else this.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}else {this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}return this.zpp_inner.invalidate(),le(n)};L.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}else {n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}return this.zpp_inner.invalidate(),le(n)};L.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};L.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};var _n=chunkKHH45HMB_cjs.E(),un=_n.__zpp;un.util.ZPP_MixVec2List=L;var z=chunkKHH45HMB_cjs.E();z.Config=Object.assign(z.Config||{},Pt);z.util.Debug=Xe;z.geom.Vec2=chunkKHH45HMB_cjs.H;z.geom.Vec3=chunkKHH45HMB_cjs.I;z.geom.Mat23=fe;z.geom.MatMN=chunkKHH45HMB_cjs.J;z.geom.AABB=chunkKHH45HMB_cjs.K;z.geom.Winding=chunkKHH45HMB_cjs.L;z.geom.Ray=q;z.geom.ConvexResult=ze;z.geom.RayResult=de;z.geom.Geom=Se;z.geom.GeomPoly=chunkKHH45HMB_cjs.N;z.geom.MarchingSquares=Ze;z.geom.Vec2Iterator=I;z.geom.Vec2List=E;z.geom.GeomVertexIterator=pe;z.__zpp.geom.ZPP_GeomVertexIterator=chunkKHH45HMB_cjs.M;z.__zpp.util.ZPP_ContactList=Y;z.phys.Interactor=chunkKHH45HMB_cjs.R;z.phys.Body=chunkKHH45HMB_cjs._;chunkKHH45HMB_cjs.O(n=>chunkKHH45HMB_cjs._._wrap(n));z.phys.BodyType=chunkKHH45HMB_cjs.$;z.phys.Compound=chunkKHH45HMB_cjs.aa;chunkKHH45HMB_cjs.Q(n=>chunkKHH45HMB_cjs.aa._wrap(n));z.phys.FluidProperties=chunkKHH45HMB_cjs.T;z.phys.Material=chunkKHH45HMB_cjs.ba;z.phys.GravMassMode=chunkKHH45HMB_cjs.ca;z.phys.InertiaMode=chunkKHH45HMB_cjs.da;z.phys.MassMode=chunkKHH45HMB_cjs.ea;z.shape.Shape=chunkKHH45HMB_cjs.V;chunkKHH45HMB_cjs.P(n=>chunkKHH45HMB_cjs.V._wrap(n));z.shape.Circle=chunkKHH45HMB_cjs.fa;z.shape.Polygon=chunkKHH45HMB_cjs.ga;z.shape.Capsule=chunkKHH45HMB_cjs.ha;z.shape.Edge=be;z.shape.ShapeType=chunkKHH45HMB_cjs.U;z.shape.ValidationResult=ge;z.space.Space=chunkKHH45HMB_cjs.X;z.space.Broadphase=chunkKHH45HMB_cjs.ia;z.dynamics.InteractionFilter=chunkKHH45HMB_cjs.ja;z.dynamics.InteractionGroup=we;z.dynamics.ArbiterType=Ee;z.dynamics.Arbiter=j;chunkKHH45HMB_cjs.t._createColArb=()=>new Ve;chunkKHH45HMB_cjs.t._createFluidArb=()=>new Oe;z.dynamics.Contact=Pe;z.dynamics.ContactIterator=v;z.dynamics.ContactList=A;z.callbacks.CbEvent=C;z.callbacks.CbType=Ce;z.callbacks.InteractionType=Z;z.callbacks.PreFlag=W;z.callbacks.OptionType=xe;z.callbacks.Listener=B;z.callbacks.ListenerType=ve;z.callbacks.Callback=F;chunkKHH45HMB_cjs.d._createBodyCb=()=>new Re;chunkKHH45HMB_cjs.d._createConCb=()=>new ke;chunkKHH45HMB_cjs.d._createIntCb=()=>new Be;chunkKHH45HMB_cjs.d._createPreCb=()=>new Fe;z.callbacks.BodyListener=Ge;z.callbacks.ConstraintListener=De;z.callbacks.InteractionListener=Ue;z.callbacks.PreListener=ae;z.constraint.Constraint=chunkKHH45HMB_cjs.ka;chunkKHH45HMB_cjs.k._createFn=(...n)=>new chunkKHH45HMB_cjs.la(...n);chunkKHH45HMB_cjs.m._createFn=(...n)=>new chunkKHH45HMB_cjs.ma(...n);chunkKHH45HMB_cjs.n._createFn=(...n)=>new chunkKHH45HMB_cjs.na(...n);chunkKHH45HMB_cjs.o._createFn=(...n)=>new chunkKHH45HMB_cjs.oa(...n);chunkKHH45HMB_cjs.p._createFn=(...n)=>new chunkKHH45HMB_cjs.pa(...n);chunkKHH45HMB_cjs.q._createFn=(...n)=>new chunkKHH45HMB_cjs.qa(...n);chunkKHH45HMB_cjs.s._createFn=(...n)=>new chunkKHH45HMB_cjs.ra(...n);z.constraint.UserConstraint=We;var Ct=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,i){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,i){}drawSolidCapsule(e,t,r,i){}drawPoint(e,t){}};function hn(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof chunkKHH45HMB_cjs.N){if(n.zpp_disp)throw new Error("Error: GeomPoly has been disposed and cannot be used!");t=n.copy();}else {if(!Array.isArray(n))throw new Error("Error: vertices must be an Array<Vec2> or GeomPoly");if(n.length<3)throw new Error("Error: At least 3 vertices are required, got "+n.length);for(let f=0;f<n.length;f++)if(n[f]==null)throw new Error("Error: vertices["+f+"] is null");t=new chunkKHH45HMB_cjs.N(n);}if(t.size()<3)throw t.dispose(),new Error("Error: At least 3 vertices are required, got "+t.size());if(t.isDegenerate())throw t.dispose(),new Error("Error: Polygon is degenerate (zero area)");if(!t.isSimple())throw t.dispose(),new Error("Error: Polygon is self-intersecting");let r=e?.simplify??0;if(r>0){let f=t.simplify(r);if(t.dispose(),t=f,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let f=[],u=t.forwardIterator();for(;u.hasNext();){let m=u.next();f.push(chunkKHH45HMB_cjs.H.get(m.x,m.y));}t.dispose(),f.reverse(),t=new chunkKHH45HMB_cjs.N(f);}let i=e?.material,p=e?.filter,s=e?.delaunay??false,a=new chunkKHH45HMB_cjs._(e?.type??chunkKHH45HMB_cjs.$.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new chunkKHH45HMB_cjs.ga(t,i,p)),t.dispose(),a;let c=t.convexDecomposition(s);for(let f of c)a.shapes.add(new chunkKHH45HMB_cjs.ga(f,i,p));return t.dispose(),a}var xt=class{constructor(e,t,r={}){this._oneWayListener=null;this._grounded=false;this._groundNormal=null;this._groundBody=null;this._onMovingPlatform=false;this._slopeAngle=0;this._wallLeft=false;this._wallRight=false;this._timeSinceGrounded=0;this.space=e,this.body=t,this._maxSlopeAngle=r.maxSlopeAngle??Math.PI/4,this._maxSlopeCos=Math.cos(this._maxSlopeAngle);let i=256;if(r.filter)this._filter=r.filter;else {let p=t.shapes;for(let s=0;s<p.length;s++){let c=p.at(s).filter;c.collisionGroup=c.collisionGroup|i;}this._filter=new chunkKHH45HMB_cjs.ja(1,~i);}r.oneWayPlatformTag&&r.characterTag&&this._setupOneWayPlatforms(r.oneWayPlatformTag,r.characterTag);}get grounded(){return this._grounded}get groundNormal(){return this._groundNormal}get groundBody(){return this._groundBody}get timeSinceGrounded(){return this._timeSinceGrounded}get maxSlopeAngle(){return this._maxSlopeAngle}set maxSlopeAngle(e){this._maxSlopeAngle=e,this._maxSlopeCos=Math.cos(e);}setVelocity(e,t){this.body.velocity=new chunkKHH45HMB_cjs.H(e,t);}update(){this._wallLeft=false,this._wallRight=false;let e=this.body.position.x,t=this.body.position.y;return this._detectGround(e,t),this._detectWalls(e,t),this._grounded&&this._groundBody?this._onMovingPlatform=this._groundBody.type===chunkKHH45HMB_cjs.$.KINEMATIC:this._onMovingPlatform=false,this._grounded?this._timeSinceGrounded=0:this._timeSinceGrounded+=1/60,{grounded:this._grounded,groundNormal:this._groundNormal,groundBody:this._groundBody,onMovingPlatform:this._onMovingPlatform,slopeAngle:this._slopeAngle,wallLeft:this._wallLeft,wallRight:this._wallRight,timeSinceGrounded:this._timeSinceGrounded}}destroy(){this._oneWayListener&&(this._oneWayListener.space=null,this._oneWayListener=null);}_detectGround(e,t){let i=this._getCharacterRadius(0,1)+4,p=new q(new chunkKHH45HMB_cjs.H(e,t),new chunkKHH45HMB_cjs.H(0,1));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);if(s&&s.distance<=i){let a=s.normal.y;if(a<0){let c=-a;if(c>=this._maxSlopeCos){this._grounded=true,this._groundNormal=new chunkKHH45HMB_cjs.H(s.normal.x,s.normal.y),this._groundBody=s.shape?.body??null,this._slopeAngle=Math.acos(Math.min(1,c));return}}}this._grounded=false,this._groundNormal=null,this._groundBody=null,this._slopeAngle=0;}_detectWalls(e,t){let i=this._getCharacterRadius(1,0)+2,p=new q(new chunkKHH45HMB_cjs.H(e,t),new chunkKHH45HMB_cjs.H(-1,0));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);s&&s.distance<=i&&Math.abs(s.normal.x)>.7&&(this._wallLeft=true);let a=new q(new chunkKHH45HMB_cjs.H(e,t),new chunkKHH45HMB_cjs.H(1,0));a.maxDistance=i;let c=this.space.rayCast(a,false,this._filter);c&&c.distance<=i&&Math.abs(c.normal.x)>.7&&(this._wallRight=true);}_setupOneWayPlatforms(e,t){let r=new ae(Z.COLLISION,e,t,i=>{try{let p=i.arbiter.collisionArbiter;if(!p)return W.ACCEPT;let s=p.normal.y,a=i.swapped;return s>0!==a?W.IGNORE:W.ACCEPT}catch{return W.ACCEPT}},0,true);r.space=this.space,this._oneWayListener=r;}_getCharacterRadius(e,t){let r=this.body.shapes.at(0);if(!r)return 0;if(r.isCircle())return r.castCircle?.radius??0;if(r.isCapsule()){let a=r.castCapsule;if(a){let c=a.radius,f=a.halfLength,u=this.body.rotation,m=Math.cos(u),y=Math.sin(u);return Math.abs(e*m+t*y)*f+c}}let i=r.bounds,p=i.width/2,s=i.height/2;return Math.abs(e)*p+Math.abs(t)*s}};var Xp="3.19.0";Object.defineProperty(exports,"AABB",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.K}});Object.defineProperty(exports,"AngleJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.la}});Object.defineProperty(exports,"Body",{enumerable:true,get:function(){return chunkKHH45HMB_cjs._}});Object.defineProperty(exports,"BodyType",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.$}});Object.defineProperty(exports,"Broadphase",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ia}});Object.defineProperty(exports,"Capsule",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ha}});Object.defineProperty(exports,"Circle",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.fa}});Object.defineProperty(exports,"Compound",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.aa}});Object.defineProperty(exports,"Constraint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ka}});Object.defineProperty(exports,"DebugDrawFlags",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.W}});Object.defineProperty(exports,"DistanceJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ma}});Object.defineProperty(exports,"FluidProperties",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.T}});Object.defineProperty(exports,"GeomPoly",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.N}});Object.defineProperty(exports,"GravMassMode",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ca}});Object.defineProperty(exports,"InertiaMode",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.da}});Object.defineProperty(exports,"InteractionFilter",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ja}});Object.defineProperty(exports,"Interactor",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.R}});Object.defineProperty(exports,"LineJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.na}});Object.defineProperty(exports,"MassMode",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ea}});Object.defineProperty(exports,"MatMN",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.J}});Object.defineProperty(exports,"Material",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ba}});Object.defineProperty(exports,"MotorJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.oa}});Object.defineProperty(exports,"NapeList",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.S}});Object.defineProperty(exports,"PivotJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.pa}});Object.defineProperty(exports,"Polygon",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ga}});Object.defineProperty(exports,"PulleyJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.qa}});Object.defineProperty(exports,"Shape",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.V}});Object.defineProperty(exports,"ShapeType",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.U}});Object.defineProperty(exports,"Space",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.X}});Object.defineProperty(exports,"Vec2",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.H}});Object.defineProperty(exports,"Vec3",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.I}});Object.defineProperty(exports,"WeldJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ra}});Object.defineProperty(exports,"Winding",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.L}});exports.Arbiter=j;exports.ArbiterType=Ee;exports.BodyCallback=Re;exports.BodyListener=Ge;exports.Callback=F;exports.CbEvent=C;exports.CbType=Ce;exports.CharacterController=xt;exports.CollisionArbiter=Ve;exports.ConstraintCallback=ke;exports.ConstraintListener=De;exports.Contact=Pe;exports.ConvexResult=ze;exports.DebugDraw=Ct;exports.Edge=be;exports.FluidArbiter=Oe;exports.Geom=Se;exports.InteractionCallback=Be;exports.InteractionGroup=we;exports.InteractionListener=Ue;exports.InteractionType=Z;exports.Listener=B;exports.ListenerType=ve;exports.MarchingSquares=Ze;exports.Mat23=fe;exports.OptionType=xe;exports.PreCallback=Fe;exports.PreFlag=W;exports.PreListener=ae;exports.Ray=q;exports.RayResult=de;exports.UserConstraint=We;exports.VERSION=Xp;exports.ValidationResult=ge;exports.createConcaveBody=hn;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var chunkKHH45HMB_cjs=require('./chunk-KHH45HMB.cjs');var Pt={epsilon:1e-8,fluidAngularDragFriction:2.5,fluidAngularDrag:100,fluidVacuumDrag:.5,fluidLinearDrag:.5,collisionSlop:.2,collisionSlopCCD:.5,distanceThresholdCCD:.05,staticCCDLinearThreshold:.05,staticCCDAngularThreshold:.005,bulletCCDLinearThreshold:.125,bulletCCDAngularThreshold:.0125,dynamicSweepLinearThreshold:17,dynamicSweepAngularThreshold:.6,angularCCDSlipScale:.75,arbiterExpirationDelay:6,staticFrictionThreshold:2,elasticThreshold:20,sleepDelay:60,linearSleepThreshold:.2,angularSleepThreshold:.4,contactBiasCoef:.3,contactStaticBiasCoef:.6,contactContinuousBiasCoef:.4,contactContinuousStaticBiasCoef:.5,constraintLinearSlop:.1,constraintAngularSlop:.001,illConditionedThreshold:2e8},jt=chunkKHH45HMB_cjs.E();jt.Config=Object.assign(jt.Config||{},Pt);function l(n,e,t){for(;n[e]!=null;){let r=n[e][t];n[e][t]=null,n[e]=r;}}var Xe=class{static version(){return "Nape 2.0.19"}static clearObjectPools(){let e=chunkKHH45HMB_cjs.E(),t=e.__zpp;l(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),l(e.phys.InteractorIterator,"zpp_pool","zpp_next"),l(e.phys.BodyIterator,"zpp_pool","zpp_next"),l(e.phys.CompoundIterator,"zpp_pool","zpp_next"),l(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),l(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),l(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),l(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),l(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),l(e.geom.RayResultIterator,"zpp_pool","zpp_next"),l(e.shape.ShapeIterator,"zpp_pool","zpp_next"),l(e.shape.EdgeIterator,"zpp_pool","zpp_next"),l(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),l(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),l(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),l(t.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Body,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Component,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),l(t.util.ZNPNode_ConvexResult,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),l(t.util.ZNPNode_RayResult,"zpp_pool","next"),l(t.phys.ZPP_Material,"zpp_pool","next"),l(t.phys.ZPP_FluidProperties,"zpp_pool","next"),l(t.callbacks.ZPP_CbSetPair,"zpp_pool","next"),l(t.callbacks.ZPP_Callback,"zpp_pool","next"),l(t.callbacks.ZPP_CbSet,"zpp_pool","next"),l(t.geom.ZPP_GeomVert,"zpp_pool","next"),l(t.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),l(t.geom.ZPP_Mat23,"zpp_pool","next"),l(t.geom.ZPP_CutVert,"zpp_pool","next"),l(t.geom.ZPP_CutInt,"zpp_pool","next"),l(t.geom.ZPP_Vec2,"zpp_pool","next"),l(t.geom.ZPP_PartitionVertex,"zpp_pool","next"),l(t.geom.ZPP_SimplifyV,"zpp_pool","next"),l(t.geom.ZPP_SimplifyP,"zpp_pool","next"),l(t.geom.ZPP_PartitionedPoly,"zpp_pool","next"),l(t.geom.ZPP_PartitionPair,"zpp_pool","next"),l(t.geom.ZPP_AABB,"zpp_pool","next"),l(t.geom.ZPP_SimpleVert,"zpp_pool","next"),l(t.geom.ZPP_SimpleSeg,"zpp_pool","next"),l(t.geom.ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.Hashable2_Boolfalse,"zpp_pool","next"),l(t.geom.ZPP_ToiEvent,"zpp_pool","next"),l(t.geom.ZPP_MarchSpan,"zpp_pool","next"),l(t.geom.ZPP_MarchPair,"zpp_pool","next"),l(t.shape.ZPP_Edge,"zpp_pool","next"),l(t.space.ZPP_SweepData,"zpp_pool","next"),l(t.space.ZPP_AABBNode,"zpp_pool","next"),l(t.space.ZPP_AABBPair,"zpp_pool","next"),l(t.dynamics.ZPP_Contact,"zpp_pool","next"),l(t.space.ZPP_Island,"zpp_pool","next"),l(t.space.ZPP_Component,"zpp_pool","next"),l(t.space.ZPP_CallbackSet,"zpp_pool","next"),l(t.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_ColArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec2","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec3","zpp_pool");}};var fe=class n{get _inner(){return this}constructor(e=1,t=0,r=0,i=1,p=0,s=0){let a=chunkKHH45HMB_cjs.A.get();this.zpp_inner=a,a.outer=this;let c=["a","b","tx","c","d","ty"],f=[e,t,p,r,i,s];for(let u=0;u<f.length;u++)if(f[u]!==f[u])throw new Error("Error: Mat23::"+c[u]+" cannot be NaN");a.setas(e,t,r,i,p,s);}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let t=Math.cos(e),r=Math.sin(e);return new n(t,-r,r,t,0,0)}static translation(e,t){return new n(1,0,0,1,e,t)}static scale(e,t){return new n(e,0,0,t,0,0)}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.A?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}_setProp(e,t){if(t!==t)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=t,this.zpp_inner.invalidate();}get a(){return this.zpp_inner.a}set a(e){this._setProp("a",e);}get b(){return this.zpp_inner.b}set b(e){this._setProp("b",e);}get c(){return this.zpp_inner.c}set c(e){this._setProp("c",e);}get d(){return this.zpp_inner.d}set d(e){this._setProp("d",e);}get tx(){return this.zpp_inner.tx}set tx(e){this._setProp("tx",e);}get ty(){return this.zpp_inner.ty}set ty(e){this._setProp("ty",e);}get determinant(){return this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c}clone(){return this.copy()}equals(e,t=0){if(e==null)return false;let r=this.zpp_inner,i=e.zpp_inner,p=r.a-i.a,s=r.b-i.b,a=r.c-i.c,c=r.d-i.d,f=r.tx-i.tx,u=r.ty-i.ty;return (p<0?-p:p)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(c<0?-c:c)<=t&&(f<0?-f:f)<=t&&(u<0?-u:u)<=t}copy(){return new n(this.zpp_inner.a,this.zpp_inner.b,this.zpp_inner.c,this.zpp_inner.d,this.zpp_inner.tx,this.zpp_inner.ty)}set(e){if(e==null)throw new Error("Error: Cannot set form null matrix");let t=e.zpp_inner;return this.zpp_inner.setas(t.a,t.b,t.c,t.d,t.tx,t.ty),this.zpp_inner.invalidate(),this}setAs(e=1,t=0,r=0,i=1,p=0,s=0){return this.zpp_inner.setas(e,t,r,i,p,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=e*e+t*t+r*r+i*i,s=e*i-t*r;s<0&&(s=-s);let a=chunkKHH45HMB_cjs.E();return p>a.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner,a=1/(e*i-t*r);return new n(i*a,-t*a,-r*a,e*a,(t*s-i*p)*a,(r*p-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return new n(e,r,t,i,-e*p-r*s,-t*p-i*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let t=e.zpp_inner,r=this.zpp_inner;return new n(t.a*r.a+t.b*r.c,t.a*r.b+t.b*r.d,t.c*r.a+t.d*r.c,t.c*r.b+t.d*r.d,t.a*r.tx+t.b*r.ty+t.tx,t.c*r.tx+t.d*r.ty+t.ty)}transform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");e.zpp_inner.validate();let i=e.zpp_inner.x,p=e.zpp_inner.y,{a:s,b:a,c,d:f,tx:u,ty:m}=this.zpp_inner,y,g;t?(y=i*s+p*a,g=i*c+p*f):(y=i*s+p*a+u,g=i*c+p*f+m);let R=chunkKHH45HMB_cjs.H.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");if(this.singular())throw new Error("Error: Matrix is singular and inverse transformation cannot be performed");let{a:i,b:p,c:s,d:a,tx:c,ty:f}=this.zpp_inner,u=1/(i*a-p*s);e.zpp_inner.validate();let m=e.zpp_inner.x,y=e.zpp_inner.y,g,R;if(t)g=(m*a-y*p)*u,R=(y*i-m*s)*u;else {let _=m-c,h=y-f;g=(_*a-h*p)*u,R=(h*i-_*s)*u;}let J=chunkKHH45HMB_cjs.H.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),J}equiorthogonal(){if(this.singular())return false;let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=chunkKHH45HMB_cjs.E(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-r*r-i*i;return a*a<p.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=chunkKHH45HMB_cjs.E(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-1,c=r*r+i*i-1;return a*a<p.Config.epsilon&&c*c<p.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:i,d:p}=this.zpp_inner,s=chunkKHH45HMB_cjs.E(),a=Math.sqrt(t*t+i*i),c=Math.sqrt(r*r+p*p);if(a*a<s.Config.epsilon||c*c<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let f=e?(a+c)/2:1;a=f/a,c=f/c,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*c,this.d=this.zpp_inner.d*c;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(u/(f*f));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let y=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*y,J=this.zpp_inner.b*g+this.zpp_inner.d*y,_=this.zpp_inner.c*g+this.zpp_inner.a*y,h=this.zpp_inner.d*g-this.zpp_inner.b*y;return this.c=_,this.a=R,this.d=h,this.b=J,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(true)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(false)}toString(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return "{ a: "+e+" b: "+t+" c: "+r+" d: "+i+" tx: "+p+" ty: "+s+" }"}};chunkKHH45HMB_cjs.A._wrapFn=n=>chunkKHH45HMB_cjs.G(n,e=>{let t=Object.create(fe.prototype);return t.zpp_inner=e,e.outer=t,t});function et(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.x}function tt(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.y}function me(n){n.zpp_inner.weak&&n.dispose();}var q=class n{get _inner(){return this}constructor(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::direction cannot be null");let r=new chunkKHH45HMB_cjs.B;this.zpp_inner=r;let i=et(e),p=tt(e);r.origin.zpp_inner.x=i,r.origin.zpp_inner.y=p,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),me(e);let s=et(t),a=tt(t);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=a,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),me(t),r.zip_dir=true,r.maxdist=1/0;}static _wrap(e){return e==null?null:e instanceof n?e:chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r})}static fromSegment(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::fromSegment::start is null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::fromSegment::end is null");let r=t.sub(e,true),i=new n(e,r),p=et(e),s=tt(e),a=et(t),c=tt(t),f=a-p,u=c-s,m=Math.sqrt(f*f+u*u);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return i.zpp_inner.maxdist=m,me(e),me(t),i}get origin(){return this.zpp_inner.origin}set origin(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");this.zpp_inner.origin.set(e),me(e);}get direction(){return this.zpp_inner.direction}set direction(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::direction cannot be null");this.zpp_inner.direction.set(e),this.zpp_inner.zip_dir=true,me(e);}get maxDistance(){return this.zpp_inner.maxdist}set maxDistance(e){if(e!==e)throw new Error("Error: maxDistance cannot be NaN");this.zpp_inner.maxdist=e;}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}aabb(){return chunkKHH45HMB_cjs.K._wrap(this.zpp_inner.rayAABB())}at(e,t=false){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let i=r.x,p=r.y,s=i+e*this.zpp_inner.dirx,a=p+e*this.zpp_inner.diry;return chunkKHH45HMB_cjs.H.get(s,a,t)}clone(){return this.copy()}copy(){let e=new n(this.zpp_inner.origin,this.zpp_inner.direction),t=this.zpp_inner.maxdist;if(t!==t)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=t,e}};var ze=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.x.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return chunkKHH45HMB_cjs.G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.position)}get toi(){return this._disposed(),this.zpp_inner.toiDistance}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" toi: "+this.zpp_inner.toiDistance+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};chunkKHH45HMB_cjs.x._createConvexResult=()=>new ze;var de=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.x.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return chunkKHH45HMB_cjs.G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.normal)}get distance(){return this._disposed(),this.zpp_inner.toiDistance}get inner(){return this._disposed(),this.zpp_inner.inner}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" distance: "+this.zpp_inner.toiDistance+" ?inner: "+String(this.zpp_inner.inner)+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};chunkKHH45HMB_cjs.x._createRayResult=()=>new de;function ie(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function rt(n,e){if(n!=null&&n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let t=n.zpp_inner;if(t._immutable)throw new Error("Error: Vec2 is immutable");t._isimmutable!=null&&t._isimmutable();}function ye(n,e){if(ie(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Se=class{static distanceBody(e,t,r,i){rt(r),rt(i);let p=nt(e),s=nt(t);if(p.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=p.shapes.head;for(;a!=null;)chunkKHH45HMB_cjs.y.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)chunkKHH45HMB_cjs.y.validateShape(a.elt),a=a.next;return chunkKHH45HMB_cjs.C.distanceBody(p,s,r.zpp_inner,i.zpp_inner)}static distance(e,t,r,i){rt(r),rt(i),ye(e,"distances"),ye(t,"distances");let p=ie(e),s=ie(t);chunkKHH45HMB_cjs.y.validateShape(p),chunkKHH45HMB_cjs.y.validateShape(s);let a;chunkKHH45HMB_cjs.l.zpp_pool==null?a=new chunkKHH45HMB_cjs.l:(a=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=a.next,a.next=null),a.weak=false;let c=chunkKHH45HMB_cjs.C.distance(p,s,r.zpp_inner,i.zpp_inner,a,1e100);return a.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=a,c}static intersectsBody(e,t){let r=nt(e),i=nt(t);if(r.shapes.head==null||i.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let p=r.shapes.head;for(;p!=null;)chunkKHH45HMB_cjs.y.validateShape(p.elt),p=p.next;for(p=i.shapes.head;p!=null;)chunkKHH45HMB_cjs.y.validateShape(p.elt),p=p.next;let s=r.aabb,a=i.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return false;let c=r.shapes.head;for(;c!=null;){let f=i.shapes.head;for(;f!=null;){if(chunkKHH45HMB_cjs.w.testCollide_safe(c.elt,f.elt))return true;f=f.next;}c=c.next;}return false}static intersects(e,t){ye(e,"intersection"),ye(t,"intersection");let r=ie(e),i=ie(t);chunkKHH45HMB_cjs.y.validateShape(r),chunkKHH45HMB_cjs.y.validateShape(i);let p=r.aabb,s=i.aabb;return p.minx>s.maxx||p.maxx<s.minx||p.miny>s.maxy||p.maxy<s.miny?false:chunkKHH45HMB_cjs.w.testCollide_safe(r,i)}static contains(e,t){ye(e,"containment"),ye(t,"containment");let r=ie(e),i=ie(t);return chunkKHH45HMB_cjs.y.validateShape(r),chunkKHH45HMB_cjs.y.validateShape(i),chunkKHH45HMB_cjs.w.containTest(r,i)}};var Ze=class{static run(e,t,r,i=2,p=null,s=true,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: MarchingSquares requires an iso function to operate");if(t==null)throw new Error("Error: MarchingSquares requires an AABB to define bounds of surface extraction");if(r==null)throw new Error("Error: MarchingSquares requires a Vec2 to define cell size for surface extraction");let c=r.zpp_inner;if(c._validate!=null&&c._validate(),c.x<=0||c.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(i<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(p!=null){let g=p.zpp_inner;if(g._validate!=null&&g._validate(),g.x<=0||g.y<=0)throw new Error("Error: MarchingSquares cannot with non-positive sub-grid dimensions")}let f=chunkKHH45HMB_cjs.E(),u=a??new f.geom.GeomPolyList,m=chunkKHH45HMB_cjs.z,y=t.zpp_inner;if(y._validate!=null&&y._validate(),p==null){let g=y.minx,R=y.miny,J=y.maxx,_=y.maxy;m.run(e,g,R,J,_,r,i,s,u);}else {let g=p.zpp_inner;g._validate!=null&&g._validate();let R=y.maxx-y.minx,J=y.maxy-y.miny,_=R/g.x,h=J/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let vt=y.minx+g.x*Ye,Kt=Ye===b-1?y.maxx:vt+g.x;for(let je=0;je<G;je++){let Nt=y.miny+g.y*je,Jt=je===G-1?y.maxy:Nt+g.y;m.run(e,vt,Nt,Kt,Jt,r,i,s,u);}}}return c.weak&&r.dispose(),p!=null&&p.zpp_inner.weak&&p.dispose(),u}};var Q=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new chunkKHH45HMB_cjs.c,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=chunkKHH45HMB_cjs.E(),i=new r.geom.Vec2List;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Q.internal=false;function oe(n){if(n.outer==null){let e=chunkKHH45HMB_cjs.E();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function I(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Q.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}I.zpp_pool=null;I.get=function(n){let e;return I.zpp_pool==null?(Q.internal=true,e=new I,Q.internal=false):(e=I.zpp_pool,I.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};I.prototype.zpp_inner=null;I.prototype.zpp_i=null;I.prototype.zpp_critical=null;I.prototype.zpp_next=null;I.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=I.zpp_pool,I.zpp_pool=this,this.zpp_inner=null,false)};I.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function E(){this.zpp_inner=null,this.zpp_inner=new Q,this.zpp_inner.outer=this;}E.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=chunkKHH45HMB_cjs.E(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};E.prototype.zpp_inner=null;Object.defineProperty(E.prototype,"length",{get:function(){return this.zpp_gl()}});E.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};E.prototype.zpp_vm=function(){this.zpp_inner.valmod();};E.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};E.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=n,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(n);else for(;this.zpp_inner.at_index!=n;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return oe(this.zpp_inner.at_ite.elt)};E.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(n.zpp_inner):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)):this.zpp_inner.inner.add(n.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}return this.zpp_inner.invalidate(),oe(n)};E.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}else {n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),oe(n)};E.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};E.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};E.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};E.prototype.empty=function(){return this.zpp_gl()==0};E.prototype.iterator=function(){return this.zpp_vm(),I.get(this)};E.prototype.copy=function(n){n==null&&(n=false);let e=chunkKHH45HMB_cjs.E(),t=new e.geom.Vec2List,r=I.get(this);for(;r.hasNext();){let i=r.next(),p;if(n){if(i!=null&&i.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=i.zpp_inner;s._validate!=null&&s._validate();let a=i.zpp_inner.x,c=i.zpp_inner;c._validate!=null&&c._validate();let f=i.zpp_inner.y,u;if(chunkKHH45HMB_cjs.b.poolVec2==null?u=new e.geom.Vec2:(u=chunkKHH45HMB_cjs.b.poolVec2,chunkKHH45HMB_cjs.b.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=false,u==chunkKHH45HMB_cjs.b.nextVec2&&(chunkKHH45HMB_cjs.b.nextVec2=null)),u.zpp_inner==null){let m;chunkKHH45HMB_cjs.l.zpp_pool==null?m=new chunkKHH45HMB_cjs.l:(m=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=m.next,m.next=null),m.weak=false,m._immutable=false,m.x=a,m.y=f,u.zpp_inner=m,u.zpp_inner.outer=u;}else u.zpp_inner.x=a,u.zpp_inner.y=f,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=false,p=u;}else p=i;t.push(p);}return t};E.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");let e=n.iterator();for(;e.hasNext();){let t=e.next();this.has(t)||this.add(t);}};E.prototype.toString=function(){let n="[",e=true,t=I.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};E.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=I.zpp_pool,I.zpp_pool=e,e.zpp_inner=null;break}return this};E.prototype[Symbol.iterator]=function(){let n=I.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};E.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let t=this.at(e);try{n(t)?++e:this.remove(t);}catch{break}}return this};function pe(){if(!chunkKHH45HMB_cjs.M.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}pe.prototype.zpp_inner=null;pe.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=false,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=chunkKHH45HMB_cjs.M.zpp_pool,chunkKHH45HMB_cjs.M.zpp_pool=e;}return n};pe.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr;if(n.wrap==null){let t=n.x,r=n.y;if(t!==t||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let i=chunkKHH45HMB_cjs.E(),p;if(chunkKHH45HMB_cjs.b.poolVec2==null?p=new i.geom.Vec2:(p=chunkKHH45HMB_cjs.b.poolVec2,chunkKHH45HMB_cjs.b.poolVec2=p.zpp_pool,p.zpp_pool=null,p.zpp_disp=false,p==chunkKHH45HMB_cjs.b.nextVec2&&(chunkKHH45HMB_cjs.b.nextVec2=null)),p.zpp_inner==null){let s;chunkKHH45HMB_cjs.l.zpp_pool==null?s=new chunkKHH45HMB_cjs.l:(s=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=s.next,s.next=null),s.weak=false,s._immutable=false,s.x=t,s.y=r,p.zpp_inner=s,p.zpp_inner.outer=p;}else {if(p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;if(s._immutable)throw new Error("Error: Vec2 is immutable");s._isimmutable!=null&&s._isimmutable(),s.x==t&&s.y==r||(s.x=t,s.y=r,s._invalidate!=null&&s._invalidate(s));}p.zpp_inner.weak=false,n.wrap=p,n.wrap.zpp_inner._inuse=true,n.wrap.zpp_inner._invalidate=s=>n.modwrap(s),n.wrap.zpp_inner._validate=()=>n.getwrap();}let e=n.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};pe.prototype[Symbol.iterator]=function(){return {_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};var $t=chunkKHH45HMB_cjs.E();$t.geom.GeomVertexIterator=pe;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new chunkKHH45HMB_cjs.u,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=chunkKHH45HMB_cjs.E(),i=new r.dynamics.ContactList;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Y.internal=false;var be=class n{constructor(){if(!chunkKHH45HMB_cjs.D.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof chunkKHH45HMB_cjs.D?chunkKHH45HMB_cjs.G(e,t=>{chunkKHH45HMB_cjs.D.internal=true;let r=new n;return chunkKHH45HMB_cjs.D.internal=false,r.zpp_inner=t,t.outer=r,r}):null:null}get polygon(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.outer_zn}get localNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_lnorm==null&&e.getlnorm(),e.wrap_lnorm}get worldNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_gnorm==null&&e.getgnorm(),e.wrap_gnorm}get length(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.length}get localProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.lprojection}get worldProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");if(e.polygon.body==null)throw new Error("Error: Edge world projection only makes sense for Polygons contained within a rigid body");return e.polygon.validate_gaxi(),e.gprojection}get localVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp0)}get localVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp1)}get worldVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp0)}get worldVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp1)}toString(){let e=this.zpp_inner;return e.polygon==null?"Edge(object-pooled)":e.polygon.body==null?(e.polygon.validate_laxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } }"):(e.polygon.validate_gaxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } worldNormal : { x: "+e.gnormx+" y: "+e.gnormy+" } }")}_wrapVert(e){let t=chunkKHH45HMB_cjs.E();if(e.outer==null){e.outer=new t.geom.Vec2;let r=e.outer.zpp_inner;r.outer!=null&&(r.outer.zpp_inner=null,r.outer=null),r._isimmutable=null,r._validate=null,r._invalidate=null,r.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=r,e.outer.zpp_inner=e;}return e.outer}};chunkKHH45HMB_cjs.D._wrapFn=n=>chunkKHH45HMB_cjs.G(n,e=>{chunkKHH45HMB_cjs.D.internal=true;let t=new be;return chunkKHH45HMB_cjs.D.internal=false,t.zpp_inner=e,e.outer=t,t});var ge=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return chunkKHH45HMB_cjs.a.ValidationResult_VALID==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_VALID=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_VALID}static get DEGENERATE(){return chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE}static get CONCAVE(){return chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING}toString(){return this===chunkKHH45HMB_cjs.a.ValidationResult_VALID?"VALID":this===chunkKHH45HMB_cjs.a.ValidationResult_DEGENERATE?"DEGENERATE":this===chunkKHH45HMB_cjs.a.ValidationResult_CONCAVE?"CONCAVE":this===chunkKHH45HMB_cjs.a.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Qt=chunkKHH45HMB_cjs.E();Qt.shape.ValidationResult=ge;var we=class n{get _inner(){return this}constructor(e=false){let t=new chunkKHH45HMB_cjs.v;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(true),t.ignore=e);}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.v?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}get group(){return this.zpp_inner.group==null?null:this.zpp_inner.group.outer}set group(e){if(e===this)throw new Error("Error: Cannot assign InteractionGroup to itself");this.zpp_inner.setGroup(e==null?null:e.zpp_inner);}get ignore(){return this.zpp_inner.ignore}set ignore(e){this.zpp_inner.ignore!=e&&(this.zpp_inner.invalidate(true),this.zpp_inner.ignore=e);}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=chunkKHH45HMB_cjs.E();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,true);}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=chunkKHH45HMB_cjs.E();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,true);}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};chunkKHH45HMB_cjs.v._wrapFn=n=>chunkKHH45HMB_cjs.G(n,e=>{let t=Object.create(we.prototype);return t.zpp_inner=e,e.outer=t,t});var Ee=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return chunkKHH45HMB_cjs.a.ArbiterType_COLLISION==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ArbiterType_COLLISION=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ArbiterType_COLLISION}static get SENSOR(){return chunkKHH45HMB_cjs.a.ArbiterType_SENSOR==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ArbiterType_SENSOR=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ArbiterType_SENSOR}static get FLUID(){return chunkKHH45HMB_cjs.a.ArbiterType_FLUID==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ArbiterType_FLUID=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ArbiterType_FLUID}toString(){return this===chunkKHH45HMB_cjs.a.ArbiterType_COLLISION?"COLLISION":this===chunkKHH45HMB_cjs.a.ArbiterType_SENSOR?"SENSOR":this===chunkKHH45HMB_cjs.a.ArbiterType_FLUID?"FLUID":""}},Xt=chunkKHH45HMB_cjs.E();Xt.dynamics.ArbiterType=Ee;chunkKHH45HMB_cjs.F();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.t.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return chunkKHH45HMB_cjs.t.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.FLUID?this.zpp_inner.fluidarb.outer_zn:null}get shape1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer}get shape2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer}get body1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b2.outer:this.zpp_inner.b1.outer}get body2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b1.outer:this.zpp_inner.b2.outer}get state(){this._activeCheck();let e=chunkKHH45HMB_cjs.E(),t=this.zpp_inner.immState;return t==5?(chunkKHH45HMB_cjs.a.PreFlag_ACCEPT==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT):t==1?(chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE):t==6?(chunkKHH45HMB_cjs.a.PreFlag_IGNORE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE):(chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL}isFluidArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.FLUID}isSensorArbiter(){return this.zpp_inner.type==chunkKHH45HMB_cjs.t.SENSOR}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),chunkKHH45HMB_cjs.I.get(0,0,0)}toString(){let e=this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL?"CollisionArbiter":this.zpp_inner.type==chunkKHH45HMB_cjs.t.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer,r=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer,i=e+"("+t.toString()+"|"+r.toString()+")";return this.zpp_inner.type==chunkKHH45HMB_cjs.t.COL&&(i+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),i+="<-"+this.state.toString(),i}_activeCheck(){if(!this.zpp_inner.active)throw new Error("Error: Arbiter not currently in use")}_checkBody(e){let t=this.zpp_inner,r=t.ws1.id>t.ws2.id?t.b2.outer:t.b1.outer,i=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=i)throw new Error("Error: Arbiter does not relate to body")}},en=chunkKHH45HMB_cjs.E();en.dynamics.Arbiter=j;var Ve=class extends j{constructor(){super();}get contacts(){return this._activeCheck(),this.zpp_inner.colarb.wrap_contacts==null&&this.zpp_inner.colarb.setupcontacts(),this.zpp_inner.colarb.wrap_contacts}get normal(){return this._activeCheck(),this.zpp_inner.colarb.wrap_normal==null&&this.zpp_inner.colarb.getnormal(),this.zpp_inner.colarb.wrap_normal}get radius(){return this._activeCheck(),this.zpp_inner.colarb.radius}get referenceEdge1(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get referenceEdge2(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get elasticity(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.restitution}set elasticity(e){if(this._mutableCheck("elasticity"),e!==e)throw new Error("Error: CollisionArbiter::elasticity cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::elasticity cannot be negative");this.zpp_inner.colarb.restitution=e,this.zpp_inner.colarb.userdef_restitution=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get dynamicFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.dyn_fric}set dynamicFriction(e){if(this._mutableCheck("dynamicFriction"),e!==e)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be negative");this.zpp_inner.colarb.dyn_fric=e,this.zpp_inner.colarb.userdef_dyn_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get staticFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.stat_fric}set staticFriction(e){if(this._mutableCheck("staticFriction"),e!==e)throw new Error("Error: CollisionArbiter::staticFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::staticFriction cannot be negative");this.zpp_inner.colarb.stat_fric=e,this.zpp_inner.colarb.userdef_stat_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get rollingFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.rfric}set rollingFriction(e){if(this._mutableCheck("rollingFriction"),e!==e)throw new Error("Error: CollisionArbiter::rollingFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::rollingFriction cannot be negative");this.zpp_inner.colarb.rfric=e,this.zpp_inner.colarb.userdef_rfric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}firstVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==-1:false}secondVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==1:false}normalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return !t||r.oc1.fresh?r.oc1.wrapper().rollingImpulse(e):0}_mutableCheck(e){if(!this.zpp_inner.colarb.mutable)throw new Error("Error: CollisionArbiter::"+e+" is only mutable during a pre-handler")}_accumulateImpulse(e,t,r){let i=0,p=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let c=a.oc1.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}if(a.hc2&&(!r||a.oc2.fresh)){let c=a.oc2.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}return chunkKHH45HMB_cjs.I.get(i,p,s)}};var Oe=class extends j{constructor(){super();}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.fluidarb.wrap_position)}set position(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e==null)throw new Error("Error: FluidArbiter::position cannot be null");this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),this.zpp_inner.fluidarb.wrap_position.set(e);}get overlap(){return this._activeCheck(),this.zpp_inner.fluidarb.overlap}set overlap(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e!==e)throw new Error("Error: FluidArbiter::overlap cannot be NaN");if(e<=0||e==1/0)throw new Error("Error: FluidArbiter::overlap must be strictly positive and non infinite");this.zpp_inner.fluidarb.overlap=e;}buoyancyImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb;return e==null?chunkKHH45HMB_cjs.I.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?chunkKHH45HMB_cjs.I.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):chunkKHH45HMB_cjs.I.get(-t.buoyx,-t.buoyy,-(t.buoyy*t.r1x-t.buoyx*t.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return chunkKHH45HMB_cjs.I.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),i=this.dragImpulse(e),p=r.zpp_inner,s=i.zpp_inner;return p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.x=s.x+p.x,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.y=s.y+p.y,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.z=s.z+p.z,r.dispose(),i}};var Pe=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!chunkKHH45HMB_cjs.u.internal)throw new Error("Error: Cannot instantiate Contact derp!")}get arbiter(){if(this.zpp_inner.arbiter==null)return null;let e=this.zpp_inner.arbiter.outer;return e.zpp_inner.type==chunkKHH45HMB_cjs.t.COL?e.zpp_inner.colarb.outer_zn:null}get penetration(){return this._inactiveCheck(),-this.zpp_inner.dist}get position(){return this._inactiveCheck(),this.zpp_inner.wrap_position==null&&this.zpp_inner.getposition(),chunkKHH45HMB_cjs.H._wrap(this.zpp_inner.wrap_position)}get fresh(){return this._inactiveCheck(),this.zpp_inner.fresh}get friction(){return this._inactiveCheck(),this.zpp_inner.inner.friction}normalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc;return e==null?chunkKHH45HMB_cjs.I.get(t.nx*i,t.ny*i):(this._checkBody(e,t),e==t.b1.outer?chunkKHH45HMB_cjs.I.get(t.nx*-i,t.ny*-i,-(t.ny*r.r1x-t.nx*r.r1y)*i):chunkKHH45HMB_cjs.I.get(t.nx*i,t.ny*i,(t.ny*r.r2x-t.nx*r.r2y)*i))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jtAcc;return e==null?chunkKHH45HMB_cjs.I.get(-t.ny*i,t.nx*i):(this._checkBody(e,t),e==t.b1.outer?chunkKHH45HMB_cjs.I.get(t.ny*i,-t.nx*i,-(r.r1x*t.nx+r.r1y*t.ny)*i):chunkKHH45HMB_cjs.I.get(-t.ny*i,t.nx*i,(r.r2x*t.nx+r.r2y*t.ny)*i))}rollingImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=t.jrAcc;return e==null?r:(this._checkBody(e,t),e==t.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc,p=r.jtAcc,s=t.jrAcc;if(e==null)return chunkKHH45HMB_cjs.I.get(t.nx*i-t.ny*p,t.ny*i+t.nx*p,s);this._checkBody(e,t);let a=t.nx*i-t.ny*p,c=t.ny*i+t.nx*p;return e==t.b1.outer?chunkKHH45HMB_cjs.I.get(-a,-c,-(c*r.r1x-a*r.r1y)-s):chunkKHH45HMB_cjs.I.get(a,c,c*r.r2x-a*r.r2y+s)}toString(){return this.zpp_inner.arbiter==null||this.zpp_inner.arbiter.cleared?"{object-pooled}":"{Contact}"}_inactiveCheck(){if(this.zpp_inner.inactiveme())throw new Error("Error: Contact not currently in use")}_checkBody(e,t){if(e!=t.b1.outer&&e!=t.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};chunkKHH45HMB_cjs.u._wrapFn=n=>{chunkKHH45HMB_cjs.u.internal=true;let e=new Pe;return chunkKHH45HMB_cjs.u.internal=false,e.zpp_inner=n,n.outer=e,e};function tn(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function V(n){return n.valmod(),n.zip_length&&(n.zip_length=false,n.user_length=tn(n)),n.user_length}function v(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}v.zpp_pool=null;v.get=function(n){let e;return v.zpp_pool==null?(Y.internal=true,e=new v,Y.internal=false):(e=v.zpp_pool,v.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};v.prototype.zpp_inner=null;v.prototype.zpp_i=null;v.prototype.zpp_critical=null;v.prototype.zpp_next=null;v.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=V(this.zpp_inner.zpp_inner);return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=v.zpp_pool,v.zpp_pool=this,this.zpp_inner=null,false)};v.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function A(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this;}A.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=chunkKHH45HMB_cjs.E(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};A.prototype.zpp_inner=null;Object.defineProperty(A.prototype,"length",{get:function(){return V(this.zpp_inner)}});A.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};A.prototype.at=function(n){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=V(this.zpp_inner)-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)for(this.zpp_inner.at_index=0,this.zpp_inner.at_ite=this.zpp_inner.inner.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}for(;this.zpp_inner.at_index!=n;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}return this.zpp_inner.at_ite.wrapper()};A.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(n.zpp_inner);else {if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}else this.zpp_inner.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}else {e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};A.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=false,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};A.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift();};A.prototype.empty=function(){return V(this.zpp_inner)==0};A.prototype.iterator=function(){return this.zpp_inner.valmod(),v.get(this)};A.prototype.copy=function(n){n==null&&(n=false);let e=chunkKHH45HMB_cjs.E(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=v.get(this);for(;r.hasNext();){let i=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(i);}return t};A.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=v.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t));}};A.prototype.toString=function(){let n="[",e=true;this.zpp_inner.valmod();let t=v.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};A.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=v.get(this);for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=v.zpp_pool,v.zpp_pool=e,e.zpp_inner=null;break}return this};A.prototype[Symbol.iterator]=function(){let n=v.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};A.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=V(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r);}catch{break}}return this};var C=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return chunkKHH45HMB_cjs.a.CbEvent_BEGIN==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_BEGIN=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_BEGIN}static get ONGOING(){return chunkKHH45HMB_cjs.a.CbEvent_ONGOING==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_ONGOING=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_ONGOING}static get END(){return chunkKHH45HMB_cjs.a.CbEvent_END==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_END=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_END}static get WAKE(){return chunkKHH45HMB_cjs.a.CbEvent_WAKE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_WAKE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_WAKE}static get SLEEP(){return chunkKHH45HMB_cjs.a.CbEvent_SLEEP==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_SLEEP=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_SLEEP}static get BREAK(){return chunkKHH45HMB_cjs.a.CbEvent_BREAK==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_BREAK=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_BREAK}static get PRE(){return chunkKHH45HMB_cjs.a.CbEvent_PRE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.CbEvent_PRE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.CbEvent_PRE}toString(){return this===chunkKHH45HMB_cjs.a.CbEvent_BEGIN?"BEGIN":this===chunkKHH45HMB_cjs.a.CbEvent_ONGOING?"ONGOING":this===chunkKHH45HMB_cjs.a.CbEvent_END?"END":this===chunkKHH45HMB_cjs.a.CbEvent_WAKE?"WAKE":this===chunkKHH45HMB_cjs.a.CbEvent_SLEEP?"SLEEP":this===chunkKHH45HMB_cjs.a.CbEvent_BREAK?"BREAK":this===chunkKHH45HMB_cjs.a.CbEvent_PRE?"PRE":""}},nn=chunkKHH45HMB_cjs.E();nn.callbacks.CbEvent=C;chunkKHH45HMB_cjs.F();var Ce=class n{get _inner(){return this}constructor(){this.zpp_inner=new chunkKHH45HMB_cjs.e,this.zpp_inner.outer=this;}static get ANY_BODY(){return chunkKHH45HMB_cjs.e.ANY_BODY}static get ANY_CONSTRAINT(){return chunkKHH45HMB_cjs.e.ANY_CONSTRAINT}static get ANY_SHAPE(){return chunkKHH45HMB_cjs.e.ANY_SHAPE}static get ANY_COMPOUND(){return chunkKHH45HMB_cjs.e.ANY_COMPOUND}get id(){return this.zpp_inner.id}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}get interactors(){return this.zpp_inner.wrap_interactors==null&&(this.zpp_inner.wrap_interactors=chunkKHH45HMB_cjs.Z.get(this.zpp_inner.interactors,true)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=chunkKHH45HMB_cjs.Y.get(this.zpp_inner.constraints,true)),this.zpp_inner.wrap_constraints}including(e){return new(chunkKHH45HMB_cjs.E()).callbacks.OptionType(this).including(e)}excluding(e){return new(chunkKHH45HMB_cjs.E()).callbacks.OptionType(this).excluding(e)}toString(){return this===chunkKHH45HMB_cjs.e.ANY_BODY?"ANY_BODY":this===chunkKHH45HMB_cjs.e.ANY_SHAPE?"ANY_SHAPE":this===chunkKHH45HMB_cjs.e.ANY_COMPOUND?"ANY_COMPOUND":this===chunkKHH45HMB_cjs.e.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.e?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},rn=chunkKHH45HMB_cjs.E();rn.callbacks.CbType=Ce;chunkKHH45HMB_cjs.F();var Z=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return chunkKHH45HMB_cjs.a.InteractionType_COLLISION==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_COLLISION=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_COLLISION}static get SENSOR(){return chunkKHH45HMB_cjs.a.InteractionType_SENSOR==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_SENSOR=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_SENSOR}static get FLUID(){return chunkKHH45HMB_cjs.a.InteractionType_FLUID==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_FLUID=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_FLUID}static get ANY(){return chunkKHH45HMB_cjs.a.InteractionType_ANY==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.InteractionType_ANY=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.InteractionType_ANY}toString(){return this===chunkKHH45HMB_cjs.a.InteractionType_COLLISION?"COLLISION":this===chunkKHH45HMB_cjs.a.InteractionType_SENSOR?"SENSOR":this===chunkKHH45HMB_cjs.a.InteractionType_FLUID?"FLUID":this===chunkKHH45HMB_cjs.a.InteractionType_ANY?"ANY":""}},on=chunkKHH45HMB_cjs.E();on.callbacks.InteractionType=Z;var W=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return chunkKHH45HMB_cjs.a.PreFlag_ACCEPT==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT}static get IGNORE(){return chunkKHH45HMB_cjs.a.PreFlag_IGNORE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE}static get ACCEPT_ONCE(){return chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE}toString(){return this===chunkKHH45HMB_cjs.a.PreFlag_ACCEPT?"ACCEPT":this===chunkKHH45HMB_cjs.a.PreFlag_IGNORE?"IGNORE":this===chunkKHH45HMB_cjs.a.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===chunkKHH45HMB_cjs.a.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},pn=chunkKHH45HMB_cjs.E();pn.callbacks.PreFlag=W;var xe=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new chunkKHH45HMB_cjs.j,this.zpp_inner.outer=this,e!=null&&this.including(e),t!=null&&this.excluding(t);}get includes(){return this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes(),this.zpp_inner.wrap_includes}get excludes(){return this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes(),this.zpp_inner.wrap_excludes}including(e){return this.zpp_inner.append(this.zpp_inner.includes,e),this}excluding(e){return this.zpp_inner.append(this.zpp_inner.excludes,e),this}toString(){this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes();let e=this.zpp_inner.wrap_includes.toString();this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes();let t=this.zpp_inner.wrap_excludes.toString();return "@{"+e+" excluding "+t+"}"}static _wrap(e){return e instanceof n?e:e?e instanceof chunkKHH45HMB_cjs.j?chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},sn=chunkKHH45HMB_cjs.E();sn.callbacks.OptionType=xe;function an(n){return n===C.BEGIN?0:n===C.END?1:n===C.WAKE?2:n===C.SLEEP?3:n===C.BREAK?4:n===C.PRE?5:n===C.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!chunkKHH45HMB_cjs.f.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null;}static _wrap(e){return e instanceof n?e:e&&e instanceof chunkKHH45HMB_cjs.f?chunkKHH45HMB_cjs.G(e,t=>{if(t.outer)return t.outer;let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):null}get type(){return chunkKHH45HMB_cjs.f.types[this.zpp_inner.type]}get event(){return chunkKHH45HMB_cjs.f.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(chunkKHH45HMB_cjs.f.events[this.zpp_inner.event]!=e){let t=an(e);this.zpp_inner.swapEvent(t);}}get precedence(){return this.zpp_inner.precedence}set precedence(e){this.zpp_inner.precedence!=e&&(this.zpp_inner.precedence=e,this.zpp_inner.invalidate_precedence());}get space(){return this.zpp_inner.space==null?null:chunkKHH45HMB_cjs.X._wrap(this.zpp_inner.space.outer)}set space(e){let t=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=t)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),t!=null){let i=t.zpp_inner.wrap_listeners;i.zpp_inner.reverse_flag?i.push(this):i.unshift(this);}else this.zpp_inner.space=null;}toString(){let t=["BEGIN","END","WAKE","SLEEP","BREAK","PRE","ONGOING"][this.zpp_inner.event];if(this.zpp_inner.type==0){let r=this.zpp_inner.body;return "BodyListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return "ConstraintListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else {let r=this.zpp_inner.interaction,i;switch(r.itype){case 1:i="COLLISION";break;case 2:i="SENSOR";break;case 4:i="FLUID";break;default:i="ALL";}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+i+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+i+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var ve=class n{constructor(){if(!chunkKHH45HMB_cjs.a.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return chunkKHH45HMB_cjs.a.ListenerType_BODY==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_BODY=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_BODY}static get CONSTRAINT(){return chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT}static get INTERACTION(){return chunkKHH45HMB_cjs.a.ListenerType_INTERACTION==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_INTERACTION=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_INTERACTION}static get PRE(){return chunkKHH45HMB_cjs.a.ListenerType_PRE==null&&(chunkKHH45HMB_cjs.a.internal=true,chunkKHH45HMB_cjs.a.ListenerType_PRE=new n,chunkKHH45HMB_cjs.a.internal=false),chunkKHH45HMB_cjs.a.ListenerType_PRE}toString(){return this===chunkKHH45HMB_cjs.a.ListenerType_BODY?"BODY":this===chunkKHH45HMB_cjs.a.ListenerType_CONSTRAINT?"CONSTRAINT":this===chunkKHH45HMB_cjs.a.ListenerType_INTERACTION?"INTERACTION":this===chunkKHH45HMB_cjs.a.ListenerType_PRE?"PRE":""}},ln=chunkKHH45HMB_cjs.E();ln.callbacks.ListenerType=ve;chunkKHH45HMB_cjs.F();var F=class{constructor(){this.zpp_inner=null;if(!chunkKHH45HMB_cjs.d.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return chunkKHH45HMB_cjs.f.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return ""}};var Re=class extends F{get body(){return this.zpp_inner.body.outer}toString(){return "Cb:"+["WAKE","SLEEP"][this.zpp_inner.event-2]+":"+this.zpp_inner.body.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var ke=class extends F{get constraint(){return this.zpp_inner.constraint.outer}toString(){return "Cb:"+["WAKE","SLEEP","BREAK"][this.zpp_inner.event-2]+":"+this.zpp_inner.constraint.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Be=class extends F{get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get arbiters(){return this.zpp_inner.wrap_arbiters}toString(){return "Cb:"+["BEGIN","END","","","","","ONGOING"][this.zpp_inner.event]+":"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.wrap_arbiters.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Fe=class extends F{get arbiter(){return this.zpp_inner.pre_arbiter.wrapper()}get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get swapped(){return this.zpp_inner.pre_swapped}toString(){return "Cb:PRE::"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.pre_arbiter.wrapper().toString()+" : listnener: "+String(this.zpp_inner.listener.outer)}};var Ge=class extends B{constructor(e,t,r,i=0){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,r==null)throw new Error("Error: BodyListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new chunkKHH45HMB_cjs.g(chunkKHH45HMB_cjs.j.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: BodyListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};var De=class extends B{constructor(e,t,r,i=0){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else if(e===C.BREAK)p=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new chunkKHH45HMB_cjs.h(chunkKHH45HMB_cjs.j.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: ConstraintListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};function Me(n){return n===Z.COLLISION?1:n===Z.SENSOR?2:n===Z.FLUID?4:7}function se(n){return n==1?Z.COLLISION:n==2?Z.SENSOR:n==4?Z.FLUID:n==7?Z.ANY:null}var Ue=class extends B{constructor(e,t,r,i,p,s=0){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,p==null)throw new Error("Error: InteractionListener::handler cannot be null");if(e==null)throw new Error("Error: CbEvent cannot be null for InteractionListener");let a;if(e===C.BEGIN)a=0;else if(e===C.END)a=1;else if(e===C.ONGOING)a=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new chunkKHH45HMB_cjs.i(chunkKHH45HMB_cjs.j.argument(r),chunkKHH45HMB_cjs.j.argument(i),a,2),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zni=this,this.zpp_inner.precedence=s,this.zpp_inner_zn.handleri=p,t==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Me(t));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handleri}set handler(e){if(e==null)throw new Error("Error: InteractionListener::handler cannot be null");this.zpp_inner_zn.handleri=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e;}};var ae=class extends B{constructor(e,t,r,i,p=0,s=false){if(chunkKHH45HMB_cjs.f.internal=true,super(),chunkKHH45HMB_cjs.f.internal=false,i==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new chunkKHH45HMB_cjs.i(chunkKHH45HMB_cjs.j.argument(t),chunkKHH45HMB_cjs.j.argument(r),5,3),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_znp=this,this.zpp_inner.precedence=p,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=i,e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handlerp}set handler(e){if(e==null)throw new Error("Error: PreListener must take a non-null handler!");this.zpp_inner_zn.handlerp=e,this.zpp_inner_zn.wake();}get pure(){return this.zpp_inner_zn.pure}set pure(e){e||this.zpp_inner_zn.wake(),this.zpp_inner_zn.pure=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}};var We=class n extends chunkKHH45HMB_cjs.ka{constructor(e,t=false){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r=new chunkKHH45HMB_cjs.r(e,t);this.zpp_inner=r,r.outer=this,r.outer_zn=this;}static _wrap(e){return e==null?null:e instanceof n?e:e.zpp_inner?.outer instanceof n?e.zpp_inner.outer:chunkKHH45HMB_cjs.G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new chunkKHH45HMB_cjs.H;return e.zpp_inner._inuse=true,e.zpp_inner._invalidate=this.zpp_inner.bindVec2_invalidate.bind(this.zpp_inner),e}__copy(){throw new Error("Error: UserConstraint::__copy must be overriden")}__broken(){}__validate(){}__draw(e){}__prepare(){}__position(e){throw new Error("Error: UserConstraint::__position must be overriden")}__velocity(e){throw new Error("Error: Userconstraint::__velocity must be overriden")}__eff_mass(e){throw new Error("Error: UserConstraint::__eff_mass must be overriden")}__clamp(e){}__impulse(e,t,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,t=new chunkKHH45HMB_cjs.J(e,1);for(let r=0;r<e;r++){if(r<0||r>=t.zpp_inner.m||0>=t.zpp_inner.n)throw new Error("Error: MatMN indices out of range");t.zpp_inner.x[r*t.zpp_inner.n]=this.zpp_inner.jAcc[r];}return t}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let t=false;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=true;break}if(!t)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):chunkKHH45HMB_cjs.I.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let i=this.zpp_inner.bodies[r];if(i.body!=null){let p=false;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==i.body){p=true;break}p||e(i.body.outer);}++r;}}__invalidate(){this.zpp_inner.immutable_midstep("UserConstraint::invalidate()"),this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&this.zpp_inner.wake();}__registerBody(e,t){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=t){if(e!=null){if(!this.zpp_inner.remBody(e.zpp_inner))throw new Error("Error: oldBody is not registered to the cosntraint");this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&e.zpp_inner.wake();}t!=null&&this.zpp_inner.addBody(t.zpp_inner),this.zpp_inner.wake(),t?.zpp_inner.wake();}return t}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e;}};function O(n){let{typeName:e,namespaceParts:t,zppListClass:r,wrapElement:i,unwrapElement:p}=n,s=chunkKHH45HMB_cjs.E(),a=s.__zpp,c=()=>a.util[r],f=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!c().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=c();return u.zpp_pool==null?(b.internal=true,h=new u,b.internal=false):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=false,h},u.prototype.zpp_inner=null,u.prototype.zpp_i=null,u.prototype.zpp_critical=null,u.prototype.zpp_next=null,u.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let _=this.zpp_inner;_.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=true,this.zpp_i<h?true:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,false)},u.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(c()),this.zpp_inner.outer=this;}m.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new m;for(let b=0;b<_.length;b++)h.push(_[b]);return h},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function y(_){return _.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return y(this)}}),m.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(p(_))},m.prototype.at=function(_){if(this.zpp_inner.valmod(),_<0||_>=y(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(_=y(this)-1-_),_<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=_,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(_);else for(;this.zpp_inner.at_index!=_;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return i(this.zpp_inner.at_ite.elt)},m.prototype.push=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(p(_)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.unshift=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))):this.zpp_inner.inner.add(p(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}return this.zpp_inner.invalidate(),i(_)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}else {_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),i(_)},m.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},m.prototype.remove=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=false,b=this.zpp_inner.inner.head,G=p(_);for(;b!=null;){if(b.elt==G){h=true;break}b=b.next;}return h&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(_),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(G),this.zpp_inner.invalidate()),h},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift();},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},m.prototype.copy=function(_){_==null&&(_=false);let h=new m,b=u.get(this);for(;b.hasNext();){let G=b.next();if(_)throw new Error("Error: "+e+" is not a copyable type");h.push(G);}return h},m.prototype.merge=function(_){if(_==null)throw new Error("Error: Cannot merge with null list");let h=u.get(_);for(;h.hasNext();){let b=h.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b));}},m.prototype.toString=function(){let _="[",h=true,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=false;}return _+"]"},m.prototype.foreach=function(_){if(_==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let h=u.get(this);for(;h.hasNext();)try{_(h.next());}catch{h.zpp_next=u.zpp_pool,u.zpp_pool=h,h.zpp_inner=null;break}return this},m.prototype.filter=function(_){if(_==null)throw new Error("Error: Cannot select elements of list with null");let h=0;for(;h<y(this);){let b=this.at(h);try{_(b)?++h:this.remove(b);}catch{break}}return this},m.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},m.prototype[Symbol.iterator]=function(){let _=u.get(this);return {next(){return _.hasNext()?{value:_.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};let g=f(),R=e+"Iterator",J=e+"List";return g[R]=u,g[J]=m,{Iterator:u,List:m}}var X=n=>n.outer,K=n=>n.zpp_inner??(n._inner?n._inner.zpp_inner??n._inner:n);O({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:X,unwrapElement:K});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:X,unwrapElement:K});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:X,unwrapElement:K});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:X,unwrapElement:K});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:X,unwrapElement:K});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:X,unwrapElement:K});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:X,unwrapElement:K});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:X,unwrapElement:K});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:n=>n.outer_i,unwrapElement:n=>n.zpp_inner_i});function le(n){if(n.outer==null){let e=chunkKHH45HMB_cjs.E();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=chunkKHH45HMB_cjs.l.zpp_pool,chunkKHH45HMB_cjs.l.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=false,this._length=0,this.inner=null,E.call(this),this.at_ite=null,this.at_index=0,this.zip_length=true,this._length=0;}for(let n in E.prototype)L.prototype[n]=E.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:true});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=false;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=false);let t=new L;return t.inner=n,t.zpp_inner.immutable=e,t};L.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let n=this.inner.next;for(;n!=null;)this._length++,n=n.next;this.zip_length=false;}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=true,this._length=0,this.at_ite=null);};L.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),(n<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==n;)this.at_index++,this.at_ite=this.at_ite.next;return le(this.at_ite)};L.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(n.zpp_inner);else {let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}else this.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}else {this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}return this.zpp_inner.invalidate(),le(n)};L.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}else {n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}return this.zpp_inner.invalidate(),le(n)};L.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};L.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};var _n=chunkKHH45HMB_cjs.E(),un=_n.__zpp;un.util.ZPP_MixVec2List=L;var z=chunkKHH45HMB_cjs.E();z.Config=Object.assign(z.Config||{},Pt);z.util.Debug=Xe;z.geom.Vec2=chunkKHH45HMB_cjs.H;z.geom.Vec3=chunkKHH45HMB_cjs.I;z.geom.Mat23=fe;z.geom.MatMN=chunkKHH45HMB_cjs.J;z.geom.AABB=chunkKHH45HMB_cjs.K;z.geom.Winding=chunkKHH45HMB_cjs.L;z.geom.Ray=q;z.geom.ConvexResult=ze;z.geom.RayResult=de;z.geom.Geom=Se;z.geom.GeomPoly=chunkKHH45HMB_cjs.N;z.geom.MarchingSquares=Ze;z.geom.Vec2Iterator=I;z.geom.Vec2List=E;z.geom.GeomVertexIterator=pe;z.__zpp.geom.ZPP_GeomVertexIterator=chunkKHH45HMB_cjs.M;z.__zpp.util.ZPP_ContactList=Y;z.phys.Interactor=chunkKHH45HMB_cjs.R;z.phys.Body=chunkKHH45HMB_cjs._;chunkKHH45HMB_cjs.O(n=>chunkKHH45HMB_cjs._._wrap(n));z.phys.BodyType=chunkKHH45HMB_cjs.$;z.phys.Compound=chunkKHH45HMB_cjs.aa;chunkKHH45HMB_cjs.Q(n=>chunkKHH45HMB_cjs.aa._wrap(n));z.phys.FluidProperties=chunkKHH45HMB_cjs.T;z.phys.Material=chunkKHH45HMB_cjs.ba;z.phys.GravMassMode=chunkKHH45HMB_cjs.ca;z.phys.InertiaMode=chunkKHH45HMB_cjs.da;z.phys.MassMode=chunkKHH45HMB_cjs.ea;z.shape.Shape=chunkKHH45HMB_cjs.V;chunkKHH45HMB_cjs.P(n=>chunkKHH45HMB_cjs.V._wrap(n));z.shape.Circle=chunkKHH45HMB_cjs.fa;z.shape.Polygon=chunkKHH45HMB_cjs.ga;z.shape.Capsule=chunkKHH45HMB_cjs.ha;z.shape.Edge=be;z.shape.ShapeType=chunkKHH45HMB_cjs.U;z.shape.ValidationResult=ge;z.space.Space=chunkKHH45HMB_cjs.X;z.space.Broadphase=chunkKHH45HMB_cjs.ia;z.dynamics.InteractionFilter=chunkKHH45HMB_cjs.ja;z.dynamics.InteractionGroup=we;z.dynamics.ArbiterType=Ee;z.dynamics.Arbiter=j;chunkKHH45HMB_cjs.t._createColArb=()=>new Ve;chunkKHH45HMB_cjs.t._createFluidArb=()=>new Oe;z.dynamics.Contact=Pe;z.dynamics.ContactIterator=v;z.dynamics.ContactList=A;z.callbacks.CbEvent=C;z.callbacks.CbType=Ce;z.callbacks.InteractionType=Z;z.callbacks.PreFlag=W;z.callbacks.OptionType=xe;z.callbacks.Listener=B;z.callbacks.ListenerType=ve;z.callbacks.Callback=F;chunkKHH45HMB_cjs.d._createBodyCb=()=>new Re;chunkKHH45HMB_cjs.d._createConCb=()=>new ke;chunkKHH45HMB_cjs.d._createIntCb=()=>new Be;chunkKHH45HMB_cjs.d._createPreCb=()=>new Fe;z.callbacks.BodyListener=Ge;z.callbacks.ConstraintListener=De;z.callbacks.InteractionListener=Ue;z.callbacks.PreListener=ae;z.constraint.Constraint=chunkKHH45HMB_cjs.ka;chunkKHH45HMB_cjs.k._createFn=(...n)=>new chunkKHH45HMB_cjs.la(...n);chunkKHH45HMB_cjs.m._createFn=(...n)=>new chunkKHH45HMB_cjs.ma(...n);chunkKHH45HMB_cjs.n._createFn=(...n)=>new chunkKHH45HMB_cjs.na(...n);chunkKHH45HMB_cjs.o._createFn=(...n)=>new chunkKHH45HMB_cjs.oa(...n);chunkKHH45HMB_cjs.p._createFn=(...n)=>new chunkKHH45HMB_cjs.pa(...n);chunkKHH45HMB_cjs.q._createFn=(...n)=>new chunkKHH45HMB_cjs.qa(...n);chunkKHH45HMB_cjs.s._createFn=(...n)=>new chunkKHH45HMB_cjs.ra(...n);z.constraint.UserConstraint=We;var Ct=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,i){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,i){}drawSolidCapsule(e,t,r,i){}drawPoint(e,t){}};function hn(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof chunkKHH45HMB_cjs.N){if(n.zpp_disp)throw new Error("Error: GeomPoly has been disposed and cannot be used!");t=n.copy();}else {if(!Array.isArray(n))throw new Error("Error: vertices must be an Array<Vec2> or GeomPoly");if(n.length<3)throw new Error("Error: At least 3 vertices are required, got "+n.length);for(let f=0;f<n.length;f++)if(n[f]==null)throw new Error("Error: vertices["+f+"] is null");t=new chunkKHH45HMB_cjs.N(n);}if(t.size()<3)throw t.dispose(),new Error("Error: At least 3 vertices are required, got "+t.size());if(t.isDegenerate())throw t.dispose(),new Error("Error: Polygon is degenerate (zero area)");if(!t.isSimple())throw t.dispose(),new Error("Error: Polygon is self-intersecting");let r=e?.simplify??0;if(r>0){let f=t.simplify(r);if(t.dispose(),t=f,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let f=[],u=t.forwardIterator();for(;u.hasNext();){let m=u.next();f.push(chunkKHH45HMB_cjs.H.get(m.x,m.y));}t.dispose(),f.reverse(),t=new chunkKHH45HMB_cjs.N(f);}let i=e?.material,p=e?.filter,s=e?.delaunay??false,a=new chunkKHH45HMB_cjs._(e?.type??chunkKHH45HMB_cjs.$.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new chunkKHH45HMB_cjs.ga(t,i,p)),t.dispose(),a;let c=t.convexDecomposition(s);for(let f of c)a.shapes.add(new chunkKHH45HMB_cjs.ga(f,i,p));return t.dispose(),a}var xt=class{constructor(e,t,r={}){this._oneWayListener=null;this._grounded=false;this._groundNormal=null;this._groundBody=null;this._onMovingPlatform=false;this._slopeAngle=0;this._wallLeft=false;this._wallRight=false;this._timeSinceGrounded=0;this.space=e,this.body=t,this._maxSlopeAngle=r.maxSlopeAngle??Math.PI/4,this._maxSlopeCos=Math.cos(this._maxSlopeAngle);let i=256;if(r.filter)this._filter=r.filter;else {let p=t.shapes;for(let s=0;s<p.length;s++){let c=p.at(s).filter;c.collisionGroup=c.collisionGroup|i;}this._filter=new chunkKHH45HMB_cjs.ja(1,~i);}r.oneWayPlatformTag&&r.characterTag&&this._setupOneWayPlatforms(r.oneWayPlatformTag,r.characterTag);}get grounded(){return this._grounded}get groundNormal(){return this._groundNormal}get groundBody(){return this._groundBody}get timeSinceGrounded(){return this._timeSinceGrounded}get maxSlopeAngle(){return this._maxSlopeAngle}set maxSlopeAngle(e){this._maxSlopeAngle=e,this._maxSlopeCos=Math.cos(e);}setVelocity(e,t){this.body.velocity=new chunkKHH45HMB_cjs.H(e,t);}update(){this._wallLeft=false,this._wallRight=false;let e=this.body.position.x,t=this.body.position.y;return this._detectGround(e,t),this._detectWalls(e,t),this._grounded&&this._groundBody?this._onMovingPlatform=this._groundBody.type===chunkKHH45HMB_cjs.$.KINEMATIC:this._onMovingPlatform=false,this._grounded?this._timeSinceGrounded=0:this._timeSinceGrounded+=1/60,{grounded:this._grounded,groundNormal:this._groundNormal,groundBody:this._groundBody,onMovingPlatform:this._onMovingPlatform,slopeAngle:this._slopeAngle,wallLeft:this._wallLeft,wallRight:this._wallRight,timeSinceGrounded:this._timeSinceGrounded}}destroy(){this._oneWayListener&&(this._oneWayListener.space=null,this._oneWayListener=null);}_detectGround(e,t){let i=this._getCharacterRadius(0,1)+4,p=new q(new chunkKHH45HMB_cjs.H(e,t),new chunkKHH45HMB_cjs.H(0,1));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);if(s&&s.distance<=i){let a=s.normal.y;if(a<0){let c=-a;if(c>=this._maxSlopeCos){this._grounded=true,this._groundNormal=new chunkKHH45HMB_cjs.H(s.normal.x,s.normal.y),this._groundBody=s.shape?.body??null,this._slopeAngle=Math.acos(Math.min(1,c));return}}}this._grounded=false,this._groundNormal=null,this._groundBody=null,this._slopeAngle=0;}_detectWalls(e,t){let i=this._getCharacterRadius(1,0)+2,p=new q(new chunkKHH45HMB_cjs.H(e,t),new chunkKHH45HMB_cjs.H(-1,0));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);s&&s.distance<=i&&Math.abs(s.normal.x)>.7&&(this._wallLeft=true);let a=new q(new chunkKHH45HMB_cjs.H(e,t),new chunkKHH45HMB_cjs.H(1,0));a.maxDistance=i;let c=this.space.rayCast(a,false,this._filter);c&&c.distance<=i&&Math.abs(c.normal.x)>.7&&(this._wallRight=true);}_setupOneWayPlatforms(e,t){let r=new ae(Z.COLLISION,e,t,i=>{try{let p=i.arbiter.collisionArbiter;if(!p)return W.ACCEPT;let s=p.normal.y,a=i.swapped;return s>0!==a?W.IGNORE:W.ACCEPT}catch{return W.ACCEPT}},0,true);r.space=this.space,this._oneWayListener=r;}_getCharacterRadius(e,t){let r=this.body.shapes.at(0);if(!r)return 0;if(r.isCircle())return r.castCircle?.radius??0;if(r.isCapsule()){let a=r.castCapsule;if(a){let c=a.radius,f=a.halfLength,u=this.body.rotation,m=Math.cos(u),y=Math.sin(u);return Math.abs(e*m+t*y)*f+c}}let i=r.bounds,p=i.width/2,s=i.height/2;return Math.abs(e)*p+Math.abs(t)*s}};var Xp="3.20.0";Object.defineProperty(exports,"AABB",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.K}});Object.defineProperty(exports,"AngleJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.la}});Object.defineProperty(exports,"Body",{enumerable:true,get:function(){return chunkKHH45HMB_cjs._}});Object.defineProperty(exports,"BodyType",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.$}});Object.defineProperty(exports,"Broadphase",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ia}});Object.defineProperty(exports,"Capsule",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ha}});Object.defineProperty(exports,"Circle",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.fa}});Object.defineProperty(exports,"Compound",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.aa}});Object.defineProperty(exports,"Constraint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ka}});Object.defineProperty(exports,"DebugDrawFlags",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.W}});Object.defineProperty(exports,"DistanceJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ma}});Object.defineProperty(exports,"FluidProperties",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.T}});Object.defineProperty(exports,"GeomPoly",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.N}});Object.defineProperty(exports,"GravMassMode",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ca}});Object.defineProperty(exports,"InertiaMode",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.da}});Object.defineProperty(exports,"InteractionFilter",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ja}});Object.defineProperty(exports,"Interactor",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.R}});Object.defineProperty(exports,"LineJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.na}});Object.defineProperty(exports,"MassMode",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ea}});Object.defineProperty(exports,"MatMN",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.J}});Object.defineProperty(exports,"Material",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ba}});Object.defineProperty(exports,"MotorJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.oa}});Object.defineProperty(exports,"NapeList",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.S}});Object.defineProperty(exports,"PivotJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.pa}});Object.defineProperty(exports,"Polygon",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ga}});Object.defineProperty(exports,"PulleyJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.qa}});Object.defineProperty(exports,"Shape",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.V}});Object.defineProperty(exports,"ShapeType",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.U}});Object.defineProperty(exports,"Space",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.X}});Object.defineProperty(exports,"Vec2",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.H}});Object.defineProperty(exports,"Vec3",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.I}});Object.defineProperty(exports,"WeldJoint",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.ra}});Object.defineProperty(exports,"Winding",{enumerable:true,get:function(){return chunkKHH45HMB_cjs.L}});exports.Arbiter=j;exports.ArbiterType=Ee;exports.BodyCallback=Re;exports.BodyListener=Ge;exports.Callback=F;exports.CbEvent=C;exports.CbType=Ce;exports.CharacterController=xt;exports.CollisionArbiter=Ve;exports.ConstraintCallback=ke;exports.ConstraintListener=De;exports.Contact=Pe;exports.ConvexResult=ze;exports.DebugDraw=Ct;exports.Edge=be;exports.FluidArbiter=Oe;exports.Geom=Se;exports.InteractionCallback=Be;exports.InteractionGroup=we;exports.InteractionListener=Ue;exports.InteractionType=Z;exports.Listener=B;exports.ListenerType=ve;exports.MarchingSquares=Ze;exports.Mat23=fe;exports.OptionType=xe;exports.PreCallback=Fe;exports.PreFlag=W;exports.PreListener=ae;exports.Ray=q;exports.RayResult=de;exports.UserConstraint=We;exports.VERSION=Xp;exports.ValidationResult=ge;exports.createConcaveBody=hn;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {E as E$1,A as A$1,G,x,b,l as l$1,D,v as v$1,F as F$1,u,H,I as I$1,J,K as K$1,L as L$1,N,M,R,_,O as O$1,$,aa,Q as Q$1,T,ba,ca,da,ea,V as V$1,P,fa,ga,ha,U,X as X$1,ia,ja,t,d,ka,la,k,ma,m,na,n,oa,o,pa,p,qa,q as q$1,ra,s,a,e,Z as Z$1,Y as Y$1,j as j$1,B as B$1,y,C as C$1,w,z as z$1,f,g,h,i,r,c}from'./chunk-SNMC46IS.js';export{K as AABB,la as AngleJoint,_ as Body,$ as BodyType,ia as Broadphase,ha as Capsule,fa as Circle,aa as Compound,ka as Constraint,W as DebugDrawFlags,ma as DistanceJoint,T as FluidProperties,N as GeomPoly,ca as GravMassMode,da as InertiaMode,ja as InteractionFilter,R as Interactor,na as LineJoint,ea as MassMode,J as MatMN,ba as Material,oa as MotorJoint,S as NapeList,pa as PivotJoint,ga as Polygon,qa as PulleyJoint,V as Shape,U as ShapeType,X as Space,H as Vec2,I as Vec3,ra as WeldJoint,L as Winding}from'./chunk-SNMC46IS.js';var Pt={epsilon:1e-8,fluidAngularDragFriction:2.5,fluidAngularDrag:100,fluidVacuumDrag:.5,fluidLinearDrag:.5,collisionSlop:.2,collisionSlopCCD:.5,distanceThresholdCCD:.05,staticCCDLinearThreshold:.05,staticCCDAngularThreshold:.005,bulletCCDLinearThreshold:.125,bulletCCDAngularThreshold:.0125,dynamicSweepLinearThreshold:17,dynamicSweepAngularThreshold:.6,angularCCDSlipScale:.75,arbiterExpirationDelay:6,staticFrictionThreshold:2,elasticThreshold:20,sleepDelay:60,linearSleepThreshold:.2,angularSleepThreshold:.4,contactBiasCoef:.3,contactStaticBiasCoef:.6,contactContinuousBiasCoef:.4,contactContinuousStaticBiasCoef:.5,constraintLinearSlop:.1,constraintAngularSlop:.001,illConditionedThreshold:2e8},jt=E$1();jt.Config=Object.assign(jt.Config||{},Pt);function l(n,e,t){for(;n[e]!=null;){let r=n[e][t];n[e][t]=null,n[e]=r;}}var Xe=class{static version(){return "Nape 2.0.19"}static clearObjectPools(){let e=E$1(),t=e.__zpp;l(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),l(e.phys.InteractorIterator,"zpp_pool","zpp_next"),l(e.phys.BodyIterator,"zpp_pool","zpp_next"),l(e.phys.CompoundIterator,"zpp_pool","zpp_next"),l(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),l(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),l(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),l(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),l(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),l(e.geom.RayResultIterator,"zpp_pool","zpp_next"),l(e.shape.ShapeIterator,"zpp_pool","zpp_next"),l(e.shape.EdgeIterator,"zpp_pool","zpp_next"),l(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),l(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),l(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),l(t.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Body,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Component,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),l(t.util.ZNPNode_ConvexResult,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),l(t.util.ZNPNode_RayResult,"zpp_pool","next"),l(t.phys.ZPP_Material,"zpp_pool","next"),l(t.phys.ZPP_FluidProperties,"zpp_pool","next"),l(t.callbacks.ZPP_CbSetPair,"zpp_pool","next"),l(t.callbacks.ZPP_Callback,"zpp_pool","next"),l(t.callbacks.ZPP_CbSet,"zpp_pool","next"),l(t.geom.ZPP_GeomVert,"zpp_pool","next"),l(t.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),l(t.geom.ZPP_Mat23,"zpp_pool","next"),l(t.geom.ZPP_CutVert,"zpp_pool","next"),l(t.geom.ZPP_CutInt,"zpp_pool","next"),l(t.geom.ZPP_Vec2,"zpp_pool","next"),l(t.geom.ZPP_PartitionVertex,"zpp_pool","next"),l(t.geom.ZPP_SimplifyV,"zpp_pool","next"),l(t.geom.ZPP_SimplifyP,"zpp_pool","next"),l(t.geom.ZPP_PartitionedPoly,"zpp_pool","next"),l(t.geom.ZPP_PartitionPair,"zpp_pool","next"),l(t.geom.ZPP_AABB,"zpp_pool","next"),l(t.geom.ZPP_SimpleVert,"zpp_pool","next"),l(t.geom.ZPP_SimpleSeg,"zpp_pool","next"),l(t.geom.ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.Hashable2_Boolfalse,"zpp_pool","next"),l(t.geom.ZPP_ToiEvent,"zpp_pool","next"),l(t.geom.ZPP_MarchSpan,"zpp_pool","next"),l(t.geom.ZPP_MarchPair,"zpp_pool","next"),l(t.shape.ZPP_Edge,"zpp_pool","next"),l(t.space.ZPP_SweepData,"zpp_pool","next"),l(t.space.ZPP_AABBNode,"zpp_pool","next"),l(t.space.ZPP_AABBPair,"zpp_pool","next"),l(t.dynamics.ZPP_Contact,"zpp_pool","next"),l(t.space.ZPP_Island,"zpp_pool","next"),l(t.space.ZPP_Component,"zpp_pool","next"),l(t.space.ZPP_CallbackSet,"zpp_pool","next"),l(t.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_ColArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec2","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec3","zpp_pool");}};var fe=class n{get _inner(){return this}constructor(e=1,t=0,r=0,i=1,p=0,s=0){let a=A$1.get();this.zpp_inner=a,a.outer=this;let c=["a","b","tx","c","d","ty"],f=[e,t,p,r,i,s];for(let u=0;u<f.length;u++)if(f[u]!==f[u])throw new Error("Error: Mat23::"+c[u]+" cannot be NaN");a.setas(e,t,r,i,p,s);}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let t=Math.cos(e),r=Math.sin(e);return new n(t,-r,r,t,0,0)}static translation(e,t){return new n(1,0,0,1,e,t)}static scale(e,t){return new n(e,0,0,t,0,0)}static _wrap(e){return e instanceof n?e:e?e instanceof A$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}_setProp(e,t){if(t!==t)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=t,this.zpp_inner.invalidate();}get a(){return this.zpp_inner.a}set a(e){this._setProp("a",e);}get b(){return this.zpp_inner.b}set b(e){this._setProp("b",e);}get c(){return this.zpp_inner.c}set c(e){this._setProp("c",e);}get d(){return this.zpp_inner.d}set d(e){this._setProp("d",e);}get tx(){return this.zpp_inner.tx}set tx(e){this._setProp("tx",e);}get ty(){return this.zpp_inner.ty}set ty(e){this._setProp("ty",e);}get determinant(){return this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c}clone(){return this.copy()}equals(e,t=0){if(e==null)return false;let r=this.zpp_inner,i=e.zpp_inner,p=r.a-i.a,s=r.b-i.b,a=r.c-i.c,c=r.d-i.d,f=r.tx-i.tx,u=r.ty-i.ty;return (p<0?-p:p)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(c<0?-c:c)<=t&&(f<0?-f:f)<=t&&(u<0?-u:u)<=t}copy(){return new n(this.zpp_inner.a,this.zpp_inner.b,this.zpp_inner.c,this.zpp_inner.d,this.zpp_inner.tx,this.zpp_inner.ty)}set(e){if(e==null)throw new Error("Error: Cannot set form null matrix");let t=e.zpp_inner;return this.zpp_inner.setas(t.a,t.b,t.c,t.d,t.tx,t.ty),this.zpp_inner.invalidate(),this}setAs(e=1,t=0,r=0,i=1,p=0,s=0){return this.zpp_inner.setas(e,t,r,i,p,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=e*e+t*t+r*r+i*i,s=e*i-t*r;s<0&&(s=-s);let a=E$1();return p>a.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner,a=1/(e*i-t*r);return new n(i*a,-t*a,-r*a,e*a,(t*s-i*p)*a,(r*p-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return new n(e,r,t,i,-e*p-r*s,-t*p-i*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let t=e.zpp_inner,r=this.zpp_inner;return new n(t.a*r.a+t.b*r.c,t.a*r.b+t.b*r.d,t.c*r.a+t.d*r.c,t.c*r.b+t.d*r.d,t.a*r.tx+t.b*r.ty+t.tx,t.c*r.tx+t.d*r.ty+t.ty)}transform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");e.zpp_inner.validate();let i=e.zpp_inner.x,p=e.zpp_inner.y,{a:s,b:a,c,d:f,tx:u,ty:m}=this.zpp_inner,y,g;t?(y=i*s+p*a,g=i*c+p*f):(y=i*s+p*a+u,g=i*c+p*f+m);let R=H.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");if(this.singular())throw new Error("Error: Matrix is singular and inverse transformation cannot be performed");let{a:i,b:p,c:s,d:a,tx:c,ty:f}=this.zpp_inner,u=1/(i*a-p*s);e.zpp_inner.validate();let m=e.zpp_inner.x,y=e.zpp_inner.y,g,R;if(t)g=(m*a-y*p)*u,R=(y*i-m*s)*u;else {let _=m-c,h=y-f;g=(_*a-h*p)*u,R=(h*i-_*s)*u;}let J=H.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),J}equiorthogonal(){if(this.singular())return false;let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=E$1(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-r*r-i*i;return a*a<p.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=E$1(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-1,c=r*r+i*i-1;return a*a<p.Config.epsilon&&c*c<p.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:i,d:p}=this.zpp_inner,s=E$1(),a=Math.sqrt(t*t+i*i),c=Math.sqrt(r*r+p*p);if(a*a<s.Config.epsilon||c*c<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let f=e?(a+c)/2:1;a=f/a,c=f/c,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*c,this.d=this.zpp_inner.d*c;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(u/(f*f));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let y=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*y,J=this.zpp_inner.b*g+this.zpp_inner.d*y,_=this.zpp_inner.c*g+this.zpp_inner.a*y,h=this.zpp_inner.d*g-this.zpp_inner.b*y;return this.c=_,this.a=R,this.d=h,this.b=J,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(true)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(false)}toString(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return "{ a: "+e+" b: "+t+" c: "+r+" d: "+i+" tx: "+p+" ty: "+s+" }"}};A$1._wrapFn=n=>G(n,e=>{let t=Object.create(fe.prototype);return t.zpp_inner=e,e.outer=t,t});function et(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.x}function tt(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.y}function me(n){n.zpp_inner.weak&&n.dispose();}var q=class n{get _inner(){return this}constructor(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::direction cannot be null");let r=new B$1;this.zpp_inner=r;let i=et(e),p=tt(e);r.origin.zpp_inner.x=i,r.origin.zpp_inner.y=p,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),me(e);let s=et(t),a=tt(t);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=a,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),me(t),r.zip_dir=true,r.maxdist=1/0;}static _wrap(e){return e==null?null:e instanceof n?e:G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r})}static fromSegment(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::fromSegment::start is null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::fromSegment::end is null");let r=t.sub(e,true),i=new n(e,r),p=et(e),s=tt(e),a=et(t),c=tt(t),f=a-p,u=c-s,m=Math.sqrt(f*f+u*u);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return i.zpp_inner.maxdist=m,me(e),me(t),i}get origin(){return this.zpp_inner.origin}set origin(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");this.zpp_inner.origin.set(e),me(e);}get direction(){return this.zpp_inner.direction}set direction(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::direction cannot be null");this.zpp_inner.direction.set(e),this.zpp_inner.zip_dir=true,me(e);}get maxDistance(){return this.zpp_inner.maxdist}set maxDistance(e){if(e!==e)throw new Error("Error: maxDistance cannot be NaN");this.zpp_inner.maxdist=e;}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}aabb(){return K$1._wrap(this.zpp_inner.rayAABB())}at(e,t=false){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let i=r.x,p=r.y,s=i+e*this.zpp_inner.dirx,a=p+e*this.zpp_inner.diry;return H.get(s,a,t)}clone(){return this.copy()}copy(){let e=new n(this.zpp_inner.origin,this.zpp_inner.direction),t=this.zpp_inner.maxdist;if(t!==t)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=t,e}};var ze=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),H._wrap(this.zpp_inner.position)}get toi(){return this._disposed(),this.zpp_inner.toiDistance}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" toi: "+this.zpp_inner.toiDistance+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x._createConvexResult=()=>new ze;var de=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H._wrap(this.zpp_inner.normal)}get distance(){return this._disposed(),this.zpp_inner.toiDistance}get inner(){return this._disposed(),this.zpp_inner.inner}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" distance: "+this.zpp_inner.toiDistance+" ?inner: "+String(this.zpp_inner.inner)+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x._createRayResult=()=>new de;function ie(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function rt(n,e){if(n!=null&&n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let t=n.zpp_inner;if(t._immutable)throw new Error("Error: Vec2 is immutable");t._isimmutable!=null&&t._isimmutable();}function ye(n,e){if(ie(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Se=class{static distanceBody(e,t,r,i){rt(r),rt(i);let p=nt(e),s=nt(t);if(p.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=p.shapes.head;for(;a!=null;)y.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)y.validateShape(a.elt),a=a.next;return C$1.distanceBody(p,s,r.zpp_inner,i.zpp_inner)}static distance(e,t,r,i){rt(r),rt(i),ye(e,"distances"),ye(t,"distances");let p=ie(e),s=ie(t);y.validateShape(p),y.validateShape(s);let a;l$1.zpp_pool==null?a=new l$1:(a=l$1.zpp_pool,l$1.zpp_pool=a.next,a.next=null),a.weak=false;let c=C$1.distance(p,s,r.zpp_inner,i.zpp_inner,a,1e100);return a.next=l$1.zpp_pool,l$1.zpp_pool=a,c}static intersectsBody(e,t){let r=nt(e),i=nt(t);if(r.shapes.head==null||i.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let p=r.shapes.head;for(;p!=null;)y.validateShape(p.elt),p=p.next;for(p=i.shapes.head;p!=null;)y.validateShape(p.elt),p=p.next;let s=r.aabb,a=i.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return false;let c=r.shapes.head;for(;c!=null;){let f=i.shapes.head;for(;f!=null;){if(w.testCollide_safe(c.elt,f.elt))return true;f=f.next;}c=c.next;}return false}static intersects(e,t){ye(e,"intersection"),ye(t,"intersection");let r=ie(e),i=ie(t);y.validateShape(r),y.validateShape(i);let p=r.aabb,s=i.aabb;return p.minx>s.maxx||p.maxx<s.minx||p.miny>s.maxy||p.maxy<s.miny?false:w.testCollide_safe(r,i)}static contains(e,t){ye(e,"containment"),ye(t,"containment");let r=ie(e),i=ie(t);return y.validateShape(r),y.validateShape(i),w.containTest(r,i)}};var Ze=class{static run(e,t,r,i=2,p=null,s=true,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: MarchingSquares requires an iso function to operate");if(t==null)throw new Error("Error: MarchingSquares requires an AABB to define bounds of surface extraction");if(r==null)throw new Error("Error: MarchingSquares requires a Vec2 to define cell size for surface extraction");let c=r.zpp_inner;if(c._validate!=null&&c._validate(),c.x<=0||c.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(i<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(p!=null){let g=p.zpp_inner;if(g._validate!=null&&g._validate(),g.x<=0||g.y<=0)throw new Error("Error: MarchingSquares cannot with non-positive sub-grid dimensions")}let f=E$1(),u=a??new f.geom.GeomPolyList,m=z$1,y=t.zpp_inner;if(y._validate!=null&&y._validate(),p==null){let g=y.minx,R=y.miny,J=y.maxx,_=y.maxy;m.run(e,g,R,J,_,r,i,s,u);}else {let g=p.zpp_inner;g._validate!=null&&g._validate();let R=y.maxx-y.minx,J=y.maxy-y.miny,_=R/g.x,h=J/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let vt=y.minx+g.x*Ye,Kt=Ye===b-1?y.maxx:vt+g.x;for(let je=0;je<G;je++){let Nt=y.miny+g.y*je,Jt=je===G-1?y.maxy:Nt+g.y;m.run(e,vt,Nt,Kt,Jt,r,i,s,u);}}}return c.weak&&r.dispose(),p!=null&&p.zpp_inner.weak&&p.dispose(),u}};var Q=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new c,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E$1(),i=new r.geom.Vec2List;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Q.internal=false;function oe(n){if(n.outer==null){let e=E$1();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l$1.zpp_pool,l$1.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function I(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Q.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}I.zpp_pool=null;I.get=function(n){let e;return I.zpp_pool==null?(Q.internal=true,e=new I,Q.internal=false):(e=I.zpp_pool,I.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};I.prototype.zpp_inner=null;I.prototype.zpp_i=null;I.prototype.zpp_critical=null;I.prototype.zpp_next=null;I.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=I.zpp_pool,I.zpp_pool=this,this.zpp_inner=null,false)};I.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function E(){this.zpp_inner=null,this.zpp_inner=new Q,this.zpp_inner.outer=this;}E.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E$1(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};E.prototype.zpp_inner=null;Object.defineProperty(E.prototype,"length",{get:function(){return this.zpp_gl()}});E.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};E.prototype.zpp_vm=function(){this.zpp_inner.valmod();};E.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};E.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=n,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(n);else for(;this.zpp_inner.at_index!=n;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return oe(this.zpp_inner.at_ite.elt)};E.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(n.zpp_inner):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)):this.zpp_inner.inner.add(n.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}return this.zpp_inner.invalidate(),oe(n)};E.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}else {n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),oe(n)};E.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};E.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};E.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};E.prototype.empty=function(){return this.zpp_gl()==0};E.prototype.iterator=function(){return this.zpp_vm(),I.get(this)};E.prototype.copy=function(n){n==null&&(n=false);let e=E$1(),t=new e.geom.Vec2List,r=I.get(this);for(;r.hasNext();){let i=r.next(),p;if(n){if(i!=null&&i.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=i.zpp_inner;s._validate!=null&&s._validate();let a=i.zpp_inner.x,c=i.zpp_inner;c._validate!=null&&c._validate();let f=i.zpp_inner.y,u;if(b.poolVec2==null?u=new e.geom.Vec2:(u=b.poolVec2,b.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=false,u==b.nextVec2&&(b.nextVec2=null)),u.zpp_inner==null){let m;l$1.zpp_pool==null?m=new l$1:(m=l$1.zpp_pool,l$1.zpp_pool=m.next,m.next=null),m.weak=false,m._immutable=false,m.x=a,m.y=f,u.zpp_inner=m,u.zpp_inner.outer=u;}else u.zpp_inner.x=a,u.zpp_inner.y=f,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=false,p=u;}else p=i;t.push(p);}return t};E.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");let e=n.iterator();for(;e.hasNext();){let t=e.next();this.has(t)||this.add(t);}};E.prototype.toString=function(){let n="[",e=true,t=I.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};E.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=I.zpp_pool,I.zpp_pool=e,e.zpp_inner=null;break}return this};E.prototype[Symbol.iterator]=function(){let n=I.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};E.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let t=this.at(e);try{n(t)?++e:this.remove(t);}catch{break}}return this};function pe(){if(!M.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}pe.prototype.zpp_inner=null;pe.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=false,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=M.zpp_pool,M.zpp_pool=e;}return n};pe.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr;if(n.wrap==null){let t=n.x,r=n.y;if(t!==t||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let i=E$1(),p;if(b.poolVec2==null?p=new i.geom.Vec2:(p=b.poolVec2,b.poolVec2=p.zpp_pool,p.zpp_pool=null,p.zpp_disp=false,p==b.nextVec2&&(b.nextVec2=null)),p.zpp_inner==null){let s;l$1.zpp_pool==null?s=new l$1:(s=l$1.zpp_pool,l$1.zpp_pool=s.next,s.next=null),s.weak=false,s._immutable=false,s.x=t,s.y=r,p.zpp_inner=s,p.zpp_inner.outer=p;}else {if(p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;if(s._immutable)throw new Error("Error: Vec2 is immutable");s._isimmutable!=null&&s._isimmutable(),s.x==t&&s.y==r||(s.x=t,s.y=r,s._invalidate!=null&&s._invalidate(s));}p.zpp_inner.weak=false,n.wrap=p,n.wrap.zpp_inner._inuse=true,n.wrap.zpp_inner._invalidate=s=>n.modwrap(s),n.wrap.zpp_inner._validate=()=>n.getwrap();}let e=n.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};pe.prototype[Symbol.iterator]=function(){return {_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};var $t=E$1();$t.geom.GeomVertexIterator=pe;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new u,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E$1(),i=new r.dynamics.ContactList;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Y.internal=false;var be=class n{constructor(){if(!D.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof D?G(e,t=>{D.internal=true;let r=new n;return D.internal=false,r.zpp_inner=t,t.outer=r,r}):null:null}get polygon(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.outer_zn}get localNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_lnorm==null&&e.getlnorm(),e.wrap_lnorm}get worldNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_gnorm==null&&e.getgnorm(),e.wrap_gnorm}get length(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.length}get localProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.lprojection}get worldProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");if(e.polygon.body==null)throw new Error("Error: Edge world projection only makes sense for Polygons contained within a rigid body");return e.polygon.validate_gaxi(),e.gprojection}get localVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp0)}get localVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp1)}get worldVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp0)}get worldVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp1)}toString(){let e=this.zpp_inner;return e.polygon==null?"Edge(object-pooled)":e.polygon.body==null?(e.polygon.validate_laxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } }"):(e.polygon.validate_gaxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } worldNormal : { x: "+e.gnormx+" y: "+e.gnormy+" } }")}_wrapVert(e){let t=E$1();if(e.outer==null){e.outer=new t.geom.Vec2;let r=e.outer.zpp_inner;r.outer!=null&&(r.outer.zpp_inner=null,r.outer=null),r._isimmutable=null,r._validate=null,r._invalidate=null,r.next=l$1.zpp_pool,l$1.zpp_pool=r,e.outer.zpp_inner=e;}return e.outer}};D._wrapFn=n=>G(n,e=>{D.internal=true;let t=new be;return D.internal=false,t.zpp_inner=e,e.outer=t,t});var ge=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return a.ValidationResult_VALID==null&&(a.internal=true,a.ValidationResult_VALID=new n,a.internal=false),a.ValidationResult_VALID}static get DEGENERATE(){return a.ValidationResult_DEGENERATE==null&&(a.internal=true,a.ValidationResult_DEGENERATE=new n,a.internal=false),a.ValidationResult_DEGENERATE}static get CONCAVE(){return a.ValidationResult_CONCAVE==null&&(a.internal=true,a.ValidationResult_CONCAVE=new n,a.internal=false),a.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return a.ValidationResult_SELF_INTERSECTING==null&&(a.internal=true,a.ValidationResult_SELF_INTERSECTING=new n,a.internal=false),a.ValidationResult_SELF_INTERSECTING}toString(){return this===a.ValidationResult_VALID?"VALID":this===a.ValidationResult_DEGENERATE?"DEGENERATE":this===a.ValidationResult_CONCAVE?"CONCAVE":this===a.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Qt=E$1();Qt.shape.ValidationResult=ge;var we=class n{get _inner(){return this}constructor(e=false){let t=new v$1;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(true),t.ignore=e);}static _wrap(e){return e instanceof n?e:e?e instanceof v$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}get group(){return this.zpp_inner.group==null?null:this.zpp_inner.group.outer}set group(e){if(e===this)throw new Error("Error: Cannot assign InteractionGroup to itself");this.zpp_inner.setGroup(e==null?null:e.zpp_inner);}get ignore(){return this.zpp_inner.ignore}set ignore(e){this.zpp_inner.ignore!=e&&(this.zpp_inner.invalidate(true),this.zpp_inner.ignore=e);}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=E$1();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,true);}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=E$1();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,true);}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};v$1._wrapFn=n=>G(n,e=>{let t=Object.create(we.prototype);return t.zpp_inner=e,e.outer=t,t});var Ee=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return a.ArbiterType_COLLISION==null&&(a.internal=true,a.ArbiterType_COLLISION=new n,a.internal=false),a.ArbiterType_COLLISION}static get SENSOR(){return a.ArbiterType_SENSOR==null&&(a.internal=true,a.ArbiterType_SENSOR=new n,a.internal=false),a.ArbiterType_SENSOR}static get FLUID(){return a.ArbiterType_FLUID==null&&(a.internal=true,a.ArbiterType_FLUID=new n,a.internal=false),a.ArbiterType_FLUID}toString(){return this===a.ArbiterType_COLLISION?"COLLISION":this===a.ArbiterType_SENSOR?"SENSOR":this===a.ArbiterType_FLUID?"FLUID":""}},Xt=E$1();Xt.dynamics.ArbiterType=Ee;F$1();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!t.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return t.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==t.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==t.FLUID?this.zpp_inner.fluidarb.outer_zn:null}get shape1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer}get shape2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer}get body1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b2.outer:this.zpp_inner.b1.outer}get body2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b1.outer:this.zpp_inner.b2.outer}get state(){this._activeCheck();let e=E$1(),t=this.zpp_inner.immState;return t==5?(a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT):t==1?(a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT_ONCE):t==6?(a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE):(a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==t.COL}isFluidArbiter(){return this.zpp_inner.type==t.FLUID}isSensorArbiter(){return this.zpp_inner.type==t.SENSOR}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),I$1.get(0,0,0)}toString(){let e=this.zpp_inner.type==t.COL?"CollisionArbiter":this.zpp_inner.type==t.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let t$1=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer,r=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer,i=e+"("+t$1.toString()+"|"+r.toString()+")";return this.zpp_inner.type==t.COL&&(i+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),i+="<-"+this.state.toString(),i}_activeCheck(){if(!this.zpp_inner.active)throw new Error("Error: Arbiter not currently in use")}_checkBody(e){let t=this.zpp_inner,r=t.ws1.id>t.ws2.id?t.b2.outer:t.b1.outer,i=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=i)throw new Error("Error: Arbiter does not relate to body")}},en=E$1();en.dynamics.Arbiter=j;var Ve=class extends j{constructor(){super();}get contacts(){return this._activeCheck(),this.zpp_inner.colarb.wrap_contacts==null&&this.zpp_inner.colarb.setupcontacts(),this.zpp_inner.colarb.wrap_contacts}get normal(){return this._activeCheck(),this.zpp_inner.colarb.wrap_normal==null&&this.zpp_inner.colarb.getnormal(),this.zpp_inner.colarb.wrap_normal}get radius(){return this._activeCheck(),this.zpp_inner.colarb.radius}get referenceEdge1(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get referenceEdge2(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get elasticity(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.restitution}set elasticity(e){if(this._mutableCheck("elasticity"),e!==e)throw new Error("Error: CollisionArbiter::elasticity cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::elasticity cannot be negative");this.zpp_inner.colarb.restitution=e,this.zpp_inner.colarb.userdef_restitution=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get dynamicFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.dyn_fric}set dynamicFriction(e){if(this._mutableCheck("dynamicFriction"),e!==e)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be negative");this.zpp_inner.colarb.dyn_fric=e,this.zpp_inner.colarb.userdef_dyn_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get staticFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.stat_fric}set staticFriction(e){if(this._mutableCheck("staticFriction"),e!==e)throw new Error("Error: CollisionArbiter::staticFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::staticFriction cannot be negative");this.zpp_inner.colarb.stat_fric=e,this.zpp_inner.colarb.userdef_stat_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get rollingFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.rfric}set rollingFriction(e){if(this._mutableCheck("rollingFriction"),e!==e)throw new Error("Error: CollisionArbiter::rollingFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::rollingFriction cannot be negative");this.zpp_inner.colarb.rfric=e,this.zpp_inner.colarb.userdef_rfric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}firstVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==-1:false}secondVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==1:false}normalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return !t||r.oc1.fresh?r.oc1.wrapper().rollingImpulse(e):0}_mutableCheck(e){if(!this.zpp_inner.colarb.mutable)throw new Error("Error: CollisionArbiter::"+e+" is only mutable during a pre-handler")}_accumulateImpulse(e,t,r){let i=0,p=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let c=a.oc1.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}if(a.hc2&&(!r||a.oc2.fresh)){let c=a.oc2.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}return I$1.get(i,p,s)}};var Oe=class extends j{constructor(){super();}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),H._wrap(this.zpp_inner.fluidarb.wrap_position)}set position(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e==null)throw new Error("Error: FluidArbiter::position cannot be null");this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),this.zpp_inner.fluidarb.wrap_position.set(e);}get overlap(){return this._activeCheck(),this.zpp_inner.fluidarb.overlap}set overlap(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e!==e)throw new Error("Error: FluidArbiter::overlap cannot be NaN");if(e<=0||e==1/0)throw new Error("Error: FluidArbiter::overlap must be strictly positive and non infinite");this.zpp_inner.fluidarb.overlap=e;}buoyancyImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb;return e==null?I$1.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?I$1.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):I$1.get(-t.buoyx,-t.buoyy,-(t.buoyy*t.r1x-t.buoyx*t.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return I$1.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),i=this.dragImpulse(e),p=r.zpp_inner,s=i.zpp_inner;return p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.x=s.x+p.x,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.y=s.y+p.y,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.z=s.z+p.z,r.dispose(),i}};var Pe=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!u.internal)throw new Error("Error: Cannot instantiate Contact derp!")}get arbiter(){if(this.zpp_inner.arbiter==null)return null;let e=this.zpp_inner.arbiter.outer;return e.zpp_inner.type==t.COL?e.zpp_inner.colarb.outer_zn:null}get penetration(){return this._inactiveCheck(),-this.zpp_inner.dist}get position(){return this._inactiveCheck(),this.zpp_inner.wrap_position==null&&this.zpp_inner.getposition(),H._wrap(this.zpp_inner.wrap_position)}get fresh(){return this._inactiveCheck(),this.zpp_inner.fresh}get friction(){return this._inactiveCheck(),this.zpp_inner.inner.friction}normalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc;return e==null?I$1.get(t.nx*i,t.ny*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.nx*-i,t.ny*-i,-(t.ny*r.r1x-t.nx*r.r1y)*i):I$1.get(t.nx*i,t.ny*i,(t.ny*r.r2x-t.nx*r.r2y)*i))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jtAcc;return e==null?I$1.get(-t.ny*i,t.nx*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.ny*i,-t.nx*i,-(r.r1x*t.nx+r.r1y*t.ny)*i):I$1.get(-t.ny*i,t.nx*i,(r.r2x*t.nx+r.r2y*t.ny)*i))}rollingImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=t.jrAcc;return e==null?r:(this._checkBody(e,t),e==t.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc,p=r.jtAcc,s=t.jrAcc;if(e==null)return I$1.get(t.nx*i-t.ny*p,t.ny*i+t.nx*p,s);this._checkBody(e,t);let a=t.nx*i-t.ny*p,c=t.ny*i+t.nx*p;return e==t.b1.outer?I$1.get(-a,-c,-(c*r.r1x-a*r.r1y)-s):I$1.get(a,c,c*r.r2x-a*r.r2y+s)}toString(){return this.zpp_inner.arbiter==null||this.zpp_inner.arbiter.cleared?"{object-pooled}":"{Contact}"}_inactiveCheck(){if(this.zpp_inner.inactiveme())throw new Error("Error: Contact not currently in use")}_checkBody(e,t){if(e!=t.b1.outer&&e!=t.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};u._wrapFn=n=>{u.internal=true;let e=new Pe;return u.internal=false,e.zpp_inner=n,n.outer=e,e};function tn(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function V(n){return n.valmod(),n.zip_length&&(n.zip_length=false,n.user_length=tn(n)),n.user_length}function v(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}v.zpp_pool=null;v.get=function(n){let e;return v.zpp_pool==null?(Y.internal=true,e=new v,Y.internal=false):(e=v.zpp_pool,v.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};v.prototype.zpp_inner=null;v.prototype.zpp_i=null;v.prototype.zpp_critical=null;v.prototype.zpp_next=null;v.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=V(this.zpp_inner.zpp_inner);return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=v.zpp_pool,v.zpp_pool=this,this.zpp_inner=null,false)};v.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function A(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this;}A.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E$1(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};A.prototype.zpp_inner=null;Object.defineProperty(A.prototype,"length",{get:function(){return V(this.zpp_inner)}});A.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};A.prototype.at=function(n){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=V(this.zpp_inner)-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)for(this.zpp_inner.at_index=0,this.zpp_inner.at_ite=this.zpp_inner.inner.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}for(;this.zpp_inner.at_index!=n;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}return this.zpp_inner.at_ite.wrapper()};A.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(n.zpp_inner);else {if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}else this.zpp_inner.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}else {e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};A.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=false,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};A.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift();};A.prototype.empty=function(){return V(this.zpp_inner)==0};A.prototype.iterator=function(){return this.zpp_inner.valmod(),v.get(this)};A.prototype.copy=function(n){n==null&&(n=false);let e=E$1(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=v.get(this);for(;r.hasNext();){let i=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(i);}return t};A.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=v.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t));}};A.prototype.toString=function(){let n="[",e=true;this.zpp_inner.valmod();let t=v.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};A.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=v.get(this);for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=v.zpp_pool,v.zpp_pool=e,e.zpp_inner=null;break}return this};A.prototype[Symbol.iterator]=function(){let n=v.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};A.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=V(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r);}catch{break}}return this};var C=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return a.CbEvent_BEGIN==null&&(a.internal=true,a.CbEvent_BEGIN=new n,a.internal=false),a.CbEvent_BEGIN}static get ONGOING(){return a.CbEvent_ONGOING==null&&(a.internal=true,a.CbEvent_ONGOING=new n,a.internal=false),a.CbEvent_ONGOING}static get END(){return a.CbEvent_END==null&&(a.internal=true,a.CbEvent_END=new n,a.internal=false),a.CbEvent_END}static get WAKE(){return a.CbEvent_WAKE==null&&(a.internal=true,a.CbEvent_WAKE=new n,a.internal=false),a.CbEvent_WAKE}static get SLEEP(){return a.CbEvent_SLEEP==null&&(a.internal=true,a.CbEvent_SLEEP=new n,a.internal=false),a.CbEvent_SLEEP}static get BREAK(){return a.CbEvent_BREAK==null&&(a.internal=true,a.CbEvent_BREAK=new n,a.internal=false),a.CbEvent_BREAK}static get PRE(){return a.CbEvent_PRE==null&&(a.internal=true,a.CbEvent_PRE=new n,a.internal=false),a.CbEvent_PRE}toString(){return this===a.CbEvent_BEGIN?"BEGIN":this===a.CbEvent_ONGOING?"ONGOING":this===a.CbEvent_END?"END":this===a.CbEvent_WAKE?"WAKE":this===a.CbEvent_SLEEP?"SLEEP":this===a.CbEvent_BREAK?"BREAK":this===a.CbEvent_PRE?"PRE":""}},nn=E$1();nn.callbacks.CbEvent=C;F$1();var Ce=class n{get _inner(){return this}constructor(){this.zpp_inner=new e,this.zpp_inner.outer=this;}static get ANY_BODY(){return e.ANY_BODY}static get ANY_CONSTRAINT(){return e.ANY_CONSTRAINT}static get ANY_SHAPE(){return e.ANY_SHAPE}static get ANY_COMPOUND(){return e.ANY_COMPOUND}get id(){return this.zpp_inner.id}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}get interactors(){return this.zpp_inner.wrap_interactors==null&&(this.zpp_inner.wrap_interactors=Z$1.get(this.zpp_inner.interactors,true)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=Y$1.get(this.zpp_inner.constraints,true)),this.zpp_inner.wrap_constraints}including(e){return new(E$1()).callbacks.OptionType(this).including(e)}excluding(e){return new(E$1()).callbacks.OptionType(this).excluding(e)}toString(){return this===e.ANY_BODY?"ANY_BODY":this===e.ANY_SHAPE?"ANY_SHAPE":this===e.ANY_COMPOUND?"ANY_COMPOUND":this===e.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e$1){return e$1 instanceof n?e$1:e$1?e$1 instanceof e?G(e$1,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e$1.zpp_inner?n._wrap(e$1.zpp_inner):null:null}},rn=E$1();rn.callbacks.CbType=Ce;F$1();var Z=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return a.InteractionType_COLLISION==null&&(a.internal=true,a.InteractionType_COLLISION=new n,a.internal=false),a.InteractionType_COLLISION}static get SENSOR(){return a.InteractionType_SENSOR==null&&(a.internal=true,a.InteractionType_SENSOR=new n,a.internal=false),a.InteractionType_SENSOR}static get FLUID(){return a.InteractionType_FLUID==null&&(a.internal=true,a.InteractionType_FLUID=new n,a.internal=false),a.InteractionType_FLUID}static get ANY(){return a.InteractionType_ANY==null&&(a.internal=true,a.InteractionType_ANY=new n,a.internal=false),a.InteractionType_ANY}toString(){return this===a.InteractionType_COLLISION?"COLLISION":this===a.InteractionType_SENSOR?"SENSOR":this===a.InteractionType_FLUID?"FLUID":this===a.InteractionType_ANY?"ANY":""}},on=E$1();on.callbacks.InteractionType=Z;var W=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new n,a.internal=false),a.PreFlag_ACCEPT}static get IGNORE(){return a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new n,a.internal=false),a.PreFlag_IGNORE}static get ACCEPT_ONCE(){return a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new n,a.internal=false),a.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new n,a.internal=false),a.PreFlag_IGNORE_ONCE}toString(){return this===a.PreFlag_ACCEPT?"ACCEPT":this===a.PreFlag_IGNORE?"IGNORE":this===a.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===a.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},pn=E$1();pn.callbacks.PreFlag=W;var xe=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new j$1,this.zpp_inner.outer=this,e!=null&&this.including(e),t!=null&&this.excluding(t);}get includes(){return this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes(),this.zpp_inner.wrap_includes}get excludes(){return this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes(),this.zpp_inner.wrap_excludes}including(e){return this.zpp_inner.append(this.zpp_inner.includes,e),this}excluding(e){return this.zpp_inner.append(this.zpp_inner.excludes,e),this}toString(){this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes();let e=this.zpp_inner.wrap_includes.toString();this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes();let t=this.zpp_inner.wrap_excludes.toString();return "@{"+e+" excluding "+t+"}"}static _wrap(e){return e instanceof n?e:e?e instanceof j$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},sn=E$1();sn.callbacks.OptionType=xe;function an(n){return n===C.BEGIN?0:n===C.END?1:n===C.WAKE?2:n===C.SLEEP?3:n===C.BREAK?4:n===C.PRE?5:n===C.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!f.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null;}static _wrap(e){return e instanceof n?e:e&&e instanceof f?G(e,t=>{if(t.outer)return t.outer;let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):null}get type(){return f.types[this.zpp_inner.type]}get event(){return f.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(f.events[this.zpp_inner.event]!=e){let t=an(e);this.zpp_inner.swapEvent(t);}}get precedence(){return this.zpp_inner.precedence}set precedence(e){this.zpp_inner.precedence!=e&&(this.zpp_inner.precedence=e,this.zpp_inner.invalidate_precedence());}get space(){return this.zpp_inner.space==null?null:X$1._wrap(this.zpp_inner.space.outer)}set space(e){let t=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=t)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),t!=null){let i=t.zpp_inner.wrap_listeners;i.zpp_inner.reverse_flag?i.push(this):i.unshift(this);}else this.zpp_inner.space=null;}toString(){let t=["BEGIN","END","WAKE","SLEEP","BREAK","PRE","ONGOING"][this.zpp_inner.event];if(this.zpp_inner.type==0){let r=this.zpp_inner.body;return "BodyListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return "ConstraintListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else {let r=this.zpp_inner.interaction,i;switch(r.itype){case 1:i="COLLISION";break;case 2:i="SENSOR";break;case 4:i="FLUID";break;default:i="ALL";}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+i+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+i+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var ve=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return a.ListenerType_BODY==null&&(a.internal=true,a.ListenerType_BODY=new n,a.internal=false),a.ListenerType_BODY}static get CONSTRAINT(){return a.ListenerType_CONSTRAINT==null&&(a.internal=true,a.ListenerType_CONSTRAINT=new n,a.internal=false),a.ListenerType_CONSTRAINT}static get INTERACTION(){return a.ListenerType_INTERACTION==null&&(a.internal=true,a.ListenerType_INTERACTION=new n,a.internal=false),a.ListenerType_INTERACTION}static get PRE(){return a.ListenerType_PRE==null&&(a.internal=true,a.ListenerType_PRE=new n,a.internal=false),a.ListenerType_PRE}toString(){return this===a.ListenerType_BODY?"BODY":this===a.ListenerType_CONSTRAINT?"CONSTRAINT":this===a.ListenerType_INTERACTION?"INTERACTION":this===a.ListenerType_PRE?"PRE":""}},ln=E$1();ln.callbacks.ListenerType=ve;F$1();var F=class{constructor(){this.zpp_inner=null;if(!d.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return f.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return ""}};var Re=class extends F{get body(){return this.zpp_inner.body.outer}toString(){return "Cb:"+["WAKE","SLEEP"][this.zpp_inner.event-2]+":"+this.zpp_inner.body.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var ke=class extends F{get constraint(){return this.zpp_inner.constraint.outer}toString(){return "Cb:"+["WAKE","SLEEP","BREAK"][this.zpp_inner.event-2]+":"+this.zpp_inner.constraint.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Be=class extends F{get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get arbiters(){return this.zpp_inner.wrap_arbiters}toString(){return "Cb:"+["BEGIN","END","","","","","ONGOING"][this.zpp_inner.event]+":"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.wrap_arbiters.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Fe=class extends F{get arbiter(){return this.zpp_inner.pre_arbiter.wrapper()}get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get swapped(){return this.zpp_inner.pre_swapped}toString(){return "Cb:PRE::"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.pre_arbiter.wrapper().toString()+" : listnener: "+String(this.zpp_inner.listener.outer)}};var Ge=class extends B{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: BodyListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new g(j$1.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: BodyListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};var De=class extends B{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else if(e===C.BREAK)p=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new h(j$1.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: ConstraintListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};function Me(n){return n===Z.COLLISION?1:n===Z.SENSOR?2:n===Z.FLUID?4:7}function se(n){return n==1?Z.COLLISION:n==2?Z.SENSOR:n==4?Z.FLUID:n==7?Z.ANY:null}var Ue=class extends B{constructor(e,t,r,i$1,p,s=0){if(f.internal=true,super(),f.internal=false,p==null)throw new Error("Error: InteractionListener::handler cannot be null");if(e==null)throw new Error("Error: CbEvent cannot be null for InteractionListener");let a;if(e===C.BEGIN)a=0;else if(e===C.END)a=1;else if(e===C.ONGOING)a=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new i(j$1.argument(r),j$1.argument(i$1),a,2),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zni=this,this.zpp_inner.precedence=s,this.zpp_inner_zn.handleri=p,t==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Me(t));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handleri}set handler(e){if(e==null)throw new Error("Error: InteractionListener::handler cannot be null");this.zpp_inner_zn.handleri=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e;}};var ae=class extends B{constructor(e,t,r,i$1,p=0,s=false){if(f.internal=true,super(),f.internal=false,i$1==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new i(j$1.argument(t),j$1.argument(r),5,3),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_znp=this,this.zpp_inner.precedence=p,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=i$1,e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handlerp}set handler(e){if(e==null)throw new Error("Error: PreListener must take a non-null handler!");this.zpp_inner_zn.handlerp=e,this.zpp_inner_zn.wake();}get pure(){return this.zpp_inner_zn.pure}set pure(e){e||this.zpp_inner_zn.wake(),this.zpp_inner_zn.pure=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}};var We=class n extends ka{constructor(e,t=false){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r$1=new r(e,t);this.zpp_inner=r$1,r$1.outer=this,r$1.outer_zn=this;}static _wrap(e){return e==null?null:e instanceof n?e:e.zpp_inner?.outer instanceof n?e.zpp_inner.outer:G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new H;return e.zpp_inner._inuse=true,e.zpp_inner._invalidate=this.zpp_inner.bindVec2_invalidate.bind(this.zpp_inner),e}__copy(){throw new Error("Error: UserConstraint::__copy must be overriden")}__broken(){}__validate(){}__draw(e){}__prepare(){}__position(e){throw new Error("Error: UserConstraint::__position must be overriden")}__velocity(e){throw new Error("Error: Userconstraint::__velocity must be overriden")}__eff_mass(e){throw new Error("Error: UserConstraint::__eff_mass must be overriden")}__clamp(e){}__impulse(e,t,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,t=new J(e,1);for(let r=0;r<e;r++){if(r<0||r>=t.zpp_inner.m||0>=t.zpp_inner.n)throw new Error("Error: MatMN indices out of range");t.zpp_inner.x[r*t.zpp_inner.n]=this.zpp_inner.jAcc[r];}return t}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let t=false;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=true;break}if(!t)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):I$1.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let i=this.zpp_inner.bodies[r];if(i.body!=null){let p=false;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==i.body){p=true;break}p||e(i.body.outer);}++r;}}__invalidate(){this.zpp_inner.immutable_midstep("UserConstraint::invalidate()"),this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&this.zpp_inner.wake();}__registerBody(e,t){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=t){if(e!=null){if(!this.zpp_inner.remBody(e.zpp_inner))throw new Error("Error: oldBody is not registered to the cosntraint");this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&e.zpp_inner.wake();}t!=null&&this.zpp_inner.addBody(t.zpp_inner),this.zpp_inner.wake(),t?.zpp_inner.wake();}return t}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e;}};function O(n){let{typeName:e,namespaceParts:t,zppListClass:r,wrapElement:i,unwrapElement:p}=n,s=E$1(),a=s.__zpp,c=()=>a.util[r],f=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!c().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=c();return u.zpp_pool==null?(b.internal=true,h=new u,b.internal=false):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=false,h},u.prototype.zpp_inner=null,u.prototype.zpp_i=null,u.prototype.zpp_critical=null,u.prototype.zpp_next=null,u.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let _=this.zpp_inner;_.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=true,this.zpp_i<h?true:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,false)},u.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(c()),this.zpp_inner.outer=this;}m.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new m;for(let b=0;b<_.length;b++)h.push(_[b]);return h},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function y(_){return _.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return y(this)}}),m.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(p(_))},m.prototype.at=function(_){if(this.zpp_inner.valmod(),_<0||_>=y(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(_=y(this)-1-_),_<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=_,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(_);else for(;this.zpp_inner.at_index!=_;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return i(this.zpp_inner.at_ite.elt)},m.prototype.push=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(p(_)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.unshift=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))):this.zpp_inner.inner.add(p(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}return this.zpp_inner.invalidate(),i(_)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}else {_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),i(_)},m.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},m.prototype.remove=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=false,b=this.zpp_inner.inner.head,G=p(_);for(;b!=null;){if(b.elt==G){h=true;break}b=b.next;}return h&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(_),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(G),this.zpp_inner.invalidate()),h},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift();},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},m.prototype.copy=function(_){_==null&&(_=false);let h=new m,b=u.get(this);for(;b.hasNext();){let G=b.next();if(_)throw new Error("Error: "+e+" is not a copyable type");h.push(G);}return h},m.prototype.merge=function(_){if(_==null)throw new Error("Error: Cannot merge with null list");let h=u.get(_);for(;h.hasNext();){let b=h.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b));}},m.prototype.toString=function(){let _="[",h=true,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=false;}return _+"]"},m.prototype.foreach=function(_){if(_==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let h=u.get(this);for(;h.hasNext();)try{_(h.next());}catch{h.zpp_next=u.zpp_pool,u.zpp_pool=h,h.zpp_inner=null;break}return this},m.prototype.filter=function(_){if(_==null)throw new Error("Error: Cannot select elements of list with null");let h=0;for(;h<y(this);){let b=this.at(h);try{_(b)?++h:this.remove(b);}catch{break}}return this},m.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},m.prototype[Symbol.iterator]=function(){let _=u.get(this);return {next(){return _.hasNext()?{value:_.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};let g=f(),R=e+"Iterator",J=e+"List";return g[R]=u,g[J]=m,{Iterator:u,List:m}}var X=n=>n.outer,K=n=>n.zpp_inner??(n._inner?n._inner.zpp_inner??n._inner:n);O({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:X,unwrapElement:K});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:X,unwrapElement:K});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:X,unwrapElement:K});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:X,unwrapElement:K});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:X,unwrapElement:K});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:X,unwrapElement:K});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:X,unwrapElement:K});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:X,unwrapElement:K});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:n=>n.outer_i,unwrapElement:n=>n.zpp_inner_i});function le(n){if(n.outer==null){let e=E$1();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l$1.zpp_pool,l$1.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=false,this._length=0,this.inner=null,E.call(this),this.at_ite=null,this.at_index=0,this.zip_length=true,this._length=0;}for(let n in E.prototype)L.prototype[n]=E.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:true});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=false;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=false);let t=new L;return t.inner=n,t.zpp_inner.immutable=e,t};L.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let n=this.inner.next;for(;n!=null;)this._length++,n=n.next;this.zip_length=false;}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=true,this._length=0,this.at_ite=null);};L.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),(n<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==n;)this.at_index++,this.at_ite=this.at_ite.next;return le(this.at_ite)};L.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(n.zpp_inner);else {let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}else this.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}else {this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}return this.zpp_inner.invalidate(),le(n)};L.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}else {n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}return this.zpp_inner.invalidate(),le(n)};L.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};L.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};var _n=E$1(),un=_n.__zpp;un.util.ZPP_MixVec2List=L;var z=E$1();z.Config=Object.assign(z.Config||{},Pt);z.util.Debug=Xe;z.geom.Vec2=H;z.geom.Vec3=I$1;z.geom.Mat23=fe;z.geom.MatMN=J;z.geom.AABB=K$1;z.geom.Winding=L$1;z.geom.Ray=q;z.geom.ConvexResult=ze;z.geom.RayResult=de;z.geom.Geom=Se;z.geom.GeomPoly=N;z.geom.MarchingSquares=Ze;z.geom.Vec2Iterator=I;z.geom.Vec2List=E;z.geom.GeomVertexIterator=pe;z.__zpp.geom.ZPP_GeomVertexIterator=M;z.__zpp.util.ZPP_ContactList=Y;z.phys.Interactor=R;z.phys.Body=_;O$1(n=>_._wrap(n));z.phys.BodyType=$;z.phys.Compound=aa;Q$1(n=>aa._wrap(n));z.phys.FluidProperties=T;z.phys.Material=ba;z.phys.GravMassMode=ca;z.phys.InertiaMode=da;z.phys.MassMode=ea;z.shape.Shape=V$1;P(n=>V$1._wrap(n));z.shape.Circle=fa;z.shape.Polygon=ga;z.shape.Capsule=ha;z.shape.Edge=be;z.shape.ShapeType=U;z.shape.ValidationResult=ge;z.space.Space=X$1;z.space.Broadphase=ia;z.dynamics.InteractionFilter=ja;z.dynamics.InteractionGroup=we;z.dynamics.ArbiterType=Ee;z.dynamics.Arbiter=j;t._createColArb=()=>new Ve;t._createFluidArb=()=>new Oe;z.dynamics.Contact=Pe;z.dynamics.ContactIterator=v;z.dynamics.ContactList=A;z.callbacks.CbEvent=C;z.callbacks.CbType=Ce;z.callbacks.InteractionType=Z;z.callbacks.PreFlag=W;z.callbacks.OptionType=xe;z.callbacks.Listener=B;z.callbacks.ListenerType=ve;z.callbacks.Callback=F;d._createBodyCb=()=>new Re;d._createConCb=()=>new ke;d._createIntCb=()=>new Be;d._createPreCb=()=>new Fe;z.callbacks.BodyListener=Ge;z.callbacks.ConstraintListener=De;z.callbacks.InteractionListener=Ue;z.callbacks.PreListener=ae;z.constraint.Constraint=ka;k._createFn=(...n)=>new la(...n);m._createFn=(...n)=>new ma(...n);n._createFn=(...n)=>new na(...n);o._createFn=(...n)=>new oa(...n);p._createFn=(...n)=>new pa(...n);q$1._createFn=(...n)=>new qa(...n);s._createFn=(...n)=>new ra(...n);z.constraint.UserConstraint=We;var Ct=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,i){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,i){}drawSolidCapsule(e,t,r,i){}drawPoint(e,t){}};function hn(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof N){if(n.zpp_disp)throw new Error("Error: GeomPoly has been disposed and cannot be used!");t=n.copy();}else {if(!Array.isArray(n))throw new Error("Error: vertices must be an Array<Vec2> or GeomPoly");if(n.length<3)throw new Error("Error: At least 3 vertices are required, got "+n.length);for(let f=0;f<n.length;f++)if(n[f]==null)throw new Error("Error: vertices["+f+"] is null");t=new N(n);}if(t.size()<3)throw t.dispose(),new Error("Error: At least 3 vertices are required, got "+t.size());if(t.isDegenerate())throw t.dispose(),new Error("Error: Polygon is degenerate (zero area)");if(!t.isSimple())throw t.dispose(),new Error("Error: Polygon is self-intersecting");let r=e?.simplify??0;if(r>0){let f=t.simplify(r);if(t.dispose(),t=f,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let f=[],u=t.forwardIterator();for(;u.hasNext();){let m=u.next();f.push(H.get(m.x,m.y));}t.dispose(),f.reverse(),t=new N(f);}let i=e?.material,p=e?.filter,s=e?.delaunay??false,a=new _(e?.type??$.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new ga(t,i,p)),t.dispose(),a;let c=t.convexDecomposition(s);for(let f of c)a.shapes.add(new ga(f,i,p));return t.dispose(),a}var xt=class{constructor(e,t,r={}){this._oneWayListener=null;this._grounded=false;this._groundNormal=null;this._groundBody=null;this._onMovingPlatform=false;this._slopeAngle=0;this._wallLeft=false;this._wallRight=false;this._timeSinceGrounded=0;this.space=e,this.body=t,this._maxSlopeAngle=r.maxSlopeAngle??Math.PI/4,this._maxSlopeCos=Math.cos(this._maxSlopeAngle);let i=256;if(r.filter)this._filter=r.filter;else {let p=t.shapes;for(let s=0;s<p.length;s++){let c=p.at(s).filter;c.collisionGroup=c.collisionGroup|i;}this._filter=new ja(1,~i);}r.oneWayPlatformTag&&r.characterTag&&this._setupOneWayPlatforms(r.oneWayPlatformTag,r.characterTag);}get grounded(){return this._grounded}get groundNormal(){return this._groundNormal}get groundBody(){return this._groundBody}get timeSinceGrounded(){return this._timeSinceGrounded}get maxSlopeAngle(){return this._maxSlopeAngle}set maxSlopeAngle(e){this._maxSlopeAngle=e,this._maxSlopeCos=Math.cos(e);}setVelocity(e,t){this.body.velocity=new H(e,t);}update(){this._wallLeft=false,this._wallRight=false;let e=this.body.position.x,t=this.body.position.y;return this._detectGround(e,t),this._detectWalls(e,t),this._grounded&&this._groundBody?this._onMovingPlatform=this._groundBody.type===$.KINEMATIC:this._onMovingPlatform=false,this._grounded?this._timeSinceGrounded=0:this._timeSinceGrounded+=1/60,{grounded:this._grounded,groundNormal:this._groundNormal,groundBody:this._groundBody,onMovingPlatform:this._onMovingPlatform,slopeAngle:this._slopeAngle,wallLeft:this._wallLeft,wallRight:this._wallRight,timeSinceGrounded:this._timeSinceGrounded}}destroy(){this._oneWayListener&&(this._oneWayListener.space=null,this._oneWayListener=null);}_detectGround(e,t){let i=this._getCharacterRadius(0,1)+4,p=new q(new H(e,t),new H(0,1));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);if(s&&s.distance<=i){let a=s.normal.y;if(a<0){let c=-a;if(c>=this._maxSlopeCos){this._grounded=true,this._groundNormal=new H(s.normal.x,s.normal.y),this._groundBody=s.shape?.body??null,this._slopeAngle=Math.acos(Math.min(1,c));return}}}this._grounded=false,this._groundNormal=null,this._groundBody=null,this._slopeAngle=0;}_detectWalls(e,t){let i=this._getCharacterRadius(1,0)+2,p=new q(new H(e,t),new H(-1,0));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);s&&s.distance<=i&&Math.abs(s.normal.x)>.7&&(this._wallLeft=true);let a=new q(new H(e,t),new H(1,0));a.maxDistance=i;let c=this.space.rayCast(a,false,this._filter);c&&c.distance<=i&&Math.abs(c.normal.x)>.7&&(this._wallRight=true);}_setupOneWayPlatforms(e,t){let r=new ae(Z.COLLISION,e,t,i=>{try{let p=i.arbiter.collisionArbiter;if(!p)return W.ACCEPT;let s=p.normal.y,a=i.swapped;return s>0!==a?W.IGNORE:W.ACCEPT}catch{return W.ACCEPT}},0,true);r.space=this.space,this._oneWayListener=r;}_getCharacterRadius(e,t){let r=this.body.shapes.at(0);if(!r)return 0;if(r.isCircle())return r.castCircle?.radius??0;if(r.isCapsule()){let a=r.castCapsule;if(a){let c=a.radius,f=a.halfLength,u=this.body.rotation,m=Math.cos(u),y=Math.sin(u);return Math.abs(e*m+t*y)*f+c}}let i=r.bounds,p=i.width/2,s=i.height/2;return Math.abs(e)*p+Math.abs(t)*s}};var Xp="3.19.0";export{j as Arbiter,Ee as ArbiterType,Re as BodyCallback,Ge as BodyListener,F as Callback,C as CbEvent,Ce as CbType,xt as CharacterController,Ve as CollisionArbiter,ke as ConstraintCallback,De as ConstraintListener,Pe as Contact,ze as ConvexResult,Ct as DebugDraw,be as Edge,Oe as FluidArbiter,Se as Geom,Be as InteractionCallback,we as InteractionGroup,Ue as InteractionListener,Z as InteractionType,B as Listener,ve as ListenerType,Ze as MarchingSquares,fe as Mat23,xe as OptionType,Fe as PreCallback,W as PreFlag,ae as PreListener,q as Ray,de as RayResult,We as UserConstraint,Xp as VERSION,ge as ValidationResult,hn as createConcaveBody};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {E as E$1,A as A$1,G,x,b,l as l$1,D,v as v$1,F as F$1,u,H,I as I$1,J,K as K$1,L as L$1,N,M,R,_,O as O$1,$,aa,Q as Q$1,T,ba,ca,da,ea,V as V$1,P,fa,ga,ha,U,X as X$1,ia,ja,t,d,ka,la,k,ma,m,na,n,oa,o,pa,p,qa,q as q$1,ra,s,a,e,Z as Z$1,Y as Y$1,j as j$1,B as B$1,y,C as C$1,w,z as z$1,f,g,h,i,r,c}from'./chunk-SNMC46IS.js';export{K as AABB,la as AngleJoint,_ as Body,$ as BodyType,ia as Broadphase,ha as Capsule,fa as Circle,aa as Compound,ka as Constraint,W as DebugDrawFlags,ma as DistanceJoint,T as FluidProperties,N as GeomPoly,ca as GravMassMode,da as InertiaMode,ja as InteractionFilter,R as Interactor,na as LineJoint,ea as MassMode,J as MatMN,ba as Material,oa as MotorJoint,S as NapeList,pa as PivotJoint,ga as Polygon,qa as PulleyJoint,V as Shape,U as ShapeType,X as Space,H as Vec2,I as Vec3,ra as WeldJoint,L as Winding}from'./chunk-SNMC46IS.js';var Pt={epsilon:1e-8,fluidAngularDragFriction:2.5,fluidAngularDrag:100,fluidVacuumDrag:.5,fluidLinearDrag:.5,collisionSlop:.2,collisionSlopCCD:.5,distanceThresholdCCD:.05,staticCCDLinearThreshold:.05,staticCCDAngularThreshold:.005,bulletCCDLinearThreshold:.125,bulletCCDAngularThreshold:.0125,dynamicSweepLinearThreshold:17,dynamicSweepAngularThreshold:.6,angularCCDSlipScale:.75,arbiterExpirationDelay:6,staticFrictionThreshold:2,elasticThreshold:20,sleepDelay:60,linearSleepThreshold:.2,angularSleepThreshold:.4,contactBiasCoef:.3,contactStaticBiasCoef:.6,contactContinuousBiasCoef:.4,contactContinuousStaticBiasCoef:.5,constraintLinearSlop:.1,constraintAngularSlop:.001,illConditionedThreshold:2e8},jt=E$1();jt.Config=Object.assign(jt.Config||{},Pt);function l(n,e,t){for(;n[e]!=null;){let r=n[e][t];n[e][t]=null,n[e]=r;}}var Xe=class{static version(){return "Nape 2.0.19"}static clearObjectPools(){let e=E$1(),t=e.__zpp;l(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),l(e.phys.InteractorIterator,"zpp_pool","zpp_next"),l(e.phys.BodyIterator,"zpp_pool","zpp_next"),l(e.phys.CompoundIterator,"zpp_pool","zpp_next"),l(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),l(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),l(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),l(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),l(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),l(e.geom.RayResultIterator,"zpp_pool","zpp_next"),l(e.shape.ShapeIterator,"zpp_pool","zpp_next"),l(e.shape.EdgeIterator,"zpp_pool","zpp_next"),l(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),l(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),l(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),l(t.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Body,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Component,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),l(t.util.ZNPNode_ConvexResult,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),l(t.util.ZNPNode_RayResult,"zpp_pool","next"),l(t.phys.ZPP_Material,"zpp_pool","next"),l(t.phys.ZPP_FluidProperties,"zpp_pool","next"),l(t.callbacks.ZPP_CbSetPair,"zpp_pool","next"),l(t.callbacks.ZPP_Callback,"zpp_pool","next"),l(t.callbacks.ZPP_CbSet,"zpp_pool","next"),l(t.geom.ZPP_GeomVert,"zpp_pool","next"),l(t.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),l(t.geom.ZPP_Mat23,"zpp_pool","next"),l(t.geom.ZPP_CutVert,"zpp_pool","next"),l(t.geom.ZPP_CutInt,"zpp_pool","next"),l(t.geom.ZPP_Vec2,"zpp_pool","next"),l(t.geom.ZPP_PartitionVertex,"zpp_pool","next"),l(t.geom.ZPP_SimplifyV,"zpp_pool","next"),l(t.geom.ZPP_SimplifyP,"zpp_pool","next"),l(t.geom.ZPP_PartitionedPoly,"zpp_pool","next"),l(t.geom.ZPP_PartitionPair,"zpp_pool","next"),l(t.geom.ZPP_AABB,"zpp_pool","next"),l(t.geom.ZPP_SimpleVert,"zpp_pool","next"),l(t.geom.ZPP_SimpleSeg,"zpp_pool","next"),l(t.geom.ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.Hashable2_Boolfalse,"zpp_pool","next"),l(t.geom.ZPP_ToiEvent,"zpp_pool","next"),l(t.geom.ZPP_MarchSpan,"zpp_pool","next"),l(t.geom.ZPP_MarchPair,"zpp_pool","next"),l(t.shape.ZPP_Edge,"zpp_pool","next"),l(t.space.ZPP_SweepData,"zpp_pool","next"),l(t.space.ZPP_AABBNode,"zpp_pool","next"),l(t.space.ZPP_AABBPair,"zpp_pool","next"),l(t.dynamics.ZPP_Contact,"zpp_pool","next"),l(t.space.ZPP_Island,"zpp_pool","next"),l(t.space.ZPP_Component,"zpp_pool","next"),l(t.space.ZPP_CallbackSet,"zpp_pool","next"),l(t.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_ColArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec2","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec3","zpp_pool");}};var fe=class n{get _inner(){return this}constructor(e=1,t=0,r=0,i=1,p=0,s=0){let a=A$1.get();this.zpp_inner=a,a.outer=this;let c=["a","b","tx","c","d","ty"],f=[e,t,p,r,i,s];for(let u=0;u<f.length;u++)if(f[u]!==f[u])throw new Error("Error: Mat23::"+c[u]+" cannot be NaN");a.setas(e,t,r,i,p,s);}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let t=Math.cos(e),r=Math.sin(e);return new n(t,-r,r,t,0,0)}static translation(e,t){return new n(1,0,0,1,e,t)}static scale(e,t){return new n(e,0,0,t,0,0)}static _wrap(e){return e instanceof n?e:e?e instanceof A$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}_setProp(e,t){if(t!==t)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=t,this.zpp_inner.invalidate();}get a(){return this.zpp_inner.a}set a(e){this._setProp("a",e);}get b(){return this.zpp_inner.b}set b(e){this._setProp("b",e);}get c(){return this.zpp_inner.c}set c(e){this._setProp("c",e);}get d(){return this.zpp_inner.d}set d(e){this._setProp("d",e);}get tx(){return this.zpp_inner.tx}set tx(e){this._setProp("tx",e);}get ty(){return this.zpp_inner.ty}set ty(e){this._setProp("ty",e);}get determinant(){return this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c}clone(){return this.copy()}equals(e,t=0){if(e==null)return false;let r=this.zpp_inner,i=e.zpp_inner,p=r.a-i.a,s=r.b-i.b,a=r.c-i.c,c=r.d-i.d,f=r.tx-i.tx,u=r.ty-i.ty;return (p<0?-p:p)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(c<0?-c:c)<=t&&(f<0?-f:f)<=t&&(u<0?-u:u)<=t}copy(){return new n(this.zpp_inner.a,this.zpp_inner.b,this.zpp_inner.c,this.zpp_inner.d,this.zpp_inner.tx,this.zpp_inner.ty)}set(e){if(e==null)throw new Error("Error: Cannot set form null matrix");let t=e.zpp_inner;return this.zpp_inner.setas(t.a,t.b,t.c,t.d,t.tx,t.ty),this.zpp_inner.invalidate(),this}setAs(e=1,t=0,r=0,i=1,p=0,s=0){return this.zpp_inner.setas(e,t,r,i,p,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=e*e+t*t+r*r+i*i,s=e*i-t*r;s<0&&(s=-s);let a=E$1();return p>a.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner,a=1/(e*i-t*r);return new n(i*a,-t*a,-r*a,e*a,(t*s-i*p)*a,(r*p-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return new n(e,r,t,i,-e*p-r*s,-t*p-i*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let t=e.zpp_inner,r=this.zpp_inner;return new n(t.a*r.a+t.b*r.c,t.a*r.b+t.b*r.d,t.c*r.a+t.d*r.c,t.c*r.b+t.d*r.d,t.a*r.tx+t.b*r.ty+t.tx,t.c*r.tx+t.d*r.ty+t.ty)}transform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");e.zpp_inner.validate();let i=e.zpp_inner.x,p=e.zpp_inner.y,{a:s,b:a,c,d:f,tx:u,ty:m}=this.zpp_inner,y,g;t?(y=i*s+p*a,g=i*c+p*f):(y=i*s+p*a+u,g=i*c+p*f+m);let R=H.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");if(this.singular())throw new Error("Error: Matrix is singular and inverse transformation cannot be performed");let{a:i,b:p,c:s,d:a,tx:c,ty:f}=this.zpp_inner,u=1/(i*a-p*s);e.zpp_inner.validate();let m=e.zpp_inner.x,y=e.zpp_inner.y,g,R;if(t)g=(m*a-y*p)*u,R=(y*i-m*s)*u;else {let _=m-c,h=y-f;g=(_*a-h*p)*u,R=(h*i-_*s)*u;}let J=H.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),J}equiorthogonal(){if(this.singular())return false;let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=E$1(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-r*r-i*i;return a*a<p.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=E$1(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-1,c=r*r+i*i-1;return a*a<p.Config.epsilon&&c*c<p.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:i,d:p}=this.zpp_inner,s=E$1(),a=Math.sqrt(t*t+i*i),c=Math.sqrt(r*r+p*p);if(a*a<s.Config.epsilon||c*c<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let f=e?(a+c)/2:1;a=f/a,c=f/c,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*c,this.d=this.zpp_inner.d*c;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(u/(f*f));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let y=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*y,J=this.zpp_inner.b*g+this.zpp_inner.d*y,_=this.zpp_inner.c*g+this.zpp_inner.a*y,h=this.zpp_inner.d*g-this.zpp_inner.b*y;return this.c=_,this.a=R,this.d=h,this.b=J,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(true)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(false)}toString(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return "{ a: "+e+" b: "+t+" c: "+r+" d: "+i+" tx: "+p+" ty: "+s+" }"}};A$1._wrapFn=n=>G(n,e=>{let t=Object.create(fe.prototype);return t.zpp_inner=e,e.outer=t,t});function et(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.x}function tt(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.y}function me(n){n.zpp_inner.weak&&n.dispose();}var q=class n{get _inner(){return this}constructor(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::direction cannot be null");let r=new B$1;this.zpp_inner=r;let i=et(e),p=tt(e);r.origin.zpp_inner.x=i,r.origin.zpp_inner.y=p,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),me(e);let s=et(t),a=tt(t);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=a,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),me(t),r.zip_dir=true,r.maxdist=1/0;}static _wrap(e){return e==null?null:e instanceof n?e:G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r})}static fromSegment(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::fromSegment::start is null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::fromSegment::end is null");let r=t.sub(e,true),i=new n(e,r),p=et(e),s=tt(e),a=et(t),c=tt(t),f=a-p,u=c-s,m=Math.sqrt(f*f+u*u);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return i.zpp_inner.maxdist=m,me(e),me(t),i}get origin(){return this.zpp_inner.origin}set origin(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");this.zpp_inner.origin.set(e),me(e);}get direction(){return this.zpp_inner.direction}set direction(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::direction cannot be null");this.zpp_inner.direction.set(e),this.zpp_inner.zip_dir=true,me(e);}get maxDistance(){return this.zpp_inner.maxdist}set maxDistance(e){if(e!==e)throw new Error("Error: maxDistance cannot be NaN");this.zpp_inner.maxdist=e;}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}aabb(){return K$1._wrap(this.zpp_inner.rayAABB())}at(e,t=false){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let i=r.x,p=r.y,s=i+e*this.zpp_inner.dirx,a=p+e*this.zpp_inner.diry;return H.get(s,a,t)}clone(){return this.copy()}copy(){let e=new n(this.zpp_inner.origin,this.zpp_inner.direction),t=this.zpp_inner.maxdist;if(t!==t)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=t,e}};var ze=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),H._wrap(this.zpp_inner.position)}get toi(){return this._disposed(),this.zpp_inner.toiDistance}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" toi: "+this.zpp_inner.toiDistance+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x._createConvexResult=()=>new ze;var de=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H._wrap(this.zpp_inner.normal)}get distance(){return this._disposed(),this.zpp_inner.toiDistance}get inner(){return this._disposed(),this.zpp_inner.inner}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" distance: "+this.zpp_inner.toiDistance+" ?inner: "+String(this.zpp_inner.inner)+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x._createRayResult=()=>new de;function ie(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function rt(n,e){if(n!=null&&n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let t=n.zpp_inner;if(t._immutable)throw new Error("Error: Vec2 is immutable");t._isimmutable!=null&&t._isimmutable();}function ye(n,e){if(ie(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Se=class{static distanceBody(e,t,r,i){rt(r),rt(i);let p=nt(e),s=nt(t);if(p.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=p.shapes.head;for(;a!=null;)y.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)y.validateShape(a.elt),a=a.next;return C$1.distanceBody(p,s,r.zpp_inner,i.zpp_inner)}static distance(e,t,r,i){rt(r),rt(i),ye(e,"distances"),ye(t,"distances");let p=ie(e),s=ie(t);y.validateShape(p),y.validateShape(s);let a;l$1.zpp_pool==null?a=new l$1:(a=l$1.zpp_pool,l$1.zpp_pool=a.next,a.next=null),a.weak=false;let c=C$1.distance(p,s,r.zpp_inner,i.zpp_inner,a,1e100);return a.next=l$1.zpp_pool,l$1.zpp_pool=a,c}static intersectsBody(e,t){let r=nt(e),i=nt(t);if(r.shapes.head==null||i.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let p=r.shapes.head;for(;p!=null;)y.validateShape(p.elt),p=p.next;for(p=i.shapes.head;p!=null;)y.validateShape(p.elt),p=p.next;let s=r.aabb,a=i.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return false;let c=r.shapes.head;for(;c!=null;){let f=i.shapes.head;for(;f!=null;){if(w.testCollide_safe(c.elt,f.elt))return true;f=f.next;}c=c.next;}return false}static intersects(e,t){ye(e,"intersection"),ye(t,"intersection");let r=ie(e),i=ie(t);y.validateShape(r),y.validateShape(i);let p=r.aabb,s=i.aabb;return p.minx>s.maxx||p.maxx<s.minx||p.miny>s.maxy||p.maxy<s.miny?false:w.testCollide_safe(r,i)}static contains(e,t){ye(e,"containment"),ye(t,"containment");let r=ie(e),i=ie(t);return y.validateShape(r),y.validateShape(i),w.containTest(r,i)}};var Ze=class{static run(e,t,r,i=2,p=null,s=true,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: MarchingSquares requires an iso function to operate");if(t==null)throw new Error("Error: MarchingSquares requires an AABB to define bounds of surface extraction");if(r==null)throw new Error("Error: MarchingSquares requires a Vec2 to define cell size for surface extraction");let c=r.zpp_inner;if(c._validate!=null&&c._validate(),c.x<=0||c.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(i<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(p!=null){let g=p.zpp_inner;if(g._validate!=null&&g._validate(),g.x<=0||g.y<=0)throw new Error("Error: MarchingSquares cannot with non-positive sub-grid dimensions")}let f=E$1(),u=a??new f.geom.GeomPolyList,m=z$1,y=t.zpp_inner;if(y._validate!=null&&y._validate(),p==null){let g=y.minx,R=y.miny,J=y.maxx,_=y.maxy;m.run(e,g,R,J,_,r,i,s,u);}else {let g=p.zpp_inner;g._validate!=null&&g._validate();let R=y.maxx-y.minx,J=y.maxy-y.miny,_=R/g.x,h=J/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let vt=y.minx+g.x*Ye,Kt=Ye===b-1?y.maxx:vt+g.x;for(let je=0;je<G;je++){let Nt=y.miny+g.y*je,Jt=je===G-1?y.maxy:Nt+g.y;m.run(e,vt,Nt,Kt,Jt,r,i,s,u);}}}return c.weak&&r.dispose(),p!=null&&p.zpp_inner.weak&&p.dispose(),u}};var Q=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new c,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E$1(),i=new r.geom.Vec2List;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Q.internal=false;function oe(n){if(n.outer==null){let e=E$1();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l$1.zpp_pool,l$1.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function I(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Q.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}I.zpp_pool=null;I.get=function(n){let e;return I.zpp_pool==null?(Q.internal=true,e=new I,Q.internal=false):(e=I.zpp_pool,I.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};I.prototype.zpp_inner=null;I.prototype.zpp_i=null;I.prototype.zpp_critical=null;I.prototype.zpp_next=null;I.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=I.zpp_pool,I.zpp_pool=this,this.zpp_inner=null,false)};I.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function E(){this.zpp_inner=null,this.zpp_inner=new Q,this.zpp_inner.outer=this;}E.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E$1(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};E.prototype.zpp_inner=null;Object.defineProperty(E.prototype,"length",{get:function(){return this.zpp_gl()}});E.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};E.prototype.zpp_vm=function(){this.zpp_inner.valmod();};E.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};E.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=n,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(n);else for(;this.zpp_inner.at_index!=n;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return oe(this.zpp_inner.at_ite.elt)};E.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(n.zpp_inner):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)):this.zpp_inner.inner.add(n.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};E.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}return this.zpp_inner.invalidate(),oe(n)};E.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}else {n=this.zpp_inner.inner.head.elt;let e=oe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),oe(n)};E.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};E.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};E.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};E.prototype.empty=function(){return this.zpp_gl()==0};E.prototype.iterator=function(){return this.zpp_vm(),I.get(this)};E.prototype.copy=function(n){n==null&&(n=false);let e=E$1(),t=new e.geom.Vec2List,r=I.get(this);for(;r.hasNext();){let i=r.next(),p;if(n){if(i!=null&&i.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=i.zpp_inner;s._validate!=null&&s._validate();let a=i.zpp_inner.x,c=i.zpp_inner;c._validate!=null&&c._validate();let f=i.zpp_inner.y,u;if(b.poolVec2==null?u=new e.geom.Vec2:(u=b.poolVec2,b.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=false,u==b.nextVec2&&(b.nextVec2=null)),u.zpp_inner==null){let m;l$1.zpp_pool==null?m=new l$1:(m=l$1.zpp_pool,l$1.zpp_pool=m.next,m.next=null),m.weak=false,m._immutable=false,m.x=a,m.y=f,u.zpp_inner=m,u.zpp_inner.outer=u;}else u.zpp_inner.x=a,u.zpp_inner.y=f,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=false,p=u;}else p=i;t.push(p);}return t};E.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");let e=n.iterator();for(;e.hasNext();){let t=e.next();this.has(t)||this.add(t);}};E.prototype.toString=function(){let n="[",e=true,t=I.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};E.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=I.zpp_pool,I.zpp_pool=e,e.zpp_inner=null;break}return this};E.prototype[Symbol.iterator]=function(){let n=I.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};E.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let t=this.at(e);try{n(t)?++e:this.remove(t);}catch{break}}return this};function pe(){if(!M.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}pe.prototype.zpp_inner=null;pe.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=false,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=M.zpp_pool,M.zpp_pool=e;}return n};pe.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr;if(n.wrap==null){let t=n.x,r=n.y;if(t!==t||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let i=E$1(),p;if(b.poolVec2==null?p=new i.geom.Vec2:(p=b.poolVec2,b.poolVec2=p.zpp_pool,p.zpp_pool=null,p.zpp_disp=false,p==b.nextVec2&&(b.nextVec2=null)),p.zpp_inner==null){let s;l$1.zpp_pool==null?s=new l$1:(s=l$1.zpp_pool,l$1.zpp_pool=s.next,s.next=null),s.weak=false,s._immutable=false,s.x=t,s.y=r,p.zpp_inner=s,p.zpp_inner.outer=p;}else {if(p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;if(s._immutable)throw new Error("Error: Vec2 is immutable");s._isimmutable!=null&&s._isimmutable(),s.x==t&&s.y==r||(s.x=t,s.y=r,s._invalidate!=null&&s._invalidate(s));}p.zpp_inner.weak=false,n.wrap=p,n.wrap.zpp_inner._inuse=true,n.wrap.zpp_inner._invalidate=s=>n.modwrap(s),n.wrap.zpp_inner._validate=()=>n.getwrap();}let e=n.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};pe.prototype[Symbol.iterator]=function(){return {_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};var $t=E$1();$t.geom.GeomVertexIterator=pe;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new u,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E$1(),i=new r.dynamics.ContactList;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Y.internal=false;var be=class n{constructor(){if(!D.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof D?G(e,t=>{D.internal=true;let r=new n;return D.internal=false,r.zpp_inner=t,t.outer=r,r}):null:null}get polygon(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.outer_zn}get localNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_lnorm==null&&e.getlnorm(),e.wrap_lnorm}get worldNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_gnorm==null&&e.getgnorm(),e.wrap_gnorm}get length(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.length}get localProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.lprojection}get worldProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");if(e.polygon.body==null)throw new Error("Error: Edge world projection only makes sense for Polygons contained within a rigid body");return e.polygon.validate_gaxi(),e.gprojection}get localVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp0)}get localVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp1)}get worldVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp0)}get worldVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp1)}toString(){let e=this.zpp_inner;return e.polygon==null?"Edge(object-pooled)":e.polygon.body==null?(e.polygon.validate_laxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } }"):(e.polygon.validate_gaxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } worldNormal : { x: "+e.gnormx+" y: "+e.gnormy+" } }")}_wrapVert(e){let t=E$1();if(e.outer==null){e.outer=new t.geom.Vec2;let r=e.outer.zpp_inner;r.outer!=null&&(r.outer.zpp_inner=null,r.outer=null),r._isimmutable=null,r._validate=null,r._invalidate=null,r.next=l$1.zpp_pool,l$1.zpp_pool=r,e.outer.zpp_inner=e;}return e.outer}};D._wrapFn=n=>G(n,e=>{D.internal=true;let t=new be;return D.internal=false,t.zpp_inner=e,e.outer=t,t});var ge=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return a.ValidationResult_VALID==null&&(a.internal=true,a.ValidationResult_VALID=new n,a.internal=false),a.ValidationResult_VALID}static get DEGENERATE(){return a.ValidationResult_DEGENERATE==null&&(a.internal=true,a.ValidationResult_DEGENERATE=new n,a.internal=false),a.ValidationResult_DEGENERATE}static get CONCAVE(){return a.ValidationResult_CONCAVE==null&&(a.internal=true,a.ValidationResult_CONCAVE=new n,a.internal=false),a.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return a.ValidationResult_SELF_INTERSECTING==null&&(a.internal=true,a.ValidationResult_SELF_INTERSECTING=new n,a.internal=false),a.ValidationResult_SELF_INTERSECTING}toString(){return this===a.ValidationResult_VALID?"VALID":this===a.ValidationResult_DEGENERATE?"DEGENERATE":this===a.ValidationResult_CONCAVE?"CONCAVE":this===a.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Qt=E$1();Qt.shape.ValidationResult=ge;var we=class n{get _inner(){return this}constructor(e=false){let t=new v$1;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(true),t.ignore=e);}static _wrap(e){return e instanceof n?e:e?e instanceof v$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}get group(){return this.zpp_inner.group==null?null:this.zpp_inner.group.outer}set group(e){if(e===this)throw new Error("Error: Cannot assign InteractionGroup to itself");this.zpp_inner.setGroup(e==null?null:e.zpp_inner);}get ignore(){return this.zpp_inner.ignore}set ignore(e){this.zpp_inner.ignore!=e&&(this.zpp_inner.invalidate(true),this.zpp_inner.ignore=e);}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=E$1();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,true);}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=E$1();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,true);}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};v$1._wrapFn=n=>G(n,e=>{let t=Object.create(we.prototype);return t.zpp_inner=e,e.outer=t,t});var Ee=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return a.ArbiterType_COLLISION==null&&(a.internal=true,a.ArbiterType_COLLISION=new n,a.internal=false),a.ArbiterType_COLLISION}static get SENSOR(){return a.ArbiterType_SENSOR==null&&(a.internal=true,a.ArbiterType_SENSOR=new n,a.internal=false),a.ArbiterType_SENSOR}static get FLUID(){return a.ArbiterType_FLUID==null&&(a.internal=true,a.ArbiterType_FLUID=new n,a.internal=false),a.ArbiterType_FLUID}toString(){return this===a.ArbiterType_COLLISION?"COLLISION":this===a.ArbiterType_SENSOR?"SENSOR":this===a.ArbiterType_FLUID?"FLUID":""}},Xt=E$1();Xt.dynamics.ArbiterType=Ee;F$1();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!t.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return t.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==t.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==t.FLUID?this.zpp_inner.fluidarb.outer_zn:null}get shape1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer}get shape2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer}get body1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b2.outer:this.zpp_inner.b1.outer}get body2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b1.outer:this.zpp_inner.b2.outer}get state(){this._activeCheck();let e=E$1(),t=this.zpp_inner.immState;return t==5?(a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT):t==1?(a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT_ONCE):t==6?(a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE):(a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==t.COL}isFluidArbiter(){return this.zpp_inner.type==t.FLUID}isSensorArbiter(){return this.zpp_inner.type==t.SENSOR}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),I$1.get(0,0,0)}toString(){let e=this.zpp_inner.type==t.COL?"CollisionArbiter":this.zpp_inner.type==t.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let t$1=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer,r=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer,i=e+"("+t$1.toString()+"|"+r.toString()+")";return this.zpp_inner.type==t.COL&&(i+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),i+="<-"+this.state.toString(),i}_activeCheck(){if(!this.zpp_inner.active)throw new Error("Error: Arbiter not currently in use")}_checkBody(e){let t=this.zpp_inner,r=t.ws1.id>t.ws2.id?t.b2.outer:t.b1.outer,i=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=i)throw new Error("Error: Arbiter does not relate to body")}},en=E$1();en.dynamics.Arbiter=j;var Ve=class extends j{constructor(){super();}get contacts(){return this._activeCheck(),this.zpp_inner.colarb.wrap_contacts==null&&this.zpp_inner.colarb.setupcontacts(),this.zpp_inner.colarb.wrap_contacts}get normal(){return this._activeCheck(),this.zpp_inner.colarb.wrap_normal==null&&this.zpp_inner.colarb.getnormal(),this.zpp_inner.colarb.wrap_normal}get radius(){return this._activeCheck(),this.zpp_inner.colarb.radius}get referenceEdge1(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get referenceEdge2(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get elasticity(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.restitution}set elasticity(e){if(this._mutableCheck("elasticity"),e!==e)throw new Error("Error: CollisionArbiter::elasticity cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::elasticity cannot be negative");this.zpp_inner.colarb.restitution=e,this.zpp_inner.colarb.userdef_restitution=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get dynamicFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.dyn_fric}set dynamicFriction(e){if(this._mutableCheck("dynamicFriction"),e!==e)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be negative");this.zpp_inner.colarb.dyn_fric=e,this.zpp_inner.colarb.userdef_dyn_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get staticFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.stat_fric}set staticFriction(e){if(this._mutableCheck("staticFriction"),e!==e)throw new Error("Error: CollisionArbiter::staticFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::staticFriction cannot be negative");this.zpp_inner.colarb.stat_fric=e,this.zpp_inner.colarb.userdef_stat_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get rollingFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.rfric}set rollingFriction(e){if(this._mutableCheck("rollingFriction"),e!==e)throw new Error("Error: CollisionArbiter::rollingFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::rollingFriction cannot be negative");this.zpp_inner.colarb.rfric=e,this.zpp_inner.colarb.userdef_rfric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}firstVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==-1:false}secondVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==1:false}normalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return !t||r.oc1.fresh?r.oc1.wrapper().rollingImpulse(e):0}_mutableCheck(e){if(!this.zpp_inner.colarb.mutable)throw new Error("Error: CollisionArbiter::"+e+" is only mutable during a pre-handler")}_accumulateImpulse(e,t,r){let i=0,p=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let c=a.oc1.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}if(a.hc2&&(!r||a.oc2.fresh)){let c=a.oc2.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}return I$1.get(i,p,s)}};var Oe=class extends j{constructor(){super();}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),H._wrap(this.zpp_inner.fluidarb.wrap_position)}set position(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e==null)throw new Error("Error: FluidArbiter::position cannot be null");this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),this.zpp_inner.fluidarb.wrap_position.set(e);}get overlap(){return this._activeCheck(),this.zpp_inner.fluidarb.overlap}set overlap(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e!==e)throw new Error("Error: FluidArbiter::overlap cannot be NaN");if(e<=0||e==1/0)throw new Error("Error: FluidArbiter::overlap must be strictly positive and non infinite");this.zpp_inner.fluidarb.overlap=e;}buoyancyImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb;return e==null?I$1.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?I$1.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):I$1.get(-t.buoyx,-t.buoyy,-(t.buoyy*t.r1x-t.buoyx*t.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return I$1.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),i=this.dragImpulse(e),p=r.zpp_inner,s=i.zpp_inner;return p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.x=s.x+p.x,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.y=s.y+p.y,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.z=s.z+p.z,r.dispose(),i}};var Pe=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!u.internal)throw new Error("Error: Cannot instantiate Contact derp!")}get arbiter(){if(this.zpp_inner.arbiter==null)return null;let e=this.zpp_inner.arbiter.outer;return e.zpp_inner.type==t.COL?e.zpp_inner.colarb.outer_zn:null}get penetration(){return this._inactiveCheck(),-this.zpp_inner.dist}get position(){return this._inactiveCheck(),this.zpp_inner.wrap_position==null&&this.zpp_inner.getposition(),H._wrap(this.zpp_inner.wrap_position)}get fresh(){return this._inactiveCheck(),this.zpp_inner.fresh}get friction(){return this._inactiveCheck(),this.zpp_inner.inner.friction}normalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc;return e==null?I$1.get(t.nx*i,t.ny*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.nx*-i,t.ny*-i,-(t.ny*r.r1x-t.nx*r.r1y)*i):I$1.get(t.nx*i,t.ny*i,(t.ny*r.r2x-t.nx*r.r2y)*i))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jtAcc;return e==null?I$1.get(-t.ny*i,t.nx*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.ny*i,-t.nx*i,-(r.r1x*t.nx+r.r1y*t.ny)*i):I$1.get(-t.ny*i,t.nx*i,(r.r2x*t.nx+r.r2y*t.ny)*i))}rollingImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=t.jrAcc;return e==null?r:(this._checkBody(e,t),e==t.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc,p=r.jtAcc,s=t.jrAcc;if(e==null)return I$1.get(t.nx*i-t.ny*p,t.ny*i+t.nx*p,s);this._checkBody(e,t);let a=t.nx*i-t.ny*p,c=t.ny*i+t.nx*p;return e==t.b1.outer?I$1.get(-a,-c,-(c*r.r1x-a*r.r1y)-s):I$1.get(a,c,c*r.r2x-a*r.r2y+s)}toString(){return this.zpp_inner.arbiter==null||this.zpp_inner.arbiter.cleared?"{object-pooled}":"{Contact}"}_inactiveCheck(){if(this.zpp_inner.inactiveme())throw new Error("Error: Contact not currently in use")}_checkBody(e,t){if(e!=t.b1.outer&&e!=t.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};u._wrapFn=n=>{u.internal=true;let e=new Pe;return u.internal=false,e.zpp_inner=n,n.outer=e,e};function tn(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function V(n){return n.valmod(),n.zip_length&&(n.zip_length=false,n.user_length=tn(n)),n.user_length}function v(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}v.zpp_pool=null;v.get=function(n){let e;return v.zpp_pool==null?(Y.internal=true,e=new v,Y.internal=false):(e=v.zpp_pool,v.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};v.prototype.zpp_inner=null;v.prototype.zpp_i=null;v.prototype.zpp_critical=null;v.prototype.zpp_next=null;v.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=V(this.zpp_inner.zpp_inner);return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=v.zpp_pool,v.zpp_pool=this,this.zpp_inner=null,false)};v.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function A(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this;}A.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E$1(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};A.prototype.zpp_inner=null;Object.defineProperty(A.prototype,"length",{get:function(){return V(this.zpp_inner)}});A.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};A.prototype.at=function(n){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=V(this.zpp_inner)-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)for(this.zpp_inner.at_index=0,this.zpp_inner.at_ite=this.zpp_inner.inner.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}for(;this.zpp_inner.at_index!=n;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}return this.zpp_inner.at_ite.wrapper()};A.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(n.zpp_inner);else {if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}else this.zpp_inner.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};A.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}else {e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),e.wrapper()};A.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};A.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=false,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};A.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift();};A.prototype.empty=function(){return V(this.zpp_inner)==0};A.prototype.iterator=function(){return this.zpp_inner.valmod(),v.get(this)};A.prototype.copy=function(n){n==null&&(n=false);let e=E$1(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=v.get(this);for(;r.hasNext();){let i=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(i);}return t};A.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=v.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t));}};A.prototype.toString=function(){let n="[",e=true;this.zpp_inner.valmod();let t=v.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};A.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=v.get(this);for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=v.zpp_pool,v.zpp_pool=e,e.zpp_inner=null;break}return this};A.prototype[Symbol.iterator]=function(){let n=v.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};A.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=V(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r);}catch{break}}return this};var C=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return a.CbEvent_BEGIN==null&&(a.internal=true,a.CbEvent_BEGIN=new n,a.internal=false),a.CbEvent_BEGIN}static get ONGOING(){return a.CbEvent_ONGOING==null&&(a.internal=true,a.CbEvent_ONGOING=new n,a.internal=false),a.CbEvent_ONGOING}static get END(){return a.CbEvent_END==null&&(a.internal=true,a.CbEvent_END=new n,a.internal=false),a.CbEvent_END}static get WAKE(){return a.CbEvent_WAKE==null&&(a.internal=true,a.CbEvent_WAKE=new n,a.internal=false),a.CbEvent_WAKE}static get SLEEP(){return a.CbEvent_SLEEP==null&&(a.internal=true,a.CbEvent_SLEEP=new n,a.internal=false),a.CbEvent_SLEEP}static get BREAK(){return a.CbEvent_BREAK==null&&(a.internal=true,a.CbEvent_BREAK=new n,a.internal=false),a.CbEvent_BREAK}static get PRE(){return a.CbEvent_PRE==null&&(a.internal=true,a.CbEvent_PRE=new n,a.internal=false),a.CbEvent_PRE}toString(){return this===a.CbEvent_BEGIN?"BEGIN":this===a.CbEvent_ONGOING?"ONGOING":this===a.CbEvent_END?"END":this===a.CbEvent_WAKE?"WAKE":this===a.CbEvent_SLEEP?"SLEEP":this===a.CbEvent_BREAK?"BREAK":this===a.CbEvent_PRE?"PRE":""}},nn=E$1();nn.callbacks.CbEvent=C;F$1();var Ce=class n{get _inner(){return this}constructor(){this.zpp_inner=new e,this.zpp_inner.outer=this;}static get ANY_BODY(){return e.ANY_BODY}static get ANY_CONSTRAINT(){return e.ANY_CONSTRAINT}static get ANY_SHAPE(){return e.ANY_SHAPE}static get ANY_COMPOUND(){return e.ANY_COMPOUND}get id(){return this.zpp_inner.id}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}get interactors(){return this.zpp_inner.wrap_interactors==null&&(this.zpp_inner.wrap_interactors=Z$1.get(this.zpp_inner.interactors,true)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=Y$1.get(this.zpp_inner.constraints,true)),this.zpp_inner.wrap_constraints}including(e){return new(E$1()).callbacks.OptionType(this).including(e)}excluding(e){return new(E$1()).callbacks.OptionType(this).excluding(e)}toString(){return this===e.ANY_BODY?"ANY_BODY":this===e.ANY_SHAPE?"ANY_SHAPE":this===e.ANY_COMPOUND?"ANY_COMPOUND":this===e.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e$1){return e$1 instanceof n?e$1:e$1?e$1 instanceof e?G(e$1,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e$1.zpp_inner?n._wrap(e$1.zpp_inner):null:null}},rn=E$1();rn.callbacks.CbType=Ce;F$1();var Z=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return a.InteractionType_COLLISION==null&&(a.internal=true,a.InteractionType_COLLISION=new n,a.internal=false),a.InteractionType_COLLISION}static get SENSOR(){return a.InteractionType_SENSOR==null&&(a.internal=true,a.InteractionType_SENSOR=new n,a.internal=false),a.InteractionType_SENSOR}static get FLUID(){return a.InteractionType_FLUID==null&&(a.internal=true,a.InteractionType_FLUID=new n,a.internal=false),a.InteractionType_FLUID}static get ANY(){return a.InteractionType_ANY==null&&(a.internal=true,a.InteractionType_ANY=new n,a.internal=false),a.InteractionType_ANY}toString(){return this===a.InteractionType_COLLISION?"COLLISION":this===a.InteractionType_SENSOR?"SENSOR":this===a.InteractionType_FLUID?"FLUID":this===a.InteractionType_ANY?"ANY":""}},on=E$1();on.callbacks.InteractionType=Z;var W=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new n,a.internal=false),a.PreFlag_ACCEPT}static get IGNORE(){return a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new n,a.internal=false),a.PreFlag_IGNORE}static get ACCEPT_ONCE(){return a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new n,a.internal=false),a.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new n,a.internal=false),a.PreFlag_IGNORE_ONCE}toString(){return this===a.PreFlag_ACCEPT?"ACCEPT":this===a.PreFlag_IGNORE?"IGNORE":this===a.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===a.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},pn=E$1();pn.callbacks.PreFlag=W;var xe=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new j$1,this.zpp_inner.outer=this,e!=null&&this.including(e),t!=null&&this.excluding(t);}get includes(){return this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes(),this.zpp_inner.wrap_includes}get excludes(){return this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes(),this.zpp_inner.wrap_excludes}including(e){return this.zpp_inner.append(this.zpp_inner.includes,e),this}excluding(e){return this.zpp_inner.append(this.zpp_inner.excludes,e),this}toString(){this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes();let e=this.zpp_inner.wrap_includes.toString();this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes();let t=this.zpp_inner.wrap_excludes.toString();return "@{"+e+" excluding "+t+"}"}static _wrap(e){return e instanceof n?e:e?e instanceof j$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},sn=E$1();sn.callbacks.OptionType=xe;function an(n){return n===C.BEGIN?0:n===C.END?1:n===C.WAKE?2:n===C.SLEEP?3:n===C.BREAK?4:n===C.PRE?5:n===C.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!f.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null;}static _wrap(e){return e instanceof n?e:e&&e instanceof f?G(e,t=>{if(t.outer)return t.outer;let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):null}get type(){return f.types[this.zpp_inner.type]}get event(){return f.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(f.events[this.zpp_inner.event]!=e){let t=an(e);this.zpp_inner.swapEvent(t);}}get precedence(){return this.zpp_inner.precedence}set precedence(e){this.zpp_inner.precedence!=e&&(this.zpp_inner.precedence=e,this.zpp_inner.invalidate_precedence());}get space(){return this.zpp_inner.space==null?null:X$1._wrap(this.zpp_inner.space.outer)}set space(e){let t=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=t)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),t!=null){let i=t.zpp_inner.wrap_listeners;i.zpp_inner.reverse_flag?i.push(this):i.unshift(this);}else this.zpp_inner.space=null;}toString(){let t=["BEGIN","END","WAKE","SLEEP","BREAK","PRE","ONGOING"][this.zpp_inner.event];if(this.zpp_inner.type==0){let r=this.zpp_inner.body;return "BodyListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return "ConstraintListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else {let r=this.zpp_inner.interaction,i;switch(r.itype){case 1:i="COLLISION";break;case 2:i="SENSOR";break;case 4:i="FLUID";break;default:i="ALL";}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+i+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+i+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var ve=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return a.ListenerType_BODY==null&&(a.internal=true,a.ListenerType_BODY=new n,a.internal=false),a.ListenerType_BODY}static get CONSTRAINT(){return a.ListenerType_CONSTRAINT==null&&(a.internal=true,a.ListenerType_CONSTRAINT=new n,a.internal=false),a.ListenerType_CONSTRAINT}static get INTERACTION(){return a.ListenerType_INTERACTION==null&&(a.internal=true,a.ListenerType_INTERACTION=new n,a.internal=false),a.ListenerType_INTERACTION}static get PRE(){return a.ListenerType_PRE==null&&(a.internal=true,a.ListenerType_PRE=new n,a.internal=false),a.ListenerType_PRE}toString(){return this===a.ListenerType_BODY?"BODY":this===a.ListenerType_CONSTRAINT?"CONSTRAINT":this===a.ListenerType_INTERACTION?"INTERACTION":this===a.ListenerType_PRE?"PRE":""}},ln=E$1();ln.callbacks.ListenerType=ve;F$1();var F=class{constructor(){this.zpp_inner=null;if(!d.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return f.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return ""}};var Re=class extends F{get body(){return this.zpp_inner.body.outer}toString(){return "Cb:"+["WAKE","SLEEP"][this.zpp_inner.event-2]+":"+this.zpp_inner.body.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var ke=class extends F{get constraint(){return this.zpp_inner.constraint.outer}toString(){return "Cb:"+["WAKE","SLEEP","BREAK"][this.zpp_inner.event-2]+":"+this.zpp_inner.constraint.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Be=class extends F{get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get arbiters(){return this.zpp_inner.wrap_arbiters}toString(){return "Cb:"+["BEGIN","END","","","","","ONGOING"][this.zpp_inner.event]+":"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.wrap_arbiters.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Fe=class extends F{get arbiter(){return this.zpp_inner.pre_arbiter.wrapper()}get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get swapped(){return this.zpp_inner.pre_swapped}toString(){return "Cb:PRE::"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.pre_arbiter.wrapper().toString()+" : listnener: "+String(this.zpp_inner.listener.outer)}};var Ge=class extends B{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: BodyListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new g(j$1.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: BodyListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};var De=class extends B{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let p;if(e===C.WAKE)p=2;else if(e===C.SLEEP)p=3;else if(e===C.BREAK)p=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new h(j$1.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: ConstraintListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};function Me(n){return n===Z.COLLISION?1:n===Z.SENSOR?2:n===Z.FLUID?4:7}function se(n){return n==1?Z.COLLISION:n==2?Z.SENSOR:n==4?Z.FLUID:n==7?Z.ANY:null}var Ue=class extends B{constructor(e,t,r,i$1,p,s=0){if(f.internal=true,super(),f.internal=false,p==null)throw new Error("Error: InteractionListener::handler cannot be null");if(e==null)throw new Error("Error: CbEvent cannot be null for InteractionListener");let a;if(e===C.BEGIN)a=0;else if(e===C.END)a=1;else if(e===C.ONGOING)a=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new i(j$1.argument(r),j$1.argument(i$1),a,2),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zni=this,this.zpp_inner.precedence=s,this.zpp_inner_zn.handleri=p,t==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Me(t));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handleri}set handler(e){if(e==null)throw new Error("Error: InteractionListener::handler cannot be null");this.zpp_inner_zn.handleri=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e;}};var ae=class extends B{constructor(e,t,r,i$1,p=0,s=false){if(f.internal=true,super(),f.internal=false,i$1==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new i(j$1.argument(t),j$1.argument(r),5,3),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_znp=this,this.zpp_inner.precedence=p,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=i$1,e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handlerp}set handler(e){if(e==null)throw new Error("Error: PreListener must take a non-null handler!");this.zpp_inner_zn.handlerp=e,this.zpp_inner_zn.wake();}get pure(){return this.zpp_inner_zn.pure}set pure(e){e||this.zpp_inner_zn.wake(),this.zpp_inner_zn.pure=e;}get interactionType(){return se(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");se(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Me(e));}};var We=class n extends ka{constructor(e,t=false){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r$1=new r(e,t);this.zpp_inner=r$1,r$1.outer=this,r$1.outer_zn=this;}static _wrap(e){return e==null?null:e instanceof n?e:e.zpp_inner?.outer instanceof n?e.zpp_inner.outer:G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new H;return e.zpp_inner._inuse=true,e.zpp_inner._invalidate=this.zpp_inner.bindVec2_invalidate.bind(this.zpp_inner),e}__copy(){throw new Error("Error: UserConstraint::__copy must be overriden")}__broken(){}__validate(){}__draw(e){}__prepare(){}__position(e){throw new Error("Error: UserConstraint::__position must be overriden")}__velocity(e){throw new Error("Error: Userconstraint::__velocity must be overriden")}__eff_mass(e){throw new Error("Error: UserConstraint::__eff_mass must be overriden")}__clamp(e){}__impulse(e,t,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,t=new J(e,1);for(let r=0;r<e;r++){if(r<0||r>=t.zpp_inner.m||0>=t.zpp_inner.n)throw new Error("Error: MatMN indices out of range");t.zpp_inner.x[r*t.zpp_inner.n]=this.zpp_inner.jAcc[r];}return t}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let t=false;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=true;break}if(!t)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):I$1.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let i=this.zpp_inner.bodies[r];if(i.body!=null){let p=false;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==i.body){p=true;break}p||e(i.body.outer);}++r;}}__invalidate(){this.zpp_inner.immutable_midstep("UserConstraint::invalidate()"),this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&this.zpp_inner.wake();}__registerBody(e,t){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=t){if(e!=null){if(!this.zpp_inner.remBody(e.zpp_inner))throw new Error("Error: oldBody is not registered to the cosntraint");this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&e.zpp_inner.wake();}t!=null&&this.zpp_inner.addBody(t.zpp_inner),this.zpp_inner.wake(),t?.zpp_inner.wake();}return t}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e;}};function O(n){let{typeName:e,namespaceParts:t,zppListClass:r,wrapElement:i,unwrapElement:p}=n,s=E$1(),a=s.__zpp,c=()=>a.util[r],f=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!c().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=c();return u.zpp_pool==null?(b.internal=true,h=new u,b.internal=false):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=false,h},u.prototype.zpp_inner=null,u.prototype.zpp_i=null,u.prototype.zpp_critical=null,u.prototype.zpp_next=null,u.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let _=this.zpp_inner;_.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=true,this.zpp_i<h?true:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,false)},u.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(c()),this.zpp_inner.outer=this;}m.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new m;for(let b=0;b<_.length;b++)h.push(_[b]);return h},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function y(_){return _.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return y(this)}}),m.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(p(_))},m.prototype.at=function(_){if(this.zpp_inner.valmod(),_<0||_>=y(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(_=y(this)-1-_),_<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=_,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(_);else for(;this.zpp_inner.at_index!=_;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return i(this.zpp_inner.at_ite.elt)},m.prototype.push=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(p(_)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.unshift=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))):this.zpp_inner.inner.add(p(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}return this.zpp_inner.invalidate(),i(_)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}else {_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),i(_)},m.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},m.prototype.remove=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=false,b=this.zpp_inner.inner.head,G=p(_);for(;b!=null;){if(b.elt==G){h=true;break}b=b.next;}return h&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(_),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(G),this.zpp_inner.invalidate()),h},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift();},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},m.prototype.copy=function(_){_==null&&(_=false);let h=new m,b=u.get(this);for(;b.hasNext();){let G=b.next();if(_)throw new Error("Error: "+e+" is not a copyable type");h.push(G);}return h},m.prototype.merge=function(_){if(_==null)throw new Error("Error: Cannot merge with null list");let h=u.get(_);for(;h.hasNext();){let b=h.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b));}},m.prototype.toString=function(){let _="[",h=true,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=false;}return _+"]"},m.prototype.foreach=function(_){if(_==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let h=u.get(this);for(;h.hasNext();)try{_(h.next());}catch{h.zpp_next=u.zpp_pool,u.zpp_pool=h,h.zpp_inner=null;break}return this},m.prototype.filter=function(_){if(_==null)throw new Error("Error: Cannot select elements of list with null");let h=0;for(;h<y(this);){let b=this.at(h);try{_(b)?++h:this.remove(b);}catch{break}}return this},m.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},m.prototype[Symbol.iterator]=function(){let _=u.get(this);return {next(){return _.hasNext()?{value:_.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};let g=f(),R=e+"Iterator",J=e+"List";return g[R]=u,g[J]=m,{Iterator:u,List:m}}var X=n=>n.outer,K=n=>n.zpp_inner??(n._inner?n._inner.zpp_inner??n._inner:n);O({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:X,unwrapElement:K});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:X,unwrapElement:K});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:X,unwrapElement:K});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:X,unwrapElement:K});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:X,unwrapElement:K});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:X,unwrapElement:K});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:X,unwrapElement:K});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:X,unwrapElement:K});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:n=>n.outer_i,unwrapElement:n=>n.zpp_inner_i});function le(n){if(n.outer==null){let e=E$1();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l$1.zpp_pool,l$1.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=false,this._length=0,this.inner=null,E.call(this),this.at_ite=null,this.at_index=0,this.zip_length=true,this._length=0;}for(let n in E.prototype)L.prototype[n]=E.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:true});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=false;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=false);let t=new L;return t.inner=n,t.zpp_inner.immutable=e,t};L.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let n=this.inner.next;for(;n!=null;)this._length++,n=n.next;this.zip_length=false;}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=true,this._length=0,this.at_ite=null);};L.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),(n<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==n;)this.at_index++,this.at_ite=this.at_ite.next;return le(this.at_ite)};L.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(n.zpp_inner);else {let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}else this.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}else {this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}return this.zpp_inner.invalidate(),le(n)};L.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}else {n=this.inner.next;let e=le(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}return this.zpp_inner.invalidate(),le(n)};L.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};L.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};var _n=E$1(),un=_n.__zpp;un.util.ZPP_MixVec2List=L;var z=E$1();z.Config=Object.assign(z.Config||{},Pt);z.util.Debug=Xe;z.geom.Vec2=H;z.geom.Vec3=I$1;z.geom.Mat23=fe;z.geom.MatMN=J;z.geom.AABB=K$1;z.geom.Winding=L$1;z.geom.Ray=q;z.geom.ConvexResult=ze;z.geom.RayResult=de;z.geom.Geom=Se;z.geom.GeomPoly=N;z.geom.MarchingSquares=Ze;z.geom.Vec2Iterator=I;z.geom.Vec2List=E;z.geom.GeomVertexIterator=pe;z.__zpp.geom.ZPP_GeomVertexIterator=M;z.__zpp.util.ZPP_ContactList=Y;z.phys.Interactor=R;z.phys.Body=_;O$1(n=>_._wrap(n));z.phys.BodyType=$;z.phys.Compound=aa;Q$1(n=>aa._wrap(n));z.phys.FluidProperties=T;z.phys.Material=ba;z.phys.GravMassMode=ca;z.phys.InertiaMode=da;z.phys.MassMode=ea;z.shape.Shape=V$1;P(n=>V$1._wrap(n));z.shape.Circle=fa;z.shape.Polygon=ga;z.shape.Capsule=ha;z.shape.Edge=be;z.shape.ShapeType=U;z.shape.ValidationResult=ge;z.space.Space=X$1;z.space.Broadphase=ia;z.dynamics.InteractionFilter=ja;z.dynamics.InteractionGroup=we;z.dynamics.ArbiterType=Ee;z.dynamics.Arbiter=j;t._createColArb=()=>new Ve;t._createFluidArb=()=>new Oe;z.dynamics.Contact=Pe;z.dynamics.ContactIterator=v;z.dynamics.ContactList=A;z.callbacks.CbEvent=C;z.callbacks.CbType=Ce;z.callbacks.InteractionType=Z;z.callbacks.PreFlag=W;z.callbacks.OptionType=xe;z.callbacks.Listener=B;z.callbacks.ListenerType=ve;z.callbacks.Callback=F;d._createBodyCb=()=>new Re;d._createConCb=()=>new ke;d._createIntCb=()=>new Be;d._createPreCb=()=>new Fe;z.callbacks.BodyListener=Ge;z.callbacks.ConstraintListener=De;z.callbacks.InteractionListener=Ue;z.callbacks.PreListener=ae;z.constraint.Constraint=ka;k._createFn=(...n)=>new la(...n);m._createFn=(...n)=>new ma(...n);n._createFn=(...n)=>new na(...n);o._createFn=(...n)=>new oa(...n);p._createFn=(...n)=>new pa(...n);q$1._createFn=(...n)=>new qa(...n);s._createFn=(...n)=>new ra(...n);z.constraint.UserConstraint=We;var Ct=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,i){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,i){}drawSolidCapsule(e,t,r,i){}drawPoint(e,t){}};function hn(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof N){if(n.zpp_disp)throw new Error("Error: GeomPoly has been disposed and cannot be used!");t=n.copy();}else {if(!Array.isArray(n))throw new Error("Error: vertices must be an Array<Vec2> or GeomPoly");if(n.length<3)throw new Error("Error: At least 3 vertices are required, got "+n.length);for(let f=0;f<n.length;f++)if(n[f]==null)throw new Error("Error: vertices["+f+"] is null");t=new N(n);}if(t.size()<3)throw t.dispose(),new Error("Error: At least 3 vertices are required, got "+t.size());if(t.isDegenerate())throw t.dispose(),new Error("Error: Polygon is degenerate (zero area)");if(!t.isSimple())throw t.dispose(),new Error("Error: Polygon is self-intersecting");let r=e?.simplify??0;if(r>0){let f=t.simplify(r);if(t.dispose(),t=f,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let f=[],u=t.forwardIterator();for(;u.hasNext();){let m=u.next();f.push(H.get(m.x,m.y));}t.dispose(),f.reverse(),t=new N(f);}let i=e?.material,p=e?.filter,s=e?.delaunay??false,a=new _(e?.type??$.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new ga(t,i,p)),t.dispose(),a;let c=t.convexDecomposition(s);for(let f of c)a.shapes.add(new ga(f,i,p));return t.dispose(),a}var xt=class{constructor(e,t,r={}){this._oneWayListener=null;this._grounded=false;this._groundNormal=null;this._groundBody=null;this._onMovingPlatform=false;this._slopeAngle=0;this._wallLeft=false;this._wallRight=false;this._timeSinceGrounded=0;this.space=e,this.body=t,this._maxSlopeAngle=r.maxSlopeAngle??Math.PI/4,this._maxSlopeCos=Math.cos(this._maxSlopeAngle);let i=256;if(r.filter)this._filter=r.filter;else {let p=t.shapes;for(let s=0;s<p.length;s++){let c=p.at(s).filter;c.collisionGroup=c.collisionGroup|i;}this._filter=new ja(1,~i);}r.oneWayPlatformTag&&r.characterTag&&this._setupOneWayPlatforms(r.oneWayPlatformTag,r.characterTag);}get grounded(){return this._grounded}get groundNormal(){return this._groundNormal}get groundBody(){return this._groundBody}get timeSinceGrounded(){return this._timeSinceGrounded}get maxSlopeAngle(){return this._maxSlopeAngle}set maxSlopeAngle(e){this._maxSlopeAngle=e,this._maxSlopeCos=Math.cos(e);}setVelocity(e,t){this.body.velocity=new H(e,t);}update(){this._wallLeft=false,this._wallRight=false;let e=this.body.position.x,t=this.body.position.y;return this._detectGround(e,t),this._detectWalls(e,t),this._grounded&&this._groundBody?this._onMovingPlatform=this._groundBody.type===$.KINEMATIC:this._onMovingPlatform=false,this._grounded?this._timeSinceGrounded=0:this._timeSinceGrounded+=1/60,{grounded:this._grounded,groundNormal:this._groundNormal,groundBody:this._groundBody,onMovingPlatform:this._onMovingPlatform,slopeAngle:this._slopeAngle,wallLeft:this._wallLeft,wallRight:this._wallRight,timeSinceGrounded:this._timeSinceGrounded}}destroy(){this._oneWayListener&&(this._oneWayListener.space=null,this._oneWayListener=null);}_detectGround(e,t){let i=this._getCharacterRadius(0,1)+4,p=new q(new H(e,t),new H(0,1));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);if(s&&s.distance<=i){let a=s.normal.y;if(a<0){let c=-a;if(c>=this._maxSlopeCos){this._grounded=true,this._groundNormal=new H(s.normal.x,s.normal.y),this._groundBody=s.shape?.body??null,this._slopeAngle=Math.acos(Math.min(1,c));return}}}this._grounded=false,this._groundNormal=null,this._groundBody=null,this._slopeAngle=0;}_detectWalls(e,t){let i=this._getCharacterRadius(1,0)+2,p=new q(new H(e,t),new H(-1,0));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);s&&s.distance<=i&&Math.abs(s.normal.x)>.7&&(this._wallLeft=true);let a=new q(new H(e,t),new H(1,0));a.maxDistance=i;let c=this.space.rayCast(a,false,this._filter);c&&c.distance<=i&&Math.abs(c.normal.x)>.7&&(this._wallRight=true);}_setupOneWayPlatforms(e,t){let r=new ae(Z.COLLISION,e,t,i=>{try{let p=i.arbiter.collisionArbiter;if(!p)return W.ACCEPT;let s=p.normal.y,a=i.swapped;return s>0!==a?W.IGNORE:W.ACCEPT}catch{return W.ACCEPT}},0,true);r.space=this.space,this._oneWayListener=r;}_getCharacterRadius(e,t){let r=this.body.shapes.at(0);if(!r)return 0;if(r.isCircle())return r.castCircle?.radius??0;if(r.isCapsule()){let a=r.castCapsule;if(a){let c=a.radius,f=a.halfLength,u=this.body.rotation,m=Math.cos(u),y=Math.sin(u);return Math.abs(e*m+t*y)*f+c}}let i=r.bounds,p=i.width/2,s=i.height/2;return Math.abs(e)*p+Math.abs(t)*s}};var Xp="3.20.0";export{j as Arbiter,Ee as ArbiterType,Re as BodyCallback,Ge as BodyListener,F as Callback,C as CbEvent,Ce as CbType,xt as CharacterController,Ve as CollisionArbiter,ke as ConstraintCallback,De as ConstraintListener,Pe as Contact,ze as ConvexResult,Ct as DebugDraw,be as Edge,Oe as FluidArbiter,Se as Geom,Be as InteractionCallback,we as InteractionGroup,Ue as InteractionListener,Z as InteractionType,B as Listener,ve as ListenerType,Ze as MarchingSquares,fe as Mat23,xe as OptionType,Fe as PreCallback,W as PreFlag,ae as PreListener,q as Ray,de as RayResult,We as UserConstraint,Xp as VERSION,ge as ValidationResult,hn as createConcaveBody};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newkrok/nape-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
4
4
|
"description": "High-performance 2D physics engine for TypeScript & JavaScript — rigid bodies, constraints, fluid simulation, raycasting, and deterministic multiplayer. Tree-shakeable, zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|