@newkrok/nape-js 3.8.2 → 3.9.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.js CHANGED
@@ -1,2 +1,2 @@
1
- import{$ as En,A as sn,B as et,C as mn,D as X,E as c,F as $,G as v,H as L,I as C,J as Ye,K as je,L as yn,M as ge,N as dn,O as nt,P as tt,Q as rt,R as bn,S as lt,T as gn,U as wn,V as an,W as _t,X as We,Y as it,Z as pt,_ as ln,a as i,aa as _n,b as U,ba as Pn,c as Mn,ca as xn,d as ne,da as Cn,e as Y,ea as vn,f as T,fa as Nn,g as Un,ga as In,h as Yn,ha as An,i as rn,ia as Tn,j as B,ja as Ke,k as jn,ka as Ln,l as E,la as Sn,m as Wn,ma as Zn,n as Kn,na as Vn,o as Jn,oa as On,p as qn,pa as kn,q as Hn,qa as Rn,r as Xn,s as $n,t as Z,u as te,v as pn,w as on,x as be,y as j,z as Qn}from"./chunk-3TXNIYBK.js";var Bn={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},ot=c();ot.Config=Object.assign(ot.Config||{},Bn);function a(t,e,n){for(;t[e]!=null;){let r=t[e][n];t[e][n]=null,t[e]=r}}var un=class{static version(){return"Nape 2.0.19"}static clearObjectPools(){let e=c(),n=e.__zpp;a(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),a(e.phys.InteractorIterator,"zpp_pool","zpp_next"),a(e.phys.BodyIterator,"zpp_pool","zpp_next"),a(e.phys.CompoundIterator,"zpp_pool","zpp_next"),a(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),a(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),a(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),a(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),a(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),a(e.geom.RayResultIterator,"zpp_pool","zpp_next"),a(e.shape.ShapeIterator,"zpp_pool","zpp_next"),a(e.shape.EdgeIterator,"zpp_pool","zpp_next"),a(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),a(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),a(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),a(n.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Body,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Component,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),a(n.util.ZNPNode_ConvexResult,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),a(n.util.ZNPNode_RayResult,"zpp_pool","next"),a(n.phys.ZPP_Material,"zpp_pool","next"),a(n.phys.ZPP_FluidProperties,"zpp_pool","next"),a(n.callbacks.ZPP_CbSetPair,"zpp_pool","next"),a(n.callbacks.ZPP_Callback,"zpp_pool","next"),a(n.callbacks.ZPP_CbSet,"zpp_pool","next"),a(n.geom.ZPP_GeomVert,"zpp_pool","next"),a(n.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),a(n.geom.ZPP_Mat23,"zpp_pool","next"),a(n.geom.ZPP_CutVert,"zpp_pool","next"),a(n.geom.ZPP_CutInt,"zpp_pool","next"),a(n.geom.ZPP_Vec2,"zpp_pool","next"),a(n.geom.ZPP_PartitionVertex,"zpp_pool","next"),a(n.geom.ZPP_SimplifyV,"zpp_pool","next"),a(n.geom.ZPP_SimplifyP,"zpp_pool","next"),a(n.geom.ZPP_PartitionedPoly,"zpp_pool","next"),a(n.geom.ZPP_PartitionPair,"zpp_pool","next"),a(n.geom.ZPP_AABB,"zpp_pool","next"),a(n.geom.ZPP_SimpleVert,"zpp_pool","next"),a(n.geom.ZPP_SimpleSeg,"zpp_pool","next"),a(n.geom.ZPP_SimpleEvent,"zpp_pool","next"),a(n.util.Hashable2_Boolfalse,"zpp_pool","next"),a(n.geom.ZPP_ToiEvent,"zpp_pool","next"),a(n.geom.ZPP_MarchSpan,"zpp_pool","next"),a(n.geom.ZPP_MarchPair,"zpp_pool","next"),a(n.shape.ZPP_Edge,"zpp_pool","next"),a(n.space.ZPP_SweepData,"zpp_pool","next"),a(n.space.ZPP_AABBNode,"zpp_pool","next"),a(n.space.ZPP_AABBPair,"zpp_pool","next"),a(n.dynamics.ZPP_Contact,"zpp_pool","next"),a(n.space.ZPP_Island,"zpp_pool","next"),a(n.space.ZPP_Component,"zpp_pool","next"),a(n.space.ZPP_CallbackSet,"zpp_pool","next"),a(n.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),a(n.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),a(n.dynamics.ZPP_ColArbiter,"zpp_pool","next"),a(n.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),a(n.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),a(n.util.ZPP_PubPool,"poolVec2","zpp_pool"),a(n.util.ZPP_PubPool,"poolVec3","zpp_pool")}};var F=class F{get _inner(){return this}constructor(e=1,n=0,r=0,p=1,o=0,s=0){let _=sn.get();this.zpp_inner=_,_.outer=this;let f=["a","b","tx","c","d","ty"],y=[e,n,o,r,p,s];for(let h=0;h<y.length;h++)if(y[h]!==y[h])throw new Error("Error: Mat23::"+f[h]+" cannot be NaN");_.setas(e,n,r,p,o,s)}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let n=Math.cos(e),r=Math.sin(e);return new F(n,-r,r,n,0,0)}static translation(e,n){return new F(1,0,0,1,e,n)}static scale(e,n){return new F(e,0,0,n,0,0)}static _wrap(e){return e instanceof F?e:e?e instanceof sn?v(e,n=>{let r=Object.create(F.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?F._wrap(e.zpp_inner):null:null}_setProp(e,n){if(n!==n)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=n,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,n=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,_=r.c-p.c,f=r.d-p.d,y=r.tx-p.tx,h=r.ty-p.ty;return(o<0?-o:o)<=n&&(s<0?-s:s)<=n&&(_<0?-_:_)<=n&&(f<0?-f:f)<=n&&(y<0?-y:y)<=n&&(h<0?-h:h)<=n}copy(){return new F(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 n=e.zpp_inner;return this.zpp_inner.setas(n.a,n.b,n.c,n.d,n.tx,n.ty),this.zpp_inner.invalidate(),this}setAs(e=1,n=0,r=0,p=1,o=0,s=0){return this.zpp_inner.setas(e,n,r,p,o,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:n,c:r,d:p}=this.zpp_inner,o=e*e+n*n+r*r+p*p,s=e*p-n*r;s<0&&(s=-s);let _=c();return o>_.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:n,c:r,d:p,tx:o,ty:s}=this.zpp_inner,_=1/(e*p-n*r);return new F(p*_,-n*_,-r*_,e*_,(n*s-p*o)*_,(r*o-e*s)*_)}transpose(){let{a:e,b:n,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return new F(e,r,n,p,-e*o-r*s,-n*o-p*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let n=e.zpp_inner,r=this.zpp_inner;return new F(n.a*r.a+n.b*r.c,n.a*r.b+n.b*r.d,n.c*r.a+n.d*r.c,n.c*r.b+n.d*r.d,n.a*r.tx+n.b*r.ty+n.tx,n.c*r.tx+n.d*r.ty+n.ty)}transform(e,n=!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:_,c:f,d:y,tx:h,ty:m}=this.zpp_inner,d,g;n?(d=p*s+o*_,g=p*f+o*y):(d=p*s+o*_+h,g=p*f+o*y+m);let R=L.get(d,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,n=!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:_,tx:f,ty:y}=this.zpp_inner,h=1/(p*_-o*s);e.zpp_inner.validate();let m=e.zpp_inner.x,d=e.zpp_inner.y,g,R;if(n)g=(m*_-d*o)*h,R=(d*p-m*s)*h;else{let l=m-f,u=d-y;g=(l*_-u*o)*h,R=(u*p-l*s)*h}let q=L.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),q}equiorthogonal(){if(this.singular())return!1;let{a:e,b:n,c:r,d:p}=this.zpp_inner,o=c(),s=e*n+r*p;if(s*s>=o.Config.epsilon)return!1;let _=e*e+n*n-r*r-p*p;return _*_<o.Config.epsilon}orthogonal(){let{a:e,b:n,c:r,d:p}=this.zpp_inner,o=c(),s=e*n+r*p;if(s*s>=o.Config.epsilon)return!1;let _=e*e+n*n-1,f=r*r+p*p-1;return _*_<o.Config.epsilon&&f*f<o.Config.epsilon}_orthogonaliseImpl(e){let{a:n,b:r,c:p,d:o}=this.zpp_inner,s=c(),_=Math.sqrt(n*n+p*p),f=Math.sqrt(r*r+o*o);if(_*_<s.Config.epsilon||f*f<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let y=e?(_+f)/2:1;_=y/_,f=y/f,this.a=this.zpp_inner.a*_,this.c=this.zpp_inner.c*_,this.b=this.zpp_inner.b*f,this.d=this.zpp_inner.d*f;let h=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(h/(y*y));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let d=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*d,q=this.zpp_inner.b*g+this.zpp_inner.d*d,l=this.zpp_inner.c*g+this.zpp_inner.a*d,u=this.zpp_inner.d*g-this.zpp_inner.b*d;return this.c=l,this.a=R,this.d=u,this.b=q,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:n,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return"{ a: "+e+" b: "+n+" c: "+r+" d: "+p+" tx: "+o+" ty: "+s+" }"}};F.__name__=["nape","geom","Mat23"];var we=F;sn._wrapFn=t=>v(t,e=>{let n=Object.create(we.prototype);return n.zpp_inner=e,e.outer=n,n});function hn(t){if(t.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=t.zpp_inner;return e._validate!=null&&e._validate(),e.x}function cn(t){if(t.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=t.zpp_inner;return e._validate!=null&&e._validate(),e.y}function Ee(t){t.zpp_inner.weak&&t.dispose()}var re=class re{get _inner(){return this}constructor(e,n){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(n?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(n==null)throw new Error("Error: Ray::direction cannot be null");let r=new et;this.zpp_inner=r;let p=hn(e),o=cn(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),Ee(e);let s=hn(n),_=cn(n);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=_,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),Ee(n),r.zip_dir=!0,r.maxdist=1/0}static _wrap(e){return e==null?null:e instanceof re?e:v(e,n=>{let r=Object.create(re.prototype);return r.zpp_inner=n.zpp_inner??n,r})}static fromSegment(e,n){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(n?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(n==null)throw new Error("Error: Ray::fromSegment::end is null");let r=n.sub(e,!0),p=new re(e,r),o=hn(e),s=cn(e),_=hn(n),f=cn(n),y=_-o,h=f-s,m=Math.sqrt(y*y+h*h);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return p.zpp_inner.maxdist=m,Ee(e),Ee(n),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),Ee(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,Ee(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 je._wrap(this.zpp_inner.rayAABB())}at(e,n=!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,_=o+e*this.zpp_inner.diry;return L.get(s,_,n)}clone(){return this.copy()}copy(){let e=new re(this.zpp_inner.origin,this.zpp_inner.direction),n=this.zpp_inner.maxdist;if(n!==n)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=n,e}};re.__name__=["nape","geom","Ray"];var Je=re;var qe=class qe{get _inner(){return this}constructor(){if(this.zpp_inner=null,!be.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof qe)return e;let n=e.zpp_inner??e;return v(n,r=>{let p=Object.create(qe.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),L._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),L._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")}};qe.__name__=["nape","geom","ConvexResult"];var Pe=qe;be._createConvexResult=()=>new Pe;var He=class He{get _inner(){return this}constructor(){if(this.zpp_inner=null,!be.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof He)return e;let n=e.zpp_inner??e;return v(n,r=>{let p=Object.create(He.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),L._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")}};He.__name__=["nape","geom","RayResult"];var xe=He;be._createRayResult=()=>new xe;function ie(t){return t?.zpp_inner??t?._inner?.zpp_inner}function zn(t){return t?.zpp_inner??t?._inner?.zpp_inner}function fn(t,e){if(t!=null&&t.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let n=t.zpp_inner;if(n._immutable)throw new Error("Error: Vec2 is immutable");n._isimmutable!=null&&n._isimmutable()}function Ce(t,e){if(ie(t)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var ve=class{static distanceBody(e,n,r,p){fn(r,"out1"),fn(p,"out2");let o=zn(e),s=zn(n);if(o.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let _=o.shapes.head;for(;_!=null;)j.validateShape(_.elt),_=_.next;for(_=s.shapes.head;_!=null;)j.validateShape(_.elt),_=_.next;return mn.distanceBody(o,s,r.zpp_inner,p.zpp_inner)}static distance(e,n,r,p){fn(r,"out1"),fn(p,"out2"),Ce(e,"distances"),Ce(n,"distances");let o=ie(e),s=ie(n);j.validateShape(o),j.validateShape(s);let _;E.zpp_pool==null?_=new E:(_=E.zpp_pool,E.zpp_pool=_.next,_.next=null),_.weak=!1;let f=mn.distance(o,s,r.zpp_inner,p.zpp_inner,_,1e100);return _.next=E.zpp_pool,E.zpp_pool=_,f}static intersectsBody(e,n){let r=zn(e),p=zn(n);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;)j.validateShape(o.elt),o=o.next;for(o=p.shapes.head;o!=null;)j.validateShape(o.elt),o=o.next;let s=r.aabb,_=p.aabb;if(s.minx>_.maxx||s.maxx<_.minx||s.miny>_.maxy||s.maxy<_.miny)return!1;let f=r.shapes.head;for(;f!=null;){let y=p.shapes.head;for(;y!=null;){if(on.testCollide_safe(f.elt,y.elt))return!0;y=y.next}f=f.next}return!1}static intersects(e,n){Ce(e,"intersection"),Ce(n,"intersection");let r=ie(e),p=ie(n);j.validateShape(r),j.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:on.testCollide_safe(r,p)}static contains(e,n){Ce(e,"containment"),Ce(n,"containment");let r=ie(e),p=ie(n);return j.validateShape(r),j.validateShape(p),on.containTest(r,p)}};ve.__name__=["nape","geom","Geom"];var Ne=class{static run(e,n,r,p=2,o=null,s=!0,_=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(n==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 f=r.zpp_inner;if(f._validate!=null&&f._validate(),f.x<=0||f.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 y=c(),h=_??new y.geom.GeomPolyList,m=Qn,d=n.zpp_inner;if(d._validate!=null&&d._validate(),o==null){let g=d.minx,R=d.miny,q=d.maxx,l=d.maxy;m.run(e,g,R,q,l,r,p,s,h)}else{let g=o.zpp_inner;g._validate!=null&&g._validate();let R=d.maxx-d.minx,q=d.maxy-d.miny,l=R/g.x,u=q/g.y,b=l|0,M=u|0;b!==l&&++b,M!==u&&++M;for(let nn=0;nn<b;nn++){let Gn=d.minx+g.x*nn,st=nn===b-1?d.maxx:Gn+g.x;for(let tn=0;tn<M;tn++){let Dn=d.miny+g.y*tn,at=tn===M-1?d.maxy:Dn+g.y;m.run(e,Gn,Dn,st,at,r,p,s,h)}}}return f.weak&&r.dispose(),o!=null&&o.zpp_inner.weak&&o.dispose(),h}};Ne.__name__=["nape","geom","MarchingSquares"];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 Mn,this._invalidated=!0}static get(e,n){n==null&&(n=!1);let r=c(),p=new r.geom.Vec2List;return p.zpp_inner.inner=e,n&&(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.__name__=["zpp_nape","util","ZPP_Vec2List"],H.internal=!1;function pe(t){if(t.outer==null){let e=c();t.outer=new e.geom.Vec2;let n=t.outer.zpp_inner;n.outer!=null&&(n.outer.zpp_inner=null,n.outer=null),n._isimmutable=null,n._validate=null,n._invalidate=null,n.next=E.zpp_pool,E.zpp_pool=n,t.outer.zpp_inner=t}return t.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.__name__=["nape","geom","Vec2Iterator"];N.zpp_pool=null;N.get=function(t){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=t,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 t=this.zpp_inner.zpp_gl();return this.zpp_critical=!0,this.zpp_i<t?!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.__name__=["nape","geom","Vec2List"];w.fromArray=function(t){if(t==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=c(),n=new e.geom.Vec2List;for(let r=0;r<t.length;r++)n.push(t[r]);return n};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(t){return this.zpp_vm(),this.zpp_inner.inner.has(t.zpp_inner)};w.prototype.at=function(t){if(this.zpp_vm(),t<0||t>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(t=this.zpp_gl()-1-t),t<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=t,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(t);else for(;this.zpp_inner.at_index!=t;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return pe(this.zpp_inner.at_ite.elt)};w.prototype.push=function(t){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(t):!0;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(t.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,t.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)),e};w.prototype.unshift=function(t){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(t):!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,t.zpp_inner)):this.zpp_inner.inner.add(t.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)),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 t;if(this.zpp_inner.reverse_flag){t=this.zpp_inner.inner.head.elt;let e=pe(t);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);t=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let n=pe(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e)}return this.zpp_inner.invalidate(),pe(t)};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 t;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);t=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let n=pe(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e)}else{t=this.zpp_inner.inner.head.elt;let e=pe(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),pe(t)};w.prototype.add=function(t){return this.zpp_inner.reverse_flag?this.push(t):this.unshift(t)};w.prototype.remove=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=!1,n=this.zpp_inner.inner.head;for(;n!=null;){if(n.elt==t.zpp_inner){e=!0;break}n=n.next}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(t.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(t){t==null&&(t=!1);let e=c(),n=new e.geom.Vec2List,r=N.get(this);for(;r.hasNext();){let p=r.next(),o;if(t){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 _=p.zpp_inner.x,f=p.zpp_inner;f._validate!=null&&f._validate();let y=p.zpp_inner.y,h;if(U.poolVec2==null?h=new e.geom.Vec2:(h=U.poolVec2,U.poolVec2=h.zpp_pool,h.zpp_pool=null,h.zpp_disp=!1,h==U.nextVec2&&(U.nextVec2=null)),h.zpp_inner==null){let m;E.zpp_pool==null?m=new E:(m=E.zpp_pool,E.zpp_pool=m.next,m.next=null),m.weak=!1,m._immutable=!1,m.x=_,m.y=y,h.zpp_inner=m,h.zpp_inner.outer=h}else h.zpp_inner.x=_,h.zpp_inner.y=y,h.zpp_inner._invalidate!=null&&h.zpp_inner._invalidate(h.zpp_inner);h.zpp_inner.weak=!1,o=h}else o=p;n.push(o)}return n};w.prototype.merge=function(t){if(t==null)throw new Error("Error: Cannot merge with null list");let e=t.iterator();for(;e.hasNext();){let n=e.next();this.has(n)||this.add(n)}};w.prototype.toString=function(){let t="[",e=!0,n=N.get(this);for(;n.hasNext();){let r=n.next();e||(t+=","),t+=r==null?"NULL":r.toString(),e=!1}return t+"]"};w.prototype.foreach=function(t){if(t==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{t(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 t=N.get(this);return{next(){return t.hasNext()?{value:t.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};w.prototype.filter=function(t){if(t==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let n=this.at(e);try{t(n)?++e:this.remove(n)}catch{break}}return this};function Q(){if(!ge.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}Q.__name__=["nape","geom","GeomVertexIterator"];Q.prototype.zpp_inner=null;Q.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let t=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=!1,!t){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=ge.zpp_pool,ge.zpp_pool=e}return t};Q.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let t=this.zpp_inner.ptr;if(t.wrap==null){let n=t.x,r=t.y;if(n!==n||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let p=c(),o;if(U.poolVec2==null?o=new p.geom.Vec2:(o=U.poolVec2,U.poolVec2=o.zpp_pool,o.zpp_pool=null,o.zpp_disp=!1,o==U.nextVec2&&(U.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=n,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==n&&s.y==r||(s.x=n,s.y=r,s._invalidate!=null&&s._invalidate(s))}o.zpp_inner.weak=!1,t.wrap=o,t.wrap.zpp_inner._inuse=!0,t.wrap.zpp_inner._invalidate=s=>t.modwrap(s),t.wrap.zpp_inner._validate=()=>t.getwrap()}let e=t.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};Q.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 ut=c();ut.geom.GeomVertexIterator=Q;var W=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 te,this._invalidated=!0}static get(e,n){n==null&&(n=!1);let r=c(),p=new r.dynamics.ContactList;return p.zpp_inner.inner=e,n&&(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)}};W.__name__=["zpp_nape","util","ZPP_ContactList"],W.internal=!1;var Xe=class Xe{constructor(){if(!X.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof Xe?e:e instanceof X?v(e,n=>{X.internal=!0;let r=new Xe;return X.internal=!1,r.zpp_inner=n,n.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 n=c();if(e.outer==null){e.outer=new n.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}};Xe.__name__=["nape","shape","Edge"];var Ie=Xe;X._wrapFn=t=>v(t,e=>{X.internal=!0;let n=new Ie;return X.internal=!1,n.zpp_inner=e,e.outer=n,n});var oe=class oe{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 oe,i.internal=!1),i.ValidationResult_VALID}static get DEGENERATE(){return i.ValidationResult_DEGENERATE==null&&(i.internal=!0,i.ValidationResult_DEGENERATE=new oe,i.internal=!1),i.ValidationResult_DEGENERATE}static get CONCAVE(){return i.ValidationResult_CONCAVE==null&&(i.internal=!0,i.ValidationResult_CONCAVE=new oe,i.internal=!1),i.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return i.ValidationResult_SELF_INTERSECTING==null&&(i.internal=!0,i.ValidationResult_SELF_INTERSECTING=new oe,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":""}};oe.__name__=["nape","shape","ValidationResult"];var Ae=oe,ht=c();ht.shape.ValidationResult=Ae;var Te=class Te{get _inner(){return this}constructor(e=!1){let n=new pn;this.zpp_inner=n,n.outer=this,n.ignore!=e&&(n.invalidate(!0),n.ignore=e)}static _wrap(e){return e instanceof Te?e:e?e instanceof pn?v(e,n=>{let r=Object.create(Te.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?Te._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=c();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=c();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}};Te.__name__=["nape","dynamics","InteractionGroup"];var Le=Te;pn._wrapFn=t=>v(t,e=>{let n=Object.create(Le.prototype);return n.zpp_inner=e,e.outer=n,n});var Se=class Se{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 Se,i.internal=!1),i.ArbiterType_COLLISION}static get SENSOR(){return i.ArbiterType_SENSOR==null&&(i.internal=!0,i.ArbiterType_SENSOR=new Se,i.internal=!1),i.ArbiterType_SENSOR}static get FLUID(){return i.ArbiterType_FLUID==null&&(i.internal=!0,i.ArbiterType_FLUID=new Se,i.internal=!1),i.ArbiterType_FLUID}toString(){return this===i.ArbiterType_COLLISION?"COLLISION":this===i.ArbiterType_SENSOR?"SENSOR":this===i.ArbiterType_FLUID?"FLUID":""}};Se.__name__=["nape","dynamics","ArbiterType"];var Ze=Se,ct=c();ct.dynamics.ArbiterType=Ze;$();var G=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!Z.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return Z.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==Z.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==Z.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=c(),n=this.zpp_inner.immState;return n==5?(i.PreFlag_ACCEPT==null&&(i.internal=!0,i.PreFlag_ACCEPT=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT):n==1?(i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT_ONCE):n==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==Z.COL}isFluidArbiter(){return this.zpp_inner.type==Z.FLUID}isSensorArbiter(){return this.zpp_inner.type==Z.SENSOR}totalImpulse(e=null,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),C.get(0,0,0)}toString(){let e=this.zpp_inner.type==Z.COL?"CollisionArbiter":this.zpp_inner.type==Z.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let n=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+"("+n.toString()+"|"+r.toString()+")";return this.zpp_inner.type==Z.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 n=this.zpp_inner,r=n.ws1.id>n.ws2.id?n.b2.outer:n.b1.outer,p=n.ws1.id>n.ws2.id?n.b1.outer:n.b2.outer;if(e!=r&&e!=p)throw new Error("Error: Arbiter does not relate to body")}};G.__name__=["nape","dynamics","Arbiter"];var zt=c();zt.dynamics.Arbiter=G;var se=class extends G{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 n=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;n.zpp_inner.type==1?n.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 n=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;n.zpp_inner.type==1?n.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,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,n)}tangentImpulse(e=null,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,n)}totalImpulse(e=null,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,n)}rollingImpulse(e=null,n=!1){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return!n||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,n,r){let p=0,o=0,s=0,_=this.zpp_inner.colarb;if(!r||_.oc1.fresh){let f=_.oc1.wrapper()[e](n),y=f.zpp_inner;y._validate!=null&&y._validate(),p+=y.x,y._validate!=null&&y._validate(),o+=y.y,y._validate!=null&&y._validate(),s+=y.z,f.dispose()}if(_.hc2&&(!r||_.oc2.fresh)){let f=_.oc2.wrapper()[e](n),y=f.zpp_inner;y._validate!=null&&y._validate(),p+=y.x,y._validate!=null&&y._validate(),o+=y.y,y._validate!=null&&y._validate(),s+=y.z,f.dispose()}return C.get(p,o,s)}};se.__name__=["nape","dynamics","CollisionArbiter"],se.__super__=G;var ae=class extends G{constructor(){super()}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),L._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 n=this.zpp_inner.fluidarb;return e==null?C.get(n.buoyx,n.buoyy,0):e.zpp_inner==this.zpp_inner.b2?C.get(n.buoyx,n.buoyy,n.buoyy*n.r2x-n.buoyx*n.r2y):C.get(-n.buoyx,-n.buoyy,-(n.buoyy*n.r1x-n.buoyx*n.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let n=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return C.get(n.dampx*r,n.dampy*r,n.adamp*r)}totalImpulse(e=null,n=!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}};ae.__name__=["nape","dynamics","FluidArbiter"],ae.__super__=G;var le=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!te.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==Z.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(),L._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 n=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jnAcc;return e==null?C.get(n.nx*p,n.ny*p):(this._checkBody(e,n),e==n.b1.outer?C.get(n.nx*-p,n.ny*-p,-(n.ny*r.r1x-n.nx*r.r1y)*p):C.get(n.nx*p,n.ny*p,(n.ny*r.r2x-n.nx*r.r2y)*p))}tangentImpulse(e=null){this._inactiveCheck();let n=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jtAcc;return e==null?C.get(-n.ny*p,n.nx*p):(this._checkBody(e,n),e==n.b1.outer?C.get(n.ny*p,-n.nx*p,-(r.r1x*n.nx+r.r1y*n.ny)*p):C.get(-n.ny*p,n.nx*p,(r.r2x*n.nx+r.r2y*n.ny)*p))}rollingImpulse(e=null){this._inactiveCheck();let n=this.zpp_inner.arbiter.colarb,r=n.jrAcc;return e==null?r:(this._checkBody(e,n),e==n.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let n=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jnAcc,o=r.jtAcc,s=n.jrAcc;if(e==null)return C.get(n.nx*p-n.ny*o,n.ny*p+n.nx*o,s);this._checkBody(e,n);let _=n.nx*p-n.ny*o,f=n.ny*p+n.nx*o;return e==n.b1.outer?C.get(-_,-f,-(f*r.r1x-_*r.r1y)-s):C.get(_,f,f*r.r2x-_*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,n){if(e!=n.b1.outer&&e!=n.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};le.__name__=["nape","dynamics","Contact"];te._wrapFn=t=>{te.internal=!0;let e=new le;return te.internal=!1,e.zpp_inner=t,t.outer=e,e};function ft(t){let e=0,n=t.inner.next;for(;n!=null;)n.active&&n.arbiter.active&&e++,n=n.next;return e}function V(t){return t.valmod(),t.zip_length&&(t.zip_length=!1,t.user_length=ft(t)),t.user_length}function P(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!W.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}P.__name__=["nape","dynamics","ContactIterator"];P.zpp_pool=null;P.get=function(t){let e;return P.zpp_pool==null?(W.internal=!0,e=new P,W.internal=!1):(e=P.zpp_pool,P.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=t,e.zpp_critical=!1,e};P.prototype.zpp_inner=null;P.prototype.zpp_i=null;P.prototype.zpp_critical=null;P.prototype.zpp_next=null;P.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let t=V(this.zpp_inner.zpp_inner);return this.zpp_critical=!0,this.zpp_i<t?!0:(this.zpp_next=P.zpp_pool,P.zpp_pool=this,this.zpp_inner=null,!1)};P.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 W,this.zpp_inner.outer=this}I.__name__=["nape","dynamics","ContactList"];I.fromArray=function(t){if(t==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=c(),n=new e.dynamics.ContactList;for(let r=0;r<t.length;r++)n.push(t[r]);return n};I.prototype.zpp_inner=null;Object.defineProperty(I.prototype,"length",{get:function(){return V(this.zpp_inner)}});I.prototype.has=function(t){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(t.zpp_inner)};I.prototype.at=function(t){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(t<0||t>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(t=V(this.zpp_inner)-1-t),t<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 n=this.zpp_inner.at_ite;if(n.active&&n.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next}for(;this.zpp_inner.at_index!=t;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let n=this.zpp_inner.at_ite;if(n.active&&n.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(t){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(t):!0;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(t.zpp_inner);else{if(this.zpp_inner.push_ite==null){let n=V(this.zpp_inner);n==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(n-1)}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,t.zpp_inner)}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};I.prototype.unshift=function(t){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(t):!0;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let n=V(this.zpp_inner);n==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(n-1)}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,t.zpp_inner)}else this.zpp_inner.inner.add(t.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};I.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let n=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),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 n=V(this.zpp_inner),r;n==1?r=null:r=this.zpp_inner.inner.iterator_at(n-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(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let n=V(this.zpp_inner),r;n==1?r=null:r=this.zpp_inner.inner.iterator_at(n-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 n=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),e.wrapper()};I.prototype.add=function(t){return this.zpp_inner.reverse_flag?this.push(t):this.unshift(t)};I.prototype.remove=function(t){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=!1,n=this.zpp_inner.inner.next;for(;n!=null;){if(n==t.zpp_inner){e=!0;break}n=n.next}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(t.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(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift()};I.prototype.empty=function(){return V(this.zpp_inner)==0};I.prototype.iterator=function(){return this.zpp_inner.valmod(),P.get(this)};I.prototype.copy=function(t){t==null&&(t=!1);let e=c(),n=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=P.get(this);for(;r.hasNext();){let p=r.next();if(t)throw new Error("Error: Contact is not a copyable type");n.push(p)}return n};I.prototype.merge=function(t){if(t==null)throw new Error("Error: Cannot merge with null list");t.zpp_inner.valmod();let e=P.get(t);for(;e.hasNext();){let n=e.next();this.has(n)||(this.zpp_inner.reverse_flag?this.push(n):this.unshift(n))}};I.prototype.toString=function(){let t="[",e=!0;this.zpp_inner.valmod();let n=P.get(this);for(;n.hasNext();){let r=n.next();e||(t+=","),t+=r==null?"NULL":r.toString(),e=!1}return t+"]"};I.prototype.foreach=function(t){if(t==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=P.get(this);for(;e.hasNext();)try{t(e.next())}catch{e.zpp_next=P.zpp_pool,P.zpp_pool=e,e.zpp_inner=null;break}return this};I.prototype[Symbol.iterator]=function(){let t=P.get(this);return{next(){return t.hasNext()?{value:t.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};I.prototype.filter=function(t){if(t==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let n=V(this.zpp_inner);if(!(e<n))break;let r=this.at(e);try{t(r)?++e:this.remove(r)}catch{break}}return this};var K=class K{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 K,i.internal=!1),i.CbEvent_BEGIN}static get ONGOING(){return i.CbEvent_ONGOING==null&&(i.internal=!0,i.CbEvent_ONGOING=new K,i.internal=!1),i.CbEvent_ONGOING}static get END(){return i.CbEvent_END==null&&(i.internal=!0,i.CbEvent_END=new K,i.internal=!1),i.CbEvent_END}static get WAKE(){return i.CbEvent_WAKE==null&&(i.internal=!0,i.CbEvent_WAKE=new K,i.internal=!1),i.CbEvent_WAKE}static get SLEEP(){return i.CbEvent_SLEEP==null&&(i.internal=!0,i.CbEvent_SLEEP=new K,i.internal=!1),i.CbEvent_SLEEP}static get BREAK(){return i.CbEvent_BREAK==null&&(i.internal=!0,i.CbEvent_BREAK=new K,i.internal=!1),i.CbEvent_BREAK}static get PRE(){return i.CbEvent_PRE==null&&(i.internal=!0,i.CbEvent_PRE=new K,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":""}};K.__name__=["nape","callbacks","CbEvent"];var x=K,mt=c();mt.callbacks.CbEvent=x;$();var Ve=class Ve{get _inner(){return this}constructor(){this.zpp_inner=new Y,this.zpp_inner.outer=this}static get ANY_BODY(){return Y.ANY_BODY}static get ANY_CONSTRAINT(){return Y.ANY_CONSTRAINT}static get ANY_SHAPE(){return Y.ANY_SHAPE}static get ANY_COMPOUND(){return Y.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=pt.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=it.get(this.zpp_inner.constraints,!0)),this.zpp_inner.wrap_constraints}including(e){return new(c()).callbacks.OptionType(this).including(e)}excluding(e){return new(c()).callbacks.OptionType(this).excluding(e)}toString(){return this===Y.ANY_BODY?"ANY_BODY":this===Y.ANY_SHAPE?"ANY_SHAPE":this===Y.ANY_COMPOUND?"ANY_COMPOUND":this===Y.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e){return e instanceof Ve?e:e?e instanceof Y?v(e,n=>{let r=Object.create(Ve.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?Ve._wrap(e.zpp_inner):null:null}};Ve.__name__=["nape","callbacks","CbType"];var Oe=Ve,yt=c();yt.callbacks.CbType=Oe;$();var _e=class _e{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 _e,i.internal=!1),i.InteractionType_COLLISION}static get SENSOR(){return i.InteractionType_SENSOR==null&&(i.internal=!0,i.InteractionType_SENSOR=new _e,i.internal=!1),i.InteractionType_SENSOR}static get FLUID(){return i.InteractionType_FLUID==null&&(i.internal=!0,i.InteractionType_FLUID=new _e,i.internal=!1),i.InteractionType_FLUID}static get ANY(){return i.InteractionType_ANY==null&&(i.internal=!0,i.InteractionType_ANY=new _e,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":""}};_e.__name__=["nape","callbacks","InteractionType"];var O=_e,dt=c();dt.callbacks.InteractionType=O;var ue=class ue{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 ue,i.internal=!1),i.PreFlag_ACCEPT}static get IGNORE(){return i.PreFlag_IGNORE==null&&(i.internal=!0,i.PreFlag_IGNORE=new ue,i.internal=!1),i.PreFlag_IGNORE}static get ACCEPT_ONCE(){return i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new ue,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 ue,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":""}};ue.__name__=["nape","callbacks","PreFlag"];var ke=ue,bt=c();bt.callbacks.PreFlag=ke;var Re=class Re{get _inner(){return this}constructor(e,n){this.zpp_inner=new B,this.zpp_inner.outer=this,e!=null&&this.including(e),n!=null&&this.excluding(n)}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 n=this.zpp_inner.wrap_excludes.toString();return"@{"+e+" excluding "+n+"}"}static _wrap(e){return e instanceof Re?e:e?e instanceof B?v(e,n=>{let r=Object.create(Re.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?Re._wrap(e.zpp_inner):null:null}};Re.__name__=["nape","callbacks","OptionType"];var Be=Re,gt=c();gt.callbacks.OptionType=Be;function wt(t){return t===x.BEGIN?0:t===x.END?1:t===x.WAKE?2:t===x.SLEEP?3:t===x.BREAK?4:t===x.PRE?5:t===x.ONGOING?6:-1}var $e=class $e{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 $e?e:e&&e instanceof T?v(e,n=>{if(n.outer)return n.outer;let r=Object.create($e.prototype);return r.zpp_inner=n,n.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 n=wt(e);this.zpp_inner.swapEvent(n)}}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:We._wrap(this.zpp_inner.space.outer)}set space(e){let n=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=n)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),n!=null){let p=n.zpp_inner.wrap_listeners;p.zpp_inner.reverse_flag?p.push(this):p.unshift(this)}else this.zpp_inner.space=null}toString(){let n=["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{"+n+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return"ConstraintListener{"+n+"::"+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{"+n+"#"+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}}};$e.__name__=["nape","callbacks","Listener"];var D=$e;var he=class he{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 he,i.internal=!1),i.ListenerType_BODY}static get CONSTRAINT(){return i.ListenerType_CONSTRAINT==null&&(i.internal=!0,i.ListenerType_CONSTRAINT=new he,i.internal=!1),i.ListenerType_CONSTRAINT}static get INTERACTION(){return i.ListenerType_INTERACTION==null&&(i.internal=!0,i.ListenerType_INTERACTION=new he,i.internal=!1),i.ListenerType_INTERACTION}static get PRE(){return i.ListenerType_PRE==null&&(i.internal=!0,i.ListenerType_PRE=new he,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":""}};he.__name__=["nape","callbacks","ListenerType"];var Fe=he,Et=c();Et.callbacks.ListenerType=Fe;$();var S=class{constructor(){this.zpp_inner=null;if(!ne.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""}};S.__name__=["nape","callbacks","Callback"];var ce=class extends S{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)}};ce.__name__=["nape","callbacks","BodyCallback"];var ze=class extends S{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)}};ze.__name__=["nape","callbacks","ConstraintCallback"];var fe=class extends S{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)}};fe.__name__=["nape","callbacks","InteractionCallback"];var me=class extends S{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)}};me.__name__=["nape","callbacks","PreCallback"];var Ge=class extends D{constructor(e,n,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===x.WAKE)o=2;else if(e===x.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 Un(B.argument(n),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}};Ge.__name__=["nape","callbacks","BodyListener"];var De=class extends D{constructor(e,n,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===x.WAKE)o=2;else if(e===x.SLEEP)o=3;else if(e===x.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 Yn(B.argument(n),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}};De.__name__=["nape","callbacks","ConstraintListener"];function Qe(t){return t===O.COLLISION?1:t===O.SENSOR?2:t===O.FLUID?4:7}function ye(t){return t==1?O.COLLISION:t==2?O.SENSOR:t==4?O.FLUID:t==7?O.ANY:null}var Me=class extends D{constructor(e,n,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 _;if(e===x.BEGIN)_=0;else if(e===x.END)_=1;else if(e===x.ONGOING)_=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new rn(B.argument(r),B.argument(p),_,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,n==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=n&&(this.zpp_inner_zn.itype=Qe(n))}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 ye(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Qe(e))}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e}};Me.__name__=["nape","callbacks","InteractionListener"];var Ue=class extends D{constructor(e,n,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 rn(B.argument(n),B.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");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Qe(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 ye(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Qe(e))}};Ue.__name__=["nape","callbacks","PreListener"];var en=class t extends Ke{constructor(e,n=!1){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r=new Xn(e,n);this.zpp_inner=r,r.outer=this,r.outer_zn=this}static _wrap(e){return e==null?null:e instanceof t?e:e.zpp_inner?.outer instanceof t?e.zpp_inner.outer:v(e,n=>{let r=Object.create(t.prototype);return r.zpp_inner=n.zpp_inner??n,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new L;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,n,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,n=new Ye(e,1);for(let r=0;r<e;r++){if(r<0||r>=n.zpp_inner.m||0>=n.zpp_inner.n)throw new Error("Error: MatMN indices out of range");n.zpp_inner.x[r*n.zpp_inner.n]=this.zpp_inner.jAcc[r]}return n}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let n=!1;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){n=!0;break}if(!n)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):C.get()}visitBodies(e){let n=this.zpp_inner.bodies.length,r=0;for(;r<n;){let p=this.zpp_inner.bodies[r];if(p.body!=null){let o=!1;for(let s=r+1;s<n;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,n){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=n){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()}n!=null&&this.zpp_inner.addBody(n.zpp_inner),this.zpp_inner.wake(),n?.zpp_inner.wake()}return n}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e}};function k(t){let{typeName:e,namespaceParts:n,zppListClass:r,wrapElement:p,unwrapElement:o}=t,s=c(),_=s.__zpp,f=()=>_.util[r],y=()=>{let l=s;for(let u=1;u<n.length;u++)l=l[n[u]];return l};function h(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!f().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}h.__name__=[...n,e+"Iterator"],h.zpp_pool=null,h.get=function(l){let u,b=f();return h.zpp_pool==null?(b.internal=!0,u=new h,b.internal=!1):(u=h.zpp_pool,h.zpp_pool=u.zpp_next),u.zpp_i=0,u.zpp_inner=l,u.zpp_critical=!1,u},h.prototype.zpp_inner=null,h.prototype.zpp_i=null,h.prototype.zpp_critical=null,h.prototype.zpp_next=null,h.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let l=this.zpp_inner;l.zpp_inner.valmod(),l.zpp_inner.zip_length&&(l.zpp_inner.zip_length=!1,l.zpp_inner.user_length=l.zpp_inner.inner.length);let u=l.zpp_inner.user_length;return this.zpp_critical=!0,this.zpp_i<u?!0:(this.zpp_next=h.zpp_pool,h.zpp_pool=this,this.zpp_inner=null,!1)},h.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(f()),this.zpp_inner.outer=this}m.__name__=[...n,e+"List"],m.fromArray=function(l){if(l==null)throw new Error("Error: Cannot convert null Array to Nape list");let u=new m;for(let b=0;b<l.length;b++)u.push(l[b]);return u},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=!1,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function d(l){return l.zpp_inner.valmod(),l.zpp_inner.zip_length&&(l.zpp_inner.zip_length=!1,l.zpp_inner.user_length=l.zpp_inner.inner.length),l.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return d(this)}}),m.prototype.has=function(l){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(o(l))},m.prototype.at=function(l){if(this.zpp_inner.valmod(),l<0||l>=d(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(l=d(this)-1-l),l<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=l,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(l);else for(;this.zpp_inner.at_index!=l;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return p(this.zpp_inner.at_ite.elt)},m.prototype.push=function(l){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let u=this.zpp_inner.adder!=null?this.zpp_inner.adder(l):!0;return u&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(o(l)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(d(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,o(l))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(l)),u},m.prototype.unshift=function(l){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let u=this.zpp_inner.adder!=null?this.zpp_inner.adder(l):!0;return u&&(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(d(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,o(l))):this.zpp_inner.inner.add(o(l)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(l)),u},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let l;if(this.zpp_inner.reverse_flag){l=this.zpp_inner.inner.head.elt;let u=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(u),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 u;d(this)==1?u=null:u=this.zpp_inner.inner.iterator_at(d(this)-2),l=u==null?this.zpp_inner.inner.head.elt:u.next.elt;let b=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(u)}return this.zpp_inner.invalidate(),p(l)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let l;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 u;d(this)==1?u=null:u=this.zpp_inner.inner.iterator_at(d(this)-2),l=u==null?this.zpp_inner.inner.head.elt:u.next.elt;let b=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(u)}else{l=this.zpp_inner.inner.head.elt;let u=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(u),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),p(l)},m.prototype.add=function(l){return this.zpp_inner.reverse_flag?this.push(l):this.unshift(l)},m.prototype.remove=function(l){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let u=!1,b=this.zpp_inner.inner.head,M=o(l);for(;b!=null;){if(b.elt==M){u=!0;break}b=b.next}return u&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(l),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(M),this.zpp_inner.invalidate()),u},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift()},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),h.get(this)},m.prototype.copy=function(l){l==null&&(l=!1);let u=new m,b=h.get(this);for(;b.hasNext();){let M=b.next();if(l)throw new Error("Error: "+e+" is not a copyable type");u.push(M)}return u},m.prototype.merge=function(l){if(l==null)throw new Error("Error: Cannot merge with null list");let u=h.get(l);for(;u.hasNext();){let b=u.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b))}},m.prototype.toString=function(){let l="[",u=!0,b=h.get(this);for(;b.hasNext();){let M=b.next();u||(l+=","),l+=M==null?"NULL":M.toString(),u=!1}return l+"]"},m.prototype.foreach=function(l){if(l==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let u=h.get(this);for(;u.hasNext();)try{l(u.next())}catch{u.zpp_next=h.zpp_pool,h.zpp_pool=u,u.zpp_inner=null;break}return this},m.prototype.filter=function(l){if(l==null)throw new Error("Error: Cannot select elements of list with null");let u=0;for(;u<d(this);){let b=this.at(u);try{l(b)?++u:this.remove(b)}catch{break}}return this},m.prototype.toArray=function(){let l=[],u=h.get(this);for(;u.hasNext();)l.push(u.next());return l},m.prototype[Symbol.iterator]=function(){let l=h.get(this);return{next(){return l.hasNext()?{value:l.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};let g=y(),R=e+"Iterator",q=e+"List";return g[R]=h,g[q]=m,{Iterator:h,List:m}}var ee=t=>t.outer,J=t=>t.zpp_inner??(t._inner?t._inner.zpp_inner??t._inner:t);k({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:ee,unwrapElement:J});k({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:ee,unwrapElement:J});k({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:ee,unwrapElement:J});k({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:ee,unwrapElement:J});k({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:ee,unwrapElement:J});k({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:ee,unwrapElement:J});k({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:ee,unwrapElement:J});k({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:ee,unwrapElement:J});k({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:t=>t.wrapper(),unwrapElement:J});k({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:t=>t.wrapper(),unwrapElement:J});k({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:t=>t,unwrapElement:t=>t});k({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:t=>t,unwrapElement:t=>t});k({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:t=>t.outer_i,unwrapElement:t=>t.zpp_inner_i});function de(t){if(t.outer==null){let e=c();t.outer=new e.geom.Vec2;let n=t.outer.zpp_inner;n.outer!=null&&(n.outer.zpp_inner=null,n.outer=null),n._isimmutable=null,n._validate=null,n._invalidate=null,n.next=E.zpp_pool,E.zpp_pool=n,t.outer.zpp_inner=t}return t.outer}function A(){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}A.__name__=["zpp_nape","util","ZPP_MixVec2List"];A.__super__=w;for(let t in w.prototype)A.prototype[t]=w.prototype[t];Object.defineProperty(A.prototype,"length",{get:function(){return this.zpp_gl()},configurable:!0});A.prototype.inner=null;A.prototype._length=0;A.prototype.zip_length=!1;A.prototype.at_ite=null;A.prototype.at_index=0;A.get=function(t,e){e==null&&(e=!1);let n=new A;return n.inner=t,n.zpp_inner.immutable=e,n};A.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let t=this.inner.next;for(;t!=null;)this._length++,t=t.next;this.zip_length=!1}return this._length};A.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=!0,this._length=0,this.at_ite=null)};A.prototype.at=function(t){if(this.zpp_vm(),t<0||t>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(t=this.zpp_gl()-1-t),(t<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==t;)this.at_index++,this.at_ite=this.at_ite.next;return de(this.at_ite)};A.prototype.push=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),t.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(t):!0;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(t.zpp_inner);else{let n=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(n,t.zpp_inner)}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};A.prototype.unshift=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),t.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(t):!0;if(e){if(this.zpp_inner.reverse_flag){let n=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(n,t.zpp_inner)}else this.inner.add(t.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};A.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 t;if(this.zpp_inner.reverse_flag){t=this.inner.next;let e=de(t);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);t=e==null?this.inner.next:e.next;let n=de(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.erase(e)}return this.zpp_inner.invalidate(),de(t)};A.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 t;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);t=e==null?this.inner.next:e.next;let n=de(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.erase(e)}else{t=this.inner.next;let e=de(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop()}return this.zpp_inner.invalidate(),de(t)};A.prototype.remove=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=!1,n=this.inner.next;for(;n!=null;){if(t.zpp_inner===n){e=!0;break}n=n.next}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.remove(t.zpp_inner),this.zpp_inner.invalidate()),e};A.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 Pt=c(),xt=Pt.__zpp;xt.util.ZPP_MixVec2List=A;var z=c();z.Config=Object.assign(z.Config||{},Bn);z.util.Debug=un;z.geom.Vec2=L;z.geom.Vec3=C;z.geom.Mat23=we;z.geom.MatMN=Ye;z.geom.AABB=je;z.geom.Winding=yn;z.geom.Ray=Je;z.geom.ConvexResult=Pe;z.geom.RayResult=xe;z.geom.Geom=ve;z.geom.GeomPoly=dn;z.geom.MarchingSquares=Ne;z.geom.Vec2Iterator=N;z.geom.Vec2List=w;z.geom.GeomVertexIterator=Q;z.__zpp.geom.ZPP_GeomVertexIterator=ge;z.__zpp.util.ZPP_ContactList=W;z.phys.Interactor=bn;z.phys.Body=ln;nt(t=>ln._wrap(t));z.phys.BodyType=En;z.phys.Compound=_n;rt(t=>_n._wrap(t));z.phys.FluidProperties=gn;z.phys.Material=Pn;z.phys.GravMassMode=xn;z.phys.InertiaMode=Cn;z.phys.MassMode=vn;z.shape.Shape=an;tt(t=>an._wrap(t));z.shape.Circle=Nn;z.shape.Polygon=In;z.shape.Edge=Ie;z.shape.ShapeType=wn;z.shape.ValidationResult=Ae;z.space.Space=We;z.space.Broadphase=An;z.dynamics.InteractionFilter=Tn;z.dynamics.InteractionGroup=Le;z.dynamics.ArbiterType=Ze;z.dynamics.Arbiter=G;Z._createColArb=()=>new se;Z._createFluidArb=()=>new ae;z.dynamics.Contact=le;z.dynamics.ContactIterator=P;z.dynamics.ContactList=I;z.callbacks.CbEvent=x;z.callbacks.CbType=Oe;z.callbacks.InteractionType=O;z.callbacks.PreFlag=ke;z.callbacks.OptionType=Be;z.callbacks.Listener=D;z.callbacks.ListenerType=Fe;z.callbacks.Callback=S;ce.__super__=S;ne._createBodyCb=()=>new ce;ze.__super__=S;ne._createConCb=()=>new ze;fe.__super__=S;ne._createIntCb=()=>new fe;me.__super__=S;ne._createPreCb=()=>new me;z.callbacks.BodyListener=Ge;z.callbacks.ConstraintListener=De;z.callbacks.InteractionListener=Me;z.callbacks.PreListener=Ue;z.constraint.Constraint=Ke;jn._createFn=(...t)=>new Ln(...t);Wn._createFn=(...t)=>new Sn(...t);Kn._createFn=(...t)=>new Zn(...t);Jn._createFn=(...t)=>new Vn(...t);qn._createFn=(...t)=>new On(...t);Hn._createFn=(...t)=>new kn(...t);$n._createFn=(...t)=>new Rn(...t);z.constraint.UserConstraint=en;var Fn=class{drawSegment(e,n,r){}drawCircle(e,n,r){}drawSolidCircle(e,n,r,p){}drawPolygon(e,n){}drawSolidPolygon(e,n){}drawPoint(e,n){}};var Ho="3.8.1";export{je as AABB,Ln as AngleJoint,G as Arbiter,Ze as ArbiterType,ln as Body,ce as BodyCallback,Ge as BodyListener,En as BodyType,An as Broadphase,S as Callback,x as CbEvent,Oe as CbType,Nn as Circle,se as CollisionArbiter,_n as Compound,Ke as Constraint,ze as ConstraintCallback,De as ConstraintListener,le as Contact,Pe as ConvexResult,Fn as DebugDraw,_t as DebugDrawFlags,Sn as DistanceJoint,Ie as Edge,ae as FluidArbiter,gn as FluidProperties,ve as Geom,dn as GeomPoly,xn as GravMassMode,Cn as InertiaMode,fe as InteractionCallback,Tn as InteractionFilter,Le as InteractionGroup,Me as InteractionListener,O as InteractionType,bn as Interactor,Zn as LineJoint,D as Listener,Fe as ListenerType,Ne as MarchingSquares,vn as MassMode,we as Mat23,Ye as MatMN,Pn as Material,Vn as MotorJoint,lt as NapeList,Be as OptionType,On as PivotJoint,In as Polygon,me as PreCallback,ke as PreFlag,Ue as PreListener,kn as PulleyJoint,Je as Ray,xe as RayResult,an as Shape,wn as ShapeType,We as Space,en as UserConstraint,Ho as VERSION,Ae as ValidationResult,L as Vec2,C as Vec3,Rn as WeldJoint,yn as Winding};
1
+ import{$ as En,A as sn,B as et,C as mn,D as X,E as c,F as $,G as v,H as L,I as C,J as Ye,K as je,L as yn,M as ge,N as dn,O as nt,P as tt,Q as rt,R as bn,S as lt,T as gn,U as wn,V as an,W as _t,X as We,Y as it,Z as pt,_ as ln,a as i,aa as _n,b as U,ba as Pn,c as Mn,ca as xn,d as ne,da as Cn,e as Y,ea as vn,f as T,fa as Nn,g as Un,ga as In,h as Yn,ha as An,i as rn,ia as Tn,j as B,ja as Ke,k as jn,ka as Ln,l as E,la as Sn,m as Wn,ma as Zn,n as Kn,na as Vn,o as Jn,oa as On,p as qn,pa as kn,q as Hn,qa as Rn,r as Xn,s as $n,t as Z,u as te,v as pn,w as on,x as be,y as j,z as Qn}from"./chunk-3TXNIYBK.js";var Bn={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},ot=c();ot.Config=Object.assign(ot.Config||{},Bn);function a(t,e,n){for(;t[e]!=null;){let r=t[e][n];t[e][n]=null,t[e]=r}}var un=class{static version(){return"Nape 2.0.19"}static clearObjectPools(){let e=c(),n=e.__zpp;a(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),a(e.phys.InteractorIterator,"zpp_pool","zpp_next"),a(e.phys.BodyIterator,"zpp_pool","zpp_next"),a(e.phys.CompoundIterator,"zpp_pool","zpp_next"),a(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),a(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),a(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),a(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),a(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),a(e.geom.RayResultIterator,"zpp_pool","zpp_next"),a(e.shape.ShapeIterator,"zpp_pool","zpp_next"),a(e.shape.EdgeIterator,"zpp_pool","zpp_next"),a(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),a(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),a(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),a(n.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Body,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Component,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),a(n.util.ZNPNode_ConvexResult,"zpp_pool","next"),a(n.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),a(n.util.ZNPNode_RayResult,"zpp_pool","next"),a(n.phys.ZPP_Material,"zpp_pool","next"),a(n.phys.ZPP_FluidProperties,"zpp_pool","next"),a(n.callbacks.ZPP_CbSetPair,"zpp_pool","next"),a(n.callbacks.ZPP_Callback,"zpp_pool","next"),a(n.callbacks.ZPP_CbSet,"zpp_pool","next"),a(n.geom.ZPP_GeomVert,"zpp_pool","next"),a(n.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),a(n.geom.ZPP_Mat23,"zpp_pool","next"),a(n.geom.ZPP_CutVert,"zpp_pool","next"),a(n.geom.ZPP_CutInt,"zpp_pool","next"),a(n.geom.ZPP_Vec2,"zpp_pool","next"),a(n.geom.ZPP_PartitionVertex,"zpp_pool","next"),a(n.geom.ZPP_SimplifyV,"zpp_pool","next"),a(n.geom.ZPP_SimplifyP,"zpp_pool","next"),a(n.geom.ZPP_PartitionedPoly,"zpp_pool","next"),a(n.geom.ZPP_PartitionPair,"zpp_pool","next"),a(n.geom.ZPP_AABB,"zpp_pool","next"),a(n.geom.ZPP_SimpleVert,"zpp_pool","next"),a(n.geom.ZPP_SimpleSeg,"zpp_pool","next"),a(n.geom.ZPP_SimpleEvent,"zpp_pool","next"),a(n.util.Hashable2_Boolfalse,"zpp_pool","next"),a(n.geom.ZPP_ToiEvent,"zpp_pool","next"),a(n.geom.ZPP_MarchSpan,"zpp_pool","next"),a(n.geom.ZPP_MarchPair,"zpp_pool","next"),a(n.shape.ZPP_Edge,"zpp_pool","next"),a(n.space.ZPP_SweepData,"zpp_pool","next"),a(n.space.ZPP_AABBNode,"zpp_pool","next"),a(n.space.ZPP_AABBPair,"zpp_pool","next"),a(n.dynamics.ZPP_Contact,"zpp_pool","next"),a(n.space.ZPP_Island,"zpp_pool","next"),a(n.space.ZPP_Component,"zpp_pool","next"),a(n.space.ZPP_CallbackSet,"zpp_pool","next"),a(n.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),a(n.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),a(n.dynamics.ZPP_ColArbiter,"zpp_pool","next"),a(n.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),a(n.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),a(n.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),a(n.util.ZPP_PubPool,"poolVec2","zpp_pool"),a(n.util.ZPP_PubPool,"poolVec3","zpp_pool")}};var F=class F{get _inner(){return this}constructor(e=1,n=0,r=0,p=1,o=0,s=0){let _=sn.get();this.zpp_inner=_,_.outer=this;let f=["a","b","tx","c","d","ty"],y=[e,n,o,r,p,s];for(let h=0;h<y.length;h++)if(y[h]!==y[h])throw new Error("Error: Mat23::"+f[h]+" cannot be NaN");_.setas(e,n,r,p,o,s)}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let n=Math.cos(e),r=Math.sin(e);return new F(n,-r,r,n,0,0)}static translation(e,n){return new F(1,0,0,1,e,n)}static scale(e,n){return new F(e,0,0,n,0,0)}static _wrap(e){return e instanceof F?e:e?e instanceof sn?v(e,n=>{let r=Object.create(F.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?F._wrap(e.zpp_inner):null:null}_setProp(e,n){if(n!==n)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=n,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,n=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,_=r.c-p.c,f=r.d-p.d,y=r.tx-p.tx,h=r.ty-p.ty;return(o<0?-o:o)<=n&&(s<0?-s:s)<=n&&(_<0?-_:_)<=n&&(f<0?-f:f)<=n&&(y<0?-y:y)<=n&&(h<0?-h:h)<=n}copy(){return new F(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 n=e.zpp_inner;return this.zpp_inner.setas(n.a,n.b,n.c,n.d,n.tx,n.ty),this.zpp_inner.invalidate(),this}setAs(e=1,n=0,r=0,p=1,o=0,s=0){return this.zpp_inner.setas(e,n,r,p,o,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:n,c:r,d:p}=this.zpp_inner,o=e*e+n*n+r*r+p*p,s=e*p-n*r;s<0&&(s=-s);let _=c();return o>_.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:n,c:r,d:p,tx:o,ty:s}=this.zpp_inner,_=1/(e*p-n*r);return new F(p*_,-n*_,-r*_,e*_,(n*s-p*o)*_,(r*o-e*s)*_)}transpose(){let{a:e,b:n,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return new F(e,r,n,p,-e*o-r*s,-n*o-p*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let n=e.zpp_inner,r=this.zpp_inner;return new F(n.a*r.a+n.b*r.c,n.a*r.b+n.b*r.d,n.c*r.a+n.d*r.c,n.c*r.b+n.d*r.d,n.a*r.tx+n.b*r.ty+n.tx,n.c*r.tx+n.d*r.ty+n.ty)}transform(e,n=!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:_,c:f,d:y,tx:h,ty:m}=this.zpp_inner,d,g;n?(d=p*s+o*_,g=p*f+o*y):(d=p*s+o*_+h,g=p*f+o*y+m);let R=L.get(d,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,n=!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:_,tx:f,ty:y}=this.zpp_inner,h=1/(p*_-o*s);e.zpp_inner.validate();let m=e.zpp_inner.x,d=e.zpp_inner.y,g,R;if(n)g=(m*_-d*o)*h,R=(d*p-m*s)*h;else{let l=m-f,u=d-y;g=(l*_-u*o)*h,R=(u*p-l*s)*h}let q=L.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),q}equiorthogonal(){if(this.singular())return!1;let{a:e,b:n,c:r,d:p}=this.zpp_inner,o=c(),s=e*n+r*p;if(s*s>=o.Config.epsilon)return!1;let _=e*e+n*n-r*r-p*p;return _*_<o.Config.epsilon}orthogonal(){let{a:e,b:n,c:r,d:p}=this.zpp_inner,o=c(),s=e*n+r*p;if(s*s>=o.Config.epsilon)return!1;let _=e*e+n*n-1,f=r*r+p*p-1;return _*_<o.Config.epsilon&&f*f<o.Config.epsilon}_orthogonaliseImpl(e){let{a:n,b:r,c:p,d:o}=this.zpp_inner,s=c(),_=Math.sqrt(n*n+p*p),f=Math.sqrt(r*r+o*o);if(_*_<s.Config.epsilon||f*f<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let y=e?(_+f)/2:1;_=y/_,f=y/f,this.a=this.zpp_inner.a*_,this.c=this.zpp_inner.c*_,this.b=this.zpp_inner.b*f,this.d=this.zpp_inner.d*f;let h=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(h/(y*y));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let d=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*d,q=this.zpp_inner.b*g+this.zpp_inner.d*d,l=this.zpp_inner.c*g+this.zpp_inner.a*d,u=this.zpp_inner.d*g-this.zpp_inner.b*d;return this.c=l,this.a=R,this.d=u,this.b=q,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:n,c:r,d:p,tx:o,ty:s}=this.zpp_inner;return"{ a: "+e+" b: "+n+" c: "+r+" d: "+p+" tx: "+o+" ty: "+s+" }"}};F.__name__=["nape","geom","Mat23"];var we=F;sn._wrapFn=t=>v(t,e=>{let n=Object.create(we.prototype);return n.zpp_inner=e,e.outer=n,n});function hn(t){if(t.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=t.zpp_inner;return e._validate!=null&&e._validate(),e.x}function cn(t){if(t.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=t.zpp_inner;return e._validate!=null&&e._validate(),e.y}function Ee(t){t.zpp_inner.weak&&t.dispose()}var re=class re{get _inner(){return this}constructor(e,n){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(n?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(n==null)throw new Error("Error: Ray::direction cannot be null");let r=new et;this.zpp_inner=r;let p=hn(e),o=cn(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),Ee(e);let s=hn(n),_=cn(n);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=_,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),Ee(n),r.zip_dir=!0,r.maxdist=1/0}static _wrap(e){return e==null?null:e instanceof re?e:v(e,n=>{let r=Object.create(re.prototype);return r.zpp_inner=n.zpp_inner??n,r})}static fromSegment(e,n){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(n?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(n==null)throw new Error("Error: Ray::fromSegment::end is null");let r=n.sub(e,!0),p=new re(e,r),o=hn(e),s=cn(e),_=hn(n),f=cn(n),y=_-o,h=f-s,m=Math.sqrt(y*y+h*h);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return p.zpp_inner.maxdist=m,Ee(e),Ee(n),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),Ee(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,Ee(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 je._wrap(this.zpp_inner.rayAABB())}at(e,n=!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,_=o+e*this.zpp_inner.diry;return L.get(s,_,n)}clone(){return this.copy()}copy(){let e=new re(this.zpp_inner.origin,this.zpp_inner.direction),n=this.zpp_inner.maxdist;if(n!==n)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=n,e}};re.__name__=["nape","geom","Ray"];var Je=re;var qe=class qe{get _inner(){return this}constructor(){if(this.zpp_inner=null,!be.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof qe)return e;let n=e.zpp_inner??e;return v(n,r=>{let p=Object.create(qe.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),L._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),L._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")}};qe.__name__=["nape","geom","ConvexResult"];var Pe=qe;be._createConvexResult=()=>new Pe;var He=class He{get _inner(){return this}constructor(){if(this.zpp_inner=null,!be.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof He)return e;let n=e.zpp_inner??e;return v(n,r=>{let p=Object.create(He.prototype);return p.zpp_inner=r,p})}get normal(){return this._disposed(),L._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")}};He.__name__=["nape","geom","RayResult"];var xe=He;be._createRayResult=()=>new xe;function ie(t){return t?.zpp_inner??t?._inner?.zpp_inner}function zn(t){return t?.zpp_inner??t?._inner?.zpp_inner}function fn(t,e){if(t!=null&&t.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let n=t.zpp_inner;if(n._immutable)throw new Error("Error: Vec2 is immutable");n._isimmutable!=null&&n._isimmutable()}function Ce(t,e){if(ie(t)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var ve=class{static distanceBody(e,n,r,p){fn(r,"out1"),fn(p,"out2");let o=zn(e),s=zn(n);if(o.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let _=o.shapes.head;for(;_!=null;)j.validateShape(_.elt),_=_.next;for(_=s.shapes.head;_!=null;)j.validateShape(_.elt),_=_.next;return mn.distanceBody(o,s,r.zpp_inner,p.zpp_inner)}static distance(e,n,r,p){fn(r,"out1"),fn(p,"out2"),Ce(e,"distances"),Ce(n,"distances");let o=ie(e),s=ie(n);j.validateShape(o),j.validateShape(s);let _;E.zpp_pool==null?_=new E:(_=E.zpp_pool,E.zpp_pool=_.next,_.next=null),_.weak=!1;let f=mn.distance(o,s,r.zpp_inner,p.zpp_inner,_,1e100);return _.next=E.zpp_pool,E.zpp_pool=_,f}static intersectsBody(e,n){let r=zn(e),p=zn(n);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;)j.validateShape(o.elt),o=o.next;for(o=p.shapes.head;o!=null;)j.validateShape(o.elt),o=o.next;let s=r.aabb,_=p.aabb;if(s.minx>_.maxx||s.maxx<_.minx||s.miny>_.maxy||s.maxy<_.miny)return!1;let f=r.shapes.head;for(;f!=null;){let y=p.shapes.head;for(;y!=null;){if(on.testCollide_safe(f.elt,y.elt))return!0;y=y.next}f=f.next}return!1}static intersects(e,n){Ce(e,"intersection"),Ce(n,"intersection");let r=ie(e),p=ie(n);j.validateShape(r),j.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:on.testCollide_safe(r,p)}static contains(e,n){Ce(e,"containment"),Ce(n,"containment");let r=ie(e),p=ie(n);return j.validateShape(r),j.validateShape(p),on.containTest(r,p)}};ve.__name__=["nape","geom","Geom"];var Ne=class{static run(e,n,r,p=2,o=null,s=!0,_=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(n==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 f=r.zpp_inner;if(f._validate!=null&&f._validate(),f.x<=0||f.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 y=c(),h=_??new y.geom.GeomPolyList,m=Qn,d=n.zpp_inner;if(d._validate!=null&&d._validate(),o==null){let g=d.minx,R=d.miny,q=d.maxx,l=d.maxy;m.run(e,g,R,q,l,r,p,s,h)}else{let g=o.zpp_inner;g._validate!=null&&g._validate();let R=d.maxx-d.minx,q=d.maxy-d.miny,l=R/g.x,u=q/g.y,b=l|0,M=u|0;b!==l&&++b,M!==u&&++M;for(let nn=0;nn<b;nn++){let Gn=d.minx+g.x*nn,st=nn===b-1?d.maxx:Gn+g.x;for(let tn=0;tn<M;tn++){let Dn=d.miny+g.y*tn,at=tn===M-1?d.maxy:Dn+g.y;m.run(e,Gn,Dn,st,at,r,p,s,h)}}}return f.weak&&r.dispose(),o!=null&&o.zpp_inner.weak&&o.dispose(),h}};Ne.__name__=["nape","geom","MarchingSquares"];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 Mn,this._invalidated=!0}static get(e,n){n==null&&(n=!1);let r=c(),p=new r.geom.Vec2List;return p.zpp_inner.inner=e,n&&(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.__name__=["zpp_nape","util","ZPP_Vec2List"],H.internal=!1;function pe(t){if(t.outer==null){let e=c();t.outer=new e.geom.Vec2;let n=t.outer.zpp_inner;n.outer!=null&&(n.outer.zpp_inner=null,n.outer=null),n._isimmutable=null,n._validate=null,n._invalidate=null,n.next=E.zpp_pool,E.zpp_pool=n,t.outer.zpp_inner=t}return t.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.__name__=["nape","geom","Vec2Iterator"];N.zpp_pool=null;N.get=function(t){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=t,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 t=this.zpp_inner.zpp_gl();return this.zpp_critical=!0,this.zpp_i<t?!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.__name__=["nape","geom","Vec2List"];w.fromArray=function(t){if(t==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=c(),n=new e.geom.Vec2List;for(let r=0;r<t.length;r++)n.push(t[r]);return n};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(t){return this.zpp_vm(),this.zpp_inner.inner.has(t.zpp_inner)};w.prototype.at=function(t){if(this.zpp_vm(),t<0||t>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(t=this.zpp_gl()-1-t),t<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=t,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(t);else for(;this.zpp_inner.at_index!=t;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return pe(this.zpp_inner.at_ite.elt)};w.prototype.push=function(t){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(t):!0;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(t.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,t.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)),e};w.prototype.unshift=function(t){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(t):!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,t.zpp_inner)):this.zpp_inner.inner.add(t.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)),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 t;if(this.zpp_inner.reverse_flag){t=this.zpp_inner.inner.head.elt;let e=pe(t);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);t=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let n=pe(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e)}return this.zpp_inner.invalidate(),pe(t)};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 t;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);t=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let n=pe(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e)}else{t=this.zpp_inner.inner.head.elt;let e=pe(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),pe(t)};w.prototype.add=function(t){return this.zpp_inner.reverse_flag?this.push(t):this.unshift(t)};w.prototype.remove=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=!1,n=this.zpp_inner.inner.head;for(;n!=null;){if(n.elt==t.zpp_inner){e=!0;break}n=n.next}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(t.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(t){t==null&&(t=!1);let e=c(),n=new e.geom.Vec2List,r=N.get(this);for(;r.hasNext();){let p=r.next(),o;if(t){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 _=p.zpp_inner.x,f=p.zpp_inner;f._validate!=null&&f._validate();let y=p.zpp_inner.y,h;if(U.poolVec2==null?h=new e.geom.Vec2:(h=U.poolVec2,U.poolVec2=h.zpp_pool,h.zpp_pool=null,h.zpp_disp=!1,h==U.nextVec2&&(U.nextVec2=null)),h.zpp_inner==null){let m;E.zpp_pool==null?m=new E:(m=E.zpp_pool,E.zpp_pool=m.next,m.next=null),m.weak=!1,m._immutable=!1,m.x=_,m.y=y,h.zpp_inner=m,h.zpp_inner.outer=h}else h.zpp_inner.x=_,h.zpp_inner.y=y,h.zpp_inner._invalidate!=null&&h.zpp_inner._invalidate(h.zpp_inner);h.zpp_inner.weak=!1,o=h}else o=p;n.push(o)}return n};w.prototype.merge=function(t){if(t==null)throw new Error("Error: Cannot merge with null list");let e=t.iterator();for(;e.hasNext();){let n=e.next();this.has(n)||this.add(n)}};w.prototype.toString=function(){let t="[",e=!0,n=N.get(this);for(;n.hasNext();){let r=n.next();e||(t+=","),t+=r==null?"NULL":r.toString(),e=!1}return t+"]"};w.prototype.foreach=function(t){if(t==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{t(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 t=N.get(this);return{next(){return t.hasNext()?{value:t.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};w.prototype.filter=function(t){if(t==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let n=this.at(e);try{t(n)?++e:this.remove(n)}catch{break}}return this};function Q(){if(!ge.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}Q.__name__=["nape","geom","GeomVertexIterator"];Q.prototype.zpp_inner=null;Q.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let t=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=!1,!t){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=ge.zpp_pool,ge.zpp_pool=e}return t};Q.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let t=this.zpp_inner.ptr;if(t.wrap==null){let n=t.x,r=t.y;if(n!==n||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let p=c(),o;if(U.poolVec2==null?o=new p.geom.Vec2:(o=U.poolVec2,U.poolVec2=o.zpp_pool,o.zpp_pool=null,o.zpp_disp=!1,o==U.nextVec2&&(U.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=n,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==n&&s.y==r||(s.x=n,s.y=r,s._invalidate!=null&&s._invalidate(s))}o.zpp_inner.weak=!1,t.wrap=o,t.wrap.zpp_inner._inuse=!0,t.wrap.zpp_inner._invalidate=s=>t.modwrap(s),t.wrap.zpp_inner._validate=()=>t.getwrap()}let e=t.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};Q.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 ut=c();ut.geom.GeomVertexIterator=Q;var W=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 te,this._invalidated=!0}static get(e,n){n==null&&(n=!1);let r=c(),p=new r.dynamics.ContactList;return p.zpp_inner.inner=e,n&&(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)}};W.__name__=["zpp_nape","util","ZPP_ContactList"],W.internal=!1;var Xe=class Xe{constructor(){if(!X.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof Xe?e:e instanceof X?v(e,n=>{X.internal=!0;let r=new Xe;return X.internal=!1,r.zpp_inner=n,n.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 n=c();if(e.outer==null){e.outer=new n.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}};Xe.__name__=["nape","shape","Edge"];var Ie=Xe;X._wrapFn=t=>v(t,e=>{X.internal=!0;let n=new Ie;return X.internal=!1,n.zpp_inner=e,e.outer=n,n});var oe=class oe{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 oe,i.internal=!1),i.ValidationResult_VALID}static get DEGENERATE(){return i.ValidationResult_DEGENERATE==null&&(i.internal=!0,i.ValidationResult_DEGENERATE=new oe,i.internal=!1),i.ValidationResult_DEGENERATE}static get CONCAVE(){return i.ValidationResult_CONCAVE==null&&(i.internal=!0,i.ValidationResult_CONCAVE=new oe,i.internal=!1),i.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return i.ValidationResult_SELF_INTERSECTING==null&&(i.internal=!0,i.ValidationResult_SELF_INTERSECTING=new oe,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":""}};oe.__name__=["nape","shape","ValidationResult"];var Ae=oe,ht=c();ht.shape.ValidationResult=Ae;var Te=class Te{get _inner(){return this}constructor(e=!1){let n=new pn;this.zpp_inner=n,n.outer=this,n.ignore!=e&&(n.invalidate(!0),n.ignore=e)}static _wrap(e){return e instanceof Te?e:e?e instanceof pn?v(e,n=>{let r=Object.create(Te.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?Te._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=c();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=c();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}};Te.__name__=["nape","dynamics","InteractionGroup"];var Le=Te;pn._wrapFn=t=>v(t,e=>{let n=Object.create(Le.prototype);return n.zpp_inner=e,e.outer=n,n});var Se=class Se{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 Se,i.internal=!1),i.ArbiterType_COLLISION}static get SENSOR(){return i.ArbiterType_SENSOR==null&&(i.internal=!0,i.ArbiterType_SENSOR=new Se,i.internal=!1),i.ArbiterType_SENSOR}static get FLUID(){return i.ArbiterType_FLUID==null&&(i.internal=!0,i.ArbiterType_FLUID=new Se,i.internal=!1),i.ArbiterType_FLUID}toString(){return this===i.ArbiterType_COLLISION?"COLLISION":this===i.ArbiterType_SENSOR?"SENSOR":this===i.ArbiterType_FLUID?"FLUID":""}};Se.__name__=["nape","dynamics","ArbiterType"];var Ze=Se,ct=c();ct.dynamics.ArbiterType=Ze;$();var G=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!Z.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return Z.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==Z.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==Z.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=c(),n=this.zpp_inner.immState;return n==5?(i.PreFlag_ACCEPT==null&&(i.internal=!0,i.PreFlag_ACCEPT=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT):n==1?(i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,i.internal=!1),i.PreFlag_ACCEPT_ONCE):n==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==Z.COL}isFluidArbiter(){return this.zpp_inner.type==Z.FLUID}isSensorArbiter(){return this.zpp_inner.type==Z.SENSOR}totalImpulse(e=null,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),C.get(0,0,0)}toString(){let e=this.zpp_inner.type==Z.COL?"CollisionArbiter":this.zpp_inner.type==Z.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let n=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+"("+n.toString()+"|"+r.toString()+")";return this.zpp_inner.type==Z.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 n=this.zpp_inner,r=n.ws1.id>n.ws2.id?n.b2.outer:n.b1.outer,p=n.ws1.id>n.ws2.id?n.b1.outer:n.b2.outer;if(e!=r&&e!=p)throw new Error("Error: Arbiter does not relate to body")}};G.__name__=["nape","dynamics","Arbiter"];var zt=c();zt.dynamics.Arbiter=G;var se=class extends G{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 n=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;n.zpp_inner.type==1?n.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 n=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;n.zpp_inner.type==1?n.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,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,n)}tangentImpulse(e=null,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,n)}totalImpulse(e=null,n=!1){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,n)}rollingImpulse(e=null,n=!1){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return!n||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,n,r){let p=0,o=0,s=0,_=this.zpp_inner.colarb;if(!r||_.oc1.fresh){let f=_.oc1.wrapper()[e](n),y=f.zpp_inner;y._validate!=null&&y._validate(),p+=y.x,y._validate!=null&&y._validate(),o+=y.y,y._validate!=null&&y._validate(),s+=y.z,f.dispose()}if(_.hc2&&(!r||_.oc2.fresh)){let f=_.oc2.wrapper()[e](n),y=f.zpp_inner;y._validate!=null&&y._validate(),p+=y.x,y._validate!=null&&y._validate(),o+=y.y,y._validate!=null&&y._validate(),s+=y.z,f.dispose()}return C.get(p,o,s)}};se.__name__=["nape","dynamics","CollisionArbiter"],se.__super__=G;var ae=class extends G{constructor(){super()}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),L._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 n=this.zpp_inner.fluidarb;return e==null?C.get(n.buoyx,n.buoyy,0):e.zpp_inner==this.zpp_inner.b2?C.get(n.buoyx,n.buoyy,n.buoyy*n.r2x-n.buoyx*n.r2y):C.get(-n.buoyx,-n.buoyy,-(n.buoyy*n.r1x-n.buoyx*n.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let n=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return C.get(n.dampx*r,n.dampy*r,n.adamp*r)}totalImpulse(e=null,n=!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}};ae.__name__=["nape","dynamics","FluidArbiter"],ae.__super__=G;var le=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!te.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==Z.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(),L._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 n=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jnAcc;return e==null?C.get(n.nx*p,n.ny*p):(this._checkBody(e,n),e==n.b1.outer?C.get(n.nx*-p,n.ny*-p,-(n.ny*r.r1x-n.nx*r.r1y)*p):C.get(n.nx*p,n.ny*p,(n.ny*r.r2x-n.nx*r.r2y)*p))}tangentImpulse(e=null){this._inactiveCheck();let n=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jtAcc;return e==null?C.get(-n.ny*p,n.nx*p):(this._checkBody(e,n),e==n.b1.outer?C.get(n.ny*p,-n.nx*p,-(r.r1x*n.nx+r.r1y*n.ny)*p):C.get(-n.ny*p,n.nx*p,(r.r2x*n.nx+r.r2y*n.ny)*p))}rollingImpulse(e=null){this._inactiveCheck();let n=this.zpp_inner.arbiter.colarb,r=n.jrAcc;return e==null?r:(this._checkBody(e,n),e==n.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let n=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,p=r.jnAcc,o=r.jtAcc,s=n.jrAcc;if(e==null)return C.get(n.nx*p-n.ny*o,n.ny*p+n.nx*o,s);this._checkBody(e,n);let _=n.nx*p-n.ny*o,f=n.ny*p+n.nx*o;return e==n.b1.outer?C.get(-_,-f,-(f*r.r1x-_*r.r1y)-s):C.get(_,f,f*r.r2x-_*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,n){if(e!=n.b1.outer&&e!=n.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};le.__name__=["nape","dynamics","Contact"];te._wrapFn=t=>{te.internal=!0;let e=new le;return te.internal=!1,e.zpp_inner=t,t.outer=e,e};function ft(t){let e=0,n=t.inner.next;for(;n!=null;)n.active&&n.arbiter.active&&e++,n=n.next;return e}function V(t){return t.valmod(),t.zip_length&&(t.zip_length=!1,t.user_length=ft(t)),t.user_length}function P(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!W.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}P.__name__=["nape","dynamics","ContactIterator"];P.zpp_pool=null;P.get=function(t){let e;return P.zpp_pool==null?(W.internal=!0,e=new P,W.internal=!1):(e=P.zpp_pool,P.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=t,e.zpp_critical=!1,e};P.prototype.zpp_inner=null;P.prototype.zpp_i=null;P.prototype.zpp_critical=null;P.prototype.zpp_next=null;P.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let t=V(this.zpp_inner.zpp_inner);return this.zpp_critical=!0,this.zpp_i<t?!0:(this.zpp_next=P.zpp_pool,P.zpp_pool=this,this.zpp_inner=null,!1)};P.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 W,this.zpp_inner.outer=this}I.__name__=["nape","dynamics","ContactList"];I.fromArray=function(t){if(t==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=c(),n=new e.dynamics.ContactList;for(let r=0;r<t.length;r++)n.push(t[r]);return n};I.prototype.zpp_inner=null;Object.defineProperty(I.prototype,"length",{get:function(){return V(this.zpp_inner)}});I.prototype.has=function(t){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(t.zpp_inner)};I.prototype.at=function(t){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(t<0||t>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(t=V(this.zpp_inner)-1-t),t<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 n=this.zpp_inner.at_ite;if(n.active&&n.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next}for(;this.zpp_inner.at_index!=t;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let n=this.zpp_inner.at_ite;if(n.active&&n.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(t){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(t):!0;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(t.zpp_inner);else{if(this.zpp_inner.push_ite==null){let n=V(this.zpp_inner);n==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(n-1)}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,t.zpp_inner)}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};I.prototype.unshift=function(t){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(t):!0;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let n=V(this.zpp_inner);n==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(n-1)}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,t.zpp_inner)}else this.zpp_inner.inner.add(t.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};I.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let n=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),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 n=V(this.zpp_inner),r;n==1?r=null:r=this.zpp_inner.inner.iterator_at(n-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(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let n=V(this.zpp_inner),r;n==1?r=null:r=this.zpp_inner.inner.iterator_at(n-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 n=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),e.wrapper()};I.prototype.add=function(t){return this.zpp_inner.reverse_flag?this.push(t):this.unshift(t)};I.prototype.remove=function(t){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=!1,n=this.zpp_inner.inner.next;for(;n!=null;){if(n==t.zpp_inner){e=!0;break}n=n.next}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(t.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(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift()};I.prototype.empty=function(){return V(this.zpp_inner)==0};I.prototype.iterator=function(){return this.zpp_inner.valmod(),P.get(this)};I.prototype.copy=function(t){t==null&&(t=!1);let e=c(),n=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=P.get(this);for(;r.hasNext();){let p=r.next();if(t)throw new Error("Error: Contact is not a copyable type");n.push(p)}return n};I.prototype.merge=function(t){if(t==null)throw new Error("Error: Cannot merge with null list");t.zpp_inner.valmod();let e=P.get(t);for(;e.hasNext();){let n=e.next();this.has(n)||(this.zpp_inner.reverse_flag?this.push(n):this.unshift(n))}};I.prototype.toString=function(){let t="[",e=!0;this.zpp_inner.valmod();let n=P.get(this);for(;n.hasNext();){let r=n.next();e||(t+=","),t+=r==null?"NULL":r.toString(),e=!1}return t+"]"};I.prototype.foreach=function(t){if(t==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=P.get(this);for(;e.hasNext();)try{t(e.next())}catch{e.zpp_next=P.zpp_pool,P.zpp_pool=e,e.zpp_inner=null;break}return this};I.prototype[Symbol.iterator]=function(){let t=P.get(this);return{next(){return t.hasNext()?{value:t.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};I.prototype.filter=function(t){if(t==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let n=V(this.zpp_inner);if(!(e<n))break;let r=this.at(e);try{t(r)?++e:this.remove(r)}catch{break}}return this};var K=class K{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 K,i.internal=!1),i.CbEvent_BEGIN}static get ONGOING(){return i.CbEvent_ONGOING==null&&(i.internal=!0,i.CbEvent_ONGOING=new K,i.internal=!1),i.CbEvent_ONGOING}static get END(){return i.CbEvent_END==null&&(i.internal=!0,i.CbEvent_END=new K,i.internal=!1),i.CbEvent_END}static get WAKE(){return i.CbEvent_WAKE==null&&(i.internal=!0,i.CbEvent_WAKE=new K,i.internal=!1),i.CbEvent_WAKE}static get SLEEP(){return i.CbEvent_SLEEP==null&&(i.internal=!0,i.CbEvent_SLEEP=new K,i.internal=!1),i.CbEvent_SLEEP}static get BREAK(){return i.CbEvent_BREAK==null&&(i.internal=!0,i.CbEvent_BREAK=new K,i.internal=!1),i.CbEvent_BREAK}static get PRE(){return i.CbEvent_PRE==null&&(i.internal=!0,i.CbEvent_PRE=new K,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":""}};K.__name__=["nape","callbacks","CbEvent"];var x=K,mt=c();mt.callbacks.CbEvent=x;$();var Ve=class Ve{get _inner(){return this}constructor(){this.zpp_inner=new Y,this.zpp_inner.outer=this}static get ANY_BODY(){return Y.ANY_BODY}static get ANY_CONSTRAINT(){return Y.ANY_CONSTRAINT}static get ANY_SHAPE(){return Y.ANY_SHAPE}static get ANY_COMPOUND(){return Y.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=pt.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=it.get(this.zpp_inner.constraints,!0)),this.zpp_inner.wrap_constraints}including(e){return new(c()).callbacks.OptionType(this).including(e)}excluding(e){return new(c()).callbacks.OptionType(this).excluding(e)}toString(){return this===Y.ANY_BODY?"ANY_BODY":this===Y.ANY_SHAPE?"ANY_SHAPE":this===Y.ANY_COMPOUND?"ANY_COMPOUND":this===Y.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e){return e instanceof Ve?e:e?e instanceof Y?v(e,n=>{let r=Object.create(Ve.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?Ve._wrap(e.zpp_inner):null:null}};Ve.__name__=["nape","callbacks","CbType"];var Oe=Ve,yt=c();yt.callbacks.CbType=Oe;$();var _e=class _e{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 _e,i.internal=!1),i.InteractionType_COLLISION}static get SENSOR(){return i.InteractionType_SENSOR==null&&(i.internal=!0,i.InteractionType_SENSOR=new _e,i.internal=!1),i.InteractionType_SENSOR}static get FLUID(){return i.InteractionType_FLUID==null&&(i.internal=!0,i.InteractionType_FLUID=new _e,i.internal=!1),i.InteractionType_FLUID}static get ANY(){return i.InteractionType_ANY==null&&(i.internal=!0,i.InteractionType_ANY=new _e,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":""}};_e.__name__=["nape","callbacks","InteractionType"];var O=_e,dt=c();dt.callbacks.InteractionType=O;var ue=class ue{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 ue,i.internal=!1),i.PreFlag_ACCEPT}static get IGNORE(){return i.PreFlag_IGNORE==null&&(i.internal=!0,i.PreFlag_IGNORE=new ue,i.internal=!1),i.PreFlag_IGNORE}static get ACCEPT_ONCE(){return i.PreFlag_ACCEPT_ONCE==null&&(i.internal=!0,i.PreFlag_ACCEPT_ONCE=new ue,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 ue,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":""}};ue.__name__=["nape","callbacks","PreFlag"];var ke=ue,bt=c();bt.callbacks.PreFlag=ke;var Re=class Re{get _inner(){return this}constructor(e,n){this.zpp_inner=new B,this.zpp_inner.outer=this,e!=null&&this.including(e),n!=null&&this.excluding(n)}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 n=this.zpp_inner.wrap_excludes.toString();return"@{"+e+" excluding "+n+"}"}static _wrap(e){return e instanceof Re?e:e?e instanceof B?v(e,n=>{let r=Object.create(Re.prototype);return r.zpp_inner=n,n.outer=r,r}):e.zpp_inner?Re._wrap(e.zpp_inner):null:null}};Re.__name__=["nape","callbacks","OptionType"];var Be=Re,gt=c();gt.callbacks.OptionType=Be;function wt(t){return t===x.BEGIN?0:t===x.END?1:t===x.WAKE?2:t===x.SLEEP?3:t===x.BREAK?4:t===x.PRE?5:t===x.ONGOING?6:-1}var $e=class $e{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 $e?e:e&&e instanceof T?v(e,n=>{if(n.outer)return n.outer;let r=Object.create($e.prototype);return r.zpp_inner=n,n.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 n=wt(e);this.zpp_inner.swapEvent(n)}}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:We._wrap(this.zpp_inner.space.outer)}set space(e){let n=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=n)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),n!=null){let p=n.zpp_inner.wrap_listeners;p.zpp_inner.reverse_flag?p.push(this):p.unshift(this)}else this.zpp_inner.space=null}toString(){let n=["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{"+n+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return"ConstraintListener{"+n+"::"+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{"+n+"#"+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}}};$e.__name__=["nape","callbacks","Listener"];var D=$e;var he=class he{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 he,i.internal=!1),i.ListenerType_BODY}static get CONSTRAINT(){return i.ListenerType_CONSTRAINT==null&&(i.internal=!0,i.ListenerType_CONSTRAINT=new he,i.internal=!1),i.ListenerType_CONSTRAINT}static get INTERACTION(){return i.ListenerType_INTERACTION==null&&(i.internal=!0,i.ListenerType_INTERACTION=new he,i.internal=!1),i.ListenerType_INTERACTION}static get PRE(){return i.ListenerType_PRE==null&&(i.internal=!0,i.ListenerType_PRE=new he,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":""}};he.__name__=["nape","callbacks","ListenerType"];var Fe=he,Et=c();Et.callbacks.ListenerType=Fe;$();var S=class{constructor(){this.zpp_inner=null;if(!ne.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""}};S.__name__=["nape","callbacks","Callback"];var ce=class extends S{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)}};ce.__name__=["nape","callbacks","BodyCallback"];var ze=class extends S{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)}};ze.__name__=["nape","callbacks","ConstraintCallback"];var fe=class extends S{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)}};fe.__name__=["nape","callbacks","InteractionCallback"];var me=class extends S{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)}};me.__name__=["nape","callbacks","PreCallback"];var Ge=class extends D{constructor(e,n,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===x.WAKE)o=2;else if(e===x.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 Un(B.argument(n),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}};Ge.__name__=["nape","callbacks","BodyListener"];var De=class extends D{constructor(e,n,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===x.WAKE)o=2;else if(e===x.SLEEP)o=3;else if(e===x.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 Yn(B.argument(n),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}};De.__name__=["nape","callbacks","ConstraintListener"];function Qe(t){return t===O.COLLISION?1:t===O.SENSOR?2:t===O.FLUID?4:7}function ye(t){return t==1?O.COLLISION:t==2?O.SENSOR:t==4?O.FLUID:t==7?O.ANY:null}var Me=class extends D{constructor(e,n,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 _;if(e===x.BEGIN)_=0;else if(e===x.END)_=1;else if(e===x.ONGOING)_=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new rn(B.argument(r),B.argument(p),_,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,n==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=n&&(this.zpp_inner_zn.itype=Qe(n))}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 ye(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Qe(e))}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e}};Me.__name__=["nape","callbacks","InteractionListener"];var Ue=class extends D{constructor(e,n,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 rn(B.argument(n),B.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");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Qe(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 ye(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Qe(e))}};Ue.__name__=["nape","callbacks","PreListener"];var en=class t extends Ke{constructor(e,n=!1){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r=new Xn(e,n);this.zpp_inner=r,r.outer=this,r.outer_zn=this}static _wrap(e){return e==null?null:e instanceof t?e:e.zpp_inner?.outer instanceof t?e.zpp_inner.outer:v(e,n=>{let r=Object.create(t.prototype);return r.zpp_inner=n.zpp_inner??n,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new L;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,n,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,n=new Ye(e,1);for(let r=0;r<e;r++){if(r<0||r>=n.zpp_inner.m||0>=n.zpp_inner.n)throw new Error("Error: MatMN indices out of range");n.zpp_inner.x[r*n.zpp_inner.n]=this.zpp_inner.jAcc[r]}return n}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let n=!1;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){n=!0;break}if(!n)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):C.get()}visitBodies(e){let n=this.zpp_inner.bodies.length,r=0;for(;r<n;){let p=this.zpp_inner.bodies[r];if(p.body!=null){let o=!1;for(let s=r+1;s<n;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,n){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=n){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()}n!=null&&this.zpp_inner.addBody(n.zpp_inner),this.zpp_inner.wake(),n?.zpp_inner.wake()}return n}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e}};function k(t){let{typeName:e,namespaceParts:n,zppListClass:r,wrapElement:p,unwrapElement:o}=t,s=c(),_=s.__zpp,f=()=>_.util[r],y=()=>{let l=s;for(let u=1;u<n.length;u++)l=l[n[u]];return l};function h(){if(this.zpp_next=null,this.zpp_critical=!1,this.zpp_i=0,this.zpp_inner=null,!f().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}h.__name__=[...n,e+"Iterator"],h.zpp_pool=null,h.get=function(l){let u,b=f();return h.zpp_pool==null?(b.internal=!0,u=new h,b.internal=!1):(u=h.zpp_pool,h.zpp_pool=u.zpp_next),u.zpp_i=0,u.zpp_inner=l,u.zpp_critical=!1,u},h.prototype.zpp_inner=null,h.prototype.zpp_i=null,h.prototype.zpp_critical=null,h.prototype.zpp_next=null,h.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let l=this.zpp_inner;l.zpp_inner.valmod(),l.zpp_inner.zip_length&&(l.zpp_inner.zip_length=!1,l.zpp_inner.user_length=l.zpp_inner.inner.length);let u=l.zpp_inner.user_length;return this.zpp_critical=!0,this.zpp_i<u?!0:(this.zpp_next=h.zpp_pool,h.zpp_pool=this,this.zpp_inner=null,!1)},h.prototype.next=function(){return this.zpp_critical=!1,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(f()),this.zpp_inner.outer=this}m.__name__=[...n,e+"List"],m.fromArray=function(l){if(l==null)throw new Error("Error: Cannot convert null Array to Nape list");let u=new m;for(let b=0;b<l.length;b++)u.push(l[b]);return u},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=!1,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function d(l){return l.zpp_inner.valmod(),l.zpp_inner.zip_length&&(l.zpp_inner.zip_length=!1,l.zpp_inner.user_length=l.zpp_inner.inner.length),l.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return d(this)}}),m.prototype.has=function(l){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(o(l))},m.prototype.at=function(l){if(this.zpp_inner.valmod(),l<0||l>=d(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(l=d(this)-1-l),l<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=l,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(l);else for(;this.zpp_inner.at_index!=l;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return p(this.zpp_inner.at_ite.elt)},m.prototype.push=function(l){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let u=this.zpp_inner.adder!=null?this.zpp_inner.adder(l):!0;return u&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(o(l)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(d(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,o(l))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(l)),u},m.prototype.unshift=function(l){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let u=this.zpp_inner.adder!=null?this.zpp_inner.adder(l):!0;return u&&(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(d(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,o(l))):this.zpp_inner.inner.add(o(l)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(l)),u},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let l;if(this.zpp_inner.reverse_flag){l=this.zpp_inner.inner.head.elt;let u=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(u),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 u;d(this)==1?u=null:u=this.zpp_inner.inner.iterator_at(d(this)-2),l=u==null?this.zpp_inner.inner.head.elt:u.next.elt;let b=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(u)}return this.zpp_inner.invalidate(),p(l)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let l;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 u;d(this)==1?u=null:u=this.zpp_inner.inner.iterator_at(d(this)-2),l=u==null?this.zpp_inner.inner.head.elt:u.next.elt;let b=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(u)}else{l=this.zpp_inner.inner.head.elt;let u=p(l);this.zpp_inner.subber!=null&&this.zpp_inner.subber(u),this.zpp_inner.dontremove||this.zpp_inner.inner.pop()}return this.zpp_inner.invalidate(),p(l)},m.prototype.add=function(l){return this.zpp_inner.reverse_flag?this.push(l):this.unshift(l)},m.prototype.remove=function(l){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let u=!1,b=this.zpp_inner.inner.head,M=o(l);for(;b!=null;){if(b.elt==M){u=!0;break}b=b.next}return u&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(l),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(M),this.zpp_inner.invalidate()),u},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift()},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),h.get(this)},m.prototype.copy=function(l){l==null&&(l=!1);let u=new m,b=h.get(this);for(;b.hasNext();){let M=b.next();if(l)throw new Error("Error: "+e+" is not a copyable type");u.push(M)}return u},m.prototype.merge=function(l){if(l==null)throw new Error("Error: Cannot merge with null list");let u=h.get(l);for(;u.hasNext();){let b=u.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b))}},m.prototype.toString=function(){let l="[",u=!0,b=h.get(this);for(;b.hasNext();){let M=b.next();u||(l+=","),l+=M==null?"NULL":M.toString(),u=!1}return l+"]"},m.prototype.foreach=function(l){if(l==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let u=h.get(this);for(;u.hasNext();)try{l(u.next())}catch{u.zpp_next=h.zpp_pool,h.zpp_pool=u,u.zpp_inner=null;break}return this},m.prototype.filter=function(l){if(l==null)throw new Error("Error: Cannot select elements of list with null");let u=0;for(;u<d(this);){let b=this.at(u);try{l(b)?++u:this.remove(b)}catch{break}}return this},m.prototype.toArray=function(){let l=[],u=h.get(this);for(;u.hasNext();)l.push(u.next());return l},m.prototype[Symbol.iterator]=function(){let l=h.get(this);return{next(){return l.hasNext()?{value:l.next(),done:!1}:{value:void 0,done:!0}},[Symbol.iterator](){return this}}};let g=y(),R=e+"Iterator",q=e+"List";return g[R]=h,g[q]=m,{Iterator:h,List:m}}var ee=t=>t.outer,J=t=>t.zpp_inner??(t._inner?t._inner.zpp_inner??t._inner:t);k({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:ee,unwrapElement:J});k({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:ee,unwrapElement:J});k({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:ee,unwrapElement:J});k({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:ee,unwrapElement:J});k({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:ee,unwrapElement:J});k({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:ee,unwrapElement:J});k({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:ee,unwrapElement:J});k({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:ee,unwrapElement:J});k({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:t=>t.wrapper(),unwrapElement:J});k({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:t=>t.wrapper(),unwrapElement:J});k({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:t=>t,unwrapElement:t=>t});k({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:t=>t,unwrapElement:t=>t});k({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:t=>t.outer_i,unwrapElement:t=>t.zpp_inner_i});function de(t){if(t.outer==null){let e=c();t.outer=new e.geom.Vec2;let n=t.outer.zpp_inner;n.outer!=null&&(n.outer.zpp_inner=null,n.outer=null),n._isimmutable=null,n._validate=null,n._invalidate=null,n.next=E.zpp_pool,E.zpp_pool=n,t.outer.zpp_inner=t}return t.outer}function A(){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}A.__name__=["zpp_nape","util","ZPP_MixVec2List"];A.__super__=w;for(let t in w.prototype)A.prototype[t]=w.prototype[t];Object.defineProperty(A.prototype,"length",{get:function(){return this.zpp_gl()},configurable:!0});A.prototype.inner=null;A.prototype._length=0;A.prototype.zip_length=!1;A.prototype.at_ite=null;A.prototype.at_index=0;A.get=function(t,e){e==null&&(e=!1);let n=new A;return n.inner=t,n.zpp_inner.immutable=e,n};A.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let t=this.inner.next;for(;t!=null;)this._length++,t=t.next;this.zip_length=!1}return this._length};A.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=!0,this._length=0,this.at_ite=null)};A.prototype.at=function(t){if(this.zpp_vm(),t<0||t>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(t=this.zpp_gl()-1-t),(t<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==t;)this.at_index++,this.at_ite=this.at_ite.next;return de(this.at_ite)};A.prototype.push=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),t.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(t):!0;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(t.zpp_inner);else{let n=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(n,t.zpp_inner)}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};A.prototype.unshift=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),t.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(t):!0;if(e){if(this.zpp_inner.reverse_flag){let n=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(n,t.zpp_inner)}else this.inner.add(t.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(t)}return e};A.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 t;if(this.zpp_inner.reverse_flag){t=this.inner.next;let e=de(t);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);t=e==null?this.inner.next:e.next;let n=de(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.erase(e)}return this.zpp_inner.invalidate(),de(t)};A.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 t;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);t=e==null?this.inner.next:e.next;let n=de(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.erase(e)}else{t=this.inner.next;let e=de(t);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop()}return this.zpp_inner.invalidate(),de(t)};A.prototype.remove=function(t){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=!1,n=this.inner.next;for(;n!=null;){if(t.zpp_inner===n){e=!0;break}n=n.next}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.remove(t.zpp_inner),this.zpp_inner.invalidate()),e};A.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 Pt=c(),xt=Pt.__zpp;xt.util.ZPP_MixVec2List=A;var z=c();z.Config=Object.assign(z.Config||{},Bn);z.util.Debug=un;z.geom.Vec2=L;z.geom.Vec3=C;z.geom.Mat23=we;z.geom.MatMN=Ye;z.geom.AABB=je;z.geom.Winding=yn;z.geom.Ray=Je;z.geom.ConvexResult=Pe;z.geom.RayResult=xe;z.geom.Geom=ve;z.geom.GeomPoly=dn;z.geom.MarchingSquares=Ne;z.geom.Vec2Iterator=N;z.geom.Vec2List=w;z.geom.GeomVertexIterator=Q;z.__zpp.geom.ZPP_GeomVertexIterator=ge;z.__zpp.util.ZPP_ContactList=W;z.phys.Interactor=bn;z.phys.Body=ln;nt(t=>ln._wrap(t));z.phys.BodyType=En;z.phys.Compound=_n;rt(t=>_n._wrap(t));z.phys.FluidProperties=gn;z.phys.Material=Pn;z.phys.GravMassMode=xn;z.phys.InertiaMode=Cn;z.phys.MassMode=vn;z.shape.Shape=an;tt(t=>an._wrap(t));z.shape.Circle=Nn;z.shape.Polygon=In;z.shape.Edge=Ie;z.shape.ShapeType=wn;z.shape.ValidationResult=Ae;z.space.Space=We;z.space.Broadphase=An;z.dynamics.InteractionFilter=Tn;z.dynamics.InteractionGroup=Le;z.dynamics.ArbiterType=Ze;z.dynamics.Arbiter=G;Z._createColArb=()=>new se;Z._createFluidArb=()=>new ae;z.dynamics.Contact=le;z.dynamics.ContactIterator=P;z.dynamics.ContactList=I;z.callbacks.CbEvent=x;z.callbacks.CbType=Oe;z.callbacks.InteractionType=O;z.callbacks.PreFlag=ke;z.callbacks.OptionType=Be;z.callbacks.Listener=D;z.callbacks.ListenerType=Fe;z.callbacks.Callback=S;ce.__super__=S;ne._createBodyCb=()=>new ce;ze.__super__=S;ne._createConCb=()=>new ze;fe.__super__=S;ne._createIntCb=()=>new fe;me.__super__=S;ne._createPreCb=()=>new me;z.callbacks.BodyListener=Ge;z.callbacks.ConstraintListener=De;z.callbacks.InteractionListener=Me;z.callbacks.PreListener=Ue;z.constraint.Constraint=Ke;jn._createFn=(...t)=>new Ln(...t);Wn._createFn=(...t)=>new Sn(...t);Kn._createFn=(...t)=>new Zn(...t);Jn._createFn=(...t)=>new Vn(...t);qn._createFn=(...t)=>new On(...t);Hn._createFn=(...t)=>new kn(...t);$n._createFn=(...t)=>new Rn(...t);z.constraint.UserConstraint=en;var Fn=class{drawSegment(e,n,r){}drawCircle(e,n,r){}drawSolidCircle(e,n,r,p){}drawPolygon(e,n){}drawSolidPolygon(e,n){}drawPoint(e,n){}};var Ho="3.8.2";export{je as AABB,Ln as AngleJoint,G as Arbiter,Ze as ArbiterType,ln as Body,ce as BodyCallback,Ge as BodyListener,En as BodyType,An as Broadphase,S as Callback,x as CbEvent,Oe as CbType,Nn as Circle,se as CollisionArbiter,_n as Compound,Ke as Constraint,ze as ConstraintCallback,De as ConstraintListener,le as Contact,Pe as ConvexResult,Fn as DebugDraw,_t as DebugDrawFlags,Sn as DistanceJoint,Ie as Edge,ae as FluidArbiter,gn as FluidProperties,ve as Geom,dn as GeomPoly,xn as GravMassMode,Cn as InertiaMode,fe as InteractionCallback,Tn as InteractionFilter,Le as InteractionGroup,Me as InteractionListener,O as InteractionType,bn as Interactor,Zn as LineJoint,D as Listener,Fe as ListenerType,Ne as MarchingSquares,vn as MassMode,we as Mat23,Ye as MatMN,Pn as Material,Vn as MotorJoint,lt as NapeList,Be as OptionType,On as PivotJoint,In as Polygon,me as PreCallback,ke as PreFlag,Ue as PreListener,kn as PulleyJoint,Je as Ray,xe as RayResult,an as Shape,wn as ShapeType,We as Space,en as UserConstraint,Ho as VERSION,Ae as ValidationResult,L as Vec2,C as Vec3,Rn as WeldJoint,yn as Winding};
2
2
  //# sourceMappingURL=index.js.map