@newkrok/nape-js 3.17.0 → 3.18.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.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as Ne,A as qe,B as Ft,C as rt,D as J,E as z,F as q,G as v,H as A,I as x,J as xe,K as Ce,L as it,M as se,N as ee,O as Gt,P as Dt,Q as Mt,R as pt,S as Jt,T as ot,U as st,V as He,W as qt,X as ve,Y as Ut,Z as Yt,_ as ae,a as i,aa as Xe,b as D,ba as at,c as Nt,ca as lt,d as $,da as _t,e as M,ea as ut,f as T,fa as ht,g as It,ga as le,h as At,ha as ct,i as We,ia as ft,j as R,ja as zt,k as Tt,ka as Ie,l as E,la as mt,m as Lt,ma as dt,n as St,na as yt,o as Zt,oa as bt,p as Vt,pa as gt,q as Ot,qa as wt,r as kt,ra as Et,s as Rt,t as S,u as Q,v as Ke,w as Je,x as oe,y as U,z as Bt}from"./chunk-SQVUZDT6.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=z();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 $e=class{static version(){return"Nape 2.0.19"}static clearObjectPools(){let e=z(),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 _e=class n{get _inner(){return this}constructor(e=1,t=0,r=0,p=1,o=0,s=0){let a=qe.get();this.zpp_inner=a,a.outer=this;let m=["a","b","tx","c","d","ty"],c=[e,t,o,r,p,s];for(let u=0;u<c.length;u++)if(c[u]!==c[u])throw new Error("Error: Mat23::"+m[u]+" cannot be NaN");a.setas(e,t,r,p,o,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 qe?v(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!1;let r=this.zpp_inner,p=e.zpp_inner,o=r.a-p.a,s=r.b-p.b,a=r.c-p.c,m=r.d-p.d,c=r.tx-p.tx,u=r.ty-p.ty;return(o<0?-o:o)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(m<0?-m:m)<=t&&(c<0?-c:c)<=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,p=1,o=0,s=0){return this.zpp_inner.setas(e,t,r,p,o,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:p}=this.zpp_inner,o=e*e+t*t+r*r+p*p,s=e*p-t*r;s<0&&(s=-s);let a=z();return o>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:p,tx:o,ty:s}=this.zpp_inner,a=1/(e*p-t*r);return new n(p*a,-t*a,-r*a,e*a,(t*s-p*o)*a,(r*o-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return new n(e,r,t,p,-e*o-r*s,-t*o-p*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=!1,r=!1){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 p=e.zpp_inner.x,o=e.zpp_inner.y,{a:s,b:a,c:m,d:c,tx:u,ty:d}=this.zpp_inner,y,g;t?(y=p*s+o*a,g=p*m+o*c):(y=p*s+o*a+u,g=p*m+o*c+d);let k=A.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),k}inverseTransform(e,t=!1,r=!1){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:p,b:o,c:s,d:a,tx:m,ty:c}=this.zpp_inner,u=1/(p*a-o*s);e.zpp_inner.validate();let d=e.zpp_inner.x,y=e.zpp_inner.y,g,k;if(t)g=(d*a-y*o)*u,k=(y*p-d*s)*u;else{let _=d-m,h=y-c;g=(_*a-h*o)*u,k=(h*p-_*s)*u}let K=A.get(g,k,r);return e.zpp_inner.weak&&e.dispose(),K}equiorthogonal(){if(this.singular())return!1;let{a:e,b:t,c:r,d:p}=this.zpp_inner,o=z(),s=e*t+r*p;if(s*s>=o.Config.epsilon)return!1;let a=e*e+t*t-r*r-p*p;return a*a<o.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:p}=this.zpp_inner,o=z(),s=e*t+r*p;if(s*s>=o.Config.epsilon)return!1;let a=e*e+t*t-1,m=r*r+p*p-1;return a*a<o.Config.epsilon&&m*m<o.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:p,d:o}=this.zpp_inner,s=z(),a=Math.sqrt(t*t+p*p),m=Math.sqrt(r*r+o*o);if(a*a<s.Config.epsilon||m*m<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let c=e?(a+m)/2:1;a=c/a,m=c/m,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*m,this.d=this.zpp_inner.d*m;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,d=.25*Math.PI-.5*Math.acos(u/(c*c));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(d=-d);let y=Math.sin(d),g=Math.cos(d),k=this.zpp_inner.a*g-this.zpp_inner.c*y,K=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=k,this.d=h,this.b=K,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(!0)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(!1)}toString(){let{a:e,b:t,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return"{ a: "+e+" b: "+t+" c: "+r+" d: "+p+" tx: "+o+" ty: "+s+" }"}};qe._wrapFn=n=>v(n,e=>{let t=Object.create(_e.prototype);return t.zpp_inner=e,e.outer=t,t});function Qe(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 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.y}function ue(n){n.zpp_inner.weak&&n.dispose()}var Ae=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 Ft;this.zpp_inner=r;let p=Qe(e),o=et(e);r.origin.zpp_inner.x=p,r.origin.zpp_inner.y=o,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),ue(e);let s=Qe(t),a=et(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),ue(t),r.zip_dir=!0,r.maxdist=1/0}static _wrap(e){return e==null?null:e instanceof n?e:v(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,!0),p=new n(e,r),o=Qe(e),s=et(e),a=Qe(t),m=et(t),c=a-o,u=m-s,d=Math.sqrt(c*c+u*u);if(d!==d)throw new Error("Error: maxDistance cannot be NaN");return p.zpp_inner.maxdist=d,ue(e),ue(t),p}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),ue(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=!0,ue(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 Ce._wrap(this.zpp_inner.rayAABB())}at(e,t=!1){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let p=r.x,o=r.y,s=p+e*this.zpp_inner.dirx,a=o+e*this.zpp_inner.diry;return A.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 he=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!oe.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 v(t,r=>{let p=Object.create(n.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),A._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),A._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")}};oe._createConvexResult=()=>new he;var ce=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!oe.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 v(t,r=>{let p=Object.create(n.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),A._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")}};oe._createRayResult=()=>new ce;function te(n){return n?.zpp_inner??n?._inner?.zpp_inner}function tt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(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 fe(n,e){if(te(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Te=class{static distanceBody(e,t,r,p){nt(r,"out1"),nt(p,"out2");let o=tt(e),s=tt(t);if(o.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=o.shapes.head;for(;a!=null;)U.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)U.validateShape(a.elt),a=a.next;return rt.distanceBody(o,s,r.zpp_inner,p.zpp_inner)}static distance(e,t,r,p){nt(r,"out1"),nt(p,"out2"),fe(e,"distances"),fe(t,"distances");let o=te(e),s=te(t);U.validateShape(o),U.validateShape(s);let a;E.zpp_pool==null?a=new E:(a=E.zpp_pool,E.zpp_pool=a.next,a.next=null),a.weak=!1;let m=rt.distance(o,s,r.zpp_inner,p.zpp_inner,a,1e100);return a.next=E.zpp_pool,E.zpp_pool=a,m}static intersectsBody(e,t){let r=tt(e),p=tt(t);if(r.shapes.head==null||p.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let o=r.shapes.head;for(;o!=null;)U.validateShape(o.elt),o=o.next;for(o=p.shapes.head;o!=null;)U.validateShape(o.elt),o=o.next;let s=r.aabb,a=p.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return!1;let m=r.shapes.head;for(;m!=null;){let c=p.shapes.head;for(;c!=null;){if(Je.testCollide_safe(m.elt,c.elt))return!0;c=c.next}m=m.next}return!1}static intersects(e,t){fe(e,"intersection"),fe(t,"intersection");let r=te(e),p=te(t);U.validateShape(r),U.validateShape(p);let o=r.aabb,s=p.aabb;return o.minx>s.maxx||o.maxx<s.minx||o.miny>s.maxy||o.maxy<s.miny?!1:Je.testCollide_safe(r,p)}static contains(e,t){fe(e,"containment"),fe(t,"containment");let r=te(e),p=te(t);return U.validateShape(r),U.validateShape(p),Je.containTest(r,p)}};var Le=class{static run(e,t,r,p=2,o=null,s=!0,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(o!=null&&o.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 m=r.zpp_inner;if(m._validate!=null&&m._validate(),m.x<=0||m.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(p<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(o!=null){let g=o.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 c=z(),u=a??new c.geom.GeomPolyList,d=Bt,y=t.zpp_inner;if(y._validate!=null&&y._validate(),o==null){let g=y.minx,k=y.miny,K=y.maxx,_=y.maxy;d.run(e,g,k,K,_,r,p,s,u)}else{let g=o.zpp_inner;g._validate!=null&&g._validate();let k=y.maxx-y.minx,K=y.maxy-y.miny,_=k/g.x,h=K/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let Ct=y.minx+g.x*Ye,Wt=Ye===b-1?y.maxx:Ct+g.x;for(let je=0;je<G;je++){let vt=y.miny+g.y*je,Kt=je===G-1?y.maxy:vt+g.y;d.run(e,Ct,vt,Wt,Kt,r,p,s,u)}}}return m.weak&&r.dispose(),o!=null&&o.zpp_inner.weak&&o.dispose(),u}};var H=class{constructor(){this.outer=null;this.inner=null;this.immutable=!1;this._invalidated=!1;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=!1;this.reverse_flag=!1;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=!1;this.user_length=0;this.inner=new Nt,this._invalidated=!0}static get(e,t){t==null&&(t=!1);let r=z(),p=new r.geom.Vec2List;return p.zpp_inner.inner=e,t&&(p.zpp_inner.immutable=!0),p.zpp_inner.zip_length=!0,p}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=!1,this.inner.pushmod=!1,this.zip_length=!0)}modified(){this.zip_length=!0,this.at_ite=null,this.push_ite=null}modify_test(){this._modifiable!=null&&this._modifiable()}validate(){this._invalidated&&(this._invalidated=!1,this._validate!=null&&this._validate())}invalidate(){this._invalidated=!0,this._invalidate!=null&&this._invalidate(this)}};H.internal=!1;function ne(n){if(n.outer==null){let e=z();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=E.zpp_pool,E.zpp_pool=t,n.outer.zpp_inner=n}return n.outer}function N(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!H.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}N.zpp_pool=null;N.get=function(n){let e;return N.zpp_pool==null?(H.internal=!0,e=new N,H.internal=!1):(e=N.zpp_pool,N.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=!1,e};N.prototype.zpp_inner=null;N.prototype.zpp_i=null;N.prototype.zpp_critical=null;N.prototype.zpp_next=null;N.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=!0,this.zpp_i<n?!0:(this.zpp_next=N.zpp_pool,N.zpp_pool=this,this.zpp_inner=null,!1)};N.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function w(){this.zpp_inner=null,this.zpp_inner=new H,this.zpp_inner.outer=this}w.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=z(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};w.prototype.zpp_inner=null;Object.defineProperty(w.prototype,"length",{get:function(){return this.zpp_gl()}});w.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=!1,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};w.prototype.zpp_vm=function(){this.zpp_inner.valmod()};w.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};w.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 ne(this.zpp_inner.at_ite.elt)};w.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):!0;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};w.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):!0;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};w.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=ne(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=ne(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(),ne(n)};w.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=ne(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=ne(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(),ne(n)};w.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};w.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=!1,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=!0;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};w.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()};w.prototype.empty=function(){return this.zpp_gl()==0};w.prototype.iterator=function(){return this.zpp_vm(),N.get(this)};w.prototype.copy=function(n){n==null&&(n=!1);let e=z(),t=new e.geom.Vec2List,r=N.get(this);for(;r.hasNext();){let p=r.next(),o;if(n){if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;s._validate!=null&&s._validate();let a=p.zpp_inner.x,m=p.zpp_inner;m._validate!=null&&m._validate();let c=p.zpp_inner.y,u;if(D.poolVec2==null?u=new e.geom.Vec2:(u=D.poolVec2,D.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=!1,u==D.nextVec2&&(D.nextVec2=null)),u.zpp_inner==null){let d;E.zpp_pool==null?d=new E:(d=E.zpp_pool,E.zpp_pool=d.next,d.next=null),d.weak=!1,d._immutable=!1,d.x=a,d.y=c,u.zpp_inner=d,u.zpp_inner.outer=u}else u.zpp_inner.x=a,u.zpp_inner.y=c,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=!1,o=u}else o=p;t.push(o)}return t};w.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)}};w.prototype.toString=function(){let n="[",e=!0,t=N.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=!1}return n+"]"};w.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=N.zpp_pool,N.zpp_pool=e,e.zpp_inner=null;break}return this};w.prototype[Symbol.iterator]=function(){let n=N.get(this);return{next(){return n.hasNext()?{value:n.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};w.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 re(){if(!se.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}re.prototype.zpp_inner=null;re.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=!1,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=se.zpp_pool,se.zpp_pool=e}return n};re.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 p=z(),o;if(D.poolVec2==null?o=new p.geom.Vec2:(o=D.poolVec2,D.poolVec2=o.zpp_pool,o.zpp_pool=null,o.zpp_disp=!1,o==D.nextVec2&&(D.nextVec2=null)),o.zpp_inner==null){let s;E.zpp_pool==null?s=new E:(s=E.zpp_pool,E.zpp_pool=s.next,s.next=null),s.weak=!1,s._immutable=!1,s.x=t,s.y=r,o.zpp_inner=s,o.zpp_inner.outer=o}else{if(o.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=o.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))}o.zpp_inner.weak=!1,n.wrap=o,n.wrap.zpp_inner._inuse=!0,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};re.prototype[Symbol.iterator]=function(){return{_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};var Ht=z();Ht.geom.GeomVertexIterator=re;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=!1;this._invalidated=!1;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=!1;this.reverse_flag=!1;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=!1;this.user_length=0;this.inner=new Q,this._invalidated=!0}static get(e,t){t==null&&(t=!1);let r=z(),p=new r.dynamics.ContactList;return p.zpp_inner.inner=e,t&&(p.zpp_inner.immutable=!0),p.zpp_inner.zip_length=!0,p}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=!1,this.inner.pushmod=!1,this.zip_length=!0)}modified(){this.zip_length=!0,this.at_ite=null,this.push_ite=null}modify_test(){this._modifiable!=null&&this._modifiable()}validate(){this._invalidated&&(this._invalidated=!1,this._validate!=null&&this._validate())}invalidate(){this._invalidated=!0,this._invalidate!=null&&this._invalidate(this)}};Y.internal=!1;var ze=class n{constructor(){if(!J.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof J?v(e,t=>{J.internal=!0;let r=new n;return J.internal=!1,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=z();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=E.zpp_pool,E.zpp_pool=r,e.outer.zpp_inner=e}return e.outer}};J._wrapFn=n=>v(n,e=>{J.internal=!0;let t=new ze;return J.internal=!1,t.zpp_inner=e,e.outer=t,t});var me=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return i.ValidationResult_VALID==null&&(i.internal=!0,i.ValidationResult_VALID=new n,i.internal=!1),i.ValidationResult_VALID}static get DEGENERATE(){return i.ValidationResult_DEGENERATE==null&&(i.internal=!0,i.ValidationResult_DEGENERATE=new n,i.internal=!1),i.ValidationResult_DEGENERATE}static get CONCAVE(){return i.ValidationResult_CONCAVE==null&&(i.internal=!0,i.ValidationResult_CONCAVE=new n,i.internal=!1),i.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return i.ValidationResult_SELF_INTERSECTING==null&&(i.internal=!0,i.ValidationResult_SELF_INTERSECTING=new n,i.internal=!1),i.ValidationResult_SELF_INTERSECTING}toString(){return this===i.ValidationResult_VALID?"VALID":this===i.ValidationResult_DEGENERATE?"DEGENERATE":this===i.ValidationResult_CONCAVE?"CONCAVE":this===i.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Xt=z();Xt.shape.ValidationResult=me;var de=class n{get _inner(){return this}constructor(e=!1){let t=new Ke;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(!0),t.ignore=e)}static _wrap(e){return e instanceof n?e:e?e instanceof Ke?v(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(!0),this.zpp_inner.ignore=e)}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=z();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,!0)}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=z();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,!0)}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};Ke._wrapFn=n=>v(n,e=>{let t=Object.create(de.prototype);return t.zpp_inner=e,e.outer=t,t});var ye=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return i.ArbiterType_COLLISION==null&&(i.internal=!0,i.ArbiterType_COLLISION=new n,i.internal=!1),i.ArbiterType_COLLISION}static get SENSOR(){return i.ArbiterType_SENSOR==null&&(i.internal=!0,i.ArbiterType_SENSOR=new n,i.internal=!1),i.ArbiterType_SENSOR}static get FLUID(){return i.ArbiterType_FLUID==null&&(i.internal=!0,i.ArbiterType_FLUID=new n,i.internal=!1),i.ArbiterType_FLUID}toString(){return this===i.ArbiterType_COLLISION?"COLLISION":this===i.ArbiterType_SENSOR?"SENSOR":this===i.ArbiterType_FLUID?"FLUID":""}},$t=z();$t.dynamics.ArbiterType=ye;q();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!S.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return S.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==S.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==S.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=z(),t=this.zpp_inner.immState;return t==5?(i.PreFlag_ACCEPT==null&&(i.internal=!0,i.PreFlag_ACCEPT=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT):t==1?(i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT_ONCE):t==6?(i.PreFlag_IGNORE==null&&(i.internal=!0,i.PreFlag_IGNORE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_IGNORE):(i.PreFlag_IGNORE_ONCE==null&&(i.internal=!0,i.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==S.COL}isFluidArbiter(){return this.zpp_inner.type==S.FLUID}isSensorArbiter(){return this.zpp_inner.type==S.SENSOR}totalImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),x.get(0,0,0)}toString(){let e=this.zpp_inner.type==S.COL?"CollisionArbiter":this.zpp_inner.type==S.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,p=e+"("+t.toString()+"|"+r.toString()+")";return this.zpp_inner.type==S.COL&&(p+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),p+="<-"+this.state.toString(),p}_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,p=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=p)throw new Error("Error: Arbiter does not relate to body")}},Qt=z();Qt.dynamics.Arbiter=j;var Se=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=!0,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=!0,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=!0,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=!0,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:!1}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:!1}normalImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=!1){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 p=0,o=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let m=a.oc1.wrapper()[e](t),c=m.zpp_inner;c._validate!=null&&c._validate(),p+=c.x,c._validate!=null&&c._validate(),o+=c.y,c._validate!=null&&c._validate(),s+=c.z,m.dispose()}if(a.hc2&&(!r||a.oc2.fresh)){let m=a.oc2.wrapper()[e](t),c=m.zpp_inner;c._validate!=null&&c._validate(),p+=c.x,c._validate!=null&&c._validate(),o+=c.y,c._validate!=null&&c._validate(),s+=c.z,m.dispose()}return x.get(p,o,s)}};var Ze=class extends j{constructor(){super()}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),A._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?x.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?x.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):x.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 x.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=!1){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),p=this.dragImpulse(e),o=r.zpp_inner,s=p.zpp_inner;return o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.x=s.x+o.x,o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.y=s.y+o.y,o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.z=s.z+o.z,r.dispose(),p}};var be=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!Q.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==S.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(),A._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,p=r.jnAcc;return e==null?x.get(t.nx*p,t.ny*p):(this._checkBody(e,t),e==t.b1.outer?x.get(t.nx*-p,t.ny*-p,-(t.ny*r.r1x-t.nx*r.r1y)*p):x.get(t.nx*p,t.ny*p,(t.ny*r.r2x-t.nx*r.r2y)*p))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jtAcc;return e==null?x.get(-t.ny*p,t.nx*p):(this._checkBody(e,t),e==t.b1.outer?x.get(t.ny*p,-t.nx*p,-(r.r1x*t.nx+r.r1y*t.ny)*p):x.get(-t.ny*p,t.nx*p,(r.r2x*t.nx+r.r2y*t.ny)*p))}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,p=r.jnAcc,o=r.jtAcc,s=t.jrAcc;if(e==null)return x.get(t.nx*p-t.ny*o,t.ny*p+t.nx*o,s);this._checkBody(e,t);let a=t.nx*p-t.ny*o,m=t.ny*p+t.nx*o;return e==t.b1.outer?x.get(-a,-m,-(m*r.r1x-a*r.r1y)-s):x.get(a,m,m*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")}};Q._wrapFn=n=>{Q.internal=!0;let e=new be;return Q.internal=!1,e.zpp_inner=n,n.outer=e,e};function en(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function Z(n){return n.valmod(),n.zip_length&&(n.zip_length=!1,n.user_length=en(n)),n.user_length}function C(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}C.zpp_pool=null;C.get=function(n){let e;return C.zpp_pool==null?(Y.internal=!0,e=new C,Y.internal=!1):(e=C.zpp_pool,C.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=!1,e};C.prototype.zpp_inner=null;C.prototype.zpp_i=null;C.prototype.zpp_critical=null;C.prototype.zpp_next=null;C.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=Z(this.zpp_inner.zpp_inner);return this.zpp_critical=!0,this.zpp_i<n?!0:(this.zpp_next=C.zpp_pool,C.zpp_pool=this,this.zpp_inner=null,!1)};C.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function I(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this}I.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=z(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};I.prototype.zpp_inner=null;Object.defineProperty(I.prototype,"length",{get:function(){return Z(this.zpp_inner)}});I.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};I.prototype.at=function(n){this.zpp_inner.valmod();let e=Z(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=Z(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()};I.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):!0;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=Z(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};I.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):!0;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=Z(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};I.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),Z(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=Z(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 p=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(p),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r)}return this.zpp_inner.invalidate(),e.wrapper()};I.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),Z(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=Z(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 p=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(p),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()};I.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};I.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=!1,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=!0;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};I.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;Z(this.zpp_inner)!=0;)this.pop();else for(;Z(this.zpp_inner)!=0;)this.shift()};I.prototype.empty=function(){return Z(this.zpp_inner)==0};I.prototype.iterator=function(){return this.zpp_inner.valmod(),C.get(this)};I.prototype.copy=function(n){n==null&&(n=!1);let e=z(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=C.get(this);for(;r.hasNext();){let p=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(p)}return t};I.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=C.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t))}};I.prototype.toString=function(){let n="[",e=!0;this.zpp_inner.valmod();let t=C.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=!1}return n+"]"};I.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=C.get(this);for(;e.hasNext();)try{n(e.next())}catch{e.zpp_next=C.zpp_pool,C.zpp_pool=e,e.zpp_inner=null;break}return this};I.prototype[Symbol.iterator]=function(){let n=C.get(this);return{next(){return n.hasNext()?{value:n.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};I.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=Z(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r)}catch{break}}return this};var P=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return i.CbEvent_BEGIN==null&&(i.internal=!0,i.CbEvent_BEGIN=new n,i.internal=!1),i.CbEvent_BEGIN}static get ONGOING(){return i.CbEvent_ONGOING==null&&(i.internal=!0,i.CbEvent_ONGOING=new n,i.internal=!1),i.CbEvent_ONGOING}static get END(){return i.CbEvent_END==null&&(i.internal=!0,i.CbEvent_END=new n,i.internal=!1),i.CbEvent_END}static get WAKE(){return i.CbEvent_WAKE==null&&(i.internal=!0,i.CbEvent_WAKE=new n,i.internal=!1),i.CbEvent_WAKE}static get SLEEP(){return i.CbEvent_SLEEP==null&&(i.internal=!0,i.CbEvent_SLEEP=new n,i.internal=!1),i.CbEvent_SLEEP}static get BREAK(){return i.CbEvent_BREAK==null&&(i.internal=!0,i.CbEvent_BREAK=new n,i.internal=!1),i.CbEvent_BREAK}static get PRE(){return i.CbEvent_PRE==null&&(i.internal=!0,i.CbEvent_PRE=new n,i.internal=!1),i.CbEvent_PRE}toString(){return this===i.CbEvent_BEGIN?"BEGIN":this===i.CbEvent_ONGOING?"ONGOING":this===i.CbEvent_END?"END":this===i.CbEvent_WAKE?"WAKE":this===i.CbEvent_SLEEP?"SLEEP":this===i.CbEvent_BREAK?"BREAK":this===i.CbEvent_PRE?"PRE":""}},tn=z();tn.callbacks.CbEvent=P;q();var ge=class n{get _inner(){return this}constructor(){this.zpp_inner=new M,this.zpp_inner.outer=this}static get ANY_BODY(){return M.ANY_BODY}static get ANY_CONSTRAINT(){return M.ANY_CONSTRAINT}static get ANY_SHAPE(){return M.ANY_SHAPE}static get ANY_COMPOUND(){return M.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=Yt.get(this.zpp_inner.interactors,!0)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=Ut.get(this.zpp_inner.constraints,!0)),this.zpp_inner.wrap_constraints}including(e){return new(z()).callbacks.OptionType(this).including(e)}excluding(e){return new(z()).callbacks.OptionType(this).excluding(e)}toString(){return this===M.ANY_BODY?"ANY_BODY":this===M.ANY_SHAPE?"ANY_SHAPE":this===M.ANY_COMPOUND?"ANY_COMPOUND":this===M.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e){return e instanceof n?e:e?e instanceof M?v(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}},nn=z();nn.callbacks.CbType=ge;q();var V=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return i.InteractionType_COLLISION==null&&(i.internal=!0,i.InteractionType_COLLISION=new n,i.internal=!1),i.InteractionType_COLLISION}static get SENSOR(){return i.InteractionType_SENSOR==null&&(i.internal=!0,i.InteractionType_SENSOR=new n,i.internal=!1),i.InteractionType_SENSOR}static get FLUID(){return i.InteractionType_FLUID==null&&(i.internal=!0,i.InteractionType_FLUID=new n,i.internal=!1),i.InteractionType_FLUID}static get ANY(){return i.InteractionType_ANY==null&&(i.internal=!0,i.InteractionType_ANY=new n,i.internal=!1),i.InteractionType_ANY}toString(){return this===i.InteractionType_COLLISION?"COLLISION":this===i.InteractionType_SENSOR?"SENSOR":this===i.InteractionType_FLUID?"FLUID":this===i.InteractionType_ANY?"ANY":""}},rn=z();rn.callbacks.InteractionType=V;var we=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return i.PreFlag_ACCEPT==null&&(i.internal=!0,i.PreFlag_ACCEPT=new n,i.internal=!1),i.PreFlag_ACCEPT}static get IGNORE(){return i.PreFlag_IGNORE==null&&(i.internal=!0,i.PreFlag_IGNORE=new n,i.internal=!1),i.PreFlag_IGNORE}static get ACCEPT_ONCE(){return i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new n,i.internal=!1),i.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return i.PreFlag_IGNORE_ONCE==null&&(i.internal=!0,i.PreFlag_IGNORE_ONCE=new n,i.internal=!1),i.PreFlag_IGNORE_ONCE}toString(){return this===i.PreFlag_ACCEPT?"ACCEPT":this===i.PreFlag_IGNORE?"IGNORE":this===i.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===i.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},pn=z();pn.callbacks.PreFlag=we;var Ee=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new R,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 R?v(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}},on=z();on.callbacks.OptionType=Ee;function sn(n){return n===P.BEGIN?0:n===P.END?1:n===P.WAKE?2:n===P.SLEEP?3:n===P.BREAK?4:n===P.PRE?5:n===P.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!T.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null}static _wrap(e){return e instanceof n?e:e&&e instanceof T?v(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 T.types[this.zpp_inner.type]}get event(){return T.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(T.events[this.zpp_inner.event]!=e){let t=sn(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:ve._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 p=t.zpp_inner.wrap_listeners;p.zpp_inner.reverse_flag?p.push(this):p.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,p;switch(r.itype){case 1:p="COLLISION";break;case 2:p="SENSOR";break;case 4:p="FLUID";break;default:p="ALL"}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+p+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+p+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var Pe=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return i.ListenerType_BODY==null&&(i.internal=!0,i.ListenerType_BODY=new n,i.internal=!1),i.ListenerType_BODY}static get CONSTRAINT(){return i.ListenerType_CONSTRAINT==null&&(i.internal=!0,i.ListenerType_CONSTRAINT=new n,i.internal=!1),i.ListenerType_CONSTRAINT}static get INTERACTION(){return i.ListenerType_INTERACTION==null&&(i.internal=!0,i.ListenerType_INTERACTION=new n,i.internal=!1),i.ListenerType_INTERACTION}static get PRE(){return i.ListenerType_PRE==null&&(i.internal=!0,i.ListenerType_PRE=new n,i.internal=!1),i.ListenerType_PRE}toString(){return this===i.ListenerType_BODY?"BODY":this===i.ListenerType_CONSTRAINT?"CONSTRAINT":this===i.ListenerType_INTERACTION?"INTERACTION":this===i.ListenerType_PRE?"PRE":""}},an=z();an.callbacks.ListenerType=Pe;q();var F=class{constructor(){this.zpp_inner=null;if(!$.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return T.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return""}};var Ve=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 Oe=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 ke=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 Re=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 Be=class extends B{constructor(e,t,r,p=0){if(T.internal=!0,super(),T.internal=!1,r==null)throw new Error("Error: BodyListener::handler cannot be null");let o;if(e===P.WAKE)o=2;else if(e===P.SLEEP)o=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new It(R.argument(t),o,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=p}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 Fe=class extends B{constructor(e,t,r,p=0){if(T.internal=!0,super(),T.internal=!1,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let o;if(e===P.WAKE)o=2;else if(e===P.SLEEP)o=3;else if(e===P.BREAK)o=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new At(R.argument(t),o,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=p}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 Ge(n){return n===V.COLLISION?1:n===V.SENSOR?2:n===V.FLUID?4:7}function ie(n){return n==1?V.COLLISION:n==2?V.SENSOR:n==4?V.FLUID:n==7?V.ANY:null}var De=class extends B{constructor(e,t,r,p,o,s=0){if(T.internal=!0,super(),T.internal=!1,o==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===P.BEGIN)a=0;else if(e===P.END)a=1;else if(e===P.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 We(R.argument(r),R.argument(p),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=o,t==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Ge(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 ie(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ge(e))}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e}};var Me=class extends B{constructor(e,t,r,p,o=0,s=!1){if(T.internal=!0,super(),T.internal=!1,p==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new We(R.argument(t),R.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=o,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=p,e==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ge(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 ie(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ge(e))}};var Ue=class n extends Ie{constructor(e,t=!1){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r=new kt(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:v(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 A;return e.zpp_inner._inuse=!0,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 xe(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=!1;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=!0;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):x.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let p=this.zpp_inner.bodies[r];if(p.body!=null){let o=!1;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==p.body){o=!0;break}o||e(p.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:p,unwrapElement:o}=n,s=z(),a=s.__zpp,m=()=>a.util[r],c=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!m().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=m();return u.zpp_pool==null?(b.internal=!0,h=new u,b.internal=!1):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=!1,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=!1,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=!0,this.zpp_i<h?!0:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,!1)},u.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function d(){this.zpp_inner=null,this.zpp_inner=new(m()),this.zpp_inner.outer=this}d.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new d;for(let b=0;b<_.length;b++)h.push(_[b]);return h},d.prototype.zpp_inner=null,d.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=!1,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=!1,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(d.prototype,"length",{get:function(){return y(this)}}),d.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(o(_))},d.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 p(this.zpp_inner.at_ite.elt)},d.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(_):!0;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(o(_)):(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,o(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},d.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(_):!0;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,o(_))):this.zpp_inner.inner.add(o(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},d.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=p(_);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=p(_);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(),p(_)},d.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=p(_);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=p(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),p(_)},d.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},d.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=!1,b=this.zpp_inner.inner.head,G=o(_);for(;b!=null;){if(b.elt==G){h=!0;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},d.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()},d.prototype.empty=function(){return this.zpp_inner.inner.head==null},d.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},d.prototype.copy=function(_){_==null&&(_=!1);let h=new d,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},d.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))}},d.prototype.toString=function(){let _="[",h=!0,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=!1}return _+"]"},d.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},d.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},d.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},d.prototype[Symbol.iterator]=function(){let _=u.get(this);return{next(){return _.hasNext()?{value:_.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};let g=c(),k=e+"Iterator",K=e+"List";return g[k]=u,g[K]=d,{Iterator:u,List:d}}var X=n=>n.outer,W=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:W});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:X,unwrapElement:W});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:X,unwrapElement:W});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:X,unwrapElement:W});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:X,unwrapElement:W});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:X,unwrapElement:W});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:X,unwrapElement:W});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:X,unwrapElement:W});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:W});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:W});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 pe(n){if(n.outer==null){let e=z();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=E.zpp_pool,E.zpp_pool=t,n.outer.zpp_inner=n}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=!1,this._length=0,this.inner=null,w.call(this),this.at_ite=null,this.at_index=0,this.zip_length=!0,this._length=0}for(let n in w.prototype)L.prototype[n]=w.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:!0});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=!1;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=!1);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=!1}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=!0,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 pe(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):!0;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):!0;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=pe(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=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e)}return this.zpp_inner.invalidate(),pe(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=pe(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=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop()}return this.zpp_inner.invalidate(),pe(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=!1,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=!0;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 ln=z(),_n=ln.__zpp;_n.util.ZPP_MixVec2List=L;var f=z();f.Config=Object.assign(f.Config||{},Pt);f.util.Debug=$e;f.geom.Vec2=A;f.geom.Vec3=x;f.geom.Mat23=_e;f.geom.MatMN=xe;f.geom.AABB=Ce;f.geom.Winding=it;f.geom.Ray=Ae;f.geom.ConvexResult=he;f.geom.RayResult=ce;f.geom.Geom=Te;f.geom.GeomPoly=ee;f.geom.MarchingSquares=Le;f.geom.Vec2Iterator=N;f.geom.Vec2List=w;f.geom.GeomVertexIterator=re;f.__zpp.geom.ZPP_GeomVertexIterator=se;f.__zpp.util.ZPP_ContactList=Y;f.phys.Interactor=pt;f.phys.Body=ae;Gt(n=>ae._wrap(n));f.phys.BodyType=Ne;f.phys.Compound=Xe;Mt(n=>Xe._wrap(n));f.phys.FluidProperties=ot;f.phys.Material=at;f.phys.GravMassMode=lt;f.phys.InertiaMode=_t;f.phys.MassMode=ut;f.shape.Shape=He;Dt(n=>He._wrap(n));f.shape.Circle=ht;f.shape.Polygon=le;f.shape.Capsule=ct;f.shape.Edge=ze;f.shape.ShapeType=st;f.shape.ValidationResult=me;f.space.Space=ve;f.space.Broadphase=ft;f.dynamics.InteractionFilter=zt;f.dynamics.InteractionGroup=de;f.dynamics.ArbiterType=ye;f.dynamics.Arbiter=j;S._createColArb=()=>new Se;S._createFluidArb=()=>new Ze;f.dynamics.Contact=be;f.dynamics.ContactIterator=C;f.dynamics.ContactList=I;f.callbacks.CbEvent=P;f.callbacks.CbType=ge;f.callbacks.InteractionType=V;f.callbacks.PreFlag=we;f.callbacks.OptionType=Ee;f.callbacks.Listener=B;f.callbacks.ListenerType=Pe;f.callbacks.Callback=F;$._createBodyCb=()=>new Ve;$._createConCb=()=>new Oe;$._createIntCb=()=>new ke;$._createPreCb=()=>new Re;f.callbacks.BodyListener=Be;f.callbacks.ConstraintListener=Fe;f.callbacks.InteractionListener=De;f.callbacks.PreListener=Me;f.constraint.Constraint=Ie;Tt._createFn=(...n)=>new mt(...n);Lt._createFn=(...n)=>new dt(...n);St._createFn=(...n)=>new yt(...n);Zt._createFn=(...n)=>new bt(...n);Vt._createFn=(...n)=>new gt(...n);Ot._createFn=(...n)=>new wt(...n);Rt._createFn=(...n)=>new Et(...n);f.constraint.UserConstraint=Ue;var xt=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,p){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,p){}drawSolidCapsule(e,t,r,p){}drawPoint(e,t){}};function un(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof ee){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 c=0;c<n.length;c++)if(n[c]==null)throw new Error("Error: vertices["+c+"] is null");t=new ee(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 c=t.simplify(r);if(t.dispose(),t=c,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let c=[],u=t.forwardIterator();for(;u.hasNext();){let d=u.next();c.push(A.get(d.x,d.y))}t.dispose(),c.reverse(),t=new ee(c)}let p=e?.material,o=e?.filter,s=e?.delaunay??!1,a=new ae(e?.type??Ne.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new le(t,p,o)),t.dispose(),a;let m=t.convexDecomposition(s);for(let c of m)a.shapes.add(new le(c,p,o));return t.dispose(),a}var Yo="3.16.2";export{Ce as AABB,mt as AngleJoint,j as Arbiter,ye as ArbiterType,ae as Body,Ve as BodyCallback,Be as BodyListener,Ne as BodyType,ft as Broadphase,F as Callback,ct as Capsule,P as CbEvent,ge as CbType,ht as Circle,Se as CollisionArbiter,Xe as Compound,Ie as Constraint,Oe as ConstraintCallback,Fe as ConstraintListener,be as Contact,he as ConvexResult,xt as DebugDraw,qt as DebugDrawFlags,dt as DistanceJoint,ze as Edge,Ze as FluidArbiter,ot as FluidProperties,Te as Geom,ee as GeomPoly,lt as GravMassMode,_t as InertiaMode,ke as InteractionCallback,zt as InteractionFilter,de as InteractionGroup,De as InteractionListener,V as InteractionType,pt as Interactor,yt as LineJoint,B as Listener,Pe as ListenerType,Le as MarchingSquares,ut as MassMode,_e as Mat23,xe as MatMN,at as Material,bt as MotorJoint,Jt as NapeList,Ee as OptionType,gt as PivotJoint,le as Polygon,Re as PreCallback,we as PreFlag,Me as PreListener,wt as PulleyJoint,Ae as Ray,ce as RayResult,He as Shape,st as ShapeType,ve as Space,Ue as UserConstraint,Yo as VERSION,me as ValidationResult,A as Vec2,x as Vec3,Et as WeldJoint,it as Winding,un as createConcaveBody};
|
|
1
|
+
import{$ as Ne,A as qe,B as Ft,C as rt,D as J,E as z,F as q,G as v,H as A,I as x,J as xe,K as Ce,L as it,M as se,N as ee,O as Gt,P as Dt,Q as Mt,R as pt,S as Jt,T as ot,U as st,V as He,W as qt,X as ve,Y as Ut,Z as Yt,_ as ae,a as i,aa as Xe,b as D,ba as at,c as Nt,ca as lt,d as $,da as _t,e as M,ea as ut,f as T,fa as ht,g as It,ga as le,h as At,ha as ct,i as We,ia as ft,j as R,ja as zt,k as Tt,ka as Ie,l as E,la as mt,m as Lt,ma as dt,n as St,na as yt,o as Zt,oa as bt,p as Vt,pa as gt,q as Ot,qa as wt,r as kt,ra as Et,s as Rt,t as S,u as Q,v as Ke,w as Je,x as oe,y as U,z as Bt}from"./chunk-SQVUZDT6.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=z();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 $e=class{static version(){return"Nape 2.0.19"}static clearObjectPools(){let e=z(),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 _e=class n{get _inner(){return this}constructor(e=1,t=0,r=0,p=1,o=0,s=0){let a=qe.get();this.zpp_inner=a,a.outer=this;let m=["a","b","tx","c","d","ty"],c=[e,t,o,r,p,s];for(let u=0;u<c.length;u++)if(c[u]!==c[u])throw new Error("Error: Mat23::"+m[u]+" cannot be NaN");a.setas(e,t,r,p,o,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 qe?v(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!1;let r=this.zpp_inner,p=e.zpp_inner,o=r.a-p.a,s=r.b-p.b,a=r.c-p.c,m=r.d-p.d,c=r.tx-p.tx,u=r.ty-p.ty;return(o<0?-o:o)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(m<0?-m:m)<=t&&(c<0?-c:c)<=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,p=1,o=0,s=0){return this.zpp_inner.setas(e,t,r,p,o,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:p}=this.zpp_inner,o=e*e+t*t+r*r+p*p,s=e*p-t*r;s<0&&(s=-s);let a=z();return o>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:p,tx:o,ty:s}=this.zpp_inner,a=1/(e*p-t*r);return new n(p*a,-t*a,-r*a,e*a,(t*s-p*o)*a,(r*o-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return new n(e,r,t,p,-e*o-r*s,-t*o-p*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=!1,r=!1){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 p=e.zpp_inner.x,o=e.zpp_inner.y,{a:s,b:a,c:m,d:c,tx:u,ty:d}=this.zpp_inner,y,g;t?(y=p*s+o*a,g=p*m+o*c):(y=p*s+o*a+u,g=p*m+o*c+d);let k=A.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),k}inverseTransform(e,t=!1,r=!1){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:p,b:o,c:s,d:a,tx:m,ty:c}=this.zpp_inner,u=1/(p*a-o*s);e.zpp_inner.validate();let d=e.zpp_inner.x,y=e.zpp_inner.y,g,k;if(t)g=(d*a-y*o)*u,k=(y*p-d*s)*u;else{let _=d-m,h=y-c;g=(_*a-h*o)*u,k=(h*p-_*s)*u}let K=A.get(g,k,r);return e.zpp_inner.weak&&e.dispose(),K}equiorthogonal(){if(this.singular())return!1;let{a:e,b:t,c:r,d:p}=this.zpp_inner,o=z(),s=e*t+r*p;if(s*s>=o.Config.epsilon)return!1;let a=e*e+t*t-r*r-p*p;return a*a<o.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:p}=this.zpp_inner,o=z(),s=e*t+r*p;if(s*s>=o.Config.epsilon)return!1;let a=e*e+t*t-1,m=r*r+p*p-1;return a*a<o.Config.epsilon&&m*m<o.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:p,d:o}=this.zpp_inner,s=z(),a=Math.sqrt(t*t+p*p),m=Math.sqrt(r*r+o*o);if(a*a<s.Config.epsilon||m*m<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let c=e?(a+m)/2:1;a=c/a,m=c/m,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*m,this.d=this.zpp_inner.d*m;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,d=.25*Math.PI-.5*Math.acos(u/(c*c));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(d=-d);let y=Math.sin(d),g=Math.cos(d),k=this.zpp_inner.a*g-this.zpp_inner.c*y,K=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=k,this.d=h,this.b=K,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(!0)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(!1)}toString(){let{a:e,b:t,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return"{ a: "+e+" b: "+t+" c: "+r+" d: "+p+" tx: "+o+" ty: "+s+" }"}};qe._wrapFn=n=>v(n,e=>{let t=Object.create(_e.prototype);return t.zpp_inner=e,e.outer=t,t});function Qe(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 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.y}function ue(n){n.zpp_inner.weak&&n.dispose()}var Ae=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 Ft;this.zpp_inner=r;let p=Qe(e),o=et(e);r.origin.zpp_inner.x=p,r.origin.zpp_inner.y=o,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),ue(e);let s=Qe(t),a=et(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),ue(t),r.zip_dir=!0,r.maxdist=1/0}static _wrap(e){return e==null?null:e instanceof n?e:v(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,!0),p=new n(e,r),o=Qe(e),s=et(e),a=Qe(t),m=et(t),c=a-o,u=m-s,d=Math.sqrt(c*c+u*u);if(d!==d)throw new Error("Error: maxDistance cannot be NaN");return p.zpp_inner.maxdist=d,ue(e),ue(t),p}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),ue(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=!0,ue(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 Ce._wrap(this.zpp_inner.rayAABB())}at(e,t=!1){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let p=r.x,o=r.y,s=p+e*this.zpp_inner.dirx,a=o+e*this.zpp_inner.diry;return A.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 he=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!oe.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 v(t,r=>{let p=Object.create(n.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),A._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),A._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")}};oe._createConvexResult=()=>new he;var ce=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!oe.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 v(t,r=>{let p=Object.create(n.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),A._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")}};oe._createRayResult=()=>new ce;function te(n){return n?.zpp_inner??n?._inner?.zpp_inner}function tt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(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 fe(n,e){if(te(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Te=class{static distanceBody(e,t,r,p){nt(r,"out1"),nt(p,"out2");let o=tt(e),s=tt(t);if(o.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=o.shapes.head;for(;a!=null;)U.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)U.validateShape(a.elt),a=a.next;return rt.distanceBody(o,s,r.zpp_inner,p.zpp_inner)}static distance(e,t,r,p){nt(r,"out1"),nt(p,"out2"),fe(e,"distances"),fe(t,"distances");let o=te(e),s=te(t);U.validateShape(o),U.validateShape(s);let a;E.zpp_pool==null?a=new E:(a=E.zpp_pool,E.zpp_pool=a.next,a.next=null),a.weak=!1;let m=rt.distance(o,s,r.zpp_inner,p.zpp_inner,a,1e100);return a.next=E.zpp_pool,E.zpp_pool=a,m}static intersectsBody(e,t){let r=tt(e),p=tt(t);if(r.shapes.head==null||p.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let o=r.shapes.head;for(;o!=null;)U.validateShape(o.elt),o=o.next;for(o=p.shapes.head;o!=null;)U.validateShape(o.elt),o=o.next;let s=r.aabb,a=p.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return!1;let m=r.shapes.head;for(;m!=null;){let c=p.shapes.head;for(;c!=null;){if(Je.testCollide_safe(m.elt,c.elt))return!0;c=c.next}m=m.next}return!1}static intersects(e,t){fe(e,"intersection"),fe(t,"intersection");let r=te(e),p=te(t);U.validateShape(r),U.validateShape(p);let o=r.aabb,s=p.aabb;return o.minx>s.maxx||o.maxx<s.minx||o.miny>s.maxy||o.maxy<s.miny?!1:Je.testCollide_safe(r,p)}static contains(e,t){fe(e,"containment"),fe(t,"containment");let r=te(e),p=te(t);return U.validateShape(r),U.validateShape(p),Je.containTest(r,p)}};var Le=class{static run(e,t,r,p=2,o=null,s=!0,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(o!=null&&o.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 m=r.zpp_inner;if(m._validate!=null&&m._validate(),m.x<=0||m.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(p<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(o!=null){let g=o.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 c=z(),u=a??new c.geom.GeomPolyList,d=Bt,y=t.zpp_inner;if(y._validate!=null&&y._validate(),o==null){let g=y.minx,k=y.miny,K=y.maxx,_=y.maxy;d.run(e,g,k,K,_,r,p,s,u)}else{let g=o.zpp_inner;g._validate!=null&&g._validate();let k=y.maxx-y.minx,K=y.maxy-y.miny,_=k/g.x,h=K/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let Ct=y.minx+g.x*Ye,Wt=Ye===b-1?y.maxx:Ct+g.x;for(let je=0;je<G;je++){let vt=y.miny+g.y*je,Kt=je===G-1?y.maxy:vt+g.y;d.run(e,Ct,vt,Wt,Kt,r,p,s,u)}}}return m.weak&&r.dispose(),o!=null&&o.zpp_inner.weak&&o.dispose(),u}};var H=class{constructor(){this.outer=null;this.inner=null;this.immutable=!1;this._invalidated=!1;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=!1;this.reverse_flag=!1;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=!1;this.user_length=0;this.inner=new Nt,this._invalidated=!0}static get(e,t){t==null&&(t=!1);let r=z(),p=new r.geom.Vec2List;return p.zpp_inner.inner=e,t&&(p.zpp_inner.immutable=!0),p.zpp_inner.zip_length=!0,p}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=!1,this.inner.pushmod=!1,this.zip_length=!0)}modified(){this.zip_length=!0,this.at_ite=null,this.push_ite=null}modify_test(){this._modifiable!=null&&this._modifiable()}validate(){this._invalidated&&(this._invalidated=!1,this._validate!=null&&this._validate())}invalidate(){this._invalidated=!0,this._invalidate!=null&&this._invalidate(this)}};H.internal=!1;function ne(n){if(n.outer==null){let e=z();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=E.zpp_pool,E.zpp_pool=t,n.outer.zpp_inner=n}return n.outer}function N(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!H.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}N.zpp_pool=null;N.get=function(n){let e;return N.zpp_pool==null?(H.internal=!0,e=new N,H.internal=!1):(e=N.zpp_pool,N.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=!1,e};N.prototype.zpp_inner=null;N.prototype.zpp_i=null;N.prototype.zpp_critical=null;N.prototype.zpp_next=null;N.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=!0,this.zpp_i<n?!0:(this.zpp_next=N.zpp_pool,N.zpp_pool=this,this.zpp_inner=null,!1)};N.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function w(){this.zpp_inner=null,this.zpp_inner=new H,this.zpp_inner.outer=this}w.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=z(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};w.prototype.zpp_inner=null;Object.defineProperty(w.prototype,"length",{get:function(){return this.zpp_gl()}});w.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=!1,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};w.prototype.zpp_vm=function(){this.zpp_inner.valmod()};w.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};w.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 ne(this.zpp_inner.at_ite.elt)};w.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):!0;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};w.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):!0;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};w.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=ne(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=ne(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(),ne(n)};w.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=ne(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=ne(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(),ne(n)};w.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};w.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=!1,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=!0;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};w.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()};w.prototype.empty=function(){return this.zpp_gl()==0};w.prototype.iterator=function(){return this.zpp_vm(),N.get(this)};w.prototype.copy=function(n){n==null&&(n=!1);let e=z(),t=new e.geom.Vec2List,r=N.get(this);for(;r.hasNext();){let p=r.next(),o;if(n){if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;s._validate!=null&&s._validate();let a=p.zpp_inner.x,m=p.zpp_inner;m._validate!=null&&m._validate();let c=p.zpp_inner.y,u;if(D.poolVec2==null?u=new e.geom.Vec2:(u=D.poolVec2,D.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=!1,u==D.nextVec2&&(D.nextVec2=null)),u.zpp_inner==null){let d;E.zpp_pool==null?d=new E:(d=E.zpp_pool,E.zpp_pool=d.next,d.next=null),d.weak=!1,d._immutable=!1,d.x=a,d.y=c,u.zpp_inner=d,u.zpp_inner.outer=u}else u.zpp_inner.x=a,u.zpp_inner.y=c,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=!1,o=u}else o=p;t.push(o)}return t};w.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)}};w.prototype.toString=function(){let n="[",e=!0,t=N.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=!1}return n+"]"};w.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=N.zpp_pool,N.zpp_pool=e,e.zpp_inner=null;break}return this};w.prototype[Symbol.iterator]=function(){let n=N.get(this);return{next(){return n.hasNext()?{value:n.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};w.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 re(){if(!se.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}re.prototype.zpp_inner=null;re.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=!1,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=se.zpp_pool,se.zpp_pool=e}return n};re.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 p=z(),o;if(D.poolVec2==null?o=new p.geom.Vec2:(o=D.poolVec2,D.poolVec2=o.zpp_pool,o.zpp_pool=null,o.zpp_disp=!1,o==D.nextVec2&&(D.nextVec2=null)),o.zpp_inner==null){let s;E.zpp_pool==null?s=new E:(s=E.zpp_pool,E.zpp_pool=s.next,s.next=null),s.weak=!1,s._immutable=!1,s.x=t,s.y=r,o.zpp_inner=s,o.zpp_inner.outer=o}else{if(o.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=o.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))}o.zpp_inner.weak=!1,n.wrap=o,n.wrap.zpp_inner._inuse=!0,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};re.prototype[Symbol.iterator]=function(){return{_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};var Ht=z();Ht.geom.GeomVertexIterator=re;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=!1;this._invalidated=!1;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=!1;this.reverse_flag=!1;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=!1;this.user_length=0;this.inner=new Q,this._invalidated=!0}static get(e,t){t==null&&(t=!1);let r=z(),p=new r.dynamics.ContactList;return p.zpp_inner.inner=e,t&&(p.zpp_inner.immutable=!0),p.zpp_inner.zip_length=!0,p}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=!1,this.inner.pushmod=!1,this.zip_length=!0)}modified(){this.zip_length=!0,this.at_ite=null,this.push_ite=null}modify_test(){this._modifiable!=null&&this._modifiable()}validate(){this._invalidated&&(this._invalidated=!1,this._validate!=null&&this._validate())}invalidate(){this._invalidated=!0,this._invalidate!=null&&this._invalidate(this)}};Y.internal=!1;var ze=class n{constructor(){if(!J.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof J?v(e,t=>{J.internal=!0;let r=new n;return J.internal=!1,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=z();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=E.zpp_pool,E.zpp_pool=r,e.outer.zpp_inner=e}return e.outer}};J._wrapFn=n=>v(n,e=>{J.internal=!0;let t=new ze;return J.internal=!1,t.zpp_inner=e,e.outer=t,t});var me=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return i.ValidationResult_VALID==null&&(i.internal=!0,i.ValidationResult_VALID=new n,i.internal=!1),i.ValidationResult_VALID}static get DEGENERATE(){return i.ValidationResult_DEGENERATE==null&&(i.internal=!0,i.ValidationResult_DEGENERATE=new n,i.internal=!1),i.ValidationResult_DEGENERATE}static get CONCAVE(){return i.ValidationResult_CONCAVE==null&&(i.internal=!0,i.ValidationResult_CONCAVE=new n,i.internal=!1),i.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return i.ValidationResult_SELF_INTERSECTING==null&&(i.internal=!0,i.ValidationResult_SELF_INTERSECTING=new n,i.internal=!1),i.ValidationResult_SELF_INTERSECTING}toString(){return this===i.ValidationResult_VALID?"VALID":this===i.ValidationResult_DEGENERATE?"DEGENERATE":this===i.ValidationResult_CONCAVE?"CONCAVE":this===i.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Xt=z();Xt.shape.ValidationResult=me;var de=class n{get _inner(){return this}constructor(e=!1){let t=new Ke;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(!0),t.ignore=e)}static _wrap(e){return e instanceof n?e:e?e instanceof Ke?v(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(!0),this.zpp_inner.ignore=e)}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=z();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,!0)}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=z();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,!0)}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};Ke._wrapFn=n=>v(n,e=>{let t=Object.create(de.prototype);return t.zpp_inner=e,e.outer=t,t});var ye=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return i.ArbiterType_COLLISION==null&&(i.internal=!0,i.ArbiterType_COLLISION=new n,i.internal=!1),i.ArbiterType_COLLISION}static get SENSOR(){return i.ArbiterType_SENSOR==null&&(i.internal=!0,i.ArbiterType_SENSOR=new n,i.internal=!1),i.ArbiterType_SENSOR}static get FLUID(){return i.ArbiterType_FLUID==null&&(i.internal=!0,i.ArbiterType_FLUID=new n,i.internal=!1),i.ArbiterType_FLUID}toString(){return this===i.ArbiterType_COLLISION?"COLLISION":this===i.ArbiterType_SENSOR?"SENSOR":this===i.ArbiterType_FLUID?"FLUID":""}},$t=z();$t.dynamics.ArbiterType=ye;q();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!S.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return S.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==S.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==S.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=z(),t=this.zpp_inner.immState;return t==5?(i.PreFlag_ACCEPT==null&&(i.internal=!0,i.PreFlag_ACCEPT=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT):t==1?(i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT_ONCE):t==6?(i.PreFlag_IGNORE==null&&(i.internal=!0,i.PreFlag_IGNORE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_IGNORE):(i.PreFlag_IGNORE_ONCE==null&&(i.internal=!0,i.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==S.COL}isFluidArbiter(){return this.zpp_inner.type==S.FLUID}isSensorArbiter(){return this.zpp_inner.type==S.SENSOR}totalImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),x.get(0,0,0)}toString(){let e=this.zpp_inner.type==S.COL?"CollisionArbiter":this.zpp_inner.type==S.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,p=e+"("+t.toString()+"|"+r.toString()+")";return this.zpp_inner.type==S.COL&&(p+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),p+="<-"+this.state.toString(),p}_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,p=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=p)throw new Error("Error: Arbiter does not relate to body")}},Qt=z();Qt.dynamics.Arbiter=j;var Se=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=!0,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=!0,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=!0,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=!0,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:!1}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:!1}normalImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=!1){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 p=0,o=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let m=a.oc1.wrapper()[e](t),c=m.zpp_inner;c._validate!=null&&c._validate(),p+=c.x,c._validate!=null&&c._validate(),o+=c.y,c._validate!=null&&c._validate(),s+=c.z,m.dispose()}if(a.hc2&&(!r||a.oc2.fresh)){let m=a.oc2.wrapper()[e](t),c=m.zpp_inner;c._validate!=null&&c._validate(),p+=c.x,c._validate!=null&&c._validate(),o+=c.y,c._validate!=null&&c._validate(),s+=c.z,m.dispose()}return x.get(p,o,s)}};var Ze=class extends j{constructor(){super()}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),A._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?x.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?x.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):x.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 x.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=!1){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),p=this.dragImpulse(e),o=r.zpp_inner,s=p.zpp_inner;return o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.x=s.x+o.x,o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.y=s.y+o.y,o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.z=s.z+o.z,r.dispose(),p}};var be=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!Q.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==S.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(),A._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,p=r.jnAcc;return e==null?x.get(t.nx*p,t.ny*p):(this._checkBody(e,t),e==t.b1.outer?x.get(t.nx*-p,t.ny*-p,-(t.ny*r.r1x-t.nx*r.r1y)*p):x.get(t.nx*p,t.ny*p,(t.ny*r.r2x-t.nx*r.r2y)*p))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jtAcc;return e==null?x.get(-t.ny*p,t.nx*p):(this._checkBody(e,t),e==t.b1.outer?x.get(t.ny*p,-t.nx*p,-(r.r1x*t.nx+r.r1y*t.ny)*p):x.get(-t.ny*p,t.nx*p,(r.r2x*t.nx+r.r2y*t.ny)*p))}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,p=r.jnAcc,o=r.jtAcc,s=t.jrAcc;if(e==null)return x.get(t.nx*p-t.ny*o,t.ny*p+t.nx*o,s);this._checkBody(e,t);let a=t.nx*p-t.ny*o,m=t.ny*p+t.nx*o;return e==t.b1.outer?x.get(-a,-m,-(m*r.r1x-a*r.r1y)-s):x.get(a,m,m*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")}};Q._wrapFn=n=>{Q.internal=!0;let e=new be;return Q.internal=!1,e.zpp_inner=n,n.outer=e,e};function en(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function Z(n){return n.valmod(),n.zip_length&&(n.zip_length=!1,n.user_length=en(n)),n.user_length}function C(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}C.zpp_pool=null;C.get=function(n){let e;return C.zpp_pool==null?(Y.internal=!0,e=new C,Y.internal=!1):(e=C.zpp_pool,C.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=!1,e};C.prototype.zpp_inner=null;C.prototype.zpp_i=null;C.prototype.zpp_critical=null;C.prototype.zpp_next=null;C.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=Z(this.zpp_inner.zpp_inner);return this.zpp_critical=!0,this.zpp_i<n?!0:(this.zpp_next=C.zpp_pool,C.zpp_pool=this,this.zpp_inner=null,!1)};C.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function I(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this}I.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=z(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};I.prototype.zpp_inner=null;Object.defineProperty(I.prototype,"length",{get:function(){return Z(this.zpp_inner)}});I.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};I.prototype.at=function(n){this.zpp_inner.valmod();let e=Z(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=Z(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()};I.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):!0;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=Z(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};I.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):!0;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=Z(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};I.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),Z(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=Z(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 p=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(p),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r)}return this.zpp_inner.invalidate(),e.wrapper()};I.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),Z(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=Z(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 p=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(p),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()};I.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};I.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=!1,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=!0;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};I.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;Z(this.zpp_inner)!=0;)this.pop();else for(;Z(this.zpp_inner)!=0;)this.shift()};I.prototype.empty=function(){return Z(this.zpp_inner)==0};I.prototype.iterator=function(){return this.zpp_inner.valmod(),C.get(this)};I.prototype.copy=function(n){n==null&&(n=!1);let e=z(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=C.get(this);for(;r.hasNext();){let p=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(p)}return t};I.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=C.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t))}};I.prototype.toString=function(){let n="[",e=!0;this.zpp_inner.valmod();let t=C.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=!1}return n+"]"};I.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=C.get(this);for(;e.hasNext();)try{n(e.next())}catch{e.zpp_next=C.zpp_pool,C.zpp_pool=e,e.zpp_inner=null;break}return this};I.prototype[Symbol.iterator]=function(){let n=C.get(this);return{next(){return n.hasNext()?{value:n.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};I.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=Z(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r)}catch{break}}return this};var P=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return i.CbEvent_BEGIN==null&&(i.internal=!0,i.CbEvent_BEGIN=new n,i.internal=!1),i.CbEvent_BEGIN}static get ONGOING(){return i.CbEvent_ONGOING==null&&(i.internal=!0,i.CbEvent_ONGOING=new n,i.internal=!1),i.CbEvent_ONGOING}static get END(){return i.CbEvent_END==null&&(i.internal=!0,i.CbEvent_END=new n,i.internal=!1),i.CbEvent_END}static get WAKE(){return i.CbEvent_WAKE==null&&(i.internal=!0,i.CbEvent_WAKE=new n,i.internal=!1),i.CbEvent_WAKE}static get SLEEP(){return i.CbEvent_SLEEP==null&&(i.internal=!0,i.CbEvent_SLEEP=new n,i.internal=!1),i.CbEvent_SLEEP}static get BREAK(){return i.CbEvent_BREAK==null&&(i.internal=!0,i.CbEvent_BREAK=new n,i.internal=!1),i.CbEvent_BREAK}static get PRE(){return i.CbEvent_PRE==null&&(i.internal=!0,i.CbEvent_PRE=new n,i.internal=!1),i.CbEvent_PRE}toString(){return this===i.CbEvent_BEGIN?"BEGIN":this===i.CbEvent_ONGOING?"ONGOING":this===i.CbEvent_END?"END":this===i.CbEvent_WAKE?"WAKE":this===i.CbEvent_SLEEP?"SLEEP":this===i.CbEvent_BREAK?"BREAK":this===i.CbEvent_PRE?"PRE":""}},tn=z();tn.callbacks.CbEvent=P;q();var ge=class n{get _inner(){return this}constructor(){this.zpp_inner=new M,this.zpp_inner.outer=this}static get ANY_BODY(){return M.ANY_BODY}static get ANY_CONSTRAINT(){return M.ANY_CONSTRAINT}static get ANY_SHAPE(){return M.ANY_SHAPE}static get ANY_COMPOUND(){return M.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=Yt.get(this.zpp_inner.interactors,!0)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=Ut.get(this.zpp_inner.constraints,!0)),this.zpp_inner.wrap_constraints}including(e){return new(z()).callbacks.OptionType(this).including(e)}excluding(e){return new(z()).callbacks.OptionType(this).excluding(e)}toString(){return this===M.ANY_BODY?"ANY_BODY":this===M.ANY_SHAPE?"ANY_SHAPE":this===M.ANY_COMPOUND?"ANY_COMPOUND":this===M.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e){return e instanceof n?e:e?e instanceof M?v(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}},nn=z();nn.callbacks.CbType=ge;q();var V=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return i.InteractionType_COLLISION==null&&(i.internal=!0,i.InteractionType_COLLISION=new n,i.internal=!1),i.InteractionType_COLLISION}static get SENSOR(){return i.InteractionType_SENSOR==null&&(i.internal=!0,i.InteractionType_SENSOR=new n,i.internal=!1),i.InteractionType_SENSOR}static get FLUID(){return i.InteractionType_FLUID==null&&(i.internal=!0,i.InteractionType_FLUID=new n,i.internal=!1),i.InteractionType_FLUID}static get ANY(){return i.InteractionType_ANY==null&&(i.internal=!0,i.InteractionType_ANY=new n,i.internal=!1),i.InteractionType_ANY}toString(){return this===i.InteractionType_COLLISION?"COLLISION":this===i.InteractionType_SENSOR?"SENSOR":this===i.InteractionType_FLUID?"FLUID":this===i.InteractionType_ANY?"ANY":""}},rn=z();rn.callbacks.InteractionType=V;var we=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return i.PreFlag_ACCEPT==null&&(i.internal=!0,i.PreFlag_ACCEPT=new n,i.internal=!1),i.PreFlag_ACCEPT}static get IGNORE(){return i.PreFlag_IGNORE==null&&(i.internal=!0,i.PreFlag_IGNORE=new n,i.internal=!1),i.PreFlag_IGNORE}static get ACCEPT_ONCE(){return i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new n,i.internal=!1),i.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return i.PreFlag_IGNORE_ONCE==null&&(i.internal=!0,i.PreFlag_IGNORE_ONCE=new n,i.internal=!1),i.PreFlag_IGNORE_ONCE}toString(){return this===i.PreFlag_ACCEPT?"ACCEPT":this===i.PreFlag_IGNORE?"IGNORE":this===i.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===i.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},pn=z();pn.callbacks.PreFlag=we;var Ee=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new R,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 R?v(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}},on=z();on.callbacks.OptionType=Ee;function sn(n){return n===P.BEGIN?0:n===P.END?1:n===P.WAKE?2:n===P.SLEEP?3:n===P.BREAK?4:n===P.PRE?5:n===P.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!T.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null}static _wrap(e){return e instanceof n?e:e&&e instanceof T?v(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 T.types[this.zpp_inner.type]}get event(){return T.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(T.events[this.zpp_inner.event]!=e){let t=sn(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:ve._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 p=t.zpp_inner.wrap_listeners;p.zpp_inner.reverse_flag?p.push(this):p.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,p;switch(r.itype){case 1:p="COLLISION";break;case 2:p="SENSOR";break;case 4:p="FLUID";break;default:p="ALL"}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+p+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+p+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var Pe=class n{constructor(){if(!i.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return i.ListenerType_BODY==null&&(i.internal=!0,i.ListenerType_BODY=new n,i.internal=!1),i.ListenerType_BODY}static get CONSTRAINT(){return i.ListenerType_CONSTRAINT==null&&(i.internal=!0,i.ListenerType_CONSTRAINT=new n,i.internal=!1),i.ListenerType_CONSTRAINT}static get INTERACTION(){return i.ListenerType_INTERACTION==null&&(i.internal=!0,i.ListenerType_INTERACTION=new n,i.internal=!1),i.ListenerType_INTERACTION}static get PRE(){return i.ListenerType_PRE==null&&(i.internal=!0,i.ListenerType_PRE=new n,i.internal=!1),i.ListenerType_PRE}toString(){return this===i.ListenerType_BODY?"BODY":this===i.ListenerType_CONSTRAINT?"CONSTRAINT":this===i.ListenerType_INTERACTION?"INTERACTION":this===i.ListenerType_PRE?"PRE":""}},an=z();an.callbacks.ListenerType=Pe;q();var F=class{constructor(){this.zpp_inner=null;if(!$.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return T.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return""}};var Ve=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 Oe=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 ke=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 Re=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 Be=class extends B{constructor(e,t,r,p=0){if(T.internal=!0,super(),T.internal=!1,r==null)throw new Error("Error: BodyListener::handler cannot be null");let o;if(e===P.WAKE)o=2;else if(e===P.SLEEP)o=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new It(R.argument(t),o,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=p}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 Fe=class extends B{constructor(e,t,r,p=0){if(T.internal=!0,super(),T.internal=!1,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let o;if(e===P.WAKE)o=2;else if(e===P.SLEEP)o=3;else if(e===P.BREAK)o=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new At(R.argument(t),o,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=p}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 Ge(n){return n===V.COLLISION?1:n===V.SENSOR?2:n===V.FLUID?4:7}function ie(n){return n==1?V.COLLISION:n==2?V.SENSOR:n==4?V.FLUID:n==7?V.ANY:null}var De=class extends B{constructor(e,t,r,p,o,s=0){if(T.internal=!0,super(),T.internal=!1,o==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===P.BEGIN)a=0;else if(e===P.END)a=1;else if(e===P.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 We(R.argument(r),R.argument(p),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=o,t==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Ge(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 ie(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ge(e))}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e}};var Me=class extends B{constructor(e,t,r,p,o=0,s=!1){if(T.internal=!0,super(),T.internal=!1,p==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new We(R.argument(t),R.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=o,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=p,e==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ge(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 ie(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ie(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ge(e))}};var Ue=class n extends Ie{constructor(e,t=!1){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r=new kt(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:v(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 A;return e.zpp_inner._inuse=!0,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 xe(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=!1;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=!0;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):x.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let p=this.zpp_inner.bodies[r];if(p.body!=null){let o=!1;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==p.body){o=!0;break}o||e(p.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:p,unwrapElement:o}=n,s=z(),a=s.__zpp,m=()=>a.util[r],c=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!m().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=m();return u.zpp_pool==null?(b.internal=!0,h=new u,b.internal=!1):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=!1,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=!1,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=!0,this.zpp_i<h?!0:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,!1)},u.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function d(){this.zpp_inner=null,this.zpp_inner=new(m()),this.zpp_inner.outer=this}d.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new d;for(let b=0;b<_.length;b++)h.push(_[b]);return h},d.prototype.zpp_inner=null,d.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=!1,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=!1,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(d.prototype,"length",{get:function(){return y(this)}}),d.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(o(_))},d.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 p(this.zpp_inner.at_ite.elt)},d.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(_):!0;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(o(_)):(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,o(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},d.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(_):!0;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,o(_))):this.zpp_inner.inner.add(o(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},d.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=p(_);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=p(_);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(),p(_)},d.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=p(_);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=p(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),p(_)},d.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},d.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=!1,b=this.zpp_inner.inner.head,G=o(_);for(;b!=null;){if(b.elt==G){h=!0;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},d.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()},d.prototype.empty=function(){return this.zpp_inner.inner.head==null},d.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},d.prototype.copy=function(_){_==null&&(_=!1);let h=new d,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},d.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))}},d.prototype.toString=function(){let _="[",h=!0,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=!1}return _+"]"},d.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},d.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},d.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},d.prototype[Symbol.iterator]=function(){let _=u.get(this);return{next(){return _.hasNext()?{value:_.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};let g=c(),k=e+"Iterator",K=e+"List";return g[k]=u,g[K]=d,{Iterator:u,List:d}}var X=n=>n.outer,W=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:W});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:X,unwrapElement:W});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:X,unwrapElement:W});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:X,unwrapElement:W});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:X,unwrapElement:W});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:X,unwrapElement:W});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:X,unwrapElement:W});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:X,unwrapElement:W});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:W});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:W});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 pe(n){if(n.outer==null){let e=z();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=E.zpp_pool,E.zpp_pool=t,n.outer.zpp_inner=n}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=!1,this._length=0,this.inner=null,w.call(this),this.at_ite=null,this.at_index=0,this.zip_length=!0,this._length=0}for(let n in w.prototype)L.prototype[n]=w.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:!0});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=!1;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=!1);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=!1}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=!0,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 pe(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):!0;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):!0;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=pe(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=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e)}return this.zpp_inner.invalidate(),pe(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=pe(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=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop()}return this.zpp_inner.invalidate(),pe(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=!1,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=!0;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 ln=z(),_n=ln.__zpp;_n.util.ZPP_MixVec2List=L;var f=z();f.Config=Object.assign(f.Config||{},Pt);f.util.Debug=$e;f.geom.Vec2=A;f.geom.Vec3=x;f.geom.Mat23=_e;f.geom.MatMN=xe;f.geom.AABB=Ce;f.geom.Winding=it;f.geom.Ray=Ae;f.geom.ConvexResult=he;f.geom.RayResult=ce;f.geom.Geom=Te;f.geom.GeomPoly=ee;f.geom.MarchingSquares=Le;f.geom.Vec2Iterator=N;f.geom.Vec2List=w;f.geom.GeomVertexIterator=re;f.__zpp.geom.ZPP_GeomVertexIterator=se;f.__zpp.util.ZPP_ContactList=Y;f.phys.Interactor=pt;f.phys.Body=ae;Gt(n=>ae._wrap(n));f.phys.BodyType=Ne;f.phys.Compound=Xe;Mt(n=>Xe._wrap(n));f.phys.FluidProperties=ot;f.phys.Material=at;f.phys.GravMassMode=lt;f.phys.InertiaMode=_t;f.phys.MassMode=ut;f.shape.Shape=He;Dt(n=>He._wrap(n));f.shape.Circle=ht;f.shape.Polygon=le;f.shape.Capsule=ct;f.shape.Edge=ze;f.shape.ShapeType=st;f.shape.ValidationResult=me;f.space.Space=ve;f.space.Broadphase=ft;f.dynamics.InteractionFilter=zt;f.dynamics.InteractionGroup=de;f.dynamics.ArbiterType=ye;f.dynamics.Arbiter=j;S._createColArb=()=>new Se;S._createFluidArb=()=>new Ze;f.dynamics.Contact=be;f.dynamics.ContactIterator=C;f.dynamics.ContactList=I;f.callbacks.CbEvent=P;f.callbacks.CbType=ge;f.callbacks.InteractionType=V;f.callbacks.PreFlag=we;f.callbacks.OptionType=Ee;f.callbacks.Listener=B;f.callbacks.ListenerType=Pe;f.callbacks.Callback=F;$._createBodyCb=()=>new Ve;$._createConCb=()=>new Oe;$._createIntCb=()=>new ke;$._createPreCb=()=>new Re;f.callbacks.BodyListener=Be;f.callbacks.ConstraintListener=Fe;f.callbacks.InteractionListener=De;f.callbacks.PreListener=Me;f.constraint.Constraint=Ie;Tt._createFn=(...n)=>new mt(...n);Lt._createFn=(...n)=>new dt(...n);St._createFn=(...n)=>new yt(...n);Zt._createFn=(...n)=>new bt(...n);Vt._createFn=(...n)=>new gt(...n);Ot._createFn=(...n)=>new wt(...n);Rt._createFn=(...n)=>new Et(...n);f.constraint.UserConstraint=Ue;var xt=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,p){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,p){}drawSolidCapsule(e,t,r,p){}drawPoint(e,t){}};function un(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof ee){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 c=0;c<n.length;c++)if(n[c]==null)throw new Error("Error: vertices["+c+"] is null");t=new ee(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 c=t.simplify(r);if(t.dispose(),t=c,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let c=[],u=t.forwardIterator();for(;u.hasNext();){let d=u.next();c.push(A.get(d.x,d.y))}t.dispose(),c.reverse(),t=new ee(c)}let p=e?.material,o=e?.filter,s=e?.delaunay??!1,a=new ae(e?.type??Ne.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new le(t,p,o)),t.dispose(),a;let m=t.convexDecomposition(s);for(let c of m)a.shapes.add(new le(c,p,o));return t.dispose(),a}var Yo="3.17.0";export{Ce as AABB,mt as AngleJoint,j as Arbiter,ye as ArbiterType,ae as Body,Ve as BodyCallback,Be as BodyListener,Ne as BodyType,ft as Broadphase,F as Callback,ct as Capsule,P as CbEvent,ge as CbType,ht as Circle,Se as CollisionArbiter,Xe as Compound,Ie as Constraint,Oe as ConstraintCallback,Fe as ConstraintListener,be as Contact,he as ConvexResult,xt as DebugDraw,qt as DebugDrawFlags,dt as DistanceJoint,ze as Edge,Ze as FluidArbiter,ot as FluidProperties,Te as Geom,ee as GeomPoly,lt as GravMassMode,_t as InertiaMode,ke as InteractionCallback,zt as InteractionFilter,de as InteractionGroup,De as InteractionListener,V as InteractionType,pt as Interactor,yt as LineJoint,B as Listener,Pe as ListenerType,Le as MarchingSquares,ut as MassMode,_e as Mat23,xe as MatMN,at as Material,bt as MotorJoint,Jt as NapeList,Ee as OptionType,gt as PivotJoint,le as Polygon,Re as PreCallback,we as PreFlag,Me as PreListener,wt as PulleyJoint,Ae as Ray,ce as RayResult,He as Shape,st as ShapeType,ve as Space,Ue as UserConstraint,Yo as VERSION,me as ValidationResult,A as Vec2,x as Vec3,Et as WeldJoint,it as Winding,un as createConcaveBody};
|
|
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.18.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": [
|