chuck.js/build/client.min.js
2014-12-21 19:39:49 +01:00

181 lines
No EOL
565 KiB
JavaScript
Raw Blame History

/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
/*!
* screenfull
* v1.2.0 - 2014-04-29
* (c) Sindre Sorhus; MIT License
*/
/**
* @license
* pixi.js - v1.5.1
* Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/
*
* Compiled: 2014-02-13
*
* pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
*/
// MIT license
/*
PolyK library
url: http://polyk.ivank.net
Released under MIT licence.
Copyright (c) 2012 Ivan Kuckir
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This is an amazing lib!
slightly modified by Mat Groves (matgroves.com);
*/
/*
CryptoJS v3.0.2
code.google.com/p/crypto-js
(c) 2009-2012 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* Parses an URI
*
* @author Steven Levithan <stevenlevithan.com> (MIT license)
* @api public
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/* SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
// License: New BSD License
// Reference: http://dev.w3.org/html5/websockets/
// Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
define("Lib/Utilities/Protocol/Parser",[],function(){var e={};return e.encode=function(e){return JSON.stringify(e)},e.decode=function(e){return JSON.parse(e)},e}),define("Lib/Utilities/Exception",[],function(){function e(){var e=[];for(var t=0;t<arguments.length;t++){var n=arguments[t];if(typeof n=="object"){var r=this.getTypeOfObject(n);e.push(r)}else e.push(n)}this.message=e.join(" ");var i=Error.call(this,this.message);console.log(i.stack)}return e.prototype=Object.create(Error.prototype),e.prototype.toString=function(){return this.message},e.prototype.getTypeOfObject=function(e){var t=/function (.{1,})\(/,n=t.exec(e.constructor.toString());return n&&n.length>1?n[1]:""},e}),define("Lib/Utilities/Protocol/Helper",["Lib/Utilities/Protocol/Parser","Lib/Utilities/Exception"],function(e,t){var n={};return n.encodeCommand=function(t,n){var r={};return r[t]=n||null,e.encode(r)},n.applyCommand=function(n,r){var i;typeof n=="string"?i=e.decode(n):i=n;for(var s in i){var o="on"+s.toUpperCaseFirstChar(),n=i[s];if(!r[o])throw new t("Helper.applyCommand:",r,"has no method",o);r[o].call(r,n)}},n}),define("Game/Config/Settings",[],function(){var e={STAGE_WIDTH:600,STAGE_HEIGHT:400,ZOOM_FACTOR:.8,ZOOM_DEFAULT:1,ZOOM_MAX:10,BOX2D_WORLD_AABB_SIZE:3e3,BOX2D_ALLOW_SLEEP:!0,BOX2D_GRAVITY:26,BOX2D_VELOCITY_ITERATIONS:5,BOX2D_POSITION_ITERATIONS:5,BOX2D_TIME_STEP:1/60,GRAPHICS_PATH:"static/img/",GRAPHICS_SUBPATH_ITEMS:"Items/",GRAPHICS_SUBPATH_CHARACTERS:"Characters/",GRAPHICS_SUBPATH_TILES:"Tiles/",MAPS_PATH:"static/maps/tiled/",AUDIO_PATH:"static/sounds/",RATIO:21,ORIGINAL_TILE_SIZE:25,TILE_SIZE:20,CAMERA_IS_ORTHOGRAPHIC:!0,CAMERA_GLIDE:12,VIEW_CONTROLLER:"Pixi",ARROW_GLIDE:30,WALK_SPEED:4,RUN_SPEED:8,FLY_SPEED:6.2,JUMP_SPEED:20,JUMP_STOP_DAMPING_FACTOR:.5,MAX_THROW_FORCE:63,MAX_THROW_ANGULAR_VELOCITY:0,MAX_RUNNING_WEIGHT:9,RESPAWN_TIME:5,HEALTH_DISPLAY_TIME:2,RAGDOLL_DESTRUCTION_TIME:20,VIEWPORT_SPEED_FACTOR:640,VIEWPORT_LOOK_AHEAD:.1,TILE_FRICTION:.99,TILE_RESTITUTION:.1,PLAYER_DENSITY:3.68,PLAYER_FRICTION:5,PLAYER_MOTION_FRICTION:.1,PLAYER_RESTITUTION:0,PLAYER_LINEAR_DAMPING:.4,ITEM_DENSITY:.9,ITEM_FRICTION:.99,ITEM_RESTITUTION:.02,ITEM_LINEAR_DAMPING:.02,CANVAS_DOM_ID:"canvasContainer",IS_BROWSER_ENVIRONMENT:typeof window!="undefined",USE_WEBGL:!0,NETWORK_UPDATE_INTERVAL:70,NETWORK_LOG_INCOMING:!1,NETWORK_LOG_OUTGOING:!1,NETWORK_LOG_FILTER:["ping","pong","worldUpdate","lookAt"],CHANNEL_DESTRUCTION_TIME:300,CHANNEL_END_ROUND_TIME:4,CHANNEL_DEFAULT_MAX_USERS:40,CHANNEL_DEFAULT_SCORE_LIMIT:10,CHANNEL_DEFAULT_LEVELS:["debug"],ME_STATE_MAX_DIFFERENCE_METERS:1,PUNKBUSTER_DIFFERENCE_METERS:1};return e.TILE_RATIO=e.ORIGINAL_TILE_SIZE/e.TILE_SIZE,e}),define("Lib/Vendor/Box2D",[],function(){var e={};(function(e,t){function n(){}e.inherit=function(e,t){var r=e;n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=r},e.generateCallback=function(t,n){return function(){n.apply(t,arguments)}},e.NVector=function(n){n===t&&(n=0);var r=new Array(n||0);for(var i=0;i<n;++i)r[i]=0;return r},e.is=function(n,r){return n===null?!1:r instanceof Function&&n instanceof r?!0:n.constructor.__implements!=t&&n.constructor.__implements[r]?!0:!1},e.parseUInt=function(e){return Math.abs(parseInt(e))}})(e);var t=Array,n=e.NVector;typeof e=="undefined"&&(e={}),typeof e.Collision=="undefined"&&(e.Collision={}),typeof e.Collision.Shapes=="undefined"&&(e.Collision.Shapes={}),typeof e.Common=="undefined"&&(e.Common={}),typeof e.Common.Math=="undefined"&&(e.Common.Math={}),typeof e.Dynamics=="undefined"&&(e.Dynamics={}),typeof e.Dynamics.Contacts=="undefined"&&(e.Dynamics.Contacts={}),typeof e.Dynamics.Controllers=="undefined"&&(e.Dynamics.Controllers={}),typeof e.Dynamics.Joints=="undefined"&&(e.Dynamics.Joints={}),function(){function t(){t.b2AABB.apply(this,arguments)}function n(){n.b2Bound.apply(this,arguments)}function r(){r.b2BoundValues.apply(this,arguments),this.constructor===r&&this.b2BoundValues.apply(this,arguments)}function i(){i.b2Collision.apply(this,arguments)}function s(){s.b2ContactID.apply(this,arguments),this.constructor===s&&this.b2ContactID.apply(this,arguments)}function o(){o.b2ContactPoint.apply(this,arguments)}function u(){u.b2Distance.apply(this,arguments)}function a(){a.b2DistanceInput.apply(this,arguments)}function f(){f.b2DistanceOutput.apply(this,arguments)}function l(){l.b2DistanceProxy.apply(this,arguments)}function c(){c.b2DynamicTree.apply(this,arguments),this.constructor===c&&this.b2DynamicTree.apply(this,arguments)}function h(){h.b2DynamicTreeBroadPhase.apply(this,arguments)}function p(){p.b2DynamicTreeNode.apply(this,arguments)}function d(){d.b2DynamicTreePair.apply(this,arguments)}function v(){v.b2Manifold.apply(this,arguments),this.constructor===v&&this.b2Manifold.apply(this,arguments)}function m(){m.b2ManifoldPoint.apply(this,arguments),this.constructor===m&&this.b2ManifoldPoint.apply(this,arguments)}function g(){g.b2Point.apply(this,arguments)}function y(){y.b2RayCastInput.apply(this,arguments),this.constructor===y&&this.b2RayCastInput.apply(this,arguments)}function b(){b.b2RayCastOutput.apply(this,arguments)}function w(){w.b2Segment.apply(this,arguments)}function E(){E.b2SeparationFunction.apply(this,arguments)}function S(){S.b2Simplex.apply(this,arguments),this.constructor===S&&this.b2Simplex.apply(this,arguments)}function x(){x.b2SimplexCache.apply(this,arguments)}function T(){T.b2SimplexVertex.apply(this,arguments)}function N(){N.b2TimeOfImpact.apply(this,arguments)}function C(){C.b2TOIInput.apply(this,arguments)}function k(){k.b2WorldManifold.apply(this,arguments),this.constructor===k&&this.b2WorldManifold.apply(this,arguments)}function L(){L.ClipVertex.apply(this,arguments)}function A(){A.Features.apply(this,arguments)}function O(){O.b2CircleShape.apply(this,arguments),this.constructor===O&&this.b2CircleShape.apply(this,arguments)}function M(){M.b2EdgeChainDef.apply(this,arguments),this.constructor===M&&this.b2EdgeChainDef.apply(this,arguments)}function _(){_.b2EdgeShape.apply(this,arguments),this.constructor===_&&this.b2EdgeShape.apply(this,arguments)}function D(){D.b2MassData.apply(this,arguments)}function P(){P.b2PolygonShape.apply(this,arguments),this.constructor===P&&this.b2PolygonShape.apply(this,arguments)}function H(){H.b2Shape.apply(this,arguments),this.constructor===H&&this.b2Shape.apply(this,arguments)}function B(){B.b2Color.apply(this,arguments),this.constructor===B&&this.b2Color.apply(this,arguments)}function j(){j.b2Settings.apply(this,arguments)}function F(){F.b2Mat22.apply(this,arguments),this.constructor===F&&this.b2Mat22.apply(this,arguments)}function I(){I.b2Mat33.apply(this,arguments),this.constructor===I&&this.b2Mat33.apply(this,arguments)}function q(){q.b2Math.apply(this,arguments)}function R(){R.b2Sweep.apply(this,arguments)}function U(){U.b2Transform.apply(this,arguments),this.constructor===U&&this.b2Transform.apply(this,arguments)}function z(){z.b2Vec2.apply(this,arguments),this.constructor===z&&this.b2Vec2.apply(this,arguments)}function W(){W.b2Vec3.apply(this,arguments),this.constructor===W&&this.b2Vec3.apply(this,arguments)}function X(){X.b2Body.apply(this,arguments),this.constructor===X&&this.b2Body.apply(this,arguments)}function V(){V.b2BodyDef.apply(this,arguments),this.constructor===V&&this.b2BodyDef.apply(this,arguments)}function $(){$.b2ContactFilter.apply(this,arguments)}function J(){J.b2ContactImpulse.apply(this,arguments)}function K(){K.b2ContactListener.apply(this,arguments)}function Q(){Q.b2ContactManager.apply(this,arguments),this.constructor===Q&&this.b2ContactManager.apply(this,arguments)}function G(){G.b2DebugDraw.apply(this,arguments),this.constructor===G&&this.b2DebugDraw.apply(this,arguments)}function Y(){Y.b2DestructionListener.apply(this,arguments)}function Z(){Z.b2FilterData.apply(this,arguments)}function et(){et.b2Fixture.apply(this,arguments),this.constructor===et&&this.b2Fixture.apply(this,arguments)}function tt(){tt.b2FixtureDef.apply(this,arguments),this.constructor===tt&&this.b2FixtureDef.apply(this,arguments)}function nt(){nt.b2Island.apply(this,arguments),this.constructor===nt&&this.b2Island.apply(this,arguments)}function rt(){rt.b2TimeStep.apply(this,arguments)}function it(){it.b2World.apply(this,arguments),this.constructor===it&&this.b2World.apply(this,arguments)}function st(){st.b2CircleContact.apply(this,arguments)}function ot(){ot.b2Contact.apply(this,arguments),this.constructor===ot&&this.b2Contact.apply(this,arguments)}function ut(){ut.b2ContactConstraint.apply(this,arguments),this.constructor===ut&&this.b2ContactConstraint.apply(this,arguments)}function at(){at.b2ContactConstraintPoint.apply(this,arguments)}function ft(){ft.b2ContactEdge.apply(this,arguments)}function lt(){lt.b2ContactFactory.apply(this,arguments),this.constructor===lt&&this.b2ContactFactory.apply(this,arguments)}function ct(){ct.b2ContactRegister.apply(this,arguments)}function ht(){ht.b2ContactResult.apply(this,arguments)}function pt(){pt.b2ContactSolver.apply(this,arguments),this.constructor===pt&&this.b2ContactSolver.apply(this,arguments)}function dt(){dt.b2EdgeAndCircleContact.apply(this,arguments)}function vt(){vt.b2NullContact.apply(this,arguments),this.constructor===vt&&this.b2NullContact.apply(this,arguments)}function mt(){mt.b2PolyAndCircleContact.apply(this,arguments)}function gt(){gt.b2PolyAndEdgeContact.apply(this,arguments)}function yt(){yt.b2PolygonContact.apply(this,arguments)}function bt(){bt.b2PositionSolverManifold.apply(this,arguments),this.constructor===bt&&this.b2PositionSolverManifold.apply(this,arguments)}function wt(){wt.b2BuoyancyController.apply(this,arguments)}function Et(){Et.b2ConstantAccelController.apply(this,arguments)}function St(){St.b2ConstantForceController.apply(this,arguments)}function xt(){xt.b2Controller.apply(this,arguments)}function Tt(){Tt.b2ControllerEdge.apply(this,arguments)}function Nt(){Nt.b2GravityController.apply(this,arguments)}function Ct(){Ct.b2TensorDampingController.apply(this,arguments)}function kt(){kt.b2DistanceJoint.apply(this,arguments),this.constructor===kt&&this.b2DistanceJoint.apply(this,arguments)}function Lt(){Lt.b2DistanceJointDef.apply(this,arguments),this.constructor===Lt&&this.b2DistanceJointDef.apply(this,arguments)}function At(){At.b2FrictionJoint.apply(this,arguments),this.constructor===At&&this.b2FrictionJoint.apply(this,arguments)}function Ot(){Ot.b2FrictionJointDef.apply(this,arguments),this.constructor===Ot&&this.b2FrictionJointDef.apply(this,arguments)}function Mt(){Mt.b2GearJoint.apply(this,arguments),this.constructor===Mt&&this.b2GearJoint.apply(this,arguments)}function _t(){_t.b2GearJointDef.apply(this,arguments),this.constructor===_t&&this.b2GearJointDef.apply(this,arguments)}function Dt(){Dt.b2Jacobian.apply(this,arguments)}function Pt(){Pt.b2Joint.apply(this,arguments),this.constructor===Pt&&this.b2Joint.apply(this,arguments)}function Ht(){Ht.b2JointDef.apply(this,arguments),this.constructor===Ht&&this.b2JointDef.apply(this,arguments)}function Bt(){Bt.b2JointEdge.apply(this,arguments)}function jt(){jt.b2LineJoint.apply(this,arguments),this.constructor===jt&&this.b2LineJoint.apply(this,arguments)}function Ft(){Ft.b2LineJointDef.apply(this,arguments),this.constructor===Ft&&this.b2LineJointDef.apply(this,arguments)}function It(){It.b2MouseJoint.apply(this,arguments),this.constructor===It&&this.b2MouseJoint.apply(this,arguments)}function qt(){qt.b2MouseJointDef.apply(this,arguments),this.constructor===qt&&this.b2MouseJointDef.apply(this,arguments)}function Rt(){Rt.b2PrismaticJoint.apply(this,arguments),this.constructor===Rt&&this.b2PrismaticJoint.apply(this,arguments)}function Ut(){Ut.b2PrismaticJointDef.apply(this,arguments),this.constructor===Ut&&this.b2PrismaticJointDef.apply(this,arguments)}function zt(){zt.b2PulleyJoint.apply(this,arguments),this.constructor===zt&&this.b2PulleyJoint.apply(this,arguments)}function Wt(){Wt.b2PulleyJointDef.apply(this,arguments),this.constructor===Wt&&this.b2PulleyJointDef.apply(this,arguments)}function Xt(){Xt.b2RevoluteJoint.apply(this,arguments),this.constructor===Xt&&this.b2RevoluteJoint.apply(this,arguments)}function Vt(){Vt.b2RevoluteJointDef.apply(this,arguments),this.constructor===Vt&&this.b2RevoluteJointDef.apply(this,arguments)}function $t(){$t.b2WeldJoint.apply(this,arguments),this.constructor===$t&&this.b2WeldJoint.apply(this,arguments)}function Jt(){Jt.b2WeldJointDef.apply(this,arguments),this.constructor===Jt&&this.b2WeldJointDef.apply(this,arguments)}e.Collision.IBroadPhase="Box2D.Collision.IBroadPhase",e.Collision.b2AABB=t,e.Collision.b2Bound=n,e.Collision.b2BoundValues=r,e.Collision.b2Collision=i,e.Collision.b2ContactID=s,e.Collision.b2ContactPoint=o,e.Collision.b2Distance=u,e.Collision.b2DistanceInput=a,e.Collision.b2DistanceOutput=f,e.Collision.b2DistanceProxy=l,e.Collision.b2DynamicTree=c,e.Collision.b2DynamicTreeBroadPhase=h,e.Collision.b2DynamicTreeNode=p,e.Collision.b2DynamicTreePair=d,e.Collision.b2Manifold=v,e.Collision.b2ManifoldPoint=m,e.Collision.b2Point=g,e.Collision.b2RayCastInput=y,e.Collision.b2RayCastOutput=b,e.Collision.b2Segment=w,e.Collision.b2SeparationFunction=E,e.Collision.b2Simplex=S,e.Collision.b2SimplexCache=x,e.Collision.b2SimplexVertex=T,e.Collision.b2TimeOfImpact=N,e.Collision.b2TOIInput=C,e.Collision.b2WorldManifold=k,e.Collision.ClipVertex=L,e.Collision.Features=A,e.Collision.Shapes.b2CircleShape=O,e.Collision.Shapes.b2EdgeChainDef=M,e.Collision.Shapes.b2EdgeShape=_,e.Collision.Shapes.b2MassData=D,e.Collision.Shapes.b2PolygonShape=P,e.Collision.Shapes.b2Shape=H,e.Common.b2internal="Box2D.Common.b2internal",e.Common.b2Color=B,e.Common.b2Settings=j,e.Common.Math.b2Mat22=F,e.Common.Math.b2Mat33=I,e.Common.Math.b2Math=q,e.Common.Math.b2Sweep=R,e.Common.Math.b2Transform=U,e.Common.Math.b2Vec2=z,e.Common.Math.b2Vec3=W,e.Dynamics.b2Body=X,e.Dynamics.b2BodyDef=V,e.Dynamics.b2ContactFilter=$,e.Dynamics.b2ContactImpulse=J,e.Dynamics.b2ContactListener=K,e.Dynamics.b2ContactManager=Q,e.Dynamics.b2DebugDraw=G,e.Dynamics.b2DestructionListener=Y,e.Dynamics.b2FilterData=Z,e.Dynamics.b2Fixture=et,e.Dynamics.b2FixtureDef=tt,e.Dynamics.b2Island=nt,e.Dynamics.b2TimeStep=rt,e.Dynamics.b2World=it,e.Dynamics.Contacts.b2CircleContact=st,e.Dynamics.Contacts.b2Contact=ot,e.Dynamics.Contacts.b2ContactConstraint=ut,e.Dynamics.Contacts.b2ContactConstraintPoint=at,e.Dynamics.Contacts.b2ContactEdge=ft,e.Dynamics.Contacts.b2ContactFactory=lt,e.Dynamics.Contacts.b2ContactRegister=ct,e.Dynamics.Contacts.b2ContactResult=ht,e.Dynamics.Contacts.b2ContactSolver=pt,e.Dynamics.Contacts.b2EdgeAndCircleContact=dt,e.Dynamics.Contacts.b2NullContact=vt,e.Dynamics.Contacts.b2PolyAndCircleContact=mt,e.Dynamics.Contacts.b2PolyAndEdgeContact=gt,e.Dynamics.Contacts.b2PolygonContact=yt,e.Dynamics.Contacts.b2PositionSolverManifold=bt,e.Dynamics.Controllers.b2BuoyancyController=wt,e.Dynamics.Controllers.b2ConstantAccelController=Et,e.Dynamics.Controllers.b2ConstantForceController=St,e.Dynamics.Controllers.b2Controller=xt,e.Dynamics.Controllers.b2ControllerEdge=Tt,e.Dynamics.Controllers.b2GravityController=Nt,e.Dynamics.Controllers.b2TensorDampingController=Ct,e.Dynamics.Joints.b2DistanceJoint=kt,e.Dynamics.Joints.b2DistanceJointDef=Lt,e.Dynamics.Joints.b2FrictionJoint=At,e.Dynamics.Joints.b2FrictionJointDef=Ot,e.Dynamics.Joints.b2GearJoint=Mt,e.Dynamics.Joints.b2GearJointDef=_t,e.Dynamics.Joints.b2Jacobian=Dt,e.Dynamics.Joints.b2Joint=Pt,e.Dynamics.Joints.b2JointDef=Ht,e.Dynamics.Joints.b2JointEdge=Bt,e.Dynamics.Joints.b2LineJoint=jt,e.Dynamics.Joints.b2LineJointDef=Ft,e.Dynamics.Joints.b2MouseJoint=It,e.Dynamics.Joints.b2MouseJointDef=qt,e.Dynamics.Joints.b2PrismaticJoint=Rt,e.Dynamics.Joints.b2PrismaticJointDef=Ut,e.Dynamics.Joints.b2PulleyJoint=zt,e.Dynamics.Joints.b2PulleyJointDef=Wt,e.Dynamics.Joints.b2RevoluteJoint=Xt,e.Dynamics.Joints.b2RevoluteJointDef=Vt,e.Dynamics.Joints.b2WeldJoint=$t,e.Dynamics.Joints.b2WeldJointDef=Jt}(),e.postDefs=[],function(){var r=e.Collision.Shapes.b2CircleShape,i=e.Collision.Shapes.b2EdgeChainDef,s=e.Collision.Shapes.b2EdgeShape,o=e.Collision.Shapes.b2MassData,u=e.Collision.Shapes.b2PolygonShape,a=e.Collision.Shapes.b2Shape,f=e.Common.b2Color,l=e.Common.b2internal,c=e.Common.b2Settings,h=e.Common.Math.b2Mat22,p=e.Common.Math.b2Mat33,d=e.Common.Math.b2Math,v=e.Common.Math.b2Sweep,m=e.Common.Math.b2Transform,g=e.Common.Math.b2Vec2,y=e.Common.Math.b2Vec3,b=e.Collision.b2AABB,w=e.Collision.b2Bound,E=e.Collision.b2BoundValues,S=e.Collision.b2Collision,x=e.Collision.b2ContactID,T=e.Collision.b2ContactPoint,N=e.Collision.b2Distance,C=e.Collision.b2DistanceInput,k=e.Collision.b2DistanceOutput,L=e.Collision.b2DistanceProxy,A=e.Collision.b2DynamicTree,O=e.Collision.b2DynamicTreeBroadPhase,M=e.Collision.b2DynamicTreeNode,_=e.Collision.b2DynamicTreePair,D=e.Collision.b2Manifold,P=e.Collision.b2ManifoldPoint,H=e.Collision.b2Point,B=e.Collision.b2RayCastInput,j=e.Collision.b2RayCastOutput,F=e.Collision.b2Segment,I=e.Collision.b2SeparationFunction,q=e.Collision.b2Simplex,R=e.Collision.b2SimplexCache,U=e.Collision.b2SimplexVertex,z=e.Collision.b2TimeOfImpact,W=e.Collision.b2TOIInput,X=e.Collision.b2WorldManifold,V=e.Collision.ClipVertex,$=e.Collision.Features,J=e.Collision.IBroadPhase;b.b2AABB=function(){this.lowerBound=new g,this.upperBound=new g},b.prototype.IsValid=function(){var e=this.upperBound.x-this.lowerBound.x,t=this.upperBound.y-this.lowerBound.y,n=e>=0&&t>=0;return n=n&&this.lowerBound.IsValid()&&this.upperBound.IsValid(),n},b.prototype.GetCenter=function(){return new g((this.lowerBound.x+this.upperBound.x)/2,(this.lowerBound.y+this.upperBound.y)/2)},b.prototype.GetExtents=function(){return new g((this.upperBound.x-this.lowerBound.x)/2,(this.upperBound.y-this.lowerBound.y)/2)},b.prototype.Contains=function(e){var t=!0;return t=t&&this.lowerBound.x<=e.lowerBound.x,t=t&&this.lowerBound.y<=e.lowerBound.y,t=t&&e.upperBound.x<=this.upperBound.x,t=t&&e.upperBound.y<=this.upperBound.y,t},b.prototype.RayCast=function(e,t){var n=-Number.MAX_VALUE,r=Number.MAX_VALUE,i=t.p1.x,s=t.p1.y,o=t.p2.x-t.p1.x,u=t.p2.y-t.p1.y,a=Math.abs(o),f=Math.abs(u),l=e.normal,c=0,h=0,p=0,d=0,v=0;if(a<Number.MIN_VALUE){if(i<this.lowerBound.x||this.upperBound.x<i)return!1}else{c=1/o,h=(this.lowerBound.x-i)*c,p=(this.upperBound.x-i)*c,v=-1,h>p&&(d=h,h=p,p=d,v=1),h>n&&(l.x=v,l.y=0,n=h),r=Math.min(r,p);if(n>r)return!1}if(f<Number.MIN_VALUE){if(s<this.lowerBound.y||this.upperBound.y<s)return!1}else{c=1/u,h=(this.lowerBound.y-s)*c,p=(this.upperBound.y-s)*c,v=-1,h>p&&(d=h,h=p,p=d,v=1),h>n&&(l.y=v,l.x=0,n=h),r=Math.min(r,p);if(n>r)return!1}return e.fraction=n,!0},b.prototype.TestOverlap=function(e){var t=e.lowerBound.x-this.upperBound.x,n=e.lowerBound.y-this.upperBound.y,r=this.lowerBound.x-e.upperBound.x,i=this.lowerBound.y-e.upperBound.y;return t>0||n>0?!1:r>0||i>0?!1:!0},b.Combine=function(e,t){var n=new b;return n.Combine(e,t),n},b.prototype.Combine=function(e,t){this.lowerBound.x=Math.min(e.lowerBound.x,t.lowerBound.x),this.lowerBound.y=Math.min(e.lowerBound.y,t.lowerBound.y),this.upperBound.x=Math.max(e.upperBound.x,t.upperBound.x),this.upperBound.y=Math.max(e.upperBound.y,t.upperBound.y)},w.b2Bound=function(){},w.prototype.IsLower=function(){return(this.value&1)==0},w.prototype.IsUpper=function(){return(this.value&1)==1},w.prototype.Swap=function(e){var t=this.value,n=this.proxy,r=this.stabbingCount;this.value=e.value,this.proxy=e.proxy,this.stabbingCount=e.stabbingCount,e.value=t,e.proxy=n,e.stabbingCount=r},E.b2BoundValues=function(){},E.prototype.b2BoundValues=function(){this.lowerValues=new n,this.lowerValues[0]=0,this.lowerValues[1]=0,this.upperValues=new n,this.upperValues[0]=0,this.upperValues[1]=0},S.b2Collision=function(){},S.ClipSegmentToLine=function(e,t,n,r){r===undefined&&(r=0);var i,s=0;i=t[0];var o=i.v;i=t[1];var u=i.v,a=n.x*o.x+n.y*o.y-r,f=n.x*u.x+n.y*u.y-r;a<=0&&e[s++].Set(t[0]),f<=0&&e[s++].Set(t[1]);if(a*f<0){var l=a/(a-f);i=e[s];var c=i.v;c.x=o.x+l*(u.x-o.x),c.y=o.y+l*(u.y-o.y),i=e[s];var h;a>0?(h=t[0],i.id=h.id):(h=t[1],i.id=h.id),++s}return s},S.EdgeSeparation=function(e,t,n,r,i){n===undefined&&(n=0);var s=parseInt(e.m_vertexCount),o=e.m_vertices,u=e.m_normals,a=parseInt(r.m_vertexCount),f=r.m_vertices,l,c;l=t.R,c=u[n];var h=l.col1.x*c.x+l.col2.x*c.y,p=l.col1.y*c.x+l.col2.y*c.y;l=i.R;var d=l.col1.x*h+l.col1.y*p,v=l.col2.x*h+l.col2.y*p,m=0,g=Number.MAX_VALUE;for(var y=0;y<a;++y){c=f[y];var b=c.x*d+c.y*v;b<g&&(g=b,m=y)}c=o[n],l=t.R;var w=t.position.x+(l.col1.x*c.x+l.col2.x*c.y),E=t.position.y+(l.col1.y*c.x+l.col2.y*c.y);c=f[m],l=i.R;var S=i.position.x+(l.col1.x*c.x+l.col2.x*c.y),x=i.position.y+(l.col1.y*c.x+l.col2.y*c.y);S-=w,x-=E;var T=S*h+x*p;return T},S.FindMaxSeparation=function(e,t,n,r,i){var s=parseInt(t.m_vertexCount),o=t.m_normals,u,a;a=i.R,u=r.m_centroid;var f=i.position.x+(a.col1.x*u.x+a.col2.x*u.y),l=i.position.y+(a.col1.y*u.x+a.col2.y*u.y);a=n.R,u=t.m_centroid,f-=n.position.x+(a.col1.x*u.x+a.col2.x*u.y),l-=n.position.y+(a.col1.y*u.x+a.col2.y*u.y);var c=f*n.R.col1.x+l*n.R.col1.y,h=f*n.R.col2.x+l*n.R.col2.y,p=0,d=-Number.MAX_VALUE;for(var v=0;v<s;++v){u=o[v];var m=u.x*c+u.y*h;m>d&&(d=m,p=v)}var g=S.EdgeSeparation(t,n,p,r,i),y=parseInt(p-1>=0?p-1:s-1),b=S.EdgeSeparation(t,n,y,r,i),w=parseInt(p+1<s?p+1:0),E=S.EdgeSeparation(t,n,w,r,i),x=0,T=0,N=0;if(b>g&&b>E)N=-1,x=y,T=b;else{if(!(E>g))return e[0]=p,g;N=1,x=w,T=E}for(;;){N==-1?p=x-1>=0?x-1:s-1:p=x+1<s?x+1:0,g=S.EdgeSeparation(t,n,p,r,i);if(!(g>T))break;x=p,T=g}return e[0]=x,T},S.FindIncidentEdge=function(e,t,n,r,i,s){r===undefined&&(r=0);var o=parseInt(t.m_vertexCount),u=t.m_normals,a=parseInt(i.m_vertexCount),f=i.m_vertices,l=i.m_normals,c,h;c=n.R,h=u[r];var p=c.col1.x*h.x+c.col2.x*h.y,d=c.col1.y*h.x+c.col2.y*h.y;c=s.R;var v=c.col1.x*p+c.col1.y*d;d=c.col2.x*p+c.col2.y*d,p=v;var m=0,g=Number.MAX_VALUE;for(var y=0;y<a;++y){h=l[y];var b=p*h.x+d*h.y;b<g&&(g=b,m=y)}var w,E=parseInt(m),S=parseInt(E+1<a?E+1:0);w=e[0],h=f[E],c=s.R,w.v.x=s.position.x+(c.col1.x*h.x+c.col2.x*h.y),w.v.y=s.position.y+(c.col1.y*h.x+c.col2.y*h.y),w.id.features.referenceEdge=r,w.id.features.incidentEdge=E,w.id.features.incidentVertex=0,w=e[1],h=f[S],c=s.R,w.v.x=s.position.x+(c.col1.x*h.x+c.col2.x*h.y),w.v.y=s.position.y+(c.col1.y*h.x+c.col2.y*h.y),w.id.features.referenceEdge=r,w.id.features.incidentEdge=S,w.id.features.incidentVertex=1},S.MakeClipPointVector=function(){var e=new t(2);return e[0]=new V,e[1]=new V,e},S.CollidePolygons=function(e,t,n,r,i){var s;e.m_pointCount=0;var o=t.m_radius+r.m_radius,u=0;S.s_edgeAO[0]=u;var a=S.FindMaxSeparation(S.s_edgeAO,t,n,r,i);u=S.s_edgeAO[0];if(a>o)return;var f=0;S.s_edgeBO[0]=f;var l=S.FindMaxSeparation(S.s_edgeBO,r,i,t,n);f=S.s_edgeBO[0];if(l>o)return;var h,p,d,v,m=0,g=0,y=.98,b=.001,w;l>y*a+b?(h=r,p=t,d=i,v=n,m=f,e.m_type=D.e_faceB,g=1):(h=t,p=r,d=n,v=i,m=u,e.m_type=D.e_faceA,g=0);var E=S.s_incidentEdge;S.FindIncidentEdge(E,h,d,m,p,v);var x=parseInt(h.m_vertexCount),T=h.m_vertices,N=T[m],C;m+1<x?C=T[parseInt(m+1)]:C=T[0];var k=S.s_localTangent;k.Set(C.x-N.x,C.y-N.y),k.Normalize();var L=S.s_localNormal;L.x=k.y,L.y=-k.x;var A=S.s_planePoint;A.Set(.5*(N.x+C.x),.5*(N.y+C.y));var O=S.s_tangent;w=d.R,O.x=w.col1.x*k.x+w.col2.x*k.y,O.y=w.col1.y*k.x+w.col2.y*k.y;var M=S.s_tangent2;M.x=-O.x,M.y=-O.y;var _=S.s_normal;_.x=O.y,_.y=-O.x;var P=S.s_v11,H=S.s_v12;P.x=d.position.x+(w.col1.x*N.x+w.col2.x*N.y),P.y=d.position.y+(w.col1.y*N.x+w.col2.y*N.y),H.x=d.position.x+(w.col1.x*C.x+w.col2.x*C.y),H.y=d.position.y+(w.col1.y*C.x+w.col2.y*C.y);var B=_.x*P.x+_.y*P.y,j=-O.x*P.x-O.y*P.y+o,F=O.x*H.x+O.y*H.y+o,I=S.s_clipPoints1,q=S.s_clipPoints2,R=0;R=S.ClipSegmentToLine(I,E,M,j);if(R<2)return;R=S.ClipSegmentToLine(q,I,O,F);if(R<2)return;e.m_localPlaneNormal.SetV(L),e.m_localPoint.SetV(A);var U=0;for(var z=0;z<c.b2_maxManifoldPoints;++z){s=q[z];var W=_.x*s.v.x+_.y*s.v.y-B;if(W<=o){var X=e.m_points[U];w=v.R;var V=s.v.x-v.position.x,$=s.v.y-v.position.y;X.m_localPoint.x=V*w.col1.x+$*w.col1.y,X.m_localPoint.y=V*w.col2.x+$*w.col2.y,X.m_id.Set(s.id),X.m_id.features.flip=g,++U}}e.m_pointCount=U},S.CollideCircles=function(e,t,n,r,i){e.m_pointCount=0;var s,o;s=n.R,o=t.m_p;var u=n.position.x+(s.col1.x*o.x+s.col2.x*o.y),a=n.position.y+(s.col1.y*o.x+s.col2.y*o.y);s=i.R,o=r.m_p;var f=i.position.x+(s.col1.x*o.x+s.col2.x*o.y),l=i.position.y+(s.col1.y*o.x+s.col2.y*o.y),c=f-u,h=l-a,p=c*c+h*h,d=t.m_radius+r.m_radius;if(p>d*d)return;e.m_type=D.e_circles,e.m_localPoint.SetV(t.m_p),e.m_localPlaneNormal.SetZero(),e.m_pointCount=1,e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0},S.CollidePolygonAndCircle=function(e,t,n,r,i){e.m_pointCount=0;var s,o=0,u=0,a=0,f=0,l,c;c=i.R,l=r.m_p;var h=i.position.x+(c.col1.x*l.x+c.col2.x*l.y),p=i.position.y+(c.col1.y*l.x+c.col2.y*l.y);o=h-n.position.x,u=p-n.position.y,c=n.R;var d=o*c.col1.x+u*c.col1.y,v=o*c.col2.x+u*c.col2.y,m=0,g=0,y=-Number.MAX_VALUE,b=t.m_radius+r.m_radius,w=parseInt(t.m_vertexCount),E=t.m_vertices,S=t.m_normals;for(var x=0;x<w;++x){l=E[x],o=d-l.x,u=v-l.y,l=S[x];var T=l.x*o+l.y*u;if(T>b)return;T>y&&(y=T,g=x)}var N=parseInt(g),C=parseInt(N+1<w?N+1:0),k=E[N],L=E[C];if(y<Number.MIN_VALUE){e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.SetV(S[g]),e.m_localPoint.x=.5*(k.x+L.x),e.m_localPoint.y=.5*(k.y+L.y),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0;return}var A=(d-k.x)*(L.x-k.x)+(v-k.y)*(L.y-k.y),O=(d-L.x)*(k.x-L.x)+(v-L.y)*(k.y-L.y);if(A<=0){if((d-k.x)*(d-k.x)+(v-k.y)*(v-k.y)>b*b)return;e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.x=d-k.x,e.m_localPlaneNormal.y=v-k.y,e.m_localPlaneNormal.Normalize(),e.m_localPoint.SetV(k),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0}else if(O<=0){if((d-L.x)*(d-L.x)+(v-L.y)*(v-L.y)>b*b)return;e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.x=d-L.x,e.m_localPlaneNormal.y=v-L.y,e.m_localPlaneNormal.Normalize(),e.m_localPoint.SetV(L),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0}else{var M=.5*(k.x+L.x),_=.5*(k.y+L.y);y=(d-M)*S[N].x+(v-_)*S[N].y;if(y>b)return;e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.x=S[N].x,e.m_localPlaneNormal.y=S[N].y,e.m_localPlaneNormal.Normalize(),e.m_localPoint.Set(M,_),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0}},S.TestOverlap=function(e,t){var n=t.lowerBound,r=e.upperBound,i=n.x-r.x,s=n.y-r.y;n=e.lowerBound,r=t.upperBound;var o=n.x-r.x,u=n.y-r.y;return i>0||s>0?!1:o>0||u>0?!1:!0},e.postDefs.push(function(){e.Collision.b2Collision.s_incidentEdge=S.MakeClipPointVector(),e.Collision.b2Collision.s_clipPoints1=S.MakeClipPointVector(),e.Collision.b2Collision.s_clipPoints2=S.MakeClipPointVector(),e.Collision.b2Collision.s_edgeAO=new n(1),e.Collision.b2Collision.s_edgeBO=new n(1),e.Collision.b2Collision.s_localTangent=new g,e.Collision.b2Collision.s_localNormal=new g,e.Collision.b2Collision.s_planePoint=new g,e.Collision.b2Collision.s_normal=new g,e.Collision.b2Collision.s_tangent=new g,e.Collision.b2Collision.s_tangent2=new g,e.Collision.b2Collision.s_v11=new g,e.Collision.b2Collision.s_v12=new g,e.Collision.b2Collision.b2CollidePolyTempVec=new g,e.Collision.b2Collision.b2_nullFeature=255}),x.b2ContactID=function(){this.features=new $},x.prototype.b2ContactID=function(){this.features._m_id=this},x.prototype.Set=function(e){this.key=e._key},x.prototype.Copy=function(){var e=new x;return e.key=this.key,e},Object.defineProperty(x.prototype,"key",{enumerable:!1,configurable:!0,get:function(){return this._key}}),Object.defineProperty(x.prototype,"key",{enumerable:!1,configurable:!0,set:function(e){e===undefined&&(e=0),this._key=e,this.features._referenceEdge=this._key&255,this.features._incidentEdge=(this._key&65280)>>8&255,this.features._incidentVertex=(this._key&16711680)>>16&255,this.features._flip=(this._key&4278190080)>>24&255}}),T.b2ContactPoint=function(){this.position=new g,this.velocity=new g,this.normal=new g,this.id=new x},N.b2Distance=function(){},N.Distance=function(e,t,n){++N.b2_gjkCalls;var r=n.proxyA,i=n.proxyB,s=n.transformA,o=n.transformB,u=N.s_simplex;u.ReadCache(t,r,s,i,o);var a=u.m_vertices,f=20,l=N.s_saveA,h=N.s_saveB,p=0,v=u.GetClosestPoint(),m=v.LengthSquared(),y=m,b=0,w,E=0;while(E<f){p=u.m_count;for(b=0;b<p;b++)l[b]=a[b].indexA,h[b]=a[b].indexB;switch(u.m_count){case 1:break;case 2:u.Solve2();break;case 3:u.Solve3();break;default:c.b2Assert(!1)}if(u.m_count==3)break;w=u.GetClosestPoint(),y=w.LengthSquared(),y>m,m=y;var S=u.GetSearchDirection();if(S.LengthSquared()<Number.MIN_VALUE*Number.MIN_VALUE)break;var x=a[u.m_count];x.indexA=r.GetSupport(d.MulTMV(s.R,S.GetNegative())),x.wA=d.MulX(s,r.GetVertex(x.indexA)),x.indexB=i.GetSupport(d.MulTMV(o.R,S)),x.wB=d.MulX(o,i.GetVertex(x.indexB)),x.w=d.SubtractVV(x.wB,x.wA),++E,++N.b2_gjkIters;var T=!1;for(b=0;b<p;b++)if(x.indexA==l[b]&&x.indexB==h[b]){T=!0;break}if(T)break;++u.m_count}N.b2_gjkMaxIters=d.Max(N.b2_gjkMaxIters,E),u.GetWitnessPoints(e.pointA,e.pointB),e.distance=d.SubtractVV(e.pointA,e.pointB).Length(),e.iterations=E,u.WriteCache(t);if(n.useRadii){var C=r.m_radius,k=i.m_radius;if(e.distance>C+k&&e.distance>Number.MIN_VALUE){e.distance-=C+k;var L=d.SubtractVV(e.pointB,e.pointA);L.Normalize(),e.pointA.x+=C*L.x,e.pointA.y+=C*L.y,e.pointB.x-=k*L.x,e.pointB.y-=k*L.y}else w=new g,w.x=.5*(e.pointA.x+e.pointB.x),w.y=.5*(e.pointA.y+e.pointB.y),e.pointA.x=e.pointB.x=w.x,e.pointA.y=e.pointB.y=w.y,e.distance=0}},e.postDefs.push(function(){e.Collision.b2Distance.s_simplex=new q,e.Collision.b2Distance.s_saveA=new n(3),e.Collision.b2Distance.s_saveB=new n(3)}),C.b2DistanceInput=function(){},k.b2DistanceOutput=function(){this.pointA=new g,this.pointB=new g},L.b2DistanceProxy=function(){},L.prototype.Set=function(e){switch(e.GetType()){case a.e_circleShape:var n=e instanceof r?e:null;this.m_vertices=new t(1,!0),this.m_vertices[0]=n.m_p,this.m_count=1,this.m_radius=n.m_radius;break;case a.e_polygonShape:var i=e instanceof u?e:null;this.m_vertices=i.m_vertices,this.m_count=i.m_vertexCount,this.m_radius=i.m_radius;break;default:c.b2Assert(!1)}},L.prototype.GetSupport=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;r<this.m_count;++r){var i=this.m_vertices[r].x*e.x+this.m_vertices[r].y*e.y;i>n&&(t=r,n=i)}return t},L.prototype.GetSupportVertex=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;r<this.m_count;++r){var i=this.m_vertices[r].x*e.x+this.m_vertices[r].y*e.y;i>n&&(t=r,n=i)}return this.m_vertices[t]},L.prototype.GetVertexCount=function(){return this.m_count},L.prototype.GetVertex=function(e){return e===undefined&&(e=0),c.b2Assert(0<=e&&e<this.m_count),this.m_vertices[e]},A.b2DynamicTree=function(){},A.prototype.b2DynamicTree=function(){this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0},A.prototype.CreateProxy=function(e,t){var n=this.AllocateNode(),r=c.b2_aabbExtension,i=c.b2_aabbExtension;return n.aabb.lowerBound.x=e.lowerBound.x-r,n.aabb.lowerBound.y=e.lowerBound.y-i,n.aabb.upperBound.x=e.upperBound.x+r,n.aabb.upperBound.y=e.upperBound.y+i,n.userData=t,this.InsertLeaf(n),n},A.prototype.DestroyProxy=function(e){this.RemoveLeaf(e),this.FreeNode(e)},A.prototype.MoveProxy=function(e,t,n){c.b2Assert(e.IsLeaf());if(e.aabb.Contains(t))return!1;this.RemoveLeaf(e);var r=c.b2_aabbExtension+c.b2_aabbMultiplier*(n.x>0?n.x:-n.x),i=c.b2_aabbExtension+c.b2_aabbMultiplier*(n.y>0?n.y:-n.y);return e.aabb.lowerBound.x=t.lowerBound.x-r,e.aabb.lowerBound.y=t.lowerBound.y-i,e.aabb.upperBound.x=t.upperBound.x+r,e.aabb.upperBound.y=t.upperBound.y+i,this.InsertLeaf(e),!0},A.prototype.Rebalance=function(e){e===undefined&&(e=0);if(this.m_root==null)return;for(var t=0;t<e;t++){var n=this.m_root,r=0;while(n.IsLeaf()==0)n=this.m_path>>r&1?n.child2:n.child1,r=r+1&31;++this.m_path,this.RemoveLeaf(n),this.InsertLeaf(n)}},A.prototype.GetFatAABB=function(e){return e.aabb},A.prototype.GetUserData=function(e){return e.userData},A.prototype.Query=function(e,n){if(this.m_root==null)return;var r=new t,i=0;r[i++]=this.m_root;while(i>0){var s=r[--i];if(s.aabb.TestOverlap(n))if(s.IsLeaf()){var o=e(s);if(!o)return}else r[i++]=s.child1,r[i++]=s.child2}},A.prototype.RayCast=function(e,n){if(this.m_root==null)return;var r=n.p1,i=n.p2,s=d.SubtractVV(r,i);s.Normalize();var o=d.CrossFV(1,s),u=d.AbsV(o),a=n.maxFraction,f=new b,l=0,c=0;l=r.x+a*(i.x-r.x),c=r.y+a*(i.y-r.y),f.lowerBound.x=Math.min(r.x,l),f.lowerBound.y=Math.min(r.y,c),f.upperBound.x=Math.max(r.x,l),f.upperBound.y=Math.max(r.y,c);var h=new t,p=0;h[p++]=this.m_root;while(p>0){var v=h[--p];if(v.aabb.TestOverlap(f)==0)continue;var m=v.aabb.GetCenter(),g=v.aabb.GetExtents(),y=Math.abs(o.x*(r.x-m.x)+o.y*(r.y-m.y))-u.x*g.x-u.y*g.y;if(y>0)continue;if(v.IsLeaf()){var w=new B;w.p1=n.p1,w.p2=n.p2,w.maxFraction=n.maxFraction,a=e(w,v);if(a==0)return;a>0&&(l=r.x+a*(i.x-r.x),c=r.y+a*(i.y-r.y),f.lowerBound.x=Math.min(r.x,l),f.lowerBound.y=Math.min(r.y,c),f.upperBound.x=Math.max(r.x,l),f.upperBound.y=Math.max(r.y,c))}else h[p++]=v.child1,h[p++]=v.child2}},A.prototype.AllocateNode=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}return new M},A.prototype.FreeNode=function(e){e.parent=this.m_freeList,this.m_freeList=e},A.prototype.InsertLeaf=function(e){++this.m_insertionCount;if(this.m_root==null){this.m_root=e,this.m_root.parent=null;return}var t=e.aabb.GetCenter(),n=this.m_root;if(n.IsLeaf()==0)do{var r=n.child1,i=n.child2,s=Math.abs((r.aabb.lowerBound.x+r.aabb.upperBound.x)/2-t.x)+Math.abs((r.aabb.lowerBound.y+r.aabb.upperBound.y)/2-t.y),o=Math.abs((i.aabb.lowerBound.x+i.aabb.upperBound.x)/2-t.x)+Math.abs((i.aabb.lowerBound.y+i.aabb.upperBound.y)/2-t.y);s<o?n=r:n=i}while(n.IsLeaf()==0);var u=n.parent,a=this.AllocateNode();a.parent=u,a.userData=null,a.aabb.Combine(e.aabb,n.aabb);if(u){n.parent.child1==n?u.child1=a:u.child2=a,a.child1=n,a.child2=e,n.parent=a,e.parent=a;do{if(u.aabb.Contains(a.aabb))break;u.aabb.Combine(u.child1.aabb,u.child2.aabb),a=u,u=u.parent}while(u)}else a.child1=n,a.child2=e,n.parent=a,e.parent=a,this.m_root=a},A.prototype.RemoveLeaf=function(e){if(e==this.m_root){this.m_root=null;return}var t=e.parent,n=t.parent,r;t.child1==e?r=t.child2:r=t.child1;if(n){n.child1==t?n.child1=r:n.child2=r,r.parent=n,this.FreeNode(t);while(n){var i=n.aabb;n.aabb=b.Combine(n.child1.aabb,n.child2.aabb);if(i.Contains(n.aabb))break;n=n.parent}}else this.m_root=r,r.parent=null,this.FreeNode(t)},O.b2DynamicTreeBroadPhase=function(){this.m_tree=new A,this.m_moveBuffer=new t,this.m_pairBuffer=new t,this.m_pairCount=0},O.prototype.CreateProxy=function(e,t){var n=this.m_tree.CreateProxy(e,t);return++this.m_proxyCount,this.BufferMove(n),n},O.prototype.DestroyProxy=function(e){this.UnBufferMove(e),--this.m_proxyCount,this.m_tree.DestroyProxy(e)},O.prototype.MoveProxy=function(e,t,n){var r=this.m_tree.MoveProxy(e,t,n);r&&this.BufferMove(e)},O.prototype.TestOverlap=function(e,t){var n=this.m_tree.GetFatAABB(e),r=this.m_tree.GetFatAABB(t);return n.TestOverlap(r)},O.prototype.GetUserData=function(e){return this.m_tree.GetUserData(e)},O.prototype.GetFatAABB=function(e){return this.m_tree.GetFatAABB(e)},O.prototype.GetProxyCount=function(){return this.m_proxyCount},O.prototype.UpdatePairs=function(e){var t=this;t.m_pairCount=0;var n=0,r;for(n=0;n<t.m_moveBuffer.length;++n){r=t.m_moveBuffer[n];function i(e){if(e==r)return!0;t.m_pairCount==t.m_pairBuffer.length&&(t.m_pairBuffer[t.m_pairCount]=new _);var n=t.m_pairBuffer[t.m_pairCount];return n.proxyA=e<r?e:r,n.proxyB=e>=r?e:r,++t.m_pairCount,!0}var s=t.m_tree.GetFatAABB(r);t.m_tree.Query(i,s)}t.m_moveBuffer.length=0;for(var n=0;n<t.m_pairCount;){var o=t.m_pairBuffer[n],u=t.m_tree.GetUserData(o.proxyA),a=t.m_tree.GetUserData(o.proxyB);e(u,a),++n;while(n<t.m_pairCount){var f=t.m_pairBuffer[n];if(f.proxyA!=o.proxyA||f.proxyB!=o.proxyB)break;++n}}},O.prototype.Query=function(e,t){this.m_tree.Query(e,t)},O.prototype.RayCast=function(e,t){this.m_tree.RayCast(e,t)},O.prototype.Validate=function(){},O.prototype.Rebalance=function(e){e===undefined&&(e=0),this.m_tree.Rebalance(e)},O.prototype.BufferMove=function(e){this.m_moveBuffer[this.m_moveBuffer.length]=e},O.prototype.UnBufferMove=function(e){var t=parseInt(this.m_moveBuffer.indexOf(e));this.m_moveBuffer.splice(t,1)},O.prototype.ComparePairs=function(e,t){return 0},O.__implements={},O.__implements[J]=!0,M.b2DynamicTreeNode=function(){this.aabb=new b},M.prototype.IsLeaf=function(){return this.child1==null},_.b2DynamicTreePair=function(){},D.b2Manifold=function(){this.m_pointCount=0},D.prototype.b2Manifold=function(){this.m_points=new t(c.b2_maxManifoldPoints);for(var e=0;e<c.b2_maxManifoldPoints;e++)this.m_points[e]=new P;this.m_localPlaneNormal=new g,this.m_localPoint=new g},D.prototype.Reset=function(){for(var e=0;e<c.b2_maxManifoldPoints;e++)(this.m_points[e]instanceof P?this.m_points[e]:null).Reset();this.m_localPlaneNormal.SetZero(),this.m_localPoint.SetZero(),this.m_type=0,this.m_pointCount=0},D.prototype.Set=function(e){this.m_pointCount=e.m_pointCount;for(var t=0;t<c.b2_maxManifoldPoints;t++)(this.m_points[t]instanceof P?this.m_points[t]:null).Set(e.m_points[t]);this.m_localPlaneNormal.SetV(e.m_localPlaneNormal),this.m_localPoint.SetV(e.m_localPoint),this.m_type=e.m_type},D.prototype.Copy=function(){var e=new D;return e.Set(this),e},e.postDefs.push(function(){e.Collision.b2Manifold.e_circles=1,e.Collision.b2Manifold.e_faceA=2,e.Collision.b2Manifold.e_faceB=4}),P.b2ManifoldPoint=function(){this.m_localPoint=new g,this.m_id=new x},P.prototype.b2ManifoldPoint=function(){this.Reset()},P.prototype.Reset=function(){this.m_localPoint.SetZero(),this.m_normalImpulse=0,this.m_tangentImpulse=0,this.m_id.key=0},P.prototype.Set=function(e){this.m_localPoint.SetV(e.m_localPoint),this.m_normalImpulse=e.m_normalImpulse,this.m_tangentImpulse=e.m_tangentImpulse,this.m_id.Set(e.m_id)},H.b2Point=function(){this.p=new g},H.prototype.Support=function(e,t,n){return t===undefined&&(t=0),n===undefined&&(n=0),this.p},H.prototype.GetFirstVertex=function(e){return this.p},B.b2RayCastInput=function(){this.p1=new g,this.p2=new g},B.prototype.b2RayCastInput=function(e,t,n){e===undefined&&(e=null),t===undefined&&(t=null),n===undefined&&(n=1),e&&this.p1.SetV(e),t&&this.p2.SetV(t),this.maxFraction=n},j.b2RayCastOutput=function(){this.normal=new g},F.b2Segment=function(){this.p1=new g,this.p2=new g},F.prototype.TestSegment=function(e,t,n,r){r===undefined&&(r=0);var i=n.p1,s=n.p2.x-i.x,o=n.p2.y-i.y,u=this.p2.x-this.p1.x,a=this.p2.y-this.p1.y,f=a,l=-u,c=100*Number.MIN_VALUE,h=-(s*f+o*l);if(h>c){var p=i.x-this.p1.x,d=i.y-this.p1.y,v=p*f+d*l;if(0<=v&&v<=r*h){var m=-s*d+o*p;if(-c*h<=m&&m<=h*(1+c)){v/=h;var g=Math.sqrt(f*f+l*l);return f/=g,l/=g,e[0]=v,t.Set(f,l),!0}}}return!1},F.prototype.Extend=function(e){this.ExtendForward(e),this.ExtendBackward(e)},F.prototype.ExtendForward=function(e){var t=this.p2.x-this.p1.x,n=this.p2.y-this.p1.y,r=Math.min(t>0?(e.upperBound.x-this.p1.x)/t:t<0?(e.lowerBound.x-this.p1.x)/t:Number.POSITIVE_INFINITY,n>0?(e.upperBound.y-this.p1.y)/n:n<0?(e.lowerBound.y-this.p1.y)/n:Number.POSITIVE_INFINITY);this.p2.x=this.p1.x+t*r,this.p2.y=this.p1.y+n*r},F.prototype.ExtendBackward=function(e){var t=-this.p2.x+this.p1.x,n=-this.p2.y+this.p1.y,r=Math.min(t>0?(e.upperBound.x-this.p2.x)/t:t<0?(e.lowerBound.x-this.p2.x)/t:Number.POSITIVE_INFINITY,n>0?(e.upperBound.y-this.p2.y)/n:n<0?(e.lowerBound.y-this.p2.y)/n:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+t*r,this.p1.y=this.p2.y+n*r},I.b2SeparationFunction=function(){this.m_localPoint=new g,this.m_axis=new g},I.prototype.Initialize=function(e,t,n,r,i){this.m_proxyA=t,this.m_proxyB=r;var s=parseInt(e.count);c.b2Assert(0<s&&s<3);var o,u,a,f,l,h,p=0,v=0,m=0,y=0,b=0,w=0,E,S,x=0,T=0;if(s==1)this.m_type=I.e_points,o=this.m_proxyA.GetVertex(e.indexA[0]),f=this.m_proxyB.GetVertex(e.indexB[0]),S=o,E=n.R,p=n.position.x+(E.col1.x*S.x+E.col2.x*S.y),v=n.position.y+(E.col1.y*S.x+E.col2.y*S.y),S=f,E=i.R,m=i.position.x+(E.col1.x*S.x+E.col2.x*S.y),y=i.position.y+(E.col1.y*S.x+E.col2.y*S.y),this.m_axis.x=m-p,this.m_axis.y=y-v,this.m_axis.Normalize();else if(e.indexB[0]==e.indexB[1])this.m_type=I.e_faceA,u=this.m_proxyA.GetVertex(e.indexA[0]),a=this.m_proxyA.GetVertex(e.indexA[1]),f=this.m_proxyB.GetVertex(e.indexB[0]),this.m_localPoint.x=.5*(u.x+a.x),this.m_localPoint.y=.5*(u.y+a.y),this.m_axis=d.CrossVF(d.SubtractVV(a,u),1),this.m_axis.Normalize(),S=this.m_axis,E=n.R,b=E.col1.x*S.x+E.col2.x*S.y,w=E.col1.y*S.x+E.col2.y*S.y,S=this.m_localPoint,E=n.R,p=n.position.x+(E.col1.x*S.x+E.col2.x*S.y),v=n.position.y+(E.col1.y*S.x+E.col2.y*S.y),S=f,E=i.R,m=i.position.x+(E.col1.x*S.x+E.col2.x*S.y),y=i.position.y+(E.col1.y*S.x+E.col2.y*S.y),x=(m-p)*b+(y-v)*w,x<0&&this.m_axis.NegativeSelf();else if(e.indexA[0]==e.indexA[0])this.m_type=I.e_faceB,l=this.m_proxyB.GetVertex(e.indexB[0]),h=this.m_proxyB.GetVertex(e.indexB[1]),o=this.m_proxyA.GetVertex(e.indexA[0]),this.m_localPoint.x=.5*(l.x+h.x),this.m_localPoint.y=.5*(l.y+h.y),this.m_axis=d.CrossVF(d.SubtractVV(h,l),1),this.m_axis.Normalize(),S=this.m_axis,E=i.R,b=E.col1.x*S.x+E.col2.x*S.y,w=E.col1.y*S.x+E.col2.y*S.y,S=this.m_localPoint,E=i.R,m=i.position.x+(E.col1.x*S.x+E.col2.x*S.y),y=i.position.y+(E.col1.y*S.x+E.col2.y*S.y),S=o,E=n.R,p=n.position.x+(E.col1.x*S.x+E.col2.x*S.y),v=n.position.y+(E.col1.y*S.x+E.col2.y*S.y),x=(p-m)*b+(v-y)*w,x<0&&this.m_axis.NegativeSelf();else{u=this.m_proxyA.GetVertex(e.indexA[0]),a=this.m_proxyA.GetVertex(e.indexA[1]),l=this.m_proxyB.GetVertex(e.indexB[0]),h=this.m_proxyB.GetVertex(e.indexB[1]);var N=d.MulX(n,o),C=d.MulMV(n.R,d.SubtractVV(a,u)),k=d.MulX(i,f),L=d.MulMV(i.R,d.SubtractVV(h,l)),A=C.x*C.x+C.y*C.y,O=L.x*L.x+L.y*L.y,M=d.SubtractVV(L,C),_=C.x*M.x+C.y*M.y,D=L.x*M.x+L.y*M.y,P=C.x*L.x+C.y*L.y,H=A*O-P*P;x=0,H!=0&&(x=d.Clamp((P*D-_*O)/H,0,1));var B=(P*x+D)/O;B<0&&(B=0,x=d.Clamp((P-_)/A,0,1)),o=new g,o.x=u.x+x*(a.x-u.x),o.y=u.y+x*(a.y-u.y),f=new g,f.x=l.x+x*(h.x-l.x),f.y=l.y+x*(h.y-l.y),x==0||x==1?(this.m_type=I.e_faceB,this.m_axis=d.CrossVF(d.SubtractVV(h,l),1),this.m_axis.Normalize(),this.m_localPoint=f,S=this.m_axis,E=i.R,b=E.col1.x*S.x+E.col2.x*S.y,w=E.col1.y*S.x+E.col2.y*S.y,S=this.m_localPoint,E=i.R,m=i.position.x+(E.col1.x*S.x+E.col2.x*S.y),y=i.position.y+(E.col1.y*S.x+E.col2.y*S.y),S=o,E=n.R,p=n.position.x+(E.col1.x*S.x+E.col2.x*S.y),v=n.position.y+(E.col1.y*S.x+E.col2.y*S.y),T=(p-m)*b+(v-y)*w,x<0&&this.m_axis.NegativeSelf()):(this.m_type=I.e_faceA,this.m_axis=d.CrossVF(d.SubtractVV(a,u),1),this.m_localPoint=o,S=this.m_axis,E=n.R,b=E.col1.x*S.x+E.col2.x*S.y,w=E.col1.y*S.x+E.col2.y*S.y,S=this.m_localPoint,E=n.R,p=n.position.x+(E.col1.x*S.x+E.col2.x*S.y),v=n.position.y+(E.col1.y*S.x+E.col2.y*S.y),S=f,E=i.R,m=i.position.x+(E.col1.x*S.x+E.col2.x*S.y),y=i.position.y+(E.col1.y*S.x+E.col2.y*S.y),T=(m-p)*b+(y-v)*w,x<0&&this.m_axis.NegativeSelf())}},I.prototype.Evaluate=function(e,t){var n,r,i,s,o,u,a=0,f;switch(this.m_type){case I.e_points:return n=d.MulTMV(e.R,this.m_axis),r=d.MulTMV(t.R,this.m_axis.GetNegative()),i=this.m_proxyA.GetSupportVertex(n),s=this.m_proxyB.GetSupportVertex(r),o=d.MulX(e,i),u=d.MulX(t,s),a=(u.x-o.x)*this.m_axis.x+(u.y-o.y)*this.m_axis.y,a;case I.e_faceA:return f=d.MulMV(e.R,this.m_axis),o=d.MulX(e,this.m_localPoint),r=d.MulTMV(t.R,f.GetNegative()),s=this.m_proxyB.GetSupportVertex(r),u=d.MulX(t,s),a=(u.x-o.x)*f.x+(u.y-o.y)*f.y,a;case I.e_faceB:return f=d.MulMV(t.R,this.m_axis),u=d.MulX(t,this.m_localPoint),n=d.MulTMV(e.R,f.GetNegative()),i=this.m_proxyA.GetSupportVertex(n),o=d.MulX(e,i),a=(o.x-u.x)*f.x+(o.y-u.y)*f.y,a;default:return c.b2Assert(!1),0}},e.postDefs.push(function(){e.Collision.b2SeparationFunction.e_points=1,e.Collision.b2SeparationFunction.e_faceA=2,e.Collision.b2SeparationFunction.e_faceB=4}),q.b2Simplex=function(){this.m_v1=new U,this.m_v2=new U,this.m_v3=new U,this.m_vertices=new t(3)},q.prototype.b2Simplex=function(){this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3},q.prototype.ReadCache=function(e,t,n,r,i){c.b2Assert(0<=e.count&&e.count<=3);var s,o;this.m_count=e.count;var u=this.m_vertices;for(var a=0;a<this.m_count;a++){var f=u[a];f.indexA=e.indexA[a],f.indexB=e.indexB[a],s=t.GetVertex(f.indexA),o=r.GetVertex(f.indexB),f.wA=d.MulX(n,s),f.wB=d.MulX(i,o),f.w=d.SubtractVV(f.wB,f.wA),f.a=0}if(this.m_count>1){var l=e.metric,h=this.GetMetric();if(h<.5*l||2*l<h||h<Number.MIN_VALUE)this.m_count=0}this.m_count==0&&(f=u[0],f.indexA=0,f.indexB=0,s=t.GetVertex(0),o=r.GetVertex(0),f.wA=d.MulX(n,s),f.wB=d.MulX(i,o),f.w=d.SubtractVV(f.wB,f.wA),this.m_count=1)},q.prototype.WriteCache=function(t){t.metric=this.GetMetric(),t.count=e.parseUInt(this.m_count);var n=this.m_vertices;for(var r=0;r<this.m_count;r++)t.indexA[r]=e.parseUInt(n[r].indexA),t.indexB[r]=e.parseUInt(n[r].indexB)},q.prototype.GetSearchDirection=function(){switch(this.m_count){case 1:return this.m_v1.w.GetNegative();case 2:var e=d.SubtractVV(this.m_v2.w,this.m_v1.w),t=d.CrossVV(e,this.m_v1.w.GetNegative());return t>0?d.CrossFV(1,e):d.CrossVF(e,1);default:return c.b2Assert(!1),new g}},q.prototype.GetClosestPoint=function(){switch(this.m_count){case 0:return c.b2Assert(!1),new g;case 1:return this.m_v1.w;case 2:return new g(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);default:return c.b2Assert(!1),new g}},q.prototype.GetWitnessPoints=function(e,t){switch(this.m_count){case 0:c.b2Assert(!1);break;case 1:e.SetV(this.m_v1.wA),t.SetV(this.m_v1.wB);break;case 2:e.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,e.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,t.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,t.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:t.x=e.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,t.y=e.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;break;default:c.b2Assert(!1)}},q.prototype.GetMetric=function(){switch(this.m_count){case 0:return c.b2Assert(!1),0;case 1:return 0;case 2:return d.SubtractVV(this.m_v1.w,this.m_v2.w).Length();case 3:return d.CrossVV(d.SubtractVV(this.m_v2.w,this.m_v1.w),d.SubtractVV(this.m_v3.w,this.m_v1.w));default:return c.b2Assert(!1),0}},q.prototype.Solve2=function(){var e=this.m_v1.w,t=this.m_v2.w,n=d.SubtractVV(t,e),r=-(e.x*n.x+e.y*n.y);if(r<=0){this.m_v1.a=1,this.m_count=1;return}var i=t.x*n.x+t.y*n.y;if(i<=0){this.m_v2.a=1,this.m_count=1,this.m_v1.Set(this.m_v2);return}var s=1/(i+r);this.m_v1.a=i*s,this.m_v2.a=r*s,this.m_count=2},q.prototype.Solve3=function(){var e=this.m_v1.w,t=this.m_v2.w,n=this.m_v3.w,r=d.SubtractVV(t,e),i=d.Dot(e,r),s=d.Dot(t,r),o=s,u=-i,a=d.SubtractVV(n,e),f=d.Dot(e,a),l=d.Dot(n,a),c=l,h=-f,p=d.SubtractVV(n,t),v=d.Dot(t,p),m=d.Dot(n,p),g=m,y=-v,b=d.CrossVV(r,a),w=b*d.CrossVV(t,n),E=b*d.CrossVV(n,e),S=b*d.CrossVV(e,t);if(u<=0&&h<=0){this.m_v1.a=1,this.m_count=1;return}if(o>0&&u>0&&S<=0){var x=1/(o+u);this.m_v1.a=o*x,this.m_v2.a=u*x,this.m_count=2;return}if(c>0&&h>0&&E<=0){var T=1/(c+h);this.m_v1.a=c*T,this.m_v3.a=h*T,this.m_count=2,this.m_v2.Set(this.m_v3);return}if(o<=0&&y<=0){this.m_v2.a=1,this.m_count=1,this.m_v1.Set(this.m_v2);return}if(c<=0&&g<=0){this.m_v3.a=1,this.m_count=1,this.m_v1.Set(this.m_v3);return}if(g>0&&y>0&&w<=0){var N=1/(g+y);this.m_v2.a=g*N,this.m_v3.a=y*N,this.m_count=2,this.m_v1.Set(this.m_v3);return}var C=1/(w+E+S);this.m_v1.a=w*C,this.m_v2.a=E*C,this.m_v3.a=S*C,this.m_count=3},R.b2SimplexCache=function(){this.indexA=new n(3),this.indexB=new n(3)},U.b2SimplexVertex=function(){},U.prototype.Set=function(e){this.wA.SetV(e.wA),this.wB.SetV(e.wB),this.w.SetV(e.w),this.a=e.a,this.indexA=e.indexA,this.indexB=e.indexB},z.b2TimeOfImpact=function(){},z.TimeOfImpact=function(e){++z.b2_toiCalls;var t=e.proxyA,n=e.proxyB,r=e.sweepA,i=e.sweepB;c.b2Assert(r.t0==i.t0),c.b2Assert(1-r.t0>Number.MIN_VALUE);var s=t.m_radius+n.m_radius,o=e.tolerance,u=0,a=1e3,f=0,l=0;z.s_cache.count=0,z.s_distanceInput.useRadii=!1;for(;;){r.GetTransform(z.s_xfA,u),i.GetTransform(z.s_xfB,u),z.s_distanceInput.proxyA=t,z.s_distanceInput.proxyB=n,z.s_distanceInput.transformA=z.s_xfA,z.s_distanceInput.transformB=z.s_xfB,N.Distance(z.s_distanceOutput,z.s_cache,z.s_distanceInput);if(z.s_distanceOutput.distance<=0){u=1;break}z.s_fcn.Initialize(z.s_cache,t,z.s_xfA,n,z.s_xfB);var h=z.s_fcn.Evaluate(z.s_xfA,z.s_xfB);if(h<=0){u=1;break}f==0&&(h>s?l=d.Max(s-o,.75*s):l=d.Max(h-o,.02*s));if(h-l<.5*o){if(f==0){u=1;break}break}var p=u,v=u,m=1,g=h;r.GetTransform(z.s_xfA,m),i.GetTransform(z.s_xfB,m);var y=z.s_fcn.Evaluate(z.s_xfA,z.s_xfB);if(y>=l){u=1;break}var b=0;for(;;){var w=0;b&1?w=v+(l-g)*(m-v)/(y-g):w=.5*(v+m),r.GetTransform(z.s_xfA,w),i.GetTransform(z.s_xfB,w);var E=z.s_fcn.Evaluate(z.s_xfA,z.s_xfB);if(d.Abs(E-l)<.025*o){p=w;break}E>l?(v=w,g=E):(m=w,y=E),++b,++z.b2_toiRootIters;if(b==50)break}z.b2_toiMaxRootIters=d.Max(z.b2_toiMaxRootIters,b);if(p<(1+100*Number.MIN_VALUE)*u)break;u=p,f++,++z.b2_toiIters;if(f==a)break}return z.b2_toiMaxIters=d.Max(z.b2_toiMaxIters,f),u},e.postDefs.push(function(){e.Collision.b2TimeOfImpact.b2_toiCalls=0,e.Collision.b2TimeOfImpact.b2_toiIters=0,e.Collision.b2TimeOfImpact.b2_toiMaxIters=0,e.Collision.b2TimeOfImpact.b2_toiRootIters=0,e.Collision.b2TimeOfImpact.b2_toiMaxRootIters=0,e.Collision.b2TimeOfImpact.s_cache=new R,e.Collision.b2TimeOfImpact.s_distanceInput=new C,e.Collision.b2TimeOfImpact.s_xfA=new m,e.Collision.b2TimeOfImpact.s_xfB=new m,e.Collision.b2TimeOfImpact.s_fcn=new I,e.Collision.b2TimeOfImpact.s_distanceOutput=new k}),W.b2TOIInput=function(){this.proxyA=new L,this.proxyB=new L,this.sweepA=new v,this.sweepB=new v},X.b2WorldManifold=function(){this.m_normal=new g},X.prototype.b2WorldManifold=function(){this.m_points=new t(c.b2_maxManifoldPoints);for(var e=0;e<c.b2_maxManifoldPoints;e++)this.m_points[e]=new g},X.prototype.Initialize=function(e,t,n,r,i){n===undefined&&(n=0),i===undefined&&(i=0);if(e.m_pointCount==0)return;var s=0,o,u,a=0,f=0,l=0,c=0,h=0,p=0;switch(e.m_type){case D.e_circles:u=t.R,o=e.m_localPoint;var d=t.position.x+u.col1.x*o.x+u.col2.x*o.y,v=t.position.y+u.col1.y*o.x+u.col2.y*o.y;u=r.R,o=e.m_points[0].m_localPoint;var m=r.position.x+u.col1.x*o.x+u.col2.x*o.y,g=r.position.y+u.col1.y*o.x+u.col2.y*o.y,y=m-d,b=g-v,w=y*y+b*b;if(w>Number.MIN_VALUE*Number.MIN_VALUE){var E=Math.sqrt(w);this.m_normal.x=y/E,this.m_normal.y=b/E}else this.m_normal.x=1,this.m_normal.y=0;var S=d+n*this.m_normal.x,x=v+n*this.m_normal.y,T=m-i*this.m_normal.x,N=g-i*this.m_normal.y;this.m_points[0].x=.5*(S+T),this.m_points[0].y=.5*(x+N);break;case D.e_faceA:u=t.R,o=e.m_localPlaneNormal,a=u.col1.x*o.x+u.col2.x*o.y,f=u.col1.y*o.x+u.col2.y*o.y,u=t.R,o=e.m_localPoint,l=t.position.x+u.col1.x*o.x+u.col2.x*o.y,c=t.position.y+u.col1.y*o.x+u.col2.y*o.y,this.m_normal.x=a,this.m_normal.y=f;for(s=0;s<e.m_pointCount;s++)u=r.R,o=e.m_points[s].m_localPoint,h=r.position.x+u.col1.x*o.x+u.col2.x*o.y,p=r.position.y+u.col1.y*o.x+u.col2.y*o.y,this.m_points[s].x=h+.5*(n-(h-l)*a-(p-c)*f-i)*a,this.m_points[s].y=p+.5*(n-(h-l)*a-(p-c)*f-i)*f;break;case D.e_faceB:u=r.R,o=e.m_localPlaneNormal,a=u.col1.x*o.x+u.col2.x*o.y,f=u.col1.y*o.x+u.col2.y*o.y,u=r.R,o=e.m_localPoint,l=r.position.x+u.col1.x*o.x+u.col2.x*o.y,c=r.position.y+u.col1.y*o.x+u.col2.y*o.y,this.m_normal.x=-a,this.m_normal.y=-f;for(s=0;s<e.m_pointCount;s++)u=t.R,o=e.m_points[s].m_localPoint,h=t.position.x+u.col1.x*o.x+u.col2.x*o.y,p=t.position.y+u.col1.y*o.x+u.col2.y*o.y,this.m_points[s].x=h+.5*(i-(h-l)*a-(p-c)*f-n)*a,this.m_points[s].y=p+.5*(i-(h-l)*a-(p-c)*f-n)*f}},V.ClipVertex=function(){this.v=new g,this.id=new x},V.prototype.Set=function(e){this.v.SetV(e.v),this.id.Set(e.id)},$.Features=function(){},Object.defineProperty($.prototype,"referenceEdge",{enumerable:!1,configurable:!0,get:function(){return this._referenceEdge}}),Object.defineProperty($.prototype,"referenceEdge",{enumerable:!1,configurable:!0,set:function(e){e===undefined&&(e=0),this._referenceEdge=e,this._m_id._key=this._m_id._key&4294967040|this._referenceEdge&255}}),Object.defineProperty($.prototype,"incidentEdge",{enumerable:!1,configurable:!0,get:function(){return this._incidentEdge}}),Object.defineProperty($.prototype,"incidentEdge",{enumerable:!1,configurable:!0,set:function(e){e===undefined&&(e=0),this._incidentEdge=e,this._m_id._key=this._m_id._key&4294902015|this._incidentEdge<<8&65280}}),Object.defineProperty($.prototype,"incidentVertex",{enumerable:!1,configurable:!0,get:function(){return this._incidentVertex}}),Object.defineProperty($.prototype,"incidentVertex",{enumerable:!1,configurable:!0,set:function(e){e===undefined&&(e=0),this._incidentVertex=e,this._m_id._key=this._m_id._key&4278255615|this._incidentVertex<<16&16711680}}),Object.defineProperty($.prototype,"flip",{enumerable:!1,configurable:!0,get:function(){return this._flip}}),Object.defineProperty($.prototype,"flip",{enumerable:!1,configurable:!0,set:function(e){e===undefined&&(e=0),this._flip=e,this._m_id._key=this._m_id._key&16777215|this._flip<<24&4278190080}})}(),function(){var r=e.Common.b2Color,i=e.Common.b2internal,s=e.Common.b2Settings,o=e.Collision.Shapes.b2CircleShape,u=e.Collision.Shapes.b2EdgeChainDef,a=e.Collision.Shapes.b2EdgeShape,f=e.Collision.Shapes.b2MassData,l=e.Collision.Shapes.b2PolygonShape,c=e.Collision.Shapes.b2Shape,h=e.Common.Math.b2Mat22,p=e.Common.Math.b2Mat33,d=e.Common.Math.b2Math,v=e.Common.Math.b2Sweep,m=e.Common.Math.b2Transform,g=e.Common.Math.b2Vec2,y=e.Common.Math.b2Vec3,b=e.Dynamics.b2Body,w=e.Dynamics.b2BodyDef,E=e.Dynamics.b2ContactFilter,S=e.Dynamics.b2ContactImpulse,x=e.Dynamics.b2ContactListener,T=e.Dynamics.b2ContactManager,N=e.Dynamics.b2DebugDraw,C=e.Dynamics.b2DestructionListener,k=e.Dynamics.b2FilterData,L=e.Dynamics.b2Fixture,A=e.Dynamics.b2FixtureDef,O=e.Dynamics.b2Island,M=e.Dynamics.b2TimeStep,_=e.Dynamics.b2World,D=e.Collision.b2AABB,P=e.Collision.b2Bound,H=e.Collision.b2BoundValues,B=e.Collision.b2Collision,j=e.Collision.b2ContactID,F=e.Collision.b2ContactPoint,I=e.Collision.b2Distance,q=e.Collision.b2DistanceInput,R=e.Collision.b2DistanceOutput,U=e.Collision.b2DistanceProxy,z=e.Collision.b2DynamicTree,W=e.Collision.b2DynamicTreeBroadPhase,X=e.Collision.b2DynamicTreeNode,V=e.Collision.b2DynamicTreePair,$=e.Collision.b2Manifold,J=e.Collision.b2ManifoldPoint,K=e.Collision.b2Point,Q=e.Collision.b2RayCastInput,G=e.Collision.b2RayCastOutput,Y=e.Collision.b2Segment,Z=e.Collision.b2SeparationFunction,et=e.Collision.b2Simplex,tt=e.Collision.b2SimplexCache,nt=e.Collision.b2SimplexVertex,rt=e.Collision.b2TimeOfImpact,it=e.Collision.b2TOIInput,st=e.Collision.b2WorldManifold,ot=e.Collision.ClipVertex,ut=e.Collision.Features,at=e.Collision.IBroadPhase;e.inherit(o,e.Collision.Shapes.b2Shape),o.prototype.__super=e.Collision.Shapes.b2Shape.prototype,o.b2CircleShape=function(){e.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments),this.m_p=new g},o.prototype.Copy=function(){var e=new o;return e.Set(this),e},o.prototype.Set=function(t){this.__super.Set.call(this,t);if(e.is(t,o)){var n=t instanceof o?t:null;this.m_p.SetV(n.m_p)}},o.prototype.TestPoint=function(e,t){var n=e.R,r=e.position.x+(n.col1.x*this.m_p.x+n.col2.x*this.m_p.y),i=e.position.y+(n.col1.y*this.m_p.x+n.col2.y*this.m_p.y);return r=t.x-r,i=t.y-i,r*r+i*i<=this.m_radius*this.m_radius},o.prototype.RayCast=function(e,t,n){var r=n.R,i=n.position.x+(r.col1.x*this.m_p.x+r.col2.x*this.m_p.y),s=n.position.y+(r.col1.y*this.m_p.x+r.col2.y*this.m_p.y),o=t.p1.x-i,u=t.p1.y-s,a=o*o+u*u-this.m_radius*this.m_radius,f=t.p2.x-t.p1.x,l=t.p2.y-t.p1.y,c=o*f+u*l,h=f*f+l*l,p=c*c-h*a;if(p<0||h<Number.MIN_VALUE)return!1;var d=-(c+Math.sqrt(p));return 0<=d&&d<=t.maxFraction*h?(d/=h,e.fraction=d,e.normal.x=o+d*f,e.normal.y=u+d*l,e.normal.Normalize(),!0):!1},o.prototype.ComputeAABB=function(e,t){var n=t.R,r=t.position.x+(n.col1.x*this.m_p.x+n.col2.x*this.m_p.y),i=t.position.y+(n.col1.y*this.m_p.x+n.col2.y*this.m_p.y);e.lowerBound.Set(r-this.m_radius,i-this.m_radius),e.upperBound.Set(r+this.m_radius,i+this.m_radius)},o.prototype.ComputeMass=function(e,t){t===undefined&&(t=0),e.mass=t*s.b2_pi*this.m_radius*this.m_radius,e.center.SetV(this.m_p),e.I=e.mass*(.5*this.m_radius*this.m_radius+(this.m_p.x*this.m_p.x+this.m_p.y*this.m_p.y))},o.prototype.ComputeSubmergedArea=function(e,t,n,r){t===undefined&&(t=0);var i=d.MulX(n,this.m_p),s=-(d.Dot(e,i)-t);if(s<-this.m_radius+Number.MIN_VALUE)return 0;if(s>this.m_radius)return r.SetV(i),Math.PI*this.m_radius*this.m_radius;var o=this.m_radius*this.m_radius,u=s*s,a=o*(Math.asin(s/this.m_radius)+Math.PI/2)+s*Math.sqrt(o-u),f=-2/3*Math.pow(o-u,1.5)/a;return r.x=i.x+e.x*f,r.y=i.y+e.y*f,a},o.prototype.GetLocalPosition=function(){return this.m_p},o.prototype.SetLocalPosition=function(e){this.m_p.SetV(e)},o.prototype.GetRadius=function(){return this.m_radius},o.prototype.SetRadius=function(e){e===undefined&&(e=0),this.m_radius=e},o.prototype.b2CircleShape=function(e){e===undefined&&(e=0),this.__super.b2Shape.call(this),this.m_type=c.e_circleShape,this.m_radius=e},u.b2EdgeChainDef=function(){},u.prototype.b2EdgeChainDef=function(){this.vertexCount=0,this.isALoop=!0,this.vertices=[]},e.inherit(a,e.Collision.Shapes.b2Shape),a.prototype.__super=e.Collision.Shapes.b2Shape.prototype,a.b2EdgeShape=function(){e.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments),this.s_supportVec=new g,this.m_v1=new g,this.m_v2=new g,this.m_coreV1=new g,this.m_coreV2=new g,this.m_normal=new g,this.m_direction=new g,this.m_cornerDir1=new g,this.m_cornerDir2=new g},a.prototype.TestPoint=function(e,t){return!1},a.prototype.RayCast=function(e,t,n){var r,i=t.p2.x-t.p1.x,s=t.p2.y-t.p1.y;r=n.R;var o=n.position.x+(r.col1.x*this.m_v1.x+r.col2.x*this.m_v1.y),u=n.position.y+(r.col1.y*this.m_v1.x+r.col2.y*this.m_v1.y),a=n.position.y+(r.col1.y*this.m_v2.x+r.col2.y*this.m_v2.y)-u,f=-(n.position.x+(r.col1.x*this.m_v2.x+r.col2.x*this.m_v2.y)-o),l=100*Number.MIN_VALUE,c=-(i*a+s*f);if(c>l){var h=t.p1.x-o,p=t.p1.y-u,d=h*a+p*f;if(0<=d&&d<=t.maxFraction*c){var v=-i*p+s*h;if(-l*c<=v&&v<=c*(1+l)){d/=c,e.fraction=d;var m=Math.sqrt(a*a+f*f);return e.normal.x=a/m,e.normal.y=f/m,!0}}}return!1},a.prototype.ComputeAABB=function(e,t){var n=t.R,r=t.position.x+(n.col1.x*this.m_v1.x+n.col2.x*this.m_v1.y),i=t.position.y+(n.col1.y*this.m_v1.x+n.col2.y*this.m_v1.y),s=t.position.x+(n.col1.x*this.m_v2.x+n.col2.x*this.m_v2.y),o=t.position.y+(n.col1.y*this.m_v2.x+n.col2.y*this.m_v2.y);r<s?(e.lowerBound.x=r,e.upperBound.x=s):(e.lowerBound.x=s,e.upperBound.x=r),i<o?(e.lowerBound.y=i,e.upperBound.y=o):(e.lowerBound.y=o,e.upperBound.y=i)},a.prototype.ComputeMass=function(e,t){t===undefined&&(t=0),e.mass=0,e.center.SetV(this.m_v1),e.I=0},a.prototype.ComputeSubmergedArea=function(e,t,n,r){t===undefined&&(t=0);var i=new g(e.x*t,e.y*t),s=d.MulX(n,this.m_v1),o=d.MulX(n,this.m_v2),u=d.Dot(e,s)-t,a=d.Dot(e,o)-t;if(u>0){if(a>0)return 0;s.x=-a/(u-a)*s.x+u/(u-a)*o.x,s.y=-a/(u-a)*s.y+u/(u-a)*o.y}else a>0&&(o.x=-a/(u-a)*s.x+u/(u-a)*o.x,o.y=-a/(u-a)*s.y+u/(u-a)*o.y);return r.x=(i.x+s.x+o.x)/3,r.y=(i.y+s.y+o.y)/3,.5*((s.x-i.x)*(o.y-i.y)-(s.y-i.y)*(o.x-i.x))},a.prototype.GetLength=function(){return this.m_length},a.prototype.GetVertex1=function(){return this.m_v1},a.prototype.GetVertex2=function(){return this.m_v2},a.prototype.GetCoreVertex1=function(){return this.m_coreV1},a.prototype.GetCoreVertex2=function(){return this.m_coreV2},a.prototype.GetNormalVector=function(){return this.m_normal},a.prototype.GetDirectionVector=function(){return this.m_direction},a.prototype.GetCorner1Vector=function(){return this.m_cornerDir1},a.prototype.GetCorner2Vector=function(){return this.m_cornerDir2},a.prototype.Corner1IsConvex=function(){return this.m_cornerConvex1},a.prototype.Corner2IsConvex=function(){return this.m_cornerConvex2},a.prototype.GetFirstVertex=function(e){var t=e.R;return new g(e.position.x+(t.col1.x*this.m_coreV1.x+t.col2.x*this.m_coreV1.y),e.position.y+(t.col1.y*this.m_coreV1.x+t.col2.y*this.m_coreV1.y))},a.prototype.GetNextEdge=function(){return this.m_nextEdge},a.prototype.GetPrevEdge=function(){return this.m_prevEdge},a.prototype.Support=function(e,t,n){t===undefined&&(t=0),n===undefined&&(n=0);var r=e.R,i=e.position.x+(r.col1.x*this.m_coreV1.x+r.col2.x*this.m_coreV1.y),s=e.position.y+(r.col1.y*this.m_coreV1.x+r.col2.y*this.m_coreV1.y),o=e.position.x+(r.col1.x*this.m_coreV2.x+r.col2.x*this.m_coreV2.y),u=e.position.y+(r.col1.y*this.m_coreV2.x+r.col2.y*this.m_coreV2.y);return i*t+s*n>o*t+u*n?(this.s_supportVec.x=i,this.s_supportVec.y=s):(this.s_supportVec.x=o,this.s_supportVec.y=u),this.s_supportVec},a.prototype.b2EdgeShape=function(e,t){this.__super.b2Shape.call(this),this.m_type=c.e_edgeShape,this.m_prevEdge=null,this.m_nextEdge=null,this.m_v1=e,this.m_v2=t,this.m_direction.Set(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y),this.m_length=this.m_direction.Normalize(),this.m_normal.Set(this.m_direction.y,-this.m_direction.x),this.m_coreV1.Set(-s.b2_toiSlop*(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-s.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y),this.m_coreV2.Set(-s.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-s.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y),this.m_cornerDir1=this.m_normal,this.m_cornerDir2.Set(-this.m_normal.x,-this.m_normal.y)},a.prototype.SetPrevEdge=function(e,t,n,r){this.m_prevEdge=e,this.m_coreV1=t,this.m_cornerDir1=n,this.m_cornerConvex1=r},a.prototype.SetNextEdge=function(e,t,n,r){this.m_nextEdge=e,this.m_coreV2=t,this.m_cornerDir2=n,this.m_cornerConvex2=r},f.b2MassData=function(){this.mass=0,this.center=new g(0,0),this.I=0},e.inherit(l,e.Collision.Shapes.b2Shape),l.prototype.__super=e.Collision.Shapes.b2Shape.prototype,l.b2PolygonShape=function(){e.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments)},l.prototype.Copy=function(){var e=new l;return e.Set(this),e},l.prototype.Set=function(t){this.__super.Set.call(this,t);if(e.is(t,l)){var n=t instanceof l?t:null;this.m_centroid.SetV(n.m_centroid),this.m_vertexCount=n.m_vertexCount,this.Reserve(this.m_vertexCount);for(var r=0;r<this.m_vertexCount;r++)this.m_vertices[r].SetV(n.m_vertices[r]),this.m_normals[r].SetV(n.m_normals[r])}},l.prototype.SetAsArray=function(e,n){n===undefined&&(n=0);var r=new t,i=0,s;for(i=0;i<e.length;++i)s=e[i],r.push(s);this.SetAsVector(r,n)},l.AsArray=function(e,t){t===undefined&&(t=0);var n=new l;return n.SetAsArray(e,t),n},l.prototype.SetAsVector=function(e,t){t===undefined&&(t=0),t==0&&(t=e.length),s.b2Assert(2<=t),this.m_vertexCount=t,this.Reserve(t);var n=0;for(n=0;n<this.m_vertexCount;n++)this.m_vertices[n].SetV(e[n]);for(n=0;n<this.m_vertexCount;++n){var r=parseInt(n),i=parseInt(n+1<this.m_vertexCount?n+1:0),o=d.SubtractVV(this.m_vertices[i],this.m_vertices[r]);s.b2Assert(o.LengthSquared()>Number.MIN_VALUE),this.m_normals[n].SetV(d.CrossVF(o,1)),this.m_normals[n].Normalize()}this.m_centroid=l.ComputeCentroid(this.m_vertices,this.m_vertexCount)},l.AsVector=function(e,t){t===undefined&&(t=0);var n=new l;return n.SetAsVector(e,t),n},l.prototype.SetAsBox=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.m_vertexCount=4,this.Reserve(4),this.m_vertices[0].Set(-e,-t),this.m_vertices[1].Set(e,-t),this.m_vertices[2].Set(e,t),this.m_vertices[3].Set(-e,t),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()},l.AsBox=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0);var n=new l;return n.SetAsBox(e,t),n},l.prototype.SetAsOrientedBox=function(e,t,n,r){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=null),r===undefined&&(r=0),this.m_vertexCount=4,this.Reserve(4),this.m_vertices[0].Set(-e,-t),this.m_vertices[1].Set(e,-t),this.m_vertices[2].Set(e,t),this.m_vertices[3].Set(-e,t),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=n;var i=new m;i.position=n,i.R.Set(r);for(var s=0;s<this.m_vertexCount;++s)this.m_vertices[s]=d.MulX(i,this.m_vertices[s]),this.m_normals[s]=d.MulMV(i.R,this.m_normals[s])},l.AsOrientedBox=function(e,t,n,r){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=null),r===undefined&&(r=0);var i=new l;return i.SetAsOrientedBox(e,t,n,r),i},l.prototype.SetAsEdge=function(e,t){this.m_vertexCount=2,this.Reserve(2),this.m_vertices[0].SetV(e),this.m_vertices[1].SetV(t),this.m_centroid.x=.5*(e.x+t.x),this.m_centroid.y=.5*(e.y+t.y),this.m_normals[0]=d.CrossVF(d.SubtractVV(t,e),1),this.m_normals[0].Normalize(),this.m_normals[1].x=-this.m_normals[0].x,this.m_normals[1].y=-this.m_normals[0].y},l.AsEdge=function(e,t){var n=new l;return n.SetAsEdge(e,t),n},l.prototype.TestPoint=function(e,t){var n,r=e.R,i=t.x-e.position.x,s=t.y-e.position.y,o=i*r.col1.x+s*r.col1.y,u=i*r.col2.x+s*r.col2.y;for(var a=0;a<this.m_vertexCount;++a){n=this.m_vertices[a],i=o-n.x,s=u-n.y,n=this.m_normals[a];var f=n.x*i+n.y*s;if(f>0)return!1}return!0},l.prototype.RayCast=function(e,t,n){var r=0,i=t.maxFraction,s=0,o=0,u,a;s=t.p1.x-n.position.x,o=t.p1.y-n.position.y,u=n.R;var f=s*u.col1.x+o*u.col1.y,l=s*u.col2.x+o*u.col2.y;s=t.p2.x-n.position.x,o=t.p2.y-n.position.y,u=n.R;var c=s*u.col1.x+o*u.col1.y,h=s*u.col2.x+o*u.col2.y,p=c-f,d=h-l,v=parseInt(-1);for(var m=0;m<this.m_vertexCount;++m){a=this.m_vertices[m],s=a.x-f,o=a.y-l,a=this.m_normals[m];var g=a.x*s+a.y*o,y=a.x*p+a.y*d;if(y==0){if(g<0)return!1}else y<0&&g<r*y?(r=g/y,v=m):y>0&&g<i*y&&(i=g/y);if(i<r-Number.MIN_VALUE)return!1}return v>=0?(e.fraction=r,u=n.R,a=this.m_normals[v],e.normal.x=u.col1.x*a.x+u.col2.x*a.y,e.normal.y=u.col1.y*a.x+u.col2.y*a.y,!0):!1},l.prototype.ComputeAABB=function(e,t){var n=t.R,r=this.m_vertices[0],i=t.position.x+(n.col1.x*r.x+n.col2.x*r.y),s=t.position.y+(n.col1.y*r.x+n.col2.y*r.y),o=i,u=s;for(var a=1;a<this.m_vertexCount;++a){r=this.m_vertices[a];var f=t.position.x+(n.col1.x*r.x+n.col2.x*r.y),l=t.position.y+(n.col1.y*r.x+n.col2.y*r.y);i=i<f?i:f,s=s<l?s:l,o=o>f?o:f,u=u>l?u:l}e.lowerBound.x=i-this.m_radius,e.lowerBound.y=s-this.m_radius,e.upperBound.x=o+this.m_radius,e.upperBound.y=u+this.m_radius},l.prototype.ComputeMass=function(e,t){t===undefined&&(t=0);if(this.m_vertexCount==2){e.center.x=.5*(this.m_vertices[0].x+this.m_vertices[1].x),e.center.y=.5*(this.m_vertices[0].y+this.m_vertices[1].y),e.mass=0,e.I=0;return}var n=0,r=0,i=0,s=0,o=0,u=0,a=1/3;for(var f=0;f<this.m_vertexCount;++f){var l=this.m_vertices[f],c=f+1<this.m_vertexCount?this.m_vertices[parseInt(f+1)]:this.m_vertices[0],h=l.x-o,p=l.y-u,d=c.x-o,v=c.y-u,m=h*v-p*d,g=.5*m;i+=g,n+=g*a*(o+l.x+c.x),r+=g*a*(u+l.y+c.y);var y=o,b=u,w=h,E=p,S=d,x=v,T=a*(.25*(w*w+S*w+S*S)+(y*w+y*S))+.5*y*y,N=a*(.25*(E*E+x*E+x*x)+(b*E+b*x))+.5*b*b;s+=m*(T+N)}e.mass=t*i,n*=1/i,r*=1/i,e.center.Set(n,r),e.I=t*s},l.prototype.ComputeSubmergedArea=function(e,t,r,i){t===undefined&&(t=0);var s=d.MulTMV(r.R,e),o=t-d.Dot(e,r.position),u=new n,a=0,l=parseInt(-1),c=parseInt(-1),h=!1,p=0;for(p=0;p<this.m_vertexCount;++p){u[p]=d.Dot(s,this.m_vertices[p])-o;var v=u[p]<-Number.MIN_VALUE;p>0&&(v?h||(l=p-1,a++):h&&(c=p-1,a++)),h=v}switch(a){case 0:if(h){var m=new f;return this.ComputeMass(m,1),i.SetV(d.MulX(r,m.center)),m.mass}return 0;case 1:l==-1?l=this.m_vertexCount-1:c=this.m_vertexCount-1}var y=parseInt((l+1)%this.m_vertexCount),b=parseInt((c+1)%this.m_vertexCount),w=(0-u[l])/(u[y]-u[l]),E=(0-u[c])/(u[b]-u[c]),S=new g(this.m_vertices[l].x*(1-w)+this.m_vertices[y].x*w,this.m_vertices[l].y*(1-w)+this.m_vertices[y].y*w),x=new g(this.m_vertices[c].x*(1-E)+this.m_vertices[b].x*E,this.m_vertices[c].y*(1-E)+this.m_vertices[b].y*E),T=0,N=new g,C=this.m_vertices[y],k;p=y;while(p!=b){p=(p+1)%this.m_vertexCount,p==b?k=x:k=this.m_vertices[p];var L=.5*((C.x-S.x)*(k.y-S.y)-(C.y-S.y)*(k.x-S.x));T+=L,N.x+=L*(S.x+C.x+k.x)/3,N.y+=L*(S.y+C.y+k.y)/3,C=k}return N.Multiply(1/T),i.SetV(d.MulX(r,N)),T},l.prototype.GetVertexCount=function(){return this.m_vertexCount},l.prototype.GetVertices=function(){return this.m_vertices},l.prototype.GetNormals=function(){return this.m_normals},l.prototype.GetSupport=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;r<this.m_vertexCount;++r){var i=this.m_vertices[r].x*e.x+this.m_vertices[r].y*e.y;i>n&&(t=r,n=i)}return t},l.prototype.GetSupportVertex=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;r<this.m_vertexCount;++r){var i=this.m_vertices[r].x*e.x+this.m_vertices[r].y*e.y;i>n&&(t=r,n=i)}return this.m_vertices[t]},l.prototype.Validate=function(){return!1},l.prototype.b2PolygonShape=function(){this.__super.b2Shape.call(this),this.m_type=c.e_polygonShape,this.m_centroid=new g,this.m_vertices=new t,this.m_normals=new t},l.prototype.Reserve=function(e){e===undefined&&(e=0);for(var t=parseInt(this.m_vertices.length);t<e;t++)this.m_vertices[t]=new g,this.m_normals[t]=new g},l.ComputeCentroid=function(e,t){t===undefined&&(t=0);var n=new g,r=0,i=0,s=0,o=1/3;for(var u=0;u<t;++u){var a=e[u],f=u+1<t?e[parseInt(u+1)]:e[0],l=a.x-i,c=a.y-s,h=f.x-i,p=f.y-s,d=l*p-c*h,v=.5*d;r+=v,n.x+=v*o*(i+a.x+f.x),n.y+=v*o*(s+a.y+f.y)}return n.x*=1/r,n.y*=1/r,n},l.ComputeOBB=function(e,n,r){r===undefined&&(r=0);var i=0,s=new t(r+1);for(i=0;i<r;++i)s[i]=n[i];s[r]=s[0];var o=Number.MAX_VALUE;for(i=1;i<=r;++i){var u=s[parseInt(i-1)],a=s[i].x-u.x,f=s[i].y-u.y,l=Math.sqrt(a*a+f*f);a/=l,f/=l;var c=-f,h=a,p=Number.MAX_VALUE,d=Number.MAX_VALUE,v=-Number.MAX_VALUE,m=-Number.MAX_VALUE;for(var g=0;g<r;++g){var y=s[g].x-u.x,b=s[g].y-u.y,w=a*y+f*b,E=c*y+h*b;w<p&&(p=w),E<d&&(d=E),w>v&&(v=w),E>m&&(m=E)}var S=(v-p)*(m-d);if(S<.95*o){o=S,e.R.col1.x=a,e.R.col1.y=f,e.R.col2.x=c,e.R.col2.y=h;var x=.5*(p+v),T=.5*(d+m),N=e.R;e.center.x=u.x+(N.col1.x*x+N.col2.x*T),e.center.y=u.y+(N.col1.y*x+N.col2.y*T),e.extents.x=.5*(v-p),e.extents.y=.5*(m-d)}}},e.postDefs.push(function(){e.Collision.Shapes.b2PolygonShape.s_mat=new h}),c.b2Shape=function(){},c.prototype.Copy=function(){return null},c.prototype.Set=function(e){this.m_radius=e.m_radius},c.prototype.GetType=function(){return this.m_type},c.prototype.TestPoint=function(e,t){return!1},c.prototype.RayCast=function(e,t,n){return!1},c.prototype.ComputeAABB=function(e,t){},c.prototype.ComputeMass=function(e,t){t===undefined&&(t=0)},c.prototype.ComputeSubmergedArea=function(e,t,n,r){return t===undefined&&(t=0),0},c.TestOverlap=function(e,t,n,r){var i=new q;i.proxyA=new U,i.proxyA.Set(e),i.proxyB=new U,i.proxyB.Set(n),i.transformA=t,i.transformB=r,i.useRadii=!0;var s=new tt;s.count=0;var o=new R;return I.Distance(o,s,i),o.distance<10*Number.MIN_VALUE},c.prototype.b2Shape=function(){this.m_type=c.e_unknownShape,this.m_radius=s.b2_linearSlop},e.postDefs.push(function(){e.Collision.Shapes.b2Shape.e_unknownShape=parseInt(-1),e.Collision.Shapes.b2Shape.e_circleShape=0,e.Collision.Shapes.b2Shape.e_polygonShape=1,e.Collision.Shapes.b2Shape.e_edgeShape=2,e.Collision.Shapes.b2Shape.e_shapeTypeCount=3,e.Collision.Shapes.b2Shape.e_hitCollide=1,e.Collision.Shapes.b2Shape.e_missCollide=0,e.Collision.Shapes.b2Shape.e_startsInsideCollide=parseInt(-1)})}(),function(){var t=e.Common.b2Color,n=e.Common.b2internal,r=e.Common.b2Settings,i=e.Common.Math.b2Mat22,s=e.Common.Math.b2Mat33,o=e.Common.Math.b2Math,u=e.Common.Math.b2Sweep,a=e.Common.Math.b2Transform,f=e.Common.Math.b2Vec2,l=e.Common.Math.b2Vec3;t.b2Color=function(){this._r=0,this._g=0,this._b=0},t.prototype.b2Color=function(t,n,r){t===undefined&&(t=0),n===undefined&&(n=0),r===undefined&&(r=0),this._r=e.parseUInt(255*o.Clamp(t,0,1)),this._g=e.parseUInt(255*o.Clamp(n,0,1)),this._b=e.parseUInt(255*o.Clamp(r,0,1))},t.prototype.Set=function(t,n,r){t===undefined&&(t=0),n===undefined&&(n=0),r===undefined&&(r=0),this._r=e.parseUInt(255*o.Clamp(t,0,1)),this._g=e.parseUInt(255*o.Clamp(n,0,1)),this._b=e.parseUInt(255*o.Clamp(r,0,1))},Object.defineProperty(t.prototype,"r",{enumerable:!1,configurable:!0,set:function(t){t===undefined&&(t=0),this._r=e.parseUInt(255*o.Clamp(t,0,1))}}),Object.defineProperty(t.prototype,"g",{enumerable:!1,configurable:!0,set:function(t){t===undefined&&(t=0),this._g=e.parseUInt(255*o.Clamp(t,0,1))}}),Object.defineProperty(t.prototype,"b",{enumerable:!1,configurable:!0,set:function(t){t===undefined&&(t=0),this._b=e.parseUInt(255*o.Clamp(t,0,1))}}),Object.defineProperty(t.prototype,"color",{enumerable:!1,configurable:!0,get:function(){return this._r<<16|this._g<<8|this._b}}),r.b2Settings=function(){},r.b2MixFriction=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),Math.sqrt(e*t)},r.b2MixRestitution=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),e>t?e:t},r.b2Assert=function(e){if(!e)throw"Assertion Failed"},e.postDefs.push(function(){e.Common.b2Settings.VERSION="2.1alpha",e.Common.b2Settings.USHRT_MAX=65535,e.Common.b2Settings.b2_pi=Math.PI,e.Common.b2Settings.b2_maxManifoldPoints=2,e.Common.b2Settings.b2_aabbExtension=.1,e.Common.b2Settings.b2_aabbMultiplier=2,e.Common.b2Settings.b2_polygonRadius=2*r.b2_linearSlop,e.Common.b2Settings.b2_linearSlop=.005,e.Common.b2Settings.b2_angularSlop=2/180*r.b2_pi,e.Common.b2Settings.b2_toiSlop=8*r.b2_linearSlop,e.Common.b2Settings.b2_maxTOIContactsPerIsland=32,e.Common.b2Settings.b2_maxTOIJointsPerIsland=32,e.Common.b2Settings.b2_velocityThreshold=1,e.Common.b2Settings.b2_maxLinearCorrection=.2,e.Common.b2Settings.b2_maxAngularCorrection=8/180*r.b2_pi,e.Common.b2Settings.b2_maxTranslation=2,e.Common.b2Settings.b2_maxTranslationSquared=r.b2_maxTranslation*r.b2_maxTranslation,e.Common.b2Settings.b2_maxRotation=.5*r.b2_pi,e.Common.b2Settings.b2_maxRotationSquared=r.b2_maxRotation*r.b2_maxRotation,e.Common.b2Settings.b2_contactBaumgarte=.2,e.Common.b2Settings.b2_timeToSleep=.5,e.Common.b2Settings.b2_linearSleepTolerance=.01,e.Common.b2Settings.b2_angularSleepTolerance=2/180*r.b2_pi})}(),function(){var t=e.Collision.b2AABB,n=e.Common.b2Color,r=e.Common.b2internal,i=e.Common.b2Settings,s=e.Common.Math.b2Mat22,o=e.Common.Math.b2Mat33,u=e.Common.Math.b2Math,a=e.Common.Math.b2Sweep,f=e.Common.Math.b2Transform,l=e.Common.Math.b2Vec2,c=e.Common.Math.b2Vec3;s.b2Mat22=function(){this.col1=new l,this.col2=new l},s.prototype.b2Mat22=function(){this.SetIdentity()},s.FromAngle=function(e){e===undefined&&(e=0);var t=new s;return t.Set(e),t},s.FromVV=function(e,t){var n=new s;return n.SetVV(e,t),n},s.prototype.Set=function(e){e===undefined&&(e=0);var t=Math.cos(e),n=Math.sin(e);this.col1.x=t,this.col2.x=-n,this.col1.y=n,this.col2.y=t},s.prototype.SetVV=function(e,t){this.col1.SetV(e),this.col2.SetV(t)},s.prototype.Copy=function(){var e=new s;return e.SetM(this),e},s.prototype.SetM=function(e){this.col1.SetV(e.col1),this.col2.SetV(e.col2)},s.prototype.AddM=function(e){this.col1.x+=e.col1.x,this.col1.y+=e.col1.y,this.col2.x+=e.col2.x,this.col2.y+=e.col2.y},s.prototype.SetIdentity=function(){this.col1.x=1,this.col2.x=0,this.col1.y=0,this.col2.y=1},s.prototype.SetZero=function(){this.col1.x=0,this.col2.x=0,this.col1.y=0,this.col2.y=0},s.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)},s.prototype.GetInverse=function(e){var t=this.col1.x,n=this.col2.x,r=this.col1.y,i=this.col2.y,s=t*i-n*r;return s!=0&&(s=1/s),e.col1.x=s*i,e.col2.x=-s*n,e.col1.y=-s*r,e.col2.y=s*t,e},s.prototype.Solve=function(e,t,n){t===undefined&&(t=0),n===undefined&&(n=0);var r=this.col1.x,i=this.col2.x,s=this.col1.y,o=this.col2.y,u=r*o-i*s;return u!=0&&(u=1/u),e.x=u*(o*t-i*n),e.y=u*(r*n-s*t),e},s.prototype.Abs=function(){this.col1.Abs(),this.col2.Abs()},o.b2Mat33=function(){this.col1=new c,this.col2=new c,this.col3=new c},o.prototype.b2Mat33=function(e,t,n){e===undefined&&(e=null),t===undefined&&(t=null),n===undefined&&(n=null),!e&&!t&&!n?(this.col1.SetZero(),this.col2.SetZero(),this.col3.SetZero()):(this.col1.SetV(e),this.col2.SetV(t),this.col3.SetV(n))},o.prototype.SetVVV=function(e,t,n){this.col1.SetV(e),this.col2.SetV(t),this.col3.SetV(n)},o.prototype.Copy=function(){return new o(this.col1,this.col2,this.col3)},o.prototype.SetM=function(e){this.col1.SetV(e.col1),this.col2.SetV(e.col2),this.col3.SetV(e.col3)},o.prototype.AddM=function(e){this.col1.x+=e.col1.x,this.col1.y+=e.col1.y,this.col1.z+=e.col1.z,this.col2.x+=e.col2.x,this.col2.y+=e.col2.y,this.col2.z+=e.col2.z,this.col3.x+=e.col3.x,this.col3.y+=e.col3.y,this.col3.z+=e.col3.z},o.prototype.SetIdentity=function(){this.col1.x=1,this.col2.x=0,this.col3.x=0,this.col1.y=0,this.col2.y=1,this.col3.y=0,this.col1.z=0,this.col2.z=0,this.col3.z=1},o.prototype.SetZero=function(){this.col1.x=0,this.col2.x=0,this.col3.x=0,this.col1.y=0,this.col2.y=0,this.col3.y=0,this.col1.z=0,this.col2.z=0,this.col3.z=0},o.prototype.Solve22=function(e,t,n){t===undefined&&(t=0),n===undefined&&(n=0);var r=this.col1.x,i=this.col2.x,s=this.col1.y,o=this.col2.y,u=r*o-i*s;return u!=0&&(u=1/u),e.x=u*(o*t-i*n),e.y=u*(r*n-s*t),e},o.prototype.Solve33=function(e,t,n,r){t===undefined&&(t=0),n===undefined&&(n=0),r===undefined&&(r=0);var i=this.col1.x,s=this.col1.y,o=this.col1.z,u=this.col2.x,a=this.col2.y,f=this.col2.z,l=this.col3.x,c=this.col3.y,h=this.col3.z,p=i*(a*h-f*c)+s*(f*l-u*h)+o*(u*c-a*l);return p!=0&&(p=1/p),e.x=p*(t*(a*h-f*c)+n*(f*l-u*h)+r*(u*c-a*l)),e.y=p*(i*(n*h-r*c)+s*(r*l-t*h)+o*(t*c-n*l)),e.z=p*(i*(a*r-f*n)+s*(f*t-u*r)+o*(u*n-a*t)),e},u.b2Math=function(){},u.IsValid=function(e){return e===undefined&&(e=0),isFinite(e)},u.Dot=function(e,t){return e.x*t.x+e.y*t.y},u.CrossVV=function(e,t){return e.x*t.y-e.y*t.x},u.CrossVF=function(e,t){t===undefined&&(t=0);var n=new l(t*e.y,-t*e.x);return n},u.CrossFV=function(e,t){e===undefined&&(e=0);var n=new l(-e*t.y,e*t.x);return n},u.MulMV=function(e,t){var n=new l(e.col1.x*t.x+e.col2.x*t.y,e.col1.y*t.x+e.col2.y*t.y);return n},u.MulTMV=function(e,t){var n=new l(u.Dot(t,e.col1),u.Dot(t,e.col2));return n},u.MulX=function(e,t){var n=u.MulMV(e.R,t);return n.x+=e.position.x,n.y+=e.position.y,n},u.MulXT=function(e,t){var n=u.SubtractVV(t,e.position),r=n.x*e.R.col1.x+n.y*e.R.col1.y;return n.y=n.x*e.R.col2.x+n.y*e.R.col2.y,n.x=r,n},u.AddVV=function(e,t){var n=new l(e.x+t.x,e.y+t.y);return n},u.SubtractVV=function(e,t){var n=new l(e.x-t.x,e.y-t.y);return n},u.Distance=function(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)},u.DistanceSquared=function(e,t){var n=e.x-t.x,r=e.y-t.y;return n*n+r*r},u.MulFV=function(e,t){e===undefined&&(e=0);var n=new l(e*t.x,e*t.y);return n},u.AddMM=function(e,t){var n=s.FromVV(u.AddVV(e.col1,t.col1),u.AddVV(e.col2,t.col2));return n},u.MulMM=function(e,t){var n=s.FromVV(u.MulMV(e,t.col1),u.MulMV(e,t.col2));return n},u.MulTMM=function(e,t){var n=new l(u.Dot(e.col1,t.col1),u.Dot(e.col2,t.col1)),r=new l(u.Dot(e.col1,t.col2),u.Dot(e.col2,t.col2)),i=s.FromVV(n,r);return i},u.Abs=function(e){return e===undefined&&(e=0),e>0?e:-e},u.AbsV=function(e){var t=new l(u.Abs(e.x),u.Abs(e.y));return t},u.AbsM=function(e){var t=s.FromVV(u.AbsV(e.col1),u.AbsV(e.col2));return t},u.Min=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),e<t?e:t},u.MinV=function(e,t){var n=new l(u.Min(e.x,t.x),u.Min(e.y,t.y));return n},u.Max=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),e>t?e:t},u.MaxV=function(e,t){var n=new l(u.Max(e.x,t.x),u.Max(e.y,t.y));return n},u.Clamp=function(e,t,n){return e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0),e<t?t:e>n?n:e},u.ClampV=function(e,t,n){return u.MaxV(t,u.MinV(e,n))},u.Swap=function(e,t){var n=e[0];e[0]=t[0],t[0]=n},u.Random=function(){return Math.random()*2-1},u.RandomRange=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0);var n=Math.random();return n=(t-e)*n+e,n},u.NextPowerOfTwo=function(e){return e===undefined&&(e=0),e|=e>>1&2147483647,e|=e>>2&1073741823,e|=e>>4&268435455,e|=e>>8&16777215,e|=e>>16&65535,e+1},u.IsPowerOfTwo=function(e){e===undefined&&(e=0);var t=e>0&&(e&e-1)==0;return t},e.postDefs.push(function(){e.Common.Math.b2Math.b2Vec2_zero=new l(0,0),e.Common.Math.b2Math.b2Mat22_identity=s.FromVV(new l(1,0),new l(0,1)),e.Common.Math.b2Math.b2Transform_identity=new f(u.b2Vec2_zero,u.b2Mat22_identity)}),a.b2Sweep=function(){this.localCenter=new l,this.c0=new l,this.c=new l},a.prototype.Set=function(e){this.localCenter.SetV(e.localCenter),this.c0.SetV(e.c0),this.c.SetV(e.c),this.a0=e.a0,this.a=e.a,this.t0=e.t0},a.prototype.Copy=function(){var e=new a;return e.localCenter.SetV(this.localCenter),e.c0.SetV(this.c0),e.c.SetV(this.c),e.a0=this.a0,e.a=this.a,e.t0=this.t0,e},a.prototype.GetTransform=function(e,t){t===undefined&&(t=0),e.position.x=(1-t)*this.c0.x+t*this.c.x,e.position.y=(1-t)*this.c0.y+t*this.c.y;var n=(1-t)*this.a0+t*this.a;e.R.Set(n);var r=e.R;e.position.x-=r.col1.x*this.localCenter.x+r.col2.x*this.localCenter.y,e.position.y-=r.col1.y*this.localCenter.x+r.col2.y*this.localCenter.y},a.prototype.Advance=function(e){e===undefined&&(e=0);if(this.t0<e&&1-this.t0>Number.MIN_VALUE){var t=(e-this.t0)/(1-this.t0);this.c0.x=(1-t)*this.c0.x+t*this.c.x,this.c0.y=(1-t)*this.c0.y+t*this.c.y,this.a0=(1-t)*this.a0+t*this.a,this.t0=e}},f.b2Transform=function(){this.position=new l,this.R=new s},f.prototype.b2Transform=function(e,t){e===undefined&&(e=null),t===undefined&&(t=null),e&&(this.position.SetV(e),this.R.SetM(t))},f.prototype.Initialize=function(e,t){this.position.SetV(e),this.R.SetM(t)},f.prototype.SetIdentity=function(){this.position.SetZero(),this.R.SetIdentity()},f.prototype.Set=function(e){this.position.SetV(e.position),this.R.SetM(e.R)},f.prototype.GetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)},l.b2Vec2=function(){},l.prototype.b2Vec2=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.x=e,this.y=t},l.prototype.SetZero=function(){this.x=0,this.y=0},l.prototype.Set=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.x=e,this.y=t},l.prototype.SetV=function(e){this.x=e.x,this.y=e.y},l.prototype.GetNegative=function(){return new l(-this.x,-this.y)},l.prototype.NegativeSelf=function(){this.x=-this.x,this.y=-this.y},l.Make=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),new l(e,t)},l.prototype.Copy=function(){return new l(this.x,this.y)},l.prototype.Add=function(e){this.x+=e.x,this.y+=e.y},l.prototype.Subtract=function(e){this.x-=e.x,this.y-=e.y},l.prototype.Multiply=function(e){e===undefined&&(e=0),this.x*=e,this.y*=e},l.prototype.MulM=function(e){var t=this.x;this.x=e.col1.x*t+e.col2.x*this.y,this.y=e.col1.y*t+e.col2.y*this.y},l.prototype.MulTM=function(e){var t=u.Dot(this,e.col1);this.y=u.Dot(this,e.col2),this.x=t},l.prototype.CrossVF=function(e){e===undefined&&(e=0);var t=this.x;this.x=e*this.y,this.y=-e*t},l.prototype.CrossFV=function(e){e===undefined&&(e=0);var t=this.x;this.x=-e*this.y,this.y=e*t},l.prototype.MinV=function(e){this.x=this.x<e.x?this.x:e.x,this.y=this.y<e.y?this.y:e.y},l.prototype.MaxV=function(e){this.x=this.x>e.x?this.x:e.x,this.y=this.y>e.y?this.y:e.y},l.prototype.Abs=function(){this.x<0&&(this.x=-this.x),this.y<0&&(this.y=-this.y)},l.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},l.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y},l.prototype.Normalize=function(){var e=Math.sqrt(this.x*this.x+this.y*this.y);if(e<Number.MIN_VALUE)return 0;var t=1/e;return this.x*=t,this.y*=t,e},l.prototype.IsValid=function(){return u.IsValid(this.x)&&u.IsValid(this.y)},c.b2Vec3=function(){},c.prototype.b2Vec3=function(e,t,n){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0),this.x=e,this.y=t,this.z=n},c.prototype.SetZero=function(){this.x=this.y=this.z=0},c.prototype.Set=function(e,t,n){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0),this.x=e,this.y=t,this.z=n},c.prototype.SetV=function(e){this.x=e.x,this.y=e.y,this.z=e.z},c.prototype.GetNegative=function(){return new c(-this.x,-this.y,-this.z)},c.prototype.NegativeSelf=function(){this.x=-this.x,this.y=-this.y,this.z=-this.z},c.prototype.Copy=function(){return new c(this.x,this.y,this.z)},c.prototype.Add=function(e){this.x+=e.x,this.y+=e.y,this.z+=e.z},c.prototype.Subtract=function(e){this.x-=e.x,this.y-=e.y,this.z-=e.z},c.prototype.Multiply=function(e){e===undefined&&(e=0),this.x*=e,this.y*=e,this.z*=e}}(),function(){var r=e.Dynamics.Controllers.b2ControllerEdge,i=e.Common.Math.b2Mat22,s=e.Common.Math.b2Mat33,o=e.Common.Math.b2Math,u=e.Common.Math.b2Sweep,a=e.Common.Math.b2Transform,f=e.Common.Math.b2Vec2,l=e.Common.Math.b2Vec3,c=e.Common.b2Color,h=e.Common.b2internal,p=e.Common.b2Settings,d=e.Collision.b2AABB,v=e.Collision.b2Bound,m=e.Collision.b2BoundValues,g=e.Collision.b2Collision,y=e.Collision.b2ContactID,b=e.Collision.b2ContactPoint,w=e.Collision.b2Distance,E=e.Collision.b2DistanceInput,S=e.Collision.b2DistanceOutput,x=e.Collision.b2DistanceProxy,T=e.Collision.b2DynamicTree,N=e.Collision.b2DynamicTreeBroadPhase,C=e.Collision.b2DynamicTreeNode,k=e.Collision.b2DynamicTreePair,L=e.Collision.b2Manifold,A=e.Collision.b2ManifoldPoint,O=e.Collision.b2Point,M=e.Collision.b2RayCastInput,_=e.Collision.b2RayCastOutput,D=e.Collision.b2Segment,P=e.Collision.b2SeparationFunction,H=e.Collision.b2Simplex,B=e.Collision.b2SimplexCache,j=e.Collision.b2SimplexVertex,F=e.Collision.b2TimeOfImpact,I=e.Collision.b2TOIInput,q=e.Collision.b2WorldManifold,R=e.Collision.ClipVertex,U=e.Collision.Features,z=e.Collision.IBroadPhase,W=e.Collision.Shapes.b2CircleShape,X=e.Collision.Shapes.b2EdgeChainDef,V=e.Collision.Shapes.b2EdgeShape,$=e.Collision.Shapes.b2MassData,J=e.Collision.Shapes.b2PolygonShape,K=e.Collision.Shapes.b2Shape,Q=e.Dynamics.b2Body,G=e.Dynamics.b2BodyDef,Y=e.Dynamics.b2ContactFilter,Z=e.Dynamics.b2ContactImpulse,et=e.Dynamics.b2ContactListener,tt=e.Dynamics.b2ContactManager,nt=e.Dynamics.b2DebugDraw,rt=e.Dynamics.b2DestructionListener,it=e.Dynamics.b2FilterData,st=e.Dynamics.b2Fixture,ot=e.Dynamics.b2FixtureDef,ut=e.Dynamics.b2Island,at=e.Dynamics.b2TimeStep,ft=e.Dynamics.b2World,lt=e.Dynamics.Contacts.b2CircleContact,ct=e.Dynamics.Contacts.b2Contact,ht=e.Dynamics.Contacts.b2ContactConstraint,pt=e.Dynamics.Contacts.b2ContactConstraintPoint,dt=e.Dynamics.Contacts.b2ContactEdge,vt=e.Dynamics.Contacts.b2ContactFactory,mt=e.Dynamics.Contacts.b2ContactRegister,gt=e.Dynamics.Contacts.b2ContactResult,yt=e.Dynamics.Contacts.b2ContactSolver,bt=e.Dynamics.Contacts.b2EdgeAndCircleContact,wt=e.Dynamics.Contacts.b2NullContact,Et=e.Dynamics.Contacts.b2PolyAndCircleContact,St=e.Dynamics.Contacts.b2PolyAndEdgeContact,xt=e.Dynamics.Contacts.b2PolygonContact,Tt=e.Dynamics.Contacts.b2PositionSolverManifold,Nt=e.Dynamics.Controllers.b2Controller,Ct=e.Dynamics.Joints.b2DistanceJoint,kt=e.Dynamics.Joints.b2DistanceJointDef,Lt=e.Dynamics.Joints.b2FrictionJoint,At=e.Dynamics.Joints.b2FrictionJointDef,Ot=e.Dynamics.Joints.b2GearJoint,Mt=e.Dynamics.Joints.b2GearJointDef,_t=e.Dynamics.Joints.b2Jacobian,Dt=e.Dynamics.Joints.b2Joint,Pt=e.Dynamics.Joints.b2JointDef,Ht=e.Dynamics.Joints.b2JointEdge,Bt=e.Dynamics.Joints.b2LineJoint,jt=e.Dynamics.Joints.b2LineJointDef,Ft=e.Dynamics.Joints.b2MouseJoint,It=e.Dynamics.Joints.b2MouseJointDef,qt=e.Dynamics.Joints.b2PrismaticJoint,Rt=e.Dynamics.Joints.b2PrismaticJointDef,Ut=e.Dynamics.Joints.b2PulleyJoint,zt=e.Dynamics.Joints.b2PulleyJointDef,Wt=e.Dynamics.Joints.b2RevoluteJoint,Xt=e.Dynamics.Joints.b2RevoluteJointDef,Vt=e.Dynamics.Joints.b2WeldJoint,$t=e.Dynamics.Joints.b2WeldJointDef;Q.b2Body=function(){this.m_xf=new a,this.m_sweep=new u,this.m_linearVelocity=new f,this.m_force=new f},Q.prototype.connectEdges=function(e,t,n){n===undefined&&(n=0);var r=Math.atan2(t.GetDirectionVector().y,t.GetDirectionVector().x),i=Math.tan((r-n)*.5),s=o.MulFV(i,t.GetDirectionVector());s=o.SubtractVV(s,t.GetNormalVector()),s=o.MulFV(p.b2_toiSlop,s),s=o.AddVV(s,t.GetVertex1());var u=o.AddVV(e.GetDirectionVector(),t.GetDirectionVector());u.Normalize();var a=o.Dot(e.GetDirectionVector(),t.GetNormalVector())>0;return e.SetNextEdge(t,s,u,a),t.SetPrevEdge(e,s,u,a),r},Q.prototype.CreateFixture=function(e){if(this.m_world.IsLocked()==1)return null;var t=new st;t.Create(this,this.m_xf,e);if(this.m_flags&Q.e_activeFlag){var n=this.m_world.m_contactManager.m_broadPhase;t.CreateProxy(n,this.m_xf)}return t.m_next=this.m_fixtureList,this.m_fixtureList=t,++this.m_fixtureCount,t.m_body=this,t.m_density>0&&this.ResetMassData(),this.m_world.m_flags|=ft.e_newFixture,t},Q.prototype.CreateFixture2=function(e,t){t===undefined&&(t=0);var n=new ot;return n.shape=e,n.density=t,this.CreateFixture(n)},Q.prototype.DestroyFixture=function(e){if(this.m_world.IsLocked()==1)return;var t=this.m_fixtureList,n=null,r=!1;while(t!=null){if(t==e){n?n.m_next=e.m_next:this.m_fixtureList=e.m_next,r=!0;break}n=t,t=t.m_next}var i=this.m_contactList;while(i){var s=i.contact;i=i.next;var o=s.GetFixtureA(),u=s.GetFixtureB();(e==o||e==u)&&this.m_world.m_contactManager.Destroy(s)}if(this.m_flags&Q.e_activeFlag){var a=this.m_world.m_contactManager.m_broadPhase;e.DestroyProxy(a)}e.Destroy(),e.m_body=null,e.m_next=null,--this.m_fixtureCount,this.ResetMassData()},Q.prototype.SetPositionAndAngle=function(e,t){t===undefined&&(t=0);var n;if(this.m_world.IsLocked()==1)return;this.m_xf.R.Set(t),this.m_xf.position.SetV(e);var r=this.m_xf.R,i=this.m_sweep.localCenter;this.m_sweep.c.x=r.col1.x*i.x+r.col2.x*i.y,this.m_sweep.c.y=r.col1.y*i.x+r.col2.y*i.y,this.m_sweep.c.x+=this.m_xf.position.x,this.m_sweep.c.y+=this.m_xf.position.y,this.m_sweep.c0.SetV(this.m_sweep.c),this.m_sweep.a0=this.m_sweep.a=t;var s=this.m_world.m_contactManager.m_broadPhase;for(n=this.m_fixtureList;n;n=n.m_next)n.Synchronize(s,this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()},Q.prototype.SetTransform=function(e){this.SetPositionAndAngle(e.position,e.GetAngle())},Q.prototype.GetTransform=function(){return this.m_xf},Q.prototype.GetPosition=function(){return this.m_xf.position},Q.prototype.SetPosition=function(e){this.SetPositionAndAngle(e,this.GetAngle())},Q.prototype.GetAngle=function(){return this.m_sweep.a},Q.prototype.SetAngle=function(e){e===undefined&&(e=0),this.SetPositionAndAngle(this.GetPosition(),e)},Q.prototype.GetWorldCenter=function(){return this.m_sweep.c},Q.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter},Q.prototype.SetLinearVelocity=function(e){if(this.m_type==Q.b2_staticBody)return;this.m_linearVelocity.SetV(e)},Q.prototype.GetLinearVelocity=function(){return this.m_linearVelocity},Q.prototype.SetAngularVelocity=function(e){e===undefined&&(e=0);if(this.m_type==Q.b2_staticBody)return;this.m_angularVelocity=e},Q.prototype.GetAngularVelocity=function(){return this.m_angularVelocity},Q.prototype.GetDefinition=function(){var e=new G;return e.type=this.GetType(),e.allowSleep=(this.m_flags&Q.e_allowSleepFlag)==Q.e_allowSleepFlag,e.angle=this.GetAngle(),e.angularDamping=this.m_angularDamping,e.angularVelocity=this.m_angularVelocity,e.fixedRotation=(this.m_flags&Q.e_fixedRotationFlag)==Q.e_fixedRotationFlag,e.bullet=(this.m_flags&Q.e_bulletFlag)==Q.e_bulletFlag,e.awake=(this.m_flags&Q.e_awakeFlag)==Q.e_awakeFlag,e.linearDamping=this.m_linearDamping,e.linearVelocity.SetV(this.GetLinearVelocity()),e.position=this.GetPosition(),e.userData=this.GetUserData(),e},Q.prototype.ApplyForce=function(e,t){if(this.m_type!=Q.b2_dynamicBody)return;this.IsAwake()==0&&this.SetAwake(!0),this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(t.x-this.m_sweep.c.x)*e.y-(t.y-this.m_sweep.c.y)*e.x},Q.prototype.ApplyTorque=function(e){e===undefined&&(e=0);if(this.m_type!=Q.b2_dynamicBody)return;this.IsAwake()==0&&this.SetAwake(!0),this.m_torque+=e},Q.prototype.ApplyImpulse=function(e,t){if(this.m_type!=Q.b2_dynamicBody)return;this.IsAwake()==0&&this.SetAwake(!0),this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((t.x-this.m_sweep.c.x)*e.y-(t.y-this.m_sweep.c.y)*e.x)},Q.prototype.Split=function(e){var t=this.GetLinearVelocity().Copy(),n=this.GetAngularVelocity(),r=this.GetWorldCenter(),i=this,s=this.m_world.CreateBody(this.GetDefinition()),u;for(var a=i.m_fixtureList;a;)if(e(a)){var f=a.m_next;u?u.m_next=f:i.m_fixtureList=f,i.m_fixtureCount--,a.m_next=s.m_fixtureList,s.m_fixtureList=a,s.m_fixtureCount++,a.m_body=s,a=f}else u=a,a=a.m_next;i.ResetMassData(),s.ResetMassData();var l=i.GetWorldCenter(),c=s.GetWorldCenter(),h=o.AddVV(t,o.CrossFV(n,o.SubtractVV(l,r))),p=o.AddVV(t,o.CrossFV(n,o.SubtractVV(c,r)));return i.SetLinearVelocity(h),s.SetLinearVelocity(p),i.SetAngularVelocity(n),s.SetAngularVelocity(n),i.SynchronizeFixtures(),s.SynchronizeFixtures(),s},Q.prototype.Merge=function(e){var t;for(t=e.m_fixtureList;t;){var n=t.m_next;e.m_fixtureCount--,t.m_next=this.m_fixtureList,this.m_fixtureList=t,this.m_fixtureCount++,t.m_body=i,t=n}r.m_fixtureCount=0;var r=this,i=e,s=r.GetWorldCenter(),o=i.GetWorldCenter(),u=r.GetLinearVelocity().Copy(),a=i.GetLinearVelocity().Copy(),f=r.GetAngularVelocity(),l=i.GetAngularVelocity();r.ResetMassData(),this.SynchronizeFixtures()},Q.prototype.GetMass=function(){return this.m_mass},Q.prototype.GetInertia=function(){return this.m_I},Q.prototype.GetMassData=function(e){e.mass=this.m_mass,e.I=this.m_I,e.center.SetV(this.m_sweep.localCenter)},Q.prototype.SetMassData=function(e){p.b2Assert(this.m_world.IsLocked()==0);if(this.m_world.IsLocked()==1)return;if(this.m_type!=Q.b2_dynamicBody)return;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_flags&Q.e_fixedRotationFlag)==0&&(this.m_I=e.I-this.m_mass*(e.center.x*e.center.x+e.center.y*e.center.y),this.m_invI=1/this.m_I);var t=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(e.center),this.m_sweep.c0.SetV(o.MulX(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.SetV(this.m_sweep.c0),this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-t.y),this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-t.x)},Q.prototype.ResetMassData=function(){this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero();if(this.m_type==Q.b2_staticBody||this.m_type==Q.b2_kinematicBody)return;var e=f.Make(0,0);for(var t=this.m_fixtureList;t;t=t.m_next){if(t.m_density==0)continue;var n=t.GetMassData();this.m_mass+=n.mass,e.x+=n.center.x*n.mass,e.y+=n.center.y*n.mass,this.m_I+=n.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_flags&Q.e_fixedRotationFlag)==0?(this.m_I-=this.m_mass*(e.x*e.x+e.y*e.y),this.m_I*=this.m_inertiaScale,p.b2Assert(this.m_I>0),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var r=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(e),this.m_sweep.c0.SetV(o.MulX(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.SetV(this.m_sweep.c0),this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-r.y),this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-r.x)},Q.prototype.GetWorldPoint=function(e){var t=this.m_xf.R,n=new f(t.col1.x*e.x+t.col2.x*e.y,t.col1.y*e.x+t.col2.y*e.y);return n.x+=this.m_xf.position.x,n.y+=this.m_xf.position.y,n},Q.prototype.GetWorldVector=function(e){return o.MulMV(this.m_xf.R,e)},Q.prototype.GetLocalPoint=function(e){return o.MulXT(this.m_xf,e)},Q.prototype.GetLocalVector=function(e){return o.MulTMV(this.m_xf.R,e)},Q.prototype.GetLinearVelocityFromWorldPoint=function(e){return new f(this.m_linearVelocity.x-this.m_angularVelocity*(e.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(e.x-this.m_sweep.c.x))},Q.prototype.GetLinearVelocityFromLocalPoint=function(e){var t=this.m_xf.R,n=new f(t.col1.x*e.x+t.col2.x*e.y,t.col1.y*e.x+t.col2.y*e.y);return n.x+=this.m_xf.position.x,n.y+=this.m_xf.position.y,new f(this.m_linearVelocity.x-this.m_angularVelocity*(n.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(n.x-this.m_sweep.c.x))},Q.prototype.GetLinearDamping=function(){return this.m_linearDamping},Q.prototype.SetLinearDamping=function(e){e===undefined&&(e=0),this.m_linearDamping=e},Q.prototype.GetAngularDamping=function(){return this.m_angularDamping},Q.prototype.SetAngularDamping=function(e){e===undefined&&(e=0),this.m_angularDamping=e},Q.prototype.SetType=function(e){e===undefined&&(e=0);if(this.m_type==e)return;this.m_type=e,this.ResetMassData(),this.m_type==Q.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var t=this.m_contactList;t;t=t.next)t.contact.FlagForFiltering()},Q.prototype.GetType=function(){return this.m_type},Q.prototype.SetBullet=function(e){e?this.m_flags|=Q.e_bulletFlag:this.m_flags&=~Q.e_bulletFlag},Q.prototype.IsBullet=function(){return(this.m_flags&Q.e_bulletFlag)==Q.e_bulletFlag},Q.prototype.SetSleepingAllowed=function(e){e?this.m_flags|=Q.e_allowSleepFlag:(this.m_flags&=~Q.e_allowSleepFlag,this.SetAwake(!0))},Q.prototype.SetAwake=function(e){e?(this.m_flags|=Q.e_awakeFlag,this.m_sleepTime=0):(this.m_flags&=~Q.e_awakeFlag,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},Q.prototype.IsAwake=function(){return(this.m_flags&Q.e_awakeFlag)==Q.e_awakeFlag},Q.prototype.SetFixedRotation=function(e){e?this.m_flags|=Q.e_fixedRotationFlag:this.m_flags&=~Q.e_fixedRotationFlag,this.ResetMassData()},Q.prototype.IsFixedRotation=function(){return(this.m_flags&Q.e_fixedRotationFlag)==Q.e_fixedRotationFlag},Q.prototype.SetActive=function(e){if(e==this.IsActive())return;var t,n;if(e){this.m_flags|=Q.e_activeFlag,t=this.m_world.m_contactManager.m_broadPhase;for(n=this.m_fixtureList;n;n=n.m_next)n.CreateProxy(t,this.m_xf)}else{this.m_flags&=~Q.e_activeFlag,t=this.m_world.m_contactManager.m_broadPhase;for(n=this.m_fixtureList;n;n=n.m_next)n.DestroyProxy(t);var r=this.m_contactList;while(r){var i=r;r=r.next,this.m_world.m_contactManager.Destroy(i.contact)}this.m_contactList=null}},Q.prototype.IsActive=function(){return(this.m_flags&Q.e_activeFlag)==Q.e_activeFlag},Q.prototype.IsSleepingAllowed=function(){return(this.m_flags&Q.e_allowSleepFlag)==Q.e_allowSleepFlag},Q.prototype.GetFixtureList=function(){return this.m_fixtureList},Q.prototype.GetJointList=function(){return this.m_jointList},Q.prototype.GetControllerList=function(){return this.m_controllerList},Q.prototype.GetContactList=function(){return this.m_contactList},Q.prototype.GetNext=function(){return this.m_next},Q.prototype.GetUserData=function(){return this.m_userData},Q.prototype.SetUserData=function(e){this.m_userData=e},Q.prototype.GetWorld=function(){return this.m_world},Q.prototype.b2Body=function(e,t){this.m_flags=0,e.bullet&&(this.m_flags|=Q.e_bulletFlag),e.fixedRotation&&(this.m_flags|=Q.e_fixedRotationFlag),e.allowSleep&&(this.m_flags|=Q.e_allowSleepFlag),e.awake&&(this.m_flags|=Q.e_awakeFlag),e.active&&(this.m_flags|=Q.e_activeFlag),this.m_world=t,this.m_xf.position.SetV(e.position),this.m_xf.R.Set(e.angle),this.m_sweep.localCenter.SetZero(),this.m_sweep.t0=1,this.m_sweep.a0=this.m_sweep.a=e.angle;var n=this.m_xf.R,r=this.m_sweep.localCenter;this.m_sweep.c.x=n.col1.x*r.x+n.col2.x*r.y,this.m_sweep.c.y=n.col1.y*r.x+n.col2.y*r.y,this.m_sweep.c.x+=this.m_xf.position.x,this.m_sweep.c.y+=this.m_xf.position.y,this.m_sweep.c0.SetV(this.m_sweep.c),this.m_jointList=null,this.m_controllerList=null,this.m_contactList=null,this.m_controllerCount=0,this.m_prev=null,this.m_next=null,this.m_linearVelocity.SetV(e.linearVelocity),this.m_angularVelocity=e.angularVelocity,this.m_linearDamping=e.linearDamping,this.m_angularDamping=e.angularDamping,this.m_force.Set(0,0),this.m_torque=0,this.m_sleepTime=0,this.m_type=e.type,this.m_type==Q.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0),this.m_I=0,this.m_invI=0,this.m_inertiaScale=e.inertiaScale,this.m_userData=e.userData,this.m_fixtureList=null,this.m_fixtureCount=0},Q.prototype.SynchronizeFixtures=function(){var e=Q.s_xf1;e.R.Set(this.m_sweep.a0);var t=e.R,n=this.m_sweep.localCenter;e.position.x=this.m_sweep.c0.x-(t.col1.x*n.x+t.col2.x*n.y),e.position.y=this.m_sweep.c0.y-(t.col1.y*n.x+t.col2.y*n.y);var r,i=this.m_world.m_contactManager.m_broadPhase;for(r=this.m_fixtureList;r;r=r.m_next)r.Synchronize(i,e,this.m_xf)},Q.prototype.SynchronizeTransform=function(){this.m_xf.R.Set(this.m_sweep.a);var e=this.m_xf.R,t=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(e.col1.x*t.x+e.col2.x*t.y),this.m_xf.position.y=this.m_sweep.c.y-(e.col1.y*t.x+e.col2.y*t.y)},Q.prototype.ShouldCollide=function(e){if(this.m_type!=Q.b2_dynamicBody&&e.m_type!=Q.b2_dynamicBody)return!1;for(var t=this.m_jointList;t;t=t.next)if(t.other==e&&t.joint.m_collideConnected==0)return!1;return!0},Q.prototype.Advance=function(e){e===undefined&&(e=0),this.m_sweep.Advance(e),this.m_sweep.c.SetV(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.SynchronizeTransform()},e.postDefs.push(function(){e.Dynamics.b2Body.s_xf1=new a,e.Dynamics.b2Body.e_islandFlag=1,e.Dynamics.b2Body.e_awakeFlag=2,e.Dynamics.b2Body.e_allowSleepFlag=4,e.Dynamics.b2Body.e_bulletFlag=8,e.Dynamics.b2Body.e_fixedRotationFlag=16,e.Dynamics.b2Body.e_activeFlag=32,e.Dynamics.b2Body.b2_staticBody=0,e.Dynamics.b2Body.b2_kinematicBody=1,e.Dynamics.b2Body.b2_dynamicBody=2}),G.b2BodyDef=function(){this.position=new f,this.linearVelocity=new f},G.prototype.b2BodyDef=function(){this.userData=null,this.position.Set(0,0),this.angle=0,this.linearVelocity.Set(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.type=Q.b2_staticBody,this.active=!0,this.inertiaScale=1},Y.b2ContactFilter=function(){},Y.prototype.ShouldCollide=function(e,t){var n=e.GetFilterData(),r=t.GetFilterData();if(n.groupIndex==r.groupIndex&&n.groupIndex!=0)return n.groupIndex>0;var i=(n.maskBits&r.categoryBits)!=0&&(n.categoryBits&r.maskBits)!=0;return i},Y.prototype.RayCollide=function(e,t){return e?this.ShouldCollide(e instanceof st?e:null,t):!0},e.postDefs.push(function(){e.Dynamics.b2ContactFilter.b2_defaultFilter=new Y}),Z.b2ContactImpulse=function(){this.normalImpulses=new n(p.b2_maxManifoldPoints),this.tangentImpulses=new n(p.b2_maxManifoldPoints)},et.b2ContactListener=function(){},et.prototype.BeginContact=function(e){},et.prototype.EndContact=function(e){},et.prototype.PreSolve=function(e,t){},et.prototype.PostSolve=function(e,t){},e.postDefs.push(function(){e.Dynamics.b2ContactListener.b2_defaultListener=new et}),tt.b2ContactManager=function(){},tt.prototype.b2ContactManager=function(){this.m_world=null,this.m_contactCount=0,this.m_contactFilter=Y.b2_defaultFilter,this.m_contactListener=et.b2_defaultListener,this.m_contactFactory=new vt(this.m_allocator),this.m_broadPhase=new N},tt.prototype.AddPair=function(e,t){var n=e instanceof st?e:null,r=t instanceof st?t:null,i=n.GetBody(),s=r.GetBody();if(i==s)return;var o=s.GetContactList();while(o){if(o.other==i){var u=o.contact.GetFixtureA(),a=o.contact.GetFixtureB();if(u==n&&a==r)return;if(u==r&&a==n)return}o=o.next}if(s.ShouldCollide(i)==0)return;if(this.m_contactFilter.ShouldCollide(n,r)==0)return;var f=this.m_contactFactory.Create(n,r);n=f.GetFixtureA(),r=f.GetFixtureB(),i=n.m_body,s=r.m_body,f.m_prev=null,f.m_next=this.m_world.m_contactList,this.m_world.m_contactList!=null&&(this.m_world.m_contactList.m_prev=f),this.m_world.m_contactList=f,f.m_nodeA.contact=f,f.m_nodeA.other=s,f.m_nodeA.prev=null,f.m_nodeA.next=i.m_contactList,i.m_contactList!=null&&(i.m_contactList.prev=f.m_nodeA),i.m_contactList=f.m_nodeA,f.m_nodeB.contact=f,f.m_nodeB.other=i,f.m_nodeB.prev=null,f.m_nodeB.next=s.m_contactList,s.m_contactList!=null&&(s.m_contactList.prev=f.m_nodeB),s.m_contactList=f.m_nodeB,++this.m_world.m_contactCount;return},tt.prototype.FindNewContacts=function(){this.m_broadPhase.UpdatePairs(e.generateCallback(this,this.AddPair))},tt.prototype.Destroy=function(e){var t=e.GetFixtureA(),n=e.GetFixtureB(),r=t.GetBody(),i=n.GetBody();e.IsTouching()&&this.m_contactListener.EndContact(e),e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),e==this.m_world.m_contactList&&(this.m_world.m_contactList=e.m_next),e.m_nodeA.prev&&(e.m_nodeA.prev.next=e.m_nodeA.next),e.m_nodeA.next&&(e.m_nodeA.next.prev=e.m_nodeA.prev),e.m_nodeA==r.m_contactList&&(r.m_contactList=e.m_nodeA.next),e.m_nodeB.prev&&(e.m_nodeB.prev.next=e.m_nodeB.next),e.m_nodeB.next&&(e.m_nodeB.next.prev=e.m_nodeB.prev),e.m_nodeB==i.m_contactList&&(i.m_contactList=e.m_nodeB.next),this.m_contactFactory.Destroy(e),--this.m_contactCount},tt.prototype.Collide=function(){var e=this.m_world.m_contactList;while(e){var t=e.GetFixtureA(),n=e.GetFixtureB(),r=t.GetBody(),i=n.GetBody();if(r.IsAwake()==0&&i.IsAwake()==0){e=e.GetNext();continue}if(e.m_flags&ct.e_filterFlag){if(i.ShouldCollide(r)==0){var s=e;e=s.GetNext(),this.Destroy(s);continue}if(this.m_contactFilter.ShouldCollide(t,n)==0){s=e,e=s.GetNext(),this.Destroy(s);continue}e.m_flags&=~ct.e_filterFlag}var o=t.m_proxy,u=n.m_proxy,a=this.m_broadPhase.TestOverlap(o,u);if(a==0){s=e,e=s.GetNext(),this.Destroy(s);continue}e.Update(this.m_contactListener),e=e.GetNext()}},e.postDefs.push(function(){e.Dynamics.b2ContactManager.s_evalCP=new b}),nt.b2DebugDraw=function(){},nt.prototype.b2DebugDraw=function(){},nt.prototype.SetFlags=function(e){e===undefined&&(e=0)},nt.prototype.GetFlags=function(){},nt.prototype.AppendFlags=function(e){e===undefined&&(e=0)},nt.prototype.ClearFlags=function(e){e===undefined&&(e=0)},nt.prototype.SetSprite=function(e){},nt.prototype.GetSprite=function(){},nt.prototype.SetDrawScale=function(e){e===undefined&&(e=0)},nt.prototype.GetDrawScale=function(){},nt.prototype.SetLineThickness=function(e){e===undefined&&(e=0)},nt.prototype.GetLineThickness=function(){},nt.prototype.SetAlpha=function(e){e===undefined&&(e=0)},nt.prototype.GetAlpha=function(){},nt.prototype.SetFillAlpha=function(e){e===undefined&&(e=0)},nt.prototype.GetFillAlpha=function(){},nt.prototype.SetXFormScale=function(e){e===undefined&&(e=0)},nt.prototype.GetXFormScale=function(){},nt.prototype.DrawPolygon=function(e,t,n){t===undefined&&(t=0)},nt.prototype.DrawSolidPolygon=function(e,t,n){t===undefined&&(t=0)},nt.prototype.DrawCircle=function(e,t,n){t===undefined&&(t=0)},nt.prototype.DrawSolidCircle=function(e,t,n,r){t===undefined&&(t=0)},nt.prototype.DrawSegment=function(e,t,n){},nt.prototype.DrawTransform=function(e){},e.postDefs.push(function(){e.Dynamics.b2DebugDraw.e_shapeBit=1,e.Dynamics.b2DebugDraw.e_jointBit=2,e.Dynamics.b2DebugDraw.e_aabbBit=4,e.Dynamics.b2DebugDraw.e_pairBit=8,e.Dynamics.b2DebugDraw.e_centerOfMassBit=16,e.Dynamics.b2DebugDraw.e_controllerBit=32}),rt.b2DestructionListener=function(){},rt.prototype.SayGoodbyeJoint=function(e){},rt.prototype.SayGoodbyeFixture=function(e){},it.b2FilterData=function(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0},it.prototype.Copy=function(){var e=new it;return e.categoryBits=this.categoryBits,e.maskBits=this.maskBits,e.groupIndex=this.groupIndex,e},st.b2Fixture=function(){this.m_filter=new it},st.prototype.GetType=function(){return this.m_shape.GetType()},st.prototype.GetShape=function(){return this.m_shape},st.prototype.SetSensor=function(e){if(this.m_isSensor==e)return;this.m_isSensor=e;if(this.m_body==null)return;var t=this.m_body.GetContactList();while(t){var n=t.contact,r=n.GetFixtureA(),i=n.GetFixtureB();(r==this||i==this)&&n.SetSensor(r.IsSensor()||i.IsSensor()),t=t.next}},st.prototype.IsSensor=function(){return this.m_isSensor},st.prototype.SetFilterData=function(e){this.m_filter=e.Copy();if(this.m_body)return;var t=this.m_body.GetContactList();while(t){var n=t.contact,r=n.GetFixtureA(),i=n.GetFixtureB();(r==this||i==this)&&n.FlagForFiltering(),t=t.next}},st.prototype.GetFilterData=function(){return this.m_filter.Copy()},st.prototype.GetBody=function(){return this.m_body},st.prototype.GetNext=function(){return this.m_next},st.prototype.GetUserData=function(){return this.m_userData},st.prototype.SetUserData=function(e){this.m_userData=e},st.prototype.TestPoint=function(e){return this.m_shape.TestPoint(this.m_body.GetTransform(),e)},st.prototype.RayCast=function(e,t){return this.m_shape.RayCast(e,t,this.m_body.GetTransform())},st.prototype.GetMassData=function(e){return e===undefined&&(e=null),e==null&&(e=new $),this.m_shape.ComputeMass(e,this.m_density),e},st.prototype.SetDensity=function(e){e===undefined&&(e=0),this.m_density=e},st.prototype.GetDensity=function(){return this.m_density},st.prototype.GetFriction=function(){return this.m_friction},st.prototype.SetFriction=function(e){e===undefined&&(e=0),this.m_friction=e},st.prototype.GetRestitution=function(){return this.m_restitution},st.prototype.SetRestitution=function(e){e===undefined&&(e=0),this.m_restitution=e},st.prototype.GetAABB=function(){return this.m_aabb},st.prototype.b2Fixture=function(){this.m_aabb=new d,this.m_userData=null,this.m_body=null,this.m_next=null,this.m_shape=null,this.m_density=0,this.m_friction=0,this.m_restitution=0},st.prototype.Create=function(e,t,n){this.m_userData=n.userData,this.m_friction=n.friction,this.m_restitution=n.restitution,this.m_body=e,this.m_next=null,this.m_filter=n.filter.Copy(),this.m_isSensor=n.isSensor,this.m_shape=n.shape.Copy(),this.m_density=n.density},st.prototype.Destroy=function(){this.m_shape=null},st.prototype.CreateProxy=function(e,t){this.m_shape.ComputeAABB(this.m_aabb,t),this.m_proxy=e.CreateProxy(this.m_aabb,this)},st.prototype.DestroyProxy=function(e){if(this.m_proxy==null)return;e.DestroyProxy(this.m_proxy),this.m_proxy=null},st.prototype.Synchronize=function(e,t,n){if(!this.m_proxy)return;var r=new d,i=new d;this.m_shape.ComputeAABB(r,t),this.m_shape.ComputeAABB(i,n),this.m_aabb.Combine(r,i);var s=o.SubtractVV(n.position,t.position);e.MoveProxy(this.m_proxy,this.m_aabb,s)},ot.b2FixtureDef=function(){this.filter=new it},ot.prototype.b2FixtureDef=function(){this.shape=null,this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.filter.categoryBits=1,this.filter.maskBits=65535,this.filter.groupIndex=0,this.isSensor=!1},ut.b2Island=function(){},ut.prototype.b2Island=function(){this.m_bodies=new t,this.m_contacts=new t,this.m_joints=new t},ut.prototype.Initialize=function(e,t,n,r,i,s){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0);var o=0;this.m_bodyCapacity=e,this.m_contactCapacity=t,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_contactSolver=s;for(o=this.m_bodies.length;o<e;o++)this.m_bodies[o]=null;for(o=this.m_contacts.length;o<t;o++)this.m_contacts[o]=null;for(o=this.m_joints.length;o<n;o++)this.m_joints[o]=null},ut.prototype.Clear=function(){this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0},ut.prototype.Solve=function(e,t,n){var r=0,i=0,s,u;for(r=0;r<this.m_bodyCount;++r){s=this.m_bodies[r];if(s.GetType()!=Q.b2_dynamicBody)continue;s.m_linearVelocity.x+=e.dt*(t.x+s.m_invMass*s.m_force.x),s.m_linearVelocity.y+=e.dt*(t.y+s.m_invMass*s.m_force.y),s.m_angularVelocity+=e.dt*s.m_invI*s.m_torque,s.m_linearVelocity.Multiply(o.Clamp(1-e.dt*s.m_linearDamping,0,1)),s.m_angularVelocity*=o.Clamp(1-e.dt*s.m_angularDamping,0,1)}this.m_contactSolver.Initialize(e,this.m_contacts,this.m_contactCount,this.m_allocator);var a=this.m_contactSolver;a.InitVelocityConstraints(e);for(r=0;r<this.m_jointCount;++r)u=this.m_joints[r],u.InitVelocityConstraints(e);for(r=0;r<e.velocityIterations;++r){for(i=0;i<this.m_jointCount;++i)u=this.m_joints[i],u.SolveVelocityConstraints(e);a.SolveVelocityConstraints()}for(r=0;r<this.m_jointCount;++r)u=this.m_joints[r],u.FinalizeVelocityConstraints();a.FinalizeVelocityConstraints();for(r=0;r<this.m_bodyCount;++r){s=this.m_bodies[r];if(s.GetType()==Q.b2_staticBody)continue;var f=e.dt*s.m_linearVelocity.x,l=e.dt*s.m_linearVelocity.y;f*f+l*l>p.b2_maxTranslationSquared&&(s.m_linearVelocity.Normalize(),s.m_linearVelocity.x*=p.b2_maxTranslation*e.inv_dt,s.m_linearVelocity.y*=p.b2_maxTranslation*e.inv_dt);var c=e.dt*s.m_angularVelocity;c*c>p.b2_maxRotationSquared&&(s.m_angularVelocity<0?s.m_angularVelocity=-p.b2_maxRotation*e.inv_dt:s.m_angularVelocity=p.b2_maxRotation*e.inv_dt),s.m_sweep.c0.SetV(s.m_sweep.c),s.m_sweep.a0=s.m_sweep.a,s.m_sweep.c.x+=e.dt*s.m_linearVelocity.x,s.m_sweep.c.y+=e.dt*s.m_linearVelocity.y,s.m_sweep.a+=e.dt*s.m_angularVelocity,s.SynchronizeTransform()}for(r=0;r<e.positionIterations;++r){var h=a.SolvePositionConstraints(p.b2_contactBaumgarte),d=!0;for(i=0;i<this.m_jointCount;++i){u=this.m_joints[i];var v=u.SolvePositionConstraints(p.b2_contactBaumgarte);d=d&&v}if(h&&d)break}this.Report(a.m_constraints);if(n){var m=Number.MAX_VALUE,g=p.b2_linearSleepTolerance*p.b2_linearSleepTolerance,y=p.b2_angularSleepTolerance*p.b2_angularSleepTolerance;for(r=0;r<this.m_bodyCount;++r){s=this.m_bodies[r];if(s.GetType()==Q.b2_staticBody)continue;(s.m_flags&Q.e_allowSleepFlag)==0&&(s.m_sleepTime=0,m=0),(s.m_flags&Q.e_allowSleepFlag)==0||s.m_angularVelocity*s.m_angularVelocity>y||o.Dot(s.m_linearVelocity,s.m_linearVelocity)>g?(s.m_sleepTime=0,m=0):(s.m_sleepTime+=e.dt,m=o.Min(m,s.m_sleepTime))}if(m>=p.b2_timeToSleep)for(r=0;r<this.m_bodyCount;++r)s=this.m_bodies[r],s.SetAwake(!1)}},ut.prototype.SolveTOI=function(e){var t=0,n=0;this.m_contactSolver.Initialize(e,this.m_contacts,this.m_contactCount,this.m_allocator);var r=this.m_contactSolver;for(t=0;t<this.m_jointCount;++t)this.m_joints[t].InitVelocityConstraints(e);for(t=0;t<e.velocityIterations;++t){r.SolveVelocityConstraints();for(n=0;n<this.m_jointCount;++n)this.m_joints[n].SolveVelocityConstraints(e)}for(t=0;t<this.m_bodyCount;++t){var i=this.m_bodies[t];if(i.GetType()==Q.b2_staticBody)continue;var s=e.dt*i.m_linearVelocity.x,o=e.dt*i.m_linearVelocity.y;s*s+o*o>p.b2_maxTranslationSquared&&(i.m_linearVelocity.Normalize(),i.m_linearVelocity.x*=p.b2_maxTranslation*e.inv_dt,i.m_linearVelocity.y*=p.b2_maxTranslation*e.inv_dt);var u=e.dt*i.m_angularVelocity;u*u>p.b2_maxRotationSquared&&(i.m_angularVelocity<0?i.m_angularVelocity=-p.b2_maxRotation*e.inv_dt:i.m_angularVelocity=p.b2_maxRotation*e.inv_dt),i.m_sweep.c0.SetV(i.m_sweep.c),i.m_sweep.a0=i.m_sweep.a,i.m_sweep.c.x+=e.dt*i.m_linearVelocity.x,i.m_sweep.c.y+=e.dt*i.m_linearVelocity.y,i.m_sweep.a+=e.dt*i.m_angularVelocity,i.SynchronizeTransform()}var a=.75;for(t=0;t<e.positionIterations;++t){var f=r.SolvePositionConstraints(a),l=!0;for(n=0;n<this.m_jointCount;++n){var c=this.m_joints[n].SolvePositionConstraints(p.b2_contactBaumgarte);l=l&&c}if(f&&l)break}this.Report(r.m_constraints)},ut.prototype.Report=function(e){if(this.m_listener==null)return;for(var t=0;t<this.m_contactCount;++t){var n=this.m_contacts[t],r=e[t];for(var i=0;i<r.pointCount;++i)ut.s_impulse.normalImpulses[i]=r.points[i].normalImpulse,ut.s_impulse.tangentImpulses[i]=r.points[i].tangentImpulse;this.m_listener.PostSolve(n,ut.s_impulse)}},ut.prototype.AddBody=function(e){e.m_islandIndex=this.m_bodyCount,this.m_bodies[this.m_bodyCount++]=e},ut.prototype.AddContact=function(e){this.m_contacts[this.m_contactCount++]=e},ut.prototype.AddJoint=function(e){this.m_joints[this.m_jointCount++]=e},e.postDefs.push(function(){e.Dynamics.b2Island.s_impulse=new Z}),at.b2TimeStep=function(){},at.prototype.Set=function(e){this.dt=e.dt,this.inv_dt=e.inv_dt,this.positionIterations=e.positionIterations,this.velocityIterations=e.velocityIterations,this.warmStarting=e.warmStarting},ft.b2World=function(){this.s_stack=new t,this.m_contactManager=new tt,this.m_contactSolver=new yt,this.m_island=new ut},ft.prototype.b2World=function(e,t){this.m_destructionListener=null,this.m_debugDraw=null,this.m_bodyList=null,this.m_contactList=null,this.m_jointList=null,this.m_controllerList=null,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_controllerCount=0,ft.m_warmStarting=!0,ft.m_continuousPhysics=!0,this.m_allowSleep=t,this.m_gravity=e,this.m_inv_dt0=0,this.m_contactManager.m_world=this;var n=new G;this.m_groundBody=this.CreateBody(n)},ft.prototype.SetDestructionListener=function(e){this.m_destructionListener=e},ft.prototype.SetContactFilter=function(e){this.m_contactManager.m_contactFilter=e},ft.prototype.SetContactListener=function(e){this.m_contactManager.m_contactListener=e},ft.prototype.SetDebugDraw=function(e){this.m_debugDraw=e},ft.prototype.SetBroadPhase=function(e){var t=this.m_contactManager.m_broadPhase;this.m_contactManager.m_broadPhase=e;for(var n=this.m_bodyList;n;n=n.m_next)for(var r=n.m_fixtureList;r;r=r.m_next)r.m_proxy=e.CreateProxy(t.GetFatAABB(r.m_proxy),r)},ft.prototype.Validate=function(){this.m_contactManager.m_broadPhase.Validate()},ft.prototype.GetProxyCount=function(){return this.m_contactManager.m_broadPhase.GetProxyCount()},ft.prototype.CreateBody=function(e){if(this.IsLocked()==1)return null;var t=new Q(e,this);return t.m_prev=null,t.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=t),this.m_bodyList=t,++this.m_bodyCount,t},ft.prototype.DestroyBody=function(e){if(this.IsLocked()==1)return;var t=e.m_jointList;while(t){var n=t;t=t.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(n.joint),this.DestroyJoint(n.joint)}var r=e.m_controllerList;while(r){var i=r;r=r.nextController,i.controller.RemoveBody(e)}var s=e.m_contactList;while(s){var o=s;s=s.next,this.m_contactManager.Destroy(o.contact)}e.m_contactList=null;var u=e.m_fixtureList;while(u){var a=u;u=u.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(a),a.DestroyProxy(this.m_contactManager.m_broadPhase),a.Destroy()}e.m_fixtureList=null,e.m_fixtureCount=0,e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),e==this.m_bodyList&&(this.m_bodyList=e.m_next),--this.m_bodyCount},ft.prototype.CreateJoint=function(e){var t=Dt.Create(e,null);t.m_prev=null,t.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=t),this.m_jointList=t,++this.m_jointCount,t.m_edgeA.joint=t,t.m_edgeA.other=t.m_bodyB,t.m_edgeA.prev=null,t.m_edgeA.next=t.m_bodyA.m_jointList,t.m_bodyA.m_jointList&&(t.m_bodyA.m_jointList.prev=t.m_edgeA),t.m_bodyA.m_jointList=t.m_edgeA,t.m_edgeB.joint=t,t.m_edgeB.other=t.m_bodyA,t.m_edgeB.prev=null,t.m_edgeB.next=t.m_bodyB.m_jointList,t.m_bodyB.m_jointList&&(t.m_bodyB.m_jointList.prev=t.m_edgeB),t.m_bodyB.m_jointList=t.m_edgeB;var n=e.bodyA,r=e.bodyB;if(e.collideConnected==0){var i=r.GetContactList();while(i)i.other==n&&i.contact.FlagForFiltering(),i=i.next}return t},ft.prototype.DestroyJoint=function(e){var t=e.m_collideConnected;e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),e==this.m_jointList&&(this.m_jointList=e.m_next);var n=e.m_bodyA,r=e.m_bodyB;n.SetAwake(!0),r.SetAwake(!0),e.m_edgeA.prev&&(e.m_edgeA.prev.next=e.m_edgeA.next),e.m_edgeA.next&&(e.m_edgeA.next.prev=e.m_edgeA.prev),e.m_edgeA==n.m_jointList&&(n.m_jointList=e.m_edgeA.next),e.m_edgeA.prev=null,e.m_edgeA.next=null,e.m_edgeB.prev&&(e.m_edgeB.prev.next=e.m_edgeB.next),e.m_edgeB.next&&(e.m_edgeB.next.prev=e.m_edgeB.prev),e.m_edgeB==r.m_jointList&&(r.m_jointList=e.m_edgeB.next),e.m_edgeB.prev=null,e.m_edgeB.next=null,Dt.Destroy(e,null),--this.m_jointCount;if(t==0){var i=r.GetContactList();while(i)i.other==n&&i.contact.FlagForFiltering(),i=i.next}},ft.prototype.AddController=function(e){return e.m_next=this.m_controllerList,e.m_prev=null,this.m_controllerList=e,e.m_world=this,this.m_controllerCount++,e},ft.prototype.RemoveController=function(e){e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),this.m_controllerList==e&&(this.m_controllerList=e.m_next),this.m_controllerCount--},ft.prototype.CreateController=function(e){if(e.m_world!=this)throw new Error("Controller can only be a member of one world");return e.m_next=this.m_controllerList,e.m_prev=null,this.m_controllerList&&(this.m_controllerList.m_prev=e),this.m_controllerList=e,++this.m_controllerCount,e.m_world=this,e},ft.prototype.DestroyController=function(e){e.Clear(),e.m_next&&(e.m_next.m_prev=e.m_prev),e.m_prev&&(e.m_prev.m_next=e.m_next),e==this.m_controllerList&&(this.m_controllerList=e.m_next),--this.m_controllerCount},ft.prototype.SetWarmStarting=function(e){ft.m_warmStarting=e},ft.prototype.SetContinuousPhysics=function(e){ft.m_continuousPhysics=e},ft.prototype.GetBodyCount=function(){return this.m_bodyCount},ft.prototype.GetJointCount=function(){return this.m_jointCount},ft.prototype.GetContactCount=function(){return this.m_contactCount},ft.prototype.SetGravity=function(e){this.m_gravity=e},ft.prototype.GetGravity=function(){return this.m_gravity},ft.prototype.GetGroundBody=function(){return this.m_groundBody},ft.prototype.Step=function(e,t,n){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0),this.m_flags&ft.e_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_flags&=~ft.e_newFixture),this.m_flags|=ft.e_locked;var r=ft.s_timestep2;r.dt=e,r.velocityIterations=t,r.positionIterations=n,e>0?r.inv_dt=1/e:r.inv_dt=0,r.dtRatio=this.m_inv_dt0*e,r.warmStarting=ft.m_warmStarting,this.m_contactManager.Collide(),r.dt>0&&this.Solve(r),ft.m_continuousPhysics&&r.dt>0&&this.SolveTOI(r),r.dt>0&&(this.m_inv_dt0=r.inv_dt),this.m_flags&=~ft.e_locked},ft.prototype.ClearForces=function(){for(var e=this.m_bodyList;e;e=e.m_next)e.m_force.SetZero(),e.m_torque=0},ft.prototype.DrawDebugData=function(){if(this.m_debugDraw==null)return;this.m_debugDraw.m_sprite.graphics.clear();var e=this.m_debugDraw.GetFlags(),t=0,n,r,i,s,o,u=new f,a=new f,l=new f,h,p=new d,v=new d,m=[new f,new f,new f,new f],g=new c(0,0,0);if(e&nt.e_shapeBit)for(n=this.m_bodyList;n;n=n.m_next){h=n.m_xf;for(r=n.GetFixtureList();r;r=r.m_next)i=r.GetShape(),n.IsActive()==0?(g.Set(.5,.5,.3),this.DrawShape(i,h,g)):n.GetType()==Q.b2_staticBody?(g.Set(.5,.9,.5),this.DrawShape(i,h,g)):n.GetType()==Q.b2_kinematicBody?(g.Set(.5,.5,.9),this.DrawShape(i,h,g)):n.IsAwake()==0?(g.Set(.6,.6,.6),this.DrawShape(i,h,g)):(g.Set(.9,.7,.7),this.DrawShape(i,h,g))}if(e&nt.e_jointBit)for(s=this.m_jointList;s;s=s.m_next)this.DrawJoint(s);if(e&nt.e_controllerBit)for(var y=this.m_controllerList;y;y=y.m_next)y.Draw(this.m_debugDraw);if(e&nt.e_pairBit){g.Set(.3,.9,.9);for(var b=this.m_contactManager.m_contactList;b;b=b.GetNext()){var w=b.GetFixtureA(),E=b.GetFixtureB(),S=w.GetAABB().GetCenter(),x=E.GetAABB().GetCenter();this.m_debugDraw.DrawSegment(S,x,g)}}if(e&nt.e_aabbBit){o=this.m_contactManager.m_broadPhase,m=[new f,new f,new f,new f];for(n=this.m_bodyList;n;n=n.GetNext()){if(n.IsActive()==0)continue;for(r=n.GetFixtureList();r;r=r.GetNext()){var T=o.GetFatAABB(r.m_proxy);m[0].Set(T.lowerBound.x,T.lowerBound.y),m[1].Set(T.upperBound.x,T.lowerBound.y),m[2].Set(T.upperBound.x,T.upperBound.y),m[3].Set(T.lowerBound.x,T.upperBound.y),this.m_debugDraw.DrawPolygon(m,4,g)}}}if(e&nt.e_centerOfMassBit)for(n=this.m_bodyList;n;n=n.m_next)h=ft.s_xf,h.R=n.m_xf.R,h.position=n.GetWorldCenter(),this.m_debugDraw.DrawTransform(h)},ft.prototype.QueryAABB=function(e,t){function i(t){return e(r.GetUserData(t))}var n=this,r=n.m_contactManager.m_broadPhase;r.Query(i,t)},ft.prototype.QueryShape=function(e,t,n){function s(r){var s=i.GetUserData(r)instanceof st?i.GetUserData(r):null;return K.TestOverlap(t,n,s.GetShape(),s.GetBody().GetTransform())?e(s):!0}var r=this;n===undefined&&(n=null),n==null&&(n=new a,n.SetIdentity());var i=r.m_contactManager.m_broadPhase,o=new d;t.ComputeAABB(o,n),i.Query(s,o)},ft.prototype.QueryPoint=function(e,t){function i(n){var i=r.GetUserData(n)instanceof st?r.GetUserData(n):null;return i.TestPoint(t)?e(i):!0}var n=this,r=n.m_contactManager.m_broadPhase,s=new d;s.lowerBound.Set(t.x-p.b2_linearSlop,t.y-p.b2_linearSlop),s.upperBound.Set(t.x+p.b2_linearSlop,t.y+p.b2_linearSlop),r.Query(i,s)},ft.prototype.RayCast=function(e,t,n){function o(r,o){var u=i.GetUserData(o),a=u instanceof st?u:null,l=a.RayCast(s,r);if(l){var c=s.fraction,h=new f((1-c)*t.x+c*n.x,(1-c)*t.y+c*n.y);return e(a,h,s.normal,c)}return r.maxFraction}var r=this,i=r.m_contactManager.m_broadPhase,s=new _,u=new M(t,n);i.RayCast(o,u)},ft.prototype.RayCastOne=function(e,t){function i(e,t,n,i){return i===undefined&&(i=0),r=e,i}var n=this,r;return n.RayCast(i,e,t),r},ft.prototype.RayCastAll=function(e,n){function s(e,t,n,r){return r===undefined&&(r=0),i[i.length]=e,1}var r=this,i=new t;return r.RayCast(s,e,n),i},ft.prototype.GetBodyList=function(){return this.m_bodyList},ft.prototype.GetJointList=function(){return this.m_jointList},ft.prototype.GetContactList=function(){return this.m_contactList},ft.prototype.IsLocked=function(){return(this.m_flags&ft.e_locked)>0},ft.prototype.Solve=function(e){var t;for(var n=this.m_controllerList;n;n=n.m_next)n.Step(e);var r=this.m_island;r.Initialize(this.m_bodyCount,this.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener,this.m_contactSolver);for(t=this.m_bodyList;t;t=t.m_next)t.m_flags&=~Q.e_islandFlag;for(var i=this.m_contactList;i;i=i.m_next)i.m_flags&=~ct.e_islandFlag;for(var s=this.m_jointList;s;s=s.m_next)s.m_islandFlag=!1;var o=parseInt(this.m_bodyCount),u=this.s_stack;for(var a=this.m_bodyList;a;a=a.m_next){if(a.m_flags&Q.e_islandFlag)continue;if(a.IsAwake()==0||a.IsActive()==0)continue;if(a.GetType()==Q.b2_staticBody)continue;r.Clear();var f=0;u[f++]=a,a.m_flags|=Q.e_islandFlag;while(f>0){t=u[--f],r.AddBody(t),t.IsAwake()==0&&t.SetAwake(!0);if(t.GetType()==Q.b2_staticBody)continue;var l;for(var c=t.m_contactList;c;c=c.next){if(c.contact.m_flags&ct.e_islandFlag)continue;if(c.contact.IsSensor()==1||c.contact.IsEnabled()==0||c.contact.IsTouching()==0)continue;r.AddContact(c.contact),c.contact.m_flags|=ct.e_islandFlag,l=c.other;if(l.m_flags&Q.e_islandFlag)continue;u[f++]=l,l.m_flags|=Q.e_islandFlag}for(var h=t.m_jointList;h;h=h.next){if(h.joint.m_islandFlag==1)continue;l=h.other;if(l.IsActive()==0)continue;r.AddJoint(h.joint),h.joint.m_islandFlag=!0;if(l.m_flags&Q.e_islandFlag)continue;u[f++]=l,l.m_flags|=Q.e_islandFlag}}r.Solve(e,this.m_gravity,this.m_allowSleep);for(var p=0;p<r.m_bodyCount;++p)t=r.m_bodies[p],t.GetType()==Q.b2_staticBody&&(t.m_flags&=~Q.e_islandFlag)}for(p=0;p<u.length;++p){if(!u[p])break;u[p]=null}for(t=this.m_bodyList;t;t=t.m_next){if(t.IsAwake()==0||t.IsActive()==0)continue;if(t.GetType()==Q.b2_staticBody)continue;t.SynchronizeFixtures()}this.m_contactManager.FindNewContacts()},ft.prototype.SolveTOI=function(e){var t,n,r,i,s,o,u,a=this.m_island;a.Initialize(this.m_bodyCount,p.b2_maxTOIContactsPerIsland,p.b2_maxTOIJointsPerIsland,null,this.m_contactManager.m_contactListener,this.m_contactSolver);var f=ft.s_queue;for(t=this.m_bodyList;t;t=t.m_next)t.m_flags&=~Q.e_islandFlag,t.m_sweep.t0=0;var l;for(l=this.m_contactList;l;l=l.m_next)l.m_flags&=~(ct.e_toiFlag|ct.e_islandFlag);for(u=this.m_jointList;u;u=u.m_next)u.m_islandFlag=!1;for(;;){var c=null,h=1;for(l=this.m_contactList;l;l=l.m_next){if(l.IsSensor()==1||l.IsEnabled()==0||l.IsContinuous()==0)continue;var d=1;if(l.m_flags&ct.e_toiFlag)d=l.m_toi;else{n=l.m_fixtureA,r=l.m_fixtureB,i=n.m_body,s=r.m_body;if(!(i.GetType()==Q.b2_dynamicBody&&i.IsAwake()!=0||s.GetType()==Q.b2_dynamicBody&&s.IsAwake()!=0))continue;var v=i.m_sweep.t0;i.m_sweep.t0<s.m_sweep.t0?(v=s.m_sweep.t0,i.m_sweep.Advance(v)):s.m_sweep.t0<i.m_sweep.t0&&(v=i.m_sweep.t0,s.m_sweep.Advance(v)),d=l.ComputeTOI(i.m_sweep,s.m_sweep),p.b2Assert(0<=d&&d<=1),d>0&&d<1&&(d=(1-d)*v+d,d>1&&(d=1)),l.m_toi=d,l.m_flags|=ct.e_toiFlag}Number.MIN_VALUE<d&&d<h&&(c=l,h=d)}if(c==null||1-100*Number.MIN_VALUE<h)break;n=c.m_fixtureA,r=c.m_fixtureB,i=n.m_body,s=r.m_body,ft.s_backupA.Set(i.m_sweep),ft.s_backupB.Set(s.m_sweep),i.Advance(h),s.Advance(h),c.Update(this.m_contactManager.m_contactListener),c.m_flags&=~ct.e_toiFlag;if(c.IsSensor()==1||c.IsEnabled()==0){i.m_sweep.Set(ft.s_backupA),s.m_sweep.Set(ft.s_backupB),i.SynchronizeTransform(),s.SynchronizeTransform();continue}if(c.IsTouching()==0)continue;var m=i;m.GetType()!=Q.b2_dynamicBody&&(m=s),a.Clear();var g=0,y=0;f[g+y++]=m,m.m_flags|=Q.e_islandFlag;while(y>0){t=f[g++],--y,a.AddBody(t),t.IsAwake()==0&&t.SetAwake(!0);if(t.GetType()!=Q.b2_dynamicBody)continue;for(o=t.m_contactList;o;o=o.next){if(a.m_contactCount==a.m_contactCapacity)break;if(o.contact.m_flags&ct.e_islandFlag)continue;if(o.contact.IsSensor()==1||o.contact.IsEnabled()==0||o.contact.IsTouching()==0)continue;a.AddContact(o.contact),o.contact.m_flags|=ct.e_islandFlag;var b=o.other;if(b.m_flags&Q.e_islandFlag)continue;b.GetType()!=Q.b2_staticBody&&(b.Advance(h),b.SetAwake(!0)),f[g+y]=b,++y,b.m_flags|=Q.e_islandFlag}for(var w=t.m_jointList;w;w=w.next){if(a.m_jointCount==a.m_jointCapacity)continue;if(w.joint.m_islandFlag==1)continue;b=w.other;if(b.IsActive()==0)continue;a.AddJoint(w.joint),w.joint.m_islandFlag=!0;if(b.m_flags&Q.e_islandFlag)continue;b.GetType()!=Q.b2_staticBody&&(b.Advance(h),b.SetAwake(!0)),f[g+y]=b,++y,b.m_flags|=Q.e_islandFlag}}var E=ft.s_timestep;E.warmStarting=!1,E.dt=(1-h)*e.dt,E.inv_dt=1/E.dt,E.dtRatio=0,E.velocityIterations=e.velocityIterations,E.positionIterations=e.positionIterations,a.SolveTOI(E);var S=0;for(S=0;S<a.m_bodyCount;++S){t=a.m_bodies[S],t.m_flags&=~Q.e_islandFlag;if(t.IsAwake()==0)continue;if(t.GetType()!=Q.b2_dynamicBody)continue;t.SynchronizeFixtures();for(o=t.m_contactList;o;o=o.next)o.contact.m_flags&=~ct.e_toiFlag}for(S=0;S<a.m_contactCount;++S)l=a.m_contacts[S],l.m_flags&=~(ct.e_toiFlag|ct.e_islandFlag);for(S=0;S<a.m_jointCount;++S)u=a.m_joints[S],u.m_islandFlag=!1;this.m_contactManager.FindNewContacts()}},ft.prototype.DrawJoint=function(e){var t=e.GetBodyA(),n=e.GetBodyB(),r=t.m_xf,i=n.m_xf,s=r.position,o=i.position,u=e.GetAnchorA(),a=e.GetAnchorB(),f=ft.s_jointColor;switch(e.m_type){case Dt.e_distanceJoint:this.m_debugDraw.DrawSegment(u,a,f);break;case Dt.e_pulleyJoint:var l=e instanceof Ut?e:null,c=l.GetGroundAnchorA(),h=l.GetGroundAnchorB();this.m_debugDraw.DrawSegment(c,u,f),this.m_debugDraw.DrawSegment(h,a,f),this.m_debugDraw.DrawSegment(c,h,f);break;case Dt.e_mouseJoint:this.m_debugDraw.DrawSegment(u,a,f);break;default:t!=this.m_groundBody&&this.m_debugDraw.DrawSegment(s,u,f),this.m_debugDraw.DrawSegment(u,a,f),n!=this.m_groundBody&&this.m_debugDraw.DrawSegment(o,a,f)}},ft.prototype.DrawShape=function(e,n,r){switch(e.m_type){case K.e_circleShape:var i=e instanceof W?e:null,s=o.MulX(n,i.m_p),u=i.m_radius,a=n.R.col1;this.m_debugDraw.DrawSolidCircle(s,u,a,r);break;case K.e_polygonShape:var f=0,l=e instanceof J?e:null,c=parseInt(l.GetVertexCount()),h=l.GetVertices(),p=new t(c);for(f=0;f<c;++f)p[f]=o.MulX(n,h[f]);this.m_debugDraw.DrawSolidPolygon(p,c,r);break;case K.e_edgeShape:var d=e instanceof V?e:null;this.m_debugDraw.DrawSegment(o.MulX(n,d.GetVertex1()),o.MulX(n,d.GetVertex2()),r)}},e.postDefs.push(function(){e.Dynamics.b2World.s_timestep2=new at,e.Dynamics.b2World.s_xf=new a,e.Dynamics.b2World.s_backupA=new u,e.Dynamics.b2World.s_backupB=new u,e.Dynamics.b2World.s_timestep=new at,e.Dynamics.b2World.s_queue=new t,e.Dynamics.b2World.s_jointColor=new c(.5,.8,.8),e.Dynamics.b2World.e_newFixture=1,e.Dynamics.b2World.e_locked=2})}(),function(){var r=e.Collision.Shapes.b2CircleShape,i=e.Collision.Shapes.b2EdgeChainDef,s=e.Collision.Shapes.b2EdgeShape,o=e.Collision.Shapes.b2MassData,u=e.Collision.Shapes.b2PolygonShape,a=e.Collision.Shapes.b2Shape,f=e.Dynamics.Contacts.b2CircleContact,l=e.Dynamics.Contacts.b2Contact,c=e.Dynamics.Contacts.b2ContactConstraint,h=e.Dynamics.Contacts.b2ContactConstraintPoint,p=e.Dynamics.Contacts.b2ContactEdge,d=e.Dynamics.Contacts.b2ContactFactory,v=e.Dynamics.Contacts.b2ContactRegister,m=e.Dynamics.Contacts.b2ContactResult,g=e.Dynamics.Contacts.b2ContactSolver,y=e.Dynamics.Contacts.b2EdgeAndCircleContact,b=e.Dynamics.Contacts.b2NullContact,w=e.Dynamics.Contacts.b2PolyAndCircleContact,E=e.Dynamics.Contacts.b2PolyAndEdgeContact,S=e.Dynamics.Contacts.b2PolygonContact,x=e.Dynamics.Contacts.b2PositionSolverManifold,T=e.Dynamics.b2Body,N=e.Dynamics.b2BodyDef,C=e.Dynamics.b2ContactFilter,k=e.Dynamics.b2ContactImpulse,L=e.Dynamics.b2ContactListener,A=e.Dynamics.b2ContactManager,O=e.Dynamics.b2DebugDraw,M=e.Dynamics.b2DestructionListener,_=e.Dynamics.b2FilterData,D=e.Dynamics.b2Fixture,P=e.Dynamics.b2FixtureDef,H=e.Dynamics.b2Island,B=e.Dynamics.b2TimeStep,j=e.Dynamics.b2World,F=e.Common.b2Color,I=e.Common.b2internal,q=e.Common.b2Settings,R=e.Common.Math.b2Mat22,U=e.Common.Math.b2Mat33,z=e.Common.Math.b2Math,W=e.Common.Math.b2Sweep,X=e.Common.Math.b2Transform,V=e.Common.Math.b2Vec2,$=e.Common.Math.b2Vec3,J=e.Collision.b2AABB,K=e.Collision.b2Bound,Q=e.Collision.b2BoundValues,G=e.Collision.b2Collision,Y=e.Collision.b2ContactID,Z=e.Collision.b2ContactPoint,et=e.Collision.b2Distance,tt=e.Collision.b2DistanceInput,nt=e.Collision.b2DistanceOutput,rt=e.Collision.b2DistanceProxy,it=e.Collision.b2DynamicTree,st=e.Collision.b2DynamicTreeBroadPhase,ot=e.Collision.b2DynamicTreeNode,ut=e.Collision.b2DynamicTreePair,at=e.Collision.b2Manifold,ft=e.Collision.b2ManifoldPoint,lt=e.Collision.b2Point,ct=e.Collision.b2RayCastInput,ht=e.Collision.b2RayCastOutput,pt=e.Collision.b2Segment,dt=e.Collision.b2SeparationFunction,vt=e.Collision.b2Simplex,mt=e.Collision.b2SimplexCache,gt=e.Collision.b2SimplexVertex,yt=e.Collision.b2TimeOfImpact,bt=e.Collision.b2TOIInput,wt=e.Collision.b2WorldManifold,Et=e.Collision.ClipVertex,St=e.Collision.Features,xt=e.Collision.IBroadPhase;e.inherit(f,e.Dynamics.Contacts.b2Contact),f.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,f.b2CircleContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},f.Create=function(e){return new f},f.Destroy=function(e,t){},f.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t)},f.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();G.CollideCircles(this.m_manifold,this.m_fixtureA.GetShape()instanceof r?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof r?this.m_fixtureB.GetShape():null,t.m_xf)},l.b2Contact=function(){this.m_nodeA=new p,this.m_nodeB=new p,this.m_manifold=new at,this.m_oldManifold=new at},l.prototype.GetManifold=function(){return this.m_manifold},l.prototype.GetWorldManifold=function(e){var t=this.m_fixtureA.GetBody(),n=this.m_fixtureB.GetBody(),r=this.m_fixtureA.GetShape(),i=this.m_fixtureB.GetShape();e.Initialize(this.m_manifold,t.GetTransform(),r.m_radius,n.GetTransform(),i.m_radius)},l.prototype.IsTouching=function(){return(this.m_flags&l.e_touchingFlag)==l.e_touchingFlag},l.prototype.IsContinuous=function(){return(this.m_flags&l.e_continuousFlag)==l.e_continuousFlag},l.prototype.SetSensor=function(e){e?this.m_flags|=l.e_sensorFlag:this.m_flags&=~l.e_sensorFlag},l.prototype.IsSensor=function(){return(this.m_flags&l.e_sensorFlag)==l.e_sensorFlag},l.prototype.SetEnabled=function(e){e?this.m_flags|=l.e_enabledFlag:this.m_flags&=~l.e_enabledFlag},l.prototype.IsEnabled=function(){return(this.m_flags&l.e_enabledFlag)==l.e_enabledFlag},l.prototype.GetNext=function(){return this.m_next},l.prototype.GetFixtureA=function(){return this.m_fixtureA},l.prototype.GetFixtureB=function(){return this.m_fixtureB},l.prototype.FlagForFiltering=function(){this.m_flags|=l.e_filterFlag},l.prototype.b2Contact=function(){},l.prototype.Reset=function(e,t){e===undefined&&(e=null),t===undefined&&(t=null),this.m_flags=l.e_enabledFlag;if(!e||!t){this.m_fixtureA=null,this.m_fixtureB=null;return}if(e.IsSensor()||t.IsSensor())this.m_flags|=l.e_sensorFlag;var n=e.GetBody(),r=t.GetBody();if(n.GetType()!=T.b2_dynamicBody||n.IsBullet()||r.GetType()!=T.b2_dynamicBody||r.IsBullet())this.m_flags|=l.e_continuousFlag;this.m_fixtureA=e,this.m_fixtureB=t,this.m_manifold.m_pointCount=0,this.m_prev=null,this.m_next=null,this.m_nodeA.contact=null,this.m_nodeA.prev=null,this.m_nodeA.next=null,this.m_nodeA.other=null,this.m_nodeB.contact=null,this.m_nodeB.prev=null,this.m_nodeB.next=null,this.m_nodeB.other=null},l.prototype.Update=function(e){var t=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=t,this.m_flags|=l.e_enabledFlag;var n=!1,r=(this.m_flags&l.e_touchingFlag)==l.e_touchingFlag,i=this.m_fixtureA.m_body,s=this.m_fixtureB.m_body,o=this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb);if(this.m_flags&l.e_sensorFlag){if(o){var u=this.m_fixtureA.GetShape(),f=this.m_fixtureB.GetShape(),c=i.GetTransform(),h=s.GetTransform();n=a.TestOverlap(u,c,f,h)}this.m_manifold.m_pointCount=0}else{i.GetType()!=T.b2_dynamicBody||i.IsBullet()||s.GetType()!=T.b2_dynamicBody||s.IsBullet()?this.m_flags|=l.e_continuousFlag:this.m_flags&=~l.e_continuousFlag;if(o){this.Evaluate(),n=this.m_manifold.m_pointCount>0;for(var p=0;p<this.m_manifold.m_pointCount;++p){var d=this.m_manifold.m_points[p];d.m_normalImpulse=0,d.m_tangentImpulse=0;var v=d.m_id;for(var m=0;m<this.m_oldManifold.m_pointCount;++m){var g=this.m_oldManifold.m_points[m];if(g.m_id.key==v.key){d.m_normalImpulse=g.m_normalImpulse,d.m_tangentImpulse=g.m_tangentImpulse;break}}}}else this.m_manifold.m_pointCount=0;n!=r&&(i.SetAwake(!0),s.SetAwake(!0))}n?this.m_flags|=l.e_touchingFlag:this.m_flags&=~l.e_touchingFlag,r==0&&n==1&&e.BeginContact(this),r==1&&n==0&&e.EndContact(this),(this.m_flags&l.e_sensorFlag)==0&&e.PreSolve(this,this.m_oldManifold)},l.prototype.Evaluate=function(){},l.prototype.ComputeTOI=function(e,t){return l.s_input.proxyA.Set(this.m_fixtureA.GetShape()),l.s_input.proxyB.Set(this.m_fixtureB.GetShape()),l.s_input.sweepA=e,l.s_input.sweepB=t,l.s_input.tolerance=q.b2_linearSlop,yt.TimeOfImpact(l.s_input)},e.postDefs.push(function(){e.Dynamics.Contacts.b2Contact.e_sensorFlag=1,e.Dynamics.Contacts.b2Contact.e_continuousFlag=2,e.Dynamics.Contacts.b2Contact.e_islandFlag=4,e.Dynamics.Contacts.b2Contact.e_toiFlag=8,e.Dynamics.Contacts.b2Contact.e_touchingFlag=16,e.Dynamics.Contacts.b2Contact.e_enabledFlag=32,e.Dynamics.Contacts.b2Contact.e_filterFlag=64,e.Dynamics.Contacts.b2Contact.s_input=new bt}),c.b2ContactConstraint=function(){this.localPlaneNormal=new V,this.localPoint=new V,this.normal=new V,this.normalMass=new R,this.K=new R},c.prototype.b2ContactConstraint=function(){this.points=new t(q.b2_maxManifoldPoints);for(var e=0;e<q.b2_maxManifoldPoints;e++)this.points[e]=new h},h.b2ContactConstraintPoint=function(){this.localPoint=new V,this.rA=new V,this.rB=new V},p.b2ContactEdge=function(){},d.b2ContactFactory=function(){},d.prototype.b2ContactFactory=function(e){this.m_allocator=e,this.InitializeRegisters()},d.prototype.AddType=function(e,t,n,r){n===undefined&&(n=0),r===undefined&&(r=0),this.m_registers[n][r].createFcn=e,this.m_registers[n][r].destroyFcn=t,this.m_registers[n][r].primary=!0,n!=r&&(this.m_registers[r][n].createFcn=e,this.m_registers[r][n].destroyFcn=t,this.m_registers[r][n].primary=!1)},d.prototype.InitializeRegisters=function(){this.m_registers=new t(a.e_shapeTypeCount);for(var e=0;e<a.e_shapeTypeCount;e++){this.m_registers[e]=new t(a.e_shapeTypeCount);for(var n=0;n<a.e_shapeTypeCount;n++)this.m_registers[e][n]=new v}this.AddType(f.Create,f.Destroy,a.e_circleShape,a.e_circleShape),this.AddType(w.Create,w.Destroy,a.e_polygonShape,a.e_circleShape),this.AddType(S.Create,S.Destroy,a.e_polygonShape,a.e_polygonShape),this.AddType(y.Create,y.Destroy,a.e_edgeShape,a.e_circleShape),this.AddType(E.Create,E.Destroy,a.e_polygonShape,a.e_edgeShape)},d.prototype.Create=function(e,t){var n=parseInt(e.GetType()),r=parseInt(t.GetType()),i=this.m_registers[n][r],s;if(i.pool)return s=i.pool,i.pool=s.m_next,i.poolCount--,s.Reset(e,t),s;var o=i.createFcn;return o!=null?i.primary?(s=o(this.m_allocator),s.Reset(e,t),s):(s=o(this.m_allocator),s.Reset(t,e),s):null},d.prototype.Destroy=function(e){e.m_manifold.m_pointCount>0&&(e.m_fixtureA.m_body.SetAwake(!0),e.m_fixtureB.m_body.SetAwake(!0));var t=parseInt(e.m_fixtureA.GetType()),n=parseInt(e.m_fixtureB.GetType()),r=this.m_registers[t][n];r.poolCount++,e.m_next=r.pool,r.pool=e;var i=r.destroyFcn;i(e,this.m_allocator)},v.b2ContactRegister=function(){},m.b2ContactResult=function(){this.position=new V,this.normal=new V,this.id=new Y},g.b2ContactSolver=function(){this.m_step=new B,this.m_constraints=new t},g.prototype.b2ContactSolver=function(){},g.prototype.Initialize=function(e,t,n,r){n===undefined&&(n=0);var i;this.m_step.Set(e),this.m_allocator=r;var s=0,o,u;this.m_constraintCount=n;while(this.m_constraints.length<this.m_constraintCount)this.m_constraints[this.m_constraints.length]=new c;for(s=0;s<n;++s){i=t[s];var a=i.m_fixtureA,f=i.m_fixtureB,l=a.m_shape,h=f.m_shape,p=l.m_radius,d=h.m_radius,v=a.m_body,m=f.m_body,y=i.GetManifold(),b=q.b2MixFriction(a.GetFriction(),f.GetFriction()),w=q.b2MixRestitution(a.GetRestitution(),f.GetRestitution()),E=v.m_linearVelocity.x,S=v.m_linearVelocity.y,x=m.m_linearVelocity.x,T=m.m_linearVelocity.y,N=v.m_angularVelocity,C=m.m_angularVelocity;q.b2Assert(y.m_pointCount>0),g.s_worldManifold.Initialize(y,v.m_xf,p,m.m_xf,d);var k=g.s_worldManifold.m_normal.x,L=g.s_worldManifold.m_normal.y,A=this.m_constraints[s];A.bodyA=v,A.bodyB=m,A.manifold=y,A.normal.x=k,A.normal.y=L,A.pointCount=y.m_pointCount,A.friction=b,A.restitution=w,A.localPlaneNormal.x=y.m_localPlaneNormal.x,A.localPlaneNormal.y=y.m_localPlaneNormal.y,A.localPoint.x=y.m_localPoint.x,A.localPoint.y=y.m_localPoint.y,A.radius=p+d,A.type=y.m_type;for(var O=0;O<A.pointCount;++O){var M=y.m_points[O],_=A.points[O];_.normalImpulse=M.m_normalImpulse,_.tangentImpulse=M.m_tangentImpulse,_.localPoint.SetV(M.m_localPoint);var D=_.rA.x=g.s_worldManifold.m_points[O].x-v.m_sweep.c.x,P=_.rA.y=g.s_worldManifold.m_points[O].y-v.m_sweep.c.y,H=_.rB.x=g.s_worldManifold.m_points[O].x-m.m_sweep.c.x,B=_.rB.y=g.s_worldManifold.m_points[O].y-m.m_sweep.c.y,j=D*L-P*k,F=H*L-B*k;j*=j,F*=F;var I=v.m_invMass+m.m_invMass+v.m_invI*j+m.m_invI*F;_.normalMass=1/I;var R=v.m_mass*v.m_invMass+m.m_mass*m.m_invMass;R+=v.m_mass*v.m_invI*j+m.m_mass*m.m_invI*F,_.equalizedMass=1/R;var U=L,z=-k,W=D*z-P*U,X=H*z-B*U;W*=W,X*=X;var V=v.m_invMass+m.m_invMass+v.m_invI*W+m.m_invI*X;_.tangentMass=1/V,_.velocityBias=0;var $=x+ -C*B-E- -N*P,J=T+C*H-S-N*D,K=A.normal.x*$+A.normal.y*J;K<-q.b2_velocityThreshold&&(_.velocityBias+=-A.restitution*K)}if(A.pointCount==2){var Q=A.points[0],G=A.points[1],Y=v.m_invMass,Z=v.m_invI,et=m.m_invMass,tt=m.m_invI,nt=Q.rA.x*L-Q.rA.y*k,rt=Q.rB.x*L-Q.rB.y*k,it=G.rA.x*L-G.rA.y*k,st=G.rB.x*L-G.rB.y*k,ot=Y+et+Z*nt*nt+tt*rt*rt,ut=Y+et+Z*it*it+tt*st*st,at=Y+et+Z*nt*it+tt*rt*st,ft=100;ot*ot<ft*(ot*ut-at*at)?(A.K.col1.Set(ot,at),A.K.col2.Set(at,ut),A.K.GetInverse(A.normalMass)):A.pointCount=1}}},g.prototype.InitVelocityConstraints=function(e){var t,n,r;for(var i=0;i<this.m_constraintCount;++i){var s=this.m_constraints[i],o=s.bodyA,u=s.bodyB,a=o.m_invMass,f=o.m_invI,l=u.m_invMass,c=u.m_invI,h=s.normal.x,p=s.normal.y,d=p,v=-h,m=0,g=0,y=0;if(e.warmStarting){y=s.pointCount;for(g=0;g<y;++g){var b=s.points[g];b.normalImpulse*=e.dtRatio,b.tangentImpulse*=e.dtRatio;var w=b.normalImpulse*h+b.tangentImpulse*d,E=b.normalImpulse*p+b.tangentImpulse*v;o.m_angularVelocity-=f*(b.rA.x*E-b.rA.y*w),o.m_linearVelocity.x-=a*w,o.m_linearVelocity.y-=a*E,u.m_angularVelocity+=c*(b.rB.x*E-b.rB.y*w),u.m_linearVelocity.x+=l*w,u.m_linearVelocity.y+=l*E}}else{y=s.pointCount;for(g=0;g<y;++g){var S=s.points[g];S.normalImpulse=0,S.tangentImpulse=0}}}},g.prototype.SolveVelocityConstraints=function(){var e=0,t,n=0,r=0,i=0,s=0,o=0,u=0,a=0,f=0,l=0,c=0,h=0,p=0,d=0,v=0,m=0,g=0,y=0,b=0,w=0,E,S;for(var x=0;x<this.m_constraintCount;++x){var T=this.m_constraints[x],N=T.bodyA,C=T.bodyB,k=N.m_angularVelocity,L=C.m_angularVelocity,A=N.m_linearVelocity,O=C.m_linearVelocity,M=N.m_invMass,_=N.m_invI,D=C.m_invMass,P=C.m_invI,H=T.normal.x,B=T.normal.y,j=B,F=-H,I=T.friction,q=0;for(e=0;e<T.pointCount;e++)t=T.points[e],o=O.x-L*t.rB.y-A.x+k*t.rA.y,u=O.y+L*t.rB.x-A.y-k*t.rA.x,f=o*j+u*F,l=t.tangentMass*-f,c=I*t.normalImpulse,h=z.Clamp(t.tangentImpulse+l,-c,c),l=h-t.tangentImpulse,p=l*j,d=l*F,A.x-=M*p,A.y-=M*d,k-=_*(t.rA.x*d-t.rA.y*p),O.x+=D*p,O.y+=D*d,L+=P*(t.rB.x*d-t.rB.y*p),t.tangentImpulse=h;var R=parseInt(T.pointCount);if(T.pointCount==1)t=T.points[0],o=O.x+ -L*t.rB.y-A.x- -k*t.rA.y,u=O.y+L*t.rB.x-A.y-k*t.rA.x,a=o*H+u*B,l=-t.normalMass*(a-t.velocityBias),h=t.normalImpulse+l,h=h>0?h:0,l=h-t.normalImpulse,p=l*H,d=l*B,A.x-=M*p,A.y-=M*d,k-=_*(t.rA.x*d-t.rA.y*p),O.x+=D*p,O.y+=D*d,L+=P*(t.rB.x*d-t.rB.y*p),t.normalImpulse=h;else{var U=T.points[0],W=T.points[1],X=U.normalImpulse,V=W.normalImpulse,$=O.x-L*U.rB.y-A.x+k*U.rA.y,J=O.y+L*U.rB.x-A.y-k*U.rA.x,K=O.x-L*W.rB.y-A.x+k*W.rA.y,Q=O.y+L*W.rB.x-A.y-k*W.rA.x,G=$*H+J*B,Y=K*H+Q*B,Z=G-U.velocityBias,et=Y-W.velocityBias;E=T.K,Z-=E.col1.x*X+E.col2.x*V,et-=E.col1.y*X+E.col2.y*V;var tt=.001;for(;;){E=T.normalMass;var nt=-(E.col1.x*Z+E.col2.x*et),rt=-(E.col1.y*Z+E.col2.y*et);if(nt>=0&&rt>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}nt=-U.normalMass*Z,rt=0,G=0,Y=T.K.col1.y*nt+et;if(nt>=0&&Y>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}nt=0,rt=-W.normalMass*et,G=T.K.col2.x*rt+Z,Y=0;if(rt>=0&&G>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}nt=0,rt=0,G=Z,Y=et;if(G>=0&&Y>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}break}}N.m_angularVelocity=k,C.m_angularVelocity=L}},g.prototype.FinalizeVelocityConstraints=function(){for(var e=0;e<this.m_constraintCount;++e){var t=this.m_constraints[e],n=t.manifold;for(var r=0;r<t.pointCount;++r){var i=n.m_points[r],s=t.points[r];i.m_normalImpulse=s.normalImpulse,i.m_tangentImpulse=s.tangentImpulse}}},g.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0;for(var n=0;n<this.m_constraintCount;n++){var r=this.m_constraints[n],i=r.bodyA,s=r.bodyB,o=i.m_mass*i.m_invMass,u=i.m_mass*i.m_invI,a=s.m_mass*s.m_invMass,f=s.m_mass*s.m_invI;g.s_psm.Initialize(r);var l=g.s_psm.m_normal;for(var c=0;c<r.pointCount;c++){var h=r.points[c],p=g.s_psm.m_points[c],d=g.s_psm.m_separations[c],v=p.x-i.m_sweep.c.x,m=p.y-i.m_sweep.c.y,y=p.x-s.m_sweep.c.x,b=p.y-s.m_sweep.c.y;t=t<d?t:d;var w=z.Clamp(e*(d+q.b2_linearSlop),-q.b2_maxLinearCorrection,0),E=-h.equalizedMass*w,S=E*l.x,x=E*l.y;i.m_sweep.c.x-=o*S,i.m_sweep.c.y-=o*x,i.m_sweep.a-=u*(v*x-m*S),i.SynchronizeTransform(),s.m_sweep.c.x+=a*S,s.m_sweep.c.y+=a*x,s.m_sweep.a+=f*(y*x-b*S),s.SynchronizeTransform()}}return t>-1.5*q.b2_linearSlop},e.postDefs.push(function(){e.Dynamics.Contacts.b2ContactSolver.s_worldManifold=new wt,e.Dynamics.Contacts.b2ContactSolver.s_psm=new x}),e.inherit(y,e.Dynamics.Contacts.b2Contact),y.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,y.b2EdgeAndCircleContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},y.Create=function(e){return new y},y.Destroy=function(e,t){},y.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t)},y.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof s?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof r?this.m_fixtureB.GetShape():null,t.m_xf)},y.prototype.b2CollideEdgeAndCircle=function(e,t,n,r,i){},e.inherit(b,e.Dynamics.Contacts.b2Contact),b.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,b.b2NullContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},b.prototype.b2NullContact=function(){this.__super.b2Contact.call(this)},b.prototype.Evaluate=function(){},e.inherit(w,e.Dynamics.Contacts.b2Contact),w.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,w.b2PolyAndCircleContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},w.Create=function(e){return new w},w.Destroy=function(e,t){},w.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t),q.b2Assert(e.GetType()==a.e_polygonShape),q.b2Assert(t.GetType()==a.e_circleShape)},w.prototype.Evaluate=function(){var e=this.m_fixtureA.m_body,t=this.m_fixtureB.m_body;G.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof u?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof r?this.m_fixtureB.GetShape():null,t.m_xf)},e.inherit(E,e.Dynamics.Contacts.b2Contact),E.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,E.b2PolyAndEdgeContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},E.Create=function(e){return new E},E.Destroy=function(e,t){},E.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t),q.b2Assert(e.GetType()==a.e_polygonShape),q.b2Assert(t.GetType()==a.e_edgeShape)},E.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape()instanceof u?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof s?this.m_fixtureB.GetShape():null,t.m_xf)},E.prototype.b2CollidePolyAndEdge=function(e,t,n,r,i){},e.inherit(S,e.Dynamics.Contacts.b2Contact),S.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,S.b2PolygonContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},S.Create=function(e){return new S},S.Destroy=function(e,t){},S.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t)},S.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();G.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape()instanceof u?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof u?this.m_fixtureB.GetShape():null,t.m_xf)},x.b2PositionSolverManifold=function(){},x.prototype.b2PositionSolverManifold=function(){this.m_normal=new V,this.m_separations=new n(q.b2_maxManifoldPoints),this.m_points=new t(q.b2_maxManifoldPoints);for(var e=0;e<q.b2_maxManifoldPoints;e++)this.m_points[e]=new V},x.prototype.Initialize=function(e){q.b2Assert(e.pointCount>0);var t=0,n=0,r=0,i,s,o=0,u=0;switch(e.type){case at.e_circles:i=e.bodyA.m_xf.R,s=e.localPoint;var a=e.bodyA.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),f=e.bodyA.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y);i=e.bodyB.m_xf.R,s=e.points[0].localPoint;var l=e.bodyB.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),c=e.bodyB.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),h=l-a,p=c-f,d=h*h+p*p;if(d>Number.MIN_VALUE*Number.MIN_VALUE){var v=Math.sqrt(d);this.m_normal.x=h/v,this.m_normal.y=p/v}else this.m_normal.x=1,this.m_normal.y=0;this.m_points[0].x=.5*(a+l),this.m_points[0].y=.5*(f+c),this.m_separations[0]=h*this.m_normal.x+p*this.m_normal.y-e.radius;break;case at.e_faceA:i=e.bodyA.m_xf.R,s=e.localPlaneNormal,this.m_normal.x=i.col1.x*s.x+i.col2.x*s.y,this.m_normal.y=i.col1.y*s.x+i.col2.y*s.y,i=e.bodyA.m_xf.R,s=e.localPoint,o=e.bodyA.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),u=e.bodyA.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),i=e.bodyB.m_xf.R;for(t=0;t<e.pointCount;++t)s=e.points[t].localPoint,n=e.bodyB.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),r=e.bodyB.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),this.m_separations[t]=(n-o)*this.m_normal.x+(r-u)*this.m_normal.y-e.radius,this.m_points[t].x=n,this.m_points[t].y=r;break;case at.e_faceB:i=e.bodyB.m_xf.R,s=e.localPlaneNormal,this.m_normal.x=i.col1.x*s.x+i.col2.x*s.y,this.m_normal.y=i.col1.y*s.x+i.col2.y*s.y,i=e.bodyB.m_xf.R,s=e.localPoint,o=e.bodyB.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),u=e.bodyB.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),i=e.bodyA.m_xf.R;for(t=0;t<e.pointCount;++t)s=e.points[t].localPoint,n=e.bodyA.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),r=e.bodyA.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),this.m_separations[t]=(n-o)*this.m_normal.x+(r-u)*this.m_normal.y-e.radius,this.m_points[t].Set(n,r);this.m_normal.x*=-1,this.m_normal.y*=-1}},e.postDefs.push(function(){e.Dynamics.Contacts.b2PositionSolverManifold.circlePointA=new V,e.Dynamics.Contacts.b2PositionSolverManifold.circlePointB=new V})}(),function(){var t=e.Dynamics.b2Body,n=e.Dynamics.b2BodyDef,r=e.Dynamics.b2ContactFilter,i=e.Dynamics.b2ContactImpulse,s=e.Dynamics.b2ContactListener,o=e.Dynamics.b2ContactManager,u=e.Dynamics.b2DebugDraw,a=e.Dynamics.b2DestructionListener,f=e.Dynamics.b2FilterData,l=e.Dynamics.b2Fixture,c=e.Dynamics.b2FixtureDef,h=e.Dynamics.b2Island,p=e.Dynamics.b2TimeStep,d=e.Dynamics.b2World,v=e.Common.Math.b2Mat22,m=e.Common.Math.b2Mat33,g=e.Common.Math.b2Math,y=e.Common.Math.b2Sweep,b=e.Common.Math.b2Transform,w=e.Common.Math.b2Vec2,E=e.Common.Math.b2Vec3,S=e.Common.b2Color,x=e.Common.b2internal,T=e.Common.b2Settings,N=e.Collision.Shapes.b2CircleShape,C=e.Collision.Shapes.b2EdgeChainDef,k=e.Collision.Shapes.b2EdgeShape,L=e.Collision.Shapes.b2MassData,A=e.Collision.Shapes.b2PolygonShape,O=e.Collision.Shapes.b2Shape,M=e.Dynamics.Controllers.b2BuoyancyController,_=e.Dynamics.Controllers.b2ConstantAccelController,D=e.Dynamics.Controllers.b2ConstantForceController,P=e.Dynamics.Controllers.b2Controller,H=e.Dynamics.Controllers.b2ControllerEdge,B=e.Dynamics.Controllers.b2GravityController,j=e.Dynamics.Controllers.b2TensorDampingController;e.inherit(M,e.Dynamics.Controllers.b2Controller),M.prototype.__super=e.Dynamics.Controllers.b2Controller.prototype,M.b2BuoyancyController=function(){e.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments),this.normal=new w(0,-1),this.offset=0,this.density=0,this.velocity=new w(0,0),this.linearDrag=2,this.angularDrag=1,this.useDensity=!1,this.useWorldGravity=!0,this.gravity=null},M.prototype.Step=function(e){if(!this.m_bodyList)return;this.useWorldGravity&&(this.gravity=this.GetWorld().GetGravity().Copy());for(var t=this.m_bodyList;t;t=t.nextBody){var n=t.body;if(n.IsAwake()==0)continue;var r=new w,i=new w,s=0,o=0;for(var u=n.GetFixtureList();u;u=u.GetNext()){var a=new w,f=u.GetShape().ComputeSubmergedArea(this.normal,this.offset,n.GetTransform(),a);s+=f,r.x+=f*a.x,r.y+=f*a.y;var l=0;this.useDensity?l=1:l=1,o+=f*l,i.x+=f*a.x*l,i.y+=f*a.y*l}r.x/=s,r.y/=s,i.x/=o,i.y/=o;if(s<Number.MIN_VALUE)continue;var c=this.gravity.GetNegative();c.Multiply(this.density*s),n.ApplyForce(c,i);var h=n.GetLinearVelocityFromWorldPoint(r);h.Subtract(this.velocity),h.Multiply(-this.linearDrag*s),n.ApplyForce(h,r),n.ApplyTorque(-n.GetInertia()/n.GetMass()*s*n.GetAngularVelocity()*this.angularDrag)}},M.prototype.Draw=function(e){var t=1e3,n=new w,r=new w;n.x=this.normal.x*this.offset+this.normal.y*t,n.y=this.normal.y*this.offset-this.normal.x*t,r.x=this.normal.x*this.offset-this.normal.y*t,r.y=this.normal.y*this.offset+this.normal.x*t;var i=new S(0,0,1);e.DrawSegment(n,r,i)},e.inherit(_,e.Dynamics.Controllers.b2Controller),_.prototype.__super=e.Dynamics.Controllers.b2Controller.prototype,_.b2ConstantAccelController=function(){e.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments),this.A=new w(0,0)},_.prototype.Step=function(e){var t=new w(this.A.x*e.dt,this.A.y*e.dt);for(var n=this.m_bodyList;n;n=n.nextBody){var r=n.body;if(!r.IsAwake())continue;r.SetLinearVelocity(new w(r.GetLinearVelocity().x+t.x,r.GetLinearVelocity().y+t.y))}},e.inherit(D,e.Dynamics.Controllers.b2Controller),D.prototype.__super=e.Dynamics.Controllers.b2Controller.prototype,D.b2ConstantForceController=function(){e.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments),this.F=new w(0,0)},D.prototype.Step=function(e){for(var t=this.m_bodyList;t;t=t.nextBody){var n=t.body;if(!n.IsAwake())continue;n.ApplyForce(this.F,n.GetWorldCenter())}},P.b2Controller=function(){},P.prototype.Step=function(e){},P.prototype.Draw=function(e){},P.prototype.AddBody=function(e){var t=new H;t.controller=this,t.body=e,t.nextBody=this.m_bodyList,t.prevBody=null,this.m_bodyList=t,t.nextBody&&(t.nextBody.prevBody=t),this.m_bodyCount++,t.nextController=e.m_controllerList,t.prevController=null,e.m_controllerList=t,t.nextController&&(t.nextController.prevController=t),e.m_controllerCount++},P.prototype.RemoveBody=function(e){var t=e.m_controllerList;while(t&&t.controller!=this)t=t.nextController;t.prevBody&&(t.prevBody.nextBody=t.nextBody),t.nextBody&&(t.nextBody.prevBody=t.prevBody),t.nextController&&(t.nextController.prevController=t.prevController),t.prevController&&(t.prevController.nextController=t.nextController),this.m_bodyList==t&&(this.m_bodyList=t.nextBody),e.m_controllerList==t&&(e.m_controllerList=t.nextController),e.m_controllerCount--,this.m_bodyCount--},P.prototype.Clear=function(){while(this.m_bodyList)this.RemoveBody(this.m_bodyList.body)},P.prototype.GetNext=function(){return this.m_next},P.prototype.GetWorld=function(){return this.m_world},P.prototype.GetBodyList=function(){return this.m_bodyList},H.b2ControllerEdge=function(){},e.inherit(B,e.Dynamics.Controllers.b2Controller),B.prototype.__super=e.Dynamics.Controllers.b2Controller.prototype,B.b2GravityController=function(){e.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments),this.G=1,this.invSqr=!0},B.prototype.Step=function(e){var t=null,n=null,r=null,i=0,s=null,o=null,u=null,a=0,f=0,l=0,c=null;if(this.invSqr)for(t=this.m_bodyList;t;t=t.nextBody){n=t.body,r=n.GetWorldCenter(),i=n.GetMass();for(s=this.m_bodyList;s!=t;s=s.nextBody){o=s.body,u=o.GetWorldCenter(),a=u.x-r.x,f=u.y-r.y,l=a*a+f*f;if(l<Number.MIN_VALUE)continue;c=new w(a,f),c.Multiply(this.G/l/Math.sqrt(l)*i*o.GetMass()),n.IsAwake()&&n.ApplyForce(c,r),c.Multiply(-1),o.IsAwake()&&o.ApplyForce(c,u)}}else for(t=this.m_bodyList;t;t=t.nextBody){n=t.body,r=n.GetWorldCenter(),i=n.GetMass();for(s=this.m_bodyList;s!=t;s=s.nextBody){o=s.body,u=o.GetWorldCenter(),a=u.x-r.x,f=u.y-r.y,l=a*a+f*f;if(l<Number.MIN_VALUE)continue;c=new w(a,f),c.Multiply(this.G/l*i*o.GetMass()),n.IsAwake()&&n.ApplyForce(c,r),c.Multiply(-1),o.IsAwake()&&o.ApplyForce(c,u)}}},e.inherit(j,e.Dynamics.Controllers.b2Controller),j.prototype.__super=e.Dynamics.Controllers.b2Controller.prototype,j.b2TensorDampingController=function(){e.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments),this.T=new v,this.maxTimestep=0},j.prototype.SetAxisAligned=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.T.col1.x=-e,this.T.col1.y=0,this.T.col2.x=0,this.T.col2.y=-t,e>0||t>0?this.maxTimestep=1/Math.max(e,t):this.maxTimestep=0},j.prototype.Step=function(e){var t=e.dt;if(t<=Number.MIN_VALUE)return;t>this.maxTimestep&&this.maxTimestep>0&&(t=this.maxTimestep);for(var n=this.m_bodyList;n;n=n.nextBody){var r=n.body;if(!r.IsAwake())continue;var i=r.GetWorldVector(g.MulMV(this.T,r.GetLocalVector(r.GetLinearVelocity())));r.SetLinearVelocity(new w(r.GetLinearVelocity().x+i.x*t,r.GetLinearVelocity().y+i.y*t))}}}(),function(){var t=e.Common.b2Color,n=e.Common.b2internal,r=e.Common.b2Settings,i=e.Common.Math.b2Mat22,s=e.Common.Math.b2Mat33,o=e.Common.Math.b2Math,u=e.Common.Math.b2Sweep,a=e.Common.Math.b2Transform,f=e.Common.Math.b2Vec2,l=e.Common.Math.b2Vec3,c=e.Dynamics.Joints.b2DistanceJoint,h=e.Dynamics.Joints.b2DistanceJointDef,p=e.Dynamics.Joints.b2FrictionJoint,d=e.Dynamics.Joints.b2FrictionJointDef,v=e.Dynamics.Joints.b2GearJoint,m=e.Dynamics.Joints.b2GearJointDef,g=e.Dynamics.Joints.b2Jacobian,y=e.Dynamics.Joints.b2Joint,b=e.Dynamics.Joints.b2JointDef,w=e.Dynamics.Joints.b2JointEdge,E=e.Dynamics.Joints.b2LineJoint,S=e.Dynamics.Joints.b2LineJointDef,x=e.Dynamics.Joints.b2MouseJoint,T=e.Dynamics.Joints.b2MouseJointDef,N=e.Dynamics.Joints.b2PrismaticJoint,C=e.Dynamics.Joints.b2PrismaticJointDef,k=e.Dynamics.Joints.b2PulleyJoint,L=e.Dynamics.Joints.b2PulleyJointDef,A=e.Dynamics.Joints.b2RevoluteJoint,O=e.Dynamics.Joints.b2RevoluteJointDef,M=e.Dynamics.Joints.b2WeldJoint,_=e.Dynamics.Joints.b2WeldJointDef,D=e.Dynamics.b2Body,P=e.Dynamics.b2BodyDef,H=e.Dynamics.b2ContactFilter,B=e.Dynamics.b2ContactImpulse,j=e.Dynamics.b2ContactListener,F=e.Dynamics.b2ContactManager,I=e.Dynamics.b2DebugDraw,q=e.Dynamics.b2DestructionListener,R=e.Dynamics.b2FilterData,U=e.Dynamics.b2Fixture,z=e.Dynamics.b2FixtureDef,W=e.Dynamics.b2Island,X=e.Dynamics.b2TimeStep,V=e.Dynamics.b2World;e.inherit(c,e.Dynamics.Joints.b2Joint),c.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,c.b2DistanceJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_u=new f},c.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},c.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},c.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse*this.m_u.x,e*this.m_impulse*this.m_u.y)},c.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},c.prototype.GetLength=function(){return this.m_length},c.prototype.SetLength=function(e){e===undefined&&(e=0),this.m_length=e},c.prototype.GetFrequency=function(){return this.m_frequencyHz},c.prototype.SetFrequency=function(e){e===undefined&&(e=0),this.m_frequencyHz=e},c.prototype.GetDampingRatio=function(){return this.m_dampingRatio},c.prototype.SetDampingRatio=function(e){e===undefined&&(e=0),this.m_dampingRatio=e},c.prototype.b2DistanceJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_length=e.length,this.m_frequencyHz=e.frequencyHz,this.m_dampingRatio=e.dampingRatio,this.m_impulse=0,this.m_gamma=0,this.m_bias=0},c.prototype.InitVelocityConstraints=function(e){var t,n=0,i=this.m_bodyA,s=this.m_bodyB;t=i.m_xf.R;var o=this.m_localAnchor1.x-i.m_sweep.localCenter.x,u=this.m_localAnchor1.y-i.m_sweep.localCenter.y;n=t.col1.x*o+t.col2.x*u,u=t.col1.y*o+t.col2.y*u,o=n,t=s.m_xf.R;var a=this.m_localAnchor2.x-s.m_sweep.localCenter.x,f=this.m_localAnchor2.y-s.m_sweep.localCenter.y;n=t.col1.x*a+t.col2.x*f,f=t.col1.y*a+t.col2.y*f,a=n,this.m_u.x=s.m_sweep.c.x+a-i.m_sweep.c.x-o,this.m_u.y=s.m_sweep.c.y+f-i.m_sweep.c.y-u;var l=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);l>r.b2_linearSlop?this.m_u.Multiply(1/l):this.m_u.SetZero();var c=o*this.m_u.y-u*this.m_u.x,h=a*this.m_u.y-f*this.m_u.x,p=i.m_invMass+i.m_invI*c*c+s.m_invMass+s.m_invI*h*h;this.m_mass=p!=0?1/p:0;if(this.m_frequencyHz>0){var d=l-this.m_length,v=2*Math.PI*this.m_frequencyHz,m=2*this.m_mass*this.m_dampingRatio*v,g=this.m_mass*v*v;this.m_gamma=e.dt*(m+e.dt*g),this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0,this.m_bias=d*e.dt*g*this.m_gamma,this.m_mass=p+this.m_gamma,this.m_mass=this.m_mass!=0?1/this.m_mass:0}if(e.warmStarting){this.m_impulse*=e.dtRatio;var y=this.m_impulse*this.m_u.x,b=this.m_impulse*this.m_u.y;i.m_linearVelocity.x-=i.m_invMass*y,i.m_linearVelocity.y-=i.m_invMass*b,i.m_angularVelocity-=i.m_invI*(o*b-u*y),s.m_linearVelocity.x+=s.m_invMass*y,s.m_linearVelocity.y+=s.m_invMass*b,s.m_angularVelocity+=s.m_invI*(a*b-f*y)}else this.m_impulse=0},c.prototype.SolveVelocityConstraints=function(e){var t,n=this.m_bodyA,r=this.m_bodyB;t=n.m_xf.R;var i=this.m_localAnchor1.x-n.m_sweep.localCenter.x,s=this.m_localAnchor1.y-n.m_sweep.localCenter.y,o=t.col1.x*i+t.col2.x*s;s=t.col1.y*i+t.col2.y*s,i=o,t=r.m_xf.R;var u=this.m_localAnchor2.x-r.m_sweep.localCenter.x,a=this.m_localAnchor2.y-r.m_sweep.localCenter.y;o=t.col1.x*u+t.col2.x*a,a=t.col1.y*u+t.col2.y*a,u=o;var f=n.m_linearVelocity.x+ -n.m_angularVelocity*s,l=n.m_linearVelocity.y+n.m_angularVelocity*i,c=r.m_linearVelocity.x+ -r.m_angularVelocity*a,h=r.m_linearVelocity.y+r.m_angularVelocity*u,p=this.m_u.x*(c-f)+this.m_u.y*(h-l),d=-this.m_mass*(p+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=d;var v=d*this.m_u.x,m=d*this.m_u.y;n.m_linearVelocity.x-=n.m_invMass*v,n.m_linearVelocity.y-=n.m_invMass*m,n.m_angularVelocity-=n.m_invI*(i*m-s*v),r.m_linearVelocity.x+=r.m_invMass*v,r.m_linearVelocity.y+=r.m_invMass*m,r.m_angularVelocity+=r.m_invI*(u*m-a*v)},c.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t;if(this.m_frequencyHz>0)return!0;var n=this.m_bodyA,i=this.m_bodyB;t=n.m_xf.R;var s=this.m_localAnchor1.x-n.m_sweep.localCenter.x,u=this.m_localAnchor1.y-n.m_sweep.localCenter.y,a=t.col1.x*s+t.col2.x*u;u=t.col1.y*s+t.col2.y*u,s=a,t=i.m_xf.R;var f=this.m_localAnchor2.x-i.m_sweep.localCenter.x,l=this.m_localAnchor2.y-i.m_sweep.localCenter.y;a=t.col1.x*f+t.col2.x*l,l=t.col1.y*f+t.col2.y*l,f=a;var c=i.m_sweep.c.x+f-n.m_sweep.c.x-s,h=i.m_sweep.c.y+l-n.m_sweep.c.y-u,p=Math.sqrt(c*c+h*h);c/=p,h/=p;var d=p-this.m_length;d=o.Clamp(d,-r.b2_maxLinearCorrection,r.b2_maxLinearCorrection);var v=-this.m_mass*d;this.m_u.Set(c,h);var m=v*this.m_u.x,g=v*this.m_u.y;return n.m_sweep.c.x-=n.m_invMass*m,n.m_sweep.c.y-=n.m_invMass*g,n.m_sweep.a-=n.m_invI*(s*g-u*m),i.m_sweep.c.x+=i.m_invMass*m,i.m_sweep.c.y+=i.m_invMass*g,i.m_sweep.a+=i.m_invI*(f*g-l*m),n.SynchronizeTransform(),i.SynchronizeTransform(),o.Abs(d)<r.b2_linearSlop},e.inherit(h,e.Dynamics.Joints.b2JointDef),h.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,h.b2DistanceJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},h.prototype.b2DistanceJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_distanceJoint,this.length=1,this.frequencyHz=0,this.dampingRatio=0},h.prototype.Initialize=function(e,t,n,r){this.bodyA=e,this.bodyB=t,this.localAnchorA.SetV(this.bodyA.GetLocalPoint(n)),this.localAnchorB.SetV(this.bodyB.GetLocalPoint(r));var i=r.x-n.x,s=r.y-n.y;this.length=Math.sqrt(i*i+s*s),this.frequencyHz=0,this.dampingRatio=0},e.inherit(p,e.Dynamics.Joints.b2Joint),p.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,p.b2FrictionJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchorA=new f,this.m_localAnchorB=new f,this.m_linearMass=new i,this.m_linearImpulse=new f},p.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},p.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},p.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_linearImpulse.x,e*this.m_linearImpulse.y)},p.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_angularImpulse},p.prototype.SetMaxForce=function(e){e===undefined&&(e=0),this.m_maxForce=e},p.prototype.GetMaxForce=function(){return this.m_maxForce},p.prototype.SetMaxTorque=function(e){e===undefined&&(e=0),this.m_maxTorque=e},p.prototype.GetMaxTorque=function(){return this.m_maxTorque},p.prototype.b2FrictionJoint=function(e){this.__super.b2Joint.call(this,e),this.m_localAnchorA.SetV(e.localAnchorA),this.m_localAnchorB.SetV(e.localAnchorB),this.m_linearMass.SetZero(),this.m_angularMass=0,this.m_linearImpulse.SetZero(),this.m_angularImpulse=0,this.m_maxForce=e.maxForce,this.m_maxTorque=e.maxTorque},p.prototype.InitVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,s=this.m_bodyB;t=r.m_xf.R;var o=this.m_localAnchorA.x-r.m_sweep.localCenter.x,u=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*o+t.col2.x*u,u=t.col1.y*o+t.col2.y*u,o=n,t=s.m_xf.R;var a=this.m_localAnchorB.x-s.m_sweep.localCenter.x,f=this.m_localAnchorB.y-s.m_sweep.localCenter.y;n=t.col1.x*a+t.col2.x*f,f=t.col1.y*a+t.col2.y*f,a=n;var l=r.m_invMass,c=s.m_invMass,h=r.m_invI,p=s.m_invI,d=new i;d.col1.x=l+c,d.col2.x=0,d.col1.y=0,d.col2.y=l+c,d.col1.x+=h*u*u,d.col2.x+=-h*o*u,d.col1.y+=-h*o*u,d.col2.y+=h*o*o,d.col1.x+=p*f*f,d.col2.x+=-p*a*f,d.col1.y+=-p*a*f,d.col2.y+=p*a*a,d.GetInverse(this.m_linearMass),this.m_angularMass=h+p,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass);if(e.warmStarting){this.m_linearImpulse.x*=e.dtRatio,this.m_linearImpulse.y*=e.dtRatio,this.m_angularImpulse*=e.dtRatio;var v=this.m_linearImpulse;r.m_linearVelocity.x-=l*v.x,r.m_linearVelocity.y-=l*v.y,r.m_angularVelocity-=h*(o*v.y-u*v.x+this.m_angularImpulse),s.m_linearVelocity.x+=c*v.x,s.m_linearVelocity.y+=c*v.y,s.m_angularVelocity+=p*(a*v.y-f*v.x+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0},p.prototype.SolveVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,i=this.m_bodyB,s=r.m_linearVelocity,u=r.m_angularVelocity,a=i.m_linearVelocity,l=i.m_angularVelocity,c=r.m_invMass,h=i.m_invMass,p=r.m_invI,d=i.m_invI;t=r.m_xf.R;var v=this.m_localAnchorA.x-r.m_sweep.localCenter.x,m=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*v+t.col2.x*m,m=t.col1.y*v+t.col2.y*m,v=n,t=i.m_xf.R;var g=this.m_localAnchorB.x-i.m_sweep.localCenter.x,y=this.m_localAnchorB.y-i.m_sweep.localCenter.y;n=t.col1.x*g+t.col2.x*y,y=t.col1.y*g+t.col2.y*y,g=n;var b=0,w=l-u,E=-this.m_angularMass*w,S=this.m_angularImpulse;b=e.dt*this.m_maxTorque,this.m_angularImpulse=o.Clamp(this.m_angularImpulse+E,-b,b),E=this.m_angularImpulse-S,u-=p*E,l+=d*E;var x=a.x-l*y-s.x+u*m,T=a.y+l*g-s.y-u*v,N=o.MulMV(this.m_linearMass,new f(-x,-T)),C=this.m_linearImpulse.Copy();this.m_linearImpulse.Add(N),b=e.dt*this.m_maxForce,this.m_linearImpulse.LengthSquared()>b*b&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(b)),N=o.SubtractVV(this.m_linearImpulse,C),s.x-=c*N.x,s.y-=c*N.y,u-=p*(v*N.y-m*N.x),a.x+=h*N.x,a.y+=h*N.y,l+=d*(g*N.y-y*N.x),r.m_angularVelocity=u,i.m_angularVelocity=l},p.prototype.SolvePositionConstraints=function(e){return e===undefined&&(e=0),!0},e.inherit(d,e.Dynamics.Joints.b2JointDef),d.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,d.b2FrictionJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},d.prototype.b2FrictionJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_frictionJoint,this.maxForce=0,this.maxTorque=0},d.prototype.Initialize=function(e,t,n){this.bodyA=e,this.bodyB=t,this.localAnchorA.SetV(this.bodyA.GetLocalPoint(n)),this.localAnchorB.SetV(this.bodyB.GetLocalPoint(n))},e.inherit(v,e.Dynamics.Joints.b2Joint),v.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,v.b2GearJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_groundAnchor1=new f,this.m_groundAnchor2=new f,this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_J=new g},v.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},v.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},v.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse*this.m_J.linearB.x,e*this.m_impulse*this.m_J.linearB.y)},v.prototype.GetReactionTorque=function(e){e===undefined&&(e=0);var t=this.m_bodyB.m_xf.R,n=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,r=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,i=t.col1.x*n+t.col2.x*r;r=t.col1.y*n+t.col2.y*r,n=i;var s=this.m_impulse*this.m_J.linearB.x,o=this.m_impulse*this.m_J.linearB.y;return e*(this.m_impulse*this.m_J.angularB-n*o+r*s)},v.prototype.GetRatio=function(){return this.m_ratio},v.prototype.SetRatio=function(e){e===undefined&&(e=0),this.m_ratio=e},v.prototype.b2GearJoint=function(e){this.__super.b2Joint.call(this,e);var t=parseInt(e.joint1.m_type),n=parseInt(e.joint2.m_type);this.m_revolute1=null,this.m_prismatic1=null,this.m_revolute2=null,this.m_prismatic2=null;var r=0,i=0;this.m_ground1=e.joint1.GetBodyA(),this.m_bodyA=e.joint1.GetBodyB(),t==y.e_revoluteJoint?(this.m_revolute1=e.joint1 instanceof A?e.joint1:null,this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2),r=this.m_revolute1.GetJointAngle()):(this.m_prismatic1=e.joint1 instanceof N?e.joint1:null,this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2),r=this.m_prismatic1.GetJointTranslation()),this.m_ground2=e.joint2.GetBodyA(),this.m_bodyB=e.joint2.GetBodyB(),n==y.e_revoluteJoint?(this.m_revolute2=e.joint2 instanceof A?e.joint2:null,this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2),i=this.m_revolute2.GetJointAngle()):(this.m_prismatic2=e.joint2 instanceof N?e.joint2:null,this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2),i=this.m_prismatic2.GetJointTranslation()),this.m_ratio=e.ratio,this.m_constant=r+this.m_ratio*i,this.m_impulse=0},v.prototype.InitVelocityConstraints=function(e){var t=this.m_ground1,n=this.m_ground2,r=this.m_bodyA,i=this.m_bodyB,s=0,o=0,u=0,a=0,f,l,c=0,h=0,p=0;this.m_J.SetZero(),this.m_revolute1?(this.m_J.angularA=-1,p+=r.m_invI):(f=t.m_xf.R,l=this.m_prismatic1.m_localXAxis1,s=f.col1.x*l.x+f.col2.x*l.y,o=f.col1.y*l.x+f.col2.y*l.y,f=r.m_xf.R,u=this.m_localAnchor1.x-r.m_sweep.localCenter.x,a=this.m_localAnchor1.y-r.m_sweep.localCenter.y,h=f.col1.x*u+f.col2.x*a,a=f.col1.y*u+f.col2.y*a,u=h,c=u*o-a*s,this.m_J.linearA.Set(-s,-o),this.m_J.angularA=-c,p+=r.m_invMass+r.m_invI*c*c),this.m_revolute2?(this.m_J.angularB=-this.m_ratio,p+=this.m_ratio*this.m_ratio*i.m_invI):(f=n.m_xf.R,l=this.m_prismatic2.m_localXAxis1,s=f.col1.x*l.x+f.col2.x*l.y,o=f.col1.y*l.x+f.col2.y*l.y,f=i.m_xf.R,u=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y,h=f.col1.x*u+f.col2.x*a,a=f.col1.y*u+f.col2.y*a,u=h,c=u*o-a*s,this.m_J.linearB.Set(-this.m_ratio*s,-this.m_ratio*o),this.m_J.angularB=-this.m_ratio*c,p+=this.m_ratio*this.m_ratio*(i.m_invMass+i.m_invI*c*c)),this.m_mass=p>0?1/p:0,e.warmStarting?(r.m_linearVelocity.x+=r.m_invMass*this.m_impulse*this.m_J.linearA.x,r.m_linearVelocity.y+=r.m_invMass*this.m_impulse*this.m_J.linearA.y,r.m_angularVelocity+=r.m_invI*this.m_impulse*this.m_J.angularA,i.m_linearVelocity.x+=i.m_invMass*this.m_impulse*this.m_J.linearB.x,i.m_linearVelocity.y+=i.m_invMass*this.m_impulse*this.m_J.linearB.y,i.m_angularVelocity+=i.m_invI*this.m_impulse*this.m_J.angularB):this.m_impulse=0},v.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r=this.m_J.Compute(t.m_linearVelocity,t.m_angularVelocity,n.m_linearVelocity,n.m_angularVelocity),i=-this.m_mass*r;this.m_impulse+=i,t.m_linearVelocity.x+=t.m_invMass*i*this.m_J.linearA.x,t.m_linearVelocity.y+=t.m_invMass*i*this.m_J.linearA.y,t.m_angularVelocity+=t.m_invI*i*this.m_J.angularA,n.m_linearVelocity.x+=n.m_invMass*i*this.m_J.linearB.x,n.m_linearVelocity.y+=n.m_invMass*i*this.m_J.linearB.y,n.m_angularVelocity+=n.m_invI*i*this.m_J.angularB},v.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=this.m_bodyA,i=this.m_bodyB,s=0,o=0;this.m_revolute1?s=this.m_revolute1.GetJointAngle():s=this.m_prismatic1.GetJointTranslation(),this.m_revolute2?o=this.m_revolute2.GetJointAngle():o=this.m_prismatic2.GetJointTranslation();var u=this.m_constant-(s+this.m_ratio*o),a=-this.m_mass*u;return n.m_sweep.c.x+=n.m_invMass*a*this.m_J.linearA.x,n.m_sweep.c.y+=n.m_invMass*a*this.m_J.linearA.y,n.m_sweep.a+=n.m_invI*a*this.m_J.angularA,i.m_sweep.c.x+=i.m_invMass*a*this.m_J.linearB.x,i.m_sweep.c.y+=i.m_invMass*a*this.m_J.linearB.y,i.m_sweep.a+=i.m_invI*a*this.m_J.angularB,n.SynchronizeTransform(),i.SynchronizeTransform(),t<r.b2_linearSlop},e.inherit(m,e.Dynamics.Joints.b2JointDef),m.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,m.b2GearJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments)},m.prototype.b2GearJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_gearJoint,this.joint1=null,this.joint2=null,this.ratio=1},g.b2Jacobian=function(){this.linearA=new f,this.linearB=new f},g.prototype.SetZero=function(){this.linearA.SetZero(),this.angularA=0,this.linearB.SetZero(),this.angularB=0},g.prototype.Set=function(e,t,n,r){t===undefined&&(t=0),r===undefined&&(r=0),this.linearA.SetV(e),this.angularA=t,this.linearB.SetV(n),this.angularB=r},g.prototype.Compute=function(e,t,n,r){return t===undefined&&(t=0),r===undefined&&(r=0),this.linearA.x*e.x+this.linearA.y*e.y+this.angularA*t+(this.linearB.x*n.x+this.linearB.y*n.y)+this.angularB*r},y.b2Joint=function(){this.m_edgeA=new w,this.m_edgeB=new w,this.m_localCenterA=new f,this.m_localCenterB=new f},y.prototype.GetType=function(){return this.m_type},y.prototype.GetAnchorA=function(){return null},y.prototype.GetAnchorB=function(){return null},y.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),null},y.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},y.prototype.GetBodyA=function(){return this.m_bodyA},y.prototype.GetBodyB=function(){return this.m_bodyB},y.prototype.GetNext=function(){return this.m_next},y.prototype.GetUserData=function(){return this.m_userData},y.prototype.SetUserData=function(e){this.m_userData=e},y.prototype.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()},y.Create=function(e,t){var n=null;switch(e.type){case y.e_distanceJoint:n=new c(e instanceof h?e:null);break;case y.e_mouseJoint:n=new x(e instanceof T?e:null);break;case y.e_prismaticJoint:n=new N(e instanceof C?e:null);break;case y.e_revoluteJoint:n=new A(e instanceof O?e:null);break;case y.e_pulleyJoint:n=new k(e instanceof L?e:null);break;case y.e_gearJoint:n=new v(e instanceof m?e:null);break;case y.e_lineJoint:n=new E(e instanceof S?e:null);break;case y.e_weldJoint:n=new M(e instanceof _?e:null);break;case y.e_frictionJoint:n=new p(e instanceof d?e:null);break;default:}return n},y.Destroy=function(e,t){},y.prototype.b2Joint=function(e){r.b2Assert(e.bodyA!=e.bodyB),this.m_type=e.type,this.m_prev=null,this.m_next=null,this.m_bodyA=e.bodyA,this.m_bodyB=e.bodyB,this.m_collideConnected=e.collideConnected,this.m_islandFlag=!1,this.m_userData=e.userData},y.prototype.InitVelocityConstraints=function(e){},y.prototype.SolveVelocityConstraints=function(e){},y.prototype.FinalizeVelocityConstraints=function(){},y.prototype.SolvePositionConstraints=function(e){return e===undefined&&(e=0),!1},e.postDefs.push(function(){e.Dynamics.Joints.b2Joint.e_unknownJoint=0,e.Dynamics.Joints.b2Joint.e_revoluteJoint=1,e.Dynamics.Joints.b2Joint.e_prismaticJoint=2,e.Dynamics.Joints.b2Joint.e_distanceJoint=3,e.Dynamics.Joints.b2Joint.e_pulleyJoint=4,e.Dynamics.Joints.b2Joint.e_mouseJoint=5,e.Dynamics.Joints.b2Joint.e_gearJoint=6,e.Dynamics.Joints.b2Joint.e_lineJoint=7,e.Dynamics.Joints.b2Joint.e_weldJoint=8,e.Dynamics.Joints.b2Joint.e_frictionJoint=9,e.Dynamics.Joints.b2Joint.e_inactiveLimit=0,e.Dynamics.Joints.b2Joint.e_atLowerLimit=1,e.Dynamics.Joints.b2Joint.e_atUpperLimit=2,e.Dynamics.Joints.b2Joint.e_equalLimits=3}),b.b2JointDef=function(){},b.prototype.b2JointDef=function(){this.type=y.e_unknownJoint,this.userData=null,this.bodyA=null,this.bodyB=null,this.collideConnected=!1},w.b2JointEdge=function(){},e.inherit(E,e.Dynamics.Joints.b2Joint),E.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,E.b2LineJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_localXAxis1=new f,this.m_localYAxis1=new f,this.m_axis=new f,this.m_perp=new f,this.m_K=new i,this.m_impulse=new f},E.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},E.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},E.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x),e*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y))},E.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_impulse.y},E.prototype.GetJointTranslation=function(){var e=this.m_bodyA,t=this.m_bodyB,n,r=e.GetWorldPoint(this.m_localAnchor1),i=t.GetWorldPoint(this.m_localAnchor2),s=i.x-r.x,o=i.y-r.y,u=e.GetWorldVector(this.m_localXAxis1),a=u.x*s+u.y*o;return a},E.prototype.GetJointSpeed=function(){var e=this.m_bodyA,t=this.m_bodyB,n;n=e.m_xf.R;var r=this.m_localAnchor1.x-e.m_sweep.localCenter.x,i=this.m_localAnchor1.y-e.m_sweep.localCenter.y,s=n.col1.x*r+n.col2.x*i;i=n.col1.y*r+n.col2.y*i,r=s,n=t.m_xf.R;var o=this.m_localAnchor2.x-t.m_sweep.localCenter.x,u=this.m_localAnchor2.y-t.m_sweep.localCenter.y;s=n.col1.x*o+n.col2.x*u,u=n.col1.y*o+n.col2.y*u,o=s;var a=e.m_sweep.c.x+r,f=e.m_sweep.c.y+i,l=t.m_sweep.c.x+o,c=t.m_sweep.c.y+u,h=l-a,p=c-f,d=e.GetWorldVector(this.m_localXAxis1),v=e.m_linearVelocity,m=t.m_linearVelocity,g=e.m_angularVelocity,y=t.m_angularVelocity,b=h*-g*d.y+p*g*d.x+(d.x*(m.x+ -y*u-v.x- -g*i)+d.y*(m.y+y*o-v.y-g*r));return b},E.prototype.IsLimitEnabled=function(){return this.m_enableLimit},E.prototype.EnableLimit=function(e){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=e},E.prototype.GetLowerLimit=function(){return this.m_lowerTranslation},E.prototype.GetUpperLimit=function(){return this.m_upperTranslation},E.prototype.SetLimits=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=e,this.m_upperTranslation=t},E.prototype.IsMotorEnabled=function(){return this.m_enableMotor},E.prototype.EnableMotor=function(e){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=e},E.prototype.SetMotorSpeed=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=e},E.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},E.prototype.SetMaxMotorForce=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=e},E.prototype.GetMaxMotorForce=function(){return this.m_maxMotorForce},E.prototype.GetMotorForce=function(){return this.m_motorImpulse},E.prototype.b2LineJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_localXAxis1.SetV(e.localAxisA),this.m_localYAxis1.x=-this.m_localXAxis1.y,this.m_localYAxis1.y=this.m_localXAxis1.x,this.m_impulse.SetZero(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=e.lowerTranslation,this.m_upperTranslation=e.upperTranslation,this.m_maxMotorForce=e.maxMotorForce,this.m_motorSpeed=e.motorSpeed,this.m_enableLimit=e.enableLimit,this.m_enableMotor=e.enableMotor,this.m_limitState=y.e_inactiveLimit,this.m_axis.SetZero(),this.m_perp.SetZero()},E.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,i,s=0;this.m_localCenterA.SetV(t.GetLocalCenter()),this.m_localCenterB.SetV(n.GetLocalCenter());var u=t.GetTransform(),a=n.GetTransform();i=t.m_xf.R;var f=this.m_localAnchor1.x-this.m_localCenterA.x,l=this.m_localAnchor1.y-this.m_localCenterA.y;s=i.col1.x*f+i.col2.x*l,l=i.col1.y*f+i.col2.y*l,f=s,i=n.m_xf.R;var c=this.m_localAnchor2.x-this.m_localCenterB.x,h=this.m_localAnchor2.y-this.m_localCenterB.y;s=i.col1.x*c+i.col2.x*h,h=i.col1.y*c+i.col2.y*h,c=s;var p=n.m_sweep.c.x+c-t.m_sweep.c.x-f,d=n.m_sweep.c.y+h-t.m_sweep.c.y-l;this.m_invMassA=t.m_invMass,this.m_invMassB=n.m_invMass,this.m_invIA=t.m_invI,this.m_invIB=n.m_invI,this.m_axis.SetV(o.MulMV(u.R,this.m_localXAxis1)),this.m_a1=(p+f)*this.m_axis.y-(d+l)*this.m_axis.x,this.m_a2=c*this.m_axis.y-h*this.m_axis.x,this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2,this.m_motorMass=this.m_motorMass>Number.MIN_VALUE?1/this.m_motorMass:0,this.m_perp.SetV(o.MulMV(u.R,this.m_localYAxis1)),this.m_s1=(p+f)*this.m_perp.y-(d+l)*this.m_perp.x,this.m_s2=c*this.m_perp.y-h*this.m_perp.x;var v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,b=this.m_invIB;this.m_K.col1.x=v+m+g*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=v+m+g*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_enableLimit){var w=this.m_axis.x*p+this.m_axis.y*d;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?this.m_limitState=y.e_equalLimits:w<=this.m_lowerTranslation?this.m_limitState!=y.e_atLowerLimit&&(this.m_limitState=y.e_atLowerLimit,this.m_impulse.y=0):w>=this.m_upperTranslation?this.m_limitState!=y.e_atUpperLimit&&(this.m_limitState=y.e_atUpperLimit,this.m_impulse.y=0):(this.m_limitState=y.e_inactiveLimit,this.m_impulse.y=0)}else this.m_limitState=y.e_inactiveLimit;this.m_enableMotor==0&&(this.m_motorImpulse=0);if(e.warmStarting){this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_motorImpulse*=e.dtRatio;var E=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x,S=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y,x=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1,T=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2;t.m_linearVelocity.x-=this.m_invMassA*E,t.m_linearVelocity.y-=this.m_invMassA*S,t.m_angularVelocity-=this.m_invIA*x,n.m_linearVelocity.x+=this.m_invMassB*E,n.m_linearVelocity.y+=this.m_invMassB*S,n.m_angularVelocity+=this.m_invIB*T}else this.m_impulse.SetZero(),this.m_motorImpulse=0},E.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r=t.m_linearVelocity,i=t.m_angularVelocity,s=n.m_linearVelocity,u=n.m_angularVelocity,a=0,l=0,c=0,h=0;if(this.m_enableMotor&&this.m_limitState!=y.e_equalLimits){var p=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,d=this.m_motorMass*(this.m_motorSpeed-p),v=this.m_motorImpulse,m=e.dt*this.m_maxMotorForce;this.m_motorImpulse=o.Clamp(this.m_motorImpulse+d,-m,m),d=this.m_motorImpulse-v,a=d*this.m_axis.x,l=d*this.m_axis.y,c=d*this.m_a1,h=d*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*l,i-=this.m_invIA*c,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*l,u+=this.m_invIB*h}var g=this.m_perp.x*(s.x-r.x)+this.m_perp.y*(s.y-r.y)+this.m_s2*u-this.m_s1*i;if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){var b=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,w=this.m_impulse.Copy(),E=this.m_K.Solve(new f,-g,-b);this.m_impulse.Add(E),this.m_limitState==y.e_atLowerLimit?this.m_impulse.y=o.Max(this.m_impulse.y,0):this.m_limitState==y.e_atUpperLimit&&(this.m_impulse.y=o.Min(this.m_impulse.y,0));var S=-g-(this.m_impulse.y-w.y)*this.m_K.col2.x,x=0;this.m_K.col1.x!=0?x=S/this.m_K.col1.x+w.x:x=w.x,this.m_impulse.x=x,E.x=this.m_impulse.x-w.x,E.y=this.m_impulse.y-w.y,a=E.x*this.m_perp.x+E.y*this.m_axis.x,l=E.x*this.m_perp.y+E.y*this.m_axis.y,c=E.x*this.m_s1+E.y*this.m_a1,h=E.x*this.m_s2+E.y*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*l,i-=this.m_invIA*c,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*l,u+=this.m_invIB*h}else{var T=0;this.m_K.col1.x!=0?T=-g/this.m_K.col1.x:T=0,this.m_impulse.x+=T,a=T*this.m_perp.x,l=T*this.m_perp.y,c=T*this.m_s1,h=T*this.m_s2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*l,i-=this.m_invIA*c,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*l,u+=this.m_invIB*h}t.m_linearVelocity.SetV(r),t.m_angularVelocity=i,n.m_linearVelocity.SetV(s),n.m_angularVelocity=u},E.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=0,s=this.m_bodyA,u=this.m_bodyB,a=s.m_sweep.c,l=s.m_sweep.a,c=u.m_sweep.c,h=u.m_sweep.a,p,d=0,v=0,m=0,g=0,y=0,b=0,w=0,E=!1,S=0,x=i.FromAngle(l),T=i.FromAngle(h);p=x;var N=this.m_localAnchor1.x-this.m_localCenterA.x,C=this.m_localAnchor1.y-this.m_localCenterA.y;d=p.col1.x*N+p.col2.x*C,C=p.col1.y*N+p.col2.y*C,N=d,p=T;var k=this.m_localAnchor2.x-this.m_localCenterB.x,L=this.m_localAnchor2.y-this.m_localCenterB.y;d=p.col1.x*k+p.col2.x*L,L=p.col1.y*k+p.col2.y*L,k=d;var A=c.x+k-a.x-N,O=c.y+L-a.y-C;if(this.m_enableLimit){this.m_axis=o.MulMV(x,this.m_localXAxis1),this.m_a1=(A+N)*this.m_axis.y-(O+C)*this.m_axis.x,this.m_a2=k*this.m_axis.y-L*this.m_axis.x;var M=this.m_axis.x*A+this.m_axis.y*O;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?(S=o.Clamp(M,-r.b2_maxLinearCorrection,r.b2_maxLinearCorrection),b=o.Abs(M),E=!0):M<=this.m_lowerTranslation?(S=o.Clamp(M-this.m_lowerTranslation+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),b=this.m_lowerTranslation-M,E=!0):M>=this.m_upperTranslation&&(S=o.Clamp(M-this.m_upperTranslation+r.b2_linearSlop,0,r.b2_maxLinearCorrection),b=M-this.m_upperTranslation,E=!0)}this.m_perp=o.MulMV(x,this.m_localYAxis1),this.m_s1=(A+N)*this.m_perp.y-(O+C)*this.m_perp.x,this.m_s2=k*this.m_perp.y-L*this.m_perp.x;var _=new f,D=this.m_perp.x*A+this.m_perp.y*O;b=o.Max(b,o.Abs(D)),w=0;if(E)v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,y=this.m_invIB,this.m_K.col1.x=v+m+g*this.m_s1*this.m_s1+y*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1*this.m_a1+y*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=v+m+g*this.m_a1*this.m_a1+y*this.m_a2*this.m_a2,this.m_K.Solve(_,-D,-S);else{v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,y=this.m_invIB;var P=v+m+g*this.m_s1*this.m_s1+y*this.m_s2*this.m_s2,H=0;P!=0?H=-D/P:H=0,_.x=H,_.y=0}var B=_.x*this.m_perp.x+_.y*this.m_axis.x,j=_.x*this.m_perp.y+_.y*this.m_axis.y,F=_.x*this.m_s1+_.y*this.m_a1,I=_.x*this.m_s2+_.y*this.m_a2;return a.x-=this.m_invMassA*B,a.y-=this.m_invMassA*j,l-=this.m_invIA*F,c.x+=this.m_invMassB*B,c.y+=this.m_invMassB*j,h+=this.m_invIB*I,s.m_sweep.a=l,u.m_sweep.a=h,s.SynchronizeTransform(),u.SynchronizeTransform(),b<=r.b2_linearSlop&&w<=r.b2_angularSlop},e.inherit(S,e.Dynamics.Joints.b2JointDef),S.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,S.b2LineJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f,this.localAxisA=new f},S.prototype.b2LineJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_lineJoint,this.localAxisA.Set(1,0),this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0},S.prototype.Initialize=function(e,t,n,r){this.bodyA=e,this.bodyB=t,this.localAnchorA=this.bodyA.GetLocalPoint(n),this.localAnchorB=this.bodyB.GetLocalPoint(n),this.localAxisA=this.bodyA.GetLocalVector(r)},e.inherit(x,e.Dynamics.Joints.b2Joint),x.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,x.b2MouseJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.K=new i,this.K1=new i,this.K2=new i,this.m_localAnchor=new f,this.m_target=new f,this.m_impulse=new f,this.m_mass=new i,this.m_C=new f},x.prototype.GetAnchorA=function(){return this.m_target},x.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor)},x.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse.x,e*this.m_impulse.y)},x.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},x.prototype.GetTarget=function(){return this.m_target},x.prototype.SetTarget=function(e){this.m_bodyB.IsAwake()==0&&this.m_bodyB.SetAwake(!0),this.m_target=e},x.prototype.GetMaxForce=function(){return this.m_maxForce},x.prototype.SetMaxForce=function(e){e===undefined&&(e=0),this.m_maxForce=e},x.prototype.GetFrequency=function(){return this.m_frequencyHz},x.prototype.SetFrequency=function(e){e===undefined&&(e=0),this.m_frequencyHz=e},x.prototype.GetDampingRatio=function(){return this.m_dampingRatio},x.prototype.SetDampingRatio=function(e){e===undefined&&(e=0),this.m_dampingRatio=e},x.prototype.b2MouseJoint=function(e){this.__super.b2Joint.call(this,e),this.m_target.SetV(e.target);var t=this.m_target.x-this.m_bodyB.m_xf.position.x,n=this.m_target.y-this.m_bodyB.m_xf.position.y,r=this.m_bodyB.m_xf.R;this.m_localAnchor.x=t*r.col1.x+n*r.col1.y,this.m_localAnchor.y=t*r.col2.x+n*r.col2.y,this.m_maxForce=e.maxForce,this.m_impulse.SetZero(),this.m_frequencyHz=e.frequencyHz,this.m_dampingRatio=e.dampingRatio,this.m_beta=0,this.m_gamma=0},x.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyB,n=t.GetMass(),r=2*Math.PI*this.m_frequencyHz,i=2*n*this.m_dampingRatio*r,s=n*r*r;this.m_gamma=e.dt*(i+e.dt*s),this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0,this.m_beta=e.dt*s*this.m_gamma;var o;o=t.m_xf.R;var u=this.m_localAnchor.x-t.m_sweep.localCenter.x,a=this.m_localAnchor.y-t.m_sweep.localCenter.y,f=o.col1.x*u+o.col2.x*a;a=o.col1.y*u+o.col2.y*a,u=f;var l=t.m_invMass,c=t.m_invI;this.K1.col1.x=l,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=l,this.K2.col1.x=c*a*a,this.K2.col2.x=-c*u*a,this.K2.col1.y=-c*u*a,this.K2.col2.y=c*u*u,this.K.SetM(this.K1),this.K.AddM(this.K2),this.K.col1.x+=this.m_gamma,this.K.col2.y+=this.m_gamma,this.K.GetInverse(this.m_mass),this.m_C.x=t.m_sweep.c.x+u-this.m_target.x,this.m_C.y=t.m_sweep.c.y+a-this.m_target.y,t.m_angularVelocity*=.98,this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,t.m_linearVelocity.x+=l*this.m_impulse.x,t.m_linearVelocity.y+=l*this.m_impulse.y,t.m_angularVelocity+=c*(u*this.m_impulse.y-a*this.m_impulse.x)},x.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyB,n,r=0,i=0;n=t.m_xf.R;var s=this.m_localAnchor.x-t.m_sweep.localCenter.x,o=this.m_localAnchor.y-t.m_sweep.localCenter.y;r=n.col1.x*s+n.col2.x*o,o=n.col1.y*s+n.col2.y*o,s=r;var u=t.m_linearVelocity.x+ -t.m_angularVelocity*o,a=t.m_linearVelocity.y+t.m_angularVelocity*s;n=this.m_mass,r=u+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x,i=a+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;var f=-(n.col1.x*r+n.col2.x*i),l=-(n.col1.y*r+n.col2.y*i),c=this.m_impulse.x,h=this.m_impulse.y;this.m_impulse.x+=f,this.m_impulse.y+=l;var p=e.dt*this.m_maxForce;this.m_impulse.LengthSquared()>p*p&&this.m_impulse.Multiply(p/this.m_impulse.Length()),f=this.m_impulse.x-c,l=this.m_impulse.y-h,t.m_linearVelocity.x+=t.m_invMass*f,t.m_linearVelocity.y+=t.m_invMass*l,t.m_angularVelocity+=t.m_invI*(s*l-o*f)},x.prototype.SolvePositionConstraints=function(e){return e===undefined&&(e=0),!0},e.inherit(T,e.Dynamics.Joints.b2JointDef),T.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,T.b2MouseJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.target=new f},T.prototype.b2MouseJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_mouseJoint,this.maxForce=0,this.frequencyHz=5,this.dampingRatio=.7},e.inherit(N,e.Dynamics.Joints.b2Joint),N.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,N.b2PrismaticJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_localXAxis1=new f,this.m_localYAxis1=new f,this.m_axis=new f,this.m_perp=new f,this.m_K=new s,this.m_impulse=new l},N.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},N.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},N.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))},N.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_impulse.y},N.prototype.GetJointTranslation=function(){var e=this.m_bodyA,t=this.m_bodyB,n,r=e.GetWorldPoint(this.m_localAnchor1),i=t.GetWorldPoint(this.m_localAnchor2),s=i.x-r.x,o=i.y-r.y,u=e.GetWorldVector(this.m_localXAxis1),a=u.x*s+u.y*o;return a},N.prototype.GetJointSpeed=function(){var e=this.m_bodyA,t=this.m_bodyB,n;n=e.m_xf.R;var r=this.m_localAnchor1.x-e.m_sweep.localCenter.x,i=this.m_localAnchor1.y-e.m_sweep.localCenter.y,s=n.col1.x*r+n.col2.x*i;i=n.col1.y*r+n.col2.y*i,r=s,n=t.m_xf.R;var o=this.m_localAnchor2.x-t.m_sweep.localCenter.x,u=this.m_localAnchor2.y-t.m_sweep.localCenter.y;s=n.col1.x*o+n.col2.x*u,u=n.col1.y*o+n.col2.y*u,o=s;var a=e.m_sweep.c.x+r,f=e.m_sweep.c.y+i,l=t.m_sweep.c.x+o,c=t.m_sweep.c.y+u,h=l-a,p=c-f,d=e.GetWorldVector(this.m_localXAxis1),v=e.m_linearVelocity,m=t.m_linearVelocity,g=e.m_angularVelocity,y=t.m_angularVelocity,b=h*-g*d.y+p*g*d.x+(d.x*(m.x+ -y*u-v.x- -g*i)+d.y*(m.y+y*o-v.y-g*r));return b},N.prototype.IsLimitEnabled=function(){return this.m_enableLimit},N.prototype.EnableLimit=function(e){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=e},N.prototype.GetLowerLimit=function(){return this.m_lowerTranslation},N.prototype.GetUpperLimit=function(){return this.m_upperTranslation},N.prototype.SetLimits=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=e,this.m_upperTranslation=t},N.prototype.IsMotorEnabled=function(){return this.m_enableMotor},N.prototype.EnableMotor=function(e){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=e},N.prototype.SetMotorSpeed=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=e},N.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},N.prototype.SetMaxMotorForce=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=e},N.prototype.GetMotorForce=function(){return this.m_motorImpulse},N.prototype.b2PrismaticJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_localXAxis1.SetV(e.localAxisA),this.m_localYAxis1.x=-this.m_localXAxis1.y,this.m_localYAxis1.y=this.m_localXAxis1.x,this.m_refAngle=e.referenceAngle,this.m_impulse.SetZero(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=e.lowerTranslation,this.m_upperTranslation=e.upperTranslation,this.m_maxMotorForce=e.maxMotorForce,this.m_motorSpeed=e.motorSpeed,this.m_enableLimit=e.enableLimit,this.m_enableMotor=e.enableMotor,this.m_limitState=y.e_inactiveLimit,this.m_axis.SetZero(),this.m_perp.SetZero()},N.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,i,s=0;this.m_localCenterA.SetV(t.GetLocalCenter()),this.m_localCenterB.SetV(n.GetLocalCenter());var u=t.GetTransform(),a=n.GetTransform();i=t.m_xf.R;var f=this.m_localAnchor1.x-this.m_localCenterA.x,l=this.m_localAnchor1.y-this.m_localCenterA.y;s=i.col1.x*f+i.col2.x*l,l=i.col1.y*f+i.col2.y*l,f=s,i=n.m_xf.R;var c=this.m_localAnchor2.x-this.m_localCenterB.x,h=this.m_localAnchor2.y-this.m_localCenterB.y;s=i.col1.x*c+i.col2.x*h,h=i.col1.y*c+i.col2.y*h,c=s;var p=n.m_sweep.c.x+c-t.m_sweep.c.x-f,d=n.m_sweep.c.y+h-t.m_sweep.c.y-l;this.m_invMassA=t.m_invMass,this.m_invMassB=n.m_invMass,this.m_invIA=t.m_invI,this.m_invIB=n.m_invI,this.m_axis.SetV(o.MulMV(u.R,this.m_localXAxis1)),this.m_a1=(p+f)*this.m_axis.y-(d+l)*this.m_axis.x,this.m_a2=c*this.m_axis.y-h*this.m_axis.x,this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2,this.m_motorMass>Number.MIN_VALUE&&(this.m_motorMass=1/this.m_motorMass),this.m_perp.SetV(o.MulMV(u.R,this.m_localYAxis1)),this.m_s1=(p+f)*this.m_perp.y-(d+l)*this.m_perp.x,this.m_s2=c*this.m_perp.y-h*this.m_perp.x;var v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,b=this.m_invIB;this.m_K.col1.x=v+m+g*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1+b*this.m_s2,this.m_K.col1.z=g*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=g+b,this.m_K.col2.z=g*this.m_a1+b*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=v+m+g*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_enableLimit){var w=this.m_axis.x*p+this.m_axis.y*d;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?this.m_limitState=y.e_equalLimits:w<=this.m_lowerTranslation?this.m_limitState!=y.e_atLowerLimit&&(this.m_limitState=y.e_atLowerLimit,this.m_impulse.z=0):w>=this.m_upperTranslation?this.m_limitState!=y.e_atUpperLimit&&(this.m_limitState=y.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=y.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=y.e_inactiveLimit;this.m_enableMotor==0&&(this.m_motorImpulse=0);if(e.warmStarting){this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_motorImpulse*=e.dtRatio;var E=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x,S=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y,x=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,T=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;t.m_linearVelocity.x-=this.m_invMassA*E,t.m_linearVelocity.y-=this.m_invMassA*S,t.m_angularVelocity-=this.m_invIA*x,n.m_linearVelocity.x+=this.m_invMassB*E,n.m_linearVelocity.y+=this.m_invMassB*S,n.m_angularVelocity+=this.m_invIB*T}else this.m_impulse.SetZero(),this.m_motorImpulse=0},N.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r=t.m_linearVelocity,i=t.m_angularVelocity,s=n.m_linearVelocity,u=n.m_angularVelocity,a=0,c=0,h=0,p=0;if(this.m_enableMotor&&this.m_limitState!=y.e_equalLimits){var d=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,v=this.m_motorMass*(this.m_motorSpeed-d),m=this.m_motorImpulse,g=e.dt*this.m_maxMotorForce;this.m_motorImpulse=o.Clamp(this.m_motorImpulse+v,-g,g),v=this.m_motorImpulse-m,a=v*this.m_axis.x,c=v*this.m_axis.y,h=v*this.m_a1,p=v*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*c,i-=this.m_invIA*h,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*c,u+=this.m_invIB*p}var b=this.m_perp.x*(s.x-r.x)+this.m_perp.y*(s.y-r.y)+this.m_s2*u-this.m_s1*i,w=u-i;if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){var E=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,S=this.m_impulse.Copy(),x=this.m_K.Solve33(new l,-b,-w,-E);this.m_impulse.Add(x),this.m_limitState==y.e_atLowerLimit?this.m_impulse.z=o.Max(this.m_impulse.z,0):this.m_limitState==y.e_atUpperLimit&&(this.m_impulse.z=o.Min(this.m_impulse.z,0));var T=-b-(this.m_impulse.z-S.z)*this.m_K.col3.x,N=-w-(this.m_impulse.z-S.z)*this.m_K.col3.y,C=this.m_K.Solve22(new f,T,N);C.x+=S.x,C.y+=S.y,this.m_impulse.x=C.x,this.m_impulse.y=C.y,x.x=this.m_impulse.x-S.x,x.y=this.m_impulse.y-S.y,x.z=this.m_impulse.z-S.z,a=x.x*this.m_perp.x+x.z*this.m_axis.x,c=x.x*this.m_perp.y+x.z*this.m_axis.y,h=x.x*this.m_s1+x.y+x.z*this.m_a1,p=x.x*this.m_s2+x.y+x.z*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*c,i-=this.m_invIA*h,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*c,u+=this.m_invIB*p}else{var k=this.m_K.Solve22(new f,-b,-w);this.m_impulse.x+=k.x,this.m_impulse.y+=k.y,a=k.x*this.m_perp.x,c=k.x*this.m_perp.y,h=k.x*this.m_s1+k.y,p=k.x*this.m_s2+k.y,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*c,i-=this.m_invIA*h,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*c,u+=this.m_invIB*p}t.m_linearVelocity.SetV(r),t.m_angularVelocity=i,n.m_linearVelocity.SetV(s),n.m_angularVelocity=u},N.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=0,s=this.m_bodyA,u=this.m_bodyB,a=s.m_sweep.c,c=s.m_sweep.a,h=u.m_sweep.c,p=u.m_sweep.a,d,v=0,m=0,g=0,y=0,b=0,w=0,E=0,S=!1,x=0,T=i.FromAngle(c),N=i.FromAngle(p);d=T;var C=this.m_localAnchor1.x-this.m_localCenterA.x,k=this.m_localAnchor1.y-this.m_localCenterA.y;v=d.col1.x*C+d.col2.x*k,k=d.col1.y*C+d.col2.y*k,C=v,d=N;var L=this.m_localAnchor2.x-this.m_localCenterB.x,A=this.m_localAnchor2.y-this.m_localCenterB.y;v=d.col1.x*L+d.col2.x*A,A=d.col1.y*L+d.col2.y*A,L=v;var O=h.x+L-a.x-C,M=h.y+A-a.y-k;if(this.m_enableLimit){this.m_axis=o.MulMV(T,this.m_localXAxis1),this.m_a1=(O+C)*this.m_axis.y-(M+k)*this.m_axis.x,this.m_a2=L*this.m_axis.y-A*this.m_axis.x;var _=this.m_axis.x*O+this.m_axis.y*M;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?(x=o.Clamp(_,-r.b2_maxLinearCorrection,r.b2_maxLinearCorrection),w=o.Abs(_),S=!0):_<=this.m_lowerTranslation?(x=o.Clamp(_-this.m_lowerTranslation+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),w=this.m_lowerTranslation-_,S=!0):_>=this.m_upperTranslation&&(x=o.Clamp(_-this.m_upperTranslation+r.b2_linearSlop,0,r.b2_maxLinearCorrection),w=_-this.m_upperTranslation,S=!0)}this.m_perp=o.MulMV(T,this.m_localYAxis1),this.m_s1=(O+C)*this.m_perp.y-(M+k)*this.m_perp.x,this.m_s2=L*this.m_perp.y-A*this.m_perp.x;var D=new l,P=this.m_perp.x*O+this.m_perp.y*M,H=p-c-this.m_refAngle;w=o.Max(w,o.Abs(P)),E=o.Abs(H);if(S)m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,b=this.m_invIB,this.m_K.col1.x=m+g+y*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=y*this.m_s1+b*this.m_s2,this.m_K.col1.z=y*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=y+b,this.m_K.col2.z=y*this.m_a1+b*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=m+g+y*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2,this.m_K.Solve33(D,-P,-H,-x);else{m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,b=this.m_invIB;var B=m+g+y*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,j=y*this.m_s1+b*this.m_s2,F=y+b;this.m_K.col1.Set(B,j,0),this.m_K.col2.Set(j,F,0);var I=this.m_K.Solve22(new f,-P,-H);D.x=I.x,D.y=I.y,D.z=0}var q=D.x*this.m_perp.x+D.z*this.m_axis.x,R=D.x*this.m_perp.y+D.z*this.m_axis.y,U=D.x*this.m_s1+D.y+D.z*this.m_a1,z=D.x*this.m_s2+D.y+D.z*this.m_a2;return a.x-=this.m_invMassA*q,a.y-=this.m_invMassA*R,c-=this.m_invIA*U,h.x+=this.m_invMassB*q,h.y+=this.m_invMassB*R,p+=this.m_invIB*z,s.m_sweep.a=c,u.m_sweep.a=p,s.SynchronizeTransform(),u.SynchronizeTransform(),w<=r.b2_linearSlop&&E<=r.b2_angularSlop},e.inherit(C,e.Dynamics.Joints.b2JointDef),C.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,C.b2PrismaticJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f,this.localAxisA=new f},C.prototype.b2PrismaticJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_prismaticJoint,this.localAxisA.Set(1,0),this.referenceAngle=0,this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0},C.prototype.Initialize=function(e,t,n,r){this.bodyA=e,this.bodyB=t,this.localAnchorA=this.bodyA.GetLocalPoint(n),this.localAnchorB=this.bodyB.GetLocalPoint(n),this.localAxisA=this.bodyA.GetLocalVector(r),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},e.inherit(k,e.Dynamics.Joints.b2Joint),k.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,k.b2PulleyJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_groundAnchor1=new f,this.m_groundAnchor2=new f,this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_u1=new f,this.m_u2=new f},k.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},k.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},k.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse*this.m_u2.x,e*this.m_impulse*this.m_u2.y)},k.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},k.prototype.GetGroundAnchorA=function(){var e=this.m_ground.m_xf.position.Copy();return e.Add(this.m_groundAnchor1),e},k.prototype.GetGroundAnchorB=function(){var e=this.m_ground.m_xf.position.Copy();return e.Add(this.m_groundAnchor2),e},k.prototype.GetLength1=function(){var e=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),t=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,n=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,r=e.x-t,i=e.y-n;return Math.sqrt(r*r+i*i)},k.prototype.GetLength2=function(){var e=this.m_bodyB.GetWorldPoint(this.m_localAnchor2),t=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,n=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,r=e.x-t,i=e.y-n;return Math.sqrt(r*r+i*i)},k.prototype.GetRatio=function(){return this.m_ratio},k.prototype.b2PulleyJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_ground=this.m_bodyA.m_world.m_groundBody,this.m_groundAnchor1.x=e.groundAnchorA.x-this.m_ground.m_xf.position.x,this.m_groundAnchor1.y=e.groundAnchorA.y-this.m_ground.m_xf.position.y,this.m_groundAnchor2.x=e.groundAnchorB.x-this.m_ground.m_xf.position.x,this.m_groundAnchor2.y=e.groundAnchorB.y-this.m_ground.m_xf.position.y,this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_ratio=e.ratio,this.m_constant=e.lengthA+this.m_ratio*e.lengthB,this.m_maxLength1=o.Min(e.maxLengthA,this.m_constant-this.m_ratio*k.b2_minPulleyLength),this.m_maxLength2=o.Min(e.maxLengthB,(this.m_constant-k.b2_minPulleyLength)/this.m_ratio),this.m_impulse=0,this.m_limitImpulse1=0,this.m_limitImpulse2=0},k.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,i;i=t.m_xf.R;var s=this.m_localAnchor1.x-t.m_sweep.localCenter.x,o=this.m_localAnchor1.y-t.m_sweep.localCenter.y,u=i.col1.x*s+i.col2.x*o;o=i.col1.y*s+i.col2.y*o,s=u,i=n.m_xf.R;var a=this.m_localAnchor2.x-n.m_sweep.localCenter.x,f=this.m_localAnchor2.y-n.m_sweep.localCenter.y;u=i.col1.x*a+i.col2.x*f,f=i.col1.y*a+i.col2.y*f,a=u;var l=t.m_sweep.c.x+s,c=t.m_sweep.c.y+o,h=n.m_sweep.c.x+a,p=n.m_sweep.c.y+f,d=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,v=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,m=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,g=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.Set(l-d,c-v),this.m_u2.Set(h-m,p-g);var b=this.m_u1.Length(),w=this.m_u2.Length();b>r.b2_linearSlop?this.m_u1.Multiply(1/b):this.m_u1.SetZero(),w>r.b2_linearSlop?this.m_u2.Multiply(1/w):this.m_u2.SetZero();var E=this.m_constant-b-this.m_ratio*w;E>0?(this.m_state=y.e_inactiveLimit,this.m_impulse=0):this.m_state=y.e_atUpperLimit,b<this.m_maxLength1?(this.m_limitState1=y.e_inactiveLimit,this.m_limitImpulse1=0):this.m_limitState1=y.e_atUpperLimit,w<this.m_maxLength2?(this.m_limitState2=y.e_inactiveLimit,this.m_limitImpulse2=0):this.m_limitState2=y.e_atUpperLimit;var S=s*this.m_u1.y-o*this.m_u1.x,x=a*this.m_u2.y-f*this.m_u2.x;this.m_limitMass1=t.m_invMass+t.m_invI*S*S,this.m_limitMass2=n.m_invMass+n.m_invI*x*x,this.m_pulleyMass=this.m_limitMass1+this.m_ratio*this.m_ratio*this.m_limitMass2,this.m_limitMass1=1/this.m_limitMass1,this.m_limitMass2=1/this.m_limitMass2,this.m_pulleyMass=1/this.m_pulleyMass;if(e.warmStarting){this.m_impulse*=e.dtRatio,this.m_limitImpulse1*=e.dtRatio,this.m_limitImpulse2*=e.dtRatio;var T=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.x,N=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.y,C=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.x,k=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.y;t.m_linearVelocity.x+=t.m_invMass*T,t.m_linearVelocity.y+=t.m_invMass*N,t.m_angularVelocity+=t.m_invI*(s*N-o*T),n.m_linearVelocity.x+=n.m_invMass*C,n.m_linearVelocity.y+=n.m_invMass*k,n.m_angularVelocity+=n.m_invI*(a*k-f*C)}else this.m_impulse=0,this.m_limitImpulse1=0,this.m_limitImpulse2=0},k.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r;r=t.m_xf.R;var i=this.m_localAnchor1.x-t.m_sweep.localCenter.x,s=this.m_localAnchor1.y-t.m_sweep.localCenter.y,u=r.col1.x*i+r.col2.x*s;s=r.col1.y*i+r.col2.y*s,i=u,r=n.m_xf.R;var a=this.m_localAnchor2.x-n.m_sweep.localCenter.x,f=this.m_localAnchor2.y-n.m_sweep.localCenter.y;u=r.col1.x*a+r.col2.x*f,f=r.col1.y*a+r.col2.y*f,a=u;var l=0,c=0,h=0,p=0,d=0,v=0,m=0,g=0,b=0,w=0,E=0;this.m_state==y.e_atUpperLimit&&(l=t.m_linearVelocity.x+ -t.m_angularVelocity*s,c=t.m_linearVelocity.y+t.m_angularVelocity*i,h=n.m_linearVelocity.x+ -n.m_angularVelocity*f,p=n.m_linearVelocity.y+n.m_angularVelocity*a,b=-(this.m_u1.x*l+this.m_u1.y*c)-this.m_ratio*(this.m_u2.x*h+this.m_u2.y*p),w=this.m_pulleyMass*-b,E=this.m_impulse,this.m_impulse=o.Max(0,this.m_impulse+w),w=this.m_impulse-E,d=-w*this.m_u1.x,v=-w*this.m_u1.y,m=-this.m_ratio*w*this.m_u2.x,g=-this.m_ratio*w*this.m_u2.y,t.m_linearVelocity.x+=t.m_invMass*d,t.m_linearVelocity.y+=t.m_invMass*v,t.m_angularVelocity+=t.m_invI*(i*v-s*d),n.m_linearVelocity.x+=n.m_invMass*m,n.m_linearVelocity.y+=n.m_invMass*g,n.m_angularVelocity+=n.m_invI*(a*g-f*m)),this.m_limitState1==y.e_atUpperLimit&&(l=t.m_linearVelocity.x+ -t.m_angularVelocity*s,c=t.m_linearVelocity.y+t.m_angularVelocity*i,b=-(this.m_u1.x*l+this.m_u1.y*c),w=-this.m_limitMass1*b,E=this.m_limitImpulse1,this.m_limitImpulse1=o.Max(0,this.m_limitImpulse1+w),w=this.m_limitImpulse1-E,d=-w*this.m_u1.x,v=-w*this.m_u1.y,t.m_linearVelocity.x+=t.m_invMass*d,t.m_linearVelocity.y+=t.m_invMass*v,t.m_angularVelocity+=t.m_invI*(i*v-s*d)),this.m_limitState2==y.e_atUpperLimit&&(h=n.m_linearVelocity.x+ -n.m_angularVelocity*f,p=n.m_linearVelocity.y+n.m_angularVelocity*a,b=-(this.m_u2.x*h+this.m_u2.y*p),w=-this.m_limitMass2*b,E=this.m_limitImpulse2,this.m_limitImpulse2=o.Max(0,this.m_limitImpulse2+w),w=this.m_limitImpulse2-E,m=-w*this.m_u2.x,g=-w*this.m_u2.y,n.m_linearVelocity.x+=n.m_invMass*m,n.m_linearVelocity.y+=n.m_invMass*g,n.m_angularVelocity+=n.m_invI*(a*g-f*m))},k.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=this.m_bodyA,n=this.m_bodyB,i,s=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,u=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,a=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,f=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,l=0,c=0,h=0,p=0,d=0,v=0,m=0,g=0,b=0,w=0,E=0,S=0,x=0,T=0,N=0,C=0;return this.m_state==y.e_atUpperLimit&&(i=t.m_xf.R,l=this.m_localAnchor1.x-t.m_sweep.localCenter.x,c=this.m_localAnchor1.y-t.m_sweep.localCenter.y,N=i.col1.x*l+i.col2.x*c,c=i.col1.y*l+i.col2.y*c,l=N,i=n.m_xf.R,h=this.m_localAnchor2.x-n.m_sweep.localCenter.x,p=this.m_localAnchor2.y-n.m_sweep.localCenter.y,N=i.col1.x*h+i.col2.x*p,p=i.col1.y*h+i.col2.y*p,h=N,d=t.m_sweep.c.x+l,v=t.m_sweep.c.y+c,m=n.m_sweep.c.x+h,g=n.m_sweep.c.y+p,this.m_u1.Set(d-s,v-u),this.m_u2.Set(m-a,g-f),b=this.m_u1.Length(),w=this.m_u2.Length(),b>r.b2_linearSlop?this.m_u1.Multiply(1/b):this.m_u1.SetZero(),w>r.b2_linearSlop?this.m_u2.Multiply(1/w):this.m_u2.SetZero(),E=this.m_constant-b-this.m_ratio*w,C=o.Max(C,-E),E=o.Clamp(E+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),S=-this.m_pulleyMass*E,d=-S*this.m_u1.x,v=-S*this.m_u1.y,m=-this.m_ratio*S*this.m_u2.x,g=-this.m_ratio*S*this.m_u2.y,t.m_sweep.c.x+=t.m_invMass*d,t.m_sweep.c.y+=t.m_invMass*v,t.m_sweep.a+=t.m_invI*(l*v-c*d),n.m_sweep.c.x+=n.m_invMass*m,n.m_sweep.c.y+=n.m_invMass*g,n.m_sweep.a+=n.m_invI*(h*g-p*m),t.SynchronizeTransform(),n.SynchronizeTransform()),this.m_limitState1==y.e_atUpperLimit&&(i=t.m_xf.R,l=this.m_localAnchor1.x-t.m_sweep.localCenter.x,c=this.m_localAnchor1.y-t.m_sweep.localCenter.y,N=i.col1.x*l+i.col2.x*c,c=i.col1.y*l+i.col2.y*c,l=N,d=t.m_sweep.c.x+l,v=t.m_sweep.c.y+c,this.m_u1.Set(d-s,v-u),b=this.m_u1.Length(),b>r.b2_linearSlop?(this.m_u1.x*=1/b,this.m_u1.y*=1/b):this.m_u1.SetZero(),E=this.m_maxLength1-b,C=o.Max(C,-E),E=o.Clamp(E+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),S=-this.m_limitMass1*E,d=-S*this.m_u1.x,v=-S*this.m_u1.y,t.m_sweep.c.x+=t.m_invMass*d,t.m_sweep.c.y+=t.m_invMass*v,t.m_sweep.a+=t.m_invI*(l*v-c*d),t.SynchronizeTransform()),this.m_limitState2==y.e_atUpperLimit&&(i=n.m_xf.R,h=this.m_localAnchor2.x-n.m_sweep.localCenter.x,p=this.m_localAnchor2.y-n.m_sweep.localCenter.y,N=i.col1.x*h+i.col2.x*p,p=i.col1.y*h+i.col2.y*p,h=N,m=n.m_sweep.c.x+h,g=n.m_sweep.c.y+p,this.m_u2.Set(m-a,g-f),w=this.m_u2.Length(),w>r.b2_linearSlop?(this.m_u2.x*=1/w,this.m_u2.y*=1/w):this.m_u2.SetZero(),E=this.m_maxLength2-w,C=o.Max(C,-E),E=o.Clamp(E+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),S=-this.m_limitMass2*E,m=-S*this.m_u2.x,g=-S*this.m_u2.y,n.m_sweep.c.x+=n.m_invMass*m,n.m_sweep.c.y+=n.m_invMass*g,n.m_sweep.a+=n.m_invI*(h*g-p*m),n.SynchronizeTransform()),C<r.b2_linearSlop},e.postDefs.push(function(){e.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength=2}),e.inherit(L,e.Dynamics.Joints.b2JointDef),L.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,L.b2PulleyJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.groundAnchorA=new f,this.groundAnchorB=new f,this.localAnchorA=new f,this.localAnchorB=new f},L.prototype.b2PulleyJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_pulleyJoint,this.groundAnchorA.Set(-1,1),this.groundAnchorB.Set(1,1),this.localAnchorA.Set(-1,0),this.localAnchorB.Set(1,0),this.lengthA=0,this.maxLengthA=0,this.lengthB=0,this.maxLengthB=0,this.ratio=1,this.collideConnected=!0},L.prototype.Initialize=function(e,t,n,r,i,s,o){o===undefined&&(o=0),this.bodyA=e,this.bodyB=t,this.groundAnchorA.SetV(n),this.groundAnchorB.SetV(r),this.localAnchorA=this.bodyA.GetLocalPoint(i),this.localAnchorB=this.bodyB.GetLocalPoint(s);var u=i.x-n.x,a=i.y-n.y;this.lengthA=Math.sqrt(u*u+a*a);var f=s.x-r.x,l=s.y-r.y;this.lengthB=Math.sqrt(f*f+l*l),this.ratio=o;var c=this.lengthA+this.ratio*this.lengthB;this.maxLengthA=c-this.ratio*k.b2_minPulleyLength,this.maxLengthB=(c-k.b2_minPulleyLength)/this.ratio},e.inherit(A,e.Dynamics.Joints.b2Joint),A.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,A.b2RevoluteJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.K=new i,this.K1=new i,this.K2=new i,this.K3=new i,this.impulse3=new l,this.impulse2=new f,this.reduced=new f,this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_impulse=new l,this.m_mass=new s},A.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},A.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},A.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse.x,e*this.m_impulse.y)},A.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_impulse.z},A.prototype.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle},A.prototype.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity},A.prototype.IsLimitEnabled=function(){return this.m_enableLimit},A.prototype.EnableLimit=function(e){this.m_enableLimit=e},A.prototype.GetLowerLimit=function(){return this.m_lowerAngle},A.prototype.GetUpperLimit=function(){return this.m_upperAngle},A.prototype.SetLimits=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.m_lowerAngle=e,this.m_upperAngle=t},A.prototype.IsMotorEnabled=function(){return this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor},A.prototype.EnableMotor=function(e){this.m_enableMotor=e},A.prototype.SetMotorSpeed=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=e},A.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},A.prototype.SetMaxMotorTorque=function(e){e===undefined&&(e=0),this.m_maxMotorTorque=e},A.prototype.GetMotorTorque=function(){return this.m_maxMotorTorque},A.prototype.b2RevoluteJoint=function(e){this.__super.b2Joint.call(this,e),this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_referenceAngle=e.referenceAngle,this.m_impulse.SetZero(),this.m_motorImpulse=0,this.m_lowerAngle=e.lowerAngle,this.m_upperAngle=e.upperAngle,this.m_maxMotorTorque=e.maxMotorTorque,this.m_motorSpeed=e.motorSpeed,this.m_enableLimit=e.enableLimit,this.m_enableMotor=e.enableMotor,this.m_limitState=y.e_inactiveLimit},A.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,i,s=0;this.m_enableMotor||this.m_enableLimit,i=t.m_xf.R;var u=this.m_localAnchor1.x-t.m_sweep.localCenter.x,a=this.m_localAnchor1.y-t.m_sweep.localCenter.y;s=i.col1.x*u+i.col2.x*a,a=i.col1.y*u+i.col2.y*a,u=s,i=n.m_xf.R;var f=this.m_localAnchor2.x-n.m_sweep.localCenter.x,l=this.m_localAnchor2.y-n.m_sweep.localCenter.y;s=i.col1.x*f+i.col2.x*l,l=i.col1.y*f+i.col2.y*l,f=s;var c=t.m_invMass,h=n.m_invMass,p=t.m_invI,d=n.m_invI;this.m_mass.col1.x=c+h+a*a*p+l*l*d,this.m_mass.col2.x=-a*u*p-l*f*d,this.m_mass.col3.x=-a*p-l*d,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=c+h+u*u*p+f*f*d,this.m_mass.col3.y=u*p+f*d,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=p+d,this.m_motorMass=1/(p+d),this.m_enableMotor==0&&(this.m_motorImpulse=0);if(this.m_enableLimit){var v=n.m_sweep.a-t.m_sweep.a-this.m_referenceAngle;o.Abs(this.m_upperAngle-this.m_lowerAngle)<2*r.b2_angularSlop?this.m_limitState=y.e_equalLimits:v<=this.m_lowerAngle?(this.m_limitState!=y.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=y.e_atLowerLimit):v>=this.m_upperAngle?(this.m_limitState!=y.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=y.e_atUpperLimit):(this.m_limitState=y.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=y.e_inactiveLimit;if(e.warmStarting){this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_motorImpulse*=e.dtRatio;var m=this.m_impulse.x,g=this.m_impulse.y;t.m_linearVelocity.x-=c*m,t.m_linearVelocity.y-=c*g,t.m_angularVelocity-=p*(u*g-a*m+this.m_motorImpulse+this.m_impulse.z),n.m_linearVelocity.x+=h*m,n.m_linearVelocity.y+=h*g,n.m_angularVelocity+=d*(f*g-l*m+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0},A.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r,i=0,s=0,u=0,a=0,f=0,l=0,c=t.m_linearVelocity,h=t.m_angularVelocity,p=n.m_linearVelocity,d=n.m_angularVelocity,v=t.m_invMass,m=n.m_invMass,g=t.m_invI,b=n.m_invI;if(this.m_enableMotor&&this.m_limitState!=y.e_equalLimits){var w=d-h-this.m_motorSpeed,E=this.m_motorMass*-w,S=this.m_motorImpulse,x=e.dt*this.m_maxMotorTorque;this.m_motorImpulse=o.Clamp(this.m_motorImpulse+E,-x,x),E=this.m_motorImpulse-S,h-=g*E,d+=b*E}if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){r=t.m_xf.R,u=this.m_localAnchor1.x-t.m_sweep.localCenter.x,a=this.m_localAnchor1.y-t.m_sweep.localCenter.y,i=r.col1.x*u+r.col2.x*a,a=r.col1.y*u+r.col2.y*a,u=i,r=n.m_xf.R,f=this.m_localAnchor2.x-n.m_sweep.localCenter.x,l=this.m_localAnchor2.y-n.m_sweep.localCenter.y,i=r.col1.x*f+r.col2.x*l,l=r.col1.y*f+r.col2.y*l,f=i;var T=p.x+ -d*l-c.x- -h*a,N=p.y+d*f-c.y-h*u,C=d-h;this.m_mass.Solve33(this.impulse3,-T,-N,-C),this.m_limitState==y.e_equalLimits?this.m_impulse.Add(this.impulse3):this.m_limitState==y.e_atLowerLimit?(s=this.m_impulse.z+this.impulse3.z,s<0&&(this.m_mass.Solve22(this.reduced,-T,-N),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)):this.m_limitState==y.e_atUpperLimit&&(s=this.m_impulse.z+this.impulse3.z,s>0&&(this.m_mass.Solve22(this.reduced,-T,-N),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)),c.x-=v*this.impulse3.x,c.y-=v*this.impulse3.y,h-=g*(u*this.impulse3.y-a*this.impulse3.x+this.impulse3.z),p.x+=m*this.impulse3.x,p.y+=m*this.impulse3.y,d+=b*(f*this.impulse3.y-l*this.impulse3.x+this.impulse3.z)}else{r=t.m_xf.R,u=this.m_localAnchor1.x-t.m_sweep.localCenter.x,a=this.m_localAnchor1.y-t.m_sweep.localCenter.y,i=r.col1.x*u+r.col2.x*a,a=r.col1.y*u+r.col2.y*a,u=i,r=n.m_xf.R,f=this.m_localAnchor2.x-n.m_sweep.localCenter.x,l=this.m_localAnchor2.y-n.m_sweep.localCenter.y,i=r.col1.x*f+r.col2.x*l,l=r.col1.y*f+r.col2.y*l,f=i;var k=p.x+ -d*l-c.x- -h*a,L=p.y+d*f-c.y-h*u;this.m_mass.Solve22(this.impulse2,-k,-L),this.m_impulse.x+=this.impulse2.x,this.m_impulse.y+=this.impulse2.y,c.x-=v*this.impulse2.x,c.y-=v*this.impulse2.y,h-=g*(u*this.impulse2.y-a*this.impulse2.x),p.x+=m*this.impulse2.x,p.y+=m*this.impulse2.y,d+=b*(f*this.impulse2.y-l*this.impulse2.x)}t.m_linearVelocity.SetV(c),t.m_angularVelocity=h,n.m_linearVelocity.SetV(p),n.m_angularVelocity=d},A.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=0,i,s=this.m_bodyA,u=this.m_bodyB,a=0,f=0,l=0,c=0,h=0;if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){var p=u.m_sweep.a-s.m_sweep.a-this.m_referenceAngle,d=0;this.m_limitState==y.e_equalLimits?(n=o.Clamp(p-this.m_lowerAngle,-r.b2_maxAngularCorrection,r.b2_maxAngularCorrection),d=-this.m_motorMass*n,a=o.Abs(n)):this.m_limitState==y.e_atLowerLimit?(n=p-this.m_lowerAngle,a=-n,n=o.Clamp(n+r.b2_angularSlop,-r.b2_maxAngularCorrection,0),d=-this.m_motorMass*n):this.m_limitState==y.e_atUpperLimit&&(n=p-this.m_upperAngle,a=n,n=o.Clamp(n-r.b2_angularSlop,0,r.b2_maxAngularCorrection),d=-this.m_motorMass*n),s.m_sweep.a-=s.m_invI*d,u.m_sweep.a+=u.m_invI*d,s.SynchronizeTransform(),u.SynchronizeTransform()}i=s.m_xf.R;var v=this.m_localAnchor1.x-s.m_sweep.localCenter.x,m=this.m_localAnchor1.y-s.m_sweep.localCenter.y;l=i.col1.x*v+i.col2.x*m,m=i.col1.y*v+i.col2.y*m,v=l,i=u.m_xf.R;var g=this.m_localAnchor2.x-u.m_sweep.localCenter.x,b=this.m_localAnchor2.y-u.m_sweep.localCenter.y;l=i.col1.x*g+i.col2.x*b,b=i.col1.y*g+i.col2.y*b,g=l;var w=u.m_sweep.c.x+g-s.m_sweep.c.x-v,E=u.m_sweep.c.y+b-s.m_sweep.c.y-m,S=w*w+E*E,x=Math.sqrt(S);f=x;var T=s.m_invMass,N=u.m_invMass,C=s.m_invI,k=u.m_invI,L=10*r.b2_linearSlop;if(S>L*L){var O=w/x,M=E/x,_=T+N,D=1/_;c=D*-w,h=D*-E;var P=.5;s.m_sweep.c.x-=P*T*c,s.m_sweep.c.y-=P*T*h,u.m_sweep.c.x+=P*N*c,u.m_sweep.c.y+=P*N*h,w=u.m_sweep.c.x+g-s.m_sweep.c.x-v,E=u.m_sweep.c.y+b-s.m_sweep.c.y-m}return this.K1.col1.x=T+N,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=T+N,this.K2.col1.x=C*m*m,this.K2.col2.x=-C*v*m,this.K2.col1.y=-C*v*m,this.K2.col2.y=C*v*v,this.K3.col1.x=k*b*b,this.K3.col2.x=-k*g*b,this.K3.col1.y=-k*g*b,this.K3.col2.y=k*g*g,this.K.SetM(this.K1),this.K.AddM(this.K2),this.K.AddM(this.K3),this.K.Solve(A.tImpulse,-w,-E),c=A.tImpulse.x,h=A.tImpulse.y,s.m_sweep.c.x-=s.m_invMass*c,s.m_sweep.c.y-=s.m_invMass*h,s.m_sweep.a-=s.m_invI*(v*h-m*c),u.m_sweep.c.x+=u.m_invMass*c,u.m_sweep.c.y+=u.m_invMass*h,u.m_sweep.a+=u.m_invI*(g*h-b*c),s.SynchronizeTransform(),u.SynchronizeTransform(),f<=r.b2_linearSlop&&a<=r.b2_angularSlop},e.postDefs.push(function(){e.Dynamics.Joints.b2RevoluteJoint.tImpulse=new f}),e.inherit(O,e.Dynamics.Joints.b2JointDef),O.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,O.b2RevoluteJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},O.prototype.b2RevoluteJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_revoluteJoint,this.localAnchorA.Set(0,0),this.localAnchorB.Set(0,0),this.referenceAngle=0,this.lowerAngle=0,this.upperAngle=0,this.maxMotorTorque=0,this.motorSpeed=0,this.enableLimit=!1,this.enableMotor=!1},O.prototype.Initialize=function(e,t,n){this.bodyA=e,this.bodyB=t,this.localAnchorA=this.bodyA.GetLocalPoint(n),this.localAnchorB=this.bodyB.GetLocalPoint(n),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},e.inherit(M,e.Dynamics.Joints.b2Joint),M.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,M.b2WeldJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchorA=new f,this.m_localAnchorB=new f,this.m_impulse=new l,this.m_mass=new s},M.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},M.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},M.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse.x,e*this.m_impulse.y)},M.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_impulse.z},M.prototype.b2WeldJoint=function(e){this.__super.b2Joint.call(this,e),this.m_localAnchorA.SetV(e.localAnchorA),this.m_localAnchorB.SetV(e.localAnchorB),this.m_referenceAngle=e.referenceAngle,this.m_impulse.SetZero(),this.m_mass=new s},M.prototype.InitVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,i=this.m_bodyB;t=r.m_xf.R;var s=this.m_localAnchorA.x-r.m_sweep.localCenter.x,o=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*s+t.col2.x*o,o=t.col1.y*s+t.col2.y*o,s=n,t=i.m_xf.R;var u=this.m_localAnchorB.x-i.m_sweep.localCenter.x,a=this.m_localAnchorB.y-i.m_sweep.localCenter.y;n=t.col1.x*u+t.col2.x*a,a=t.col1.y*u+t.col2.y*a,u=n;var f=r.m_invMass,l=i.m_invMass,c=r.m_invI,h=i.m_invI;this.m_mass.col1.x=f+l+o*o*c+a*a*h,this.m_mass.col2.x=-o*s*c-a*u*h,this.m_mass.col3.x=-o*c-a*h,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=f+l+s*s*c+u*u*h,this.m_mass.col3.y=s*c+u*h,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=c+h,e.warmStarting?(this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_impulse.z*=e.dtRatio,r.m_linearVelocity.x-=f*this.m_impulse.x,r.m_linearVelocity.y-=f*this.m_impulse.y,r.m_angularVelocity-=c*(s*this.m_impulse.y-o*this.m_impulse.x+this.m_impulse.z),i.m_linearVelocity.x+=l*this.m_impulse.x,i.m_linearVelocity.y+=l*this.m_impulse.y,i.m_angularVelocity+=h*(u*this.m_impulse.y-a*this.m_impulse.x+this.m_impulse.z)):this.m_impulse.SetZero()},M.prototype.SolveVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,i=this.m_bodyB,s=r.m_linearVelocity,o=r.m_angularVelocity,u=i.m_linearVelocity,a=i.m_angularVelocity,f=r.m_invMass,c=i.m_invMass,h=r.m_invI,p=i.m_invI;t=r.m_xf.R;var d=this.m_localAnchorA.x-r.m_sweep.localCenter.x,v=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*d+t.col2.x*v,v=t.col1.y*d+t.col2.y*v,d=n,t=i.m_xf.R;var m=this.m_localAnchorB.x-i.m_sweep.localCenter.x,g=this.m_localAnchorB.y-i.m_sweep.localCenter.y;n=t.col1.x*m+t.col2.x*g,g=t.col1.y*m+t.col2.y*g,m=n;var y=u.x-a*g-s.x+o*v,b=u.y+a*m-s.y-o*d,w=a-o,E=new l;this.m_mass.Solve33(E,-y,-b,-w),this.m_impulse.Add(E),s.x-=f*E.x,s.y-=f*E.y,o-=h*(d*E.y-v*E.x+E.z),u.x+=c*E.x,u.y+=c*E.y,a+=p*(m*E.y-g*E.x+E.z),r.m_angularVelocity=o,i.m_angularVelocity=a},M.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t,n=0,i=this.m_bodyA,s=this.m_bodyB;t=i.m_xf.R;var u=this.m_localAnchorA.x-i.m_sweep.localCenter.x,a=this.m_localAnchorA.y-i.m_sweep.localCenter.y;n=t.col1.x*u+t.col2.x*a,a=t.col1.y*u+t.col2.y*a,u=n,t=s.m_xf.R;var f=this.m_localAnchorB.x-s.m_sweep.localCenter.x,c=this.m_localAnchorB.y-s.m_sweep.localCenter.y;n=t.col1.x*f+t.col2.x*c,c=t.col1.y*f+t.col2.y*c,f=n;var h=i.m_invMass,p=s.m_invMass,d=i.m_invI,v=s.m_invI,m=s.m_sweep.c.x+f-i.m_sweep.c.x-u,g=s.m_sweep.c.y+c-i.m_sweep.c.y-a,y=s.m_sweep.a-i.m_sweep.a-this.m_referenceAngle,b=10*r.b2_linearSlop,w=Math.sqrt(m*m+g*g),E=o.Abs(y);w>b&&(d*=1,v*=1),this.m_mass.col1.x=h+p+a*a*d+c*c*v,this.m_mass.col2.x=-a*u*d-c*f*v,this.m_mass.col3.x=-a*d-c*v,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=h+p+u*u*d+f*f*v,this.m_mass.col3.y=u*d+f*v,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=d+v;var S=new l;return this.m_mass.Solve33(S,-m,-g,-y),i.m_sweep.c.x-=h*S.x,i.m_sweep.c.y-=h*S.y,i.m_sweep.a-=d*(u*S.y-a*S.x+S.z),s.m_sweep.c.x+=p*S.x,s.m_sweep.c.y+=p*S.y,s.m_sweep.a+=v*(f*S.y-c*S.x+S.z),i.SynchronizeTransform(),s.SynchronizeTransform(),w<=r.b2_linearSlop&&E<=r.b2_angularSlop},e.inherit(_,e.Dynamics.Joints.b2JointDef),_.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,_.b2WeldJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},_.prototype.b2WeldJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_weldJoint,this.referenceAngle=0},_.prototype.Initialize=function(e,t,n){this.bodyA=e,this.bodyB=t,this.localAnchorA.SetV(this.bodyA.GetLocalPoint(n)),this.localAnchorB.SetV(this.bodyB.GetLocalPoint(n)),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}}(),function(){var t=e.Dynamics.b2DebugDraw;t.b2DebugDraw=function(){this.m_drawScale=1,this.m_lineThickness=1,this.m_alpha=1,this.m_fillAlpha=1,this.m_xformScale=1;var e=this;this.m_sprite={graphics:{clear:function(){e.m_ctx.clearRect(0,0,e.m_ctx.canvas.width,e.m_ctx.canvas.height)}}}},t.prototype._color=function(e,t){return"rgba("+((e&16711680)>>16)+","+((e&65280)>>8)+","+(e&255)+","+t+")"},t.prototype.b2DebugDraw=function(){this.m_drawFlags=0},t.prototype.SetFlags=function(e){e===undefined&&(e=0),this.m_drawFlags=e},t.prototype.GetFlags=function(){return this.m_drawFlags},t.prototype.AppendFlags=function(e){e===undefined&&(e=0),this.m_drawFlags|=e},t.prototype.ClearFlags=function(e){e===undefined&&(e=0),this.m_drawFlags&=~e},t.prototype.SetSprite=function(e){this.m_ctx=e},t.prototype.GetSprite=function(){return this.m_ctx},t.prototype.SetDrawScale=function(e){e===undefined&&(e=0),this.m_drawScale=e},t.prototype.GetDrawScale=function(){return this.m_drawScale},t.prototype.SetLineThickness=function(e){e===undefined&&(e=0),this.m_lineThickness=e,this.m_ctx.strokeWidth=e},t.prototype.GetLineThickness=function(){return this.m_lineThickness},t.prototype.SetAlpha=function(e){e===undefined&&(e=0),this.m_alpha=e},t.prototype.GetAlpha=function(){return this.m_alpha},t.prototype.SetFillAlpha=function(e){e===undefined&&(e=0),this.m_fillAlpha=e},t.prototype.GetFillAlpha=function(){return this.m_fillAlpha},t.prototype.SetXFormScale=function(e){e===undefined&&(e=0),this.m_xformScale=e},t.prototype.GetXFormScale=function(){return this.m_xformScale},t.prototype.DrawPolygon=function(e,t,n){if(!t)return;var r=this.m_ctx,i=this.m_drawScale;r.beginPath(),r.strokeStyle=this._color(n.color,this.m_alpha),r.moveTo(e[0].x*i,e[0].y*i);for(var s=1;s<t;s++)r.lineTo(e[s].x*i,e[s].y*i);r.lineTo(e[0].x*i,e[0].y*i),r.closePath(),r.stroke()},t.prototype.DrawSolidPolygon=function(e,t,n){if(!t)return;var r=this.m_ctx,i=this.m_drawScale;r.beginPath(),r.strokeStyle=this._color(n.color,this.m_alpha),r.fillStyle=this._color(n.color,this.m_fillAlpha),r.moveTo(e[0].x*i,e[0].y*i);for(var s=1;s<t;s++)r.lineTo(e[s].x*i,e[s].y*i);r.lineTo(e[0].x*i,e[0].y*i),r.closePath(),r.fill(),r.stroke()},t.prototype.DrawCircle=function(e,t,n){if(!t)return;var r=this.m_ctx,i=this.m_drawScale;r.beginPath(),r.strokeStyle=this._color(n.color,this.m_alpha),r.arc(e.x*i,e.y*i,t*i,0,Math.PI*2,!0),r.closePath(),r.stroke()},t.prototype.DrawSolidCircle=function(e,t,n,r){if(!t)return;var i=this.m_ctx,s=this.m_drawScale,o=e.x*s,u=e.y*s;i.moveTo(0,0),i.beginPath(),i.strokeStyle=this._color(r.color,this.m_alpha),i.fillStyle=this._color(r.color,this.m_fillAlpha),i.arc(o,u,t*s,0,Math.PI*2,!0),i.moveTo(o,u),i.lineTo((e.x+n.x*t)*s,(e.y+n.y*t)*s),i.closePath(),i.fill(),i.stroke()},t.prototype.DrawSegment=function(e,t,n){var r=this.m_ctx,i=this.m_drawScale;r.strokeStyle=this._color(n.color,this.m_alpha),r.beginPath(),r.moveTo(e.x*i,e.y*i),r.lineTo(t.x*i,t.y*i),r.closePath(),r.stroke()},t.prototype.DrawTransform=function(e){var t=this.m_ctx,n=this.m_drawScale;t.beginPath(),t.strokeStyle=this._color(16711680,this.m_alpha),t.moveTo(e.position.x*n,e.position.y*n),t.lineTo((e.position.x+this.m_xformScale*e.R.col1.x)*n,(e.position.y+this.m_xformScale*e.R.col1.y)*n),t.strokeStyle=this._color(65280,this.m_alpha),t.moveTo(e.position.x*n,e.position.y*n),t.lineTo((e.position.x+this.m_xformScale*e.R.col2.x)*n,(e.position.y+this.m_xformScale*e.R.col2.y)*n),t.closePath(),t.stroke()}}();var r;for(r=0;r<e.postDefs.length;++r)e.postDefs[r]();return delete e.postDefs,e}),define("Game/Core/Collision/Detector",["Lib/Vendor/Box2D"],function(e){function t(){this.listener=new e.Dynamics.b2ContactListener,this.listener.BeginContact=this.beginContact.bind(this),this.listener.EndContact=this.endContact.bind(this)}return t.prototype.getListener=function(){return this.listener},t.prototype.onCollisionChange=function(e,t){var n=e.GetFixtureA().GetUserData(),r=e.GetFixtureB().GetUserData();n&&n.onCollisionChange&&n.onCollisionChange(t,e.GetFixtureB()),r&&r.onCollisionChange&&r.onCollisionChange(t,e.GetFixtureA())},t.prototype.beginContact=function(e){this.onCollisionChange(e,!0)},t.prototype.endContact=function(e){this.onCollisionChange(e,!1)},t}),define("Game/Client/Collision/Detector",["Game/Core/Collision/Detector"],function(e){function t(){e.call(this)}return t.prototype=Object.create(e.prototype),t}),define("Lib/Utilities/NotificationCenter",["Lib/Utilities/Exception"],function(e){function t(e,n){n=n||"Nc.ns";for(var r in e){if(!e.hasOwnProperty(r))continue;e[r]===null?e[r]=n+"."+r:e[r]=t(e[r],n+"."+r)}return e}function n(){this.topics={},this.subUid=-1;var e=0;this.ns={client:{view:{layer:{createAndInsert:null},mesh:{create:null,add:null,remove:null,update:null,addFilter:null,removeFilter:null},animatedMesh:{create:null},healthBar:{createAndAdd:null,remove:null,update:null},playerArrow:{createAndAdd:null,update:null},preloadBar:{update:null},fullscreen:{change:null},debugMode:{toggle:null},events:{ready:null},gameStats:{toggle:null},swiper:{swipe:null,end:null}},input:{handAction:{request:null},xy:{change:null}},game:{gameStats:{toggle:null},zoomIn:null,zoomOut:null,zoomReset:null},to:{server:{gameCommand:{send:null}}}},core:{game:{gameObject:{add:null,remove:null},events:{level:{loaded:null}}}},channel:{events:{controlCommand:{channel:null,user:null},user:{joined:null,left:null,client:{ready:null},level:{reset:null}},round:{end:null},game:{player:{killed:null}}},engine:{worldQueue:{add:null}},to:{server:{controlCommand:{send:null}},client:{user:{gameCommand:{send:null},controlCommand:{joinSuccess:null}},gameCommand:{broadcast:null},controlCommand:{broadcast:null}}}},server:{events:{controlCommand:{coordinator:null,user:null},user:{joined:null,left:null}},to:{client:{message:{send:null}}}}},t(this.ns)}return n.prototype.validate=function(t){if(typeof t=="object")throw new e("Topic bad format "+JSON.stringify(t));if(t.indexOf("Nc.ns")!==0)throw new e("Topic bad format, does not begin with Nc.ns. : "+t)},n.prototype.trigger=function(e){this.validate(e),this.topics[e]||console.warn("No such topic "+e+". Could not trigger. arguments: "+arguments.join);var t=Array.prototype.slice.call(arguments,1),n=this.topics[e],r=n?n.length:0;while(r--){var i=n[r];i.func.apply(i.context,t)}},n.prototype.on=function(e,t,n){this.validate(e),this.topics[e]||(this.topics[e]=[]);var r=(++this.subUid).toString();return this.topics[e].push({token:r,func:t,context:n}),r},n.prototype.off=function(e){for(var t in this.topics)if(this.topics[t])for(var n=0,r=this.topics[t].length;n<r;n++)if(this.topics[t][n].token===e)return this.topics[t].splice(n,1),e},n.prototype.offAll=function(e){for(var t=0;t<e.length;t++)this.off(e[t])},new n}),define("Game/Core/Physics/Engine",["Game/Config/Settings","Lib/Vendor/Box2D","Game/Client/Collision/Detector","Lib/Utilities/NotificationCenter"],function(e,t,n,r){function i(){this.world=new t.Dynamics.b2World(new t.Common.Math.b2Vec2(0,e.BOX2D_GRAVITY),e.BOX2D_ALLOW_SLEEP),this.world.SetWarmStarting(!0),this.ground=null,this.lastStep=Date.now(),this.worldQueue=[],this.ncTokens=[r.on(r.ns.channel.engine.worldQueue.add,this.addToWorldQueue,this)]}return i.prototype.getWorld=function(){return this.world},i.prototype.getGround=function(){return this.ground},i.prototype.setCollisionDetector=function(){var e=new n;this.world.SetContactListener(e.getListener())},i.prototype.createBody=function(e){var t=this.world.CreateBody(e);return this.ground||(this.ground=t),t},i.prototype.addToWorldQueue=function(e){this.worldQueue.push(e)},i.prototype.processWorldQueue=function(){for(var e=0;e<this.worldQueue.length;e++)this.worldQueue[e]();this.worldQueue=[]},i.prototype.update=function(){var t=(Date.now()-this.lastStep)/1e3;this.world.Step(t,e.BOX2D_VELOCITY_ITERATIONS,e.BOX2D_POSITION_ITERATIONS),this.lastStep=Date.now(),this.world.ClearForces(),this.processWorldQueue()},i.prototype.destroy=function(){delete this.world,r.offAll(this.ncTokens)},i}),define("Lib/Vendor/Stats",[],function(){var e=function(){var e=Date.now(),t=e,n=0,r=Infinity,i=0,s=0,o=Infinity,u=0,a=0,f=0,l=document.createElement("div");l.id="stats",l.addEventListener("mousedown",function(e){e.preventDefault(),y(++f%2)},!1),l.style.cssText="width:80px;opacity:0.9;cursor:pointer";var c=document.createElement("div");c.id="fps",c.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002",l.appendChild(c);var h=document.createElement("div");h.id="fpsText",h.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",h.innerHTML="FPS",c.appendChild(h);var p=document.createElement("div");p.id="fpsGraph",p.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(c.appendChild(p);74>p.children.length;){var d=document.createElement("span");d.style.cssText="width:1px;height:30px;float:left;background-color:#113",p.appendChild(d)}var v=document.createElement("div");v.id="ms",v.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none",l.appendChild(v);var m=document.createElement("div");m.id="msText",m.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",m.innerHTML="MS",v.appendChild(m);var g=document.createElement("div");g.id="msGraph",g.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(v.appendChild(g);74>g.children.length;)d=document.createElement("span"),d.style.cssText="width:1px;height:30px;float:left;background-color:#131",g.appendChild(d);var y=function(e){f=e;switch(f){case 0:c.style.display="block",v.style.display="none";break;case 1:c.style.display="none",v.style.display="block"}};return{REVISION:11,domElement:l,setMode:y,begin:function(){e=Date.now()},end:function(){var f=Date.now();n=f-e,r=Math.min(r,n),i=Math.max(i,n),m.textContent=n+" MS ("+r+"-"+i+")";var l=Math.min(30,30-30*(n/200));return g.appendChild(g.firstChild).style.height=l+"px",a++,f>t+1e3&&(s=Math.round(1e3*a/(f-t)),o=Math.min(o,s),u=Math.max(u,s),h.textContent=s+" FPS ("+o+"-"+u+")",l=Math.min(30,30-30*(s/100)),p.appendChild(p.firstChild).style.height=l+"px",t=f,a=0),f},update:function(){e=this.end()}}};return e}),function(){var e=typeof module!="undefined"&&module.exports,t=typeof Element!="undefined"&&"ALLOW_KEYBOARD_INPUT"in Element,n=function(){var e,t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,s={};for(;r<i;r++){e=n[r];if(e&&e[1]in document){for(r=0,t=e.length;r<t;r++)s[n[0][r]]=e[r];return s}}return!1}(),r={request:function(e){var r=n.requestFullscreen;e=e||document.documentElement,/5\.1[\.\d]* Safari/.test(navigator.userAgent)?e[r]():e[r](t&&Element.ALLOW_KEYBOARD_INPUT)},exit:function(){document[n.exitFullscreen]()},toggle:function(e){this.isFullscreen?this.exit():this.request(e)},onchange:function(){},onerror:function(){},raw:n};if(!n){e?module.exports=!1:window.screenfull=!1;return}Object.defineProperties(r,{isFullscreen:{get:function(){return!!document[n.fullscreenElement]}},element:{enumerable:!0,get:function(){return document[n.fullscreenElement]}},enabled:{enumerable:!0,get:function(){return!!document[n.fullscreenEnabled]}}}),document.addEventListener(n.fullscreenchange,function(e){r.onchange.call(r,e)}),document.addEventListener(n.fullscreenerror,function(e){r.onerror.call(r,e)}),e?module.exports=r:window.screenfull=r}(),define("screenfull",function(){}),define("Lib/Vendor/Screenfull",["screenfull"],function(){return screenfull}),define("Game/Client/View/DomController",["Game/Config/Settings","Lib/Utilities/NotificationCenter","Lib/Vendor/Stats","Lib/Vendor/Screenfull"],function(e,t,n,r){function i(){this.canvas=document.getElementById("canvas"),this.debugCanvas=null,this.stats=null,this.ping=null,t.on(t.ns.client.view.events.ready,this.initDevTools,this)}return i.prototype.initDevTools=function(){var e=this;this.devToolsContainer=document.createElement("div"),this.devToolsContainer.id="devtools",document.body.appendChild(this.devToolsContainer);var i=document.createElement("p"),s=document.createElement("button");s.innerHTML="Fullscreen",s.onclick=function(){r.enabled&&r.request(e.canvas)},i.appendChild(s),this.devToolsContainer.appendChild(i),window.onresize=function(){r.enabled&&t.trigger(t.ns.client.view.fullscreen.change,r.isFullscreen)},this.ping=document.createElement("span"),this.devToolsContainer.appendChild(this.ping),this.stats=new n,this.stats.setMode(0),this.devToolsContainer.appendChild(this.stats.domElement);var o=document.createElement("label"),u=document.createElement("input");u.type="checkbox",u.onclick=function(n){t.trigger(t.ns.client.view.debugMode.toggle,n.target.checked),e.getDebugCanvas().style.display=n.target.checked?"":"none"},o.appendChild(u),o.appendChild(document.createTextNode("Debug")),this.devToolsContainer.appendChild(o),this.health=document.createElement("span"),this.health.innerHTML="Health: 100",i=document.createElement("p"),i.appendChild(this.health),this.devToolsContainer.appendChild(i)},i.prototype.statsBegin=function(){this.stats&&this.stats.begin()},i.prototype.statsEnd=function(){this.stats&&this.stats.end()},i.prototype.setPing=function(e){this.ping.innerHTML="Ping: "+e},i.prototype.getCanvasContainer=function(){var t=document.getElementById(e.CANVAS_DOM_ID);if(t)return t;throw"Canvas Container missing: #"+e.CANVAS_DOM_ID},i.prototype.getCanvas=function(){return this.canvas},i.prototype.initCanvas=function(e){t.trigger(t.ns.client.view.fullscreen.change,r.isFullscreen)},i.prototype.getDebugCanvas=function(){if(!this.debugCanvas){var t=document.createElement("canvas");t.width=e.STAGE_WIDTH,t.height=e.STAGE_HEIGHT,this.debugCanvas=t,this.getCanvasContainer().appendChild(t)}return this.debugCanvas},i.prototype.setHealth=function(e){this.health.innerHTML="Health: "+parseInt(e,10)},i.prototype.setConnected=function(e){e?document.body.style.backgroundColor="":document.body.style.backgroundColor="#aaaaaa"},new i}),define("Game/Client/Physics/Engine",["Game/Core/Physics/Engine","Game/Config/Settings","Game/Client/View/DomController","Lib/Vendor/Box2D","Lib/Utilities/NotificationCenter"],function(e,t,n,r,i){function s(){e.call(this),this.debugMode=!1,i.on(i.ns.client.view.debugMode.toggle,this.onToggleDebugMode,this)}return s.prototype=Object.create(e.prototype),s.prototype.onToggleDebugMode=function(e){this.debugMode=e,this.debugMode&&!this.debugDraw&&this.setupDebugDraw()},s.prototype.setupDebugDraw=function(){var e=n.getDebugCanvas().getContext("2d");this.debugDraw=new r.Dynamics.b2DebugDraw,this.debugDraw.SetSprite(e),this.debugDraw.SetDrawScale(t.RATIO),this.debugDraw.SetFillAlpha(.5),this.debugDraw.SetLineThickness(1),this.debugDraw.SetFlags(null|r.Dynamics.b2DebugDraw.e_shapeBit|r.Dynamics.b2DebugDraw.e_jointBit),this.world.SetDebugDraw(this.debugDraw)},s.prototype.update=function(){e.prototype.update.call(this),this.debugMode&&this.world.DrawDebugData()},s}),define("Lib/Utilities/Abstract",["Lib/Utilities/Exception"],function(e){function t(){}return t.prototype.addMethod=function(t,n){this.prototype[t]=function(){throw new e("Abstract method",this,t+"("+n.join(", ")+") not overwritten.")}},t}),define("Game/Core/GameObjects/GameObject",["Lib/Vendor/Box2D","Lib/Utilities/Exception"],function(e,t){function n(e,t){this.uid=t;var n=this.getBodyDef();n.userData=this,this.body=e.getWorld().CreateBody(n)}return n.prototype.getBodyDef=function(){throw new t("Abstract method GameObject.getBodyDef not overwritten")},n.prototype.destroy=function(){if(!(this.body instanceof e.Dynamics.b2Body))throw new t("can not destroy body");this.body.GetWorld().DestroyBody(this.body)},n.prototype.getBody=function(){return this.body},n.prototype.getPosition=function(){return this.body.GetPosition().Copy()},n}),define("Game/Client/GameObjects/GameObject",["Game/Core/GameObjects/GameObject","Lib/Utilities/Exception","Lib/Utilities/NotificationCenter"],function(e,t,n){function r(t,n){e.call(this,t,n),this.createMesh(),this.render()}return r.prototype=Object.create(e.prototype),r.prototype.destroy=function(){e.prototype.destroy.call(this)},r.prototype.render=function(){throw new t("Abstract method GameObject.render not overwritten")},r.prototype.createMesh=function(){throw new t("Abstract method GameObject.createMesh not overwritten")},r}),define("Game/Core/GameObjects/Tile",["Game/Client/GameObjects/GameObject","Lib/Vendor/Box2D","Game/Config/Settings","Lib/Utilities/Exception","Lib/Utilities/NotificationCenter"],function(e,t,n,r,i){function s(t,n,r){this.options=r,e.call(this,t,n),this.createPhysicTile(this.options),i.trigger(i.ns.core.game.gameObject.add,"fixed",this)}return s.prototype=Object.create(e.prototype),s.prototype.getBodyDef=function(){var e=new t.Dynamics.b2BodyDef;return e.type=t.Dynamics.b2Body.b2_staticBody,e.position.x=(this.options.x*n.TILE_SIZE+n.TILE_SIZE/2)/n.RATIO,e.position.y=(this.options.y*n.TILE_SIZE+n.TILE_SIZE/2)/n.RATIO,e.angle=(this.options.r||0)*90*Math.PI/180,e},s.prototype.createPhysicTile=function(e){var r=this.createVertices(e),i=new t.Collision.Shapes.b2PolygonShape;i.SetAsArray(r,r.length);var s=new t.Dynamics.b2FixtureDef;s.shape=i,s.density=0,s.friction=n.TILE_FRICTION,s.restitution=n.TILE_RESTITUTION,s.isSensor=!1,this.body.CreateFixture(s)},s.prototype.createVertices=function(e){var t=[];switch(e.s){case 1:this.addVec(t,-1,-1),this.addVec(t,1,-1),this.addVec(t,1,1),this.addVec(t,-1,1);break;case 2:this.addVec(t,-1,-1),this.addVec(t,1,1),this.addVec(t,-1,1);break;case 3:this.addVec(t,-1,-1),this.addVec(t,0,1),this.addVec(t,-1,1);break;case 4:this.addVec(t,-1,-1),this.addVec(t,1,0),this.addVec(t,1,1),this.addVec(t,-1,1);break;case 5:this.addVec(t,1,-1),this.addVec(t,1,1),this.addVec(t,0,1);break;case 6:this.addVec(t,1,-1),this.addVec(t,1,1),this.addVec(t,-1,1),this.addVec(t,-1,0);break;case 7:this.addVec(t,-1,0),this.addVec(t,0,1),this.addVec(t,-1,1);break;case 8:this.addVec(t,-1,-1),this.addVec(t,0,-1),this.addVec(t,1,0),this.addVec(t,1,1),this.addVec(t,-1,1);break;default:throw new r("Tile Creation - no shape given")}return t},s.prototype.mkArg=function(e){return n.TILE_SIZE/2/n.RATIO*e},s.prototype.addVec=function(e,n,r){return e.push(new t.Common.Math.b2Vec2(this.mkArg(n),this.mkArg(r)))},s.prototype.destroy=function(){i.trigger(i.ns.core.game.gameObject.remove,"fixed",this)},s}),define("Game/Client/View/Abstract/Layer",["Lib/Utilities/Abstract"],function(e){function t(e,t){this.name=e,this.parallaxSpeed=t,this.zoom={current:1,target:1},this.position={current:{x:0,y:0},target:{x:0,y:0}}}return Object.defineProperty(t,"ID",{value:{TILE:"tile",ITEM:"item",SPAWN:"spawn"}}),e.prototype.addMethod.call(t,"show"),e.prototype.addMethod.call(t,"hide"),e.prototype.addMethod.call(t,"createMesh",["texturePath","callback","options"]),e.prototype.addMethod.call(t,"createAnimatedMesh",["texturePaths","callback","options"]),e.prototype.addMethod.call(t,"addMesh",["mesh"]),e.prototype.addMethod.call(t,"removeMesh",["mesh"]),e.prototype.addMethod.call(t,"updateMesh",["mesh","options"]),e.prototype.addMethod.call(t,"render",["centerPosition"]),t.prototype.getName=function(){return this.name},t.prototype.setPosition=function(e){this.position.target.x=e.x,this.position.target.y=e.y},t.prototype.setZoom=function(e){this.zoom.target=e},t}),define("Game/Client/GameObjects/Tile",["Game/Core/GameObjects/Tile","Game/Config/Settings","Lib/Utilities/NotificationCenter","Game/Client/View/Abstract/Layer"],function(e,t,n,r){function i(t,n,i){this.layerId=r.ID.TILE,e.call(this,t,n,i)}return i.prototype=Object.create(e.prototype),i.prototype.createMesh=function(){var e=this,r=t.MAPS_PATH+this.options.t,i=function(t){e.mesh=t,n.trigger(n.ns.client.view.mesh.add,e.layerId,t)};n.trigger(n.ns.client.view.mesh.create,this.layerId,r,i,{width:t.TILE_SIZE,height:t.TILE_SIZE,pivot:{x:t.TILE_SIZE/2*t.TILE_RATIO,y:t.TILE_SIZE/2*t.TILE_RATIO}})},i.prototype.destroy=function(){n.trigger(n.ns.client.view.mesh.remove,this.layerId,this.mesh),e.prototype.destroy.call(this)},i.prototype.render=function(){n.trigger(n.ns.client.view.mesh.update,this.layerId,this.mesh,{x:this.body.GetPosition().x*t.RATIO,y:this.body.GetPosition().y*t.RATIO})},i}),define("Lib/Utilities/Options",["Lib/Utilities/Exception"],function(e){function t(){}return t.prototype.merge=function(n,r){if(!r&&!n)throw new e("Options requires objects");if(r.constructor!==Object&&n.constructor!==Object)throw new e("Options requires objects");if(!r||r.constructor!==Object)return n;if(!n||n.constructor!==Object)return r;r=JSON.parse(JSON.stringify(r));for(var i in n)if(!r.hasOwnProperty(i))r[i]=n[i];else{if(n[i]===undefined)continue;n[i].constructor!==Object?r[i]=n[i]:r[i]=t.prototype.merge.call(this,n[i],r[i])}return r},new t}),define("Game/Core/GameObjects/Item",["Game/Client/GameObjects/GameObject","Lib/Vendor/Box2D","Lib/Utilities/Options","Game/Config/Settings","Lib/Utilities/Exception","Lib/Utilities/NotificationCenter"],function(e,t,n,r,i,s){function o(t,r,i){var o={grabAngle:parseFloat(i.grabAngle),danger:parseFloat(i.danger),weight:parseFloat(i.weight),width:parseFloat(i.width),height:parseFloat(i.height),rotation:parseFloat(i.rotation),bounce:parseFloat(i.bounce),x:parseFloat(i.x),y:parseFloat(i.y)};this.options=n.merge(o,i),!this.options.category,e.call(this,t,r),this.createFixture(),this.body.ResetMassData(),this.flipDirection=1,s.trigger(s.ns.core.game.gameObject.add,"animated",this)}return o.prototype=Object.create(e.prototype),o.prototype.getBodyDef=function(){var e=new t.Dynamics.b2BodyDef;return e.type=t.Dynamics.b2Body.b2_dynamicBody,e.position.x=this.options.x/r.RATIO,e.position.y=this.options.y/r.RATIO,e.angle=0,e},o.prototype.getFixtureDef=function(){var e,n=this.options.width/r.RATIO,i=this.options.height/r.RATIO;if(this.options.type=="circle"){var s=(n+i)/4;e=new t.Collision.Shapes.b2CircleShape,e.SetRadius(s),e.SetLocalPosition(new t.Common.Math.b2Vec2(0,-s))}else e=new t.Collision.Shapes.b2PolygonShape,e.SetAsOrientedBox(n/2,i/2,new t.Common.Math.b2Vec2(0,-(i/2)));var o=new t.Dynamics.b2FixtureDef;o.shape=e;var u=4,a=80,f=(this.options.weight+u)/this.options.width/this.options.height*a;return o.density=f,o.friction=r.ITEM_FRICTION,o.restitution=this.options.bounce?this.options.bounce/10:r.ITEM_RESTITUTION,o.isSensor=!1,o.userData={onCollisionChange:this.onCollisionChange.bind(this)},o},o.prototype.createFixture=function(){var e=this.getFixtureDef();this.body.CreateFixture(e)},o.prototype.flip=function(e){this.flipDirection=e},o.prototype.beingGrabbed=function(e){},o.prototype.beingReleased=function(e){},o.prototype.onCollisionChange=function(e,t,n){},o.prototype.reposition=function(e,n){this.body.SetAwake(!0);var i=new t.Common.Math.b2Vec2(e.x+this.options.width/r.RATIO/2*n,e.y);this.body.SetPosition(i),this.flip(n),this.body.SetAngle((this.options.grabAngle||0)*n)},o.prototype.getGrabPoint=function(){return this.body.GetWorldCenter()},o.prototype.throw=function(e,n){var i=this.body;i.SetAwake(!0);var s=new t.Common.Math.b2Vec2(e*r.MAX_THROW_FORCE/this.options.weight,-n*r.MAX_THROW_FORCE/this.options.weight);this.body.SetLinearVelocity(s),i.SetAngularVelocity(r.MAX_THROW_ANGULAR_VELOCITY*e)},o.prototype.destroy=function(){s.trigger(s.ns.core.game.gameObject.remove,"animated",this),e.prototype.destroy.call(this)},o}),define("Game/Client/GameObjects/Item",["Game/Core/GameObjects/Item","Game/Config/Settings","Lib/Utilities/NotificationCenter","Game/Client/View/Abstract/Layer"],function(e,t,n,r){function i(t,n,i){this.layerId=r.ID.ITEM,e.call(this,t,n,i)}return i.prototype=Object.create(e.prototype),i.prototype.createMesh=function(){var e=this,r=t.GRAPHICS_PATH+t.GRAPHICS_SUBPATH_ITEMS+this.options.category+"/"+this.options.image,i=function(t){e.mesh=t,n.trigger(n.ns.client.view.mesh.add,e.layerId,t)};n.trigger(n.ns.client.view.mesh.create,this.layerId,r,i,{width:this.options.width,height:this.options.height,pivot:{x:this.options.width/2,y:this.options.height}})},i.prototype.destroy=function(){n.trigger(n.ns.client.view.mesh.remove,this.layerId,this.mesh),e.prototype.destroy.call(this)},i.prototype.render=function(){n.trigger(n.ns.client.view.mesh.update,this.layerId,this.mesh,{x:this.body.GetPosition().x*t.RATIO,y:this.body.GetPosition().y*t.RATIO,rotation:this.body.GetAngle()})},i.prototype.flip=function(t){var r=this.flipDirection;e.prototype.flip.call(this,t),r!=t&&n.trigger(n.ns.client.view.mesh.update,this.layerId,this.mesh,{xScale:t})},i}),define("Game/Core/GameObjects/Items/Skateboard",["Game/Client/GameObjects/Item","Lib/Vendor/Box2D","Game/Config/Settings"],function(e,t,n){function r(t,n,r){e.call(this,t,n,r),this.wheels=[this.addWheel(r.x+8,r.y-1.5),this.addWheel(r.x-8,r.y-1.5)]}return r.prototype=Object.create(e.prototype),r.prototype.createFixture=function(){var e=new t.Collision.Shapes.b2PolygonShape,r=this.options.width/n.RATIO,i=1.5/n.RATIO;e.SetAsOrientedBox(r/2,i/2,new t.Common.Math.b2Vec2(0,-(4.5/n.RATIO)));var s=new t.Dynamics.b2FixtureDef;s.shape=e;var o=4,u=80,a=(this.options.weight+o)/this.options.width/this.options.height*u;s.density=a,s.friction=n.ITEM_FRICTION,s.restitution=n.ITEM_RESTITUTION,s.isSensor=!1,this.body.CreateFixture(s)},r.prototype.addWheel=function(e,r){var i=new t.Dynamics.b2BodyDef;i.type=t.Dynamics.b2Body.b2_dynamicBody,i.position.x=e/n.RATIO,i.position.y=r/n.RATIO,i.angle=0;var s=new t.Collision.Shapes.b2CircleShape;s.SetRadius(1.5/n.RATIO),s.SetLocalPosition(new t.Common.Math.b2Vec2(0,0));var o=new t.Dynamics.b2FixtureDef,u=4,a=80,f=(.1+u)/3/3*a;o.density=f,o.shape=s,o.isSensor=!1;var l=this.body.GetWorld().CreateBody(i);l.CreateFixture(o);var c=new t.Dynamics.Joints.b2RevoluteJointDef;return c.enableMotor=!1,c.Initialize(this.body,l,l.GetWorldCenter()),this.body.GetWorld().CreateJoint(c),l},r.prototype.flip=function(e){this.flipDirection=e},r.prototype.throw=function(r,i){e.prototype.throw.call(this,r,i);for(var s=0;s<this.wheels.length;s++){var o=this.wheels[s];o.SetAwake(!0);var u=new t.Common.Math.b2Vec2(r*n.MAX_THROW_FORCE/this.options.weight,-i*n.MAX_THROW_FORCE/this.options.weight);o.SetLinearVelocity(u)}},r.prototype.destroy=function(){for(var t=0;t<this.wheels.length;t++)this.body.GetWorld().DestroyBody(this.wheels[t]);e.prototype.destroy.call(this)},r}),define("Game/Client/GameObjects/Items/Skateboard",["Game/Core/GameObjects/Items/Skateboard"],function(e){return e}),define("Game/Core/GameObjects/Items/RagDoll",["Game/Client/GameObjects/Item","Lib/Vendor/Box2D","Game/Config/Settings","Lib/Utilities/NotificationCenter"],function(e,t,n,r){function i(t,n,r){r.width=20,r.height=40,r.limbs={},r.limbs.chest={width:6,height:18,x:0,y:0},r.limbs.head={width:10,height:12,x:0,y:-r.limbs.chest.height/2-7},r.limbs.upperLeftLeg={width:3,height:4,x:-2,y:r.limbs.chest.height/2},r.limbs.upperRightLeg={width:3,height:4,x:2,y:r.limbs.chest.height/2},r.limbs.lowerLeftLeg={width:4,height:4,x:-2,y:r.limbs.chest.height/2+r.limbs.upperLeftLeg.height},r.limbs.lowerRightLeg={width:4,height:4,x:2,y:r.limbs.chest.height/2+r.limbs.upperRightLeg.height},r.limbs.upperLeftArm={width:2,height:8,x:-2,y:-r.limbs.chest.height/2},r.limbs.upperRightArm={width:3,height:8,x:2,y:-r.limbs.chest.height/2},r.limbs.lowerLeftArm={width:2,height:5,x:-2,y:-r.limbs.chest.height/2+r.limbs.upperLeftArm.height},r.limbs.lowerRightArm={width:2,height:5,x:2,y:-r.limbs.chest.height/2+r.limbs.upperRightArm.height},e.call(this,t,n,r),this.limbs={},this.addHead(),this.addLimb("upperLeftLeg",this.body,r.limbs.upperLeftLeg.x,r.limbs.chest.height/2),this.addLimb("upperRightLeg",this.body,r.limbs.upperRightLeg.x,r.limbs.chest.height/2),this.addLimb("lowerLeftLeg",this.limbs.upperLeftLeg,0,r.limbs.upperLeftLeg.height/2),this.addLimb("lowerRightLeg",this.limbs.upperRightLeg,0,r.limbs.upperRightLeg.height/2),this.addLimb("upperLeftArm",this.body,r.limbs.upperLeftArm.x,-r.limbs.chest.height/2),this.addLimb("upperRightArm",this.body,r.limbs.upperRightArm.x,-r.limbs.chest.height/2),this.addLimb("lowerLeftArm",this.limbs.upperLeftArm,0,r.limbs.upperLeftArm.height/2),this.addLimb("lowerRightArm",this.limbs.upperRightArm,0,r.limbs.upperRightArm.height/2)}return i.prototype=Object.create(e.prototype),i.prototype.getId=function(){return 55},i.prototype.getPosition=function(){return this.body.GetPosition().Copy()},i.prototype.getHeadPosition=function(){return this.limbs.head.GetPosition().Copy()},i.prototype.getBodyDef=function(){var r=e.prototype.getBodyDef.call(this);return r.linearDamping=n.PLAYER_LINEAR_DAMPING,r.type=t.Dynamics.b2Body.b2_dynamicBody,r},i.prototype.getFixtureDef=function(){var r=e.prototype.getFixtureDef.call(this);r.density=n.PLAYER_DENSITY,r.friction=n.PLAYER_FRICTION,r.restitution=n.PLAYER_RESTITUTION,r.filter.groupIndex=-this.getId();var i=new t.Collision.Shapes.b2PolygonShape;return i.SetAsOrientedBox(this.options.limbs.chest.width/2/n.RATIO,this.options.limbs.chest.height/2/n.RATIO,new t.Common.Math.b2Vec2(0,0)),r.shape=i,r},i.prototype.createSensor=function(){var e=this.options.width/n.RATIO,r=this.options.height/n.RATIO,i=new t.Collision.Shapes.b2PolygonShape;i.SetAsOrientedBox(e/2,r/2,new t.Common.Math.b2Vec2(0,0));var s=new t.Dynamics.b2FixtureDef;s.shape=i,s.isSensor=!0,s.userData={onCollisionChange:this.onCollisionChange.bind(this)},this.body.CreateFixture(s)},i.prototype.addHead=function(){var e=this.options.x+this.options.limbs.head.x,r=this.options.y+this.options.limbs.head.y,i=new t.Dynamics.b2BodyDef;i.type=t.Dynamics.b2Body.b2_dynamicBody,i.position.x=e/n.RATIO,i.position.y=r/n.RATIO,i.angle=0;var s=new t.Collision.Shapes.b2CircleShape;s.SetRadius(this.options.limbs.head.width/2/n.RATIO),s.SetLocalPosition(new t.Common.Math.b2Vec2(0,0));var o=new t.Dynamics.b2FixtureDef;o.density=n.PLAYER_DENSITY,o.friction=n.PLAYER_FRICTION,o.restitution=n.PLAYER_RESTITUTION,o.shape=s,o.isSensor=!1,o.filter.groupIndex=-this.getId();var u=this.body.GetWorld().CreateBody(i);u.CreateFixture(o),this.limbs.head=u,this.attachHead()},i.prototype.attachHead=function(){var e=this.limbs.head,r=new t.Dynamics.Joints.b2RevoluteJointDef;r.enableMotor=!1;var i=this.body.GetWorldCenter().Copy();i.y-=this.options.limbs.chest.height/2/n.RATIO,r.Initialize(this.body,e,i),r.lowerAngle=-0.25*t.Common.b2Settings.b2_pi,r.upperAngle=.25*t.Common.b2Settings.b2_pi,r.enableLimit=!0,this.body.GetWorld().CreateJoint(r)},i.prototype.addLimb=function(e,r,i,s){var o=this.options.x+this.options.limbs[e].x,u=this.options.y+this.options.limbs[e].y,a=new t.Dynamics.b2BodyDef;a.linearDamping=n.PLAYER_LINEAR_DAMPING,a.type=t.Dynamics.b2Body.b2_dynamicBody,a.position.x=o/n.RATIO,a.position.y=u/n.RATIO,a.angle=0;var f=new t.Collision.Shapes.b2PolygonShape;f.SetAsOrientedBox(this.options.limbs[e].width/2/n.RATIO,this.options.limbs[e].height/2/n.RATIO,new t.Common.Math.b2Vec2(0,this.options.limbs[e].height/2/n.RATIO));var l=new t.Dynamics.b2FixtureDef;l.density=n.PLAYER_DENSITY,l.friction=n.PLAYER_FRICTION,l.restitution=n.PLAYER_RESTITUTION,l.shape=f,l.isSensor=!1,l.filter.groupIndex=-this.getId();var c=this.body.GetWorld().CreateBody(a);c.CreateFixture(l),this.limbs[e]=c;var h=new t.Dynamics.Joints.b2RevoluteJointDef;h.enableMotor=!1;var p=r.GetWorldCenter().Copy();p.x+=i/n.RATIO,p.y+=s/n.RATIO,h.Initialize(r,c,p),h.lowerAngle=-0.15*t.Common.b2Settings.b2_pi,h.upperAngle=.15*t.Common.b2Settings.b2_pi,h.enableLimit=!0,this.body.GetWorld().CreateJoint(h)},i.prototype.detachHead=function(){var e=this.limbs.head.GetJointList().joint;e&&this.body.GetWorld().DestroyJoint(e)},i.prototype.reposition=function(r,i){e.prototype.reposition.call(this,r,i);var s=this.body.GetPosition(),o=new t.Common.Math.b2Vec2(s.x+this.options.limbs.head.x/n.RATIO,s.y+this.options.limbs.head.y/n.RATIO);this.limbs.head.SetPosition(o),this.limbs.head.SetAngle((this.options.grabAngle||0)*i)},i.prototype.throw=function(r,i){e.prototype.throw.call(this,r,i);var s=1;for(var o in this.limbs){var u=this.limbs[o];u.SetAwake(!0);var a=new t.Common.Math.b2Vec2(r*n.MAX_THROW_FORCE*s/this.options.weight,-i*n.MAX_THROW_FORCE*s/this.options.weight);u.SetLinearVelocity(a)}},i.prototype.setVelocities=function(e){this.body.SetLinearVelocity(e.linearVelocity),this.body.SetAngularVelocity(e.angularVelocity);for(var t in this.limbs)this.limbs[t].SetLinearVelocity(e.linearVelocity)},i.prototype.destroy=function(){r.trigger(r.ns.core.game.gameObject.remove,"animated",this);var t=this.body.GetWorld();for(var n in this.limbs)t.DestroyBody(this.limbs[n]);e.prototype.destroy.call(this)},i}),define("Game/Client/GameObjects/Items/RagDoll",["Game/Core/GameObjects/Items/RagDoll","Game/Core/GameObjects/Item","Game/Config/Settings","Lib/Utilities/NotificationCenter","Game/Client/View/Abstract/Layer"],function(e,t,n,r,i){function s(t,n,r){this.layerId=i.ID.SPAWN,this.limbMeshes={},this.baseMeshName="chest",this.characterName="Chuck",e.call(this,t,n,r)}return s.prototype=Object.create(e.prototype),s.prototype.createMesh=function(){for(var e in this.options.limbs)this.createLimbMesh(e)},s.prototype.createLimbMesh=function(e){var t=this,i=n.GRAPHICS_PATH+n.GRAPHICS_SUBPATH_CHARACTERS+"/"+this.characterName+"/",s=function(n){e==t.baseMeshName?t.mesh=n:t.limbMeshes[e]=n,r.trigger(r.ns.client.view.mesh.add,t.layerId,n)};r.trigger(r.ns.client.view.mesh.create,this.layerId,i+e+".png",s,{width:this.options.limbs[e].width,height:this.options.limbs[e].height,pivot:{x:this.options.limbs[e].width/2,y:this.options.limbs[e].height/2}})},s.prototype.render=function(){e.prototype.render.call(this);if(this.limbs)for(var t in this.limbMeshes)this.limbs[t]&&r.trigger(r.ns.client.view.mesh.update,this.layerId,this.limbMeshes[t],{x:this.limbs[t].GetPosition().x*n.RATIO,y:this.limbs[t].GetPosition().y*n.RATIO,rotation:this.limbs[t].GetAngle()})},s.prototype.flip=function(e){var n=this.flipDirection;t.prototype.flip.call(this,e);if(n!=e){r.trigger(r.ns.client.view.mesh.update,this.layerId,this.mesh,{xScale:e});for(var i in this.limbMeshes)r.trigger(r.ns.client.view.mesh.update,this.layerId,this.limbMeshes[i],{xScale:e})}},s.prototype.destroy=function(){for(var t in this.limbMeshes)r.trigger(r.ns.client.view.mesh.remove,this.layerId,this.limbMeshes[t]);e.prototype.destroy.call(this)},s}),define("Lib/Vendor/RubeLoader",["Lib/Vendor/Box2D"],function(e){function pt(e,t){this.scene=this.loadSceneIntoWorld(e,t)}var t=e.Common.b2Color,n=e.Common.b2internal,r=e.Common.b2Settings,s=e.Collision.Shapes.b2CircleShape,o=e.Collision.Shapes.b2EdgeChainDef,u=e.Collision.Shapes.b2EdgeShape,a=e.Collision.Shapes.b2MassData,l=e.Collision.Shapes.b2PolygonShape,c=e.Collision.Shapes.b2Shape,h=e.Common.Math.b2Mat22,p=e.Common.Math.b2Mat33,d=e.Common.Math.b2Math,m=e.Common.Math.b2Sweep,g=e.Common.Math.b2Transform,y=e.Common.Math.b2Vec2,w=e.Common.Math.b2Vec3,E=e.Dynamics.b2Body,S=e.Dynamics.b2BodyDef,x=e.Dynamics.b2ContactFilter,T=e.Dynamics.b2ContactImpulse,N=e.Dynamics.b2ContactListener,C=e.Dynamics.b2ContactManager,L=e.Dynamics.b2DebugDraw,A=e.Dynamics.b2DestructionListener,O=e.Dynamics.b2FilterData,M=e.Dynamics.b2Fixture,_=e.Dynamics.b2FixtureDef,D=e.Dynamics.b2Island,P=e.Dynamics.b2TimeStep,H=e.Dynamics.b2World,B=e.Collision.b2AABB,F=e.Collision.b2Bound,I=e.Collision.b2BoundValues,q=e.Collision.b2Collision,R=e.Collision.b2ContactID,U=e.Collision.b2ContactPoint,z=e.Collision.b2Distance,W=e.Collision.b2DistanceInput,X=e.Collision.b2DistanceOutput,V=e.Collision.b2DistanceProxy,$=e.Collision.b2DynamicTree,J=e.Collision.b2DynamicTreeBroadPhase,K=e.Collision.b2DynamicTreeNode,Q=e.Collision.b2DynamicTreePair,G=e.Collision.b2Manifold,Y=e.Collision.b2ManifoldPoint,Z=e.Collision.b2Point,et=e.Collision.b2RayCastInput,tt=e.Collision.b2RayCastOutput,nt=e.Collision.b2Segment,rt=e.Collision.b2SeparationFunction,it=e.Collision.b2Simplex,st=e.Collision.b2SimplexCache,ot=e.Collision.b2SimplexVertex,ut=e.Collision.b2TimeOfImpact,at=e.Collision.b2TOIInput,ft=e.Collision.b2WorldManifold,lt=e.Collision.ClipVertex,ct=e.Collision.Features,ht=e.Collision.IBroadPhase;return b2_dynamicBody=e.Dynamics.b2Body.b2_dynamicBody,b2ControllerEdge=e.Dynamics.Controllers.b2ControllerEdge,ht=e.Collision.IBroadPhase,b2CircleContact=e.Dynamics.Contacts.b2CircleContact,b2Contact=e.Dynamics.Contacts.b2Contact,b2ContactConstraint=e.Dynamics.Contacts.b2ContactConstraint,b2ContactConstraintPoint=e.Dynamics.Contacts.b2ContactConstraintPoint,b2ContactEdge=e.Dynamics.Contacts.b2ContactEdge,b2ContactFactory=e.Dynamics.Contacts.b2ContactFactory,b2ContactRegister=e.Dynamics.Contacts.b2ContactRegister,b2ContactResult=e.Dynamics.Contacts.b2ContactResult,b2ContactSolver=e.Dynamics.Contacts.b2ContactSolver,b2EdgeAndCircleContact=e.Dynamics.Contacts.b2EdgeAndCircleContact,b2NullContact=e.Dynamics.Contacts.b2NullContact,b2PolyAndCircleContact=e.Dynamics.Contacts.b2PolyAndCircleContact,b2PolyAndEdgeContact=e.Dynamics.Contacts.b2PolyAndEdgeContact,b2PolygonContact=e.Dynamics.Contacts.b2PolygonContact,b2PositionSolverManifold=e.Dynamics.Contacts.b2PositionSolverManifold,b2Controller=e.Dynamics.Controllers.b2Controller,b2DistanceJoint=e.Dynamics.Joints.b2DistanceJoint,b2DistanceJointDef=e.Dynamics.Joints.b2DistanceJointDef,b2FrictionJoint=e.Dynamics.Joints.b2FrictionJoint,b2FrictionJointDef=e.Dynamics.Joints.b2FrictionJointDef,b2GearJoint=e.Dynamics.Joints.b2GearJoint,b2GearJointDef=e.Dynamics.Joints.b2GearJointDef,b2Jacobian=e.Dynamics.Joints.b2Jacobian,b2Joint=e.Dynamics.Joints.b2Joint,b2JointDef=e.Dynamics.Joints.b2JointDef,b2JointEdge=e.Dynamics.Joints.b2JointEdge,b2LineJoint=e.Dynamics.Joints.b2LineJoint,b2LineJointDef=e.Dynamics.Joints.b2LineJointDef,b2MouseJoint=e.Dynamics.Joints.b2MouseJoint,b2MouseJointDef=e.Dynamics.Joints.b2MouseJointDef,b2PrismaticJoint=e.Dynamics.Joints.b2PrismaticJoint,b2PrismaticJointDef=e.Dynamics.Joints.b2PrismaticJointDef,b2PulleyJoint=e.Dynamics.Joints.b2PulleyJoint,b2PulleyJointDef=e.Dynamics.Joints.b2PulleyJointDef,b2RevoluteJoint=e.Dynamics.Joints.b2RevoluteJoint,b2RevoluteJointDef=e.Dynamics.Joints.b2RevoluteJointDef,b2WeldJoint=e.Dynamics.Joints.b2WeldJoint,b2WeldJointDef=e.Dynamics.Joints.b2WeldJointDef,Object.prototype.hasOwnProperty=function(e){return typeof this[e]!="undefined"},pt.prototype.getScene=function(){return this.scene},pt.prototype.loadBodyFromRUBE=function(e,t){if(!e.hasOwnProperty("type"))return console.log("Body does not have a 'type' property"),null;var n=new S;e.type==2?n.type=b2_dynamicBody:e.type==1&&(n.type=b2_kinematicBody),e.hasOwnProperty("angle")&&(n.angle=e.angle),e.hasOwnProperty("angularVelocity")&&(n.angularVelocity=e.angularVelocity),e.hasOwnProperty("active")&&(n.awake=e.active),e.hasOwnProperty("fixedRotation")&&(n.fixedRotation=e.fixedRotation),e.hasOwnProperty("linearVelocity")&&e.linearVelocity instanceof Object&&n.linearVelocity.SetV(e.linearVelocity),e.hasOwnProperty("position")&&e.position instanceof Object&&(e.position.y*=-1),n.position.SetV(e.position),e.hasOwnProperty("awake")?n.awake=e.awake:n.awake=!1;var r=t.CreateBody(n);if(e.hasOwnProperty("fixture"))for(k=0;k<e.fixture.length;k++){var i=e.fixture[k];this.loadFixtureFromRUBE(r,i)}return e.hasOwnProperty("name")&&(r.name=e.name),e.hasOwnProperty("customProperties")&&(r.customProperties=e.customProperties),r},pt.prototype.loadFixtureFromRUBE=function(e,t){var n=new _;t.hasOwnProperty("friction")&&(n.friction=t.friction),t.hasOwnProperty("density")&&(n.density=t.density),t.hasOwnProperty("restitution")&&(n.restitution=t.restitution),t.hasOwnProperty("sensor")&&(n.isSensor=t.sensor),t.hasOwnProperty("filter-categoryBits")&&(n.filter.categoryBits=t["filter-categoryBits"]),t.hasOwnProperty("filter-maskBits")&&(n.filter.maskBits=t["filter-maskBits"]),t.hasOwnProperty("filter-groupIndex")&&(n.filter.groupIndex=t["filter-groupIndex"]);if(t.hasOwnProperty("circle")){n.shape=new s,n.shape.m_radius=t.circle.radius,t.circle.center&&n.shape.m_p.SetV(t.circle.center);var r=e.CreateFixture(n);t.name&&(r.name=t.name)}else if(t.hasOwnProperty("polygon")){n.shape=new l;var i=[];for(v=t.polygon.vertices.x.length-1;v>=0;v--)i.push(new y(t.polygon.vertices.x[v],-t.polygon.vertices.y[v]));n.shape.SetAsArray(i,i.length);var r=e.CreateFixture(n);r&&t.name&&(r.name=t.name)}else if(t.hasOwnProperty("chain")){n.shape=new l;var o=new y;for(v=t.chain.vertices.x.length-1;v>=0;v--){var u=new y(t.chain.vertices.x[v],-t.chain.vertices.y[v]);if(v<t.chain.vertices.x.length-1){n.shape.SetAsEdge(o,u);var r=e.CreateFixture(n);t.name&&(r.name=t.name)}o=u}}else console.log("Could not find shape type for fixture")},pt.prototype.getVectorValue=function(e){return e instanceof Object?(e.y*=-1,e):{x:0,y:0}},pt.prototype.loadJointCommonProperties=function(e,t,n){e.bodyA=n[t.bodyA],e.bodyB=n[t.bodyB],e.localAnchorA.SetV(this.getVectorValue(t.anchorA)),e.localAnchorB.SetV(this.getVectorValue(t.anchorB)),t.collideConnected&&(e.collideConnected=t.collideConnected)},pt.prototype.loadJointFromRUBE=function(e,t,n){if(!e.hasOwnProperty("type"))return console.log("Joint does not have a 'type' property"),null;if(e.bodyA>=n.length)return console.log("Index for bodyA is invalid: "+e.bodyA),null;if(e.bodyB>=n.length)return console.log("Index for bodyB is invalid: "+e.bodyB),null;var r=null;if(e.type=="revolute"){var i=new b2RevoluteJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("refAngle")&&(i.referenceAngle=e.refAngle),e.hasOwnProperty("lowerLimit")&&(i.lowerAngle=e.lowerLimit),e.hasOwnProperty("upperLimit")&&(i.upperAngle=e.upperLimit),e.hasOwnProperty("maxMotorTorque")&&(i.maxMotorTorque=e.maxMotorTorque),e.hasOwnProperty("motorSpeed")&&(i.motorSpeed=e.motorSpeed),e.hasOwnProperty("enableLimit")&&(i.enableLimit=e.enableLimit),e.hasOwnProperty("enableMotor")&&(i.enableMotor=e.enableMotor),r=t.CreateJoint(i)}else if(e.type=="distance"||e.type=="rope"){e.type=="rope"&&console.log("Replacing unsupported rope joint with distance joint!");var i=new b2DistanceJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("length")&&(i.length=e.length),e.hasOwnProperty("dampingRatio")&&(i.dampingRatio=e.dampingRatio),e.hasOwnProperty("frequency")&&(i.frequencyHz=e.frequency),r=t.CreateJoint(i)}else if(e.type=="prismatic"){var i=new b2PrismaticJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("localAxisA")&&i.localAxisA.SetV(this.getVectorValue(e.localAxisA)),e.hasOwnProperty("refAngle")&&(i.referenceAngle=e.refAngle),e.hasOwnProperty("enableLimit")&&(i.enableLimit=e.enableLimit),e.hasOwnProperty("lowerLimit")&&(i.lowerTranslation=e.lowerLimit),e.hasOwnProperty("upperLimit")&&(i.upperTranslation=e.upperLimit),e.hasOwnProperty("enableMotor")&&(i.enableMotor=e.enableMotor),e.hasOwnProperty("maxMotorForce")&&(i.maxMotorForce=e.maxMotorForce),e.hasOwnProperty("motorSpeed")&&(i.motorSpeed=e.motorSpeed),r=t.CreateJoint(i)}else if(e.type=="wheel"){var i=new b2DistanceJointDef;this.loadJointCommonProperties(i,e,n),i.length=0,e.hasOwnProperty("springDampingRatio")&&(i.dampingRatio=e.springDampingRatio),e.hasOwnProperty("springFrequency")&&(i.frequencyHz=e.springFrequency),t.CreateJoint(i),i=new b2LineJointDef,this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("localAxisA")&&i.localAxisA.SetV(this.getVectorValue(e.localAxisA)),r=t.CreateJoint(i)}else if(e.type=="friction"){var i=new b2FrictionJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("maxForce")&&(i.maxForce=e.maxForce),e.hasOwnProperty("maxTorque")&&(i.maxTorque=e.maxTorque),r=t.CreateJoint(i)}else if(e.type=="weld"){var i=new b2WeldJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("referenceAngle")&&(i.referenceAngle=e.referenceAngle),r=t.CreateJoint(i)}else console.log("Unsupported joint type: "+e.type),console.log(e);return r&&e.name&&(r.name=e.name),r},pt.prototype.makeClone=function(e){var t=e instanceof Array?[]:{};for(var n in e)e[n]&&typeof e[n]=="object"?t[n]=this.makeClone(e[n]):t[n]=e[n];return t},pt.prototype.loadImageFromRUBE=function(e,t,n){var r=this.makeClone(e);return r.hasOwnProperty("body")&&r.body>=0?r.body=n[r.body]:r.body=null,r.center=new y,r.center.SetV(this.getVectorValue(e.center)),r},pt.prototype.loadSceneIntoWorld=function(e,t){var n=[];if(e.hasOwnProperty("body"))for(var r=0;r<e.body.length;r++){var i=e.body[r],s=this.loadBodyFromRUBE(i,t);s&&n.push(s)}var o=[];if(e.hasOwnProperty("joint"))for(var r=0;r<e.joint.length;r++){var u=e.joint[r],a=this.loadJointFromRUBE(u,t,n);a&&o.push(a)}var f={bodies:n};return f},pt.prototype.loadWorldFromRUBE=function(e){var t=new y(0,0);e.hasOwnProperty("gravity")&&e.gravity instanceof Object&&t.SetV(e.gravity);var n=new H(t);return this.loadSceneIntoWorld(e,n)?n:!1},pt.prototype.getNamedBodies=function(e,t){var n=[];for(b=e.m_bodyList;b;b=b.m_next)b.name==t&&n.push(b);return n},pt.prototype.getNamedFixtures=function(e,t){var n=[];for(b=e.m_bodyList;b;b=b.m_next)for(f=b.m_fixtureList;f;f=f.m_next)f.name==t&&n.push(f);return n},pt.prototype.getNamedJoints=function(e,t){var n=[];for(j=e.m_jointList;j;j=j.m_next)j.name==t&&n.push(j);return n},pt.prototype.getNamedImages=function(e,t){var n=[];for(i=0;i<e.images.length;i++)e.images[i].name==t&&n.push(e.images[i].name);return n},pt.prototype.getBodiesByCustomProperty=function(e,t,n,r){var i=[];for(b=e.m_bodyList;b;b=b.m_next){if(!b.hasOwnProperty("customProperties"))continue;for(var s=0;s<b.customProperties.length;s++){if(!b.customProperties[s].hasOwnProperty("name"))continue;if(!b.customProperties[s].hasOwnProperty(t))continue;b.customProperties[s].name==n&&b.customProperties[s][t]==r&&i.push(b)}}return i},pt.prototype.hasCustomProperty=function(e,t,n){if(!e.hasOwnProperty("customProperties"))return!1;for(var r=0;r<e.customProperties.length;r++){if(!e.customProperties[r].hasOwnProperty("name"))continue;if(!e.customProperties[r].hasOwnProperty(t))continue;return!0}return!1},pt.prototype.getCustomProperty=function(e,t,n,r){if(!e.hasOwnProperty("customProperties"))return r;for(var i=0;i<e.customProperties.length;i++){if(!e.customProperties[i].hasOwnProperty("name"))continue;if(!e.customProperties[i].hasOwnProperty(t))continue;if(e.customProperties[i].name==n)return e.customProperties[i][t]}return r},pt}),define("Game/Core/GameObjects/Items/Rube",["Game/Client/GameObjects/Item","Lib/Vendor/RubeLoader","Lib/Vendor/Box2D","Game/Config/Settings"],function(e,t,n,r){function s(s,o,u){this.rubeLoader=null,this.body=null,e.call(this,s,o,u);var a=s.getWorld();a.DestroyBody(this.body);var f=i;this.rubeLoader=new t(f,a);var l=this.rubeLoader.getScene();for(var c in l.bodies){var h=l.bodies[c],p=h.GetPosition().Copy();p.Add(new n.Common.Math.b2Vec2(u.x/r.RATIO,u.y/r.RATIO)),h.SetPosition(p),h.name=="chest"&&(this.body=h)}var d=this.body.GetDefinition();d.userData=this,this.body.SetUserData(this)}var i;return s.prototype=Object.create(e.prototype),s.prototype.flip=function(t){e.prototype.flip.call(this,t)},i={allowSleep:!0,autoClearForces:!0,body:[{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.05748672783374786,.05748672783374786,-0.05748683214187622,-0.05748683214187622],y:[-0.2322469353675842,.2322462797164917,.2322462797164917,-0.2322469353675842]}}}],linearVelocity:0,"massData-I":.001019014045596123,"massData-center":{x:-5.215406062575312e-8,y:-3.278255462646484e-7},"massData-mass":.05340443924069405,name:"upperArmLeft",position:{x:-0.1699507087469101,y:1.113796472549438},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture0",polygon:{vertices:{x:[.1718577891588211,.168481633067131,.001688212156295776,-0.1718577295541763,-0.1718577295541763,.001460619270801544],y:[-0.3928470611572266,.4921868443489075,.4921868443489075,.3841522336006165,-0.4204435348510742,-0.4519201517105103]}}},{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture2",polygon:{vertices:{x:[.1679489463567734,.1679489463567734,-0.004204027354717255,-0.004204027354717255],y:[.4449140429496765,.6170670390129089,.6170670390129089,.4449140429496765]}}}],linearVelocity:0,"massData-I":.03228222951292992,"massData-center":{x:.00885884091258049,y:.06282533705234528},"massData-mass":.335511714220047,name:"chest",position:{x:-0.05338868126273155,y:.9620395302772522},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{circle:{center:{x:-0.007499951869249344,y:.003749847412109375},radius:.2746430933475494},density:.2204959988594055,"filter-groupIndex":-55,friction:.2,name:"fixture1"},{circle:{center:{x:-0.03327952325344086,y:-0.1384725570678711},radius:.2485582530498505},density:.2204959988594055,"filter-groupIndex":-55,friction:.2,name:"fixture1"}],linearVelocity:0,"massData-I":.004164268728345633,"massData-center":{x:-0.01910765282809734,y:-0.06028826907277107},"massData-mass":.09504657238721848,name:"head",position:{x:.04257059469819069,y:1.812389135360718},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.05748683214187622,.05748683214187622,-0.05748690664768219,-0.05748690664768219],y:[-0.1419981122016907,.1419981718063354,.1419981718063354,-0.1419981122016907]}}}],linearVelocity:0,"massData-I":.0002554289239924401,"massData-center":{x:-3.725290298461914e-8,y:2.980232238769531e-8},"massData-mass":.0326521135866642,name:"lowerArmRight",position:{x:.1177217364311218,y:.8479318022727966},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.141526535153389,.141526535153389,-0.08457186818122864,-0.08457186818122864],y:[-0.1143886670470238,-0.05680520832538605,-0.05680520832538605,-0.1143886670470238]}}},{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.08623030036687851,.08623030036687851,-0.08623020350933075,-0.08623020350933075],y:[-0.1138511821627617,.1565139442682266,.1565139442682266,-0.1138511821627617]}}}],linearVelocity:0,"massData-I":.0005858240183442831,"massData-center":{x:.006215983536094427,y:-0.002008607611060143},"massData-mass":.05964682996273041,name:"lowerLegLeft",position:{x:-0.0831906795501709,y:.1298431605100632},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.05748684704303741,.05748684704303741,-0.05748672783374786,-0.05748672783374786],y:[-0.1419981122016907,.1419981718063354,.1419981718063354,-0.1419981122016907]}}}],linearVelocity:0,"massData-I":.0002554284874349833,"massData-center":{x:5.960464477539062e-8,y:2.980232238769531e-8},"massData-mass":.03265206888318062,name:"lowerArmLeft",position:{x:-0.1699528992176056,y:.8479318022727966},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.05748683214187622,.05748683214187622,-0.05748690664768219,-0.05748690664768219],y:[-0.2322469353675842,.2322462797164917,.2322462797164917,-0.2322469353675842]}}}],linearVelocity:0,"massData-I":.00101901579182595,"massData-center":{x:-3.725290298461914e-8,y:-3.278255462646484e-7},"massData-mass":.05340452119708061,name:"upperArmRight",position:{x:.1177217364311218,y:1.113796472549438},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.08623021841049194,.08623021841049194,-0.0862300843000412,-0.0862300843000412],y:[-0.2315792292356491,.2315795421600342,.2315795421600342,-0.2315792292356491]}}}],linearVelocity:0,"massData-I":.001625877106562257,"massData-center":{x:6.705522537231445e-8,y:1.564621925354004e-7},"massData-mass":.07987650483846664,name:"upperLegRight",position:{x:.03142313286662102,y:.4171121716499329},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.0862303227186203,.0862303227186203,-0.08623017370700836,-0.08623017370700836],y:[-0.2315792292356491,.2315795421600342,.2315795421600342,-0.2315792292356491]}}}],linearVelocity:0,"massData-I":.001625879434868693,"massData-center":{x:7.450580596923828e-8,y:1.564621925354004e-7},"massData-mass":.07987659424543381,name:"upperLegLeft",position:{x:-0.0831906795501709,y:.4171121716499329},type:2},{angle:0,angularVelocity:0,awake:!0,fixture:[{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.08623021841049194,.08623021841049194,-0.0862300843000412,-0.0862300843000412],y:[-0.1138515025377274,.1563164740800858,.1563164740800858,-0.1138515025377274]}}},{density:1,"filter-groupIndex":-55,friction:.2,name:"fixture3",polygon:{vertices:{x:[.141526460647583,.141526460647583,-0.08457189798355103,-0.08457189798355103],y:[-0.1143886670470238,-0.05680520832538605,-0.05680520832538605,-0.1143886670470238]}}}],linearVelocity:0,"massData-I":.0005849063745699823,"massData-center":{x:.006219535600394011,y:-0.00209923111833632},"massData-mass":.05961277708411217,name:"lowerLegRight",position:{x:.03142313286662102,y:.1298431605100632},type:2}],collisionbitplanes:{names:["bitplane1","bitplane2","bitplane3","bitplane4","bitplane5","bitplane6","bitplane7","bitplane8","bitplane9","bitplane10","bitplane11","bitplane12","bitplane13","bitplane14","bitplane15","bitplane16","bitplane17","bitplane18","bitplane19","bitplane20","bitplane21","bitplane22","bitplane23","bitplane24","bitplane25","bitplane26","bitplane27","bitplane28","bitplane29","bitplane30","bitplane31","bitplane32"]},continuousPhysics:!0,gravity:{x:0,y:-10},image:[{aspectScale:1,body:9,center:{x:.02911517955362797,y:-0.0009155124425888062},corners:{x:[-0.08536797016859055,.1435983330011368,.1435983330011368,-0.08536797016859055],y:[-0.1153986603021622,-0.1153986603021622,.1135676354169846,.1135676354169846]},file:"../../img/Characters/Chuck/lowerLeftLeg.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.08536797016859055,-0.1153986603021622,.1435983330011368,-0.1153986603021622,.1435983330011368,.1135676354169846,-0.08536797016859055,.1135676354169846],name:"image5",opacity:1,scale:.2289662957191467},{aspectScale:1,body:7,center:{x:-0.02732392773032188,y:.02671334147453308},corners:{x:[-0.1425068378448486,.08785898983478546,.08785898983478546,-0.1425068378448486],y:[-0.2324482202529907,-0.2324482202529907,.2858749032020569,.2858749032020569]},file:"../../img/Characters/Chuck/upperRightLeg.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.1425068378448486,-0.2324482202529907,.08785898983478546,-0.2324482202529907,.08785898983478546,.2858749032020569,-0.1425068378448486,.2858749032020569],name:"image6",opacity:1,scale:.5183231234550476},{aspectScale:1,body:6,center:{x:.0003027096390724182,y:.0006600618362426758},corners:{x:[-0.05836960300803185,.05897502228617668,.05897502228617668,-0.05836960300803185],y:[-0.2340291887521744,-0.2340291887521744,.2353493124246597,.2353493124246597]},file:"../../img/Characters/Chuck/upperLeftArm.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.05836960300803185,-0.2340291887521744,.05897502228617668,-0.2340291887521744,.05897502228617668,.2353493124246597,-0.05836960300803185,.2353493124246597],name:"image4",opacity:1,renderOrder:1,scale:.4693785011768341},{aspectScale:1,body:3,center:{x:.0007003694772720337,y:.001779437065124512},corners:{x:[-0.05596264451742172,.05736338347196579,.05736338347196579,-0.05596264451742172],y:[-0.1398780941963196,-0.1398780941963196,.1434369683265686,.1434369683265686]},file:"../../img/Characters/Chuck/lowerLeftArm.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.05596264451742172,-0.1398780941963196,.05736338347196579,-0.1398780941963196,.05736338347196579,.1434369683265686,-0.05596264451742172,.1434369683265686],name:"image3",opacity:1,renderOrder:1,scale:.2833150625228882},{aspectScale:1,body:1,center:{x:-0.0008481591939926147,y:-0.001265347003936768},corners:{x:[-0.1698881536722183,.1681918352842331,.1681918352842331,-0.1698881536722183],y:[-0.48021200299263,-0.48021200299263,.4776813089847565,.4776813089847565]},file:"../../img/Characters/Chuck/chest.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.1698881536722183,-0.48021200299263,.1681918352842331,-0.48021200299263,.1681918352842331,.4776813089847565,-0.1698881536722183,.4776813089847565],name:"image2",opacity:1,renderOrder:5,scale:.9578933119773865},{aspectScale:1,body:8,center:{x:.003173574805259705,y:-0.001172244548797607},corners:{x:[-0.1414211541414261,.1477683037519455,.1477683037519455,-0.1414211541414261],y:[-0.2325238138437271,-0.2325238138437271,.2301793247461319,.2301793247461319]},file:"../../img/Characters/Chuck/upperLeftLeg.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.1414211541414261,-0.2325238138437271,.1477683037519455,-0.2325238138437271,.1477683037519455,.2301793247461319,-0.1414211541414261,.2301793247461319],name:"image6",opacity:1,renderOrder:6,scale:.462703138589859},{aspectScale:1,body:4,center:{x:.02851789817214012,y:-0.0009155124425888062},corners:{x:[-0.08596524596214294,.1430010497570038,.1430010497570038,-0.08596524596214294],y:[-0.1153986603021622,-0.1153986603021622,.1135676354169846,.1135676354169846]},file:"../../img/Characters/Chuck/lowerLeftLeg.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.08596524596214294,-0.1153986603021622,.1430010497570038,-0.1153986603021622,.1430010497570038,.1135676354169846,-0.08596524596214294,.1135676354169846],name:"image5",opacity:1,renderOrder:6,scale:.2289662957191467},{aspectScale:1,body:2,center:{x:.01975236460566521,y:-0.07194232940673828},corners:{x:[-0.2679373621940613,.3074420690536499,.3074420690536499,-0.2679373621940613],y:[-0.417169988155365,-0.417169988155365,.2732853293418884,.2732853293418884]},file:"../../img/Characters/Chuck/head.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.2679373621940613,-0.417169988155365,.3074420690536499,-0.417169988155365,.3074420690536499,.2732853293418884,-0.2679373621940613,.2732853293418884],name:"image1",opacity:1,renderOrder:6,scale:.6904553174972534},{aspectScale:1,body:0,center:{x:.002138927578926086,y:.0006600618362426758},corners:{x:[-0.05653338506817818,.06081124022603035,.06081124022603035,-0.05653338506817818],y:[-0.2340291887521744,-0.2340291887521744,.2353493124246597,.2353493124246597]},file:"../../img/Characters/Chuck/upperLeftArm.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.05653338506817818,-0.2340291887521744,.06081124022603035,-0.2340291887521744,.06081124022603035,.2353493124246597,-0.05653338506817818,.2353493124246597],name:"image4",opacity:1,renderOrder:8,scale:.4693785011768341},{aspectScale:1,body:5,center:{x:.002538725733757019,y:.001779437065124512},corners:{x:[-0.05412428826093674,.05920173972845078,.05920173972845078,-0.05412428826093674],y:[-0.1398780941963196,-0.1398780941963196,.1434369683265686,.1434369683265686]},file:"../../img/Characters/Chuck/lowerLeftArm.png",filter:0,glDrawElements:[0,1,2,2,3,0],glTexCoordPointer:[0,0,1,0,1,1,0,1],glVertexPointer:[-0.05412428826093674,-0.1398780941963196,.05920173972845078,-0.1398780941963196,.05920173972845078,.1434369683265686,-0.05412428826093674,.1434369683265686],name:"image3",opacity:1,renderOrder:8,scale:.2833150625228882}],joint:[{anchorA:{x:.001047849655151367,y:-0.1790249347686768},anchorB:{x:.00104820728302002,y:.08683943748474121},bodyA:0,bodyB:5,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:0,maxMotorTorque:1,motorSpeed:0,name:"joint4",refAngle:0,type:"revolute",upperLimit:1.919862151145935},{anchorA:{x:-0.1165831685066223,y:.3330366015434265},anchorB:{x:-0.00002135336399078369,y:.1812803745269775},bodyA:1,bodyB:0,enableLimit:!1,enableMotor:!1,jointSpeed:0,lowerLimit:-2.268928050994873,maxMotorTorque:1,motorSpeed:0,name:"joint3",refAngle:0,type:"revolute",upperLimit:3.141592741012573},{anchorA:{x:.07454992830753326,y:.5068108439445496},anchorB:{x:-0.02141102217137814,y:-0.3435407876968384},bodyA:1,bodyB:2,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:-1.221730470657349,maxMotorTorque:1,motorSpeed:0,name:"joint0",refAngle:0,type:"revolute",upperLimit:.6981316804885864},{anchorA:{x:.1367489844560623,y:-0.3606387376785278},anchorB:{x:.05056380107998848,y:.1842886805534363},bodyA:1,bodyB:7,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:-0.6981316804885864,maxMotorTorque:1,motorSpeed:0,name:"joint5",refAngle:0,type:"revolute",upperLimit:1.919862151145935},{anchorA:{x:-0.08329562842845917,y:-0.354114830493927},anchorB:{x:-0.0550386905670166,y:.1909851431846619},bodyA:1,bodyB:8,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:-0.6981316804885864,maxMotorTorque:1,motorSpeed:0,name:"joint6",refAngle:0,type:"revolute",upperLimit:1.919862151145935},{anchorA:{x:.1710196435451508,y:.3308989405632019},anchorB:{x:-0.00009131431579589844,y:.1791421175003052},bodyA:1,bodyB:6,enableLimit:!1,enableMotor:!1,jointSpeed:0,lowerLimit:-2.268928050994873,maxMotorTorque:1,motorSpeed:0,name:"joint2",refAngle:0,type:"revolute",upperLimit:3.141592741012573},{anchorA:{x:.0004334598779678345,y:.08706557750701904},anchorB:{x:.0004332214593887329,y:-0.178799033164978},bodyA:3,bodyB:6,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:0,maxMotorTorque:1,motorSpeed:0,name:"joint1",refAngle:0,type:"revolute",upperLimit:1.919862151145935},{anchorA:{x:.002425249665975571,y:-0.1845821887254715},anchorB:{x:.002425376325845718,y:.1026860624551773},bodyA:7,bodyB:9,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:-2.268928050994873,maxMotorTorque:1,motorSpeed:0,name:"joint8",refAngle:0,type:"revolute",upperLimit:0},{anchorA:{x:-0.0009558200836181641,y:-0.1818936169147491},anchorB:{x:-0.0009555891156196594,y:.105518251657486},bodyA:8,bodyB:4,enableLimit:!0,enableMotor:!1,jointSpeed:0,lowerLimit:-2.268928050994873,maxMotorTorque:1,motorSpeed:0,name:"joint7",refAngle:0,type:"revolute",upperLimit:0}],positionIterations:3,stepsPerSecond:60,subStepping:!1,velocityIterations:8,warmStarting:!0},s}),define("Game/Client/GameObjects/Items/Rube",["Game/Core/GameObjects/Items/Rube"],function(e){function t(t,n,r){e.call(this,t,n,r)}return t.prototype=Object.create(e.prototype),t.prototype.createMesh=function(){},t.prototype.destroy=function(){},t.prototype.render=function(){},t.prototype.flip=function(e){},t}),define("Game/Core/Loader/Level",["Game/Config/Settings","Lib/Vendor/Box2D","Lib/Utilities/NotificationCenter","Lib/Utilities/Abstract","Game/Client/Collision/Detector","Game/Client/GameObjects/Tile","Game/Client/GameObjects/Item","Game/Client/GameObjects/Items/Skateboard","Game/Client/GameObjects/Items/RagDoll","Game/Client/GameObjects/Items/Rube"],function(e,t,n,r,i,s,o,u,a,f){function l(e,t){this.uid=e,this.engine=t,this.levelObject=null,this.isLoaded=!1,this.load(this.uid),this.spawnPoints=null}return l.prototype.load=function(t){var n=this,r=e.MAPS_PATH+t+".json";this.loadLevelDataFromPath(r,function(e){n.setup(e)})},l.prototype.setup=function(e){this.isLoaded=!0,n.trigger(n.ns.core.game.events.level.loaded)},l.prototype.createItems=function(e){for(var t=0;t<e.length;t++){var n="item-"+t;this.createItem(n,e[t])}},l.prototype.createItem=function(e,t){switch(t.type){case"ragdoll":return new a(this.engine,e,t);case"rube":return new f(this.engine,e,t);default:return new o(this.engine,e,t)}},l.prototype.createTiles=function(e){for(var t=0;t<e.length;t++)new s(this.engine,"tile-"+t,e[t])},l.prototype.createSpawnPoints=function(e){this.spawnPoints=e},l.prototype.setupLayer=function(e,t,n){},l.prototype.createContainer=function(e){},l.prototype.getRandomSpawnPoint=function(){if(!this.spawnPoints)return{x:150+Math.random()*300,y:-500};var t=this.spawnPoints.length,n=this.spawnPoints[parseInt(Math.random()*(t-1),10)];return{x:n.x/e.TILE_RATIO,y:n.y/e.TILE_RATIO}},l.prototype.destroy=function(){this.isLoaded=!1},l}),function(){var e=this,t=t||{};t.WEBGL_RENDERER=0,t.CANVAS_RENDERER=1,t.VERSION="v1.5.1",t.blendModes={NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},t.scaleModes={DEFAULT:0,LINEAR:0,NEAREST:1},t.INTERACTION_FREQUENCY=30,t.AUTO_PREVENT_DEFAULT=!0,t.RAD_TO_DEG=180/Math.PI,t.DEG_TO_RAD=Math.PI/180,t.Point=function(e,t){this.x=e||0,this.y=t||0},t.Point.prototype.clone=function(){return new t.Point(this.x,this.y)},t.Point.prototype.constructor=t.Point,t.Point.prototype.set=function(e,t){this.x=e||0,this.y=t||(t!==0?this.x:0)},t.Rectangle=function(e,t,n,r){this.x=e||0,this.y=t||0,this.width=n||0,this.height=r||0},t.Rectangle.prototype.clone=function(){return new t.Rectangle(this.x,this.y,this.width,this.height)},t.Rectangle.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;var n=this.x;if(e>=n&&e<=n+this.width){var r=this.y;if(t>=r&&t<=r+this.height)return!0}return!1},t.Rectangle.prototype.constructor=t.Rectangle,t.EmptyRectangle=new t.Rectangle(0,0,0,0),t.Polygon=function(e){e instanceof Array||(e=Array.prototype.slice.call(arguments));if(typeof e[0]=="number"){var n=[];for(var r=0,i=e.length;r<i;r+=2)n.push(new t.Point(e[r],e[r+1]));e=n}this.points=e},t.Polygon.prototype.clone=function(){var e=[];for(var n=0;n<this.points.length;n++)e.push(this.points[n].clone());return new t.Polygon(e)},t.Polygon.prototype.contains=function(e,t){var n=!1;for(var r=0,i=this.points.length-1;r<this.points.length;i=r++){var s=this.points[r].x,o=this.points[r].y,u=this.points[i].x,a=this.points[i].y,f=o>t!=a>t&&e<(u-s)*(t-o)/(a-o)+s;f&&(n=!n)}return n},t.Polygon.prototype.constructor=t.Polygon,t.Circle=function(e,t,n){this.x=e||0,this.y=t||0,this.radius=n||0},t.Circle.prototype.clone=function(){return new t.Circle(this.x,this.y,this.radius)},t.Circle.prototype.contains=function(e,t){if(this.radius<=0)return!1;var n=this.x-e,r=this.y-t,i=this.radius*this.radius;return n*=n,r*=r,n+r<=i},t.Circle.prototype.constructor=t.Circle,t.Ellipse=function(e,t,n,r){this.x=e||0,this.y=t||0,this.width=n||0,this.height=r||0},t.Ellipse.prototype.clone=function(){return new t.Ellipse(this.x,this.y,this.width,this.height)},t.Ellipse.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;var n=(e-this.x)/this.width,r=(t-this.y)/this.height;return n*=n,r*=r,n+r<=1},t.Ellipse.prototype.getBounds=function(){return new t.Rectangle(this.x,this.y,this.width,this.height)},t.Ellipse.prototype.constructor=t.Ellipse,t.determineMatrixArrayType=function(){return typeof Float32Array!="undefined"?Float32Array:Array},t.Matrix2=t.determineMatrixArrayType(),t.Matrix=function(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0},t.Matrix.prototype.fromArray=function(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]},t.Matrix.prototype.toArray=function(e){this.array||(this.array=new Float32Array(9));var t=this.array;return e?(this.array[0]=this.a,this.array[1]=this.c,this.array[2]=0,this.array[3]=this.b,this.array[4]=this.d,this.array[5]=0,this.array[6]=this.tx,this.array[7]=this.ty,this.array[8]=1):(this.array[0]=this.a,this.array[1]=this.b,this.array[2]=this.tx,this.array[3]=this.c,this.array[4]=this.d,this.array[5]=this.ty,this.array[6]=0,this.array[7]=0,this.array[8]=1),t},t.identityMatrix=new t.Matrix,t.DisplayObject=function(){this.position=new t.Point,this.scale=new t.Point(1,1),this.pivot=new t.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.defaultCursor="pointer",this.worldTransform=new t.Matrix,this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=new t.Rectangle(0,0,1,1),this._bounds=new t.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null},t.DisplayObject.prototype.constructor=t.DisplayObject,t.DisplayObject.prototype.setInteractive=function(e){this.interactive=e},Object.defineProperty(t.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(e){this._interactive=e,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(t.DisplayObject.prototype,"worldVisible",{get:function(){var e=this;do{if(!e.visible)return!1;e=e.parent}while(e);return!0}}),Object.defineProperty(t.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask&&(this._mask.isMask=!1),this._mask=e,this._mask&&(this._mask.isMask=!0)}}),Object.defineProperty(t.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(e){if(e){var t=[];for(var n=0;n<e.length;n++){var r=e[n].passes;for(var i=0;i<r.length;i++)t.push(r[i])}this._filterBlock={target:this,filterPasses:t}}this._filters=e}}),t.DisplayObject.prototype.updateTransform=function(){this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var e=this.parent.worldTransform,t=this.worldTransform,n=this.pivot.x,r=this.pivot.y,i=this._cr*this.scale.x,s=-this._sr*this.scale.y,o=this._sr*this.scale.x,u=this._cr*this.scale.y,a=this.position.x-i*n-r*s,f=this.position.y-u*r-n*o,l=e.a,c=e.b,h=e.c,p=e.d;t.a=l*i+c*o,t.b=l*s+c*u,t.tx=l*a+c*f+e.tx,t.c=h*i+p*o,t.d=h*s+p*u,t.ty=h*a+p*f+e.ty,this.worldAlpha=this.alpha*this.parent.worldAlpha},t.DisplayObject.prototype.getBounds=function(e){return e=e,t.EmptyRectangle},t.DisplayObject.prototype.getLocalBounds=function(){return this.getBounds(t.identityMatrix)},t.DisplayObject.prototype.setStageReference=function(e){this.stage=e,this._interactive&&(this.stage.dirty=!0)},t.DisplayObject.prototype._renderWebGL=function(e){e=e},t.DisplayObject.prototype._renderCanvas=function(e){e=e},Object.defineProperty(t.DisplayObject.prototype,"x",{get:function(){return this.position.x},set:function(e){this.position.x=e}}),Object.defineProperty(t.DisplayObject.prototype,"y",{get:function(){return this.position.y},set:function(e){this.position.y=e}}),t.DisplayObjectContainer=function(){t.DisplayObject.call(this),this.children=[]},t.DisplayObjectContainer.prototype=Object.create(t.DisplayObject.prototype),t.DisplayObjectContainer.prototype.constructor=t.DisplayObjectContainer,t.DisplayObjectContainer.prototype.addChild=function(e){this.addChildAt(e,this.children.length)},t.DisplayObjectContainer.prototype.addChildAt=function(e,t){if(!(t>=0&&t<=this.children.length))throw new Error(e+" The index "+t+" supplied is out of bounds "+this.children.length);e.parent&&e.parent.removeChild(e),e.parent=this,this.children.splice(t,0,e),this.stage&&e.setStageReference(this.stage)},t.DisplayObjectContainer.prototype.swapChildren=function(e,t){if(e===t)return;var n=this.children.indexOf(e),r=this.children.indexOf(t);if(n<0||r<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[n]=t,this.children[r]=e},t.DisplayObjectContainer.prototype.getChildAt=function(e){if(e>=0&&e<this.children.length)return this.children[e];throw new Error("The supplied DisplayObjects must be a child of the caller "+this)},t.DisplayObjectContainer.prototype.removeChild=function(e){var t=this.children.indexOf(e);if(t===-1)throw new Error(e+" The supplied DisplayObject must be a child of the caller "+this);this.stage&&e.removeStageReference(),e.parent=undefined,this.children.splice(t,1)},t.DisplayObjectContainer.prototype.updateTransform=function(){if(!this.visible)return;t.DisplayObject.prototype.updateTransform.call(this);for(var e=0,n=this.children.length;e<n;e++)this.children[e].updateTransform()},t.DisplayObjectContainer.prototype.getBounds=function(e){if(this.children.length===0)return t.EmptyRectangle;if(e){var n=this.worldTransform;this.worldTransform=e,this.updateTransform(),this.worldTransform=n}var r=Infinity,i=Infinity,s=-Infinity,o=-Infinity,u,a,f,l=!1;for(var c=0,h=this.children.length;c<h;c++){var p=this.children[c];if(!p.visible)continue;l=!0,u=this.children[c].getBounds(e),r=r<u.x?r:u.x,i=i<u.y?i:u.y,a=u.width+u.x,f=u.height+u.y,s=s>a?s:a,o=o>f?o:f}if(!l)return t.EmptyRectangle;var d=this._bounds;return d.x=r,d.y=i,d.width=s-r,d.height=o-i,d},t.DisplayObjectContainer.prototype.getLocalBounds=function(){var e=this.worldTransform;this.worldTransform=t.identityMatrix;for(var n=0,r=this.children.length;n<r;n++)this.children[n].updateTransform();var i=this.getBounds();return this.worldTransform=e,i},t.DisplayObjectContainer.prototype.setStageReference=function(e){this.stage=e,this._interactive&&(this.stage.dirty=!0);for(var t=0,n=this.children.length;t<n;t++){var r=this.children[t];r.setStageReference(e)}},t.DisplayObjectContainer.prototype.removeStageReference=function(){for(var e=0,t=this.children.length;e<t;e++){var n=this.children[e];n.removeStageReference()}this._interactive&&(this.stage.dirty=!0),this.stage=null},t.DisplayObjectContainer.prototype._renderWebGL=function(e){if(!this.visible||this.alpha<=0)return;var t,n;if(this._mask||this._filters){this._mask&&(e.spriteBatch.stop(),e.maskManager.pushMask(this.mask,e),e.spriteBatch.start()),this._filters&&(e.spriteBatch.flush(),e.filterManager.pushFilter(this._filterBlock));for(t=0,n=this.children.length;t<n;t++)this.children[t]._renderWebGL(e);e.spriteBatch.stop(),this._filters&&e.filterManager.popFilter(),this._mask&&e.maskManager.popMask(e),e.spriteBatch.start()}else for(t=0,n=this.children.length;t<n;t++)this.children[t]._renderWebGL(e)},t.DisplayObjectContainer.prototype._renderCanvas=function(e){if(this.visible===!1||this.alpha===0)return;this._mask&&e.maskManager.pushMask(this._mask,e.context);for(var t=0,n=this.children.length;t<n;t++){var r=this.children[t];r._renderCanvas(e)}this._mask&&e.maskManager.popMask(e.context)},t.Sprite=function(e){t.DisplayObjectContainer.call(this),this.anchor=new t.Point,this.texture=e,this._width=0,this._height=0,this.tint=16777215,this.blendMode=t.blendModes.NORMAL,e.baseTexture.hasLoaded?this.onTextureUpdate():(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},t.Sprite.prototype=Object.create(t.DisplayObjectContainer.prototype),t.Sprite.prototype.constructor=t.Sprite,Object.defineProperty(t.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(e){this.scale.x=e/this.texture.frame.width,this._width=e}}),Object.defineProperty(t.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(e){this.scale.y=e/this.texture.frame.height,this._height=e}}),t.Sprite.prototype.setTexture=function(e){this.texture.baseTexture!==e.baseTexture?(this.textureChange=!0,this.texture=e):this.texture=e,this.cachedTint=16777215,this.updateFrame=!0},t.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height),this.updateFrame=!0},t.Sprite.prototype.getBounds=function(e){var t=this.texture.frame.width,n=this.texture.frame.height,r=t*(1-this.anchor.x),i=t*-this.anchor.x,s=n*(1-this.anchor.y),o=n*-this.anchor.y,u=e||this.worldTransform,a=u.a,f=u.c,l=u.b,c=u.d,h=u.tx,p=u.ty,d=a*i+l*o+h,v=c*o+f*i+p,m=a*r+l*o+h,g=c*o+f*r+p,y=a*r+l*s+h,b=c*s+f*r+p,w=a*i+l*s+h,E=c*s+f*i+p,S=-Infinity,x=-Infinity,T=Infinity,N=Infinity;T=d<T?d:T,T=m<T?m:T,T=y<T?y:T,T=w<T?w:T,N=v<N?v:N,N=g<N?g:N,N=b<N?b:N,N=E<N?E:N,S=d>S?d:S,S=m>S?m:S,S=y>S?y:S,S=w>S?w:S,x=v>x?v:x,x=g>x?g:x,x=b>x?b:x,x=E>x?E:x;var C=this._bounds;return C.x=T,C.width=S-T,C.y=N,C.height=x-N,this._currentBounds=C,C},t.Sprite.prototype._renderWebGL=function(e){if(!this.visible||this.alpha<=0)return;var t,n;if(this._mask||this._filters){var r=e.spriteBatch;this._mask&&(r.stop(),e.maskManager.pushMask(this.mask,e),r.start()),this._filters&&(r.flush(),e.filterManager.pushFilter(this._filterBlock)),r.render(this);for(t=0,n=this.children.length;t<n;t++)this.children[t]._renderWebGL(e);r.stop(),this._filters&&e.filterManager.popFilter(),this._mask&&e.maskManager.popMask(e),r.start()}else{e.spriteBatch.render(this);for(t=0,n=this.children.length;t<n;t++)this.children[t]._renderWebGL(e)}},t.Sprite.prototype._renderCanvas=function(e){if(this.visible===!1||this.alpha===0)return;var n=this.texture.frame,r=e.context,i=this.texture;this.blendMode!==e.currentBlendMode&&(e.currentBlendMode=this.blendMode,r.globalCompositeOperation=t.blendModesCanvas[e.currentBlendMode]),this._mask&&e.maskManager.pushMask(this._mask,e.context);if(n&&n.width&&n.height&&i.baseTexture.source){r.globalAlpha=this.worldAlpha;var s=this.worldTransform;e.roundPixels?r.setTransform(s.a,s.c,s.b,s.d,s.tx||0,s.ty||0):r.setTransform(s.a,s.c,s.b,s.d,s.tx,s.ty),e.smoothProperty&&e.scaleMode!==this.texture.baseTexture.scaleMode&&(e.scaleMode=this.texture.baseTexture.scaleMode,r[e.smoothProperty]=e.scaleMode===t.scaleModes.LINEAR);if(this.tint!==16777215){if(this.cachedTint!==this.tint){if(!i.baseTexture.hasLoaded)return;this.cachedTint=this.tint,this.tintedTexture=t.CanvasTinter.getTintedTexture(this,this.tint)}r.drawImage(this.tintedTexture,0,0,n.width,n.height,this.anchor.x*-n.width,this.anchor.y*-n.height,n.width,n.height)}else if(i.trim){var o=i.trim;r.drawImage(this.texture.baseTexture.source,n.x,n.y,n.width,n.height,o.x-this.anchor.x*o.width,o.y-this.anchor.y*o.height,n.width,n.height)}else r.drawImage(this.texture.baseTexture.source,n.x,n.y,n.width,n.height,this.anchor.x*-n.width,this.anchor.y*-n.height,n.width,n.height)}for(var u=0,a=this.children.length;u<a;u++){var f=this.children[u];f._renderCanvas(e)}this._mask&&e.maskManager.popMask(e.context)},t.Sprite.fromFrame=function(e){var n=t.TextureCache[e];if(!n)throw new Error('The frameId "'+e+'" does not exist in the texture cache'+this);return new t.Sprite(n)},t.Sprite.fromImage=function(e,n,r){var i=t.Texture.fromImage(e,n,r);return new t.Sprite(i)},t.SpriteBatch=function(e){t.DisplayObjectContainer.call(this),this.textureThing=e,this.ready=!1},t.SpriteBatch.prototype=Object.create(t.DisplayObjectContainer.prototype),t.SpriteBatch.constructor=t.SpriteBatch,t.SpriteBatch.prototype.initWebGL=function(e){this.fastSpriteBatch=new t.WebGLFastSpriteBatch(e),this.ready=!0},t.SpriteBatch.prototype.updateTransform=function(){t.DisplayObject.prototype.updateTransform.call(this)},t.SpriteBatch.prototype._renderWebGL=function(e){if(!this.visible||this.alpha<=0||!this.children.length)return;this.ready||this.initWebGL(e.gl),e.spriteBatch.stop(),e.shaderManager.activateShader(e.shaderManager.fastShader),this.fastSpriteBatch.begin(this,e),this.fastSpriteBatch.render(this),e.shaderManager.activateShader(e.shaderManager.defaultShader),e.spriteBatch.start()},t.SpriteBatch.prototype._renderCanvas=function(e){var n=e.context;n.globalAlpha=this.worldAlpha;var r=this.worldTransform;e.roundPixels?n.setTransform(r.a,r.c,r.b,r.d,Math.floor(r.tx),Math.floor(r.ty)):n.setTransform(r.a,r.c,r.b,r.d,r.tx,r.ty),n.save();for(var i=0;i<this.children.length;i++){var s=this.children[i],o=s.texture,u=o.frame;n.globalAlpha=this.worldAlpha*s.alpha;if(s.rotation%(Math.PI*2)===0)n.drawImage(o.baseTexture.source,u.x,u.y,u.width,u.height,s.anchor.x*-u.width*s.scale.x+s.position.x+.5|0,s.anchor.y*-u.height*s.scale.y+s.position.y+.5|0,u.width*s.scale.x,u.height*s.scale.y);else{t.DisplayObject.prototype.updateTransform.call(s),r=s.localTransform,this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var a=s._cr*s.scale.x,f=-s._sr*s.scale.y,l=s._sr*s.scale.x,c=s._cr*s.scale.y;n.setTransform(a,l,f,c,s.position.x,s.position.y),n.drawImage(o.baseTexture.source,u.x,u.y,u.width,u.height,s.anchor.x*-u.width+.5|0,s.anchor.y*-u.height+.5|0,u.width,u.height)}}n.restore()},t.MovieClip=function(e){t.Sprite.call(this,e[0]),this.textures=e,this.animationSpeed=1,this.loop=!0,this.onComplete=null,this.currentFrame=0,this.playing=!1},t.MovieClip.prototype=Object.create(t.Sprite.prototype),t.MovieClip.prototype.constructor=t.MovieClip,Object.defineProperty(t.MovieClip.prototype,"totalFrames",{get:function(){return this.textures.length}}),t.MovieClip.prototype.stop=function(){this.playing=!1},t.MovieClip.prototype.play=function(){this.playing=!0},t.MovieClip.prototype.gotoAndStop=function(e){this.playing=!1,this.currentFrame=e;var t=this.currentFrame+.5|0;this.setTexture(this.textures[t%this.textures.length])},t.MovieClip.prototype.gotoAndPlay=function(e){this.currentFrame=e,this.playing=!0},t.MovieClip.prototype.updateTransform=function(){t.Sprite.prototype.updateTransform.call(this);if(!this.playing)return;this.currentFrame+=this.animationSpeed;var e=this.currentFrame+.5|0;this.loop||e<this.textures.length?this.setTexture(this.textures[e%this.textures.length]):e>=this.textures.length&&(this.gotoAndStop(this.textures.length-1),this.onComplete&&this.onComplete())},t.FilterBlock=function(){this.visible=!0,this.renderable=!0},t.Text=function(e,n){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),t.Sprite.call(this,t.Texture.fromCanvas(this.canvas)),this.setText(e),this.setStyle(n),this.updateText(),this.dirty=!1},t.Text.prototype=Object.create(t.Sprite.prototype),t.Text.prototype.constructor=t.Text,t.Text.prototype.setStyle=function(e){e=e||{},e.font=e.font||"bold 20pt Arial",e.fill=e.fill||"black",e.align=e.align||"left",e.stroke=e.stroke||"black",e.strokeThickness=e.strokeThickness||0,e.wordWrap=e.wordWrap||!1,e.wordWrapWidth=e.wordWrapWidth||100,this.style=e,this.dirty=!0},t.Text.prototype.setText=function(e){this.text=e.toString()||" ",this.dirty=!0},t.Text.prototype.updateText=function(){this.context.font=this.style.font;var e=this.text;this.style.wordWrap&&(e=this.wordWrap(this.text));var n=e.split(/(?:\r\n|\r|\n)/),r=[],i=0;for(var s=0;s<n.length;s++){var o=this.context.measureText(n[s]).width;r[s]=o,i=Math.max(i,o)}this.canvas.width=i+this.style.strokeThickness;var u=this.determineFontHeight("font: "+this.style.font+";")+this.style.strokeThickness;this.canvas.height=u*n.length,navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.lineWidth=this.style.strokeThickness,this.context.textBaseline="top";for(s=0;s<n.length;s++){var a=new t.Point(this.style.strokeThickness/2,this.style.strokeThickness/2+s*u);this.style.align==="right"?a.x+=i-r[s]:this.style.align==="center"&&(a.x+=(i-r[s])/2),this.style.stroke&&this.style.strokeThickness&&this.context.strokeText(n[s],a.x,a.y),this.style.fill&&this.context.fillText(n[s],a.x,a.y)}this.updateTexture()},t.Text.prototype.updateTexture=function(){this.texture.baseTexture.width=this.canvas.width,this.texture.baseTexture.height=this.canvas.height,this.texture.frame.width=this.canvas.width,this.texture.frame.height=this.canvas.height,this._width=this.canvas.width,this._height=this.canvas.height,this.requiresUpdate=!0},t.Text.prototype._renderWebGL=function(e){this.requiresUpdate&&(this.requiresUpdate=!1,t.updateWebGLTexture(this.texture.baseTexture,e.gl)),t.Sprite.prototype._renderWebGL.call(this,e)},t.Text.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),t.Sprite.prototype.updateTransform.call(this)},t.Text.prototype.determineFontHeight=function(e){var n=t.Text.heightCache[e];if(!n){var r=document.getElementsByTagName("body")[0],i=document.createElement("div"),s=document.createTextNode("M");i.appendChild(s),i.setAttribute("style",e+";position:absolute;top:0;left:0"),r.appendChild(i),n=i.offsetHeight,t.Text.heightCache[e]=n,r.removeChild(i)}return n},t.Text.prototype.wordWrap=function(e){var t="",n=e.split("\n");for(var r=0;r<n.length;r++){var i=this.style.wordWrapWidth,s=n[r].split(" ");for(var o=0;o<s.length;o++){var u=this.context.measureText(s[o]).width,a=u+this.context.measureText(" ").width;a>i?(o>0&&(t+="\n"),t+=s[o]+" ",i=this.style.wordWrapWidth-u):(i-=a,t+=s[o]+" ")}r<n.length-1&&(t+="\n")}return t},t.Text.prototype.destroy=function(e){e&&this.texture.destroy()},t.Text.heightCache={},t.BitmapText=function(e,n){t.DisplayObjectContainer.call(this),this._pool=[],this.setText(e),this.setStyle(n),this.updateText(),this.dirty=!1},t.BitmapText.prototype=Object.create(t.DisplayObjectContainer.prototype),t.BitmapText.prototype.constructor=t.BitmapText,t.BitmapText.prototype.setText=function(e){this.text=e||" ",this.dirty=!0},t.BitmapText.prototype.setStyle=function(e){e=e||{},e.align=e.align||"left",this.style=e;var n=e.font.split(" ");this.fontName=n[n.length-1],this.fontSize=n.length>=2?parseInt(n[n.length-2],10):t.BitmapText.fonts[this.fontName].size,this.dirty=!0,this.tint=e.tint},t.BitmapText.prototype.updateText=function(){var e=t.BitmapText.fonts[this.fontName],n=new t.Point,r=null,i=[],s=0,o=[],u=0,a=this.fontSize/e.size;for(var f=0;f<this.text.length;f++){var l=this.text.charCodeAt(f);if(/(?:\r\n|\r|\n)/.test(this.text.charAt(f))){o.push(n.x),s=Math.max(s,n.x),u++,n.x=0,n.y+=e.lineHeight,r=null;continue}var c=e.chars[l];if(!c)continue;r&&c[r]&&(n.x+=c.kerning[r]),i.push({texture:c.texture,line:u,charCode:l,position:new t.Point(n.x+c.xOffset,n.y+c.yOffset)}),n.x+=c.xAdvance,r=l}o.push(n.x),s=Math.max(s,n.x);var h=[];for(f=0;f<=u;f++){var p=0;this.style.align==="right"?p=s-o[f]:this.style.align==="center"&&(p=(s-o[f])/2),h.push(p)}var d=this.children.length,v=i.length,m=this.tint||16777215;for(f=0;f<v;f++){var g=f<d?this.children[f]:this._pool.pop();g?g.setTexture(i[f].texture):g=new t.Sprite(i[f].texture),g.position.x=(i[f].position.x+h[i[f].line])*a,g.position.y=i[f].position.y*a,g.scale.x=g.scale.y=a,g.tint=m,g.parent||this.addChild(g)}while(this.children.length>v){var y=this.getChildAt(this.children.length-1);this._pool.push(y),this.removeChild(y)}this.textWidth=s*a,this.textHeight=(n.y+e.lineHeight)*a},t.BitmapText.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),t.DisplayObjectContainer.prototype.updateTransform.call(this)},t.BitmapText.fonts={},t.InteractionData=function(){this.global=new t.Point,this.local=new t.Point,this.target=null,this.originalEvent=null},t.InteractionData.prototype.getLocalPosition=function(e){var n=e.worldTransform,r=this.global,i=n.a,s=n.b,o=n.tx,u=n.c,a=n.d,f=n.ty,l=1/(i*a+s*-u);return new t.Point(a*l*r.x+ -s*l*r.y+(f*s-o*a)*l,i*l*r.y+ -u*l*r.x+(-f*i+o*u)*l)},t.InteractionData.prototype.constructor=t.InteractionData,t.InteractionManager=function(e){this.stage=e,this.mouse=new t.InteractionData,this.touchs={},this.tempPoint=new t.Point,this.mouseoverEnabled=!0,this.pool=[],this.interactiveItems=[],this.interactionDOMElement=null,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this.mouseOut=!1},t.InteractionManager.prototype.constructor=t.InteractionManager,t.InteractionManager.prototype.collectInteractiveSprite=function(e,t){var n=e.children,r=n.length;for(var i=r-1;i>=0;i--){var s=n[i];s.interactive?(t.interactiveChildren=!0,this.interactiveItems.push(s),s.children.length>0&&this.collectInteractiveSprite(s,s)):(s.__iParent=null,s.children.length>0&&this.collectInteractiveSprite(s,t))}},t.InteractionManager.prototype.setTarget=function(e){this.target=e,this.interactionDOMElement===null&&this.setTargetDomElement(e.view)},t.InteractionManager.prototype.setTargetDomElement=function(e){this.removeEvents(),window.navigator.msPointerEnabled&&(e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none"),this.interactionDOMElement=e,e.addEventListener("mousemove",this.onMouseMove,!0),e.addEventListener("mousedown",this.onMouseDown,!0),e.addEventListener("mouseout",this.onMouseOut,!0),e.addEventListener("touchstart",this.onTouchStart,!0),e.addEventListener("touchend",this.onTouchEnd,!0),e.addEventListener("touchmove",this.onTouchMove,!0),document.body.addEventListener("mouseup",this.onMouseUp,!0)},t.InteractionManager.prototype.removeEvents=function(){if(!this.interactionDOMElement)return;this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]="",this.interactionDOMElement.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,document.body.removeEventListener("mouseup",this.onMouseUp,!0)},t.InteractionManager.prototype.update=function(){if(!this.target)return;var e=Date.now(),n=e-this.last;n=n*t.INTERACTION_FREQUENCY/1e3;if(n<1)return;this.last=e;var r=0;if(this.dirty){this.dirty=!1;var i=this.interactiveItems.length;for(r=0;r<i;r++)this.interactiveItems[r].interactiveChildren=!1;this.interactiveItems=[],this.stage.interactive&&this.interactiveItems.push(this.stage),this.collectInteractiveSprite(this.stage,this.stage)}var s=this.interactiveItems.length,o="inherit",u=!1;for(r=0;r<s;r++){var a=this.interactiveItems[r];a.__hit=this.hitTest(a,this.mouse),this.mouse.target=a,a.__hit&&!u?(a.buttonMode&&(o=a.defaultCursor),a.interactiveChildren||(u=!0),a.__isOver||(a.mouseover&&a.mouseover(this.mouse),a.__isOver=!0)):a.__isOver&&(a.mouseout&&a.mouseout(this.mouse),a.__isOver=!1)}this.currentCursorStyle!==o&&(this.currentCursorStyle=o,this.interactionDOMElement.style.cursor=o)},t.InteractionManager.prototype.onMouseMove=function(e){this.mouse.originalEvent=e||window.event;var t=this.interactionDOMElement.getBoundingClientRect();this.mouse.global.x=(e.clientX-t.left)*(this.target.width/t.width),this.mouse.global.y=(e.clientY-t.top)*(this.target.height/t.height);var n=this.interactiveItems.length;for(var r=0;r<n;r++){var i=this.interactiveItems[r];i.mousemove&&i.mousemove(this.mouse)}},t.InteractionManager.prototype.onMouseDown=function(e){this.mouse.originalEvent=e||window.event,t.AUTO_PREVENT_DEFAULT&&this.mouse.originalEvent.preventDefault();var n=this.interactiveItems.length;for(var r=0;r<n;r++){var i=this.interactiveItems[r];if(i.mousedown||i.click){i.__mouseIsDown=!0,i.__hit=this.hitTest(i,this.mouse);if(i.__hit){i.mousedown&&i.mousedown(this.mouse),i.__isDown=!0;if(!i.interactiveChildren)break}}}},t.InteractionManager.prototype.onMouseOut=function(){var e=this.interactiveItems.length;this.interactionDOMElement.style.cursor="inherit";for(var t=0;t<e;t++){var n=this.interactiveItems[t];n.__isOver&&(this.mouse.target=n,n.mouseout&&n.mouseout(this.mouse),n.__isOver=!1)}this.mouseOut=!0,this.mouse.global.x=-1e4,this.mouse.global.y=-1e4},t.InteractionManager.prototype.onMouseUp=function(e){this.mouse.originalEvent=e||window.event;var t=this.interactiveItems.length,n=!1;for(var r=0;r<t;r++){var i=this.interactiveItems[r];i.__hit=this.hitTest(i,this.mouse),i.__hit&&!n?(i.mouseup&&i.mouseup(this.mouse),i.__isDown&&i.click&&i.click(this.mouse),i.interactiveChildren||(n=!0)):i.__isDown&&i.mouseupoutside&&i.mouseupoutside(this.mouse),i.__isDown=!1}},t.InteractionManager.prototype.hitTest=function(e,n){var r=n.global;if(!e.worldVisible)return!1;var i=e instanceof t.Sprite,s=e.worldTransform,o=s.a,u=s.b,a=s.tx,f=s.c,l=s.d,c=s.ty,h=1/(o*l+u*-f),p=l*h*r.x+ -u*h*r.y+(c*u-a*l)*h,d=o*h*r.y+ -f*h*r.x+(-c*o+a*f)*h;n.target=e;if(e.hitArea&&e.hitArea.contains)return e.hitArea.contains(p,d)?(n.target=e,!0):!1;if(i){var v=e.texture.frame.width,m=e.texture.frame.height,g=-v*e.anchor.x,y;if(p>g&&p<g+v){y=-m*e.anchor.y;if(d>y&&d<y+m)return n.target=e,!0}}var b=e.children.length;for(var w=0;w<b;w++){var E=e.children[w],S=this.hitTest(E,n);if(S)return n.target=e,!0}return!1},t.InteractionManager.prototype.onTouchMove=function(e){var t=this.interactionDOMElement.getBoundingClientRect(),n=e.changedTouches,r,i=0;for(i=0;i<n.length;i++){var s=n[i];r=this.touchs[s.identifier],r.originalEvent=e||window.event,r.global.x=(s.clientX-t.left)*(this.target.width/t.width),r.global.y=(s.clientY-t.top)*(this.target.height/t.height),navigator.isCocoonJS&&(r.global.x=s.clientX,r.global.y=s.clientY)}var o=this.interactiveItems.length;for(i=0;i<o;i++){var u=this.interactiveItems[i];u.touchmove&&u.touchmove(r)}},t.InteractionManager.prototype.onTouchStart=function(e){var n=this.interactionDOMElement.getBoundingClientRect();t.AUTO_PREVENT_DEFAULT&&e.preventDefault();var r=e.changedTouches;for(var i=0;i<r.length;i++){var s=r[i],o=this.pool.pop();o||(o=new t.InteractionData),o.originalEvent=e||window.event,this.touchs[s.identifier]=o,o.global.x=(s.clientX-n.left)*(this.target.width/n.width),o.global.y=(s.clientY-n.top)*(this.target.height/n.height),navigator.isCocoonJS&&(o.global.x=s.clientX,o.global.y=s.clientY);var u=this.interactiveItems.length;for(var a=0;a<u;a++){var f=this.interactiveItems[a];if(f.touchstart||f.tap){f.__hit=this.hitTest(f,o);if(f.__hit){f.touchstart&&f.touchstart(o),f.__isDown=!0,f.__touchData=o;if(!f.interactiveChildren)break}}}}},t.InteractionManager.prototype.onTouchEnd=function(e){var t=this.interactionDOMElement.getBoundingClientRect(),n=e.changedTouches;for(var r=0;r<n.length;r++){var i=n[r],s=this.touchs[i.identifier],o=!1;s.global.x=(i.clientX-t.left)*(this.target.width/t.width),s.global.y=(i.clientY-t.top)*(this.target.height/t.height),navigator.isCocoonJS&&(s.global.x=i.clientX,s.global.y=i.clientY);var u=this.interactiveItems.length;for(var a=0;a<u;a++){var f=this.interactiveItems[a],l=f.__touchData;f.__hit=this.hitTest(f,s);if(l===s){s.originalEvent=e||window.event;if(f.touchend||f.tap)f.__hit&&!o?(f.touchend&&f.touchend(s),f.__isDown&&f.tap&&f.tap(s),f.interactiveChildren||(o=!0)):f.__isDown&&f.touchendoutside&&f.touchendoutside(s),f.__isDown=!1;f.__touchData=null}}this.pool.push(s),this.touchs[i.identifier]=null}},t.Stage=function(e){t.DisplayObjectContainer.call(this),this.worldTransform=new t.Matrix,this.interactive=!0,this.interactionManager=new t.InteractionManager(this),this.dirty=!0,this.stage=this,this.stage.hitArea=new t.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(e)},t.Stage.prototype=Object.create(t.DisplayObjectContainer.prototype),t.Stage.prototype.constructor=t.Stage,t.Stage.prototype.setInteractionDelegate=function(e){this.interactionManager.setTargetDomElement(e)},t.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var e=0,t=this.children.length;e<t;e++)this.children[e].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},t.Stage.prototype.setBackgroundColor=function(e){this.backgroundColor=e||0,this.backgroundColorSplit=t.hex2rgb(this.backgroundColor);var n=this.backgroundColor.toString(16);n="000000".substr(0,6-n.length)+n,this.backgroundColorString="#"+n},t.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global};var n=0,i=["ms","moz","webkit","o"];for(var s=0;s<i.length&&!window.requestAnimationFrame;++s)window.requestAnimationFrame=window[i[s]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i[s]+"CancelAnimationFrame"]||window[i[s]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var t=(new Date).getTime(),r=Math.max(0,16-(t-n)),i=window.setTimeout(function(){e(t+r)},r);return n=t+r,i}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)}),window.requestAnimFrame=window.requestAnimationFrame,t.hex2rgb=function(e){return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]},t.rgb2hex=function(e){return(e[0]*255<<16)+(e[1]*255<<8)+e[2]*255},typeof Function.prototype.bind!="function"&&(Function.prototype.bind=function(){var e=Array.prototype.slice;return function(t){function i(){var s=r.concat(e.call(arguments));n.apply(this instanceof i?this:t,s)}var n=this,r=e.call(arguments,1);if(typeof n!="function")throw new TypeError;return i.prototype=function s(e){e&&(s.prototype=e);if(!(this instanceof s))return new s}(n.prototype),i}}()),t.AjaxRequest=function(){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];if(!window.ActiveXObject)return window.XMLHttpRequest?new window.XMLHttpRequest:!1;for(var t=0;t<e.length;t++)try{return new window.ActiveXObject(e[t])}catch(n){}},t.canUseNewCanvasBlendModes=function(){var e=document.createElement("canvas");e.width=1,e.height=1;var t=e.getContext("2d");return t.fillStyle="#000",t.fillRect(0,0,1,1),t.globalCompositeOperation="multiply",t.fillStyle="#fff",t.fillRect(0,0,1,1),t.getImageData(0,0,1,1).data[0]===0},t.getNextPowerOfTwo=function(e){if(e>0&&(e&e-1)===0)return e;var t=1;while(t<e)t<<=1;return t},t.EventTarget=function(){var e={};this.addEventListener=this.on=function(t,n){e[t]===undefined&&(e[t]=[]),e[t].indexOf(n)===-1&&e[t].push(n)},this.dispatchEvent=this.emit=function(t){if(!e[t.type]||!e[t.type].length)return;for(var n=0,r=e[t.type].length;n<r;n++)e[t.type][n](t)},this.removeEventListener=this.off=function(t,n){var r=e[t].indexOf(n);r!==-1&&e[t].splice(r,1)},this.removeAllEventListeners=function(t){var n=e[t];n&&(n.length=0)}},t.autoDetectRenderer=function(e,n,r,i,s){e||(e=800),n||(n=600);var o=function(){try{var e=document.createElement("canvas");return!!window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl"))}catch(t){return!1}}();return o?new t.WebGLRenderer(e,n,r,i,s):new t.CanvasRenderer(e,n,r,i)},t.PolyK={},t.PolyK.Triangulate=function(e){var n=!0,r=e.length>>1;if(r<3)return[];var i=[],s=[];for(var o=0;o<r;o++)s.push(o);o=0;var u=r;while(u>3){var a=s[(o+0)%u],f=s[(o+1)%u],l=s[(o+2)%u],c=e[2*a],h=e[2*a+1],p=e[2*f],d=e[2*f+1],v=e[2*l],m=e[2*l+1],g=!1;if(t.PolyK._convex(c,h,p,d,v,m,n)){g=!0;for(var y=0;y<u;y++){var b=s[y];if(b===a||b===f||b===l)continue;if(t.PolyK._PointInTriangle(e[2*b],e[2*b+1],c,h,p,d,v,m)){g=!1;break}}}if(g)i.push(a,f,l),s.splice((o+1)%u,1),u--,o=0;else if(o++>3*u){if(!n)return window.console.log("PIXI Warning: shape too complex to fill"),[];i=[],s=[];for(o=0;o<r;o++)s.push(o);o=0,u=r,n=!1}}return i.push(s[0],s[1],s[2]),i},t.PolyK._PointInTriangle=function(e,t,n,r,i,s,o,u){var a=o-n,f=u-r,l=i-n,c=s-r,h=e-n,p=t-r,d=a*a+f*f,v=a*l+f*c,m=a*h+f*p,g=l*l+c*c,y=l*h+c*p,b=1/(d*g-v*v),w=(g*m-v*y)*b,E=(d*y-v*m)*b;return w>=0&&E>=0&&w+E<1},t.PolyK._convex=function(e,t,n,r,i,s,o){return(t-r)*(i-n)+(n-e)*(s-r)>=0===o},t.initDefaultShaders=function(){},t.CompileVertexShader=function(e,n){return t._CompileShader(e,n,e.VERTEX_SHADER)},t.CompileFragmentShader=function(e,n){return t._CompileShader(e,n,e.FRAGMENT_SHADER)},t._CompileShader=function(e,t,n){var r=t.join("\n"),i=e.createShader(n);return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(window.console.log(e.getShaderInfoLog(i)),null)},t.compileProgram=function(e,n,r){var i=t.CompileFragmentShader(e,r),s=t.CompileVertexShader(e,n),o=e.createProgram();return e.attachShader(o,s),e.attachShader(o,i),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)||window.console.log("Could not initialise shaders"),o},t.PixiShader=function(e){this.gl=e,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.attributes=[],this.init()},t.PixiShader.prototype.init=function(){var e=this.gl,n=t.compileProgram(e,this.vertexSrc||t.PixiShader.defaultVertexSrc,this.fragmentSrc);e.useProgram(n),this.uSampler=e.getUniformLocation(n,"uSampler"),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.dimensions=e.getUniformLocation(n,"dimensions"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];for(var r in this.uniforms)this.uniforms[r].uniformLocation=e.getUniformLocation(n,r);this.initUniforms(),this.program=n},t.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var e=this.gl,t;for(var n in this.uniforms){t=this.uniforms[n];var r=t.type;r==="sampler2D"?(t._init=!1,t.value!==null&&this.initSampler2D(t)):r==="mat2"||r==="mat3"||r==="mat4"?(t.glMatrix=!0,t.glValueLength=1,r==="mat2"?t.glFunc=e.uniformMatrix2fv:r==="mat3"?t.glFunc=e.uniformMatrix3fv:r==="mat4"&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+r],r==="2f"||r==="2i"?t.glValueLength=2:r==="3f"||r==="3i"?t.glValueLength=3:r==="4f"||r==="4i"?t.glValueLength=4:t.glValueLength=1)}},t.PixiShader.prototype.initSampler2D=function(e){if(!e.value||!e.value.baseTexture||!e.value.baseTexture.hasLoaded)return;var t=this.gl;t.activeTexture(t["TEXTURE"+this.textureCount]),t.bindTexture(t.TEXTURE_2D,e.value.baseTexture._glTexture);if(e.textureData){var n=e.textureData,r=n.magFilter?n.magFilter:t.LINEAR,i=n.minFilter?n.minFilter:t.LINEAR,s=n.wrapS?n.wrapS:t.CLAMP_TO_EDGE,o=n.wrapT?n.wrapT:t.CLAMP_TO_EDGE,u=n.luminance?t.LUMINANCE:t.RGBA;n.repeat&&(s=t.REPEAT,o=t.REPEAT),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!!n.flipY);if(n.width){var a=n.width?n.width:512,f=n.height?n.height:2,l=n.border?n.border:0;t.texImage2D(t.TEXTURE_2D,0,u,a,f,l,u,t.UNSIGNED_BYTE,null)}else t.texImage2D(t.TEXTURE_2D,0,u,t.RGBA,t.UNSIGNED_BYTE,e.value.baseTexture.source);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o)}t.uniform1i(e.uniformLocation,this.textureCount),e._init=!0,this.textureCount++},t.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var e,n=this.gl;for(var r in this.uniforms)e=this.uniforms[r],e.glValueLength===1?e.glMatrix===!0?e.glFunc.call(n,e.uniformLocation,e.transpose,e.value):e.glFunc.call(n,e.uniformLocation,e.value):e.glValueLength===2?e.glFunc.call(n,e.uniformLocation,e.value.x,e.value.y):e.glValueLength===3?e.glFunc.call(n,e.uniformLocation,e.value.x,e.value.y,e.value.z):e.glValueLength===4?e.glFunc.call(n,e.uniformLocation,e.value.x,e.value.y,e.value.z,e.value.w):e.type==="sampler2D"&&(e._init?(n.activeTexture(n["TEXTURE"+this.textureCount]),n.bindTexture(n.TEXTURE_2D,e.value.baseTexture._glTextures[n.id]||t.createWebGLTexture(e.value.baseTexture,n)),n.uniform1i(e.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(e))},t.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},t.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec2 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;"," vColor = vec4(color * aColor.x, aColor.x);","}"],t.PixiFastShader=function(e){this.gl=e,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.textureCount=0,this.init()},t.PixiFastShader.prototype.init=function(){var e=this.gl,n=t.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(n),this.uSampler=e.getUniformLocation(n,"uSampler"),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.dimensions=e.getUniformLocation(n,"dimensions"),this.uMatrix=e.getUniformLocation(n,"uMatrix"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.aPositionCoord=e.getAttribLocation(n,"aPositionCoord"),this.aScale=e.getAttribLocation(n,"aScale"),this.aRotation=e.getAttribLocation(n,"aRotation"),this.aTextureCoord=e.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=n},t.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},t.StripShader=function(){this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));"," gl_FragColor = gl_FragColor * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","uniform vec2 offsetVector;","varying float vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"]},t.StripShader.prototype.init=function(){var e=t.gl,n=t.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(n),this.uSampler=e.getUniformLocation(n,"uSampler"),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(n,"aTextureCoord"),this.translationMatrix=e.getUniformLocation(n,"translationMatrix"),this.alpha=e.getUniformLocation(n,"alpha"),this.program=n},t.PrimitiveShader=function(e){this.gl=e,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},t.PrimitiveShader.prototype.init=function(){var e=this.gl,n=t.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(n),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.tintColor=e.getUniformLocation(n,"tint"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=e.getUniformLocation(n,"translationMatrix"),this.alpha=e.getUniformLocation(n,"alpha"),this.program=n},t.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},t.WebGLGraphics=function(){},t.WebGLGraphics.renderGraphics=function(e,n){var r=n.gl,i=n.projection,s=n.offset,o=n.shaderManager.primitiveShader;e._webGL[r.id]||(e._webGL[r.id]={points:[],indices:[],lastIndex:0,buffer:r.createBuffer(),indexBuffer:r.createBuffer()});var u=e._webGL[r.id];e.dirty&&(e.dirty=!1,e.clearDirty&&(e.clearDirty=!1,u.lastIndex=0,u.points=[],u.indices=[]),t.WebGLGraphics.updateGraphics(e,r)),n.shaderManager.activatePrimitiveShader(),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.uniformMatrix3fv(o.translationMatrix,!1,e.worldTransform.toArray(!0)),r.uniform2f(o.projectionVector,i.x,-i.y),r.uniform2f(o.offsetVector,-s.x,-s.y),r.uniform3fv(o.tintColor,t.hex2rgb(e.tint)),r.uniform1f(o.alpha,e.worldAlpha),r.bindBuffer(r.ARRAY_BUFFER,u.buffer),r.vertexAttribPointer(o.aVertexPosition,2,r.FLOAT,!1,24,0),r.vertexAttribPointer(o.colorAttribute,4,r.FLOAT,!1,24,8),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,u.indexBuffer),r.drawElements(r.TRIANGLE_STRIP,u.indices.length,r.UNSIGNED_SHORT,0),n.shaderManager.deactivatePrimitiveShader()},t.WebGLGraphics.updateGraphics=function(e,n){var r=e._webGL[n.id];for(var i=r.lastIndex;i<e.graphicsData.length;i++){var s=e.graphicsData[i];s.type===t.Graphics.POLY?(s.fill&&s.points.length>3&&t.WebGLGraphics.buildPoly(s,r),s.lineWidth>0&&t.WebGLGraphics.buildLine(s,r)):s.type===t.Graphics.RECT?t.WebGLGraphics.buildRectangle(s,r):(s.type===t.Graphics.CIRC||s.type===t.Graphics.ELIP)&&t.WebGLGraphics.buildCircle(s,r)}r.lastIndex=e.graphicsData.length,r.glPoints=new Float32Array(r.points),n.bindBuffer(n.ARRAY_BUFFER,r.buffer),n.bufferData(n.ARRAY_BUFFER,r.glPoints,n.STATIC_DRAW),r.glIndicies=new Uint16Array(r.indices),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,r.indexBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,r.glIndicies,n.STATIC_DRAW)},t.WebGLGraphics.buildRectangle=function(e,n){var r=e.points,i=r[0],s=r[1],o=r[2],u=r[3];if(e.fill){var a=t.hex2rgb(e.fillColor),f=e.fillAlpha,l=a[0]*f,c=a[1]*f,h=a[2]*f,p=n.points,d=n.indices,v=p.length/6;p.push(i,s),p.push(l,c,h,f),p.push(i+o,s),p.push(l,c,h,f),p.push(i,s+u),p.push(l,c,h,f),p.push(i+o,s+u),p.push(l,c,h,f),d.push(v,v,v+1,v+2,v+3,v+3)}if(e.lineWidth){var m=e.points;e.points=[i,s,i+o,s,i+o,s+u,i,s+u,i,s],t.WebGLGraphics.buildLine(e,n),e.points=m}},t.WebGLGraphics.buildCircle=function(e,n){var r=e.points,i=r[0],s=r[1],o=r[2],u=r[3],a=40,f=Math.PI*2/a,l=0;if(e.fill){var c=t.hex2rgb(e.fillColor),h=e.fillAlpha,p=c[0]*h,d=c[1]*h,v=c[2]*h,m=n.points,g=n.indices,y=m.length/6;g.push(y);for(l=0;l<a+1;l++)m.push(i,s,p,d,v,h),m.push(i+Math.sin(f*l)*o,s+Math.cos(f*l)*u,p,d,v,h),g.push(y++,y++);g.push(y-1)}if(e.lineWidth){var b=e.points;e.points=[];for(l=0;l<a+1;l++)e.points.push(i+Math.sin(f*l)*o,s+Math.cos(f*l)*u);t.WebGLGraphics.buildLine(e,n),e.points=b}},t.WebGLGraphics.buildLine=function(e,n){var r=0,i=e.points;if(i.length===0)return;if(e.lineWidth%2)for(r=0;r<i.length;r++)i[r]+=.5;var s=new t.Point(i[0],i[1]),o=new t.Point(i[i.length-2],i[i.length-1]);if(s.x===o.x&&s.y===o.y){i.pop(),i.pop(),o=new t.Point(i[i.length-2],i[i.length-1]);var u=o.x+(s.x-o.x)*.5,a=o.y+(s.y-o.y)*.5;i.unshift(u,a),i.push(u,a)}var f=n.points,l=n.indices,c=i.length/2,h=i.length,p=f.length/6,d=e.lineWidth/2,v=t.hex2rgb(e.lineColor),m=e.lineAlpha,g=v[0]*m,y=v[1]*m,b=v[2]*m,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F,I,q,R,U;S=i[0],x=i[1],T=i[2],N=i[3],L=-(x-N),A=S-T,U=Math.sqrt(L*L+A*A),L/=U,A/=U,L*=d,A*=d,f.push(S-L,x-A,g,y,b,m),f.push(S+L,x+A,g,y,b,m);for(r=1;r<c-1;r++){S=i[(r-1)*2],x=i[(r-1)*2+1],T=i[r*2],N=i[r*2+1],C=i[(r+1)*2],k=i[(r+1)*2+1],L=-(x-N),A=S-T,U=Math.sqrt(L*L+A*A),L/=U,A/=U,L*=d,A*=d,O=-(N-k),M=T-C,U=Math.sqrt(O*O+M*M),O/=U,M/=U,O*=d,M*=d,P=-A+x-(-A+N),H=-L+T-(-L+S),B=(-L+S)*(-A+N)-(-L+T)*(-A+x),j=-M+k-(-M+N),F=-O+T-(-O+C),I=(-O+C)*(-M+N)-(-O+T)*(-M+k),q=P*F-j*H;if(Math.abs(q)<.1){q+=10.1,f.push(T-L,N-A,g,y,b,m),f.push(T+L,N+A,g,y,b,m);continue}w=(H*I-F*B)/q,E=(j*B-P*I)/q,R=(w-T)*(w-T)+(E-N)+(E-N),R>19600?(_=L-O,D=A-M,U=Math.sqrt(_*_+D*D),_/=U,D/=U,_*=d,D*=d,f.push(T-_,N-D),f.push(g,y,b,m),f.push(T+_,N+D),f.push(g,y,b,m),f.push(T-_,N-D),f.push(g,y,b,m),h++):(f.push(w,E),f.push(g,y,b,m),f.push(T-(w-T),N-(E-N)),f.push(g,y,b,m))}S=i[(c-2)*2],x=i[(c-2)*2+1],T=i[(c-1)*2],N=i[(c-1)*2+1],L=-(x-N),A=S-T,U=Math.sqrt(L*L+A*A),L/=U,A/=U,L*=d,A*=d,f.push(T-L,N-A),f.push(g,y,b,m),f.push(T+L,N+A),f.push(g,y,b,m),l.push(p);for(r=0;r<h;r++)l.push(p++);l.push(p-1)},t.WebGLGraphics.buildPoly=function(e,n){var r=e.points;if(r.length<6)return;var i=n.points,s=n.indices,o=r.length/2,u=t.hex2rgb(e.fillColor),a=e.fillAlpha,f=u[0]*a,l=u[1]*a,c=u[2]*a,h=t.PolyK.Triangulate(r),p=i.length/6,d=0;for(d=0;d<h.length;d+=3)s.push(h[d]+p),s.push(h[d]+p),s.push(h[d+1]+p),s.push(h[d+2]+p),s.push(h[d+2]+p);for(d=0;d<o;d++)i.push(r[d*2],r[d*2+1],f,l,c,a)},t.glContexts=[],t.WebGLRenderer=function(e,n,r,i,s){t.defaultRenderer||(t.defaultRenderer=this),this.type=t.WEBGL_RENDERER,this.transparent=!!i,this.width=e||800,this.height=n||600,this.view=r||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height,this.contextLost=this.handleContextLost.bind(this),this.contextRestoredLost=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.contextLost,!1),this.view.addEventListener("webglcontextrestored",this.contextRestoredLost,!1),this.options={alpha:this.transparent,antialias:!!s,premultipliedAlpha:!!i,stencil:!0};try{this.gl=this.view.getContext("experimental-webgl",this.options)}catch(o){try{this.gl=this.view.getContext("webgl",this.options)}catch(u){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}var a=this.gl;this.glContextId=a.id=t.WebGLRenderer.glContextId++,t.glContexts[this.glContextId]=a,t.blendModesWebGL||(t.blendModesWebGL=[],t.blendModesWebGL[t.blendModes.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],t.blendModesWebGL[t.blendModes.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.SCREEN]=[a.SRC_ALPHA,a.ONE],t.blendModesWebGL[t.blendModes.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],t.blendModesWebGL[t.blendModes.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA]),this.projection=new t.Point,this.projection.x=this.width/2,this.projection.y=-this.height/2,this.offset=new t.Point(0,0),this.resize(this.width,this.height),this.contextLost=!1,this.shaderManager=new t.WebGLShaderManager(a),this.spriteBatch=new t.WebGLSpriteBatch(a),this.maskManager=new t.WebGLMaskManager(a),this.filterManager=new t.WebGLFilterManager(a,this.transparent),this.renderSession={},this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.spriteBatch=this.spriteBatch,a.useProgram(this.shaderManager.defaultShader.program),a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),a.colorMask(!0,!0,!0,this.transparent)},t.WebGLRenderer.prototype.constructor=t.WebGLRenderer,t.WebGLRenderer.prototype.render=function(e){if(this.contextLost)return;this.__stage!==e&&(e.interactive&&e.interactionManager.removeEvents(),this.__stage=e),t.WebGLRenderer.updateTextures(),e.updateTransform();var n=this.gl;n.viewport(0,0,this.width,this.height),n.bindFramebuffer(n.FRAMEBUFFER,null),this.transparent?n.clearColor(0,0,0,0):n.clearColor(e.backgroundColorSplit[0],e.backgroundColorSplit[1],e.backgroundColorSplit[2],1),n.clear(n.COLOR_BUFFER_BIT),this.renderDisplayObject(e,this.projection),e.interactive?e._interactiveEventsAdded||(e._interactiveEventsAdded=!0,e.interactionManager.setTarget(this)):e._interactiveEventsAdded&&(e._interactiveEventsAdded=!1,e.interactionManager.setTarget(this))},t.WebGLRenderer.prototype.renderDisplayObject=function(e,t,n){this.renderSession.drawCount=0,this.renderSession.currentBlendMode=9999,this.renderSession.projection=t,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,n),e._renderWebGL(this.renderSession),this.spriteBatch.end()},t.WebGLRenderer.updateTextures=function(){var e=0;for(e=0;e<t.Texture.frameUpdates.length;e++)t.WebGLRenderer.updateTextureFrame(t.Texture.frameUpdates[e]);for(e=0;e<t.texturesToDestroy.length;e++)t.WebGLRenderer.destroyTexture(t.texturesToDestroy[e]);t.texturesToUpdate.length=0,t.texturesToDestroy.length=0,t.Texture.frameUpdates.length=0},t.WebGLRenderer.destroyTexture=function(e){for(var n=e._glTextures.length-1;n>=0;n--){var r=e._glTextures[n],i=t.glContexts[n];i&&r&&i.deleteTexture(r)}e._glTextures.length=0},t.WebGLRenderer.updateTextureFrame=function(e){e.updateFrame=!1,e._updateWebGLuvs()},t.WebGLRenderer.prototype.resize=function(e,t){this.width=e,this.height=t,this.view.width=e,this.view.height=t,this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2,this.projection.y=-this.height/2},t.createWebGLTexture=function(e,n){return e.hasLoaded&&(e._glTextures[n.id]=n.createTexture(),n.bindTexture(n.TEXTURE_2D,e._glTextures[n.id]),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.source),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),e._powerOf2?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),n.bindTexture(n.TEXTURE_2D,null)),e._glTextures[n.id]},t.updateWebGLTexture=function(e,n){e._glTextures[n.id]&&(n.bindTexture(n.TEXTURE_2D,e._glTextures[n.id]),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.source),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),e._powerOf2?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),n.bindTexture(n.TEXTURE_2D,null))},t.WebGLRenderer.prototype.handleContextLost=function(e){e.preventDefault(),this.contextLost=!0},t.WebGLRenderer.prototype.handleContextRestored=function(){try{this.gl=this.view.getContext("experimental-webgl",this.options)}catch(e){try{this.gl=this.view.getContext("webgl",this.options)}catch(n){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}var r=this.gl;r.id=t.WebGLRenderer.glContextId++,this.shaderManager.setContext(r),this.spriteBatch.setContext(r),this.maskManager.setContext(r),this.filterManager.setContext(r),this.renderSession.gl=this.gl,r.disable(r.DEPTH_TEST),r.disable(r.CULL_FACE),r.enable(r.BLEND),r.colorMask(!0,!0,!0,this.transparent),this.gl.viewport(0,0,this.width,this.height);for(var i in t.TextureCache){var s=t.TextureCache[i].baseTexture;s._glTextures=[]}this.contextLost=!1},t.WebGLRenderer.prototype.destroy=function(){this.view.removeEventListener("webglcontextlost",this.contextLost),this.view.removeEventListener("webglcontextrestored",this.contextRestoredLost),t.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null},t.WebGLRenderer.glContextId=0,t.WebGLMaskManager=function(e){this.maskStack=[],this.maskPosition=0,this.setContext(e)},t.WebGLMaskManager.prototype.setContext=function(e){this.gl=e},t.WebGLMaskManager.prototype.pushMask=function(e,n){var r=this.gl;this.maskStack.length===0&&(r.enable(r.STENCIL_TEST),r.stencilFunc(r.ALWAYS,1,1)),this.maskStack.push(e),r.colorMask(!1,!1,!1,!0),r.stencilOp(r.KEEP,r.KEEP,r.INCR),t.WebGLGraphics.renderGraphics(e,n),r.colorMask(!0,!0,!0,!0),r.stencilFunc(r.NOTEQUAL,0,this.maskStack.length),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)},t.WebGLMaskManager.prototype.popMask=function(e){var n=this.gl,r=this.maskStack.pop();r&&(n.colorMask(!1,!1,!1,!1),n.stencilOp(n.KEEP,n.KEEP,n.DECR),t.WebGLGraphics.renderGraphics(r,e),n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.NOTEQUAL,0,this.maskStack.length),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)),this.maskStack.length===0&&n.disable(n.STENCIL_TEST)},t.WebGLMaskManager.prototype.destroy=function(){this.maskStack=null,this.gl=null},t.WebGLShaderManager=function(e){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var t=0;t<this.maxAttibs;t++)this.attribState[t]=!1;this.setContext(e)},t.WebGLShaderManager.prototype.setContext=function(e){this.gl=e,this.primitiveShader=new t.PrimitiveShader(e),this.defaultShader=new t.PixiShader(e),this.fastShader=new t.PixiFastShader(e),this.activateShader(this.defaultShader)},t.WebGLShaderManager.prototype.setAttribs=function(e){var t;for(t=0;t<this.tempAttribState.length;t++)this.tempAttribState[t]=!1;for(t=0;t<e.length;t++){var n=e[t];this.tempAttribState[n]=!0}var r=this.gl;for(t=0;t<this.attribState.length;t++)this.attribState[t]!==this.tempAttribState[t]&&(this.attribState[t]=this.tempAttribState[t],this.tempAttribState[t]?r.enableVertexAttribArray(t):r.disableVertexAttribArray(t))},t.WebGLShaderManager.prototype.activateShader=function(e){this.currentShader=e,this.gl.useProgram(e.program),this.setAttribs(e.attributes)},t.WebGLShaderManager.prototype.activatePrimitiveShader=function(){var e=this.gl;e.useProgram(this.primitiveShader.program),this.setAttribs(this.primitiveShader.attributes)},t.WebGLShaderManager.prototype.deactivatePrimitiveShader=function(){var e=this.gl;e.useProgram(this.defaultShader.program),this.setAttribs(this.defaultShader.attributes)},t.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.gl=null},t.WebGLSpriteBatch=function(e){this.vertSize=6,this.size=1e4;var t=this.size*4*this.vertSize,n=this.size*6;this.vertices=new Float32Array(t),this.indices=new Uint16Array(n),this.lastIndexCount=0;for(var r=0,i=0;r<n;r+=6,i+=4)this.indices[r+0]=i+0,this.indices[r+1]=i+1,this.indices[r+2]=i+2,this.indices[r+3]=i+0,this.indices[r+4]=i+2,this.indices[r+5]=i+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.setContext(e)},t.WebGLSpriteBatch.prototype.setContext=function(e){this.gl=e,this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),this.currentBlendMode=99999},t.WebGLSpriteBatch.prototype.begin=function(e){this.renderSession=e,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},t.WebGLSpriteBatch.prototype.end=function(){this.flush()},t.WebGLSpriteBatch.prototype.render=function(e){if(e.texture.baseTexture!==this.currentBaseTexture||this.currentBatchSize>=this.size)this.flush(),this.currentBaseTexture=e.texture.baseTexture;e.blendMode!==this.currentBlendMode&&this.setBlendMode(e.blendMode);var t=e._uvs||e.texture._uvs;if(!t)return;var n=e.worldAlpha,r=e.tint,i=this.vertices,s=e.texture.frame.width,o=e.texture.frame.height,u=e.anchor.x,a=e.anchor.y,f,l,c,h;if(e.texture.trim){var p=e.texture.trim;l=p.x-u*p.width,f=l+s,h=p.y-a*p.height,c=h+o}else f=s*(1-u),l=s*-u,c=o*(1-a),h=o*-a;var d=this.currentBatchSize*4*this.vertSize,v=e.worldTransform,m=v.a,g=v.c,y=v.b,b=v.d,w=v.tx,E=v.ty;i[d++]=m*l+y*h+w,i[d++]=b*h+g*l+E,i[d++]=t.x0,i[d++]=t.y0,i[d++]=n,i[d++]=r,i[d++]=m*f+y*h+w,i[d++]=b*h+g*f+E,i[d++]=t.x1,i[d++]=t.y1,i[d++]=n,i[d++]=r,i[d++]=m*f+y*c+w,i[d++]=b*c+g*f+E,i[d++]=t.x2,i[d++]=t.y2,i[d++]=n,i[d++]=r,i[d++]=m*l+y*c+w,i[d++]=b*c+g*l+E,i[d++]=t.x3,i[d++]=t.y3,i[d++]=n,i[d++]=r,this.currentBatchSize++},t.WebGLSpriteBatch.prototype.renderTilingSprite=function(e){var n=e.tilingTexture;if(n.baseTexture!==this.currentBaseTexture||this.currentBatchSize>=this.size)this.flush(),this.currentBaseTexture=n.baseTexture;e.blendMode!==this.currentBlendMode&&this.setBlendMode(e.blendMode),e._uvs||(e._uvs=new t.TextureUvs);var r=e._uvs;e.tilePosition.x%=n.baseTexture.width,e.tilePosition.y%=n.baseTexture.height;var i=e.tilePosition.x/n.baseTexture.width,s=e.tilePosition.y/n.baseTexture.height,o=e.width/n.baseTexture.width/(e.tileScale.x*e.tileScaleOffset.x),u=e.height/n.baseTexture.height/(e.tileScale.y*e.tileScaleOffset.y);r.x0=0-i,r.y0=0-s,r.x1=1*o-i,r.y1=0-s,r.x2=1*o-i,r.y2=1*u-s,r.x3=0-i,r.y3=1*u-s;var a=e.worldAlpha,f=e.tint,l=this.vertices,c=e.width,h=e.height,p=e.anchor.x,d=e.anchor.y,v=c*(1-p),m=c*-p,g=h*(1-d),y=h*-d,b=this.currentBatchSize*4*this.vertSize,w=e.worldTransform,E=w.a,S=w.c,x=w.b,T=w.d,N=w.tx,C=w.ty;l[b++]=E*m+x*y+N,l[b++]=T*y+S*m+C,l[b++]=r.x0,l[b++]=r.y0,l[b++]=a,l[b++]=f,l[b++]=E*v+x*y+N,l[b++]=T*y+S*v+C,l[b++]=r.x1,l[b++]=r.y1,l[b++]=a,l[b++]=f,l[b++]=E*v+x*g+N,l[b++]=T*g+S*v+C,l[b++]=r.x2,l[b++]=r.y2,l[b++]=a,l[b++]=f,l[b++]=E*m+x*g+N,l[b++]=T*g+S*m+C,l[b++]=r.x3,l[b++]=r.y3,l[b++]=a,l[b++]=f,this.currentBatchSize++},t.WebGLSpriteBatch.prototype.flush=function(){if(this.currentBatchSize===0)return;var e=this.gl;e.bindTexture(e.TEXTURE_2D,this.currentBaseTexture._glTextures[e.id]||t.createWebGLTexture(this.currentBaseTexture,e));if(this.currentBatchSize>this.size*.5)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var n=this.vertices.subarray(0,this.currentBatchSize*4*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}e.drawElements(e.TRIANGLES,this.currentBatchSize*6,e.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++},t.WebGLSpriteBatch.prototype.stop=function(){this.flush()},t.WebGLSpriteBatch.prototype.start=function(){var e=this.gl;e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var n=this.renderSession.projection;e.uniform2f(this.shader.projectionVector,n.x,n.y);var r=this.vertSize*4;e.vertexAttribPointer(this.shader.aVertexPosition,2,e.FLOAT,!1,r,0),e.vertexAttribPointer(this.shader.aTextureCoord,2,e.FLOAT,!1,r,8),e.vertexAttribPointer(this.shader.colorAttribute,2,e.FLOAT,!1,r,16),this.currentBlendMode!==t.blendModes.NORMAL&&this.setBlendMode(t.blendModes.NORMAL)},t.WebGLSpriteBatch.prototype.setBlendMode=function(e){this.flush(),this.currentBlendMode=e;var n=t.blendModesWebGL[this.currentBlendMode];this.gl.blendFunc(n[0],n[1])},t.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},t.WebGLFastSpriteBatch=function(e){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var t=this.size*4*this.vertSize,n=this.maxSize*6;this.vertices=new Float32Array(t),this.indices=new Uint16Array(n),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var r=0,i=0;r<n;r+=6,i+=4)this.indices[r+0]=i+0,this.indices[r+1]=i+1,this.indices[r+2]=i+2,this.indices[r+3]=i+0,this.indices[r+4]=i+2,this.indices[r+5]=i+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(e)},t.WebGLFastSpriteBatch.prototype.setContext=function(e){this.gl=e,this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),this.currentBlendMode=99999},t.WebGLFastSpriteBatch.prototype.begin=function(e,t){this.renderSession=t,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=e.worldTransform.toArray(!0),this.start()},t.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},t.WebGLFastSpriteBatch.prototype.render=function(e){var t=e.children,n=t[0];if(!n.texture._uvs)return;this.currentBaseTexture=n.texture.baseTexture,n.blendMode!==this.currentBlendMode&&this.setBlendMode(n.blendMode);for(var r=0,i=t.length;r<i;r++)this.renderSprite(t[r]);this.flush()},t.WebGLFastSpriteBatch.prototype.renderSprite=function(e){if(e.texture.baseTexture!==this.currentBaseTexture){this.flush(),this.currentBaseTexture=e.texture.baseTexture;if(!e.texture._uvs)return}var t,n=this.vertices,r,i,s,o,u,a,f;t=e.texture._uvs,r=e.texture.frame.width,i=e.texture.frame.height;if(e.texture.trim){var l=e.texture.trim;o=l.x-e.anchor.x*l.width,s=o+e.texture.frame.width,a=l.y-e.anchor.y*l.height,u=a+e.texture.frame.height}else s=e.texture.frame.width*(1-e.anchor.x),o=e.texture.frame.width*-e.anchor.x,u=e.texture.frame.height*(1-e.anchor.y),a=e.texture.frame.height*-e.anchor.y;f=this.currentBatchSize*4*this.vertSize,n[f++]=o,n[f++]=a,n[f++]=e.position.x,n[f++]=e.position.y,n[f++]=e.scale.x,n[f++]=e.scale.y,n[f++]=e.rotation,n[f++]=t.x0,n[f++]=t.y1,n[f++]=e.alpha,n[f++]=s,n[f++]=a,n[f++]=e.position.x,n[f++]=e.position.y,n[f++]=e.scale.x,n[f++]=e.scale.y,n[f++]=e.rotation,n[f++]=t.x1,n[f++]=t.y1,n[f++]=e.alpha,n[f++]=s,n[f++]=u,n[f++]=e.position.x,n[f++]=e.position.y,n[f++]=e.scale.x,n[f++]=e.scale.y,n[f++]=e.rotation,n[f++]=t.x2,n[f++]=t.y2,n[f++]=e.alpha,n[f++]=o,n[f++]=u,n[f++]=e.position.x,n[f++]=e.position.y,n[f++]=e.scale.x,n[f++]=e.scale.y,n[f++]=e.rotation,n[f++]=t.x3,n[f++]=t.y3,n[f++]=e.alpha,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()},t.WebGLFastSpriteBatch.prototype.flush=function(){if(this.currentBatchSize===0)return;var e=this.gl;this.currentBaseTexture._glTextures[e.id]||t.createWebGLTexture(this.currentBaseTexture,e),e.bindTexture(e.TEXTURE_2D,this.currentBaseTexture._glTextures[e.id]);if(this.currentBatchSize>this.size*.5)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var n=this.vertices.subarray(0,this.currentBatchSize*4*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}e.drawElements(e.TRIANGLES,this.currentBatchSize*6,e.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++},t.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},t.WebGLFastSpriteBatch.prototype.start=function(){var e=this.gl;e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var n=this.renderSession.projection;e.uniform2f(this.shader.projectionVector,n.x,n.y),e.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var r=this.vertSize*4;e.vertexAttribPointer(this.shader.aVertexPosition,2,e.FLOAT,!1,r,0),e.vertexAttribPointer(this.shader.aPositionCoord,2,e.FLOAT,!1,r,8),e.vertexAttribPointer(this.shader.aScale,2,e.FLOAT,!1,r,16),e.vertexAttribPointer(this.shader.aRotation,1,e.FLOAT,!1,r,24),e.vertexAttribPointer(this.shader.aTextureCoord,2,e.FLOAT,!1,r,28),e.vertexAttribPointer(this.shader.colorAttribute,1,e.FLOAT,!1,r,36),this.currentBlendMode!==t.blendModes.NORMAL&&this.setBlendMode(t.blendModes.NORMAL)},t.WebGLFastSpriteBatch.prototype.setBlendMode=function(e){this.flush(),this.currentBlendMode=e;var n=t.blendModesWebGL[this.currentBlendMode];this.gl.blendFunc(n[0],n[1])},t.WebGLFilterManager=function(e,t){this.transparent=t,this.filterStack=[],this.offsetX=0,this.offsetY=0,this.setContext(e)},t.WebGLFilterManager.prototype.setContext=function(e){this.gl=e,this.texturePool=[],this.initShaderBuffers()},t.WebGLFilterManager.prototype.begin=function(e,t){this.renderSession=e,this.defaultShader=e.shaderManager.defaultShader;var n=this.renderSession.projection;this.width=n.x*2,this.height=-n.y*2,this.buffer=t},t.WebGLFilterManager.prototype.pushFilter=function(e){var n=this.gl,r=this.renderSession.projection,i=this.renderSession.offset;this.filterStack.push(e);var s=e.filterPasses[0];this.offsetX+=e.target.filterArea.x,this.offsetY+=e.target.filterArea.y;var o=this.texturePool.pop();o?o.resize(this.width,this.height):o=new t.FilterTexture(this.gl,this.width,this.height),n.bindTexture(n.TEXTURE_2D,o.texture),e.target.filterArea=e.target.getBounds();var u=e.target.filterArea,a=s.padding;u.x-=a,u.y-=a,u.width+=a*2,u.height+=a*2,u.x<0&&(u.x=0),u.width>this.width&&(u.width=this.width),u.y<0&&(u.y=0),u.height>this.height&&(u.height=this.height),n.bindFramebuffer(n.FRAMEBUFFER,o.frameBuffer),n.viewport(0,0,u.width,u.height),r.x=u.width/2,r.y=-u.height/2,i.x=-u.x,i.y=-u.y,n.uniform2f(this.defaultShader.projectionVector,u.width/2,-u.height/2),n.uniform2f(this.defaultShader.offsetVector,-u.x,-u.y),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),e._glFilterTexture=o},t.WebGLFilterManager.prototype.popFilter=function(){var e=this.gl,n=this.filterStack.pop(),r=n.target.filterArea,i=n._glFilterTexture,s=this.renderSession.projection,o=this.renderSession.offset;if(n.filterPasses.length>1){e.viewport(0,0,r.width,r.height),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=r.height,this.vertexArray[2]=r.width,this.vertexArray[3]=r.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=r.width,this.vertexArray[7]=0,e.bufferSubData(e.ARRAY_BUFFER,0,this.vertexArray),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=r.width/this.width,this.uvArray[5]=r.height/this.height,this.uvArray[6]=r.width/this.width,this.uvArray[7]=r.height/this.height,e.bufferSubData(e.ARRAY_BUFFER,0,this.uvArray);var u=i,a=this.texturePool.pop();a||(a=new t.FilterTexture(this.gl,this.width,this.height)),e.bindFramebuffer(e.FRAMEBUFFER,a.frameBuffer),e.clear(e.COLOR_BUFFER_BIT),e.disable(e.BLEND);for(var f=0;f<n.filterPasses.length-1;f++){var l=n.filterPasses[f];e.bindFramebuffer(e.FRAMEBUFFER,a.frameBuffer),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,u.texture),this.applyFilterPass(l,r,r.width,r.height);var c=u;u=a,a=c}e.enable(e.BLEND),i=u,this.texturePool.push(a)}var h=n.filterPasses[n.filterPasses.length-1];this.offsetX-=r.x,this.offsetY-=r.y;var p=this.width,d=this.height,v=0,m=0,g=this.buffer;if(this.filterStack.length===0)e.colorMask(!0,!0,!0,this.transparent);else{var y=this.filterStack[this.filterStack.length-1];r=y.target.filterArea,p=r.width,d=r.height,v=r.x,m=r.y,g=y._glFilterTexture.frameBuffer}s.x=p/2,s.y=-d/2,o.x=v,o.y=m,r=n.target.filterArea;var b=r.x-v,w=r.y-m;e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=b,this.vertexArray[1]=w+r.height,this.vertexArray[2]=b+r.width,this.vertexArray[3]=w+r.height,this.vertexArray[4]=b,this.vertexArray[5]=w,this.vertexArray[6]=b+r.width,this.vertexArray[7]=w,e.bufferSubData(e.ARRAY_BUFFER,0,this.vertexArray),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=r.width/this.width,this.uvArray[5]=r.height/this.height,this.uvArray[6]=r.width/this.width,this.uvArray[7]=r.height/this.height,e.bufferSubData(e.ARRAY_BUFFER,0,this.uvArray),e.viewport(0,0,p,d),e.bindFramebuffer(e.FRAMEBUFFER,g),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i.texture),this.applyFilterPass(h,r,p,d),e.useProgram(this.defaultShader.program),e.uniform2f(this.defaultShader.projectionVector,p/2,-d/2),e.uniform2f(this.defaultShader.offsetVector,-v,-m),this.texturePool.push(i),n._glFilterTexture=null},t.WebGLFilterManager.prototype.applyFilterPass=function(e,n,r,i){var s=this.gl,o=e.shaders[s.id];o||(o=new t.PixiShader(s),o.fragmentSrc=e.fragmentSrc,o.uniforms=e.uniforms,o.init(),e.shaders[s.id]=o),s.useProgram(o.program),s.uniform2f(o.projectionVector,r/2,-i/2),s.uniform2f(o.offsetVector,0,0),e.uniforms.dimensions&&(e.uniforms.dimensions.value[0]=this.width,e.uniforms.dimensions.value[1]=this.height,e.uniforms.dimensions.value[2]=this.vertexArray[0],e.uniforms.dimensions.value[3]=this.vertexArray[5]),o.syncUniforms(),s.bindBuffer(s.ARRAY_BUFFER,this.vertexBuffer),s.vertexAttribPointer(o.aVertexPosition,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this.uvBuffer),s.vertexAttribPointer(o.aTextureCoord,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this.colorBuffer),s.vertexAttribPointer(o.colorAttribute,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.indexBuffer),s.drawElements(s.TRIANGLES,6,s.UNSIGNED_SHORT,0),this.renderSession.drawCount++},t.WebGLFilterManager.prototype.initShaderBuffers=function(){var e=this.gl;this.vertexBuffer=e.createBuffer(),this.uvBuffer=e.createBuffer(),this.colorBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexArray,e.STATIC_DRAW),this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvArray,e.STATIC_DRAW),this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),e.bindBuffer(e.ARRAY_BUFFER,this.colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colorArray,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),e.STATIC_DRAW)},t.WebGLFilterManager.prototype.destroy=function(){var e=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var t=0;t<this.texturePool.length;t++)this.texturePool.destroy();this.texturePool=null,e.deleteBuffer(this.vertexBuffer),e.deleteBuffer(this.uvBuffer),e.deleteBuffer(this.colorBuffer),e.deleteBuffer(this.indexBuffer)},t.FilterTexture=function(e,t,n){this.gl=e,this.frameBuffer=e.createFramebuffer(),this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer),e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture,0),this.resize(t,n)},t.FilterTexture.prototype.clear=function(){var e=this.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},t.FilterTexture.prototype.resize=function(e,t){if(this.width===e&&this.height===t)return;this.width=e,this.height=t;var n=this.gl;n.bindTexture(n.TEXTURE_2D,this.texture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e,t,0,n.RGBA,n.UNSIGNED_BYTE,null)},t.FilterTexture.prototype.destroy=function(){var e=this.gl;e.deleteFramebuffer(this.frameBuffer),e.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},t.CanvasMaskManager=function(){},t.CanvasMaskManager.prototype.pushMask=function(e,n){n.save();var r=e.alpha,i=e.worldTransform;n.setTransform(i.a,i.c,i.b,i.d,i.tx,i.ty),t.CanvasGraphics.renderGraphicsMask(e,n),n.clip(),e.worldAlpha=r},t.CanvasMaskManager.prototype.popMask=function(e){e.restore()},t.CanvasTinter=function(){},t.CanvasTinter.getTintedTexture=function(e,n){var r=e.texture;n=t.CanvasTinter.roundColor(n);var i="#"+("00000"+(n|0).toString(16)).substr(-6);r.tintCache=r.tintCache||{};if(r.tintCache[i])return r.tintCache[i];var s=t.CanvasTinter.canvas||document.createElement("canvas");t.CanvasTinter.tintMethod(r,n,s);if(t.CanvasTinter.convertTintToImage){var o=new Image;o.src=s.toDataURL(),r.tintCache[i]=o}else r.tintCache[i]=s,t.CanvasTinter.canvas=null;return s},t.CanvasTinter.tintWithMultiply=function(e,t,n){var r=n.getContext("2d"),i=e.frame;n.width=i.width,n.height=i.height,r.fillStyle="#"+("00000"+(t|0).toString(16)).substr(-6),r.fillRect(0,0,i.width,i.height),r.globalCompositeOperation="multiply",r.drawImage(e.baseTexture.source,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(e.baseTexture.source,i.x,i.y,i.width,i.height,0,0,i.width,i.height)},t.CanvasTinter.tintWithOverlay=function(e,t,n){var r=n.getContext("2d"),i=e.frame;n.width=i.width,n.height=i.height,r.globalCompositeOperation="copy",r.fillStyle="#"+("00000"+(t|0).toString(16)).substr(-6),r.fillRect(0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(e.baseTexture.source,i.x,i.y,i.width,i.height,0,0,i.width,i.height)},t.CanvasTinter.tintWithPerPixel=function(e,n,r){var i=r.getContext("2d"),s=e.frame;r.width=s.width,r.height=s.height,i.globalCompositeOperation="copy",i.drawImage(e.baseTexture.source,s.x,s.y,s.width,s.height,0,0,s.width,s.height);var o=t.hex2rgb(n),u=o[0],a=o[1],f=o[2],l=i.getImageData(0,0,s.width,s.height),c=l.data;for(var h=0;h<c.length;h+=4)c[h+0]*=u,c[h+1]*=a,c[h+2]*=f;i.putImageData(l,0,0)},t.CanvasTinter.roundColor=function(e){var n=t.CanvasTinter.cacheStepsPerColorChannel,r=t.hex2rgb(e);return r[0]=Math.min(255,r[0]/n*n),r[1]=Math.min(255,r[1]/n*n),r[2]=Math.min(255,r[2]/n*n),t.rgb2hex(r)},t.CanvasTinter.cacheStepsPerColorChannel=8,t.CanvasTinter.convertTintToImage=!1,t.CanvasTinter.canUseMultiply=t.canUseNewCanvasBlendModes(),t.CanvasTinter.tintMethod=t.CanvasTinter.canUseMultiply?t.CanvasTinter.tintWithMultiply:t.CanvasTinter.tintWithPerPixel,t.CanvasRenderer=function(e,n,r,i){t.defaultRenderer=t.defaultRenderer||this,this.type=t.CANVAS_RENDERER,this.clearBeforeRender=!0,this.roundPixels=!1,this.transparent=!!i,t.blendModesCanvas||(t.blendModesCanvas=[],t.canUseNewCanvasBlendModes()?(t.blendModesCanvas[t.blendModes.NORMAL]="source-over",t.blendModesCanvas[t.blendModes.ADD]="lighter",t.blendModesCanvas[t.blendModes.MULTIPLY]="multiply",t.blendModesCanvas[t.blendModes.SCREEN]="screen",t.blendModesCanvas[t.blendModes.OVERLAY]="overlay",t.blendModesCanvas[t.blendModes.DARKEN]="darken",t.blendModesCanvas[t.blendModes.LIGHTEN]="lighten",t.blendModesCanvas[t.blendModes.COLOR_DODGE]="color-dodge",t.blendModesCanvas[t.blendModes.COLOR_BURN]="color-burn",t.blendModesCanvas[t.blendModes.HARD_LIGHT]="hard-light",t.blendModesCanvas[t.blendModes.SOFT_LIGHT]="soft-light",t.blendModesCanvas[t.blendModes.DIFFERENCE]="difference",t.blendModesCanvas[t.blendModes.EXCLUSION]="exclusion",t.blendModesCanvas[t.blendModes.HUE]="hue",t.blendModesCanvas[t.blendModes.SATURATION]="saturation",t.blendModesCanvas[t.blendModes.COLOR]="color",t.blendModesCanvas[t.blendModes.LUMINOSITY]="luminosity"):(t.blendModesCanvas[t.blendModes.NORMAL]="source-over",t.blendModesCanvas[t.blendModes.ADD]="lighter",t.blendModesCanvas[t.blendModes.MULTIPLY]="source-over",t.blendModesCanvas[t.blendModes.SCREEN]="source-over",t.blendModesCanvas[t.blendModes.OVERLAY]="source-over",t.blendModesCanvas[t.blendModes.DARKEN]="source-over",t.blendModesCanvas[t.blendModes.LIGHTEN]="source-over",t.blendModesCanvas[t.blendModes.COLOR_DODGE]="source-over",t.blendModesCanvas[t.blendModes.COLOR_BURN]="source-over",t.blendModesCanvas[t.blendModes.HARD_LIGHT]="source-over",t.blendModesCanvas[t.blendModes.SOFT_LIGHT]="source-over",t.blendModesCanvas[t.blendModes.DIFFERENCE]="source-over",t.blendModesCanvas[t.blendModes.EXCLUSION]="source-over",t.blendModesCanvas[t.blendModes.HUE]="source-over",t.blendModesCanvas[t.blendModes.SATURATION]="source-over",t.blendModesCanvas[t.blendModes.COLOR]="source-over",t.blendModesCanvas[t.blendModes.LUMINOSITY]="source-over")),this.width=e||800,this.height=n||600,this.view=r||document.createElement("canvas"),this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.view.width=this.width,this.view.height=this.height,this.count=0,this.maskManager=new t.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:null},"imageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="imageSmoothingEnabled":"webkitImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="webkitImageSmoothingEnabled":"mozImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="mozImageSmoothingEnabled":"oImageSmoothingEnabled"in this.context&&(this.renderSession.smoothProperty="oImageSmoothingEnabled")},t.CanvasRenderer.prototype.constructor=t.CanvasRenderer,t.CanvasRenderer.prototype.render=function(e){t.texturesToUpdate.length=0,t.texturesToDestroy.length=0,e.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,!this.transparent&&this.clearBeforeRender?(this.context.fillStyle=e.backgroundColorString,this.context.fillRect(0,0,this.width,this.height)):this.transparent&&this.clearBeforeRender&&this.context.clearRect(0,0,this.width,this.height),this.renderDisplayObject(e),e.interactive&&(e._interactiveEventsAdded||(e._interactiveEventsAdded=!0,e.interactionManager.setTarget(this))),t.Texture.frameUpdates.length>0&&(t.Texture.frameUpdates.length=0)},t.CanvasRenderer.prototype.resize=function(e,t){this.width=e,this.height=t,this.view.width=e,this.view.height=t},t.CanvasRenderer.prototype.renderDisplayObject=function(e,t){this.renderSession.context=t||this.context,e._renderCanvas(this.renderSession)},t.CanvasRenderer.prototype.renderStripFlat=function(e){var t=this.context,n=e.verticies,r=n.length/2;this.count++,t.beginPath();for(var i=1;i<r-2;i++){var s=i*2,o=n[s],u=n[s+2],a=n[s+4],f=n[s+1],l=n[s+3],c=n[s+5];t.moveTo(o,f),t.lineTo(u,l),t.lineTo(a,c)}t.fillStyle="#FF0000",t.fill(),t.closePath()},t.CanvasRenderer.prototype.renderStrip=function(e){var t=this.context,n=e.verticies,r=e.uvs,i=n.length/2;this.count++;for(var s=1;s<i-2;s++){var o=s*2,u=n[o],a=n[o+2],f=n[o+4],l=n[o+1],c=n[o+3],h=n[o+5],p=r[o]*e.texture.width,d=r[o+2]*e.texture.width,v=r[o+4]*e.texture.width,m=r[o+1]*e.texture.height,g=r[o+3]*e.texture.height,y=r[o+5]*e.texture.height;t.save(),t.beginPath(),t.moveTo(u,l),t.lineTo(a,c),t.lineTo(f,h),t.closePath(),t.clip();var b=p*g+m*v+d*y-g*v-m*d-p*y,w=u*g+m*f+a*y-g*f-m*a-u*y,E=p*a+u*v+d*f-a*v-u*d-p*f,S=p*g*f+m*a*v+u*d*y-u*g*v-m*d*f-p*a*y,x=l*g+m*h+c*y-g*h-m*c-l*y,T=p*c+l*v+d*h-c*v-l*d-p*h,N=p*g*h+m*c*v+l*d*y-l*g*v-m*d*h-p*c*y;t.transform(w/b,x/b,E/b,T/b,S/b,N/b),t.drawImage(e.texture.baseTexture.source,0,0),t.restore()}},t.CanvasBuffer=function(e,t){this.width=e,this.height=t,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.canvas.width=e,this.canvas.height=t},t.CanvasBuffer.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},t.CanvasBuffer.prototype.resize=function(e,t){this.width=this.canvas.width=e,this.height=this.canvas.height=t},t.CanvasGraphics=function(){},t.CanvasGraphics.renderGraphics=function(e,n){var r=e.worldAlpha,i="";for(var s=0;s<e.graphicsData.length;s++){var o=e.graphicsData[s],u=o.points;n.strokeStyle=i="#"+("00000"+(o.lineColor|0).toString(16)).substr(-6),n.lineWidth=o.lineWidth;if(o.type===t.Graphics.POLY){n.beginPath(),n.moveTo(u[0],u[1]);for(var a=1;a<u.length/2;a++)n.lineTo(u[a*2],u[a*2+1]);u[0]===u[u.length-2]&&u[1]===u[u.length-1]&&n.closePath(),o.fill&&(n.globalAlpha=o.fillAlpha*r,n.fillStyle=i="#"+("00000"+(o.fillColor|0).toString(16)).substr(-6),n.fill()),o.lineWidth&&(n.globalAlpha=o.lineAlpha*r,n.stroke())}else if(o.type===t.Graphics.RECT){if(o.fillColor||o.fillColor===0)n.globalAlpha=o.fillAlpha*r,n.fillStyle=i="#"+("00000"+(o.fillColor|0).toString(16)).substr(-6),n.fillRect(u[0],u[1],u[2],u[3]);o.lineWidth&&(n.globalAlpha=o.lineAlpha*r,n.strokeRect(u[0],u[1],u[2],u[3]))}else if(o.type===t.Graphics.CIRC)n.beginPath(),n.arc(u[0],u[1],u[2],0,2*Math.PI),n.closePath(),o.fill&&(n.globalAlpha=o.fillAlpha*r,n.fillStyle=i="#"+("00000"+(o.fillColor|0).toString(16)).substr(-6),n.fill()),o.lineWidth&&(n.globalAlpha=o.lineAlpha*r,n.stroke());else if(o.type===t.Graphics.ELIP){var f=o.points,l=f[2]*2,c=f[3]*2,h=f[0]-l/2,p=f[1]-c/2;n.beginPath();var d=.5522848,v=l/2*d,m=c/2*d,g=h+l,y=p+c,b=h+l/2,w=p+c/2;n.moveTo(h,w),n.bezierCurveTo(h,w-m,b-v,p,b,p),n.bezierCurveTo(b+v,p,g,w-m,g,w),n.bezierCurveTo(g,w+m,b+v,y,b,y),n.bezierCurveTo(b-v,y,h,w+m,h,w),n.closePath(),o.fill&&(n.globalAlpha=o.fillAlpha*r,n.fillStyle=i="#"+("00000"+(o.fillColor|0).toString(16)).substr(-6),n.fill()),o.lineWidth&&(n.globalAlpha=o.lineAlpha*r,n.stroke())}}},t.CanvasGraphics.renderGraphicsMask=function(e,n){var r=e.graphicsData.length;if(r===0)return;r>1&&(r=1,window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var i=0;i<1;i++){var s=e.graphicsData[i],o=s.points;if(s.type===t.Graphics.POLY){n.beginPath(),n.moveTo(o[0],o[1]);for(var u=1;u<o.length/2;u++)n.lineTo(o[u*2],o[u*2+1]);o[0]===o[o.length-2]&&o[1]===o[o.length-1]&&n.closePath()}else if(s.type===t.Graphics.RECT)n.beginPath(),n.rect(o[0],o[1],o[2],o[3]),n.closePath();else if(s.type===t.Graphics.CIRC)n.beginPath(),n.arc(o[0],o[1],o[2],0,2*Math.PI),n.closePath();else if(s.type===t.Graphics.ELIP){var a=s.points,f=a[2]*2,l=a[3]*2,c=a[0]-f/2,h=a[1]-l/2;n.beginPath();var p=.5522848,d=f/2*p,v=l/2*p,m=c+f,g=h+l,y=c+f/2,b=h+l/2;n.moveTo(c,b),n.bezierCurveTo(c,b-v,y-d,h,y,h),n.bezierCurveTo(y+d,h,m,b-v,m,b),n.bezierCurveTo(m,b+v,y+d,g,y,g),n.bezierCurveTo(y-d,g,c,b+v,c,b),n.closePath()}}},t.Graphics=function(){t.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.tint=16777215,this.blendMode=t.blendModes.NORMAL,this.currentPath={points:[]},this._webGL=[],this.isMask=!1,this.bounds=null,this.boundsPadding=10},t.Graphics.prototype=Object.create(t.DisplayObjectContainer.prototype),t.Graphics.prototype.constructor=t.Graphics,Object.defineProperty(t.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(e){this._cacheAsBitmap=e,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),t.Graphics.prototype.lineStyle=function(e,n,r){return this.currentPath.points.length||this.graphicsData.pop(),this.lineWidth=e||0,this.lineColor=n||0,this.lineAlpha=arguments.length<3?1:r,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:t.Graphics.POLY},this.graphicsData.push(this.currentPath),this},t.Graphics.prototype.moveTo=function(e,n){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:t.Graphics.POLY},this.currentPath.points.push(e,n),this.graphicsData.push(this.currentPath),this},t.Graphics.prototype.lineTo=function(e,t){return this.currentPath.points.push(e,t),this.dirty=!0,this},t.Graphics.prototype.beginFill=function(e,t){return this.filling=!0,this.fillColor=e||0,this.fillAlpha=arguments.length<2?1:t,this},t.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},t.Graphics.prototype.drawRect=function(e,n,r,i){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[e,n,r,i],type:t.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0,this},t.Graphics.prototype.drawCircle=function(e,n,r){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[e,n,r,r],type:t.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0,this},t.Graphics.prototype.drawEllipse=function(e,n,r,i){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[e,n,r,i],type:t.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0,this},t.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this.bounds=null,this},t.Graphics.prototype.generateTexture=function(){var e=this.getBounds(),n=new t.CanvasBuffer(e.width,e.height),r=t.Texture.fromCanvas(n.canvas);return n.context.translate(-e.x,-e.y),t.CanvasGraphics.renderGraphics(this,n.context),r},t.Graphics.prototype._renderWebGL=function(e){if(this.visible===!1||this.alpha===0||this.isMask===!0)return;if(this._cacheAsBitmap){this.dirty&&(this._generateCachedSprite(),t.updateWebGLTexture(this._cachedSprite.texture.baseTexture,e.gl),this.dirty=!1),t.Sprite.prototype._renderWebGL.call(this._cachedSprite,e);return}e.spriteBatch.stop(),this._mask&&e.maskManager.pushMask(this.mask,e),this._filters&&e.filterManager.pushFilter(this._filterBlock);if(this.blendMode!==e.spriteBatch.currentBlendMode){e.spriteBatch.currentBlendMode=this.blendMode;var n=t.blendModesWebGL[e.spriteBatch.currentBlendMode];e.spriteBatch.gl.blendFunc(n[0],n[1])}t.WebGLGraphics.renderGraphics(this,e);if(this.children.length){e.spriteBatch.start();for(var r=0,i=this.children.length;r<i;r++)this.children[r]._renderWebGL(e);e.spriteBatch.stop()}this._filters&&e.filterManager.popFilter(),this._mask&&e.maskManager.popMask(e),e.drawCount++,e.spriteBatch.start()},t.Graphics.prototype._renderCanvas=function(e){if(this.visible===!1||this.alpha===0||this.isMask===!0)return;var n=e.context,r=this.worldTransform;this.blendMode!==e.currentBlendMode&&(e.currentBlendMode=this.blendMode,n.globalCompositeOperation=t.blendModesCanvas[e.currentBlendMode]),n.setTransform(r.a,r.c,r.b,r.d,r.tx,r.ty),t.CanvasGraphics.renderGraphics(this,n);for(var i=0,s=this.children.length;i<s;i++)this.children[i]._renderCanvas(e)},t.Graphics.prototype.getBounds=function(e){this.bounds||this.updateBounds();var t=this.bounds.x,n=this.bounds.width+this.bounds.x,r=this.bounds.y,i=this.bounds.height+this.bounds.y,s=e||this.worldTransform,o=s.a,u=s.c,a=s.b,f=s.d,l=s.tx,c=s.ty,h=o*n+a*i+l,p=f*i+u*n+c,d=o*t+a*i+l,v=f*i+u*t+c,m=o*t+a*r+l,g=f*r+u*t+c,y=o*n+a*r+l,b=f*r+u*n+c,w=-Infinity,E=-Infinity,S=Infinity,x=Infinity;S=h<S?h:S,S=d<S?d:S,S=m<S?m:S,S=y<S?y:S,x=p<x?p:x,x=v<x?v:x,x=g<x?g:x,x=b<x?b:x,w=h>w?h:w,w=d>w?d:w,w=m>w?m:w,w=y>w?y:w,E=p>E?p:E,E=v>E?v:E,E=g>E?g:E,E=b>E?b:E;var T=this._bounds;return T.x=S,T.width=w-S,T.y=x,T.height=E-x,T},t.Graphics.prototype.updateBounds=function(){var e=Infinity,n=-Infinity,r=Infinity,i=-Infinity,s,o,u,a,f;for(var l=0;l<this.graphicsData.length;l++){var c=this.graphicsData[l],h=c.type,p=c.lineWidth;s=c.points;if(h===t.Graphics.RECT)o=s[0]-p/2,u=s[1]-p/2,a=s[2]+p,f=s[3]+p,e=o<e?o:e,n=o+a>n?o+a:n,r=u<r?o:r,i=u+f>i?u+f:i;else if(h===t.Graphics.CIRC||h===t.Graphics.ELIP)o=s[0],u=s[1],a=s[2]+p/2,f=s[3]+p/2,e=o-a<e?o-a:e,n=o+a>n?o+a:n,r=u-f<r?u-f:r,i=u+f>i?u+f:i;else for(var d=0;d<s.length;d+=2)o=s[d],u=s[d+1],e=o-p<e?o-p:e,n=o+p>n?o+p:n,r=u-p<r?u-p:r,i=u+p>i?u+p:i}var v=this.boundsPadding;this.bounds=new t.Rectangle(e-v,r-v,n-e+v*2,i-r+v*2)},t.Graphics.prototype._generateCachedSprite=function(){var e=this.getLocalBounds();if(!this._cachedSprite){var n=new t.CanvasBuffer(e.width,e.height),r=t.Texture.fromCanvas(n.canvas);this._cachedSprite=new t.Sprite(r),this._cachedSprite.buffer=n,this._cachedSprite.worldTransform=this.worldTransform}else this._cachedSprite.buffer.resize(e.width,e.height);this._cachedSprite.anchor.x=-(e.x/e.width),this._cachedSprite.anchor.y=-(e.y/e.height),this._cachedSprite.buffer.context.translate(-e.x,-e.y),t.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context)},t.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},t.Graphics.POLY=0,t.Graphics.RECT=1,t.Graphics.CIRC=2,t.Graphics.ELIP=3,t.Strip=function(e,n,r){t.DisplayObjectContainer.call(this),this.texture=e,this.blendMode=t.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(i){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=n,this.height=r,e.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},t.Strip.prototype=Object.create(t.DisplayObjectContainer.prototype),t.Strip.prototype.constructor=t.Strip,t.Strip.prototype.setTexture=function(e){this.texture=e,this.width=e.frame.width,this.height=e.frame.height,this.updateFrame=!0},t.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},t.Rope=function(e,n){t.Strip.call(this,e),this.points=n;try{this.verticies=new Float32Array(n.length*4),this.uvs=new Float32Array(n.length*4),this.colors=new Float32Array(n.length*2),this.indices=new Uint16Array(n.length*2)}catch(r){this.verticies=new Array(n.length*4),this.uvs=new Array(n.length*4),this.colors=new Array(n.length*2),this.indices=new Array(n.length*2)}this.refresh()},t.Rope.prototype=Object.create(t.Strip.prototype),t.Rope.prototype.constructor=t.Rope,t.Rope.prototype.refresh=function(){var e=this.points;if(e.length<1)return;var t=this.uvs,n=e[0],r=this.indices,i=this.colors;this.count-=.2,t[0]=0,t[1]=1,t[2]=0,t[3]=1,i[0]=1,i[1]=1,r[0]=0,r[1]=1;var s=e.length,o,u,a;for(var f=1;f<s;f++)o=e[f],u=f*4,a=f/(s-1),f%2?(t[u]=a,t[u+1]=0,t[u+2]=a,t[u+3]=1):(t[u]=a,t[u+1]=0,t[u+2]=a,t[u+3]=1),u=f*2,i[u]=1,i[u+1]=1,u=f*2,r[u]=u,r[u+1]=u+1,n=o},t.Rope.prototype.updateTransform=function(){var e=this.points;if(e.length<1)return;var n=e[0],r,i={x:0,y:0};this.count-=.2;var s=this.verticies;s[0]=n.x+i.x,s[1]=n.y+i.y,s[2]=n.x-i.x,s[3]=n.y-i.y;var o=e.length,u,a,f,l,c;for(var h=1;h<o;h++)u=e[h],a=h*4,h<e.length-1?r=e[h+1]:r=u,i.y=-(r.x-n.x),i.x=r.y-n.y,f=(1-h/(o-1))*10,f>1&&(f=1),l=Math.sqrt(i.x*i.x+i.y*i.y),c=this.texture.height/2,i.x/=l,i.y/=l,i.x*=c,i.y*=c,s[a]=u.x+i.x,s[a+1]=u.y+i.y,s[a+2]=u.x-i.x,s[a+3]=u.y-i.y,n=u;t.DisplayObjectContainer.prototype.updateTransform.call(this)},t.Rope.prototype.setTexture=function(e){this.texture=e,this.updateFrame=!0},t.TilingSprite=function(e,n,r){t.Sprite.call(this,e),this.width=n||100,this.height=r||100,this.tileScale=new t.Point(1,1),this.tileScaleOffset=new t.Point(1,1),this.tilePosition=new t.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=t.blendModes.NORMAL},t.TilingSprite.prototype=Object.create(t.Sprite.prototype),t.TilingSprite.prototype.constructor=t.TilingSprite,Object.defineProperty(t.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(t.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),t.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},t.TilingSprite.prototype._renderWebGL=function(e){if(this.visible===!1||this.alpha===0)return;var t,n;if(this.mask||this.filters){this.mask&&(e.spriteBatch.stop(),e.maskManager.pushMask(this.mask,e),e.spriteBatch.start()),this.filters&&(e.spriteBatch.flush(),e.filterManager.pushFilter(this._filterBlock)),this.tilingTexture?e.spriteBatch.renderTilingSprite(this):this.generateTilingTexture(!0);for(t=0,n=this.children.length;t<n;t++)this.children[t]._renderWebGL(e);e.spriteBatch.stop(),this.filters&&e.filterManager.popFilter(),this.mask&&e.maskManager.popMask(e),e.spriteBatch.start()}else{this.tilingTexture?e.spriteBatch.renderTilingSprite(this):this.generateTilingTexture(!0);for(t=0,n=this.children.length;t<n;t++)this.children[t]._renderWebGL(e)}},t.TilingSprite.prototype._renderCanvas=function(e){if(this.visible===!1||this.alpha===0)return;var n=e.context;this._mask&&e.maskManager.pushMask(this._mask,n),n.globalAlpha=this.worldAlpha;var r=this.worldTransform;n.setTransform(r.a,r.c,r.b,r.d,r.tx,r.ty),this.__tilePattern||(this.generateTilingTexture(!1),this.tilingTexture&&(this.__tilePattern=n.createPattern(this.tilingTexture.baseTexture.source,"repeat"))),this.blendMode!==e.currentBlendMode&&(e.currentBlendMode=this.blendMode,n.globalCompositeOperation=t.blendModesCanvas[e.currentBlendMode]),n.beginPath();var i=this.tilePosition,s=this.tileScale;i.x%=this.tilingTexture.baseTexture.width,i.y%=this.tilingTexture.baseTexture.height,n.scale(s.x,s.y),n.translate(i.x,i.y),n.fillStyle=this.__tilePattern,n.fillRect(-i.x,-i.y,this.width/s.x,this.height/s.y),n.scale(1/s.x,1/s.y),n.translate(-i.x,-i.y),n.closePath(),this._mask&&e.maskManager.popMask(e.context)},t.TilingSprite.prototype.getBounds=function(){var e=this._width,t=this._height,n=e*(1-this.anchor.x),r=e*-this.anchor.x,i=t*(1-this.anchor.y),s=t*-this.anchor.y,o=this.worldTransform,u=o.a,a=o.c,f=o.b,l=o.d,c=o.tx,h=o.ty,p=u*r+f*s+c,d=l*s+a*r+h,v=u*n+f*s+c,m=l*s+a*n+h,g=u*n+f*i+c,y=l*i+a*n+h,b=u*r+f*i+c,w=l*i+a*r+h,E=-Infinity,S=-Infinity,x=Infinity,T=Infinity;x=p<x?p:x,x=v<x?v:x,x=g<x?g:x,x=b<x?b:x,T=d<T?d:T,T=m<T?m:T,T=y<T?y:T,T=w<T?w:T,E=p>E?p:E,E=v>E?v:E,E=g>E?g:E,E=b>E?b:E,S=d>S?d:S,S=m>S?m:S,S=y>S?y:S,S=w>S?w:S;var N=this._bounds;return N.x=x,N.width=E-x,N.y=T,N.height=S-T,this._currentBounds=N,N},t.TilingSprite.prototype.generateTilingTexture=function(e){var n=this.texture;if(!n.baseTexture.hasLoaded)return;var r=n.baseTexture,i=n.frame,s,o,u=i.width!==r.width||i.height!==r.height;this.tilingTexture=n;var a=!1;e?(s=t.getNextPowerOfTwo(n.frame.width),o=t.getNextPowerOfTwo(n.frame.height),i.width!==s&&i.height!==o&&(a=!0)):u&&(s=i.width,o=i.height,a=!0);if(a){var f=new t.CanvasBuffer(s,o);f.context.drawImage(n.baseTexture.source,i.x,i.y,i.width,i.height,0,0,s,o),this.tilingTexture=t.Texture.fromCanvas(f.canvas),this.tileScaleOffset.x=i.width/s,this.tileScaleOffset.y=i.height/o}this.tilingTexture.baseTexture._powerOf2=!0};var o={};o.BoneData=function(e,t){this.name=e,this.parent=t},o.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1},o.SlotData=function(e,t){this.name=e,this.boneData=t},o.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null},o.Bone=function(e,t){this.data=e,this.parent=t,this.setToSetupPose()},o.Bone.yDown=!1,o.Bone.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,updateWorldTransform:function(e,t){var n=this.parent;n!=null?(this.worldX=this.x*n.m00+this.y*n.m01+n.worldX,this.worldY=this.x*n.m10+this.y*n.m11+n.worldY,this.worldScaleX=n.worldScaleX*this.scaleX,this.worldScaleY=n.worldScaleY*this.scaleY,this.worldRotation=n.worldRotation+this.rotation):(this.worldX=this.x,this.worldY=this.y,this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY,this.worldRotation=this.rotation);var r=this.worldRotation*Math.PI/180,i=Math.cos(r),s=Math.sin(r);this.m00=i*this.worldScaleX,this.m10=s*this.worldScaleX,this.m01=-s*this.worldScaleY,this.m11=i*this.worldScaleY,e&&(this.m00=-this.m00,this.m01=-this.m01),t&&(this.m10=-this.m10,this.m11=-this.m11),o.Bone.yDown&&(this.m10=-this.m10,this.m11=-this.m11)},setToSetupPose:function(){var e=this.data;this.x=e.x,this.y=e.y,this.rotation=e.rotation,this.scaleX=e.scaleX,this.scaleY=e.scaleY}},o.Slot=function(e,t,n){this.data=e,this.skeleton=t,this.bone=n,this.setToSetupPose()},o.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,setAttachment:function(e){this.attachment=e,this._attachmentTime=this.skeleton.time},setAttachmentTime:function(e){this._attachmentTime=this.skeleton.time-e},getAttachmentTime:function(){return this.skeleton.time-this._attachmentTime},setToSetupPose:function(){var e=this.data;this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a;var t=this.skeleton.data.slots;for(var n=0,r=t.length;n<r;n++)if(t[n]==e){this.setAttachment(e.attachmentName?this.skeleton.getAttachmentBySlotIndex(n,e.attachmentName):null);break}}},o.Skin=function(e){this.name=e,this.attachments={}},o.Skin.prototype={addAttachment:function(e,t,n){this.attachments[e+":"+t]=n},getAttachment:function(e,t){return this.attachments[e+":"+t]},_attachAll:function(e,t){for(var n in t.attachments){var r=n.indexOf(":"),i=parseInt(n.substring(0,r),10),s=n.substring(r+1),o=e.slots[i];if(o.attachment&&o.attachment.name==s){var u=this.getAttachment(i,s);u&&o.setAttachment(u)}}}},o.Animation=function(e,t,n){this.name=e,this.timelines=t,this.duration=n},o.Animation.prototype={apply:function(e,t,n){n&&this.duration&&(t%=this.duration);var r=this.timelines;for(var i=0,s=r.length;i<s;i++)r[i].apply(e,t,1)},mix:function(e,t,n,r){n&&this.duration&&(t%=this.duration);var i=this.timelines;for(var s=0,o=i.length;s<o;s++)i[s].apply(e,t,r)}},o.binarySearch=function(e,t,n){var r=0,i=Math.floor(e.length/n)-2;if(!i)return n;var s=i>>>1;for(;;){e[(s+1)*n]<=t?r=s+1:i=s;if(r==i)return(r+1)*n;s=r+i>>>1}},o.linearSearch=function(e,t,n){for(var r=0,i=e.length-n;r<=i;r+=n)if(e[r]>t)return r;return-1},o.Curves=function(e){this.curves=[],this.curves.length=(e-1)*6},o.Curves.prototype={setLinear:function(e){this.curves[e*6]=0},setStepped:function(e){this.curves[e*6]=-1},setCurve:function(e,t,n,r,i){var s=.1,o=s*s,u=o*s,a=3*s,f=3*o,l=6*o,c=6*u,h=-t*2+r,p=-n*2+i,d=(t-r)*3+1,v=(n-i)*3+1,m=e*6,g=this.curves;g[m]=t*a+h*f+d*u,g[m+1]=n*a+p*f+v*u,g[m+2]=h*l+d*c,g[m+3]=p*l+v*c,g[m+4]=d*c,g[m+5]=v*c},getCurvePercent:function(e,t){t=t<0?0:t>1?1:t;var n=e*6,r=this.curves,i=r[n];if(!i)return t;if(i==-1)return 0;var s=r[n+1],o=r[n+2],u=r[n+3],a=r[n+4],f=r[n+5],l=i,c=s,h=8;for(;;){if(l>=t){var p=l-i,d=c-s;return d+(c-d)*(t-p)/(l-p)}if(!h)break;h--,i+=o,s+=u,o+=a,u+=f,l+=i,c+=s}return c+(1-c)*(t-l)/(1-l)}},o.RotateTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*2},o.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(e,t,n){e*=2,this.frames[e]=t,this.frames[e+1]=n},apply:function(e,t,n){var r=this.frames,i;if(t<r[0])return;var s=e.bones[this.boneIndex];if(t>=r[r.length-2]){i=s.data.rotation+r[r.length-1]-s.rotation;while(i>180)i-=360;while(i<-180)i+=360;s.rotation+=i*n;return}var u=o.binarySearch(r,t,2),a=r[u-1],f=r[u],l=1-(t-f)/(r[u-2]-f);l=this.curves.getCurvePercent(u/2-1,l),i=r[u+1]-a;while(i>180)i-=360;while(i<-180)i+=360;i=s.data.rotation+(a+i*l)-s.rotation;while(i>180)i-=360;while(i<-180)i+=360;s.rotation+=i*n}},o.TranslateTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*3},o.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(e,t,n,r){e*=3,this.frames[e]=t,this.frames[e+1]=n,this.frames[e+2]=r},apply:function(e,t,n){var r=this.frames;if(t<r[0])return;var i=e.bones[this.boneIndex];if(t>=r[r.length-3]){i.x+=(i.data.x+r[r.length-2]-i.x)*n,i.y+=(i.data.y+r[r.length-1]-i.y)*n;return}var s=o.binarySearch(r,t,3),u=r[s-2],a=r[s-1],f=r[s],l=1-(t-f)/(r[s+ -3]-f);l=this.curves.getCurvePercent(s/3-1,l),i.x+=(i.data.x+u+(r[s+1]-u)*l-i.x)*n,i.y+=(i.data.y+a+(r[s+2]-a)*l-i.y)*n}},o.ScaleTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*3},o.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(e,t,n,r){e*=3,this.frames[e]=t,this.frames[e+1]=n,this.frames[e+2]=r},apply:function(e,t,n){var r=this.frames;if(t<r[0])return;var i=e.bones[this.boneIndex];if(t>=r[r.length-3]){i.scaleX+=(i.data.scaleX-1+r[r.length-2]-i.scaleX)*n,i.scaleY+=(i.data.scaleY-1+r[r.length-1]-i.scaleY)*n;return}var s=o.binarySearch(r,t,3),u=r[s-2],a=r[s-1],f=r[s],l=1-(t-f)/(r[s+ -3]-f);l=this.curves.getCurvePercent(s/3-1,l),i.scaleX+=(i.data.scaleX-1+u+(r[s+1]-u)*l-i.scaleX)*n,i.scaleY+=(i.data.scaleY-1+a+(r[s+2]-a)*l-i.scaleY)*n}},o.ColorTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*5},o.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(e,t,n,i){e*=5,this.frames[e]=t,this.frames[e+1]=r,this.frames[e+2]=g,this.frames[e+3]=b,this.frames[e+4]=a},apply:function(e,t,n){var r=this.frames;if(t<r[0])return;var i=e.slots[this.slotIndex];if(t>=r[r.length-5]){var s=r.length-1;i.r=r[s-3],i.g=r[s-2],i.b=r[s-1],i.a=r[s];return}var u=o.binarySearch(r,t,5),a=r[u-4],f=r[u-3],l=r[u-2],c=r[u-1],h=r[u],p=1-(t-h)/(r[u-5]-h);p=this.curves.getCurvePercent(u/5-1,p);var d=a+(r[u+1]-a)*p,v=f+(r[u+2]-f)*p,m=l+(r[u+3]-l)*p,g=c+(r[u+4]-c)*p;n<1?(i.r+=(d-i.r)*n,i.g+=(v-i.g)*n,i.b+=(m-i.b)*n,i.a+=(g-i.a)*n):(i.r=d,i.g=v,i.b=m,i.a=g)}},o.AttachmentTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e,this.attachmentNames=[],this.attachmentNames.length=e},o.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(e,t,n){this.frames[e]=t,this.attachmentNames[e]=n},apply:function(e,t,n){var r=this.frames;if(t<r[0])return;var i;t>=r[r.length-1]?i=r.length-1:i=o.binarySearch(r,t,1)-1;var s=this.attachmentNames[i];e.slots[this.slotIndex].setAttachment(s?e.getAttachmentBySlotIndex(this.slotIndex,s):null)}},o.SkeletonData=function(){this.bones=[],this.slots=[],this.skins=[],this.animations=[]},o.SkeletonData.prototype={defaultSkin:null,findBone:function(e){var t=this.bones;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return t[n];return null},findBoneIndex:function(e){var t=this.bones;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return n;return-1},findSlot:function(e){var t=this.slots;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return slot[n];return null},findSlotIndex:function(e){var t=this.slots;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return n;return-1},findSkin:function(e){var t=this.skins;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return t[n];return null},findAnimation:function(e){var t=this.animations;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return t[n];return null}},o.Skeleton=function(e){this.data=e,this.bones=[];for(var t=0,n=e.bones.length;t<n;t++){var r=e.bones[t],i=r.parent?this.bones[e.bones.indexOf(r.parent)]:null;this.bones.push(new o.Bone(r,i))}this.slots=[],this.drawOrder=[];for(t=0,n=e.slots.length;t<n;t++){var s=e.slots[t],u=this.bones[e.bones.indexOf(s.boneData)],a=new o.Slot(s,this,u);this.slots.push(a),this.drawOrder.push(a)}},o.Skeleton.prototype={x:0,y:0,skin:null,r:1,g:1,b:1,a:1,time:0,flipX:!1,flipY:!1,updateWorldTransform:function(){var e=this.flipX,t=this.flipY,n=this.bones;for(var r=0,i=n.length;r<i;r++)n[r].updateWorldTransform(e,t)},setToSetupPose:function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},setBonesToSetupPose:function(){var e=this.bones;for(var t=0,n=e.length;t<n;t++)e[t].setToSetupPose()},setSlotsToSetupPose:function(){var e=this.slots;for(var t=0,n=e.length;t<n;t++)e[t].setToSetupPose(t)},getRootBone:function(){return this.bones.length?this.bones[0]:null},findBone:function(e){var t=this.bones;for(var n=0,r=t.length;n<r;n++)if(t[n].data.name==e)return t[n];return null},findBoneIndex:function(e){var t=this.bones;for(var n=0,r=t.length;n<r;n++)if(t[n].data.name==e)return n;return-1},findSlot:function(e){var t=this.slots;for(var n=0,r=t.length;n<r;n++)if(t[n].data.name==e)return t[n];return null},findSlotIndex:function(e){var t=this.slots;for(var n=0,r=t.length;n<r;n++)if(t[n].data.name==e)return n;return-1},setSkinByName:function(e){var t=this.data.findSkin(e);if(!t)throw"Skin not found: "+e;this.setSkin(t)},setSkin:function(e){this.skin&&e&&e._attachAll(this,this.skin),this.skin=e},getAttachmentBySlotName:function(e,t){return this.getAttachmentBySlotIndex(this.data.findSlotIndex(e),t)},getAttachmentBySlotIndex:function(e,t){if(this.skin){var n=this.skin.getAttachment(e,t);if(n)return n}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(e,t):null},setAttachment:function(e,t){var n=this.slots;for(var r=0,i=n.size;r<i;r++){var s=n[r];if(s.data.name==e){var o=null;if(t){o=this.getAttachment(r,t);if(o==null)throw"Attachment not found: "+t+", for slot: "+e}s.setAttachment(o);return}}throw"Slot not found: "+e},update:function(e){time+=e}},o.AttachmentType={region:0},o.RegionAttachment=function(){this.offset=[],this.offset.length=8,this.uvs=[],this.uvs.length=8},o.RegionAttachment.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,width:0,height:0,rendererObject:null,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,setUVs:function(e,t,n,r,i){var s=this.uvs;i?(s[2]=e,s[3]=r,s[4]=e,s[5]=t,s[6]=n,s[7]=t,s[0]=n,s[1]=r):(s[0]=e,s[1]=r,s[2]=e,s[3]=t,s[4]=n,s[5]=t,s[6]=n,s[7]=r)},updateOffset:function(){var e=this.width/this.regionOriginalWidth*this.scaleX,t=this.height/this.regionOriginalHeight*this.scaleY,n=-this.width/2*this.scaleX+this.regionOffsetX*e,r=-this.height/2*this.scaleY+this.regionOffsetY*t,i=n+this.regionWidth*e,s=r+this.regionHeight*t,o=this.rotation*Math.PI/180,u=Math.cos(o),a=Math.sin(o),f=n*u+this.x,l=n*a,c=r*u+this.y,h=r*a,p=i*u+this.x,d=i*a,v=s*u+this.y,m=s*a,g=this.offset;g[0]=f-h,g[1]=c+l,g[2]=f-m,g[3]=v+l,g[4]=p-m,g[5]=v+d,g[6]=p-h,g[7]=c+d},computeVertices:function(e,t,n,r){e+=n.worldX,t+=n.worldY;var i=n.m00,s=n.m01,o=n.m10,u=n.m11,a=this.offset;r[0]=a[0]*i+a[1]*s+e,r[1]=a[0]*o+a[1]*u+t,r[2]=a[2]*i+a[3]*s+e,r[3]=a[2]*o+a[3]*u+t,r[4]=a[4]*i+a[5]*s+e,r[5]=a[4]*o+a[5]*u+t,r[6]=a[6]*i+a[7]*s+e,r[7]=a[6]*o+a[7]*u+t}},o.AnimationStateData=function(e){this.skeletonData=e,this.animationToMixTime={}},o.AnimationStateData.prototype={defaultMix:0,setMixByName:function(e,t,n){var r=this.skeletonData.findAnimation(e);if(!r)throw"Animation not found: "+e;var i=this.skeletonData.findAnimation(t);if(!i)throw"Animation not found: "+t;this.setMix(r,i,n)},setMix:function(e,t,n){this.animationToMixTime[e.name+":"+t.name]=n},getMix:function(e,t){var n=this.animationToMixTime[e.name+":"+t.name];return n?n:this.defaultMix}},o.AnimationState=function(e){this.data=e,this.queue=[]},o.AnimationState.prototype={current:null,previous:null,currentTime:0,previousTime:0,currentLoop:!1,previousLoop:!1,mixTime:0,mixDuration:0,update:function(e){this.currentTime+=e,this.previousTime+=e,this.mixTime+=e;if(this.queue.length>0){var t=this.queue[0];this.currentTime>=t.delay&&(this._setAnimation(t.animation,t.loop),this.queue.shift())}},apply:function(e){if(!this.current)return;if(this.previous){this.previous.apply(e,this.previousTime,this.previousLoop);var t=this.mixTime/this.mixDuration;t>=1&&(t=1,this.previous=null),this.current.mix(e,this.currentTime,this.currentLoop,t)}else this.current.apply(e,this.currentTime,this.currentLoop)},clearAnimation:function(){this.previous=null,this.current=null,this.queue.length=0},_setAnimation:function(e,t){this.previous=null,e&&this.current&&(this.mixDuration=this.data.getMix(this.current,e),this.mixDuration>0&&(this.mixTime=0,this.previous=this.current,this.previousTime=this.currentTime,this.previousLoop=this.currentLoop)),this.current=e,this.currentLoop=t,this.currentTime=0},setAnimationByName:function(e,t){var n=this.data.skeletonData.findAnimation(e);if(!n)throw"Animation not found: "+e;this.setAnimation(n,t)},setAnimation:function(e,t){this.queue.length=0,this._setAnimation(e,t)},addAnimationByName:function(e,t,n){var r=this.data.skeletonData.findAnimation(e);if(!r)throw"Animation not found: "+e;this.addAnimation(r,t,n)},addAnimation:function(e,t,n){var r={};r.animation=e,r.loop=t;if(!n||n<=0){var i=this.queue.length?this.queue[this.queue.length-1].animation:this.current;i!=null?n=i.duration-this.data.getMix(i,e)+(n||0):n=0}r.delay=n,this.queue.push(r)},isComplete:function(){return!this.current||this.currentTime>=this.current.duration}},o.SkeletonJson=function(e){this.attachmentLoader=e},o.SkeletonJson.prototype={scale:1,readSkeletonData:function(e){var t=new o.SkeletonData,n,r=e.bones;for(var i=0,s=r.length;i<s;i++){var u=r[i],a=null;if(u.parent){a=t.findBone(u.parent);if(!a)throw"Parent bone not found: "+u.parent}n=new o.BoneData(u.name,a),n.length=(u.length||0)*this.scale,n.x=(u.x||0)*this.scale,n.y=(u.y||0)*this.scale,n.rotation=u.rotation||0,n.scaleX=u.scaleX||1,n.scaleY=u.scaleY||1,t.bones.push(n)}var f=e.slots;for(i=0,s=f.length;i<s;i++){var l=f[i];n=t.findBone(l.bone);if(!n)throw"Slot bone not found: "+l.bone;var c=new o.SlotData(l.name,n),h=l.color;h&&(c.r=o.SkeletonJson.toColor(h,0),c.g=o.SkeletonJson.toColor(h,1),c.b=o.SkeletonJson.toColor(h,2),c.a=o.SkeletonJson.toColor(h,3)),c.attachmentName=l.attachment,t.slots.push(c)}var p=e.skins;for(var d in p){if(!p.hasOwnProperty(d))continue;var v=p[d],m=new o.Skin(d);for(var g in v){if(!v.hasOwnProperty(g))continue;var y=t.findSlotIndex(g),b=v[g];for(var w in b){if(!b.hasOwnProperty(w))continue;var E=this.readAttachment(m,w,b[w]);E!=null&&m.addAttachment(y,w,E)}}t.skins.push(m),m.name=="default"&&(t.defaultSkin=m)}var S=e.animations;for(var x in S){if(!S.hasOwnProperty(x))continue;this.readAnimation(x,S[x],t)}return t},readAttachment:function(e,t,n){t=n.name||t;var r=o.AttachmentType[n.type||"region"];if(r==o.AttachmentType.region){var i=new o.RegionAttachment;return i.x=(n.x||0)*this.scale,i.y=(n.y||0)*this.scale,i.scaleX=n.scaleX||1,i.scaleY=n.scaleY||1,i.rotation=n.rotation||0,i.width=(n.width||32)*this.scale,i.height=(n.height||32)*this.scale,i.updateOffset(),i.rendererObject={},i.rendererObject.name=t,i.rendererObject.scale={},i.rendererObject.scale.x=i.scaleX,i.rendererObject.scale.y=i.scaleY,i.rendererObject.rotation=-i.rotation*Math.PI/180,i}throw"Unknown attachment type: "+r},readAnimation:function(e,t,n){var r=[],i=0,s,u,a,f,l,c,h,p=t.bones;for(var d in p){if(!p.hasOwnProperty(d))continue;var v=n.findBoneIndex(d);if(v==-1)throw"Bone not found: "+d;var m=p[d];for(a in m){if(!m.hasOwnProperty(a))continue;l=m[a];if(a=="rotate"){u=new o.RotateTimeline(l.length),u.boneIndex=v,s=0;for(c=0,h=l.length;c<h;c++)f=l[c],u.setFrame(s,f.time,f.angle),o.SkeletonJson.readCurve(u,s,f),s++;r.push(u),i=Math.max(i,u.frames[u.getFrameCount()*2-2])}else{if(a!="translate"&&a!="scale")throw"Invalid timeline type for a bone: "+a+" ("+d+")";var g=1;a=="scale"?u=new o.ScaleTimeline(l.length):(u=new o.TranslateTimeline(l.length),g=this.scale),u.boneIndex=v,s=0;for(c=0,h=l.length;c<h;c++){f=l[c];var y=(f.x||0)*g,b=(f.y||0)*g;u.setFrame(s,f.time,y,b),o.SkeletonJson.readCurve(u,s,f),s++}r.push(u),i=Math.max(i,u.frames[u.getFrameCount()*3-3])}}}var w=t.slots;for(var E in w){if(!w.hasOwnProperty(E))continue;var S=w[E],x=n.findSlotIndex(E);for(a in S){if(!S.hasOwnProperty(a))continue;l=S[a];if(a=="color"){u=new o.ColorTimeline(l.length),u.slotIndex=x,s=0;for(c=0,h=l.length;c<h;c++){f=l[c];var T=f.color,N=o.SkeletonJson.toColor(T,0),C=o.SkeletonJson.toColor(T,1),k=o.SkeletonJson.toColor(T,2),L=o.SkeletonJson.toColor(T,3);u.setFrame(s,f.time,N,C,k,L),o.SkeletonJson.readCurve(u,s,f),s++}r.push(u),i=Math.max(i,u.frames[u.getFrameCount()*5-5])}else{if(a!="attachment")throw"Invalid timeline type for a slot: "+a+" ("+E+")";u=new o.AttachmentTimeline(l.length),u.slotIndex=x,s=0;for(c=0,h=l.length;c<h;c++)f=l[c],u.setFrame(s++,f.time,f.name);r.push(u),i=Math.max(i,u.frames[u.getFrameCount()-1])}}}n.animations.push(new o.Animation(e,r,i))}},o.SkeletonJson.readCurve=function(e,t,n){var r=n.curve;if(!r)return;r=="stepped"?e.curves.setStepped(t):r instanceof Array&&e.curves.setCurve(t,r[0],r[1],r[2],r[3])},o.SkeletonJson.toColor=function(e,t){if(e.length!=8)throw"Color hexidecimal length must be 8, recieved: "+e;return parseInt(e.substring(t*2,2),16)/255},o.Atlas=function(e,t){this.textureLoader=t,this.pages=[],this.regions=[];var n=new o.AtlasReader(e),r=[];r.length=4;var i=null;for(;;){var s=n.readLine();if(s==null)break;s=n.trim(s);if(!s.length)i=null;else if(!i){i=new o.AtlasPage,i.name=s,i.format=o.Atlas.Format[n.readValue()],n.readTuple(r),i.minFilter=o.Atlas.TextureFilter[r[0]],i.magFilter=o.Atlas.TextureFilter[r[1]];var u=n.readValue();i.uWrap=o.Atlas.TextureWrap.clampToEdge,i.vWrap=o.Atlas.TextureWrap.clampToEdge,u=="x"?i.uWrap=o.Atlas.TextureWrap.repeat:u=="y"?i.vWrap=o.Atlas.TextureWrap.repeat:u=="xy"&&(i.uWrap=i.vWrap=o.Atlas.TextureWrap.repeat),t.load(i,s),this.pages.push(i)}else{var a=new o.AtlasRegion;a.name=s,a.page=i,a.rotate=n.readValue()=="true",n.readTuple(r);var f=parseInt(r[0],10),l=parseInt(r[1],10);n.readTuple(r);var c=parseInt(r[0],10),h=parseInt(r[1],10);a.u=f/i.width,a.v=l/i.height,a.rotate?(a.u2=(f+h)/i.width,a.v2=(l+c)/i.height):(a.u2=(f+c)/i.width,a.v2=(l+h)/i.height),a.x=f,a.y=l,a.width=Math.abs(c),a.height=Math.abs(h),n.readTuple(r)==4&&(a.splits=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)],n.readTuple(r)==4&&(a.pads=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)],n.readTuple(r))),a.originalWidth=parseInt(r[0],10),a.originalHeight=parseInt(r[1],10),n.readTuple(r),a.offsetX=parseInt(r[0],10),a.offsetY=parseInt(r[1],10),a.index=parseInt(n.readValue(),10),this.regions.push(a)}}},o.Atlas.prototype={findRegion:function(e){var t=this.regions;for(var n=0,r=t.length;n<r;n++)if(t[n].name==e)return t[n];return null},dispose:function(){var e=this.pages;for(var t=0,n=e.length;t<n;t++)this.textureLoader.unload(e[t].rendererObject)},updateUVs:function(e){var t=this.regions;for(var n=0,r=t.length;n<r;n++){var i=t[n];if(i.page!=e)continue;i.u=i.x/e.width,i.v=i.y/e.height,i.rotate?(i.u2=(i.x+i.height)/e.width,i.v2=(i.y+i.width)/e.height):(i.u2=(i.x+i.width)/e.width,i.v2=(i.y+i.height)/e.height)}}},o.Atlas.Format={alpha:0,intensity:1,luminanceAlpha:2,rgb565:3,rgba4444:4,rgb888:5,rgba8888:6},o.Atlas.TextureFilter={nearest:0,linear:1,mipMap:2,mipMapNearestNearest:3,mipMapLinearNearest:4,mipMapNearestLinear:5,mipMapLinearLinear:6},o.Atlas.TextureWrap={mirroredRepeat:0,clampToEdge:1,repeat:2},o.AtlasPage=function(){},o.AtlasPage.prototype={name:null,format:null,minFilter:null,magFilter:null,uWrap:null,vWrap:null,rendererObject:null,width:0,height:0},o.AtlasRegion=function(){},o.AtlasRegion.prototype={page:null,name:null,x:0,y:0,width:0,height:0,u:0,v:0,u2:0,v2:0,offsetX:0,offsetY:0,originalWidth:0,originalHeight:0,index:0,rotate:!1,splits:null,pads:null},o.AtlasReader=function(e){this.lines=e.split(/\r\n|\r|\n/)},o.AtlasReader.prototype={index:0,trim:function(e){return e.replace(/^\s+|\s+$/g,"")},readLine:function(){return this.index>=this.lines.length?null:this.lines[this.index++]},readValue:function(){var e=this.readLine(),t=e.indexOf(":");if(t==-1)throw"Invalid line: "+e;return this.trim(e.substring(t+1))},readTuple:function(e){var t=this.readLine(),n=t.indexOf(":");if(n==-1)throw"Invalid line: "+t;var r=0,i=n+1;for(;r<3;r++){var s=t.indexOf(",",i);if(s==-1){if(!r)throw"Invalid line: "+t;break}e[r]=this.trim(t.substr(i,s-i)),i=s+1}return e[r]=this.trim(t.substring(i)),r+1}},o.AtlasAttachmentLoader=function(e){this.atlas=e},o.AtlasAttachmentLoader.prototype={newAttachment:function(e,t,n){switch(t){case o.AttachmentType.region:var r=this.atlas.findRegion(n);if(!r)throw"Region not found in atlas: "+n+" ("+t+")";var i=new o.RegionAttachment(n);return i.rendererObject=r,i.setUVs(r.u,r.v,r.u2,r.v2,r.rotate),i.regionOffsetX=r.offsetX,i.regionOffsetY=r.offsetY,i.regionWidth=r.width,i.regionHeight=r.height,i.regionOriginalWidth=r.originalWidth,i.regionOriginalHeight=r.originalHeight,i}throw"Unknown attachment type: "+t}},o.Bone.yDown=!0,t.AnimCache={},t.Spine=function(e){t.DisplayObjectContainer.call(this),this.spineData=t.AnimCache[e];if(!this.spineData)throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+e);this.skeleton=new o.Skeleton(this.spineData),this.skeleton.updateWorldTransform(),this.stateData=new o.AnimationStateData(this.spineData),this.state=new o.AnimationState(this.stateData),this.slotContainers=[];for(var n=0,r=this.skeleton.drawOrder.length;n<r;n++){var i=this.skeleton.drawOrder[n],s=i.attachment,u=new t.DisplayObjectContainer;this.slotContainers.push(u),this.addChild(u);if(!(s instanceof o.RegionAttachment))continue;var a=s.rendererObject.name,f=this.createSprite(i,s.rendererObject);i.currentSprite=f,i.currentSpriteName=a,u.addChild(f)}},t.Spine.prototype=Object.create(t.DisplayObjectContainer.prototype),t.Spine.prototype.constructor=t.Spine,t.Spine.prototype.updateTransform=function(){this.lastTime=this.lastTime||Date.now();var e=(Date.now()-this.lastTime)*.001;this.lastTime=Date.now(),this.state.update(e),this.state.apply(this.skeleton),this.skeleton.updateWorldTransform();var n=this.skeleton.drawOrder;for(var r=0,i=n.length;r<i;r++){var s=n[r],u=s.attachment,a=this.slotContainers[r];if(!(u instanceof o.RegionAttachment)){a.visible=!1;continue}if(u.rendererObject)if(!s.currentSpriteName||s.currentSpriteName!=u.name){var f=u.rendererObject.name;s.currentSprite!==undefined&&(s.currentSprite.visible=!1),s.sprites=s.sprites||{};if(s.sprites[f]!==undefined)s.sprites[f].visible=!0;else{var l=this.createSprite(s,u.rendererObject);a.addChild(l)}s.currentSprite=s.sprites[f],s.currentSpriteName=f}a.visible=!0;var c=s.bone;a.position.x=c.worldX+u.x*c.m00+u.y*c.m01,a.position.y=c.worldY+u.x*c.m10+u.y*c.m11,a.scale.x=c.worldScaleX,a.scale.y=c.worldScaleY,a.rotation=-(s.bone.worldRotation*Math.PI/180)}t.DisplayObjectContainer.prototype.updateTransform.call(this)},t.Spine.prototype.createSprite=function(e,n){var r=t.TextureCache[n.name]?n.name:n.name+".png",i=new t.Sprite(t.Texture.fromFrame(r));return i.scale=n.scale,i.rotation=n.rotation,i.anchor.x=i.anchor.y=.5,e.sprites=e.sprites||{},e.sprites[n.name]=i,i},t.BaseTextureCache={},t.texturesToUpdate=[],t.texturesToDestroy=[],t.BaseTextureCacheIdGenerator=0,t.BaseTexture=function(e,n){t.EventTarget.call(this),this.width=100,this.height=100,this.scaleMode=n||t.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=e;if(!e)return;if(this.source.complete||this.source.getContext)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,t.texturesToUpdate.push(this);else{var r=this;this.source.onload=function(){r.hasLoaded=!0,r.width=r.source.width,r.height=r.source.height,t.texturesToUpdate.push(r),r.dispatchEvent({type:"loaded",content:r})}}this.imageUrl=null,this._powerOf2=!1,this.id=t.BaseTextureCacheIdGenerator++,this._glTextures=[]},t.BaseTexture.prototype.constructor=t.BaseTexture,t.BaseTexture.prototype.destroy=function(){this.imageUrl&&(delete t.BaseTextureCache[this.imageUrl],this.imageUrl=null,this.source.src=null),this.source=null,t.texturesToDestroy.push(this)},t.BaseTexture.prototype.updateSourceImage=function(e){this.hasLoaded=!1,this.source.src=null,this.source.src=e},t.BaseTexture.fromImage=function(e,n,r){var i=t.BaseTextureCache[e];n=!n;if(!i){var s=new Image;n&&(s.crossOrigin=""),s.src=e,i=new t.BaseTexture(s,r),i.imageUrl=e,t.BaseTextureCache[e]=i}return i},t.BaseTexture.fromCanvas=function(e,n){e._pixiId||(e._pixiId="canvas_"+t.TextureCacheIdGenerator++);var r=t.BaseTextureCache[e._pixiId];return r||(r=new t.BaseTexture(e,n),t.BaseTextureCache[e._pixiId]=r),r},t.TextureCache={},t.FrameCache={},t.TextureCacheIdGenerator=0,t.Texture=function(e,n){t.EventTarget.call(this),n||(this.noFrame=!0,n=new t.Rectangle(0,0,1,1)),e instanceof t.Texture&&(e=e.baseTexture),this.baseTexture=e,this.frame=n,this.trim=null,this.scope=this;if(e.hasLoaded)this.noFrame&&(n=new t.Rectangle(0,0,e.width,e.height)),this.setFrame(n);else{var r=this;e.addEventListener("loaded",function(){r.onBaseTextureLoaded()})}},t.Texture.prototype.constructor=t.Texture,t.Texture.prototype.onBaseTextureLoaded=function(){var e=this.baseTexture;e.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new t.Rectangle(0,0,e.width,e.height)),this.setFrame(this.frame),this.scope.dispatchEvent({type:"update",content:this})},t.Texture.prototype.destroy=function(e){e&&this.baseTexture.destroy()},t.Texture.prototype.setFrame=function(e){this.frame=e,this.width=e.width,this.height=e.height;if(e.x+e.width>this.baseTexture.width||e.y+e.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,t.Texture.frameUpdates.push(this)},t.Texture.prototype._updateWebGLuvs=function(){this._uvs||(this._uvs=new t.TextureUvs);var e=this.frame,n=this.baseTexture.width,r=this.baseTexture.height;this._uvs.x0=e.x/n,this._uvs.y0=e.y/r,this._uvs.x1=(e.x+e.width)/n,this._uvs.y1=e.y/r,this._uvs.x2=(e.x+e.width)/n,this._uvs.y2=(e.y+e.height)/r,this._uvs.x3=e.x/n,this._uvs.y3=(e.y+e.height)/r},t.Texture.fromImage=function(e,n,r){var i=t.TextureCache[e];return i||(i=new t.Texture(t.BaseTexture.fromImage(e,n,r)),t.TextureCache[e]=i),i},t.Texture.fromFrame=function(e){var n=t.TextureCache[e];if(!n)throw new Error('The frameId "'+e+'" does not exist in the texture cache ');return n},t.Texture.fromCanvas=function(e,n){var r=t.BaseTexture.fromCanvas(e,n);return new t.Texture(r)},t.Texture.addTextureToCache=function(e,n){t.TextureCache[n]=e},t.Texture.removeTextureFromCache=function(e){var n=t.TextureCache[e];return t.TextureCache[e]=null,n},t.Texture.frameUpdates=[],t.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y4=0},t.RenderTexture=function(e,n,r){t.EventTarget.call(this),this.width=e||100,this.height=n||100,this.frame=new t.Rectangle(0,0,this.width,this.height),this.baseTexture=new t.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTextures=[],this.baseTexture.hasLoaded=!0,this.renderer=r||t.defaultRenderer;if(this.renderer.type===t.WEBGL_RENDERER){var i=this.renderer.gl;this.textureBuffer=new t.FilterTexture(i,this.width,this.height),this.baseTexture._glTextures[i.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new t.Point(this.width/2,-this.height/2)}else this.render=this.renderCanvas,this.textureBuffer=new t.CanvasBuffer(this.width,this.height),this.baseTexture.source=this.textureBuffer.canvas;t.Texture.frameUpdates.push(this)},t.RenderTexture.prototype=Object.create(t.Texture.prototype),t.RenderTexture.prototype.constructor=t.RenderTexture,t.RenderTexture.prototype.resize=function(e,n){this.width=e,this.height=n,this.frame.width=this.width,this.frame.height=this.height;if(this.renderer.type===t.WEBGL_RENDERER){this.projection.x=this.width/2,this.projection.y=-this.height/2;var r=this.renderer.gl;r.bindTexture(r.TEXTURE_2D,this.baseTexture._glTextures[r.id]),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null)}else this.textureBuffer.resize(this.width,this.height);t.Texture.frameUpdates.push(this)},t.RenderTexture.prototype.renderWebGL=function(e,n,r){var i=this.renderer.gl;i.colorMask(!0,!0,!0,!0),i.viewport(0,0,this.width,this.height),i.bindFramebuffer(i.FRAMEBUFFER,this.textureBuffer.frameBuffer),r&&this.textureBuffer.clear();var s=e.children,o=e.worldTransform;e.worldTransform=t.RenderTexture.tempMatrix,e.worldTransform.d=-1,e.worldTransform.ty=this.projection.y*-2,n&&(e.worldTransform.tx=n.x,e.worldTransform.ty-=n.y);for(var u=0,a=s.length;u<a;u++)s[u].updateTransform();t.WebGLRenderer.updateTextures(),this.renderer.renderDisplayObject(e,this.projection,this.textureBuffer.frameBuffer),e.worldTransform=o},t.RenderTexture.prototype.renderCanvas=function(e,n,r){var i=e.children;e.worldTransform=t.RenderTexture.tempMatrix,n&&(e.worldTransform.tx=n.x,e.worldTransform.ty=n.y);for(var s=0,o=i.length;s<o;s++)i[s].updateTransform();r&&this.textureBuffer.clear();var u=this.textureBuffer.context;this.renderer.renderDisplayObject(e,u),u.setTransform(1,0,0,1,0,0)},t.RenderTexture.tempMatrix=new t.Matrix,t.AssetLoader=function(e,n){t.EventTarget.call(this),this.assetURLs=e,this.crossorigin=n,this.loadersByType={jpg:t.ImageLoader,jpeg:t.ImageLoader,png:t.ImageLoader,gif:t.ImageLoader,json:t.JsonLoader,atlas:t.AtlasLoader,anim:t.SpineLoader,xml:t.BitmapFontLoader,fnt:t.BitmapFontLoader}},t.AssetLoader.prototype.constructor=t.AssetLoader,t.AssetLoader.prototype._getDataType=function(e){var t="data:",n=e.slice(0,t.length).toLowerCase();if(n===t){var r=e.slice(t.length),i=r.indexOf(",");if(i===-1)return null;var s=r.slice(0,i).split(";")[0];return!s||s.toLowerCase()==="text/plain"?"txt":s.split("/").pop().toLowerCase()}return null},t.AssetLoader.prototype.load=function(){function t(t){e.onAssetLoaded(t.loader)}var e=this;this.loadCount=this.assetURLs.length;for(var n=0;n<this.assetURLs.length;n++){var r=this.assetURLs[n],i=this._getDataType(r);i||(i=r.split("?").shift().split(".").pop().toLowerCase());var s=this.loadersByType[i];if(!s)throw new Error(i+" is an unsupported file type");var o=new s(r,this.crossorigin);o.addEventListener("loaded",t),o.load()}},t.AssetLoader.prototype.onAssetLoaded=function(e){this.loadCount--,this.dispatchEvent({type:"onProgress",content:this,loader:e}),this.onProgress&&this.onProgress(e),this.loadCount||(this.dispatchEvent({type:"onComplete",content:this}),this.onComplete&&this.onComplete())},t.JsonLoader=function(e,n){t.EventTarget.call(this),this.url=e,this.crossorigin=n,this.baseUrl=e.replace(/[^\/]*$/,""),this.loaded=!1},t.JsonLoader.prototype.constructor=t.JsonLoader,t.JsonLoader.prototype.load=function(){this.ajaxRequest=new t.AjaxRequest(this.crossorigin);var e=this;this.ajaxRequest.onreadystatechange=function(){e.onJSONLoaded()},this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/json"),this.ajaxRequest.send(null)},t.JsonLoader.prototype.onJSONLoaded=function(){if(this.ajaxRequest.readyState===4)if(this.ajaxRequest.status===200||window.location.protocol.indexOf("http")===-1){this.json=JSON.parse(this.ajaxRequest.responseText);if(this.json.frames){var e=this,n=this.baseUrl+this.json.meta.image,r=new t.ImageLoader(n,this.crossorigin),i=this.json.frames;this.texture=r.texture.baseTexture,r.addEventListener("loaded",function(){e.onLoaded()});for(var s in i){var u=i[s].frame;if(u){t.TextureCache[s]=new t.Texture(this.texture,{x:u.x,y:u.y,width:u.w,height:u.h});if(i[s].trimmed){var a=t.TextureCache[s],f=i[s].sourceSize,l=i[s].spriteSourceSize;a.trim=new t.Rectangle(l.x,l.y,f.w,f.h)}}}r.load()}else if(this.json.bones){var c=new o.SkeletonJson,h=c.readSkeletonData(this.json);t.AnimCache[this.url]=h,this.onLoaded()}else this.onLoaded()}else this.onError()},t.JsonLoader.prototype.onLoaded=function(){this.loaded=!0,this.dispatchEvent({type:"loaded",content:this})},t.JsonLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},t.AtlasLoader=function(e,n){t.EventTarget.call(this),this.url=e,this.baseUrl=e.replace(/[^\/]*$/,""),this.crossorigin=n,this.loaded=!1},t.AtlasLoader.constructor=t.AtlasLoader,t.AtlasLoader.prototype.load=function(){this.ajaxRequest=new t.AjaxRequest,this.ajaxRequest.onreadystatechange=this.onAtlasLoaded.bind(this),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/json"),this.ajaxRequest.send(null)},t.AtlasLoader.prototype.onAtlasLoaded=function(){if(this.ajaxRequest.readyState===4)if(this.ajaxRequest.status===200||window.location.href.indexOf("http")===-1){this.atlas={meta:{image:[]},frames:[]};var e=this.ajaxRequest.responseText.split(/\r?\n/),n=-3,r=0,i=null,s=!1,o=0,u=0,a=this.onLoaded.bind(this);for(o=0;o<e.length;o++){e[o]=e[o].replace(/^\s+|\s+$/g,""),e[o]===""&&(s=o+1);if(e[o].length>0){if(s===o)this.atlas.meta.image.push(e[o]),r=this.atlas.meta.image.length-1,this.atlas.frames.push({}),n=-3;else if(n>0)if(n%7===1)i!=null&&(this.atlas.frames[r][i.name]=i),i={name:e[o],frame:{}};else{var f=e[o].split(" ");if(n%7===3)i.frame.x=Number(f[1].replace(",","")),i.frame.y=Number(f[2]);else if(n%7===4)i.frame.w=Number(f[1].replace(",","")),i.frame.h=Number(f[2]);else if(n%7===5){var l={x:0,y:0,w:Number(f[1].replace(",","")),h:Number(f[2])};l.w>i.frame.w||l.h>i.frame.h?(i.trimmed=!0,i.realSize=l):i.trimmed=!1}}n++}}i!=null&&(this.atlas.frames[r][i.name]=i);if(this.atlas.meta.image.length>0){this.images=[];for(u=0;u<this.atlas.meta.image.length;u++){var c=this.baseUrl+this.atlas.meta.image[u],h=this.atlas.frames[u];this.images.push(new t.ImageLoader(c,this.crossorigin));for(o in h){var p=h[o].frame;p&&(t.TextureCache[o]=new t.Texture(this.images[u].texture.baseTexture,{x:p.x,y:p.y,width:p.w,height:p.h}),h[o].trimmed&&(t.TextureCache[o].realSize=h[o].realSize,t.TextureCache[o].trim.x=0,t.TextureCache[o].trim.y=0))}}this.currentImageId=0;for(u=0;u<this.images.length;u++)this.images[u].addEventListener("loaded",a);this.images[this.currentImageId].load()}else this.onLoaded()}else this.onError()},t.AtlasLoader.prototype.onLoaded=function(){this.images.length-1>this.currentImageId?(this.currentImageId++,this.images[this.currentImageId].load()):(this.loaded=!0,this.dispatchEvent({type:"loaded",content:this}))},t.AtlasLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},t.SpriteSheetLoader=function(e,n){t.EventTarget.call(this),this.url=e,this.crossorigin=n,this.baseUrl=e.replace(/[^\/]*$/,""),this.texture=null,this.frames={}},t.SpriteSheetLoader.prototype.constructor=t.SpriteSheetLoader,t.SpriteSheetLoader.prototype.load=function(){var e=this,n=new t.JsonLoader(this.url,this.crossorigin);n.addEventListener("loaded",function(t){e.json=t.content.json,e.onLoaded()}),n.load()},t.SpriteSheetLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},t.ImageLoader=function(e,n){t.EventTarget.call(this),this.texture=t.Texture.fromImage(e,n),this.frames=[]},t.ImageLoader.prototype.constructor=t.ImageLoader,t.ImageLoader.prototype.load=function(){if(!this.texture.baseTexture.hasLoaded){var e=this;this.texture.baseTexture.addEventListener("loaded",function(){e.onLoaded()})}else this.onLoaded()},t.ImageLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},t.ImageLoader.prototype.loadFramedSpriteSheet=function(e,n,r){this.frames=[];var i=Math.floor(this.texture.width/e),s=Math.floor(this.texture.height/n),o=0;for(var u=0;u<s;u++)for(var a=0;a<i;a++,o++){var f=new t.Texture(this.texture,{x:a*e,y:u*n,width:e,height:n});this.frames.push(f),r&&(t.TextureCache[r+"-"+o]=f)}if(!this.texture.baseTexture.hasLoaded){var l=this;this.texture.baseTexture.addEventListener("loaded",function(){l.onLoaded()})}else this.onLoaded()},t.BitmapFontLoader=function(e,n){t.EventTarget.call(this),this.url=e,this.crossorigin=n,this.baseUrl=e.replace(/[^\/]*$/,""),this.texture=null},t.BitmapFontLoader.prototype.constructor=t.BitmapFontLoader,t.BitmapFontLoader.prototype.load=function(){this.ajaxRequest=new t.AjaxRequest;var e=this;this.ajaxRequest.onreadystatechange=function(){e.onXMLLoaded()},this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/xml"),this.ajaxRequest.send(null)},t.BitmapFontLoader.prototype.onXMLLoaded=function(){if(this.ajaxRequest.readyState===4)if(this.ajaxRequest.status===200||window.location.protocol.indexOf("http")===-1){var e=this.ajaxRequest.responseXML;if(!e||/MSIE 9/i.test(navigator.userAgent)||navigator.isCocoonJS)if(typeof window.DOMParser=="function"){var n=new DOMParser;e=n.parseFromString(this.ajaxRequest.responseText,"text/xml")}else{var r=document.createElement("div");r.innerHTML=this.ajaxRequest.responseText,e=r}var i=this.baseUrl+e.getElementsByTagName("page")[0].getAttribute("file"),s=new t.ImageLoader(i,this.crossorigin);this.texture=s.texture.baseTexture;var o={},u=e.getElementsByTagName("info")[0],a=e.getElementsByTagName("common")[0];o.font=u.getAttribute("face"),o.size=parseInt(u.getAttribute("size"),10),o.lineHeight=parseInt(a.getAttribute("lineHeight"),10),o.chars={};var f=e.getElementsByTagName("char");for(var l=0;l<f.length;l++){var c=parseInt(f[l].getAttribute("id"),10),h=new t.Rectangle(parseInt(f[l].getAttribute("x"),10),parseInt(f[l].getAttribute("y"),10),parseInt(f[l].getAttribute("width"),10),parseInt(f[l].getAttribute("height"),10));o.chars[c]={xOffset:parseInt(f[l].getAttribute("xoffset"),10),yOffset:parseInt(f[l].getAttribute("yoffset"),10),xAdvance:parseInt(f[l].getAttribute("xadvance"),10),kerning:{},texture:t.TextureCache[c]=new t.Texture(this.texture,h)}}var p=e.getElementsByTagName("kerning");for(l=0;l<p.length;l++){var d=parseInt(p[l].getAttribute("first"),10),v=parseInt(p[l].getAttribute("second"),10),m=parseInt(p[l].getAttribute("amount"),10);o.chars[v].kerning[d]=m}t.BitmapText.fonts[o.font]=o;var g=this;s.addEventListener("loaded",function(){g.onLoaded()}),s.load()}},t.BitmapFontLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},t.SpineLoader=function(e,n){t.EventTarget.call(this),this.url=e,this.crossorigin=n,this.loaded=!1},t.SpineLoader.prototype.constructor=t.SpineLoader,t.SpineLoader.prototype.load=function(){var e=this,n=new t.JsonLoader(this.url,this.crossorigin);n.addEventListener("loaded",function(t){e.json=t.content.json,e.onLoaded()}),n.load()},t.SpineLoader.prototype.onLoaded=function(){this.loaded=!0,this.dispatchEvent({type:"loaded",content:this})},t.AbstractFilter=function(e,t){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=t||{},this.fragmentSrc=e||[]},t.AlphaMaskFilter=function(e){t.AbstractFilter.call(this),this.passes=[this],e.baseTexture._powerOf2=!0,this.uniforms={mask:{type:"sampler2D",value:e},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},e.baseTexture.hasLoaded?(this.uniforms.mask.value.x=e.width,this.uniforms.mask.value.y=e.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),e.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D mask;","uniform sampler2D uSampler;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {"," vec2 mapCords = vTextureCoord.xy;"," mapCords += (dimensions.zw + offset)/ dimensions.xy ;"," mapCords.y *= -1.0;"," mapCords.y += 1.0;"," mapCords *= dimensions.xy / mapDimensions;"," vec4 original = texture2D(uSampler, vTextureCoord);"," float maskAlpha = texture2D(mask, mapCords).r;"," original *= maskAlpha;"," gl_FragColor = original;","}"]},t.AlphaMaskFilter.prototype=Object.create(t.AbstractFilter.prototype),t.AlphaMaskFilter.prototype.constructor=t.AlphaMaskFilter,t.AlphaMaskFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.mask.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.mask.value.height,this.uniforms.mask.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(t.AlphaMaskFilter.prototype,"map",{get:function(){return this.uniforms.mask.value},set:function(e){this.uniforms.mask.value=e}}),t.ColorMatrixFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","}"]},t.ColorMatrixFilter.prototype=Object.create(t.AbstractFilter.prototype),t.ColorMatrixFilter.prototype.constructor=t.ColorMatrixFilter,Object.defineProperty(t.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(e){this.uniforms.matrix.value=e}}),t.GrayFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={gray:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float gray;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);","}"]},t.GrayFilter.prototype=Object.create(t.AbstractFilter.prototype),t.GrayFilter.prototype.constructor=t.GrayFilter,Object.defineProperty(t.GrayFilter.prototype,"gray",{get:function(){return this.uniforms.gray.value},set:function(e){this.uniforms.gray.value=e}}),t.DisplacementFilter=function(e){t.AbstractFilter.call(this),this.passes=[this],e.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:e},scale:{type:"2f",value:{x:30,y:30}},offset:{type:"2f",value:{x:0,y:0}},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},e.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=e.width,this.uniforms.mapDimensions.value.y=e.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),e.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {"," vec2 mapCords = vTextureCoord.xy;"," mapCords += (dimensions.zw + offset)/ dimensions.xy ;"," mapCords.y *= -1.0;"," mapCords.y += 1.0;"," vec2 matSample = texture2D(displacementMap, mapCords).xy;"," matSample -= 0.5;"," matSample *= scale;"," matSample /= mapDimensions;"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));"," gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);"," vec2 cord = vTextureCoord;","}"]},t.DisplacementFilter.prototype=Object.create(t.AbstractFilter.prototype),t.DisplacementFilter.prototype.constructor=t.DisplacementFilter,t.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(t.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(e){this.uniforms.displacementMap.value=e}}),Object.defineProperty(t.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(e){this.uniforms.scale.value=e}}),Object.defineProperty(t.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(e){this.uniforms.offset.value=e}}),t.PixelateFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:0},dimensions:{type:"4fv",value:new Float32Array([1e4,100,10,10])},pixelSize:{type:"2f",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {"," vec2 coord = vTextureCoord;"," vec2 size = dimensions.xy/pixelSize;"," vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;"," gl_FragColor = texture2D(uSampler, color);","}"]},t.PixelateFilter.prototype=Object.create(t.AbstractFilter.prototype),t.PixelateFilter.prototype.constructor=t.PixelateFilter,Object.defineProperty(t.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(e){this.dirty=!0,this.uniforms.pixelSize.value=e}}),t.BlurXFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," vec4 sum = vec4(0.0);"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;"," gl_FragColor = sum;","}"]},t.BlurXFilter.prototype=Object.create(t.AbstractFilter.prototype),t.BlurXFilter.prototype.constructor=t.BlurXFilter,Object.defineProperty(t.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(e){this.dirty=!0,this.uniforms.blur.value=1/7e3*e}}),t.BlurYFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," vec4 sum = vec4(0.0);"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;"," gl_FragColor = sum;","}"]},t.BlurYFilter.prototype=Object.create(t.AbstractFilter.prototype),t.BlurYFilter.prototype.constructor=t.BlurYFilter,Object.defineProperty(t.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(e){this.uniforms.blur.value=1/7e3*e}}),t.BlurFilter=function(){this.blurXFilter=new t.BlurXFilter,this.blurYFilter=new t.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},Object.defineProperty(t.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(e){this.blurXFilter.blur=this.blurYFilter.blur=e}}),Object.defineProperty(t.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(e){this.blurXFilter.blur=e}}),Object.defineProperty(t.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(e){this.blurYFilter.blur=e}}),t.InvertFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","}"]},t.InvertFilter.prototype=Object.create(t.AbstractFilter.prototype),t.InvertFilter.prototype.constructor=t.InvertFilter,Object.defineProperty(t.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(e){this.uniforms.invert.value=e}}),t.SepiaFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","}"]},t.SepiaFilter.prototype=Object.create(t.AbstractFilter.prototype),t.SepiaFilter.prototype.constructor=t.SepiaFilter,Object.defineProperty(t.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(e){this.uniforms.sepia.value=e}}),t.TwistFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"2f",value:{x:.5,y:.5}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float radius;","uniform float angle;","uniform vec2 offset;","void main(void) {"," vec2 coord = vTextureCoord - offset;"," float distance = length(coord);"," if (distance < radius) {"," float ratio = (radius - distance) / radius;"," float angleMod = ratio * ratio * angle;"," float s = sin(angleMod);"," float c = cos(angleMod);"," coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);"," }"," gl_FragColor = texture2D(uSampler, coord+offset);","}"]},t.TwistFilter.prototype=Object.create(t.AbstractFilter.prototype),t.TwistFilter.prototype.constructor=t.TwistFilter,Object.defineProperty(t.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(e){this.dirty=!0,this.uniforms.offset.value=e}}),Object.defineProperty(t.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(e){this.dirty=!0,this.uniforms.radius.value=e}}),Object.defineProperty(t.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(e){this.dirty=!0,this.uniforms.angle.value=e}}),t.ColorStepFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={step:{type:"1f",value:5}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float step;","void main(void) {"," vec4 color = texture2D(uSampler, vTextureCoord);"," color = floor(color * step) / step;"," gl_FragColor = color;","}"]},t.ColorStepFilter.prototype=Object.create(t.AbstractFilter.prototype),t.ColorStepFilter.prototype.constructor=t.ColorStepFilter,Object.defineProperty(t.ColorStepFilter.prototype,"step",{get:function(){return this.uniforms.step.value},set:function(e){this.uniforms.step.value=e}}),t.DotScreenFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {"," float s = sin(angle), c = cos(angle);"," vec2 tex = vTextureCoord * dimensions.xy;"," vec2 point = vec2("," c * tex.x - s * tex.y,"," s * tex.x + c * tex.y"," ) * scale;"," return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {"," vec4 color = texture2D(uSampler, vTextureCoord);"," float average = (color.r + color.g + color.b) / 3.0;"," gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},t.DotScreenFilter.prototype=Object.create(t.DotScreenFilter.prototype),t.DotScreenFilter.prototype.constructor=t.DotScreenFilter,Object.defineProperty(t.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(e){this.dirty=!0,this.uniforms.scale.value=e}}),Object.defineProperty(t.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(e){this.dirty=!0,this.uniforms.angle.value=e}}),t.CrossHatchFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);"," gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"," if (lum < 1.00) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.75) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.50) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.3) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }","}"]},t.CrossHatchFilter.prototype=Object.create(t.AbstractFilter.prototype),t.CrossHatchFilter.prototype.constructor=t.BlurYFilter,Object.defineProperty(t.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(e){this.uniforms.blur.value=1/7e3*e}}),t.RGBSplitFilter=function(){t.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"2f",value:{x:20,y:20}},green:{type:"2f",value:{x:-20,y:20}},blue:{type:"2f",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;"," gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;"," gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;"," gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},t.RGBSplitFilter.prototype=Object.create(t.AbstractFilter.prototype),t.RGBSplitFilter.prototype.constructor=t.RGBSplitFilter,Object.defineProperty(t.RGBSplitFilter.prototype,"angle",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(e){this.uniforms.blur.value=1/7e3*e}}),typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=t),exports.PIXI=t):typeof define!="undefined"&&define.amd?define("Lib/Vendor/Pixi/pixi.dev",[],t):e.PIXI=t}.call(this),define("Lib/Vendor/Pixi",["Lib/Vendor/Pixi/pixi.dev"],function(e){return e}),define("Game/Client/Loader/Level",["Game/Core/Loader/Level","Game/Config/Settings","Lib/Utilities/NotificationCenter","Lib/Vendor/Pixi","Game/Client/View/Abstract/Layer"],function(e,t,n,r,i){function s(t,n,r){e.call(this,t,n,r)}return s.prototype=Object.create(e.prototype),s.prototype.loadLevelDataFromPath=function(e,t){var n=this,r=new XMLHttpRequest;r.onreadystatechange=function(){r.readyState==4&&(r.status==200?n.loadAssets(JSON.parse(r.responseText),t):console.error("Ajax error: "+r.status+" "+r.statusText))},r.open("GET",e,!0),r.send(null)},s.prototype.loadAssets=function(e,t){var i=this.getAssetPaths(e),s=0,o=i.length,u=new r.AssetLoader(i);u.onComplete=function(){t(e)},u.onProgress=function(){var e=parseInt(100/o*++s,10)+1;n.trigger(n.ns.client.view.preloadBar.update,e)},u.load()},s.prototype.getAssetPaths=function(e){var n=[],r=function(e){return e<10?"00"+e:e<100?"0"+e:e},i=["Chuck"],s=["WithArms","WithoutArms"],o="";for(var u=0;u<i.length;u++){var a=i[u];for(var f=1;f<=126;f++)for(var l=0;l<s.length;l++){var c=s[l];n.push(t.GRAPHICS_PATH+t.GRAPHICS_SUBPATH_CHARACTERS+a+"/Animation/"+c+"/ChuckAnimations0"+r(f)+".png")}}return n.push(t.GRAPHICS_PATH+t.GRAPHICS_SUBPATH_CHARACTERS+a+"/head.png"),n},s.prototype.setupLayer=function(t,r,i){e.prototype.setupLayer.call(this,t,r,i);var s=0;t.properties&&t.properties.parallaxSpeed&&(s=parseFloat(t.properties.parallaxSpeed)),n.trigger(n.ns.client.view.layer.createAndInsert,t.layerId,s,r,i)},s}),define("Game/Config/ItemSettings",[],function(){var e={Default:{category:"",image:"",type:"rectangle",weight:"2.5",width:"25",height:"25",rotation:"0",bounce:"0",grabAngle:"-1.5",danger:"1",bodyType:"dynamic"},RagDoll:{category:"graveyard",image:"chest.png",type:"ragdoll",weight:"5",width:"6",height:"12",bounce:"4",grabAngle:"-0.5",danger:"1"},Knife:{category:"kitchen",image:"knife.gif",weight:"1.5",width:"4",height:"15",grabAngle:"0.3",danger:"3"},"Large Knife":{category:"kitchen",image:"knife_big.gif",weight:"2.2",width:"4",height:"23",grabAngle:"0.3",danger:"3"},"Small Cleaver":{category:"kitchen",image:"cleaver_small.gif",weight:"2",width:"6",height:"17",grabAngle:"0.3",danger:"3"},"Large Cleaver":{category:"kitchen",image:"cleaver_large.gif",weight:"3",width:"8",height:"22",grabAngle:"0.3",danger:"3"},"Herb Chopper":{category:"kitchen",image:"herb_chopper.gif",weight:"1.1",width:"9",height:"7",grabAngle:"0.3",danger:"2.6"},Fork:{category:"kitchen",image:"fork.gif",weight:"1.5",width:"5",height:"16",grabAngle:"0.3",danger:"1.8"},"Meat Fork":{category:"kitchen",image:"fork_meat.gif",weight:"2",width:"3",height:"22",grabAngle:"0.3",danger:"1.9"},Spoon:{category:"kitchen",image:"spoon.gif",weight:"2",width:"4",height:"21",grabAngle:"0.3",danger:"1.1"},Plate:{category:"kitchen",image:"plate.gif",type:"circle",weight:"1.9",width:"13",height:"13",grabAngle:"0"},Cup:{category:"kitchen",image:"cup.gif",weight:"1.1",width:"8",height:"8",grabAngle:"-0.3"},Can:{category:"kitchen",image:"can.gif",weight:"1",width:"4",height:"7",grabAngle:"-0.1",bounce:"2"},"Rolling Pin":{category:"kitchen",image:"rolling_pin.gif",weight:"1.3",width:"6",height:"26",grabAngle:"0.3"},Pan:{category:"kitchen",image:"pan.gif",weight:"1.4",width:"14",height:"8",grabAngle:"0.3"},Refridgerator:{category:"kitchen",image:"fridge.gif",weight:"10",width:"31",height:"53",bounce:"0",grabAngle:"-0.5"},Microwave:{category:"kitchen",image:"microwave.gif",weight:"3.6",width:"19",height:"12",grabAngle:"-0.1"},Coffeemachine:{category:"kitchen",image:"coffeemachine.gif",weight:"2.4",width:"11",height:"14"},Toaster:{category:"kitchen",image:"toaster.gif",weight:"1.9",width:"15",height:"9"},Banana:{category:"kitchen",image:"banana.gif",weight:"1",width:"5",height:"9",grabAngle:"0.5"},Tomato:{category:"kitchen",image:"tomato.gif",type:"circle",weight:"1",width:"8",height:"9",grabAngle:"-0.3"},Football:{category:"outdoor",image:"football.gif",type:"circle",weight:"2",width:"10",height:"10",bounce:"6"},Skateboard:{category:"outdoor",image:"skateboard.gif",type:"skateboard",weight:"1.5",width:"26",height:"6",grabAngle:"-1.5"},"Laundry Machine":{category:"laundry",image:"laundry_machine.gif",weight:"10",width:"24",height:"31",grabAngle:"-0.5"},"Laundry Powder":{category:"laundry",image:"laundry_powder.gif",weight:"2",width:"11",height:"13",grabAngle:"-0.2"},Bible:{category:"livingroom",image:"book_bible.gif",weight:"1.5",width:"11",height:"14",grabAngle:"-0.2"},Television:{category:"livingroom",image:"television.gif",weight:"7",width:"24",height:"21",grabAngle:"-0.4"},"TV Cabinet":{category:"livingroom",image:"telly_cabinet.gif",weight:"5",width:"24",height:"17",grabAngle:"-0.4"},Rube:{category:"kitchen",image:"banana.gif",weight:"1",width:"5",height:"9",grabAngle:"0.5"}};return e}),define("Game/Core/Loader/TiledLevel",["Game/Client/Loader/Level","Game/Config/Settings","Game/Config/ItemSettings","Lib/Vendor/Box2D","Lib/Utilities/Options","Lib/Utilities/Exception","Lib/Utilities/NotificationCenter","Game/Client/View/Abstract/Layer","Game/Client/Collision/Detector","Game/Client/GameObjects/Tile","Game/Client/GameObjects/Item","Game/Client/GameObjects/Items/Skateboard"],function(e,t,n,r,i,s,o,u,a,f,l,c){function h(t,n){this.layerMapping={tiles:this.createTiles.bind(this),items:this.createItems.bind(this),spawnpoints:this.createSpawnPoints.bind(this)},this.levelData=null,e.call(this,t,n)}return h.prototype=Object.create(e.prototype),h.prototype.setup=function(t){function r(e,t){var n={tiles:u.ID.TILE,items:u.ID.ITEM,spawnpoints:u.ID.SPAWN};return n[e]?n[e]:"layer-"+t+"-"+e}this.levelData=t;var n=t.layers.some(function(e){return e.name=="spawnpoints"});if(!n){console.warn("No layerMapping for level file layer: "+a.name);return}var i=!1,s=null;for(var o=t.layers.length-1;o>=0;o--){var a=t.layers[o];a.z=o,a.layerId=r(a.name,o),a.name=="spawnpoints"&&(i=!0);if(!i)continue;this.setupLayer(a,!0,s),this.layerMapping[a.name]&&this.layerMapping[a.name](a),s=a.layerId}i=!1,s=u.ID.SPAWN;for(var o=0;o<t.layers.length;o++){var a=t.layers[o];a.z=o,a.layerId=r(a.name,o);if(a.name=="spawnpoints"){i=!0;continue}if(!i)continue;this.setupLayer(a,!1,s),this.layerMapping[a.name]&&this.layerMapping[a.name](a),s=a.layerId}e.prototype.setup.call(this,t)},h.prototype.createTiles=function(t){var n=t.data,r=[];for(var i=0;i<n.length;i++){var s=n[i];if(s===0)continue;var o=this.getTileImagePath(s),u=o.split("/"),a=u[u.length-1].split(".")[0].split(""),f={s:parseInt(a[0],10),r:parseInt(a[1],10),t:o,x:i%t.width,y:parseInt(i/t.height,10)};r.push(f)}e.prototype.createTiles.call(this,r)},h.prototype.createItems=function(t){var n=t.objects,r=[];for(var i=0;i<n.length;i++){var t=this.gatherOptions(n[i]);r.push(t)}e.prototype.createItems.call(this,r)},h.prototype.createSpawnPoints=function(t){var n=t.objects.map(function(e){return{x:e.x,y:e.y}});e.prototype.createSpawnPoints.call(this,n)},h.prototype.gatherOptions=function(e){var n={};n.name=e.name,n.rotation=e.rotation,n.width=e.width/t.TILE_RATIO,n.height=e.height/t.TILE_RATIO,n.x=(e.x+e.width/2)/t.TILE_RATIO,n.y=(e.y+n.height/2)/t.TILE_RATIO,n.width||(n.width=undefined),n.height||(n.height=undefined);var r=this.getDefaultItemSettingsByName(n.name);return n=i.merge(n,r),n},h.prototype.getDefaultItemSettingsByName=function(e){if(!e)throw new s("Item name cannot be be empty");if(n[e]===undefined)throw new s("Item name ("+e+") cannot be found in item list");var t=n.Default;return t=i.merge(n[e],t),t},h.prototype.getTileImagePath=function(e){for(var t=0;t<this.levelData.tilesets.length;t++){var n=this.levelData.tilesets[t],r=n.firstgid;if(e>=r&&e<r+Object.keys(n.tiles).length)return n.tiles[""+(e-r)].image}},h}),define("Game/Client/Loader/TiledLevel",["Game/Core/Loader/TiledLevel","Game/Config/Settings","Lib/Utilities/NotificationCenter"],function(e,t,n){function r(t,n,r){this.layerId="background",e.call(this,t,n,r)}return r.prototype=Object.create(e.prototype),r.prototype.setup=function(t){e.prototype.setup.call(this,t)},r.prototype.getAssetPaths=function(n){var r=e.prototype.getAssetPaths.call(this,n);for(var i=0;i<n.tilesets.length;i++){var s=n.tilesets[i];for(var o in s.tiles){var u=s.tiles[o].image;u&&r.push(t.MAPS_PATH+u)}}var a=this.getLayer(n,"items").objects;for(var i=0;i<a.length;i++){var f=a[i],l=this.gatherOptions(f),c=t.GRAPHICS_PATH+t.GRAPHICS_SUBPATH_ITEMS+l.category+"/"+l.image;r.push(c)}for(var i=0;i<n.layers.length;i++){var h=n.layers[i];h.type=="imagelayer"&&r.push(t.MAPS_PATH+h.image)}return r},r.prototype.setupLayer=function(r,i,s){e.prototype.setupLayer.call(this,r,i,s);if(r.type=="imagelayer"){var o=t.MAPS_PATH+r.image,u=function(e){n.trigger(n.ns.client.view.mesh.add,r.layerId,e),n.trigger(n.ns.client.view.mesh.update,r.layerId,e,{x:t.STAGE_WIDTH/2,y:t.STAGE_HEIGHT/2,pivot:{x:e.texture.width/2,y:e.texture.height/2},xScale:1,yScale:1})};n.trigger(n.ns.client.view.mesh.create,r.layerId,o,u,{alpha:r.opacity})}},r.prototype.getLayer=function(e,t){for(var n=0;n<e.layers.length;n++)if(e.layers[n].name===t)return e.layers[n];throw"Layer '"+t+"' not found."},r}),define("Game/Core/GameObjects/Doll",["Game/Client/GameObjects/GameObject","Lib/Vendor/Box2D","Game/Config/Settings","Game/Client/Collision/Detector","Game/Client/GameObjects/Item","Lib/Utilities/NotificationCenter"],function(e,t,n,r,i,s){function o(t,n,r){this.characterName="Chuck",this.player=r,this.height=37,this.width=9,this.headHeight=12,this.reachDistance=20,this.areaSize=35,e.call(this,t,n),this.standing=!1,this.moveDirection=0,this.lookDirection=0,this.legs,this.footSensor,this.actionState=null,this.lookAtXY={x:0,y:0},this.reachableItems={left:[],right:[]},this.nearbyDolls=[],this.holdingJoint=null,this.holdingItem=null,this.ragDoll={head:null,body:null},this.createFixtures(),this.body.SetActive(!1)}return o.prototype=Object.create(e.prototype),o.prototype.getBodyDef=function(){var e=new t.Dynamics.b2BodyDef;return e.position.x=0,e.position.y=0,e.fixedRotation=!0,e.linearDamping=n.PLAYER_LINEAR_DAMPING,e.type=t.Dynamics.b2Body.b2_dynamicBody,e},o.prototype.createFixtures=function(){var e=this,r=new t.Dynamics.b2FixtureDef;r.density=n.PLAYER_DENSITY,r.friction=0,r.restitution=n.PLAYER_RESTITUTION;var i=new t.Collision.Shapes.b2CircleShape;i.SetRadius(this.width/2/n.RATIO),i.SetLocalPosition(new t.Common.Math.b2Vec2(0,-(this.height-this.width/2)/n.RATIO)),r.shape=i,r.isSensor=!1,r.userData={onCollisionChange:this.onImpact.bind(this)},this.body.CreateFixture(r);var s=new t.Collision.Shapes.b2PolygonShape;s.SetAsOrientedBox(this.width/2/n.RATIO,(this.height-this.width)/2/n.RATIO,new t.Common.Math.b2Vec2(0,-this.height/2/n.RATIO)),r.shape=s,r.isSensor=!1,this.body.CreateFixture(r);var u=new t.Collision.Shapes.b2CircleShape;u.SetRadius(this.width/2/n.RATIO),u.SetLocalPosition(new t.Common.Math.b2Vec2(0,-this.width/2/n.RATIO)),r.shape=u,r.friction=n.PLAYER_FRICTION,r.isSensor=!1,this.legs=this.body.CreateFixture(r),r.density=0;var a=new t.Collision.Shapes.b2CircleShape;a.SetRadius((this.width-1)/2/n.RATIO),a.SetLocalPosition(new t.Common.Math.b2Vec2(0,2/n.RATIO)),r.shape=a,r.isSensor=!0,r.userData={onCollisionChange:this.onFootSensorDetection.bind(this)},this.footSensor=this.body.CreateFixture(r);var f=new t.Collision.Shapes.b2PolygonShape;f.SetAsOrientedBox(this.reachDistance/2/n.RATIO,(this.height/2+this.reachDistance/4)/n.RATIO,new t.Common.Math.b2Vec2(-this.reachDistance/2/n.RATIO,-this.height/2/n.RATIO)),r.shape=f,r.isSensor=!0,r.userData={onCollisionChange:function(t,n){e.onFixtureWithinReach(t,"left",n)}},this.body.CreateFixture(r);var l=new t.Collision.Shapes.b2PolygonShape;l.SetAsOrientedBox(this.reachDistance/2/n.RATIO,(this.height/2+this.reachDistance/4)/n.RATIO,new t.Common.Math.b2Vec2(this.reachDistance/2/n.RATIO,-this.height/2/n.RATIO)),r.shape=l,r.isSensor=!0,r.userData={onCollisionChange:function(t,n){e.onFixtureWithinReach(t,"right",n)}},this.body.CreateFixture(r);var c=new t.Collision.Shapes.b2PolygonShape;c.SetAsOrientedBox((this.width+this.areaSize)/2/n.RATIO,(this.height+this.areaSize)/2/n.RATIO,new t.Common.Math.b2Vec2(0,-this.height/2/n.RATIO)),r.shape=c,r.isSensor=!0,r.userData={onCollisionChange:function(t,n){var r=n.GetBody().GetUserData();if(r instanceof o){var i=r,s=e.nearbyDolls.indexOf(i);t?s===-1&&e.nearbyDolls.push(i):s!==-1&&e.nearbyDolls.splice(s,1)}}},this.body.CreateFixture(r)},o.prototype.setActionState=function(e){this.actionState=e},o.prototype.getActionState=function(){return this.actionState},o.prototype.isWalking=function(){return["walk","walkback","run"].indexOf(this.actionState)>=0},o.prototype.spawn=function(e,r){this.body.SetPosition(new t.Common.Math.b2Vec2(e/n.RATIO,r/n.RATIO)),this.body.SetActive(!0),this.setActionState("fall")},o.prototype.getHeadPosition=function(){var e=this.body.GetPosition();return{x:e.x,y:e.y-(this.height-this.headHeight/2)/n.RATIO}},o.prototype.setFriction=function(e){e||(e=-1),this.legs.GetFriction()!=e&&this.legs.SetFriction(e)},o.prototype.move=function(e){this.moveDirection=e;var r,i=this.holdingItem&&this.holdingItem.options.weight>n.MAX_RUNNING_WEIGHT;switch(!0){case e==this.lookDirection&&this.isStanding()&&!i:r=n.RUN_SPEED;break;case!this.isStanding():r=n.FLY_SPEED,i&&n.FLY_SPEED>n.WALK_SPEED&&(r=n.WALK_SPEED);break;default:r=n.WALK_SPEED}this.setFriction(n.PLAYER_MOTION_FRICTION),this.body.SetAwake(!0);var s=new t.Common.Math.b2Vec2(r*e,this.body.GetLinearVelocity().y);this.body.SetLinearVelocity(s),this.isStanding()&&(this.moveDirection==this.lookDirection?i?this.setActionState("walk"):this.setActionState("run"):this.setActionState("walkback"))},o.prototype.stop=function(){this.moveDirection=0,this.setFriction(n.PLAYER_FRICTION);if(this.isStanding())this.setActionState("stand");else{var e=this.body.GetLinearVelocity().Copy();e.x*=n.JUMP_STOP_DAMPING_FACTOR,this.body.SetLinearVelocity(e)}},o.prototype.jump=function(){if(this.isStanding()){this.body.SetAwake(!0);var e=new t.Common.Math.b2Vec2(0,-n.JUMP_SPEED);this.body.SetLinearVelocity(e),this.setStanding(!1),this.setActionState("jump")}},o.prototype.jumpStop=function(){if(!this.isStanding()){this.body.SetAwake(!0);var e=this.body.GetLinearVelocity().Copy();e.y<0&&(e.y*=n.JUMP_STOP_DAMPING_FACTOR,this.body.SetLinearVelocity(e))}},o.prototype.setStanding=function(e){if(this.standing==e)return;this.standing=e,e&&this.setActionState("stand")},o.prototype.isStanding=function(){return this.standing},o.prototype.lookAt=function(e,t){var n=this.lookDirection;this.body.SetAwake(!0),e<0?this.lookDirection=-1:this.lookDirection=1,this.lookAtXY.x=e,this.lookAtXY.y=t,n!=this.lookDirection&&this.positionHoldingItem()},o.prototype.grab=function(e){this.holdingItem=e,this.positionHoldingItem()},o.prototype.positionHoldingItem=function(){if(this.holdingItem){this.holdingJoint&&(this.body.GetWorld().DestroyJoint(this.holdingJoint),this.holdingJoint=null);var e=this.body.GetPosition(),r=new t.Common.Math.b2Vec2(e.x+this.width/2/n.RATIO*this.lookDirection,e.y-this.height/4*2/n.RATIO);this.holdingItem.reposition(r,this.lookDirection);var i=new t.Dynamics.Joints.b2WeldJointDef;i.Initialize(this.body,this.holdingItem.body,this.holdingItem.getGrabPoint()),this.holdingJoint=this.body.GetWorld().CreateJoint(i)}},o.prototype.throw=function(e,t,n){this.body.GetWorld().DestroyJoint(this.holdingJoint),this.holdingJoint=null,this.holdingItem=null,e.throw(t,n)},o.prototype.isAnotherPlayerNearby=function(){return this.nearbyDolls.length>0},o.prototype.onFootSensorDetection=function(e,t){var r=this,i=this.body.GetLinearVelocity().y<-n.JUMP_SPEED;if(e)i||this.setStanding(!0);else{var s=0,o=r.body.GetContactList();while(o){var u=o.contact;if(!u.IsTouching()){o=o.next;continue}u.GetFixtureA()===r.footSensor&&s++,u.GetFixtureB()===r.footSensor&&s++,o=o.next}s===0&&r.setStanding(!1)}},o.prototype.onImpact=function(e,t){},o.prototype.onFixtureWithinReach=function(e,t,n){var r=n.GetBody().GetUserData();if(!(r instanceof i))return;if(e)this.reachableItems[t].push(r);else{var s=this.reachableItems[t].indexOf(r);s>=0&&this.reachableItems[t].splice(s,1)}},o.prototype.getVelocities=function(){return{linearVelocity:this.body.GetLinearVelocity(),angularVelocity:this.body.GetAngularVelocity()}},o.prototype.update=function(){this.body.GetLinearVelocity().x==0&&this.isWalking()&&this.stop(),!this.body.IsAwake()&&!this.isStanding()&&this.setStanding(!0)},o.prototype.destroy=function(){e.prototype.destroy.call(this)},o}),define("Lib/Vendor/CryptoJS",[],function(){var e=e||function(e,t){var n={},r=n.lib={},i=r.Base=function(){function e(){}return{extend:function(t){e.prototype=this;var n=new e;return t&&n.mixIn(t),n.$super=this,n},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.$super.extend(this)}}}(),s=r.WordArray=i.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,e=e.sigBytes;this.clamp();if(r%4)for(var i=0;i<e;i++)t[r+i>>>2]|=(n[i>>>2]>>>24-8*(i%4)&255)<<24-8*((r+i)%4);else if(65535<n.length)for(i=0;i<e;i+=4)t[r+i>>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-8*(n%4),t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r<t;r+=4)n.push(4294967296*e.random()|0);return s.create(n,t)}}),o=n.enc={},u=o.Hex={stringify:function(e){for(var t=e.words,e=e.sigBytes,n=[],r=0;r<e;r++){var i=t[r>>>2]>>>24-8*(r%4)&255;n.push((i>>>4).toString(16)),n.push((i&15).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-4*(r%8);return s.create(n,t/2)}},a=o.Latin1={stringify:function(e){for(var t=e.words,e=e.sigBytes,n=[],r=0;r<e;r++)n.push(String.fromCharCode(t[r>>>2]>>>24-8*(r%4)&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(e.charCodeAt(r)&255)<<24-8*(r%4);return s.create(n,t)}},f=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(a.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return a.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=s.create(),this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,u=i/(4*o),u=t?e.ceil(u):e.max((u|0)-this._minBufferSize,0),t=u*o,i=e.min(4*t,i);if(t){for(var a=0;a<t;a+=o)this._doProcessBlock(r,a);a=r.splice(0,t),n.sigBytes-=i}return s.create(a,i)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=l.extend({init:function(){this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize(),this._hash},clone:function(){var e=l.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:16,_createHelper:function(e){return function(t,n){return e.create(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return c.HMAC.create(e,n).finalize(t)}}});var c=n.algo={};return n}(Math);return function(t){function n(e,t,n,r,i,s,o){return e=e+(t&n|~t&r)+i+o,(e<<s|e>>>32-s)+t}function r(e,t,n,r,i,s,o){return e=e+(t&r|n&~r)+i+o,(e<<s|e>>>32-s)+t}function i(e,t,n,r,i,s,o){return e=e+(t^n^r)+i+o,(e<<s|e>>>32-s)+t}function s(e,t,n,r,i,s,o){return e=e+(n^(t|~r))+i+o,(e<<s|e>>>32-s)+t}var o=e,u=o.lib,a=u.WordArray,u=u.Hasher,f=o.algo,l=[];(function(){for(var e=0;64>e;e++)l[e]=4294967296*t.abs(t.sin(e+1))|0})(),f=f.MD5=u.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var o=0;16>o;o++){var u=t+o,a=e[u];e[u]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360}for(var u=this._hash.words,a=u[0],f=u[1],c=u[2],p=u[3],o=0;64>o;o+=4)16>o?(a=n(a,f,c,p,e[t+o],7,l[o]),p=n(p,a,f,c,e[t+o+1],12,l[o+1]),c=n(c,p,a,f,e[t+o+2],17,l[o+2]),f=n(f,c,p,a,e[t+o+3],22,l[o+3])):32>o?(a=r(a,f,c,p,e[t+(o+1)%16],5,l[o]),p=r(p,a,f,c,e[t+(o+6)%16],9,l[o+1]),c=r(c,p,a,f,e[t+(o+11)%16],14,l[o+2]),f=r(f,c,p,a,e[t+o%16],20,l[o+3])):48>o?(a=i(a,f,c,p,e[t+(3*o+5)%16],4,l[o]),p=i(p,a,f,c,e[t+(3*o+8)%16],11,l[o+1]),c=i(c,p,a,f,e[t+(3*o+11)%16],16,l[o+2]),f=i(f,c,p,a,e[t+(3*o+14)%16],23,l[o+3])):(a=s(a,f,c,p,e[t+3*o%16],6,l[o]),p=s(p,a,f,c,e[t+(3*o+7)%16],10,l[o+1]),c=s(c,p,a,f,e[t+(3*o+14)%16],15,l[o+2]),f=s(f,c,p,a,e[t+(3*o+5)%16],21,l[o+3]));u[0]=u[0]+a|0,u[1]=u[1]+f|0,u[2]=u[2]+c|0,u[3]=u[3]+p|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[(r+64>>>9<<4)+14]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360,e.sigBytes=4*(t.length+1),this._process(),e=this._hash.words;for(t=0;4>t;t++)n=e[t],e[t]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360}}),o.MD5=u._createHelper(f),o.HmacMD5=u._createHmacHelper(f)}(Math),e}),define("Lib/Utilities/ColorConverter",["Lib/Vendor/CryptoJS"],function(e){function t(){this.sin=0;var e=[6507634,7490654,7895376,5273969,5270137,9191996,5602890,4417413,10888227,4358023,4664858,5072508,2767945,8158763,3882017,2505767,8292734,11882516,9931826,7573815,4620879,1683636,794289,13414918,4406816,2103827,283542,3226888,12034885,14423690,3212549,333361];this.palette=e}return t.prototype.getColorByName=function(t){t=e.MD5(t).toString();var n=0;for(var r=0;r<t.length;r++)n+=t.charCodeAt(r)*3;return this.palette[n%this.palette.length]},t}),define("Game/Client/GameObjects/Doll",["Game/Core/GameObjects/Doll","Game/Config/Settings","Lib/Utilities/NotificationCenter","Lib/Utilities/Exception","Lib/Utilities/ColorConverter","Game/Client/View/Abstract/Layer"],function(e,t,n,r,i,s){function o(t,n,r){this.layerId=s.ID.SPAWN,this.animationDef={stand:[1,1],walk:[2,28],walkback:[29,55],jump:[81,91],fall:[81,91],duck:[92,97],standup:[98,103],run:[104,126]},this.animatedMeshesContainer={withArms:{},withoutArms:{}},this.animatedMeshes=this.animatedMeshesContainer.withArms,this.headMesh=null,this.holdingArmMesh=null;var o=new i;this.primaryColor=o.getColorByName(r.getNickname()),e.call(this,t,n,r)}return o.prototype=Object.create(e.prototype),o.prototype.setActionState=function(t,i){if(!i&&this.actionState==t)return;if(!t)throw new r("action state is undefined");this.animatedMeshes[this.actionState]&&(n.trigger(n.ns.client.view.mesh.update,this.layerId,this.animatedMeshesContainer.withArms[this.actionState],{visible:!1}),n.trigger(n.ns.client.view.mesh.update,this.layerId,this.animatedMeshesContainer.withoutArms[this.actionState],{visible:!1})),e.prototype.setActionState.call(this,t),n.trigger(n.ns.client.view.mesh.update,this.layerId,this.animatedMeshes[this.actionState],{visible:!0,xScale:this.lookDirection})},o.prototype.createMesh=function(){var e=this,r=function(t){n.trigger(n.ns.client.view.mesh.addFilter,e.layerId,t,"colorRangeReplace",{minColor:3885617,maxColor:6651732,newColor:e.primaryColor,brightnessOffset:.56})},i=function(e){return e<10?"00"+e:e<100?"0"+e:e},e=this,s=["withArms","withoutArms"];for(var o=0;o<s.length;o++){var u=s[o];for(var a in this.animationDef){var f=this.animationDef[a][0],l=this.animationDef[a][1],c=[];for(var h=f;h<=l;h++)c.push(t.GRAPHICS_PATH+t.GRAPHICS_SUBPATH_CHARACTERS+this.characterName+"/Animation/"+u.toUpperCaseFirstChar()+"/ChuckAnimations0"+i(h)+".png");var p=function(t){e.animatedMeshesContainer[u][a]=t,n.trigger(n.ns.client.view.mesh.add,e.layerId,t),r(t)};n.trigger(n.ns.client.view.animatedMesh.create,this.layerId,c,p,{visible:!1,pivot:{x:70,y:160},width:35,height:40})}}var d=t.GRAPHICS_PATH+"Characters/Chuck/head.png",p=function(t){e.headMesh=t,n.trigger(n.ns.client.view.mesh.add,e.layerId,t)};n.trigger(n.ns.client.view.mesh.create,this.layerId,d,p,{pivot:{x:5,y:12},width:10,height:12}),d=t.GRAPHICS_PATH+"Characters/Chuck/holdingArm.png";var p=function(t){e.holdingArmMesh=t,n.trigger(n.ns.client.view.mesh.add,e.layerId,t),r(t)};n.trigger(n.ns.client.view.mesh.create,this.layerId,d,p,{visible:!1,pivot:{x:70,y:160},width:35,height:40})},o.prototype.lookAt=function(t,r){var i=this.lookDirection;e.prototype.lookAt.call(this,t,r);if(i!=this.lookDirection){for(var s in this.animatedMeshes)n.trigger(n.ns.client.view.mesh.update,this.layerId,this.animatedMeshes[s],{xScale:this.lookDirection});n.trigger(n.ns.client.view.mesh.update,this.layerId,this.holdingArmMesh,{xScale:this.lookDirection})}var o=Math.atan2(this.lookAtXY.x,this.lookAtXY.y)/2-.7855*this.lookDirection;n.trigger(n.ns.client.view.mesh.update,this.layerId,this.headMesh,{xScale:this.lookDirection,rotation:o})},o.prototype.grab=function(t){e.prototype.grab.call(this,t),this.animatedMeshes=this.animatedMeshesContainer.withoutArms,this.setActionState(this.actionState,!0),n.trigger(n.ns.client.view.mesh.update,this.layerId,this.holdingArmMesh,{visible:!0})},o.prototype.throw=function(t,r,i){e.prototype.throw.call(this,t,r,i),this.animatedMeshes=this.animatedMeshesContainer.withArms,this.setActionState(this.actionState,!0),n.trigger(n.ns.client.view.mesh.update,this.layerId,this.holdingArmMesh,{visible:!1})},o.prototype.destroy=function(){for(var t in this.animatedMeshes)n.trigger(n.ns.client.view.mesh.remove,this.layerId,this.animatedMeshes[t]);n.trigger(n.ns.client.view.mesh.remove,this.layerId,this.headMesh),e.prototype.destroy.call(this)},o.prototype.render=function(){this.actionState&&(n.trigger(n.ns.client.view.mesh.update,this.layerId,this.animatedMeshes[this.actionState],{x:this.body.GetPosition().x*t.RATIO,y:this.body.GetPosition().y*t.RATIO}),n.trigger(n.ns.client.view.mesh.update,this.layerId,this.headMesh,{x:this.body.GetPosition().x*t.RATIO,y:this.body.GetPosition().y*t.RATIO-this.height+this.headHeight}),n.trigger(n.ns.client.view.mesh.update,this.layerId,this.holdingArmMesh,{x:this.body.GetPosition().x*t.RATIO,y:this.body.GetPosition().y*t.RATIO}))},o}),define("Game/Core/GameObjects/SpectatorDoll",["Game/Client/GameObjects/GameObject","Lib/Vendor/Box2D"],function(e,t){function n(t,n,r){e.call(this,t,n)}return n.prototype=Object.create(e.prototype),n.prototype.getBodyDef=function(){var e=new t.Dynamics.b2BodyDef;return e.type=t.Dynamics.b2Body.b2_dynamicBody,e.position.x=this.getPosition().x,e.position.y=this.getPosition().y,e.angle=0,e},n.prototype.getPosition=function(){return{x:10,y:10}},n.prototype.getHeadPosition=function(){return{x:10,y:10}},n.prototype.update=function(){},n}),define("Game/Client/GameObjects/SpectatorDoll",["Game/Core/GameObjects/SpectatorDoll"],function(e){function t(t,n){e.call(this,t,n)}return t.prototype=Object.create(e.prototype),t.prototype.render=function(){},t.prototype.createMesh=function(){},t}),define("Game/Core/Player",["Game/Client/GameObjects/Doll","Game/Config/Settings","Lib/Utilities/NotificationCenter","Lib/Utilities/Exception","Game/Client/GameObjects/SpectatorDoll","Game/Client/GameObjects/Items/RagDoll"],function(e,t,n,r,i,s){function o(e,t,r){this.stats={health:100,deaths:0,score:0},this.user=r,this.physicsEngine=t,this.playerController=null,this.doll,this.id=e,this.isSpawned=!1,this.holdingItem=null,this.spectatorDoll=new i(this.physicsEngine,"spectatorDoll-"+this.id,this),n.trigger(n.ns.core.game.gameObject.add,"animated",this)}return o.prototype.getActiveDoll=function(){return this.isSpawned?this.doll:this.ragDoll?this.ragDoll:this.spectatorDoll},o.prototype.spawn=function(t,n){this.doll=new e(this.physicsEngine,"doll-"+this.id,this),this.doll.spawn(t,n),this.isSpawned=!0},o.prototype.getPosition=function(){return this.getActiveDoll().getPosition()},o.prototype.getHeadPosition=function(){return this.getActiveDoll().getHeadPosition()},o.prototype.move=function(e){if(!this.isSpawned)return!1;this.doll.move(e)},o.prototype.stop=function(){if(!this.isSpawned)return!1;this.doll.stop()},o.prototype.jump=function(){if(!this.isSpawned)return!1;this.doll.jump()},o.prototype.jumpStop=function(){if(!this.isSpawned)return!1;this.doll.jumpStop()},o.prototype.lookAt=function(e,t){if(!this.isSpawned)return!1;this.doll.lookAt(e,t)},o.prototype.grab=function(e){if(!this.isSpawned)return!1;this.doll.grab(e),e.beingGrabbed(this),this.holdingItem=e},o.prototype.throw=function(e,t,n){if(!this.isSpawned)return!1;this.doll.throw(n,e,t),n.beingReleased(this),this.holdingItem=null},o.prototype.kill=function(e,n){if(!this.isSpawned)return!1;this.holdingItem&&this.throw(0,0,this.holdingItem);var r={x:this.getPosition().x*t.RATIO,y:this.getPosition().y*t.RATIO,category:"graveyard",grabAngle:-0.3,image:"chest.png",name:"RagDoll",rotation:0,type:"ragdoll",weight:3,width:5,height:12},i=new s(this.physicsEngine,"ragDoll-"+this.id+"-"+n,r);i.setVelocities(this.doll.getVelocities()),this.isSpawned=!1,this.doll.destroy(),this.doll=null,this.ragDoll=i},o.prototype.update=function(){this.doll&&this.doll.update(),this.playerController&&this.playerController.update()},o.prototype.destroy=function(){n.trigger(n.ns.core.game.gameObject.remove,"animated",this),this.holdingItem&&this.throw(0,0,this.holdingItem),this.spectatorDoll.destroy(),this.doll&&this.doll.destroy(),this.playerController&&this.playerController.destroy()},o.prototype.setPlayerController=function(e){this.playerController=e},o}),define("Game/Client/Player",["Game/Core/Player","Lib/Utilities/NotificationCenter","Game/Config/Settings"],function(e,t,n){function r(t,n,r){e.call(this,t,n,r),this.healthBarView=null,this.healthBarViewVisibleTimeout=null,this.healthBarViewVisible=!1,this.initHealthBar()}return r.prototype=Object.create(e.prototype),r.prototype.setStats=function(e){var t=this.stats.health;this.stats=e,t!=this.stats.health&&this.onHealthChange()},r.prototype.initHealthBar=function(){var e=this;this.healthBarViewVisible=!1;var n={x:100,y:100,healthFactor:this.stats.health/100,visible:this.healthBarViewVisible},r=function(t){e.healthBarView=t};t.trigger(t.ns.client.view.healthBar.createAndAdd,r,n)},r.prototype.onHealthChange=function(){this.stats.health!=100&&this.setHealthBarVisible(!0)},r.prototype.spawn=function(t,n){e.prototype.spawn.call(this,t,n),this.setHealthBarVisible(!1)},r.prototype.setHealthBarVisible=function(e){var r=this;this.healthBarViewVisible=e,this.healthBarViewVisibleTimeout&&clearTimeout(this.healthBarViewVisibleTimeout);if(e){var i=this.getPosition(),s={x:i.x*n.RATIO,y:i.y*n.RATIO,healthFactor:this.stats.health/100,visible:this.healthBarViewVisible};t.trigger(t.ns.client.view.healthBar.update,this.healthBarView,s),this.healthBarViewVisibleTimeout=setTimeout(function(){r.healthBarViewVisible=!1,t.trigger(t.ns.client.view.healthBar.update,r.healthBarView,{visible:r.healthBarViewVisible})},n.HEALTH_DISPLAY_TIME*1e3)}else t.trigger(t.ns.client.view.healthBar.update,this.healthBarView,{visible:this.healthBarViewVisible})},r.prototype.getNickname=function(){return this.user.options.nickname},r.prototype.render=function(){this.doll&&this.doll.render();if(this.healthBarViewVisible){var e=this.getPosition(),r={healthFactor:this.stats.health/100,x:e.x*n.RATIO,y:e.y*n.RATIO};t.trigger(t.ns.client.view.healthBar.update,this.healthBarView,r)}},r.prototype.isHoldingSomething=function(){return!!this.holdingItem},r.prototype.destroy=function(){clearTimeout(this.healthBarViewVisibleTimeout),t.trigger(t.ns.client.view.healthBar.remove,this.healthBarView),e.prototype.destroy.call(this)},r}),define("Game/Core/GameController",["Game/Client/Physics/Engine","Game/Client/Loader/TiledLevel","Game/Client/Player","Lib/Utilities/NotificationCenter","Game/Client/GameObjects/Doll"],function(e,t,n,r,i){function s(t){this.options=t,this.players={},this.level=null,this.gameObjects=null,this.resetGameObjects(),this.physicsEngine=new e,this.physicsEngine.setCollisionDetector(),this.ncTokens=[r.on(r.ns.core.game.gameObject.add,this.onGameObjectAdd,this),r.on(r.ns.core.game.gameObject.remove,this.onGameObjectRemove,this)],this.loadLevel(t.levelUid),this.update()}return s.prototype.update=function(){},s.prototype.resetGameObjects=function(){this.gameObjects={fixed:[],animated:[]}},s.prototype.onGameObjectAdd=function(e,t){this.gameObjects[e].push(t)},s.prototype.onGameObjectRemove=function(e,t){var n=this.gameObjects[e].indexOf(t);n>=0&&this.gameObjects[e].splice(n,1)},s.prototype.getPhysicsEngine=function(){return this.physicsEngine},s.prototype.loadLevel=function(e){this.level&&(this.level.destroy(),this.resetGameObjects()),this.level=new t(e,this.physicsEngine,this.gameObjects)},s.prototype.onResetLevel=function(){this.loadLevel(this.level.uid)},s.prototype.onUserLeft=function(e){var t=this.players[e];if(!t){console.warn("User (",e,") left who has not joined");return}t.destroy(),delete this.players[e]},s.prototype.createPlayer=function(e){var t=new n(e.id,this.physicsEngine,e);return this.players[e.id]=t,t},s.prototype.destroy=function(){for(var e in this.players);for(var t=0;t<this.ncTokens.length;t++)r.off(this.ncTokens[t]);for(var n in this.gameObjects)for(var t=0;t<this.gameObjects[n].length;t++){var i=this.gameObjects[n][t];i.destroy()}this.gameObjects={fixed:[],animated:[]},this.physicsEngine.destroy()},s}),define("Game/Client/View/Abstract/View",["Lib/Utilities/Abstract","Game/Client/View/DomController","Game/Config/Settings","Lib/Utilities/Exception","Lib/Utilities/NotificationCenter"],function(e,t,n,r,i){function s(){this.me=null,this.canvas=null,this.debugMode=!1,this.ncTokens=[i.on(i.ns.client.view.fullscreen.change,this.onFullscreenChange,this),i.on(i.ns.client.view.debugMode.toggle,this.onToggleDebugMode,this),i.on(i.ns.client.game.zoomIn,this.onZoomIn,this),i.on(i.ns.client.game.zoomOut,this.onZoomOut,this),i.on(i.ns.client.game.zoomReset,this.onZoomReset,this),i.on(i.ns.client.view.preloadBar.update,this.onUpdateLoader,this)]}return e.prototype.addMethod.call(s,"render"),e.prototype.addMethod.call(s,"addFilter",["mesh","options"]),e.prototype.addMethod.call(s,"removeFilter",["mesh","options"]),e.prototype.addMethod.call(s,"setCameraPosition",["x","y"]),e.prototype.addMethod.call(s,"onZoomIn"),e.prototype.addMethod.call(s,"onZoomOut"),e.prototype.addMethod.call(s,"onZoomReset"),e.prototype.addMethod.call(s,"toggleInfo",["show","string"]),e.prototype.addMethod.call(s,"onUpdateLoader",["progress"]),s.prototype.isWebGlEnabled=function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(e){return!1}},s.prototype.initCanvas=function(e){this.canvas=e,t.initCanvas(e)},s.prototype.setMe=function(e){this.me=e},s.prototype.onFullscreenChange=function(e){e?(n.STAGE_WIDTH=window.innerWidth,n.STAGE_HEIGHT=window.innerHeight):(n.STAGE_WIDTH=600,n.STAGE_HEIGHT=400)},s.prototype.onToggleDebugMode=function(e){e&&this.setCameraPosition(-n.STAGE_WIDTH/2,-n.STAGE_HEIGHT/2),this.debugMode=e},s.prototype.destroy=function(){for(var e=0;e<this.ncTokens.length;e++)i.off(this.ncTokens[e])},s}),define("Game/Client/View/Pixi/GameStats",["Lib/Vendor/Pixi","Lib/Utilities/NotificationCenter","Game/Config/Settings","Lib/Utilities/ColorConverter"],function(e,t,n,r){function i(n){this.style={borderWidth:3,padding:20,colors:{background:0,text:"red",border:11141120}},this.container=n,this.infoContainer=new e.DisplayObjectContainer;var r=new e.BlurFilter;r.blurX=12,r.blurY=12;var i=new e.GrayFilter;i.gray=.85,this.infoFilters=[r,i],this.infoText=new e.Text("",{font:"normal 20px monospace",fill:this.style.colors.text,align:"center"}),this.infoBox=new e.Graphics,this.infoBox.alpha=.7,this.infoContainer.addChild(this.infoBox),this.infoContainer.addChild(this.infoText),this.infoContainer.visible=!1,t.on(t.ns.client.view.gameStats.toggle,this.toggle,this)}return i.prototype.getInfoContainer=function(){return this.infoContainer},i.prototype.toggle=function(t,r){function i(e,t,n){e=e.substring(0,t-1);var r=(new Array(t-e.length+1)).join(" ");return n?e+r:r+e}var s=""+i("#",2,!1)+" "+i("Name",12,!0)+i("Score",6,!1)+i("Deaths",7,!1)+i("Health",7,!1)+"\n-----------------------------------\n",o=[];r.forEach(function(e,t){var n=e.getNickname();o.push(i(""+(t+1)+".",2,!1)+" "+i(n,12,!0)+i(""+e.stats.score,6,!1)+i(""+e.stats.deaths,7,!1)+i(""+parseInt(e.stats.health,10),7,!1))},this),s+=o.join("\n");if(t){this.infoText.setText(s),this.infoText.updateText(),this.infoText.dirty=!1;var u=n.STAGE_WIDTH/2-this.infoText.width/2,a=n.STAGE_HEIGHT/2-this.infoText.height/2;this.infoText.position=new e.Point(u,a),this.infoBox.clear(),this.infoBox.beginFill(this.style.colors.background),this.infoBox.lineStyle(this.style.borderWidth,this.style.colors.border),this.infoBox.drawRect(0,0,this.infoText.width-this.style.borderWidth+2*this.style.padding*2,this.infoText.height-this.style.borderWidth+2*this.style.padding),this.infoBox.endFill(),this.infoBox.position.x=this.infoText.position.x+this.style.borderWidth/2-this.style.padding*2,this.infoBox.position.y=this.infoText.position.y+this.style.borderWidth/2-this.style.padding,this.infoContainer.visible=!0,this.container.filters=this.infoFilters,this.infoFilters.forEach(function(e){e.dirty=!0}),this.drawPlayerColors(r)}else this.infoText.setText("..."),this.infoContainer.visible=!1,this.container.filters=null},i.prototype.drawPlayerColors=function(e){var t=new r;e.forEach(function(e,n){this.infoBox.beginFill(t.getColorByName(e.getNickname())),this.infoBox.lineStyle(),this.infoBox.drawRect(this.style.padding,n*21+this.style.padding+42,16,16),this.infoBox.endFill()},this)},i}),define("Game/Client/View/Pixi/ColorRangeReplaceFilter",["Lib/Vendor/Pixi"],function(e){function n(){t.call(this),this.passes=[this],this.uniforms={minColor:{type:"3fv",value:[0,0,0]},maxColor:{type:"3fv",value:[0,0,0]},newColor:{type:"3fv",value:[0,0,0]},brightnessOffset:{type:"1f",value:0}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform vec3 minColor;","uniform vec3 maxColor;","uniform vec3 newColor;","uniform float brightnessOffset;","void main(void) {"," vec4 pixel = texture2D(uSampler, vTextureCoord);"," if(pixel.x >= minColor.x && pixel.y >= minColor.y && pixel.z >= minColor.z"," && pixel.w == 1.0"," && pixel.x <= maxColor.x && pixel.y <= maxColor.y && pixel.z <= maxColor.z) {"," pixel.rgb = mix(pixel.rgb, vec3(0.2126*pixel.r + 0.7152*pixel.g + 0.0722*pixel.b), 1.0);"," pixel.rgb += brightnessOffset;"," pixel.rgb *= newColor;"," }"," gl_FragColor = pixel;","}"]}var t=e.AbstractFilter;return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.defineProperty(n.prototype,"minColor",{get:function(){return e.rgb2hex(this.uniforms.minColor.value)},set:function(t){this.uniforms.minColor.value=e.hex2rgb(t)}}),Object.defineProperty(n.prototype,"maxColor",{get:function(){return e.rgb2hex(this.uniforms.maxColor.value)},set:function(t){this.uniforms.maxColor.value=e.hex2rgb(t)}}),Object.defineProperty(n.prototype,"newColor",{get:function(){return e.rgb2hex(this.uniforms.newColor.value)},set:function(t){this.uniforms.newColor.value=e.hex2rgb(t)}}),Object.defineProperty(n.prototype,"brightnessOffset",{get:function(){return this.uniforms.brightnessOffset.value},set:function(e){this.uniforms.brightnessOffset.value=e}}),n}),define("Game/Client/View/Pixi/Layer",["Game/Client/View/Abstract/Layer","Lib/Vendor/Pixi","Game/Client/View/Pixi/ColorRangeReplaceFilter","Game/Config/Settings"],function(e,t,n,r){function s(n,r){e.call(this,n,r),this.container=new t.DisplayObjectContainer,this.container.x=0,this.container.y=0}var i={blur:t.BlurFilter,desaturate:t.GrayFilter,pixelate:t.PixelateFilter,colorRangeReplace:n};return s.prototype=Object.create(e.prototype),s.prototype.getContainer=function(){return this.container},s.prototype.show=function(){this.container.visible=!0},s.prototype.hide=function(){this.container.visible=!1},s.prototype.addMesh=function(e){this.container.addChild(e)},s.prototype.removeMesh=function(e){this.container.removeChild(e)},s.prototype.createMesh=function(e,n,r){var i=t.Texture.fromImage(e),s=new t.Sprite(i);r&&this.updateMesh(s,r),n(s)},s.prototype.createAnimatedMesh=function(e,n,r){var i=[];for(var s=0;s<e.length;s++){var o=t.Texture.fromImage(e[s]);o.width=r.width,o.height=r.height,t.texturesToUpdate.push(o),i.push(o)}var u=new t.MovieClip(i);r&&this.updateMesh(u,r),u.animationSpeed=.5,u.play(),n(u)},s.prototype.updateMesh=function(e,n){n.x&&(e.position.x=n.x),n.y&&(e.position.y=n.y),n.rotation&&(e.rotation=n.rotation),n.alpha&&(e.alpha=n.alpha),n.width&&(e.width=n.width),n.height&&(e.height=n.height),n.xScale&&(e.width=Math.abs(e.width)*n.xScale),n.yScale&&(e.scale.y=n.yScale);if(n.visible===!0||n.visible===!1)e.visible=n.visible;n.pivot&&(e.pivot=new t.Point(n.pivot.x,n.pivot.y))},s.prototype.addFilter=function(e,t,n){if(!i.hasOwnProperty(t))throw new Exception("Filter "+t+" is not available");var r=i[t],s=new r;switch(t){case"desaturate":n.amount&&(s.gray=n.amount);break;case"blur":n.blurX&&(s.blurX=n.blurX),n.blurY&&(s.blurY=n.blurY);break;case"colorRangeReplace":n.minColor&&(s.minColor=n.minColor),n.maxColor&&(s.maxColor=n.maxColor),n.newColor&&(s.newColor=n.newColor),n.brightnessOffset&&(s.brightnessOffset=n.brightnessOffset);break;case"pixelate":n.sizeX&&(s.size.x=n.sizeX),n.sizeY&&(s.size.y=n.sizeY);break;default:}var o=e.filters;o?this.removeFilter(e,t):o=[],o.push(s),e.filters=o},s.prototype.removeFilter=function(e,t){var n=e.filters;if(!n)return;var r=i[options.filter];n=n.filter(function(e){return!e instanceof r}),e.filters=filter},s.prototype.render=function(e,t){this.setPosition(e),this.setZoom(t);var n=(this.zoom.target-this.zoom.current)*r.CAMERA_GLIDE/100;this.zoom.current+=n,this.container.scale.x=this.zoom.current,this.container.scale.y=this.container.scale.x;var i=(this.position.target.x-this.position.current.x)*r.CAMERA_GLIDE/100;this.position.current.x+=i,this.container.x=this.position.current.x+this.position.current.x*this.parallaxSpeed;var s=(this.position.target.y-this.position.current.y)*r.CAMERA_GLIDE/100;this.position.current.y+=s,this.container.y=this.position.current.y+this.position.current.y*this.parallaxSpeed},s}),define("Game/Client/View/LayerManager",["Lib/Utilities/NotificationCenter","Lib/Utilities/Exception","Game/Client/View/Pixi/Layer"],function(e,t,n){function r(t,n){this.layers=[],this.container=t,this.ncTokens=[e.on(e.ns.client.view.layer.createAndInsert,this.createAndInsert,this),e.on(e.ns.client.view.mesh.create,this.createMesh,this),e.on(e.ns.client.view.animatedMesh.create,this.createAnimatedMesh,this),e.on(e.ns.client.view.mesh.add,this.addMesh,this),e.on(e.ns.client.view.mesh.remove,this.removeMesh,this),e.on(e.ns.client.view.mesh.update,this.updateMesh,this),e.on(e.ns.client.view.mesh.addFilter,this.addFilter,this),e.on(e.ns.client.view.mesh.removeFilter,this.removeFilter,this)]}return r.prototype.render=function(e,t){for(var n=0;n<this.layers.length;n++){var r=this.layers[n];r.render(e,t)}},r.prototype.createAndInsert=function(e,t,r,i){var s=new n(e,t);this.insert(s,r,i)},r.prototype.insert=function(e,n,r){var i=-1;n=!!n;if(r){for(var s=0;s<this.layers.length;s++){var o=this.layers[s];if(o.getName()===r){i=s;break}}if(i===-1)throw new t("Reference Layer ("+r+") could not be found")}else i=n?0:this.container.children.length;var u=n?i:i+1;this.layers.splice(u,0,e),this.rearrangeLayers()},r.prototype.rearrangeLayers=function(){var e;for(var t=this.layers.length-1;t>=0;t--)e=this.layers[t],this.container.children.indexOf(e.getContainer())!==-1&&this.container.removeChild(e.getContainer());this.container.children.length!==0&&console.warn("Unmanaged stuff in container... ",this.container.children);for(var t=0;t<this.layers.length;t++)e=this.layers[t],this.container.addChildAt(e.getContainer(),t)},r.prototype.getLayerById=function(e){for(var t=0;t<this.layers.length;t++){var n=this.layers[t];if(n.getName()===e)return n}return null},r.prototype.delegate=function(){var e=arguments[0],n=arguments[1],r=this.getLayerById(n);if(!r)throw new t("Layer ("+n+") does not exist.");var i=arguments;Array.prototype.splice.call(i,0,2),r[e].apply(r,i)},r.prototype.createMesh=function(){var e=arguments;Array.prototype.splice.call(e,0,0,"createMesh"),this.delegate.apply(this,e)},r.prototype.createAnimatedMesh=function(){Array.prototype.splice.call(arguments,0,0,"createAnimatedMesh"),this.delegate.apply(this,arguments)},r.prototype.addMesh=function(){Array.prototype.splice.call(arguments,0,0,"addMesh"),this.delegate.apply(this,arguments)},r.prototype.removeMesh=function(){Array.prototype.splice.call(arguments,0,0,"removeMesh"),this.delegate.apply(this,arguments)},r.prototype.updateMesh=function(){Array.prototype.splice.call(arguments,0,0,"updateMesh"),this.delegate.apply(this,arguments)},r.prototype.addFilter=function(){Array.prototype.splice.call(arguments,0,0,"addFilter"),this.delegate.apply(this,arguments)},r.prototype.removeFilter=function(){Array.prototype.splice.call(arguments,0,0,"removeFilter"),this.delegate.apply(this,arguments)},r.prototype.destroy=function(){for(var t=0;t<this.ncTokens.length;t++)e.off(this.ncTokens[t])},r}),define("Game/Client/View/Pixi/Layers/Ghost",["Game/Client/View/Pixi/Layer","Lib/Vendor/Pixi","Lib/Utilities/NotificationCenter","Game/Config/Settings"],function(e,t,n,r){function i(){e.call(this,"ghost",0),this.ncTokens=[n.on(n.ns.client.view.playerArrow.createAndAdd,this.onCreateAndAddPlayerArrow,this),n.on(n.ns.client.view.playerArrow.update,this.onUpdatePlayerArrow,this),n.on(n.ns.client.view.healthBar.createAndAdd,this.onCreateAndAddHealthBar,this),n.on(n.ns.client.view.healthBar.update,this.onUpdateHealthBar,this),n.on(n.ns.client.view.healthBar.remove,this.onRemoveHealthBar,this)]}return i.prototype=Object.create(e.prototype),i.prototype.onCreateAndAddPlayerArrow=function(e,n){var r=new t.Graphics;r.visible=!1,this.container.addChild(r);var i=12,s=12;r.beginFill(16777215,.1),r.lineStyle(0,0),r.moveTo(0,0),r.lineTo(i,0),r.lineTo(i/2,s),r.endFill(),r.pivot=new t.Point(i/2,s/2),r.visible=!0,this.onUpdatePlayerArrow(r,n),e(r)},i.prototype.onUpdatePlayerArrow=function(e,n){var i=0,s=-60,o=i+n.x,u=s+n.y,a=new t.Point(o,u);e.position.x+=(a.x-e.position.x)*r.ARROW_GLIDE/1.5/100,e.position.y+=(a.y-e.position.y)*r.ARROW_GLIDE/100;var f=-Math.atan2(e.position.x-o,e.position.y-n.y);f+=3.141592652,e.rotation=f},i.prototype.onCreateAndAddHealthBar=function(e,n){var r=new t.Graphics;this.container.addChild(r),this.onUpdateHealthBar(r,n),e(r)},i.prototype.onUpdateHealthBar=function(e,n){var r=14,i=2,s=1,o=-8,u=-52;if(typeof n.healthFactor!="undefined"){e.clear(),e.beginFill(0),e.lineStyle(s,0),e.drawRect(0,0,r,i),e.endFill();if(n.healthFactor>0){var a=65280;n.healthFactor<.3&&(a=16711680),e.beginFill(a),e.lineStyle(0,0),e.drawRect(s,s,r*n.healthFactor,i),e.endFill()}}n.x&&n.y&&(e.position=new t.Point(o+n.x,u+n.y));if(n.visible===!0||n.visible===!1)e.visible=n.visible},i.prototype.onRemoveHealthBar=function(e){this.container.removeChild(e)},i.prototype.destroy=function(){for(var e=0;e<this.ncTokens.length;e++)n.off(this.ncTokens[e])},i}),define("Game/Client/View/Pixi/Layers/Swiper",["Game/Client/View/Pixi/Layer","Lib/Vendor/Pixi","Lib/Utilities/NotificationCenter","Game/Config/Settings"],function(e,t,n,r){function i(){e.call(this,"ghost",0),this.ncTokens=[n.on(n.ns.client.view.swiper.swipe,this.swipe,this),n.on(n.ns.client.view.swiper.end,this.end,this)],this.offset={x:r.STAGE_WIDTH/2,y:r.STAGE_HEIGHT/2},this.sprite=new t.Graphics,this.container.addChild(this.sprite),this.end()}return i.prototype=Object.create(e.prototype),i.prototype.swipe=function(e,t){this.sprite.moveTo(this.offset.x+this.last.x,this.offset.y+this.last.y),this.last.x+=e,this.last.y-=t,this.sprite.lineTo(this.offset.x+this.last.x,this.offset.y+this.last.y)},i.prototype.end=function(e,t){this.sprite.clear(),this.sprite.lineStyle(2,16777215),this.sprite.alpha=.5,this.last={x:0,y:0}},i}),define("Game/Client/View/Pixi/View",["Game/Client/View/Abstract/View","Game/Client/View/DomController","Lib/Vendor/Pixi","Game/Config/Settings","Lib/Utilities/NotificationCenter","Lib/Utilities/Exception","Game/Client/View/Pixi/GameStats","Game/Client/View/LayerManager","Game/Client/View/Pixi/Layers/Ghost","Game/Client/View/Pixi/Layers/Swiper"],function(e,t,n,r,i,s,o,u,a,f){function l(){e.call(this),this.layerManager=null,this.stage=null,this.container=null,this.infoContainer=null,this.infoFilters=[],this.loader=null,this.currentZoom=r.ZOOM_DEFAULT,this.init(),n.scaleModes.DEFAULT=n.scaleModes.NEAREST}return l.prototype=Object.create(e.prototype),l.prototype.init=function(){var e=!1,i=!0,s=t.getCanvas();r.USE_WEBGL?(this.renderer=new n.WebGLRenderer(r.STAGE_WIDTH,r.STAGE_HEIGHT,s,e,i),console.log("WebGLRenderer")):(this.renderer=new n.CanvasRenderer(r.STAGE_WIDTH,r.STAGE_HEIGHT,s,e,i),console.log("CanvasRenderer - not using WebGL!")),this.stage=new n.Stage(3355443),this.container=new n.DisplayObjectContainer,this.stage.addChild(this.container),this.layerManager=new u(this.container,this.me),this.initLoader(),this.initCanvas(this.renderer.view),this.gameStats=new o(this.container),this.stage.addChild(this.gameStats.getInfoContainer()),this.ghostLayer=new a,this.layerManager.insert(this.ghostLayer,!1),this.swiperLayer=new f,this.stage.addChild(this.swiperLayer.getContainer())},l.prototype.render=function(){this.me&&this.layerManager.render(this.calculateCenterPosition(),this.currentZoom),this.renderer.render(this.stage)},l.prototype.calculateCenterPosition=function(){var e=this.me.getHeadPosition(),t={x:e.x,y:e.y};t.x*=-r.RATIO*this.currentZoom,t.y*=-r.RATIO*this.currentZoom,t.x+=r.STAGE_WIDTH/2,t.y+=r.STAGE_HEIGHT/2;var n=this.me.getLookAt();return t.x-=n.x*r.STAGE_WIDTH/4,t.y+=n.y*r.STAGE_HEIGHT/4,t},l.prototype.onFullscreenChange=function(t){e.prototype.onFullscreenChange.call(this,t),t?(this.renderer.resize(window.innerWidth,window.innerHeight),this.currentZoom=window.innerWidth/600):(this.renderer.resize(600,400),this.currentZoom=1)},l.prototype.initLoader=function(){this.loader=new n.Graphics,this.stage.addChild(this.loader),this.onUpdateLoader(0)},l.prototype.onUpdateLoader=function(e){var t=200,i=5,s=1;if(e<100){this.loader.clear(),this.loader.beginFill(0),this.loader.lineStyle(s,0),this.loader.drawRect(0,0,t,i),this.loader.endFill();if(e>0){var o=16715683;this.loader.beginFill(o),this.loader.lineStyle(0,0),this.loader.drawRect(s,s,t*e/100,i),this.loader.endFill()}this.loader.position=new n.Point(r.STAGE_WIDTH/2-t/2-s,r.STAGE_HEIGHT/2-i/2-s)}this.loader.visible=e<100},l.prototype.onZoomIn=function(){console.log("onZoomIn"),this.currentZoom+r.ZOOM_FACTOR<=r.ZOOM_MAX&&(this.currentZoom+=r.ZOOM_FACTOR)},l.prototype.onZoomOut=function(){this.currentZoom-r.ZOOM_FACTOR>0&&(this.currentZoom-=r.ZOOM_FACTOR)},l.prototype.onZoomReset=function(){this.currentZoom=r.ZOOM_DEFAULT},l.prototype.destroy=function(){this.layerManager.destroy(),this.ghostLayer.destroy(),this.swiperLayer.destroy();for(var t=0;t<this.stage.children.length;t++)this.stage.removeChild(this.stage.children[t]);this.renderer.render(this.stage),e.prototype.destroy.call(this)},l}),define("Game/Client/View/ViewManager",["Game/Config/Settings","Lib/Utilities/Exception","Game/Client/View/Abstract/View","Game/Client/View/Pixi/View","Lib/Utilities/NotificationCenter"],function(e,t,n,r,i){var s={};return s.createView=function(){var s=null;switch(e.VIEW_CONTROLLER){case"Pixi":s=new r;break;default:throw new t("A view called",e.VIEW_CONTROLLER,"has not been (fully) implemented.")}if(s instanceof n){if(!s.canvas)throw new t("In the view",e.VIEW_CONTROLLER+"View","the method 'this.setCanvas(canvas)' has not been called");if(s.canvas instanceof HTMLCanvasElement)return i.trigger(i.ns.client.view.events.ready,s),s;throw new t("In the view",e.VIEW_CONTROLLER+"View","this.setCanvas(canvas) has not been called with a valid HTMLCanvasElement!")}throw new t("The view",e.VIEW_CONTROLLER+"View","must extend AbstractView!")},s}),define("Game/Core/Control/PlayerController",[],function(){function e(e){this.player=e,this._shift,this._isJumping,this._walkingDirectionStatus=0}return e.prototype.moveLeft=function(){this.player.move(-1),this._walkingDirectionStatus=-1},e.prototype.moveRight=function(){this.player.move(1),this._walkingDirectionStatus=1},e.prototype.stop=function(){this.player.stop(),this._walkingDirectionStatus=0},e.prototype.jump=function(){this._isJumping=!0,this.player.jump()},e.prototype.jumpStop=function(){this.player.jumpStop()},e.prototype.lookAt=function(e){e&&this.player.lookAt(e.x,e.y)},e.prototype.update=function(){this._walkingDirectionStatus!=0&&this.player.move(this._walkingDirectionStatus)},e.prototype.destroy=function(){},e}),define("Game/Client/Control/Input",["Lib/Utilities/NotificationCenter"],function(e){function t(e){this.playerController=e,this.x=null,this.y=null}return t.prototype.onXyChange=function(e,t){this.x=e,this.y=t,this.playerController.setXY(this.x,this.y)},t}),define("Game/Client/Control/Key",[],function(){function e(){this._active=!1,this._activityUpdateStatus=!1,this._activityUpdateNeeded=!1,this._keyDownFunction=null,this._keyUpFunction=null}return e.prototype.setActivityUpdateStatus=function(e){this._activityUpdateStatus=e},e.prototype.getActivityUpdateStatus=function(){return this._activityUpdateStatus},e.prototype.setActivityUpdateNeeded=function(e){this._activityUpdateNeeded=e},e.prototype.getActivityUpdateNeeded=function(){return this._activityUpdateNeeded},e.prototype.setActive=function(e){this._active=e},e.prototype.getActive=function(){return this._active},e.prototype.setKeyDownFunction=function(e){this._keyDownFunction=e},e.prototype.getKeyDownFunction=function(){return this._keyDownFunction},e.prototype.setKeyUpFunction=function(e){this._keyUpFunction=e},e.prototype.getKeyUpFunction=function(){return this._keyUpFunction},e}),define("Game/Client/Control/KeyboardInput",["Game/Client/Control/Key"],function(e){function t(){this._registry={},this.init()}return t.prototype.init=function(){window.onkeydown=this._onKeyDown.bind(this),window.onkeyup=this._onKeyUp.bind(this)},t.prototype.registerKey=function(t,n,r){var i=new e;n&&i.setKeyDownFunction(n),r&&i.setKeyUpFunction(r),this._registry[t]=i},t.prototype._getKeyByKeyCode=function(e){return this._registry[e]},t.prototype._onKeyDown=function(e){var t=this._getKeyByKeyCode(e.keyCode);if(t&&!t.getActive()){var n=t.getKeyDownFunction();n&&n(),t.setActive(!0)}if(e.keyCode==9)return!1},t.prototype._onKeyUp=function(e){var t=this._getKeyByKeyCode(e.keyCode);if(t&&t.getActive()){var n=t.getKeyUpFunction();n&&n(),t.setActive(!1)}if(e.keyCode==9)return!1},t}),define("Game/Client/Control/Swiper",["Lib/Utilities/NotificationCenter"],function(e){function n(){this.points=[],this.angleSum=0,this.lengthSum=0}var t=150;return n.prototype.swipe=function(n,r){if(this.lengthSum>t)return;this.points.push({x:n,y:r}),e.trigger(e.ns.client.view.swiper.swipe,n,r);var i=this.points;if(i.length>=3){var s=i.length-1,o=[{x:i[s].x-i[s-1].x,y:i[s].y-i[s-1].y},{x:i[s-2].x-i[s-1].x,y:i[s-2].y-i[s-1].y}],u=o[0].y*o[1].x,a=o[0].x*o[1].y,f=0;u>a?f=-1:u<a&&(f=1);var l=o[0].x*o[1].x+o[0].y*o[1].y,c=Math.sqrt(Math.pow(o[0].x,2)+Math.pow(o[0].y,2)),h=Math.sqrt(Math.pow(o[1].x,2)+Math.pow(o[1].y,2)),p=180-Math.acos(l/(c*h)%1)*180/Math.PI;p*=f,!isNaN(parseFloat(p))&&f!=0&&(this.angleSum+=p),isNaN(parseFloat(c))||(this.lengthSum+=Math.abs(c))}},n.prototype.swipeEnd=function(t,n){var r=this.angleSum,i=this.lengthSum,s=this.points[0].x,o=this.points[0].y,u=0,a=0;e.trigger(e.ns.client.view.swiper.end);for(var f=0,l=this.points.length;f<l;f++){var c=this.points[f];u+=c.x-s,a+=c.y-o}var h={x:u/l,y:a/l},p=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y;return h.x/=Math.abs(p),h.y/=Math.abs(p),this.angleSum=0,this.lengthSum=0,this.points=[],{x:h.x*i/100,y:h.y*i/100,spin:r}},n.prototype.destroy=function(){for(var t=0;t<this.ncTokens.length;t++)e.off(this.ncTokens[t])},n}),define("Game/Client/Control/Inputs/KeyboardAndMouse",["Game/Client/Control/Input","Game/Client/Control/KeyboardInput","Game/Client/View/DomController","Game/Config/Settings","Game/Client/Control/Swiper"],function(e,t,n,r,i){function s(t){e.call(this),this.x=0,this.y=0,this.modifier=!1,this.swiper=null,this.lastLookDirection=1,this.playerController=t,this.keyboardInit(),this.mouseInit()}return s.prototype=Object.create(e.prototype),s.prototype.keyboardInit=function(){function r(t){return e.playerController[t].bind(e.playerController)}this.keyboardInput=new t;var e=this,n={w:87,a:65,s:83,d:68,f:70,g:71,k:75,up:38,left:37,down:40,right:39,space:32,tab:9,shift:16,plus:187,plusfx:171,minus:189,minusfx:173,zero:48};this.keyboardInput.registerKey(n.a,this.moveLeft.bind(this),r("stop")),this.keyboardInput.registerKey(n.left,this.moveLeft.bind(this),r("stop")),this.keyboardInput.registerKey(n.d,this.moveRight.bind(this),r("stop")),this.keyboardInput.registerKey(n.right,this.moveRight.bind(this),r("stop")),this.keyboardInput.registerKey(n.w,r("jump"),r("jumpStop")),this.keyboardInput.registerKey(n.up,r("jump"),r("jumpStop")),this.keyboardInput.registerKey(n.space,r("jump"),r("jumpStop")),this.keyboardInput.registerKey(n.plus,r("zoomIn")),this.keyboardInput.registerKey(n.plusfx,r("zoomIn")),this.keyboardInput.registerKey(n.minus,r("zoomOut")),this.keyboardInput.registerKey(n.minusfx,r("zoomOut")),this.keyboardInput.registerKey(n.zero,r("zoomReset")),this.keyboardInput.registerKey(n.tab,r("showInfo"),r("hideInfo")),this.keyboardInput.registerKey(n.f,r("handActionLeft")),this.keyboardInput.registerKey(n.g,r("handActionRight")),this.keyboardInput.registerKey(n.k,r("suicide")),this.keyboardInput.registerKey(n.shift,this.activateModifier.bind(this),this.deactivateModifier.bind(this))},s.prototype.moveLeft=function(){this.modifier||(this.lastLookDirection=-1,this.onXyChange(this.lastLookDirection*r.VIEWPORT_LOOK_AHEAD,0)),this.playerController.moveLeft()},s.prototype.moveRight=function(){this.modifier||(this.lastLookDirection=1,this.onXyChange(this.lastLookDirection*r.VIEWPORT_LOOK_AHEAD,0)),this.playerController.moveRight()},s.prototype.mouseInit=function(){var e=n.getCanvas(),t=this;e.onmousedown=function(e){t.playerController.player.isHoldingSomething()?t.swiper=new i:t.playerController.handActionRequest(t.x,t.y)},e.onmousemove=function(e){t.swiper?t.draw(e):t.modifier&&t.updateViewport(e)},e.onmouseup=function(e){if(t.swiper){var n=t.swiper.swipeEnd(e.x,e.y);t.playerController.handActionRequest(n.x,n.y),t.swiper=null}}},s.prototype.updateViewport=function(e){var t=e.movementX||e.mozMovementX||e.webkitMovementX||0,n=e.movementY||e.mozMovementY||e.webkitMovementY||0;this.x+=t/r.VIEWPORT_SPEED_FACTOR,this.x>1&&(this.x=1),this.x<-1&&(this.x=-1),this.y-=n/r.VIEWPORT_SPEED_FACTOR,this.y>1&&(this.y=1),this.y<-1&&(this.y=-1),this.lastLookDirection=this.x>=0?1:-1,this.onXyChange(this.x,this.y)},s.prototype.draw=function(e){var t=e.movementX||e.mozMovementX||e.webkitMovementX||0,n=e.movementY||e.mozMovementY||e.webkitMovementY||0;this.swiper.swipe(t,-n)},s.prototype.activateModifier=function(){this.modifier=!0},s.prototype.deactivateModifier=function(){this.modifier=!1,this.x=this.lastLookDirection*r.VIEWPORT_LOOK_AHEAD,this.y=0,this.onXyChange(this.x,this.y)},s}),define("Game/Client/Control/Inputs/Gamepad",["Game/Client/Control/Input","Game/Config/Settings"],function(e,t){function n(t){this.playerController=t,e.call(this),this.gamepad=null,this.oldHoldingPressure=0,this.keyChanged={w:!1,a:!1,d:!1};var n=this;window.addEventListener("gamepadconnected",function(e){n.gamepad=e.gamepad}),window.addEventListener("gamepaddisconnected",function(e){n.gamepad=null})}return n.prototype=Object.create(e.prototype),n.prototype.update=function(){if(this.gamepad){var e=this.gamepad.axes[2],t=-this.gamepad.axes[3];this.onXyChange(e,t);var n=this.gamepad.axes[5];(n>0&&this.oldHoldingPressure<=0||n<=0&&this.oldHoldingPressure>0)&&this.playerController.handActionRequest(e,t),this.oldHoldingPressure=n,this.simulateKeyboard()}},n.prototype.simulateKeyboard=function(){this.key(11,87),this.key(13,65),this.key(14,68)},n.prototype.key=function(e,t){if(this.keyChanged[t]!=this.gamepad.buttons[e].pressed){var n={keyCode:t};this.gamepad.buttons[e].pressed?window.onkeydown(n):window.onkeyup(n),this.keyChanged[t]=this.gamepad.buttons[e].pressed}},n}),define("Game/Client/Control/PlayerController",["Game/Core/Control/PlayerController","Lib/Utilities/NotificationCenter","Game/Client/Control/Inputs/KeyboardAndMouse","Game/Client/Control/Inputs/Gamepad"],function(e,t,n,r){function i(t){e.call(this,t),this.keyboardAndMouse=new n(this),this.gamepad=new r(this)}return i.prototype=Object.create(e.prototype),i.prototype.update=function(){e.prototype.update.call(this),this.gamepad.update()},i.prototype.moveLeft=function(){e.prototype.moveLeft.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"moveLeft")},i.prototype.moveRight=function(){e.prototype.moveRight.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"moveRight")},i.prototype.stop=function(){e.prototype.stop.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"stop")},i.prototype.jump=function(){e.prototype.jump.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"jump")},i.prototype.jumpStop=function(){e.prototype.jumpStop.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"jumpStop")},i.prototype.setXY=function(n,r){var i={x:n,y:r};e.prototype.lookAt.call(this,i),t.trigger(t.ns.client.to.server.gameCommand.send,"lookAt",i)},i.prototype.handActionLeft=function(){this.handActionRequest(-0.5,.5)},i.prototype.handActionRight=function(){this.handActionRequest(.5,.5)},i.prototype.suicide=function(){t.trigger(t.ns.client.to.server.gameCommand.send,"suicide")},i.prototype.handActionRequest=function(e,n){var r={x:e,y:n};t.trigger(t.ns.client.to.server.gameCommand.send,"handActionRequest",r)},i.prototype.showInfo=function(){t.trigger(t.ns.client.game.gameStats.toggle,!0)},i.prototype.hideInfo=function(){t.trigger(t.ns.client.game.gameStats.toggle,!1)},i.prototype.zoomIn=function(){t.trigger(t.ns.client.game.zoomIn,!0)},i.prototype.zoomOut=function(){t.trigger(t.ns.client.game.zoomOut,!1)},i.prototype.zoomReset=function(){t.trigger(t.ns.client.game.zoomReset,!1)},i}),define("Lib/Utilities/RequestAnimFrame",["Game/Config/Settings"],function(e){var t=function(){var t=function(t){return setTimeout(t,e.BOX2D_TIME_STEP*1e3)};return typeof window!="undefined"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||t:t}();return t}),define("Game/Client/Me",["Game/Client/Player","Game/Config/Settings","Lib/Utilities/NotificationCenter"],function(e,t,n){function r(n,r,i){e.call(this,n,r,i),this.lookAtXY={x:t.VIEWPORT_LOOK_AHEAD,y:0},this.lastServerPositionState={p:{x:0,y:0}},this.arrowMesh=null,this.createAndAddArrow()}return r.prototype=Object.create(e.prototype),r.prototype.lookAt=function(t,n){this.lookAtXY={x:t,y:n},e.prototype.lookAt.call(this,t,n)},r.prototype.getLookAt=function(){return{x:this.lookAtXY.x,y:this.lookAtXY.y}},r.prototype.setLastServerPositionState=function(e){this.lastServerPositionState=e},r.prototype.isPositionStateUpdateNeeded=function(){if(!this.doll)return!1;if(this.doll.isAnotherPlayerNearby())return!1;var e={x:Math.abs(this.lastServerPositionState.p.x-this.doll.body.GetPosition().x),y:Math.abs(this.lastServerPositionState.p.y-this.doll.body.GetPosition().y)};return e.x>t.ME_STATE_MAX_DIFFERENCE_METERS||e.y>t.ME_STATE_MAX_DIFFERENCE_METERS?!0:!1},r.prototype.getPositionStateUpdate=function(){return{p:this.doll.body.GetPosition().Copy(),lv:this.doll.body.GetLinearVelocity().Copy()}},r.prototype.acceptPositionStateUpdateFromServer=function(){return this.doll.isAnotherPlayerNearby()},r.prototype.resetPositionState=function(e){this.doll.body.SetPosition(e.p),this.doll.body.SetLinearVelocity(e.lv)},r.prototype.createAndAddArrow=function(e){var r=this,i=this.getPosition(),s={x:i.x*t.RATIO,y:i.y*t.RATIO},o=function(e){r.arrowMesh=e};n.trigger(n.ns.client.view.playerArrow.createAndAdd,o,s)},r.prototype.render=function(){e.prototype.render.call(this);var r=this.getPosition(),i={x:r.x*t.RATIO,y:r.y*t.RATIO};n.trigger(n.ns.client.view.playerArrow.update,this.arrowMesh,i)},r}),define("Game/Client/AudioPlayer",[],function(){function e(e){this.audio=new Audio(e),this.audio.loop=!0,this.audio.volume=.1,this.audio.addEventListener("timeupdate",function(){var e=1;this.currentTime>this.duration-e&&(this.currentTime=1,this.play())},!1)}return e.prototype.play=function(){},e.prototype.stop=function(){this.audio.stop(),this.doPlay=!1},e.prototype.destroy=function(){this.stop()},e}),define("Game/Client/GameController",["Game/Core/GameController","Lib/Vendor/Box2D","Game/Client/Physics/Engine","Game/Client/View/ViewManager","Game/Client/Control/PlayerController","Lib/Utilities/NotificationCenter","Lib/Utilities/RequestAnimFrame","Game/Config/Settings","Game/Client/GameObjects/GameObject","Game/Client/GameObjects/Doll","Game/Client/View/DomController","Lib/Utilities/Protocol/Helper","Game/Client/Me","Game/Client/AudioPlayer"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p){function d(t){this.clientIsReady=!1,this.view=r.createView(),this.me=null,this.animationRequestId=null,this.audioPlayer=null,e.call(this,t),this.ncTokens=this.ncTokens.concat([s.on(s.ns.client.game.gameStats.toggle,this.toggleGameStats,this)])}return window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)}),d.prototype=Object.create(e.prototype),d.prototype.getMe=function(){return this.me},d.prototype.update=function(){e.prototype.update.call(this),l.statsBegin(),this.animationRequestId=o(this.update.bind(this)),this.physicsEngine.update(),this.me&&(this.me.update(),this.mePositionStateUpdate());for(var t=0;t<this.gameObjects.animated.length;t++)this.gameObjects.animated[t].render();this.view.render(),l.statsEnd()},d.prototype.mePositionStateUpdate=function(){this.me.isPositionStateUpdateNeeded()&&s.trigger(s.ns.client.to.server.gameCommand.send,"mePositionStateUpdate",this.me.getPositionStateUpdate())},d.prototype.onClientReadyResponse=function(e){e.worldUpdate&&this.onWorldUpdate(e.worldUpdate);if(e.runtimeItems)for(var t=0;t<e.runtimeItems.length;t++){var n=e.runtimeItems[t],r=!1;for(var t=0;t<this.gameObjects.animated.length;t++)if(this.gameObjects.animated[t].uid==n.uid){r=!0;break}if(!r)var i=this.level.createItem(n.uid,n.options)}this.setMe(),this.clientIsReady=!0;if(e.spawnedPlayers)for(var t=0;t<e.spawnedPlayers.length;t++)this.onSpawnPlayer(e.spawnedPlayers[t]);this.audioPlayer=new p(u.AUDIO_PATH+"city.mp3"),this.audioPlayer.play()},d.prototype.onWorldUpdate=function(e){var t=this.physicsEngine.world.GetBodyList();do{var n=t.GetUserData();if(n instanceof a){var r=n;if(e[r.uid]){var i=e[r.uid];if(r instanceof f){if(r===this.me.doll){this.me.setLastServerPositionState(i);if(!this.me.acceptPositionStateUpdateFromServer())continue}r.setActionState(i.as),r.lookAt(i.laxy.x,i.laxy.y)}t.SetAwake(!0),t.SetPosition(i.p),t.SetAngle(i.a),t.SetLinearVelocity(i.lv),t.SetAngularVelocity(i.av)}}}while(t=t.GetNext())},d.prototype.createMe=function(e){this.me=new h(e.id,this.physicsEngine,e),this.players[e.id]=this.me},d.prototype.setMe=function(){this.me.setPlayerController(new i(this.me)),this.view.setMe(this.me)},d.prototype.onGameCommand=function(e){c.applyCommand(e,this)},d.prototype.onSpawnPlayer=function(e){if(!this.clientIsReady)return;var t=e.id,n=e.x,r=e.y,i=this.players[t];i.spawn(n,r),e.holdingItemUid&&this.onHandActionResponse({itemUid:e.holdingItemUid,action:"grab",playerId:t})},d.prototype.onHandActionResponse=function(e){var t=this.players[e.playerId],n=null;for(var r=0;r<this.gameObjects.animated.length;r++){var i=this.gameObjects.animated[r];if(i.uid==e.itemUid){n=i;break}}n?e.action=="throw"?t.throw(e.x,e.y,n):e.action=="grab"&&t.grab(n):console.warn("Item for joint can not be found locally. "+e.itemUid)},d.prototype.onUpdateStats=function(e){var t=this.players[e.playerId];t.setStats(e.stats),t==this.me&&l.setHealth(t.stats.health)},d.prototype.onPlayerKill=function(e){var t=this.players[e.playerId],n=this.players[e.killedByPlayerId];t.kill(n,e.ragDollId)},d.prototype.onPositionStateReset=function(e){this.me.resetPositionState(e)},d.prototype.onRemoveGameObject=function(e){var t=null;for(var n=0;n<this.gameObjects[e.type].length;n++)if(this.gameObjects[e.type][n].uid==e.uid){t=this.gameObjects[e.type][n];break}t?t.destroy():console.warn("GameObject for removal can not be found locally. "+e.uid)},d.prototype.loadLevel=function(t){e.prototype.loadLevel.call(this,t)},d.prototype.toggleGameStats=function(e){var t=[];for(var n in this.players)t.push(this.players[n]);var r=t.sort(function(e,t){return e.stats.score>t.stats.score?-1:e.stats.score<t.stats.score?1:e.stats.deaths<t.stats.deaths?-1:e.stats.deaths>t.stats.deaths?1:e.stats.health>t.stats.health?-1:e.stats.health<t.stats.health?1:0});s.trigger(s.ns.client.view.gameStats.toggle,e,r)},d.prototype.destroy=function(){cancelAnimationFrame(this.animationRequestId),e.prototype.destroy.call(this),this.audioPlayer.destroy(),this.view.destroy()},d}),define("Game/Core/User",[],function(){function e(e,t){this.id=e,this.options=t,this.options.id=this.id,this.options.nickname||(this.options.nickname=this.id)}return e}),define("Game/Client/User",["Game/Core/User"],function(e){return e}),define("Game/Client/Networker",["Lib/Utilities/Protocol/Helper","Game/Client/GameController","Game/Client/User","Lib/Utilities/NotificationCenter","Game/Config/Settings","Game/Client/View/DomController"],function(e,t,n,r,i,s){function o(t,n,s){this.channelName=n,this.nickname=s,this.socketLink=t,this.gameController=null,this.users={},this.socketLink.on("connect",this.onConnect.bind(this)),this.socketLink.on("disconnect",this.onDisconnect.bind(this));var o=this;this.socketLink.on("message",function(t){var n=JSON.parse(t);i.NETWORK_LOG_INCOMING&&t.indexOf("worldUpdate")==-1&&t.indexOf("pong")==-1&&console.log("INCOMING",t),e.applyCommand(t,o)}),r.on(r.ns.client.to.server.gameCommand.send,this.sendGameCommand,this),r.on(r.ns.core.game.events.level.loaded,this.onLevelLoaded,this)}return o.prototype.onConnect=function(){console.log("connected.");if(this.channelName){var e={channelName:this.channelName,nickname:this.nickname};this.sendCommand("join",e),s.setConnected(!0)}else window.location.href="/"},o.prototype.onDisconnect=function(){console.log("disconnected. game destroyed. no auto-reconnect"),s.setConnected(!1)},o.prototype.onJoinSuccess=function(e){console.log("join success"),this.onUserJoined(e.user,!0),this.meUserId=e.user.id;if(e.joinedUsers)for(var t=0;t<e.joinedUsers.length;t++)this.onUserJoined(e.joinedUsers[t]);this.initPing()},o.prototype.onJoinError=function(e){window.location.href="/"},o.prototype.onLevelLoaded=function(){this.gameController.createMe(this.users[this.meUserId]);for(var e in this.users)this.meUserId!=e&&this.gameController.createPlayer(this.users[e]);this.sendGameCommand("clientReady")},o.prototype.initPing=function(){this.ping()},o.prototype.ping=function(){this.sendCommand("ping",Date.now())},o.prototype.sendCommand=function(t,n){var r=e.encodeCommand(t,n);this.socketLink.send(r);if(i.NETWORK_LOG_OUTGOING)if(i.NETWORK_LOG_FILTER.length>0){var s=!1,o;for(var u=0;u<i.NETWORK_LOG_FILTER.length;u++){o=i.NETWORK_LOG_FILTER[u];if(r.search(o)!=-1){s=!0;break}}s||console.log("OUTGOING",r)}else console.log("OUTGOING",r)},o.prototype.sendGameCommand=function(t,n){var r=e.encodeCommand(t,n);this.sendCommand("gameCommand",r)},o.prototype.onUserJoined=function(e,t){var r=new n(e.id,e);console.log(e.nickname),this.users[r.id]=r,!t&&this.gameController&&this.gameController.level&&this.gameController.level.isLoaded&&this.gameController.createPlayer(r)},o.prototype.onUserLeft=function(e){this.gameController.onUserLeft(e),delete this.users[e]},o.prototype.onGameCommand=function(e){this.gameController.onGameCommand(e)},o.prototype.onPong=function(e){var t=Date.now()-parseInt(e,10);s.setPing(t),setTimeout(this.ping.bind(this),1e3)},o.prototype.onBeginRound=function(e){this.gameController&&(this.gameController.destroy(),delete this.gameController),this.gameController=new t(e)},o.prototype.onEndRound=function(){this.gameController.toggleInfo(!0)},o}),function(e,t){var n=e;n.version="0.9.6",n.protocol=1,n.transports=[],n.j=[],n.sockets={},n.connect=function(e,r){var i=n.util.parseUri(e),s,o;t&&t.location&&(i.protocol=i.protocol||t.location.protocol.slice(0,-1),i.host=i.host||(t.document?t.document.domain:t.location.hostname),i.port=i.port||t.location.port),s=n.util.uniqueUri(i);var u={host:i.host,secure:"https"==i.protocol,port:i.port||("https"==i.protocol?443:80),query:i.query||""};n.util.merge(u,r);if(u["force new connection"]||!n.sockets[s])o=new n.Socket(u);return!u["force new connection"]&&o&&(n.sockets[s]=o),o=o||n.sockets[s],o.of(i.path.length>1?i.path:"")}}("object"==typeof module?module.exports:this.io={},this),function(e,t){var n=e.util={},r=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];n.parseUri=function(e){var t=r.exec(e||""),n={},s=14;while(s--)n[i[s]]=t[s]||"";return n},n.uniqueUri=function(e){var n=e.protocol,r=e.host,i=e.port;return"document"in t?(r=r||document.domain,i=i||(n=="https"&&document.location.protocol!=="https:"?443:document.location.port)):(r=r||"localhost",!i&&n=="https"&&(i=443)),(n||"http")+"://"+r+":"+(i||80)},n.query=function(e,t){var r=n.chunkQuery(e||""),i=[];n.merge(r,n.chunkQuery(t||""));for(var s in r)r.hasOwnProperty(s)&&i.push(s+"="+r[s]);return i.length?"?"+i.join("&"):""},n.chunkQuery=function(e){var t={},n=e.split("&"),r=0,i=n.length,s;for(;r<i;++r)s=n[r].split("="),s[0]&&(t[s[0]]=s[1]);return t};var s=!1;n.load=function(e){if("document"in t&&document.readyState==="complete"||s)return e();n.on(t,"load",e,!1)},n.on=function(e,t,n,r){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener&&e.addEventListener(t,n,r)},n.request=function(e){if(e&&"undefined"!=typeof XDomainRequest)return new XDomainRequest;if("undefined"!=typeof XMLHttpRequest&&(!e||n.ua.hasCORS))return new XMLHttpRequest;if(!e)try{return new(window[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}return null},"undefined"!=typeof window&&n.load(function(){s=!0}),n.defer=function(e){if(!n.ua.webkit||"undefined"!=typeof importScripts)return e();n.load(function(){setTimeout(e,100)})},n.merge=function(t,r,i,s){var o=s||[],u=typeof i=="undefined"?2:i,a;for(a in r)r.hasOwnProperty(a)&&n.indexOf(o,a)<0&&(typeof t[a]!="object"||!u?(t[a]=r[a],o.push(r[a])):n.merge(t[a],r[a],u-1,o));return t},n.mixin=function(e,t){n.merge(e.prototype,t.prototype)},n.inherit=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},n.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},n.intersect=function(e,t){var r=[],i=e.length>t.length?e:t,s=e.length>t.length?t:e;for(var o=0,u=s.length;o<u;o++)~n.indexOf(i,s[o])&&r.push(s[o]);return r},n.indexOf=function(e,t,n){for(var r=e.length,n=n<0?n+r<0?0:n+r:n||0;n<r&&e[n]!==t;n++);return r<=n?-1:n},n.toArray=function(e){var t=[];for(var n=0,r=e.length;n<r;n++)t.push(e[n]);return t},n.ua={},n.ua.hasCORS="undefined"!=typeof XMLHttpRequest&&function(){try{var e=new XMLHttpRequest}catch(t){return!1}return e.withCredentials!=undefined}(),n.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent)}("undefined"!=typeof io?io:module.exports,this),function(e,t){function n(){}e.EventEmitter=n,n.prototype.on=function(e,n){return this.$events||(this.$events={}),this.$events[e]?t.util.isArray(this.$events[e])?this.$events[e].push(n):this.$events[e]=[this.$events[e],n]:this.$events[e]=n,this},n.prototype.addListener=n.prototype.on,n.prototype.once=function(e,t){function r(){n.removeListener(e,r),t.apply(this,arguments)}var n=this;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,n){if(this.$events&&this.$events[e]){var r=this.$events[e];if(t.util.isArray(r)){var i=-1;for(var s=0,o=r.length;s<o;s++)if(r[s]===n||r[s].listener&&r[s].listener===n){i=s;break}if(i<0)return this;r.splice(i,1),r.length||delete this.$events[e]}else(r===n||r.listener&&r.listener===n)&&delete this.$events[e]}return this},n.prototype.removeAllListeners=function(e){return this.$events&&this.$events[e]&&(this.$events[e]=null),this},n.prototype.listeners=function(e){return this.$events||(this.$events={}),this.$events[e]||(this.$events[e]=[]),t.util.isArray(this.$events[e])||(this.$events[e]=[this.$events[e]]),this.$events[e]},n.prototype.emit=function(e){if(!this.$events)return!1;var n=this.$events[e];if(!n)return!1;var r=Array.prototype.slice.call(arguments,1);if("function"==typeof n)n.apply(this,r);else{if(!t.util.isArray(n))return!1;var i=n.slice();for(var s=0,o=i.length;s<o;s++)i[s].apply(this,r)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(exports,nativeJSON){function f(e){return e<10?"0"+e:e}function date(e,t){return isFinite(e.valueOf())?e.getUTCFullYear()+"-"+f(e.getUTCMonth()+1)+"-"+f(e.getUTCDate())+"T"+f(e.getUTCHours())+":"+f(e.getUTCMinutes())+":"+f(e.getUTCSeconds())+"Z":null}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a instanceof Date&&(a=date(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||"null";return i=u.length===0?"[]":gap?"[\n"+gap+u.join(",\n"+gap)+"\n"+o+"]":"["+u.join(",")+"]",gap=o,i}if(rep&&typeof rep=="object"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]=="string"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i));return i=u.length===0?"{}":gap?"{\n"+gap+u.join(",\n"+gap)+"\n"+o+"}":"{"+u.join(",")+"}",gap=o,i}}if(nativeJSON&&nativeJSON.parse)return exports.JSON={parse:nativeJSON.parse,stringify:nativeJSON.stringify};var JSON=exports.JSON={},cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;JSON.stringify=function(e,t,n){var r;gap="",indent="";if(typeof n=="number")for(r=0;r<n;r+=1)indent+=" ";else typeof n=="string"&&(indent=n);rep=t;if(!t||typeof t=="function"||typeof t=="object"&&typeof t.length=="number")return str("",{"":e});throw new Error("JSON.stringify")},JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i=="object")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")}}("undefined"!=typeof io?io:module.exports,typeof JSON!="undefined"?JSON:undefined),function(e,t){var n=e.parser={},r=n.packets=["disconnect","connect","heartbeat","message","json","event","ack","error","noop"],i=n.reasons=["transport not supported","client not handshaken","unauthorized"],s=n.advice=["reconnect"],o=t.JSON,u=t.util.indexOf;n.encodePacket=function(e){var t=u(r,e.type),n=e.id||"",a=e.endpoint||"",f=e.ack,l=null;switch(e.type){case"error":var c=e.reason?u(i,e.reason):"",h=e.advice?u(s,e.advice):"";if(c!==""||h!=="")l=c+(h!==""?"+"+h:"");break;case"message":e.data!==""&&(l=e.data);break;case"event":var p={name:e.name};e.args&&e.args.length&&(p.args=e.args),l=o.stringify(p);break;case"json":l=o.stringify(e.data);break;case"connect":e.qs&&(l=e.qs);break;case"ack":l=e.ackId+(e.args&&e.args.length?"+"+o.stringify(e.args):"")}var d=[t,n+(f=="data"?"+":""),a];return l!==null&&l!==undefined&&d.push(l),d.join(":")},n.encodePayload=function(e){var t="";if(e.length==1)return e[0];for(var n=0,r=e.length;n<r;n++){var i=e[n];t+="<22>"+i.length+"<22>"+e[n]}return t};var a=/([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]*)?/;n.decodePacket=function(e){var t=e.match(a);if(!t)return{};var n=t[2]||"",e=t[5]||"",u={type:r[t[1]],endpoint:t[4]||""};n&&(u.id=n,t[3]?u.ack="data":u.ack=!0);switch(u.type){case"error":var t=e.split("+");u.reason=i[t[0]]||"",u.advice=s[t[1]]||"";break;case"message":u.data=e||"";break;case"event":try{var f=o.parse(e);u.name=f.name,u.args=f.args}catch(l){}u.args=u.args||[];break;case"json":try{u.data=o.parse(e)}catch(l){}break;case"connect":u.qs=e||"";break;case"ack":var t=e.match(/^([0-9]+)(\+)?(.*)/);if(t){u.ackId=t[1],u.args=[];if(t[3])try{u.args=t[3]?o.parse(t[3]):[]}catch(l){}}break;case"disconnect":case"heartbeat":}return u},n.decodePayload=function(e){if(e.charAt(0)=="<22>"){var t=[];for(var r=1,i="";r<e.length;r++)e.charAt(r)=="<22>"?(t.push(n.decodePacket(e.substr(r+1).substr(0,i))),r+=Number(i)+1,i=""):i+=e.charAt(r);return t}return[n.decodePacket(e)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t){function n(e,t){this.socket=e,this.sessid=t}e.Transport=n,t.util.mixin(n,t.EventEmitter),n.prototype.onData=function(e){this.clearCloseTimeout(),(this.socket.connected||this.socket.connecting||this.socket.reconnecting)&&this.setCloseTimeout();if(e!==""){var n=t.parser.decodePayload(e);if(n&&n.length)for(var r=0,i=n.length;r<i;r++)this.onPacket(n[r])}return this},n.prototype.onPacket=function(e){return this.socket.setHeartbeatTimeout(),e.type=="heartbeat"?this.onHeartbeat():(e.type=="connect"&&e.endpoint==""&&this.onConnect(),e.type=="error"&&e.advice=="reconnect"&&(this.open=!1),this.socket.onPacket(e),this)},n.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var e=this;this.closeTimeout=setTimeout(function(){e.onDisconnect()},this.socket.closeTimeout)}},n.prototype.onDisconnect=function(){return this.close&&this.open&&this.close(),this.clearTimeouts(),this.socket.onDisconnect(),this},n.prototype.onConnect=function(){return this.socket.onConnect(),this},n.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)},n.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&&clearTimeout(this.reopenTimeout)},n.prototype.packet=function(e){this.send(t.parser.encodePacket(e))},n.prototype.onHeartbeat=function(e){this.packet({type:"heartbeat"})},n.prototype.onOpen=function(){this.open=!0,this.clearCloseTimeout(),this.socket.onOpen()},n.prototype.onClose=function(){var e=this;this.open=!1,this.socket.onClose(),this.onDisconnect()},n.prototype.prepareUrl=function(){var e=this.socket.options;return this.scheme()+"://"+e.host+":"+e.port+"/"+e.resource+"/"+t.protocol+"/"+this.name+"/"+this.sessid},n.prototype.ready=function(e,t){t.call(this)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function r(e){this.options={port:80,secure:!1,document:"document"in n?document:!1,resource:"socket.io",transports:t.transports,"connect timeout":1e4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reconnection limit":Infinity,"reopen delay":3e3,"max reconnection attempts":10,"sync disconnect on unload":!0,"auto connect":!0,"flash policy port":10843},t.util.merge(this.options,e),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1,this.namespaces={},this.buffer=[],this.doBuffer=!1;if(this.options["sync disconnect on unload"]&&(!this.isXDomain()||t.util.ua.hasCORS)){var r=this;t.util.on(n,"unload",function(){r.disconnectSync()},!1)}this.options["auto connect"]&&this.connect()}function i(){}e.Socket=r,t.util.mixin(r,t.EventEmitter),r.prototype.of=function(e){return this.namespaces[e]||(this.namespaces[e]=new t.SocketNamespace(this,e),e!==""&&this.namespaces[e].packet({type:"connect"})),this.namespaces[e]},r.prototype.publish=function(){this.emit.apply(this,arguments);var e;for(var t in this.namespaces)this.namespaces.hasOwnProperty(t)&&(e=this.of(t),e.$emit.apply(e,arguments))},r.prototype.handshake=function(e){function s(t){t instanceof Error?n.onError(t.message):e.apply(null,t.split(":"))}var n=this,r=this.options,o=["http"+(r.secure?"s":"")+":/",r.host+":"+r.port,r.resource,t.protocol,t.util.query(this.options.query,"t="+ +(new Date))].join("/");if(this.isXDomain()&&!t.util.ua.hasCORS){var u=document.getElementsByTagName("script")[0],a=document.createElement("script");a.src=o+"&jsonp="+t.j.length,u.parentNode.insertBefore(a,u),t.j.push(function(e){s(e),a.parentNode.removeChild(a)})}else{var f=t.util.request();f.open("GET",o,!0),f.withCredentials=!0,f.onreadystatechange=function(){f.readyState==4&&(f.onreadystatechange=i,f.status==200?s(f.responseText):!n.reconnecting&&n.onError(f.responseText))},f.send(null)}},r.prototype.getTransport=function(e){var n=e||this.transports,r;for(var i=0,s;s=n[i];i++)if(t.Transport[s]&&t.Transport[s].check(this)&&(!this.isXDomain()||t.Transport[s].xdomainCheck()))return new t.Transport[s](this,this.sessionid);return null},r.prototype.connect=function(e){if(this.connecting)return this;var n=this;return this.handshake(function(r,i,s,o){function u(e){n.transport&&n.transport.clearTimeouts(),n.transport=n.getTransport(e);if(!n.transport)return n.publish("connect_failed");n.transport.ready(n,function(){n.connecting=!0,n.publish("connecting",n.transport.name),n.transport.open(),n.options["connect timeout"]&&(n.connectTimeoutTimer=setTimeout(function(){if(!n.connected){n.connecting=!1;if(n.options["try multiple transports"]){n.remainingTransports||(n.remainingTransports=n.transports.slice(0));var e=n.remainingTransports;while(e.length>0&&e.splice(0,1)[0]!=n.transport.name);e.length?u(e):n.publish("connect_failed")}}},n.options["connect timeout"]))})}n.sessionid=r,n.closeTimeout=s*1e3,n.heartbeatTimeout=i*1e3,n.transports=o?t.util.intersect(o.split(","),n.options.transports):n.options.transports,n.setHeartbeatTimeout(),u(n.transports),n.once("connect",function(){clearTimeout(n.connectTimeoutTimer),e&&typeof e=="function"&&e()})}),this},r.prototype.setHeartbeatTimeout=function(){clearTimeout(this.heartbeatTimeoutTimer);var e=this;this.heartbeatTimeoutTimer=setTimeout(function(){e.transport.onClose()},this.heartbeatTimeout)},r.prototype.packet=function(e){return this.connected&&!this.doBuffer?this.transport.packet(e):this.buffer.push(e),this},r.prototype.setBuffer=function(e){this.doBuffer=e,!e&&this.connected&&this.buffer.length&&(this.transport.payload(this.buffer),this.buffer=[])},r.prototype.disconnect=function(){if(this.connected||this.connecting)this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted");return this},r.prototype.disconnectSync=function(){var e=t.util.request(),n=this.resource+"/"+t.protocol+"/"+this.sessionid;e.open("GET",n,!0),this.onDisconnect("booted")},r.prototype.isXDomain=function(){var e=n.location.port||("https:"==n.location.protocol?443:80);return this.options.host!==n.location.hostname||this.options.port!=e},r.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))},r.prototype.onOpen=function(){this.open=!0},r.prototype.onClose=function(){this.open=!1,clearTimeout(this.heartbeatTimeoutTimer)},r.prototype.onPacket=function(e){this.of(e.endpoint).onPacket(e)},r.prototype.onError=function(e){e&&e.advice&&e.advice==="reconnect"&&(this.connected||this.connecting)&&(this.disconnect(),this.options.reconnect&&this.reconnect()),this.publish("error",e&&e.reason?e.reason:e)},r.prototype.onDisconnect=function(e){var t=this.connected,n=this.connecting;this.connected=!1,this.connecting=!1,this.open=!1;if(t||n)this.transport.close(),this.transport.clearTimeouts(),t&&(this.publish("disconnect",e),"booted"!=e&&this.options.reconnect&&!this.reconnecting&&this.reconnect())},r.prototype.reconnect=function(){function i(){if(e.connected){for(var t in e.namespaces)e.namespaces.hasOwnProperty(t)&&""!==t&&e.namespaces[t].packet({type:"connect"});e.publish("reconnect",e.transport.name,e.reconnectionAttempts)}clearTimeout(e.reconnectionTimer),e.removeListener("connect_failed",s),e.removeListener("connect",s),e.reconnecting=!1,delete e.reconnectionAttempts,delete e.reconnectionDelay,delete e.reconnectionTimer,delete e.redoTransports,e.options["try multiple transports"]=n}function s(){if(!e.reconnecting)return;if(e.connected)return i();if(e.connecting&&e.reconnecting)return e.reconnectionTimer=setTimeout(s,1e3);e.reconnectionAttempts++>=t?e.redoTransports?(e.publish("reconnect_failed"),i()):(e.on("connect_failed",s),e.options["try multiple transports"]=!0,e.transport=e.getTransport(),e.redoTransports=!0,e.connect()):(e.reconnectionDelay<r&&(e.reconnectionDelay*=2),e.connect(),e.publish("reconnecting",e.reconnectionDelay,e.reconnectionAttempts),e.reconnectionTimer=setTimeout(s,e.reconnectionDelay))}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var e=this,t=this.options["max reconnection attempts"],n=this.options["try multiple transports"],r=this.options["reconnection limit"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(s,this.reconnectionDelay),this.on("connect",s)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t){function n(e,t){this.socket=e,this.name=t||"",this.flags={},this.json=new r(this,"json"),this.ackPackets=0,this.acks={}}function r(e,t){this.namespace=e,this.name=t}e.SocketNamespace=n,t.util.mixin(n,t.EventEmitter),n.prototype.$emit=t.EventEmitter.prototype.emit,n.prototype.of=function(){return this.socket.of.apply(this.socket,arguments)},n.prototype.packet=function(e){return e.endpoint=this.name,this.socket.packet(e),this.flags={},this},n.prototype.send=function(e,t){var n={type:this.flags.json?"json":"message",data:e};return"function"==typeof t&&(n.id=++this.ackPackets,n.ack=!0,this.acks[n.id]=t),this.packet(n)},n.prototype.emit=function(e){var t=Array.prototype.slice.call(arguments,1),n=t[t.length-1],r={type:"event",name:e};return"function"==typeof n&&(r.id=++this.ackPackets,r.ack="data",this.acks[r.id]=n,t=t.slice(0,t.length-1)),r.args=t,this.packet(r)},n.prototype.disconnect=function(){return this.name===""?this.socket.disconnect():(this.packet({type:"disconnect"}),this.$emit("disconnect")),this},n.prototype.onPacket=function(e){function r(){n.packet({type:"ack",args:t.util.toArray(arguments),ackId:e.id})}var n=this;switch(e.type){case"connect":this.$emit("connect");break;case"disconnect":this.name===""?this.socket.onDisconnect(e.reason||"booted"):this.$emit("disconnect",e.reason);break;case"message":case"json":var i=["message",e.data];e.ack=="data"?i.push(r):e.ack&&this.packet({type:"ack",ackId:e.id}),this.$emit.apply(this,i);break;case"event":var i=[e.name].concat(e.args);e.ack=="data"&&i.push(r),this.$emit.apply(this,i);break;case"ack":this.acks[e.ackId]&&(this.acks[e.ackId].apply(this,e.args),delete this.acks[e.ackId]);break;case"error":e.advice?this.socket.onError(e):e.reason=="unauthorized"?this.$emit("connect_failed",e.reason):this.$emit("error",e.reason)}},r.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this.namespace,arguments)},r.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this.namespace,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function r(e){t.Transport.apply(this,arguments)}e.websocket=r,t.util.inherit(r,t.Transport),r.prototype.name="websocket",r.prototype.open=function(){var e=t.util.query(this.socket.options.query),r=this,i;return i||(i=n.MozWebSocket||n.WebSocket),this.websocket=new i(this.prepareUrl()+e),this.websocket.onopen=function(){r.onOpen(),r.socket.setBuffer(!1)},this.websocket.onmessage=function(e){r.onData(e.data)},this.websocket.onclose=function(){r.onClose(),r.socket.setBuffer(!0)},this.websocket.onerror=function(e){r.onError(e)},this},r.prototype.send=function(e){return this.websocket.send(e),this},r.prototype.payload=function(e){for(var t=0,n=e.length;t<n;t++)this.packet(e[t]);return this},r.prototype.close=function(){return this.websocket.close(),this},r.prototype.onError=function(e){this.socket.onError(e)},r.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},r.check=function(){return"WebSocket"in n&&!("__addTask"in WebSocket)||"MozWebSocket"in n},r.xdomainCheck=function(){return!0},t.transports.push("websocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t){function n(){t.Transport.websocket.apply(this,arguments)}e.flashsocket=n,t.util.inherit(n,t.Transport.websocket),n.prototype.name="flashsocket",n.prototype.open=function(){var e=this,n=arguments;return WebSocket.__addTask(function(){t.Transport.websocket.prototype.open.apply(e,n)}),this},n.prototype.send=function(){var e=this,n=arguments;return WebSocket.__addTask(function(){t.Transport.websocket.prototype.send.apply(e,n)}),this},n.prototype.close=function(){return WebSocket.__tasks.length=0,t.Transport.websocket.prototype.close.call(this),this},n.prototype.ready=function(e,r){function i(){var t=e.options,i=t["flash policy port"],o=["http"+(t.secure?"s":"")+":/",t.host+":"+t.port,t.resource,"static/flashsocket","WebSocketMain"+(e.isXDomain()?"Insecure":"")+".swf"];n.loaded||(typeof WEB_SOCKET_SWF_LOCATION=="undefined"&&(WEB_SOCKET_SWF_LOCATION=o.join("/")),i!==843&&WebSocket.loadFlashPolicyFile("xmlsocket://"+t.host+":"+i),WebSocket.__initialize(),n.loaded=!0),r.call(s)}var s=this;if(document.body)return i();t.util.load(i)},n.check=function(){return typeof WebSocket!="undefined"&&"__initialize"in WebSocket&&!!swfobject?swfobject.getFlashPlayerVersion().major>=10:!1},n.xdomainCheck=function(){return!0},typeof window!="undefined"&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),t.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);if("undefined"!=typeof window)var swfobject=function(){function C(){if(b)return;try{var e=a.getElementsByTagName("body")[0].appendChild(U("span"));e.parentNode.removeChild(e)}catch(t){return}b=!0;var n=c.length;for(var r=0;r<n;r++)c[r]()}function k(e){b?e():c[c.length]=e}function L(t){if(typeof u.addEventListener!=e)u.addEventListener("load",t,!1);else if(typeof a.addEventListener!=e)a.addEventListener("load",t,!1);else if(typeof u.attachEvent!=e)z(u,"onload",t);else if(typeof u.onload=="function"){var n=u.onload;u.onload=function(){n(),t()}}else u.onload=t}function A(){l?O():M()}function O(){var n=a.getElementsByTagName("body")[0],r=U(t);r.setAttribute("type",i);var s=n.appendChild(r);if(s){var o=0;(function(){if(typeof s.GetVariable!=e){var t=s.GetVariable("$version");t&&(t=t.split(" ")[1].split(","),T.pv=[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10)])}else if(o<10){o++,setTimeout(arguments.callee,10);return}n.removeChild(r),s=null,M()})()}else M()}function M(){var t=h.length;if(t>0)for(var n=0;n<t;n++){var r=h[n].id,i=h[n].callbackFn,s={success:!1,id:r};if(T.pv[0]>0){var o=R(r);if(o)if(W(h[n].swfVersion)&&!(T.wk&&T.wk<312))V(r,!0),i&&(s.success=!0,s.ref=_(r),i(s));else if(h[n].expressInstall&&D()){var u={};u.data=h[n].expressInstall,u.width=o.getAttribute("width")||"0",u.height=o.getAttribute("height")||"0",o.getAttribute("class")&&(u.styleclass=o.getAttribute("class")),o.getAttribute("align")&&(u.align=o.getAttribute("align"));var a={},f=o.getElementsByTagName("param"),l=f.length;for(var c=0;c<l;c++)f[c].getAttribute("name").toLowerCase()!="movie"&&(a[f[c].getAttribute("name")]=f[c].getAttribute("value"));P(u,a,r,i)}else H(o),i&&i(s)}else{V(r,!0);if(i){var p=_(r);p&&typeof p.SetVariable!=e&&(s.success=!0,s.ref=p),i(s)}}}}function _(n){var r=null,i=R(n);if(i&&i.nodeName=="OBJECT")if(typeof i.SetVariable!=e)r=i;else{var s=i.getElementsByTagName(t)[0];s&&(r=s)}return r}function D(){return!w&&W("6.0.65")&&(T.win||T.mac)&&!(T.wk&&T.wk<312)}function P(t,n,r,i){w=!0,g=i||null,y={success:!1,id:r};var o=R(r);if(o){o.nodeName=="OBJECT"?(v=B(o),m=null):(v=o,m=r),t.id=s;if(typeof t.width==e||!/%$/.test(t.width)&&parseInt(t.width,10)<310)t.width="310";if(typeof t.height==e||!/%$/.test(t.height)&&parseInt(t.height,10)<137)t.height="137";a.title=a.title.slice(0,47)+" - Flash Player Installation";var f=T.ie&&T.win?["Active"].concat("").join("X"):"PlugIn",l="MMredirectURL="+u.location.toString().replace(/&/g,"%26")+"&MMplayerType="+f+"&MMdoctitle="+a.title;typeof n.flashvars!=e?n.flashvars+="&"+l:n.flashvars=l;if(T.ie&&T.win&&o.readyState!=4){var c=U("div");r+="SWFObjectNew",c.setAttribute("id",r),o.parentNode.insertBefore(c,o),o.style.display="none",function(){o.readyState==4?o.parentNode.removeChild(o):setTimeout(arguments.callee,10)}()}j(t,n,r)}}function H(e){if(T.ie&&T.win&&e.readyState!=4){var t=U("div");e.parentNode.insertBefore(t,e),t.parentNode.replaceChild(B(e),t),e.style.display="none",function(){e.readyState==4?e.parentNode.removeChild(e):setTimeout(arguments.callee,10)}()}else e.parentNode.replaceChild(B(e),e)}function B(e){var n=U("div");if(T.win&&T.ie)n.innerHTML=e.innerHTML;else{var r=e.getElementsByTagName(t)[0];if(r){var i=r.childNodes;if(i){var s=i.length;for(var o=0;o<s;o++)(i[o].nodeType!=1||i[o].nodeName!="PARAM")&&i[o].nodeType!=8&&n.appendChild(i[o].cloneNode(!0))}}}return n}function j(n,r,s){var o,u=R(s);if(T.wk&&T.wk<312)return o;if(u){typeof n.id==e&&(n.id=s);if(T.ie&&T.win){var a="";for(var f in n)n[f]!=Object.prototype[f]&&(f.toLowerCase()=="data"?r.movie=n[f]:f.toLowerCase()=="styleclass"?a+=' class="'+n[f]+'"':f.toLowerCase()!="classid"&&(a+=" "+f+'="'+n[f]+'"'));var l="";for(var c in r)r[c]!=Object.prototype[c]&&(l+='<param name="'+c+'" value="'+r[c]+'" />');u.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+a+">"+l+"</object>",p[p.length]=n.id,o=R(n.id)}else{var h=U(t);h.setAttribute("type",i);for(var d in n)n[d]!=Object.prototype[d]&&(d.toLowerCase()=="styleclass"?h.setAttribute("class",n[d]):d.toLowerCase()!="classid"&&h.setAttribute(d,n[d]));for(var v in r)r[v]!=Object.prototype[v]&&v.toLowerCase()!="movie"&&F(h,v,r[v]);u.parentNode.replaceChild(h,u),o=h}}return o}function F(e,t,n){var r=U("param");r.setAttribute("name",t),r.setAttribute("value",n),e.appendChild(r)}function I(e){var t=R(e);t&&t.nodeName=="OBJECT"&&(T.ie&&T.win?(t.style.display="none",function(){t.readyState==4?q(e):setTimeout(arguments.callee,10)}()):t.parentNode.removeChild(t))}function q(e){var t=R(e);if(t){for(var n in t)typeof t[n]=="function"&&(t[n]=null);t.parentNode.removeChild(t)}}function R(e){var t=null;try{t=a.getElementById(e)}catch(n){}return t}function U(e){return a.createElement(e)}function z(e,t,n){e.attachEvent(t,n),d[d.length]=[e,t,n]}function W(e){var t=T.pv,n=e.split(".");return n[0]=parseInt(n[0],10),n[1]=parseInt(n[1],10)||0,n[2]=parseInt(n[2],10)||0,t[0]>n[0]||t[0]==n[0]&&t[1]>n[1]||t[0]==n[0]&&t[1]==n[1]&&t[2]>=n[2]?!0:!1}function X(n,r,i,s){if(T.ie&&T.mac)return;var o=a.getElementsByTagName("head")[0];if(!o)return;var u=i&&typeof i=="string"?i:"screen";s&&(E=null,S=null);if(!E||S!=u){var f=U("style");f.setAttribute("type","text/css"),f.setAttribute("media",u),E=o.appendChild(f),T.ie&&T.win&&typeof a.styleSheets!=e&&a.styleSheets.length>0&&(E=a.styleSheets[a.styleSheets.length-1]),S=u}T.ie&&T.win?E&&typeof E.addRule==t&&E.addRule(n,r):E&&typeof a.createTextNode!=e&&E.appendChild(a.createTextNode(n+" {"+r+"}"))}function V(e,t){if(!x)return;var n=t?"visible":"hidden";b&&R(e)?R(e).style.visibility=n:X("#"+e,"visibility:"+n)}function $(t){var n=/[\\\"<>\.;]/,r=n.exec(t)!=null;return r&&typeof encodeURIComponent!=e?encodeURIComponent(t):t}var e="undefined",t="object",n="Shockwave Flash",r="ShockwaveFlash.ShockwaveFlash",i="application/x-shockwave-flash",s="SWFObjectExprInst",o="onreadystatechange",u=window,a=document,f=navigator,l=!1,c=[A],h=[],p=[],d=[],v,m,g,y,b=!1,w=!1,E,S,x=!0,T=function(){var s=typeof a.getElementById!=e&&typeof a.getElementsByTagName!=e&&typeof a.createElement!=e,o=f.userAgent.toLowerCase(),c=f.platform.toLowerCase(),h=c?/win/.test(c):/win/.test(o),p=c?/mac/.test(c):/mac/.test(o),d=/webkit/.test(o)?parseFloat(o.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,v=!1,m=[0,0,0],g=null;if(typeof f.plugins!=e&&typeof f.plugins[n]==t)g=f.plugins[n].description,g&&(typeof f.mimeTypes==e||!f.mimeTypes[i]||!!f.mimeTypes[i].enabledPlugin)&&(l=!0,v=!1,g=g.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),m[0]=parseInt(g.replace(/^(.*)\..*$/,"$1"),10),m[1]=parseInt(g.replace(/^.*\.(.*)\s.*$/,"$1"),10),m[2]=/[a-zA-Z]/.test(g)?parseInt(g.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof u[["Active"].concat("Object").join("X")]!=e)try{var y=new(window[["Active"].concat("Object").join("X")])(r);y&&(g=y.GetVariable("$version"),g&&(v=!0,g=g.split(" ")[1].split(","),m=[parseInt(g[0],10),parseInt(g[1],10),parseInt(g[2],10)]))}catch(b){}return{w3:s,pv:m,wk:d,ie:v,win:h,mac:p}}(),N=function(){if(!T.w3)return;(typeof a.readyState!=e&&a.readyState=="complete"||typeof a.readyState==e&&(a.getElementsByTagName("body")[0]||a.body))&&C(),b||(typeof a.addEventListener!=e&&a.addEventListener("DOMContentLoaded",C,!1),T.ie&&T.win&&(a.attachEvent(o,function(){a.readyState=="complete"&&(a.detachEvent(o,arguments.callee),C())}),u==top&&function(){if(b)return;try{a.documentElement.doScroll("left")}catch(e){setTimeout(arguments.callee,0);return}C()}()),T.wk&&function(){if(b)return;if(!/loaded|complete/.test(a.readyState)){setTimeout(arguments.callee,0);return}C()}(),L(C))}(),J=function(){T.ie&&T.win&&window.attachEvent("onunload",function(){var e=d.length;for(var t=0;t<e;t++)d[t][0].detachEvent(d[t][1],d[t][2]);var n=p.length;for(var r=0;r<n;r++)I(p[r]);for(var i in T)T[i]=null;T=null;for(var s in swfobject)swfobject[s]=null;swfobject=null})}();return{registerObject:function(e,t,n,r){if(T.w3&&e&&t){var i={};i.id=e,i.swfVersion=t,i.expressInstall=n,i.callbackFn=r,h[h.length]=i,V(e,!1)}else r&&r({success:!1,id:e})},getObjectById:function(e){if(T.w3)return _(e)},embedSWF:function(n,r,i,s,o,u,a,f,l,c){var h={success:!1,id:r};T.w3&&!(T.wk&&T.wk<312)&&n&&r&&i&&s&&o?(V(r,!1),k(function(){i+="",s+="";var p={};if(l&&typeof l===t)for(var d in l)p[d]=l[d];p.data=n,p.width=i,p.height=s;var v={};if(f&&typeof f===t)for(var m in f)v[m]=f[m];if(a&&typeof a===t)for(var g in a)typeof v.flashvars!=e?v.flashvars+="&"+g+"="+a[g]:v.flashvars=g+"="+a[g];if(W(o)){var y=j(p,v,r);p.id==r&&V(r,!0),h.success=!0,h.ref=y}else{if(u&&D()){p.data=u,P(p,v,r,c);return}V(r,!0)}c&&c(h)})):c&&c(h)},switchOffAutoHideShow:function(){x=!1},ua:T,getFlashPlayerVersion:function(){return{major:T.pv[0],minor:T.pv[1],release:T.pv[2]}},hasFlashPlayerVersion:W,createSWF:function(e,t,n){return T.w3?j(e,t,n):undefined},showExpressInstall:function(e,t,n,r){T.w3&&D()&&P(e,t,n,r)},removeSWF:function(e){T.w3&&I(e)},createCSS:function(e,t,n,r){T.w3&&X(e,t,n,r)},addDomLoadEvent:k,addLoadEvent:L,getQueryParamValue:function(e){var t=a.location.search||a.location.hash;if(t){/\?/.test(t)&&(t=t.split("?")[1]);if(e==null)return $(t);var n=t.split("&");for(var r=0;r<n.length;r++)if(n[r].substring(0,n[r].indexOf("="))==e)return $(n[r].substring(n[r].indexOf("=")+1))}return""},expressInstallCallback:function(){if(w){var e=R(s);e&&v&&(e.parentNode.replaceChild(v,e),m&&(V(m,!0),T.ie&&T.win&&(v.style.display="block")),g&&g(y)),w=!1}}}}();(function(){if("undefined"==typeof window||window.WebSocket)return;var e=window.console;if(!e||!e.log||!e.error)e={log:function(){},error:function(){}};if(!swfobject.hasFlashPlayerVersion("10.0.0")){e.error("Flash Player >= 10.0.0 is required.");return}location.protocol=="file:"&&e.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(e,t,n,r,i){var s=this;s.__id=WebSocket.__nextId++,WebSocket.__instances[s.__id]=s,s.readyState=WebSocket.CONNECTING,s.bufferedAmount=0,s.__events={},t?typeof t=="string"&&(t=[t]):t=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(s.__id,e,t,n||null,r||0,i||null)})},0)},WebSocket.prototype.send=function(e){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var t=WebSocket.__flash.send(this.__id,encodeURIComponent(e));return t<0?!0:(this.bufferedAmount+=t,!1)},WebSocket.prototype.close=function(){if(this.readyState==WebSocket.CLOSED||this.readyState==WebSocket.CLOSING)return;this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id)},WebSocket.prototype.addEventListener=function(e,t,n){e in this.__events||(this.__events[e]=[]),this.__events[e].push(t)},WebSocket.prototype.removeEventListener=function(e,t,n){if(!(e in this.__events))return;var r=this.__events[e];for(var i=r.length-1;i>=0;--i)if(r[i]===t){r.splice(i,1);break}},WebSocket.prototype.dispatchEvent=function(e){var t=this.__events[e.type]||[];for(var n=0;n<t.length;++n)t[n](e);var r=this["on"+e.type];r&&r(e)},WebSocket.prototype.__handleEvent=function(e){"readyState"in e&&(this.readyState=e.readyState),"protocol"in e&&(this.protocol=e.protocol);var t;if(e.type=="open"||e.type=="error")t=this.__createSimpleEvent(e.type);else if(e.type=="close")t=this.__createSimpleEvent("close");else{if(e.type!="message")throw"unknown event type: "+e.type;var n=decodeURIComponent(e.message);t=this.__createMessageEvent("message",n)}this.dispatchEvent(t)},WebSocket.prototype.__createSimpleEvent=function(e){if(document.createEvent&&window.Event){var t=document.createEvent("Event");return t.initEvent(e,!1,!1),t}return{type:e,bubbles:!1,cancelable:!1}},WebSocket.prototype.__createMessageEvent=function(e,t){if(document.createEvent&&window.MessageEvent&&!window.opera){var n=document.createEvent("MessageEvent");return n.initMessageEvent("message",!1,!1,t,null,null,window,null),n}return{type:e,data:t,bubbles:!1,cancelable:!1}},WebSocket.CONNECTING=0,WebSocket.OPEN=1,WebSocket.CLOSING=2,WebSocket.CLOSED=3,WebSocket.__flash=null,WebSocket.__instances={},WebSocket.__tasks=[],WebSocket.__nextId=0,WebSocket.loadFlashPolicyFile=function(e){WebSocket.__addTask(function(){WebSocket.__flash.loadManualPolicyFile(e)})},WebSocket.__initialize=function(){if(WebSocket.__flash)return;WebSocket.__swfLocation&&(window.WEB_SOCKET_SWF_LOCATION=WebSocket.__swfLocation);if(!window.WEB_SOCKET_SWF_LOCATION){e.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");return}var t=document.createElement("div");t.id="webSocketContainer",t.style.position="absolute",WebSocket.__isFlashLite()?(t.style.left="0px",t.style.top="0px"):(t.style.left="-100px",t.style.top="-100px");var n=document.createElement("div");n.id="webSocketFlash",t.appendChild(n),document.body.appendChild(t),swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","10.0.0",null,null,{hasPriority:!0,swliveconnect:!0,allowScriptAccess:"always"},null,function(t){t.success||e.error("[WebSocket] swfobject.embedSWF failed")})},WebSocket.__onFlashInitialized=function(){setTimeout(function(){WebSocket.__flash=document.getElementById("webSocketFlash"),WebSocket.__flash.setCallerUrl(location.href),WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var e=0;e<WebSocket.__tasks.length;++e)WebSocket.__tasks[e]();WebSocket.__tasks=[]},0)},WebSocket.__onFlashEvent=function(){return setTimeout(function(){try{var t=WebSocket.__flash.receiveEvents();for(var n=0;n<t.length;++n)WebSocket.__instances[t[n].webSocketId].__handleEvent(t[n])}catch(r){e.error(r)}},0),!0},WebSocket.__log=function(t){e.log(decodeURIComponent(t))},WebSocket.__error=function(t){e.error(decodeURIComponent(t))},WebSocket.__addTask=function(e){WebSocket.__flash?e():WebSocket.__tasks.push(e)},WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes)return!1;var e=window.navigator.mimeTypes["application/x-shockwave-flash"];return!e||!e.enabledPlugin||!e.enabledPlugin.filename?!1:e.enabledPlugin.filename.match(/flashlite/i)?!0:!1},window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION||(window.addEventListener?window.addEventListener("load",function(){WebSocket.__initialize()},!1):window.attachEvent("onload",function(){WebSocket.__initialize()}))})(),function(e,t,n){function r(e){if(!e)return;t.Transport.apply(this,arguments),this.sendBuffer=[]}function i(){}e.XHR=r,t.util.inherit(r,t.Transport),r.prototype.open=function(){return this.socket.setBuffer(!1),this.onOpen(),this.get(),this.setCloseTimeout(),this},r.prototype.payload=function(e){var n=[];for(var r=0,i=e.length;r<i;r++)n.push(t.parser.encodePacket(e[r]));this.send(t.parser.encodePayload(n))},r.prototype.send=function(e){return this.post(e),this},r.prototype.post=function(e){function r(){this.readyState==4&&(this.onreadystatechange=i,t.posting=!1,this.status==200?t.socket.setBuffer(!1):t.onClose())}function s(){this.onload=i,t.socket.setBuffer(!1)}var t=this;this.socket.setBuffer(!0),this.sendXHR=this.request("POST"),n.XDomainRequest&&this.sendXHR instanceof XDomainRequest?this.sendXHR.onload=this.sendXHR.onerror=s:this.sendXHR.onreadystatechange=r,this.sendXHR.send(e)},r.prototype.close=function(){return this.onClose(),this},r.prototype.request=function(e){var n=t.util.request(this.socket.isXDomain()),r=t.util.query(this.socket.options.query,"t="+ +(new Date));n.open(e||"GET",this.prepareUrl()+r,!0);if(e=="POST")try{n.setRequestHeader?n.setRequestHeader("Content-type","text/plain;charset=UTF-8"):n.contentType="text/plain"}catch(i){}return n},r.prototype.scheme=function(){return this.socket.options.secure?"https":"http"},r.check=function(e,r){try{var i=t.util.request(r),s=n.XDomainRequest&&i instanceof XDomainRequest,o=e&&e.options&&e.options.secure?"https:":"http:",u=o!=n.location.protocol;if(i&&(!s||!u))return!0}catch(a){}return!1},r.xdomainCheck=function(){return r.check(null,!0)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t){function n(e){t.Transport.XHR.apply(this,arguments)}e.htmlfile=n,t.util.inherit(n,t.Transport.XHR),n.prototype.name="htmlfile",n.prototype.get=function(){this.doc=new(window[["Active"].concat("Object").join("X")])("htmlfile"),this.doc.open(),this.doc.write("<html></html>"),this.doc.close(),this.doc.parentWindow.s=this;var e=this.doc.createElement("div");e.className="socketio",this.doc.body.appendChild(e),this.iframe=this.doc.createElement("iframe"),e.appendChild(this.iframe);var n=this,r=t.util.query(this.socket.options.query,"t="+ +(new Date));this.iframe.src=this.prepareUrl()+r,t.util.on(window,"unload",function(){n.destroy()})},n.prototype._=function(e,t){this.onData(e);try{var n=t.getElementsByTagName("script")[0];n.parentNode.removeChild(n)}catch(r){}},n.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(e){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,CollectGarbage()}},n.prototype.close=function(){return this.destroy(),t.Transport.XHR.prototype.close.call(this)},n.check=function(){if(typeof window!="undefined"&&["Active"].concat("Object").join("X")in window)try{var e=new(window[["Active"].concat("Object").join("X")])("htmlfile");return e&&t.Transport.XHR.check()}catch(n){}return!1},n.xdomainCheck=function(){return!1},t.transports.push("htmlfile")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function r(){t.Transport.XHR.apply(this,arguments)}function i(){}e["xhr-polling"]=r,t.util.inherit(r,t.Transport.XHR),t.util.merge(r,t.Transport.XHR),r.prototype.name="xhr-polling",r.prototype.open=function(){var e=this;return t.Transport.XHR.prototype.open.call(e),!1},r.prototype.get=function(){function t(){this.readyState==4&&(this.onreadystatechange=i,this.status==200?(e.onData(this.responseText),e.get()):e.onClose())}function r(){this.onload=i,this.onerror=i,e.onData(this.responseText),e.get()}function s(){e.onClose()}if(!this.open)return;var e=this;this.xhr=this.request(),n.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=r,this.xhr.onerror=s):this.xhr.onreadystatechange=t,this.xhr.send(null)},r.prototype.onClose=function(){t.Transport.XHR.prototype.onClose.call(this);if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=i;try{this.xhr.abort()}catch(e){}this.xhr=null}},r.prototype.ready=function(e,n){var r=this;t.util.defer(function(){n.call(r)})},t.transports.push("xhr-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t,n){function i(e){t.Transport["xhr-polling"].apply(this,arguments),this.index=t.j.length;var n=this;t.j.push(function(e){n._(e)})}var r=n.document&&"MozAppearance"in n.document.documentElement.style;e["jsonp-polling"]=i,t.util.inherit(i,t.Transport["xhr-polling"]),i.prototype.name="jsonp-polling",i.prototype.post=function(e){function a(){f(),n.socket.setBuffer(!1)}function f(){n.iframe&&n.form.removeChild(n.iframe);try{u=document.createElement('<iframe name="'+n.iframeId+'">')}catch(e){u=document.createElement("iframe"),u.name=n.iframeId}u.id=n.iframeId,n.form.appendChild(u),n.iframe=u}var n=this,r=t.util.query(this.socket.options.query,"t="+ +(new Date)+"&i="+this.index);if(!this.form){var i=document.createElement("form"),s=document.createElement("textarea"),o=this.iframeId="socketio_iframe_"+this.index,u;i.className="socketio",i.style.position="absolute",i.style.top="0px",i.style.left="0px",i.style.display="none",i.target=o,i.method="POST",i.setAttribute("accept-charset","utf-8"),s.name="d",i.appendChild(s),document.body.appendChild(i),this.form=i,this.area=s}this.form.action=this.prepareUrl()+r,f(),this.area.value=t.JSON.stringify(e);try{this.form.submit()}catch(l){}this.iframe.attachEvent?u.onreadystatechange=function(){n.iframe.readyState=="complete"&&a()}:this.iframe.onload=a,this.socket.setBuffer(!0)},i.prototype.get=function(){var e=this,n=document.createElement("script"),i=t.util.query(this.socket.options.query,"t="+ +(new Date)+"&i="+this.index);this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),n.async=!0,n.src=this.prepareUrl()+i,n.onerror=function(){e.onClose()};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(n,s),this.script=n,r&&setTimeout(function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)},100)},i.prototype._=function(e){return this.onData(e),this.open&&this.get(),this},i.prototype.ready=function(e,n){var i=this;if(!r)return n.call(this);t.util.load(function(){n.call(i)})},i.check=function(){return"document"in n},i.xdomainCheck=function(){return!0},t.transports.push("jsonp-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),define("socketio",function(){}),define("Lib/Vendor/SocketIO",["socketio"],function(){return io}),define("Menu/Menu",["Lib/Utilities/ColorConverter","Lib/Utilities/Exception"],function(e,t){function r(){}function i(e){return document.querySelector(e)}function s(e){return document.querySelectorAll(e)}function u(e){return a("getChannels",{},function(t){t!=o&&(o=t,f(JSON.parse(t).success)),document.body.className="",typeof e=="function"&&e(JSON.parse(t).success)},function(e,t){console.error("getChannels error: ",t)}),!1}function a(e,t,n,r){try{var s=new XMLHttpRequest;s.onreadystatechange=function(){s.readyState==4&&(s.status==200?typeof n=="function"&&n(s.responseText):typeof r=="function"&&s.status=="400"?r(s.status,s.responseText):(console.error("Ajax error: "+s.status+" "+s.responseText),i("#list").innerHTML="",document.body.className="offline"))},s.open("POST","/api",!0),s.send(JSON.stringify({command:e,options:t}))}catch(o){console.error(o)}}function f(e){var t="";if(e.length>0)for(var n=0;n<e.length;n++){var r=e[n];t+="<tr><td>",t+="<a href='#"+r.name+"'>",t+=r.name,t+="</a></td><td>death match</td></tr>"}else t+="<tr><td colspan='2'>No channels found.</td></tr>";i("#list").innerHTML=t}function l(){a("getMaps",{},function(e){var t=JSON.parse(e).success,n="";for(var r=0;r<t.length;r++){var s=t[r];n+="<li><label>",n+='<input name="maps" value="'+s+'" type="checkbox" checked> ',n+=s,n+="</label></li>"}i("#maps").innerHTML=n},function(e,t){console.error("getMaps error:",e,t)})}function c(e){window.location.hash=e.channelName,v(e.timeout)}function h(){i("#customname").value=unescape(window.location.hash.substr(1)),i("#link").value=window.location.href,p("#customjoinform")}function p(e){i("#createform").style.display="none",i("#listform").style.display="none",i("#customjoinform").style.display="none",i("#game").style.display="none",e!="#customjoinform"&&history.pushState("",document.title,window.location.pathname),i(e).style.display="block"}function d(){return u(function(e){var t="Dungeon";history.pushState("",document.title,window.location.pathname+"#"+t);var n=i("#nick").value;n||(n="Guest"+(Math.floor(Math.random()*899)+100)),g(e,t)?S(n,t):x(t,function(){S(n,t)})}),!1}function v(e){var t=new Date,r=new Date(t.getTime()+e*1e3);n.channelDestructionTimeout=setInterval(function(){t=new Date;var e=new Date(r.getTime()-t.getTime());e.getTime()<0?(alert("Your channel has timed out."),window.location.href="/"):i("#timeout").innerHTML=" within "+m(e)+" minutes"},1e3)}function m(e){var t=e.getMinutes(),n=e.getSeconds();return t<10&&(t="0"+t),n<10&&(n="0"+n),t+":"+n}function g(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.name==t)return!0}return!1}function y(e,t){return!e||e.length<3?(alert("Nickname too short"),!1):t?!0:(alert("No channel name provided"),!1)}function b(e,t){return!0}function w(){var e=[],t=document.querySelectorAll("form#createform input[name=maps]");for(var n=0;n<t.length;n++){var r=t[n];r.checked&&e.push(r.value)}return e}function E(){var e=null,t=document.querySelectorAll("form#listform input[name=channel]");for(var n=0;n<t.length;n++){var r=t[n];if(r.checked){e=r.value;break}}return e}function S(e,t){y(e,t)&&(localStorage.player=JSON.stringify({nickname:e}),localStorage.channel=JSON.stringify({name:t}),i("#menu").style.display="none",i("#game").style.display="block",n.onRun(t,e),n.refreshInterval&&clearInterval(n.refreshInterval),n.channelDestructionTimeout&&clearInterval(n.channelDestructionTimeout),T())}function x(e,t){var n=w();if(b(e,n)){var r={channelName:e,levelUids:n,maxUsers:10,minUsers:2,scoreLimit:parseInt(i("#scoreLimit").value,10)};localStorage.customname=e,a("createChannel",r,function(e){typeof t=="function"&&t(JSON.parse(e).success)},function(e,t){console.log(t),alert(JSON.parse(t).error)})}}function T(){var e=i("#canvas");e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,e.requestPointerLock()}var n=null;r.prototype.init=function(){n=this;if(localStorage.player){var t=JSON.parse(localStorage.player);t.nickname&&(i("#nick").value=t.nickname)}localStorage.customname&&(i("#customname").value=localStorage.customname),i("#refresh").onclick=u,u(),l(),this.channelDestructionTimeout=null,this.refreshInterval=setInterval(u,5e3),i("#createbutton").onclick=function(){return p("#createform"),!1},i("#quickstartbutton").onclick=d;var r=s(".cancel");for(var o=0;o<r.length;o++)r[o].onclick=function(){return p("#listform"),!1};this.colorConverter=new e;var a=i("#nick");a.onchange=a.onkeyup=a.onblur=a.onclick=this.updatePrimaryColor.bind(this),this.updatePrimaryColor({target:a})},r.prototype.updatePrimaryColor=function(e){i("#primarycolor").style.backgroundColor="#"+this.colorConverter.getColorByName(e.target.value).toString(16)},r.prototype.onRun=function(e,n){throw new t("Menu onRun has to be overwritten")},window.onhashchange=function(){window.location.hash&&(i("#game").style.display=="block"&&window.location.reload(),u(function(e){var t=unescape(window.location.hash.substr(1));g(e,t)?h():(alert('Channel "'+t+'" does not exist (anymore).'),window.location.href="/")}))},window.onload=window.onhashchange;var o;return i("form#listform").onsubmit=function(e){try{var t=i("#nick").value,n=E();S(t,n)}catch(e){console.error(e)}return!1},i("form#createform").onsubmit=function(e){try{var t=i("#customname").value;x(t,c)}catch(e){console.error(e)}return!1},i("form#customjoinform").onsubmit=function(e){try{var t=i("#nick").value,n=i("#customname").value;S(t,n)}catch(e){console.error(e)}return!1},i("#canvas").onclick=T,r}),GLOBALS={context:"Client"},requirejs.config({baseUrl:"app",deps:["Lib/Utilities/Extensions"],waitSeconds:0,paths:{screenfull:"/screenfull",socketio:"/socket.io/socket.io"}});if(!Chuck)var Chuck={};Chuck.inspector={},requirejs(["Game/Client/Networker","Lib/Vendor/SocketIO","Game/Config/Settings","Lib/Utilities/Exception","Menu/Menu"],function(e,t,n,r,i){var s=new i;s.onRun=function(r,i){var s={reconnect:!1,"reconnection delay":500,"max reconnection attempts":10,transports:["websocket","flashsocket"]},o=t.connect("/",s),u=new e(o,r,i);Chuck.inspector.networker=u,Chuck.inspector.settings=n,Chuck.inspector.resetLevel=function(){u.sendGameCommand("resetLevel")}},s.init()}),define("../client",function(){})