/*! For license information please see 3.b5690e6d.chunk.js.LICENSE.txt */ (this.webpackJsonpui=this.webpackJsonpui||[]).push([[3],[function(t,e,n){"use strict";t.exports=n(443)},function(t,e,n){t.exports=n(447)()},function(t,e,n){var r=n(8),i=n(33).f,o=n(38),a=n(36),s=n(118),u=n(158),l=n(85);t.exports=function(t,e){var n,c,f,h,m,d=t.target,p=t.global,_=t.stat;if(n=p?r:_?r[d]||s(d,{}):(r[d]||{}).prototype)for(c in e){if(h=e[c],f=t.noTargetGet?(m=i(n,c))&&m.value:n[c],!l(p?c:d+(_?".":"#")+c,t.forced)&&void 0!==f){if(typeof h===typeof f)continue;u(h,f)}(t.sham||f&&f.sham)&&o(h,"sham",!0),a(n,c,h,t)}}},function(t,e,n){"use strict";n.d(e,"k",(function(){return a})),n.d(e,"g",(function(){return s})),n.d(e,"e",(function(){return u})),n.d(e,"h",(function(){return l})),n.d(e,"i",(function(){return c})),n.d(e,"j",(function(){return f})),n.d(e,"l",(function(){return m})),n.d(e,"c",(function(){return d})),n.d(e,"a",(function(){return p})),n.d(e,"b",(function(){return _})),n.d(e,"d",(function(){return y})),n.d(e,"f",(function(){return v}));var r,i=n(1),o=n.n(i);function a(t){document.body.style.paddingRight=t>0?t+"px":null}function s(){var t=window.getComputedStyle(document.body,null);return parseInt(t&&t.getPropertyValue("padding-right")||0,10)}function u(){var t=function(){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}(),e=document.querySelectorAll(".fixed-top, .fixed-bottom, .is-fixed, .sticky-top")[0],n=e?parseInt(e.style.paddingRight||0,10):0;document.body.clientWidth0;)o[n=r[i-=1]]=t[n];return o}var h="object"===typeof window&&window.Element||function(){};o.a.oneOfType([o.a.string,o.a.func,function(t,e,n){if(!(t[e]instanceof h))return new Error("Invalid prop `"+e+"` supplied to `"+n+"`. Expected prop to be an instance of Element. Validation failed.")},o.a.shape({current:o.a.any})]);var m=o.a.oneOfType([o.a.func,o.a.string,o.a.shape({$$typeof:o.a.symbol,render:o.a.func}),o.a.arrayOf(o.a.oneOfType([o.a.func,o.a.string,o.a.shape({$$typeof:o.a.symbol,render:o.a.func})]))]),d={Fade:150,Collapse:350,Modal:300,Carousel:600},p=["in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","onEnter","onEntering","onEntered","onExit","onExiting","onExited"],_={ENTERING:"entering",ENTERED:"entered",EXITING:"exiting",EXITED:"exited"},y=!("undefined"===typeof window||!window.document||!window.document.createElement);var v=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","object","embed","[tabindex]:not(.modal)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])']},function(t,e,n){"use strict";function r(){return(r=Object.assign||function(t){for(var e=1;e=0||(i[n]=t[n]);return i}n.d(e,"a",(function(){return r}))},function(t,e,n){(function(e){var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||Function("return this")()}).call(this,n(57))},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";function r(t,e){for(var n=0;n. You may also pass a {context : MyContext} option to connect");var O=M;return function(e){var n=e.displayName||e.name||"Component",o=a(n),s=Object(d.a)({},I,{getDisplayName:a,methodName:l,renderCountProp:h,shouldHandleStateChanges:_,storeKey:B,displayName:o,wrappedComponentName:n,WrappedComponent:e}),u=I.pure;var c=u?r.useMemo:function(t){return t()};function m(n){var a=Object(r.useMemo)((function(){var t=n.forwardedRef,e=Object(p.a)(n,["forwardedRef"]);return[n.context,t,e]}),[n]),u=a[0],l=a[1],h=a[2],m=Object(r.useMemo)((function(){return u&&u.Consumer&&Object(b.isContextConsumer)(i.a.createElement(u.Consumer,null))?u:O}),[u,O]),y=Object(r.useContext)(m),v=Boolean(n.store),B=Boolean(y)&&Boolean(y.store);g()(v||B,'Could not find "store" in the context of "'+o+'". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to '+o+" in connect options.");var k=n.store||y.store,P=Object(r.useMemo)((function(){return function(e){return t(e.dispatch,s)}(k)}),[k]),V=Object(r.useMemo)((function(){if(!_)return w;var t=new f(k,v?null:y.subscription),e=t.notifyNestedSubs.bind(t);return[t,e]}),[k,v,y]),E=V[0],T=V[1],M=Object(r.useMemo)((function(){return v?y:Object(d.a)({},y,{subscription:E})}),[v,y,E]),I=Object(r.useReducer)(S,x,C),R=I[0][0],D=I[1];if(R&&R.error)throw R.error;var j=Object(r.useRef)(),L=Object(r.useRef)(h),F=Object(r.useRef)(),G=Object(r.useRef)(!1),N=c((function(){return F.current&&h===L.current?F.current:P(k.getState(),h)}),[k,R,h]);A((function(){L.current=h,j.current=N,G.current=!1,F.current&&(F.current=null,T())})),A((function(){if(_){var t=!1,e=null,n=function(){if(!t){var n,r,i=k.getState();try{n=P(i,L.current)}catch(o){r=o,e=o}r||(e=null),n===j.current?G.current||T():(j.current=n,F.current=n,G.current=!0,D({type:"STORE_UPDATED",payload:{latestStoreState:i,error:r}}))}};E.onStateChange=n,E.trySubscribe(),n();return function(){if(t=!0,E.tryUnsubscribe(),E.onStateChange=null,e)throw e}}}),[k,E,P]);var z=Object(r.useMemo)((function(){return i.a.createElement(e,Object(d.a)({},N,{ref:l}))}),[l,e,N]);return Object(r.useMemo)((function(){return _?i.a.createElement(m.Provider,{value:M},z):z}),[m,z,M])}var v=u?i.a.memo(m):m;if(v.WrappedComponent=e,v.displayName=o,E){var k=i.a.forwardRef((function(t,e){return i.a.createElement(v,Object(d.a)({},t,{forwardedRef:e}))}));return k.displayName=o,k.WrappedComponent=e,y()(k,e)}return y()(v,e)}}var k=Object.prototype.hasOwnProperty;function P(t,e){return t===e?0!==t||0!==e||1/t===1/e:t!==t&&e!==e}function V(t,e){if(P(t,e))return!0;if("object"!==typeof t||null===t||"object"!==typeof e||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=0;i=0;r--){var i=e[r](t);if(i)return i}return function(e,r){throw new Error("Invalid value of type "+typeof t+" for "+n+" argument when connecting component "+r.wrappedComponentName+".")}}function z(t,e){return t===e}var q=function(t){var e=void 0===t?{}:t,n=e.connectHOC,r=void 0===n?B:n,i=e.mapStateToPropsFactories,o=void 0===i?R:i,a=e.mapDispatchToPropsFactories,s=void 0===a?O:a,u=e.mergePropsFactories,l=void 0===u?j:u,c=e.selectorFactory,f=void 0===c?G:c;return function(t,e,n,i){void 0===i&&(i={});var a=i,u=a.pure,c=void 0===u||u,h=a.areStatesEqual,m=void 0===h?z:h,_=a.areOwnPropsEqual,y=void 0===_?V:_,v=a.areStatePropsEqual,g=void 0===v?V:v,b=a.areMergedPropsEqual,x=void 0===b?V:b,w=Object(p.a)(a,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),S=N(t,o,"mapStateToProps"),C=N(e,s,"mapDispatchToProps"),A=N(n,l,"mergeProps");return r(f,Object(d.a)({methodName:"connect",getDisplayName:function(t){return"Connect("+t+")"},shouldHandleStateChanges:Boolean(t),initMapStateToProps:S,initMapDispatchToProps:C,initMergeProps:A,pure:c,areStatesEqual:m,areOwnPropsEqual:y,areStatePropsEqual:g,areMergedPropsEqual:x},w))}}();function U(){var t=Object(r.useContext)(s);return g()(t,"could not find react-redux context value; please ensure the component is wrapped in a "),t}function W(t){void 0===t&&(t=s);var e=t===s?U:function(){return Object(r.useContext)(t)};return function(){return e().store}}var J=W();!function(t){void 0===t&&(t=s);var e=t===s?J:W(t)}();var H="undefined"!==typeof window?r.useLayoutEffect:r.useEffect,X=function(t,e){return t===e};!function(t){void 0===t&&(t=s);var e=t===s?U:function(){return Object(r.useContext)(t)}}();var $,Y=n(60);$=Y.unstable_batchedUpdates,u=$},function(t,e,n){"use strict";n.d(e,"a",(function(){return _})),n.d(e,"b",(function(){return f})),n.d(e,"c",(function(){return l})),n.d(e,"d",(function(){return p})),n.d(e,"e",(function(){return s}));var r=n(147),i=function(){return Math.random().toString(36).substring(7).split("").join(".")},o={INIT:"@@redux/INIT"+i(),REPLACE:"@@redux/REPLACE"+i(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+i()}};function a(t){if("object"!==typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function s(t,e,n){var i;if("function"===typeof e&&"function"===typeof n||"function"===typeof n&&"function"===typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"===typeof e&&"undefined"===typeof n&&(n=e,e=void 0),"undefined"!==typeof n){if("function"!==typeof n)throw new Error("Expected the enhancer to be a function.");return n(s)(t,e)}if("function"!==typeof t)throw new Error("Expected the reducer to be a function.");var u=t,l=e,c=[],f=c,h=!1;function m(){f===c&&(f=c.slice())}function d(){if(h)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return l}function p(t){if("function"!==typeof t)throw new Error("Expected the listener to be a function.");if(h)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var e=!0;return m(),f.push(t),function(){if(e){if(h)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");e=!1,m();var n=f.indexOf(t);f.splice(n,1)}}}function _(t){if(!a(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if("undefined"===typeof t.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(h)throw new Error("Reducers may not dispatch actions.");try{h=!0,l=u(l,t)}finally{h=!1}for(var e=c=f,n=0;n0?i(r(t),9007199254740991):0}},function(t,e,n){"use strict";var r,i=n(194),o=n(18),a=n(8),s=n(13),u=n(27),l=n(91),c=n(38),f=n(36),h=n(25).f,m=n(53),d=n(73),p=n(17),_=n(82),y=a.Int8Array,v=y&&y.prototype,g=a.Uint8ClampedArray,b=g&&g.prototype,x=y&&m(y),w=v&&m(v),S=Object.prototype,C=S.isPrototypeOf,A=p("toStringTag"),B=_("TYPED_ARRAY_TAG"),k=i&&!!d&&"Opera"!==l(a.opera),P=!1,V={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},E=function(t){return s(t)&&u(V,l(t))};for(r in V)a[r]||(k=!1);if((!k||"function"!=typeof x||x===Function.prototype)&&(x=function(){throw TypeError("Incorrect invocation")},k))for(r in V)a[r]&&d(a[r],x);if((!k||!w||w===S)&&(w=x.prototype,k))for(r in V)a[r]&&d(a[r].prototype,w);if(k&&m(b)!==w&&d(b,w),o&&!u(w,A))for(r in P=!0,h(w,A,{get:function(){return s(this)?this[B]:void 0}}),V)a[r]&&c(a[r],B,r);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:k,TYPED_ARRAY_TAG:P&&B,aTypedArray:function(t){if(E(t))return t;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(t){if(d){if(C.call(x,t))return t}else for(var e in V)if(u(V,r)){var n=a[e];if(n&&(t===n||C.call(n,t)))return t}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(t,e,n){if(o){if(n)for(var r in V){var i=a[r];i&&u(i.prototype,t)&&delete i.prototype[t]}w[t]&&!n||f(w,t,n?e:k&&v[t]||e)}},exportTypedArrayStaticMethod:function(t,e,n){var r,i;if(o){if(d){if(n)for(r in V)(i=a[r])&&u(i,t)&&delete i[t];if(x[t]&&!n)return;try{return f(x,t,n?e:k&&y[t]||e)}catch(s){}}for(r in V)!(i=a[r])||i[t]&&!n||f(i,t,e)}},isView:function(t){var e=l(t);return"DataView"===e||u(V,e)},isTypedArray:E,TypedArray:x,TypedArrayPrototype:w}},function(t,e,n){"use strict";n.d(e,"a",(function(){return A})),n.d(e,"b",(function(){return x})),n.d(e,"c",(function(){return T})),n.d(e,"d",(function(){return b})),n.d(e,"e",(function(){return C})),n.d(e,"f",(function(){return I}));var r=n(26),i=n(0),o=n.n(i),a=n(1),s=n.n(a),u=n(40),l=n(148),c=n.n(l),f=n(239),h=n.n(f);function m(t){var e=[];return{on:function(t){e.push(t)},off:function(t){e=e.filter((function(e){return e!==t}))},get:function(){return t},set:function(n,r){t=n,e.forEach((function(e){return e(t,r)}))}}}var d=o.a.createContext||function(t,e){var n,r,o="__create-react-context-"+h()()+"__",a=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).emitter=m(e.props.value),e}c()(n,t);var r=n.prototype;return r.getChildContext=function(){var t;return(t={})[o]=this.emitter,t},r.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var n,r=this.props.value,i=t.value;((o=r)===(a=i)?0!==o||1/o===1/a:o!==o&&a!==a)?n=0:(n="function"===typeof e?e(r,i):1073741823,0!==(n|=0)&&this.emitter.set(t.value,n))}var o,a},r.render=function(){return this.props.children},n}(i.Component);a.childContextTypes=((n={})[o]=s.a.object.isRequired,n);var u=function(e){function n(){var t;return(t=e.apply(this,arguments)||this).state={value:t.getValue()},t.onUpdate=function(e,n){0!==((0|t.observedBits)&n)&&t.setState({value:t.getValue()})},t}c()(n,e);var r=n.prototype;return r.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=void 0===e||null===e?1073741823:e},r.componentDidMount=function(){this.context[o]&&this.context[o].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=void 0===t||null===t?1073741823:t},r.componentWillUnmount=function(){this.context[o]&&this.context[o].off(this.onUpdate)},r.getValue=function(){return this.context[o]?this.context[o].get():t},r.render=function(){return(t=this.props.children,Array.isArray(t)?t[0]:t)(this.state.value);var t},n}(i.Component);return u.contextTypes=((r={})[o]=s.a.object,r),{Provider:a,Consumer:u}},p=n(46),_=n(4),y=n(149),v=n.n(y),g=(n(76),n(7)),b=(n(70),function(t){var e=d();return e.displayName=t,e}("Router")),x=function(t){function e(e){var n;return(n=t.call(this,e)||this).state={location:e.history.location},n._isMounted=!1,n._pendingLocation=null,e.staticContext||(n.unlisten=e.history.listen((function(t){n._isMounted?n.setState({location:t}):n._pendingLocation=t}))),n}Object(r.a)(e,t),e.computeRootMatch=function(t){return{path:"/",url:"/",params:{},isExact:"/"===t}};var n=e.prototype;return n.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&this.unlisten()},n.render=function(){return o.a.createElement(b.Provider,{children:this.props.children||null,value:{history:this.props.history,location:this.state.location,match:e.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}})},e}(o.a.Component);o.a.Component;o.a.Component;var w={},S=0;function C(t,e){void 0===e&&(e={}),("string"===typeof e||Array.isArray(e))&&(e={path:e});var n=e,r=n.path,i=n.exact,o=void 0!==i&&i,a=n.strict,s=void 0!==a&&a,u=n.sensitive,l=void 0!==u&&u;return[].concat(r).reduce((function(e,n){if(!n&&""!==n)return null;if(e)return e;var r=function(t,e){var n=""+e.end+e.strict+e.sensitive,r=w[n]||(w[n]={});if(r[t])return r[t];var i=[],o={regexp:v()(t,i,e),keys:i};return S<1e4&&(r[t]=o,S++),o}(n,{end:o,strict:s,sensitive:l}),i=r.regexp,a=r.keys,u=i.exec(t);if(!u)return null;var c=u[0],f=u.slice(1),h=t===c;return o&&!h?null:{path:n,url:"/"===n&&""===c?"/":c,isExact:h,params:a.reduce((function(t,e,n){return t[e.name]=f[n],t}),{})}}),null)}var A=function(t){function e(){return t.apply(this,arguments)||this}return Object(r.a)(e,t),e.prototype.render=function(){var t=this;return o.a.createElement(b.Consumer,null,(function(e){e||Object(p.a)(!1);var n=t.props.location||e.location,r=t.props.computedMatch?t.props.computedMatch:t.props.path?C(n.pathname,t.props):e.match,i=Object(_.a)({},e,{location:n,match:r}),a=t.props,s=a.children,u=a.component,l=a.render;return Array.isArray(s)&&0===s.length&&(s=null),o.a.createElement(b.Provider,{value:i},i.match?s?"function"===typeof s?s(i):s:u?o.a.createElement(u,i):l?l(i):null:"function"===typeof s?s(i):null)}))},e}(o.a.Component);function B(t){return"/"===t.charAt(0)?t:"/"+t}function k(t,e){if(!t)return e;var n=B(t);return 0!==e.pathname.indexOf(n)?e:Object(_.a)({},e,{pathname:e.pathname.substr(n.length)})}function P(t){return"string"===typeof t?t:Object(u.e)(t)}function V(t){return function(){Object(p.a)(!1)}}function E(){}o.a.Component;var T=function(t){function e(){return t.apply(this,arguments)||this}return Object(r.a)(e,t),e.prototype.render=function(){var t=this;return o.a.createElement(b.Consumer,null,(function(e){e||Object(p.a)(!1);var n,r,i=t.props.location||e.location;return o.a.Children.forEach(t.props.children,(function(t){if(null==r&&o.a.isValidElement(t)){n=t;var a=t.props.path||t.props.from;r=a?C(i.pathname,Object(_.a)({},t.props,{path:a})):e.match}})),r?o.a.cloneElement(n,{location:i,computedMatch:r}):null}))},e}(o.a.Component);var M=o.a.useContext;function I(){return M(b).history}},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function o(t){for(var e=1;e=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function m(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0||!Array.isArray(e)&&e?l({},t,e):{}}function g(t){var e=t.forwardedRef,n=h(t,["forwardedRef"]),i=n.icon,o=n.mask,a=n.symbol,s=n.className,u=n.title,c=y(i),d=v("classes",[].concat(m(function(t){var e,n=t.spin,r=t.pulse,i=t.fixedWidth,o=t.inverse,a=t.border,s=t.listItem,u=t.flip,c=t.size,f=t.rotation,h=t.pull,m=(l(e={"fa-spin":n,"fa-pulse":r,"fa-fw":i,"fa-inverse":o,"fa-border":a,"fa-li":s,"fa-flip-horizontal":"horizontal"===u||"both"===u,"fa-flip-vertical":"vertical"===u||"both"===u},"fa-".concat(c),"undefined"!==typeof c&&null!==c),l(e,"fa-rotate-".concat(f),"undefined"!==typeof f&&null!==f&&0!==f),l(e,"fa-pull-".concat(h),"undefined"!==typeof h&&null!==h),l(e,"fa-swap-opacity",t.swapOpacity),e);return Object.keys(m).map((function(t){return m[t]?t:null})).filter((function(t){return t}))}(n)),m(s.split(" ")))),p=v("transform","string"===typeof n.transform?r.b.transform(n.transform):n.transform),x=v("mask",y(o)),w=Object(r.a)(c,f({},d,{},p,{},x,{symbol:a,title:u}));if(!w)return function(){var t;!_&&console&&"function"===typeof console.error&&(t=console).error.apply(t,arguments)}("Could not find icon",c),null;var S=w.abstract,C={ref:e};return Object.keys(n).forEach((function(t){g.defaultProps.hasOwnProperty(t)||(C[t]=n[t])})),b(S[0],C)}g.displayName="FontAwesomeIcon",g.propTypes={border:o.a.bool,className:o.a.string,mask:o.a.oneOfType([o.a.object,o.a.array,o.a.string]),fixedWidth:o.a.bool,inverse:o.a.bool,flip:o.a.oneOf(["horizontal","vertical","both"]),icon:o.a.oneOfType([o.a.object,o.a.array,o.a.string]),listItem:o.a.bool,pull:o.a.oneOf(["right","left"]),pulse:o.a.bool,rotation:o.a.oneOf([0,90,180,270]),size:o.a.oneOf(["lg","xs","sm","1x","2x","3x","4x","5x","6x","7x","8x","9x","10x"]),spin:o.a.bool,symbol:o.a.oneOfType([o.a.bool,o.a.string]),title:o.a.string,transform:o.a.oneOfType([o.a.string,o.a.object]),swapOpacity:o.a.bool},g.defaultProps={border:!1,className:"",mask:null,fixedWidth:!1,inverse:!1,flip:null,icon:null,listItem:!1,pull:null,pulse:!1,rotation:null,size:null,spin:!1,symbol:!1,title:"",transform:null,swapOpacity:!1};var b=function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"===typeof n)return n;var i=(n.children||[]).map((function(n){return t(e,n)})),o=Object.keys(n.attributes||{}).reduce((function(t,e){var r=n.attributes[e];switch(e){case"class":t.attrs.className=r,delete n.attributes.class;break;case"style":t.attrs.style=p(r);break;default:0===e.indexOf("aria-")||0===e.indexOf("data-")?t.attrs[e.toLowerCase()]=r:t.attrs[d(e)]=r}return t}),{attrs:{}}),a=r.style,s=void 0===a?{}:a,u=h(r,["style"]);return o.attrs.style=f({},o.attrs.style,{},s),e.apply(void 0,[n.tag,f({},o.attrs,{},u)].concat(m(i)))}.bind(null,s.a.createElement)},function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return o})),n.d(e,"d",(function(){return a})),n.d(e,"e",(function(){return s})),n.d(e,"f",(function(){return u})),n.d(e,"g",(function(){return l})),n.d(e,"h",(function(){return c})),n.d(e,"i",(function(){return f})),n.d(e,"j",(function(){return h})),n.d(e,"k",(function(){return m})),n.d(e,"l",(function(){return d})),n.d(e,"m",(function(){return p})),n.d(e,"n",(function(){return _})),n.d(e,"o",(function(){return y})),n.d(e,"p",(function(){return v})),n.d(e,"q",(function(){return g}));var r={prefix:"fas",iconName:"arrow-circle-up",icon:[512,512,[],"f0aa","M8 256C8 119 119 8 256 8s248 111 248 248-111 248-248 248S8 393 8 256zm143.6 28.9l72.4-75.5V392c0 13.3 10.7 24 24 24h16c13.3 0 24-10.7 24-24V209.4l72.4 75.5c9.3 9.7 24.8 9.9 34.3.4l10.9-11c9.4-9.4 9.4-24.6 0-33.9L273 107.7c-9.4-9.4-24.6-9.4-33.9 0L106.3 240.4c-9.4 9.4-9.4 24.6 0 33.9l10.9 11c9.6 9.5 25.1 9.3 34.4-.4z"]},i={prefix:"fas",iconName:"child",icon:[384,512,[],"f1ae","M120 72c0-39.765 32.235-72 72-72s72 32.235 72 72c0 39.764-32.235 72-72 72s-72-32.236-72-72zm254.627 1.373c-12.496-12.497-32.758-12.497-45.254 0L242.745 160H141.254L54.627 73.373c-12.496-12.497-32.758-12.497-45.254 0-12.497 12.497-12.497 32.758 0 45.255L104 213.254V480c0 17.673 14.327 32 32 32h16c17.673 0 32-14.327 32-32V368h16v112c0 17.673 14.327 32 32 32h16c17.673 0 32-14.327 32-32V213.254l94.627-94.627c12.497-12.497 12.497-32.757 0-45.254z"]},o={prefix:"fas",iconName:"comment-dots",icon:[512,512,[],"f4ad","M256 32C114.6 32 0 125.1 0 240c0 49.6 21.4 95 57 130.7C44.5 421.1 2.7 466 2.2 466.5c-2.2 2.3-2.8 5.7-1.5 8.7S4.8 480 8 480c66.3 0 116-31.8 140.6-51.4 32.7 12.3 69 19.4 107.4 19.4 141.4 0 256-93.1 256-208S397.4 32 256 32zM128 272c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 0c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 0c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"]},a={prefix:"fas",iconName:"envelope",icon:[512,512,[],"f0e0","M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"]},s={prefix:"fas",iconName:"file-pdf",icon:[384,512,[],"f1c1","M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"]},u={prefix:"fas",iconName:"football-ball",icon:[496,512,[],"f44e","M481.5 60.3c-4.8-18.2-19.1-32.5-37.3-37.4C420.3 16.5 383 8.9 339.4 8L496 164.8c-.8-43.5-8.2-80.6-14.5-104.5zm-467 391.4c4.8 18.2 19.1 32.5 37.3 37.4 23.9 6.4 61.2 14 104.8 14.9L0 347.2c.8 43.5 8.2 80.6 14.5 104.5zM4.2 283.4L220.4 500c132.5-19.4 248.8-118.7 271.5-271.4L275.6 12C143.1 31.4 26.8 130.7 4.2 283.4zm317.3-123.6c3.1-3.1 8.2-3.1 11.3 0l11.3 11.3c3.1 3.1 3.1 8.2 0 11.3l-28.3 28.3 28.3 28.3c3.1 3.1 3.1 8.2 0 11.3l-11.3 11.3c-3.1 3.1-8.2 3.1-11.3 0l-28.3-28.3-22.6 22.7 28.3 28.3c3.1 3.1 3.1 8.2 0 11.3l-11.3 11.3c-3.1 3.1-8.2 3.1-11.3 0L248 278.6l-22.6 22.6 28.3 28.3c3.1 3.1 3.1 8.2 0 11.3l-11.3 11.3c-3.1 3.1-8.2 3.1-11.3 0l-28.3-28.3-28.3 28.3c-3.1 3.1-8.2 3.1-11.3 0l-11.3-11.3c-3.1-3.1-3.1-8.2 0-11.3l28.3-28.3-28.3-28.2c-3.1-3.1-3.1-8.2 0-11.3l11.3-11.3c3.1-3.1 8.2-3.1 11.3 0l28.3 28.3 22.6-22.6-28.3-28.3c-3.1-3.1-3.1-8.2 0-11.3l11.3-11.3c3.1-3.1 8.2-3.1 11.3 0l28.3 28.3 22.6-22.6-28.3-28.3c-3.1-3.1-3.1-8.2 0-11.3l11.3-11.3c3.1-3.1 8.2-3.1 11.3 0l28.3 28.3 28.3-28.5z"]},l={prefix:"fas",iconName:"graduation-cap",icon:[640,512,[],"f19d","M622.34 153.2L343.4 67.5c-15.2-4.67-31.6-4.67-46.79 0L17.66 153.2c-23.54 7.23-23.54 38.36 0 45.59l48.63 14.94c-10.67 13.19-17.23 29.28-17.88 46.9C38.78 266.15 32 276.11 32 288c0 10.78 5.68 19.85 13.86 25.65L20.33 428.53C18.11 438.52 25.71 448 35.94 448h56.11c10.24 0 17.84-9.48 15.62-19.47L82.14 313.65C90.32 307.85 96 298.78 96 288c0-11.57-6.47-21.25-15.66-26.87.76-15.02 8.44-28.3 20.69-36.72L296.6 284.5c9.06 2.78 26.44 6.25 46.79 0l278.95-85.7c23.55-7.24 23.55-38.36 0-45.6zM352.79 315.09c-28.53 8.76-52.84 3.92-65.59 0l-145.02-44.55L128 384c0 35.35 85.96 64 192 64s192-28.65 192-64l-14.18-113.47-145.03 44.56z"]},c={prefix:"fas",iconName:"home",icon:[576,512,[],"f015","M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"]},f={prefix:"fas",iconName:"laptop-code",icon:[640,512,[],"f5fc","M255.03 261.65c6.25 6.25 16.38 6.25 22.63 0l11.31-11.31c6.25-6.25 6.25-16.38 0-22.63L253.25 192l35.71-35.72c6.25-6.25 6.25-16.38 0-22.63l-11.31-11.31c-6.25-6.25-16.38-6.25-22.63 0l-58.34 58.34c-6.25 6.25-6.25 16.38 0 22.63l58.35 58.34zm96.01-11.3l11.31 11.31c6.25 6.25 16.38 6.25 22.63 0l58.34-58.34c6.25-6.25 6.25-16.38 0-22.63l-58.34-58.34c-6.25-6.25-16.38-6.25-22.63 0l-11.31 11.31c-6.25 6.25-6.25 16.38 0 22.63L386.75 192l-35.71 35.72c-6.25 6.25-6.25 16.38 0 22.63zM624 416H381.54c-.74 19.81-14.71 32-32.74 32H288c-18.69 0-33.02-17.47-32.77-32H16c-8.8 0-16 7.2-16 16v16c0 35.2 28.8 64 64 64h512c35.2 0 64-28.8 64-64v-16c0-8.8-7.2-16-16-16zM576 48c0-26.4-21.6-48-48-48H112C85.6 0 64 21.6 64 48v336h512V48zm-64 272H128V64h384v256z"]},h={prefix:"fas",iconName:"lightbulb",icon:[352,512,[],"f0eb","M96.06 454.35c.01 6.29 1.87 12.45 5.36 17.69l17.09 25.69a31.99 31.99 0 0 0 26.64 14.28h61.71a31.99 31.99 0 0 0 26.64-14.28l17.09-25.69a31.989 31.989 0 0 0 5.36-17.69l.04-38.35H96.01l.05 38.35zM0 176c0 44.37 16.45 84.85 43.56 115.78 16.52 18.85 42.36 58.23 52.21 91.45.04.26.07.52.11.78h160.24c.04-.26.07-.51.11-.78 9.85-33.22 35.69-72.6 52.21-91.45C335.55 260.85 352 220.37 352 176 352 78.61 272.91-.3 175.45 0 73.44.31 0 82.97 0 176zm176-80c-44.11 0-80 35.89-80 80 0 8.84-7.16 16-16 16s-16-7.16-16-16c0-61.76 50.24-112 112-112 8.84 0 16 7.16 16 16s-7.16 16-16 16z"]},m={prefix:"fas",iconName:"map-marked-alt",icon:[576,512,[],"f5a0","M288 0c-69.59 0-126 56.41-126 126 0 56.26 82.35 158.8 113.9 196.02 6.39 7.54 17.82 7.54 24.2 0C331.65 284.8 414 182.26 414 126 414 56.41 357.59 0 288 0zm0 168c-23.2 0-42-18.8-42-42s18.8-42 42-42 42 18.8 42 42-18.8 42-42 42zM20.12 215.95A32.006 32.006 0 0 0 0 245.66v250.32c0 11.32 11.43 19.06 21.94 14.86L160 448V214.92c-8.84-15.98-16.07-31.54-21.25-46.42L20.12 215.95zM288 359.67c-14.07 0-27.38-6.18-36.51-16.96-19.66-23.2-40.57-49.62-59.49-76.72v182l192 64V266c-18.92 27.09-39.82 53.52-59.49 76.72-9.13 10.77-22.44 16.95-36.51 16.95zm266.06-198.51L416 224v288l139.88-55.95A31.996 31.996 0 0 0 576 426.34V176.02c0-11.32-11.43-19.06-21.94-14.86z"]},d={prefix:"fas",iconName:"paw",icon:[512,512,[],"f1b0","M256 224c-79.41 0-192 122.76-192 200.25 0 34.9 26.81 55.75 71.74 55.75 48.84 0 81.09-25.08 120.26-25.08 39.51 0 71.85 25.08 120.26 25.08 44.93 0 71.74-20.85 71.74-55.75C448 346.76 335.41 224 256 224zm-147.28-12.61c-10.4-34.65-42.44-57.09-71.56-50.13-29.12 6.96-44.29 40.69-33.89 75.34 10.4 34.65 42.44 57.09 71.56 50.13 29.12-6.96 44.29-40.69 33.89-75.34zm84.72-20.78c30.94-8.14 46.42-49.94 34.58-93.36s-46.52-72.01-77.46-63.87-46.42 49.94-34.58 93.36c11.84 43.42 46.53 72.02 77.46 63.87zm281.39-29.34c-29.12-6.96-61.15 15.48-71.56 50.13-10.4 34.65 4.77 68.38 33.89 75.34 29.12 6.96 61.15-15.48 71.56-50.13 10.4-34.65-4.77-68.38-33.89-75.34zm-156.27 29.34c30.94 8.14 65.62-20.45 77.46-63.87 11.84-43.42-3.64-85.21-34.58-93.36s-65.62 20.45-77.46 63.87c-11.84 43.42 3.64 85.22 34.58 93.36z"]},p={prefix:"fas",iconName:"question",icon:[384,512,[],"f128","M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z"]},_={prefix:"fas",iconName:"rocket",icon:[512,512,[],"f135","M505.12019,19.09375c-1.18945-5.53125-6.65819-11-12.207-12.1875C460.716,0,435.507,0,410.40747,0,307.17523,0,245.26909,55.20312,199.05238,128H94.83772c-16.34763.01562-35.55658,11.875-42.88664,26.48438L2.51562,253.29688A28.4,28.4,0,0,0,0,264a24.00867,24.00867,0,0,0,24.00582,24H127.81618l-22.47457,22.46875c-11.36521,11.36133-12.99607,32.25781,0,45.25L156.24582,406.625c11.15623,11.1875,32.15619,13.15625,45.27726,0l22.47457-22.46875V488a24.00867,24.00867,0,0,0,24.00581,24,28.55934,28.55934,0,0,0,10.707-2.51562l98.72834-49.39063c14.62888-7.29687,26.50776-26.5,26.50776-42.85937V312.79688c72.59753-46.3125,128.03493-108.40626,128.03493-211.09376C512.07526,76.5,512.07526,51.29688,505.12019,19.09375ZM384.04033,168A40,40,0,1,1,424.05,128,40.02322,40.02322,0,0,1,384.04033,168Z"]},y={prefix:"fas",iconName:"skiing",icon:[512,512,[],"f7c9","M432 96c26.5 0 48-21.5 48-48S458.5 0 432 0s-48 21.5-48 48 21.5 48 48 48zm73 356.1c-9.4-9.4-24.6-9.4-33.9 0-12.1 12.1-30.5 15.4-45.1 8.7l-135.8-70.2 49.2-73.8c12.7-19 10.2-44.5-6-60.6L293 215.7l-107-53.1c-2.9 19.9 3.4 40 17.7 54.4l75.1 75.2-45.9 68.8L35 258.7c-11.7-6-26.2-1.5-32.3 10.3-6.1 11.8-1.5 26.3 10.3 32.3l391.9 202.5c11.9 5.5 24.5 8.1 37.1 8.1 23.2 0 46-9 63-26 9.3-9.3 9.3-24.5 0-33.8zM120 91.6l-11.5 22.5c14.4 7.3 31.2 4.9 42.8-4.8l47.2 23.4c-.1.1-.1.2-.2.3l114.5 56.8 32.4-13 6.4 19.1c4 12.1 12.6 22 24 27.7l58.1 29c15.9 7.9 35 1.5 42.9-14.3 7.9-15.8 1.5-35-14.3-42.9l-52.1-26.1-17.1-51.2c-8.1-24.2-40.9-56.6-84.5-39.2l-81.2 32.5-62.5-31c.3-14.5-7.2-28.6-20.9-35.6l-11.1 21.7h-.2l-34.4-7c-1.8-.4-3.7.2-5 1.7-1.9 2.2-1.7 5.5.5 7.4l26.2 23z"]},v={prefix:"fas",iconName:"sun",icon:[512,512,[],"f185","M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"]},g={prefix:"fas",iconName:"user-plus",icon:[640,512,[],"f234","M624 208h-64v-64c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v64h-64c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h64v64c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-64h64c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm-400 48c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"]}},function(t,e,n){"use strict";n.d(e,"a",(function(){return _}));var r=n(21),i=n(26),o=n(0),a=n.n(o),s=n(40),u=(n(1),n(4)),l=n(7),c=n(46);a.a.Component;a.a.Component;var f=function(t,e){return"function"===typeof t?t(e):t},h=function(t,e){return"string"===typeof t?Object(s.c)(t,null,null,e):t},m=function(t){return t},d=a.a.forwardRef;"undefined"===typeof d&&(d=m);var p=d((function(t,e){var n=t.innerRef,r=t.navigate,i=t.onClick,o=Object(l.a)(t,["innerRef","navigate","onClick"]),s=o.target,c=Object(u.a)({},o,{onClick:function(t){try{i&&i(t)}catch(e){throw t.preventDefault(),e}t.defaultPrevented||0!==t.button||s&&"_self"!==s||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||(t.preventDefault(),r())}});return c.ref=m!==d&&e||n,a.a.createElement("a",c)}));var _=d((function(t,e){var n=t.component,i=void 0===n?p:n,o=t.replace,s=t.to,_=t.innerRef,y=Object(l.a)(t,["component","replace","to","innerRef"]);return a.a.createElement(r.d.Consumer,null,(function(t){t||Object(c.a)(!1);var n=t.history,r=h(f(s,t.location),t.location),l=r?n.createHref(r):"",p=Object(u.a)({},y,{href:l,navigate:function(){var e=f(s,t.location);(o?n.replace:n.push)(e)}});return m!==d?p.ref=e||_:p.innerRef=_,a.a.createElement(i,p)}))})),y=function(t){return t},v=a.a.forwardRef;"undefined"===typeof v&&(v=y);v((function(t,e){var n=t["aria-current"],i=void 0===n?"page":n,o=t.activeClassName,s=void 0===o?"active":o,m=t.activeStyle,d=t.className,p=t.exact,g=t.isActive,b=t.location,x=t.strict,w=t.style,S=t.to,C=t.innerRef,A=Object(l.a)(t,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","strict","style","to","innerRef"]);return a.a.createElement(r.d.Consumer,null,(function(t){t||Object(c.a)(!1);var n=b||t.location,o=h(f(S,n),n),l=o.pathname,B=l&&l.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),k=B?Object(r.e)(n.pathname,{path:B,exact:p,strict:x}):null,P=!!(g?g(k,n):k),V=P?function(){for(var t=arguments.length,e=new Array(t),n=0;nS;S++)if((h||S in b)&&(v=x(y=b[S],S,g),t))if(e)A[S]=v;else if(v)switch(t){case 3:return!0;case 5:return y;case 6:return S;case 2:u.call(A,y)}else if(c)return!1;return f?-1:l||c?c:A}};t.exports={forEach:l(0),map:l(1),filter:l(2),some:l(3),every:l(4),find:l(5),findIndex:l(6)}},function(t,e,n){var r=n(18),i=n(98),o=n(63),a=n(41),s=n(54),u=n(27),l=n(155),c=Object.getOwnPropertyDescriptor;e.f=r?c:function(t,e){if(t=a(t),e=s(e,!0),l)try{return c(t,e)}catch(n){}if(u(t,e))return o(!i.f.call(t,e),t[e])}},function(t,e,n){var r=n(159),i=n(27),o=n(165),a=n(25).f;t.exports=function(t){var e=r.Symbol||(r.Symbol={});i(e,t)||a(e,t,{value:o.f(t)})}},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){return o}));var r="@@router/LOCATION_CHANGE",i=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:r,payload:{location:t,action:e,isFirstRendering:n}}},o="@@router/CALL_HISTORY_METHOD",a=function(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r=0;h--){var m=a[h];"."===m?o(a,h):".."===m?(o(a,h),f++):f&&(o(a,h),f--)}if(!l)for(;f--;f)a.unshift("..");!l||""===a[0]||a[0]&&i(a[0])||a.unshift("");var d=a.join("/");return n&&"/"!==d.substr(-1)&&(d+="/"),d};function s(t){return t.valueOf?t.valueOf():Object.prototype.valueOf.call(t)}var u=function t(e,n){if(e===n)return!0;if(null==e||null==n)return!1;if(Array.isArray(e))return Array.isArray(n)&&e.length===n.length&&e.every((function(e,r){return t(e,n[r])}));if("object"===typeof e||"object"===typeof n){var r=s(e),i=s(n);return r!==e||i!==n?t(r,i):Object.keys(Object.assign({},e,n)).every((function(r){return t(e[r],n[r])}))}return!1},l=n(46);function c(t){return"/"===t.charAt(0)?t:"/"+t}function f(t){return"/"===t.charAt(0)?t.substr(1):t}function h(t,e){return function(t,e){return 0===t.toLowerCase().indexOf(e.toLowerCase())&&-1!=="/?#".indexOf(t.charAt(e.length))}(t,e)?t.substr(e.length):t}function m(t){return"/"===t.charAt(t.length-1)?t.slice(0,-1):t}function d(t){var e=t.pathname,n=t.search,r=t.hash,i=e||"/";return n&&"?"!==n&&(i+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(i+="#"===r.charAt(0)?r:"#"+r),i}function p(t,e,n,i){var o;"string"===typeof t?(o=function(t){var e=t||"/",n="",r="",i=e.indexOf("#");-1!==i&&(r=e.substr(i),e=e.substr(0,i));var o=e.indexOf("?");return-1!==o&&(n=e.substr(o),e=e.substr(0,o)),{pathname:e,search:"?"===n?"":n,hash:"#"===r?"":r}}(t)).state=e:(void 0===(o=Object(r.a)({},t)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==e&&void 0===o.state&&(o.state=e));try{o.pathname=decodeURI(o.pathname)}catch(s){throw s instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):s}return n&&(o.key=n),i?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=a(o.pathname,i.pathname)):o.pathname=i.pathname:o.pathname||(o.pathname="/"),o}function _(t,e){return t.pathname===e.pathname&&t.search===e.search&&t.hash===e.hash&&t.key===e.key&&u(t.state,e.state)}function y(){var t=null;var e=[];return{setPrompt:function(e){return t=e,function(){t===e&&(t=null)}},confirmTransitionTo:function(e,n,r,i){if(null!=t){var o="function"===typeof t?t(e,n):t;"string"===typeof o?"function"===typeof r?r(o,i):i(!0):i(!1!==o)}else i(!0)},appendListener:function(t){var n=!0;function r(){n&&t.apply(void 0,arguments)}return e.push(r),function(){n=!1,e=e.filter((function(t){return t!==r}))}},notifyListeners:function(){for(var t=arguments.length,n=new Array(t),r=0;re?n.splice(e,n.length-e,r):n.push(r),f({action:"PUSH",location:r,index:e,entries:n})}}))},replace:function(t,e){var r=p(t,e,h(),b.location);c.confirmTransitionTo(r,"REPLACE",n,(function(t){t&&(b.entries[b.index]=r,f({action:"REPLACE",location:r}))}))},go:g,goBack:function(){g(-1)},goForward:function(){g(1)},canGo:function(t){var e=b.index+t;return e>=0&&e"+a+""}},function(t,e,n){var r=n(6);t.exports=function(t){return r((function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3}))}},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t){for(var e=1;e0?r:n)(t)}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}},function(t,e,n){"use strict";var r=s(n(526)),i=s(n(531)),o=s(n(235)),a=s(n(232));function s(t){return t&&t.__esModule?t:{default:t}}t.exports={Transition:a.default,TransitionGroup:o.default,ReplaceTransition:i.default,CSSTransition:r.default}},,function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var r=n(159),i=n(8),o=function(t){return"function"==typeof t?t:void 0};t.exports=function(t,e){return arguments.length<2?o(r[t])||o(i[t]):r[t]&&r[t][e]||i[t]&&i[t][e]}},function(t,e,n){var r=n(27),i=n(28),o=n(99),a=n(131),s=o("IE_PROTO"),u=Object.prototype;t.exports=a?Object.getPrototypeOf:function(t){return t=i(t),r(t,s)?t[s]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,e,n){var r=n(13);t.exports=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,e){t.exports=!1},function(t,e,n){var r=n(25).f,i=n(27),o=n(17)("toStringTag");t.exports=function(t,e,n){t&&!i(t=n?t:t.prototype,o)&&r(t,o,{configurable:!0,value:e})}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(r){"object"===typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";var r=n(6);t.exports=function(t,e){var n=[][t];return!!n&&r((function(){n.call(null,e||function(){throw 1},1)}))}},function(t,e,n){"use strict";var r=n(2),i=n(8),o=n(18),a=n(143),s=n(20),u=n(133),l=n(68),c=n(63),f=n(38),h=n(19),m=n(195),d=n(212),p=n(54),_=n(27),y=n(91),v=n(13),g=n(65),b=n(73),x=n(71).f,w=n(213),S=n(32).forEach,C=n(78),A=n(25),B=n(33),k=n(42),P=n(105),V=k.get,E=k.set,T=A.f,M=B.f,I=Math.round,O=i.RangeError,R=u.ArrayBuffer,D=u.DataView,j=s.NATIVE_ARRAY_BUFFER_VIEWS,L=s.TYPED_ARRAY_TAG,F=s.TypedArray,G=s.TypedArrayPrototype,N=s.aTypedArrayConstructor,z=s.isTypedArray,q=function(t,e){for(var n=0,r=e.length,i=new(N(t))(r);r>n;)i[n]=e[n++];return i},U=function(t,e){T(t,e,{get:function(){return V(this)[e]}})},W=function(t){var e;return t instanceof R||"ArrayBuffer"==(e=y(t))||"SharedArrayBuffer"==e},J=function(t,e){return z(t)&&"symbol"!=typeof e&&e in t&&String(+e)==String(e)},H=function(t,e){return J(t,e=p(e,!0))?c(2,t[e]):M(t,e)},X=function(t,e,n){return!(J(t,e=p(e,!0))&&v(n)&&_(n,"value"))||_(n,"get")||_(n,"set")||n.configurable||_(n,"writable")&&!n.writable||_(n,"enumerable")&&!n.enumerable?T(t,e,n):(t[e]=n.value,t)};o?(j||(B.f=H,A.f=X,U(G,"buffer"),U(G,"byteOffset"),U(G,"byteLength"),U(G,"length")),r({target:"Object",stat:!0,forced:!j},{getOwnPropertyDescriptor:H,defineProperty:X}),t.exports=function(t,e,n){var o=t.match(/\d+$/)[0]/8,s=t+(n?"Clamped":"")+"Array",u="get"+t,c="set"+t,p=i[s],_=p,y=_&&_.prototype,A={},B=function(t,e){T(t,e,{get:function(){return function(t,e){var n=V(t);return n.view[u](e*o+n.byteOffset,!0)}(this,e)},set:function(t){return function(t,e,r){var i=V(t);n&&(r=(r=I(r))<0?0:r>255?255:255&r),i.view[c](e*o+i.byteOffset,r,!0)}(this,e,t)},enumerable:!0})};j?a&&(_=e((function(t,e,n,r){return l(t,_,s),P(v(e)?W(e)?void 0!==r?new p(e,d(n,o),r):void 0!==n?new p(e,d(n,o)):new p(e):z(e)?q(_,e):w.call(_,e):new p(m(e)),t,_)})),b&&b(_,F),S(x(p),(function(t){t in _||f(_,t,p[t])})),_.prototype=y):(_=e((function(t,e,n,r){l(t,_,s);var i,a,u,c=0,f=0;if(v(e)){if(!W(e))return z(e)?q(_,e):w.call(_,e);i=e,f=d(n,o);var p=e.byteLength;if(void 0===r){if(p%o)throw O("Wrong length");if((a=p-f)<0)throw O("Wrong length")}else if((a=h(r)*o)+f>p)throw O("Wrong length");u=a/o}else u=m(e),i=new R(a=u*o);for(E(t,{buffer:i,byteOffset:f,byteLength:a,length:u,view:new D(i)});c0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;u(this,t),this.major=0,this.minor=0,this.revision=0,this.major=e,this.minor=n,this.revision=r}return l(t,[{key:"toString",value:function(){return this.major+"."+this.minor+"."+this.revision}}]),t}(),m=new h(2,3,2);function d(t,e){for(var n=[],r=0;r1&&void 0!==arguments[1]?arguments[1]:0,n=[],r=0;rn?n:t}var b=isFinite;function x(t){return t*t}function w(t){return 1/Math.sqrt(t)}var S=Math.sqrt,C=Math.pow,A=Math.cos,B=Math.sin,k=Math.acos,P=Math.asin,V=Math.atan2,E=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;u(this,t),this.x=e,this.y=n}return l(t,[{key:"Clone",value:function(){return new t(this.x,this.y)}},{key:"SetZero",value:function(){return this.x=0,this.y=0,this}},{key:"Set",value:function(t,e){return this.x=t,this.y=e,this}},{key:"Copy",value:function(t){return this.x=t.x,this.y=t.y,this}},{key:"SelfAdd",value:function(t){return this.x+=t.x,this.y+=t.y,this}},{key:"SelfAddXY",value:function(t,e){return this.x+=t,this.y+=e,this}},{key:"SelfSub",value:function(t){return this.x-=t.x,this.y-=t.y,this}},{key:"SelfSubXY",value:function(t,e){return this.x-=t,this.y-=e,this}},{key:"SelfMul",value:function(t){return this.x*=t,this.y*=t,this}},{key:"SelfMulAdd",value:function(t,e){return this.x+=t*e.x,this.y+=t*e.y,this}},{key:"SelfMulSub",value:function(t,e){return this.x-=t*e.x,this.y-=t*e.y,this}},{key:"Dot",value:function(t){return this.x*t.x+this.y*t.y}},{key:"Cross",value:function(t){return this.x*t.y-this.y*t.x}},{key:"Length",value:function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}},{key:"LengthSquared",value:function(){var t=this.x,e=this.y;return t*t+e*e}},{key:"Normalize",value:function(){var t=this.Length();if(t>=1e-5){var e=1/t;this.x*=e,this.y*=e}return t}},{key:"SelfNormalize",value:function(){var t=this.Length();if(t>=1e-5){var e=1/t;this.x*=e,this.y*=e}return this}},{key:"SelfRotate",value:function(t){var e=Math.cos(t),n=Math.sin(t),r=this.x;return this.x=e*r-n*this.y,this.y=n*r+e*this.y,this}},{key:"SelfRotateCosSin",value:function(t,e){var n=this.x;return this.x=t*n-e*this.y,this.y=e*n+t*this.y,this}},{key:"IsValid",value:function(){return isFinite(this.x)&&isFinite(this.y)}},{key:"SelfCrossVS",value:function(t){var e=this.x;return this.x=t*this.y,this.y=-t*e,this}},{key:"SelfCrossSV",value:function(t){var e=this.x;return this.x=-t*this.y,this.y=t*e,this}},{key:"SelfMinV",value:function(t){return this.x=y(this.x,t.x),this.y=y(this.y,t.y),this}},{key:"SelfMaxV",value:function(t){return this.x=v(this.x,t.x),this.y=v(this.y,t.y),this}},{key:"SelfAbs",value:function(){return this.x=_(this.x),this.y=_(this.y),this}},{key:"SelfNeg",value:function(){return this.x=-this.x,this.y=-this.y,this}},{key:"SelfSkew",value:function(){var t=this.x;return this.x=-this.y,this.y=t,this}}],[{key:"MakeArray",value:function(e){return d(e,(function(e){return new t}))}},{key:"AbsV",value:function(t,e){return e.x=_(t.x),e.y=_(t.y),e}},{key:"MinV",value:function(t,e,n){return n.x=y(t.x,e.x),n.y=y(t.y,e.y),n}},{key:"MaxV",value:function(t,e,n){return n.x=v(t.x,e.x),n.y=v(t.y,e.y),n}},{key:"ClampV",value:function(t,e,n,r){return r.x=g(t.x,e.x,n.x),r.y=g(t.y,e.y,n.y),r}},{key:"RotateV",value:function(t,e,n){var r=t.x,i=t.y,o=Math.cos(e),a=Math.sin(e);return n.x=o*r-a*i,n.y=a*r+o*i,n}},{key:"DotVV",value:function(t,e){return t.x*e.x+t.y*e.y}},{key:"CrossVV",value:function(t,e){return t.x*e.y-t.y*e.x}},{key:"CrossVS",value:function(t,e,n){var r=t.x;return n.x=e*t.y,n.y=-e*r,n}},{key:"CrossVOne",value:function(t,e){var n=t.x;return e.x=t.y,e.y=-n,e}},{key:"CrossSV",value:function(t,e,n){var r=e.x;return n.x=-t*e.y,n.y=t*r,n}},{key:"CrossOneV",value:function(t,e){var n=t.x;return e.x=-t.y,e.y=n,e}},{key:"AddVV",value:function(t,e,n){return n.x=t.x+e.x,n.y=t.y+e.y,n}},{key:"SubVV",value:function(t,e,n){return n.x=t.x-e.x,n.y=t.y-e.y,n}},{key:"MulSV",value:function(t,e,n){return n.x=e.x*t,n.y=e.y*t,n}},{key:"MulVS",value:function(t,e,n){return n.x=t.x*e,n.y=t.y*e,n}},{key:"AddVMulSV",value:function(t,e,n,r){return r.x=t.x+e*n.x,r.y=t.y+e*n.y,r}},{key:"SubVMulSV",value:function(t,e,n,r){return r.x=t.x-e*n.x,r.y=t.y-e*n.y,r}},{key:"AddVCrossSV",value:function(t,e,n,r){var i=n.x;return r.x=t.x-e*n.y,r.y=t.y+e*i,r}},{key:"MidVV",value:function(t,e,n){return n.x=.5*(t.x+e.x),n.y=.5*(t.y+e.y),n}},{key:"ExtVV",value:function(t,e,n){return n.x=.5*(e.x-t.x),n.y=.5*(e.y-t.y),n}},{key:"IsEqualToV",value:function(t,e){return t.x===e.x&&t.y===e.y}},{key:"DistanceVV",value:function(t,e){var n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}},{key:"DistanceSquaredVV",value:function(t,e){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r}},{key:"NegV",value:function(t,e){return e.x=-t.x,e.y=-t.y,e}}]),t}();E.ZERO=new E(0,0),E.UNITX=new E(1,0),E.UNITY=new E(0,1),E.s_t0=new E,E.s_t1=new E,E.s_t2=new E,E.s_t3=new E;var T=new E(0,0),M=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;u(this,t),this.x=e,this.y=n,this.z=r}return l(t,[{key:"Clone",value:function(){return new t(this.x,this.y,this.z)}},{key:"SetZero",value:function(){return this.x=0,this.y=0,this.z=0,this}},{key:"SetXYZ",value:function(t,e,n){return this.x=t,this.y=e,this.z=n,this}},{key:"Copy",value:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}},{key:"SelfNeg",value:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}},{key:"SelfAdd",value:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}},{key:"SelfAddXYZ",value:function(t,e,n){return this.x+=t,this.y+=e,this.z+=n,this}},{key:"SelfSub",value:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}},{key:"SelfSubXYZ",value:function(t,e,n){return this.x-=t,this.y-=e,this.z-=n,this}},{key:"SelfMul",value:function(t){return this.x*=t,this.y*=t,this.z*=t,this}}],[{key:"DotV3V3",value:function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}},{key:"CrossV3V3",value:function(t,e,n){var r=t.x,i=t.y,o=t.z,a=e.x,s=e.y,u=e.z;return n.x=i*u-o*s,n.y=o*a-r*u,n.z=r*s-i*a,n}}]),t}();M.ZERO=new M(0,0,0),M.s_t0=new M;var I=function(){function t(){u(this,t),this.ex=new E(1,0),this.ey=new E(0,1)}return l(t,[{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"SetSSSS",value:function(t,e,n,r){return this.ex.Set(t,n),this.ey.Set(e,r),this}},{key:"SetVV",value:function(t,e){return this.ex.Copy(t),this.ey.Copy(e),this}},{key:"SetAngle",value:function(t){var e=Math.cos(t),n=Math.sin(t);return this.ex.Set(e,n),this.ey.Set(-n,e),this}},{key:"Copy",value:function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this}},{key:"SetIdentity",value:function(){return this.ex.Set(1,0),this.ey.Set(0,1),this}},{key:"SetZero",value:function(){return this.ex.SetZero(),this.ey.SetZero(),this}},{key:"GetAngle",value:function(){return Math.atan2(this.ex.y,this.ex.x)}},{key:"GetInverse",value:function(t){var e=this.ex.x,n=this.ey.x,r=this.ex.y,i=this.ey.y,o=e*i-n*r;return 0!==o&&(o=1/o),t.ex.x=o*i,t.ey.x=-o*n,t.ex.y=-o*r,t.ey.y=o*e,t}},{key:"Solve",value:function(t,e,n){var r=this.ex.x,i=this.ey.x,o=this.ex.y,a=this.ey.y,s=r*a-i*o;return 0!==s&&(s=1/s),n.x=s*(a*t-i*e),n.y=s*(r*e-o*t),n}},{key:"SelfAbs",value:function(){return this.ex.SelfAbs(),this.ey.SelfAbs(),this}},{key:"SelfInv",value:function(){return this.GetInverse(this),this}},{key:"SelfAddM",value:function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this}},{key:"SelfSubM",value:function(t){return this.ex.SelfSub(t.ex),this.ey.SelfSub(t.ey),this}}],[{key:"FromVV",value:function(e,n){return(new t).SetVV(e,n)}},{key:"FromSSSS",value:function(e,n,r,i){return(new t).SetSSSS(e,n,r,i)}},{key:"FromAngle",value:function(e){return(new t).SetAngle(e)}},{key:"AbsM",value:function(t,e){var n=t.ex,r=t.ey;return e.ex.x=_(n.x),e.ex.y=_(n.y),e.ey.x=_(r.x),e.ey.y=_(r.y),e}},{key:"MulMV",value:function(t,e,n){var r=t.ex,i=t.ey,o=e.x,a=e.y;return n.x=r.x*o+i.x*a,n.y=r.y*o+i.y*a,n}},{key:"MulTMV",value:function(t,e,n){var r=t.ex,i=t.ey,o=e.x,a=e.y;return n.x=r.x*o+r.y*a,n.y=i.x*o+i.y*a,n}},{key:"AddMM",value:function(t,e,n){var r=t.ex,i=t.ey,o=e.ex,a=e.ey;return n.ex.x=r.x+o.x,n.ex.y=r.y+o.y,n.ey.x=i.x+a.x,n.ey.y=i.y+a.y,n}},{key:"MulMM",value:function(t,e,n){var r=t.ex.x,i=t.ex.y,o=t.ey.x,a=t.ey.y,s=e.ex.x,u=e.ex.y,l=e.ey.x,c=e.ey.y;return n.ex.x=r*s+o*u,n.ex.y=i*s+a*u,n.ey.x=r*l+o*c,n.ey.y=i*l+a*c,n}},{key:"MulTMM",value:function(t,e,n){var r=t.ex.x,i=t.ex.y,o=t.ey.x,a=t.ey.y,s=e.ex.x,u=e.ex.y,l=e.ey.x,c=e.ey.y;return n.ex.x=r*s+i*u,n.ex.y=o*s+a*u,n.ey.x=r*l+i*c,n.ey.y=o*l+a*c,n}}]),t}();I.IDENTITY=new I;var O=function(){function t(){u(this,t),this.ex=new M(1,0,0),this.ey=new M(0,1,0),this.ez=new M(0,0,1)}return l(t,[{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"SetVVV",value:function(t,e,n){return this.ex.Copy(t),this.ey.Copy(e),this.ez.Copy(n),this}},{key:"Copy",value:function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this.ez.Copy(t.ez),this}},{key:"SetIdentity",value:function(){return this.ex.SetXYZ(1,0,0),this.ey.SetXYZ(0,1,0),this.ez.SetXYZ(0,0,1),this}},{key:"SetZero",value:function(){return this.ex.SetZero(),this.ey.SetZero(),this.ez.SetZero(),this}},{key:"SelfAddM",value:function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this.ez.SelfAdd(t.ez),this}},{key:"Solve33",value:function(t,e,n,r){var i=this.ex.x,o=this.ex.y,a=this.ex.z,s=this.ey.x,u=this.ey.y,l=this.ey.z,c=this.ez.x,f=this.ez.y,h=this.ez.z,m=i*(u*h-l*f)+o*(l*c-s*h)+a*(s*f-u*c);return 0!==m&&(m=1/m),r.x=m*(t*(u*h-l*f)+e*(l*c-s*h)+n*(s*f-u*c)),r.y=m*(i*(e*h-n*f)+o*(n*c-t*h)+a*(t*f-e*c)),r.z=m*(i*(u*n-l*e)+o*(l*t-s*n)+a*(s*e-u*t)),r}},{key:"Solve22",value:function(t,e,n){var r=this.ex.x,i=this.ey.x,o=this.ex.y,a=this.ey.y,s=r*a-i*o;return 0!==s&&(s=1/s),n.x=s*(a*t-i*e),n.y=s*(r*e-o*t),n}},{key:"GetInverse22",value:function(t){var e=this.ex.x,n=this.ey.x,r=this.ex.y,i=this.ey.y,o=e*i-n*r;0!==o&&(o=1/o),t.ex.x=o*i,t.ey.x=-o*n,t.ex.z=0,t.ex.y=-o*r,t.ey.y=o*e,t.ey.z=0,t.ez.x=0,t.ez.y=0,t.ez.z=0}},{key:"GetSymInverse33",value:function(t){var e=M.DotV3V3(this.ex,M.CrossV3V3(this.ey,this.ez,M.s_t0));0!==e&&(e=1/e);var n=this.ex.x,r=this.ey.x,i=this.ez.x,o=this.ey.y,a=this.ez.y,s=this.ez.z;t.ex.x=e*(o*s-a*a),t.ex.y=e*(i*a-r*s),t.ex.z=e*(r*a-i*o),t.ey.x=t.ex.y,t.ey.y=e*(n*s-i*i),t.ey.z=e*(i*r-n*a),t.ez.x=t.ex.z,t.ez.y=t.ey.z,t.ez.z=e*(n*o-r*r)}}],[{key:"MulM33V3",value:function(t,e,n){var r=e.x,i=e.y,o=e.z;return n.x=t.ex.x*r+t.ey.x*i+t.ez.x*o,n.y=t.ex.y*r+t.ey.y*i+t.ez.y*o,n.z=t.ex.z*r+t.ey.z*i+t.ez.z*o,n}},{key:"MulM33XYZ",value:function(t,e,n,r,i){return i.x=t.ex.x*e+t.ey.x*n+t.ez.x*r,i.y=t.ex.y*e+t.ey.y*n+t.ez.y*r,i.z=t.ex.z*e+t.ey.z*n+t.ez.z*r,i}},{key:"MulM33V2",value:function(t,e,n){var r=e.x,i=e.y;return n.x=t.ex.x*r+t.ey.x*i,n.y=t.ex.y*r+t.ey.y*i,n}},{key:"MulM33XY",value:function(t,e,n,r){return r.x=t.ex.x*e+t.ey.x*n,r.y=t.ex.y*e+t.ey.y*n,r}}]),t}();O.IDENTITY=new O;var R=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;u(this,t),this.s=0,this.c=1,e&&(this.s=Math.sin(e),this.c=Math.cos(e))}return l(t,[{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"Copy",value:function(t){return this.s=t.s,this.c=t.c,this}},{key:"SetAngle",value:function(t){return this.s=Math.sin(t),this.c=Math.cos(t),this}},{key:"SetIdentity",value:function(){return this.s=0,this.c=1,this}},{key:"GetAngle",value:function(){return Math.atan2(this.s,this.c)}},{key:"GetXAxis",value:function(t){return t.x=this.c,t.y=this.s,t}},{key:"GetYAxis",value:function(t){return t.x=-this.s,t.y=this.c,t}}],[{key:"MulRR",value:function(t,e,n){var r=t.c,i=t.s,o=e.c,a=e.s;return n.s=i*o+r*a,n.c=r*o-i*a,n}},{key:"MulTRR",value:function(t,e,n){var r=t.c,i=t.s,o=e.c,a=e.s;return n.s=r*a-i*o,n.c=r*o+i*a,n}},{key:"MulRV",value:function(t,e,n){var r=t.c,i=t.s,o=e.x,a=e.y;return n.x=r*o-i*a,n.y=i*o+r*a,n}},{key:"MulTRV",value:function(t,e,n){var r=t.c,i=t.s,o=e.x,a=e.y;return n.x=r*o+i*a,n.y=-i*o+r*a,n}}]),t}();R.IDENTITY=new R;var D=function(){function t(){u(this,t),this.p=new E,this.q=new R}return l(t,[{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"Copy",value:function(t){return this.p.Copy(t.p),this.q.Copy(t.q),this}},{key:"SetIdentity",value:function(){return this.p.SetZero(),this.q.SetIdentity(),this}},{key:"SetPositionRotation",value:function(t,e){return this.p.Copy(t),this.q.Copy(e),this}},{key:"SetPositionAngle",value:function(t,e){return this.p.Copy(t),this.q.SetAngle(e),this}},{key:"SetPosition",value:function(t){return this.p.Copy(t),this}},{key:"SetPositionXY",value:function(t,e){return this.p.Set(t,e),this}},{key:"SetRotation",value:function(t){return this.q.Copy(t),this}},{key:"SetRotationAngle",value:function(t){return this.q.SetAngle(t),this}},{key:"GetPosition",value:function(){return this.p}},{key:"GetRotation",value:function(){return this.q}},{key:"GetRotationAngle",value:function(){return this.q.GetAngle()}},{key:"GetAngle",value:function(){return this.q.GetAngle()}}],[{key:"MulXV",value:function(t,e,n){var r=t.q.c,i=t.q.s,o=e.x,a=e.y;return n.x=r*o-i*a+t.p.x,n.y=i*o+r*a+t.p.y,n}},{key:"MulTXV",value:function(t,e,n){var r=t.q.c,i=t.q.s,o=e.x-t.p.x,a=e.y-t.p.y;return n.x=r*o+i*a,n.y=-i*o+r*a,n}},{key:"MulXX",value:function(t,e,n){return R.MulRR(t.q,e.q,n.q),E.AddVV(R.MulRV(t.q,e.p,n.p),t.p,n.p),n}},{key:"MulTXX",value:function(t,e,n){return R.MulTRR(t.q,e.q,n.q),R.MulTRV(t.q,E.SubVV(e.p,t.p,n.p),n.p),n}}]),t}();D.IDENTITY=new D;var j,L=function(){function t(){u(this,t),this.localCenter=new E,this.c0=new E,this.c=new E,this.a0=0,this.a=0,this.alpha0=0}return l(t,[{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"Copy",value:function(t){return this.localCenter.Copy(t.localCenter),this.c0.Copy(t.c0),this.c.Copy(t.c),this.a0=t.a0,this.a=t.a,this.alpha0=t.alpha0,this}},{key:"GetTransform",value:function(t,e){var n=1-e;t.p.x=n*this.c0.x+e*this.c.x,t.p.y=n*this.c0.y+e*this.c.y;var r=n*this.a0+e*this.a;return t.q.SetAngle(r),t.p.SelfSub(R.MulRV(t.q,this.localCenter,E.s_t0)),t}},{key:"Advance",value:function(t){var e=(t-this.alpha0)/(1-this.alpha0),n=1-e;this.c0.x=n*this.c0.x+e*this.c.x,this.c0.y=n*this.c0.y+e*this.c.y,this.a0=n*this.a0+e*this.a,this.alpha0=t}},{key:"Normalize",value:function(){var t=6.28318530718*Math.floor(this.a0/6.28318530718);this.a0-=t,this.a-=t}}]),t}(),F=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;u(this,t),this.r=e,this.g=n,this.b=r,this.a=i}return l(t,[{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"Copy",value:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}},{key:"IsEqual",value:function(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a}},{key:"IsZero",value:function(){return 0===this.r&&0===this.g&&0===this.b&&0===this.a}},{key:"Set",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.a;this.SetRGBA(t,e,n,r)}},{key:"SetByteRGB",value:function(t,e,n){return this.r=t/255,this.g=e/255,this.b=n/255,this}},{key:"SetByteRGBA",value:function(t,e,n,r){return this.r=t/255,this.g=e/255,this.b=n/255,this.a=r/255,this}},{key:"SetRGB",value:function(t,e,n){return this.r=t,this.g=e,this.b=n,this}},{key:"SetRGBA",value:function(t,e,n,r){return this.r=t,this.g=e,this.b=n,this.a=r,this}},{key:"SelfAdd",value:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this}},{key:"Add",value:function(t,e){return e.r=this.r+t.r,e.g=this.g+t.g,e.b=this.b+t.b,e.a=this.a+t.a,e}},{key:"SelfSub",value:function(t){return this.r-=t.r,this.g-=t.g,this.b-=t.b,this.a-=t.a,this}},{key:"Sub",value:function(t,e){return e.r=this.r-t.r,e.g=this.g-t.g,e.b=this.b-t.b,e.a=this.a-t.a,e}},{key:"SelfMul",value:function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this}},{key:"Mul",value:function(t,e){return e.r=this.r*t,e.g=this.g*t,e.b=this.b*t,e.a=this.a*t,e}},{key:"Mix",value:function(e,n){t.MixColors(this,e,n)}},{key:"MakeStyleString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.a;return t.MakeStyleString(this.r,this.g,this.b,e)}}],[{key:"MixColors",value:function(t,e,n){var r=n*(e.r-t.r),i=n*(e.g-t.g),o=n*(e.b-t.b),a=n*(e.a-t.a);t.r+=r,t.g+=i,t.b+=o,t.a+=a,e.r-=r,e.g-=i,e.b-=o,e.a-=a}},{key:"MakeStyleString",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return t*=255,e*=255,n*=255,r<1?"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")"):"rgb(".concat(t,",").concat(e,",").concat(n,")")}}]),t}();F.ZERO=new F(0,0,0,0),F.RED=new F(1,0,0),F.GREEN=new F(0,1,0),F.BLUE=new F(0,0,1),(j=t.b2DrawFlags||(t.b2DrawFlags={}))[j.e_none=0]="e_none",j[j.e_shapeBit=1]="e_shapeBit",j[j.e_jointBit=2]="e_jointBit",j[j.e_aabbBit=4]="e_aabbBit",j[j.e_pairBit=8]="e_pairBit",j[j.e_centerOfMassBit=16]="e_centerOfMassBit",j[j.e_particleBit=32]="e_particleBit",j[j.e_controllerBit=64]="e_controllerBit",j[j.e_all=63]="e_all";var G=function(){function t(){u(this,t),this.m_start=Date.now()}return l(t,[{key:"Reset",value:function(){return this.m_start=Date.now(),this}},{key:"GetMilliseconds",value:function(){return Date.now()-this.m_start}}]),t}(),N=function(){function t(e){u(this,t),this.m_stack=[],this.m_count=0,this.m_stack=d(e,(function(t){return null})),this.m_count=0}return l(t,[{key:"Reset",value:function(){return this.m_count=0,this}},{key:"Push",value:function(t){this.m_stack[this.m_count]=t,this.m_count++}},{key:"Pop",value:function(){this.m_count--;var t=this.m_stack[this.m_count];if(this.m_stack[this.m_count]=null,null===t)throw new Error;return t}},{key:"GetCount",value:function(){return this.m_count}}]),t}(),z=function(){function t(){u(this,t),this.m_buffer=E.MakeArray(2),this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0}return l(t,[{key:"Copy",value:function(t){return t.m_vertices===t.m_buffer?(this.m_vertices=this.m_buffer,this.m_buffer[0].Copy(t.m_buffer[0]),this.m_buffer[1].Copy(t.m_buffer[1])):this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius,this}},{key:"Reset",value:function(){return this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0,this}},{key:"SetShape",value:function(t,e){t.SetupDistanceProxy(this,e)}},{key:"SetVerticesRadius",value:function(t,e,n){this.m_vertices=t,this.m_count=e,this.m_radius=n}},{key:"GetSupport",value:function(t){for(var e=0,n=E.DotVV(this.m_vertices[0],t),r=1;rn&&(e=r,n=i)}return e}},{key:"GetSupportVertex",value:function(t){for(var e=0,n=E.DotVV(this.m_vertices[0],t),r=1;rn&&(e=r,n=i)}return this.m_vertices[e]}},{key:"GetVertexCount",value:function(){return this.m_count}},{key:"GetVertex",value:function(t){return this.m_vertices[t]}}]),t}(),q=function(){function t(){u(this,t),this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}return l(t,[{key:"Reset",value:function(){return this.metric=0,this.count=0,this}}]),t}(),U=function(){function t(){u(this,t),this.proxyA=new z,this.proxyB=new z,this.transformA=new D,this.transformB=new D,this.useRadii=!1}return l(t,[{key:"Reset",value:function(){return this.proxyA.Reset(),this.proxyB.Reset(),this.transformA.SetIdentity(),this.transformB.SetIdentity(),this.useRadii=!1,this}}]),t}(),W=function(){function t(){u(this,t),this.pointA=new E,this.pointB=new E,this.distance=0,this.iterations=0}return l(t,[{key:"Reset",value:function(){return this.pointA.SetZero(),this.pointB.SetZero(),this.distance=0,this.iterations=0,this}}]),t}();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var J=function(){function t(){u(this,t),this.wA=new E,this.wB=new E,this.w=new E,this.a=0,this.indexA=0,this.indexB=0}return l(t,[{key:"Copy",value:function(t){return this.wA.Copy(t.wA),this.wB.Copy(t.wB),this.w.Copy(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB,this}}]),t}(),H=function(){function t(){u(this,t),this.m_v1=new J,this.m_v2=new J,this.m_v3=new J,this.m_vertices=[],this.m_count=0,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3}return l(t,[{key:"ReadCache",value:function(t,e,n,r,i){this.m_count=t.count;for(var o=this.m_vertices,a=0;a1){var c=t.metric,f=this.GetMetric();(f<.5*c||2*c0?E.CrossOneV(e,t):E.CrossVOne(e,t);default:return t.SetZero()}}},{key:"GetClosestPoint",value:function(t){switch(this.m_count){case 0:return t.SetZero();case 1:return t.Copy(this.m_v1.w);case 2:return t.Set(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);case 3:default:return t.SetZero()}}},{key:"GetWitnessPoints",value:function(t,e){switch(this.m_count){case 0:break;case 1:t.Copy(this.m_v1.wA),e.Copy(this.m_v1.wB);break;case 2:t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,e.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,e.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:e.x=t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,e.y=t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y}}},{key:"GetMetric",value:function(){switch(this.m_count){case 0:case 1:return 0;case 2:return E.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return E.CrossVV(E.SubVV(this.m_v2.w,this.m_v1.w,E.s_t0),E.SubVV(this.m_v3.w,this.m_v1.w,E.s_t1));default:return 0}}},{key:"Solve2",value:function(){var e=this.m_v1.w,n=this.m_v2.w,r=E.SubVV(n,e,t.s_e12),i=-E.DotVV(e,r);if(i<=0)return this.m_v1.a=1,void(this.m_count=1);var o=E.DotVV(n,r);if(o<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);var a=1/(o+i);this.m_v1.a=o*a,this.m_v2.a=i*a,this.m_count=2}},{key:"Solve3",value:function(){var e=this.m_v1.w,n=this.m_v2.w,r=this.m_v3.w,i=E.SubVV(n,e,t.s_e12),o=E.DotVV(e,i),a=E.DotVV(n,i),s=-o,u=E.SubVV(r,e,t.s_e13),l=E.DotVV(e,u),c=E.DotVV(r,u),f=-l,h=E.SubVV(r,n,t.s_e23),m=E.DotVV(n,h),d=E.DotVV(r,h),p=-m,_=E.CrossVV(i,u),y=_*E.CrossVV(n,r),v=_*E.CrossVV(r,e),g=_*E.CrossVV(e,n);if(s<=0&&f<=0)return this.m_v1.a=1,void(this.m_count=1);if(a>0&&s>0&&g<=0){var b=1/(a+s);return this.m_v1.a=a*b,this.m_v2.a=s*b,void(this.m_count=2)}if(c>0&&f>0&&v<=0){var x=1/(c+f);return this.m_v1.a=c*x,this.m_v3.a=f*x,this.m_count=2,void this.m_v2.Copy(this.m_v3)}if(a<=0&&p<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(c<=0&&d<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(d>0&&p>0&&y<=0){var w=1/(d+p);return this.m_v2.a=d*w,this.m_v3.a=p*w,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var S=1/(y+v+g);this.m_v1.a=y*S,this.m_v2.a=v*S,this.m_v3.a=g*S,this.m_count=3}}]),t}();H.s_e12=new E,H.s_e13=new E,H.s_e23=new E;var X=new H,$=[0,0,0],Y=[0,0,0],Z=new E,K=new E,Q=new E,tt=new E,et=new E;function nt(e,n,r){++t.b2_gjkCalls;var i=r.proxyA,o=r.proxyB,a=r.transformA,s=r.transformB,u=X;u.ReadCache(n,i,a,o,s);for(var l=u.m_vertices,c=$,f=Y,h=0,m=0;m<20;){h=u.m_count;for(var d=0;db+x&&e.distance>1e-5){e.distance-=b+x;var w=E.SubVV(e.pointB,e.pointA,Q);w.Normalize(),e.pointA.SelfMulAdd(b,w),e.pointB.SelfMulSub(x,w)}else{var S=E.MidVV(e.pointA,e.pointB,Z);e.pointA.Copy(S),e.pointB.Copy(S),e.distance=0}}}var rt,it,ot,at=new E,st=new H,ut=new E,lt=new E,ct=new E,ft=new E,ht=new E,mt=new E;(rt=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[rt.e_vertex=0]="e_vertex",rt[rt.e_face=1]="e_face";var dt=function(){function t(){u(this,t),this._key=0,this._key_invalid=!1,this._indexA=0,this._indexB=0,this._typeA=0,this._typeB=0}return l(t,[{key:"key",get:function(){return this._key_invalid&&(this._key_invalid=!1,this._key=this._indexA|this._indexB<<8|this._typeA<<16|this._typeB<<24),this._key},set:function(t){this._key=t,this._key_invalid=!1,this._indexA=255&this._key,this._indexB=this._key>>8&255,this._typeA=this._key>>16&255,this._typeB=this._key>>24&255}},{key:"indexA",get:function(){return this._indexA},set:function(t){this._indexA=t,this._key_invalid=!0}},{key:"indexB",get:function(){return this._indexB},set:function(t){this._indexB=t,this._key_invalid=!0}},{key:"typeA",get:function(){return this._typeA},set:function(t){this._typeA=t,this._key_invalid=!0}},{key:"typeB",get:function(){return this._typeB},set:function(t){this._typeB=t,this._key_invalid=!0}}]),t}(),pt=function(){function t(){u(this,t),this.cf=new dt}return l(t,[{key:"Copy",value:function(t){return this.key=t.key,this}},{key:"Clone",value:function(){return(new t).Copy(this)}},{key:"key",get:function(){return this.cf.key},set:function(t){this.cf.key=t}}]),t}(),_t=function(){function t(){u(this,t),this.localPoint=new E,this.normalImpulse=0,this.tangentImpulse=0,this.id=new pt}return l(t,[{key:"Reset",value:function(){this.localPoint.SetZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.key=0}},{key:"Copy",value:function(t){return this.localPoint.Copy(t.localPoint),this.normalImpulse=t.normalImpulse,this.tangentImpulse=t.tangentImpulse,this.id.Copy(t.id),this}}],[{key:"MakeArray",value:function(e){return d(e,(function(e){return new t}))}}]),t}();(it=t.b2ManifoldType||(t.b2ManifoldType={}))[it.e_unknown=-1]="e_unknown",it[it.e_circles=0]="e_circles",it[it.e_faceA=1]="e_faceA",it[it.e_faceB=2]="e_faceB";var yt=function(){function e(){u(this,e),this.points=_t.MakeArray(2),this.localNormal=new E,this.localPoint=new E,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}return l(e,[{key:"Reset",value:function(){for(var e=0;e<2;++e)this.points[e].Reset();this.localNormal.SetZero(),this.localPoint.SetZero(),this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}},{key:"Copy",value:function(t){this.pointCount=t.pointCount;for(var e=0;e<2;++e)this.points[e].Copy(t.points[e]);return this.localNormal.Copy(t.localNormal),this.localPoint.Copy(t.localPoint),this.type=t.type,this}},{key:"Clone",value:function(){return(new e).Copy(this)}}]),e}(),vt=function(){function e(){u(this,e),this.normal=new E,this.points=E.MakeArray(2),this.separations=p(2)}return l(e,[{key:"Initialize",value:function(n,r,i,o,a){if(0!==n.pointCount)switch(n.type){case t.b2ManifoldType.e_circles:this.normal.Set(1,0);var s=D.MulXV(r,n.localPoint,e.Initialize_s_pointA),u=D.MulXV(o,n.points[0].localPoint,e.Initialize_s_pointB);E.DistanceSquaredVV(s,u)>1e-5*1e-5&&E.SubVV(u,s,this.normal).SelfNormalize();var l=E.AddVMulSV(s,i,this.normal,e.Initialize_s_cA),c=E.SubVMulSV(u,a,this.normal,e.Initialize_s_cB);E.MidVV(l,c,this.points[0]),this.separations[0]=E.DotVV(E.SubVV(c,l,E.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:R.MulRV(r.q,n.localNormal,this.normal);for(var f=D.MulXV(r,n.localPoint,e.Initialize_s_planePoint),h=0;h=0&&e>=0;return n=n&&this.lowerBound.IsValid()&&this.upperBound.IsValid()}},{key:"GetCenter",value:function(){return E.MidVV(this.lowerBound,this.upperBound,this.m_cache_center)}},{key:"GetExtents",value:function(){return E.ExtVV(this.lowerBound,this.upperBound,this.m_cache_extent)}},{key:"GetPerimeter",value:function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))}},{key:"Combine1",value:function(t){return this.lowerBound.x=y(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=y(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=v(this.upperBound.x,t.upperBound.x),this.upperBound.y=v(this.upperBound.y,t.upperBound.y),this}},{key:"Combine2",value:function(t,e){return this.lowerBound.x=y(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=y(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=v(t.upperBound.x,e.upperBound.x),this.upperBound.y=v(t.upperBound.y,e.upperBound.y),this}},{key:"Contains",value:function(t){var e=!0;return e=(e=(e=(e=e&&this.lowerBound.x<=t.lowerBound.x)&&this.lowerBound.y<=t.lowerBound.y)&&t.upperBound.x<=this.upperBound.x)&&t.upperBound.y<=this.upperBound.y}},{key:"RayCast",value:function(t,e){var r=-n,i=n,o=e.p1.x,a=e.p1.y,s=e.p2.x-e.p1.x,u=e.p2.y-e.p1.y,l=_(s),c=_(u),f=t.normal;if(l<1e-5){if(od){var v=m;m=d,d=v,p=1}if(m>r&&(f.x=p,f.y=0,r=m),r>(i=y(i,d)))return!1}if(c<1e-5){if(ax){var S=b;b=x,x=S,w=1}if(b>r&&(f.x=0,f.y=w,r=b),r>(i=y(i,x)))return!1}return!(r<0||e.maxFraction0||n>0||r>0||i>0)}}],[{key:"Combine",value:function(t,e,n){return n.Combine2(t,e),n}}]),t}();function St(t,e){var n=e.lowerBound.x-t.upperBound.x,r=e.lowerBound.y-t.upperBound.y,i=t.lowerBound.x-e.upperBound.x,o=t.lowerBound.y-e.upperBound.y;return!(n>0||r>0||i>0||o>0)}function Ct(e,n,r,i,o){var a=0,s=n[0],u=n[1],l=E.DotVV(r,s.v)-i,c=E.DotVV(r,u.v)-i;if(l<=0&&e[a++].Copy(s),c<=0&&e[a++].Copy(u),l*c<0){var f=l/(l-c),h=e[a].v;h.x=s.v.x+f*(u.v.x-s.v.x),h.y=s.v.y+f*(u.v.y-s.v.y);var m=e[a].id;m.cf.indexA=o,m.cf.indexB=s.id.cf.indexB,m.cf.typeA=t.b2ContactFeatureType.e_vertex,m.cf.typeB=t.b2ContactFeatureType.e_face,++a}return a}var At=new U,Bt=new q,kt=new W;function Pt(t,e,n,r,i,o){var a=At.Reset();a.proxyA.SetShape(t,e),a.proxyB.SetShape(n,r),a.transformA.Copy(i),a.transformB.Copy(o),a.useRadii=!0;var s=Bt.Reset();s.count=0;var u=kt.Reset();return nt(u,s,a),u.distance<1e-4}function Vt(t){if(null===t)throw new Error;return t}var Et=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;u(this,t),this.m_id=0,this.aabb=new wt,this.parent=null,this.child1=null,this.child2=null,this.height=0,this.m_id=e}return l(t,[{key:"IsLeaf",value:function(){return null===this.child1}}]),t}(),Tt=function(){function t(){u(this,t),this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0,this.m_stack=new N(256)}return l(t,[{key:"Query",value:function(t,e){if(null!==this.m_root){var n=this.m_stack.Reset();for(n.Push(this.m_root);n.GetCount()>0;){var r=n.Pop();if(r.aabb.TestOverlap(t))if(r.IsLeaf()){if(!e(r))return}else n.Push(Vt(r.child1)),n.Push(Vt(r.child2))}}}},{key:"QueryPoint",value:function(t,e){if(null!==this.m_root){var n=this.m_stack.Reset();for(n.Push(this.m_root);n.GetCount()>0;){var r=n.Pop();if(r.aabb.TestContain(t))if(r.IsLeaf()){if(!e(r))return}else n.Push(Vt(r.child1)),n.Push(Vt(r.child2))}}}},{key:"RayCast",value:function(e,n){if(null!==this.m_root){var r=e.p1,i=e.p2,o=E.SubVV(i,r,t.s_r);o.Normalize();var a=E.CrossOneV(o,t.s_v),s=E.AbsV(a,t.s_abs_v),u=e.maxFraction,l=t.s_segmentAABB,c=r.x+u*(i.x-r.x),f=r.y+u*(i.y-r.y);l.lowerBound.x=y(r.x,c),l.lowerBound.y=y(r.y,f),l.upperBound.x=v(r.x,c),l.upperBound.y=v(r.y,f);var h=this.m_stack.Reset();for(h.Push(this.m_root);h.GetCount()>0;){var m=h.Pop();if(St(m.aabb,l)){var d=m.aabb.GetCenter(),p=m.aabb.GetExtents();if(!(_(E.DotVV(a,E.SubVV(r,d,E.s_t0)))-E.DotVV(s,p)>0))if(m.IsLeaf()){var g=t.s_subInput;g.p1.Copy(e.p1),g.p2.Copy(e.p2),g.maxFraction=u;var b=n(g,m);if(0===b)return;b>0&&(u=b,c=r.x+u*(i.x-r.x),f=r.y+u*(i.y-r.y),l.lowerBound.x=y(r.x,c),l.lowerBound.y=y(r.y,f),l.upperBound.x=v(r.x,c),l.upperBound.y=v(r.y,f))}else h.Push(Vt(m.child1)),h.Push(Vt(m.child2))}}}}},{key:"AllocateNode",value:function(){if(this.m_freeList){var e=this.m_freeList;return this.m_freeList=e.parent,e.parent=null,e.child1=null,e.child2=null,e.height=0,delete e.userData,e}return new Et(t.s_node_id++)}},{key:"FreeNode",value:function(t){t.parent=this.m_freeList,t.child1=null,t.child2=null,t.height=-1,delete t.userData,this.m_freeList=t}},{key:"CreateProxy",value:function(t,e){var n=this.AllocateNode();return n.aabb.lowerBound.x=t.lowerBound.x-.1,n.aabb.lowerBound.y=t.lowerBound.y-.1,n.aabb.upperBound.x=t.upperBound.x+.1,n.aabb.upperBound.y=t.upperBound.y+.1,n.userData=e,n.height=0,this.InsertLeaf(n),n}},{key:"DestroyProxy",value:function(t){this.RemoveLeaf(t),this.FreeNode(t)}},{key:"MoveProxy",value:function(t,e,n){if(t.aabb.Contains(e))return!1;this.RemoveLeaf(t);var r=.1+2*(n.x>0?n.x:-n.x),i=.1+2*(n.y>0?n.y:-n.y);return t.aabb.lowerBound.x=e.lowerBound.x-r,t.aabb.lowerBound.y=e.lowerBound.y-i,t.aabb.upperBound.x=e.upperBound.x+r,t.aabb.upperBound.y=e.upperBound.y+i,this.InsertLeaf(t),!0}},{key:"InsertLeaf",value:function(e){if(++this.m_insertionCount,null===this.m_root)return this.m_root=e,void(this.m_root.parent=null);for(var n=e.aabb,r=this.m_root;!r.IsLeaf();){var i=Vt(r.child1),o=Vt(r.child2),a=r.aabb.GetPerimeter(),s=t.s_combinedAABB;s.Combine2(r.aabb,n);var u=s.GetPerimeter(),l=2*u,c=2*(u-a),f=void 0,h=t.s_aabb,m=void 0,d=void 0;if(i.IsLeaf()?(h.Combine2(n,i.aabb),f=h.GetPerimeter()+c):(h.Combine2(n,i.aabb),m=i.aabb.GetPerimeter(),f=h.GetPerimeter()-m+c),o.IsLeaf()?(h.Combine2(n,o.aabb),d=h.GetPerimeter()+c):(h.Combine2(n,o.aabb),m=o.aabb.GetPerimeter(),d=h.GetPerimeter()-m+c),l1){var i=Vt(n.child1),o=Vt(n.child2);return n.child1=t,n.parent=t.parent,t.parent=n,null!==n.parent?n.parent.child1===t?n.parent.child1=n:n.parent.child2=n:this.m_root=n,i.height>o.height?(n.child2=i,t.child2=o,o.parent=t,t.aabb.Combine2(e.aabb,o.aabb),n.aabb.Combine2(t.aabb,i.aabb),t.height=1+v(e.height,o.height),n.height=1+v(t.height,i.height)):(n.child2=o,t.child2=i,i.parent=t,t.aabb.Combine2(e.aabb,i.aabb),n.aabb.Combine2(t.aabb,o.aabb),t.height=1+v(e.height,i.height),n.height=1+v(t.height,o.height)),n}if(r<-1){var a=Vt(e.child1),s=Vt(e.child2);return e.child1=t,e.parent=t.parent,t.parent=e,null!==e.parent?e.parent.child1===t?e.parent.child1=e:e.parent.child2=e:this.m_root=e,a.height>s.height?(e.child2=a,t.child1=s,s.parent=t,t.aabb.Combine2(n.aabb,s.aabb),e.aabb.Combine2(t.aabb,a.aabb),t.height=1+v(n.height,s.height),e.height=1+v(t.height,a.height)):(e.child2=s,t.child1=a,a.parent=t,t.aabb.Combine2(n.aabb,a.aabb),e.aabb.Combine2(t.aabb,s.aabb),t.height=1+v(n.height,a.height),e.height=1+v(t.height,s.height)),e}return t}},{key:"GetHeight",value:function(){return null===this.m_root?0:this.m_root.height}},{key:"GetAreaRatio",value:function(){if(null===this.m_root)return 0;var e=this.m_root.aabb.GetPerimeter();return t.GetAreaNode(this.m_root)/e}},{key:"ComputeHeightNode",value:function(t){if(!t||t.IsLeaf())return 0;var e=this.ComputeHeightNode(t.child1),n=this.ComputeHeightNode(t.child2);return 1+v(e,n)}},{key:"ComputeHeight",value:function(){return this.ComputeHeightNode(this.m_root)}},{key:"ValidateStructure",value:function(t){if(null!==t){this.m_root;var e=t;if(!e.IsLeaf()){var n=Vt(e.child1),r=Vt(e.child2);this.ValidateStructure(n),this.ValidateStructure(r)}}}},{key:"ValidateMetrics",value:function(e){if(null!==e){var n=e;if(!n.IsLeaf()){var r=Vt(n.child1),i=Vt(n.child2);t.s_aabb.Combine2(r.aabb,i.aabb),this.ValidateMetrics(r),this.ValidateMetrics(i)}}}},{key:"Validate",value:function(){}},{key:"GetMaxBalance",value:function(){return t.GetMaxBalanceNode(this.m_root,0)}},{key:"RebuildBottomUp",value:function(){this.Validate()}},{key:"ShiftOrigin",value:function(e){t.ShiftOriginNode(this.m_root,e)}}],[{key:"GetAreaNode",value:function(e){if(null===e)return 0;if(e.IsLeaf())return 0;var n=e.aabb.GetPerimeter();return n+=t.GetAreaNode(e.child1),n+=t.GetAreaNode(e.child2)}},{key:"GetMaxBalanceNode",value:function(t,e){if(null===t)return e;if(t.height<=1)return e;var n=Vt(t.child1),r=Vt(t.child2),i=_(r.height-n.height);return v(e,i)}},{key:"ShiftOriginNode",value:function(e,n){if(null!==e&&!(e.height<=1)){var r=e.child1,i=e.child2;t.ShiftOriginNode(r,n),t.ShiftOriginNode(i,n),e.aabb.lowerBound.SelfSub(n),e.aabb.upperBound.SelfSub(n)}}}]),t}();Tt.s_r=new E,Tt.s_v=new E,Tt.s_abs_v=new E,Tt.s_segmentAABB=new wt,Tt.s_subInput=new bt,Tt.s_combinedAABB=new wt,Tt.s_aabb=new wt,Tt.s_node_id=0;var Mt=function t(e,n){u(this,t),this.proxyA=e,this.proxyB=n},It=function(){function t(){u(this,t),this.m_tree=new Tt,this.m_proxyCount=0,this.m_moveCount=0,this.m_moveBuffer=[],this.m_pairCount=0,this.m_pairBuffer=[]}return l(t,[{key:"CreateProxy",value:function(t,e){var n=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(n),n}},{key:"DestroyProxy",value:function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)}},{key:"MoveProxy",value:function(t,e,n){this.m_tree.MoveProxy(t,e,n)&&this.BufferMove(t)}},{key:"TouchProxy",value:function(t){this.BufferMove(t)}},{key:"GetProxyCount",value:function(){return this.m_proxyCount}},{key:"UpdatePairs",value:function(t){var e=this;this.m_pairCount=0;for(var n=function(t){var n=e.m_moveBuffer[t];if(null===n)return"continue";var r=n.aabb;e.m_tree.Query(r,(function(t){if(t.m_id===n.m_id)return!0;var r,i;if(t.m_idf+.002){e.state=t.b2TOIOutputState.e_separated,e.t=l,w=!0;break}if(k>f-.002){h=S;break}var P=x.Evaluate(A[0],B[0],h);if(Pf?(E=M,P=I):(T=M,k=I),50===V)break}if(t.b2_toiMaxRootIters=v(t.b2_toiMaxRootIters,V),++C===a)break}if(++m,++t.b2_toiIters,w)break;if(20===m){e.state=t.b2TOIOutputState.e_failed,e.t=h;break}}t.b2_toiMaxIters=v(t.b2_toiMaxIters,m);var O=r.GetMilliseconds();t.b2_toiMaxTime=v(t.b2_toiMaxTime,O),t.b2_toiTime+=O}var re=new E,ie=new E;function oe(e,n,r,i,o){e.pointCount=0;var a=D.MulXV(r,n.m_p,re),s=D.MulXV(o,i.m_p,ie),u=E.DistanceSquaredVV(a,s),l=n.m_radius+i.m_radius;u>l*l||(e.type=t.b2ManifoldType.e_circles,e.localPoint.Copy(n.m_p),e.localNormal.SetZero(),e.pointCount=1,e.points[0].localPoint.Copy(i.m_p),e.points[0].id.key=0)}var ae=new E,se=new E,ue=new E;function le(e,r,i,o,a){e.pointCount=0;for(var s=D.MulXV(a,o.m_p,ae),u=D.MulTXV(i,s,se),l=0,c=-n,f=r.m_radius+o.m_radius,h=r.m_count,m=r.m_vertices,d=r.m_normals,p=0;pf)return;_>c&&(c=_,l=p)}var y=l,v=(y+1)%h,g=m[y],b=m[v];if(c<1e-5)return e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(d[l]),E.MidVV(g,b,e.localPoint),e.points[0].localPoint.Copy(o.m_p),void(e.points[0].id.key=0);var x=E.DotVV(E.SubVV(u,g,E.s_t0),E.SubVV(b,g,E.s_t1)),w=E.DotVV(E.SubVV(u,b,E.s_t0),E.SubVV(g,b,E.s_t1));if(x<=0){if(E.DistanceSquaredVV(u,g)>f*f)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,E.SubVV(u,g,e.localNormal).SelfNormalize(),e.localPoint.Copy(g),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else if(w<=0){if(E.DistanceSquaredVV(u,b)>f*f)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,E.SubVV(u,b,e.localNormal).SelfNormalize(),e.localPoint.Copy(b),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else{var S=E.MidVV(g,b,ue);if(E.DotVV(E.SubVV(u,S,E.s_t1),d[y])>f)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(d[y]).SelfNormalize(),e.localPoint.Copy(S),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}}var ce=new E,fe=new E,he=new E,me=new E;function de(t,e,r,i,o){for(var a=t.m_vertices,s=t.m_normals,u=i.m_count,l=i.m_vertices,c=R.MulRV(e.q,s[r],ce),f=R.MulTRV(o.q,c,fe),h=0,m=n,d=0;df&&(f=m,c=h)}var d=de(e,r,c,i,o),p=(c+a-1)%a,_=de(e,r,p,i,o),y=(c+1)%a,v=de(e,r,y,i,o),g=0,b=0,x=0;if(_>d&&_>v)x=-1,g=p,b=_;else{if(!(v>d))return t[0]=c,d;x=1,g=y,b=v}for(;(d=de(e,r,c=-1===x?(g+a-1)%a:(g+1)%a,i,o))>b;)g=c,b=d;return t[0]=g,b}var ve=new E,ge=gt.MakeArray(2),be=gt.MakeArray(2),xe=gt.MakeArray(2),we=[0],Se=[0],Ce=new E,Ae=new E,Be=new E,ke=new E,Pe=new E,Ve=new E,Ee=new E,Te=new E;function Me(e,r,i,o,a){e.pointCount=0;var s=r.m_radius+o.m_radius,u=we;u[0]=0;var l=ye(u,r,i,o,a);if(!(l>s)){var c=Se;c[0]=0;var f=ye(c,o,a,r,i);if(!(f>s)){var h,m,d,p,_=0,y=0;f>.98*l+.001?(h=o,m=r,d=a,p=i,_=c[0],e.type=t.b2ManifoldType.e_faceB,y=1):(h=r,m=o,d=i,p=a,_=u[0],e.type=t.b2ManifoldType.e_faceA,y=0);var v=ge;!function(e,r,i,o,a,s){for(var u=r.m_normals,l=a.m_count,c=a.m_vertices,f=a.m_normals,h=R.MulTRV(s.q,R.MulRV(i.q,u[o],E.s_t0),ve),m=0,d=n,p=0;ph*h)return;if(n.m_hasVertex0){var _=n.m_vertex0,y=s,v=E.SubVV(y,_,De);if(E.DotVV(v,E.SubVV(y,a,E.s_t0))>0)return}return m.cf.indexA=0,m.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(d),e.points[0].id.Copy(m),void e.points[0].localPoint.Copy(i.m_p)}if(c<=0){var g=u,b=E.SubVV(a,g,Re);if(E.DotVV(b,b)>h*h)return;if(n.m_hasVertex3){var x=n.m_vertex3,w=u,S=E.SubVV(x,w,je);if(E.DotVV(S,E.SubVV(a,w,E.s_t0))>0)return}return m.cf.indexA=1,m.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(g),e.points[0].id.Copy(m),void e.points[0].localPoint.Copy(i.m_p)}var C=E.DotVV(l,l),A=Le;A.x=1/C*(c*s.x+f*u.x),A.y=1/C*(c*s.y+f*u.y);var B=E.SubVV(a,A,Re);if(!(E.DotVV(B,B)>h*h)){var k=Fe.Set(-l.y,l.x);E.DotVV(k,E.SubVV(a,s,E.s_t0))<0&&k.Set(-k.x,-k.y),k.Normalize(),m.cf.indexA=0,m.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(k),e.localPoint.Copy(s),e.points[0].id.Copy(m),e.points[0].localPoint.Copy(i.m_p)}}var ze=function t(){u(this,t),this.type=0,this.index=0,this.separation=0},qe=function t(){u(this,t),this.vertices=[],this.normals=[],this.count=0},Ue=function(){function e(){u(this,e),this.m_polygonB=new qe,this.m_xf=new D,this.m_centroidB=new E,this.m_v0=new E,this.m_v1=new E,this.m_v2=new E,this.m_v3=new E,this.m_normal0=new E,this.m_normal1=new E,this.m_normal2=new E,this.m_normal=new E,this.m_type1=0,this.m_type2=0,this.m_lowerLimit=new E,this.m_upperLimit=new E,this.m_radius=0,this.m_front=!1}return l(e,[{key:"Collide",value:function(n,r,i,o,a){D.MulTXX(i,a,this.m_xf),D.MulXV(this.m_xf,o.m_centroid,this.m_centroidB),this.m_v0.Copy(r.m_vertex0),this.m_v1.Copy(r.m_vertex1),this.m_v2.Copy(r.m_vertex2),this.m_v3.Copy(r.m_vertex3);var s=r.m_hasVertex0,u=r.m_hasVertex3,l=E.SubVV(this.m_v2,this.m_v1,e.s_edge1);l.Normalize(),this.m_normal1.Set(l.y,-l.x);var c=E.DotVV(this.m_normal1,E.SubVV(this.m_centroidB,this.m_v1,E.s_t0)),f=0,h=0,m=!1,d=!1;if(s){var p=E.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),m=E.CrossVV(p,l)>=0,f=E.DotVV(this.m_normal0,E.SubVV(this.m_centroidB,this.m_v0,E.s_t0))}if(u){var _=E.SubVV(this.m_v3,this.m_v2,e.s_edge2);_.Normalize(),this.m_normal2.Set(_.y,-_.x),d=E.CrossVV(l,_)>0,h=E.DotVV(this.m_normal2,E.SubVV(this.m_centroidB,this.m_v2,E.s_t0))}s&&u?m&&d?(this.m_front=f>=0||c>=0||h>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):m?(this.m_front=f>=0||c>=0&&h>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):d?(this.m_front=h>=0||f>=0&&c>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):(this.m_front=f>=0&&c>=0&&h>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):s?m?(this.m_front=f>=0||c>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):(this.m_front=f>=0&&c>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):u?d?(this.m_front=c>=0||h>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=c>=0&&h>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=c>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1))),this.m_polygonB.count=o.m_count;for(var y=0;ythis.m_radius)){var g=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(0!==g.type&&g.separation>this.m_radius)){var b;b=0===g.type?v:g.separation>.98*v.separation+.001?g:v;var x=e.s_ie,w=e.s_rf;if(1===b.type){n.type=t.b2ManifoldType.e_faceA;for(var S=0,C=E.DotVV(this.m_normal,this.m_polygonB.normals[0]),A=1;Athis.m_radius)return r.type=2,r.index=o,r.separation=l,r;if(E.DotVV(a,i)>=0){if(E.DotVV(E.SubVV(a,this.m_upperLimit,E.s_t0),this.m_normal)<-f)continue}else if(E.DotVV(E.SubVV(a,this.m_lowerLimit,E.s_t0),this.m_normal)<-f)continue;l>r.separation&&(r.type=2,r.index=o,r.separation=l)}return r}}]),e}();Ue.s_edge1=new E,Ue.s_edge0=new E,Ue.s_edge2=new E,Ue.s_ie=gt.MakeArray(2),Ue.s_rf=new(function(){return function t(){u(this,t),this.i1=0,this.i2=0,this.v1=new E,this.v2=new E,this.normal=new E,this.sideNormal1=new E,this.sideOffset1=0,this.sideNormal2=new E,this.sideOffset2=0}}()),Ue.s_clipPoints1=gt.MakeArray(2),Ue.s_clipPoints2=gt.MakeArray(2),Ue.s_edgeAxis=new ze,Ue.s_polygonAxis=new ze,Ue.s_n=new E,Ue.s_perp=new E;var We=new Ue;function Je(t,e,n,r,i){We.Collide(t,e,n,r,i)}var He,Xe,$e,Ye,Ze,Ke,Qe=function t(){u(this,t),this.mass=0,this.center=new E(0,0),this.I=0};(He=t.b2ShapeType||(t.b2ShapeType={}))[He.e_unknown=-1]="e_unknown",He[He.e_circleShape=0]="e_circleShape",He[He.e_edgeShape=1]="e_edgeShape",He[He.e_polygonShape=2]="e_polygonShape",He[He.e_chainShape=3]="e_chainShape",He[He.e_shapeTypeCount=4]="e_shapeTypeCount";var tn=function(){function e(n,r){u(this,e),this.m_type=t.b2ShapeType.e_unknown,this.m_radius=0,this.m_type=n,this.m_radius=r}return l(e,[{key:"Copy",value:function(t){return this.m_radius=t.m_radius,this}},{key:"GetType",value:function(){return this.m_type}}]),e}(),en=function(e){a(r,e);var n=s(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return u(this,r),(e=n.call(this,t.b2ShapeType.e_circleShape,i)).m_p=new E,e}return l(r,[{key:"Set",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.m_radius;return this.m_p.Copy(t),this.m_radius=e,this}},{key:"Clone",value:function(){return(new r).Copy(this)}},{key:"Copy",value:function(t){return o(i(r.prototype),"Copy",this).call(this,t),this.m_p.Copy(t.m_p),this}},{key:"GetChildCount",value:function(){return 1}},{key:"TestPoint",value:function(t,e){var n=D.MulXV(t,this.m_p,r.TestPoint_s_center),i=E.SubVV(e,n,r.TestPoint_s_d);return E.DotVV(i,i)<=x(this.m_radius)}},{key:"ComputeDistance",value:function(t,e,n,i){var o=D.MulXV(t,this.m_p,r.ComputeDistance_s_center);return E.SubVV(e,o,n),n.Normalize()-this.m_radius}},{key:"RayCast",value:function(t,e,n,i){var o=D.MulXV(n,this.m_p,r.RayCast_s_position),a=E.SubVV(e.p1,o,r.RayCast_s_s),s=E.DotVV(a,a)-x(this.m_radius),u=E.SubVV(e.p2,e.p1,r.RayCast_s_r),l=E.DotVV(a,u),c=E.DotVV(u,u),f=l*l-c*s;if(f<0||c<1e-5)return!1;var h=-(l+S(f));return 0<=h&&h<=e.maxFraction*c&&(h/=c,t.fraction=h,E.AddVMulSV(a,h,u,t.normal).SelfNormalize(),!0)}},{key:"ComputeAABB",value:function(t,e,n){var i=D.MulXV(e,this.m_p,r.ComputeAABB_s_p);t.lowerBound.Set(i.x-this.m_radius,i.y-this.m_radius),t.upperBound.Set(i.x+this.m_radius,i.y+this.m_radius)}},{key:"ComputeMass",value:function(t,e){var n=x(this.m_radius);t.mass=e*c*n,t.center.Copy(this.m_p),t.I=t.mass*(.5*n+E.DotVV(this.m_p,this.m_p))}},{key:"SetupDistanceProxy",value:function(t,e){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_p),t.m_count=1,t.m_radius=this.m_radius}},{key:"ComputeSubmergedArea",value:function(t,e,n,r){var i=D.MulXV(n,this.m_p,new E),o=-(E.DotVV(t,i)-e);if(o<1e-5-this.m_radius)return 0;if(o>this.m_radius)return r.Copy(i),c*this.m_radius*this.m_radius;var a=this.m_radius*this.m_radius,s=o*o,u=a*(P(o/this.m_radius)+c/2)+o*S(a-s),l=-2/3*C(a-s,1.5)/u;return r.x=i.x+t.x*l,r.y=i.y+t.y*l,u}},{key:"Dump",value:function(t){t(" const shape: b2CircleShape = new b2CircleShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_p.Set(%.15f, %.15f);\n",this.m_p.x,this.m_p.y)}}]),r}(tn);en.TestPoint_s_center=new E,en.TestPoint_s_d=new E,en.ComputeDistance_s_center=new E,en.RayCast_s_position=new E,en.RayCast_s_s=new E,en.RayCast_s_r=new E,en.ComputeAABB_s_p=new E;var nn=function(e){a(c,e);var r=s(c);function c(){var e;return u(this,c),(e=r.call(this,t.b2ShapeType.e_polygonShape,.016)).m_centroid=new E(0,0),e.m_vertices=[],e.m_normals=[],e.m_count=0,e}return l(c,[{key:"Clone",value:function(){return(new c).Copy(this)}},{key:"Copy",value:function(t){o(i(c.prototype),"Copy",this).call(this,t),this.m_centroid.Copy(t.m_centroid),this.m_count=t.m_count,this.m_vertices=E.MakeArray(this.m_count),this.m_normals=E.MakeArray(this.m_count);for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:t.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(e<3)return this.SetAsBox(1,1);for(var r=e,i=[],o=0;of||m===f&&i[h].yg.LengthSquared()&&(y=v)}else y=v;if(++p,_=y,y===l)break}this.m_count=p,this.m_vertices=E.MakeArray(this.m_count),this.m_normals=E.MakeArray(this.m_count);for(var w=0;w1&&void 0!==arguments[1]?arguments[1]:t.length;return this.Set(t,e)}},{key:"SetAsBox",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(this.m_count=4,this.m_vertices=E.MakeArray(this.m_count),this.m_normals=E.MakeArray(this.m_count),this.m_vertices[0].Set(-t,-e),this.m_vertices[1].Set(t,-e),this.m_vertices[2].Set(t,e),this.m_vertices[3].Set(-t,e),this.m_normals[0].Set(0,-1),this.m_normals[1].Set(1,0),this.m_normals[2].Set(0,1),this.m_normals[3].Set(-1,0),this.m_centroid.SetZero(),n){this.m_centroid.Copy(n);var i=new D;i.SetPosition(n),i.SetRotationAngle(r);for(var o=0;o0)return!1;return!0}},{key:"ComputeDistance",value:function(t,e,r,i){for(var o=D.MulTXV(t,e,c.ComputeDistance_s_pLocal),a=-n,s=c.ComputeDistance_s_normalForMaxDistance.Copy(o),u=0;ua&&(a=l,s.Copy(this.m_normals[u]))}if(a>0){for(var f=c.ComputeDistance_s_minDistance.Copy(s),h=a*a,m=0;mp&&(f.Copy(d),h=p)}return R.MulRV(t.q,f,r),r.Normalize(),Math.sqrt(h)}return R.MulRV(t.q,s,r),a}},{key:"RayCast",value:function(t,e,n,r){for(var i=D.MulTXV(n,e.p1,c.RayCast_s_p1),o=D.MulTXV(n,e.p2,c.RayCast_s_p2),a=E.SubVV(o,i,c.RayCast_s_d),s=0,u=e.maxFraction,l=-1,f=0;f0&&h=0&&(t.fraction=s,R.MulRV(n.q,this.m_normals[l],t.normal),!0)}},{key:"ComputeAABB",value:function(t,e,n){for(var r=D.MulXV(e,this.m_vertices[0],t.lowerBound),i=t.upperBound.Copy(r),o=0;o0&&(m?f||(u=h-1,s++):f&&(l=h-1,s++)),f=m}switch(s){case 0:if(f){var d=c.ComputeSubmergedArea_s_md;return this.ComputeMass(d,1),D.MulXV(n,d.center,r),d.mass}return 0;case 1:-1===u?u=this.m_count-1:l=this.m_count-1}for(var p,_=(u+1)%this.m_count,y=(l+1)%this.m_count,v=(0-a[u])/(a[_]-a[u]),g=(0-a[l])/(a[y]-a[l]),b=c.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[u].x*(1-v)+this.m_vertices[_].x*v,this.m_vertices[u].y*(1-v)+this.m_vertices[_].y*v),x=c.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[l].x*(1-g)+this.m_vertices[y].x*g,this.m_vertices[l].y*(1-g)+this.m_vertices[y].y*g),w=0,S=c.ComputeSubmergedArea_s_center.SetZero(),C=this.m_vertices[_],A=_;A!==y;){p=(A=(A+1)%this.m_count)===y?x:this.m_vertices[A];var B=.5*((C.x-b.x)*(p.y-b.y)-(C.y-b.y)*(p.x-b.x));w+=B,S.x+=B*(b.x+C.x+p.x)/3,S.y+=B*(b.y+C.y+p.y)/3,C=p}return S.SelfMul(1/w),D.MulXV(n,S,r),w}},{key:"Dump",value:function(t){t(" const shape: b2PolygonShape = new b2PolygonShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e0){var c=E.DotVV(u,u);l>c?E.SubVV(e,a,s):s.SelfMulSub(l/c,u)}return n.Copy(s),n.Normalize()}},{key:"RayCast",value:function(t,e,n,i){var o=D.MulTXV(n,e.p1,r.RayCast_s_p1),a=D.MulTXV(n,e.p2,r.RayCast_s_p2),s=E.SubVV(a,o,r.RayCast_s_d),u=this.m_vertex1,l=this.m_vertex2,c=E.SubVV(l,u,r.RayCast_s_e),f=t.normal.Set(c.y,-c.x).SelfNormalize(),h=E.DotVV(f,E.SubVV(u,o,E.s_t0)),m=E.DotVV(f,s);if(0===m)return!1;var d=h/m;if(d<0||e.maxFraction0&&t.normal.SelfNeg(),0))}},{key:"ComputeAABB",value:function(t,e,n){var i=D.MulXV(e,this.m_vertex1,r.ComputeAABB_s_v1),o=D.MulXV(e,this.m_vertex2,r.ComputeAABB_s_v2);E.MinV(i,o,t.lowerBound),E.MaxV(i,o,t.upperBound);var a=this.m_radius;t.lowerBound.SelfSubXY(a,a),t.upperBound.SelfAddXY(a,a)}},{key:"ComputeMass",value:function(t,e){t.mass=0,E.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0}},{key:"SetupDistanceProxy",value:function(t,e){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertex1),t.m_vertices[1].Copy(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius}},{key:"ComputeSubmergedArea",value:function(t,e,n,r){return r.SetZero(),0}},{key:"Dump",value:function(t){t(" const shape: b2EdgeShape = new b2EdgeShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y),t(" shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y),t(" shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y),t(" shape.m_vertex3.Set(%.15f, %.15f);\n",this.m_vertex3.x,this.m_vertex3.y),t(" shape.m_hasVertex0 = %s;\n",this.m_hasVertex0),t(" shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)}}]),r}(tn);rn.ComputeDistance_s_v1=new E,rn.ComputeDistance_s_v2=new E,rn.ComputeDistance_s_d=new E,rn.ComputeDistance_s_s=new E,rn.RayCast_s_p1=new E,rn.RayCast_s_p2=new E,rn.RayCast_s_d=new E,rn.RayCast_s_e=new E,rn.RayCast_s_q=new E,rn.RayCast_s_r=new E,rn.ComputeAABB_s_v1=new E,rn.ComputeAABB_s_v2=new E;var on=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2ShapeType.e_chainShape,.016)).m_vertices=[],e.m_count=0,e.m_prevVertex=new E,e.m_nextVertex=new E,e.m_hasPrevVertex=!1,e.m_hasNextVertex=!1,e}return l(r,[{key:"CreateLoop",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(e<3)return this;this.m_count=e+1,this.m_vertices=E.MakeArray(this.m_count);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:t.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.m_count=e,this.m_vertices=E.MakeArray(e);for(var r=0;r0?(e.m_vertex0.Copy(this.m_vertices[n-1]),e.m_hasVertex0=!0):(e.m_vertex0.Copy(this.m_prevVertex),e.m_hasVertex0=this.m_hasPrevVertex),n0&&void 0!==arguments[0]?arguments[0]:new Qe;return this.m_shape.ComputeMass(t,this.m_density),t}},{key:"SetDensity",value:function(t){this.m_density=t}},{key:"GetDensity",value:function(){return this.m_density}},{key:"GetFriction",value:function(){return this.m_friction}},{key:"SetFriction",value:function(t){this.m_friction=t}},{key:"GetRestitution",value:function(){return this.m_restitution}},{key:"SetRestitution",value:function(t){this.m_restitution=t}},{key:"GetAABB",value:function(t){return this.m_proxies[t].aabb}},{key:"Dump",value:function(t,e){t(" const fd: b2FixtureDef = new b2FixtureDef();\n"),t(" fd.friction = %.15f;\n",this.m_friction),t(" fd.restitution = %.15f;\n",this.m_restitution),t(" fd.density = %.15f;\n",this.m_density),t(" fd.isSensor = %s;\n",this.m_isSensor?"true":"false"),t(" fd.filter.categoryBits = %d;\n",this.m_filter.categoryBits),t(" fd.filter.maskBits = %d;\n",this.m_filter.maskBits),t(" fd.filter.groupIndex = %d;\n",this.m_filter.groupIndex),this.m_shape.Dump(t),t("\n"),t(" fd.shape = shape;\n"),t("\n"),t(" bodies[%d].CreateFixture(fd);\n",e)}},{key:"Create",value:function(t){var n=this;this.m_userData=t.userData,this.m_friction=e(t.friction,.2),this.m_restitution=e(t.restitution,0),this.m_next=null,this.m_filter.Copy(e(t.filter,an.DEFAULT)),this.m_isSensor=e(t.isSensor,!1),this.m_proxies=d(this.m_shape.GetChildCount(),(function(t){return new un(n)})),this.m_proxyCount=0,this.m_density=e(t.density,0)}},{key:"Destroy",value:function(){}},{key:"CreateProxies",value:function(t){var e=this.m_body.m_world.m_contactManager.m_broadPhase;this.m_proxyCount=this.m_shape.GetChildCount();for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:0;return t instanceof tn?this.CreateFixtureShapeDensity(t,e):this.CreateFixtureDef(t)}},{key:"CreateFixtureDef",value:function(t){if(this.m_world.IsLocked())throw new Error;var e=new ln(t,this);return e.Create(t),this.m_activeFlag&&e.CreateProxies(this.m_xf),e.m_next=this.m_fixtureList,this.m_fixtureList=e,++this.m_fixtureCount,e.m_density>0&&this.ResetMassData(),this.m_world.m_newFixture=!0,e}},{key:"CreateFixtureShapeDensity",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=n.CreateFixtureShapeDensity_s_def;return r.shape=t,r.density=e,this.CreateFixtureDef(r)}},{key:"DestroyFixture",value:function(t){if(this.m_world.IsLocked())throw new Error;for(var e=this.m_fixtureList,n=null;null!==e;){if(e===t){n?n.m_next=t.m_next:this.m_fixtureList=t.m_next;break}n=e,e=e.m_next}for(var r=this.m_contactList;r;){var i=r.contact;r=r.next;var o=i.GetFixtureA(),a=i.GetFixtureB();t!==o&&t!==a||this.m_world.m_contactManager.Destroy(i)}this.m_activeFlag&&t.DestroyProxies(),t.m_next=null,t.Destroy(),--this.m_fixtureCount,this.ResetMassData()}},{key:"SetTransformVec",value:function(t,e){this.SetTransformXY(t.x,t.y,e)}},{key:"SetTransformXY",value:function(t,e,n){if(this.m_world.IsLocked())throw new Error;this.m_xf.q.SetAngle(n),this.m_xf.p.Set(t,e),this.m_xf0.Copy(this.m_xf),D.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=n,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=n;for(var r=this.m_fixtureList;r;r=r.m_next)r.Synchronize(this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()}},{key:"SetTransform",value:function(t){this.SetTransformVec(t.p,t.GetAngle())}},{key:"GetTransform",value:function(){return this.m_xf}},{key:"GetPosition",value:function(){return this.m_xf.p}},{key:"SetPosition",value:function(t){this.SetTransformVec(t,this.GetAngle())}},{key:"SetPositionXY",value:function(t,e){this.SetTransformXY(t,e,this.GetAngle())}},{key:"GetAngle",value:function(){return this.m_sweep.a}},{key:"SetAngle",value:function(t){this.SetTransformVec(this.GetPosition(),t)}},{key:"GetWorldCenter",value:function(){return this.m_sweep.c}},{key:"GetLocalCenter",value:function(){return this.m_sweep.localCenter}},{key:"SetLinearVelocity",value:function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(E.DotVV(e,e)>0&&this.SetAwake(!0),this.m_linearVelocity.Copy(e))}},{key:"GetLinearVelocity",value:function(){return this.m_linearVelocity}},{key:"SetAngularVelocity",value:function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(e*e>0&&this.SetAwake(!0),this.m_angularVelocity=e)}},{key:"GetAngularVelocity",value:function(){return this.m_angularVelocity}},{key:"GetDefinition",value:function(t){return t.type=this.GetType(),t.allowSleep=this.m_autoSleepFlag,t.angle=this.GetAngle(),t.angularDamping=this.m_angularDamping,t.gravityScale=this.m_gravityScale,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=this.m_fixedRotationFlag,t.bullet=this.m_bulletFlag,t.awake=this.m_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.Copy(this.GetLinearVelocity()),t.position.Copy(this.GetPosition()),t.userData=this.GetUserData(),t}},{key:"ApplyForce",value:function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.m_type===t.b2BodyType.b2_dynamicBody&&(r&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(n.x-this.m_sweep.c.x)*e.y-(n.y-this.m_sweep.c.y)*e.x))}},{key:"ApplyForceToCenter",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y))}},{key:"ApplyTorque",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_torque+=e))}},{key:"ApplyLinearImpulse",value:function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.m_type===t.b2BodyType.b2_dynamicBody&&(r&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((n.x-this.m_sweep.c.x)*e.y-(n.y-this.m_sweep.c.y)*e.x)))}},{key:"ApplyLinearImpulseToCenter",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y))}},{key:"ApplyAngularImpulse",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*e))}},{key:"GetMass",value:function(){return this.m_mass}},{key:"GetInertia",value:function(){return this.m_I+this.m_mass*E.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter)}},{key:"GetMassData",value:function(t){return t.mass=this.m_mass,t.I=this.m_I+this.m_mass*E.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center.Copy(this.m_sweep.localCenter),t}},{key:"SetMassData",value:function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type===t.b2BodyType.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&!this.m_fixedRotationFlag&&(this.m_I=e.I-this.m_mass*E.DotVV(e.center,e.center),this.m_invI=1/this.m_I);var r=n.SetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e.center),D.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),E.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,E.SubVV(this.m_sweep.c,r,E.s_t0),this.m_linearVelocity)}}},{key:"ResetMassData",value:function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type===t.b2BodyType.b2_staticBody||this.m_type===t.b2BodyType.b2_kinematicBody)return this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);for(var e=n.ResetMassData_s_localCenter.SetZero(),r=this.m_fixtureList;r;r=r.m_next)if(0!==r.m_density){var i=r.GetMassData(n.ResetMassData_s_massData);this.m_mass+=i.mass,e.x+=i.center.x*i.mass,e.y+=i.center.y*i.mass,this.m_I+=i.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&!this.m_fixedRotationFlag?(this.m_I-=this.m_mass*E.DotVV(e,e),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var o=n.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e),D.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),E.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,E.SubVV(this.m_sweep.c,o,E.s_t0),this.m_linearVelocity)}},{key:"GetWorldPoint",value:function(t,e){return D.MulXV(this.m_xf,t,e)}},{key:"GetWorldVector",value:function(t,e){return R.MulRV(this.m_xf.q,t,e)}},{key:"GetLocalPoint",value:function(t,e){return D.MulTXV(this.m_xf,t,e)}},{key:"GetLocalVector",value:function(t,e){return R.MulTRV(this.m_xf.q,t,e)}},{key:"GetLinearVelocityFromWorldPoint",value:function(t,e){return E.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,E.SubVV(t,this.m_sweep.c,E.s_t0),e)}},{key:"GetLinearVelocityFromLocalPoint",value:function(t,e){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t,e),e)}},{key:"GetLinearDamping",value:function(){return this.m_linearDamping}},{key:"SetLinearDamping",value:function(t){this.m_linearDamping=t}},{key:"GetAngularDamping",value:function(){return this.m_angularDamping}},{key:"SetAngularDamping",value:function(t){this.m_angularDamping=t}},{key:"GetGravityScale",value:function(){return this.m_gravityScale}},{key:"SetGravityScale",value:function(t){this.m_gravityScale=t}},{key:"SetType",value:function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type!==e){this.m_type=e,this.ResetMassData(),this.m_type===t.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var n=this.m_contactList;n;){var r=n;n=n.next,this.m_world.m_contactManager.Destroy(r.contact)}this.m_contactList=null;for(var i=this.m_fixtureList;i;i=i.m_next)i.TouchProxies()}}},{key:"GetType",value:function(){return this.m_type}},{key:"SetBullet",value:function(t){this.m_bulletFlag=t}},{key:"IsBullet",value:function(){return this.m_bulletFlag}},{key:"SetSleepingAllowed",value:function(t){this.m_autoSleepFlag=t,t||this.SetAwake(!0)}},{key:"IsSleepingAllowed",value:function(){return this.m_autoSleepFlag}},{key:"SetAwake",value:function(t){t?(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)}},{key:"IsAwake",value:function(){return this.m_awakeFlag}},{key:"SetActive",value:function(t){if(this.m_world.IsLocked())throw new Error;if(t!==this.IsActive())if(this.m_activeFlag=t,t)for(var e=this.m_fixtureList;e;e=e.m_next)e.CreateProxies(this.m_xf);else{for(var n=this.m_fixtureList;n;n=n.m_next)n.DestroyProxies();for(var r=this.m_contactList;r;){var i=r;r=r.next,this.m_world.m_contactManager.Destroy(i.contact)}this.m_contactList=null}}},{key:"IsActive",value:function(){return this.m_activeFlag}},{key:"SetFixedRotation",value:function(t){this.m_fixedRotationFlag!==t&&(this.m_fixedRotationFlag=t,this.m_angularVelocity=0,this.ResetMassData())}},{key:"IsFixedRotation",value:function(){return this.m_fixedRotationFlag}},{key:"GetFixtureList",value:function(){return this.m_fixtureList}},{key:"GetJointList",value:function(){return this.m_jointList}},{key:"GetContactList",value:function(){return this.m_contactList}},{key:"GetNext",value:function(){return this.m_next}},{key:"GetUserData",value:function(){return this.m_userData}},{key:"SetUserData",value:function(t){this.m_userData=t}},{key:"GetWorld",value:function(){return this.m_world}},{key:"Dump",value:function(e){var n=this.m_islandIndex;e("{\n"),e(" const bd: b2BodyDef = new b2BodyDef();\n");var r="";switch(this.m_type){case t.b2BodyType.b2_staticBody:r="b2BodyType.b2_staticBody";break;case t.b2BodyType.b2_kinematicBody:r="b2BodyType.b2_kinematicBody";break;case t.b2BodyType.b2_dynamicBody:r="b2BodyType.b2_dynamicBody"}e(" bd.type = %s;\n",r),e(" bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y),e(" bd.angle = %.15f;\n",this.m_sweep.a),e(" bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y),e(" bd.angularVelocity = %.15f;\n",this.m_angularVelocity),e(" bd.linearDamping = %.15f;\n",this.m_linearDamping),e(" bd.angularDamping = %.15f;\n",this.m_angularDamping),e(" bd.allowSleep = %s;\n",this.m_autoSleepFlag?"true":"false"),e(" bd.awake = %s;\n",this.m_awakeFlag?"true":"false"),e(" bd.fixedRotation = %s;\n",this.m_fixedRotationFlag?"true":"false"),e(" bd.bullet = %s;\n",this.m_bulletFlag?"true":"false"),e(" bd.active = %s;\n",this.m_activeFlag?"true":"false"),e(" bd.gravityScale = %.15f;\n",this.m_gravityScale),e("\n"),e(" bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex),e("\n");for(var i=this.m_fixtureList;i;i=i.m_next)e(" {\n"),i.Dump(e,n),e(" }\n");e("}\n")}},{key:"SynchronizeFixtures",value:function(){var t=n.SynchronizeFixtures_s_xf1;t.q.SetAngle(this.m_sweep.a0),R.MulRV(t.q,this.m_sweep.localCenter,t.p),E.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=this.m_fixtureList;e;e=e.m_next)e.Synchronize(t,this.m_xf)}},{key:"SynchronizeTransform",value:function(){this.m_xf.q.SetAngle(this.m_sweep.a),R.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),E.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)}},{key:"ShouldCollide",value:function(e){return(this.m_type!==t.b2BodyType.b2_staticBody||e.m_type!==t.b2BodyType.b2_staticBody)&&this.ShouldCollideConnected(e)}},{key:"ShouldCollideConnected",value:function(t){for(var e=this.m_jointList;e;e=e.next)if(e.other===t&&!e.joint.m_collideConnected)return!1;return!0}},{key:"Advance",value:function(t){this.m_sweep.Advance(t),this.m_sweep.c.Copy(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.SetAngle(this.m_sweep.a),R.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),E.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)}},{key:"GetControllerList",value:function(){return this.m_controllerList}},{key:"GetControllerCount",value:function(){return this.m_controllerCount}}]),n}();cn.CreateFixtureShapeDensity_s_def=new sn,cn.SetMassData_s_oldCenter=new E,cn.ResetMassData_s_localCenter=new E,cn.ResetMassData_s_oldCenter=new E,cn.ResetMassData_s_massData=new Qe,cn.SynchronizeFixtures_s_xf1=new D,(Ye=t.b2JointType||(t.b2JointType={}))[Ye.e_unknownJoint=0]="e_unknownJoint",Ye[Ye.e_revoluteJoint=1]="e_revoluteJoint",Ye[Ye.e_prismaticJoint=2]="e_prismaticJoint",Ye[Ye.e_distanceJoint=3]="e_distanceJoint",Ye[Ye.e_pulleyJoint=4]="e_pulleyJoint",Ye[Ye.e_mouseJoint=5]="e_mouseJoint",Ye[Ye.e_gearJoint=6]="e_gearJoint",Ye[Ye.e_wheelJoint=7]="e_wheelJoint",Ye[Ye.e_weldJoint=8]="e_weldJoint",Ye[Ye.e_frictionJoint=9]="e_frictionJoint",Ye[Ye.e_ropeJoint=10]="e_ropeJoint",Ye[Ye.e_motorJoint=11]="e_motorJoint",Ye[Ye.e_areaJoint=12]="e_areaJoint",($e=t.b2LimitState||(t.b2LimitState={}))[$e.e_inactiveLimit=0]="e_inactiveLimit",$e[$e.e_atLowerLimit=1]="e_atLowerLimit",$e[$e.e_atUpperLimit=2]="e_atUpperLimit",$e[$e.e_equalLimits=3]="e_equalLimits";var fn=function t(e,n){u(this,t),this.prev=null,this.next=null,this.joint=e,this.other=n},hn=function e(n){u(this,e),this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=n},mn=function(){function n(r){u(this,n),this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_index=0,this.m_islandFlag=!1,this.m_collideConnected=!1,this.m_userData=null,this.m_type=r.type,this.m_edgeA=new fn(this,r.bodyB),this.m_edgeB=new fn(this,r.bodyA),this.m_bodyA=r.bodyA,this.m_bodyB=r.bodyB,this.m_collideConnected=e(r.collideConnected,!1),this.m_userData=r.userData}return l(n,[{key:"GetType",value:function(){return this.m_type}},{key:"GetBodyA",value:function(){return this.m_bodyA}},{key:"GetBodyB",value:function(){return this.m_bodyB}},{key:"GetNext",value:function(){return this.m_next}},{key:"GetUserData",value:function(){return this.m_userData}},{key:"SetUserData",value:function(t){this.m_userData=t}},{key:"IsActive",value:function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()}},{key:"GetCollideConnected",value:function(){return this.m_collideConnected}},{key:"Dump",value:function(t){t("// Dump is not supported for this joint type.\n")}},{key:"ShiftOrigin",value:function(t){}}]),n}(),dn=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_distanceJoint)).localAnchorA=new E,e.localAnchorB=new E,e.length=1,e.frequencyHz=0,e.dampingRatio=0,e}return l(r,[{key:"Initialize",value:function(t,e,n,r){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(r,this.localAnchorB),this.length=E.DistanceVV(n,r),this.frequencyHz=0,this.dampingRatio=0}}]),r}(hn),pn=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_frequencyHz=0,i.m_dampingRatio=0,i.m_bias=0,i.m_localAnchorA=new E,i.m_localAnchorB=new E,i.m_gamma=0,i.m_impulse=0,i.m_length=0,i.m_indexA=0,i.m_indexB=0,i.m_u=new E,i.m_rA=new E,i.m_rB=new E,i.m_localCenterA=new E,i.m_localCenterB=new E,i.m_invMassA=0,i.m_invMassB=0,i.m_invIA=0,i.m_invIB=0,i.m_mass=0,i.m_qA=new R,i.m_qB=new R,i.m_lalcA=new E,i.m_lalcB=new E,i.m_frequencyHz=e(t.frequencyHz,0),i.m_dampingRatio=e(t.dampingRatio,0),i.m_localAnchorA.Copy(t.localAnchorA),i.m_localAnchorB.Copy(t.localAnchorB),i.m_length=t.length,i}return l(r,[{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*this.m_impulse*this.m_u.x,e.y=t*this.m_impulse*this.m_u.y,e}},{key:"GetReactionTorque",value:function(t){return 0}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"SetLength",value:function(t){this.m_length=t}},{key:"Length",value:function(){return this.m_length}},{key:"SetFrequency",value:function(t){this.m_frequencyHz=t}},{key:"GetFrequency",value:function(){return this.m_frequencyHz}},{key:"SetDampingRatio",value:function(t){this.m_dampingRatio=t}},{key:"GetDampingRatio",value:function(){return this.m_dampingRatio}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.length = %.15f;\n",this.m_length),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}},{key:"InitVelocityConstraints",value:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,o=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,u=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,f=this.m_qA.SetAngle(n),h=this.m_qB.SetAngle(s);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),R.MulRV(f,this.m_lalcA,this.m_rA),E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),R.MulRV(h,this.m_lalcB,this.m_rB),this.m_u.x=a.x+this.m_rB.x-e.x-this.m_rA.x,this.m_u.y=a.y+this.m_rB.y-e.y-this.m_rA.y;var m=this.m_u.Length();m>.008?this.m_u.SelfMul(1/m):this.m_u.SetZero();var d=E.CrossVV(this.m_rA,this.m_u),p=E.CrossVV(this.m_rB,this.m_u),_=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=0!==_?1/_:0,this.m_frequencyHz>0){var y=m-this.m_length,v=2*c*this.m_frequencyHz,g=2*this.m_mass*this.m_dampingRatio*v,b=this.m_mass*v*v,x=t.step.dt;this.m_gamma=x*(g+x*b),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*x*b*this.m_gamma,_+=this.m_gamma,this.m_mass=0!==_?1/_:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var w=E.MulSV(this.m_impulse,this.m_u,r.InitVelocityConstraints_s_P);i.SelfMulSub(this.m_invMassA,w),o-=this.m_invIA*E.CrossVV(this.m_rA,w),u.SelfMulAdd(this.m_invMassB,w),l+=this.m_invIB*E.CrossVV(this.m_rB,w)}else this.m_impulse=0;t.velocities[this.m_indexA].w=o,t.velocities[this.m_indexB].w=l}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,i=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=E.AddVCrossSV(e,n,this.m_rA,r.SolveVelocityConstraints_s_vpA),s=E.AddVCrossSV(i,o,this.m_rB,r.SolveVelocityConstraints_s_vpB),u=E.DotVV(this.m_u,E.SubVV(s,a,E.s_t0)),l=-this.m_mass*(u+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=l;var c=E.MulSV(l,this.m_u,r.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,c),n-=this.m_invIA*E.CrossVV(this.m_rA,c),i.SelfMulAdd(this.m_invMassB,c),o+=this.m_invIB*E.CrossVV(this.m_rB,c),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o}},{key:"SolvePositionConstraints",value:function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,i=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),s=this.m_qB.SetAngle(o),u=R.MulRV(a,this.m_lalcA,this.m_rA),l=R.MulRV(s,this.m_lalcB,this.m_rB),c=this.m_u;c.x=i.x+l.x-e.x-u.x,c.y=i.y+l.y-e.y-u.y;var f=this.m_u.Normalize()-this.m_length;f=g(f,-.2,.2);var h=-this.m_mass*f,m=E.MulSV(h,c,r.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),n-=this.m_invIA*E.CrossVV(u,m),i.SelfMulAdd(this.m_invMassB,m),o+=this.m_invIB*E.CrossVV(l,m),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=o,_(f)<.008}}]),r}(mn);pn.InitVelocityConstraints_s_P=new E,pn.SolveVelocityConstraints_s_vpA=new E,pn.SolveVelocityConstraints_s_vpB=new E,pn.SolveVelocityConstraints_s_P=new E,pn.SolvePositionConstraints_s_P=new E;var _n=function(t){a(r,t);var n=s(r);function r(t){var i;u(this,r),(i=n.call(this,t)).m_frequencyHz=0,i.m_dampingRatio=0,i.m_impulse=0,i.m_targetArea=0,i.m_bodies=t.bodies,i.m_frequencyHz=e(t.frequencyHz,0),i.m_dampingRatio=e(t.dampingRatio,0),i.m_targetLengths=p(t.bodies.length),i.m_normals=E.MakeArray(t.bodies.length),i.m_joints=[],i.m_deltas=E.MakeArray(t.bodies.length),i.m_delta=new E;var o=new dn;o.frequencyHz=i.m_frequencyHz,o.dampingRatio=i.m_dampingRatio,i.m_targetArea=0;for(var a=0;ax(.2)&&_.SelfMul(.2/S(y)),y>x(.008)&&(f=!1),d.x+=_.x,d.y+=_.y}return f}}]),r}(mn),yn=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_localAnchorA=new E,i.m_localAnchorB=new E,i.m_linearImpulse=new E,i.m_angularImpulse=0,i.m_maxForce=0,i.m_maxTorque=0,i.m_indexA=0,i.m_indexB=0,i.m_rA=new E,i.m_rB=new E,i.m_localCenterA=new E,i.m_localCenterB=new E,i.m_invMassA=0,i.m_invMassB=0,i.m_invIA=0,i.m_invIB=0,i.m_linearMass=new I,i.m_angularMass=0,i.m_qA=new R,i.m_qB=new R,i.m_lalcA=new E,i.m_lalcB=new E,i.m_K=new I,i.m_localAnchorA.Copy(t.localAnchorA),i.m_localAnchorB.Copy(t.localAnchorB),i.m_linearImpulse.SetZero(),i.m_maxForce=e(t.maxForce,0),i.m_maxTorque=e(t.maxTorque,0),i.m_linearMass.SetZero(),i}return l(r,[{key:"InitVelocityConstraints",value:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,i=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v,a=t.velocities[this.m_indexB].w,s=this.m_qA.SetAngle(e),u=this.m_qB.SetAngle(i);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=R.MulRV(s,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c=R.MulRV(u,this.m_lalcB,this.m_rB),f=this.m_invMassA,h=this.m_invMassB,m=this.m_invIA,d=this.m_invIB,p=this.m_K;if(p.ex.x=f+h+m*l.y*l.y+d*c.y*c.y,p.ex.y=-m*l.x*l.y-d*c.x*c.y,p.ey.x=p.ex.y,p.ey.y=f+h+m*l.x*l.x+d*c.x*c.x,p.GetInverse(this.m_linearMass),this.m_angularMass=m+d,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var _=this.m_linearImpulse;n.SelfMulSub(f,_),r-=m*(E.CrossVV(this.m_rA,_)+this.m_angularImpulse),o.SelfMulAdd(h,_),a+=d*(E.CrossVV(this.m_rB,_)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=a}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,i=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=this.m_invMassA,s=this.m_invMassB,u=this.m_invIA,l=this.m_invIB,c=t.step.dt,f=o-n,h=-this.m_angularMass*f,m=this.m_angularImpulse,d=c*this.m_maxTorque;this.m_angularImpulse=g(this.m_angularImpulse+h,-d,d),n-=u*(h=this.m_angularImpulse-m),o+=l*h;var p=E.SubVV(E.AddVCrossSV(i,o,this.m_rB,E.s_t0),E.AddVCrossSV(e,n,this.m_rA,E.s_t1),r.SolveVelocityConstraints_s_Cdot_v2),_=I.MulMV(this.m_linearMass,p,r.SolveVelocityConstraints_s_impulseV).SelfNeg(),y=r.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(_);var v=c*this.m_maxForce;this.m_linearImpulse.LengthSquared()>v*v&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(v)),E.SubVV(this.m_linearImpulse,y,_),e.SelfMulSub(a,_),n-=u*E.CrossVV(this.m_rA,_),i.SelfMulAdd(s,_),o+=l*E.CrossVV(this.m_rB,_),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o}},{key:"SolvePositionConstraints",value:function(t){return!0}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*this.m_linearImpulse.x,e.y=t*this.m_linearImpulse.y,e}},{key:"GetReactionTorque",value:function(t){return t*this.m_angularImpulse}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"SetMaxForce",value:function(t){this.m_maxForce=t}},{key:"GetMaxForce",value:function(){return this.m_maxForce}},{key:"SetMaxTorque",value:function(t){this.m_maxTorque=t}},{key:"GetMaxTorque",value:function(){return this.m_maxTorque}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),r}(mn);yn.SolveVelocityConstraints_s_Cdot_v2=new E,yn.SolveVelocityConstraints_s_impulseV=new E,yn.SolveVelocityConstraints_s_oldImpulseV=new E;var vn=function(n){a(i,n);var r=s(i);function i(n){var o,a,s;u(this,i),(o=r.call(this,n)).m_typeA=t.b2JointType.e_unknownJoint,o.m_typeB=t.b2JointType.e_unknownJoint,o.m_localAnchorA=new E,o.m_localAnchorB=new E,o.m_localAnchorC=new E,o.m_localAnchorD=new E,o.m_localAxisC=new E,o.m_localAxisD=new E,o.m_referenceAngleA=0,o.m_referenceAngleB=0,o.m_constant=0,o.m_ratio=0,o.m_impulse=0,o.m_indexA=0,o.m_indexB=0,o.m_indexC=0,o.m_indexD=0,o.m_lcA=new E,o.m_lcB=new E,o.m_lcC=new E,o.m_lcD=new E,o.m_mA=0,o.m_mB=0,o.m_mC=0,o.m_mD=0,o.m_iA=0,o.m_iB=0,o.m_iC=0,o.m_iD=0,o.m_JvAC=new E,o.m_JvBD=new E,o.m_JwA=0,o.m_JwB=0,o.m_JwC=0,o.m_JwD=0,o.m_mass=0,o.m_qA=new R,o.m_qB=new R,o.m_qC=new R,o.m_qD=new R,o.m_lalcA=new E,o.m_lalcB=new E,o.m_lalcC=new E,o.m_lalcD=new E,o.m_joint1=n.joint1,o.m_joint2=n.joint2,o.m_typeA=o.m_joint1.GetType(),o.m_typeB=o.m_joint2.GetType(),o.m_bodyC=o.m_joint1.GetBodyA(),o.m_bodyA=o.m_joint1.GetBodyB();var l=o.m_bodyA.m_xf,c=o.m_bodyA.m_sweep.a,f=o.m_bodyC.m_xf,h=o.m_bodyC.m_sweep.a;if(o.m_typeA===t.b2JointType.e_revoluteJoint){var m=n.joint1;o.m_localAnchorC.Copy(m.m_localAnchorA),o.m_localAnchorA.Copy(m.m_localAnchorB),o.m_referenceAngleA=m.m_referenceAngle,o.m_localAxisC.SetZero(),a=c-h-o.m_referenceAngleA}else{var d=n.joint1;o.m_localAnchorC.Copy(d.m_localAnchorA),o.m_localAnchorA.Copy(d.m_localAnchorB),o.m_referenceAngleA=d.m_referenceAngle,o.m_localAxisC.Copy(d.m_localXAxisA);var p=o.m_localAnchorC,_=R.MulTRV(f.q,E.AddVV(R.MulRV(l.q,o.m_localAnchorA,E.s_t0),E.SubVV(l.p,f.p,E.s_t1),E.s_t0),E.s_t0);a=E.DotVV(E.SubVV(_,p,E.s_t0),o.m_localAxisC)}o.m_bodyD=o.m_joint2.GetBodyA(),o.m_bodyB=o.m_joint2.GetBodyB();var y=o.m_bodyB.m_xf,v=o.m_bodyB.m_sweep.a,g=o.m_bodyD.m_xf,b=o.m_bodyD.m_sweep.a;if(o.m_typeB===t.b2JointType.e_revoluteJoint){var x=n.joint2;o.m_localAnchorD.Copy(x.m_localAnchorA),o.m_localAnchorB.Copy(x.m_localAnchorB),o.m_referenceAngleB=x.m_referenceAngle,o.m_localAxisD.SetZero(),s=v-b-o.m_referenceAngleB}else{var w=n.joint2;o.m_localAnchorD.Copy(w.m_localAnchorA),o.m_localAnchorB.Copy(w.m_localAnchorB),o.m_referenceAngleB=w.m_referenceAngle,o.m_localAxisD.Copy(w.m_localXAxisA);var S=o.m_localAnchorD,C=R.MulTRV(g.q,E.AddVV(R.MulRV(y.q,o.m_localAnchorB,E.s_t0),E.SubVV(y.p,g.p,E.s_t1),E.s_t0),E.s_t0);s=E.DotVV(E.SubVV(C,S,E.s_t0),o.m_localAxisD)}return o.m_ratio=e(n.ratio,1),o.m_constant=a+o.m_ratio*s,o.m_impulse=0,o}return l(i,[{key:"InitVelocityConstraints",value:function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var n=e.positions[this.m_indexA].a,r=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].a,s=e.velocities[this.m_indexB].v,u=e.velocities[this.m_indexB].w,l=e.positions[this.m_indexC].a,c=e.velocities[this.m_indexC].v,f=e.velocities[this.m_indexC].w,h=e.positions[this.m_indexD].a,m=e.velocities[this.m_indexD].v,d=e.velocities[this.m_indexD].w,p=this.m_qA.SetAngle(n),_=this.m_qB.SetAngle(a),y=this.m_qC.SetAngle(l),v=this.m_qD.SetAngle(h);if(this.m_mass=0,this.m_typeA===t.b2JointType.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var g=R.MulRV(y,this.m_localAxisC,i.InitVelocityConstraints_s_u);E.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var b=R.MulRV(y,this.m_lalcC,i.InitVelocityConstraints_s_rC);E.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var x=R.MulRV(p,this.m_lalcA,i.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(g),this.m_JwC=E.CrossVV(b,g),this.m_JwA=E.CrossVV(x,g),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB===t.b2JointType.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{var w=R.MulRV(v,this.m_localAxisD,i.InitVelocityConstraints_s_u);E.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var S=R.MulRV(v,this.m_lalcD,i.InitVelocityConstraints_s_rD);E.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var C=R.MulRV(_,this.m_lalcB,i.InitVelocityConstraints_s_rB);E.MulSV(this.m_ratio,w,this.m_JvBD),this.m_JwD=this.m_ratio*E.CrossVV(S,w),this.m_JwB=this.m_ratio*E.CrossVV(C,w),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,e.step.warmStarting?(r.SelfMulAdd(this.m_mA*this.m_impulse,this.m_JvAC),o+=this.m_iA*this.m_impulse*this.m_JwA,s.SelfMulAdd(this.m_mB*this.m_impulse,this.m_JvBD),u+=this.m_iB*this.m_impulse*this.m_JwB,c.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),f-=this.m_iC*this.m_impulse*this.m_JwC,m.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),d-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=u,e.velocities[this.m_indexC].w=f,e.velocities[this.m_indexD].w=d}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,i=t.velocities[this.m_indexB].w,o=t.velocities[this.m_indexC].v,a=t.velocities[this.m_indexC].w,s=t.velocities[this.m_indexD].v,u=t.velocities[this.m_indexD].w,l=E.DotVV(this.m_JvAC,E.SubVV(e,o,E.s_t0))+E.DotVV(this.m_JvBD,E.SubVV(r,s,E.s_t0));l+=this.m_JwA*n-this.m_JwC*a+(this.m_JwB*i-this.m_JwD*u);var c=-this.m_mass*l;this.m_impulse+=c,e.SelfMulAdd(this.m_mA*c,this.m_JvAC),n+=this.m_iA*c*this.m_JwA,r.SelfMulAdd(this.m_mB*c,this.m_JvBD),i+=this.m_iB*c*this.m_JwB,o.SelfMulSub(this.m_mC*c,this.m_JvAC),a-=this.m_iC*c*this.m_JwC,s.SelfMulSub(this.m_mD*c,this.m_JvBD),u-=this.m_iD*c*this.m_JwD,t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=i,t.velocities[this.m_indexC].w=a,t.velocities[this.m_indexD].w=u}},{key:"SolvePositionConstraints",value:function(e){var n,r,o,a,s,u,l=e.positions[this.m_indexA].c,c=e.positions[this.m_indexA].a,f=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,m=e.positions[this.m_indexC].c,d=e.positions[this.m_indexC].a,p=e.positions[this.m_indexD].c,_=e.positions[this.m_indexD].a,y=this.m_qA.SetAngle(c),v=this.m_qB.SetAngle(h),g=this.m_qC.SetAngle(d),b=this.m_qD.SetAngle(_),x=this.m_JvAC,w=this.m_JvBD,S=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)x.SetZero(),o=1,s=1,S+=this.m_iA+this.m_iC,n=c-d-this.m_referenceAngleA;else{var C=R.MulRV(g,this.m_localAxisC,i.SolvePositionConstraints_s_u),A=R.MulRV(g,this.m_lalcC,i.SolvePositionConstraints_s_rC),B=R.MulRV(y,this.m_lalcA,i.SolvePositionConstraints_s_rA);x.Copy(C),s=E.CrossVV(A,C),o=E.CrossVV(B,C),S+=this.m_mC+this.m_mA+this.m_iC*s*s+this.m_iA*o*o;var k=this.m_lalcC,P=R.MulTRV(g,E.AddVV(B,E.SubVV(l,m,E.s_t0),E.s_t0),E.s_t0);n=E.DotVV(E.SubVV(P,k,E.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)w.SetZero(),a=this.m_ratio,u=this.m_ratio,S+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),r=h-_-this.m_referenceAngleB;else{var V=R.MulRV(b,this.m_localAxisD,i.SolvePositionConstraints_s_u),T=R.MulRV(b,this.m_lalcD,i.SolvePositionConstraints_s_rD),M=R.MulRV(v,this.m_lalcB,i.SolvePositionConstraints_s_rB);E.MulSV(this.m_ratio,V,w),u=this.m_ratio*E.CrossVV(T,V),a=this.m_ratio*E.CrossVV(M,V),S+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*u*u+this.m_iB*a*a;var I=this.m_lalcD,O=R.MulTRV(b,E.AddVV(M,E.SubVV(f,p,E.s_t0),E.s_t0),E.s_t0);r=E.DotVV(E.SubVV(O,I,E.s_t0),this.m_localAxisD)}var D=n+this.m_ratio*r-this.m_constant,j=0;return S>0&&(j=-D/S),l.SelfMulAdd(this.m_mA*j,x),c+=this.m_iA*j*o,f.SelfMulAdd(this.m_mB*j,w),h+=this.m_iB*j*a,m.SelfMulSub(this.m_mC*j,x),d-=this.m_iC*j*s,p.SelfMulSub(this.m_mD*j,w),_-=this.m_iD*j*u,e.positions[this.m_indexA].a=c,e.positions[this.m_indexB].a=h,e.positions[this.m_indexC].a=d,e.positions[this.m_indexD].a=_,!0}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return E.MulSV(t*this.m_impulse,this.m_JvAC,e)}},{key:"GetReactionTorque",value:function(t){return t*this.m_impulse*this.m_JwA}},{key:"GetJoint1",value:function(){return this.m_joint1}},{key:"GetJoint2",value:function(){return this.m_joint2}},{key:"GetRatio",value:function(){return this.m_ratio}},{key:"SetRatio",value:function(t){this.m_ratio=t}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex,r=this.m_joint1.m_index,i=this.m_joint2.m_index;t(" const jd: b2GearJointDef = new b2GearJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.joint1 = joints[%d];\n",r),t(" jd.joint2 = joints[%d];\n",i),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),i}(mn);vn.InitVelocityConstraints_s_u=new E,vn.InitVelocityConstraints_s_rA=new E,vn.InitVelocityConstraints_s_rB=new E,vn.InitVelocityConstraints_s_rC=new E,vn.InitVelocityConstraints_s_rD=new E,vn.SolvePositionConstraints_s_u=new E,vn.SolvePositionConstraints_s_rA=new E,vn.SolvePositionConstraints_s_rB=new E,vn.SolvePositionConstraints_s_rC=new E,vn.SolvePositionConstraints_s_rD=new E;var gn=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_linearOffset=new E,i.m_angularOffset=0,i.m_linearImpulse=new E,i.m_angularImpulse=0,i.m_maxForce=0,i.m_maxTorque=0,i.m_correctionFactor=.3,i.m_indexA=0,i.m_indexB=0,i.m_rA=new E,i.m_rB=new E,i.m_localCenterA=new E,i.m_localCenterB=new E,i.m_linearError=new E,i.m_angularError=0,i.m_invMassA=0,i.m_invMassB=0,i.m_invIA=0,i.m_invIB=0,i.m_linearMass=new I,i.m_angularMass=0,i.m_qA=new R,i.m_qB=new R,i.m_K=new I,i.m_linearOffset.Copy(e(t.linearOffset,E.ZERO)),i.m_linearImpulse.SetZero(),i.m_maxForce=e(t.maxForce,0),i.m_maxTorque=e(t.maxTorque,0),i.m_correctionFactor=e(t.correctionFactor,.3),i}return l(r,[{key:"GetAnchorA",value:function(t){var e=this.m_bodyA.GetPosition();return t.x=e.x,t.y=e.y,t}},{key:"GetAnchorB",value:function(t){var e=this.m_bodyB.GetPosition();return t.x=e.x,t.y=e.y,t}},{key:"GetReactionForce",value:function(t,e){return E.MulSV(t,this.m_linearImpulse,e)}},{key:"GetReactionTorque",value:function(t){return t*this.m_angularImpulse}},{key:"SetLinearOffset",value:function(t){E.IsEqualToV(t,this.m_linearOffset)||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Copy(t))}},{key:"GetLinearOffset",value:function(){return this.m_linearOffset}},{key:"SetAngularOffset",value:function(t){t!==this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=t)}},{key:"GetAngularOffset",value:function(){return this.m_angularOffset}},{key:"SetMaxForce",value:function(t){this.m_maxForce=t}},{key:"GetMaxForce",value:function(){return this.m_maxForce}},{key:"SetMaxTorque",value:function(t){this.m_maxTorque=t}},{key:"GetMaxTorque",value:function(){return this.m_maxTorque}},{key:"InitVelocityConstraints",value:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c,a=t.positions[this.m_indexB].a,s=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,l=this.m_qA.SetAngle(n),c=this.m_qB.SetAngle(a),f=R.MulRV(l,E.SubVV(this.m_linearOffset,this.m_localCenterA,E.s_t0),this.m_rA),h=R.MulRV(c,E.NegV(this.m_localCenterB,E.s_t0),this.m_rB),m=this.m_invMassA,d=this.m_invMassB,p=this.m_invIA,_=this.m_invIB,y=this.m_K;if(y.ex.x=m+d+p*f.y*f.y+_*h.y*h.y,y.ex.y=-p*f.x*f.y-_*h.x*h.y,y.ey.x=y.ex.y,y.ey.y=m+d+p*f.x*f.x+_*h.x*h.x,y.GetInverse(this.m_linearMass),this.m_angularMass=p+_,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),E.SubVV(E.AddVV(o,h,E.s_t0),E.AddVV(e,f,E.s_t1),this.m_linearError),this.m_angularError=a-n-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var v=this.m_linearImpulse;r.SelfMulSub(m,v),i-=p*(E.CrossVV(f,v)+this.m_angularImpulse),s.SelfMulAdd(d,v),u+=_*(E.CrossVV(h,v)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=u}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,i=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=this.m_invMassA,s=this.m_invMassB,u=this.m_invIA,l=this.m_invIB,c=t.step.dt,f=t.step.inv_dt,h=o-n+f*this.m_correctionFactor*this.m_angularError,m=-this.m_angularMass*h,d=this.m_angularImpulse,p=c*this.m_maxTorque;this.m_angularImpulse=g(this.m_angularImpulse+m,-p,p),n-=u*(m=this.m_angularImpulse-d),o+=l*m;var _=this.m_rA,y=this.m_rB,v=E.AddVV(E.SubVV(E.AddVV(i,E.CrossSV(o,y,E.s_t0),E.s_t0),E.AddVV(e,E.CrossSV(n,_,E.s_t1),E.s_t1),E.s_t2),E.MulSV(f*this.m_correctionFactor,this.m_linearError,E.s_t3),r.SolveVelocityConstraints_s_Cdot_v2),b=I.MulMV(this.m_linearMass,v,r.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),x=r.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(b);var w=c*this.m_maxForce;this.m_linearImpulse.LengthSquared()>w*w&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(w)),E.SubVV(this.m_linearImpulse,x,b),e.SelfMulSub(a,b),n-=u*E.CrossVV(_,b),i.SelfMulAdd(s,b),o+=l*E.CrossVV(y,b),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o}},{key:"SolvePositionConstraints",value:function(t){return!0}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y),t(" jd.angularOffset = %.15f;\n",this.m_angularOffset),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" jd.correctionFactor = %.15f;\n",this.m_correctionFactor),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),r}(mn);gn.SolveVelocityConstraints_s_Cdot_v2=new E,gn.SolveVelocityConstraints_s_impulse_v2=new E,gn.SolveVelocityConstraints_s_oldImpulse_v2=new E;var bn=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_localAnchorB=new E,i.m_targetA=new E,i.m_frequencyHz=0,i.m_dampingRatio=0,i.m_beta=0,i.m_impulse=new E,i.m_maxForce=0,i.m_gamma=0,i.m_indexA=0,i.m_indexB=0,i.m_rB=new E,i.m_localCenterB=new E,i.m_invMassB=0,i.m_invIB=0,i.m_mass=new I,i.m_C=new E,i.m_qB=new R,i.m_lalcB=new E,i.m_K=new I,i.m_targetA.Copy(e(t.target,E.ZERO)),D.MulTXV(i.m_bodyB.GetTransform(),i.m_targetA,i.m_localAnchorB),i.m_maxForce=e(t.maxForce,0),i.m_impulse.SetZero(),i.m_frequencyHz=e(t.frequencyHz,0),i.m_dampingRatio=e(t.dampingRatio,0),i.m_beta=0,i.m_gamma=0,i}return l(r,[{key:"SetTarget",value:function(t){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0),this.m_targetA.Copy(t)}},{key:"GetTarget",value:function(){return this.m_targetA}},{key:"SetMaxForce",value:function(t){this.m_maxForce=t}},{key:"GetMaxForce",value:function(){return this.m_maxForce}},{key:"SetFrequency",value:function(t){this.m_frequencyHz=t}},{key:"GetFrequency",value:function(){return this.m_frequencyHz}},{key:"SetDampingRatio",value:function(t){this.m_dampingRatio=t}},{key:"GetDampingRatio",value:function(){return this.m_dampingRatio}},{key:"InitVelocityConstraints",value:function(t){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexB].c,n=t.positions[this.m_indexB].a,r=t.velocities[this.m_indexB].v,i=t.velocities[this.m_indexB].w,o=this.m_qB.SetAngle(n),a=this.m_bodyB.GetMass(),s=2*c*this.m_frequencyHz,u=2*a*this.m_dampingRatio*s,l=a*(s*s),f=t.step.dt;this.m_gamma=f*(u+f*l),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=f*l*this.m_gamma,E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),R.MulRV(o,this.m_lalcB,this.m_rB);var h=this.m_K;h.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,h.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,h.ey.x=h.ex.y,h.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,h.GetInverse(this.m_mass),this.m_C.x=e.x+this.m_rB.x-this.m_targetA.x,this.m_C.y=e.y+this.m_rB.y-this.m_targetA.y,this.m_C.SelfMul(this.m_beta),i*=.98,t.step.warmStarting?(this.m_impulse.SelfMul(t.step.dtRatio),r.x+=this.m_invMassB*this.m_impulse.x,r.y+=this.m_invMassB*this.m_impulse.y,i+=this.m_invIB*E.CrossVV(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),t.velocities[this.m_indexB].w=i}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,i=E.AddVCrossSV(e,n,this.m_rB,r.SolveVelocityConstraints_s_Cdot),o=I.MulMV(this.m_mass,E.AddVV(i,E.AddVV(this.m_C,E.MulSV(this.m_gamma,this.m_impulse,E.s_t0),E.s_t0),E.s_t0).SelfNeg(),r.SolveVelocityConstraints_s_impulse),a=r.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);this.m_impulse.SelfAdd(o);var s=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>s*s&&this.m_impulse.SelfMul(s/this.m_impulse.Length()),E.SubVV(this.m_impulse,a,o),e.SelfMulAdd(this.m_invMassB,o),n+=this.m_invIB*E.CrossVV(this.m_rB,o),t.velocities[this.m_indexB].w=n}},{key:"SolvePositionConstraints",value:function(t){return!0}},{key:"GetAnchorA",value:function(t){return t.x=this.m_targetA.x,t.y=this.m_targetA.y,t}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return E.MulSV(t,this.m_impulse,e)}},{key:"GetReactionTorque",value:function(t){return 0}},{key:"Dump",value:function(t){t("Mouse joint dumping is not supported.\n")}},{key:"ShiftOrigin",value:function(t){this.m_targetA.SelfSub(t)}}]),r}(mn);bn.SolveVelocityConstraints_s_Cdot=new E,bn.SolveVelocityConstraints_s_impulse=new E,bn.SolveVelocityConstraints_s_oldImpulse=new E;var xn=function(n){a(i,n);var r=s(i);function i(n){var o;return u(this,i),(o=r.call(this,n)).m_localAnchorA=new E,o.m_localAnchorB=new E,o.m_localXAxisA=new E,o.m_localYAxisA=new E,o.m_referenceAngle=0,o.m_impulse=new M(0,0,0),o.m_motorImpulse=0,o.m_lowerTranslation=0,o.m_upperTranslation=0,o.m_maxMotorForce=0,o.m_motorSpeed=0,o.m_enableLimit=!1,o.m_enableMotor=!1,o.m_limitState=t.b2LimitState.e_inactiveLimit,o.m_indexA=0,o.m_indexB=0,o.m_localCenterA=new E,o.m_localCenterB=new E,o.m_invMassA=0,o.m_invMassB=0,o.m_invIA=0,o.m_invIB=0,o.m_axis=new E(0,0),o.m_perp=new E(0,0),o.m_s1=0,o.m_s2=0,o.m_a1=0,o.m_a2=0,o.m_K=new O,o.m_K3=new O,o.m_K2=new I,o.m_motorMass=0,o.m_qA=new R,o.m_qB=new R,o.m_lalcA=new E,o.m_lalcB=new E,o.m_rA=new E,o.m_rB=new E,o.m_localAnchorA.Copy(e(n.localAnchorA,E.ZERO)),o.m_localAnchorB.Copy(e(n.localAnchorB,E.ZERO)),o.m_localXAxisA.Copy(e(n.localAxisA,new E(1,0))).SelfNormalize(),E.CrossOneV(o.m_localXAxisA,o.m_localYAxisA),o.m_referenceAngle=e(n.referenceAngle,0),o.m_lowerTranslation=e(n.lowerTranslation,0),o.m_upperTranslation=e(n.upperTranslation,0),o.m_maxMotorForce=e(n.maxMotorForce,0),o.m_motorSpeed=e(n.motorSpeed,0),o.m_enableLimit=e(n.enableLimit,!1),o.m_enableMotor=e(n.enableMotor,!1),o}return l(i,[{key:"InitVelocityConstraints",value:function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var n=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,o=e.velocities[this.m_indexA].v,a=e.velocities[this.m_indexA].w,s=e.positions[this.m_indexB].c,u=e.positions[this.m_indexB].a,l=e.velocities[this.m_indexB].v,c=e.velocities[this.m_indexB].w,f=this.m_qA.SetAngle(r),h=this.m_qB.SetAngle(u);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var m=R.MulRV(f,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d=R.MulRV(h,this.m_lalcB,this.m_rB),p=E.AddVV(E.SubVV(s,n,E.s_t0),E.SubVV(d,m,E.s_t1),i.InitVelocityConstraints_s_d),y=this.m_invMassA,v=this.m_invMassB,g=this.m_invIA,b=this.m_invIB;if(R.MulRV(f,this.m_localXAxisA,this.m_axis),this.m_a1=E.CrossVV(E.AddVV(p,m,E.s_t0),this.m_axis),this.m_a2=E.CrossVV(d,this.m_axis),this.m_motorMass=y+v+g*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),R.MulRV(f,this.m_localYAxisA,this.m_perp),this.m_s1=E.CrossVV(E.AddVV(p,m,E.s_t0),this.m_perp),this.m_s2=E.CrossVV(d,this.m_perp),this.m_K.ex.x=y+v+g*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.ex.y=g*this.m_s1+b*this.m_s2,this.m_K.ex.z=g*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=g+b,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=g*this.m_a1+b*this.m_a2,this.m_K.ez.x=this.m_K.ex.z,this.m_K.ez.y=this.m_K.ey.z,this.m_K.ez.z=y+v+g*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2,this.m_enableLimit){var x=E.DotVV(this.m_axis,p);_(this.m_upperTranslation-this.m_lowerTranslation)<.016?this.m_limitState=t.b2LimitState.e_equalLimits:x<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):x>=this.m_upperTranslation?this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_limitState=t.b2LimitState.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0;if(this.m_enableMotor||(this.m_motorImpulse=0),e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var w=E.AddVV(E.MulSV(this.m_impulse.x,this.m_perp,E.s_t0),E.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,E.s_t1),i.InitVelocityConstraints_s_P),S=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,C=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;o.SelfMulSub(y,w),a-=g*S,l.SelfMulAdd(v,w),c+=b*C}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=a,e.velocities[this.m_indexB].w=c}},{key:"SolveVelocityConstraints",value:function(e){var n=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,o=e.velocities[this.m_indexB].v,a=e.velocities[this.m_indexB].w,s=this.m_invMassA,u=this.m_invMassB,l=this.m_invIA,c=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var f=E.DotVV(this.m_axis,E.SubVV(o,n,E.s_t0))+this.m_a2*a-this.m_a1*r,h=this.m_motorMass*(this.m_motorSpeed-f),m=this.m_motorImpulse,d=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=g(this.m_motorImpulse+h,-d,d),h=this.m_motorImpulse-m;var p=E.MulSV(h,this.m_axis,i.SolveVelocityConstraints_s_P),_=h*this.m_a1,b=h*this.m_a2;n.SelfMulSub(s,p),r-=l*_,o.SelfMulAdd(u,p),a+=c*b}var x=E.DotVV(this.m_perp,E.SubVV(o,n,E.s_t0))+this.m_s2*a-this.m_s1*r,w=a-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var S=E.DotVV(this.m_axis,E.SubVV(o,n,E.s_t0))+this.m_a2*a-this.m_a1*r,C=i.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),A=this.m_K.Solve33(-x,-w,-S,i.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(A),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=v(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=y(this.m_impulse.z,0));var B=-x-(this.m_impulse.z-C.z)*this.m_K.ez.x,k=-w-(this.m_impulse.z-C.z)*this.m_K.ez.y,P=this.m_K.Solve22(B,k,i.SolveVelocityConstraints_s_f2r);P.x+=C.x,P.y+=C.y,this.m_impulse.x=P.x,this.m_impulse.y=P.y,A.x=this.m_impulse.x-C.x,A.y=this.m_impulse.y-C.y,A.z=this.m_impulse.z-C.z;var V=E.AddVV(E.MulSV(A.x,this.m_perp,E.s_t0),E.MulSV(A.z,this.m_axis,E.s_t1),i.SolveVelocityConstraints_s_P),T=A.x*this.m_s1+A.y+A.z*this.m_a1,M=A.x*this.m_s2+A.y+A.z*this.m_a2;n.SelfMulSub(s,V),r-=l*T,o.SelfMulAdd(u,V),a+=c*M}else{var I=this.m_K.Solve22(-x,-w,i.SolveVelocityConstraints_s_df2);this.m_impulse.x+=I.x,this.m_impulse.y+=I.y;var O=E.MulSV(I.x,this.m_perp,i.SolveVelocityConstraints_s_P),R=I.x*this.m_s1+I.y,D=I.x*this.m_s2+I.y;n.SelfMulSub(s,O),r-=l*R,o.SelfMulAdd(u,O),a+=c*D}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=a}},{key:"SolvePositionConstraints",value:function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),s=this.m_qB.SetAngle(o),u=this.m_invMassA,l=this.m_invMassB,c=this.m_invIA,h=this.m_invIB,m=R.MulRV(a,this.m_lalcA,this.m_rA),d=R.MulRV(s,this.m_lalcB,this.m_rB),p=E.SubVV(E.AddVV(r,d,E.s_t0),E.AddVV(e,m,E.s_t1),i.SolvePositionConstraints_s_d),y=R.MulRV(a,this.m_localXAxisA,this.m_axis),b=E.CrossVV(E.AddVV(p,m,E.s_t0),y),x=E.CrossVV(d,y),w=R.MulRV(a,this.m_localYAxisA,this.m_perp),S=E.CrossVV(E.AddVV(p,m,E.s_t0),w),C=E.CrossVV(d,w),A=i.SolvePositionConstraints_s_impulse,B=E.DotVV(w,p),k=o-n-this.m_referenceAngle,P=_(B),V=_(k),T=!1,M=0;if(this.m_enableLimit){var I=E.DotVV(y,p);_(this.m_upperTranslation-this.m_lowerTranslation)<.016?(M=g(I,-.2,.2),P=v(P,_(I)),T=!0):I<=this.m_lowerTranslation?(M=g(I-this.m_lowerTranslation+.008,-.2,0),P=v(P,this.m_lowerTranslation-I),T=!0):I>=this.m_upperTranslation&&(M=g(I-this.m_upperTranslation-.008,0,.2),P=v(P,I-this.m_upperTranslation),T=!0)}if(T){var O=u+l+c*S*S+h*C*C,D=c*S+h*C,j=c*S*b+h*C*x,L=c+h;0===L&&(L=1);var F=c*b+h*x,G=u+l+c*b*b+h*x*x,N=this.m_K3;N.ex.SetXYZ(O,D,j),N.ey.SetXYZ(D,L,F),N.ez.SetXYZ(j,F,G),A=N.Solve33(-B,-k,-M,A)}else{var z=u+l+c*S*S+h*C*C,q=c*S+h*C,U=c+h;0===U&&(U=1);var W=this.m_K2;W.ex.Set(z,q),W.ey.Set(q,U);var J=W.Solve(-B,-k,i.SolvePositionConstraints_s_impulse1);A.x=J.x,A.y=J.y,A.z=0}var H=E.AddVV(E.MulSV(A.x,w,E.s_t0),E.MulSV(A.z,y,E.s_t1),i.SolvePositionConstraints_s_P),X=A.x*S+A.y+A.z*b,$=A.x*C+A.y+A.z*x;return e.SelfMulSub(u,H),n-=c*X,r.SelfMulAdd(l,H),o+=h*$,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=o,P<=.008&&V<=f}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e.y=t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y),e}},{key:"GetReactionTorque",value:function(t){return t*this.m_impulse.y}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"GetLocalAxisA",value:function(){return this.m_localXAxisA}},{key:"GetReferenceAngle",value:function(){return this.m_referenceAngle}},{key:"GetJointTranslation",value:function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,i.GetJointTranslation_s_pA),e=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,i.GetJointTranslation_s_pB),n=E.SubVV(e,t,i.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,i.GetJointTranslation_s_axis);return E.DotVV(n,r)}},{key:"GetJointSpeed",value:function(){var t=this.m_bodyA,e=this.m_bodyB;E.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var n=R.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var r=R.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),i=E.AddVV(t.m_sweep.c,n,E.s_t0),o=E.AddVV(e.m_sweep.c,r,E.s_t1),a=E.SubVV(o,i,E.s_t2),s=t.GetWorldVector(this.m_localXAxisA,this.m_axis),u=t.m_linearVelocity,l=e.m_linearVelocity,c=t.m_angularVelocity,f=e.m_angularVelocity;return E.DotVV(a,E.CrossSV(c,s,E.s_t0))+E.DotVV(s,E.SubVV(E.AddVCrossSV(l,f,r,E.s_t0),E.AddVCrossSV(u,c,n,E.s_t1),E.s_t0))}},{key:"IsLimitEnabled",value:function(){return this.m_enableLimit}},{key:"EnableLimit",value:function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)}},{key:"GetLowerLimit",value:function(){return this.m_lowerTranslation}},{key:"GetUpperLimit",value:function(){return this.m_upperTranslation}},{key:"SetLimits",value:function(t,e){t===this.m_lowerTranslation&&e===this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=e,this.m_impulse.z=0)}},{key:"IsMotorEnabled",value:function(){return this.m_enableMotor}},{key:"EnableMotor",value:function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)}},{key:"SetMotorSpeed",value:function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)}},{key:"GetMotorSpeed",value:function(){return this.m_motorSpeed}},{key:"SetMaxMotorForce",value:function(t){t!==this.m_maxMotorForce&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t)}},{key:"GetMaxMotorForce",value:function(){return this.m_maxMotorForce}},{key:"GetMotorForce",value:function(t){return t*this.m_motorImpulse}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation),t(" jd.upperTranslation = %.15f;\n",this.m_upperTranslation),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),i}(mn);xn.InitVelocityConstraints_s_d=new E,xn.InitVelocityConstraints_s_P=new E,xn.SolveVelocityConstraints_s_P=new E,xn.SolveVelocityConstraints_s_f2r=new E,xn.SolveVelocityConstraints_s_f1=new M,xn.SolveVelocityConstraints_s_df3=new M,xn.SolveVelocityConstraints_s_df2=new E,xn.SolvePositionConstraints_s_d=new E,xn.SolvePositionConstraints_s_impulse=new M,xn.SolvePositionConstraints_s_impulse1=new E,xn.SolvePositionConstraints_s_P=new E,xn.GetJointTranslation_s_pA=new E,xn.GetJointTranslation_s_pB=new E,xn.GetJointTranslation_s_d=new E,xn.GetJointTranslation_s_axis=new E;var wn=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_groundAnchorA=new E,i.m_groundAnchorB=new E,i.m_lengthA=0,i.m_lengthB=0,i.m_localAnchorA=new E,i.m_localAnchorB=new E,i.m_constant=0,i.m_ratio=0,i.m_impulse=0,i.m_indexA=0,i.m_indexB=0,i.m_uA=new E,i.m_uB=new E,i.m_rA=new E,i.m_rB=new E,i.m_localCenterA=new E,i.m_localCenterB=new E,i.m_invMassA=0,i.m_invMassB=0,i.m_invIA=0,i.m_invIB=0,i.m_mass=0,i.m_qA=new R,i.m_qB=new R,i.m_lalcA=new E,i.m_lalcB=new E,i.m_groundAnchorA.Copy(e(t.groundAnchorA,new E(-1,1))),i.m_groundAnchorB.Copy(e(t.groundAnchorB,new E(1,0))),i.m_localAnchorA.Copy(e(t.localAnchorA,new E(-1,0))),i.m_localAnchorB.Copy(e(t.localAnchorB,new E(1,0))),i.m_lengthA=e(t.lengthA,0),i.m_lengthB=e(t.lengthB,0),i.m_ratio=e(t.ratio,1),i.m_constant=e(t.lengthA,0)+i.m_ratio*e(t.lengthB,0),i.m_impulse=0,i}return l(r,[{key:"InitVelocityConstraints",value:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,o=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,u=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,c=this.m_qA.SetAngle(n),f=this.m_qB.SetAngle(s);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),R.MulRV(c,this.m_lalcA,this.m_rA),E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),R.MulRV(f,this.m_lalcB,this.m_rB),this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA),this.m_uB.Copy(a).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);var h=this.m_uA.Length(),m=this.m_uB.Length();h>.08?this.m_uA.SelfMul(1/h):this.m_uA.SetZero(),m>.08?this.m_uB.SelfMul(1/m):this.m_uB.SetZero();var d=E.CrossVV(this.m_rA,this.m_uA),p=E.CrossVV(this.m_rB,this.m_uB),_=this.m_invMassA+this.m_invIA*d*d,y=this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=_+this.m_ratio*this.m_ratio*y,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var v=E.MulSV(-this.m_impulse,this.m_uA,r.InitVelocityConstraints_s_PA),g=E.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,r.InitVelocityConstraints_s_PB);i.SelfMulAdd(this.m_invMassA,v),o+=this.m_invIA*E.CrossVV(this.m_rA,v),u.SelfMulAdd(this.m_invMassB,g),l+=this.m_invIB*E.CrossVV(this.m_rB,g)}else this.m_impulse=0;t.velocities[this.m_indexA].w=o,t.velocities[this.m_indexB].w=l}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,i=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=E.AddVCrossSV(e,n,this.m_rA,r.SolveVelocityConstraints_s_vpA),s=E.AddVCrossSV(i,o,this.m_rB,r.SolveVelocityConstraints_s_vpB),u=-E.DotVV(this.m_uA,a)-this.m_ratio*E.DotVV(this.m_uB,s),l=-this.m_mass*u;this.m_impulse+=l;var c=E.MulSV(-l,this.m_uA,r.SolveVelocityConstraints_s_PA),f=E.MulSV(-this.m_ratio*l,this.m_uB,r.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,c),n+=this.m_invIA*E.CrossVV(this.m_rA,c),i.SelfMulAdd(this.m_invMassB,f),o+=this.m_invIB*E.CrossVV(this.m_rB,f),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o}},{key:"SolvePositionConstraints",value:function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,i=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),s=this.m_qB.SetAngle(o);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=R.MulRV(a,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l=R.MulRV(s,this.m_lalcB,this.m_rB),c=this.m_uA.Copy(e).SelfAdd(u).SelfSub(this.m_groundAnchorA),f=this.m_uB.Copy(i).SelfAdd(l).SelfSub(this.m_groundAnchorB),h=c.Length(),m=f.Length();h>.08?c.SelfMul(1/h):c.SetZero(),m>.08?f.SelfMul(1/m):f.SetZero();var d=E.CrossVV(u,c),p=E.CrossVV(l,f),y=this.m_invMassA+this.m_invIA*d*d,v=this.m_invMassB+this.m_invIB*p*p,g=y+this.m_ratio*this.m_ratio*v;g>0&&(g=1/g);var b=this.m_constant-h-this.m_ratio*m,x=_(b),w=-g*b,S=E.MulSV(-w,c,r.SolvePositionConstraints_s_PA),C=E.MulSV(-this.m_ratio*w,f,r.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,S),n+=this.m_invIA*E.CrossVV(u,S),i.SelfMulAdd(this.m_invMassB,C),o+=this.m_invIB*E.CrossVV(l,C),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=o,x<.008}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*this.m_impulse*this.m_uB.x,e.y=t*this.m_impulse*this.m_uB.y,e}},{key:"GetReactionTorque",value:function(t){return 0}},{key:"GetGroundAnchorA",value:function(){return this.m_groundAnchorA}},{key:"GetGroundAnchorB",value:function(){return this.m_groundAnchorB}},{key:"GetLengthA",value:function(){return this.m_lengthA}},{key:"GetLengthB",value:function(){return this.m_lengthB}},{key:"GetRatio",value:function(){return this.m_ratio}},{key:"GetCurrentLengthA",value:function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,r.GetCurrentLengthA_s_p),e=this.m_groundAnchorA;return E.DistanceVV(t,e)}},{key:"GetCurrentLengthB",value:function(){var t=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,r.GetCurrentLengthB_s_p),e=this.m_groundAnchorB;return E.DistanceVV(t,e)}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2PulleyJointDef = new b2PulleyJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.groundAnchorA.Set(%.15f, %.15f);\n",this.m_groundAnchorA.x,this.m_groundAnchorA.y),t(" jd.groundAnchorB.Set(%.15f, %.15f);\n",this.m_groundAnchorB.x,this.m_groundAnchorB.y),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.lengthA = %.15f;\n",this.m_lengthA),t(" jd.lengthB = %.15f;\n",this.m_lengthB),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}},{key:"ShiftOrigin",value:function(t){this.m_groundAnchorA.SelfSub(t),this.m_groundAnchorB.SelfSub(t)}}]),r}(mn);wn.InitVelocityConstraints_s_PA=new E,wn.InitVelocityConstraints_s_PB=new E,wn.SolveVelocityConstraints_s_vpA=new E,wn.SolveVelocityConstraints_s_vpB=new E,wn.SolveVelocityConstraints_s_PA=new E,wn.SolveVelocityConstraints_s_PB=new E,wn.SolvePositionConstraints_s_PA=new E,wn.SolvePositionConstraints_s_PB=new E,wn.GetCurrentLengthA_s_p=new E,wn.GetCurrentLengthB_s_p=new E;var Sn=function(n){a(i,n);var r=s(i);function i(n){var o;return u(this,i),(o=r.call(this,n)).m_localAnchorA=new E,o.m_localAnchorB=new E,o.m_impulse=new M,o.m_motorImpulse=0,o.m_enableMotor=!1,o.m_maxMotorTorque=0,o.m_motorSpeed=0,o.m_enableLimit=!1,o.m_referenceAngle=0,o.m_lowerAngle=0,o.m_upperAngle=0,o.m_indexA=0,o.m_indexB=0,o.m_rA=new E,o.m_rB=new E,o.m_localCenterA=new E,o.m_localCenterB=new E,o.m_invMassA=0,o.m_invMassB=0,o.m_invIA=0,o.m_invIB=0,o.m_mass=new O,o.m_motorMass=0,o.m_limitState=t.b2LimitState.e_inactiveLimit,o.m_qA=new R,o.m_qB=new R,o.m_lalcA=new E,o.m_lalcB=new E,o.m_K=new I,o.m_localAnchorA.Copy(e(n.localAnchorA,E.ZERO)),o.m_localAnchorB.Copy(e(n.localAnchorB,E.ZERO)),o.m_referenceAngle=e(n.referenceAngle,0),o.m_impulse.SetZero(),o.m_motorImpulse=0,o.m_lowerAngle=e(n.lowerAngle,0),o.m_upperAngle=e(n.upperAngle,0),o.m_maxMotorTorque=e(n.maxMotorTorque,0),o.m_motorSpeed=e(n.motorSpeed,0),o.m_enableLimit=e(n.enableLimit,!1),o.m_enableMotor=e(n.enableMotor,!1),o.m_limitState=t.b2LimitState.e_inactiveLimit,o}return l(i,[{key:"InitVelocityConstraints",value:function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var n=e.positions[this.m_indexA].a,r=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].a,s=e.velocities[this.m_indexB].v,u=e.velocities[this.m_indexB].w,l=this.m_qA.SetAngle(n),c=this.m_qB.SetAngle(a);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),R.MulRV(l,this.m_lalcA,this.m_rA),E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),R.MulRV(c,this.m_lalcB,this.m_rB);var h=this.m_invMassA,m=this.m_invMassB,d=this.m_invIA,p=this.m_invIB,y=d+p===0;if(this.m_mass.ex.x=h+m+this.m_rA.y*this.m_rA.y*d+this.m_rB.y*this.m_rB.y*p,this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*d-this.m_rB.y*this.m_rB.x*p,this.m_mass.ez.x=-this.m_rA.y*d-this.m_rB.y*p,this.m_mass.ex.y=this.m_mass.ey.x,this.m_mass.ey.y=h+m+this.m_rA.x*this.m_rA.x*d+this.m_rB.x*this.m_rB.x*p,this.m_mass.ez.y=this.m_rA.x*d+this.m_rB.x*p,this.m_mass.ex.z=this.m_mass.ez.x,this.m_mass.ey.z=this.m_mass.ez.y,this.m_mass.ez.z=d+p,this.m_motorMass=d+p,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!y||(this.m_motorImpulse=0),this.m_enableLimit&&!y){var v=a-n-this.m_referenceAngle;_(this.m_upperAngle-this.m_lowerAngle)<2*f?this.m_limitState=t.b2LimitState.e_equalLimits:v<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):v>=this.m_upperAngle?(this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atUpperLimit):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit;if(e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var g=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(h,g),o-=d*(E.CrossVV(this.m_rA,g)+this.m_motorImpulse+this.m_impulse.z),s.SelfMulAdd(m,g),u+=p*(E.CrossVV(this.m_rB,g)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=u}},{key:"SolveVelocityConstraints",value:function(e){var n=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,o=e.velocities[this.m_indexB].v,a=e.velocities[this.m_indexB].w,s=this.m_invMassA,u=this.m_invMassB,l=this.m_invIA,c=this.m_invIB,f=l+c===0;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits&&!f){var h=a-r-this.m_motorSpeed,m=-this.m_motorMass*h,d=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=g(this.m_motorImpulse+m,-p,p),r-=l*(m=this.m_motorImpulse-d),a+=c*m}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!f){var _=E.SubVV(E.AddVCrossSV(o,a,this.m_rB,E.s_t0),E.AddVCrossSV(n,r,this.m_rA,E.s_t1),i.SolveVelocityConstraints_s_Cdot1),y=a-r,v=this.m_mass.Solve33(_.x,_.y,y,i.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(v);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+v.z<0){var b=-_.x+this.m_impulse.z*this.m_mass.ez.x,x=-_.y+this.m_impulse.z*this.m_mass.ez.y,w=this.m_mass.Solve22(b,x,i.SolveVelocityConstraints_s_reduced_v2);v.x=w.x,v.y=w.y,v.z=-this.m_impulse.z,this.m_impulse.x+=w.x,this.m_impulse.y+=w.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(v);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+v.z>0){var S=-_.x+this.m_impulse.z*this.m_mass.ez.x,C=-_.y+this.m_impulse.z*this.m_mass.ez.y,A=this.m_mass.Solve22(S,C,i.SolveVelocityConstraints_s_reduced_v2);v.x=A.x,v.y=A.y,v.z=-this.m_impulse.z,this.m_impulse.x+=A.x,this.m_impulse.y+=A.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(v);var B=i.SolveVelocityConstraints_s_P.Set(v.x,v.y);n.SelfMulSub(s,B),r-=l*(E.CrossVV(this.m_rA,B)+v.z),o.SelfMulAdd(u,B),a+=c*(E.CrossVV(this.m_rB,B)+v.z)}else{var k=E.SubVV(E.AddVCrossSV(o,a,this.m_rB,E.s_t0),E.AddVCrossSV(n,r,this.m_rA,E.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),P=this.m_mass.Solve22(-k.x,-k.y,i.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=P.x,this.m_impulse.y+=P.y,n.SelfMulSub(s,P),r-=l*E.CrossVV(this.m_rA,P),o.SelfMulAdd(u,P),a+=c*E.CrossVV(this.m_rB,P)}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=a}},{key:"SolvePositionConstraints",value:function(e){var n,r=e.positions[this.m_indexA].c,o=e.positions[this.m_indexA].a,a=e.positions[this.m_indexB].c,s=e.positions[this.m_indexB].a,u=this.m_qA.SetAngle(o),l=this.m_qB.SetAngle(s),c=0,h=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!h){var m=s-o-this.m_referenceAngle,d=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var p=g(m-this.m_lowerAngle,-.13962634015955555,.13962634015955555);d=-this.m_motorMass*p,c=_(p)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var y=m-this.m_lowerAngle;c=-y,y=g(y+f,-.13962634015955555,0),d=-this.m_motorMass*y}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var v=m-this.m_upperAngle;c=v,v=g(v-f,0,.13962634015955555),d=-this.m_motorMass*v}o-=this.m_invIA*d,s+=this.m_invIB*d}u.SetAngle(o),l.SetAngle(s),E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var b=R.MulRV(u,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var x=R.MulRV(l,this.m_lalcB,this.m_rB),w=E.SubVV(E.AddVV(a,x,E.s_t0),E.AddVV(r,b,E.s_t1),i.SolvePositionConstraints_s_C_v2);n=w.Length();var S=this.m_invMassA,C=this.m_invMassB,A=this.m_invIA,B=this.m_invIB,k=this.m_K;k.ex.x=S+C+A*b.y*b.y+B*x.y*x.y,k.ex.y=-A*b.x*b.y-B*x.x*x.y,k.ey.x=k.ex.y,k.ey.y=S+C+A*b.x*b.x+B*x.x*x.x;var P=k.Solve(w.x,w.y,i.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(S,P),o-=A*E.CrossVV(b,P),a.SelfMulAdd(C,P),s+=B*E.CrossVV(x,P),e.positions[this.m_indexA].a=o,e.positions[this.m_indexB].a=s,n<=.008&&c<=f}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e}},{key:"GetReactionTorque",value:function(t){return t*this.m_impulse.z}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"GetReferenceAngle",value:function(){return this.m_referenceAngle}},{key:"GetJointAngle",value:function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle}},{key:"GetJointSpeed",value:function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity}},{key:"IsMotorEnabled",value:function(){return this.m_enableMotor}},{key:"EnableMotor",value:function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)}},{key:"GetMotorTorque",value:function(t){return t*this.m_motorImpulse}},{key:"GetMotorSpeed",value:function(){return this.m_motorSpeed}},{key:"SetMaxMotorTorque",value:function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)}},{key:"GetMaxMotorTorque",value:function(){return this.m_maxMotorTorque}},{key:"IsLimitEnabled",value:function(){return this.m_enableLimit}},{key:"EnableLimit",value:function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)}},{key:"GetLowerLimit",value:function(){return this.m_lowerAngle}},{key:"GetUpperLimit",value:function(){return this.m_upperAngle}},{key:"SetLimits",value:function(t,e){t===this.m_lowerAngle&&e===this.m_upperAngle||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=t,this.m_upperAngle=e)}},{key:"SetMotorSpeed",value:function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerAngle = %.15f;\n",this.m_lowerAngle),t(" jd.upperAngle = %.15f;\n",this.m_upperAngle),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),i}(mn);Sn.InitVelocityConstraints_s_P=new E,Sn.SolveVelocityConstraints_s_P=new E,Sn.SolveVelocityConstraints_s_Cdot_v2=new E,Sn.SolveVelocityConstraints_s_Cdot1=new E,Sn.SolveVelocityConstraints_s_impulse_v3=new M,Sn.SolveVelocityConstraints_s_reduced_v2=new E,Sn.SolveVelocityConstraints_s_impulse_v2=new E,Sn.SolvePositionConstraints_s_C_v2=new E,Sn.SolvePositionConstraints_s_impulse=new E;var Cn=function(n){a(i,n);var r=s(i);function i(n){var o;return u(this,i),(o=r.call(this,n)).m_localAnchorA=new E,o.m_localAnchorB=new E,o.m_maxLength=0,o.m_length=0,o.m_impulse=0,o.m_indexA=0,o.m_indexB=0,o.m_u=new E,o.m_rA=new E,o.m_rB=new E,o.m_localCenterA=new E,o.m_localCenterB=new E,o.m_invMassA=0,o.m_invMassB=0,o.m_invIA=0,o.m_invIB=0,o.m_mass=0,o.m_state=t.b2LimitState.e_inactiveLimit,o.m_qA=new R,o.m_qB=new R,o.m_lalcA=new E,o.m_lalcB=new E,o.m_localAnchorA.Copy(e(n.localAnchorA,new E(-1,0))),o.m_localAnchorB.Copy(e(n.localAnchorB,new E(1,0))),o.m_maxLength=e(n.maxLength,0),o}return l(i,[{key:"InitVelocityConstraints",value:function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var n=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,o=e.velocities[this.m_indexA].v,a=e.velocities[this.m_indexA].w,s=e.positions[this.m_indexB].c,u=e.positions[this.m_indexB].a,l=e.velocities[this.m_indexB].v,c=e.velocities[this.m_indexB].w,f=this.m_qA.SetAngle(r),h=this.m_qB.SetAngle(u);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),R.MulRV(f,this.m_lalcA,this.m_rA),E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),R.MulRV(h,this.m_lalcB,this.m_rB),this.m_u.Copy(s).SelfAdd(this.m_rB).SelfSub(n).SelfSub(this.m_rA),this.m_length=this.m_u.Length();var m=this.m_length-this.m_maxLength;if(this.m_state=m>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>.008))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var d=E.CrossVV(this.m_rA,this.m_u),p=E.CrossVV(this.m_rB,this.m_u),_=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=0!==_?1/_:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var y=E.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);o.SelfMulSub(this.m_invMassA,y),a-=this.m_invIA*E.CrossVV(this.m_rA,y),l.SelfMulAdd(this.m_invMassB,y),c+=this.m_invIB*E.CrossVV(this.m_rB,y)}else this.m_impulse=0;e.velocities[this.m_indexA].w=a,e.velocities[this.m_indexB].w=c}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=E.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),s=E.AddVCrossSV(r,o,this.m_rB,i.SolveVelocityConstraints_s_vpB),u=this.m_length-this.m_maxLength,l=E.DotVV(this.m_u,E.SubVV(s,a,E.s_t0));u<0&&(l+=t.step.inv_dt*u);var c=-this.m_mass*l,f=this.m_impulse;this.m_impulse=y(0,this.m_impulse+c),c=this.m_impulse-f;var h=E.MulSV(c,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,h),n-=this.m_invIA*E.CrossVV(this.m_rA,h),r.SelfMulAdd(this.m_invMassB,h),o+=this.m_invIB*E.CrossVV(this.m_rB,h),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o}},{key:"SolvePositionConstraints",value:function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),s=this.m_qB.SetAngle(o);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=R.MulRV(a,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l=R.MulRV(s,this.m_lalcB,this.m_rB),c=this.m_u.Copy(r).SelfAdd(l).SelfSub(e).SelfSub(u),f=c.Normalize(),h=f-this.m_maxLength;h=g(h,0,.2);var m=-this.m_mass*h,d=E.MulSV(m,c,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,d),n-=this.m_invIA*E.CrossVV(u,d),r.SelfMulAdd(this.m_invMassB,d),o+=this.m_invIB*E.CrossVV(l,d),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=o,f-this.m_maxLength<.008}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return E.MulSV(t*this.m_impulse,this.m_u,e)}},{key:"GetReactionTorque",value:function(t){return 0}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"SetMaxLength",value:function(t){this.m_maxLength=t}},{key:"GetMaxLength",value:function(){return this.m_maxLength}},{key:"GetLimitState",value:function(){return this.m_state}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2RopeJointDef = new b2RopeJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxLength = %.15f;\n",this.m_maxLength),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),i}(mn);Cn.InitVelocityConstraints_s_P=new E,Cn.SolveVelocityConstraints_s_vpA=new E,Cn.SolveVelocityConstraints_s_vpB=new E,Cn.SolveVelocityConstraints_s_P=new E,Cn.SolvePositionConstraints_s_P=new E;var An=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_frequencyHz=0,i.m_dampingRatio=0,i.m_bias=0,i.m_localAnchorA=new E,i.m_localAnchorB=new E,i.m_referenceAngle=0,i.m_gamma=0,i.m_impulse=new M(0,0,0),i.m_indexA=0,i.m_indexB=0,i.m_rA=new E,i.m_rB=new E,i.m_localCenterA=new E,i.m_localCenterB=new E,i.m_invMassA=0,i.m_invMassB=0,i.m_invIA=0,i.m_invIB=0,i.m_mass=new O,i.m_qA=new R,i.m_qB=new R,i.m_lalcA=new E,i.m_lalcB=new E,i.m_K=new O,i.m_frequencyHz=e(t.frequencyHz,0),i.m_dampingRatio=e(t.dampingRatio,0),i.m_localAnchorA.Copy(e(t.localAnchorA,E.ZERO)),i.m_localAnchorB.Copy(e(t.localAnchorB,E.ZERO)),i.m_referenceAngle=e(t.referenceAngle,0),i.m_impulse.SetZero(),i}return l(r,[{key:"InitVelocityConstraints",value:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].a,a=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(e),l=this.m_qB.SetAngle(o);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),R.MulRV(u,this.m_lalcA,this.m_rA),E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),R.MulRV(l,this.m_lalcB,this.m_rB);var f=this.m_invMassA,h=this.m_invMassB,m=this.m_invIA,d=this.m_invIB,p=this.m_K;if(p.ex.x=f+h+this.m_rA.y*this.m_rA.y*m+this.m_rB.y*this.m_rB.y*d,p.ey.x=-this.m_rA.y*this.m_rA.x*m-this.m_rB.y*this.m_rB.x*d,p.ez.x=-this.m_rA.y*m-this.m_rB.y*d,p.ex.y=p.ey.x,p.ey.y=f+h+this.m_rA.x*this.m_rA.x*m+this.m_rB.x*this.m_rB.x*d,p.ez.y=this.m_rA.x*m+this.m_rB.x*d,p.ex.z=p.ez.x,p.ey.z=p.ez.y,p.ez.z=m+d,this.m_frequencyHz>0){p.GetInverse22(this.m_mass);var _=m+d,y=_>0?1/_:0,v=o-e-this.m_referenceAngle,g=2*c*this.m_frequencyHz,b=2*y*this.m_dampingRatio*g,x=y*g*g,w=t.step.dt;this.m_gamma=w*(b+w*x),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=v*w*x*this.m_gamma,_+=this.m_gamma,this.m_mass.ez.z=0!==_?1/_:0}else p.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var S=r.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(f,S),i-=m*(E.CrossVV(this.m_rA,S)+this.m_impulse.z),a.SelfMulAdd(h,S),s+=d*(E.CrossVV(this.m_rB,S)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=s}},{key:"SolveVelocityConstraints",value:function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,i=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=this.m_invMassA,s=this.m_invMassB,u=this.m_invIA,l=this.m_invIB;if(this.m_frequencyHz>0){var c=o-n,f=-this.m_mass.ez.z*(c+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=f,n-=u*f,o+=l*f;var h=E.SubVV(E.AddVCrossSV(i,o,this.m_rB,E.s_t0),E.AddVCrossSV(e,n,this.m_rA,E.s_t1),r.SolveVelocityConstraints_s_Cdot1),m=O.MulM33XY(this.m_mass,h.x,h.y,r.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=m.x,this.m_impulse.y+=m.y;var d=m;e.SelfMulSub(a,d),n-=u*E.CrossVV(this.m_rA,d),i.SelfMulAdd(s,d),o+=l*E.CrossVV(this.m_rB,d)}else{var p=E.SubVV(E.AddVCrossSV(i,o,this.m_rB,E.s_t0),E.AddVCrossSV(e,n,this.m_rA,E.s_t1),r.SolveVelocityConstraints_s_Cdot1),_=o-n,y=O.MulM33XYZ(this.m_mass,p.x,p.y,_,r.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(y);var v=r.SolveVelocityConstraints_s_P.Set(y.x,y.y);e.SelfMulSub(a,v),n-=u*(E.CrossVV(this.m_rA,v)+y.z),i.SelfMulAdd(s,v),o+=l*(E.CrossVV(this.m_rB,v)+y.z)}t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o}},{key:"SolvePositionConstraints",value:function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,i=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),s=this.m_qB.SetAngle(o),u=this.m_invMassA,l=this.m_invMassB,c=this.m_invIA,h=this.m_invIB;E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var m=R.MulRV(a,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d,p,y=R.MulRV(s,this.m_lalcB,this.m_rB),v=this.m_K;if(v.ex.x=u+l+m.y*m.y*c+y.y*y.y*h,v.ey.x=-m.y*m.x*c-y.y*y.x*h,v.ez.x=-m.y*c-y.y*h,v.ex.y=v.ey.x,v.ey.y=u+l+m.x*m.x*c+y.x*y.x*h,v.ez.y=m.x*c+y.x*h,v.ex.z=v.ez.x,v.ey.z=v.ez.y,v.ez.z=c+h,this.m_frequencyHz>0){var g=E.SubVV(E.AddVV(i,y,E.s_t0),E.AddVV(e,m,E.s_t1),r.SolvePositionConstraints_s_C1);d=g.Length(),p=0;var b=v.Solve22(g.x,g.y,r.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(u,b),n-=c*E.CrossVV(m,b),i.SelfMulAdd(l,b),o+=h*E.CrossVV(y,b)}else{var x=E.SubVV(E.AddVV(i,y,E.s_t0),E.AddVV(e,m,E.s_t1),r.SolvePositionConstraints_s_C1),w=o-n-this.m_referenceAngle;d=x.Length(),p=_(w);var S=v.Solve33(x.x,x.y,w,r.SolvePositionConstraints_s_impulse).SelfNeg(),C=r.SolvePositionConstraints_s_P.Set(S.x,S.y);e.SelfMulSub(u,C),n-=c*(E.CrossVV(this.m_rA,C)+S.z),i.SelfMulAdd(l,C),o+=h*(E.CrossVV(this.m_rB,C)+S.z)}return t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=o,d<=.008&&p<=f}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e}},{key:"GetReactionTorque",value:function(t){return t*this.m_impulse.z}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"GetReferenceAngle",value:function(){return this.m_referenceAngle}},{key:"SetFrequency",value:function(t){this.m_frequencyHz=t}},{key:"GetFrequency",value:function(){return this.m_frequencyHz}},{key:"SetDampingRatio",value:function(t){this.m_dampingRatio=t}},{key:"GetDampingRatio",value:function(){return this.m_dampingRatio}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),r}(mn);An.InitVelocityConstraints_s_P=new E,An.SolveVelocityConstraints_s_Cdot1=new E,An.SolveVelocityConstraints_s_impulse1=new E,An.SolveVelocityConstraints_s_impulse=new M,An.SolveVelocityConstraints_s_P=new E,An.SolvePositionConstraints_s_C1=new E,An.SolvePositionConstraints_s_P=new E,An.SolvePositionConstraints_s_impulse=new M;var Bn=function(t){a(r,t);var n=s(r);function r(t){var i;return u(this,r),(i=n.call(this,t)).m_frequencyHz=0,i.m_dampingRatio=0,i.m_localAnchorA=new E,i.m_localAnchorB=new E,i.m_localXAxisA=new E,i.m_localYAxisA=new E,i.m_impulse=0,i.m_motorImpulse=0,i.m_springImpulse=0,i.m_maxMotorTorque=0,i.m_motorSpeed=0,i.m_enableMotor=!1,i.m_indexA=0,i.m_indexB=0,i.m_localCenterA=new E,i.m_localCenterB=new E,i.m_invMassA=0,i.m_invMassB=0,i.m_invIA=0,i.m_invIB=0,i.m_ax=new E,i.m_ay=new E,i.m_sAx=0,i.m_sBx=0,i.m_sAy=0,i.m_sBy=0,i.m_mass=0,i.m_motorMass=0,i.m_springMass=0,i.m_bias=0,i.m_gamma=0,i.m_qA=new R,i.m_qB=new R,i.m_lalcA=new E,i.m_lalcB=new E,i.m_rA=new E,i.m_rB=new E,i.m_frequencyHz=e(t.frequencyHz,2),i.m_dampingRatio=e(t.dampingRatio,.7),i.m_localAnchorA.Copy(e(t.localAnchorA,E.ZERO)),i.m_localAnchorB.Copy(e(t.localAnchorB,E.ZERO)),i.m_localXAxisA.Copy(e(t.localAxisA,E.UNITX)),E.CrossOneV(i.m_localXAxisA,i.m_localYAxisA),i.m_maxMotorTorque=e(t.maxMotorTorque,0),i.m_motorSpeed=e(t.motorSpeed,0),i.m_enableMotor=e(t.enableMotor,!1),i.m_ax.SetZero(),i.m_ay.SetZero(),i}return l(r,[{key:"GetMotorSpeed",value:function(){return this.m_motorSpeed}},{key:"GetMaxMotorTorque",value:function(){return this.m_maxMotorTorque}},{key:"SetSpringFrequencyHz",value:function(t){this.m_frequencyHz=t}},{key:"GetSpringFrequencyHz",value:function(){return this.m_frequencyHz}},{key:"SetSpringDampingRatio",value:function(t){this.m_dampingRatio=t}},{key:"GetSpringDampingRatio",value:function(){return this.m_dampingRatio}},{key:"InitVelocityConstraints",value:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,n=this.m_invMassB,i=this.m_invIA,o=this.m_invIB,a=t.positions[this.m_indexA].c,s=t.positions[this.m_indexA].a,u=t.velocities[this.m_indexA].v,l=t.velocities[this.m_indexA].w,f=t.positions[this.m_indexB].c,h=t.positions[this.m_indexB].a,m=t.velocities[this.m_indexB].v,d=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(s),_=this.m_qB.SetAngle(h);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var y=R.MulRV(p,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var v=R.MulRV(_,this.m_lalcB,this.m_rB),g=E.SubVV(E.AddVV(f,v,E.s_t0),E.AddVV(a,y,E.s_t1),r.InitVelocityConstraints_s_d);if(R.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=E.CrossVV(E.AddVV(g,y,E.s_t0),this.m_ay),this.m_sBy=E.CrossVV(v,this.m_ay),this.m_mass=e+n+i*this.m_sAy*this.m_sAy+o*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){R.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=E.CrossVV(E.AddVV(g,y,E.s_t0),this.m_ax),this.m_sBx=E.CrossVV(v,this.m_ax);var b=e+n+i*this.m_sAx*this.m_sAx+o*this.m_sBx*this.m_sBx;if(b>0){this.m_springMass=1/b;var x=E.DotVV(g,this.m_ax),w=2*c*this.m_frequencyHz,S=2*this.m_springMass*this.m_dampingRatio*w,C=this.m_springMass*w*w,A=t.step.dt;this.m_gamma=A*(S+A*C),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=x*A*C*this.m_gamma,this.m_springMass=b+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=i+o,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var B=E.AddVV(E.MulSV(this.m_impulse,this.m_ay,E.s_t0),E.MulSV(this.m_springImpulse,this.m_ax,E.s_t1),r.InitVelocityConstraints_s_P),k=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,P=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;u.SelfMulSub(this.m_invMassA,B),l-=this.m_invIA*k,m.SelfMulAdd(this.m_invMassB,B),d+=this.m_invIB*P}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].w=l,t.velocities[this.m_indexB].w=d}},{key:"SolveVelocityConstraints",value:function(t){var e=this.m_invMassA,n=this.m_invMassB,i=this.m_invIA,o=this.m_invIB,a=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,u=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,c=E.DotVV(this.m_ax,E.SubVV(u,a,E.s_t0))+this.m_sBx*l-this.m_sAx*s,f=-this.m_springMass*(c+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=f;var h=E.MulSV(f,this.m_ax,r.SolveVelocityConstraints_s_P),m=f*this.m_sAx,d=f*this.m_sBx;a.SelfMulSub(e,h),s-=i*m,u.SelfMulAdd(n,h);var p=(l+=o*d)-s-this.m_motorSpeed,_=-this.m_motorMass*p,y=this.m_motorImpulse,v=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=g(this.m_motorImpulse+_,-v,v),s-=i*(_=this.m_motorImpulse-y),l+=o*_;var b=E.DotVV(this.m_ay,E.SubVV(u,a,E.s_t0))+this.m_sBy*l-this.m_sAy*s,x=-this.m_mass*b;this.m_impulse+=x;var w=E.MulSV(x,this.m_ay,r.SolveVelocityConstraints_s_P),S=x*this.m_sAy,C=x*this.m_sBy;a.SelfMulSub(e,w),s-=i*S,u.SelfMulAdd(n,w),l+=o*C,t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=l}},{key:"SolvePositionConstraints",value:function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,i=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),s=this.m_qB.SetAngle(o);E.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=R.MulRV(a,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l,c=R.MulRV(s,this.m_lalcB,this.m_rB),f=E.AddVV(E.SubVV(i,e,E.s_t0),E.SubVV(c,u,E.s_t1),r.SolvePositionConstraints_s_d),h=R.MulRV(a,this.m_localYAxisA,this.m_ay),m=E.CrossVV(E.AddVV(f,u,E.s_t0),h),d=E.CrossVV(c,h),p=E.DotVV(f,this.m_ay),y=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;l=0!==y?-p/y:0;var v=E.MulSV(l,h,r.SolvePositionConstraints_s_P),g=l*m,b=l*d;return e.SelfMulSub(this.m_invMassA,v),n-=this.m_invIA*g,i.SelfMulAdd(this.m_invMassB,v),o+=this.m_invIB*b,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=o,_(p)<=.008}},{key:"GetDefinition",value:function(t){return t}},{key:"GetAnchorA",value:function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)}},{key:"GetAnchorB",value:function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)}},{key:"GetReactionForce",value:function(t,e){return e.x=t*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x),e.y=t*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y),e}},{key:"GetReactionTorque",value:function(t){return t*this.m_motorImpulse}},{key:"GetLocalAnchorA",value:function(){return this.m_localAnchorA}},{key:"GetLocalAnchorB",value:function(){return this.m_localAnchorB}},{key:"GetLocalAxisA",value:function(){return this.m_localXAxisA}},{key:"GetJointTranslation",value:function(){return this.GetPrismaticJointTranslation()}},{key:"GetJointLinearSpeed",value:function(){return this.GetPrismaticJointSpeed()}},{key:"GetJointAngle",value:function(){return this.GetRevoluteJointAngle()}},{key:"GetJointAngularSpeed",value:function(){return this.GetRevoluteJointSpeed()}},{key:"GetPrismaticJointTranslation",value:function(){var t=this.m_bodyA,e=this.m_bodyB,n=t.GetWorldPoint(this.m_localAnchorA,new E),r=e.GetWorldPoint(this.m_localAnchorB,new E),i=E.SubVV(r,n,new E),o=t.GetWorldVector(this.m_localXAxisA,new E);return E.DotVV(i,o)}},{key:"GetPrismaticJointSpeed",value:function(){var t=this.m_bodyA,e=this.m_bodyB;E.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var n=R.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);E.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var r=R.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),i=E.AddVV(t.m_sweep.c,n,E.s_t0),o=E.AddVV(e.m_sweep.c,r,E.s_t1),a=E.SubVV(o,i,E.s_t2),s=t.GetWorldVector(this.m_localXAxisA,new E),u=t.m_linearVelocity,l=e.m_linearVelocity,c=t.m_angularVelocity,f=e.m_angularVelocity;return E.DotVV(a,E.CrossSV(c,s,E.s_t0))+E.DotVV(s,E.SubVV(E.AddVCrossSV(l,f,r,E.s_t0),E.AddVCrossSV(u,c,n,E.s_t1),E.s_t0))}},{key:"GetRevoluteJointAngle",value:function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a}},{key:"GetRevoluteJointSpeed",value:function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t}},{key:"IsMotorEnabled",value:function(){return this.m_enableMotor}},{key:"EnableMotor",value:function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)}},{key:"SetMotorSpeed",value:function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)}},{key:"SetMaxMotorTorque",value:function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)}},{key:"GetMotorTorque",value:function(t){return t*this.m_motorImpulse}},{key:"Dump",value:function(t){var e=this.m_bodyA.m_islandIndex,n=this.m_bodyB.m_islandIndex;t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",n),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}}]),r}(mn);function kn(t,e){return S(t*e)}function Pn(t,e){return t>e?t:e}Bn.InitVelocityConstraints_s_d=new E,Bn.InitVelocityConstraints_s_P=new E,Bn.SolveVelocityConstraints_s_P=new E,Bn.SolvePositionConstraints_s_d=new E,Bn.SolvePositionConstraints_s_P=new E;var Vn=function t(e){u(this,t),this.prev=null,this.next=null,this.contact=e},En=function(){function t(){u(this,t),this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!1,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_prev=null,this.m_next=null,this.m_indexA=0,this.m_indexB=0,this.m_manifold=new yt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new yt,this.m_nodeA=new Vn(this),this.m_nodeB=new Vn(this)}return l(t,[{key:"GetManifold",value:function(){return this.m_manifold}},{key:"GetWorldManifold",value:function(t){var e=this.m_fixtureA.GetBody(),n=this.m_fixtureB.GetBody(),r=this.m_fixtureA.GetShape(),i=this.m_fixtureB.GetShape();t.Initialize(this.m_manifold,e.GetTransform(),r.m_radius,n.GetTransform(),i.m_radius)}},{key:"IsTouching",value:function(){return this.m_touchingFlag}},{key:"SetEnabled",value:function(t){this.m_enabledFlag=t}},{key:"IsEnabled",value:function(){return this.m_enabledFlag}},{key:"GetNext",value:function(){return this.m_next}},{key:"GetFixtureA",value:function(){return this.m_fixtureA}},{key:"GetChildIndexA",value:function(){return this.m_indexA}},{key:"GetFixtureB",value:function(){return this.m_fixtureB}},{key:"GetChildIndexB",value:function(){return this.m_indexB}},{key:"FlagForFiltering",value:function(){this.m_filterFlag=!0}},{key:"SetFriction",value:function(t){this.m_friction=t}},{key:"GetFriction",value:function(){return this.m_friction}},{key:"ResetFriction",value:function(){this.m_friction=kn(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)}},{key:"SetRestitution",value:function(t){this.m_restitution=t}},{key:"GetRestitution",value:function(){return this.m_restitution}},{key:"ResetRestitution",value:function(){this.m_restitution=Pn(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)}},{key:"SetTangentSpeed",value:function(t){this.m_tangentSpeed=t}},{key:"GetTangentSpeed",value:function(){return this.m_tangentSpeed}},{key:"Reset",value:function(t,e,n,r){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!0,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_fixtureA=t,this.m_fixtureB=n,this.m_indexA=e,this.m_indexB=r,this.m_manifold.pointCount=0,this.m_prev=null,this.m_next=null,delete this.m_nodeA.contact,this.m_nodeA.prev=null,this.m_nodeA.next=null,delete this.m_nodeA.other,delete this.m_nodeB.contact,this.m_nodeB.prev=null,this.m_nodeB.next=null,delete this.m_nodeB.other,this.m_toiCount=0,this.m_friction=kn(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=Pn(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)}},{key:"Update",value:function(t){var e=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=e,this.m_enabledFlag=!0;var n=!1,r=this.m_touchingFlag,i=this.m_fixtureA.IsSensor(),o=this.m_fixtureB.IsSensor(),a=i||o,s=this.m_fixtureA.GetBody(),u=this.m_fixtureB.GetBody(),l=s.GetTransform(),c=u.GetTransform();if(a){var f=this.m_fixtureA.GetShape(),h=this.m_fixtureB.GetShape();n=Pt(f,this.m_indexA,h,this.m_indexB,l,c),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,l,c),n=this.m_manifold.pointCount>0;for(var m=0;m0&&!e.IsSensor()&&!n.IsSensor()&&(e.GetBody().SetAwake(!0),n.GetBody().SetAwake(!0));var r=e.GetType(),i=n.GetType(),o=this.m_registers[r][i];o.destroyFcn&&o.destroyFcn(t,this.m_allocator)}}]),e}(),Gn=function(){function e(){u(this,e)}return l(e,[{key:"ShouldCollide",value:function(e,n){var r=e.GetBody(),i=n.GetBody();if(i.GetType()===t.b2BodyType.b2_staticBody&&r.GetType()===t.b2BodyType.b2_staticBody)return!1;if(!i.ShouldCollideConnected(r))return!1;var o=e.GetFilterData(),a=n.GetFilterData();return o.groupIndex===a.groupIndex&&0!==o.groupIndex?o.groupIndex>0:0!=(o.maskBits&a.categoryBits)&&0!=(o.categoryBits&a.maskBits)}},{key:"ShouldCollideFixtureParticle",value:function(t,e,n){return!0}},{key:"ShouldCollideParticleParticle",value:function(t,e,n){return!0}}]),e}();Gn.b2_defaultFilter=new Gn;var Nn=function t(){u(this,t),this.normalImpulses=p(2),this.tangentImpulses=p(2),this.count=0},zn=function(){function t(){u(this,t)}return l(t,[{key:"BeginContact",value:function(t){}},{key:"EndContact",value:function(t){}},{key:"BeginContactFixtureParticle",value:function(t,e){}},{key:"EndContactFixtureParticle",value:function(t,e){}},{key:"BeginContactParticleParticle",value:function(t,e){}},{key:"EndContactParticleParticle",value:function(t,e){}},{key:"PreSolve",value:function(t,e){}},{key:"PostSolve",value:function(t,e){}}]),t}();zn.b2_defaultListener=new zn;var qn=function(){function t(){u(this,t)}return l(t,[{key:"ReportFixture",value:function(t){return!0}},{key:"ReportParticle",value:function(t,e){return!1}},{key:"ShouldQueryParticleSystem",value:function(t){return!0}}]),t}(),Un=function(){function e(){u(this,e),this.m_broadPhase=new It,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=Gn.b2_defaultFilter,this.m_contactListener=zn.b2_defaultListener,this.m_allocator=null,this.m_contactFactory=new Fn(this.m_allocator)}return l(e,[{key:"AddPair",value:function(t,e){var n=t.fixture,r=e.fixture,i=t.childIndex,o=e.childIndex,a=n.GetBody(),s=r.GetBody();if(a!==s){for(var u=s.GetContactList();u;){if(u.other===a){var l=u.contact.GetFixtureA(),c=u.contact.GetFixtureB(),f=u.contact.GetChildIndexA(),h=u.contact.GetChildIndexB();if(l===n&&c===r&&f===i&&h===o)return;if(l===r&&c===n&&f===o&&h===i)return}u=u.next}if(!this.m_contactFilter||this.m_contactFilter.ShouldCollide(n,r)){var m=this.m_contactFactory.Create(n,i,r,o);null!==m&&(n=m.GetFixtureA(),r=m.GetFixtureB(),i=m.GetChildIndexA(),o=m.GetChildIndexB(),a=n.m_body,s=r.m_body,m.m_prev=null,m.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=m),this.m_contactList=m,m.m_nodeA.contact=m,m.m_nodeA.other=s,m.m_nodeA.prev=null,m.m_nodeA.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=m.m_nodeA),a.m_contactList=m.m_nodeA,m.m_nodeB.contact=m,m.m_nodeB.other=a,m.m_nodeB.prev=null,m.m_nodeB.next=s.m_contactList,null!==s.m_contactList&&(s.m_contactList.prev=m.m_nodeB),s.m_contactList=m.m_nodeB,n.IsSensor()||r.IsSensor()||(a.SetAwake(!0),s.SetAwake(!0)),++this.m_contactCount)}}}},{key:"FindNewContacts",value:function(){var t=this;this.m_broadPhase.UpdatePairs((function(e,n){t.AddPair(e,n)}))}},{key:"Destroy",value:function(t){var e=t.GetFixtureA(),n=t.GetFixtureB(),r=e.GetBody(),i=n.GetBody();this.m_contactListener&&t.IsTouching()&&this.m_contactListener.EndContact(t),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_contactList&&(this.m_contactList=t.m_next),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA===r.m_contactList&&(r.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB===i.m_contactList&&(i.m_contactList=t.m_nodeB.next),this.m_contactFactory.Destroy(t),--this.m_contactCount}},{key:"Collide",value:function(){for(var e=this.m_contactList;e;){var n=e.GetFixtureA(),r=e.GetFixtureB(),i=e.GetChildIndexA(),o=e.GetChildIndexB(),a=n.GetBody(),s=r.GetBody();if(e.m_filterFlag){if(this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(n,r)){var u=e;e=u.m_next,this.Destroy(u);continue}e.m_filterFlag=!1}var l=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody,c=s.IsAwake()&&s.m_type!==t.b2BodyType.b2_staticBody;if(l||c){var f=n.m_proxies[i].treeNode,h=r.m_proxies[o].treeNode;if(St(f.aabb,h.aabb))e.Update(this.m_contactListener),e=e.m_next;else{var m=e;e=m.m_next,this.Destroy(m)}}else e=e.m_next}}}]),e}(),Wn=function(){function t(){u(this,t),this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0}return l(t,[{key:"Reset",value:function(){return this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0,this}}]),t}(),Jn=function(){function t(){u(this,t),this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.particleIterations=0,this.warmStarting=!1}return l(t,[{key:"Copy",value:function(t){return this.dt=t.dt,this.inv_dt=t.inv_dt,this.dtRatio=t.dtRatio,this.positionIterations=t.positionIterations,this.velocityIterations=t.velocityIterations,this.particleIterations=t.particleIterations,this.warmStarting=t.warmStarting,this}}]),t}(),Hn=function(){function t(){u(this,t),this.c=new E,this.a=0}return l(t,null,[{key:"MakeArray",value:function(e){return d(e,(function(e){return new t}))}}]),t}(),Xn=function(){function t(){u(this,t),this.v=new E,this.w=0}return l(t,null,[{key:"MakeArray",value:function(e){return d(e,(function(e){return new t}))}}]),t}(),$n=function t(){u(this,t),this.step=new Jn},Yn=function(){function t(){u(this,t),this.rA=new E,this.rB=new E,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return l(t,null,[{key:"MakeArray",value:function(e){return d(e,(function(e){return new t}))}}]),t}(),Zn=function(){function t(){u(this,t),this.points=Yn.MakeArray(2),this.normal=new E,this.tangent=new E,this.normalMass=new I,this.K=new I,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}return l(t,null,[{key:"MakeArray",value:function(e){return d(e,(function(e){return new t}))}}]),t}(),Kn=function(){function e(){u(this,e),this.localPoints=E.MakeArray(2),this.localNormal=new E,this.localPoint=new E,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new E,this.localCenterB=new E,this.invIA=0,this.invIB=0,this.type=t.b2ManifoldType.e_unknown,this.radiusA=0,this.radiusB=0,this.pointCount=0}return l(e,null,[{key:"MakeArray",value:function(t){return d(t,(function(t){return new e}))}}]),e}(),Qn=function t(){u(this,t),this.step=new Jn,this.count=0,this.allocator=null},tr=function(){function e(){u(this,e),this.normal=new E,this.point=new E,this.separation=0}return l(e,[{key:"Initialize",value:function(n,r,i,o){var a=e.Initialize_s_pointA,s=e.Initialize_s_pointB,u=e.Initialize_s_planePoint,l=e.Initialize_s_clipPoint;switch(n.type){case t.b2ManifoldType.e_circles:D.MulXV(r,n.localPoint,a),D.MulXV(i,n.localPoints[0],s),E.SubVV(s,a,this.normal).SelfNormalize(),E.MidVV(a,s,this.point),this.separation=E.DotVV(E.SubVV(s,a,E.s_t0),this.normal)-n.radiusA-n.radiusB;break;case t.b2ManifoldType.e_faceA:R.MulRV(r.q,n.localNormal,this.normal),D.MulXV(r,n.localPoint,u),D.MulXV(i,n.localPoints[o],l),this.separation=E.DotVV(E.SubVV(l,u,E.s_t0),this.normal)-n.radiusA-n.radiusB,this.point.Copy(l);break;case t.b2ManifoldType.e_faceB:R.MulRV(i.q,n.localNormal,this.normal),D.MulXV(i,n.localPoint,u),D.MulXV(r,n.localPoints[o],l),this.separation=E.DotVV(E.SubVV(l,u,E.s_t0),this.normal)-n.radiusA-n.radiusB,this.point.Copy(l),this.normal.SelfNeg()}}}]),e}();tr.Initialize_s_pointA=new E,tr.Initialize_s_pointB=new E,tr.Initialize_s_planePoint=new E,tr.Initialize_s_clipPoint=new E;var er=function(){function t(){u(this,t),this.m_step=new Jn,this.m_allocator=null,this.m_positionConstraints=Kn.MakeArray(1024),this.m_velocityConstraints=Zn.MakeArray(1024),this.m_count=0}return l(t,[{key:"Initialize",value:function(t){if(this.m_step.Copy(t.step),this.m_allocator=t.allocator,this.m_count=t.count,this.m_positionConstraints.length0?1/M:0;var I=o.tangent,O=E.CrossVV(P.rA,I),D=E.CrossVV(P.rB,I),j=h+m+d*O*O+p*D*D;P.tangentMass=j>0?1/j:0,P.velocityBias=0;var L=E.DotVV(o.normal,E.SubVV(E.AddVCrossSV(C,A,P.rB,E.s_t0),E.AddVCrossSV(b,x,P.rA,E.s_t1),E.s_t0));L<-1&&(P.velocityBias+=-o.restitution*L)}o.pointCount}}},{key:"WarmStart",value:function(){for(var e=t.WarmStart_s_P,n=0;n0?-V/I:0;E.MulSV(O,B,a),x.SelfMulSub(m,a),w-=d*E.CrossVV(i,a),S.SelfMulAdd(_,a),C+=v*E.CrossVV(o,a)}this.m_positions[c].a=w,this.m_positions[f].a=C}return s>-.024}},{key:"SolveTOIPositionConstraints",value:function(e,n){for(var r=t.SolveTOIPositionConstraints_s_xfA,i=t.SolveTOIPositionConstraints_s_xfB,o=t.SolveTOIPositionConstraints_s_psm,a=t.SolveTOIPositionConstraints_s_rA,s=t.SolveTOIPositionConstraints_s_rB,u=t.SolveTOIPositionConstraints_s_P,l=0,c=0;c0?-M/D:0;E.MulSV(j,P,u),S.SelfMulSub(v,u),C-=b*E.CrossVV(a,u),A.SelfMulAdd(x,u),B+=w*E.CrossVV(s,u)}this.m_positions[h].a=C,this.m_positions[m].a=B}return l>=-.012}}]),t}();er.InitializeVelocityConstraints_s_xfA=new D,er.InitializeVelocityConstraints_s_xfB=new D,er.InitializeVelocityConstraints_s_worldManifold=new vt,er.WarmStart_s_P=new E,er.SolveVelocityConstraints_s_dv=new E,er.SolveVelocityConstraints_s_dv1=new E,er.SolveVelocityConstraints_s_dv2=new E,er.SolveVelocityConstraints_s_P=new E,er.SolveVelocityConstraints_s_a=new E,er.SolveVelocityConstraints_s_b=new E,er.SolveVelocityConstraints_s_x=new E,er.SolveVelocityConstraints_s_d=new E,er.SolveVelocityConstraints_s_P1=new E,er.SolveVelocityConstraints_s_P2=new E,er.SolveVelocityConstraints_s_P1P2=new E,er.SolvePositionConstraints_s_xfA=new D,er.SolvePositionConstraints_s_xfB=new D,er.SolvePositionConstraints_s_psm=new tr,er.SolvePositionConstraints_s_rA=new E,er.SolvePositionConstraints_s_rB=new E,er.SolvePositionConstraints_s_P=new E,er.SolveTOIPositionConstraints_s_xfA=new D,er.SolveTOIPositionConstraints_s_xfB=new D,er.SolveTOIPositionConstraints_s_psm=new tr,er.SolveTOIPositionConstraints_s_rA=new E,er.SolveTOIPositionConstraints_s_rB=new E,er.SolveTOIPositionConstraints_s_P=new E;var nr=function(){function e(){u(this,e),this.m_allocator=null,this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=Hn.MakeArray(1024),this.m_velocities=Xn.MakeArray(1024),this.m_bodyCount=0,this.m_jointCount=0,this.m_contactCount=0,this.m_bodyCapacity=0,this.m_contactCapacity=0,this.m_jointCapacity=0}return l(e,[{key:"Initialize",value:function(t,e,n,r,i){if(this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=n,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_allocator=r,this.m_listener=i,this.m_positions.length4){var P=2/k.Length();A.SelfMul(P)}var V=u*B;V*V>2.4674011002726646&&(B*=1.570796326795/_(V)),S.x+=u*A.x,S.y+=u*A.y,C+=u*B,this.m_positions[w].a=C,this.m_velocities[w].w=B}s.Reset();for(var T=!1,M=0;M.0012184696791469947||E.DotVV(N.m_linearVelocity,N.m_linearVelocity)>1e-4?(N.m_sleepTime=0,F=0):(N.m_sleepTime+=u,F=y(F,N.m_sleepTime)))}if(F>=.5&&T)for(var z=0;z4){var v=2/y.Length();d.SelfMul(v)}var g=c*p;g*g>2.4674011002726646&&(p*=1.570796326795/_(g)),h.SelfMulAdd(c,d),m+=c*p,this.m_positions[f].a=m,this.m_velocities[f].w=p;var b=this.m_bodies[f];b.m_sweep.c.Copy(h),b.m_sweep.a=m,b.m_linearVelocity.Copy(d),b.m_angularVelocity=p,b.SynchronizeTransform()}this.Report(s.m_velocityConstraints)}},{key:"Report",value:function(t){if(null!==this.m_listener)for(var n=0;n0){var i=1/this.m_mass;this.m_center.SelfMul(i),this.m_linearVelocity.SelfMul(i)}this.m_inertia=0,this.m_angularVelocity=0;for(var o=this.m_firstIndex;o0&&(this.m_angularVelocity*=1/this.m_inertia),this.m_timestamp=this.m_system.m_timestamp}}}]),e}();sr.GetLinearVelocityFromWorldPoint_s_t0=new E;var ur=function(){function t(e){u(this,t),this.m_front=0,this.m_back=0,this.m_capacity=0,this.m_buffer=d(e,(function(t){return null})),this.m_capacity=e}return l(t,[{key:"Push",value:function(t){if(this.m_back>=this.m_capacity){for(var e=this.m_front;e=this.m_capacity&&(this.m_capacity>0?(this.m_buffer.concat(d(this.m_capacity,(function(t){return null}))),this.m_capacity*=2):(this.m_buffer.concat(d(1,(function(t){return null}))),this.m_capacity=1))}this.m_buffer[this.m_back]=t,this.m_back++}},{key:"Pop",value:function(){this.m_buffer[this.m_front]=null,this.m_front++}},{key:"Empty",value:function(){return this.m_front===this.m_back}},{key:"Front",value:function(){var t=this.m_buffer[this.m_front];if(!t)throw new Error;return t}}]),t}(),lr=function(){function t(e){u(this,t),this.m_generatorCapacity=0,this.m_generatorCount=0,this.m_countX=0,this.m_countY=0,this.m_diagram=[],this.m_generatorBuffer=d(e,(function(e){return new t.Generator})),this.m_generatorCapacity=e}return l(t,[{key:"AddGenerator",value:function(t,e,n){var r=this.m_generatorBuffer[this.m_generatorCount++];r.center.Copy(t),r.tag=e,r.necessary=n}},{key:"Generate",value:function(e,r){for(var i=1/e,o=new E(+n,+n),a=new E(-n,-n),s=0,u=0;u=0&&d>=0&&m0&&c.Push(new t.Task(_-1,y,v-1,g)),y>0&&c.Push(new t.Task(_,y-1,v-this.m_countX,g)),_G*G+N*N&&(this.m_diagram[O]=j,M>0&&c.Push(new t.Task(M-1,I,O-1,j)),I>0&&c.Push(new t.Task(M,I-1,O-this.m_countX,j)),M1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length-e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fr,i=e,o=[],a=0;;){for(;i+1=n)break;cr(t,u,n)}}if(0===a)break;i=n,n=o[--a]}return t}function mr(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length-e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fr;return hr(t,e,n,r)}function dr(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length,r=0,i=0;i0;){var a=Math.floor(o/2),s=e+a;i(t[s],r)?(e=++s,o-=a+1):o=a}return e}function _r(t,e,n,r,i){for(var o=n-e;o>0;){var a=Math.floor(o/2),s=e+a;i(r,t[s])?o=a:(e=++s,o-=a+1)}return e}function yr(t,e,n,r){for(var i=n;e!==i;)cr(t,e++,i++),i===r?i=n:e===n&&(n=i)}!function(t){t.Generator=function(){return function t(){u(this,t),this.center=new E,this.tag=0,this.necessary=!1}}(),t.Task=function(){return function t(e,n,r,i){u(this,t),this.m_x=e,this.m_y=n,this.m_i=r,this.m_generator=i}}()}(lr||(lr={}));var vr=function(){function t(e){u(this,t),this.data=[],this.count=0,this.capacity=0,this.allocator=e}return l(t,[{key:"Append",value:function(){return this.count>=this.capacity&&this.Grow(),this.count++}},{key:"Reserve",value:function(t){if(!(this.capacity>=t)){for(var e=this.capacity;e=0;)this.ReportFixtureAndParticle(t,n,o);return!0}},{key:"ReportParticle",value:function(t,e){return!1}},{key:"ReportFixtureAndParticle",value:function(t,e,n){}}]),n}(qn),br=function(){function t(){u(this,t),this.indexA=0,this.indexB=0,this.weight=0,this.normal=new E,this.flags=0}return l(t,[{key:"SetIndices",value:function(t,e){this.indexA=t,this.indexB=e}},{key:"SetWeight",value:function(t){this.weight=t}},{key:"SetNormal",value:function(t){this.normal.Copy(t)}},{key:"SetFlags",value:function(t){this.flags=t}},{key:"GetIndexA",value:function(){return this.indexA}},{key:"GetIndexB",value:function(){return this.indexB}},{key:"GetWeight",value:function(){return this.weight}},{key:"GetNormal",value:function(){return this.normal}},{key:"GetFlags",value:function(){return this.flags}},{key:"IsEqual",value:function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&this.weight===t.weight&&this.normal.x===t.normal.x&&this.normal.y===t.normal.y}},{key:"IsNotEqual",value:function(t){return!this.IsEqual(t)}},{key:"ApproximatelyEqual",value:function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&_(this.weight-t.weight)<.01&&E.DistanceSquaredVV(this.normal,t.normal)<1e-4}}]),t}(),xr=function t(){u(this,t),this.index=0,this.weight=0,this.normal=new E,this.mass=0},wr=function t(){u(this,t),this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},Sr=function t(){u(this,t),this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new E(0,0),this.pb=new E(0,0),this.pc=new E(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},Cr=function(){function t(){u(this,t),this.strictContactCheck=!1,this.density=1,this.gravityScale=1,this.radius=1,this.maxCount=0,this.pressureStrength=.005,this.dampingStrength=1,this.elasticStrength=.25,this.springStrength=.25,this.viscousStrength=.25,this.surfaceTensionPressureStrength=.2,this.surfaceTensionNormalStrength=.2,this.repulsiveStrength=1,this.powderStrength=.5,this.ejectionStrength=.5,this.staticPressureStrength=.2,this.staticPressureRelaxation=.2,this.staticPressureIterations=8,this.colorMixingStrength=.5,this.destroyByAge=!0,this.lifetimeGranularity=1/60}return l(t,[{key:"Copy",value:function(t){return this.strictContactCheck=t.strictContactCheck,this.density=t.density,this.gravityScale=t.gravityScale,this.radius=t.radius,this.maxCount=t.maxCount,this.pressureStrength=t.pressureStrength,this.dampingStrength=t.dampingStrength,this.elasticStrength=t.elasticStrength,this.springStrength=t.springStrength,this.viscousStrength=t.viscousStrength,this.surfaceTensionPressureStrength=t.surfaceTensionPressureStrength,this.surfaceTensionNormalStrength=t.surfaceTensionNormalStrength,this.repulsiveStrength=t.repulsiveStrength,this.powderStrength=t.powderStrength,this.ejectionStrength=t.ejectionStrength,this.staticPressureStrength=t.staticPressureStrength,this.staticPressureRelaxation=t.staticPressureRelaxation,this.staticPressureIterations=t.staticPressureIterations,this.colorMixingStrength=t.colorMixingStrength,this.destroyByAge=t.destroyByAge,this.lifetimeGranularity=t.lifetimeGranularity,this}},{key:"Clone",value:function(){return(new t).Copy(this)}}]),t}(),Ar=function(){function r(t,e){u(this,r),this.m_paused=!1,this.m_timestamp=0,this.m_allParticleFlags=0,this.m_needsUpdateAllParticleFlags=!1,this.m_allGroupFlags=0,this.m_needsUpdateAllGroupFlags=!1,this.m_hasForce=!1,this.m_iterationIndex=0,this.m_inverseDensity=0,this.m_particleDiameter=0,this.m_inverseDiameter=0,this.m_squaredDiameter=0,this.m_count=0,this.m_internalAllocatedCapacity=0,this.m_handleIndexBuffer=new r.UserOverridableBuffer,this.m_flagsBuffer=new r.UserOverridableBuffer,this.m_positionBuffer=new r.UserOverridableBuffer,this.m_velocityBuffer=new r.UserOverridableBuffer,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new r.UserOverridableBuffer,this.m_groupBuffer=[],this.m_userDataBuffer=new r.UserOverridableBuffer,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new r.UserOverridableBuffer,this.m_bodyContactCountBuffer=new r.UserOverridableBuffer,this.m_consecutiveContactStepsBuffer=new r.UserOverridableBuffer,this.m_stuckParticleBuffer=new vr((function(){return 0})),this.m_proxyBuffer=new vr((function(){return new r.Proxy})),this.m_contactBuffer=new vr((function(){return new br})),this.m_bodyContactBuffer=new vr((function(){return new xr})),this.m_pairBuffer=new vr((function(){return new wr})),this.m_triadBuffer=new vr((function(){return new Sr})),this.m_expirationTimeBuffer=new r.UserOverridableBuffer,this.m_indexByExpirationTimeBuffer=new r.UserOverridableBuffer,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new Cr,this.m_prev=null,this.m_next=null,this.SetStrictContactCheck(t.strictContactCheck),this.SetDensity(t.density),this.SetGravityScale(t.gravityScale),this.SetRadius(t.radius),this.SetMaxParticleCount(t.maxCount),this.m_def=t.Clone(),this.m_world=e,this.SetDestructionByAge(this.m_def.destroyByAge)}return l(r,[{key:"Drop",value:function(){for(;this.m_groupList;)this.DestroyParticleGroup(this.m_groupList);this.FreeUserOverridableBuffer(this.m_handleIndexBuffer),this.FreeUserOverridableBuffer(this.m_flagsBuffer),this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer),this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer),this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer),this.FreeUserOverridableBuffer(this.m_positionBuffer),this.FreeUserOverridableBuffer(this.m_velocityBuffer),this.FreeUserOverridableBuffer(this.m_colorBuffer),this.FreeUserOverridableBuffer(this.m_userDataBuffer),this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer),this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer),this.FreeBuffer(this.m_forceBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_weightBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_staticPressureBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulationBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulation2Buffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_depthBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_groupBuffer,this.m_internalAllocatedCapacity)}},{key:"CreateParticle",value:function(t){if(this.m_world.IsLocked())throw new Error;if(this.m_count>=this.m_internalAllocatedCapacity){var n=this.m_count?2*this.m_count:256;this.ReallocateInternalAllocatedBuffers(n)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return-1;this.DestroyOldestParticle(0,!1),this.SolveZombie()}var r=this.m_count++;if(!this.m_flagsBuffer.data)throw new Error;if(this.m_flagsBuffer.data[r]=0,this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[r]=0),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[r]=0),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[r]=0),!this.m_positionBuffer.data)throw new Error;if(!this.m_velocityBuffer.data)throw new Error;this.m_positionBuffer.data[r]=(this.m_positionBuffer.data[r]||new E).Copy(e(t.position,E.ZERO)),this.m_velocityBuffer.data[r]=(this.m_velocityBuffer.data[r]||new E).Copy(e(t.velocity,E.ZERO)),this.m_weightBuffer[r]=0,this.m_forceBuffer[r]=(this.m_forceBuffer[r]||new E).SetZero(),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[r]=0),this.m_depthBuffer&&(this.m_depthBuffer[r]=0);var i=(new F).Copy(e(t.color,F.ZERO));!this.m_colorBuffer.data&&i.IsZero()||(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[r]=(this.m_colorBuffer.data[r]||new F).Copy(i)),(this.m_userDataBuffer.data||t.userData)&&(this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[r]=t.userData),this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[r]=null);var o=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],a=e(t.lifetime,0),s=a>0;if(this.m_expirationTimeBuffer.data||s){if(this.SetParticleLifetime(r,s?a:this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())),!this.m_indexByExpirationTimeBuffer.data)throw new Error;this.m_indexByExpirationTimeBuffer.data[r]=r}o.index=r;var u=e(t.group,null);return this.m_groupBuffer[r]=u,u&&(u.m_firstIndex1&&void 0!==arguments[1]&&arguments[1];if(!this.m_flagsBuffer.data)throw new Error;var r=t.b2ParticleFlag.b2_zombieParticle;n&&(r|=t.b2ParticleFlag.b2_destructionListenerParticle),this.SetParticleFlags(e,this.m_flagsBuffer.data[e]|r)}},{key:"DestroyOldestParticle",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.GetParticleCount();if(!this.m_indexByExpirationTimeBuffer.data)throw new Error;if(!this.m_expirationTimeBuffer.data)throw new Error;var r=this.m_indexByExpirationTimeBuffer.data[n-(t+1)],i=this.m_indexByExpirationTimeBuffer.data[t];this.DestroyParticle(this.m_expirationTimeBuffer.data[r]>0?r:i,e)}},{key:"DestroyParticlesInShape",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=r.DestroyParticlesInShape_s_aabb;if(this.m_world.IsLocked())throw new Error;var o=new r.DestroyParticlesInShapeCallback(this,t,e,n),a=i;return t.ComputeAABB(a,e,0),this.m_world.QueryAABB(o,a),o.Destroyed()}},{key:"CreateParticleGroup",value:function(t){var n=r.CreateParticleGroup_s_transform;if(this.m_world.IsLocked())throw new Error;var i=n;i.SetPositionAngle(e(t.position,E.ZERO),e(t.angle,0));var o=this.m_count;if(t.shape&&this.CreateParticlesWithShapeForGroup(t.shape,t,i),t.shapes&&this.CreateParticlesWithShapesForGroup(t.shapes,e(t.shapeCount,t.shapes.length),t,i),t.positionData)for(var a=e(t.particleCount,t.positionData.length),s=0;s0&&(this.m_lastBodyContactStepBuffer.data=this.RequestBuffer(this.m_lastBodyContactStepBuffer.data),this.m_bodyContactCountBuffer.data=this.RequestBuffer(this.m_bodyContactCountBuffer.data),this.m_consecutiveContactStepsBuffer.data=this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data))}},{key:"GetStuckCandidates",value:function(){return this.m_stuckParticleBuffer.Data()}},{key:"GetStuckCandidateCount",value:function(){return this.m_stuckParticleBuffer.GetCount()}},{key:"ComputeCollisionEnergy",value:function(){if(!this.m_velocityBuffer.data)throw new Error;for(var t=r.ComputeCollisionEnergy_s_v,e=this.m_velocityBuffer.data,n=0,i=0;i0?this.GetQuantizedTimeElapsed()+o:o;a!==this.m_expirationTimeBuffer.data[t]&&(this.m_expirationTimeBuffer.data[t]=a,this.m_expirationTimeBufferRequiresSorting=!0)}},{key:"GetParticleLifetime",value:function(t){return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t])}},{key:"SetDestructionByAge",value:function(t){t&&this.GetExpirationTimeBuffer(),this.m_def.destroyByAge=t}},{key:"GetDestructionByAge",value:function(){return this.m_def.destroyByAge}},{key:"GetExpirationTimeBuffer",value:function(){return this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_expirationTimeBuffer.data}},{key:"ExpirationTimeToLifetime",value:function(t){return(t>0?t-this.GetQuantizedTimeElapsed():t)*this.m_def.lifetimeGranularity}},{key:"GetIndexByExpirationTimeBuffer",value:function(){if(this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),!this.m_indexByExpirationTimeBuffer.data)throw new Error;return this.m_indexByExpirationTimeBuffer.data}},{key:"ParticleApplyLinearImpulse",value:function(t,e){this.ApplyLinearImpulse(t,t+1,e)}},{key:"ApplyLinearImpulse",value:function(t,e,n){if(!this.m_velocityBuffer.data)throw new Error;for(var r=this.m_velocityBuffer.data,i=(e-t)*this.GetParticleMass(),o=(new E).Copy(n).SelfMul(1/i),a=t;a3&&void 0!==arguments[3]?arguments[3]:0,o=r.QueryShapeAABB_s_aabb;e.ComputeAABB(o,n,i),this.QueryAABB(t,o)}},{key:"QueryPointAABB",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.008,i=r.QueryPointAABB_s_aabb;i.lowerBound.Set(e.x-n,e.y-n),i.upperBound.Set(e.x+n,e.y+n),this.QueryAABB(t,i)}},{key:"RayCast",value:function(t,e,n){var i=r.RayCast_s_aabb,o=r.RayCast_s_p,a=r.RayCast_s_v,s=r.RayCast_s_n,u=r.RayCast_s_point;if(0!==this.m_proxyBuffer.count){if(!this.m_positionBuffer.data)throw new Error;var l=this.m_positionBuffer.data,c=i;E.MinV(e,n,c.lowerBound),E.MaxV(e,n,c.upperBound);for(var f,h=1,m=E.SubVV(n,e,a),d=E.DotVV(m,m),p=this.GetInsideBoundsEnumerator(c);(f=p.GetNext())>=0;){var _=E.SubVV(e,l[f],o),v=E.DotVV(_,m),g=v*v-d*(E.DotVV(_,_)-this.m_squaredDiameter);if(g>=0){var b=S(g),x=(-v-b)/d;if(x>h)continue;if(x<0&&((x=(-v+b)/d)<0||x>h))continue;var w=E.AddVMulSV(_,x,m,s);w.Normalize();var C=t.ReportParticle(this,f,E.AddVMulSV(e,x,m,u),w,x);if((h=y(h,C))<=0)break}}}}},{key:"ComputeAABB",value:function(t){var e=this.GetParticleCount();if(t.lowerBound.x=+n,t.lowerBound.y=+n,t.upperBound.x=-n,t.upperBound.y=-n,!this.m_positionBuffer.data)throw new Error;for(var r=this.m_positionBuffer.data,i=0;ie?e:t}if(t=e(t,this.m_def.maxCount),t=e(t,this.m_flagsBuffer.userSuppliedCapacity),t=e(t,this.m_positionBuffer.userSuppliedCapacity),t=e(t,this.m_velocityBuffer.userSuppliedCapacity),t=e(t,this.m_colorBuffer.userSuppliedCapacity),t=e(t,this.m_userDataBuffer.userSuppliedCapacity),this.m_internalAllocatedCapacity0;this.m_lastBodyContactStepBuffer.data=this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer,this.m_internalAllocatedCapacity,t,n),this.m_bodyContactCountBuffer.data=this.ReallocateBuffer4(this.m_bodyContactCountBuffer,this.m_internalAllocatedCapacity,t,n),this.m_consecutiveContactStepsBuffer.data=this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer,this.m_internalAllocatedCapacity,t,n),this.m_positionBuffer.data=this.ReallocateBuffer4(this.m_positionBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_velocityBuffer.data=this.ReallocateBuffer4(this.m_velocityBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_forceBuffer=this.ReallocateBuffer5(this.m_forceBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_weightBuffer=this.ReallocateBuffer5(this.m_weightBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_staticPressureBuffer=this.ReallocateBuffer5(this.m_staticPressureBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_accumulationBuffer=this.ReallocateBuffer5(this.m_accumulationBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_accumulation2Buffer=this.ReallocateBuffer5(this.m_accumulation2Buffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_depthBuffer=this.ReallocateBuffer5(this.m_depthBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_colorBuffer.data=this.ReallocateBuffer4(this.m_colorBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_groupBuffer=this.ReallocateBuffer5(this.m_groupBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_userDataBuffer.data=this.ReallocateBuffer4(this.m_userDataBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_expirationTimeBuffer.data=this.ReallocateBuffer4(this.m_expirationTimeBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_indexByExpirationTimeBuffer.data=this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_internalAllocatedCapacity=t}}},{key:"CreateParticleForGroup",value:function(t,n,r){var i=new rr;i.flags=e(t.flags,0),D.MulXV(n,r,i.position),E.AddVV(e(t.linearVelocity,E.ZERO),E.CrossSV(e(t.angularVelocity,0),E.SubVV(i.position,e(t.position,E.ZERO),E.s_t0),E.s_t0),i.velocity),i.color.Copy(e(t.color,F.ZERO)),i.lifetime=e(t.lifetime,0),i.userData=t.userData,this.CreateParticle(i)}},{key:"CreateParticlesStrokeShapeForGroup",value:function(n,i,o){var a=r.CreateParticlesStrokeShapeForGroup_s_edge,s=r.CreateParticlesStrokeShapeForGroup_s_d,u=r.CreateParticlesStrokeShapeForGroup_s_p,l=e(i.stride,0);0===l&&(l=this.GetParticleStride());for(var c=0,f=n.GetChildCount(),h=0;h1&&void 0!==arguments[1]&&arguments[1],n=t.m_firstIndex;n=e&&m=e&&dg||E.DotVV(_,_)>g||E.DotVV(v,v)>g)return;var b=B.m_groupBuffer[t],x=B.m_groupBuffer[e],w=B.m_groupBuffer[n],S=B.m_triadBuffer.data[B.m_triadBuffer.Append()];S.indexA=t,S.indexB=e,S.indexC=n,S.flags=l|c|f,S.strength=y(y(b?b.m_strength:1,x?x.m_strength:1),w?w.m_strength:1);var C=(h.x+m.x+d.x)/3,A=(h.y+m.y+d.y)/3;S.pa.x=h.x-C,S.pa.y=h.y-A,S.pb.x=m.x-C,S.pb.y=m.y-A,S.pc.x=d.x-C,S.pc.y=d.y-A,S.ka=-E.DotVV(v,p),S.kb=-E.DotVV(p,_),S.kc=-E.DotVV(_,v),S.s=E.CrossVV(h,m)+E.CrossVV(m,d)+E.CrossVV(d,h)}})),mr(this.m_triadBuffer.data,0,this.m_triadBuffer.count,r.CompareTriadIndices),this.m_triadBuffer.Unique(r.MatchTriadIndices)}}},{key:"UpdatePairsAndTriadsWithReactiveParticles",value:function(){var e=new r.ReactiveFilter(this.m_flagsBuffer);if(this.UpdatePairsAndTriads(0,this.m_count,e),!this.m_flagsBuffer.data)throw new Error;for(var n=0;n>0,A=0;AO&&(this.m_depthBuffer[V]=O,B=!0),I>R&&(this.m_depthBuffer[E]=R,B=!0)}if(!B)break}for(var D=0;D0){if(!this.m_bodyContactCountBuffer.data)throw new Error;if(!this.m_lastBodyContactStepBuffer.data)throw new Error;if(!this.m_consecutiveContactStepsBuffer.data)throw new Error;for(var n=this.GetParticleCount(),i=0;ithis.m_lastBodyContactStepBuffer.data[i]+1&&(this.m_consecutiveContactStepsBuffer.data[i]=0)}this.m_bodyContactBuffer.SetCount(0),this.m_stuckParticleBuffer.SetCount(0);var o=t;this.ComputeAABB(o);var a=new r.UpdateBodyContactsCallback(this,this.GetFixtureContactFilter());this.m_world.QueryAABB(a,o),this.m_def.strictContactCheck&&this.RemoveSpuriousBodyContacts(),this.NotifyBodyContactListenerPostContact(e)}},{key:"Solve",value:function(e){var n=r.Solve_s_subStep;if(0!==this.m_count&&(this.m_expirationTimeBuffer.data&&this.SolveLifetimes(e),this.m_allParticleFlags&t.b2ParticleFlag.b2_zombieParticle&&this.SolveZombie(),this.m_needsUpdateAllParticleFlags&&this.UpdateAllParticleFlags(),this.m_needsUpdateAllGroupFlags&&this.UpdateAllGroupFlags(),!this.m_paused))for(this.m_iterationIndex=0;this.m_iterationIndexn&&i.SelfMul(S(n/o))}}},{key:"SolveGravity",value:function(t){if(!this.m_velocityBuffer.data)throw new Error;for(var e=r.SolveGravity_s_gravity,n=this.m_velocityBuffer.data,i=E.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),o=0;o=0;){var j=p[D],L=this.m_groupBuffer[D];if(P!==L&&V!==L){var F=this.GetLinearVelocity(L,D,j,u),G=E.SubVV(j,A,l),N=E.SubVV(F,T,c),z=E.CrossVV(O,N),q=E.CrossVV(I,N)-E.CrossVV(G,O),U=E.CrossVV(I,G),W=void 0,J=void 0,H=f,X=h;if(0===z){if(0===q)continue;if(!((J=-U/q)>=0&&J=0&&W<=1))continue}else{var $=q*q-4*U*z;if($<0)continue;var Y=S($),Z=(-q-Y)/(2*z),K=(-q+Y)/(2*z);if(Z>K){var Q=Z;Z=K,K=Q}if(J=Z,E.AddVMulSV(I,J,O,H),E.AddVMulSV(G,J,N,X),W=E.DotVV(H,X)/E.DotVV(H,H),!(J>=0&&J=0&&W<=1)){if(!((J=K)>=0&&J=0&&W<=1))continue}}var tt=m;tt.x=T.x+W*O.x-F.x,tt.y=T.y+W*O.y-F.y;var et=E.MulSV(g,tt,d);if(L&&this.IsRigidGroup(L)){var nt=L.GetMass(),rt=L.GetInertia();nt>0&&L.m_linearVelocity.SelfMulAdd(1/nt,et),rt>0&&(L.m_angularVelocity+=E.CrossVV(E.SubVV(j,L.GetCenter(),E.s_t0),et)/rt)}else _[D].SelfAdd(tt);this.ParticleApplyForce(D,et.SelfMul(-e.inv_dt))}}}}}},{key:"SolveStaticPressure",value:function(e){if(!this.m_flagsBuffer.data)throw new Error;this.m_staticPressureBuffer=this.RequestBuffer(this.m_staticPressureBuffer);for(var n=this.GetCriticalPressure(e),r=this.m_def.staticPressureStrength*n,i=.25*n,o=this.m_def.staticPressureRelaxation,a=0;a.25){var h=l.body,m=l.mass,d=i[c],p=l.normal,_=E.MulSV(a*m*(f-.25),p,n);o[c].SelfMulSub(s,_),h.ApplyLinearImpulse(_,d,!0)}}}for(var y=0;y.25){var b=v.indexA,x=v.indexB,w=v.normal,S=E.MulSV(a*(g-.25),w,n);o[b].SelfSub(S),o[x].SelfAdd(S)}}}}},{key:"SolveSolid",value:function(t){var e=r.SolveSolid_s_f;if(!this.m_velocityBuffer.data)throw new Error;var n=this.m_velocityBuffer.data;this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer);for(var i=t.inv_dt*this.m_def.ejectionStrength,o=0;o=0?(B=y(B,E),k=v(k,E+1)):P=!0}Bi:o})),this.m_expirationTimeBufferRequiresSorting=!1);for(var o=i-1;o>=0;--o){var a=r[o],s=n[a];if(e3)return!0;var s=t.Copy(r.normal);if(s.SelfMul(i.m_particleDiameter*(1-r.weight)),!i.m_positionBuffer.data)throw new Error;var u=E.AddVV(i.m_positionBuffer.data[r.index],s,e);if(!r.fixture.TestPoint(u)){for(var l=r.fixture.GetShape().GetChildCount(),c=0;cthis.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=t)),this.m_lastBodyContactStepBuffer.data[t]=this.m_timestamp}}},{key:"ValidateParticleIndex",value:function(t){return t>=0&&t0?1/r:0,e[0]=i>0?1/i:0,n[0]=E.CrossVV(E.SubVV(a,o,E.s_t0),s)}},{key:"InitDampingParameterWithRigidGroupOrParticle",value:function(e,n,r,i,o,a,s,u){if(o&&i)this.InitDampingParameter(e,n,r,o.GetMass(),o.GetInertia(),o.GetCenter(),s,u);else{if(!this.m_flagsBuffer.data)throw new Error;var l=this.m_flagsBuffer.data[a];this.InitDampingParameter(e,n,r,l&t.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,s,s,u)}}},{key:"ComputeDampingImpulse",value:function(t,e,n,r,i,o,a){var s=t+e*n*n+r+i*o*o;return s>0?a/s:0}},{key:"ApplyDamping",value:function(t,e,n,r,i,o,a,s){if(i&&r)i.m_linearVelocity.SelfMulAdd(a*t,s),i.m_angularVelocity+=a*n*e;else{if(!this.m_velocityBuffer.data)throw new Error;this.m_velocityBuffer.data[o].SelfMulAdd(a*t,s)}}}],[{key:"computeTag",value:function(t,e){return(e+r.yOffset>>>0<>>0)>>>0}},{key:"computeRelativeTag",value:function(t,e,n){return t+(n<>>0}},{key:"IsSignificantForce",value:function(t){return 0!==t.x||0!==t.y}},{key:"ParticleCanBeConnected",value:function(e,n){return 0!=(e&(t.b2ParticleFlag.b2_wallParticle|t.b2ParticleFlag.b2_springParticle|t.b2ParticleFlag.b2_elasticParticle))||null!==n&&0!=(n.GetGroupFlags()&t.b2ParticleGroupFlag.b2_rigidParticleGroup)}},{key:"ComparePairIndices",value:function(t,e){var n=t.indexA-e.indexA;return 0!==n?n<0:t.indexBe.weight:t.index>>0,this.m_xUpper=(i&e.xMask)>>>0,this.m_yLower=(r&e.yMask)>>>0,this.m_yUpper=(i&e.yMask)>>>0,this.m_first=o,this.m_last=a}return l(t,[{key:"GetNext",value:function(){for(;this.m_first>>0;if(t>=this.m_xLower&&t<=this.m_xUpper)return this.m_system.m_proxyBuffer.data[this.m_first++].index;this.m_first++}return-1}}]),t}(),e.ParticleListNode=function(){return function t(){u(this,t),this.next=null,this.count=0,this.index=0}}(),e.FixedSetAllocator=function(){function t(){u(this,t)}return l(t,[{key:"Allocate",value:function(t,e){return e}},{key:"Clear",value:function(){}},{key:"GetCount",value:function(){return 0}},{key:"Invalidate",value:function(t){}},{key:"GetValidBuffer",value:function(){return[]}},{key:"GetBuffer",value:function(){return[]}},{key:"SetCount",value:function(t){}}]),t}(),e.FixtureParticle=function(){return function t(e,n){u(this,t),this.second=-1,this.first=e,this.second=n}}();var r=function(t){a(n,t);var e=s(n);function n(){return u(this,n),e.apply(this,arguments)}return l(n,[{key:"Initialize",value:function(t,e){}},{key:"Find",value:function(t){return-1}}]),n}(e.FixedSetAllocator);e.FixtureParticleSet=r,e.ParticlePair=function(){return function t(e,n){u(this,t),this.first=-1,this.second=-1,this.first=e,this.second=n}}();var i=function(t){a(n,t);var e=s(n);function n(){return u(this,n),e.apply(this,arguments)}return l(n,[{key:"Initialize",value:function(t,e){}},{key:"Find",value:function(t){return-1}}]),n}(e.FixedSetAllocator);e.b2ParticlePairSet=i,e.ConnectionFilter=function(){function t(){u(this,t)}return l(t,[{key:"IsNecessary",value:function(t){return!0}},{key:"ShouldCreatePair",value:function(t,e){return!0}},{key:"ShouldCreateTriad",value:function(t,e,n){return!0}}]),t}(),e.DestroyParticlesInShapeCallback=function(t){a(n,t);var e=s(n);function n(t,r,i,o){var a;return u(this,n),(a=e.call(this)).m_callDestructionListener=!1,a.m_destroyed=0,a.m_system=t,a.m_shape=r,a.m_xf=i,a.m_callDestructionListener=o,a.m_destroyed=0,a}return l(n,[{key:"ReportFixture",value:function(t){return!1}},{key:"ReportParticle",value:function(t,e){if(t!==this.m_system)return!1;if(!this.m_system.m_positionBuffer.data)throw new Error;return this.m_shape.TestPoint(this.m_xf,this.m_system.m_positionBuffer.data[e])&&(this.m_system.DestroyParticle(e,this.m_callDestructionListener),this.m_destroyed++),!0}},{key:"Destroyed",value:function(){return this.m_destroyed}}]),n}(qn);var o=function(t){a(n,t);var e=s(n);function n(t){var r;return u(this,n),(r=e.call(this)).m_threshold=0,r.m_threshold=t,r}return l(n,[{key:"ShouldCreatePair",value:function(t,e){return t1&&void 0!==arguments[1]?arguments[1]:e.length;return u(this,i),(n=r.call(this,t.b2ShapeType.e_unknown,0)).m_shapeCount=0,n.m_shapes=e,n.m_shapeCount=o,n}return l(i,[{key:"Clone",value:function(){throw new Error}},{key:"GetChildCount",value:function(){return 1}},{key:"TestPoint",value:function(t,e){for(var n=0;n0?1/h:0,p=m>0?1/m:0,_=this.m_system.m_flagsBuffer.data[i]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),y=E.SubVV(s,f,a),v=E.CrossVV(y,u),g=_+d+p*v*v,b=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];b.index=i,b.body=c,b.fixture=n,b.weight=1-l*this.m_system.m_inverseDiameter,b.normal.Copy(u.SelfNeg()),b.mass=g>0?1/g:0,this.m_system.DetectStuckParticle(i)}}}]),i}(gr);f.ReportFixtureAndParticle_s_n=new E,f.ReportFixtureAndParticle_s_rp=new E,e.UpdateBodyContactsCallback=f;var h=function(n){a(i,n);var r=s(i);function i(t,e){var n;return u(this,i),(n=r.call(this,t)).m_step=e,n}return l(i,[{key:"ReportFixtureAndParticle",value:function(n,r,i){var o=e.SolveCollisionCallback.ReportFixtureAndParticle_s_p1,a=e.SolveCollisionCallback.ReportFixtureAndParticle_s_output,s=e.SolveCollisionCallback.ReportFixtureAndParticle_s_input,u=e.SolveCollisionCallback.ReportFixtureAndParticle_s_p,l=e.SolveCollisionCallback.ReportFixtureAndParticle_s_v,c=e.SolveCollisionCallback.ReportFixtureAndParticle_s_f,f=n.GetBody();if(!this.m_system.m_positionBuffer.data)throw new Error;if(!this.m_system.m_velocityBuffer.data)throw new Error;var h=this.m_system.m_positionBuffer.data[i],m=this.m_system.m_velocityBuffer.data[i],d=a,p=s;if(0===this.m_system.m_iterationIndex){var _=D.MulTXV(f.m_xf0,h,o);n.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(_.SelfSub(f.GetLocalCenter()),R.MulRV(f.m_xf0.q,_,_),R.MulTRV(f.m_xf.q,_,_),_.SelfAdd(f.GetLocalCenter())),D.MulXV(f.m_xf,_,p.p1)}else p.p1.Copy(h);if(E.AddVMulSV(h,this.m_step.dt,m,p.p2),p.maxFraction=1,n.RayCast(d,p,r)){var y=d.normal,v=u;v.x=(1-d.fraction)*p.p1.x+d.fraction*p.p2.x+.008*y.x,v.y=(1-d.fraction)*p.p1.y+d.fraction*p.p2.y+.008*y.y;var g=l;g.x=this.m_step.inv_dt*(v.x-h.x),g.y=this.m_step.inv_dt*(v.y-h.y),this.m_system.m_velocityBuffer.data[i].Copy(g);var b=c;b.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(m.x-g.x),b.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(m.y-g.y),this.m_system.ParticleApplyForce(i,b)}}},{key:"ReportParticle",value:function(t,e){return!1}}]),i}(gr);h.ReportFixtureAndParticle_s_p1=new E,h.ReportFixtureAndParticle_s_output=new xt,h.ReportFixtureAndParticle_s_input=new bt,h.ReportFixtureAndParticle_s_p=new E,h.ReportFixtureAndParticle_s_v=new E,h.ReportFixtureAndParticle_s_f=new E,e.SolveCollisionCallback=h}(Ar||(Ar={}));var Br=function(){function e(t){u(this,e),this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new Un,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new E,this.m_allowSleep=!0,this.m_destructionListener=null,this.m_debugDraw=null,this.m_inv_dt0=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_profile=new Wn,this.m_island=new nr,this.s_stack=[],this.m_controllerList=null,this.m_controllerCount=0,this.m_gravity.Copy(t)}return l(e,[{key:"SetDestructionListener",value:function(t){this.m_destructionListener=t}},{key:"SetContactFilter",value:function(t){this.m_contactManager.m_contactFilter=t}},{key:"SetContactListener",value:function(t){this.m_contactManager.m_contactListener=t}},{key:"SetDebugDraw",value:function(t){this.m_debugDraw=t}},{key:"CreateBody",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.IsLocked())throw new Error;var e=new cn(t,this);return e.m_prev=null,e.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=e),this.m_bodyList=e,++this.m_bodyCount,e}},{key:"DestroyBody",value:function(t){if(this.IsLocked())throw new Error;for(var e=t.m_jointList;e;){var n=e;e=e.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(n.joint),this.DestroyJoint(n.joint),t.m_jointList=e}t.m_jointList=null;for(var r=t.m_controllerList;r;){var i=r;r=r.nextController,i.controller.RemoveBody(t)}for(var o=t.m_contactList;o;){var a=o;o=o.next,this.m_contactManager.Destroy(a.contact)}t.m_contactList=null;for(var s=t.m_fixtureList;s;){var u=s;s=s.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(u),u.DestroyProxies(),u.Destroy(),t.m_fixtureList=s,t.m_fixtureCount-=1}t.m_fixtureList=null,t.m_fixtureCount=0,t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_bodyList&&(this.m_bodyList=t.m_next),--this.m_bodyCount}},{key:"CreateJoint",value:function(t){if(this.IsLocked())throw new Error;var n=e._Joint_Create(t,null);n.m_prev=null,n.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=n),this.m_jointList=n,++this.m_jointCount,n.m_edgeA.prev=null,n.m_edgeA.next=n.m_bodyA.m_jointList,n.m_bodyA.m_jointList&&(n.m_bodyA.m_jointList.prev=n.m_edgeA),n.m_bodyA.m_jointList=n.m_edgeA,n.m_edgeB.prev=null,n.m_edgeB.next=n.m_bodyB.m_jointList,n.m_bodyB.m_jointList&&(n.m_bodyB.m_jointList.prev=n.m_edgeB),n.m_bodyB.m_jointList=n.m_edgeB;var r=t.bodyA,i=t.bodyB;if(!t.collideConnected)for(var o=i.GetContactList();o;)o.other===r&&o.contact.FlagForFiltering(),o=o.next;return n}},{key:"DestroyJoint",value:function(t){if(this.IsLocked())throw new Error;var n=t.m_collideConnected;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_jointList&&(this.m_jointList=t.m_next);var r=t.m_bodyA,i=t.m_bodyB;if(r.SetAwake(!0),i.SetAwake(!0),t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA===r.m_jointList&&(r.m_jointList=t.m_edgeA.next),t.m_edgeA.prev=null,t.m_edgeA.next=null,t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB===i.m_jointList&&(i.m_jointList=t.m_edgeB.next),t.m_edgeB.prev=null,t.m_edgeB.next=null,e._Joint_Destroy(t,null),--this.m_jointCount,!n)for(var o=i.GetContactList();o;)o.other===r&&o.contact.FlagForFiltering(),o=o.next}},{key:"CreateParticleSystem",value:function(t){if(this.IsLocked())throw new Error;var e=new Ar(t,this);return e.m_prev=null,e.m_next=this.m_particleSystemList,this.m_particleSystemList&&(this.m_particleSystemList.m_prev=e),this.m_particleSystemList=e,e}},{key:"DestroyParticleSystem",value:function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_particleSystemList&&(this.m_particleSystemList=t.m_next)}},{key:"CalculateReasonableParticleIterations",value:function(t){return null===this.m_particleSystemList?1:ir(this.m_gravity.Length(),function(t){for(var e=n,r=t.GetParticleSystemList();null!==r;r=r.m_next)e=y(e,r.GetRadius());return e}(this),t)}},{key:"Step",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.CalculateReasonableParticleIterations(t),o=e.Step_s_stepTimer.Reset();this.m_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_newFixture=!1),this.m_locked=!0;var a=e.Step_s_step;a.dt=t,a.velocityIterations=n,a.positionIterations=r,a.particleIterations=i,a.inv_dt=t>0?1/t:0,a.dtRatio=this.m_inv_dt0*t,a.warmStarting=this.m_warmStarting;var s=e.Step_s_timer.Reset();if(this.m_contactManager.Collide(),this.m_profile.collide=s.GetMilliseconds(),this.m_stepComplete&&a.dt>0){for(var u=e.Step_s_timer.Reset(),l=this.m_particleSystemList;l;l=l.m_next)l.Solve(a);this.Solve(a),this.m_profile.solve=u.GetMilliseconds()}if(this.m_continuousPhysics&&a.dt>0){var c=e.Step_s_timer.Reset();this.SolveTOI(a),this.m_profile.solveTOI=c.GetMilliseconds()}a.dt>0&&(this.m_inv_dt0=a.inv_dt),this.m_clearForces&&this.ClearForces(),this.m_locked=!1,this.m_profile.step=o.GetMilliseconds()}},{key:"ClearForces",value:function(){for(var t=this.m_bodyList;t;t=t.m_next)t.m_force.SetZero(),t.m_torque=0}},{key:"DrawParticleSystem",value:function(t){if(null!==this.m_debugDraw){var e=t.GetParticleCount();if(e){var n=t.GetRadius(),r=t.GetPositionBuffer();if(t.m_colorBuffer.data){var i=t.GetColorBuffer();this.m_debugDraw.DrawParticles(r,n,i,e)}else this.m_debugDraw.DrawParticles(r,n,null,e)}}}},{key:"DrawDebugData",value:function(){if(null!==this.m_debugDraw){var n=this.m_debugDraw.GetFlags(),r=e.DrawDebugData_s_color.SetRGB(0,0,0);if(n&t.b2DrawFlags.e_shapeBit)for(var i=this.m_bodyList;i;i=i.m_next){var o=i.m_xf;this.m_debugDraw.PushTransform(o);for(var a=i.GetFixtureList();a;a=a.m_next)i.IsActive()?i.GetType()===t.b2BodyType.b2_staticBody?(r.SetRGB(.5,.9,.5),this.DrawShape(a,r)):i.GetType()===t.b2BodyType.b2_kinematicBody?(r.SetRGB(.5,.5,.9),this.DrawShape(a,r)):i.IsAwake()?(r.SetRGB(.9,.7,.7),this.DrawShape(a,r)):(r.SetRGB(.6,.6,.6),this.DrawShape(a,r)):(r.SetRGB(.5,.5,.3),this.DrawShape(a,r));this.m_debugDraw.PopTransform(o)}if(n&t.b2DrawFlags.e_particleBit)for(var s=this.m_particleSystemList;s;s=s.m_next)this.DrawParticleSystem(s);if(n&t.b2DrawFlags.e_jointBit)for(var u=this.m_jointList;u;u=u.m_next)this.DrawJoint(u);if(n&t.b2DrawFlags.e_aabbBit){r.SetRGB(.9,.3,.9);for(var l=e.DrawDebugData_s_vs,c=this.m_bodyList;c;c=c.m_next)if(c.IsActive())for(var f=c.GetFixtureList();f;f=f.m_next)for(var h=0;h1&&void 0!==arguments[1]?arguments[1]:[];return this.QueryAABB(null,t,(function(t){return e.push(t),!0})),e}},{key:"QueryPointAABB",value:function(t,e,n){if(this.m_contactManager.m_broadPhase.QueryPoint(e,(function(e){var r=e.userData.fixture;return t?t.ReportFixture(r):!n||n(r)})),t instanceof qn)for(var r=this.m_particleSystemList;r;r=r.m_next)t.ShouldQueryParticleSystem(r)&&r.QueryPointAABB(t,e)}},{key:"QueryAllPointAABB",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.QueryPointAABB(null,t,(function(t){return e.push(t),!0})),e}},{key:"QueryFixtureShape",value:function(t,n,r,i,o){var a=e.QueryFixtureShape_s_aabb;if(n.ComputeAABB(a,i,r),this.m_contactManager.m_broadPhase.Query(a,(function(e){var a=e.userData,s=a.fixture;if(Pt(n,r,s.GetShape(),a.childIndex,i,s.GetBody().GetTransform())){if(t)return t.ReportFixture(s);if(o)return o(s)}return!0})),t instanceof qn)for(var s=this.m_particleSystemList;s;s=s.m_next)t.ShouldQueryParticleSystem(s)&&s.QueryAABB(t,a)}},{key:"QueryAllFixtureShape",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return this.QueryFixtureShape(null,t,e,n,(function(t){return r.push(t),!0})),r}},{key:"QueryFixturePoint",value:function(t,e,n){if(this.m_contactManager.m_broadPhase.QueryPoint(e,(function(r){var i=r.userData.fixture;if(i.TestPoint(e)){if(t)return t.ReportFixture(i);if(n)return n(i)}return!0})),t)for(var r=this.m_particleSystemList;r;r=r.m_next)t.ShouldQueryParticleSystem(r)&&r.QueryPointAABB(t,e)}},{key:"QueryAllFixturePoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.QueryFixturePoint(null,t,(function(t){return e.push(t),!0})),e}},{key:"RayCast",value:function(t,n,r,i){var o=e.RayCast_s_input;if(o.maxFraction=1,o.p1.Copy(n),o.p2.Copy(r),this.m_contactManager.m_broadPhase.RayCast(o,(function(o,a){var s=a.userData,u=s.fixture,l=s.childIndex,c=e.RayCast_s_output;if(u.RayCast(c,o,l)){var f=c.fraction,h=e.RayCast_s_point;if(h.Set((1-f)*n.x+f*r.x,(1-f)*n.y+f*r.y),t)return t.ReportFixture(u,h,c.normal,f);if(i)return i(u,h,c.normal,f)}return o.maxFraction})),t)for(var a=this.m_particleSystemList;a;a=a.m_next)t.ShouldQueryParticleSystem(a)&&a.RayCast(t,n,r)}},{key:"RayCastOne",value:function(t,e){var n=null,r=1;return this.RayCast(null,t,e,(function(t,e,i,o){return o2&&void 0!==arguments[2]?arguments[2]:[];return this.RayCast(null,t,e,(function(t,e,r,i){return n.push(t),1})),n}},{key:"GetBodyList",value:function(){return this.m_bodyList}},{key:"GetJointList",value:function(){return this.m_jointList}},{key:"GetParticleSystemList",value:function(){return this.m_particleSystemList}},{key:"GetContactList",value:function(){return this.m_contactManager.m_contactList}},{key:"SetAllowSleeping",value:function(t){if(t!==this.m_allowSleep&&(this.m_allowSleep=t,!this.m_allowSleep))for(var e=this.m_bodyList;e;e=e.m_next)e.SetAwake(!0)}},{key:"GetAllowSleeping",value:function(){return this.m_allowSleep}},{key:"SetWarmStarting",value:function(t){this.m_warmStarting=t}},{key:"GetWarmStarting",value:function(){return this.m_warmStarting}},{key:"SetContinuousPhysics",value:function(t){this.m_continuousPhysics=t}},{key:"GetContinuousPhysics",value:function(){return this.m_continuousPhysics}},{key:"SetSubStepping",value:function(t){this.m_subStepping=t}},{key:"GetSubStepping",value:function(){return this.m_subStepping}},{key:"GetProxyCount",value:function(){return this.m_contactManager.m_broadPhase.GetProxyCount()}},{key:"GetBodyCount",value:function(){return this.m_bodyCount}},{key:"GetJointCount",value:function(){return this.m_jointCount}},{key:"GetContactCount",value:function(){return this.m_contactManager.m_contactCount}},{key:"GetTreeHeight",value:function(){return this.m_contactManager.m_broadPhase.GetTreeHeight()}},{key:"GetTreeBalance",value:function(){return this.m_contactManager.m_broadPhase.GetTreeBalance()}},{key:"GetTreeQuality",value:function(){return this.m_contactManager.m_broadPhase.GetTreeQuality()}},{key:"SetGravity",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!E.IsEqualToV(this.m_gravity,t)&&(this.m_gravity.Copy(t),e))for(var n=this.m_bodyList;n;n=n.m_next)n.SetAwake(!0)}},{key:"GetGravity",value:function(){return this.m_gravity}},{key:"IsLocked",value:function(){return this.m_locked}},{key:"SetAutoClearForces",value:function(t){this.m_clearForces=t}},{key:"GetAutoClearForces",value:function(){return this.m_clearForces}},{key:"ShiftOrigin",value:function(t){if(this.IsLocked())throw new Error;for(var e=this.m_bodyList;e;e=e.m_next)e.m_xf.p.SelfSub(t),e.m_sweep.c0.SelfSub(t),e.m_sweep.c.SelfSub(t);for(var n=this.m_jointList;n;n=n.m_next)n.ShiftOrigin(t);this.m_contactManager.m_broadPhase.ShiftOrigin(t)}},{key:"GetContactManager",value:function(){return this.m_contactManager}},{key:"GetProfile",value:function(){return this.m_profile}},{key:"Dump",value:function(e){if(!this.m_locked){e("const g: b2Vec2 = new b2Vec2(%.15f, %.15f);\n",this.m_gravity.x,this.m_gravity.y),e("this.m_world.SetGravity(g);\n"),e("const bodies: b2Body[] = [];\n"),e("const joints: b2Joint[] = [];\n");for(var n=0,r=this.m_bodyList;r;r=r.m_next)r.m_islandIndex=n,r.Dump(e),++n;n=0;for(var i=this.m_jointList;i;i=i.m_next)i.m_index=n,++n;for(var o=this.m_jointList;o;o=o.m_next)o.m_type!==t.b2JointType.e_gearJoint&&(e("{\n"),o.Dump(e),e("}\n"));for(var a=this.m_jointList;a;a=a.m_next)a.m_type===t.b2JointType.e_gearJoint&&(e("{\n"),a.Dump(e),e("}\n"))}}},{key:"DrawJoint",value:function(n){if(null!==this.m_debugDraw){var r=n.GetBodyA(),i=n.GetBodyB(),o=r.m_xf,a=i.m_xf,s=o.p,u=a.p,l=n.GetAnchorA(e.DrawJoint_s_p1),c=n.GetAnchorB(e.DrawJoint_s_p2),f=e.DrawJoint_s_color.SetRGB(.5,.8,.8);switch(n.m_type){case t.b2JointType.e_distanceJoint:this.m_debugDraw.DrawSegment(l,c,f);break;case t.b2JointType.e_pulleyJoint:var h=n,m=h.GetGroundAnchorA(),d=h.GetGroundAnchorB();this.m_debugDraw.DrawSegment(m,l,f),this.m_debugDraw.DrawSegment(d,c,f),this.m_debugDraw.DrawSegment(m,d,f);break;case t.b2JointType.e_mouseJoint:var p=e.DrawJoint_s_c;p.Set(0,1,0),this.m_debugDraw.DrawPoint(l,4,p),this.m_debugDraw.DrawPoint(c,4,p),p.Set(.8,.8,.8),this.m_debugDraw.DrawSegment(l,c,p);break;default:this.m_debugDraw.DrawSegment(s,l,f),this.m_debugDraw.DrawSegment(l,c,f),this.m_debugDraw.DrawSegment(u,c,f)}}}},{key:"DrawShape",value:function(n,r){if(null!==this.m_debugDraw){var i=n.GetShape();switch(i.m_type){case t.b2ShapeType.e_circleShape:var o=i,a=o.m_p,s=o.m_radius,u=E.UNITX;this.m_debugDraw.DrawSolidCircle(a,s,u,r);break;case t.b2ShapeType.e_edgeShape:var l=i,c=l.m_vertex1,f=l.m_vertex2;this.m_debugDraw.DrawSegment(c,f,r);break;case t.b2ShapeType.e_chainShape:var h=i,m=h.m_count,d=h.m_vertices,p=e.DrawShape_s_ghostColor.SetRGBA(.75*r.r,.75*r.g,.75*r.b,r.a),_=d[0];if(this.m_debugDraw.DrawPoint(_,4,r),h.m_hasPrevVertex){var y=h.m_prevVertex;this.m_debugDraw.DrawSegment(y,_,p),this.m_debugDraw.DrawCircle(y,.1,p)}for(var v=1;v0;){var f=u[--c];if(!f)throw new Error;if(i.AddBody(f),f.m_awakeFlag=!0,f.GetType()!==t.b2BodyType.b2_staticBody){for(var h=f.m_contactList;h;h=h.next){var m=h.contact;if(!m.m_islandFlag&&(m.IsEnabled()&&m.IsTouching())){var d=m.m_fixtureA.m_isSensor,p=m.m_fixtureB.m_isSensor;if(!d&&!p){i.AddContact(m),m.m_islandFlag=!0;var _=h.other;if(!_)throw new Error;_.m_islandFlag||(u[c++]=_,_.m_islandFlag=!0)}}}for(var y=f.m_jointList;y;y=y.next)if(!y.joint.m_islandFlag){var v=y.other;v.IsActive()&&(i.AddJoint(y.joint),y.joint.m_islandFlag=!0,v.m_islandFlag||(u[c++]=v,v.m_islandFlag=!0))}}}var g=new Wn;i.Solve(g,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=g.solveInit,this.m_profile.solveVelocity+=g.solveVelocity,this.m_profile.solvePosition+=g.solvePosition;for(var b=0;b8)){var l=1;if(u.m_toiFlag)l=u.m_toi;else{var c=u.GetFixtureA(),f=u.GetFixtureB();if(c.IsSensor()||f.IsSensor())continue;var h=c.GetBody(),m=f.GetBody(),d=h.m_type,p=m.m_type,_=h.IsAwake()&&d!==t.b2BodyType.b2_staticBody,v=m.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!_&&!v)continue;var g=h.IsBullet()||d!==t.b2BodyType.b2_dynamicBody,b=m.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!g&&!b)continue;var x=h.m_sweep.alpha0;h.m_sweep.alpha0this.maxTimestep&&this.maxTimestep>0&&(e=this.maxTimestep);for(var r=this.m_bodyList;r;r=r.nextBody){var i=r.body;if(i.IsAwake()){var o=i.GetWorldVector(I.MulMV(this.T,i.GetLocalVector(i.GetLinearVelocity(),E.s_t0),E.s_t1),n.Step_s_damping);i.SetLinearVelocity(E.AddVV(i.GetLinearVelocity(),E.MulSV(e,o,E.s_t0),E.s_t1))}}}}},{key:"Draw",value:function(t){}},{key:"SetAxisAligned",value:function(t,e){this.T.ex.x=-t,this.T.ex.y=0,this.T.ey.x=0,this.T.ey.y=-e,this.maxTimestep=t>0||e>0?1/v(t,e):0}}]),n}(Pr);Tr.Step_s_damping=new E;var Mr=function(){function t(){u(this,t),this.m_count=0,this.m_ps=[],this.m_p0s=[],this.m_vs=[],this.m_ims=[],this.m_Ls=[],this.m_as=[],this.m_gravity=new E,this.m_damping=0,this.m_k2=1,this.m_k3=.1}return l(t,[{key:"GetVertexCount",value:function(){return this.m_count}},{key:"GetVertices",value:function(){return this.m_ps}},{key:"Initialize",value:function(t){this.m_count=t.count,this.m_ps=E.MakeArray(this.m_count),this.m_p0s=E.MakeArray(this.m_count),this.m_vs=E.MakeArray(this.m_count),this.m_ims=p(this.m_count);for(var e=0;e0?1/n:0}var r=this.m_count-1,i=this.m_count-2;this.m_Ls=p(r),this.m_as=p(i);for(var o=0;o0&&this.m_vs[r].SelfMulAdd(t,this.m_gravity),this.m_vs[r].SelfMul(n),this.m_ps[r].SelfMulAdd(t,this.m_vs[r]);for(var i=0;ic;)S=(_-=2*c)-this.m_as[n];for(;S<-c;)S=(_+=2*c)-this.m_as[n];var C=-this.m_k3*w*S;r.SelfMulAdd(a*C,g),i.SelfMulAdd(s*C,b),o.SelfMulAdd(u*C,x)}}}}},{key:"Draw",value:function(t){for(var e=new F(.4,.5,.7),n=0;n1?e-1:0),i=1;i>1&2147483647,t|=t>>2&1073741823,t|=t>>4&268435455,1+((t|=t>>8&16777215)|t>>16&65535)},t.b2IsPowerOfTwo=function(t){return t>0&&0==(t&t-1)},t.b2Random=function(){return 2*Math.random()-1},t.b2RandomRange=function(t,e){return(e-t)*Math.random()+t},t.b2Vec2=E,t.b2Vec2_zero=T,t.b2Vec3=M,t.b2Mat22=I,t.b2Mat33=O,t.b2Rot=R,t.b2Transform=D,t.b2Sweep=L,t.b2Color=F,t.b2Draw=function(){function t(){u(this,t),this.m_drawFlags=0}return l(t,[{key:"SetFlags",value:function(t){this.m_drawFlags=t}},{key:"GetFlags",value:function(){return this.m_drawFlags}},{key:"AppendFlags",value:function(t){this.m_drawFlags|=t}},{key:"ClearFlags",value:function(t){this.m_drawFlags&=~t}}]),t}(),t.b2Timer=G,t.b2Counter=function(){function t(){u(this,t),this.m_count=0,this.m_min_count=0,this.m_max_count=0}return l(t,[{key:"GetCount",value:function(){return this.m_count}},{key:"GetMinCount",value:function(){return this.m_min_count}},{key:"GetMaxCount",value:function(){return this.m_max_count}},{key:"ResetCount",value:function(){var t=this.m_count;return this.m_count=0,t}},{key:"ResetMinCount",value:function(){this.m_min_count=0}},{key:"ResetMaxCount",value:function(){this.m_max_count=0}},{key:"Increment",value:function(){this.m_count++,this.m_max_countthis.m_count&&(this.m_min_count=this.m_count)}}]),t}(),t.b2GrowableStack=N,t.b2BlockAllocator=function(){return function t(){u(this,t)}}(),t.b2StackAllocator=function(){return function t(){u(this,t)}}(),t.b2ContactFeature=dt,t.b2ContactID=pt,t.b2ManifoldPoint=_t,t.b2Manifold=yt,t.b2WorldManifold=vt,t.b2GetPointStates=function(e,n,r,i){var o;for(o=0;o.004;){t.iterations+=1,h=n.GetSupport(R.MulTRV(o.q,E.NegV(y,E.s_t1),E.s_t0)),m=D.MulXV(o,n.GetVertex(h),ut),d=r.GetSupport(R.MulTRV(a.q,y,E.s_t0)),p=D.MulXV(a,r.GetVertex(d),lt);var x=E.SubVV(m,p,ft);y.Normalize();var w=E.DotVV(y,x),S=E.DotVV(y,s);if(w-g>l*S){if(S<=0)return!1;if((l=(w-g)/S)>1)return!1;u.Copy(y).SelfNeg(),c.m_count=0}var C=f[c.m_count];switch(C.indexA=d,C.wA.Copy(p).SelfMulAdd(l,s),C.indexB=h,C.wB.Copy(m),C.w.Copy(C.wB).SelfSub(C.wA),C.a=1,c.m_count+=1,c.m_count){case 1:break;case 2:c.Solve2();break;case 3:c.Solve3()}if(3===c.m_count)return!1;c.GetClosestPoint(y),++b}var A=ht,B=mt;return c.GetWitnessPoints(A,B),y.LengthSquared()>0&&(u.Copy(y).SelfNeg(),u.Normalize()),t.normal.Copy(u),t.lambda=l,t.iterations=b,!0},t.b2Pair=Mt,t.b2BroadPhase=It,t.b2PairLessThan=Ot,t.b2TreeNode=Et,t.b2DynamicTree=Tt,t.b2_toi_reset=function(){t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0},t.b2TOIInput=Ut,t.b2TOIOutput=Wt,t.b2SeparationFunction=Jt,t.b2TimeOfImpact=ne,t.b2CollideCircles=oe,t.b2CollidePolygonAndCircle=le,t.b2CollidePolygons=Me,t.b2CollideEdgeAndCircle=Ne,t.b2CollideEdgeAndPolygon=Je,t.b2MassData=Qe,t.b2Shape=tn,t.b2CircleShape=en,t.b2PolygonShape=nn,t.b2EdgeShape=rn,t.b2ChainShape=on,t.b2Filter=an,t.b2FixtureDef=sn,t.b2FixtureProxy=un,t.b2Fixture=ln,t.b2BodyDef=function(){return function e(){u(this,e),this.type=t.b2BodyType.b2_staticBody,this.position=new E(0,0),this.angle=0,this.linearVelocity=new E(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.active=!0,this.userData=null,this.gravityScale=1}}(),t.b2Body=cn,t.b2World=Br,t.b2DestructionListener=function(){function t(){u(this,t)}return l(t,[{key:"SayGoodbyeJoint",value:function(t){}},{key:"SayGoodbyeFixture",value:function(t){}},{key:"SayGoodbyeParticleGroup",value:function(t){}},{key:"SayGoodbyeParticle",value:function(t,e){}}]),t}(),t.b2ContactFilter=Gn,t.b2ContactImpulse=Nn,t.b2ContactListener=zn,t.b2QueryCallback=qn,t.b2RayCastCallback=function(){function t(){u(this,t)}return l(t,[{key:"ReportFixture",value:function(t,e,n,r){return r}},{key:"ReportParticle",value:function(t,e,n,r,i){return 0}},{key:"ShouldQueryParticleSystem",value:function(t){return!0}}]),t}(),t.b2Island=nr,t.b2Profile=Wn,t.b2TimeStep=Jn,t.b2Position=Hn,t.b2Velocity=Xn,t.b2SolverData=$n,t.b2ContactManager=Un,t.b2MixFriction=kn,t.b2MixRestitution=Pn,t.b2ContactEdge=Vn,t.b2Contact=En,t.b2ContactRegister=Ln,t.b2ContactFactory=Fn,t.g_blockSolve=!1,t.b2VelocityConstraintPoint=Yn,t.b2ContactVelocityConstraint=Zn,t.b2ContactPositionConstraint=Kn,t.b2ContactSolverDef=Qn,t.b2PositionSolverManifold=tr,t.b2ContactSolver=er,t.b2CircleContact=Tn,t.b2PolygonContact=Mn,t.b2PolygonAndCircleContact=In,t.b2EdgeAndCircleContact=On,t.b2EdgeAndPolygonContact=Rn,t.b2ChainAndCircleContact=Dn,t.b2ChainAndPolygonContact=jn,t.b2Jacobian=function(){function t(){u(this,t),this.linear=new E,this.angularA=0,this.angularB=0}return l(t,[{key:"SetZero",value:function(){return this.linear.SetZero(),this.angularA=0,this.angularB=0,this}},{key:"Set",value:function(t,e,n){return this.linear.Copy(t),this.angularA=e,this.angularB=n,this}}]),t}(),t.b2JointEdge=fn,t.b2JointDef=hn,t.b2Joint=mn,t.b2AreaJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_areaJoint)).bodies=[],e.frequencyHz=0,e.dampingRatio=0,e}return l(r,[{key:"AddBody",value:function(t){this.bodies.push(t),1===this.bodies.length?this.bodyA=t:2===this.bodies.length&&(this.bodyB=t)}}]),r}(hn),t.b2AreaJoint=_n,t.b2DistanceJointDef=dn,t.b2DistanceJoint=pn,t.b2FrictionJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_frictionJoint)).localAnchorA=new E,e.localAnchorB=new E,e.maxForce=0,e.maxTorque=0,e}return l(r,[{key:"Initialize",value:function(t,e,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB)}}]),r}(hn),t.b2FrictionJoint=yn,t.b2GearJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_gearJoint)).ratio=1,e}return r}(hn),t.b2GearJoint=vn,t.b2MotorJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_motorJoint)).linearOffset=new E(0,0),e.angularOffset=0,e.maxForce=1,e.maxTorque=1,e.correctionFactor=.3,e}return l(r,[{key:"Initialize",value:function(t,e){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(this.bodyB.GetPosition(),this.linearOffset);var n=this.bodyA.GetAngle(),r=this.bodyB.GetAngle();this.angularOffset=r-n}}]),r}(hn),t.b2MotorJoint=gn,t.b2MouseJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_mouseJoint)).target=new E,e.maxForce=0,e.frequencyHz=5,e.dampingRatio=.7,e}return r}(hn),t.b2MouseJoint=bn,t.b2PrismaticJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_prismaticJoint)).localAnchorA=new E,e.localAnchorB=new E,e.localAxisA=new E(1,0),e.referenceAngle=0,e.enableLimit=!1,e.lowerTranslation=0,e.upperTranslation=0,e.enableMotor=!1,e.maxMotorForce=0,e.motorSpeed=0,e}return l(r,[{key:"Initialize",value:function(t,e,n,r){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.bodyA.GetLocalVector(r,this.localAxisA),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}}]),r}(hn),t.b2PrismaticJoint=xn,t.b2_minPulleyLength=2,t.b2PulleyJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_pulleyJoint)).groundAnchorA=new E(-1,1),e.groundAnchorB=new E(1,1),e.localAnchorA=new E(-1,0),e.localAnchorB=new E(1,0),e.lengthA=0,e.lengthB=0,e.ratio=1,e.collideConnected=!0,e}return l(r,[{key:"Initialize",value:function(t,e,n,r,i,o,a){this.bodyA=t,this.bodyB=e,this.groundAnchorA.Copy(n),this.groundAnchorB.Copy(r),this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(o,this.localAnchorB),this.lengthA=E.DistanceVV(i,n),this.lengthB=E.DistanceVV(o,r),this.ratio=a}}]),r}(hn),t.b2PulleyJoint=wn,t.b2RevoluteJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_revoluteJoint)).localAnchorA=new E(0,0),e.localAnchorB=new E(0,0),e.referenceAngle=0,e.enableLimit=!1,e.lowerAngle=0,e.upperAngle=0,e.enableMotor=!1,e.motorSpeed=0,e.maxMotorTorque=0,e}return l(r,[{key:"Initialize",value:function(t,e,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}}]),r}(hn),t.b2RevoluteJoint=Sn,t.b2RopeJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_ropeJoint)).localAnchorA=new E(-1,0),e.localAnchorB=new E(1,0),e.maxLength=0,e}return r}(hn),t.b2RopeJoint=Cn,t.b2WeldJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_weldJoint)).localAnchorA=new E,e.localAnchorB=new E,e.referenceAngle=0,e.frequencyHz=0,e.dampingRatio=0,e}return l(r,[{key:"Initialize",value:function(t,e,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}}]),r}(hn),t.b2WeldJoint=An,t.b2WheelJointDef=function(e){a(r,e);var n=s(r);function r(){var e;return u(this,r),(e=n.call(this,t.b2JointType.e_wheelJoint)).localAnchorA=new E(0,0),e.localAnchorB=new E(0,0),e.localAxisA=new E(1,0),e.enableMotor=!1,e.maxMotorTorque=0,e.motorSpeed=0,e.frequencyHz=2,e.dampingRatio=.7,e}return l(r,[{key:"Initialize",value:function(t,e,n,r){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.bodyA.GetLocalVector(r,this.localAxisA)}}]),r}(hn),t.b2WheelJoint=Bn,t.b2ControllerEdge=kr,t.b2Controller=Pr,t.b2BuoyancyController=function(t){a(n,t);var e=s(n);function n(){var t;return u(this,n),(t=e.apply(this,arguments)).normal=new E(0,1),t.offset=0,t.density=0,t.velocity=new E(0,0),t.linearDrag=0,t.angularDrag=0,t.useDensity=!1,t.useWorldGravity=!0,t.gravity=new E(0,0),t}return l(n,[{key:"Step",value:function(t){if(this.m_bodyList){this.useWorldGravity&&this.gravity.Copy(this.m_bodyList.body.GetWorld().GetGravity());for(var e=this.m_bodyList;e;e=e.nextBody){var n=e.body;if(n.IsAwake()){for(var r=new E,i=new E,o=0,a=0,s=n.GetFixtureList();s;s=s.m_next){var u=new E,l=s.GetShape().ComputeSubmergedArea(this.normal,this.offset,n.GetTransform(),u);o+=l,r.x+=l*u.x,r.y+=l*u.y;var c;a+=l*(c=this.useDensity?s.GetDensity():1),i.x+=l*u.x*c,i.y+=l*u.y*c}if(r.x/=o,r.y/=o,i.x/=a,i.y/=a,!(o<1e-5)){var f=this.gravity.Clone().SelfNeg();f.SelfMul(this.density*o),n.ApplyForce(f,i);var h=n.GetLinearVelocityFromWorldPoint(r,new E);h.SelfSub(this.velocity),h.SelfMul(-this.linearDrag*o),n.ApplyForce(h,r),n.ApplyTorque(-n.GetInertia()/n.GetMass()*o*n.GetAngularVelocity()*this.angularDrag)}}}}}},{key:"Draw",value:function(t){var e=100,n=new E,r=new E;n.x=this.normal.x*this.offset+this.normal.y*e,n.y=this.normal.y*this.offset-this.normal.x*e,r.x=this.normal.x*this.offset-this.normal.y*e,r.y=this.normal.y*this.offset+this.normal.x*e;var i=new F(0,0,.8);t.DrawSegment(n,r,i)}}]),n}(Pr),t.b2ConstantAccelController=Vr,t.b2ConstantForceController=function(t){a(n,t);var e=s(n);function n(){var t;return u(this,n),(t=e.apply(this,arguments)).F=new E(0,0),t}return l(n,[{key:"Step",value:function(t){for(var e=this.m_bodyList;e;e=e.nextBody){var n=e.body;n.IsAwake()&&n.ApplyForce(this.F,n.GetWorldCenter())}}},{key:"Draw",value:function(t){}}]),n}(Pr),t.b2GravityController=Er,t.b2TensorDampingController=Tr,t.b2ParticleDef=rr,t.b2CalculateParticleIterations=ir,t.b2ParticleHandle=or,t.b2ParticleGroupDef=ar,t.b2ParticleGroup=sr,t.b2GrowableBuffer=vr,t.b2FixtureParticleQueryCallback=gr,t.b2ParticleContact=br,t.b2ParticleBodyContact=xr,t.b2ParticlePair=wr,t.b2ParticleTriad=Sr,t.b2ParticleSystemDef=Cr,t.b2ParticleSystem=Ar,t.b2RopeDef=function(){return function t(){u(this,t),this.vertices=[],this.count=0,this.masses=[],this.gravity=new E(0,0),this.damping=.1,this.k2=.9,this.k3=.1}}(),t.b2Rope=Mr,Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,n){t.exports=n(3)()},function(t,e){t.exports=n(0)},function(t,e,n){"use strict";var r=n(4);function i(){}function o(){}o.resetWarningCache=i,t.exports=function(){function t(t,e,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function e(){return t}t.isRequired=t;var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},function(t,e,n){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,e,n){"use strict";n.r(e),n.d(e,"World",(function(){return U})),n.d(e,"Item",(function(){return W}));var r=n(2),i=n.n(r),o=n(1),a=n.n(o),s=n(0),u=function(t,e){return t*e},l=function(t,e){return t/e},c=function(t,e,n,r,i,o,a){var s,l=function(t,e,n,r){return{left:t-n/2,top:e-r/2}}(u(r,a),u(i,a),e,n),c=l.left,f=l.top;s="translate(".concat(c,"px,").concat(f,"px) rotate(").concat(o,"rad)"),t.style.transform=s},f=function(t,e,n){return t.TWO_NUMBERS_OPTIONAL?Array.isArray(t[e])&&2==t[e].length&&t[e].every(Number.isFinite)?null:new Error("".concat(e," needs to be an array of two numbers")):null};function h(){return this.contact.GetFixtureA().m_body.GetUserData().category}function m(){return this.contact.GetFixtureB().m_body.GetUserData().category}function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var p=["width","height","gravity","allowSleep","scaleFactor","enclosed","enclosureThickness","children","style"];function _(){return(_=Object.assign||function(t){for(var e=1;e=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}(t,p);e.restProps=k,e.SCALE=y,e.world=new s.b2World(new s.b2Vec2(u[0],u[1]),d),window.world=e.world,b&&function(t,e,n,r,i){var o=new s.b2BodyDef;o.type=s.b2BodyType.b2_staticBody;var a=new s.b2FixtureDef;a.shape=new s.b2PolygonShape,a.density=1,a.friction=.5,a.restitution=0,a.shape.SetAsBox(l(n/2,i),l(e/2,i)),o.position.x=l(n/2,i),o.position.y=l(e/2,i);var u=r.CreateBody(o).CreateFixture(a);u.m_body.SetUserData({category:"_LEFT_WALL_"}),a.shape.SetAsBox(l(t/2,i),l(n/2,i)),o.position.x=l(t/2,i),o.position.y=l(e,i),(u=r.CreateBody(o).CreateFixture(a)).m_body.SetUserData({category:"_BOTTOM_WALL_"}),a.shape.SetAsBox(l(t/2,i),l(n/2,i)),o.position.x=l(t/2,i),o.position.y=l(n/2,i),(u=r.CreateBody(o).CreateFixture(a)).m_body.SetUserData({category:"_TOP_WALL_"}),a.shape.SetAsBox(l(n/2,i),l(e/2,i)),o.position.x=l(t,i),o.position.y=l(e/2,i),(u=r.CreateBody(o).CreateFixture(a)).m_body.SetUserData({category:"_RIGHT_WALL_"})}(n,i,S,e.world,e.SCALE),e.worldChangeStatus=0,e._contactCbProcess=function(t,n){var r=e.SCALE,i=t.GetFixtureA().m_body.GetUserData();i&&(i[n]=!0);var o={SCALE:r,contact:t};i&&i.rc&&i.rc.props[n]&&(o.getOthersCategory=m,i.rc.props[n](o));var a=t.GetFixtureB().m_body.GetUserData();a&&(a[n]=!0),a&&a.rc&&a.rc.props[n]&&(o.getOthersCategory=h,a.rc.props[n](o))},e._contactListener={BeginContact:function(t){e._contactCbProcess(t,"onBeginContact")},EndContact:function(t){e._contactCbProcess(t,"onEndContact")},PreSolve:function(t,e){},PostSolve:function(t,e){}},e.world.SetContactListener(e._contactListener);var P={width:n,height:i,position:"relative",overlow:"hidden",boxSizing:"border-box",padding:S};return e.worldStyle=v(v({},P),B),e}return e=o,(n=[{key:"componentDidMount",value:function(){this.physLoopStart()}},{key:"componentWillUnmount",value:function(){this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0)}},{key:"render",value:function(){var t=this.props,e=t.className,n=void 0===e?"Box2dWorld":e,r=t.children;return i.a.createElement("div",_({className:n},this.restProps,{style:this.worldStyle}),i.a.createElement(B,{value:this},r),i.a.createElement(k,_({world:this.world},this.props)))}}])&&g(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),o}(r.Component);P.propTypes={width:a.a.number.isRequired,height:a.a.number.isRequired,gravity:f,enclosed:a.a.bool,allowSleep:a.a.bool,scaleFactor:a.a.number,enclosureThickness:a.a.number};var V=P;function E(t){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function T(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function M(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&t.height>0})),h=o.left,m=(o.top,f[0]),d=0;d1?(console.log("inline element detected",D),e.createFixturesForInline(B,R,D)):(B.shape=new s.b2PolygonShape,B.shape.SetAsBox(l(P/2,k),l(V/2,k)),R.CreateFixture(B))}else{if("circle"!==m)throw new Error("Unknown shape ".concat(m,", only box and circle supported for now"));if(V!=P)throw new Error("For shape circle, height and width should be same");B.shape=new s.b2CircleShape(l(V/2,k)),R.CreateFixture(B),e.setState({circleRadius:V/2})}var j={category:p,dom:e.el,rc:F(e)};_&&(j.data=_),R.SetUserData(j),e.body=R,S&&e.body.SetBullet(S),x&&e.applyForce(x),w&&e.applyImpulse(w),e.setState({domHeight:V,domWidth:P,physicsInited:!0})})),N(F(e),"applyForce",(function(t){var n=O(t,2),r=n[0],i=n[1];e.body&&e.body.ApplyForce(new s.b2Vec2(r,i),e.body.GetWorldCenter())})),N(F(e),"applyImpulse",(function(t){var n=O(t,2),r=n[0],i=n[1];e.body&&e.body.ApplyLinearImpulse(new s.b2Vec2(r,i),e.body.GetWorldCenter())})),e.state={physicsInited:!1,domWidth:null,domHeight:null,circleRadius:null},e.width=null,e.height=null,e}return e=a,(n=[{key:"componentWillUnmount",value:function(){if(this.body){var t=this.body.GetUserData();t.removed=!0,this.body.SetUserData(t),this.body.SetAwake(!0)}}},{key:"componentDidMount",value:function(){"waitFor"in this.props?this.props.waitFor&&this.physicsInit():this.physicsInit()}},{key:"componentDidUpdate",value:function(t,e){"waitFor"in this.props&&(this.state.physicsInited||this.props.waitFor&&this.physicsInit())}},{key:"render",value:function(){var t=this,e=this.state,n=e.physicsInited,o=e.domHeight,a=e.domWidth,s=e.circleRadius,u=this.props.hideUntil,l=void 0===u||u,c=this.props.children.props.style,f=void 0===c?{}:c,h=n?{position:"absolute",display:"block",left:0,top:0,height:o,width:a,willChange:"transform"}:l?{visibility:"hidden"}:{};return n&&s&&(h.borderRadius=s),i.a.createElement(r.Fragment,null,i.a.createElement(z,I({body:this.body},this.props)),i.a.cloneElement(this.props.children,{ref:function(e){t.el=e},style:M(M({},f),h)}))}}])&&D(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),a}(r.Component);N(q,"_internalType","Box2dObject"),q.propTypes={children:a.a.element.isRequired,height:a.a.number,width:a.a.number,left:a.a.number,top:a.a.number,density:a.a.number,friction:a.a.number,restitution:a.a.number,bullet:a.a.bool,onBeginContact:a.a.func,onEndContact:a.a.func,shape:a.a.oneOf(["circle","box"]),initialForce:f,initialImpulse:f,category:a.a.string},q.contextType=A;var U=V,W=q;e.default={World:U,Item:W}}])},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var r=n(47),i=Math.max,o=Math.min;t.exports=function(t,e){var n=r(t);return n<0?i(n+e,0):o(n,e)}},function(t,e,n){var r,i=n(16),o=n(162),a=n(122),s=n(83),u=n(163),l=n(117),c=n(99),f=c("IE_PROTO"),h=function(){},m=function(t){return"