Files
cocos-lizi/bounce/build/web-mobile/cocos2d-js-min.js
2018-06-23 21:09:45 +08:00

1 line
1.5 MiB
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(t,e,i){function n(i,s){var o=e[i];if(!o){var a=t[i];if(!a){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(r)return r(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var l={};o=e[i]={exports:l},a[0]((function(t){return n(a[1][t]||t)}),o,l)}return o.exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s])})({1:[(function(t,e,i){function n(){cc._engineLoaded=!0,console.log(cc.ENGINE_VERSION),o&&o()}function r(){window.removeEventListener("load",r,!1),n()}cc._LogInfos=cc._LogInfos||{};window.CocosEngine=cc.ENGINE_VERSION="1.9.1",cc._renderContext=null,cc._supportRender=!1,cc._canvas=null,cc.container=null,cc._gameDiv=null,t("./cocos2d/core/utils"),t("./cocos2d/core/platform/CCSys");var s=!1,o=null;cc._engineLoaded=!1,cc.initEngine=function(t,e){if(s){var i=o;o=function(){i&&i(),e&&e()}}else o=e,!cc.game.config&&t?cc.game.config=t:cc.game.config||cc.game._loadConfig(),(function(t){var e=cc.game.CONFIG_KEY,i=parseInt(t[e.renderMode])||0;(isNaN(i)||i>2||i<0)&&(t[e.renderMode]=0),cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!1,0===i?cc.sys.capabilities.opengl?(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0):cc.sys.capabilities.canvas&&(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):1===i&&cc.sys.capabilities.canvas?(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):2===i&&cc.sys.capabilities.opengl&&(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0)})(t=cc.game.config),document.body?n():window.addEventListener("load",r,!1),s=!0}}),{"./cocos2d/core/platform/CCSys":185,"./cocos2d/core/utils":225}],2:[(function(t,e,i){function n(t,e){return function(i){"use strict";if(1!==arguments.length){var n="";2===arguments.length?n="Arguments: "+arguments[1]:arguments.length>2&&(n="Arguments: "+cc.js.shiftArguments.apply(null,arguments).join(", ")),t(e+" "+i+", please go to "+o+"#"+i+" to see details. "+n)}else t(e+" "+i+", please go to "+o+"#"+i+" to see details.")}}var r,s=t("./cocos2d/core/platform/CCEnum");cc.DebugMode=s({NONE:0,INFO:1,WARN:2,ERROR:3,INFO_FOR_WEB_PAGE:4,WARN_FOR_WEB_PAGE:5,ERROR_FOR_WEB_PAGE:6}),cc._initDebugSetting=function(t){if(cc.log=cc.logID=cc.warn=cc.warnID=cc.error=cc.errorID=cc.assert=cc.assertID=function(){},t!==cc.DebugMode.NONE){t>cc.DebugMode.ERROR?(function(){function e(t){if(cc._canvas){if(!r){var e=document.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200"),e.setAttribute("height",cc._canvas.height);var i=e.style;i.zIndex="99999",i.position="absolute",i.top=i.left="0",(r=document.createElement("textarea")).setAttribute("rows","20"),r.setAttribute("cols","30"),r.setAttribute("disabled","true");var n=r.style;n.backgroundColor="transparent",n.borderBottom="1px solid #cccccc",n.borderTopWidth=n.borderLeftWidth=n.borderRightWidth="0px",n.borderTopStyle=n.borderLeftStyle=n.borderRightStyle="none",n.padding="0px",n.margin=0,e.appendChild(r),cc._canvas.parentNode.appendChild(e)}r.value=r.value+t+"\r\n",r.scrollTop=r.scrollHeight}}cc.error=function(){e("ERROR : "+cc.js.formatStr.apply(null,arguments))},cc.assert=function(t,i){"use strict";!t&&i&&e("ASSERT: "+(i=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments))))},t!==cc.DebugMode.ERROR_FOR_WEB_PAGE&&(cc.warn=function(){e("WARN : "+cc.js.formatStr.apply(null,arguments))}),t===cc.DebugMode.INFO_FOR_WEB_PAGE&&(cc.log=cc.info=function(){e(cc.js.formatStr.apply(null,arguments))})})():console&&console.log.apply&&(console.error||(console.error=console.log),console.warn||(console.warn=console.log),console.error.bind?cc.error=console.error.bind(console):cc.error=function(){return console.error.apply(console,arguments)},cc.assert=function(t,e){if(!t)throw e&&(e=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments))),new Error(e)}),t!==cc.DebugMode.ERROR&&(console.warn.bind?cc.warn=console.warn.bind(console):cc.warn=function(){return console.warn.apply(console,arguments)}),t===cc.DebugMode.INFO&&(console.log.bind?cc.log=console.log.bind(console):cc.log=function(){return console.log.apply(console,arguments)},cc.info=function(){(console.info||console.log).apply(console,arguments)}),cc.warnID=n(cc.warn,"Warning"),cc.errorID=n(cc.error,"Error"),cc.logID=n(cc.log,"Log");var e=n((function(){for(var t=[!1],e=0;e<arguments.length;++e)t.push(arguments[e]);cc.assert.apply(null,t)}),"Assert");cc.assertID=function(t){"use strict";t||e.apply(null,cc.js.shiftArguments.apply(null,arguments))}}},cc._throw=function(t){var e=t.stack;e?cc.error(e):cc.error(t)};var o="https://github.com/cocos-creator/engine/blob/master/EngineErrorMap.md"}),{"./cocos2d/core/platform/CCEnum":178}],3:[(function(t,e,i){}),{}],4:[(function(t,e,i){cc.Action=cc._Class.extend({ctor:function(){this.originalTarget=null,this.target=null,this.tag=cc.Action.TAG_INVALID},clone:function(){var t=new cc.Action;return t.originalTarget=null,t.target=null,t.tag=this.tag,t},isDone:function(){return!0},startWithTarget:function(t){this.originalTarget=t,this.target=t},stop:function(){this.target=null},step:function(t){cc.logID(1006)},update:function(t){cc.logID(1007)},getTarget:function(){return this.target},setTarget:function(t){this.target=t},getOriginalTarget:function(){return this.originalTarget},setOriginalTarget:function(t){this.originalTarget=t},getTag:function(){return this.tag},setTag:function(t){this.tag=t},retain:function(){},release:function(){}}),cc.Action.TAG_INVALID=-1,cc.FiniteTimeAction=cc.Action.extend({_duration:0,ctor:function(){cc.Action.prototype.ctor.call(this),this._duration=0},getDuration:function(){return this._duration*(this._timesForRepeat||1)},setDuration:function(t){this._duration=t},reverse:function(){return cc.logID(1008),null},clone:function(){return new cc.FiniteTimeAction}}),cc.Speed=cc.Action.extend({_speed:0,_innerAction:null,ctor:function(t,e){cc.Action.prototype.ctor.call(this),this._speed=0,this._innerAction=null,t&&this.initWithAction(t,e)},getSpeed:function(){return this._speed},setSpeed:function(t){this._speed=t},initWithAction:function(t,e){if(!t)throw new Error("cc.Speed.initWithAction(): action must be non nil");return this._innerAction=t,this._speed=e,!0},clone:function(){var t=new cc.Speed;return t.initWithAction(this._innerAction.clone(),this._speed),t},startWithTarget:function(t){cc.Action.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},step:function(t){this._innerAction.step(t*this._speed)},isDone:function(){return this._innerAction.isDone()},reverse:function(){return new cc.Speed(this._innerAction.reverse(),this._speed)},setInnerAction:function(t){this._innerAction!==t&&(this._innerAction=t)},getInnerAction:function(){return this._innerAction}}),cc.speed=function(t,e){return new cc.Speed(t,e)},cc.Follow=cc.Action.extend({_followedNode:null,_boundarySet:!1,_boundaryFullyCovered:!1,_halfScreenSize:null,_fullScreenSize:null,_worldRect:null,leftBoundary:0,rightBoundary:0,topBoundary:0,bottomBoundary:0,ctor:function(t,e){cc.Action.prototype.ctor.call(this),this._followedNode=null,this._boundarySet=!1,this._boundaryFullyCovered=!1,this._halfScreenSize=null,this._fullScreenSize=null,this.leftBoundary=0,this.rightBoundary=0,this.topBoundary=0,this.bottomBoundary=0,this._worldRect=cc.rect(0,0,0,0),t&&(e?this.initWithTarget(t,e):this.initWithTarget(t))},clone:function(){var t=new cc.Follow,e=this._worldRect,i=new cc.Rect(e.x,e.y,e.width,e.height);return t.initWithTarget(this._followedNode,i),t},isBoundarySet:function(){return this._boundarySet},setBoudarySet:function(t){this._boundarySet=t},initWithTarget:function(t,e){if(!t)throw new Error("cc.Follow.initWithAction(): followedNode must be non nil");e=e||cc.rect(0,0,0,0),this._followedNode=t,this._worldRect=e,this._boundarySet=!cc._rectEqualToZero(e),this._boundaryFullyCovered=!1;var i=cc.director.getWinSize();return this._fullScreenSize=cc.p(i.width,i.height),this._halfScreenSize=cc.pMult(this._fullScreenSize,.5),this._boundarySet&&(this.leftBoundary=-(e.x+e.width-this._fullScreenSize.x),this.rightBoundary=-e.x,this.topBoundary=-e.y,this.bottomBoundary=-(e.y+e.height-this._fullScreenSize.y),this.rightBoundary<this.leftBoundary&&(this.rightBoundary=this.leftBoundary=(this.leftBoundary+this.rightBoundary)/2),this.topBoundary<this.bottomBoundary&&(this.topBoundary=this.bottomBoundary=(this.topBoundary+this.bottomBoundary)/2),this.topBoundary===this.bottomBoundary&&this.leftBoundary===this.rightBoundary&&(this._boundaryFullyCovered=!0)),!0},step:function(t){var e=this.target.convertToWorldSpaceAR(cc.Vec2.ZERO),i=this._followedNode.convertToWorldSpaceAR(cc.Vec2.ZERO),n=cc.pSub(e,i),r=this.target.parent.convertToNodeSpaceAR(cc.pAdd(n,this._halfScreenSize));if(this._boundarySet){if(this._boundaryFullyCovered)return;this.target.setPosition(cc.clampf(r.x,this.leftBoundary,this.rightBoundary),cc.clampf(r.y,this.bottomBoundary,this.topBoundary))}else this.target.setPosition(r.x,r.y)},isDone:function(){return!this._followedNode.isRunning()},stop:function(){this.target=null,cc.Action.prototype.stop.call(this)}}),cc.follow=function(t,e){return new cc.Follow(t,e)}}),{}],5:[(function(t,e,i){function n(t){for(var e=[],i=t.length-1;i>=0;i--)e.push(cc.p(t[i].x,t[i].y));return e}function r(t){for(var e=[],i=0;i<t.length;i++)e.push(cc.p(t[i].x,t[i].y));return e}cc.cardinalSplineAt=function(t,e,i,n,r,s){var o=s*s,a=o*s,c=(1-r)/2,h=c*(2*o-a-s),l=c*(-a+o)+(2*a-3*o+1),u=c*(a-2*o+s)+(-2*a+3*o),_=c*(a-o),d=t.x*h+e.x*l+i.x*u+n.x*_,f=t.y*h+e.y*l+i.y*u+n.y*_;return cc.p(d,f)},cc.getControlPointAt=function(t,e){return t[Math.min(t.length-1,Math.max(e,0))]},cc.CardinalSplineTo=cc.ActionInterval.extend({_points:null,_deltaT:0,_tension:0,_previousPosition:null,_accumulatedDiff:null,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),this._points=[],void 0!==i&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){if(!e||0===e.length)throw new Error("Invalid configuration. It must at least have one control point");return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this.setPoints(e),this._tension=i,!0)},clone:function(){var t=new cc.CardinalSplineTo;return t.initWithDuration(this._duration,r(this._points),this._tension),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._deltaT=1/(this._points.length-1),this._previousPosition=cc.p(this.target.getPositionX(),this.target.getPositionY()),this._accumulatedDiff=cc.p(0,0)},update:function(t){t=this._computeEaseTime(t);var e,i,n=this._points;if(1===t)e=n.length-1,i=1;else{var r=this._deltaT;i=(t-r*(e=0|t/r))/r}var s=cc.cardinalSplineAt(cc.getControlPointAt(n,e-1),cc.getControlPointAt(n,e-0),cc.getControlPointAt(n,e+1),cc.getControlPointAt(n,e+2),this._tension,i);if(cc.macro.ENABLE_STACKABLE_ACTIONS){var o,a;if(o=this.target.getPositionX()-this._previousPosition.x,a=this.target.getPositionY()-this._previousPosition.y,0!==o||0!==a){var c=this._accumulatedDiff;o=c.x+o,a=c.y+a,c.x=o,c.y=a,s.x+=o,s.y+=a}}this.updatePosition(s)},reverse:function(){var t=n(this._points);return cc.cardinalSplineTo(this._duration,t,this._tension)},updatePosition:function(t){this.target.setPosition(t),this._previousPosition=t},getPoints:function(){return this._points},setPoints:function(t){this._points=t}}),cc.cardinalSplineTo=function(t,e,i){return new cc.CardinalSplineTo(t,e,i)},cc.CardinalSplineBy=cc.CardinalSplineTo.extend({_startPosition:null,ctor:function(t,e,i){cc.CardinalSplineTo.prototype.ctor.call(this),this._startPosition=cc.p(0,0),void 0!==i&&this.initWithDuration(t,e,i)},startWithTarget:function(t){cc.CardinalSplineTo.prototype.startWithTarget.call(this,t),this._startPosition.x=t.getPositionX(),this._startPosition.y=t.getPositionY()},reverse:function(){for(var t,e=this._points.slice(),i=e[0],r=1;r<e.length;++r)t=e[r],e[r]=cc.pSub(t,i),i=t;var s=n(e);i=s[s.length-1],s.pop(),i.x=-i.x,i.y=-i.y,s.unshift(i);for(r=1;r<s.length;++r)(t=s[r]).x=-t.x,t.y=-t.y,t.x+=i.x,t.y+=i.y,s[r]=t,i=t;return cc.cardinalSplineBy(this._duration,s,this._tension)},updatePosition:function(t){var e=this._startPosition,i=t.x+e.x,n=t.y+e.y;this._previousPosition.x=i,this._previousPosition.y=n,this.target.setPosition(i,n)},clone:function(){var t=new cc.CardinalSplineBy;return t.initWithDuration(this._duration,r(this._points),this._tension),t}}),cc.cardinalSplineBy=function(t,e,i){return new cc.CardinalSplineBy(t,e,i)},cc.CatmullRomTo=cc.CardinalSplineTo.extend({ctor:function(t,e){e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return cc.CardinalSplineTo.prototype.initWithDuration.call(this,t,e,.5)},clone:function(){var t=new cc.CatmullRomTo;return t.initWithDuration(this._duration,r(this._points)),t}}),cc.catmullRomTo=function(t,e){return new cc.CatmullRomTo(t,e)},cc.CatmullRomBy=cc.CardinalSplineBy.extend({ctor:function(t,e){cc.CardinalSplineBy.prototype.ctor.call(this),e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return cc.CardinalSplineTo.prototype.initWithDuration.call(this,t,e,.5)},clone:function(){var t=new cc.CatmullRomBy;return t.initWithDuration(this._duration,r(this._points)),t}}),cc.catmullRomBy=function(t,e){return new cc.CatmullRomBy(t,e)}}),{}],6:[(function(t,e,i){cc.ActionEase=cc.ActionInterval.extend({_inner:null,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),t&&this.initWithAction(t)},initWithAction:function(t){if(!t)throw new Error("cc.ActionEase.initWithAction(): action must be non nil");return!!this.initWithDuration(t.getDuration())&&(this._inner=t,!0)},clone:function(){var t=new cc.ActionEase;return t.initWithAction(this._inner.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._inner.startWithTarget(this.target)},stop:function(){this._inner.stop(),cc.ActionInterval.prototype.stop.call(this)},update:function(t){this._inner.update(t)},reverse:function(){return new cc.ActionEase(this._inner.reverse())},getInnerAction:function(){return this._inner}}),cc.actionEase=function(t){return new cc.ActionEase(t)},cc.EaseRateAction=cc.ActionEase.extend({_rate:0,ctor:function(t,e){cc.ActionEase.prototype.ctor.call(this),void 0!==e&&this.initWithAction(t,e)},setRate:function(t){this._rate=t},getRate:function(){return this._rate},initWithAction:function(t,e){return!!cc.ActionEase.prototype.initWithAction.call(this,t)&&(this._rate=e,!0)},clone:function(){var t=new cc.EaseRateAction;return t.initWithAction(this._inner.clone(),this._rate),t},reverse:function(){return new cc.EaseRateAction(this._inner.reverse(),1/this._rate)}}),cc.easeRateAction=function(t,e){return new cc.EaseRateAction(t,e)},cc.EaseIn=cc.EaseRateAction.extend({update:function(t){this._inner.update(Math.pow(t,this._rate))},reverse:function(){return new cc.EaseIn(this._inner.reverse(),1/this._rate)},clone:function(){var t=new cc.EaseIn;return t.initWithAction(this._inner.clone(),this._rate),t}}),cc.easeIn=function(t){return{_rate:t,easing:function(t){return Math.pow(t,this._rate)},reverse:function(){return cc.easeIn(1/this._rate)}}},cc.EaseOut=cc.EaseRateAction.extend({update:function(t){this._inner.update(Math.pow(t,1/this._rate))},reverse:function(){return new cc.EaseOut(this._inner.reverse(),1/this._rate)},clone:function(){var t=new cc.EaseOut;return t.initWithAction(this._inner.clone(),this._rate),t}}),cc.easeOut=function(t){return{_rate:t,easing:function(t){return Math.pow(t,1/this._rate)},reverse:function(){return cc.easeOut(1/this._rate)}}},cc.EaseInOut=cc.EaseRateAction.extend({update:function(t){(t*=2)<1?this._inner.update(.5*Math.pow(t,this._rate)):this._inner.update(1-.5*Math.pow(2-t,this._rate))},clone:function(){var t=new cc.EaseInOut;return t.initWithAction(this._inner.clone(),this._rate),t},reverse:function(){return new cc.EaseInOut(this._inner.reverse(),this._rate)}}),cc.easeInOut=function(t){return{_rate:t,easing:function(t){return(t*=2)<1?.5*Math.pow(t,this._rate):1-.5*Math.pow(2-t,this._rate)},reverse:function(){return cc.easeInOut(this._rate)}}},cc.EaseExponentialIn=cc.ActionEase.extend({update:function(t){this._inner.update(0===t?0:Math.pow(2,10*(t-1)))},reverse:function(){return new cc.EaseExponentialOut(this._inner.reverse())},clone:function(){var t=new cc.EaseExponentialIn;return t.initWithAction(this._inner.clone()),t}}),cc._easeExponentialInObj={easing:function(t){return 0===t?0:Math.pow(2,10*(t-1))},reverse:function(){return cc._easeExponentialOutObj}},cc.easeExponentialIn=function(){return cc._easeExponentialInObj},cc.EaseExponentialOut=cc.ActionEase.extend({update:function(t){this._inner.update(1===t?1:1-Math.pow(2,-10*t))},reverse:function(){return new cc.EaseExponentialIn(this._inner.reverse())},clone:function(){var t=new cc.EaseExponentialOut;return t.initWithAction(this._inner.clone()),t}}),cc._easeExponentialOutObj={easing:function(t){return 1===t?1:1-Math.pow(2,-10*t)},reverse:function(){return cc._easeExponentialInObj}},cc.easeExponentialOut=function(){return cc._easeExponentialOutObj},cc.EaseExponentialInOut=cc.ActionEase.extend({update:function(t){1!==t&&0!==t&&(t=(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))),this._inner.update(t)},reverse:function(){return new cc.EaseExponentialInOut(this._inner.reverse())},clone:function(){var t=new cc.EaseExponentialInOut;return t.initWithAction(this._inner.clone()),t}}),cc._easeExponentialInOutObj={easing:function(t){return 1!==t&&0!==t?(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1))):t},reverse:function(){return cc._easeExponentialInOutObj}},cc.easeExponentialInOut=function(){return cc._easeExponentialInOutObj},cc.EaseSineIn=cc.ActionEase.extend({update:function(t){t=0===t||1===t?t:-1*Math.cos(t*Math.PI/2)+1,this._inner.update(t)},reverse:function(){return new cc.EaseSineOut(this._inner.reverse())},clone:function(){var t=new cc.EaseSineIn;return t.initWithAction(this._inner.clone()),t}}),cc._easeSineInObj={easing:function(t){return 0===t||1===t?t:-1*Math.cos(t*Math.PI/2)+1},reverse:function(){return cc._easeSineOutObj}},cc.easeSineIn=function(){return cc._easeSineInObj},cc.EaseSineOut=cc.ActionEase.extend({update:function(t){t=0===t||1===t?t:Math.sin(t*Math.PI/2),this._inner.update(t)},reverse:function(){return new cc.EaseSineIn(this._inner.reverse())},clone:function(){var t=new cc.EaseSineOut;return t.initWithAction(this._inner.clone()),t}}),cc._easeSineOutObj={easing:function(t){return 0===t||1===t?t:Math.sin(t*Math.PI/2)},reverse:function(){return cc._easeSineInObj}},cc.easeSineOut=function(){return cc._easeSineOutObj},cc.EaseSineInOut=cc.ActionEase.extend({update:function(t){t=0===t||1===t?t:-.5*(Math.cos(Math.PI*t)-1),this._inner.update(t)},clone:function(){var t=new cc.EaseSineInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseSineInOut(this._inner.reverse())}}),cc._easeSineInOutObj={easing:function(t){return 0===t||1===t?t:-.5*(Math.cos(Math.PI*t)-1)},reverse:function(){return cc._easeSineInOutObj}},cc.easeSineInOut=function(){return cc._easeSineInOutObj},cc.EaseElastic=cc.ActionEase.extend({_period:.3,ctor:function(t,e){cc.ActionEase.prototype.ctor.call(this),t&&this.initWithAction(t,e)},getPeriod:function(){return this._period},setPeriod:function(t){this._period=t},initWithAction:function(t,e){return cc.ActionEase.prototype.initWithAction.call(this,t),this._period=null==e?.3:e,!0},reverse:function(){return cc.logID(1009),null},clone:function(){var t=new cc.EaseElastic;return t.initWithAction(this._inner.clone(),this._period),t}}),cc.EaseElasticIn=cc.EaseElastic.extend({update:function(t){var e=0;if(0===t||1===t)e=t;else{var i=this._period/4;t-=1,e=-Math.pow(2,10*t)*Math.sin((t-i)*Math.PI*2/this._period)}this._inner.update(e)},reverse:function(){return new cc.EaseElasticOut(this._inner.reverse(),this._period)},clone:function(){var t=new cc.EaseElasticIn;return t.initWithAction(this._inner.clone(),this._period),t}}),cc._easeElasticInObj={easing:function(t){return 0===t||1===t?t:(t-=1,-Math.pow(2,10*t)*Math.sin((t-.075)*Math.PI*2/.3))},reverse:function(){return cc._easeElasticOutObj}},cc.easeElasticIn=function(t){return t&&.3!==t?{_period:t,easing:function(t){return 0===t||1===t?t:(t-=1,-Math.pow(2,10*t)*Math.sin((t-this._period/4)*Math.PI*2/this._period))},reverse:function(){return cc.easeElasticOut(this._period)}}:cc._easeElasticInObj},cc.EaseElasticOut=cc.EaseElastic.extend({update:function(t){var e=0;if(0===t||1===t)e=t;else{var i=this._period/4;e=Math.pow(2,-10*t)*Math.sin((t-i)*Math.PI*2/this._period)+1}this._inner.update(e)},reverse:function(){return new cc.EaseElasticIn(this._inner.reverse(),this._period)},clone:function(){var t=new cc.EaseElasticOut;return t.initWithAction(this._inner.clone(),this._period),t}}),cc._easeElasticOutObj={easing:function(t){return 0===t||1===t?t:Math.pow(2,-10*t)*Math.sin((t-.075)*Math.PI*2/.3)+1},reverse:function(){return cc._easeElasticInObj}},cc.easeElasticOut=function(t){return t&&.3!==t?{_period:t,easing:function(t){return 0===t||1===t?t:Math.pow(2,-10*t)*Math.sin((t-this._period/4)*Math.PI*2/this._period)+1},reverse:function(){return cc.easeElasticIn(this._period)}}:cc._easeElasticOutObj},cc.EaseElasticInOut=cc.EaseElastic.extend({update:function(t){var e=0,i=this._period;if(0===t||1===t)e=t;else{t*=2,i||(i=this._period=.3*1.5);var n=i/4;e=(t-=1)<0?-.5*Math.pow(2,10*t)*Math.sin((t-n)*Math.PI*2/i):Math.pow(2,-10*t)*Math.sin((t-n)*Math.PI*2/i)*.5+1}this._inner.update(e)},reverse:function(){return new cc.EaseElasticInOut(this._inner.reverse(),this._period)},clone:function(){var t=new cc.EaseElasticInOut;return t.initWithAction(this._inner.clone(),this._period),t}}),cc.easeElasticInOut=function(t){return t=t||.3,{_period:t,easing:function(t){var e=0,i=this._period;if(0===t||1===t)e=t;else{t*=2,i||(i=this._period=.3*1.5);var n=i/4;e=(t-=1)<0?-.5*Math.pow(2,10*t)*Math.sin((t-n)*Math.PI*2/i):Math.pow(2,-10*t)*Math.sin((t-n)*Math.PI*2/i)*.5+1}return e},reverse:function(){return cc.easeElasticInOut(this._period)}}},cc.EaseBounce=cc.ActionEase.extend({bounceTime:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},clone:function(){var t=new cc.EaseBounce;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseBounce(this._inner.reverse())}}),cc.EaseBounceIn=cc.EaseBounce.extend({update:function(t){var e=1-this.bounceTime(1-t);this._inner.update(e)},reverse:function(){return new cc.EaseBounceOut(this._inner.reverse())},clone:function(){var t=new cc.EaseBounceIn;return t.initWithAction(this._inner.clone()),t}}),cc._bounceTime=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},cc._easeBounceInObj={easing:function(t){return 1-cc._bounceTime(1-t)},reverse:function(){return cc._easeBounceOutObj}},cc.easeBounceIn=function(){return cc._easeBounceInObj},cc.EaseBounceOut=cc.EaseBounce.extend({update:function(t){var e=this.bounceTime(t);this._inner.update(e)},reverse:function(){return new cc.EaseBounceIn(this._inner.reverse())},clone:function(){var t=new cc.EaseBounceOut;return t.initWithAction(this._inner.clone()),t}}),cc._easeBounceOutObj={easing:function(t){return cc._bounceTime(t)},reverse:function(){return cc._easeBounceInObj}},cc.easeBounceOut=function(){return cc._easeBounceOutObj},cc.EaseBounceInOut=cc.EaseBounce.extend({update:function(t){var e=0;t<.5?(t*=2,e=.5*(1-this.bounceTime(1-t))):e=.5*this.bounceTime(2*t-1)+.5,this._inner.update(e)},clone:function(){var t=new cc.EaseBounceInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseBounceInOut(this._inner.reverse())}}),cc._easeBounceInOutObj={easing:function(t){var e;return t<.5?(t*=2,e=.5*(1-cc._bounceTime(1-t))):e=.5*cc._bounceTime(2*t-1)+.5,e},reverse:function(){return cc._easeBounceInOutObj}},cc.easeBounceInOut=function(){return cc._easeBounceInOutObj},cc.EaseBackIn=cc.ActionEase.extend({update:function(t){t=0===t||1===t?t:t*t*(2.70158*t-1.70158),this._inner.update(t)},reverse:function(){return new cc.EaseBackOut(this._inner.reverse())},clone:function(){var t=new cc.EaseBackIn;return t.initWithAction(this._inner.clone()),t}}),cc._easeBackInObj={easing:function(t){return 0===t||1===t?t:t*t*(2.70158*t-1.70158)},reverse:function(){return cc._easeBackOutObj}},cc.easeBackIn=function(){return cc._easeBackInObj},cc.EaseBackOut=cc.ActionEase.extend({update:function(t){t-=1,this._inner.update(t*t*(2.70158*t+1.70158)+1)},reverse:function(){return new cc.EaseBackIn(this._inner.reverse())},clone:function(){var t=new cc.EaseBackOut;return t.initWithAction(this._inner.clone()),t}}),cc._easeBackOutObj={easing:function(t){return(t-=1)*t*(2.70158*t+1.70158)+1},reverse:function(){return cc._easeBackInObj}},cc.easeBackOut=function(){return cc._easeBackOutObj},cc.EaseBackInOut=cc.ActionEase.extend({update:function(t){var e=2.5949095;(t*=2)<1?this._inner.update(t*t*((e+1)*t-e)/2):(t-=2,this._inner.update(t*t*((e+1)*t+e)/2+1))},clone:function(){var t=new cc.EaseBackInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseBackInOut(this._inner.reverse())}}),cc._easeBackInOutObj={easing:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)/2:(t-=2)*t*((e+1)*t+e)/2+1},reverse:function(){return cc._easeBackInOutObj}},cc.easeBackInOut=function(){return cc._easeBackInOutObj},cc.EaseBezierAction=cc.ActionEase.extend({_p0:null,_p1:null,_p2:null,_p3:null,ctor:function(t){cc.ActionEase.prototype.ctor.call(this,t)},_updateTime:function(t,e,i,n,r){return Math.pow(1-r,3)*t+3*r*Math.pow(1-r,2)*e+3*Math.pow(r,2)*(1-r)*i+Math.pow(r,3)*n},update:function(t){var e=this._updateTime(this._p0,this._p1,this._p2,this._p3,t);this._inner.update(e)},clone:function(){var t=new cc.EaseBezierAction;return t.initWithAction(this._inner.clone()),t.setBezierParamer(this._p0,this._p1,this._p2,this._p3),t},reverse:function(){var t=new cc.EaseBezierAction(this._inner.reverse());return t.setBezierParamer(this._p3,this._p2,this._p1,this._p0),t},setBezierParamer:function(t,e,i,n){this._p0=t||0,this._p1=e||0,this._p2=i||0,this._p3=n||0}}),cc.easeBezierAction=function(t,e,i,n){return{easing:function(r){return cc.EaseBezierAction.prototype._updateTime(t,e,i,n,r)},reverse:function(){return cc.easeBezierAction(n,i,e,t)}}},cc.EaseQuadraticActionIn=cc.ActionEase.extend({_updateTime:function(t){return Math.pow(t,2)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuadraticActionIn;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuadraticActionIn(this._inner.reverse())}}),cc._easeQuadraticActionIn={easing:cc.EaseQuadraticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionIn}},cc.easeQuadraticActionIn=function(){return cc._easeQuadraticActionIn},cc.EaseQuadraticActionOut=cc.ActionEase.extend({_updateTime:function(t){return-t*(t-2)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuadraticActionOut;return t.initWithAction(),t},reverse:function(){return new cc.EaseQuadraticActionOut(this._inner.reverse())}}),cc._easeQuadraticActionOut={easing:cc.EaseQuadraticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionOut}},cc.easeQuadraticActionOut=function(){return cc._easeQuadraticActionOut},cc.EaseQuadraticActionInOut=cc.ActionEase.extend({_updateTime:function(t){return t*=2,t<1?t*t*.5:-.5*(--t*(t-2)-1)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuadraticActionInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuadraticActionInOut(this._inner.reverse())}}),cc._easeQuadraticActionInOut={easing:cc.EaseQuadraticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionInOut}},cc.easeQuadraticActionInOut=function(){return cc._easeQuadraticActionInOut},cc.EaseQuarticActionIn=cc.ActionEase.extend({_updateTime:function(t){return t*t*t*t},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuarticActionIn;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuarticActionIn(this._inner.reverse())}}),cc._easeQuarticActionIn={easing:cc.EaseQuarticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuarticActionIn}},cc.easeQuarticActionIn=function(){return cc._easeQuarticActionIn},cc.EaseQuarticActionOut=cc.ActionEase.extend({_updateTime:function(t){return-((t-=1)*t*t*t-1)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuarticActionOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuarticActionOut(this._inner.reverse())}}),cc._easeQuarticActionOut={easing:cc.EaseQuarticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuarticActionOut}},cc.easeQuarticActionOut=function(){return cc._easeQuarticActionOut},cc.EaseQuarticActionInOut=cc.ActionEase.extend({_updateTime:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuarticActionInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuarticActionInOut(this._inner.reverse())}}),cc._easeQuarticActionInOut={easing:cc.EaseQuarticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuarticActionInOut}},cc.easeQuarticActionInOut=function(){return cc._easeQuarticActionInOut},cc.EaseQuinticActionIn=cc.ActionEase.extend({_updateTime:function(t){return t*t*t*t*t},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuinticActionIn;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuinticActionIn(this._inner.reverse())}}),cc._easeQuinticActionIn={easing:cc.EaseQuinticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuinticActionIn}},cc.easeQuinticActionIn=function(){return cc._easeQuinticActionIn},cc.EaseQuinticActionOut=cc.ActionEase.extend({_updateTime:function(t){return(t-=1)*t*t*t*t+1},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuinticActionOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuinticActionOut(this._inner.reverse())}}),cc._easeQuinticActionOut={easing:cc.EaseQuinticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuinticActionOut}},cc.easeQuinticActionOut=function(){return cc._easeQuinticActionOut},cc.EaseQuinticActionInOut=cc.ActionEase.extend({_updateTime:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseQuinticActionInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseQuinticActionInOut(this._inner.reverse())}}),cc._easeQuinticActionInOut={easing:cc.EaseQuinticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuinticActionInOut}},cc.easeQuinticActionInOut=function(){return cc._easeQuinticActionInOut},cc.EaseCircleActionIn=cc.ActionEase.extend({_updateTime:function(t){return-1*(Math.sqrt(1-t*t)-1)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseCircleActionIn;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseCircleActionIn(this._inner.reverse())}}),cc._easeCircleActionIn={easing:cc.EaseCircleActionIn.prototype._updateTime,reverse:function(){return cc._easeCircleActionIn}},cc.easeCircleActionIn=function(){return cc._easeCircleActionIn},cc.EaseCircleActionOut=cc.ActionEase.extend({_updateTime:function(t){return t-=1,Math.sqrt(1-t*t)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseCircleActionOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseCircleActionOut(this._inner.reverse())}}),cc._easeCircleActionOut={easing:cc.EaseCircleActionOut.prototype._updateTime,reverse:function(){return cc._easeCircleActionOut}},cc.easeCircleActionOut=function(){return cc._easeCircleActionOut},cc.EaseCircleActionInOut=cc.ActionEase.extend({_updateTime:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):(t-=2,.5*(Math.sqrt(1-t*t)+1))},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseCircleActionInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseCircleActionInOut(this._inner.reverse())}}),cc._easeCircleActionInOut={easing:cc.EaseCircleActionInOut.prototype._updateTime,reverse:function(){return cc._easeCircleActionInOut}},cc.easeCircleActionInOut=function(){return cc._easeCircleActionInOut},cc.EaseCubicActionIn=cc.ActionEase.extend({_updateTime:function(t){return t*t*t},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseCubicActionIn;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseCubicActionIn(this._inner.reverse())}}),cc._easeCubicActionIn={easing:cc.EaseCubicActionIn.prototype._updateTime,reverse:function(){return cc._easeCubicActionIn}},cc.easeCubicActionIn=function(){return cc._easeCubicActionIn},cc.EaseCubicActionOut=cc.ActionEase.extend({_updateTime:function(t){return(t-=1)*t*t+1},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseCubicActionOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseCubicActionOut(this._inner.reverse())}}),cc._easeCubicActionOut={easing:cc.EaseCubicActionOut.prototype._updateTime,reverse:function(){return cc._easeCubicActionOut}},cc.easeCubicActionOut=function(){return cc._easeCubicActionOut},cc.EaseCubicActionInOut=cc.ActionEase.extend({_updateTime:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},update:function(t){this._inner.update(this._updateTime(t))},clone:function(){var t=new cc.EaseCubicActionInOut;return t.initWithAction(this._inner.clone()),t},reverse:function(){return new cc.EaseCubicActionInOut(this._inner.reverse())}}),cc._easeCubicActionInOut={easing:cc.EaseCubicActionInOut.prototype._updateTime,reverse:function(){return cc._easeCubicActionInOut}},cc.easeCubicActionInOut=function(){return cc._easeCubicActionInOut}}),{}],7:[(function(t,e,i){cc.ActionInstant=cc.FiniteTimeAction.extend({isDone:function(){return!0},step:function(t){this.update(1)},update:function(t){},reverse:function(){return this.clone()},clone:function(){return new cc.ActionInstant}}),cc.Show=cc.ActionInstant.extend({update:function(t){for(var e=this.target.getComponentsInChildren(cc._SGComponent),i=0;i<e.length;++i){e[i].enabled=!0}},reverse:function(){return new cc.Hide},clone:function(){return new cc.Show}}),cc.show=function(){return new cc.Show},cc.Hide=cc.ActionInstant.extend({update:function(t){for(var e=this.target.getComponentsInChildren(cc._SGComponent),i=0;i<e.length;++i){e[i].enabled=!1}},reverse:function(){return new cc.Show},clone:function(){return new cc.Hide}}),cc.hide=function(){return new cc.Hide},cc.ToggleVisibility=cc.ActionInstant.extend({update:function(t){for(var e=this.target.getComponentsInChildren(cc._SGComponent),i=0;i<e.length;++i){var n=e[i];n.enabled=!n.enabled}},reverse:function(){return new cc.ToggleVisibility},clone:function(){return new cc.ToggleVisibility}}),cc.toggleVisibility=function(){return new cc.ToggleVisibility},cc.RemoveSelf=cc.ActionInstant.extend({_isNeedCleanUp:!0,ctor:function(t){cc.FiniteTimeAction.prototype.ctor.call(this),void 0!==t&&this.init(t)},update:function(t){this.target.removeFromParent(this._isNeedCleanUp)},init:function(t){return this._isNeedCleanUp=t,!0},reverse:function(){return new cc.RemoveSelf(this._isNeedCleanUp)},clone:function(){return new cc.RemoveSelf(this._isNeedCleanUp)}}),cc.removeSelf=function(t){return new cc.RemoveSelf(t)},cc.FlipX=cc.ActionInstant.extend({_flippedX:!1,ctor:function(t){cc.FiniteTimeAction.prototype.ctor.call(this),this._flippedX=!1,void 0!==t&&this.initWithFlipX(t)},initWithFlipX:function(t){return this._flippedX=t,!0},update:function(t){this.target.scaleX=Math.abs(this.target.scaleX)*(this._flippedX?-1:1)},reverse:function(){return new cc.FlipX(!this._flippedX)},clone:function(){var t=new cc.FlipX;return t.initWithFlipX(this._flippedX),t}}),cc.flipX=function(t){return new cc.FlipX(t)},cc.FlipY=cc.ActionInstant.extend({_flippedY:!1,ctor:function(t){cc.FiniteTimeAction.prototype.ctor.call(this),this._flippedY=!1,void 0!==t&&this.initWithFlipY(t)},initWithFlipY:function(t){return this._flippedY=t,!0},update:function(t){this.target.scaleY=Math.abs(this.target.scaleY)*(this._flippedY?-1:1)},reverse:function(){return new cc.FlipY(!this._flippedY)},clone:function(){var t=new cc.FlipY;return t.initWithFlipY(this._flippedY),t}}),cc.flipY=function(t){return new cc.FlipY(t)},cc.Place=cc.ActionInstant.extend({_x:0,_y:0,ctor:function(t,e){cc.FiniteTimeAction.prototype.ctor.call(this),this._x=0,this._y=0,void 0!==t&&(void 0!==t.x&&(e=t.y,t=t.x),this.initWithPosition(t,e))},initWithPosition:function(t,e){return this._x=t,this._y=e,!0},update:function(t){this.target.setPosition(this._x,this._y)},clone:function(){var t=new cc.Place;return t.initWithPosition(this._x,this._y),t}}),cc.place=function(t,e){return new cc.Place(t,e)},cc.CallFunc=cc.ActionInstant.extend({_selectorTarget:null,_function:null,_data:null,ctor:function(t,e,i){cc.FiniteTimeAction.prototype.ctor.call(this),this.initWithFunction(t,e,i)},initWithFunction:function(t,e,i){return t&&(this._function=t),e&&(this._selectorTarget=e),void 0!==i&&(this._data=i),!0},execute:function(){this._function&&this._function.call(this._selectorTarget,this.target,this._data)},update:function(t){this.execute()},getTargetCallback:function(){return this._selectorTarget},setTargetCallback:function(t){t!==this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=t)},clone:function(){var t=new cc.CallFunc;return t.initWithFunction(this._function,this._selectorTarget,this._data),t}}),cc.callFunc=function(t,e,i){return new cc.CallFunc(t,e,i)}}),{}],8:[(function(t,e,i){cc.ActionInterval=cc.FiniteTimeAction.extend({_elapsed:0,_firstTick:!1,_easeList:null,_timesForRepeat:1,_repeatForever:!1,_repeatMethod:!1,_speed:1,_speedMethod:!1,ctor:function(t){this._speed=1,this._timesForRepeat=1,this._repeatForever=!1,this.MAX_VALUE=2,this._repeatMethod=!1,this._speedMethod=!1,cc.FiniteTimeAction.prototype.ctor.call(this),void 0!==t&&this.initWithDuration(t)},getElapsed:function(){return this._elapsed},initWithDuration:function(t){return this._duration=0===t?cc.macro.FLT_EPSILON:t,this._elapsed=0,this._firstTick=!0,!0},isDone:function(){return this._elapsed>=this._duration},_cloneDecoration:function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},_reverseEaseList:function(t){if(this._easeList){t._easeList=[];for(var e=0;e<this._easeList.length;e++)t._easeList.push(this._easeList[e].reverse())}},clone:function(){var t=new cc.ActionInterval(this._duration);return this._cloneDecoration(t),t},easing:function(t){this._easeList?this._easeList.length=0:this._easeList=[];for(var e=0;e<arguments.length;e++)this._easeList.push(arguments[e]);return this},_computeEaseTime:function(t){var e=this._easeList;if(!e||0===e.length)return t;for(var i=0,n=e.length;i<n;i++)t=e[i].easing(t);return t},step:function(t){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=t;var e=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);e=1>e?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},startWithTarget:function(t){cc.Action.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},reverse:function(){return cc.logID(1010),null},setAmplitudeRate:function(t){cc.logID(1011)},getAmplitudeRate:function(){return cc.logID(1012),0},speed:function(t){return t<=0?(cc.logID(1013),this):(this._speedMethod=!0,this._speed*=t,this)},getSpeed:function(){return this._speed},setSpeed:function(t){return this._speed=t,this},repeat:function(t){return t=Math.round(t),isNaN(t)||t<1?(cc.logID(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},repeatForever:function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this}}),cc.actionInterval=function(t){return new cc.ActionInterval(t)},cc.Sequence=cc.ActionInterval.extend({_actions:null,_split:null,_last:0,_reversed:!1,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._actions=[];var e=t instanceof Array?t:arguments;if(1!==e.length){var i=e.length-1;if(i>=0&&null==e[i]&&cc.logID(1015),i>=0){for(var n,r=e[0],s=1;s<i;s++)e[s]&&(n=r,r=cc.Sequence._actionOneTwo(n,e[s]));this.initWithTwoActions(r,e[i])}}else cc.errorID(1019)},initWithTwoActions:function(t,e){if(!t||!e)throw new Error("cc.Sequence.initWithTwoActions(): arguments must all be non nil");var i=t._duration+e._duration;return this.initWithDuration(i),this._actions[0]=t,this._actions[1]=e,!0},clone:function(){var t=new cc.Sequence;return this._cloneDecoration(t),t.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._split=this._actions[0]._duration/this._duration,this._last=-1},stop:function(){-1!==this._last&&this._actions[this._last].stop(),cc.Action.prototype.stop.call(this)},update:function(t){var e,i,n=0,r=this._split,s=this._actions,o=this._last;(t=this._computeEaseTime(t))<r?(e=0!==r?t/r:1,0===n&&1===o&&this._reversed&&(s[1].update(0),s[1].stop())):(n=1,e=1===r?1:(t-r)/(1-r),-1===o&&(s[0].startWithTarget(this.target),s[0].update(1),s[0].stop()),0===o&&(s[0].update(1),s[0].stop())),i=s[n],o===n&&i.isDone()||(o!==n&&i.startWithTarget(this.target),e*=i._timesForRepeat,i.update(e>1?e%1:e),this._last=n)},reverse:function(){var t=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t}}),cc.sequence=function(t){var e=t instanceof Array?t:arguments;if(1===e.length)return cc.errorID(1019),null;var i=e.length-1;i>=0&&null==e[i]&&cc.logID(1015);var n=null;if(i>=0){n=e[0];for(var r=1;r<=i;r++)e[r]&&(n=cc.Sequence._actionOneTwo(n,e[r]))}return n},cc.Sequence._actionOneTwo=function(t,e){var i=new cc.Sequence;return i.initWithTwoActions(t,e),i},cc.Repeat=cc.ActionInterval.extend({_times:0,_total:0,_nextDt:0,_actionInstant:!1,_innerAction:null,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithAction(t,e)},initWithAction:function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof cc.ActionInstant&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},clone:function(){var t=new cc.Repeat;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},startWithTarget:function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,cc.ActionInterval.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},update:function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(t>=r){for(;t>r&&this._total<n;)e.update(1),this._total++,e.stop(),e.startWithTarget(this.target),r+=e._duration/i,this._nextDt=r;t>=1&&this._total<n&&(e.update(1),this._total++),this._actionInstant||(this._total===n?e.stop():e.update(t-(r-e._duration/i)))}else e.update(t*n%1)},isDone:function(){return this._total===this._times},reverse:function(){var t=new cc.Repeat(this._innerAction.reverse(),this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t},setInnerAction:function(t){this._innerAction!==t&&(this._innerAction=t)},getInnerAction:function(){return this._innerAction}}),cc.repeat=function(t,e){return new cc.Repeat(t,e)},cc.RepeatForever=cc.ActionInterval.extend({_innerAction:null,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._innerAction=null,t&&this.initWithAction(t)},initWithAction:function(t){if(!t)throw new Error("cc.RepeatForever.initWithAction(): action must be non null");return this._innerAction=t,!0},clone:function(){var t=new cc.RepeatForever;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},step:function(t){var e=this._innerAction;e.step(t),e.isDone()&&(e.startWithTarget(this.target),e.step(e.getElapsed()-e._duration))},isDone:function(){return!1},reverse:function(){var t=new cc.RepeatForever(this._innerAction.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},setInnerAction:function(t){this._innerAction!==t&&(this._innerAction=t)},getInnerAction:function(){return this._innerAction}}),cc.repeatForever=function(t){return new cc.RepeatForever(t)},cc.Spawn=cc.ActionInterval.extend({_one:null,_two:null,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._one=null,this._two=null;var e=t instanceof Array?t:arguments;if(1!==e.length){var i=e.length-1;if(i>=0&&null==e[i]&&cc.logID(1015),i>=0){for(var n,r=e[0],s=1;s<i;s++)e[s]&&(n=r,r=cc.Spawn._actionOneTwo(n,e[s]));this.initWithTwoActions(r,e[i])}}else cc.errorID(1020)},initWithTwoActions:function(t,e){if(!t||!e)throw new Error("cc.Spawn.initWithTwoActions(): arguments must all be non null");var i=!1,n=t._duration,r=e._duration;return this.initWithDuration(Math.max(n,r))&&(this._one=t,this._two=e,n>r?this._two=cc.Sequence._actionOneTwo(e,cc.delayTime(n-r)):n<r&&(this._one=cc.Sequence._actionOneTwo(t,cc.delayTime(r-n))),i=!0),i},clone:function(){var t=new cc.Spawn;return this._cloneDecoration(t),t.initWithTwoActions(this._one.clone(),this._two.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._one.startWithTarget(t),this._two.startWithTarget(t)},stop:function(){this._one.stop(),this._two.stop(),cc.Action.prototype.stop.call(this)},update:function(t){t=this._computeEaseTime(t),this._one&&this._one.update(t),this._two&&this._two.update(t)},reverse:function(){var t=cc.Spawn._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.spawn=function(t){var e=t instanceof Array?t:arguments;if(1===e.length)return cc.errorID(1020),null;e.length>0&&null==e[e.length-1]&&cc.logID(1015);for(var i=e[0],n=1;n<e.length;n++)null!=e[n]&&(i=cc.Spawn._actionOneTwo(i,e[n]));return i},cc.Spawn._actionOneTwo=function(t,e){var i=new cc.Spawn;return i.initWithTwoActions(t,e),i},cc.RotateTo=cc.ActionInterval.extend({_dstAngleX:0,_startAngleX:0,_diffAngleX:0,_dstAngleY:0,_startAngleY:0,_diffAngleY:0,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._dstAngleX=e||0,this._dstAngleY=void 0!==i?i:this._dstAngleX,!0)},clone:function(){var t=new cc.RotateTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._dstAngleX,this._dstAngleY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.rotationX%360,i=this._dstAngleX-e;i>180&&(i-=360),i<-180&&(i+=360),this._startAngleX=e,this._diffAngleX=i,this._startAngleY=t.rotationY%360;var n=this._dstAngleY-this._startAngleY;n>180&&(n-=360),n<-180&&(n+=360),this._diffAngleY=n},reverse:function(){cc.logID(1016)},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.rotationX=this._startAngleX+this._diffAngleX*t,this.target.rotationY=this._startAngleY+this._diffAngleY*t)}}),cc.rotateTo=function(t,e,i){return new cc.RotateTo(t,e,i)},cc.RotateBy=cc.ActionInterval.extend({_angleX:0,_startAngleX:0,_angleY:0,_startAngleY:0,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._angleX=e||0,this._angleY=void 0!==i?i:this._angleX,!0)},clone:function(){var t=new cc.RotateBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._angleX,this._angleY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startAngleX=t.rotationX,this._startAngleY=t.rotationY},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.rotationX=this._startAngleX+this._angleX*t,this.target.rotationY=this._startAngleY+this._angleY*t)},reverse:function(){var t=new cc.RotateBy(this._duration,-this._angleX,-this._angleY);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.rotateBy=function(t,e,i){return new cc.RotateBy(t,e,i)},cc.MoveBy=cc.ActionInterval.extend({_positionDelta:null,_startPosition:null,_previousPosition:null,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),this._positionDelta=cc.p(0,0),this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(void 0!==e.x&&(i=e.y,e=e.x),this._positionDelta.x=e,this._positionDelta.y=i,!0)},clone:function(){var t=new cc.MoveBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._positionDelta),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.getPositionX(),i=t.getPositionY();this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=this._positionDelta.x*t,i=this._positionDelta.y*t,n=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var r=this.target.getPositionX(),s=this.target.getPositionY(),o=this._previousPosition;n.x=n.x+r-o.x,n.y=n.y+s-o.y,e+=n.x,i+=n.y,o.x=e,o.y=i,this.target.setPosition(e,i)}else this.target.setPosition(n.x+e,n.y+i)}},reverse:function(){var t=new cc.MoveBy(this._duration,cc.p(-this._positionDelta.x,-this._positionDelta.y));return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.moveBy=function(t,e,i){return new cc.MoveBy(t,e,i)},cc.MoveTo=cc.MoveBy.extend({_endPosition:null,ctor:function(t,e,i){cc.MoveBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.MoveBy.prototype.initWithDuration.call(this,t,e,i)&&(void 0!==e.x&&(i=e.y,e=e.x),this._endPosition.x=e,this._endPosition.y=i,!0)},clone:function(){var t=new cc.MoveTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endPosition),t},startWithTarget:function(t){cc.MoveBy.prototype.startWithTarget.call(this,t),this._positionDelta.x=this._endPosition.x-t.getPositionX(),this._positionDelta.y=this._endPosition.y-t.getPositionY()}}),cc.moveTo=function(t,e,i){return new cc.MoveTo(t,e,i)},cc.SkewTo=cc.ActionInterval.extend({_skewX:0,_skewY:0,_startSkewX:0,_startSkewY:0,_endSkewX:0,_endSkewY:0,_deltaX:0,_deltaY:0,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),void 0!==i&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){var n=!1;return cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._endSkewX=e,this._endSkewY=i,n=!0),n},clone:function(){var t=new cc.SkewTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endSkewX,this._endSkewY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startSkewX=t.skewX%180,this._deltaX=this._endSkewX-this._startSkewX,this._deltaX>180&&(this._deltaX-=360),this._deltaX<-180&&(this._deltaX+=360),this._startSkewY=t.skewY%360,this._deltaY=this._endSkewY-this._startSkewY,this._deltaY>180&&(this._deltaY-=360),this._deltaY<-180&&(this._deltaY+=360)},update:function(t){t=this._computeEaseTime(t),this.target.skewX=this._startSkewX+this._deltaX*t,this.target.skewY=this._startSkewY+this._deltaY*t}}),cc.skewTo=function(t,e,i){return new cc.SkewTo(t,e,i)},cc.SkewBy=cc.SkewTo.extend({ctor:function(t,e,i){cc.SkewTo.prototype.ctor.call(this),void 0!==i&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){var n=!1;return cc.SkewTo.prototype.initWithDuration.call(this,t,e,i)&&(this._skewX=e,this._skewY=i,n=!0),n},clone:function(){var t=new cc.SkewBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._skewX,this._skewY),t},startWithTarget:function(t){cc.SkewTo.prototype.startWithTarget.call(this,t),this._deltaX=this._skewX,this._deltaY=this._skewY,this._endSkewX=this._startSkewX+this._deltaX,this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){var t=new cc.SkewBy(this._duration,-this._skewX,-this._skewY);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.skewBy=function(t,e,i){return new cc.SkewBy(t,e,i)},cc.JumpBy=cc.ActionInterval.extend({_startPosition:null,_delta:null,_height:0,_jumps:0,_previousPosition:null,ctor:function(t,e,i,n,r){cc.ActionInterval.prototype.ctor.call(this),this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),this._delta=cc.p(0,0),void 0!==n&&this.initWithDuration(t,e,i,n,r)},initWithDuration:function(t,e,i,n,r){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(void 0===r&&(r=n,n=i,i=e.y,e=e.x),this._delta.x=e,this._delta.y=i,this._height=n,this._jumps=r,!0)},clone:function(){var t=new cc.JumpBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._delta,this._height,this._jumps),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.getPositionX(),i=t.getPositionY();this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=t*this._jumps%1,i=4*this._height*e*(1-e);i+=this._delta.y*t;var n=this._delta.x*t,r=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var s=this.target.getPositionX(),o=this.target.getPositionY(),a=this._previousPosition;r.x=r.x+s-a.x,r.y=r.y+o-a.y,n+=r.x,i+=r.y,a.x=n,a.y=i,this.target.setPosition(n,i)}else this.target.setPosition(r.x+n,r.y+i)}},reverse:function(){var t=new cc.JumpBy(this._duration,cc.p(-this._delta.x,-this._delta.y),this._height,this._jumps);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.jumpBy=function(t,e,i,n,r){return new cc.JumpBy(t,e,i,n,r)},cc.JumpTo=cc.JumpBy.extend({_endPosition:null,ctor:function(t,e,i,n,r){cc.JumpBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==n&&this.initWithDuration(t,e,i,n,r)},initWithDuration:function(t,e,i,n,r){return!!cc.JumpBy.prototype.initWithDuration.call(this,t,e,i,n,r)&&(void 0===r&&(i=e.y,e=e.x),this._endPosition.x=e,this._endPosition.y=i,!0)},startWithTarget:function(t){cc.JumpBy.prototype.startWithTarget.call(this,t),this._delta.x=this._endPosition.x-this._startPosition.x,this._delta.y=this._endPosition.y-this._startPosition.y},clone:function(){var t=new cc.JumpTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endPosition,this._height,this._jumps),t}}),cc.jumpTo=function(t,e,i,n,r){return new cc.JumpTo(t,e,i,n,r)},cc.bezierAt=function(t,e,i,n,r){return Math.pow(1-r,3)*t+3*r*Math.pow(1-r,2)*e+3*Math.pow(r,2)*(1-r)*i+Math.pow(r,3)*n},cc.BezierBy=cc.ActionInterval.extend({_config:null,_startPosition:null,_previousPosition:null,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),this._config=[],this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._config=e,!0)},clone:function(){var t=new cc.BezierBy;this._cloneDecoration(t);for(var e=[],i=0;i<this._config.length;i++){var n=this._config[i];e.push(cc.p(n.x,n.y))}return t.initWithDuration(this._duration,e),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.getPositionX(),i=t.getPositionY();this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=this._config,i=e[0].x,n=e[1].x,r=e[2].x,s=e[0].y,o=e[1].y,a=e[2].y,c=cc.bezierAt(0,i,n,r,t),h=cc.bezierAt(0,s,o,a,t),l=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var u=this.target.getPositionX(),_=this.target.getPositionY(),d=this._previousPosition;l.x=l.x+u-d.x,l.y=l.y+_-d.y,c+=l.x,h+=l.y,d.x=c,d.y=h,this.target.setPosition(c,h)}else this.target.setPosition(l.x+c,l.y+h)}},reverse:function(){var t=this._config,e=[cc.pAdd(t[1],cc.pNeg(t[2])),cc.pAdd(t[0],cc.pNeg(t[2])),cc.pNeg(t[2])],i=new cc.BezierBy(this._duration,e);return this._cloneDecoration(i),this._reverseEaseList(i),i}}),cc.bezierBy=function(t,e){return new cc.BezierBy(t,e)},cc.BezierTo=cc.BezierBy.extend({_toConfig:null,ctor:function(t,e){cc.BezierBy.prototype.ctor.call(this),this._toConfig=[],e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._toConfig=e,!0)},clone:function(){var t=new cc.BezierTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toConfig),t},startWithTarget:function(t){cc.BezierBy.prototype.startWithTarget.call(this,t);var e=this._startPosition,i=this._toConfig,n=this._config;n[0]=cc.pSub(i[0],e),n[1]=cc.pSub(i[1],e),n[2]=cc.pSub(i[2],e)}}),cc.bezierTo=function(t,e){return new cc.BezierTo(t,e)},cc.ScaleTo=cc.ActionInterval.extend({_scaleX:1,_scaleY:1,_startScaleX:1,_startScaleY:1,_endScaleX:0,_endScaleY:0,_deltaX:0,_deltaY:0,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._endScaleX=e,this._endScaleY=null!=i?i:e,!0)},clone:function(){var t=new cc.ScaleTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endScaleX,this._endScaleY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startScaleX=t.scaleX,this._startScaleY=t.scaleY,this._deltaX=this._endScaleX-this._startScaleX,this._deltaY=this._endScaleY-this._startScaleY},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.scaleX=this._startScaleX+this._deltaX*t,this.target.scaleY=this._startScaleY+this._deltaY*t)}}),cc.scaleTo=function(t,e,i){return new cc.ScaleTo(t,e,i)},cc.ScaleBy=cc.ScaleTo.extend({startWithTarget:function(t){cc.ScaleTo.prototype.startWithTarget.call(this,t),this._deltaX=this._startScaleX*this._endScaleX-this._startScaleX,this._deltaY=this._startScaleY*this._endScaleY-this._startScaleY},reverse:function(){var t=new cc.ScaleBy(this._duration,1/this._endScaleX,1/this._endScaleY);return this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.ScaleBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endScaleX,this._endScaleY),t}}),cc.scaleBy=function(t,e,i){return new cc.ScaleBy(t,e,i)},cc.Blink=cc.ActionInterval.extend({_times:0,_originalState:!1,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._times=e,!0)},clone:function(){var t=new cc.Blink;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._times),t},update:function(t){if(t=this._computeEaseTime(t),this.target&&!this.isDone()){var e=1/this._times,i=t%e;this.target.opacity=i>e/2?255:0}},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._originalState=t.opacity},stop:function(){this.target.opacity=this._originalState,cc.ActionInterval.prototype.stop.call(this)},reverse:function(){var t=new cc.Blink(this._duration,this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.blink=function(t,e){return new cc.Blink(t,e)},cc.FadeTo=cc.ActionInterval.extend({_toOpacity:0,_fromOpacity:0,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._toOpacity=e,!0)},clone:function(){var t=new cc.FadeTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t},update:function(t){t=this._computeEaseTime(t);var e=void 0!==this._fromOpacity?this._fromOpacity:255;this.target.opacity=e+(this._toOpacity-e)*t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._fromOpacity=t.opacity}}),cc.fadeTo=function(t,e){return new cc.FadeTo(t,e)},cc.FadeIn=cc.FadeTo.extend({_reverseAction:null,ctor:function(t){cc.FadeTo.prototype.ctor.call(this),null==t&&(t=0),this.initWithDuration(t,255)},reverse:function(){var t=new cc.FadeOut;return t.initWithDuration(this._duration,0),this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.FadeIn;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t},startWithTarget:function(t){this._reverseAction&&(this._toOpacity=this._reverseAction._fromOpacity),cc.FadeTo.prototype.startWithTarget.call(this,t)}}),cc.fadeIn=function(t){return new cc.FadeIn(t)},cc.FadeOut=cc.FadeTo.extend({ctor:function(t){cc.FadeTo.prototype.ctor.call(this),null==t&&(t=0),this.initWithDuration(t,0)},reverse:function(){var t=new cc.FadeIn;return t._reverseAction=this,t.initWithDuration(this._duration,255),this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.FadeOut;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t}}),cc.fadeOut=function(t){return new cc.FadeOut(t)},cc.TintTo=cc.ActionInterval.extend({_to:null,_from:null,ctor:function(t,e,i,n){cc.ActionInterval.prototype.ctor.call(this),this._to=cc.color(0,0,0),this._from=cc.color(0,0,0),e instanceof cc.Color&&(n=e.b,i=e.g,e=e.r),void 0!==n&&this.initWithDuration(t,e,i,n)},initWithDuration:function(t,e,i,n){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._to=cc.color(e,i,n),!0)},clone:function(){var t=new cc.TintTo;this._cloneDecoration(t);var e=this._to;return t.initWithDuration(this._duration,e.r,e.g,e.b),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._from=this.target.color},update:function(t){t=this._computeEaseTime(t);var e=this._from,i=this._to;e&&this.target.setColor(cc.color(e.r+(i.r-e.r)*t,e.g+(i.g-e.g)*t,e.b+(i.b-e.b)*t))}}),cc.tintTo=function(t,e,i,n){return new cc.TintTo(t,e,i,n)},cc.TintBy=cc.ActionInterval.extend({_deltaR:0,_deltaG:0,_deltaB:0,_fromR:0,_fromG:0,_fromB:0,ctor:function(t,e,i,n){cc.ActionInterval.prototype.ctor.call(this),void 0!==n&&this.initWithDuration(t,e,i,n)},initWithDuration:function(t,e,i,n){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._deltaR=e,this._deltaG=i,this._deltaB=n,!0)},clone:function(){var t=new cc.TintBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.color;this._fromR=e.r,this._fromG=e.g,this._fromB=e.b},update:function(t){t=this._computeEaseTime(t),this.target.color=cc.color(this._fromR+this._deltaR*t,this._fromG+this._deltaG*t,this._fromB+this._deltaB*t)},reverse:function(){var t=new cc.TintBy(this._duration,-this._deltaR,-this._deltaG,-this._deltaB);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.tintBy=function(t,e,i,n){return new cc.TintBy(t,e,i,n)},cc.DelayTime=cc.ActionInterval.extend({update:function(t){},reverse:function(){var t=new cc.DelayTime(this._duration);return this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.DelayTime;return this._cloneDecoration(t),t.initWithDuration(this._duration),t}}),cc.delayTime=function(t){return new cc.DelayTime(t)},cc.ReverseTime=cc.ActionInterval.extend({_other:null,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._other=null,t&&this.initWithAction(t)},initWithAction:function(t){if(!t)throw new Error("cc.ReverseTime.initWithAction(): action must be non null");if(t===this._other)throw new Error("cc.ReverseTime.initWithAction(): the action was already passed in.");return!!cc.ActionInterval.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0)},clone:function(){var t=new cc.ReverseTime;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._other.startWithTarget(t)},update:function(t){t=this._computeEaseTime(t),this._other&&this._other.update(1-t)},reverse:function(){return this._other.clone()},stop:function(){this._other.stop(),cc.Action.prototype.stop.call(this)}}),cc.reverseTime=function(t){return new cc.ReverseTime(t)},cc.Animate=cc.ActionInterval.extend({_animation:null,_nextFrame:0,_origFrame:null,_executedLoops:0,_splitTimes:null,_currFrameIndex:0,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._splitTimes=[],t&&this.initWithAnimation(t)},getAnimation:function(){return this._animation},setAnimation:function(t){this._animation=t},getCurrentFrameIndex:function(){return this._currFrameIndex},initWithAnimation:function(t){if(!t)throw new Error("cc.Animate.initWithAnimation(): animation must be non-NULL");var e=t.getDuration();if(this.initWithDuration(e*t.getLoops())){this._nextFrame=0,this.setAnimation(t),this._origFrame=null,this._executedLoops=0;var i=this._splitTimes;i.length=0;var n=0,r=e/t.getTotalDelayUnits(),s=t.getFrames();cc.js.array.verifyType(s,cc.AnimationFrame);for(var o=0;o<s.length;o++){var a=n*r/e;n+=s[o].getDelayUnits(),i.push(a)}return!0}return!1},clone:function(){var t=new cc.Animate;return this._cloneDecoration(t),t.initWithAnimation(this._animation.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._animation.getRestoreOriginalFrame()&&(this._origFrame=t.getSpriteFrame()),this._nextFrame=0,this._executedLoops=0},update:function(t){if((t=this._computeEaseTime(t))<1){(0|(t*=this._animation.getLoops()))>this._executedLoops&&(this._nextFrame=0,this._executedLoops++),t%=1}for(var e=this._animation.getFrames(),i=e.length,n=this._splitTimes,r=this._nextFrame;r<i&&n[r]<=t;r++)_currFrameIndex=r,this.target.setSpriteFrame(e[_currFrameIndex].getSpriteFrame()),this._nextFrame=r+1},reverse:function(){var t=this._animation,e=t.getFrames(),i=[];if(cc.js.array.verifyType(e,cc.AnimationFrame),e.length>0)for(var n=e.length-1;n>=0;n--){var r=e[n];if(!r)break;i.push(r.clone())}var s=new cc.SpriteFrameAnimation(i,t.getDelayPerUnit(),t.getLoops());s.setRestoreOriginalFrame(t.getRestoreOriginalFrame());var o=new cc.Animate(s);return this._cloneDecoration(o),this._reverseEaseList(o),o},stop:function(){this._animation.getRestoreOriginalFrame()&&this.target&&this.target.setSpriteFrame(this._origFrame),cc.Action.prototype.stop.call(this)}}),cc.animate=function(t){return new cc.Animate(t)},cc.TargetedAction=cc.ActionInterval.extend({_action:null,_forcedTarget:null,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),e&&this.initWithTarget(t,e)},initWithTarget:function(t,e){return!!this.initWithDuration(e._duration)&&(this._forcedTarget=t,this._action=e,!0)},clone:function(){var t=new cc.TargetedAction;return this._cloneDecoration(t),t.initWithTarget(this._forcedTarget,this._action.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._action.startWithTarget(this._forcedTarget)},stop:function(){this._action.stop()},update:function(t){t=this._computeEaseTime(t),this._action.update(t)},getForcedTarget:function(){return this._forcedTarget},setForcedTarget:function(t){this._forcedTarget!==t&&(this._forcedTarget=t)}}),cc.targetedAction=function(t,e){return new cc.TargetedAction(t,e)}}),{}],9:[(function(t,e,i){cc.ActionManager=cc._Class.extend({_elementPool:[],_searchElementByTarget:function(t,e){for(var i=0;i<t.length;i++)if(e===t[i].target)return t[i];return null},ctor:function(){this._hashTargets={},this._arrayTargets=[],this._currentTarget=null},_getElement:function(t,e){var i=this._elementPool.pop();return i||(i=new function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.paused=!1,this.lock=!1}),i.target=t,i.paused=!!e,i},_putElement:function(t){t.actions.length=0,t.actionIndex=0,t.currentAction=null,t.paused=!1,t.target=null,t.lock=!1,this._elementPool.push(t)},addAction:function(t,e,i){if(!t)throw new Error("cc.ActionManager.addAction(): action must be non-null");if(!e)throw new Error("cc.ActionManager.addAction(): action must be non-null");var n=this._hashTargets[e.__instanceId];n?n.actions||(n.actions=[]):(n=this._getElement(e,i),this._hashTargets[e.__instanceId]=n,this._arrayTargets.push(n)),n.actions.push(t),t.startWithTarget(e)},removeAllActions:function(){for(var t=this._arrayTargets,e=0;e<t.length;e++){var i=t[e];i&&this.removeAllActionsFromTarget(i.target,!0)}},removeAllActionsFromTarget:function(t,e){if(null!=t){var i=this._hashTargets[t.__instanceId];i&&(i.actions.length=0,this._deleteHashElement(i))}},removeAction:function(t){if(null!=t){var e=t.getOriginalTarget(),i=this._hashTargets[e.__instanceId];if(i){for(var n=0;n<i.actions.length;n++)if(i.actions[n]===t){i.actions.splice(n,1),i.actionIndex>=n&&i.actionIndex--;break}}else cc.logID(1001)}},removeActionByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1002),cc.assertID(e,1003);var i=this._hashTargets[e.__instanceId];if(i)for(var n=i.actions.length,r=0;r<n;++r){var s=i.actions[r];if(s&&s.getTag()===t&&s.getOriginalTarget()===e){this._removeActionAtIndex(r,i);break}}},getActionByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1004);var i=this._hashTargets[e.__instanceId];if(i){if(null!=i.actions)for(var n=0;n<i.actions.length;++n){var r=i.actions[n];if(r&&r.getTag()===t)return r}cc.logID(1005,t)}return null},getNumberOfRunningActionsInTarget:function(t){var e=this._hashTargets[t.__instanceId];return e&&e.actions?e.actions.length:0},pauseTarget:function(t){var e=this._hashTargets[t.__instanceId];e&&(e.paused=!0)},resumeTarget:function(t){var e=this._hashTargets[t.__instanceId];e&&(e.paused=!1)},pauseAllRunningActions:function(){for(var t=[],e=this._arrayTargets,i=0;i<e.length;i++){var n=e[i];n&&!n.paused&&(n.paused=!0,t.push(n.target))}return t},resumeTargets:function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.resumeTarget(t[e])},pauseTargets:function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.pauseTarget(t[e])},purgeSharedManager:function(){cc.director.getScheduler().unscheduleUpdate(this)},_removeActionAtIndex:function(t,e){e.actions[t];e.actions.splice(t,1),e.actionIndex>=t&&e.actionIndex--,0===e.actions.length&&this._deleteHashElement(e)},_deleteHashElement:function(t){var e=!1;if(t&&!t.lock&&this._hashTargets[t.target.__instanceId]){delete this._hashTargets[t.target.__instanceId];for(var i=this._arrayTargets,n=0,r=i.length;n<r;n++)if(i[n]===t){i.splice(n,1);break}this._putElement(t),e=!0}return e},update:function(t){for(var e,i=this._arrayTargets,n=0;n<i.length;n++){if(this._currentTarget=i[n],!(e=this._currentTarget).paused&&e.actions){for(e.lock=!0,e.actionIndex=0;e.actionIndex<e.actions.length;e.actionIndex++)if(e.currentAction=e.actions[e.actionIndex],e.currentAction){if(e.currentAction.step(t*(e.currentAction._speedMethod?e.currentAction._speed:1)),e.currentAction&&e.currentAction.isDone()){e.currentAction.stop();var r=e.currentAction;e.currentAction=null,this.removeAction(r)}e.currentAction=null}e.lock=!1}0===e.actions.length&&this._deleteHashElement(e)&&n--}}})}),{}],10:[(function(t,e,i){t("./CCActionManager"),t("./CCAction"),t("./CCActionInterval"),t("./CCActionInstant"),t("./CCActionEase"),t("./CCActionCatmullRom")}),{"./CCAction":4,"./CCActionCatmullRom":5,"./CCActionEase":6,"./CCActionInstant":7,"./CCActionInterval":8,"./CCActionManager":9}],11:[(function(t,e,i){function n(t,e){o.call(this),this.target=t,this.animation=e,this._anims=new s.array.MutableForwardIterator([])}function r(t,e){function i(t){if(!Array.isArray(t))return!1;for(var e=0,i=t.length;e<i;e++){var n=t[e];if(!Array.isArray(n)||6!==n.length)return!1}return!0}function n(t,n,r){var o=t instanceof cc.Node&&"position"===n,l=[],u=new a;u.target=t;var _,f=n.indexOf(".");-1!==f?t[_=n.slice(0,f)]:_=n,u.prop=_,u.subProps=(function(t){var e=t.split(".");return e.shift(),e.length>0?e:null})(n);for(var p=0,m=r.length;p<m;p++){var g=r[p],y=g.frame/e.duration;if(u.ratios.push(y),o){var v=g.motionPath;v&&!i(v)&&(cc.errorID(3904,t.name,n,p),v=null),l.push(v)}var x=g.value;u.values.push(x);var C=g.curve;if(C){if("string"==typeof C){u.types.push(C);continue}if(Array.isArray(C)){C[0]===C[1]&&C[2]===C[3]?u.types.push(a.Linear):u.types.push(a.Bezier(C));continue}}u.types.push(a.Linear)}o&&h(l,u,s.duration,s.sample);for(var T,b,A=u.ratios,S=!0,w=1,E=A.length;w<E;w++)if(T=A[w]-A[w-1],1===w)b=T;else if(Math.abs(T-b)>1e-6){S=!1;break}return u._findFrameIndex=S?c:d,u}function r(t,e){var i=e.props,r=e.comps;if(i)for(var s in i){var a=n(t,s,i[s]);o.push(a)}if(r)for(var c in r){var h=t.getComponent(c);if(h){var l=r[c];for(var s in l){a=n(h,s,l[s]);o.push(a)}}}}var s=e.clip,o=e.curves;o.length=0,e.duration=s.duration,e.speed=s.speed,e.wrapMode=s.wrapMode,e.frameRate=s.sample,(e.wrapMode&_.Loop)===_.Loop?e.repeatCount=1/0:e.repeatCount=1;var f=s.curveData,p=f.paths;r(t,f);for(var m in p){var g=cc.find(m,t);if(g){r(g,p[m])}}var y=s.events;if(y)for(var v,x=0,C=y.length;x<C;x++){v||((v=new l).target=t,o.push(v));var T,b=y[x],A=b.frame/e.duration,S=d(v.ratios,A);S>=0?T=v.events[S]:(T=new u,v.ratios.push(A),v.events.push(T)),T.add(b.func,b.params)}}var s=cc.js,o=t("./playable"),a=t("./animation-curves").DynamicAnimCurve,c=t("./animation-curves").quickFindIndex,h=t("./motion-path-helper").sampleMotionPaths,l=t("./animation-curves").EventAnimCurve,u=t("./animation-curves").EventInfo,_=t("./types").WrapModeMask,d=t("../core/utils/binary-search").binarySearchEpsilon;s.extend(n,o);var f=n.prototype;f.playState=function(t,e){t.clip&&(t.curveLoaded||r(this.target,t),t.animator=this,t.play(),"number"==typeof e&&t.setTime(e),this.play())},f.stopStatesExcept=function(t){var e=this._anims,i=e.array;for(e.i=0;e.i<i.length;++e.i){var n=i[e.i];n!==t&&this.stopState(n)}},f.addAnimation=function(t){-1===this._anims.array.indexOf(t)&&this._anims.push(t),t._setListeners(this.animation)},f.removeAnimation=function(t){var e=this._anims.array.indexOf(t);e>=0?(this._anims.fastRemoveAt(e),0===this._anims.array.length&&this.stop()):cc.errorID(3908),t.animator=null},f.sample=function(){var t=this._anims,e=t.array;for(t.i=0;t.i<e.length;++t.i){e[t.i].sample()}},f.stopState=function(t){t&&t.stop()},f.pauseState=function(t){t&&t.pause()},f.resumeState=function(t){t&&t.resume(),this.isPaused&&this.resume()},f.setStateTime=function(t,e){if(void 0!==e)t&&(t.setTime(e),t.sample());else{e=t;for(var i=this._anims.array,n=0;n<i.length;++n){var r=i[n];r.setTime(e),r.sample()}}},f.onStop=function(){var t=this._anims,e=t.array;for(t.i=0;t.i<e.length;++t.i){e[t.i].stop()}},f.onPause=function(){for(var t=this._anims.array,e=0;e<t.length;++e){var i=t[e];i.pause(),i.animator=null}},f.onResume=function(){for(var t=this._anims.array,e=0;e<t.length;++e){var i=t[e];i.animator=this,i.resume()}},f._reloadClip=function(t){r(this.target,t)},e.exports=n}),{"../core/utils/binary-search":222,"./animation-curves":13,"./motion-path-helper":19,"./playable":20,"./types":21}],12:[(function(t,e,i){var n=cc.Class({name:"cc.AnimationClip",extends:cc.Asset,properties:{_duration:{default:0,type:"Float"},duration:{get:function(){return this._duration}},sample:{default:60},speed:{default:1},wrapMode:{default:cc.WrapMode.Normal},curveData:{default:{},visible:!1},events:{default:[],visible:!1}},statics:{createWithSpriteFrames:function(t,e){if(!Array.isArray(t))return cc.errorID(3905),null;var i=new n;i.sample=e||i.sample,i._duration=t.length/i.sample;for(var r=[],s=1/i.sample,o=0,a=t.length;o<a;o++)r[o]={frame:o*s,value:t[o]};return i.curveData={comps:{"cc.Sprite":{spriteFrame:r}}},i}}});cc.AnimationClip=e.exports=n}),{}],13:[(function(t,e,i){function n(t,e){if("string"==typeof e){var i=cc.Easing[e];i?t=i(t):cc.errorID(3906,e)}else Array.isArray(e)&&(t=r(e,t));return t}var r=t("./bezier").bezierByTime,s=t("../core/utils/binary-search").binarySearchEpsilon,o=t("./types").WrapModeMask,a=t("./types").WrappedInfo,c=cc.Class({name:"cc.AnimCurve",sample:function(t,e,i){},onTimeChangedManually:void 0}),h=cc.Class({name:"cc.DynamicAnimCurve",extends:c,properties:{target:null,prop:"",values:[],ratios:[],types:[],subProps:null},_findFrameIndex:s,sample:function(t,e,i){var r=this.values,s=this.ratios,o=s.length;if(0!==o){var a,c=this._findFrameIndex(s,e);if(c<0)if((c=~c)<=0)a=r[0];else if(c>=o)a=r[o-1];else{var h=r[c-1],l="number"==typeof h,u=h&&h.lerp;if(l||u){var _=s[c-1],d=s[c],f=this.types[c-1],p=(e-_)/(d-_);f&&(p=n(p,f));var m=r[c];l?a=h+(m-h)*p:u&&(a=h.lerp(m,p))}else a=h}else a=r[c];var g=this.subProps;if(g){for(var y=this.target[this.prop],v=y,x=0;x<g.length-1;x++){var C=g[x];if(!v)return;v=v[C]}var T=g[g.length-1];if(!v)return;v[T]=a,a=y}this.target[this.prop]=a}}});h.Linear=null,h.Bezier=function(t){return t};var l=function(){this.events=[]};l.prototype.add=function(t,e){this.events.push({func:t||"",params:e||[]})};var u=cc.Class({name:"cc.EventAnimCurve",extends:c,properties:{target:null,ratios:[],events:[],_wrappedInfo:{default:function(){return new a}},_lastWrappedInfo:null,_ignoreIndex:NaN},_wrapIterations:function(t){return t-(0|t)==0&&(t-=1),0|t},sample:function(t,e,i){var n=this.ratios.length,r=i.getWrappedInfo(i.time,this._wrappedInfo),c=r.direction,h=s(this.ratios,r.ratio);if(h<0&&(h=~h-1,c<0&&(h+=1)),this._ignoreIndex!==h&&(this._ignoreIndex=NaN),r.frameIndex=h,!this._lastWrappedInfo)return this._fireEvent(h),void(this._lastWrappedInfo=new a(r));var l=i.wrapMode,u=this._wrapIterations(r.iterations),_=this._lastWrappedInfo,d=this._wrapIterations(_.iterations),f=_.frameIndex,p=_.direction,m=-1!==d&&u!==d;if(f===h&&m&&1===n)this._fireEvent(0);else if(f!==h||m){c=p;do{if(f!==h){if(-1===c&&0===f&&h>0?((l&o.PingPong)===o.PingPong?c*=-1:f=n,d++):1===c&&f===n-1&&h<n-1&&((l&o.PingPong)===o.PingPong?c*=-1:f=-1,d++),f===h)break;if(d>u)break}f+=c,cc.director.getAnimationManager().pushDelayEvent(this,"_fireEvent",[f])}while(f!==h&&f>-1&&f<n)}this._lastWrappedInfo.set(r)},_fireEvent:function(t){if(!(t<0||t>=this.events.length||this._ignoreIndex===t)){var e=this.events[t].events;if(this.target.isValid)for(var i=this.target._components,n=0;n<e.length;n++)for(var r=e[n],s=r.func,o=0;o<i.length;o++){var a=i[o],c=a[s];c&&c.apply(a,r.params)}}},onTimeChangedManually:function(t,e){this._lastWrappedInfo=null,this._ignoreIndex=NaN;var i=e.getWrappedInfo(t,this._wrappedInfo),n=i.direction,r=s(this.ratios,i.ratio);r<0&&(r=~r-1,n<0&&(r+=1),this._ignoreIndex=r)}});e.exports={AnimCurve:c,DynamicAnimCurve:h,EventAnimCurve:u,EventInfo:l,computeRatioByType:n,quickFindIndex:function(t,e){var i=t.length-1;if(0===i)return 0;var n=t[0];if(e<n)return 0;var r=t[i];if(e>r)return i;var s=(e=(e-n)/(r-n))/(1/i),o=0|s;return s-o<1e-6?o:~(o+1)}}}),{"../core/utils/binary-search":222,"./bezier":16,"./types":21}],14:[(function(t,e,n){var r=cc.js,s=cc.Class({ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._anims=new r.array.MutableForwardIterator([]),this._delayEvents=[]},update:function(t){var e=this._anims,n=e.array;for(e.i=0;e.i<n.length;++e.i){var r=n[e.i];r._isPlaying&&!r._isPaused&&r.update(t)}var s=this._delayEvents;for(i=0,l=s.length;i<l;i++){var o=s[i];o.target[o.func].apply(o.target,o.args)}s.length=0},destruct:function(){},addAnimation:function(t){-1===this._anims.array.indexOf(t)&&this._anims.push(t)},removeAnimation:function(t){var e=this._anims.array.indexOf(t);e>=0?this._anims.fastRemoveAt(e):cc.errorID(3907)},pushDelayEvent:function(t,e,i){this._delayEvents.push({target:t,func:e,args:i})}});cc.AnimationManager=e.exports=s}),{}],15:[(function(t,e,i){function n(t,e){a.call(this),cc.EventTarget.call(this),this._currentFramePlayed=!1,this._delay=0,this._delayTime=0,this._wrappedInfo=new h,this._lastWrappedInfo=null,this._process=r,this._clip=t,this._name=e||t&&t.name,this.animator=null,this.curves=[],this.delay=0,this.repeatCount=1,this.duration=1,this.speed=1,this.wrapMode=l.Normal,this.time=0,this._emit=this.emit,this.emit=function(){for(var t=new Array(arguments.length),e=0,i=t.length;e<i;e++)t[e]=arguments[e];cc.director.getAnimationManager().pushDelayEvent(this,"_emit",t)}}function r(){var t=this.sample(),e=this._hasListenerCache;if(e&&e.lastframe){var i;i=this._lastWrappedInfo?this._lastWrappedInfo:this._lastWrappedInfo=new h(t),this.repeatCount>1&&(0|t.iterations)>(0|i.iterations)&&this.emit("lastframe",this),i.set(t)}t.stopped&&(this.stop(),this.emit("finished",this))}function s(){var t=this.time,e=this.duration;t>e?0===(t%=e)&&(t=e):t<0&&0!==(t%=e)&&(t+=e);for(var i=t/e,n=this.curves,r=0,s=n.length;r<s;r++){n[r].sample(t,i,this)}var o=this._hasListenerCache;o&&o.lastframe&&(void 0===this._lastIterations&&(this._lastIterations=i),(this.time>0&&this._lastIterations>i||this.time<0&&this._lastIterations<i)&&this.emit("lastframe",this),this._lastIterations=i)}var o=cc.js,a=t("./playable"),c=t("./types"),h=c.WrappedInfo,l=c.WrapMode,u=c.WrapModeMask;o.extend(n,a);var _=n.prototype;cc.js.mixin(_,cc.EventTarget.prototype),_._setListeners=function(t){this._capturingListeners=t?t._capturingListeners:null,this._bubblingListeners=t?t._bubblingListeners:null,this._hasListenerCache=t?t._hasListenerCache:null},_.onPlay=function(){this.setTime(0),this._delayTime=this._delay,cc.director.getAnimationManager().addAnimation(this),this.animator&&this.animator.addAnimation(this),this.emit("play",this)},_.onStop=function(){this.isPaused||cc.director.getAnimationManager().removeAnimation(this),this.animator&&this.animator.removeAnimation(this),this.emit("stop",this)},_.onResume=function(){cc.director.getAnimationManager().addAnimation(this),this.emit("resume",this)},_.onPause=function(){cc.director.getAnimationManager().removeAnimation(this),this.emit("pause",this)},_.setTime=function(t){this._currentFramePlayed=!1,this.time=t||0;for(var e=this.curves,i=0,n=e.length;i<n;i++){var r=e[i];r.onTimeChangedManually&&r.onTimeChangedManually(t,this)}},_.update=function(t){this._delayTime>0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this.speed:this._currentFramePlayed=!0,this._process())},_._needRevers=function(t){var e=this.wrapMode,i=!1;if((e&u.PingPong)===u.PingPong){t-(0|t)==0&&t>0&&(t-=1);1&t&&(i=!i)}return(e&u.Reverse)===u.Reverse&&(i=!i),i},_.getWrappedInfo=function(t,e){e=e||new h;var i=!1,n=this.duration,r=this.repeatCount,s=t>0?t/n:-t/n;if(s>=r){s=r,i=!0;var o=r-(0|r);0===o&&(o=1),t=o*n*(t>0?1:-1)}if(t>n){var a=t%n;t=0===a?n:a}else t<0&&0!==(t%=n)&&(t+=n);var c=!1,l=this._wrapMode&u.ShouldWrap;l&&(c=this._needRevers(s));var _=c?-1:1;return this.speed<0&&(_*=-1),l&&c&&(t=n-t),e.ratio=t/n,e.time=t,e.direction=_,e.stopped=i,e.iterations=s,e},_.sample=function(){for(var t=this.getWrappedInfo(this.time,this._wrappedInfo),e=this.curves,i=0,n=e.length;i<n;i++){e[i].sample(t.time,t.ratio,this)}return t},o.get(_,"clip",(function(){return this._clip})),o.get(_,"name",(function(){return this._name})),o.obsolete(_,"AnimationState.length","duration"),o.getset(_,"curveLoaded",(function(){return this.curves.length>0}),(function(){this.curves.length=0})),o.getset(_,"wrapMode",(function(){return this._wrapMode}),(function(t){this._wrapMode=t,this.time=0,t&u.Loop?this.repeatCount=1/0:this.repeatCount=1})),o.getset(_,"repeatCount",(function(){return this._repeatCount}),(function(t){this._repeatCount=t;var e=this._wrapMode&u.ShouldWrap,i=(this.wrapMode&u.Reverse)===u.Reverse;this._process=t!==1/0||e||i?r:s})),o.getset(_,"delay",(function(){return this._delay}),(function(t){this._delayTime=this._delay=t})),cc.AnimationState=e.exports=n}),{"./playable":20,"./types":21}],16:[(function(t,e,i){function n(t,e,i,n,r){var s=1-r;return t*s*s*s+3*e*s*s*r+3*i*s*r*r+n*r*r*r}function r(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function s(t,e){var i=(function(t,e){var i,n,s,u,_,d=e-0,f=e-t[0],p=3*d,m=3*f,g=3*(e-t[2]),y=1/(-d+m-g+(e-1)),v=(p-6*f+g)*y,x=v*(1/3),C=(-p+m)*y,T=1/3*(3*C-v*v),b=T*(1/3),A=(2*v*v*v-9*v*C+d*y*27)/27,S=A/2,w=S*S+b*b*b;if(w<0){var E=1/3*-T,I=l(E*E*E),R=-A/(2*I),P=a(R<-1?-1:R>1?1:R),O=2*r(I);return s=O*o(P*(1/3))-x,u=O*o((P+h)*(1/3))-x,_=O*o((P+2*h)*(1/3))-x,0<=s&&s<=1?0<=u&&u<=1?0<=_&&_<=1?c(s,u,_):c(s,u):0<=_&&_<=1?c(s,_):s:0<=u&&u<=1?0<=_&&_<=1?c(u,_):u:_}if(0===w)return i=S<0?r(-S):-r(S),s=2*i-x,u=-i-x,0<=s&&s<=1?0<=u&&u<=1?c(s,u):s:u;var B=l(w);return i=r(-S+B),n=r(S+B),s=i-n-x})(t,e),n=1-i;return 0*n*n*n+3*t[1]*i*n*n+3*t[3]*i*i*n+1*i*i*i}var o=Math.cos,a=Math.acos,c=Math.max,h=2*Math.PI,l=Math.sqrt;e.exports={bezier:n,bezierByTime:s}}),{}],17:[(function(t,e,i){function n(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}var r={constant:function(){return 0},linear:function(t){return t},quadIn:function(t){return t*t},quadOut:function(t){return t*(2-t)},quadInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quartIn:function(t){return t*t*t*t},quartOut:function(t){return 1- --t*t*t*t},quartInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quintIn:function(t){return t*t*t*t*t},quintOut:function(t){return--t*t*t*t*t+1},quintInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sineIn:function(t){return 1-Math.cos(t*Math.PI/2)},sineOut:function(t){return Math.sin(t*Math.PI/2)},sineInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},expoIn:function(t){return 0===t?0:Math.pow(1024,t-1)},expoOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},expoInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))},circIn:function(t){return 1-Math.sqrt(1-t*t)},circOut:function(t){return Math.sqrt(1- --t*t)},circInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},elasticOut:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},elasticInOut:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)},backIn:function(t){return t*t*(2.70158*t-1.70158)},backOut:function(t){return--t*t*(2.70158*t+1.70158)+1},backInOut:function(t){return(t*=2)<1?t*t*(3.5949095*t-2.5949095)*.5:.5*((t-=2)*t*(3.5949095*t+2.5949095)+2)},bounceOut:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},smooth:function(t){return t<=0?0:t>=1?1:t*t*(3-2*t)},fade:function(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}};r.quadOutIn=n(r.quadIn,r.quadOut),r.cubicOutIn=n(r.cubicIn,r.cubicOut),r.quartOutIn=n(r.quartIn,r.quartOut),r.quintOutIn=n(r.quintIn,r.quintOut),r.sineOutIn=n(r.sineIn,r.sineOut),r.expoOutIn=n(r.expoIn,r.expoOut),r.circOutIn=n(r.circIn,r.circOut),r.backOutIn=n(r.backIn,r.backOut),r.backOutIn=n(r.backIn,r.backOut),r.bounceIn=function(t){return 1-r.bounceOut(1-t)},r.bounceInOut=function(t){return t<.5?.5*r.bounceIn(2*t):.5*r.bounceOut(2*t-1)+.5},r.bounceOutIn=n(r.bounceIn,r.bounceOut),cc.Easing=e.exports=r}),{}],18:[(function(t,e,i){t("./bezier"),t("./easing"),t("./types"),t("./motion-path-helper"),t("./animation-curves"),t("./animation-clip"),t("./animation-manager"),t("./animation-state"),t("./animation-animator")}),{"./animation-animator":11,"./animation-clip":12,"./animation-curves":13,"./animation-manager":14,"./animation-state":15,"./bezier":16,"./easing":17,"./motion-path-helper":19,"./types":21}],19:[(function(t,e,i){function n(t){this.points=t||[],this.beziers=[],this.ratios=[],this.progresses=[],this.length=0,this.computeBeziers()}function r(){this.start=l(),this.end=l(),this.startCtrlPoint=l(),this.endCtrlPoint=l()}function s(t,e,i,r){function s(t){return t instanceof cc.Vec2?{in:t,pos:t,out:t}:Array.isArray(t)&&6===t.length?{in:l(t[2],t[3]),pos:l(t[0],t[1]),out:l(t[4],t[5])}:{in:cc.Vec2.ZERO,pos:cc.Vec2.ZERO,out:cc.Vec2.ZERO}}function c(t,e,i){f.push(t),p.push(e),m.push(i)}var u=e.values;if(0!==t.length&&0!==u.length)if(1!==(u=u.map((function(t){return l(t[0],t[1])}))).length){for(var _=e.types,d=e.ratios,f=e.values=[],p=e.types=[],m=e.ratios=[],g=0,y=o.Linear,v=0,x=t.length;v<x-1;v++){var C,T=t[v],b=d[v],A=d[v+1]-b,S=u[v],w=u[v+1],E=_[v],I=[],R=g/A,P=1/(A*i*r);if(T&&T.length>0){var O=[];O.push(s(S));for(var B=0,D=T.length;B<D;B++){var M=s(T[B]);O.push(M)}O.push(s(w));var L=new n(O);L.computeBeziers();for(var N=L.progresses;1-R>1e-6;){var F,k,z,V;if((C=a(C=R,E))<0)V=(0-C)*(k=L.beziers[0]).getLength(),z=k.start.sub(k.endCtrlPoint).normalize(),F=k.start.add(z.mul(V));else if(C>1)V=(C-1)*(k=L.beziers[L.beziers.length-1]).getLength(),z=k.end.sub(k.startCtrlPoint).normalize(),F=k.end.add(z.mul(V));else{var G=h(N,C);G<0&&(G=~G),C-=G>0?N[G-1]:0,C/=L.ratios[G],F=L.beziers[G].getPointAt(C)}I.push(F),R+=P}}else for(;1-R>1e-6;)C=a(C=R,E),I.push(S.lerp(w,C)),R+=P;y="constant"===E?E:o.Linear;for(B=0,D=I.length;B<D;B++){var W=b+g+P*B*A;c(I[B],y,W)}g=Math.abs(R-1)>1e-6?(R-1)*A:0}d[d.length-1]!==m[m.length-1]&&c(u[u.length-1],y,d[d.length-1])}else e.values=u}var o=t("./animation-curves").DynamicAnimCurve,a=t("./animation-curves").computeRatioByType,c=t("./bezier").bezier,h=t("../core/utils/binary-search").binarySearchEpsilon,l=cc.v2;n.prototype.computeBeziers=function(){this.beziers.length=0,this.ratios.length=0,this.progresses.length=0,this.length=0;for(var t,e=1;e<this.points.length;e++){var i=this.points[e-1],n=this.points[e];(t=new r).start=i.pos,t.startCtrlPoint=i.out,t.end=n.pos,t.endCtrlPoint=n.in,this.beziers.push(t),this.length+=t.getLength()}var s=0;for(e=0;e<this.beziers.length;e++)t=this.beziers[e],this.ratios[e]=t.getLength()/this.length,this.progresses[e]=s+=this.ratios[e];return this.beziers},r.prototype.getPointAt=function(t){var e=this.getUtoTmapping(t);return this.getPoint(e)},r.prototype.getPoint=function(t){var e=c(this.start.x,this.startCtrlPoint.x,this.endCtrlPoint.x,this.end.x,t),i=c(this.start.y,this.startCtrlPoint.y,this.endCtrlPoint.y,this.end.y,t);return new l(e,i)},r.prototype.getLength=function(){var t=this.getLengths();return t[t.length-1]},r.prototype.getLengths=function(t){if(t||(t=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===t+1)return this.cacheArcLengths;var e,i,n=[],r=this.getPoint(0),s=0;for(n.push(0),i=1;i<=t;i++)e=this.getPoint(i/t),s+=cc.pDistance(e,r),n.push(s),r=e;return this.cacheArcLengths=n,n},r.prototype.getUtoTmapping=function(t,e){var i,n=this.getLengths(),r=0,s=n.length;i=e||t*n[s-1];for(var o,a=0,c=s-1;a<=c;)if(r=Math.floor(a+(c-a)/2),(o=n[r]-i)<0)a=r+1;else{if(!(o>0)){c=r;break}c=r-1}if(r=c,n[r]===i){return r/(s-1)}var h=n[r];return(r+(i-h)/(n[r+1]-h))/(s-1)},e.exports={sampleMotionPaths:s,Curve:n,Bezier:r}}),{"../core/utils/binary-search":222,"./animation-curves":13,"./bezier":16}],20:[(function(t,e,i){function n(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var r=cc.js,s=n.prototype;r.get(s,"isPlaying",(function(){return this._isPlaying}),!0),r.get(s,"isPaused",(function(){return this._isPaused}),!0);var o=function(){};s.onPlay=o,s.onPause=o,s.onResume=o,s.onStop=o,s.onError=o,s.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError("already-playing"):(this._isPlaying=!0,this.onPlay())},s.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},s.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},s.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},s.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.exports=n}),{}],21:[(function(t,e,i){function n(t){t?this.set(t):(this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0)}cc.js;var r={Loop:2,ShouldWrap:4,PingPong:22,Reverse:36},s=cc.Enum({Default:0,Normal:1,Reverse:r.Reverse,Loop:r.Loop,LoopReverse:r.Loop|r.Reverse,PingPong:r.PingPong,PingPongReverse:r.PingPong|r.Reverse});cc.WrapMode=s,n.prototype.set=function(t){this.ratio=t.ratio,this.time=t.time,this.direction=t.direction,this.stopped=t.stopped,this.iterations=t.iterations,this.frameIndex=t.frameIndex},e.exports={WrapModeMask:r,WrapMode:s,WrappedInfo:n}}),{}],22:[(function(t,e,i){var n=t("../core/event/event-target"),r=t("../core/platform/CCSys"),s=!1,o=[],a=function(t){n.call(this),this._src=t,this._audioType=a.Type.UNKNOWN,this._element=null,this._eventList={},this._state=a.State.INITIALZING,this._loaded=!1,this._onended=function(){this.emit("ended")}.bind(this)};cc.js.extend(a,n),a.Type={DOM:"AUDIO",WEBAUDIO:"WEBAUDIO",NATIVE:"NATIVE",UNKNOWN:"UNKNOWN"},a.State={ERROR:-1,INITIALZING:0,PLAYING:1,PAUSED:2},(function(t){t.preload=function(){var t=this._src,e=this;if(!t)return this._src="",this._audioType=a.Type.UNKNOWN,this._element=null,this._state=a.State.INITIALZING,void(this._loaded=!1);var i=cc.loader.getItem(t);if(i||(i=cc.loader.getItem(t+"?useDom=1")),!i||!i.complete)return cc.loader.load(t,(function(i){if(!i){var n=cc.loader.getItem(t);e.mount(n.element||n.buffer),e.emit("load")}}));e.mount(i.element||i.buffer),e.emit("load")},t._bindEnded=function(t){t=t||this._onended,this._audioType===a.Type.DOM?this._element.addEventListener("ended",t):this._element.onended=t},t._unbindEnded=function(){this._audioType===a.Type.DOM?this._element.removeEventListener("ended",this._onended):this._element.onended=null},t.mount=function(t){r.platform===r.WECHAT_GAME||t instanceof HTMLElement?(this._element=document.createElement("audio"),this._element.src=t.src,this._audioType=a.Type.DOM):(this._element=new c(t,this),this._audioType=a.Type.WEBAUDIO),this._state=a.State.INITIALZING,this._loaded=!0},t.play=function(){this._element&&(this._bindEnded(),this._element.play(),this.emit("play"),this._state=a.State.PLAYING,r.platform!==r.WECHAT_GAME&&this._audioType===a.Type.DOM&&this._element.paused&&o.push({instance:this,offset:0,audio:this._element}),s||(s=!0,cc.game.canvas.addEventListener("touchstart",(function(){for(var t;t=o.pop();)t.audio.play(t.offset)}))))},t.destroy=function(){0},t.pause=function(){this._element&&(this._unbindEnded(),this._element.pause(),this.emit("pause"),this._state=a.State.PAUSED)},t.resume=function(){this._element&&0!==this._element.currentTime&&(this._bindEnded(),this._element.play(),this.emit("resume"),this._state=a.State.PLAYING)},t.stop=function(){if(this._element){try{this._element.currentTime=0}catch(t){}this._element.pause();for(var t=0;t<o.length;t++)if(o[t].instance===this){o.splice(t,1);break}this._unbindEnded(),this.emit("stop"),this._state=a.State.PAUSED}},t.setLoop=function(t){this._element&&(this._element.loop=t)},t.getLoop=function(){return this._element&&this._element.loop},t.setVolume=function(t){this._element&&(this._element.volume=t)},t.getVolume=function(){return this._element?this._element.volume:1},t.setCurrentTime=function(t){if(this._element){this._unbindEnded(),r.platform!==r.WECHAT_GAME&&this._bindEnded(function(){this._bindEnded()}.bind(this));try{this._element.currentTime=t}catch(n){var e=this._element;if(e.addEventListener){var i=function(){e.removeEventListener("loadedmetadata",i),e.currentTime=t};e.addEventListener("loadedmetadata",i)}}}},t.getCurrentTime=function(){return this._element?this._element.currentTime:0},t.getDuration=function(){return this._element?this._element.duration:0},t.getState=function(){var t=this._element;return a.State.PLAYING===this._state&&t.paused&&(this._state=a.State.PAUSED),this._state},t.__defineGetter__("src",(function(){return this._src})),t.__defineSetter__("src",(function(t){return this._src=t})),t.__defineGetter__("paused",(function(){return!this._element||this._element.paused}))})(a.prototype);var c=function(t,e){this._audio=e,this._context=r.__audioSupport.context,this._buffer=t,this._gainObj=this._context.createGain(),this._volume=1,this._gainObj.gain.setTargetAtTime?this._gainObj.gain.setTargetAtTime(this._volume,this._context.currentTime,.01):this._gainObj.gain.value=1,this._gainObj.connect(this._context.destination),this._loop=!1,this._startTime=-1,this._currentSource=null,this.playedLength=0,this._currextTimer=null,this._endCallback=function(){this.onended&&this.onended(this)}.bind(this)};(function(t){t.play=function(t){this._currentSource&&!this.paused&&(this._currentSource.onended=null,this._currentSource.stop(0),this.playedLength=0);var e=this._context.createBufferSource();e.buffer=this._buffer,e.connect(this._gainObj),e.loop=this._loop,this._startTime=this._context.currentTime,(t=t||this.playedLength)&&(this._startTime-=t);var i,n=this._buffer.duration,s=t;if(this._loop?e.start?e.start(0,s):e.notoGrainOn?e.noteGrainOn(0,s):e.noteOn(0,s):(i=n-t,e.start?e.start(0,s,i):e.notoGrainOn?e.noteGrainOn(0,s,i):e.noteOn(0,s,i)),this._currentSource=e,e.onended=this._endCallback,(!e.context.state||"suspended"===e.context.state)&&0===this._context.currentTime){var a=this;clearTimeout(this._currextTimer),this._currextTimer=setTimeout((function(){r.platform!==r.WECHAT_GAME&&0===a._context.currentTime&&o.push({instance:a._audio,offset:t,audio:a})}),10)}},t.pause=function(){if(clearTimeout(this._currextTimer),!this.paused){this.playedLength=this._context.currentTime-this._startTime,this.playedLength%=this._buffer.duration;var t=this._currentSource;this._currentSource=null,this._startTime=-1,t&&t.stop(0)}},t.__defineGetter__("paused",(function(){return(!this._currentSource||!this._currentSource.loop)&&(-1===this._startTime||this._context.currentTime-this._startTime>this._buffer.duration)})),t.__defineGetter__("loop",(function(){return this._loop})),t.__defineSetter__("loop",(function(t){return this._currentSource&&(this._currentSource.loop=t),this._loop=t})),t.__defineGetter__("volume",(function(){return this._volume})),t.__defineSetter__("volume",(function(t){return this._volume=t,this._gainObj.gain.setTargetAtTime?this._gainObj.gain.setTargetAtTime(this._volume,this._context.currentTime,.01):this._volume.gain.value=t,r.os===r.OS_IOS&&!this.paused&&this._currentSource&&(this._currentSource.onended=null,this.pause(),this.play()),t})),t.__defineGetter__("currentTime",(function(){return this.paused?this.playedLength:(this.playedLength=this._context.currentTime-this._startTime,this.playedLength%=this._buffer.duration,this.playedLength)})),t.__defineSetter__("currentTime",(function(t){return this.paused?this.playedLength=t:(this.pause(),this.playedLength=t,this.play()),t})),t.__defineGetter__("duration",(function(){return this._buffer.duration}))})(c.prototype),e.exports=cc.Audio=a}),{"../core/event/event-target":112,"../core/platform/CCSys":185}],23:[(function(t,e,i){var n=t("./CCAudio"),r=0,s={},o={},a=function(t){return s[t]},c={AudioState:n.State,_maxWebAudioSize:2097152,_maxAudioInstance:24,_id2audio:s,play:function(t,e,i){var a=(function(t){var e=r++,i=o[t];i||(i=o[t]=[]);var a;if(c._maxAudioInstance<=i.length){var h=i.shift(),l=s[h];l.stop(),l.destroy()}var u=function(){var t=this.instanceId;delete s[t];var e=i.indexOf(t);cc.js.array.fastRemoveAt(i,e)};return(a=new n(t)).on("ended",u),a.on("stop",u),s[e]=a,a.instanceId=e,i.push(e),a})(t),h=function(){a.setLoop(e||!1),("number"!=typeof i||isNaN(i))&&(i=1),a.setVolume(i),a.play()};return a.__callback=h,a.on("load",h),a.preload(),a.instanceId},setLoop:function(t,e){var i=a(t);i&&i.setLoop&&i.setLoop(e)},isLoop:function(t){var e=a(t);return!(!e||!e.isLoop)&&e.isLoop()},setVolume:function(t,e){var i=a(t);i&&(i._loaded||i.once("load",(function(){i.setVolume&&i.setVolume(e)})),i.setVolume&&i.setVolume(e))},getVolume:function(t){var e=a(t);return e&&e.getVolume?e.getVolume():1},setCurrentTime:function(t,e){var i=a(t);return!!i&&(i._loaded?(i.setCurrentTime&&i.setCurrentTime(e),!0):(i.once("load",(function(){i.setCurrentTime&&i.setCurrentTime(e)})),!0))},getCurrentTime:function(t){var e=a(t);return e&&e.getCurrentTime?e.getCurrentTime():0},getDuration:function(t){var e=a(t);return e&&e.getDuration?e.getDuration():0},getState:function(t){var e=a(t);return e&&e.getState?e.getState():this.AudioState.ERROR},setFinishCallback:function(t,e){var i=a(t);i&&(i.off("ended",i._finishCallback),i._finishCallback=e,i.on("ended",i._finishCallback))},pause:function(t){var e=a(t);return!(!e||!e.pause)&&(e.pause(),!0)},_pauseIDCache:[],pauseAll:function(){for(var t in s){var e=s[t];e.getState()===n.State.PLAYING&&(this._pauseIDCache.push(t),e.pause())}},resume:function(t){var e=a(t);if(!e||!e.resume)return!1;0===e.getCurrentTime()?e.play():e.resume()},resumeAll:function(){for(;this._pauseIDCache.length>0;){var t=this._pauseIDCache.pop(),e=a(t);e&&e.resume&&e.resume()}},stop:function(t){var e=a(t);return!(!e||!e.stop)&&(e.off("load",e.__callback),e.stop(),e.destroy(),!0)},stopAll:function(){for(var t in s){var e=s[t];e&&e.stop&&(e.stop(),e.destroy(),e.off("load",e.__callback))}},setMaxAudioInstance:function(t){return this._maxAudioInstance=t},getMaxAudioInstance:function(){return this._maxAudioInstance},uncache:function(t){var e=o[t];if(e)for(;e.length>0;){var i=e.pop(),n=s[i];n&&(n.stop(),n.destroy(),delete s[i])}},uncacheAll:function(){this.stopAll();for(var t in s){var e=s[t];e&&e.destroy()}s={},o={}},getProfile:function(t){},preload:function(t,e){cc.loader.load(t,e&&function(t){t||e()})},setMaxWebAudioSize:function(t){this._maxWebAudioSize=1024*t},_breakCache:null,_break:function(){this._breakCache=[];for(var t in s){var e=s[t];e.getState()===n.State.PLAYING&&(this._breakCache.push(t),e.pause())}},_restore:function(){if(this._breakCache){for(;this._breakCache.length>0;){var t=this._breakCache.pop(),e=a(t);e&&e.resume&&e.resume()}this._breakCache=null}}};e.exports=cc.audioEngine=c;var h=t("./deprecated");h.removed(c),h.deprecated(c)}),{"./CCAudio":22,"./deprecated":24}],24:[(function(t,e,i){var n=cc.js;i.removed=function(t){function e(){cc.errorID(1403)}n.getset(t,"willPlayMusic",e,e)},i.deprecated=function(t){var e=-1,i=1,r=1,s=[];n.get(t,"playMusic",(function(){return function(n,r){return t.stop(e),e=t.play(n,r,i),n,r,e}})),n.get(t,"stopMusic",(function(){return function(){return t.stop(e),e}})),n.get(t,"pauseMusic",(function(){return function(){return t.pause(e),e}})),n.get(t,"resumeMusic",(function(){return function(){return t.resume(e),e}})),n.get(t,"rewindMusic",(function(){return function(){return t.setCurrentTime(e,0),e}})),n.get(t,"getMusicVolume",(function(){return function(){return i}})),n.get(t,"setMusicVolume",(function(){return function(n){return i=n,t.setVolume(e,i),i}})),n.get(t,"isMusicPlaying",(function(){return function(){return t.getState(e)===t.AudioState.PLAYING}})),n.get(t,"playEffect",(function(){return function(e,i,n){return t.play(e,i||!1,void 0===n?r:n)}})),n.get(t,"setEffectsVolume",(function(i){return function(i){r=i;var n=t._id2audio;for(var s in n)s!==e&&t.setVolume(s,i)}})),n.get(t,"getEffectsVolume",(function(){return function(){return r}})),n.get(t,"pauseEffect",(function(){return function(e){return t.pause(e)}})),n.get(t,"pauseAllEffects",(function(){return function(){s.length=0;var i=t._id2audio;for(var n in i)if(n!==e){var r=i[n];r.getState()===t.AudioState.PLAYING&&(s.push(n),r.pause())}}})),n.get(t,"resumeEffect",(function(){return function(e){t.resume(e)}})),n.get(t,"resumeAllEffects",(function(){return function(){for(var e=t._id2audio;s.length>0;){var i=e[s.pop()];i&&i.resume&&i.resume()}}})),n.get(t,"stopEffect",(function(){return function(e){return t.stop(e)}})),n.get(t,"stopAllEffects",(function(){return function(){var i=t._id2audio;for(var n in i)if(n!==e){var r=i[n];r.getState()===t.AudioState.PLAYING&&r.stop()}}})),n.get(t,"unloadEffect",(function(){return function(e){return t.stop(e)}})),n.get(t,"end",(function(){return function(){return t.stopAll()}}))}}),{}],25:[(function(t,e,i){cc.ClippingNode=_ccsg.Node.extend({inverted:!1,_alphaThreshold:0,_stencil:null,_className:"ClippingNode",_originStencilProgram:null,ctor:function(t){t=t||null,_ccsg.Node.prototype.ctor.call(this),this._stencil=t,t&&(this._originStencilProgram=t.getShaderProgram()),this.alphaThreshold=1,this.inverted=!1,this._renderCmd.initStencilBits()},onEnter:function(){_ccsg.Node.prototype.onEnter.call(this),this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onEnter)},onEnterTransitionDidFinish:function(){_ccsg.Node.prototype.onEnterTransitionDidFinish.call(this),this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onEnterTransitionDidFinish)},onExitTransitionDidStart:function(){this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),_ccsg.Node.prototype.onExitTransitionDidStart.call(this)},onExit:function(){this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onExit),_ccsg.Node.prototype.onExit.call(this)},visit:function(t){this._renderCmd.clippingVisit(t&&t._renderCmd)},_visitChildren:function(){this._reorderChildDirty&&this.sortAllChildren();for(var t,e=this._children,i=0,n=e.length;i<n;i++)(t=e[i])&&t._visible&&t.visit(this);this._renderCmd._dirtyFlag=0},getAlphaThreshold:function(){return this._alphaThreshold},setAlphaThreshold:function(t){1===t&&t!==this._alphaThreshold&&this._renderCmd.resetProgramByStencil(),this._alphaThreshold=t},isInverted:function(){return this.inverted},setInverted:function(t){this.inverted=t},getStencil:function(){return this._stencil},setStencil:function(t){this._stencil!==t&&(t&&(this._originStencilProgram=t.getShaderProgram()),this._renderCmd.setStencil(t))},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ClippingNode.CanvasRenderCmd(this):new cc.ClippingNode.WebGLRenderCmd(this)}}),cc.ClippingNode.stencilBits=-1;var n=cc.ClippingNode.prototype;cc.defineGetterSetter(n,"stencil",n.getStencil,n.setStencil),cc.defineGetterSetter(n,"alphaThreshold",n.getAlphaThreshold,n.setAlphaThreshold)}),{}],26:[(function(t,e,i){t("../shape-nodes/CCDrawNode"),cc.ClippingNode.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!1,this._rendererClipCmd=new cc.CustomRenderCmd(this,this._drawStencilCommand),this._rendererRestoreCmd=new cc.CustomRenderCmd(this,this._restoreCmdCallback)};var n=cc.ClippingNode.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=cc.ClippingNode.CanvasRenderCmd,n.resetProgramByStencil=function(){},n.initStencilBits=function(){},n.setStencil=function(t){null!=t&&(this._node._stencil=t,t instanceof cc.DrawNode||cc.errorID(6300))},n._restoreCmdCallback=function(t){(t||cc._renderContext).restore()},n._drawStencilCommand=function(t,e,i){var n=t||cc._renderContext,r=n.getContext();n.save(),r.beginPath(),n.setTransform(this._worldTransform,e,i);for(var s=this._node._stencil._buffer,o=0;o<s.length;++o){var a=s[o].verts;if(!(a.length<3)){r.moveTo(a[0].x,-a[0].y);for(var c=1;c<a.length;++c)r.lineTo(a[c].x,-a[c].y)}}r.clip()},n.clippingVisit=function(t){var e=this._node;if(t=t||this.getParentRenderCmd(),this._propagateFlagsDown(t),e._visible){t&&(this._curLevel=t._curLevel+1),this._syncStatus(t),e._stencil&&cc.renderer.pushRenderCommand(this._rendererClipCmd);var i,n=e._children,r=n.length;if(r>0)for(e.sortAllChildren(),i=0;i<r;i++)n[i].visit(e);e._stencil&&cc.renderer.pushRenderCommand(this._rendererRestoreCmd),this._dirtyFlag=0}}}),{"../shape-nodes/CCDrawNode":275}],27:[(function(t,e,i){function n(t,e){t.shaderProgram=e;var i=t.children;if(i)for(var r=0;r<i.length;r++)n(i[r],e)}t("../core/CCDrawingPrimitives");var r={stencilEnabled:!1,depthWriteMask:!0};cc.ClippingNode.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!1,this._beforeVisitCmd=new cc.CustomRenderCmd(this,this._onBeforeVisit),this._afterDrawStencilCmd=new cc.CustomRenderCmd(this,this._onAfterDrawStencil),this._afterVisitCmd=new cc.CustomRenderCmd(this,this._onAfterVisit),this._previousState=null,this._state={stencilEnabled:!0,stencilWriteMask:0,depthWriteMask:!1,stencilFunc:0,stencilRef:0,stencilValueMask:0}};var s=cc.ClippingNode.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);s.constructor=cc.ClippingNode.WebGLRenderCmd,cc.ClippingNode.WebGLRenderCmd._init_once=null,cc.ClippingNode.WebGLRenderCmd._visit_once=null,cc.ClippingNode.WebGLRenderCmd._layer=-1,s.initStencilBits=function(){cc.ClippingNode.WebGLRenderCmd._init_once=!0,cc.ClippingNode.WebGLRenderCmd._init_once&&(cc.ClippingNode.stencilBits=cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS),cc.ClippingNode.stencilBits<=0&&cc.logID(6301),cc.ClippingNode.WebGLRenderCmd._init_once=!1)},s.transform=function(t,e){var i=this._node;this.originTransform(t,e),i._stencil&&(i._stencil._renderCmd.transform(this,!0),i._stencil._dirtyFlag&=~_ccsg.Node._dirtyFlags.transformDirty)},s.clippingVisit=function(t){var e=this._node;if(t=t||this.getParentRenderCmd(),this.visit(t),cc.ClippingNode.stencilBits<1)e._visitChildren();else if(e._stencil&&e._stencil.visible){if(cc.ClippingNode.WebGLRenderCmd._layer+1===cc.ClippingNode.stencilBits)return cc.ClippingNode.WebGLRenderCmd._visit_once=!0,cc.ClippingNode.WebGLRenderCmd._visit_once&&(cc.logID(6302,cc.ClippingNode.stencilBits),cc.ClippingNode.WebGLRenderCmd._visit_once=!1),void e._visitChildren();cc.renderer.pushRenderCommand(this._beforeVisitCmd),e._stencil.visit(e),cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);var i=e._children;if(i&&i.length>0){var n=i.length;e.sortAllChildren();for(var r=0;r<n;r++)i[r].visit(e)}cc.renderer.pushRenderCommand(this._afterVisitCmd),this._dirtyFlag=0}else e.inverted&&e._visitChildren()},s.setStencil=function(t){var e=this._node;e._stencil&&(e._stencil._parent=null),e._stencil=t,e._stencil&&(e._stencil._parent=e)},s._drawFullScreenQuadClearStencil=function(){var t=cc.math.projection_matrix_stack;t.push(),t.top.identity();var e=cc.math.modelview_matrix_stack;e.push(),e.top.identity(),cc._drawingUtil.drawSolidRect(cc.p(-1,-1),cc.p(1,1),cc.color(255,255,255,255)),t.pop(),e.pop()},s.resetProgramByStencil=function(){var t=this._node;if(t._stencil){var e=t._originStencilProgram;n(t._stencil,e)}},s._onBeforeVisit=function(t){var e=t||cc._renderContext,i=this._node;cc.ClippingNode.WebGLRenderCmd._layer++;var s=1<<cc.ClippingNode.WebGLRenderCmd._layer,o=s|s-1;if(this._previousState=r,e.enable(e.STENCIL_TEST),e.stencilMask(s),e.depthMask(!1),e.stencilFunc(e.NEVER,s,s),e.stencilOp(this._node.inverted?e.REPLACE:e.ZERO,e.KEEP,e.KEEP),this._drawFullScreenQuadClearStencil(),e.stencilFunc(e.NEVER,s,s),e.stencilOp(this._node.inverted?e.ZERO:e.REPLACE,e.KEEP,e.KEEP),i.alphaThreshold<1){var a=cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLORALPHATEST);cc.gl.useProgram(a.getProgram()),a.setUniformLocationWith1f(cc.macro.UNIFORM_ALPHA_TEST_VALUE_S,i.alphaThreshold),a.setUniformLocationWithMatrix4fv(cc.macro.UNIFORM_MVMATRIX_S,cc.renderer.mat4Identity.mat),n(i._stencil,a)}this._state.stencilWriteMask=s,this._state.stencilRef=this._state.stencilValueMask=o,this._state.stencilFunc=e.NEVER,r=this._state},s._onAfterDrawStencil=function(t){var e=t||cc._renderContext;e.depthMask(this._previousState.depthWriteMask),e.stencilFunc(e.EQUAL,this._state.stencilRef,this._state.stencilValueMask),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),this._state.stencilFunc=e.EQUAL},s._onAfterVisit=function(t){var e=t||cc._renderContext,i=this._previousState;i.stencilEnabled?(e.stencilFunc(i.stencilFunc,i.stencilRef,i.stencilValueMask),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.stencilMask(i.stencilWriteMask)):e.disable(e.STENCIL_TEST),r=this._previousState,this._previousState=null,cc.ClippingNode.WebGLRenderCmd._layer--}}),{"../core/CCDrawingPrimitives":36}],28:[(function(t,e,i){cc.Codec={name:"Jacob__Codec"},cc.Codec.Base64=t("./base64"),cc.Codec.GZip=t("./gzip"),cc.Codec.unzip=function(){return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,arguments)},cc.Codec.unzipBase64=function(){var t=cc.Codec.Base64.decode.apply(cc.Codec.Base64,arguments);try{return cc.Codec.GZip.gunzip.call(cc.Codec.GZip,t)}catch(e){return t.slice(7)}},cc.Codec.unzipBase64AsArray=function(t,e){e=e||1;var i,n,r,s=this.unzipBase64(t),o=[];for(i=0,r=s.length/e;i<r;i++)for(o[i]=0,n=e-1;n>=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},cc.Codec.unzipAsArray=function(t,e){e=e||1;var i,n,r,s=this.unzip(t),o=[];for(i=0,r=s.length/e;i<r;i++)for(o[i]=0,n=e-1;n>=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o}}),{"./base64":29,"./gzip":30}],29:[(function(t,e,i){var n=t("../core/utils/misc").BASE64_VALUES,r={name:"Jacob__Codec__Base64"};r.decode=function(t){var e,i,r,s,o,a,c=[],h=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<t.length;)e=n[t.charCodeAt(h++)]<<2|(s=n[t.charCodeAt(h++)])>>4,i=(15&s)<<4|(o=n[t.charCodeAt(h++)])>>2,r=(3&o)<<6|(a=n[t.charCodeAt(h++)]),c.push(String.fromCharCode(e)),64!==o&&c.push(String.fromCharCode(i)),64!==a&&c.push(String.fromCharCode(r));return c=c.join("")},r.decodeAsArray=function(t,e){var i,n,r,s=this.decode(t),o=[];for(i=0,r=s.length/e;i<r;i++)for(o[i]=0,n=e-1;n>=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},e.exports=r}),{"../core/utils/misc":226}],30:[(function(t,e,i){var n=function(t){this.data=t,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(n.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};n.gunzip=function(t){t.constructor===Array||(t.constructor,String);return new n(t).gunzip()[0][0]},n.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},n.LITERALS=288,n.NAMEMAX=256,n.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],n.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],n.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],n.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],n.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],n.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},n.prototype.readByte=function(){return this.bits+=8,this.bytepos<this.data.length?this.data.charCodeAt(this.bytepos++):-1},n.prototype.byteAlign=function(){this.bb=1},n.prototype.readBit=function(){var t;return this.bits++,t=1&this.bb,this.bb>>=1,0===this.bb&&(this.bb=this.readByte(),t=1&this.bb,this.bb=this.bb>>1|128),t},n.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=n.bitReverse[e]>>8-t),e},n.prototype.flushBuffer=function(){this.bIdx=0},n.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},n.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},n.prototype.Rec=function(){var t,e=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(t=this.IsPat())>=0)e.b0=t;else if(e.b0=32768,this.Rec())return-1;if((t=this.IsPat())>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=this.Places[this.treepos],e.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},n.prototype.CreateTree=function(t,e,i,n){var r;for(this.Places=t,this.treepos=0,this.flens=i,this.fmax=e,r=0;r<17;r++)this.fpos[r]=0;return this.len=0,this.Rec()?-1:0},n.prototype.DecodeValue=function(t){for(var e,i,n=0,r=t[n];;)if(this.readBit()){if(!(32768&r.b1))return r.b1;for(r=r.jump,e=t.length,i=0;i<e;i++)if(t[i]===r){n=i;break}}else{if(!(32768&r.b0))return r.b0;r=t[++n]}return-1},n.prototype.DeflateLoop=function(){var t,e,i;do{if(t=this.readBit(),0===(e=this.readBits(2))){var r,s;for(this.byteAlign(),r=this.readByte(),r|=this.readByte()<<8,s=this.readByte(),65535&(r^~(s|=this.readByte()<<8))&&document.write("BlockLen checksum mismatch\n");r--;)o=this.readByte(),this.addBuffer(o)}else if(1===e)for(;;)if((a=n.bitReverse[this.readBits(7)]>>1)>23?(a=a<<1|this.readBit())>199?a=(a-=128)<<1|this.readBit():(a-=48)>143&&(a+=136):a+=256,a<256)this.addBuffer(a);else{if(256===a)break;for(a-=257,p=this.readBits(n.cplext[a])+n.cplens[a],a=n.bitReverse[this.readBits(5)]>>3,n.cpdext[a]>8?(m=this.readBits(8),m|=this.readBits(n.cpdext[a]-8)<<8):m=this.readBits(n.cpdext[a]),m+=n.cpdist[a],a=0;a<p;a++){var o=this.buf32k[this.bIdx-m&32767];this.addBuffer(o)}}else if(2===e){var a,c,h,l,u,_=new Array(320);for(h=257+this.readBits(5),l=1+this.readBits(5),u=4+this.readBits(4),a=0;a<19;a++)_[a]=0;for(a=0;a<u;a++)_[n.border[a]]=this.readBits(3);for(p=this.distanceTree.length,i=0;i<p;i++)this.distanceTree[i]=new n.HufNode;if(this.CreateTree(this.distanceTree,19,_,0))return this.flushBuffer(),1;c=h+l,i=0;for(;i<c;)if(0,(a=this.DecodeValue(this.distanceTree))<16)_[i++]=a;else if(16===a){var d;if(a=3+this.readBits(2),i+a>c)return this.flushBuffer(),1;for(d=i?_[i-1]:0;a--;)_[i++]=d}else{if(a=17===a?3+this.readBits(3):11+this.readBits(7),i+a>c)return this.flushBuffer(),1;for(;a--;)_[i++]=0}for(p=this.literalTree.length,i=0;i<p;i++)this.literalTree[i]=new n.HufNode;if(this.CreateTree(this.literalTree,h,_,0))return this.flushBuffer(),1;for(p=this.literalTree.length,i=0;i<p;i++)this.distanceTree[i]=new n.HufNode;var f=new Array;for(i=h;i<_.length;i++)f[i-h]=_[i];if(this.CreateTree(this.distanceTree,l,f,0))return this.flushBuffer(),1;for(;;)if((a=this.DecodeValue(this.literalTree))>=256){var p,m;if(0==(a-=256))break;for(a--,p=this.readBits(n.cplext[a])+n.cplens[a],a=this.DecodeValue(this.distanceTree),n.cpdext[a]>8?(m=this.readBits(8),m|=this.readBits(n.cpdext[a]-8)<<8):m=this.readBits(n.cpdext[a]),m+=n.cpdist[a];p--;){o=this.buf32k[this.bIdx-m&32767];this.addBuffer(o)}}else this.addBuffer(a)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},n.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e<this.unzipped.length;e++)if(this.unzipped[e][1]===t)return this.unzipped[e][0]},n.prototype.nextFile=function(){this.outputArr=[],this.modeZIP=!1;var t=[];if(t[0]=this.readByte(),t[1]=this.readByte(),120===t[0]&&218===t[1]&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),"geonext.gxt"],this.files++),31===t[0]&&139===t[1]&&(this.skipdir(),this.unzipped[this.files]=[this.outputArr.join(""),"file"],this.files++),80===t[0]&&75===t[1]&&(this.modeZIP=!0,t[2]=this.readByte(),t[3]=this.readByte(),3===t[2]&&4===t[3])){t[0]=this.readByte(),t[1]=this.readByte(),this.gpflags=this.readByte(),this.gpflags|=this.readByte()<<8;var e=this.readByte();e|=this.readByte()<<8,this.readByte(),this.readByte(),this.readByte(),this.readByte();this.readByte();this.readByte()<<8,this.readByte()<<16,this.readByte()<<24;this.readByte();this.readByte()<<8,this.readByte()<<16,this.readByte()<<24;var i=this.readByte();i|=this.readByte()<<8;var r=this.readByte();for(r|=this.readByte()<<8,o=0,this.nameBuf=[];i--;){var s=this.readByte();"/"===s|":"===s?o=0:o<n.NAMEMAX-1&&(this.nameBuf[o++]=String.fromCharCode(s))}this.fileout||(this.fileout=this.nameBuf);for(var o=0;o<r;)s=this.readByte(),o++;8===e&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),this.nameBuf.join("")],this.files++),this.skipdir()}},n.prototype.skipdir=function(){var t,e,i,r,s=[];if(8&this.gpflags&&(s[0]=this.readByte(),s[1]=this.readByte(),s[2]=this.readByte(),s[3]=this.readByte(),t=this.readByte(),t|=this.readByte()<<8,t|=this.readByte()<<16,t|=this.readByte()<<24,e=this.readByte(),e|=this.readByte()<<8,e|=this.readByte()<<16,e|=this.readByte()<<24),this.modeZIP&&this.nextFile(),s[0]=this.readByte(),8!==s[0])return 0;if(this.gpflags=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),4&this.gpflags)for(s[0]=this.readByte(),s[2]=this.readByte(),this.len=s[0]+256*s[1],i=0;i<this.len;i++)this.readByte();if(8&this.gpflags)for(i=0,this.nameBuf=[];r=this.readByte();)"7"!==r&&":"!==r||(i=0),i<n.NAMEMAX-1&&(this.nameBuf[i++]=r);if(16&this.gpflags)for(;r=this.readByte(););2&this.gpflags&&(this.readByte(),this.readByte()),this.DeflateLoop(),e=this.readByte(),e|=this.readByte()<<8,e|=this.readByte()<<16,e|=this.readByte()<<24,this.modeZIP&&this.nextFile()},e.exports=n}),{}],31:[(function(t,e,i){(function(){"use strict";function t(t){throw t}function e(t,e){var i=t.split("."),n=v;!(i[0]in n)&&n.execScript&&n.execScript("var "+i[0]);for(var r;i.length&&(r=i.shift());)i.length||e===g?n=n[r]?n[r]:n[r]={}:n[r]=e}function i(t){if("string"==typeof t){var e,i,n=t.split("");for(e=0,i=n.length;e<i;e++)n[e]=(255&n[e].charCodeAt(0))>>>0;t=n}for(var r,s=1,o=0,a=t.length,c=0;0<a;){a-=r=1024<a?1024:a;do{o+=s+=t[c++]}while(--r);s%=65521,o%=65521}return(o<<16|s)>>>0}function n(e,i){this.index="number"==typeof i?i:0,this.i=0,this.buffer=e instanceof(x?Uint8Array:Array)?e:new(x?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}function r(t){this.buffer=new(x?Uint16Array:Array)(2*t),this.length=0}function s(t){var e,i,n,r,s,o,a,c,h,l=t.length,u=0,_=Number.POSITIVE_INFINITY;for(c=0;c<l;++c)t[c]>u&&(u=t[c]),t[c]<_&&(_=t[c]);for(e=1<<u,i=new(x?Uint32Array:Array)(e),n=1,r=0,s=2;n<=u;){for(c=0;c<l;++c)if(t[c]===n){for(o=0,a=r,h=0;h<n;++h)o=o<<1|1&a,a>>=1;for(h=o;h<e;h+=s)i[h]=n<<16|c;++r}++n,r<<=1,s<<=1}return[i,u,_]}function o(t,e){this.h=I,this.w=0,this.input=t,this.b=0,e&&(e.lazy&&(this.w=e.lazy),"number"==typeof e.compressionType&&(this.h=e.compressionType),e.outputBuffer&&(this.a=x&&e.outputBuffer instanceof Array?new Uint8Array(e.outputBuffer):e.outputBuffer),"number"==typeof e.outputIndex&&(this.b=e.outputIndex)),this.a||(this.a=new(x?Uint8Array:Array)(32768))}function a(t,e){this.length=t,this.G=e}function c(){var e=O;switch(y){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}function h(e,i){function n(e,i){var n,r=e.G,s=[],o=0;n=M[e.length],s[o++]=65535&n,s[o++]=n>>16&255,s[o++]=n>>24;var a;switch(y){case 1===r:a=[0,r-1,0];break;case 2===r:a=[1,r-2,0];break;case 3===r:a=[2,r-3,0];break;case 4===r:a=[3,r-4,0];break;case 6>=r:a=[4,r-5,1];break;case 8>=r:a=[5,r-7,1];break;case 12>=r:a=[6,r-9,2];break;case 16>=r:a=[7,r-13,2];break;case 24>=r:a=[8,r-17,3];break;case 32>=r:a=[9,r-25,3];break;case 48>=r:a=[10,r-33,4];break;case 64>=r:a=[11,r-49,4];break;case 96>=r:a=[12,r-65,5];break;case 128>=r:a=[13,r-97,5];break;case 192>=r:a=[14,r-129,6];break;case 256>=r:a=[15,r-193,6];break;case 384>=r:a=[16,r-257,7];break;case 512>=r:a=[17,r-385,7];break;case 768>=r:a=[18,r-513,8];break;case 1024>=r:a=[19,r-769,8];break;case 1536>=r:a=[20,r-1025,9];break;case 2048>=r:a=[21,r-1537,9];break;case 3072>=r:a=[22,r-2049,10];break;case 4096>=r:a=[23,r-3073,10];break;case 6144>=r:a=[24,r-4097,11];break;case 8192>=r:a=[25,r-6145,11];break;case 12288>=r:a=[26,r-8193,12];break;case 16384>=r:a=[27,r-12289,12];break;case 24576>=r:a=[28,r-16385,13];break;case 32768>=r:a=[29,r-24577,13];break;default:t("invalid distance")}n=a,s[o++]=n[0],s[o++]=n[1],s[o++]=n[2];var c,h;for(c=0,h=s.length;c<h;++c)p[m++]=s[c];C[s[0]]++,T[s[3]]++,v=e.length+i-1,_=null}var r,s,o,c,h,l,u,_,d,f={},p=x?new Uint16Array(2*i.length):[],m=0,v=0,C=new(x?Uint32Array:Array)(286),T=new(x?Uint32Array:Array)(30),b=e.w;if(!x){for(o=0;285>=o;)C[o++]=0;for(o=0;29>=o;)T[o++]=0}for(C[256]=1,r=0,s=i.length;r<s;++r){for(o=h=0,c=3;o<c&&r+o!==s;++o)h=h<<8|i[r+o];if(f[h]===g&&(f[h]=[]),l=f[h],!(0<v--)){for(;0<l.length&&32768<r-l[0];)l.shift();if(r+3>=s){for(_&&n(_,-1),o=0,c=s-r;o<c;++o)d=i[r+o],p[m++]=d,++C[d];break}if(0<l.length){var A=g,S=g,w=0,E=g,I=g,R=g,P=g,O=i.length;I=0,P=l.length;t:for(;I<P;I++){if(A=l[P-I-1],E=3,3<w){for(R=w;3<R;R--)if(i[A+R-1]!==i[r+R-1])continue t;E=w}for(;258>E&&r+E<O&&i[A+E]===i[r+E];)++E;if(E>w&&(S=A,w=E),258===E)break}u=new a(w,r-S),_?_.length<u.length?(d=i[r-1],p[m++]=d,++C[d],n(u,0)):n(_,-1):u.length<b?_=u:n(u,0)}else _?n(_,-1):(d=i[r],p[m++]=d,++C[d])}l.push(r)}return p[m++]=256,C[256]++,e.L=C,e.K=T,x?p.subarray(0,m):p}function l(t,e){function i(t){var e=b[t][A[t]];e===g?(i(t+1),i(t+1)):--C[e],++A[t]}var n,s,o,a,c,h=t.length,l=new r(572),u=new(x?Uint8Array:Array)(h);if(!x)for(a=0;a<h;a++)u[a]=0;for(a=0;a<h;++a)0<t[a]&&l.push(a,t[a]);if(n=Array(l.length/2),s=new(x?Uint32Array:Array)(l.length/2),1===n.length)return u[l.pop().index]=1,u;for(a=0,c=l.length/2;a<c;++a)n[a]=l.pop(),s[a]=n[a].value;var _,d,f,p,m,g=s.length,y=new(x?Uint16Array:Array)(e),v=new(x?Uint8Array:Array)(e),C=new(x?Uint8Array:Array)(g),T=Array(e),b=Array(e),A=Array(e),S=(1<<e)-g,w=1<<e-1;for(y[e-1]=g,d=0;d<e;++d)S<w?v[d]=0:(v[d]=1,S-=w),S<<=1,y[e-2-d]=(y[e-1-d]/2|0)+g;for(y[0]=v[0],T[0]=Array(y[0]),b[0]=Array(y[0]),d=1;d<e;++d)y[d]>2*y[d-1]+v[d]&&(y[d]=2*y[d-1]+v[d]),T[d]=Array(y[d]),b[d]=Array(y[d]);for(_=0;_<g;++_)C[_]=e;for(f=0;f<y[e-1];++f)T[e-1][f]=s[f],b[e-1][f]=f;for(_=0;_<e;++_)A[_]=0;for(1===v[e-1]&&(--C[0],++A[e-1]),d=e-2;0<=d;--d){for(p=_=0,m=A[d+1],f=0;f<y[d];f++)(p=T[d+1][m]+T[d+1][m+1])>s[_]?(T[d][f]=p,b[d][f]=g,m+=2):(T[d][f]=s[_],b[d][f]=_,++_);A[d]=0,1===v[d]&&i(d)}for(o=C,a=0,c=n.length;a<c;++a)u[n[a].index]=o[a];return u}function u(e){var i,n,r,s,o=new(x?Uint16Array:Array)(e.length),a=[],c=[],h=0;for(i=0,n=e.length;i<n;i++)a[e[i]]=1+(0|a[e[i]]);for(i=1,n=16;i<=n;i++)c[i]=h,(h+=0|a[i])>1<<i&&t("overcommitted"),h<<=1;for(65536>h&&t("undercommitted"),i=0,n=e.length;i<n;i++)for(h=c[e[i]],c[e[i]]+=1,r=o[i]=0,s=e[i];r<s;r++)o[i]=o[i]<<1|1&h,h>>>=1;return o}function _(t,e){this.input=t,this.a=new(x?Uint8Array:Array)(32768),this.h=L.j;var i,n={};!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType);for(i in e)n[i]=e[i];n.outputBuffer=this.a,this.z=new o(this.input,n)}function d(e,i){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=x?new Uint8Array(e):e,this.s=!1,this.m=F,this.B=!1,!i&&(i={})||(i.index&&(this.c=i.index),i.bufferSize&&(this.l=i.bufferSize),i.bufferType&&(this.m=i.bufferType),i.resize&&(this.B=i.resize)),this.m){case N:this.b=32768,this.a=new(x?Uint8Array:Array)(32768+this.l+258);break;case F:this.b=0,this.a=new(x?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}function f(e,i){for(var n,r=e.g,s=e.e,o=e.input,a=e.c;s<i;)(n=o[a++])===g&&t(Error("input buffer is broken")),r|=n<<s,s+=8;return n=r&(1<<i)-1,e.g=r>>>i,e.e=s-i,e.c=a,n}function p(e,i){for(var n,r,s,o=e.g,a=e.e,c=e.input,h=e.c,l=i[0],u=i[1];a<u;)(n=c[h++])===g&&t(Error("input buffer is broken")),o|=n<<a,a+=8;return r=l[o&(1<<u)-1],s=r>>>16,e.g=o>>s,e.e=a-s,e.c=h,65535&r}function m(e,i){var n,r;switch(this.input=e,this.c=0,!i&&(i={})||(i.index&&(this.c=i.index),i.verify&&(this.M=i.verify)),n=e[this.c++],r=e[this.c++],15&n){case ht:this.method=ht;break;default:t(Error("unsupported compression method"))}0!=((n<<8)+r)%31&&t(Error("invalid fcheck flag:"+((n<<8)+r)%31)),32&r&&t(Error("fdict flag is not supported")),this.A=new d(e,{index:this.c,bufferSize:i.bufferSize,bufferType:i.bufferType,resize:i.resize})}var g=void 0,y=!0,v=this,x="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;n.prototype.f=function(){var t,e=this.buffer,i=e.length,n=new(x?Uint8Array:Array)(i<<1);if(x)n.set(e);else for(t=0;t<i;++t)n[t]=e[t];return this.buffer=n},n.prototype.d=function(t,e,i){var n,r=this.buffer,s=this.index,o=this.i,a=r[s];if(i&&1<e&&(t=8<e?(w[255&t]<<24|w[t>>>8&255]<<16|w[t>>>16&255]<<8|w[t>>>24&255])>>32-e:w[t]>>8-e),8>e+o)a=a<<e|t,o+=e;else for(n=0;n<e;++n)a=a<<1|t>>e-n-1&1,8==++o&&(o=0,r[s++]=w[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.i=o,this.index=s},n.prototype.finish=function(){var t,e=this.buffer,i=this.index;return 0<this.i&&(e[i]<<=8-this.i,e[i]=w[e[i]],i++),x?t=e.subarray(0,i):(e.length=i,t=e),t};var C,T=new(x?Uint8Array:Array)(256);for(C=0;256>C;++C){for(var b=S=C,A=7,S=S>>>1;S;S>>>=1)b<<=1,b|=1&S,--A;T[C]=(b<<A&255)>>>0}var w=T;x&&new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]),r.prototype.getParent=function(t){return 2*((t-2)/4|0)},r.prototype.push=function(t,e){var i,n,r,s=this.buffer;for(i=this.length,s[this.length++]=e,s[this.length++]=t;0<i&&(n=this.getParent(i),s[i]>s[n]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return this.length},r.prototype.pop=function(){var t,e,i,n,r,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;!((n=2*r+2)>=this.length)&&(n+2<this.length&&s[n+2]>s[n]&&(n+=2),s[n]>s[r]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return{index:t,value:e,length:this.length}};var E,I=2,R={NONE:0,r:1,j:I,N:3},P=[];for(E=0;288>E;E++)switch(y){case 143>=E:P.push([E+48,8]);break;case 255>=E:P.push([E-144+400,9]);break;case 279>=E:P.push([E-256+0,7]);break;case 287>=E:P.push([E-280+192,8]);break;default:t("invalid literal: "+E)}o.prototype.n=function(){var e,i,r,s,o=this.input;switch(this.h){case 0:for(r=0,s=o.length;r<s;){var a=i=x?o.subarray(r,r+65535):o.slice(r,r+65535),c=(r+=i.length)===s,_=g,d=g,f=g,p=g,m=g,v=this.a,C=this.b;if(x){for(v=new Uint8Array(this.a.buffer);v.length<=C+a.length+5;)v=new Uint8Array(v.length<<1);v.set(this.a)}if(_=c?1:0,v[C++]=0|_,d=a.length,f=65536+~d&65535,v[C++]=255&d,v[C++]=d>>>8&255,v[C++]=255&f,v[C++]=f>>>8&255,x)v.set(a,C),C+=a.length,v=v.subarray(0,C);else{for(p=0,m=a.length;p<m;++p)v[C++]=a[p];v.length=C}this.b=C,this.a=v}break;case 1:var T=new n(new Uint8Array(this.a.buffer),this.b);T.d(1,1,y),T.d(1,2,y);var b,A,S,w=h(this,o);for(b=0,A=w.length;b<A;b++)if(S=w[b],n.prototype.d.apply(T,P[S]),256<S)T.d(w[++b],w[++b],y),T.d(w[++b],5),T.d(w[++b],w[++b],y);else if(256===S)break;this.a=T.finish(),this.b=this.a.length;break;case I:var E,R,O,B,D,M,L,N,F,k,z,V,G,W,U,j=new n(new Uint8Array(this.a),this.b),X=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Y=Array(19);for(E=I,j.d(1,1,y),j.d(E,2,y),R=h(this,o),L=u(M=l(this.L,15)),F=u(N=l(this.K,7)),O=286;257<O&&0===M[O-1];O--);for(B=30;1<B&&0===N[B-1];B--);var H,q,J,Z,Q,K,$=O,tt=B,et=new(x?Uint32Array:Array)($+tt),it=new(x?Uint32Array:Array)(316),nt=new(x?Uint8Array:Array)(19);for(H=q=0;H<$;H++)et[q++]=M[H];for(H=0;H<tt;H++)et[q++]=N[H];if(!x)for(H=0,Z=nt.length;H<Z;++H)nt[H]=0;for(H=Q=0,Z=et.length;H<Z;H+=q){for(q=1;H+q<Z&&et[H+q]===et[H];++q);if(J=q,0===et[H])if(3>J)for(;0<J--;)it[Q++]=0,nt[0]++;else for(;0<J;)(K=138>J?J:138)>J-3&&K<J&&(K=J-3),10>=K?(it[Q++]=17,it[Q++]=K-3,nt[17]++):(it[Q++]=18,it[Q++]=K-11,nt[18]++),J-=K;else if(it[Q++]=et[H],nt[et[H]]++,3>--J)for(;0<J--;)it[Q++]=et[H],nt[et[H]]++;else for(;0<J;)(K=6>J?J:6)>J-3&&K<J&&(K=J-3),it[Q++]=16,it[Q++]=K-3,nt[16]++,J-=K}for(e=x?it.subarray(0,Q):it.slice(0,Q),k=l(nt,7),W=0;19>W;W++)Y[W]=k[X[W]];for(D=19;4<D&&0===Y[D-1];D--);for(z=u(k),j.d(O-257,5,y),j.d(B-1,5,y),j.d(D-4,4,y),W=0;W<D;W++)j.d(Y[W],3,y);for(W=0,U=e.length;W<U;W++)if(V=e[W],j.d(z[V],k[V],y),16<=V){switch(W++,V){case 16:G=2;break;case 17:G=3;break;case 18:G=7;break;default:t("invalid code: "+V)}j.d(e[W],G,y)}var rt,st,ot,at,ct,ht,lt,ut,_t=[L,M],dt=[F,N];for(ct=_t[0],ht=_t[1],lt=dt[0],ut=dt[1],rt=0,st=R.length;rt<st;++rt)if(ot=R[rt],j.d(ct[ot],ht[ot],y),256<ot)j.d(R[++rt],R[++rt],y),at=R[++rt],j.d(lt[at],ut[at],y),j.d(R[++rt],R[++rt],y);else if(256===ot)break;this.a=j.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var O,B,D=[];for(O=3;258>=O;O++)B=c(),D[O]=B[2]<<24|B[1]<<16|B[0];var M=x?new Uint32Array(D):D,L=R;_.prototype.n=function(){var e,n,r,s,o,a,c,h=0;switch(c=this.a,e=ht){case ht:n=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(r=n<<4|e,c[h++]=r,e){case ht:switch(this.h){case L.NONE:o=0;break;case L.r:o=1;break;case L.j:o=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return s=o<<6|0,c[h++]=s|31-(256*r+s)%31,a=i(this.input),this.z.b=h,c=this.z.n(),h=c.length,x&&((c=new Uint8Array(c.buffer)).length<=h+4&&(this.a=new Uint8Array(c.length+4),this.a.set(c),c=this.a),c=c.subarray(0,h+4)),c[h++]=a>>24&255,c[h++]=a>>16&255,c[h++]=a>>8&255,c[h++]=255&a,c},e("Zlib.Deflate",_),e("Zlib.Deflate.compress",(function(t,e){return new _(t,e).n()})),e("Zlib.Deflate.CompressionType",L),e("Zlib.Deflate.CompressionType.NONE",L.NONE),e("Zlib.Deflate.CompressionType.FIXED",L.r),e("Zlib.Deflate.CompressionType.DYNAMIC",L.j);var N=0,F=1,k={D:N,C:F};d.prototype.p=function(){for(;!this.s;){var e=f(this,3);switch(1&e&&(this.s=y),e>>>=1){case 0:var i=this.input,n=this.c,r=this.a,o=this.b,a=g,c=g,h=g,l=r.length,u=g;switch(this.e=this.g=0,(a=i[n++])===g&&t(Error("invalid uncompressed block header: LEN (first byte)")),c=a,(a=i[n++])===g&&t(Error("invalid uncompressed block header: LEN (second byte)")),c|=a<<8,(a=i[n++])===g&&t(Error("invalid uncompressed block header: NLEN (first byte)")),h=a,(a=i[n++])===g&&t(Error("invalid uncompressed block header: NLEN (second byte)")),h|=a<<8,c===~h&&t(Error("invalid uncompressed block header: length verify")),n+c>i.length&&t(Error("input buffer is broken")),this.m){case N:for(;o+c>r.length;){if(u=l-o,c-=u,x)r.set(i.subarray(n,n+u),o),o+=u,n+=u;else for(;u--;)r[o++]=i[n++];this.b=o,r=this.f(),o=this.b}break;case F:for(;o+c>r.length;)r=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(x)r.set(i.subarray(n,n+c),o),o+=c,n+=c;else for(;c--;)r[o++]=i[n++];this.c=n,this.b=o,this.a=r;break;case 1:this.o(tt,it);break;case 2:(function(t){function e(t,e,i){var n,r,s,o;for(o=0;o<t;)switch(n=p(this,e)){case 16:for(s=3+f(this,2);s--;)i[o++]=r;break;case 17:for(s=3+f(this,3);s--;)i[o++]=0;r=0;break;case 18:for(s=11+f(this,7);s--;)i[o++]=0;r=0;break;default:r=i[o++]=n}return i}var i,n,r,o,a=f(t,5)+257,c=f(t,5)+1,h=f(t,4)+4,l=new(x?Uint8Array:Array)(W.length);for(o=0;o<h;++o)l[W[o]]=f(t,3);i=s(l),n=new(x?Uint8Array:Array)(a),r=new(x?Uint8Array:Array)(c),t.o(s(e.call(t,a,i,n)),s(e.call(t,c,i,r)))})(this);break;default:t(Error("unknown BTYPE: "+e))}}return this.t()};var z,V,G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],W=x?new Uint16Array(G):G,U=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],j=x?new Uint16Array(U):U,X=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],Y=x?new Uint8Array(X):X,H=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],q=x?new Uint16Array(H):H,J=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Z=x?new Uint8Array(J):J,Q=new(x?Uint8Array:Array)(288);for(z=0,V=Q.length;z<V;++z)Q[z]=143>=z?8:255>=z?9:279>=z?7:8;var K,$,tt=s(Q),et=new(x?Uint8Array:Array)(30);for(K=0,$=et.length;K<$;++K)et[K]=5;var it=s(et);d.prototype.o=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,c=i.length-258;256!==(r=p(this,t));)if(256>r)n>=c&&(this.b=n,i=this.f(),n=this.b),i[n++]=r;else for(a=j[s=r-257],0<Y[s]&&(a+=f(this,Y[s])),r=p(this,e),o=q[r],0<Z[r]&&(o+=f(this,Z[r])),n>=c&&(this.b=n,i=this.f(),n=this.b);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},d.prototype.I=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,c=i.length;256!==(r=p(this,t));)if(256>r)n>=c&&(i=this.f(),c=i.length),i[n++]=r;else for(a=j[s=r-257],0<Y[s]&&(a+=f(this,Y[s])),r=p(this,e),o=q[r],0<Z[r]&&(o+=f(this,Z[r])),n+a>c&&(i=this.f(),c=i.length);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},d.prototype.f=function(){var t,e,i=new(x?Uint8Array:Array)(this.b-32768),n=this.b-32768,r=this.a;if(x)i.set(r.subarray(32768,i.length));else for(t=0,e=i.length;t<e;++t)i[t]=r[t+32768];if(this.k.push(i),this.q+=i.length,x)r.set(r.subarray(n,n+32768));else for(t=0;32768>t;++t)r[t]=r[n+t];return this.b=32768,r},d.prototype.J=function(t){var e,i,n,r,s=this.input.length/this.c+1|0,o=this.input,a=this.a;return t&&("number"==typeof t.v&&(s=t.v),"number"==typeof t.F&&(s+=t.F)),2>s?(i=(o.length-this.c)/this.u[2],r=i/2*258|0,n=r<a.length?a.length+r:a.length<<1):n=a.length*s,x?(e=new Uint8Array(n)).set(a):e=a,this.a=e},d.prototype.t=function(){var t,e,i,n,r,s=0,o=this.a,a=this.k,c=new(x?Uint8Array:Array)(this.q+(this.b-32768));if(0===a.length)return x?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(e=0,i=a.length;e<i;++e)for(n=0,r=(t=a[e]).length;n<r;++n)c[s++]=t[n];for(e=32768,i=this.b;e<i;++e)c[s++]=o[e];return this.k=[],this.buffer=c},d.prototype.H=function(){var t,e=this.b;return x?this.B?(t=new Uint8Array(e)).set(this.a.subarray(0,e)):t=this.a.subarray(0,e):(this.a.length>e&&(this.a.length=e),t=this.a),this.buffer=t},m.prototype.p=function(){var e,n=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&(n[this.c++]<<24|n[this.c++]<<16|n[this.c++]<<8|n[this.c++])>>>0!==i(e)&&t(Error("invalid adler-32 checksum")),e},e("Zlib.Inflate",m),e("Zlib.Inflate.BufferType",k),k.ADAPTIVE=k.C,k.BLOCK=k.D,e("Zlib.Inflate.prototype.decompress",m.prototype.p);x&&new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);x&&new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]);x&&new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]);x&&new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]);x&&new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]);var nt,rt,st=new(x?Uint8Array:Array)(288);for(nt=0,rt=st.length;nt<rt;++nt)st[nt]=143>=nt?8:255>=nt?9:279>=nt?7:8;s(st);var ot,at,ct=new(x?Uint8Array:Array)(30);for(ot=0,at=ct.length;ot<at;++ot)ct[ot]=5;s(ct);var ht=8}).call(window);var n=window.Zlib;n.Deflate=n.Deflate,n.Deflate.compress=n.Deflate.compress,n.Inflate=n.Inflate,n.Inflate.BufferType=n.Inflate.BufferType,n.Inflate.prototype.decompress=n.Inflate.prototype.decompress,e.exports=n}),{}],32:[(function(t,e,i){cc.configuration={ERROR:0,STRING:1,INT:2,DOUBLE:3,BOOLEAN:4,_maxTextureSize:0,_maxModelviewStackDepth:0,_supportsPVRTC:!1,_supportsNPOT:!1,_supportsBGRA8888:!1,_supportsDiscardFramebuffer:!1,_supportsShareableVAO:!1,_maxSamplesAllowed:0,_maxTextureUnits:0,_GlExtensions:"",_valueDict:{},_inited:!1,_init:function(){var t=this._valueDict;t["cocos2d.x.version"]=cc.ENGINE_VERSION,t["cocos2d.x.compiled_with_profiler"]=!1,t["cocos2d.x.compiled_with_gl_state_cache"]=cc.macro.ENABLE_GL_STATE_CACHE,this._inited=!0},getMaxTextureSize:function(){return this._maxTextureSize},getMaxModelviewStackDepth:function(){return this._maxModelviewStackDepth},getMaxTextureUnits:function(){return this._maxTextureUnits},supportsNPOT:function(){return this._supportsNPOT},supportsPVRTC:function(){return this._supportsPVRTC},supportsETC:function(){return!1},supportsS3TC:function(){return!1},supportsATITC:function(){return!1},supportsBGRA8888:function(){return this._supportsBGRA8888},supportsDiscardFramebuffer:function(){return this._supportsDiscardFramebuffer},supportsShareableVAO:function(){return this._supportsShareableVAO},checkForGLExtension:function(t){return this._GlExtensions.indexOf(t)>-1},getValue:function(t,e){this._inited||this._init();var i=this._valueDict;return i[t]?i[t]:e},setValue:function(t,e){this._valueDict[t]=e},gatherGPUInfo:function(){if(cc._renderType!==cc.game.RENDER_TYPE_CANVAS){this._inited||this._init();var t=cc._renderContext,e=this._valueDict;e["gl.vendor"]=t.getParameter(t.VENDOR),e["gl.renderer"]=t.getParameter(t.RENDERER),e["gl.version"]=t.getParameter(t.VERSION),this._GlExtensions="";for(var i=t.getSupportedExtensions(),n=0;n<i.length;n++)this._GlExtensions+=i[n]+" ";this._maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),e["gl.max_texture_size"]=this._maxTextureSize,this._maxTextureUnits=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),e["gl.max_texture_units"]=this._maxTextureUnits,this._supportsPVRTC=this.checkForGLExtension("GL_IMG_texture_compression_pvrtc"),e["gl.supports_PVRTC"]=this._supportsPVRTC,this._supportsNPOT=!0,e["gl.supports_NPOT"]=this._supportsNPOT,this._supportsBGRA8888=this.checkForGLExtension("GL_IMG_texture_format_BGRA888"),e["gl.supports_BGRA8888"]=this._supportsBGRA8888,this._supportsDiscardFramebuffer=this.checkForGLExtension("GL_EXT_discard_framebuffer"),e["gl.supports_discard_framebuffer"]=this._supportsDiscardFramebuffer,this._supportsShareableVAO=this.checkForGLExtension("vertex_array_object"),e["gl.supports_vertex_array_object"]=this._supportsShareableVAO,cc.checkGLErrorDebug()}},loadConfigFile:function(t){this._inited||this._init();var e=cc.loader.getRes(t);if(!e)throw new Error("Please load the resource first : "+t);cc.assertID(e,1101,t);var i=e.data;if(i)for(var n in i)this._valueDict[n]=i[n];else cc.logID(1100,t)}}}),{}],33:[(function(t,e,i){var n=t("./event/event-target"),r=t("./platform/_CCClass"),s=t("./load-pipeline/auto-release-utils"),o=t("./component-scheduler"),a=t("./node-activator"),c=t("./event/event-listeners"),h=t("./event-manager");cc.g_NumberOfDraws=0,cc.Director=r.extend({ctor:function(){var t=this;n.call(t),t._landscape=!1,t._nextDeltaTimeZero=!1,t._paused=!1,t._purgeDirectorInNextLoop=!1,t._sendCleanupToScene=!1,t._animationInterval=0,t._oldAnimationInterval=0,t._projection=0,t._projectionDelegate=null,t._contentScaleFactor=1,t._winSizeInPoints=null,t._openGLView=null,t._scenesStack=null,t._nextScene=null,t._loadingScene="",t._runningScene=null,t._scene=null,t._totalFrames=0,t._lastUpdate=Date.now(),t._deltaTime=0,t._dirtyRegion=null,t._scheduler=null,t._compScheduler=null,t._nodeActivator=null,t._actionManager=null,cc.game.on(cc.game.EVENT_SHOW,(function(){t._lastUpdate=Date.now()}))},init:function(){return this._oldAnimationInterval=this._animationInterval=1/cc.defaultFPS,this._scenesStack=[],this._projection=cc.Director.PROJECTION_DEFAULT,this._projectionDelegate=null,this._totalFrames=0,this._lastUpdate=Date.now(),this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=cc.size(0,0),this._openGLView=null,this._contentScaleFactor=1,this._scheduler=new cc.Scheduler,cc.ActionManager?(this._actionManager=new cc.ActionManager,this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1)):this._actionManager=null,this.sharedInit(),!0},sharedInit:function(){this._compScheduler=new o,this._nodeActivator=new a,cc.AnimationManager?(this._animationManager=new cc.AnimationManager,this._scheduler.scheduleUpdate(this._animationManager,cc.Scheduler.PRIORITY_SYSTEM,!1)):this._animationManager=null,cc.CollisionManager?(this._collisionManager=new cc.CollisionManager,this._scheduler.scheduleUpdate(this._collisionManager,cc.Scheduler.PRIORITY_SYSTEM,!1)):this._collisionManager=null,cc.PhysicsManager?(this._physicsManager=new cc.PhysicsManager,this._scheduler.scheduleUpdate(this._physicsManager,cc.Scheduler.PRIORITY_SYSTEM,!1)):this._physicsManager=null,cc._widgetManager&&cc._widgetManager.init(this),cc.loader.init(this)},calculateDeltaTime:function(){var t=Date.now();this._nextDeltaTimeZero?(this._deltaTime=0,this._nextDeltaTimeZero=!1):(this._deltaTime=(t-this._lastUpdate)/1e3,cc.game.config[cc.game.CONFIG_KEY.debugMode]>0&&this._deltaTime>1&&(this._deltaTime=1/60)),this._lastUpdate=t},convertToGL:function(t){var e=cc.game.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,o=i._devicePixelRatio*(t.x-r),a=i._devicePixelRatio*(s+n.height-t.y);return i._isRotated?{x:i._viewPortRect.width-a,y:o}:{x:o,y:a}},convertToUI:function(t){var e=cc.game.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,o={x:0,y:0};return i._isRotated?(o.x=r+t.y/i._devicePixelRatio,o.y=s+n.height-(i._viewPortRect.width-t.x)/i._devicePixelRatio):(o.x=r+t.x*i._devicePixelRatio,o.y=s+n.height-t.y*i._devicePixelRatio),o},_visitScene:function(){if(this._runningScene){var t=cc.renderer;t.childrenOrderDirty?(t.clearRenderCommands(),cc.renderer.assignedZ=0,this._runningScene._renderCmd._curLevel=0,this._runningScene.visit(),t.resetFlag()):t.transformDirty()&&t.transform()}},end:function(){this._purgeDirectorInNextLoop=!0},getContentScaleFactor:function(){return this._contentScaleFactor},getWinSize:function(){return cc.size(this._winSizeInPoints)},getWinSizeInPixels:function(){return cc.size(this._winSizeInPoints.width*this._contentScaleFactor,this._winSizeInPoints.height*this._contentScaleFactor)},getVisibleSize:null,getVisibleOrigin:null,getZEye:null,pause:function(){this._paused||(this._oldAnimationInterval=this._animationInterval,this.setAnimationInterval(.25),this._paused=!0)},popScene:function(){cc.assertID(this._runningScene,1204),this._scenesStack.pop();var t=this._scenesStack.length;0===t?this.end():(this._sendCleanupToScene=!0,this._nextScene=this._scenesStack[t-1])},purgeCachedData:function(){cc.textureCache._clear(),cc.loader.releaseAll()},purgeDirector:function(){this.getScheduler().unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),h&&h.setEnabled(!1),this._runningScene&&(this._runningScene.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),this._runningScene.performRecursive(_ccsg.Node.performType.onExit),this._runningScene.performRecursive(_ccsg.Node.performType.cleanup),cc.renderer.clearRenderCommands()),this._runningScene=null,this._nextScene=null,this._scenesStack.length=0,this.stopAnimation(),this.purgeCachedData()},reset:function(){this.purgeDirector(),h&&h.setEnabled(!0),this._actionManager&&this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._animationManager&&this._scheduler.scheduleUpdate(this._animationManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._collisionManager&&this._scheduler.scheduleUpdate(this._collisionManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._physicsManager&&this._scheduler.scheduleUpdate(this._physicsManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this.startAnimation()},pushScene:function(t){cc.assertID(t,1205),this._sendCleanupToScene=!1,this._scenesStack.push(t),this._nextScene=t},runSceneImmediate:function(t,e,i){t instanceof cc.Scene&&t._load();for(var n=cc.game,r=Object.keys(n._persistRootNodes).map((function(t){return n._persistRootNodes[t]})),o=0;o<r.length;o++){var a=r[o];n._ignoreRemovePersistNode=a,a.parent=null,n._ignoreRemovePersistNode=null}var c=this._scene,h=c&&c.autoReleaseAssets&&c.dependAssets;s.autoRelease(h,t.dependAssets,r),cc.isValid(c)&&c.destroy(),this._scene=null,cc.Object._deferredDestroy(),e&&e(),this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH,t);var l=t;if(t instanceof cc.Scene){this._scene=t,l=t._sgNode;for(var u=0;u<r.length;u++){var _=r[u],d=t.getChildByUuid(_.uuid);if(d){var f=d.getSiblingIndex();d._destroyImmediate(),t.insertChild(_,f)}else _.parent=t}t._activate()}if(this._runningScene){var p=this._scenesStack.length;this._scenesStack[Math.max(p-1,0)]=l,this._sendCleanupToScene=!0,this._nextScene=l}else this.pushScene(l),this.startAnimation();this._nextScene&&this.setNextScene(),i&&i(null,t),this.emit(cc.Director.EVENT_AFTER_SCENE_LAUNCH,t)},runScene:function(t,e,i){cc.assertID(t,1205),t instanceof cc.Scene&&t._load(),this.once(cc.Director.EVENT_AFTER_UPDATE,(function(){this.runSceneImmediate(t,e,i)}))},_getSceneUuid:function(t){var e=cc.game._sceneInfos;if("string"==typeof t){t.endsWith(".fire")||(t+=".fire"),"/"===t[0]||t.startsWith("db://assets/")||(t="/"+t);for(var i=0;i<e.length;i++){var n=e[i];if(n.url.endsWith(t))return n}}else if("number"==typeof t){if(0<=t&&t<e.length)return e[t];cc.errorID(1206,t)}else cc.errorID(1207,t);return null},loadScene:function(t,e,i){if(this._loadingScene)return cc.errorID(1208,t,this._loadingScene),!1;var n=this._getSceneUuid(t);if(n){var r=n.uuid;this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING,t),this._loadingScene=t;return this._loadSceneByUuid(r,e,i),!0}return cc.errorID(1209,t),!1},preloadScene:function(t,e){var i=this._getSceneUuid(t);if(i)this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING,t),cc.loader.load({uuid:i.uuid,type:"uuid"},(function(i,n){i&&cc.errorID(1210,t,i.message),e&&e(i,n)}));else{var n='Can not preload the scene "'+t+'" because it is not in the build settings.';e(new Error(n)),cc.error("preloadScene: "+n)}},_loadSceneByUuid:function(t,e,i,n){console.time("LoadScene "+t),cc.AssetLibrary.loadAsset(t,(function(n,r){console.timeEnd("LoadScene "+t);var s=cc.director;if(s._loadingScene="",n)n="Failed to load scene: "+n,cc.error(n);else{if(r instanceof cc.SceneAsset){var o=r.scene;return o._id=r._uuid,o._name=r._name,void s.runSceneImmediate(o,i,e)}n="The asset "+t+" is not a scene",cc.error(n)}e&&e(n)}))},resume:function(){this._paused&&(this.setAnimationInterval(this._oldAnimationInterval),this._lastUpdate=Date.now(),this._lastUpdate||cc.logID(1200),this._paused=!1,this._deltaTime=0)},setContentScaleFactor:function(t){t!==this._contentScaleFactor&&(this._contentScaleFactor=t)},setDepthTest:null,setClearColor:null,setDefaultValues:function(){},setNextDeltaTimeZero:function(t){this._nextDeltaTimeZero=t},setNextScene:function(){var t=!1,e=!1;if(cc.TransitionScene&&(t=!!this._runningScene&&this._runningScene instanceof cc.TransitionScene,e=!!this._nextScene&&this._nextScene instanceof cc.TransitionScene),!e){var i=this._runningScene;i&&(i.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),i.performRecursive(_ccsg.Node.performType.onExit)),this._sendCleanupToScene&&i&&i.performRecursive(_ccsg.Node.performType.cleanup)}this._runningScene=this._nextScene,cc.renderer.childrenOrderDirty=!0,this._nextScene=null,t||null===this._runningScene||(this._runningScene.performRecursive(_ccsg.Node.performType.onEnter),this._runningScene.performRecursive(_ccsg.Node.performType.onEnterTransitionDidFinish))},getDelegate:function(){return this._projectionDelegate},setDelegate:function(t){this._projectionDelegate=t},setOpenGLView:null,setProjection:null,setViewport:null,getOpenGLView:null,getProjection:null,setAlphaBlending:null,isSendCleanupToScene:function(){return this._sendCleanupToScene},getRunningScene:function(){return this._runningScene},getScene:function(){return this._scene},getAnimationInterval:function(){return this._animationInterval},isDisplayStats:function(){return!!cc.profiler&&cc.profiler.isShowingStats()},setDisplayStats:function(t){cc.profiler&&(t?cc.profiler.showStats():cc.profiler.hideStats(),cc.game.config[cc.game.CONFIG_KEY.showFPS]=!!t)},isNextDeltaTimeZero:function(){return this._nextDeltaTimeZero},isPaused:function(){return this._paused},getTotalFrames:function(){return this._totalFrames},popToRootScene:function(){this.popToSceneStackLevel(1)},popToSceneStackLevel:function(t){cc.assertID(this._runningScene,1203);var e=this._scenesStack,i=e.length;if(0!==i){if(!(t>i)){for(;i>t;){var n=e.pop();n.running&&(n.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),n.performRecursive(_ccsg.Node.performType.onExit)),n.performRecursive(_ccsg.Node.performType.cleanup),i--}this._nextScene=e[e.length-1],this._sendCleanupToScene=!0}}else this.end()},getScheduler:function(){return this._scheduler},setScheduler:function(t){this._scheduler!==t&&(this._scheduler=t)},getActionManager:function(){return this._actionManager},setActionManager:function(t){this._actionManager!==t&&(this._actionManager&&this._scheduler.unscheduleUpdate(this._actionManager),this._actionManager=t,this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1))},getAnimationManager:function(){return this._animationManager},getCollisionManager:function(){return this._collisionManager},getPhysicsManager:function(){return this._physicsManager},getDeltaTime:function(){return this._deltaTime}}),cc.js.addon(cc.Director.prototype,n.prototype),cc.Director.EVENT_PROJECTION_CHANGED="director_projection_changed",cc.Director.EVENT_BEFORE_SCENE_LOADING="director_before_scene_loading",cc.Director.EVENT_BEFORE_SCENE_LAUNCH="director_before_scene_launch",cc.Director.EVENT_AFTER_SCENE_LAUNCH="director_after_scene_launch",cc.Director.EVENT_BEFORE_UPDATE="director_before_update",cc.Director.EVENT_AFTER_UPDATE="director_after_update",cc.Director.EVENT_BEFORE_VISIT="director_before_visit",cc.Director.EVENT_AFTER_VISIT="director_after_visit",cc.Director.EVENT_AFTER_DRAW="director_after_draw",cc.DisplayLinkDirector=cc.Director.extend({invalid:!1,startAnimation:function(){this._nextDeltaTimeZero=!0,this.invalid=!1},mainLoop:function(){this._purgeDirectorInNextLoop?(this._purgeDirectorInNextLoop=!1,this.purgeDirector()):this.invalid||(this.calculateDeltaTime(),this._paused||(this.emit(cc.Director.EVENT_BEFORE_UPDATE),this._compScheduler.startPhase(),this._compScheduler.updatePhase(this._deltaTime),this._scheduler.update(this._deltaTime),this._compScheduler.lateUpdatePhase(this._deltaTime),this.emit(cc.Director.EVENT_AFTER_UPDATE),cc.Object._deferredDestroy()),this._nextScene&&this.setNextScene(),this.emit(cc.Director.EVENT_BEFORE_VISIT),this._visitScene(),this.emit(cc.Director.EVENT_AFTER_VISIT),cc.g_NumberOfDraws=0,cc.renderer.clear(),cc.renderer.rendering(cc._renderContext),this._totalFrames++,this.emit(cc.Director.EVENT_AFTER_DRAW),h.frameUpdateListeners())},stopAnimation:function(){this.invalid=!0},setAnimationInterval:function(t){this._animationInterval=t,this.invalid||(this.stopAnimation(),this.startAnimation())},__fastOn:function(t,e,i){var n=this._bubblingListeners;n||(n=this._bubblingListeners=new c),n.add(t,e,i),this._addEventFlag(t,n,!1)},__fastOff:function(t,e,i){var n=this._bubblingListeners;n&&(n.remove(t,e,i),this._purgeEventFlag(t,n,!1))}}),cc.Director.sharedDirector=null,cc.Director.firstUseDirector=!0,cc.Director._getInstance=function(){return cc.Director.firstUseDirector&&(cc.Director.firstUseDirector=!1,cc.Director.sharedDirector=new cc.DisplayLinkDirector,cc.Director.sharedDirector.init()),cc.Director.sharedDirector},cc.defaultFPS=60,cc.Director.PROJECTION_2D=0,cc.Director.PROJECTION_3D=1,cc.Director.PROJECTION_CUSTOM=3,cc.Director.PROJECTION_DEFAULT=cc.Director.PROJECTION_2D}),{"./component-scheduler":70,"./event-manager":110,"./event/event-listeners":111,"./event/event-target":112,"./load-pipeline/auto-release-utils":134,"./node-activator":147,"./platform/_CCClass":188}],34:[(function(t,e,i){t("./CCDirector"),t("./CCGame");var n=t("./event-manager");cc.game.once(cc.game.EVENT_RENDERER_INITED,(function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var t=cc.Director.prototype;t.getProjection=function(t){return this._projection},t.setProjection=function(t){this._projection=t,this.emit(cc.Director.EVENT_PROJECTION_CHANGED,this)},t.setDepthTest=function(){},t.setClearColor=function(t){cc.renderer._clearColor=t,cc.renderer._clearFillStyle="rgb("+t.r+","+t.g+","+t.b+")"},t.setOpenGLView=function(t){this._winSizeInPoints.width=cc._canvas.width,this._winSizeInPoints.height=cc._canvas.height,this._openGLView=t||cc.view,n&&n.setEnabled(!0)},t.getVisibleSize=function(){return this.getWinSize()},t.getVisibleOrigin=function(){return cc.p(0,0)}}}))}),{"./CCDirector":33,"./CCGame":39,"./event-manager":110}],35:[(function(t,e,i){t("./CCDirector"),t("./CCGame"),t("../kazmath");var n=t("./event-manager"),r=cc.math;cc.game.once(cc.game.EVENT_RENDERER_INITED,(function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.DirectorDelegate=cc._Class.extend({updateProjection:function(){}});var t=cc.Director.prototype,e=function(t){if(t&&t._renderCmd){t._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty);var i,n=t._children;for(i=0;i<n.length;i++)e(n[i])}};cc.Director._getInstance().on(cc.Director.EVENT_PROJECTION_CHANGED,(function(){for(var t=cc.director._scenesStack,i=0;i<t.length;i++)e(t[i])})),t.setProjection=function(t){var e=this._winSizeInPoints;this.setViewport();var i=this._openGLView,n=i._viewPortRect.x/i._scaleX,s=i._viewPortRect.y/i._scaleY;switch(t){case cc.Director.PROJECTION_2D:r.glMatrixMode(r.KM_GL_PROJECTION),r.glLoadIdentity();var o=r.Matrix4.createOrthographicProjection(0,e.width,0,e.height,-1024,1024);r.glMultMatrix(o),r.glMatrixMode(r.KM_GL_MODELVIEW),r.glLoadIdentity();break;case cc.Director.PROJECTION_3D:var a=this.getZEye(),c=new r.Matrix4,h=new r.Matrix4;r.glMatrixMode(r.KM_GL_PROJECTION),r.glLoadIdentity(),c=r.Matrix4.createPerspectiveProjection(60,e.width/e.height,.1,2*a),r.glMultMatrix(c);var l=new r.Vec3(-n+e.width/2,-s+e.height/2,a),u=new r.Vec3(-n+e.width/2,-s+e.height/2,0),_=new r.Vec3(0,1,0);h.lookAt(l,u,_),r.glMultMatrix(h),r.glMatrixMode(r.KM_GL_MODELVIEW),r.glLoadIdentity();break;case cc.Director.PROJECTION_CUSTOM:this._projectionDelegate&&this._projectionDelegate.updateProjection();break;default:cc.logID(1201)}this._projection=t,this.emit(cc.Director.EVENT_PROJECTION_CHANGED,this),cc.gl.setProjectionMatrixDirty(),cc.renderer.childrenOrderDirty=!0},t.setDepthTest=function(t){cc.renderer.setDepthTest(t)},t.setClearColor=function(t){var e=cc.renderer._clearColor;e.r=t.r/255,e.g=t.g/255,e.b=t.b/255,e.a=t.a/255},t.setOpenGLView=function(t){this._winSizeInPoints.width=cc._canvas.width,this._winSizeInPoints.height=cc._canvas.height,this._openGLView=t||cc.view;cc.configuration.gatherGPUInfo(),this.setGLDefaultValues(),n&&n.setEnabled(!0)},t.getVisibleSize=function(){return this._openGLView.getVisibleSize()},t.getVisibleOrigin=function(){return this._openGLView.getVisibleOrigin()},t.getZEye=function(){return this._winSizeInPoints.height/1.1566},t.setViewport=function(){var t=this._openGLView;if(t){var e=this._winSizeInPoints;t.setViewPortInPoints(-t._viewPortRect.x/t._scaleX,-t._viewPortRect.y/t._scaleY,e.width,e.height)}},t.getOpenGLView=function(){return this._openGLView},t.getProjection=function(){return this._projection},t.setAlphaBlending=function(t){t?cc.gl.blendFunc(cc.macro.BLEND_SRC,cc.macro.BLEND_DST):cc.gl.blendFunc(cc.macro.ONE,cc.macro.ZERO)},t.setGLDefaultValues=function(){this.setAlphaBlending(!0),this.setProjection(this._projection),cc._renderContext.clearColor(0,0,0,0)}}}))}),{"../kazmath":247,"./CCDirector":33,"./CCGame":39,"./event-manager":110}],36:[(function(t,e,i){var n=t("./CCGame");cc._drawingUtil=null,n.once(n.EVENT_RENDERER_INITED,(function(){cc._renderType===n.RENDER_TYPE_WEBGL?cc._drawingUtil=new(t("./CCDrawingPrimitivesWebGL"))(cc._renderContext):cc._drawingUtil=new(t("./CCDrawingPrimitivesCanvas"))(cc._renderContext)}))}),{"./CCDrawingPrimitivesCanvas":37,"./CCDrawingPrimitivesWebGL":38,"./CCGame":39}],37:[(function(t,e,i){var n=cc._Class.extend({_cacheArray:[],ctor:function(t){this._renderContext=t},drawPoint:function(t,e){e||(e=1);var i=cc.view.getScaleX(),n=cc.view.getScaleY(),r=cc.p(t.x*i,t.y*n),s=this._renderContext.getContext();s.beginPath(),s.arc(r.x,-r.y,e*i,0,2*Math.PI,!1),s.closePath(),s.fill()},drawPoints:function(t,e,i){if(null!=t){i||(i=1);var n=this._renderContext.getContext(),r=cc.view.getScaleX(),s=cc.view.getScaleY();n.beginPath();for(var o=0,a=t.length;o<a;o++)n.arc(t[o].x*r,-t[o].y*s,i*r,0,2*Math.PI,!1);n.closePath(),n.fill()}},drawLine:function(t,e){var i=this._renderContext.getContext(),n=cc.view.getScaleX(),r=cc.view.getScaleY();i.beginPath(),i.moveTo(t.x*n,-t.y*r),i.lineTo(e.x*n,-e.y*r),i.closePath(),i.stroke()},drawRect:function(t,e){this.drawLine(cc.p(t.x,t.y),cc.p(e.x,t.y)),this.drawLine(cc.p(e.x,t.y),cc.p(e.x,e.y)),this.drawLine(cc.p(e.x,e.y),cc.p(t.x,e.y)),this.drawLine(cc.p(t.x,e.y),cc.p(t.x,t.y))},drawSolidRect:function(t,e,i){var n=[t,cc.p(e.x,t.y),e,cc.p(t.x,e.y)];this.drawSolidPoly(n,4,i)},drawPoly:function(t,e,i,n){if(n=n||!1,null!=t){if(t.length<3)throw new Error("Polygon's point must greater than 2");var r=t[0],s=this._renderContext.getContext(),o=cc.view.getScaleX(),a=cc.view.getScaleY();s.beginPath(),s.moveTo(r.x*o,-r.y*a);for(var c=1,h=t.length;c<h;c++)s.lineTo(t[c].x*o,-t[c].y*a);i&&s.closePath(),n?s.fill():s.stroke()}},drawSolidPoly:function(t,e,i){this.setDrawColor(i.r,i.g,i.b,i.a),this.drawPoly(t,e,!0,!0)},drawCircle:function(t,e,i,n,r){r=r||!1;var s=this._renderContext.getContext(),o=cc.view.getScaleX(),a=cc.view.getScaleY();s.beginPath();var c=i-2*Math.PI;s.arc(0|t.x*o,0|-t.y*a,e*o,-i,-c,!1),r&&s.lineTo(0|t.x*o,0|-t.y*a),s.stroke()},drawQuadBezier:function(t,e,i,n){var r=this._cacheArray;r.length=0;for(var s=0,o=0;o<n;o++){var a=Math.pow(1-s,2)*t.x+2*(1-s)*s*e.x+s*s*i.x,c=Math.pow(1-s,2)*t.y+2*(1-s)*s*e.y+s*s*i.y;r.push(cc.p(a,c)),s+=1/n}r.push(cc.p(i.x,i.y)),this.drawPoly(r,n+1,!1,!1)},drawCubicBezier:function(t,e,i,n,r){var s=this._cacheArray;s.length=0;for(var o=0,a=0;a<r;a++){var c=Math.pow(1-o,3)*t.x+3*Math.pow(1-o,2)*o*e.x+3*(1-o)*o*o*i.x+o*o*o*n.x,h=Math.pow(1-o,3)*t.y+3*Math.pow(1-o,2)*o*e.y+3*(1-o)*o*o*i.y+o*o*o*n.y;s.push(cc.p(c,h)),o+=1/r}s.push(cc.p(n.x,n.y)),this.drawPoly(s,r+1,!1,!1)},drawCatmullRom:function(t,e){this.drawCardinalSpline(t,.5,e)},drawCardinalSpline:function(t,e,i){cc._renderContext.setStrokeStyle("rgba(255,255,255,1)");var n=this._cacheArray;n.length=0;for(var r,s,o=1/t.length,a=0;a<i+1;a++){var c=a/i;1===c?(r=t.length-1,s=1):s=(c-o*(r=0|c/o))/o;var h=cc.cardinalSplineAt(cc.getControlPointAt(t,r-1),cc.getControlPointAt(t,r-0),cc.getControlPointAt(t,r+1),cc.getControlPointAt(t,r+2),e,s);n.push(h)}this.drawPoly(n,i+1,!1,!1)},drawImage:function(t,e,i,n,r){var s=arguments.length,o=this._renderContext.getContext();switch(s){case 2:var a=t.height;o.drawImage(t,e.x,-(e.y+a));break;case 3:o.drawImage(t,e.x,-(e.y+i.height),i.width,i.height);break;case 5:o.drawImage(t,e.x,e.y,i.width,i.height,n.x,-(n.y+r.height),r.width,r.height);break;default:throw new Error("Argument must be non-nil")}},drawStar:function(t,e,i){var n=t||this._renderContext,r=n.getContext();e*=cc.view.getScaleX();var s="rgba("+(0|i.r)+","+(0|i.g)+","+(0|i.b);n.setFillStyle(s+",1)");var o=e/10;r.beginPath(),r.moveTo(-e,e),r.lineTo(0,o),r.lineTo(e,e),r.lineTo(o,0),r.lineTo(e,-e),r.lineTo(0,-o),r.lineTo(-e,-e),r.lineTo(-o,0),r.lineTo(-e,e),r.closePath(),r.fill();var a=r.createRadialGradient(0,0,o,0,0,e);a.addColorStop(0,s+", 1)"),a.addColorStop(.3,s+", 0.8)"),a.addColorStop(1,s+", 0.0)"),n.setFillStyle(a),r.beginPath();var c=cc.macro.PI2;r.arc(0,0,e-o,0,c,!1),r.closePath(),r.fill()},drawColorBall:function(t,e,i){var n=t||this._renderContext,r=n.getContext();e*=cc.view.getScaleX();var s="rgba("+(0|i.r)+","+(0|i.g)+","+(0|i.b),o=e/10,a=r.createRadialGradient(0,0,o,0,0,e);a.addColorStop(0,s+", 1)"),a.addColorStop(.3,s+", 0.8)"),a.addColorStop(.6,s+", 0.4)"),a.addColorStop(1,s+", 0.0)"),n.setFillStyle(a),r.beginPath();var c=cc.macro.PI2;r.arc(0,0,e,0,c,!1),r.closePath(),r.fill()},fillText:function(t,e,i){this._renderContext.getContext().fillText(t,e,-i)},setDrawColor:function(t,e,i,n){this._renderContext.setFillStyle("rgba("+t+","+e+","+i+","+n/255+")"),this._renderContext.setStrokeStyle("rgba("+t+","+e+","+i+","+n/255+")")},setPointSize:function(t){},setLineWidth:function(t){this._renderContext.getContext().lineWidth=t*cc.view.getScaleX()}});e.exports=n}),{}],38:[(function(t,e,i){var n=cc.macro,r=cc._Class.extend({_initialized:!1,_shader:null,_colorLocation:"u_color",_pointSizeLocation:"u_pointSize",_pointSize:-1,ctor:function(t){if(!t instanceof WebGLRenderingContext)throw new Error("Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext");this._renderContext=t,this._colorArray=new Float32Array([1,1,1,1])},lazy_init:function(){this._initialized||(this._shader=cc.shaderCache.programForKey(n.SHADER_POSITION_UCOLOR),this._shader._addUniformLocation(this._colorLocation),this._shader._addUniformLocation(this._pointSizeLocation),this._initialized=!0)},drawInit:function(){this._initialized=!1},drawPoint:function(t){this.lazy_init();var e=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),e.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray),this._shader.setUniformLocationWith1f(this._pointSizeLocation,this._pointSize);var i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([t.x,t.y]),e.STATIC_DRAW),e.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,e.FLOAT,!1,0,0),e.drawArrays(e.POINTS,0,1),e.deleteBuffer(i),cc.incrementGLDraws(1)},drawPoints:function(t,e){if(t&&0!==t.length){this.lazy_init();var i=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),i.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray),this._shader.setUniformLocationWith1f(this._pointSizeLocation,this._pointSize);var r=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,r),i.bufferData(i.ARRAY_BUFFER,this._pointsToTypeArray(t),i.STATIC_DRAW),i.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,i.FLOAT,!1,0,0),i.drawArrays(i.POINTS,0,t.length),i.deleteBuffer(r),cc.incrementGLDraws(1)}},_pointsToTypeArray:function(t){for(var e=new Float32Array(2*t.length),i=0;i<t.length;i++)e[2*i]=t[i].x,e[2*i+1]=t[i].y;return e},drawLine:function(t,e){this.lazy_init();var i=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),i.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var r=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,r),i.bufferData(i.ARRAY_BUFFER,this._pointsToTypeArray([t,e]),i.STATIC_DRAW),i.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,i.FLOAT,!1,0,0),i.drawArrays(i.LINES,0,2),i.deleteBuffer(r),cc.incrementGLDraws(1)},drawRect:function(t,e){this.drawLine(cc.p(t.x,t.y),cc.p(e.x,t.y)),this.drawLine(cc.p(e.x,t.y),cc.p(e.x,e.y)),this.drawLine(cc.p(e.x,e.y),cc.p(t.x,e.y)),this.drawLine(cc.p(t.x,e.y),cc.p(t.x,t.y))},drawSolidRect:function(t,e,i){var n=[t,cc.p(e.x,t.y),e,cc.p(t.x,e.y)];this.drawSolidPoly(n,4,i)},drawPoly:function(t,e,i){this.lazy_init();var r=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),r.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var s=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,this._pointsToTypeArray(t),r.STATIC_DRAW),r.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,r.FLOAT,!1,0,0),i?r.drawArrays(r.LINE_LOOP,0,t.length):r.drawArrays(r.LINE_STRIP,0,t.length),r.deleteBuffer(s),cc.incrementGLDraws(1)},drawSolidPoly:function(t,e,i){this.lazy_init(),i&&this.setDrawColor(i.r,i.g,i.b,i.a);var r=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),r.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var s=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,this._pointsToTypeArray(t),r.STATIC_DRAW),r.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,r.FLOAT,!1,0,0),r.drawArrays(r.TRIANGLE_FAN,0,t.length),r.deleteBuffer(s),cc.incrementGLDraws(1)},drawCircle:function(t,e,i,r,s){this.lazy_init();var o=1;s&&o++;var a=2*Math.PI/r,c=new Float32Array(2*(r+2));if(c){for(var h=0;h<=r;h++){var l=h*a,u=e*Math.cos(l+i)+t.x,_=e*Math.sin(l+i)+t.y;c[2*h]=u,c[2*h+1]=_}c[2*(r+1)]=t.x,c[2*(r+1)+1]=t.y;var d=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),d.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var f=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,f),d.bufferData(d.ARRAY_BUFFER,c,d.STATIC_DRAW),d.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,d.FLOAT,!1,0,0),d.drawArrays(d.LINE_STRIP,0,r+o),d.deleteBuffer(f),cc.incrementGLDraws(1)}},drawQuadBezier:function(t,e,i,r){this.lazy_init();for(var s=new Float32Array(2*(r+1)),o=0,a=0;a<r;a++)s[2*a]=Math.pow(1-o,2)*t.x+2*(1-o)*o*e.x+o*o*i.x,s[2*a+1]=Math.pow(1-o,2)*t.y+2*(1-o)*o*e.y+o*o*i.y,o+=1/r;s[2*r]=i.x,s[2*r+1]=i.y;var c=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),c.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var h=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,h),c.bufferData(c.ARRAY_BUFFER,s,c.STATIC_DRAW),c.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,c.FLOAT,!1,0,0),c.drawArrays(c.LINE_STRIP,0,r+1),c.deleteBuffer(h),cc.incrementGLDraws(1)},drawCubicBezier:function(t,e,i,r,s){this.lazy_init();for(var o=new Float32Array(2*(s+1)),a=0,c=0;c<s;c++)o[2*c]=Math.pow(1-a,3)*t.x+3*Math.pow(1-a,2)*a*e.x+3*(1-a)*a*a*i.x+a*a*a*r.x,o[2*c+1]=Math.pow(1-a,3)*t.y+3*Math.pow(1-a,2)*a*e.y+3*(1-a)*a*a*i.y+a*a*a*r.y,a+=1/s;o[2*s]=r.x,o[2*s+1]=r.y;var h=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),h.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var l=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,l),h.bufferData(h.ARRAY_BUFFER,o,h.STATIC_DRAW),h.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,h.FLOAT,!1,0,0),h.drawArrays(h.LINE_STRIP,0,s+1),h.deleteBuffer(l),cc.incrementGLDraws(1)},drawCatmullRom:function(t,e){this.drawCardinalSpline(t,.5,e)},drawCardinalSpline:function(t,e,i){this.lazy_init();for(var r,s,o=new Float32Array(2*(i+1)),a=1/t.length,c=0;c<i+1;c++){var h=c/i;1===h?(r=t.length-1,s=1):s=(h-a*(r=0|h/a))/a;var l=cc.cardinalSplineAt(cc.getControlPointAt(t,r-1),cc.getControlPointAt(t,r),cc.getControlPointAt(t,r+1),cc.getControlPointAt(t,r+2),e,s);o[2*c]=l.x,o[2*c+1]=l.y}var u=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),u.enableVertexAttribArray(n.VERTEX_ATTRIB_POSITION),this._shader.setUniformLocationWith4fv(this._colorLocation,this._colorArray);var _=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,_),u.bufferData(u.ARRAY_BUFFER,o,u.STATIC_DRAW),u.vertexAttribPointer(n.VERTEX_ATTRIB_POSITION,2,u.FLOAT,!1,0,0),u.drawArrays(u.LINE_STRIP,0,i+1),u.deleteBuffer(_),cc.incrementGLDraws(1)},setDrawColor:function(t,e,i,n){this._colorArray[0]=t/255,this._colorArray[1]=e/255,this._colorArray[2]=i/255,this._colorArray[3]=n/255},setPointSize:function(t){this._pointSize=t},setLineWidth:function(t){this._renderContext.lineWidth&&this._renderContext.lineWidth(t)}});e.exports=r}),{}],39:[(function(t,e,i){var n,r=t("./event/event-target");n=t("./platform/CCView"),t("../audio/CCAudioEngine");var s=t("./platform/CCInputManager"),o={EVENT_HIDE:"game_on_hide",EVENT_SHOW:"game_on_show",EVENT_GAME_INITED:"game_inited",EVENT_RENDERER_INITED:"renderer_inited",RENDER_TYPE_CANVAS:0,RENDER_TYPE_WEBGL:1,RENDER_TYPE_OPENGL:2,_persistRootNodes:{},_ignoreRemovePersistNode:null,CONFIG_KEY:{width:"width",height:"height",debugMode:"debugMode",exposeClassName:"exposeClassName",showFPS:"showFPS",frameRate:"frameRate",id:"id",renderMode:"renderMode",registerSystemEvent:"registerSystemEvent",jsList:"jsList",scenes:"scenes"},_paused:!0,_configLoaded:!1,_isCloning:!1,_prepareCalled:!1,_prepared:!1,_rendererInitialized:!1,_renderContext:null,_intervalId:null,_lastTime:null,_frameTime:null,_sceneInfos:[],frame:null,container:null,canvas:null,config:null,onStart:null,setFrameRate:function(t){this.config[this.CONFIG_KEY.frameRate]=t,this._intervalId&&window.cancelAnimFrame(this._intervalId),this._intervalId=0,this._paused=!0,this._setAnimFrame(),this._runMainLoop()},step:function(){cc.director.mainLoop()},pause:function(){this._paused||(this._paused=!0,cc.audioEngine&&cc.audioEngine._break(),this._intervalId&&window.cancelAnimFrame(this._intervalId),this._intervalId=0)},resume:function(){this._paused&&(this._paused=!1,cc.audioEngine&&cc.audioEngine._restore(),this._runMainLoop())},isPaused:function(){return this._paused},restart:function(){cc.director.once(cc.Director.EVENT_AFTER_DRAW,(function(){for(var t in o._persistRootNodes)o.removePersistRootNode(o._persistRootNodes[t]);cc.director.getScene().destroy(),cc.Object._deferredDestroy(),cc.director.purgeDirector(),cc.audioEngine&&cc.audioEngine.uncacheAll(),cc.director.reset(),o.onStart()}))},end:function(){close()},prepare:function(t){var e=this,i=e.config,r=e.CONFIG_KEY;if(this._configLoaded){if(this._prepared)t&&t();else if(!this._prepareCalled)if(cc._engineLoaded){this._prepareCalled=!0,this._initRenderer(i[r.width],i[r.height]),cc.view=n?n._getInstance():null,cc.director=cc.Director._getInstance(),cc.director.setOpenGLView&&cc.director.setOpenGLView(cc.view),cc.winSize=cc.director.getWinSize(),this._initEvents(),this._setAnimFrame(),this._runMainLoop();var s=i[r.jsList];s&&s.length>0?cc.loader.load(s,(function(i){if(i)throw new Error(JSON.stringify(i));e._prepared=!0,t&&t(),e.emit(e.EVENT_GAME_INITED)})):(t&&t(),e.emit(e.EVENT_GAME_INITED))}else cc.initEngine(this.config,(function(){e.prepare(t)}))}else this._loadConfig((function(){e.prepare(t)}))},run:function(t,e){"function"==typeof t?o.onStart=t:(t&&(o.config=t),"function"==typeof e&&(o.onStart=e)),this.prepare(o.onStart&&o.onStart.bind(o))},addPersistRootNode:function(t){if(cc.Node.isNode(t)&&t.uuid){var e=t.uuid;if(!this._persistRootNodes[e]){var i=cc.director._scene;if(cc.isValid(i)){if(t.parent){if(!(t.parent instanceof cc.Scene))return void cc.warnID(3801);if(t.parent!==i)return void cc.warnID(3802)}else t.parent=i;this._persistRootNodes[e]=t,t._persistNode=!0}}}else cc.warnID(3800)},removePersistRootNode:function(t){if(t!==this._ignoreRemovePersistNode){var e=t.uuid||"";t===this._persistRootNodes[e]&&(delete this._persistRootNodes[e],t._persistNode=!1)}},isPersistRootNode:function(t){return t._persistNode},_setAnimFrame:function(){this._lastTime=new Date;var t=o.config[o.CONFIG_KEY.frameRate];this._frameTime=1e3/t,60!==t&&30!==t?(window.requestAnimFrame=this._stTime,window.cancelAnimFrame=this._ctTime):(window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||this._stTime,window.cancelAnimFrame=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.oCancelAnimationFrame||this._ctTime)},_stTime:function(t){var e=(new Date).getTime(),i=Math.max(0,o._frameTime-(e-o._lastTime)),n=window.setTimeout((function(){t()}),i);return o._lastTime=e+i,n},_ctTime:function(t){window.clearTimeout(t)},_runMainLoop:function(){var t,e=this,i=e.config,n=e.CONFIG_KEY,r=cc.director,s=!0,o=i[n.frameRate];r.setDisplayStats(i[n.showFPS]),t=function(){if(!e._paused){if(e._intervalId=window.requestAnimFrame(t),30===o&&(s=!s))return;r.mainLoop()}},e._intervalId=window.requestAnimFrame(t),e._paused=!1},_loadConfig:function(t){if(this.config)return this._initConfig(this.config),void(t&&t());if(document.ccConfig)return this._initConfig(document.ccConfig),void(t&&t());var e=this;cc.loader.load("project.json",(function(i,n){i&&cc.logID(3818),e._initConfig(n||{}),t&&t()}))},_initConfig:function(t){var e=this.CONFIG_KEY;"number"!=typeof t[e.debugMode]&&(t[e.debugMode]=0),t[e.exposeClassName]=!!t[e.exposeClassName],"number"!=typeof t[e.frameRate]&&(t[e.frameRate]=60),"number"!=typeof t[e.renderMode]&&(t[e.renderMode]=0),"boolean"!=typeof t[e.registerSystemEvent]&&(t[e.registerSystemEvent]=!0),t[e.showFPS]=!(e.showFPS in t)||!!t[e.showFPS],this._sceneInfos=t[e.scenes]||[],this.collisionMatrix=t.collisionMatrix||[],this.groupList=t.groupList||[],cc._initDebugSetting(t[e.debugMode]),this.config=t,this._configLoaded=!0},_initRenderer:function(t,e){if(!this._rendererInitialized){if(!cc._supportRender)throw new Error("The renderer doesn't support the renderMode "+this.config[this.CONFIG_KEY.renderMode]);var i,n,r=this.config[o.CONFIG_KEY.id],s=window,a=cc.sys.platform===cc.sys.WECHAT_GAME,c=cc.sys.platform===cc.sys.QQ_PLAY;if(a)this.container=cc.container=n=document.createElement("DIV"),this.frame=n.parentNode===document.body?document.documentElement:n.parentNode,i=cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB?wx.getSharedCanvas():canvas,this.canvas=cc._canvas=i;else if(c)this.container=cc.container=document.createElement("DIV"),this.frame=document.documentElement,this.canvas=cc._canvas=i=canvas;else{var h=r instanceof HTMLElement?r:document.querySelector(r)||document.querySelector("#"+r);"CANVAS"===h.tagName?(t=t||h.width,e=e||h.height,this.canvas=cc._canvas=i=h,this.container=cc.container=n=document.createElement("DIV"),i.parentNode&&i.parentNode.insertBefore(n,i)):("DIV"!==h.tagName&&cc.warnID(3819),t=t||h.clientWidth,e=e||h.clientHeight,this.canvas=cc._canvas=i=document.createElement("CANVAS"),this.container=cc.container=n=document.createElement("DIV"),h.appendChild(n)),n.setAttribute("id","Cocos2dGameContainer"),n.appendChild(i),this.frame=n.parentNode===document.body?document.documentElement:n.parentNode;(function(t,e){(" "+t.className+" ").indexOf(" "+e+" ")>-1||(t.className&&(t.className+=" "),t.className+=e)})(i,"gameCanvas"),i.setAttribute("width",t||480),i.setAttribute("height",e||320),i.setAttribute("tabindex",99)}if(cc._renderType===o.RENDER_TYPE_WEBGL){var l={stencil:!0,antialias:cc.macro.ENABLE_WEBGL_ANTIALIAS,alpha:cc.macro.ENABLE_TRANSPARENT_CANVAS};a&&(l.preserveDrawingBuffer=!0),this._renderContext=cc._renderContext=cc.webglContext=cc.create3DContext(i,l)}this._renderContext?(cc.renderer=cc.rendererWebGL,s.gl=this._renderContext,cc.renderer.init()):(cc._renderType=o.RENDER_TYPE_CANVAS,cc.renderer=cc.rendererCanvas,cc.renderer.init(),this._renderContext=cc._renderContext=new cc.CanvasContextWrapper(i.getContext("2d"))),cc._gameDiv=n,o.canvas.oncontextmenu=function(){if(!cc._isContextMenuEnable)return!1},this.emit(this.EVENT_RENDERER_INITED,!0),this._rendererInitialized=!0}},_initEvents:function(){var t,e=window;this.config[this.CONFIG_KEY.registerSystemEvent]&&s.registerSystemEvent(this.canvas),void 0!==document.hidden?t="hidden":void 0!==document.mozHidden?t="mozHidden":void 0!==document.msHidden?t="msHidden":void 0!==document.webkitHidden&&(t="webkitHidden");var i=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],n=function(){o.emit(o.EVENT_HIDE,o)},r=function(){o.emit(o.EVENT_SHOW,o)};if(t)for(var a=0;a<i.length;a++)document.addEventListener(i[a],(function(e){var i=document[t];(i=i||e.hidden)?n():r()}),!1);else e.addEventListener("blur",n,!1),e.addEventListener("focus",r,!1);navigator.userAgent.indexOf("MicroMessenger")>-1&&(e.onfocus=r),"onpageshow"in window&&"onpagehide"in window&&(e.addEventListener("pagehide",n,!1),e.addEventListener("pageshow",r,!1)),this.on(o.EVENT_HIDE,(function(){o.pause()})),this.on(o.EVENT_SHOW,(function(){o.resume()}))}};r.call(o),cc.js.addon(o,r.prototype),cc.game=e.exports=o}),{"../audio/CCAudioEngine":23,"./event/event-target":112,"./platform/BKInputManager":174,"./platform/CCInputManager":180,"./platform/CCView":186}],40:[(function(t,e,i){"use strict";function n(t){var e=cc.Mask;if(e)for(var i=0,n=t;n&&cc.Node.isNode(n);n=n._parent,++i)if(n.getComponent(e))return{index:i,node:n};return null}var r=t("./utils/prefab-helper"),s=t("./utils/scene-graph-helper"),o=t("./event-manager"),a=cc.Object.Flags.Destroying,c="position-changed",h="size-changed",l="anchor-changed",u="rotation-changed",_="scale-changed",d=t("./utils/misc"),f=(t("./event/event"),!!cc.ActionManager),p=function(){},m=cc.Enum({TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:"touchend",TOUCH_CANCEL:"touchcancel",MOUSE_DOWN:"mousedown",MOUSE_MOVE:"mousemove",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_UP:"mouseup",MOUSE_WHEEL:"mousewheel"}),g=[m.TOUCH_START,m.TOUCH_MOVE,m.TOUCH_END,m.TOUCH_CANCEL],y=[m.MOUSE_DOWN,m.MOUSE_ENTER,m.MOUSE_MOVE,m.MOUSE_LEAVE,m.MOUSE_UP,m.MOUSE_WHEEL],v=null,x=function(t,e){var i=t.getLocation(),n=this.owner;return!!n._hitTest(i,this)&&(e.type=m.TOUCH_START,e.touch=t,e.bubbles=!0,n.dispatchEvent(e),!0)},C=function(t,e){var i=this.owner;e.type=m.TOUCH_MOVE,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},T=function(t,e){var i=t.getLocation(),n=this.owner;n._hitTest(i,this)?e.type=m.TOUCH_END:e.type=m.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,n.dispatchEvent(e)},b=function(t,e){t.getLocation();var i=this.owner;e.type=m.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},A=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=m.MOUSE_DOWN,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},S=function(t){var e=t.getLocation(),i=this.owner,n=i._hitTest(e,this);if(n)this._previousIn||(v&&(t.type=m.MOUSE_LEAVE,v.dispatchEvent(t),v._mouseListener._previousIn=!1),v=this.owner,t.type=m.MOUSE_ENTER,i.dispatchEvent(t),this._previousIn=!0),t.type=m.MOUSE_MOVE,t.bubbles=!0,i.dispatchEvent(t);else{if(!this._previousIn)return;t.type=m.MOUSE_LEAVE,i.dispatchEvent(t),this._previousIn=!1,v=null}t.stopPropagation()},w=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=m.MOUSE_UP,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},E=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=m.MOUSE_WHEEL,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},I=cc.Class({name:"cc.Node",extends:t("./utils/base-node"),properties:{_opacity:255,_color:cc.Color.WHITE,_cascadeOpacityEnabled:!0,_anchorPoint:cc.p(.5,.5),_contentSize:cc.size(0,0),_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:cc.p(0,0),_skewX:0,_skewY:0,_localZOrder:0,_globalZOrder:0,_opacityModifyRGB:!1,groupIndex:{default:0,type:cc.Integer},group:{get:function(){return cc.game.groupList[this.groupIndex]||""},set:function(t){this.groupIndex=cc.game.groupList.indexOf(t),this.emit("group-changed")}},x:{get:function(){return this._position.x},set:function(t){var e=this._position;if(t!==e.x){e.x=t,this._sgNode.setPositionX(t);var i=this._hasListenerCache;i&&i[c]&&this.emit(c)}}},y:{get:function(){return this._position.y},set:function(t){var e=this._position;if(t!==e.y){e.y=t,this._sgNode.setPositionY(t);var i=this._hasListenerCache;i&&i[c]&&this.emit(c)}}},rotation:{get:function(){return this._rotationX!==this._rotationY&&cc.logID(1602),this._rotationX},set:function(t){if(this._rotationX!==t||this._rotationY!==t){this._rotationX=this._rotationY=t,this._sgNode.rotation=t;var e=this._hasListenerCache;e&&e[u]&&this.emit(u)}}},rotationX:{get:function(){return this._rotationX},set:function(t){if(this._rotationX!==t){this._rotationX=t,this._sgNode.rotationX=t;var e=this._hasListenerCache;e&&e[u]&&this.emit(u)}}},rotationY:{get:function(){return this._rotationY},set:function(t){if(this._rotationY!==t){this._rotationY=t,this._sgNode.rotationY=t;var e=this._hasListenerCache;e&&e[u]&&this.emit(u)}}},scaleX:{get:function(){return this._scaleX},set:function(t){if(this._scaleX!==t){this._scaleX=t,this._sgNode.scaleX=t;var e=this._hasListenerCache;e&&e[_]&&this.emit(_)}}},scaleY:{get:function(){return this._scaleY},set:function(t){if(this._scaleY!==t){this._scaleY=t,this._sgNode.scaleY=t;var e=this._hasListenerCache;e&&e[_]&&this.emit(_)}}},skewX:{get:function(){return this._skewX},set:function(t){this._skewX=t,this._sgNode.skewX=t}},skewY:{get:function(){return this._skewY},set:function(t){this._skewY=t,this._sgNode.skewY=t}},opacity:{get:function(){return this._opacity},set:function(t){if(this._opacity!==t&&(this._opacity=t,this._sgNode.setOpacity(t),!this._cascadeOpacityEnabled)){var e=this._sizeProvider;e instanceof _ccsg.Node&&e!==this._sgNode&&e.setOpacity(t)}},range:[0,255]},cascadeOpacity:{get:function(){return this._cascadeOpacityEnabled},set:function(t){if(this._cascadeOpacityEnabled!==t){this._cascadeOpacityEnabled=t,this._sgNode.cascadeOpacity=t;var e=t?255:this._opacity,i=this._sizeProvider;i instanceof _ccsg.Node&&i.setOpacity(e)}}},color:{get:function(){return this._color.clone()},set:function(t){this._color.equals(t)||(this._color.fromColor(t),this._sizeProvider instanceof _ccsg.Node&&this._sizeProvider.setColor(t))}},anchorX:{get:function(){return this._anchorPoint.x},set:function(t){var e=this._anchorPoint;if(e.x!==t){e.x=t;var i=this._sizeProvider;i instanceof _ccsg.Node&&i.setAnchorPoint(e),this.emit(l)}}},anchorY:{get:function(){return this._anchorPoint.y},set:function(t){var e=this._anchorPoint;if(e.y!==t){e.y=t;var i=this._sizeProvider;i instanceof _ccsg.Node&&i.setAnchorPoint(e),this.emit(l)}}},width:{get:function(){if(this._sizeProvider){var t=this._sizeProvider._getWidth();return this._contentSize.width=t,t}return this._contentSize.width},set:function(t){if(t!==this._contentSize.width){var e=this._sizeProvider;e&&e.setContentSize(t,e._getHeight());this._contentSize.width=t,this.emit(h)}}},height:{get:function(){if(this._sizeProvider){var t=this._sizeProvider._getHeight();return this._contentSize.height=t,t}return this._contentSize.height},set:function(t){if(t!==this._contentSize.height){var e=this._sizeProvider;e&&e.setContentSize(e._getWidth(),t);this._contentSize.height=t,this.emit(h)}}},zIndex:{get:function(){return this._localZOrder},set:function(t){this._localZOrder!==t&&(this._localZOrder=t,this._sgNode.zIndex=t,this._parent&&(function(t){t._parent._delaySort(),o._setDirtyForNode(t)})(this))}}},ctor:function(t){var e=this._sgNode=new _ccsg.Node;cc.game._isCloning||(e.cascadeOpacity=!0),this._sizeProvider=null,this._reorderChildDirty=!1,this._widget=null,this._touchListener=null,this._mouseListener=null},statics:{isNode:function(t){return t instanceof I&&(t.constructor===I||!(t instanceof cc.Scene))}},_onSetParent:function(t){var e=this._sgNode;e.parent&&e.parent.removeChild(e,!1),t&&(t._sgNode.addChild(e),t._delaySort())},_onSiblingIndexChanged:function(t){var e=this._parent,i=e._children,n=0,r=i.length;for(0;n<r;n++)i[n]._sgNode._arrivalOrder=n,o._setDirtyForNode(i[n]);cc.renderer.childrenOrderDirty=!0,e._sgNode._reorderChildDirty=!0,e._delaySort()},_onPreDestroy:function(){var t=this._onPreDestroyBase();f&&cc.director.getActionManager().removeAllActionsFromTarget(this),v===this&&(v=null),this._reorderChildDirty&&cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE,this.sortAllChildren,this),o.removeListeners(this),t||this._removeSgNode()},_onPostActivated:function(t){var e=f?cc.director.getActionManager():null;if(t)if(e&&e.resumeTarget(this),o.resumeTarget(this),this._touchListener){var i=this._touchListener.mask=n(this);this._mouseListener&&(this._mouseListener.mask=i)}else this._mouseListener&&(this._mouseListener.mask=n(this));else e&&e.pauseTarget(this),o.pauseTarget(this)},_onHierarchyChanged:function(t){this._onHierarchyChangedBase(t),cc._widgetManager._nodesOrderDirty=!0},_onBatchCreated:function(){var t=this._prefab;t&&t.sync&&!t._synced&&t.root===this&&r.syncWithPrefab(this),this._updateDummySgNode(),this._parent&&this._parent._sgNode.addChild(this._sgNode),this._activeInHierarchy||(f&&cc.director.getActionManager().pauseTarget(this),o.pauseTarget(this));for(var e=this._children,i=0,n=e.length;i<n;i++)e[i]._onBatchCreated()},on:function(t,e,i,r){var s=!1;return-1!==g.indexOf(t)?this._touchListener||(this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,owner:this,mask:n(this),onTouchBegan:x,onTouchMoved:C,onTouchEnded:T,onTouchCancelled:b}),o.addListener(this._touchListener,this),s=!0):-1!==y.indexOf(t)&&(this._mouseListener||(this._mouseListener=cc.EventListener.create({event:cc.EventListener.MOUSE,_previousIn:!1,owner:this,mask:n(this),onMouseDown:A,onMouseMove:S,onMouseUp:w,onMouseScroll:E}),o.addListener(this._mouseListener,this),s=!0)),s&&!this._activeInHierarchy&&cc.director.getScheduler().schedule((function(){this._activeInHierarchy||o.pauseTarget(this)}),this,0,0,0,!1),this._EventTargetOn(t,e,i,r)},off:function(t,e,i,n){this._EventTargetOff(t,e,i,n),-1!==g.indexOf(t)?this._checkTouchListeners():-1!==y.indexOf(t)&&this._checkMouseListeners()},targetOff:function(t){this._EventTargetTargetOff(t),this._checkTouchListeners(),this._checkMouseListeners()},pauseSystemEvents:function(t){o.pauseTarget(this,t)},resumeSystemEvents:function(t){o.resumeTarget(this,t)},_checkTouchListeners:function(){if(!(this._objFlags&a)&&this._touchListener){var t=0;if(this._bubblingListeners)for(;t<g.length;++t)if(this._bubblingListeners.has(g[t]))return;if(this._capturingListeners)for(;t<g.length;++t)if(this._capturingListeners.has(g[t]))return;o.removeListener(this._touchListener),this._touchListener=null}},_checkMouseListeners:function(){if(!(this._objFlags&a)&&this._mouseListener){var t=0;if(this._bubblingListeners)for(;t<y.length;++t)if(this._bubblingListeners.has(y[t]))return;if(this._capturingListeners)for(;t<y.length;++t)if(this._capturingListeners.has(y[t]))return;v===this&&(v=null),o.removeListener(this._mouseListener),this._mouseListener=null}},_hitTest:function(t,e){var i=this.width,n=this.height,r=t,s=cc.Camera;s&&s.main&&s.main.containsNode(this)&&(r=s.main.getCameraToWorldPoint(r));var o=cc.affineTransformInvertIn(this._sgNode.getNodeToWorldTransform());(r=cc.pointApplyAffineTransform(r,o)).x+=this._anchorPoint.x*i,r.y+=this._anchorPoint.y*n;var a=r.x,c=i-r.x,h=r.y,l=n-r.y;if(a>=0&&c>=0&&l>=0&&h>=0){if(e&&e.mask){for(var u=e.mask,_=this,d=0;_&&d<u.index;++d,_=_.parent);if(_===u.node){var f=_.getComponent(cc.Mask);return!f||!f.enabledInHierarchy||f._hitTest(t)}return e.mask=null,!0}return!0}return!1},_getCapturingTargets:function(t,e){for(var i=this.parent;i;)i.hasEventListener(t,!0)&&e.push(i),i=i.parent},_getBubblingTargets:function(t,e){for(var i=this.parent;i;)i.hasEventListener(t)&&e.push(i),i=i.parent},isRunning:function(){return this._activeInHierarchy},runAction:f?function(t){if(this.active)return cc.assertID(t,1618),cc.macro.ENABLE_GC_FOR_NATIVE_OBJECTS||this._retainAction(t),cc.director.getActionManager().addAction(t,this,!1),t}:p,pauseAllActions:f?function(){cc.director.getActionManager().pauseTarget(this)}:p,resumeAllActions:f?function(){cc.director.getActionManager().resumeTarget(this)}:p,stopAllActions:f?function(){cc.director.getActionManager().removeAllActionsFromTarget(this)}:p,stopAction:f?function(t){cc.director.getActionManager().removeAction(t)}:p,stopActionByTag:f?function(t){t!==cc.Action.TAG_INVALID?cc.director.getActionManager().removeActionByTag(t,this):cc.logID(1612)}:p,getActionByTag:f?function(t){return t===cc.Action.TAG_INVALID?(cc.logID(1613),null):cc.director.getActionManager().getActionByTag(t,this)}:function(){return null},getNumberOfRunningActions:f?function(){return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this)}:function(){return 0},_retainAction:function(t){0},_releaseAllActions:function(){},setTag:function(t){this._tag=t,this._sgNode.tag=t},getPosition:function(){return new cc.Vec2(this._position)},setPosition:function(t,e){var i;void 0===e?(i=t.x,e=t.y):i=t;var n=this._position;if(n.x!==i||n.y!==e){n.x=i,n.y=e,this._sgNode.setPosition(i,e);var r=this._hasListenerCache;r&&r[c]&&this.emit(c)}},getScale:function(){return this._scaleX!==this._scaleY&&cc.logID(1603),this._scaleX},setScale:function(t,e){if("object"==typeof t?(e=t.y,t=t.x):e=e||0===e?e:t,this._scaleX!==t||this._scaleY!==e){this._scaleX=t,this._scaleY=e,this._sgNode.setScale(t,e);var i=this._hasListenerCache;i&&i[_]&&this.emit(_)}},getContentSize:function(t){if(this._sizeProvider&&!t){var e=this._sizeProvider.getContentSize();return this._contentSize=e,cc.size(e)}return cc.size(this._contentSize)},setContentSize:function(t,e){var i=this._contentSize;if(void 0===e){if(t.width===i.width&&t.height===i.height)return;0,i.width=t.width,i.height=t.height}else{if(t===i.width&&e===i.height)return;0,i.width=t,i.height=e}this._sizeProvider&&this._sizeProvider.setContentSize(i),this.emit(h)},setOpacityModifyRGB:function(t){if(this._opacityModifyRGB!==t){this._opacityModifyRGB=t,this._sgNode.setOpacityModifyRGB(t);var e=this._sizeProvider;e instanceof _ccsg.Node&&e!==this._sgNode&&e.setOpacityModifyRGB(t)}},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setGlobalZOrder:function(t){this._globalZOrder=t,this._sgNode.setGlobalZOrder(t)},getGlobalZOrder:function(){return this._globalZOrder=this._sgNode.getGlobalZOrder(),this._globalZOrder},getAnchorPoint:function(){return cc.p(this._anchorPoint)},setAnchorPoint:function(t,e){var i=this._anchorPoint;if(void 0===e){if(t.x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}var n=this._sizeProvider;n instanceof _ccsg.Node&&n.setAnchorPoint(i),this.emit(l)},getAnchorPointInPoints:function(){return this._sgNode.getAnchorPointInPoints()},getDisplayedOpacity:function(){return this._sgNode.getDisplayedOpacity()},_updateDisplayedOpacity:function(t){this._sgNode.updateDisplayedOpacity(t)},getDisplayedColor:function(){return this._sgNode.getDisplayedColor()},getNodeToParentTransformAR:function(){var t=this.getContentSize(),e=this._sgNode.getNodeToParentTransform();if(!this._isSgTransformArToMe(t)){var i=this._anchorPoint.x*t.width,n=this._anchorPoint.y*t.height,r=cc.affineTransformMake(1,0,0,1,i,n);e=cc.affineTransformConcatIn(r,e)}return e},getBoundingBox:function(){var t=this.getContentSize(),e=cc.rect(0,0,t.width,t.height);return cc._rectApplyAffineTransformIn(e,this.getNodeToParentTransform())},getBoundingBoxToWorld:function(){var t;return this.parent&&(t=this.parent.getNodeToWorldTransformAR()),this._getBoundingBoxTo(t)},_getBoundingBoxTo:function(t){var e=this.getContentSize(),i=e.width,n=e.height,r=cc.rect(-this._anchorPoint.x*i,-this._anchorPoint.y*n,i,n),s=cc.affineTransformConcat(this.getNodeToParentTransformAR(),t);if(cc._rectApplyAffineTransformIn(r,s),!this._children)return r;for(var o=this._children,a=0;a<o.length;a++){var c=o[a];if(c&&c.active){var h=c._getBoundingBoxTo(s);h&&(r=cc.rectUnion(r,h))}}return r},getNodeToParentTransform:function(){var t=this.getContentSize(),e=this._sgNode.getNodeToParentTransform();if(this._isSgTransformArToMe(t)){var i=-this._anchorPoint.x*t.width,n=-this._anchorPoint.y*t.height,r=cc.affineTransformMake(1,0,0,1,i,n);e=cc.affineTransformConcatIn(r,e)}return e},getNodeToWorldTransform:function(){var t=this.getContentSize();cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene();var e=this._sgNode.getNodeToWorldTransform();if(this._isSgTransformArToMe(t)){var i=-this._anchorPoint.x*t.width,n=-this._anchorPoint.y*t.height,r=cc.affineTransformMake(1,0,0,1,i,n);e=cc.affineTransformConcatIn(r,e)}return e},getNodeToWorldTransformAR:function(){var t=this.getContentSize();cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene();var e=this._sgNode.getNodeToWorldTransform();if(!this._isSgTransformArToMe(t)){var i=this._anchorPoint.x*t.width,n=this._anchorPoint.y*t.height,r=cc.affineTransformMake(1,0,0,1,i,n);e=cc.affineTransformConcatIn(r,e)}return e},getParentToNodeTransform:function(){return this._sgNode.getParentToNodeTransform()},getWorldToNodeTransform:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene(),this._sgNode.getWorldToNodeTransform()},_isSgTransformArToMe:function(t){var e=this._sgNode.getContentSize();return 0===e.width&&0===e.height&&(0!==t.width||0!==t.height)||!!this._sgNode.isIgnoreAnchorPointForPosition()},convertToNodeSpace:function(t){cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene();var e=this._sgNode.convertToNodeSpace(t);return cc.pAdd(e,cc.p(this._anchorPoint.x*this._contentSize.width,this._anchorPoint.y*this._contentSize.height))},convertToWorldSpace:function(t){cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene();var e=t.x-this._anchorPoint.x*this._contentSize.width,i=t.y-this._anchorPoint.y*this._contentSize.height;return cc.v2(this._sgNode.convertToWorldSpace(cc.v2(e,i)))},convertToNodeSpaceAR:function(t){return cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene(),this._sgNode.isIgnoreAnchorPointForPosition()?cc.v2(this._sgNode.convertToNodeSpace(t)):this._sgNode.convertToNodeSpaceAR(t)},convertToWorldSpaceAR:function(t){return cc._renderType===cc.game.RENDER_TYPE_CANVAS&&cc.director._visitScene(),this._sgNode.isIgnoreAnchorPointForPosition()?cc.v2(this._sgNode.convertToWorldSpace(t)):cc.v2(this._sgNode.convertToWorldSpaceAR(t))},convertTouchToNodeSpace:function(t){return this.convertToNodeSpace(t.getLocation())},convertTouchToNodeSpaceAR:function(t){return this.convertToNodeSpaceAR(t.getLocation())},setNodeDirty:function(){this._sgNode.setNodeDirty()},addChild:function(t,e,i){e=void 0===e?t._localZOrder:e;var n,r=!1;void 0===i?(i=void 0,n=t._name):cc.js.isString(i)?(n=i,i=void 0):cc.js.isNumber(i)&&(r=!0,n=""),cc.assertID(t,1606),cc.assertID(null===t._parent,1605),t.parent=this,t.zIndex=e,r?t.setTag(i):t.setName(n)},cleanup:function(){f&&cc.director.getActionManager().removeAllActionsFromTarget(this),o.removeListeners(this);var t,e,i=this._children.length;for(t=0;t<i;++t)(e=this._children[t])&&e.cleanup()},sortAllChildren:function(){if(this._reorderChildDirty){this._reorderChildDirty=!1;var t=this._children;if(t.length>1){var e,i,n,r=t.length;for(e=1;e<r;e++){for(n=t[e],i=e-1;i>=0;){if(n._localZOrder<t[i]._localZOrder)t[i+1]=t[i];else{if(!(n._localZOrder===t[i]._localZOrder&&n._sgNode._arrivalOrder<t[i]._sgNode._arrivalOrder))break;t[i+1]=t[i]}i--}t[i+1]=n}this.emit("child-reorder")}cc.director.__fastOff(cc.Director.EVENT_AFTER_UPDATE,this.sortAllChildren,this)}},_delaySort:function(){this._reorderChildDirty||(this._reorderChildDirty=!0,cc.director.__fastOn(cc.Director.EVENT_AFTER_UPDATE,this.sortAllChildren,this))},_updateDummySgNode:function(){var t=this._sgNode;t.setPosition(this._position),t.setRotationX(this._rotationX),t.setRotationY(this._rotationY),t.setScale(this._scaleX,this._scaleY),t.setSkewX(this._skewX),t.setSkewY(this._skewY);var e=t._arrivalOrder;t.setLocalZOrder(this._localZOrder),t._arrivalOrder=e,t.setGlobalZOrder(this._globalZOrder),t.setOpacity(this._opacity),t.setOpacityModifyRGB(this._opacityModifyRGB),t.setCascadeOpacityEnabled(this._cascadeOpacityEnabled),t.setTag(this._tag)},_updateSgNode:function(){this._updateDummySgNode();var t=this._sgNode;t.setAnchorPoint(this._anchorPoint),t.setVisible(this._active),t.setColor(this._color);var e=f?cc.director.getActionManager():null;this._activeInHierarchy?(e&&e.resumeTarget(this),o.resumeTarget(this)):(e&&e.pauseTarget(this),o.pauseTarget(this))},_removeSgNode:s.removeSgNode,onRestore:!1});d.propertyDefine(I,["parent","tag","skewX","skewY","position","rotation","rotationX","rotationY","scale","scaleX","scaleY","opacity","color"],{x:["getPositionX","setPositionX"],y:["getPositionY","setPositionY"],zIndex:["getLocalZOrder","setLocalZOrder"],opacityModifyRGB:["isOpacityModifyRGB","setOpacityModifyRGB"],cascadeOpacity:["isCascadeOpacityEnabled","setCascadeOpacityEnabled"]}),I.EventType=m,cc.Node=e.exports=I}),{"./event-manager":110,"./event/event":113,"./utils/base-node":221,"./utils/misc":226,"./utils/prefab-helper":228,"./utils/scene-graph-helper":229}],41:[(function(t,e,i){cc.Scene=cc.Class({name:"cc.Scene",extends:t("./CCNode"),properties:{autoReleaseAssets:{default:void 0,type:cc.Boolean}},ctor:function(){var t=this._sgNode=new _ccsg.Scene;t.setAnchorPoint(0,0),this._anchorPoint.x=0,this._anchorPoint.y=0,this._activeInHierarchy=!1,this._inited=!cc.game._isCloning,this.dependAssets=null},destroy:function(){this._super(),this._activeInHierarchy=!1},_onHierarchyChanged:function(){},_instantiate:null,_load:function(){this._inited||(this._onBatchCreated(),this._inited=!0)},_activate:function(t){t=!1!==t,cc.director._nodeActivator.activateNode(this,t)}}),e.exports=cc.Scene}),{"./CCNode":40}],42:[(function(t,e,i){function n(){this._lock=!1,this._scheduler=null,this._elapsed=-1,this._runForever=!1,this._useDelay=!1,this._timesExecuted=0,this._repeat=0,this._delay=0,this._interval=0,this._target=null,this._callback=null}var r=function(t,e,i,n,r,s,o){this.prev=t,this.next=e,this.callback=i,this.target=n,this.priority=r,this.paused=s,this.markedForDeletion=o,this.isUpdate=!i},s=[];r.get=function(t,e,i,n,o,a,c){var h=s.pop();return h?(h.prev=t,h.next=e,h.callback=i,h.target=n,h.priority=o,h.paused=a,h.markedForDeletion=c,h.isUpdate=!i):h=new r(t,e,i,n,o,a,c),h},r.put=function(t){s.length<20&&(t.prev=t.next=t.callback=t.target=null,s.push(t))};var o=function(t,e,i,n){this.list=t,this.entry=e,this.target=i,this.callback=n},a=[];o.get=function(t,e,i,n){var r=a.pop();return r?(r.list=t,r.entry=e,r.target=i,r.callback=n):r=new o(t,e,i,n),r},o.put=function(t){a.length<20&&(t.list=t.entry=t.target=t.callback=null,a.push(t))};var c=function(t,e,i,n,r,s){this.timers=t,this.target=e,this.timerIndex=i,this.currentTimer=n,this.currentTimerSalvaged=r,this.paused=s},h=[];c.get=function(t,e,i,n,r,s){var o=h.pop();return o?(o.timers=t,o.target=e,o.timerIndex=i,o.currentTimer=n,o.currentTimerSalvaged=r,o.paused=s):o=new c(t,e,i,n,r,s),o},c.put=function(t){h.length<20&&(t.timers=t.target=t.currentTimer=null,h.push(t))};var l=n.prototype;l.initWithCallback=function(t,e,i,n,r,s){return this._lock=!1,this._scheduler=t,this._target=i,this._callback=e,this._elapsed=-1,this._interval=n,this._delay=s,this._useDelay=this._delay>0,this._repeat=r,this._runForever=this._repeat===cc.macro.REPEAT_FOREVER,!0},l.getInterval=function(){return this._interval},l.setInterval=function(t){this._interval=t},l.update=function(t){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=t,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),this._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},l.getCallback=function(){return this._callback},l.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},l.cancel=function(){this._scheduler.unschedule(this._callback,this._target)};var u=[];n.get=function(){return u.pop()||new n},n.put=function(t){u.length<20&&!t._lock&&(t._scheduler=t._target=t._callback=null,u.push(t))};var _=function(t){return t.__instanceId||t.uuid};cc.Scheduler=cc._Class.extend({ctor:function(){this._timeScale=1,this._updatesNegList=[],this._updates0List=[],this._updatesPosList=[],this._hashForUpdates={},this._hashForTimers={},this._currentTarget=null,this._currentTargetSalvaged=!1,this._updateHashLocked=!1,this._arrayForTimers=[]},_removeHashElement:function(t){delete this._hashForTimers[_(t.target)];for(var e=this._arrayForTimers,i=0,n=e.length;i<n;i++)if(e[i]===t){e.splice(i,1);break}c.put(t)},_removeUpdateFromHash:function(t){var e=_(t.target),i=this._hashForUpdates[e];if(i){for(var n=i.list,s=i.entry,a=0,c=n.length;a<c;a++)if(n[a]===s){n.splice(a,1);break}delete this._hashForUpdates[e],r.put(s),o.put(i)}},_priorityIn:function(t,e,i){for(var n=0;n<t.length;n++)if(i<t[n].priority)return void t.splice(n,0,e);t.push(e)},_appendIn:function(t,e){t.push(e)},setTimeScale:function(t){this._timeScale=t},getTimeScale:function(){return this._timeScale},update:function(t){this._updateHashLocked=!0,1!==this._timeScale&&(t*=this._timeScale);var e,i,n,r;for(e=0,n=(i=this._updatesNegList).length;e<n;e++)(r=i[e]).paused||r.markedForDeletion||(r.isUpdate?r.target.update(t):r.callback.call(r.target,t));for(e=0,n=(i=this._updates0List).length;e<n;e++)(r=i[e]).paused||r.markedForDeletion||(r.isUpdate?r.target.update(t):r.callback.call(r.target,t));for(e=0,n=(i=this._updatesPosList).length;e<n;e++)(r=i[e]).paused||r.markedForDeletion||(r.isUpdate?r.target.update(t):r.callback.call(r.target,t));var s,o=this._arrayForTimers;for(e=0;e<o.length;e++){if(s=o[e],this._currentTarget=s,this._currentTargetSalvaged=!1,!s.paused)for(s.timerIndex=0;s.timerIndex<s.timers.length;++s.timerIndex)s.currentTimer=s.timers[s.timerIndex],s.currentTimerSalvaged=!1,s.currentTimer.update(t),s.currentTimer=null;this._currentTargetSalvaged&&0===this._currentTarget.timers.length&&(this._removeHashElement(this._currentTarget),--e)}for(e=0,i=this._updatesNegList;e<i.length;)(r=i[e]).markedForDeletion?this._removeUpdateFromHash(r):e++;for(e=0,i=this._updates0List;e<i.length;)(r=i[e]).markedForDeletion?this._removeUpdateFromHash(r):e++;for(e=0,i=this._updatesPosList;e<i.length;)(r=i[e]).markedForDeletion?this._removeUpdateFromHash(r):e++;this._updateHashLocked=!1,this._currentTarget=null},scheduleCallbackForTarget:function(t,e,i,n,r,s){this.schedule(e,t,i,n,r,s)},schedule:function(t,e,i,r,s,o){"use strict";if("function"!=typeof t){var a=t;t=e,e=a}4!==arguments.length&&5!==arguments.length||(o=!!r,r=cc.macro.REPEAT_FOREVER,s=0),cc.assertID(e,1502);var h=_(e);cc.assertID(h,1510);var l=this._hashForTimers[h];l?l.paused!==o&&cc.warnID(1511):(l=c.get(null,e,0,null,null,o),this._arrayForTimers.push(l),this._hashForTimers[h]=l);var u,d;if(null==l.timers)l.timers=[];else for(d=0;d<l.timers.length;++d)if((u=l.timers[d])&&t===u._callback)return cc.logID(1507,u.getInterval(),i),void(u._interval=i);(u=n.get()).initWithCallback(this,t,e,i,r,s),l.timers.push(u),this._currentTarget===l&&this._currentTargetSalvaged&&(this._currentTargetSalvaged=!1)},scheduleUpdate:function(t,e,i,n){var s=_(t);cc.assertID(s,1510);var a=this._hashForUpdates[s];if(a&&a.entry){if(a.entry.priority===e)return a.entry.markedForDeletion=!1,void(a.entry.paused=i);if(this._updateHashLocked)return cc.logID(1506),a.entry.markedForDeletion=!1,void(a.entry.paused=i);this.unscheduleUpdate(t)}n&&cc.warnID(1512);var c,h=r.get(null,null,n,t,e,i,!1);0===e?(c=this._updates0List,this._appendIn(c,h)):(c=e<0?this._updatesNegList:this._updatesPosList,this._priorityIn(c,h,e)),this._hashForUpdates[s]=o.get(c,h,t,null)},unschedule:function(t,e){if(e&&t){var i=_(e);cc.assertID(i,1510);var r=this._hashForTimers[i];if(r)for(var s=r.timers,o=0,a=s.length;o<a;o++){var c=s[o];if(t===c._callback)return c!==r.currentTimer||r.currentTimerSalvaged||(r.currentTimerSalvaged=!0),s.splice(o,1),n.put(c),r.timerIndex>=o&&r.timerIndex--,void(0===s.length&&(this._currentTarget===r?this._currentTargetSalvaged=!0:this._removeHashElement(r)))}}},unscheduleUpdate:function(t){if(t){var e=_(t);cc.assertID(e,1510);var i=this._hashForUpdates[e];i&&(this._updateHashLocked?i.entry.markedForDeletion=!0:this._removeUpdateFromHash(i.entry))}},unscheduleAllForTarget:function(t){if(t){var e=_(t);cc.assertID(e,1510);var i=this._hashForTimers[e];if(i){var r=i.timers;r.indexOf(i.currentTimer)>-1&&!i.currentTimerSalvaged&&(i.currentTimerSalvaged=!0);for(var s=0,o=r.length;s<o;s++)n.put(r[s]);r.length=0,this._currentTarget===i?this._currentTargetSalvaged=!0:this._removeHashElement(i)}this.unscheduleUpdate(t)}},unscheduleAll:function(){this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},unscheduleAllWithMinPriority:function(t){var e,i,n=this._arrayForTimers;for(e=n.length-1;e>=0;e--)i=n[e],this.unscheduleAllForTarget(i.target);var r,s=0;if(t<0)for(e=0;e<this._updatesNegList.length;)s=this._updatesNegList.length,(r=this._updatesNegList[e])&&r.priority>=t&&this.unscheduleUpdate(r.target),s==this._updatesNegList.length&&e++;if(t<=0)for(e=0;e<this._updates0List.length;)s=this._updates0List.length,(r=this._updates0List[e])&&this.unscheduleUpdate(r.target),s==this._updates0List.length&&e++;for(e=0;e<this._updatesPosList.length;)s=this._updatesPosList.length,(r=this._updatesPosList[e])&&r.priority>=t&&this.unscheduleUpdate(r.target),s==this._updatesPosList.length&&e++},isScheduled:function(t,e){cc.assertID(t,1508),cc.assertID(e,1509);var i=_(e);cc.assertID(i,1510);var n=this._hashForTimers[i];if(!n)return!1;if(null==n.timers)return!1;for(var r=n.timers,s=0;s<r.length;++s){if(t===r[s]._callback)return!0}return!1},pauseAllTargets:function(){return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},pauseAllTargetsWithMinPriority:function(t){var e,i,n,r=[],s=this._arrayForTimers;for(i=0,n=s.length;i<n;i++)(e=s[i])&&(e.paused=!0,r.push(e.target));var o;if(t<0)for(i=0;i<this._updatesNegList.length;i++)(o=this._updatesNegList[i])&&o.priority>=t&&(o.paused=!0,r.push(o.target));if(t<=0)for(i=0;i<this._updates0List.length;i++)(o=this._updates0List[i])&&(o.paused=!0,r.push(o.target));for(i=0;i<this._updatesPosList.length;i++)(o=this._updatesPosList[i])&&o.priority>=t&&(o.paused=!0,r.push(o.target));return r},resumeTargets:function(t){if(t)for(var e=0;e<t.length;e++)this.resumeTarget(t[e])},pauseTarget:function(t){cc.assertID(t,1503);var e=_(t);cc.assertID(e,1510);var i=this._hashForTimers[e];i&&(i.paused=!0);var n=this._hashForUpdates[e];n&&(n.entry.paused=!0)},resumeTarget:function(t){cc.assertID(t,1504);var e=_(t);cc.assertID(e,1510);var i=this._hashForTimers[e];i&&(i.paused=!1);var n=this._hashForUpdates[e];n&&(n.entry.paused=!1)},isTargetPaused:function(t){cc.assertID(t,1505);var e=_(t);cc.assertID(e,1510);var i=this._hashForTimers[e];if(i)return i.paused;var n=this._hashForUpdates[e];return!!n&&n.entry.paused},scheduleUpdateForTarget:function(t,e,i){this.scheduleUpdate(t,e,i)},unscheduleCallbackForTarget:function(t,e){this.unschedule(e,t)},unscheduleUpdateForTarget:function(t){this.unscheduleUpdate(t)},unscheduleAllCallbacksForTarget:function(t){this.unscheduleAllForTarget(t)},unscheduleAllCallbacks:function(){this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},unscheduleAllCallbacksWithMinPriority:function(t){this.unscheduleAllWithMinPriority(t)}}),cc.Scheduler.PRIORITY_SYSTEM=1<<31,cc.Scheduler.PRIORITY_NON_SYSTEM=cc.Scheduler.PRIORITY_SYSTEM+1}),{}],43:[(function(t,e,i){var n=t("./CCRawAsset");cc.Asset=cc.Class({name:"cc.Asset",extends:n,properties:{rawUrl:{get:function(){if(this._rawFiles){if(cc.AssetLibrary)return cc.AssetLibrary.getLibUrlNoExt(this._uuid)+"/"+this._rawFiles[0];cc.errorID(6400)}return""},visible:!1},rawUrls:{get:function(){if(this._rawFiles){if(cc.AssetLibrary){var t=cc.AssetLibrary.getLibUrlNoExt(this._uuid)+"/";return this._rawFiles.map((function(e){return t+e}))}cc.errorID(6401)}return[]},visible:!1},_rawFiles:null},statics:{deserialize:function(t){return cc.deserialize(t)},preventDeferredLoadDependents:!1},serialize:function(){return Editor.serialize(this)},createNode:null,_setRawFiles:function(t){this._rawFiles=t.length>0?t:null},_preloadRawFiles:null}),e.exports=cc.Asset}),{"./CCRawAsset":49}],44:[(function(t,e,i){var n=cc.Class({name:"cc.AudioClip",extends:cc.RawAsset});cc.AudioClip=n,e.exports=n}),{}],45:[(function(t,e,i){var n=cc.Class({name:"cc.BitmapFont",extends:cc.Font,properties:{fntDataStr:{default:""},spriteFrame:{default:null,type:cc.SpriteFrame},fontSize:{default:-1},_fntConfig:null}});cc.BitmapFont=n,e.exports=n}),{}],46:[(function(t,e,i){var n=cc.Class({name:"cc.Font",extends:cc.Asset});cc.Font=n,e.exports=n}),{}],47:[(function(t,e,i){var n=cc.Class({name:"cc.LabelAtlas",extends:cc.BitmapFont});cc.LabelAtlas=n,e.exports=n}),{}],48:[(function(t,e,i){var n=cc.Class({name:"cc.Prefab",extends:cc.Asset,properties:{data:null,asyncLoadAssets:void 0,_createFunction:{default:null,serializable:!1}},createNode:!1,compileCreateFunction:function(){var e=t("../platform/instantiate-jit");this._createFunction=e.compile(this.data)},_doInstantiate:function(t){return this.data._prefab?this.data._prefab._synced=!0:cc.warnID(3700),this._createFunction||this.compileCreateFunction(),this._createFunction(t)},_instantiate:function(){var t;return t=this._doInstantiate(),this.data._instantiate(t),t}});cc.Prefab=e.exports=n,cc.js.obsolete(cc,"cc._Prefab","Prefab")}),{"../platform/instantiate-jit":195}],49:[(function(t,e,i){var n=t("../platform/CCObject");cc.RawAsset=cc.Class({name:"cc.RawAsset",extends:n,ctor:function(){Object.defineProperty(this,"_uuid",{value:"",writable:!0})},statics:{createNodeByInfo:null}}),Object.defineProperty(cc.RawAsset,"isRawAssetType",{value:function(t){return cc.isChildClassOf(t,cc.RawAsset)&&!cc.isChildClassOf(t,cc.Asset)}}),e.exports=cc.RawAsset}),{"../platform/CCObject":182}],50:[(function(t,e,i){var n=cc.Class({name:"cc.SceneAsset",extends:cc.Asset,properties:{scene:null,asyncLoadAssets:void 0}});cc.SceneAsset=n,e.exports=n}),{}],51:[(function(t,e,i){var n=cc.Class({name:"cc.Script",extends:cc.Asset});cc._Script=n;var r=cc.Class({name:"cc.JavaScript",extends:n});cc._JavaScript=r;var s=cc.Class({name:"cc.CoffeeScript",extends:n});cc._CoffeeScript=s;var o=cc.Class({name:"cc.TypeScript",extends:n});cc._TypeScript=o}),{}],52:[(function(t,e,i){var n=cc.Class({name:"cc.SpriteAtlas",extends:cc.Asset,properties:{_spriteFrames:{default:{}}},getTexture:function(){var t=Object.keys(this._spriteFrames);if(t.length>0){var e=this._spriteFrames[t[0]];return e?e.getTexture():null}return null},getSpriteFrame:function(t){return this._spriteFrames[t]},getSpriteFrames:function(){var t=[],e=this._spriteFrames;for(var i in e)t.push(e[i]);return t}});cc.SpriteAtlas=n,e.exports=n}),{}],53:[(function(t,e,i){var n=cc.Class({name:"cc.TTFFont",extends:cc.Font});cc.TTFFont=n,e.exports=n}),{}],54:[(function(t,e,i){t("./CCRawAsset"),t("./CCAsset"),t("./CCFont"),t("./CCPrefab"),t("./CCAudioClip"),t("./CCScripts"),t("./CCSceneAsset"),t("../sprites/CCSpriteFrame"),t("../textures/CCTexture2D"),t("./CCTTFFont"),t("./CCSpriteAtlas"),t("./CCBitmapFont"),t("./CCLabelAtlas")}),{"../sprites/CCSpriteFrame":215,"../textures/CCTexture2D":216,"./CCAsset":43,"./CCAudioClip":44,"./CCBitmapFont":45,"./CCFont":46,"./CCLabelAtlas":47,"./CCPrefab":48,"./CCRawAsset":49,"./CCSceneAsset":50,"./CCScripts":51,"./CCSpriteAtlas":52,"./CCTTFFont":53}],55:[(function(t,e,i){var n=t("../utils/misc"),r=t("../event-manager"),s=!!cc.ActionManager,o=function(){};cc.s_globalOrderOfArrival=1,_ccsg.Node=cc.Class({name:"ccsg.Node",properties:{_running:!1,_localZOrder:0,_globalZOrder:0,_arrivalOrder:0,_reorderChildDirty:!1,_vertexZ:0,_customZ:void 0,_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:cc.p(0,0),_skewX:0,_skewY:0,_children:[],_visible:!0,_anchorPoint:cc.p(0,0),_contentSize:cc.size(0,0),_parent:null,_ignoreAnchorPointForPosition:!1,tag:cc.macro.NODE_TAG_INVALID,_name:"",_realOpacity:255,_realColor:cc.Color.WHITE,_cascadeColorEnabled:!1,_cascadeOpacityEnabled:!1,_isTransitionFinished:!1,_actionManager:null,_scheduler:null,_renderCmd:null},ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._renderCmd=this._createRenderCmd()},init:function(){return!0},attr:function(t){for(var e in t)this[e]=t[e]},getSkewX:function(){return this._skewX},setSkewX:function(t){this._skewX=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getSkewY:function(){return this._skewY},setSkewY:function(t){this._skewY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},setLocalZOrder:function(t){this._parent?this._parent.reorderChild(this,t):this._localZOrder=t,r._setDirtyForNode(this)},_setLocalZOrder:function(t){this._localZOrder=t},getLocalZOrder:function(){return this._localZOrder},getZOrder:function(){return cc.logID(1600),this.getLocalZOrder()},setZOrder:function(t){cc.logID(1601),this.setLocalZOrder(t)},setGlobalZOrder:function(t){this._globalZOrder!==t&&(this._globalZOrder=t,r._setDirtyForNode(this))},getGlobalZOrder:function(){return this._globalZOrder},getVertexZ:function(){return this._vertexZ},setVertexZ:function(t){this._customZ=this._vertexZ=t},getRotation:function(){return this._rotationX!==this._rotationY&&cc.logID(1602),this._rotationX},setRotation:function(t){this._rotationX=this._rotationY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getRotationX:function(){return this._rotationX},setRotationX:function(t){this._rotationX=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getRotationY:function(){return this._rotationY},setRotationY:function(t){this._rotationY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getScale:function(){return this._scaleX!==this._scaleY&&cc.logID(1603),this._scaleX},setScale:function(t,e){this._scaleX=t,this._scaleY=e||0===e?e:t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getScaleX:function(){return this._scaleX},setScaleX:function(t){this._scaleX=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getScaleY:function(){return this._scaleY},setScaleY:function(t){this._scaleY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},setPosition:function(t,e){var i=this._position;if(void 0===e){if(i.x===t.x&&i.y===t.y)return;i.x=t.x,i.y=t.y}else{if(i.x===t&&i.y===e)return;i.x=t,i.y=e}this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getPosition:function(){return cc.p(this._position)},getPositionX:function(){return this._position.x},setPositionX:function(t){this._position.x=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getPositionY:function(){return this._position.y},setPositionY:function(t){this._position.y=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getChildrenCount:function(){return this._children.length},getChildren:function(){return this._children},isVisible:function(){return this._visible},setVisible:function(t){this._visible!==t&&(this._visible=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty),cc.renderer.childrenOrderDirty=!0)},getAnchorPoint:function(){return cc.p(this._anchorPoint)},setAnchorPoint:function(t,e){var i=this._anchorPoint;if(void 0===e){if(t.x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this._renderCmd._updateAnchorPointInPoint()},_getAnchorX:function(){return this._anchorPoint.x},_setAnchorX:function(t){this._anchorPoint.x!==t&&(this._anchorPoint.x=t,this._renderCmd._updateAnchorPointInPoint())},_getAnchorY:function(){return this._anchorPoint.y},_setAnchorY:function(t){this._anchorPoint.y!==t&&(this._anchorPoint.y=t,this._renderCmd._updateAnchorPointInPoint())},getAnchorPointInPoints:function(){return this._renderCmd.getAnchorPointInPoints()},_getWidth:function(){return this._contentSize.width},_setWidth:function(t){this._contentSize.width=t,this._renderCmd._updateAnchorPointInPoint()},_getHeight:function(){return this._contentSize.height},_setHeight:function(t){this._contentSize.height=t,this._renderCmd._updateAnchorPointInPoint()},getContentSize:function(){return cc.size(this._contentSize)},setContentSize:function(t,e){var i=this._contentSize;if(void 0===e){if(t.width===i.width&&t.height===i.height)return;i.width=t.width,i.height=t.height}else{if(t===i.width&&e===i.height)return;i.width=t,i.height=e}this._renderCmd._updateAnchorPointInPoint()},isRunning:function(){return this._running},getParent:function(){return this._parent},setParent:function(t){this._parent=t;var e=_ccsg.Node._dirtyFlags;this._renderCmd.setDirtyFlag(e.transformDirty|e.opacityDirty)},isIgnoreAnchorPointForPosition:function(){return this._ignoreAnchorPointForPosition},setIgnoreAnchorPointForPosition:function(t){t!==this._ignoreAnchorPointForPosition&&(this._ignoreAnchorPointForPosition=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty))},getTag:function(){return this.tag},setTag:function(t){this.tag=t},setName:function(t){this._name=t},getName:function(){return this._name},updateOrderOfArrival:function(){this._arrivalOrder=++cc.s_globalOrderOfArrival},getScheduler:function(){return this._scheduler||cc.director.getScheduler()},setScheduler:function(t){this._scheduler!==t&&(this.unscheduleAllCallbacks(),this._scheduler=t)},boundingBox:function(){return cc.logID(1608),this.getBoundingBox()},getBoundingBox:function(){var t=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc._rectApplyAffineTransformIn(t,this.getNodeToParentTransform())},cleanup:function(){this.stopAllActions(),this.unscheduleAllCallbacks(),r.removeListeners(this)},getChildByTag:function(t){var e=this._children;if(null!==e)for(var i=0;i<e.length;i++){var n=e[i];if(n&&n.tag===t)return n}return null},getChildByName:function(t){if(!t)return cc.log("Invalid name"),null;for(var e=this._children,i=0,n=e.length;i<n;i++)if(e[i]._name===t)return e[i];return null},addChild:function(t,e,i){e=void 0===e?t._localZOrder:e;var n,r=!1;void 0===i?n=t._name:"string"==typeof i?(n=i,i=void 0):"number"==typeof i&&(r=!0,n=""),cc.assertID(t,1606),cc.assertID(null===t._parent,1605),this._addChildHelper(t,e,i,n,r)},_addChildHelper:function(t,e,i,n,r){this._children||(this._children=[]),this._insertChild(t,e),r?t.setTag(i):t.setName(n),t.setParent(this),t.updateOrderOfArrival(),this._running&&(t.performRecursive(_ccsg.Node.performType.onEnter),this._isTransitionFinished&&t.performRecursive(_ccsg.Node.performType.onEnterTransitionDidFinish)),t._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty),this._cascadeColorEnabled&&t._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.colorDirty),this._cascadeOpacityEnabled&&t._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.opacityDirty)},removeFromParent:function(t){this._parent&&(void 0===t&&(t=!0),this._parent.removeChild(this,t))},removeFromParentAndCleanup:function(t){cc.logID(1607),this.removeFromParent(t)},removeChild:function(t,e){0!==this._children.length&&(void 0===e&&(e=!0),this._children.indexOf(t)>-1&&this._detachChild(t,e),cc.renderer.childrenOrderDirty=!0)},removeChildByTag:function(t,e){t===cc.macro.NODE_TAG_INVALID&&cc.logID(1609);var i=this.getChildByTag(t);i?this.removeChild(i,e):cc.logID(1610,t)},removeAllChildrenWithCleanup:function(t){this.removeAllChildren(t)},removeAllChildren:function(t){var e=this._children;if(null!==e){void 0===t&&(t=!0);for(var i=0;i<e.length;i++){var n=e[i];n&&(this._running&&(n.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),n.performRecursive(_ccsg.Node.performType.onExit)),t&&n.performRecursive(_ccsg.Node.performType.cleanup),n.parent=null,n._renderCmd.detachFromParent())}this._children.length=0,cc.renderer.childrenOrderDirty=!0}},_detachChild:function(t,e){this._running&&(t.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),t.performRecursive(_ccsg.Node.performType.onExit)),e&&t.performRecursive(_ccsg.Node.performType.cleanup),t.parent=null,t._renderCmd.detachFromParent(),cc.js.array.remove(this._children,t)},_insertChild:function(t,e){cc.renderer.childrenOrderDirty=this._reorderChildDirty=!0,this._children.push(t),t._setLocalZOrder(e)},setNodeDirty:function(){this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},reorderChild:function(t,e){cc.assertID(t,1617),-1!==this._children.indexOf(t)?e!==t.zIndex&&(cc.renderer.childrenOrderDirty=this._reorderChildDirty=!0,t.updateOrderOfArrival(),t._setLocalZOrder(e),this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.orderDirty)):cc.logID(1635)},sortAllChildren:function(){if(this._reorderChildDirty){var t,e,i,n=this._children,r=n.length;for(t=1;t<r;t++){for(i=n[t],e=t-1;e>=0;){if(i._localZOrder<n[e]._localZOrder)n[e+1]=n[e];else{if(!(i._localZOrder===n[e]._localZOrder&&i._arrivalOrder<n[e]._arrivalOrder))break;n[e+1]=n[e]}e--}n[e+1]=i}this._reorderChildDirty=!1}},draw:function(t){},transformAncestors:function(){null!==this._parent&&(this._parent.transformAncestors(),this._parent.transform())},onEnter:function(){this._isTransitionFinished=!1,this._running=!0,this.resume()},performRecursive:function(t){var e=_ccsg.Node.performType;if(!(t>=e.max)){var i,n,r,s,o,a=0,c=_ccsg.Node._performStacks[_ccsg.Node._performing];for(c||(c=[],_ccsg.Node._performStacks.push(c)),c.length=0,_ccsg.Node._performing++,r=c[0]=this;r;){if((i=r._children)&&i.length>0)for(s=0,o=i.length;s<o;++s)n=i[s],c.push(n);r=c[++a]}switch(t){case e.onEnter:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onEnter();break;case e.onExit:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onExit();break;case e.onEnterTransitionDidFinish:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onEnterTransitionDidFinish();break;case e.cleanup:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.cleanup();break;case e.onExitTransitionDidStart:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onExitTransitionDidStart()}_ccsg.Node._performing--}},onEnterTransitionDidFinish:function(){this._isTransitionFinished=!0},onExitTransitionDidStart:function(){},onExit:function(){this._running=!1,this.pause()},runAction:s?function(t){return cc.assertID(t,1618),cc.director.getActionManager().addAction(t,this,!this._running),t}:o,stopAllActions:s?function(){cc.director.getActionManager().removeAllActionsFromTarget(this)}:o,stopAction:s?function(t){cc.director.getActionManager().removeAction(t)}:o,stopActionByTag:s?function(t){t!==cc.Action.TAG_INVALID?cc.director.getActionManager().removeActionByTag(t,this):cc.logID(1612)}:o,getActionByTag:s?function(t){return t===cc.Action.TAG_INVALID?(cc.logID(1613),null):cc.director.getActionManager().getActionByTag(t,this)}:function(){return null},getNumberOfRunningActions:s?function(){return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this)}:function(){return 0},scheduleUpdate:function(){this.scheduleUpdateWithPriority(0)},scheduleUpdateWithPriority:function(t){this.scheduler.scheduleUpdate(this,t,!this._running)},unscheduleUpdate:function(){this.scheduler.unscheduleUpdate(this)},schedule:function(t,e,i,n,r){var s=arguments.length;"function"==typeof t?1===s?(e=0,i=cc.macro.REPEAT_FOREVER,n=0,r=this.__instanceId):2===s?"number"==typeof e?(i=cc.macro.REPEAT_FOREVER,n=0,r=this.__instanceId):(r=e,e=0,i=cc.macro.REPEAT_FOREVER,n=0):3===s?("string"==typeof i?(r=i,i=cc.macro.REPEAT_FOREVER):r=this.__instanceId,n=0):4===s&&(r=this.__instanceId):1===s?(e=0,i=cc.macro.REPEAT_FOREVER,n=0):2===s&&(i=cc.macro.REPEAT_FOREVER,n=0),cc.assertID(t,1619),cc.assertID(e>=0,1620),e=e||0,i=isNaN(i)?cc.macro.REPEAT_FOREVER:i,n=n||0,this.scheduler.schedule(t,this,e,i,n,!this._running,r)},scheduleOnce:function(t,e,i){void 0===i&&(i=this.__instanceId),this.schedule(t,0,0,e,i)},unschedule:function(t){t&&this.scheduler.unschedule(t,this)},unscheduleAllCallbacks:function(){this.scheduler.unscheduleAllForTarget(this)},resumeSchedulerAndActions:function(){cc.logID(1614),this.resume()},resume:function(){this.scheduler.resumeTarget(this),s&&cc.director.getActionManager().resumeTarget(this),r.resumeTarget(this)},pauseSchedulerAndActions:function(){cc.logID(1615),this.pause()},pause:function(){this.scheduler.pauseTarget(this),s&&cc.director.getActionManager().pauseTarget(this),r.pauseTarget(this)},getParentToNodeTransform:function(){return this._renderCmd.getParentToNodeTransform()},parentToNodeTransform:function(){return this.getParentToNodeTransform()},getNodeToWorldTransform:function(){for(var t=this.getNodeToParentTransform(),e=this._parent;null!==e;e=e.parent)t=cc.affineTransformConcat(t,e.getNodeToParentTransform());return t},nodeToWorldTransform:function(){return this.getNodeToWorldTransform()},getWorldToNodeTransform:function(){return cc.affineTransformInvert(this.getNodeToWorldTransform())},worldToNodeTransform:function(){return this.getWorldToNodeTransform()},convertToNodeSpace:function(t){return cc.pointApplyAffineTransform(t,this.getWorldToNodeTransform())},convertToWorldSpace:function(t){return t=t||cc.v2(0,0),cc.pointApplyAffineTransform(t,this.getNodeToWorldTransform())},convertToNodeSpaceAR:function(t){return cc.pSub(this.convertToNodeSpace(t),this._renderCmd.getAnchorPointInPoints())},convertToWorldSpaceAR:function(t){t=t||cc.v2(0,0);var e=cc.pAdd(t,this._renderCmd.getAnchorPointInPoints());return this.convertToWorldSpace(e)},_convertToWindowSpace:function(t){var e=this.convertToWorldSpace(t);return cc.director.convertToUI(e)},convertTouchToNodeSpace:function(t){var e=t.getLocation();return this.convertToNodeSpace(e)},convertTouchToNodeSpaceAR:function(t){var e=cc.director.convertToGL(t.getLocation());return this.convertToNodeSpaceAR(e)},updateTransform:function(){for(var t=this._children,e=0;e<t.length;e++){var i;(i=t[e])&&i.updateTransform()}},retain:function(){},release:function(){},visit:function(t){var e=this._renderCmd,i=t?t._renderCmd:null;if(this._visible){var n=cc.renderer;e.visit(i);var r,s,o=this._children,a=o.length;if(a>0){for(this._reorderChildDirty&&this.sortAllChildren(),r=0;r<a&&(s=o[r])._localZOrder<0;r++)s.visit(this);for(n.pushRenderCommand(e);r<a;r++)o[r].visit(this)}else n.pushRenderCommand(e);e._dirtyFlag=0}else e._propagateFlagsDown(i)},transform:function(t,e){this._renderCmd.transform(t,e)},nodeToParentTransform:function(){return this.getNodeToParentTransform()},getNodeToParentTransform:function(t){var e=this._renderCmd.getNodeToParentTransform();if(t){for(var i={a:e.a,b:e.b,c:e.c,d:e.d,tx:e.tx,ty:e.ty},n=this._parent;null!=n&&n!=t;n=n.getParent())cc.affineTransformConcatIn(i,n.getNodeToParentTransform());return i}return e},getNodeToParentAffineTransform:function(t){return this.getNodeToParentTransform(t)},getShaderProgram:function(){return this._renderCmd.getShaderProgram()},setShaderProgram:function(t){this._renderCmd.setShaderProgram(t)},getGLServerState:function(){return 0},setGLServerState:function(t){},getBoundingBoxToWorld:function(){var t=cc.rect(0,0,this._contentSize.width,this._contentSize.height),e=this.getNodeToWorldTransform();if(cc._rectApplyAffineTransformIn(t,e),!this._children)return t;for(var i=this._children,n=0;n<i.length;n++){var r=i[n];if(r&&r._visible){var s=r._getBoundingBoxToCurrentNode(e);s&&(t=cc.rectUnion(t,s))}}return t},_getBoundingBoxToCurrentNode:function(t){var e=cc.rect(0,0,this._contentSize.width,this._contentSize.height),i=void 0===t?this.getNodeToParentTransform():cc.affineTransformConcat(this.getNodeToParentTransform(),t);if(cc._rectApplyAffineTransformIn(e,i),!this._children)return e;for(var n=this._children,r=0;r<n.length;r++){var s=n[r];if(s&&s._visible){var o=s._getBoundingBoxToCurrentNode(i);o&&(e=cc.rectUnion(e,o))}}return e},getOpacity:function(){return this._realOpacity},getDisplayedOpacity:function(){return this._renderCmd.getDisplayedOpacity()},setOpacity:function(t){this._realOpacity=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.opacityDirty)},updateDisplayedOpacity:function(t){this._renderCmd._updateDisplayOpacity(t)},isCascadeOpacityEnabled:function(){return this._cascadeOpacityEnabled},setCascadeOpacityEnabled:function(t){this._cascadeOpacityEnabled!==t&&(this._cascadeOpacityEnabled=t,this._renderCmd.setCascadeOpacityEnabledDirty())},getColor:function(){var t=this._realColor;return cc.color(t.r,t.g,t.b,t.a)},getDisplayedColor:function(){return this._renderCmd.getDisplayedColor()},setColor:function(t){var e=this._realColor;e.r=t.r,e.g=t.g,e.b=t.b,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.colorDirty)},updateDisplayedColor:function(t){this._renderCmd._updateDisplayColor(t)},isCascadeColorEnabled:function(){return this._cascadeColorEnabled},setCascadeColorEnabled:function(t){this._cascadeColorEnabled!==t&&(this._cascadeColorEnabled=t,this._renderCmd.setCascadeColorEnabledDirty())},setOpacityModifyRGB:function(t){},isOpacityModifyRGB:function(){return!1},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.Node.CanvasRenderCmd(this):new _ccsg.Node.WebGLRenderCmd(this)}}),_ccsg.Node.extend=cc._Class.extend,_ccsg.Node.prototype.ctor=_ccsg.Node,_ccsg.Node.performType={onEnter:1,onExit:2,cleanup:3,onEnterTransitionDidFinish:4,onExitTransitionDidStart:5,max:6},_ccsg.Node._performStacks=[[]],_ccsg.Node._performing=0;n.propertyDefine(_ccsg.Node,["skewX","skewY","vertexZ","rotation","rotationX","rotationY","scale","scaleX","scaleY","children","childrenCount","parent","scheduler","shaderProgram","opacity","color"],{x:["getPositionX","setPositionX"],y:["getPositionY","setPositionY"],width:["_getWidth","_setWidth"],height:["_getHeight","_setHeight"],anchorX:["_getAnchorX","_setAnchorX"],anchorY:["_getAnchorY","_setAnchorY"],zIndex:["getLocalZOrder","setLocalZOrder"],visible:["isVisible","setVisible"],running:["isRunning"],ignoreAnchor:["isIgnoreAnchorPointForPosition","setIgnoreAnchorPointForPosition"],opacityModifyRGB:["isOpacityModifyRGB","setOpacityModifyRGB"],cascadeOpacity:["isCascadeOpacityEnabled","setCascadeOpacityEnabled"],cascadeColor:["isCascadeColorEnabled","setCascadeColorEnabled"]})}),{"../event-manager":110,"../utils/misc":226}],56:[(function(t,e,i){function n(t,e){var i,n,r,s,o,a,c=1,h=_ccsg.Node._performStacks[_ccsg.Node._performing];h||(h=[],_ccsg.Node._performStacks.push(h)),h.length=0,_ccsg.Node._performing++,h[0]=t;for(;c;)if(c--,r=h[c],h[c]=null,r&&(i=r._children)&&i.length>0)for(s=r._renderCmd,o=0,a=i.length;o<a;++o)n=i[o],h[c]=n,c++,n._renderCmd[e](s);_ccsg.Node._performing--}cc.CustomRenderCmd=function(t,e){this._needDraw=!0,this._target=t,this._callback=e},cc.CustomRenderCmd.prototype.rendering=function(t,e,i){this._callback&&this._callback.call(this._target,t,e,i)};var r=_ccsg.Node._dirtyFlags={transformDirty:1,visibleDirty:2,colorDirty:4,opacityDirty:8,cacheDirty:16,orderDirty:32,textDirty:64,gradientDirty:128,textureDirty:256,contentDirty:512,cullingDirty:1024,COUNT:9};cc.js.get(r,"all",(function(){return(1<<r.COUNT)-1}),!1),_ccsg.Node._requestDirtyFlag=function(t){cc.assertID(!r[t],1622,t);var e=1<<r.COUNT;return r[t]=e,r.COUNT++,e};var s=Math.PI/180;_ccsg.Node.RenderCmd=function(t){this._node=t,this._anchorPointInPoints=new cc.Vec2(0,0),this._needDraw=!1,this._dirtyFlag=1,this._curLevel=-1,this._cameraFlag=0,this._displayedColor=new cc.Color(255,255,255,255),this._displayedOpacity=255,this._cascadeColorEnabledDirty=!1,this._cascadeOpacityEnabledDirty=!1,this._transform={a:1,b:0,c:0,d:1,tx:0,ty:0},this._worldTransform={a:1,b:0,c:0,d:1,tx:0,ty:0},this._inverse={a:1,b:0,c:0,d:1,tx:0,ty:0},this._transformUpdated=!1,cc.renderer.pushDirtyNode(this)},_ccsg.Node.RenderCmd.prototype={constructor:_ccsg.Node.RenderCmd,_ctor:_ccsg.Node.RenderCmd,getAnchorPointInPoints:function(){return cc.p(this._anchorPointInPoints)},getDisplayedColor:function(){var t=this._displayedColor;return cc.color(t.r,t.g,t.b,t.a)},getDisplayedOpacity:function(){return this._displayedOpacity},setCascadeColorEnabledDirty:function(){this._cascadeColorEnabledDirty=!0,this.setDirtyFlag(r.colorDirty)},setCascadeOpacityEnabledDirty:function(){this._cascadeOpacityEnabledDirty=!0,this.setDirtyFlag(r.opacityDirty)},getParentToNodeTransform:function(){return this._dirtyFlag&r.transformDirty&&cc.affineTransformInvertOut(this.getNodeToParentTransform(),this._inverse),this._inverse},detachFromParent:function(){},_updateAnchorPointInPoint:function(){var t=this._anchorPointInPoints,e=this._node._contentSize,i=this._node._anchorPoint;t.x=e.width*i.x,t.y=e.height*i.y,this.setDirtyFlag(r.transformDirty)},setDirtyFlag:function(t){0===this._dirtyFlag&&0!==t&&cc.renderer.pushDirtyNode(this),this._dirtyFlag|=t},getParentRenderCmd:function(){return this._node&&this._node._parent&&this._node._parent._renderCmd?this._node._parent._renderCmd:null},updateTransform:function(t,e){var i=this._node,n=t?t._worldTransform:null,r=this._transform,o=this._worldTransform;if(!this._transformUpdated){var a=i._rotationX||i._rotationY,c=i._skewX||i._skewY,h=i._scaleX,l=i._scaleY,u=this._anchorPointInPoints.x,_=this._anchorPointInPoints.y,d=1,f=0,p=0,m=1;if(a||c){if(r.tx=i._position.x,r.ty=i._position.y,a){var g=i._rotationX*s;if(p=Math.sin(g),m=Math.cos(g),i._rotationY===i._rotationX)d=m,f=-p;else{var y=i._rotationY*s;d=Math.cos(y),f=-Math.sin(y)}}if(r.a=d*=h,r.b=f*=h,r.c=p*=l,r.d=m*=l,c){var v=Math.tan(i._skewX*s),x=Math.tan(i._skewY*s);v===1/0&&(v=99999999),x===1/0&&(x=99999999),r.a=d+p*x,r.b=f+m*x,r.c=p+d*v,r.d=m+f*v}(u||_)&&(r.tx-=r.a*u+r.c*_,r.ty-=r.b*u+r.d*_,i._ignoreAnchorPointForPosition&&(r.tx+=u,r.ty+=_))}else r.a=h,r.b=0,r.c=0,r.d=l,r.tx=i._position.x,r.ty=i._position.y,(u||_)&&(r.tx-=r.a*u,r.ty-=r.d*_,i._ignoreAnchorPointForPosition&&(r.tx+=u,r.ty+=_))}n?(o.a=r.a*n.a+r.b*n.c,o.b=r.a*n.b+r.b*n.d,o.c=r.c*n.a+r.d*n.c,o.d=r.c*n.b+r.d*n.d,o.tx=r.tx*n.a+r.ty*n.c+n.tx,o.ty=r.tx*n.b+r.ty*n.d+n.ty):(o.a=r.a,o.b=r.b,o.c=r.c,o.d=r.d,o.tx=r.tx,o.ty=r.ty)},transform:function(t,e){this.updateTransform(t),this._currentRegion&&(this._updateCurrentRegions(),this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble)),cc.macro.ENABLE_CULLING?(this._updateCameraFlag(t),this._doCulling&&this._doCulling()):this._doCulling&&(this._needDraw=!0),e&&n(this._node,"transform")},_updateCameraFlag:function(t){var e=cc.Camera;cc._renderType===cc.game.RENDER_TYPE_WEBGL&&e&&t&&this._cameraFlag!=e.flags.InCamera&&(this._cameraFlag=t._cameraFlag>0?e.flags.ParentInCamera:0)},culling:function(t,e){cc.macro.ENABLE_CULLING?(this._updateCameraFlag(t),this._doCulling&&this._doCulling(),e&&n(this._node,"culling")):this._doCulling&&(this._needDraw=!0)},getNodeToParentTransform:function(){return this._dirtyFlag&r.transformDirty&&this.transform(),this._transform},setNodeToParentTransform:function(t){t?(this._transform=t,this._transformUpdated=!0):this._transformUpdated=!1,this.setDirtyFlag(r.transformDirty)},_propagateFlagsDown:function(t){if(t){var e=this._dirtyFlag,i=t._node,n=t._dirtyFlag;i._cascadeColorEnabled&&n&r.colorDirty&&(e|=r.colorDirty),i._cascadeOpacityEnabled&&n&r.opacityDirty&&(e|=r.opacityDirty),n&r.transformDirty&&(e|=r.transformDirty),n&r.cullingDirty&&(e|=r.cullingDirty),this._dirtyFlag=e}},visit:function(t){var e=this._node,i=cc.renderer;t&&(this._curLevel=t._curLevel+1),this._propagateFlagsDown(t),isNaN(e._customZ)&&(e._vertexZ=i.assignedZ,i.assignedZ+=i.assignedZStep),this._syncStatus(t)},_updateDisplayColor:function(t){var e,i,n,s,o=this._node,a=this._displayedColor,c=o._realColor;if(this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty),this._cascadeColorEnabledDirty&&!o._cascadeColorEnabled){a.r=c.r,a.g=c.g,a.b=c.b;var h=new cc.Color(255,255,255,255);for(e=0,i=(n=o._children).length;e<i;e++)(s=n[e])&&s._renderCmd&&s._renderCmd._updateDisplayColor(h);this._cascadeColorEnabledDirty=!1}else{if(void 0===t){var l=o._parent;t=l&&l._cascadeColorEnabled?l.getDisplayedColor():cc.Color.WHITE}if(a.r=0|c.r*t.r/255,a.g=0|c.g*t.g/255,a.b=0|c.b*t.b/255,o._cascadeColorEnabled)for(e=0,i=(n=o._children).length;e<i;e++)(s=n[e])&&s._renderCmd&&(s._renderCmd._updateDisplayColor(a),s._renderCmd._updateColor())}this._dirtyFlag&=~r.colorDirty},_updateDisplayOpacity:function(t){var e,i,n,s,o=this._node;if(this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty),this._cascadeOpacityEnabledDirty&&!o._cascadeOpacityEnabled){for(this._displayedOpacity=o._realOpacity,e=0,i=(n=o._children).length;e<i;e++)(s=n[e])&&s._renderCmd&&s._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else{if(void 0===t){var a=o._parent;t=255,a&&a._cascadeOpacityEnabled&&(t=a.getDisplayedOpacity())}if(this._displayedOpacity=o._realOpacity*t/255,o._cascadeOpacityEnabled)for(e=0,i=(n=o._children).length;e<i;e++)(s=n[e])&&s._renderCmd&&(s._renderCmd._updateDisplayOpacity(this._displayedOpacity),s._renderCmd._updateColor())}this._dirtyFlag&=~r.opacityDirty},_syncDisplayColor:function(t){var e=this._node,i=this._displayedColor,n=e._realColor;if(void 0===t){var r=e._parent;t=r&&r._cascadeColorEnabled?r.getDisplayedColor():cc.Color.WHITE}i.r=0|n.r*t.r/255,i.g=0|n.g*t.g/255,i.b=0|n.b*t.b/255},_syncDisplayOpacity:function(t){var e=this._node;if(void 0===t){var i=e._parent;t=255,i&&i._cascadeOpacityEnabled&&(t=i.getDisplayedOpacity())}this._displayedOpacity=e._realOpacity*t/255},_updateColor:function(){},updateStatus:function(){var t=this._dirtyFlag,e=t&r.colorDirty,i=t&r.opacityDirty;if(t&r.contentDirty&&(this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty),this._dirtyFlag&=~r.contentDirty),e&&this._updateDisplayColor(),i&&this._updateDisplayOpacity(),(e||i)&&this._updateColor(),t&r.transformDirty){var n=this.getParentRenderCmd();this.transform(n,!0),this._dirtyFlag&=~r.transformDirty,this._dirtyFlag&=~r.cullingDirty}else t&r.cullingDirty&&(this.culling(n,!0),this._dirtyFlag&=~r.cullingDirty)},_syncStatus:function(t){var e=this._dirtyFlag,i=e&r.colorDirty,n=e&r.opacityDirty;i&&this._syncDisplayColor(),n&&this._syncDisplayOpacity(),(i||n)&&this._updateColor(),e&r.transformDirty?this.transform(t):e&r.cullingDirty&&this.culling(t)}},_ccsg.Node.RenderCmd.prototype.originUpdateTransform=_ccsg.Node.RenderCmd.prototype.updateTransform,_ccsg.Node.RenderCmd.prototype.originTransform=_ccsg.Node.RenderCmd.prototype.transform,_ccsg.Node.RenderCmd.prototype.originCulling=_ccsg.Node.RenderCmd.prototype.culling,_ccsg.Node.RenderCmd.prototype.originUpdateStatus=_ccsg.Node.RenderCmd.prototype.updateStatus,_ccsg.Node.RenderCmd.prototype._originSyncStatus=_ccsg.Node.RenderCmd.prototype._syncStatus}),{}],57:[(function(t,e,i){_ccsg.Node.CanvasRenderCmd=function(t){this._ctor(t),this._currentRegion=new cc.Region,this._oldRegion=new cc.Region,this._regionFlag=0},_ccsg.Node.CanvasRenderCmd.RegionStatus={NotDirty:0,Dirty:1,DirtyDouble:2};var n=_ccsg.Node.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.RenderCmd.prototype);n.constructor=_ccsg.Node.CanvasRenderCmd,n._rootCtor=_ccsg.Node.CanvasRenderCmd,n._notifyRegionStatus=function(t){this._needDraw&&this._regionFlag<t&&(this._regionFlag=t)};var r=new cc.Rect;n.getLocalBB=function(){var t=this._node;return r.x=r.y=0,r.width=t._contentSize.width,r.height=t._contentSize.height,r},n._updateCurrentRegions=function(){var t=this._currentRegion;this._currentRegion=this._oldRegion,this._oldRegion=t,_ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble!==this._regionFlag||this._currentRegion.isEmpty()||this._oldRegion.union(this._currentRegion),this._currentRegion.updateRegion(this.getLocalBB(),this._worldTransform)},n.detachFromParent=function(){for(var t,e=this._node._children,i=0,n=e.length;i<n;i++)(t=e[i])&&t._renderCmd&&t._renderCmd.detachFromParent()},n.setShaderProgram=function(t){},n.getShaderProgram=function(){return null},_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc=function(t){return t?t.src===cc.macro.SRC_ALPHA&&t.dst===cc.macro.ONE||t.src===cc.macro.ONE&&t.dst===cc.macro.ONE?"lighter":t.src===cc.macro.ZERO&&t.dst===cc.macro.SRC_ALPHA?"destination-in":t.src===cc.macro.ZERO&&t.dst===cc.macro.ONE_MINUS_SRC_ALPHA?"destination-out":"source-over":"source-over"}}),{}],58:[(function(t,e,i){_ccsg.Node.WebGLRenderCmd=function(t){this._ctor(t),this._shaderProgram=null};var n=_ccsg.Node.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.RenderCmd.prototype);n.constructor=_ccsg.Node.WebGLRenderCmd,n._rootCtor=_ccsg.Node.WebGLRenderCmd,n._updateColor=function(){},n.setShaderProgram=function(t){this._shaderProgram=t},n.getShaderProgram=function(){return this._shaderProgram}}),{}],59:[(function(t,e,i){function n(t){return t instanceof cc.Scene?cc.visibleRect:!t._sizeProvider||t._sizeProvider instanceof _ccsg.Node?t._contentSize:t.getContentSize()}function r(t,e,i,n){for(var r=t._parent._scaleX,s=t._parent._scaleY,o=0,a=0,c=t._parent;;){var h=c._position;if(o+=h.x,a+=h.y,!(c=c._parent))return i.x=i.y=0,void(n.x=n.y=1);if(c===e)break;var l=c._scaleX,u=c._scaleY;o*=l,a*=u,r*=l,s*=u}n.x=0!==r?1/r:1,n.y=0!==s?1/s:1,i.x=-o,i.y=-a}function s(t,e){var i,s,o,a=e._target;a?r(t,i=a,s=u,o=_):i=t._parent;var c=n(i),d=i._anchorPoint,f=i instanceof cc.Scene,p=t._position.x,m=t._position.y,g=t._anchorPoint;if(e._alignFlags&h){var y,v,x=c.width;f?(y=cc.visibleRect.left.x,v=cc.visibleRect.right.x):v=(y=-d.x*x)+x,y+=e._isAbsLeft?e._left:e._left*x,v-=e._isAbsRight?e._right:e._right*x,a&&(y+=s.x,y*=o.x,v+=s.x,v*=o.x);var C,T=g.x,b=t._scaleX;if(b<0&&(T=1-T,b=-b),e.isStretchWidth)C=v-y,0!==b&&(t.width=C/b),p=y+T*C;else if(C=t.width*b,e.isAlignHorizontalCenter){var A=e._isAbsHorizontalCenter?e._horizontalCenter:e._horizontalCenter*x,S=(.5-d.x)*c.width;a&&(A*=o.x,S+=s.x,S*=o.x),p=S+(T-.5)*C+A}else p=e.isAlignLeft?y+T*C:v+(T-1)*C}if(e._alignFlags&l){var w,E,I=c.height;f?(E=cc.visibleRect.bottom.y,w=cc.visibleRect.top.y):w=(E=-d.y*I)+I,E+=e._isAbsBottom?e._bottom:e._bottom*I,w-=e._isAbsTop?e._top:e._top*I,a&&(E+=s.y,E*=o.y,w+=s.y,w*=o.y);var R,P=g.y,O=t._scaleY;if(O<0&&(P=1-P,O=-O),e.isStretchHeight)R=w-E,0!==O&&(t.height=R/O),m=E+P*R;else if(R=t.height*O,e.isAlignVerticalCenter){var B=e._isAbsVerticalCenter?e._verticalCenter:e._verticalCenter*I,D=(.5-d.y)*c.height;a&&(B*=o.y,D+=s.y,D*=o.y),m=D+(P-.5)*R+B}else m=e.isAlignBottom?E+P*R:w+(P-1)*R}t.setPosition(p,m)}function o(t){var e=t._widget;if(e){s(t,e),e.isAlignOnce?e.enabled=!1:d.push(e)}for(var i=t._children,n=0;n<i.length;n++){var r=i[n];r._active&&o(r)}}function a(){var t=cc.director.getScene();if(t){if(f.isAligning=!0,f._nodesOrderDirty)d.length=0,o(t),f._nodesOrderDirty=!1;else{var e,i=f._activeWidgetsIterator;for(i.i=0;i.i<d.length;++i.i)s((e=d[i.i]).node,e)}f.isAligning=!1}}function c(t){var e=t._parent;cc.Node.isNode(e)&&c(e);var i=t._widget||t.getComponent(cc.Widget);i&&s(t,i)}var h=56,l=7,u=cc.Vec2.ZERO,_=cc.Vec2.ONE,d=[],f=cc._widgetManager=e.exports={_AlignFlags:{TOP:1,MID:2,BOT:4,LEFT:8,CENTER:16,RIGHT:32},isAligning:!1,_nodesOrderDirty:!1,_activeWidgetsIterator:new cc.js.array.MutableForwardIterator(d),init:function(t){t.on(cc.Director.EVENT_BEFORE_VISIT,a)},add:function(t){t.node._widget=t,this._nodesOrderDirty=!0},remove:function(t){t.node._widget=null,this._activeWidgetsIterator.remove(t)},updateAlignment:c}}),{}],60:[(function(t,e,i){var n;n=_ccsg.Node._dirtyFlags.cullingDirty,t("./CCSGCameraNode");var r=cc.Class({name:"cc.Camera",extends:cc._RendererUnderSG,ctor:function(){this.viewMatrix=cc.affineTransformMake(),this.invertViewMatrix=cc.affineTransformMake(),this._lastViewMatrix=cc.affineTransformMake(),this._sgTarges=[],this._checkedTimes=0,this.visibleRect={left:cc.v2(),right:cc.v2(),top:cc.v2(),bottom:cc.v2()},this.viewPort=cc.rect()},editor:!1,properties:{_targets:{default:[],type:cc.Node,visible:!0},zoomRatio:1},statics:{main:null},_createSgNode:function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){cc.errorID(8301);var t=new _ccsg.Node;return t.setTransform=t.addTarget=t.removeTarget=function(){},t}return new _ccsg.CameraNode},_initSgNode:function(){this._sgNode.setContentSize(this.node.getContentSize(!0))},_addSgTargetInSg:function(t){var e;if(t instanceof cc.Node?e=t._sgNode:t instanceof _ccsg.Node&&(e=t),e&&!e._cameraInfo){e._cameraInfo={touched:this._checkedTimes},this._sgNode.addTarget(e),this._sgTarges.push(e);var i=e._renderCmd;i.setDirtyFlag(n),i._cameraFlag=r.flags.InCamera,cc.renderer.childrenOrderDirty=!0}},_removeTargetInSg:function(t){var e;if(t instanceof cc.Node?e=t._sgNode:t instanceof _ccsg.Node&&(e=t),e&&e._cameraInfo){this._sgNode.removeTarget(e),delete e._cameraInfo,cc.js.array.remove(this._sgTarges,e);var i=e._renderCmd;i.setDirtyFlag(n),i._cameraFlag=0,cc.renderer.childrenOrderDirty=!0}},onEnable:function(){if(r.main)cc.errorID(8300);else{r.main=this;for(var t=this._targets,e=0,i=t.length;e<i;e++)this._addSgTargetInSg(t[e])}},onDisable:function(){if(r.main===this){r.main=null;for(var t=this._sgTarges,e=t.length-1;e>=0;e--)this._removeTargetInSg(t[e])}},addTarget:function(t){-1===this._targets.indexOf(t)&&(this._addSgTargetInSg(t),this._targets.push(t))},removeTarget:function(t){-1!==this._targets.indexOf(t)&&(this._removeTargetInSg(t),cc.js.array.remove(this._targets,t))},getTargets:function(){return this._targets},getNodeToCameraTransform:function(t){var e=t.getNodeToWorldTransform();return this.containsNode(t)&&(e=cc.affineTransformConcatIn(e,cc.Camera.main.viewMatrix)),e},getCameraToWorldPoint:function(t){return cc.Camera.main&&(t=cc.pointApplyAffineTransform(t,cc.Camera.main.invertViewMatrix)),t},containsNode:function(t){t instanceof cc.Node&&(t=t._sgNode);for(var e=this._sgTarges;t;){if(-1!==e.indexOf(t))return!0;t=t.parent}return!1},_setSgNodesCullingDirty:function(){for(var t=this._sgTarges,e=0;e<t.length;e++)t[e]._renderCmd.setDirtyFlag(n)},_checkSgTargets:function(){for(var t=this._targets,e=this._sgTarges,i=++this._checkedTimes,n=0,r=t.length;n<r;n++){var s=t[n],o=s;s instanceof cc.Node&&(o=s._sgNode)&&!o._cameraInfo&&this._addSgTargetInSg(o),o&&(o._cameraInfo.touched=i)}for(var a=e.length-1;a>=0;a--){var c=e[a];c._cameraInfo.touched!==i&&this._removeTargetInSg(c)}},lateUpdate:function(){this._checkSgTargets();var t=this.viewMatrix,e=this.invertViewMatrix,i=this.viewPort,n=cc.visibleRect,r=this.visibleRect,s=this.node.getNodeToWorldTransformAR(),o=.5*-(Math.atan2(s.b,s.a)+Math.atan2(-s.c,s.d)),a=1,c=0,h=0,l=1;o&&(h=Math.sin(o),a=l=Math.cos(o),c=-h);var u=this.zoomRatio;a*=u,c*=u,h*=u,l*=u,t.a=a,t.b=c,t.c=h,t.d=l;var _=n.center;t.tx=_.x-(a*s.tx+h*s.ty),t.ty=_.y-(c*s.tx+l*s.ty),cc.affineTransformInvertOut(t,e),i.x=n.bottomLeft.x,i.y=n.bottomLeft.y,i.width=n.width,i.height=n.height,cc._rectApplyAffineTransformIn(i,e),r.left.x=i.xMin,r.right.x=i.xMax,r.bottom.y=i.yMin,r.top.y=i.yMax,this._sgNode.setTransform(a,c,h,l,t.tx,t.ty);var d=this._lastViewMatrix;d.a===t.a&&d.b===t.b&&d.c===t.c&&d.d===t.d&&d.tx===t.tx&&d.ty===t.ty||(this._setSgNodesCullingDirty(),d.a=t.a,d.b=t.b,d.c=t.c,d.d=t.d,d.tx=t.tx,d.ty=t.ty)}});r.flags=cc.Enum({InCamera:1,ParentInCamera:2}),e.exports=cc.Camera=r}),{"./CCSGCameraNode":61}],61:[(function(t,e,i){var n=new cc.math.Matrix4,r=_ccsg.Node.extend({ctor:function(){this._super(),this._mat=new cc.math.Matrix4,this._mat.identity(),this._beforeVisitCmd=new cc.CustomRenderCmd(this,this._onBeforeVisit),this._afterVisitCmd=new cc.CustomRenderCmd(this,this._onAfterVisit)},setTransform:function(t,e,i,n,r,s){var o=this._mat.mat;o[0]=t,o[1]=e,o[4]=i,o[5]=n,o[12]=r,o[13]=s},addTarget:function(t){var e=t._cameraInfo;e.sgCameraNode=this,e.originVisit=t.visit,t.visit=this._visit},removeTarget:function(t){t.visit=t._cameraInfo.originVisit},_visit:function(t){var e=this._cameraInfo,i=e.sgCameraNode;cc.renderer.pushRenderCommand(i._beforeVisitCmd),e.originVisit.call(this,t),cc.renderer.pushRenderCommand(i._afterVisitCmd)},_onBeforeVisit:function(){cc.renderer._breakBatch(),cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),n.assignFrom(cc.current_stack.top),n.multiply(this._mat),cc.current_stack.push(n)},_onAfterVisit:function(){cc.renderer._breakBatch(),cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),cc.current_stack.pop()}});e.exports=_ccsg.CameraNode=r}),{}],62:[(function(t,e,i){cc.Collider.Box=cc.Class({properties:{_offset:cc.v2(0,0),_size:cc.size(100,100),offset:{tooltip:!1,get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},size:{tooltip:!1,get:function(){return this._size},set:function(t){this._size.width=t.width<0?0:t.width,this._size.height=t.height<0?0:t.height},type:cc.Size}},resetInEditor:!1});var n=cc.Class({name:"cc.BoxCollider",extends:cc.Collider,mixins:[cc.Collider.Box],editor:!1});cc.BoxCollider=e.exports=n}),{}],63:[(function(t,e,i){cc.Collider.Circle=cc.Class({properties:{_offset:cc.v2(0,0),_radius:50,offset:{get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},radius:{tooltip:!1,get:function(){return this._radius},set:function(t){this._radius=t<0?0:t}}},resetInEditor:!1});var n=cc.Class({name:"cc.CircleCollider",extends:cc.Collider,mixins:[cc.Collider.Circle],editor:!1});cc.CircleCollider=e.exports=n}),{}],64:[(function(t,e,i){var n=cc.Class({name:"cc.Collider",extends:cc.Component,properties:{editing:{default:!1,serializable:!1,tooltip:!1},tag:{tooltip:!1,default:0,range:[0,1e7],type:cc.Integer}},onDisable:function(){cc.director.getCollisionManager().removeCollider(this)},onEnable:function(){cc.director.getCollisionManager().addCollider(this)}});cc.Collider=e.exports=n}),{}],65:[(function(t,e,i){var n=t("./CCContact"),r=n.CollisionType,s=cc.rect(),o=cc.v2(),a=cc.Class({mixins:[cc.EventTarget],properties:{enabled:!1,enabledDrawBoundingBox:!1},ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._contacts=[],this._colliders=[],this._debugDrawer=null,this._enabledDebugDraw=!1},update:function(t){if(this.enabled){var e,i,n=this._colliders;for(e=0,i=n.length;e<i;e++)this.updateCollider(n[e]);var s=this._contacts,o=[];for(e=0,i=s.length;e<i;e++){var a=s[e].updateState();a!==r.None&&o.push([a,s[e]])}for(e=0,i=o.length;e<i;e++){var c=o[e];this._doCollide(c[0],c[1])}this.drawColliders()}},_doCollide:function(t,e){var i;switch(t){case r.CollisionEnter:i="onCollisionEnter";break;case r.CollisionStay:i="onCollisionStay";break;case r.CollisionExit:i="onCollisionExit"}var n,s,o,a=e.collider1,c=e.collider2,h=a.node._components,l=c.node._components;for(n=0,s=h.length;n<s;n++)(o=h[n])[i]&&o[i](c,a);for(n=0,s=l.length;n<s;n++)(o=l[n])[i]&&o[i](a,c)},shouldCollide:function(t,e){var i=t.node,n=e.node,r=cc.game.collisionMatrix;return i!==n&&r[i.groupIndex][n.groupIndex]},initCollider:function(t){if(!t.world){var e=t.world={};e.aabb=cc.rect(),e.preAabb=cc.rect(),e.radius=0,t instanceof cc.BoxCollider?(e.position=null,e.points=[cc.v2(),cc.v2(),cc.v2(),cc.v2()]):t instanceof cc.PolygonCollider?(e.position=null,e.points=t.points.map((function(t){return cc.v2(t.x,t.y)}))):t instanceof cc.CircleCollider&&(e.position=cc.v2(),e.points=null)}},updateCollider:function(t){var e=t.offset,i=t.world,n=i.aabb,r=i.transform=t.node.getNodeToWorldTransformAR(),a=i.preAabb;if(a.x=n.x,a.y=n.y,a.width=n.width,a.height=n.height,t instanceof cc.BoxCollider){var c=t.size;s.x=e.x-c.width/2,s.y=e.y-c.height/2,s.width=c.width,s.height=c.height;var h=i.points,l=h[0],u=h[1],_=h[2],d=h[3];cc.obbApplyAffineTransform(s,r,l,u,_,d);var f=Math.min(l.x,u.x,_.x,d.x),p=Math.min(l.y,u.y,_.y,d.y),m=Math.max(l.x,u.x,_.x,d.x),g=Math.max(l.y,u.y,_.y,d.y);n.x=f,n.y=p,n.width=m-f,n.height=g-p}else if(t instanceof cc.CircleCollider){var y=cc.pointApplyAffineTransform(t.offset,r);i.position.x=y.x,i.position.y=y.y,r.tx=r.ty=0,o.x=t.radius,o.y=0;var v=cc.pointApplyAffineTransform(o,r),x=Math.sqrt(v.x*v.x+v.y*v.y);i.radius=x,n.x=y.x-x,n.y=y.y-x,n.width=2*x,n.height=2*x}else if(t instanceof cc.PolygonCollider){var C=t.points,T=i.points;T.length=C.length;f=1e6,p=1e6,m=-1e6,g=-1e6;for(var b=0,A=C.length;b<A;b++){T[b]||(T[b]=cc.v2()),o.x=C[b].x+e.x,o.y=C[b].y+e.y;y=cc.pointApplyAffineTransform(o,r);T[b].x=y.x,T[b].y=y.y,y.x>m&&(m=y.x),y.x<f&&(f=y.x),y.y>g&&(g=y.y),y.y<p&&(p=y.y)}n.x=f,n.y=p,n.width=m-f,n.height=g-p}},addCollider:function(t){var e=this._colliders;if(-1===e.indexOf(t)){for(var i=0,r=e.length;i<r;i++){var s=e[i];if(this.shouldCollide(t,s)){var o=new n(t,s);this._contacts.push(o)}}e.push(t),this.initCollider(t)}t.node.on("group-changed",this.onNodeGroupChanged,this)},removeCollider:function(t){var e=this._colliders,i=e.indexOf(t);if(i>=0){e.splice(i,1);for(var n=this._contacts,s=n.length-1;s>=0;s--){var o=n[s];o.collider1!==t&&o.collider2!==t||(o.touching&&this._doCollide(r.CollisionExit,o),n.splice(s,1))}t.node.off("group-changed",this.onNodeGroupChanged,this)}else cc.errorID(6600)},attachDebugDrawToCamera:function(t){this._debugDrawer&&t.addTarget(this._debugDrawer)},detachDebugDrawFromCamera:function(t){this._debugDrawer&&t.removeTarget(this._debugDrawer)},onNodeGroupChanged:function(t){for(var e=t.currentTarget.getComponents(cc.Collider),i=0,n=e.length;i<n;i++)this.removeCollider(e[i]),this.addCollider(e[i])},drawColliders:function(){var t=this._debugDrawer;if(this._enabledDebugDraw&&t){t.clear();for(var e=this._colliders,i=0,n=e.length;i<n;i++){var r=e[i];if(r instanceof cc.BoxCollider||r instanceof cc.PolygonCollider){var s=r.world.points;if(s.length>0){t.strokeColor=cc.Color.WHITE,t.moveTo(s[0].x,s[0].y);for(var o=1;o<s.length;o++)t.lineTo(s[o].x,s[o].y);t.close(),t.stroke()}}else r instanceof cc.CircleCollider&&(t.circle(r.world.position.x,r.world.position.y,r.world.radius),t.stroke());if(this.enabledDrawBoundingBox){var a=r.world.aabb;t.strokeColor=cc.Color.BLUE,t.moveTo(a.xMin,a.yMin),t.lineTo(a.xMin,a.yMax),t.lineTo(a.xMax,a.yMax),t.lineTo(a.xMax,a.yMin),t.close(),t.stroke()}}}},onSceneLaunched:function(){this._enabledDebugDraw&&this._debugDrawer&&(this._debugDrawer.removeFromParent(),cc.director.getScene()._sgNode.addChild(this._debugDrawer))}});cc.js.getset(a.prototype,"enabledDebugDraw",(function(){return this._enabledDebugDraw}),(function(t){t&&!this._enabledDebugDraw?(this._debugDrawer||(this._debugDrawer=new _ccsg.GraphicsNode,this._debugDrawer.retain()),cc.director.getScene()._sgNode.addChild(this._debugDrawer),cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH,this.onSceneLaunched,this)):!t&&this._enabledDebugDraw&&(this._debugDrawer.clear(),this._debugDrawer.removeFromParent(!1),cc.director.off(cc.Director.EVENT_AFTER_SCENE_LAUNCH,this.onSceneLaunched,this)),this._enabledDebugDraw=t})),cc.CollisionManager=e.exports=a}),{"./CCContact":66}],66:[(function(t,e,i){function n(t,e){this.collider1=t,this.collider2=e,this.touching=!1;var i=t instanceof cc.BoxCollider||t instanceof cc.PolygonCollider,n=e instanceof cc.BoxCollider||e instanceof cc.PolygonCollider,s=t instanceof cc.CircleCollider,o=e instanceof cc.CircleCollider;i&&n?this.testFunc=r.polygonPolygon:s&&o?this.testFunc=r.circleCircle:i&&o?this.testFunc=r.polygonCircle:s&&n?(this.testFunc=r.polygonCircle,this.collider1=e,this.collider2=t):cc.errorID(6601,cc.js.getClassName(t),cc.js.getClassName(e))}var r=t("./CCIntersection"),s=cc.Enum({None:0,CollisionEnter:1,CollisionStay:2,CollisionExit:3});n.prototype.test=function(){var t=this.collider1.world,e=this.collider2.world;return!!t.aabb.intersects(e.aabb)&&(this.testFunc===r.polygonPolygon?this.testFunc(t.points,e.points):this.testFunc===r.circleCircle?this.testFunc(t,e):this.testFunc===r.polygonCircle&&this.testFunc(t.points,e))},n.prototype.updateState=function(){var t=this.test(),e=s.None;return t&&!this.touching?(this.touching=!0,e=s.CollisionEnter):t&&this.touching?e=s.CollisionStay:!t&&this.touching&&(this.touching=!1,e=s.CollisionExit),e},n.CollisionType=s,e.exports=n}),{"./CCIntersection":67}],67:[(function(t,e,i){function n(t,e,i,n){var r=(n.x-i.x)*(t.y-i.y)-(n.y-i.y)*(t.x-i.x),s=(e.x-t.x)*(t.y-i.y)-(e.y-t.y)*(t.x-i.x),o=(n.y-i.y)*(e.x-t.x)-(n.x-i.x)*(e.y-t.y);if(0!==o){var a=r/o,c=s/o;if(0<=a&&a<=1&&0<=c&&c<=1)return!0}return!1}function r(t,e,i){for(var r=i.length,s=0;s<r;++s){if(n(t,e,i[s],i[(s+1)%r]))return!0}return!1}function s(t,e){for(var i=!1,n=t.x,r=t.y,s=e.length,o=0,a=s-1;o<s;a=o++){var c=e[o].x,h=e[o].y,l=e[a].x,u=e[a].y;h>r!=u>r&&n<(l-c)*(r-h)/(u-h)+c&&(i=!i)}return i}function o(t,e,i,n){var r,s=i.x-e.x,o=i.y-e.y,a=s*s+o*o,c=((t.x-e.x)*s+(t.y-e.y)*o)/a;return r=n?a?c<0?e:c>1?i:cc.v2(e.x+c*s,e.y+c*o):e:cc.v2(e.x+c*s,e.y+c*o),s=t.x-r.x,o=t.y-r.y,Math.sqrt(s*s+o*o)}var a={};a.lineLine=n,a.lineRect=function(t,e,i){var r=new cc.Vec2(i.x,i.y),s=new cc.Vec2(i.x,i.yMax),o=new cc.Vec2(i.xMax,i.yMax),a=new cc.Vec2(i.xMax,i.y);return!!(n(t,e,r,s)||n(t,e,s,o)||n(t,e,o,a)||n(t,e,a,r))},a.linePolygon=r,a.rectRect=function(t,e){var i=t.x,n=t.y,r=t.x+t.width,s=t.y+t.height,o=e.x,a=e.y,c=e.x+e.width,h=e.y+e.height;return i<=c&&r>=o&&n<=h&&s>=a},a.rectPolygon=function(t,e){var i,n,o=new cc.Vec2(t.x,t.y),a=new cc.Vec2(t.x,t.yMax),c=new cc.Vec2(t.xMax,t.yMax),h=new cc.Vec2(t.xMax,t.y);if(r(o,a,e))return!0;if(r(a,c,e))return!0;if(r(c,h,e))return!0;if(r(h,o,e))return!0;for(i=0,n=e.length;i<n;++i)if(s(e[i],t))return!0;return!!(s(o,e)||s(a,e)||s(c,e)||s(h,e))},a.polygonPolygon=function(t,e){var i,n;for(i=0,n=t.length;i<n;++i)if(r(t[i],t[(i+1)%n],e))return!0;for(i=0,n=e.length;i<n;++i)if(s(e[i],t))return!0;for(i=0,n=t.length;i<n;++i)if(s(t[i],e))return!0;return!1},a.circleCircle=function(t,e){return t.position.sub(e.position).mag()<t.radius+e.radius},a.polygonCircle=function(t,e){var i=e.position;if(s(i,t))return!0;for(var n=0,r=t.length;n<r;n++)if(o(i,0===n?t[t.length-1]:t[n-1],t[n],!0)<e.radius)return!0;return!1},a.pointInPolygon=s,a.pointLineDistance=o,cc.Intersection=e.exports=a}),{}],68:[(function(t,e,i){cc.Collider.Polygon=cc.Class({properties:{threshold:{default:1,serializable:!1,visible:!1},_offset:cc.v2(0,0),offset:{get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},points:{tooltip:!1,default:function(){return[cc.v2(-50,-50),cc.v2(50,-50),cc.v2(50,50),cc.v2(-50,50)]},type:[cc.Vec2]}},resetPointsByContour:!1});var n=cc.Class({name:"cc.PolygonCollider",extends:cc.Collider,mixins:[cc.Collider.Polygon],editor:!1});cc.PolygonCollider=e.exports=n}),{}],69:[(function(t,e,i){t("./CCCollisionManager"),t("./CCCollider"),t("./CCBoxCollider"),t("./CCCircleCollider"),t("./CCPolygonCollider")}),{"./CCBoxCollider":62,"./CCCircleCollider":63,"./CCCollider":64,"./CCCollisionManager":65,"./CCPolygonCollider":68}],70:[(function(t,e,i){function n(t,e){for(var i=e.constructor._executionOrder,n=e.__instanceId,r=0,s=t.length-1,o=s>>>1;r<=s;o=r+s>>>1){var a=t[o],c=a.constructor._executionOrder;if(c>i)s=o-1;else if(c<i)r=o+1;else{var h=a.__instanceId;if(h>n)s=o-1;else{if(!(h<n))return o;r=o+1}}}return~r}function r(t,e){for(var i=t.array,n=t.i+1;n<i.length;){var r=i[n];r._enabled&&r.node._activeInHierarchy?++n:(t.removeAt(n),e&&(r._objFlags&=~e))}}function s(t,e){return t.constructor._executionOrder-e.constructor._executionOrder}function o(t,e){if("function"==typeof t)return e?function(e,i){var n=e.array;for(e.i=0;e.i<n.length;++e.i){var r=n[e.i];t(r,i)}}:function(e){var i=e.array;for(e.i=0;e.i<i.length;++e.i){var n=i[e.i];t(n)}};var i="var a=it.array;for(it.i=0;it.i<a.length;++it.i){var c=a[it.i];"+t+"}";return e?Function("it","dt",i):Function("it",i)}function a(){this.startInvoker=new m(o(_)),this.updateInvoker=new g(o(d,!0)),this.lateUpdateInvoker=new g(o(f,!0)),this.scheduleInNextFrame=[],this._updating=!1}t("./platform/CCClass");var c=t("./platform/CCObject").Flags,h=t("./platform/js").array,l=c.IsStartCalled,u=c.IsOnEnableCalled,_=(c.IsEditorOnEnableCalled,"c.start();c._objFlags|="+l),d="c.update(dt)",f="c.lateUpdate(dt)",p=cc.Class({__ctor__:function(t){var e=h.MutableForwardIterator;this._zero=new e([]),this._neg=new e([]),this._pos=new e([]),this._invoke=t},statics:{stableRemoveInactive:r},add:null,remove:null,invoke:null}),m=cc.Class({extends:p,add:function(t){var e=t.constructor._executionOrder;(0===e?this._zero:e<0?this._neg:this._pos).array.push(t)},remove:function(t){var e=t.constructor._executionOrder;(0===e?this._zero:e<0?this._neg:this._pos).fastRemove(t)},cancelInactive:function(t){r(this._zero,t),r(this._neg,t),r(this._pos,t)},invoke:function(){var t=this._neg;t.array.length>0&&(t.array.sort(s),this._invoke(t),t.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var e=this._pos;e.array.length>0&&(e.array.sort(s),this._invoke(e),e.array.length=0)}}),g=cc.Class({extends:p,add:function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.array.push(t);else{var i=e<0?this._neg.array:this._pos.array,r=n(i,t);r<0&&i.splice(~r,0,t)}},remove:function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.fastRemove(t);else{var i=e<0?this._neg:this._pos,r=n(i.array,t);r>=0&&i.removeAt(r)}},invoke:function(t){this._neg.array.length>0&&this._invoke(this._neg,t),this._invoke(this._zero,t),this._pos.array.length>0&&this._invoke(this._pos,t)}}),y=cc.Class({ctor:a,unscheduleAll:a,statics:{LifeCycleInvoker:p,OneOffInvoker:m,createInvokeImpl:o,invokeOnEnable:function(t){var e=cc.director._compScheduler,i=t.array;for(t.i=0;t.i<i.length;++t.i){var n=i[t.i];if(n._enabled){n.onEnable();!n.node._activeInHierarchy||e._onEnabled(n)}}}},_onEnabled:function(t){cc.director.getScheduler().resumeTarget(t),t._objFlags|=u,this._updating?this.scheduleInNextFrame.push(t):this._scheduleImmediate(t)},_onDisabled:function(t){cc.director.getScheduler().pauseTarget(t),t._objFlags&=~u;var e=this.scheduleInNextFrame.indexOf(t);e>=0?h.fastRemoveAt(this.scheduleInNextFrame,e):(!t.start||t._objFlags&l||this.startInvoker.remove(t),t.update&&this.updateInvoker.remove(t),t.lateUpdate&&this.lateUpdateInvoker.remove(t))},enableComp:function(t,e){if(!(t._objFlags&u)){if(t.onEnable){if(e)return void e.add(t);t.onEnable();if(!t.node._activeInHierarchy)return}this._onEnabled(t)}},disableComp:function(t){t._objFlags&u&&(t.onDisable&&t.onDisable(),this._onDisabled(t))},_scheduleImmediate:function(t){!t.start||t._objFlags&l||this.startInvoker.add(t),t.update&&this.updateInvoker.add(t),t.lateUpdate&&this.lateUpdateInvoker.add(t)},_deferredSchedule:function(){for(var t=this.scheduleInNextFrame,e=0,i=t.length;e<i;e++){var n=t[e];this._scheduleImmediate(n)}t.length=0},startPhase:function(){this._updating=!0,this.scheduleInNextFrame.length>0&&this._deferredSchedule(),this.startInvoker.invoke()},updatePhase:function(t){this.updateInvoker.invoke(t)},lateUpdatePhase:function(t){this.lateUpdateInvoker.invoke(t),this._updating=!1}});e.exports=y}),{"./platform/CCClass":176,"./platform/CCObject":182,"./platform/js":197,"./utils/misc":226}],71:[(function(t,e,i){function n(t,e){return t===e||t&&e&&(t.name===e.name||t._uuid===e._uuid)}var r=t("../../animation/animation-animator"),s=t("../../animation/animation-clip"),o=cc.Class({name:"cc.Animation",extends:t("./CCComponent"),mixins:[cc.EventTarget],editor:!1,ctor:function(){cc.EventTarget.call(this),this._animator=null,this._nameToState={},this._didInit=!1,this._currentClip=null},properties:{_defaultClip:{default:null,type:s},defaultClip:{type:s,get:function(){return this._defaultClip},set:function(t){return void 0},tooltip:!1},currentClip:{get:function(){return this._currentClip},set:function(t){this._currentClip=t},type:s,visible:!1},_clips:{default:[],type:[s],tooltip:!1,visible:!0},playOnLoad:{default:!1,tooltip:!1}},start:function(){if(this.playOnLoad&&this._defaultClip){if(!(this._animator&&this._animator.isPlaying)){var t=this.getAnimationState(this._defaultClip.name);this._animator.playState(t)}}},onEnable:function(){this._animator&&this._animator.resume()},onDisable:function(){this._animator&&this._animator.pause()},onDestroy:function(){this.stop()},getClips:function(){return this._clips},play:function(t,e){var i=this.playAdditive(t,e);return this._animator.stopStatesExcept(i),i},playAdditive:function(t,e){this._init();var i=this.getAnimationState(t||this._defaultClip&&this._defaultClip.name);if(i){this.enabled=!0;var n=this._animator;n.isPlaying&&i.isPlaying?i.isPaused?n.resumeState(i):(n.stopState(i),n.playState(i,e)):n.playState(i,e),this.currentClip=i.clip}return i},stop:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.stopState(e)}else this._animator.stop()},pause:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.pauseState(e)}else this.enabled=!1},resume:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.resumeState(e)}else this.enabled=!0},setCurrentTime:function(t,e){if(this._init(),e){var i=this._nameToState[e];i&&this._animator.setStateTime(i,t)}else this._animator.setStateTime(t)},getAnimationState:function(t){this._init();var e=this._nameToState[t];return e&&!e.curveLoaded&&this._animator._reloadClip(e),e||null},addClip:function(t,e){if(t){this._init(),cc.js.array.contains(this._clips,t)||this._clips.push(t),e=e||t.name;var i=this._nameToState[e];if(i){if(i.clip===t)return i;var n=this._clips.indexOf(i.clip);-1!==n&&this._clips.splice(n,1)}var r=new cc.AnimationState(t,e);return this._nameToState[e]=r,r}cc.warnID(3900)},removeClip:function(t,e){if(t){this._init();var i;for(var n in this._nameToState){if((i=this._nameToState[n]).clip===t)break}if(t===this._defaultClip){if(!e)return void cc.warnID(3902);this._defaultClip=null}if(i&&i.isPlaying){if(!e)return void cc.warnID(3903);this.stop(i.name)}this._clips=this._clips.filter((function(e){return e!==t})),i&&delete this._nameToState[i.name]}else cc.warnID(3901)},sample:function(t){if(this._init(),t){var e=this._nameToState[t];e&&e.sample()}else this._animator.sample()},on:function(t,e,i,n){this._init();for(var r=cc.EventTarget.prototype.on.call(this,t,e,i,n),s=this._animator._anims.array,o=0;o<s.length;++o)s[o]._setListeners(this);return r},off:function(t,e,i,n){this._init(),cc.EventTarget.prototype.off.call(this,t,e,i,n);var r=this._nameToState;for(var s in r){r[s]._setListeners(null)}},_init:function(){this._didInit||(this._didInit=!0,this._animator=new r(this.node,this),this._createStates())},_createStates:function(){this._nameToState={};for(var t=null,e=!1,i=0;i<this._clips.length;++i){var r=this._clips[i];r&&(t=new cc.AnimationState(r),this._nameToState[t.name]=t,n(this._defaultClip,r)&&(e=t))}this._defaultClip&&!e&&(t=new cc.AnimationState(this._defaultClip),this._nameToState[t.name]=t)}});cc.Animation=e.exports=o}),{"../../animation/animation-animator":11,"../../animation/animation-clip":12,"./CCComponent":76}],72:[(function(t,e,i){var n=cc.Class({name:"cc.AudioSource",extends:t("./CCComponent"),editor:!1,ctor:function(){this.audio=new cc.Audio},properties:{_clip:{default:"",url:cc.AudioClip},_volume:1,_mute:!1,_loop:!1,_pausedFlag:{default:!1,serializable:!1},isPlaying:{get:function(){if(!this.audio)return!1;return this.audio.getState()===cc.Audio.State.PLAYING},visible:!1},clip:{get:function(){return this._clip},set:function(t){t!==this._clip&&(this._clip=t,this.audio.stop(),this.audio.src=this._clip,this.audio.preload&&this.audio.preload())},url:cc.AudioClip,tooltip:!1,animatable:!1},volume:{get:function(){return this._volume},set:function(t){t=cc.clamp01(t),this._volume=t;var e=this.audio;return e&&!this._mute&&(e.setVolume(t),e._loaded||e.on("load",(function(){e.setVolume(t)}))),t},tooltip:!1},mute:{get:function(){return this._mute},set:function(t){return this._mute=t,this.audio&&this.audio.setVolume(t?0:this._volume),t},animatable:!1,tooltip:!1},loop:{get:function(){return this._loop},set:function(t){return this._loop=t,this.audio&&this.audio.setLoop(t),t},animatable:!1,tooltip:!1},playOnLoad:{default:!1,tooltip:!1,animatable:!1},preload:{default:!1,animatable:!1}},_pausedCallback:function(){var t=this.audio;t&&!t.paused&&(this.audio.pause(),this._pausedFlag=!0)},_restoreCallback:function(){this.audio&&(this._pausedFlag&&this.audio.resume(),this._pausedFlag=!1)},onEnable:function(){this.playOnLoad&&this.play(),this.preload&&(this.audio.src=this._clip,this.audio.preload()),cc.game.on(cc.game.EVENT_HIDE,this._pausedCallback,this),cc.game.on(cc.game.EVENT_SHOW,this._restoreCallback,this)},onDisable:function(){this.stop(),cc.game.off(cc.game.EVENT_HIDE,this._pausedCallback,this),cc.game.off(cc.game.EVENT_SHOW,this._restoreCallback,this)},onDestroy:function(){this.stop(),this.audio.destroy(),cc.audioEngine.uncache(this._clip)},play:function(){if(this._clip){var t=this._mute?0:this._volume,e=this.audio,i=this._loop;if(e._loaded)return e.stop(),e.setCurrentTime(0),void e.play();e.src=this._clip,e.once("load",(function(){e.setLoop(i),e.setVolume(t),e.play()})),e.preload()}},stop:function(){this.audio&&this.audio.stop()},pause:function(){this.audio&&this.audio.pause()},resume:function(){this.audio&&this.audio.resume()},rewind:function(){this.audio&&this.audio.setCurrentTime(0)},getCurrentTime:function(){var t=0;return this.audio&&(t=this.audio.getCurrentTime()),t},setCurrentTime:function(t){var e=this.audio;return e?e._loaded?(e.setCurrentTime(t),t):(e.once("load",(function(){e.setCurrentTime(t)})),t):t},getDuration:function(){var t=0;return this.audio&&(t=this.audio.getDuration()),t}});cc.AudioSource=e.exports=n}),{"./CCComponent":76}],73:[(function(t,e,i){function n(t){t.stopPropagation()}var r=["touchstart","touchmove","touchend","mousedown","mousemove","mouseup","mouseenter","mouseleave","mousewheel"],s=cc.Class({name:"cc.BlockInputEvents",extends:t("./CCComponent"),editor:{menu:"i18n:MAIN_MENU.component.ui/Block Input Events",inspector:"packages://inspector/inspectors/comps/block-input-events.js",help:"i18n:COMPONENT.help_url.block-input-events"},onEnable:function(){for(var t=0;t<r.length;t++)this.node.on(r[t],n,this)},onDisable:function(){for(var t=0;t<r.length;t++)this.node.off(r[t],n,this)}});cc.BlockInputEvents=e.exports=s}),{"./CCComponent":76}],74:[(function(t,e,i){var n=cc.Enum({NONE:0,COLOR:1,SPRITE:2,SCALE:3}),r=cc.Class({name:"cc.Button",extends:t("./CCComponent"),ctor:function(){this._resetState(),this._fromColor=null,this._toColor=null,this._time=0,this._transitionFinished=!0,this._fromScale=1,this._toScale=1,this._originalScale=1,this._sprite=null},_resetState:function(){this._pressed=!1,this._hovered=!1},editor:!1,properties:{interactable:{default:!0,tooltip:!1,notify:function(t){this._updateState(),this.interactable||this._resetState()},animatable:!1},_resizeToTarget:{animatable:!1,set:function(t){t&&this._resizeNodeToTargetNode()}},enableAutoGrayEffect:{default:!1,tooltip:!1,notify:function(){this._updateDisabledState()}},transition:{default:n.NONE,tooltip:!1,type:n,animatable:!1},normalColor:{default:cc.color(214,214,214),displayName:"Normal",tooltip:!1,notify:function(){this._updateState()}},pressedColor:{default:cc.color(211,211,211),displayName:"Pressed",tooltip:!1},hoverColor:{default:cc.Color.WHITE,displayName:"Hover",tooltip:!1},disabledColor:{default:cc.color(124,124,124),displayName:"Disabled",tooltip:!1,notify:function(){this._updateState()}},duration:{default:.1,range:[0,10],tooltip:!1},zoomScale:{default:1.2,tooltip:!1},normalSprite:{default:null,type:cc.SpriteFrame,displayName:"Normal",tooltip:!1,notify:function(){this._updateState()}},pressedSprite:{default:null,type:cc.SpriteFrame,displayName:"Pressed",tooltip:!1,formerlySerializedAs:"pressedSprite",notify:function(){this._updateState()}},hoverSprite:{default:null,type:cc.SpriteFrame,displayName:"Hover",tooltip:!1,formerlySerializedAs:"hoverSprite",notify:function(){this._updateState()}},disabledSprite:{default:null,type:cc.SpriteFrame,displayName:"Disabled",tooltip:!1,notify:function(){this._updateState()}},target:{default:null,type:cc.Node,tooltip:!1,notify:function(){this._applyTarget()}},clickEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1}},statics:{Transition:n},__preload:function(){this.target||(this.target=this.node),this._applyTarget(),this._updateState()},onEnable:function(){this.normalSprite&&this.normalSprite.ensureLoadTexture(),this.hoverSprite&&this.hoverSprite.ensureLoadTexture(),this.pressedSprite&&this.pressedSprite.ensureLoadTexture(),this.disabledSprite&&this.disabledSprite.ensureLoadTexture(),this._registerEvent()},update:function(t){var e=this.target;if(!this._transitionFinished&&(this.transition===n.COLOR||this.transition===n.SCALE)){this.time+=t;var i=1;this.duration>0&&(i=this.time/this.duration),i>=1&&(i=1,this._transitionFinished=!0),this.transition===n.COLOR?e.color=this._fromColor.lerp(this._toColor,i):this.transition===n.SCALE&&(e.scale=cc.lerp(this._fromScale,this._toScale,i))}},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMove,this),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(cc.Node.EventType.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(cc.Node.EventType.MOUSE_LEAVE,this._onMouseMoveOut,this)},_getTargetSprite:function(t){var e=null;return t&&(e=t.getComponent(cc.Sprite)),e},_applyTarget:function(){this._sprite=this._getTargetSprite(this.target),this.target&&(this._originalScale=this.target.scale)},_onTouchBegan:function(t){this.interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t.stopPropagation())},_onTouchMove:function(t){if(this.interactable&&this.enabledInHierarchy&&this._pressed){var e=t.touch,i=this.node._hitTest(e.getLocation());if(this.transition===n.SCALE&&this.target)i?(this._fromScale=this._originalScale,this._toScale=this._originalScale*this.zoomScale,this._transitionFinished=!1):(this.time=0,this._transitionFinished=!0,this.target.scale=this._originalScale);else{var r;r=i?"pressed":"normal",this._applyTransition(r)}t.stopPropagation()}},_onTouchEnded:function(t){this.interactable&&this.enabledInHierarchy&&(this._pressed&&(cc.Component.EventHandler.emitEvents(this.clickEvents,t),this.node.emit("click",this)),this._pressed=!1,this._updateState(),t.stopPropagation())},_zoomUp:function(){this._fromScale=this._originalScale,this._toScale=this._originalScale*this.zoomScale,this.time=0,this._transitionFinished=!1},_zoomBack:function(){this._fromScale=this.target.scale,this._toScale=this._originalScale,this.time=0,this._transitionFinished=!1},_onTouchCancel:function(){this.interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},_onMouseMoveIn:function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this.transition!==n.SPRITE||this.hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},_onMouseMoveOut:function(){this._hovered&&(this._hovered=!1,this._updateState())},_updateState:function(){var t=this._getButtonState();this._applyTransition(t),this._updateDisabledState()},onDisable:function(){this._hovered=!1,this._pressed=!1,this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMove,this),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(cc.Node.EventType.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(cc.Node.EventType.MOUSE_LEAVE,this._onMouseMoveOut,this)},_getButtonState:function(){return this.interactable?this._pressed?"pressed":this._hovered?"hover":"normal":"disabled"},_updateColorTransition:function(t){var e=this[t+"Color"],i=this.target;this._fromColor=i.color.clone(),this._toColor=e,this.time=0,this._transitionFinished=!1},_updateSpriteTransition:function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},_updateScaleTransition:function(t){"pressed"===t?this._zoomUp():this._zoomBack()},_applyTransition:function(t){var e=this.transition;e===n.COLOR?this._updateColorTransition(t):e===n.SPRITE?this._updateSpriteTransition(t):e===n.SCALE&&this._updateScaleTransition(t)},_resizeNodeToTargetNode:!1,_updateDisabledState:function(){this._sprite&&this._sprite._sgNode.setState(0),this.enableAutoGrayEffect&&this.transition!==n.COLOR&&(this.transition===n.SPRITE&&this.disabledSprite||this._sprite&&!this.interactable&&this._sprite._sgNode.setState(1))}});cc.Button=e.exports=r}),{"./CCComponent":76}],75:[(function(t,e,i){var n=t("../event-manager"),r={getContentSize:function(){return cc.visibleRect},setContentSize:function(t){},_getWidth:function(){return this.getContentSize().width},_getHeight:function(){return this.getContentSize().height}},s=cc.Class({name:"cc.Canvas",extends:t("./CCComponent"),editor:!1,resetInEditor:!1,statics:{instance:null},properties:{_designResolution:cc.size(960,640),designResolution:{get:function(){return cc.size(this._designResolution)},set:function(t){this._designResolution.width=t.width,this._designResolution.height=t.height,this.applySettings()},tooltip:!1},_fitWidth:!1,_fitHeight:!0,fitHeight:{get:function(){return this._fitHeight},set:function(t){this._fitHeight!==t&&(this._fitHeight=t,this.applySettings())},tooltip:!1},fitWidth:{get:function(){return this._fitWidth},set:function(t){this._fitWidth!==t&&(this._fitWidth=t,this.applySettings())},tooltip:!1}},ctor:function(){this._thisOnResized=this.onResized.bind(this)},__preload:function(){if(s.instance)return cc.errorID(6700,this.node.name,s.instance.node.name);if(s.instance=this,this.node._sizeProvider){}else this.node._sizeProvider=r;cc.director.on(cc.Director.EVENT_BEFORE_VISIT,this.alignWithScreen,this),cc.sys.isMobile?window.addEventListener("resize",this._thisOnResized):n.addCustomListener("canvas-resize",this._thisOnResized),this.applySettings(),this.onResized()},onDestroy:function(){this.node._sizeProvider===r&&(this.node._sizeProvider=null),cc.director.off(cc.Director.EVENT_BEFORE_VISIT,this.alignWithScreen,this),cc.sys.isMobile?window.removeEventListener("resize",this._thisOnResized):n.removeCustomListeners("canvas-resize",this._thisOnResized),s.instance===this&&(s.instance=null)},alignWithScreen:function(){var t,e=cc.visibleRect,i=0,n=0;!this.fitHeight&&!this.fitWidth&&(i=.5*((t=cc.view.getDesignResolutionSize()).width-e.width),n=.5*(t.height-e.height)),this.node.setPosition(.5*e.width+i,.5*e.height+n)},onResized:function(){this.alignWithScreen()},applySettings:function(){var t,e=cc.ResolutionPolicy;t=this.fitHeight&&this.fitWidth?e.SHOW_ALL:this.fitHeight||this.fitWidth?this.fitWidth?e.FIXED_WIDTH:e.FIXED_HEIGHT:e.NO_BORDER;var i=this._designResolution;cc.view.setDesignResolutionSize(i.width,i.height,t)}});cc.Canvas=e.exports=s}),{"../event-manager":110,"./CCComponent":76}],76:[(function(t,e,i){var n=t("../platform/CCObject"),r=t("../platform/js"),s=new(t("../platform/id-generater"))("Comp"),o=n.Flags.IsOnEnableCalled,a=n.Flags.IsOnLoadCalled,c=cc.Class({name:"cc.Component",extends:n,ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this.__eventTargets=[]},properties:{node:{default:null,visible:!1},name:{get:function(){if(this._name)return this._name;var t=cc.js.getClassName(this),e=t.lastIndexOf(".");return e>=0&&(t=t.slice(e+1)),this.node.name+"<"+t+">"},set:function(t){this._name=t},visible:!1},_id:{default:"",serializable:!1},uuid:{get:function(){var t=this._id;return t||(t=this._id=s.getNewId()),t},visible:!1},__scriptAsset:!1,_enabled:!0,enabled:{get:function(){return this._enabled},set:function(t){if(this._enabled!==t&&(this._enabled=t,this.node._activeInHierarchy)){var e=cc.director._compScheduler;t?e.enableComp(this):e.disableComp(this)}},visible:!1},enabledInHierarchy:{get:function(){return(this._objFlags&o)>0},visible:!1},_isOnLoadCalled:{get:function(){return this._objFlags&a}}},update:null,lateUpdate:null,__preload:null,onLoad:null,start:null,onEnable:null,onDisable:null,onDestroy:null,onFocusInEditor:null,onLostFocusInEditor:null,resetInEditor:null,addComponent:function(t){return this.node.addComponent(t)},getComponent:function(t){return this.node.getComponent(t)},getComponents:function(t){return this.node.getComponents(t)},getComponentInChildren:function(t){return this.node.getComponentInChildren(t)},getComponentsInChildren:function(t){return this.node.getComponentsInChildren(t)},_getLocalBounds:null,onRestore:null,destroy:function(){this._super()&&this._enabled&&this.node._activeInHierarchy&&cc.director._compScheduler.disableComp(this)},_onPreDestroy:function(){this.unscheduleAllCallbacks();for(var t=this.__eventTargets,e=0,i=t.length;e<i;++e){var n=t[e];n&&n.targetOff(this)}t.length=0,cc.director._nodeActivator.destroyComp(this),this.node._removeComponent(this)},_instantiate:function(t){return t||(t=cc.instantiate._clone(this,this)),t.node=null,t},isRunning:function(){return this.enabledInHierarchy},schedule:function(t,e,i,n){cc.assertID(t,1619),cc.assertID(e>=0,1620),e=e||0,i=isNaN(i)?cc.macro.REPEAT_FOREVER:i,n=n||0;var r=cc.director.getScheduler(),s=r.isTargetPaused(this);r.schedule(t,this,e,i,n,s)},scheduleOnce:function(t,e){this.schedule(t,0,0,e)},unschedule:function(t){t&&cc.director.getScheduler().unschedule(t,this)},unscheduleAllCallbacks:function(){cc.director.getScheduler().unscheduleAllForTarget(this)}});c._requireComponent=null,c._executionOrder=0,r.value(c,"_registerEditorProps",(function(t,e){var i=e.requireComponent;i&&(t._requireComponent=i);var n=e.executionOrder;n&&"number"==typeof n&&(t._executionOrder=n)})),c.prototype.__scriptUuid="",cc.Component=e.exports=c}),{"../platform/CCObject":182,"../platform/id-generater":193,"../platform/js":197}],77:[(function(t,e,i){cc.Component.EventHandler=cc.Class({name:"cc.ClickEvent",properties:{target:{default:null,type:cc.Node},component:{default:""},handler:{default:""},customEventData:{default:""}},statics:{emitEvents:function(t){"use strict";var e,i,n;if(arguments.length>0)for(i=0,n=(e=new Array(arguments.length-1)).length;i<n;i++)e[i]=arguments[i+1];for(i=0,n=t.length;i<n;i++){var r=t[i];r instanceof cc.Component.EventHandler&&r.emit(e)}}},emit:function(t){var e=this.target;if(cc.isValid(e)){var i=e.getComponent(this.component);if(cc.isValid(i)){var n=i[this.handler];"function"==typeof n&&(null!=this.customEventData&&""!==this.customEventData&&(t=t.slice()).push(this.customEventData),n.apply(i,t))}}}})}),{}],78:[(function(t,e,i){t("../editbox/CCSGEditBox");var n=_ccsg.EditBox.KeyboardReturnType,r=_ccsg.EditBox.InputMode,s=_ccsg.EditBox.InputFlag,o=cc.Class({name:"cc.EditBox",extends:cc._RendererUnderSG,editor:!1,properties:{_useOriginalSize:!0,_string:"",string:{tooltip:!1,get:function(){return this._sgNode.string},set:function(t){this._sgNode.string=this._string=t}},backgroundImage:{tooltip:!1,default:null,type:cc.SpriteFrame,notify:function(){var t=this._sgNode,e=t.getBackgroundSprite();if(this.backgroundImage){this._createBackgroundSprite().setContentSize(t.getContentSize())}else e.removeFromParent()}},returnType:{default:n.DEFAULT,tooltip:!1,displayName:"KeyboardReturnType",type:n,notify:function(){this._sgNode.returnType=this.returnType}},inputFlag:{tooltip:!1,default:s.DEFAULT,type:s,notify:function(){this._sgNode.inputFlag=this.inputFlag}},inputMode:{tooltip:!1,default:r.ANY,type:r,notify:function(){this._sgNode.inputMode=this.inputMode}},fontSize:{tooltip:!1,default:20,notify:function(){this._sgNode.fontSize=this.fontSize}},lineHeight:{tooltip:!1,default:40,notify:function(){this._sgNode.setLineHeight(this.lineHeight)}},fontColor:{tooltip:!1,default:cc.Color.WHITE,notify:function(){this._sgNode.fontColor=this.fontColor}},placeholder:{tooltip:!1,default:"Enter text here...",notify:function(){this._sgNode.placeholder=this.placeholder}},placeholderFontSize:{tooltip:!1,default:20,notify:function(){this._sgNode.placeholderFontSize=this.placeholderFontSize}},placeholderFontColor:{tooltip:!1,default:cc.Color.GRAY,notify:function(){this._sgNode.placeholderFontColor=this.placeholderFontColor}},maxLength:{tooltip:!1,default:20,notify:function(){this._sgNode.maxLength=this.maxLength}},stayOnTop:{tooltip:!1,default:!1,notify:function(){this._sgNode.stayOnTop(this.stayOnTop),this._sgNode.fontSize=this.fontSize,this._sgNode.fontColor=this.fontColor}},_tabIndex:0,tabIndex:{tooltip:!1,get:function(){return this._tabIndex},set:function(t){this._tabIndex=t,this._sgNode.setTabIndex(t)}},editingDidBegan:{default:[],type:cc.Component.EventHandler},textChanged:{default:[],type:cc.Component.EventHandler},editingDidEnded:{default:[],type:cc.Component.EventHandler},editingReturn:{default:[],type:cc.Component.EventHandler}},statics:{KeyboardReturnType:n,InputFlag:s,InputMode:r},_applyCapInset:function(t){var e=this.backgroundImage;t.setInsetTop(e.insetTop),t.setInsetBottom(e.insetBottom),t.setInsetRight(e.insetRight),t.setInsetLeft(e.insetLeft)},_createSgNode:function(){return new _ccsg.EditBox(cc.size(160,40))},_createBackgroundSprite:function(){var t=this._sgNode,e=new cc.Scale9Sprite;return e.setRenderingType(cc.Scale9Sprite.RenderingType.SLICED),this.backgroundImage&&(this.backgroundImage.ensureLoadTexture(),e.setSpriteFrame(this.backgroundImage),this._applyCapInset(e)),t.initWithSizeAndBackgroundSprite(cc.size(160,40),e),e},_initSgNode:function(){var t=this._sgNode;t.createDomElementIfNeeded(),this._createBackgroundSprite(),t.setContentSize(this.node.getContentSize()),t.inputMode=this.inputMode,t.maxLength=this.maxLength,t.string=this._string,t.fontSize=this.fontSize,t.fontColor=this.fontColor,t.placeholder=this.placeholder,t.placeholderFontSize=this.placeholderFontSize,t.placeholderFontColor=this.placeholderFontColor,t.inputFlag=this.inputFlag,t.returnType=this.returnType,t.setLineHeight(this.lineHeight),t.stayOnTop(this.stayOnTop),t.setTabIndex(this.tabIndex),t.setDelegate(this)},editBoxEditingDidBegan:function(){cc.Component.EventHandler.emitEvents(this.editingDidBegan,this),this.node.emit("editing-did-began",this)},editBoxEditingDidEnded:function(){cc.Component.EventHandler.emitEvents(this.editingDidEnded,this),this.node.emit("editing-did-ended",this)},editBoxTextChanged:function(t,e){cc.Component.EventHandler.emitEvents(this.textChanged,e,this),this.node.emit("text-changed",this)},editBoxEditingReturn:function(){cc.Component.EventHandler.emitEvents(this.editingReturn,this),this.node.emit("editing-return",this)},onDestroy:function(){this._sgNode.setDelegate(null),this._super()},__preload:function(){this._super(),this._registerEvent()},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_onTouchBegan:function(t){this._sgNode&&this._sgNode._onTouchBegan(t.touch),t.stopPropagation()},_onTouchEnded:function(t){this._sgNode&&this._sgNode._onTouchEnded(),t.stopPropagation()},setFocus:function(){this._sgNode&&this._sgNode.setFocus()},isFocused:function(){var t=!1;return this._sgNode&&(t=this._sgNode.isFocused()),t}});cc.EditBox=e.exports=o}),{"../editbox/CCSGEditBox":105}],79:[(function(t,e,i){t("../label/CCSGLabel"),t("../label/CCSGLabelCanvasRenderCmd"),t("../label/CCSGLabelWebGLRenderCmd");var n=cc.TextAlignment,r=cc.VerticalTextAlignment,s=_ccsg.Label.Overflow,o=cc.Class({name:"cc.Label",extends:cc._RendererUnderSG,ctor:function(){0},editor:!1,_updateSgNodeString:function(){this._sgNode.setString(this.string),this._updateNodeSize()},_updateSgNodeFontSize:function(){this._sgNode&&(this._sgNode.setFontSize(this._fontSize),this._updateNodeSize())},properties:{_useOriginalSize:!0,string:{default:"Label",multiline:!0,tooltip:!1,notify:function(){this._sgNode&&this._updateSgNodeString()}},horizontalAlign:{default:n.LEFT,type:n,tooltip:!1,notify:function(){this._sgNode&&this._sgNode.setHorizontalAlign(this.horizontalAlign)},animatable:!1},verticalAlign:{default:r.TOP,type:r,tooltip:!1,notify:function(){this._sgNode&&this._sgNode.setVerticalAlign(this.verticalAlign)},animatable:!1},_actualFontSize:{default:40},actualFontSize:{displayName:"Actual Font Size",animatable:!1,readonly:!0,get:function(){return this._sgNode&&(this._actualFontSize=this._sgNode.getFontSize()),this._actualFontSize}},_fontSize:40,fontSize:{get:function(){return this._fontSize},set:function(t){this._fontSize=t,this._updateSgNodeFontSize()},tooltip:!1},fontFamily:{default:"Arial",tooltip:!1,notify:function(){this._sgNode&&this._sgNode.setFontFamily(this.fontFamily)},animatable:!1},_lineHeight:40,lineHeight:{get:function(){return this._sgNode&&(this._lineHeight=this._sgNode.getLineHeight()),this._lineHeight},set:function(t){this._lineHeight=t,this._sgNode&&(this._sgNode.setLineHeight(t),this._updateNodeSize())},tooltip:!1},overflow:{default:s.NONE,type:s,tooltip:!1,notify:function(){this._sgNode&&(this._sgNode.setOverflow(this.overflow),this._updateNodeSize())},animatable:!1},_enableWrapText:!0,enableWrapText:{get:function(){return this._sgNode&&(this._enableWrapText=this._sgNode.isWrapTextEnabled()),this._enableWrapText},set:function(t){this._enableWrapText=t,this._sgNode&&this._sgNode.enableWrapText(t)},animatable:!1,tooltip:!1},_N$file:null,font:{get:function(){return this._N$file},set:function(t){if(t||(this._isSystemFontUsed=!0),this._N$file=t,this._bmFontOriginalSize=-1,t&&this._isSystemFontUsed&&(this._isSystemFontUsed=!1),this._sgNode){"string"==typeof t&&cc.warnID(4e3);var e=this.font;e instanceof cc.BitmapFont?e.spriteFrame?this._sgNode.setFontAsset(e):(cc.warnID(4011,e.name),this._sgNode.setFontFamily("")):this._sgNode.setFontAsset(e)}t instanceof cc.BitmapFont&&(this._bmFontOriginalSize=t.fontSize)},type:cc.Font,tooltip:!1,animatable:!1},_isSystemFontUsed:!0,useSystemFont:{get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed=!!t,t&&(this.font=null,this._sgNode&&this._sgNode.setFontFamily(this.fontFamily))},animatable:!1,tooltip:!1},_bmFontOriginalSize:{displayName:"BMFont Original Size",default:-1,serializable:!1,readonly:!0,visible:!0,animatable:!1},_spacingX:0,spacingX:{get:function(){return this._spacingX},set:function(t){this._spacingX=t,this._sgNode&&(this._sgNode.setSpacingX(this.spacingX),this._updateNodeSize())}}},statics:{HorizontalAlign:n,VerticalAlign:r,Overflow:s},__preload:function(){this._super(),this._sgNode.on("load",this._updateNodeSize,this),this._updateNodeSize()},_createSgNode:function(){return null},_initSgNode:function(){var t=this.font;"string"==typeof t&&cc.warnID(4e3);var e;t instanceof cc.BitmapFont?t.spriteFrame?e=this._sgNode=_ccsg.Label.pool.get(this.string,t):(cc.warnID(4011,t.name),e=this._sgNode=_ccsg.Label.pool.get(this.string)):e=this._sgNode=_ccsg.Label.pool.get(this.string,t,null,this._fontSize),t instanceof cc.BitmapFont&&(this._bmFontOriginalSize=t.fontSize),e.setVisible(!1),e.setHorizontalAlign(this.horizontalAlign),e.setVerticalAlign(this.verticalAlign),e.setFontSize(this._fontSize),this.useSystemFont&&e.setFontFamily(this.fontFamily),e.setOverflow(this.overflow),e.enableWrapText(this._enableWrapText),e.setLineHeight(this._lineHeight),e.setString(this.string),t instanceof cc.BitmapFont&&e.setSpacingX(this.spacingX),e.setContentSize(this.node.getContentSize()),e.setColor(this.node.color)},_updateNodeSize:function(){this._sgNode&&this._sgNode.parent&&(this.overflow!==s.NONE&&this.overflow!==s.RESIZE_HEIGHT||this.node.setContentSize(this._sgNode.getContentSize()))},onDestroy:function(){var t=this._sgNode;this._super(),t&&(t.removeFromParent(!0),_ccsg.Label.pool.put(t))}});cc.Label=e.exports=o}),{"../label/CCSGLabel":126,"../label/CCSGLabelCanvasRenderCmd":127,"../label/CCSGLabelWebGLRenderCmd":128}],80:[(function(t,e,i){var n=cc.Class({name:"cc.LabelOutline",extends:t("./CCComponent"),editor:!1,ctor:function(){this._labelSGNode=null},properties:{_color:cc.color(255,255,255,255),_width:1,color:{get:function(){return this._color},set:function(t){this._color=cc.color(t),this._labelSGNode&&this._labelSGNode.setOutlineColor(cc.color(this._color))}},width:{get:function(){return this._width},set:function(t){this._width=t,this._labelSGNode&&(this._labelSGNode.setOutlineWidth(t),this._labelSGNode.setMargin(t))}}},onEnable:function(){var t=this.node.getComponent("cc.Label"),e=this._labelSGNode=t&&t._sgNode;this._labelSGNode&&(e.setOutlined(!0),e.setOutlineColor(cc.color(this._color)),e.setOutlineWidth(this._width),e.setMargin(this._width))},onDisable:function(){this._labelSGNode&&(this._labelSGNode.setOutlined(!1),this._labelSGNode.setMargin(0)),this._labelSGNode=null}});cc.LabelOutline=e.exports=n}),{"./CCComponent":76}],81:[(function(t,e,i){var n=cc.Enum({NONE:0,HORIZONTAL:1,VERTICAL:2,GRID:3}),r=cc.Enum({NONE:0,CONTAINER:1,CHILDREN:2}),s=cc.Enum({HORIZONTAL:0,VERTICAL:1}),o=cc.Enum({BOTTOM_TO_TOP:0,TOP_TO_BOTTOM:1}),a=cc.Enum({LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1}),c=cc.Class({name:"cc.Layout",extends:t("./CCComponent"),editor:!1,properties:{_layoutSize:cc.size(300,200),_layoutDirty:{default:!0,serializable:!1},_resize:r.NONE,_N$layoutType:n.NONE,type:{type:n,get:function(){return this._N$layoutType},set:function(t){this._N$layoutType=t;this._doLayoutDirty()},tooltip:!1,animatable:!1},resizeMode:{type:r,tooltip:!1,animatable:!1,get:function(){return this._resize},set:function(t){if(this.type!==n.NONE||t!==r.CHILDREN){this._resize=t;this._doLayoutDirty()}}},cellSize:{default:cc.size(40,40),tooltip:!1,type:cc.Size,notify:function(){this._doLayoutDirty()}},startAxis:{default:s.HORIZONTAL,tooltip:!1,type:s,notify:function(){this._doLayoutDirty()},animatable:!1},_N$padding:{default:0},paddingLeft:{default:0,tooltip:!1,notify:function(){this._doLayoutDirty()}},paddingRight:{default:0,tooltip:!1,notify:function(){this._doLayoutDirty()}},paddingTop:{default:0,tooltip:!1,notify:function(){this._doLayoutDirty()}},paddingBottom:{default:0,tooltip:!1,notify:function(){this._doLayoutDirty()}},spacingX:{default:0,notify:function(){this._doLayoutDirty()},tooltip:!1},spacingY:{default:0,notify:function(){this._doLayoutDirty()},tooltip:!1},verticalDirection:{default:o.TOP_TO_BOTTOM,type:o,notify:function(){this._doLayoutDirty()},tooltip:!1,animatable:!1},horizontalDirection:{default:a.LEFT_TO_RIGHT,type:a,notify:function(){this._doLayoutDirty()},tooltip:!1,animatable:!1}},statics:{Type:n,VerticalDirection:o,HorizontalDirection:a,ResizeMode:r,AxisDirection:s},_migratePaddingData:function(){this.paddingLeft=this._N$padding,this.paddingRight=this._N$padding,this.paddingTop=this._N$padding,this.paddingBottom=this._N$padding,this._N$padding=0},onEnable:function(){this._addEventListeners(),cc.sizeEqualToSize(this.node.getContentSize(),cc.size(0,0))&&this.node.setContentSize(this._layoutSize),0!==this._N$padding&&this._migratePaddingData(),this._doLayoutDirty()},onDisable:function(){this._removeEventListeners()},_doLayoutDirty:function(){this._layoutDirty=!0},_addEventListeners:function(){cc.director.on(cc.Director.EVENT_BEFORE_VISIT,this.updateLayout,this),this.node.on("size-changed",this._resized,this),this.node.on("anchor-changed",this._doLayoutDirty,this),this.node.on("child-added",this._childAdded,this),this.node.on("child-removed",this._childRemoved,this),this.node.on("child-reorder",this._doLayoutDirty,this),this._addChildrenEventListeners()},_removeEventListeners:function(){cc.director.off(cc.Director.EVENT_BEFORE_VISIT,this.updateLayout,this),this.node.off("size-changed",this._resized,this),this.node.off("anchor-changed",this._doLayoutDirty,this),this.node.off("child-added",this._childAdded,this),this.node.off("child-removed",this._childRemoved,this),this.node.off("child-reorder",this._doLayoutDirty,this),this._removeChildrenEventListeners()},_addChildrenEventListeners:function(){this.node.children.forEach(function(t){t.on("size-changed",this._doLayoutDirty,this),t.on("position-changed",this._doLayoutDirty,this),t.on("anchor-changed",this._doLayoutDirty,this),t.on("active-in-hierarchy-changed",this._doLayoutDirty,this)}.bind(this))},_removeChildrenEventListeners:function(){this.node.children.forEach(function(t){t.off("size-changed",this._doLayoutDirty,this),t.off("position-changed",this._doLayoutDirty,this),t.off("anchor-changed",this._doLayoutDirty,this),t.off("active-in-hierarchy-changed",this._doLayoutDirty,this)}.bind(this))},_childAdded:function(t){var e=t.detail;e.on("size-changed",this._doLayoutDirty,this),e.on("position-changed",this._doLayoutDirty,this),e.on("anchor-changed",this._doLayoutDirty,this),e.on("active-in-hierarchy-changed",this._doLayoutDirty,this),this._doLayoutDirty()},_childRemoved:function(t){var e=t.detail;e.off("size-changed",this._doLayoutDirty,this),e.off("position-changed",this._doLayoutDirty,this),e.off("anchor-changed",this._doLayoutDirty,this),e.off("active-in-hierarchy-changed",this._doLayoutDirty,this),this._doLayoutDirty()},_resized:function(){this._layoutSize=this.node.getContentSize(),this._doLayoutDirty()},_doLayoutHorizontally:function(t,e,i,s){var c=this.node.getAnchorPoint(),h=this.node.children,l=1,u=this.paddingLeft,_=-c.x*t;this.horizontalDirection===a.RIGHT_TO_LEFT&&(l=-1,_=(1-c.x)*t,u=this.paddingRight);var d=_+l*u-l*this.spacingX,f=0,p=0,m=0,g=0,y=0,v=0,x=this.cellSize.width;return this.type!==n.GRID&&this.resizeMode===r.CHILDREN&&(x=(t-(this.paddingLeft+this.paddingRight)-(h.length-1)*this.spacingX)/h.length),h.forEach(function(h){if(h.activeInHierarchy){this._resize===r.CHILDREN&&(h.width=x,this.type===n.GRID&&(h.height=this.cellSize.height));var C=h.anchorX;m>p&&(p=m),h.height>=p&&(m=p,p=h.height,v=h.getAnchorPoint().y),this.horizontalDirection===a.RIGHT_TO_LEFT&&(C=1-h.anchorX),d=d+l*C*h.width+l*this.spacingX;var T=l*(1-C)*h.width;if(e){var b=d+T+l*(l>0?this.paddingRight:this.paddingLeft),A=this.horizontalDirection===a.LEFT_TO_RIGHT&&b>(1-c.x)*t,S=this.horizontalDirection===a.RIGHT_TO_LEFT&&b<-c.x*t;(A||S)&&(h.height>=p?(0===m&&(m=p),f+=m,m=p):(f+=p,m=h.height,p=0),d=_+l*(u+C*h.width),g++)}var w=i(h,f,g);t>=h.width+this.paddingLeft+this.paddingRight&&s&&h.setPosition(cc.p(d,w));var E,I=1,R=0===p?h.height:p;this.verticalDirection===o.TOP_TO_BOTTOM?(y=y||this.node._contentSize.height,(E=w+(I=-1)*(R*v+this.paddingBottom))<y&&(y=E)):(y=y||-this.node._contentSize.height,(E=w+I*(R*v+this.paddingTop))>y&&(y=E)),d+=T}}.bind(this)),y},_getVerticalBaseHeight:function(t){var e=0,i=0;return this.resizeMode===r.CONTAINER?(t.forEach((function(t){t.activeInHierarchy&&(i++,e+=t.height)})),e+=(i-1)*this.spacingY+this.paddingBottom+this.paddingTop):e=this.node.getContentSize().height,e},_doLayoutVertically:function(t,e,i,s){var c=this.node.getAnchorPoint(),h=this.node.children,l=1,u=this.paddingBottom,_=-c.y*t;this.verticalDirection===o.TOP_TO_BOTTOM&&(l=-1,_=(1-c.y)*t,u=this.paddingTop);var d=_+l*u-l*this.spacingY,f=0,p=0,m=0,g=0,y=0,v=0,x=this.cellSize.height;return this.type!==n.GRID&&this.resizeMode===r.CHILDREN&&(x=(t-(this.paddingTop+this.paddingBottom)-(h.length-1)*this.spacingY)/h.length),h.forEach(function(h){if(h.activeInHierarchy){this.resizeMode===r.CHILDREN&&(h.height=x,this.type===n.GRID&&(h.width=this.cellSize.width));var C=h.anchorY;m>p&&(p=m),h.width>=p&&(m=p,p=h.width,v=h.getAnchorPoint().x),this.verticalDirection===o.TOP_TO_BOTTOM&&(C=1-h.anchorY),d=d+l*C*h.height+l*this.spacingY;var T=l*(1-C)*h.height;if(e){var b=d+T+l*(l>0?this.paddingTop:this.paddingBottom),A=this.verticalDirection===o.BOTTOM_TO_TOP&&b>(1-c.y)*t,S=this.verticalDirection===o.TOP_TO_BOTTOM&&b<-c.y*t;(A||S)&&(h.width>=p?(0===m&&(m=p),f+=m,m=p):(f+=p,m=h.width,p=0),d=_+l*(u+C*h.height),g++)}var w=i(h,f,g);t>=h.height+(this.paddingTop+this.paddingBottom)&&s&&h.setPosition(cc.p(w,d));var E,I=1,R=0===p?h.width:p;this.horizontalDirection===a.RIGHT_TO_LEFT?(I=-1,y=y||this.node._contentSize.width,(E=w+I*(R*v+this.paddingLeft))<y&&(y=E)):(y=y||-this.node._contentSize.width,(E=w+I*(R*v+this.paddingRight))>y&&(y=E)),d+=T}}.bind(this)),y},_doLayoutBasic:function(){var t=null;if(this.node.children.forEach((function(e){e.activeInHierarchy&&(t=t?cc.rectUnion(t,e.getBoundingBoxToWorld()):e.getBoundingBoxToWorld())})),t){var e=this.node.parent.convertToNodeSpaceAR(cc.p(t.x,t.y));e=cc.pAdd(e,cc.p(-this.paddingLeft,-this.paddingBottom));var i=this.node.parent.convertToNodeSpaceAR(cc.p(t.x+t.width,t.y+t.height));i=cc.pAdd(i,cc.p(this.paddingRight,this.paddingTop));var n=cc.size(parseFloat((i.x-e.x).toFixed(2)),parseFloat((i.y-e.y).toFixed(2))),r=this.node.getPosition(),s=(r.x-e.x)/n.width,o=(r.y-e.y)/n.height,a=cc.p(parseFloat(s.toFixed(2)),parseFloat(o.toFixed(2)));this.node.setAnchorPoint(a),this.node.setContentSize(n)}},_doLayoutGridAxisHorizontal:function(t,e){var i=e.width,n=1,s=-t.y*e.height,a=this.paddingBottom;this.verticalDirection===o.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*e.height,a=this.paddingTop);var c=function(t,e,i){return s+n*(e+t.anchorY*t.height+a+i*this.spacingY)}.bind(this),h=0;if(this.resizeMode===r.CONTAINER){var l=this._doLayoutHorizontally(i,!0,c,!1);(h=s-l)<0&&(h*=-1),s=-t.y*h,this.verticalDirection===o.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*h)}this._doLayoutHorizontally(i,!0,c,!0),this.resizeMode===r.CONTAINER&&this.node.setContentSize(i,h)},_doLayoutGridAxisVertical:function(t,e){var i=e.height,n=1,s=-t.x*e.width,o=this.paddingLeft;this.horizontalDirection===a.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*e.width,o=this.paddingRight);var c=function(t,e,i){return s+n*(e+t.anchorX*t.width+o+i*this.spacingX)}.bind(this),h=0;if(this.resizeMode===r.CONTAINER){var l=this._doLayoutVertically(i,!0,c,!1);(h=s-l)<0&&(h*=-1),s=-t.x*h,this.horizontalDirection===a.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*h)}this._doLayoutVertically(i,!0,c,!0),this.resizeMode===r.CONTAINER&&this.node.setContentSize(h,i)},_doLayoutGrid:function(){var t=this.node.getAnchorPoint(),e=this.node.getContentSize();this.startAxis===s.HORIZONTAL?this._doLayoutGridAxisHorizontal(t,e):this.startAxis===s.VERTICAL&&this._doLayoutGridAxisVertical(t,e)},_getHorizontalBaseWidth:function(t){var e=0,i=0;return this.resizeMode===r.CONTAINER?(t.forEach((function(t){t.activeInHierarchy&&(i++,e+=t.width)})),e+=(i-1)*this.spacingX+this.paddingLeft+this.paddingRight):e=this.node.getContentSize().width,e},_doLayout:function(){if(this.type===n.HORIZONTAL){var t=this._getHorizontalBaseWidth(this.node.children),e=function(t){return t.y};this._doLayoutHorizontally(t,!1,e,!0),this.node.width=t}else if(this.type===n.VERTICAL){var i=this._getVerticalBaseHeight(this.node.children),s=function(t){return t.x};this._doLayoutVertically(i,!1,s,!0),this.node.height=i}else this.type===n.NONE?this.resizeMode===r.CONTAINER&&this._doLayoutBasic():this.type===n.GRID&&this._doLayoutGrid()},updateLayout:function(){this._layoutDirty&&this.node.children.length>0&&(this._doLayout(),this._layoutDirty=!1)}});Object.defineProperty(c.prototype,"padding",{get:function(){return cc.warnID(4100),this.paddingLeft},set:function(t){this._N$padding=t,this._migratePaddingData(),this._doLayoutDirty()}}),cc.Layout=e.exports=c}),{"./CCComponent":76}],82:[(function(t,e,i){t("../../clipping-nodes/CCClippingNode"),t("../../clipping-nodes/CCClippingNodeCanvasRenderCmd"),t("../../clipping-nodes/CCClippingNodeWebGLRenderCmd"),t("../../shape-nodes/CCDrawNode");var n=cc._RendererInSG,r=cc.Enum({RECT:0,ELLIPSE:1,IMAGE_STENCIL:2}),s=cc.Class({name:"cc.Mask",extends:n,editor:!1,properties:{_clippingStencil:{default:null,serializable:!1},_type:r.RECT,type:{get:function(){return this._type},set:function(t){this._type=t,this._refreshStencil()},type:r,tooltip:!1},spriteFrame:{default:null,type:cc.SpriteFrame,tooltip:!1,notify:function(){this._refreshStencil()}},alphaThreshold:{default:1,type:cc.Float,range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){cc._renderType!==cc.game.RENDER_TYPE_CANVAS?this._sgNode.setAlphaThreshold(this.alphaThreshold):cc.warnID(4201)}},inverted:{default:!1,type:cc.Boolean,tooltip:!1,notify:function(){cc._renderType!==cc.game.RENDER_TYPE_CANVAS?this._sgNode.setInverted(this.inverted):cc.warnID(4202)}},_segements:64,segements:{get:function(){return this._segements},set:function(t){this._segements=cc.clampf(t,3,1e4),this._refreshStencil()},tooltip:!1},_resizeToTarget:{animatable:!1,set:function(t){t&&this._resizeNodeToTargetNode()}}},statics:{Type:r},_resizeNodeToTargetNode:!1,_initSgNode:function(){},_createSgNode:function(){return new cc.ClippingNode},_hitTest:function(t){var e=this.node.getContentSize(),i=e.width,n=e.height,s=this.node.getNodeToWorldTransform();if(this.type===r.RECT||this.type===r.IMAGE_STENCIL){var o=cc.rect(0,0,i,n);cc._rectApplyAffineTransformIn(o,s);var a=t.x-o.x,c=o.x+o.width-t.x,h=t.y-o.y,l=o.y+o.height-t.y;return a>=0&&c>=0&&l>=0&&h>=0}if(this.type===r.ELLIPSE){var u=i/2,_=n/2,d=s.a*u+s.c*_+s.tx,f=s.b*u+s.d*_+s.ty,p=t.x-d,m=t.y-f;return p*p/(u*u)+m*m/(_*_)<1}},onEnable:function(){this._super(),this.spriteFrame&&this.spriteFrame.ensureLoadTexture(),this._refreshStencil(),this.node.on("size-changed",this._refreshStencil,this),this.node.on("anchor-changed",this._refreshStencil,this)},onDisable:function(){this._super(),this.node.off("size-changed",this._refreshStencil,this),this.node.off("anchor-changed",this._refreshStencil,this)},_calculateCircle:function(t,e,i){for(var n=[],r=2*Math.PI/i,s=0;s<i;++s)n.push(cc.v2(e.x*Math.cos(r*s)+t.x,e.y*Math.sin(r*s)+t.y));return n},_refreshStencil:function(){if(this.type!==r.IMAGE_STENCIL||cc._renderType===cc.game.RENDER_TYPE_WEBGL){var t=this.node.getContentSize(),e=this.node.getAnchorPoint(),i=this._clippingStencil;if(this._type===r.IMAGE_STENCIL){i instanceof cc.Scale9Sprite&&i._spriteFrame===this.spriteFrame||((i=new cc.Scale9Sprite).setSpriteFrame(this.spriteFrame),this._sgNode.setStencil(i)),i.setContentSize(t),i.setAnchorPoint(e),this._sgNode.setAlphaThreshold(this.alphaThreshold)}else{i instanceof cc.DrawNode||(i=new cc.DrawNode,this._sgNode.setStencil(i));var n=t.width,s=t.height,o=-n*e.x,a=-s*e.y,c=cc.color(255,255,255,0);if(i.clear(),this._type===r.RECT){var h=[cc.v2(o,a),cc.v2(o+n,a),cc.v2(o+n,a+s),cc.v2(o,a+s)];i.drawPoly(h,c,0,c)}else if(this._type===r.ELLIPSE){var l=cc.v2(o+n/2,a+s/2),u={x:n/2,y:s/2};i.drawPoly(this._calculateCircle(l,u,this._segements),c,0,c)}}this._sgNode.setInverted(this.inverted),this._clippingStencil=i,cc.renderer.childrenOrderDirty=!0}else cc.warnID(4200)}});cc.Mask=e.exports=s}),{"../../clipping-nodes/CCClippingNode":25,"../../clipping-nodes/CCClippingNodeCanvasRenderCmd":26,"../../clipping-nodes/CCClippingNodeWebGLRenderCmd":27,"../../shape-nodes/CCDrawNode":275}],83:[(function(t,e,i){var n=cc.Enum({Unified:0,Free:1}),r=cc.Enum({Horizontal:0,Vertical:1}),s=cc.Enum({PAGE_TURNING:0}),o=cc.Class({name:"cc.PageView",extends:cc.ScrollView,editor:!1,ctor:function(){this._curPageIdx=0,this._lastPageIdx=0,this._pages=[],this._scrollCenterOffsetX=[],this._scrollCenterOffsetY=[]},properties:{sizeMode:{default:n.Unified,type:n,tooltip:!1,notify:function(){this._syncSizeMode()}},direction:{default:r.Horizontal,type:r,tooltip:!1,notify:function(){this._syncScrollDirection()}},scrollThreshold:{default:.5,type:cc.Float,slide:!0,range:[0,1,.01],tooltip:!1},autoPageTurningThreshold:{default:100,type:cc.Float,tooltip:!1},pageTurningEventTiming:{default:.1,type:cc.Float,range:[0,1,.01],tooltip:!1},indicator:{default:null,type:cc.PageViewIndicator,tooltip:!1,notify:function(){this.indicator&&this.indicator.setPageView(this)}},pageTurningSpeed:{default:.3,type:cc.Float,tooltip:!1},pageEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1}},statics:{SizeMode:n,Direction:r,EventType:s},__preload:function(){this.node.on("size-changed",this._updateAllPagesSize,this)},onEnable:function(){this._super(),this.node.on("scroll-ended-with-threshold",this._dispatchPageTurningEvent,this)},onDisable:function(){this._super(),this.node.off("scroll-ended-with-threshold",this._dispatchPageTurningEvent,this)},onLoad:function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},onDestroy:function(){this.node.off("size-changed",this._updateAllPagesSize,this)},getCurrentPageIndex:function(){return this._curPageIdx},setCurrentPageIndex:function(t){this.scrollToPage(t,!0)},getPages:function(){return this._pages},addPage:function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(this.content.addChild(t),this._pages.push(t),this._updatePageView())},insertPage:function(t,e){if(!(e<0)&&t&&-1===this._pages.indexOf(t)&&this.content){e>=this._pages.length?this.addPage(t):(this._pages.splice(e,0,t),this.content.addChild(t),this._updatePageView())}},removePage:function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):cc.warnID(4300,t.name)}},removePageAtIndex:function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},removeAllPages:function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e<i;e++)this.content.removeChild(t[e]);this._pages.length=0,this._updatePageView()}},scrollToPage:function(t,e){t<0||t>=this._pages.length||(e=void 0!==e?e:.3,this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},getScrollEndedEventTiming:function(){return this.pageTurningEventTiming},_syncScrollDirection:function(){this.horizontal=this.direction===r.Horizontal,this.vertical=this.direction===r.Vertical},_syncSizeMode:function(){if(this.content){var t=this.content.getComponent(cc.Layout);if(t){if(0===this._pages.length)t.padding=0;else{var e=this._pages[this._pages.length-1];this.sizeMode===n.Free&&(this.direction===r.Horizontal?(t.paddingLeft=(this.node.width-this._pages[0].width)/2,t.paddingRight=(this.node.width-e.width)/2):this.direction===r.Vertical&&(t.paddingTop=(this.node.height-this._pages[0].height)/2,t.paddingBottom=(this.node.height-e.height)/2))}t.updateLayout()}}},_updatePageView:function(){var t=this._pages.length;this._curPageIdx>=t&&(this._curPageIdx=0===t?0:t-1,this._lastPageIdx=this._curPageIdx);for(var e=0;e<t;++e)this._pages[e].setSiblingIndex(e),this.direction===r.Horizontal?this._scrollCenterOffsetX[e]=Math.abs(this.content.x+this._pages[e].x):this._scrollCenterOffsetY[e]=Math.abs(this.content.y+this._pages[e].y);var i=this.content.getComponent(cc.Layout);i&&i.enabled&&i.updateLayout(),this.indicator&&this.indicator._refresh()},_updateAllPagesSize:function(){if(this.sizeMode===n.Unified)for(var t=this._pages,e=this.node.getContentSize(),i=0,r=t.length;i<r;i++)t[i].setContentSize(e)},_initPages:function(){if(this.content){for(var t=this.content.children,e=0;e<t.length;++e){var i=t[e];this._pages.indexOf(i)>=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},_dispatchPageTurningEvent:function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,cc.Component.EventHandler.emitEvents(this.pageEvents,this,s.PAGE_TURNING),this.node.emit("page-turning",this))},_isScrollable:function(t,e,i){if(this.sizeMode===n.Free){var s,o;if(this.direction===r.Horizontal)return s=this._scrollCenterOffsetX[e],o=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(s-o)*this.scrollThreshold;if(this.direction===r.Vertical)return s=this._scrollCenterOffsetY[e],o=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(s-o)*this.scrollThreshold}else{if(this.direction===r.Horizontal)return Math.abs(t.x)>=this.node.width*this.scrollThreshold;if(this.direction===r.Vertical)return Math.abs(t.y)>=this.node.height*this.scrollThreshold}},_isQuicklyScrollable:function(t){if(this.direction===r.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===r.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},_moveOffsetValue:function(t){var e=cc.p(0,0);return this.sizeMode===n.Free?this.direction===r.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===r.Vertical&&(e.y=this._scrollCenterOffsetY[t]):this.direction===r.Horizontal?e.x=t*this.node.width:this.direction===r.Vertical&&(e.y=t*this.node.height),e},_getDragDirection:function(t){return this.direction===r.Horizontal?0===t.x?0:t.x>0?1:-1:this.direction===r.Vertical?0===t.y?0:t.y<0?1:-1:void 0},_handleReleaseLogic:function(t){var e=this._startBounceBackIfNeeded(),i=cc.pSub(this._touchBeganPosition,this._touchEndPosition);if(e){var n=this._getDragDirection(i);if(0===n)return;this._curPageIdx=n>0?this._pages.length-1:0,this.indicator&&this.indicator._changedState()}else{var r=this._curPageIdx,s=r+this._getDragDirection(i),o=this.pageTurningSpeed*Math.abs(r-s);if(s<this._pages.length){if(this._isScrollable(i,r,s))return void this.scrollToPage(s,o);var a=this._calculateTouchMoveVelocity();if(this._isQuicklyScrollable(a))return void this.scrollToPage(s,o)}this.scrollToPage(r,o)}},_onTouchBegan:function(t,e){this._touchBeganPosition=t.touch.getLocation(),this._super(t,e)},_onTouchMoved:function(t,e){this._super(t,e)},_onTouchEnded:function(t,e){this._touchEndPosition=t.touch.getLocation(),this._super(t,e)},_onTouchCancelled:function(t,e){this._touchEndPosition=t.touch.getLocation(),this._super(t,e)},_onMouseWheel:function(){}});cc.PageView=e.exports=o}),{}],84:[(function(t,e,i){var n=cc.Enum({HORIZONTAL:0,VERTICAL:1}),r=cc.Class({name:"cc.PageViewIndicator",extends:t("./CCComponent"),editor:!1,properties:{_layout:null,_pageView:null,_indicators:[],spriteFrame:{default:null,type:cc.SpriteFrame,tooltip:!1},direction:{default:n.HORIZONTAL,type:n,tooltip:!1},cellSize:{default:cc.size(20,20),tooltip:!1},spacing:{default:0,tooltip:!1}},statics:{Direction:n},onLoad:function(){this._updateLayout()},setPageView:function(t){this._pageView=t,this._refresh()},_updateLayout:function(){this._layout=this.getComponent(cc.Layout),this._layout||(this._layout=this.addComponent(cc.Layout)),this.direction===n.HORIZONTAL?(this._layout.type=cc.Layout.Type.HORIZONTAL,this._layout.spacingX=this.spacing):this.direction===n.VERTICAL&&(this._layout.type=cc.Layout.Type.VERTICAL,this._layout.spacingY=this.spacing),this._layout.resizeMode=cc.Layout.ResizeMode.CONTAINER},_createIndicator:function(){var t=new cc.Node;return t.addComponent(cc.Sprite).spriteFrame=this.spriteFrame,t.parent=this.node,t.width=this.cellSize.width,t.height=this.cellSize.height,t},_changedState:function(){var t=this._indicators;if(0!==t.length){var e=this._pageView._curPageIdx;if(!(e>=t.length)){for(var i=0;i<t.length;++i){t[i].opacity=127.5}t[e].opacity=255}}},_refresh:function(){if(this._pageView){var t=this._indicators,e=this._pageView.getPages();if(e.length!==t.length){var i=0;if(e.length>t.length)for(i=0;i<e.length;++i)t[i]||(t[i]=this._createIndicator());else{for(i=t.length-e.length;i>0;--i){var n=t[i-1];this.node.removeChild(n),t.splice(i-1,1)}}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}}});cc.PageViewIndicator=e.exports=r}),{"./CCComponent":76}],85:[(function(t,e,i){var n=cc.Enum({HORIZONTAL:0,VERTICAL:1,FILLED:2}),r=cc.Class({name:"cc.ProgressBar",extends:t("./CCComponent"),editor:!1,_initBarSprite:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=this.node.getContentSize(),i=this.node.getAnchorPoint(),r=t.getContentSize();t.parent===this.node&&this.node.setContentSize(r),this.barSprite.fillType===cc.Sprite.FillType.RADIAL&&(this.mode=n.FILLED);var s=t.getContentSize();if(this.mode===n.HORIZONTAL?this.totalLength=s.width:this.mode===n.VERTICAL?this.totalLength=s.height:this.totalLength=this.barSprite.fillRange,t.parent===this.node){var o=-e.width*i.x;t.setPosition(cc.p(o,0))}}},_updateBarStatus:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e,i,r,s=t.getAnchorPoint(),o=t.getContentSize(),a=t.getPosition(),c=cc.p(0,.5),h=cc.clamp01(this.progress),l=this.totalLength*h;switch(this.mode){case n.HORIZONTAL:this.reverse&&(c=cc.p(1,.5)),e=cc.size(l,o.height),i=this.totalLength,r=o.height;break;case n.VERTICAL:c=this.reverse?cc.p(.5,1):cc.p(.5,0),e=cc.size(o.width,l),i=o.width,r=this.totalLength}if(this.mode===n.FILLED)this.barSprite.type!==cc.Sprite.Type.FILLED?cc.warn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this.reverse&&(l*=-1),this.barSprite.fillRange=l);else if(this.barSprite.type!==cc.Sprite.Type.FILLED){var u=c.x-s.x,_=c.y-s.y,d=cc.p(i*u,r*_);t.setPosition(cc.pAdd(a,d)),t.setAnchorPoint(c),t.setContentSize(e)}else cc.warn("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},properties:{barSprite:{default:null,type:cc.Sprite,tooltip:!1,notify:function(){this._initBarSprite()},animatable:!1},mode:{default:n.HORIZONTAL,type:n,tooltip:!1,notify:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=t.getContentSize();this.mode===n.HORIZONTAL?this.totalLength=e.width:this.mode===n.VERTICAL?this.totalLength=e.height:this.mode===n.FILLED&&(this.totalLength=this.barSprite.fillRange)}},animatable:!1},_N$totalLength:1,totalLength:{range:[0,Number.MAX_VALUE],tooltip:!1,get:function(){return this._N$totalLength},set:function(t){this.mode===n.FILLED&&(t=cc.clamp01(t)),this._N$totalLength=t,this._updateBarStatus()}},progress:{default:1,type:"Float",range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){this._updateBarStatus()}},reverse:{default:!1,tooltip:!1,notify:function(){this.barSprite&&(this.barSprite.fillStart=1-this.barSprite.fillStart),this._updateBarStatus()},animatable:!1}},statics:{Mode:n}});cc.ProgressBar=e.exports=r}),{"./CCComponent":76}],86:[(function(t,e,i){var n=cc.Class({extends:t("./CCSGComponent"),name:"cc._RendererInSG",ctor:function(){var t=this._sgNode=this._createSgNode();t.setVisible(!1),this._plainNode=new _ccsg.Node},__preload:function(){this._initSgNode()},onEnable:function(){this._replaceSgNode(this._sgNode)},onDisable:function(){this._replaceSgNode(this._plainNode)},onDestroy:function(){this._removeSgNode()},_replaceSgNode:function(t){var e=this.node,i=e._sgNode;i._entity=null;var n=i.getChildren().slice();i.removeAllChildren(!1),t.getChildrenCount()>0&&t.removeAllChildren(!1);for(var r=0,s=n.length;r<s;++r)t.addChild(n[r]);var o=i.getParent();o&&(o.removeChild(i,!1),o.addChild(t),t._arrivalOrder=i._arrivalOrder,cc.renderer.childrenOrderDirty=o._reorderChildDirty=!0),e._sgNode=t,e._sgNode._entity=e,e._updateSgNode()}});cc._RendererInSG=e.exports=n}),{"./CCSGComponent":89}],87:[(function(t,e,i){var n=cc.Class({extends:t("./CCSGComponent"),name:"cc._RendererUnderSG",ctor:function(){var t=this._sgNode=this._createSgNode();t&&t.setVisible(!1)},__preload:function(){this._initSgNode(),this._registSizeProvider(),this._appendSgNode(this._sgNode)},onEnable:function(){this._sgNode&&this._sgNode.setVisible(!0)},onDisable:function(){this._sgNode&&this._sgNode.setVisible(!1)},onDestroy:function(){this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),this._removeSgNode()},_appendSgNode:function(t){if(t){var e=this.node;t.setColor(e._color),e._cascadeOpacityEnabled||t.setOpacity(e._opacity),t.setAnchorPoint(e._anchorPoint),t.setOpacityModifyRGB(e._opacityModifyRGB),t.setLocalZOrder(-1);e._sgNode.addChild(t)}}});cc._RendererUnderSG=e.exports=n}),{"./CCSGComponent":89}],88:[(function(t,e,i){t("../label/CCHtmlTextParser"),t("../label/CCTextUtils");var n=cc.TextAlignment,r=cc.VerticalTextAlignment,s=cc.Class({name:"cc.RichText",extends:cc._RendererUnderSG,ctor:function(){this._textArray=null,this._labelSegments=[],this._labelSegmentsCache=[],this._linesWidth=[],this._resetState(),this._updateRichTextStatus=this._updateRichText},editor:!1,properties:{string:{default:"<color=#00ff00>Rich</c><color=#0fffff>Text</color>",multiline:!0,tooltip:!1,notify:function(){this._updateRichTextStatus()}},horizontalAlign:{default:n.LEFT,type:n,tooltip:!1,animatable:!1,notify:function(t){this.horizontalAlign!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},fontSize:{default:40,tooltip:!1,notify:function(t){this.fontSize!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},font:{default:null,type:cc.TTFFont,tooltip:!1,notify:function(t){this.font!==t&&(this._layoutDirty=!0,this.font&&this._onTTFLoaded(),this._updateRichTextStatus())}},maxWidth:{default:0,tooltip:!1,notify:function(t){this.maxWidth!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},lineHeight:{default:40,tooltip:!1,notify:function(t){this.lineHeight!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},imageAtlas:{default:null,type:cc.SpriteAtlas,tooltip:!1,notify:function(t){this.imageAtlas!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},handleTouchEvent:{default:!0,tooltip:!1,notify:function(t){this.handleTouchEvent!==t&&this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners())}}},statics:{HorizontalAlign:n,VerticalAlign:r},onEnable:function(){this._super(),this.handleTouchEvent&&this._addEventListeners()},onDisable:function(){this._super(),this.handleTouchEvent&&this._removeEventListeners()},_addEventListeners:function(){this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_removeEventListeners:function(){this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_createSgNode:function(){var t=new _ccsg.Node;t.setCascadeOpacityEnabled(!0);var e=this;return t.setColor=function(){e._updateLabelSegmentTextAttributes()},t._setContentSize=t.setContentSize,t.setContentSize=function(){},t},_updateLabelSegmentTextAttributes:function(){this._labelSegments.forEach(function(t){this._applyTextAttribute(t)}.bind(this))},_initSgNode:function(){this._updateRichText(),this._onTTFLoaded()},_createFontLabel:function(t){return _ccsg.Label.pool.get(t,this.font,null,this.fontSize)},_getFontRawUrl:function(){return this.font instanceof cc.TTFFont?this.font.rawUrl:""},_onTTFLoaded:function(){var t=this._getFontRawUrl();if(t){var e=this;cc.CustomFontLoader.loadTTF(t,(function(){e._layoutDirty=!0,e._updateRichText()}))}},_measureText:function(t,e){var i=this,n=function(e){var n;0===i._labelSegmentsCache.length?(n=i._createFontLabel(e),i._labelSegmentsCache.push(n)):(n=i._labelSegmentsCache[0]).setString(e),n._styleIndex=t,i._applyTextAttribute(n);return n.getContentSize().width};return e?n(e):n},_onTouchEnded:function(t){for(var e=this.node.getComponents(cc.Component),i=0;i<this._labelSegments.length;++i){var n=this._labelSegments[i],r=n._clickHandler;r&&this._containsTouchLocation(n,t.touch.getLocation())&&(e.forEach((function(e){e.enabledInHierarchy&&e[r]&&e[r](t)})),t.stopPropagation())}},_containsTouchLocation:function(t,e){var i=t.getBoundingBoxToWorld();return cc.rectContainsPoint(i,e)},_resetState:function(){var t=this._sgNode;t&&t.removeAllChildren(),this._labelSegments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},_addLabelSegment:function(t,e){var i;0===this._labelSegmentsCache.length?i=this._createFontLabel(t):(i=this._labelSegmentsCache.pop()).setString(t),i._styleIndex=e,i._lineCount=this._lineCount,this._applyTextAttribute(i),i.setAnchorPoint(0,0),this._sgNode.addChild(i),this._labelSegments.push(i);return i},_updateRichTextWithMaxWidth:function(t,e,i){var n=e;if(this._lineOffsetX>0&&n+this._lineOffsetX>this.maxWidth)for(var r=0;this._lineOffsetX<=this.maxWidth;){var s=this._getFirstWordLen(t,r,t.length),o=t.substr(r,s),a=this._measureText(i,o);if(!(this._lineOffsetX+a<=this.maxWidth)){if(r>0){var c=t.substr(0,r);this._addLabelSegment(c,i),t=t.substr(r,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=a,r+=s}if(n>this.maxWidth)for(var h=cc.TextUtils.fragmentText(t,n,this.maxWidth,this._measureText(i)),l=0;l<h.length;++l){var u=h[l],_=this._addLabelSegment(u,i).getContentSize();this._lineOffsetX+=_.width,h.length>1&&l<h.length-1&&this._updateLineInfo()}else this._lineOffsetX+=n,this._addLabelSegment(t,i)},_isLastComponentCR:function(t){return t.length-1===t.lastIndexOf("\n")},_updateLineInfo:function(){this._linesWidth.push(this._lineOffsetX),this._lineOffsetX=0,this._lineCount++},_needsUpdateTextLayout:function(t){if(this._layoutDirty||!this._textArray||!t)return!0;if(this._textArray.length!==t.length)return!0;for(var e=0;e<this._textArray.length;++e){var i=this._textArray[e],n=t[e];if(i.text!=n.text)return!0;if(i.style){if(n.style){if(i.style.size!==n.style.size||i.style.italic!==n.style.italic||i.style.isImage!==n.style.isImage)return!0;if(i.style.isImage===n.style.isImage&&i.style.src!==n.style.src)return!0}else if(i.style.size||i.style.italic||i.style.isImage)return!0}else if(n.style&&(n.style.size||n.style.italic||n.style.isImage))return!0}return!1},_onSpriteFrameLoaded:function(t,e){var i;(i=e||t.target).__sprite.setSpriteFrame(i)},_applySpriteFrame:function(t){t&&(t.textureLoaded()?this._onSpriteFrameLoaded(null,t):(t.once("load",this._onSpriteFrameLoaded,this),t.ensureLoadTexture()))},_addRichTextImageElement:function(t){var e=t.style.src,i=this.imageAtlas.getSpriteFrame(e);if(i){var n=new cc.Scale9Sprite;n.setAnchorPoint(0,0),i.__sprite=n,this._sgNode.addChild(n),this._labelSegments.push(n);var r=i.getRect(),s=1,o=r.width,a=r.height,c=t.style.imageWidth,h=t.style.imageHeight;h>0&&h<this.lineHeight?(o*=s=h/a,a*=s):(o*=s=this.lineHeight/a,a*=s),c>0&&(o=c),this.maxWidth>0?(this._lineOffsetX+o>this.maxWidth&&this._updateLineInfo(),this._lineOffsetX+=o):(this._lineOffsetX+=o,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),this._applySpriteFrame(i),n.setContentSize(o,a),n._lineCount=this._lineCount,t.style.event&&t.style.event.click&&(n._clickHandler=t.style.event.click)}else cc.warnID(4400)},_updateRichText:function(){if(this.enabled){var t=cc.htmlTextParser.parse(this.string);if(!this._needsUpdateTextLayout(t))return this._textArray=t,void this._updateLabelSegmentTextAttributes();this._textArray=t,this._resetState();for(var e,i=!1,n=0;n<this._textArray.length;++n){var r=this._textArray[n],s=r.text;if(""===s){if(r.style&&r.style.newline){this._updateLineInfo();continue}if(r.style&&r.style.isImage&&this.imageAtlas){this._addRichTextImageElement(r);continue}}for(var o=s.split("\n"),a=0;a<o.length;++a){var c=o[a];if(""!==c)if(i=!1,this.maxWidth>0){var h=this._measureText(n,c);this._updateRichTextWithMaxWidth(c,h,n),o.length>1&&a<o.length-1&&this._updateLineInfo()}else e=this._addLabelSegment(c,n).getContentSize(),this._lineOffsetX+=e.width,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX),o.length>1&&a<o.length-1&&this._updateLineInfo();else{if(this._isLastComponentCR(s)&&a==o.length-1)continue;this._updateLineInfo(),i=!0}}}i||this._linesWidth.push(this._lineOffsetX),this.maxWidth>0&&(this._labelWidth=this.maxWidth),this._labelHeight=this._lineCount*this.lineHeight,this.node.setContentSize(this._labelWidth,this._labelHeight),this._sgNode._setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},_getFirstWordLen:function(t,e,i){var n=t.charAt(e);if(cc.TextUtils.isUnicodeCJK(n)||cc.TextUtils.isUnicodeSpace(n))return 1;for(var r=1,s=e+1;s<i&&(n=t.charAt(s),!cc.TextUtils.isUnicodeSpace(n)&&!cc.TextUtils.isUnicodeCJK(n));++s)r++;return r},_updateRichTextPosition:function(){for(var t=0,e=1,i=this._lineCount,n=0;n<this._labelSegments.length;++n){var r=this._labelSegments[n],s=r._lineCount;s>e&&(t=0,e=s);var o=0;switch(this.horizontalAlign){case cc.TextAlignment.LEFT:o=0;break;case cc.TextAlignment.CENTER:o=(this._labelWidth-this._linesWidth[s-1])/2;break;case cc.TextAlignment.RIGHT:o=this._labelWidth-this._linesWidth[s-1]}r.setPositionX(t+o);var a=r.getContentSize(),c=(i-s)*this.lineHeight;r instanceof cc.Scale9Sprite&&(c+=(this.lineHeight-r.getContentSize().height)/2),r.setPositionY(c),s===e&&(t+=a.width)}},_convertLiteralColorValue:function(t){var e=t.toUpperCase();return cc.Color[e]?cc.Color[e]:cc.hexToColor(t)},_applyTextAttribute:function(t){if(!(t instanceof cc.Scale9Sprite)){var e=t._styleIndex;t.setLineHeight(this.lineHeight),t.setVerticalAlign(r.CENTER);var i=null;this._textArray[e]&&(i=this._textArray[e].style),i&&i.color?t.setColor(this._convertLiteralColorValue(i.color)):t.setColor(this.node.color),i&&i.bold?t.enableBold(!0):t.enableBold(!1),i&&i.italic?t.enableItalics(!0):t.enableItalics(!1),i&&i.underline?t.enableUnderline(!0):t.enableUnderline(!1),i&&i.outline?(t.setOutlined(!0),t.setOutlineColor(this._convertLiteralColorValue(i.outline.color)),t.setOutlineWidth(i.outline.width),t.setMargin(i.outline.width)):(t.setOutlined(!1),t.setMargin(0)),i&&i.size?t.setFontSize(i.size):t.setFontSize(this.fontSize),i&&i.event&&i.event.click&&(t._clickHandler=i.event.click)}},onDestroy:function(){this._super();for(var t=0;t<this._labelSegments.length;++t)this._labelSegments[t].removeFromParent(!0),_ccsg.Label.pool.put(this._labelSegments[t]);this._resetState()}});cc.RichText=e.exports=s}),{"../label/CCHtmlTextParser":125,"../label/CCTextUtils":129}],89:[(function(t,e,i){var n=t("../utils/scene-graph-helper"),r=cc.Class({extends:t("./CCComponent"),name:"cc._SGComponent",editor:!1,properties:{_sgNode:{default:null,serializable:!1}},_createSgNode:null,_initSgNode:null,_removeSgNode:n.removeSgNode,_registSizeProvider:function(){if(this.node._sizeProvider){}else this.node._sizeProvider=this._sgNode}});cc._SGComponent=e.exports=r}),{"../utils/scene-graph-helper":229,"./CCComponent":76}],90:[(function(t,e,i){var n=cc.Enum({HORIZONTAL:0,VERTICAL:1}),r=cc.Class({name:"cc.Scrollbar",extends:t("./CCComponent"),editor:!1,properties:{_scrollView:null,_touching:!1,_autoHideRemainingTime:{default:0,serializable:!1},_opacity:255,handle:{default:null,type:cc.Sprite,tooltip:!1,notify:function(){this._onScroll(cc.p(0,0))},animatable:!1},direction:{default:n.HORIZONTAL,type:n,tooltip:!1,notify:function(){this._onScroll(cc.p(0,0))},animatable:!1},enableAutoHide:{default:!0,animatable:!1,tooltip:!1},autoHideTime:{default:1,animatable:!1,tooltip:!1}},statics:{Direction:n},setTargetScrollView:function(t){this._scrollView=t},_convertToScrollViewSpace:function(t){var e=t.convertToWorldSpace(cc.p(0,0));return this._scrollView.node.convertToNodeSpace(e)},_setOpacity:function(t){this.handle&&this.node.setOpacity(t)},_onScroll:function(t){if(this._scrollView){var e=this._scrollView.content;if(e){var i=e.getContentSize(),r=this._scrollView.node.getContentSize(),s=this.node.getContentSize();if(this._conditionalDisableScrollBar(i,r))return;this.enableAutoHide&&(this._autoHideRemainingTime=this.autoHideTime,this._setOpacity(this._opacity));var o=0,a=0,c=0,h=0,l=0;this.direction===n.HORIZONTAL?(o=i.width,a=r.width,l=s.width,c=t.x,h=-this._convertToScrollViewSpace(e).x):this.direction===n.VERTICAL&&(o=i.height,a=r.height,l=s.height,c=t.y,h=-this._convertToScrollViewSpace(e).y);var u=this._calculateLength(o,a,l,c),_=this._calculatePosition(o,a,l,h,c,u);this._updateLength(u),this._updateHanlderPosition(_)}}},_updateHanlderPosition:function(t){if(this.handle){var e=this._fixupHandlerPosition();this.handle.node.setPosition(cc.pAdd(t,e))}},_fixupHandlerPosition:function(){var t=this.node.getContentSize(),e=this.node.getAnchorPoint(),i=this.handle.node.getContentSize(),r=this.handle.node.parent,s=this.node.convertToWorldSpaceAR(cc.p(-t.width*e.x,-t.height*e.y)),o=r.convertToNodeSpaceAR(s);return this.direction===n.HORIZONTAL?o=cc.pAdd(o,cc.p(0,(t.height-i.height)/2)):this.direction===n.VERTICAL&&(o=cc.pAdd(o,cc.p((t.width-i.width)/2,0))),this.handle.node.setPosition(o),o},_onTouchBegan:function(){this.enableAutoHide&&(this._touching=!0)},_conditionalDisableScrollBar:function(t,e){return t.width<=e.width&&this.direction===n.HORIZONTAL||t.height<=e.height&&this.direction===n.VERTICAL},_onTouchEnded:function(){if(this.enableAutoHide&&(this._touching=!1,!(this.autoHideTime<=0))){if(this._scrollView){var t=this._scrollView.content;if(t){var e=t.getContentSize(),i=this._scrollView.node.getContentSize();if(this._conditionalDisableScrollBar(e,i))return}}this._autoHideRemainingTime=this.autoHideTime}},_calculateLength:function(t,e,i,n){var r=t;n&&(r+=20*(n>0?n:-n));return i*(e/r)},_calculatePosition:function(t,e,i,r,s,o){var a=t-e;s&&(a+=Math.abs(s));var c=0;a&&(c=r/a,c=cc.clamp01(c));var h=(i-o)*c;return this.direction===n.VERTICAL?cc.p(0,h):cc.p(h,0)},_updateLength:function(t){if(this.handle){var e=this.handle.node,i=e.getContentSize();e.setAnchorPoint(cc.p(0,0)),this.direction===n.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},_processAutoHide:function(t){if(this.enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this.autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this.autoHideTime);this._setOpacity(e)}},start:function(){this.enableAutoHide&&this._setOpacity(0)},hide:function(){this._autoHideRemainingTime=0,this._setOpacity(0)},show:function(){this._autoHideRemainingTime=this.autoHideTime,this._setOpacity(this._opacity)},update:function(t){this._processAutoHide(t)}});cc.Scrollbar=e.exports=r}),{"./CCComponent":76}],91:[(function(t,e,i){var n=function(){return(new Date).getMilliseconds()},r=cc.Enum({SCROLL_TO_TOP:0,SCROLL_TO_BOTTOM:1,SCROLL_TO_LEFT:2,SCROLL_TO_RIGHT:3,SCROLLING:4,BOUNCE_TOP:5,BOUNCE_BOTTOM:6,BOUNCE_LEFT:7,BOUNCE_RIGHT:8,SCROLL_ENDED:9,TOUCH_UP:10,AUTOSCROLL_ENDED_WITH_THRESHOLD:11,SCROLL_BEGAN:12}),s={"scroll-to-top":r.SCROLL_TO_TOP,"scroll-to-bottom":r.SCROLL_TO_BOTTOM,"scroll-to-left":r.SCROLL_TO_LEFT,"scroll-to-right":r.SCROLL_TO_RIGHT,scrolling:r.SCROLLING,"bounce-bottom":r.BOUNCE_BOTTOM,"bounce-left":r.BOUNCE_LEFT,"bounce-right":r.BOUNCE_RIGHT,"bounce-top":r.BOUNCE_TOP,"scroll-ended":r.SCROLL_ENDED,"touch-up":r.TOUCH_UP,"scroll-ended-with-threshold":r.AUTOSCROLL_ENDED_WITH_THRESHOLD,"scroll-began":r.SCROLL_BEGAN},o=cc.Class({name:"cc.ScrollView",extends:t("./CCViewGroup"),editor:!1,ctor:function(){this._topBoundary=0,this._bottomBoundary=0,this._leftBoundary=0,this._rightBoundary=0,this._touchMoveDisplacements=[],this._touchMoveTimeDeltas=[],this._touchMovePreviousTimestamp=0,this._touchMoved=!1,this._autoScrolling=!1,this._autoScrollAttenuate=!1,this._autoScrollStartPosition=cc.p(0,0),this._autoScrollTargetDelta=cc.p(0,0),this._autoScrollTotalTime=0,this._autoScrollAccumulatedTime=0,this._autoScrollCurrentlyOutOfBoundary=!1,this._autoScrollBraking=!1,this._autoScrollBrakingStartPosition=cc.p(0,0),this._outOfBoundaryAmount=cc.p(0,0),this._outOfBoundaryAmountDirty=!0,this._stopMouseWheel=!1,this._mouseWheelEventElapsedTime=0,this._isScrollEndedWithThresholdEventFired=!1,this._scrollEventEmitMask=0,this._isBouncing=!1,this._scrolling=!1},properties:{content:{default:void 0,type:cc.Node,tooltip:!1},horizontal:{default:!0,animatable:!1,tooltip:!1},vertical:{default:!0,animatable:!1,tooltip:!1},inertia:{default:!0,tooltip:!1},brake:{default:.5,type:"Float",range:[0,1,.1],tooltip:!1},elastic:{default:!0,animatable:!1,tooltip:!1},bounceDuration:{default:1,range:[0,10],tooltip:!1},horizontalScrollBar:{default:void 0,type:cc.Scrollbar,tooltip:!1,notify:function(){this.horizontalScrollBar&&(this.horizontalScrollBar.setTargetScrollView(this),this._updateScrollBar(0))},animatable:!1},verticalScrollBar:{default:void 0,type:cc.Scrollbar,tooltip:!1,notify:function(){this.verticalScrollBar&&(this.verticalScrollBar.setTargetScrollView(this),this._updateScrollBar(0))},animatable:!1},scrollEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1},cancelInnerEvents:{default:!0,animatable:!1,tooltip:!1}},statics:{EventType:r},scrollToBottom:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},scrollToTop:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToTopLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToTopRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToBottomLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToBottomRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToOffset:function(t,e,i){var n=this.getMaxScrollOffset(),r=cc.p(0,0);0===n.x?r.x=0:r.x=t.x/n.x,0===n.y?r.y=1:r.y=(n.y-t.y)/n.y,this.scrollTo(r,e,i)},getScrollOffset:function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return cc.p(e,t)},getMaxScrollOffset:function(){var t=this.node.getContentSize(),e=this.content.getContentSize(),i=e.width-t.width,n=e.height-t.height;return i=i>=0?i:0,n=n>=0?n:0,cc.p(i,n)},scrollToPercentHorizontal:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.p(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},scrollTo:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:t,applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},scrollToPercentVertical:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.p(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},stopAutoScroll:function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},setContentPosition:function(t){cc.pFuzzyEqual(t,this.getContentPosition(),1e-4)||(this.content.setPosition(t),this._outOfBoundaryAmountDirty=!0)},getContentPosition:function(){return this.content.getPosition()},isScrolling:function(){return this._scrolling},isAutoScrolling:function(){return this._autoScrolling},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(cc.Node.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},_unregisterEvent:function(){this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(cc.Node.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},_onMouseWheel:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=cc.p(0,0),n=-.1;0,this.vertical?i=cc.p(0,t.getScrollY()*n):this.horizontal&&(i=cc.p(t.getScrollY()*n,0)),this._mouseWheelEventElapsedTime=0,this._processDeltaMove(i),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60),this._stopMouseWheel=!0),this._stopPropagationIfTargetIsMe(t)}},_checkMouseWheel:function(t){var e=this._getHowMuchOutOfBoundary();if(!cc.pFuzzyEqual(e,cc.p(0,0),1e-4))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._stopMouseWheel=!1)},_calculateMovePercentDelta:function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical;this._calculateBoundary(),e=cc.pClamp(e,cc.p(0,0),cc.p(1,1));var r=this.node.getContentSize(),s=this.content.getContentSize(),o=this._getContentBottomBoundary()-this._bottomBoundary;o=-o;var a=this._getContentLeftBoundary()-this._leftBoundary;a=-a;var c=cc.p(0,0),h=0;return i&&(h=s.width-r.width,c.x=a-h*e.x),n&&(h=s.height-r.height,c.y=o-h*e.y),c},_moveContentToTopLeft:function(t){var e=this.content.getContentSize(),i=this._getContentBottomBoundary()-this._bottomBoundary;i=-i;var n=cc.p(0,0),r=0,s=this._getContentLeftBoundary()-this._leftBoundary;s=-s,e.height<t.height?(r=e.height-t.height,n.y=i-r,this.verticalScrollBar&&this.verticalScrollBar.hide()):this.verticalScrollBar&&this.verticalScrollBar.show(),e.width<t.width?(r=e.width-t.width,n.x=s,this.horizontalScrollBar&&this.horizontalScrollBar.hide()):this.horizontalScrollBar&&this.horizontalScrollBar.show(),this._moveContent(n),this._adjustContentOutOfBoundary()},_calculateBoundary:function(){if(this.content){var t=this.content.getComponent(cc.Layout);t&&t.enabledInHierarchy&&t.updateLayout();var e=this.node.getContentSize(),i=this._convertToContentParentSpace(cc.p(0,0));this._leftBoundary=i.x,this._bottomBoundary=i.y;var n=this._convertToContentParentSpace(cc.p(e.width,e.height));this._rightBoundary=n.x,this._topBoundary=n.y,this._moveContentToTopLeft(e)}},_convertToContentParentSpace:function(t){var e=this.node.convertToWorldSpace(t);return this.content.parent.convertToNodeSpaceAR(e)},_hasNestedViewGroup:function(t,e){if(t.eventPhase===cc.Event.CAPTURING_PHASE){if(e)for(var i=0;i<e.length;++i){var n=e[i];if(this.node===n)return!!t.target.getComponent(cc.ViewGroup);if(n.getComponent(cc.ViewGroup))return!0}return!1}},_stopPropagationIfTargetIsMe:function(t){t.eventPhase===cc.Event.AT_TARGET&&t.target===this.node&&t.stopPropagation()},_onTouchBegan:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=t.touch;this.content&&this._handlePressLogic(i),this._touchMoved=!1,this._stopPropagationIfTargetIsMe(t)}},_onTouchMoved:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=t.touch;if(this.content&&this._handleMoveLogic(i),this.cancelInnerEvents){var n=cc.pSub(i.getLocation(),i.getStartLocation());if(cc.pLength(n)>7&&!this._touchMoved&&t.target!==this.node){var r=new cc.Event.EventTouch(t.getTouches(),t.bubbles);r.type=cc.Node.EventType.TOUCH_CANCEL,r.touch=t.touch,r.simulate=!0,t.target.dispatchEvent(r),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},_onTouchEnded:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent("touch-up");var i=t.touch;this.content&&this._handleReleaseLogic(i),this._touchMoved?t.stopPropagation():this._stopPropagationIfTargetIsMe(t)}},_onTouchCancelled:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){if(!t.simulate){var i=t.touch;this.content&&this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},_processDeltaMove:function(t){this._scrollChildren(t),this._gatherTouchMove(t)},_handleMoveLogic:function(t){var e=t.getDelta();this._processDeltaMove(e)},_scrollChildren:function(t){var e,i=t=this._clampDelta(t);this.elastic&&(e=this._getHowMuchOutOfBoundary(),i.x*=0===e.x?1:.5,i.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(i),i=cc.pAdd(i,e));var n=-1;if(i.y>0){this.content.y-this.content.anchorY*this.content.height+i.y>this._bottomBoundary&&(n="scroll-to-bottom")}else if(i.y<0){this.content.y-this.content.anchorY*this.content.height+this.content.height+i.y<=this._topBoundary&&(n="scroll-to-top")}else if(i.x<0){this.content.x-this.content.anchorX*this.content.width+this.content.width+i.x<=this._rightBoundary&&(n="scroll-to-right")}else if(i.x>0){this.content.x-this.content.anchorX*this.content.width+i.x>=this._leftBoundary&&(n="scroll-to-left")}this._moveContent(i,!1),0===i.x&&0===i.y||(this._scrolling||(this._scrolling=!0,this._dispatchEvent("scroll-began")),this._dispatchEvent("scrolling")),-1!==n&&this._dispatchEvent(n)},_handlePressLogic:function(){this._autoScrolling&&this._dispatchEvent("scroll-ended"),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=n(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},_clampDelta:function(t){var e=this.content.getContentSize(),i=this.node.getContentSize();return e.width<i.width&&(t.x=0),e.height<i.height&&(t.y=0),t},_gatherTouchMove:function(t){for(t=this._clampDelta(t);this._touchMoveDisplacements.length>=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(t);var e=n();this._touchMoveTimeDeltas.push((e-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=e},_startBounceBackIfNeeded:function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(t=this._clampDelta(t),cc.pFuzzyEqual(t,cc.p(0,0),1e-4))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent("bounce-top"),t.y<0&&this._dispatchEvent("bounce-bottom"),t.x>0&&this._dispatchEvent("bounce-right"),t.x<0&&this._dispatchEvent("bounce-left"),this._isBouncing=!0),!0},_processInertiaScroll:function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!cc.pFuzzyEqual(t,cc.p(0,0),1e-4)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},_handleReleaseLogic:function(t){var e=t.getDelta();this._gatherTouchMove(e),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent("scroll-ended"))},_isOutOfBoundary:function(){var t=this._getHowMuchOutOfBoundary();return!cc.pFuzzyEqual(t,cc.p(0,0),1e-4)},_isNecessaryAutoScrollBrake:function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,this._autoScrollBrakingStartPosition=this.getContentPosition(),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},getScrollEndedEventTiming:function(){return 1e-4},_processAutoScrolling:function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var n=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=(function(t){return(t-=1)*t*t*t*t+1})(n));var r=cc.pAdd(this._autoScrollStartPosition,cc.pMult(this._autoScrollTargetDelta,n)),s=Math.abs(n-1)<=1e-4;if(Math.abs(n-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent("scroll-ended-with-threshold"),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var o=cc.pSub(r,this._autoScrollBrakingStartPosition);e&&(o=cc.pMult(o,i)),r=cc.pAdd(this._autoScrollBrakingStartPosition,o)}else{var a=cc.pSub(r,this.getContentPosition()),c=this._getHowMuchOutOfBoundary(a);cc.pFuzzyEqual(c,cc.p(0,0),1e-4)||(r=cc.pAdd(r,c),s=!0)}s&&(this._autoScrolling=!1);var h=cc.pSub(r,this.getContentPosition());this._moveContent(h,s),this._dispatchEvent("scrolling"),this._autoScrolling||(this._isBouncing=!1,this._dispatchEvent("scroll-ended"))},_startInertiaScroll:function(t){var e=cc.pMult(t,.7);this._startAttenuatingAutoScroll(e,t)},_calculateAttenuatedFactor:function(t){if(this.brake<=0)return 1-this.brake;return(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},_startAttenuatingAutoScroll:function(t,e){var i=this._calculateAutoScrollTimeByInitalSpeed(cc.pLength(e)),n=cc.pNormalize(t),r=this.content.getContentSize(),s=this.node.getContentSize(),o=r.width-s.width,a=r.height-s.height,c=this._calculateAttenuatedFactor(o),h=this._calculateAttenuatedFactor(a);n=cc.p(n.x*o*(1-this.brake)*c,n.y*a*h*(1-this.brake));var l=cc.pLength(t),u=cc.pLength(n)/l;n=cc.pAdd(n,t),this.brake>0&&u>7&&(u=Math.sqrt(u),n=cc.pAdd(cc.pMult(t,u),t)),this.brake>0&&u>3&&(i*=u=3),0===this.brake&&u>1&&(i*=u),this._startAutoScroll(n,i,!0)},_calculateAutoScrollTimeByInitalSpeed:function(t){return Math.sqrt(Math.sqrt(t/5))},_startAutoScroll:function(t,e,i){var n=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=n,this._autoScrollAttenuate=i,this._autoScrollStartPosition=this.getContentPosition(),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition=cc.p(0,0);var r=this._getHowMuchOutOfBoundary();if(!cc.pFuzzyEqual(r,cc.p(0,0),1e-4)){this._autoScrollCurrentlyOutOfBoundary=!0;var s=this._getHowMuchOutOfBoundary(n);(r.x*s.x>0||r.y*s.y>0)&&(this._autoScrollBraking=!0)}},_calculateTouchMoveVelocity:function(){var t=0;if((t=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),t))<=0||t>=.5)return cc.p(0,0);var e=cc.p(0,0);return e=this._touchMoveDisplacements.reduce((function(t,e){return cc.pAdd(t,e)}),e),cc.p(e.x*(1-this.brake)/t,e.y*(1-this.brake)/t)},_flattenVectorByDirection:function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},_moveContent:function(t,e){var i=this._flattenVectorByDirection(t),n=cc.pAdd(this.getContentPosition(),i);this.setContentPosition(n);var r=this._getHowMuchOutOfBoundary();this._updateScrollBar(r),this.elastic&&e&&this._startBounceBackIfNeeded()},_getContentLeftBoundary:function(){return this.getContentPosition().x-this.content.getAnchorPoint().x*this.content.getContentSize().width},_getContentRightBoundary:function(){var t=this.content.getContentSize();return this._getContentLeftBoundary()+t.width},_getContentTopBoundary:function(){var t=this.content.getContentSize();return this._getContentBottomBoundary()+t.height},_getContentBottomBoundary:function(){return this.getContentPosition().y-this.content.getAnchorPoint().y*this.content.getContentSize().height},_getHowMuchOutOfBoundary:function(t){if(t=t||cc.p(0,0),cc.pFuzzyEqual(t,cc.p(0,0),1e-4)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=cc.p(0,0);return this._getContentLeftBoundary()+t.x>this._leftBoundary?e.x=this._leftBoundary-(this._getContentLeftBoundary()+t.x):this._getContentRightBoundary()+t.x<this._rightBoundary&&(e.x=this._rightBoundary-(this._getContentRightBoundary()+t.x)),this._getContentTopBoundary()+t.y<this._topBoundary?e.y=this._topBoundary-(this._getContentTopBoundary()+t.y):this._getContentBottomBoundary()+t.y>this._bottomBoundary&&(e.y=this._bottomBoundary-(this._getContentBottomBoundary()+t.y)),cc.pFuzzyEqual(t,cc.p(0,0),1e-4)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),e=this._clampDelta(e)},_updateScrollBar:function(t){this.horizontalScrollBar&&this.horizontalScrollBar._onScroll(t),this.verticalScrollBar&&this.verticalScrollBar._onScroll(t)},_onScrollBarTouchBegan:function(){this.horizontalScrollBar&&this.horizontalScrollBar._onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar._onTouchBegan()},_onScrollBarTouchEnded:function(){this.horizontalScrollBar&&this.horizontalScrollBar._onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar._onTouchEnded()},_dispatchEvent:function(t){if("scroll-ended"===t)this._scrollEventEmitMask=0;else if("scroll-to-top"===t||"scroll-to-bottom"===t||"scroll-to-left"===t||"scroll-to-right"===t){var e=1<<s[t];if(this._scrollEventEmitMask&e)return;this._scrollEventEmitMask|=e}cc.Component.EventHandler.emitEvents(this.scrollEvents,this,s[t]),this.node.emit(t,this)},_adjustContentOutOfBoundary:function(){if(this._outOfBoundaryAmountDirty=!0,this._isOutOfBoundary()){var t=this._getHowMuchOutOfBoundary(cc.p(0,0)),e=cc.pAdd(this.getContentPosition(),t);this.content&&(this.content.setPosition(e),this._updateScrollBar(0))}},start:function(){this._calculateBoundary(),this.content&&cc.director.once(cc.Director.EVENT_AFTER_VISIT,this._adjustContentOutOfBoundary,this)},_hideScrollbar:function(){this.horizontalScrollBar&&this.horizontalScrollBar.hide(),this.verticalScrollBar&&this.verticalScrollBar.hide()},_showScrollbar:function(){this.horizontalScrollBar&&this.horizontalScrollBar.show(),this.verticalScrollBar&&this.verticalScrollBar.show()},onDisable:function(){this._unregisterEvent(),this.node.off("size-changed",this._calculateBoundary,this),this.node.off("scale-changed",this._calculateBoundary,this),this.content&&(this.content.off("size-changed",this._calculateBoundary,this),this.content.off("scale-changed",this._calculateBoundary,this)),this._hideScrollbar(),this.stopAutoScroll()},onEnable:function(){this._registerEvent(),this.node.on("size-changed",this._calculateBoundary,this),this.node.on("scale-changed",this._calculateBoundary,this),this.content&&(this.content.on("size-changed",this._calculateBoundary,this),this.content.on("scale-changed",this._calculateBoundary,this)),this._showScrollbar()},update:function(t){this._autoScrolling&&this._processAutoScrolling(t)}});cc.ScrollView=e.exports=o}),{"./CCViewGroup":100}],92:[(function(t,e,i){var n=cc.Enum({Horizontal:0,Vertical:1}),r=cc.Class({name:"cc.Slider",extends:t("./CCComponent"),editor:!1,ctor:function(){this._dragging=!1},properties:{handle:{default:null,type:cc.Button,tooltip:!1,notify:function(){0}},direction:{default:n.Horizontal,type:n,tooltip:!1},progress:{default:.5,type:cc.Float,range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){this._updateHandlePosition()}},slideEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1}},statics:{Direction:n},__preload:function(){this._updateHandlePosition()},onEnable:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this),this.handle&&this.handle.isValid&&(this.handle.node.on(cc.Node.EventType.TOUCH_START,this._onHandleDragStart,this),this.handle.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this),this.handle.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this))},onDisable:function(){this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this),this.handle&&this.handle.isValid&&(this.handle.node.off(cc.Node.EventType.TOUCH_START,this._onHandleDragStart,this),this.handle.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this),this.handle.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this))},_onHandleDragStart:function(t){this._dragging=!0,t.stopPropagation()},_onTouchBegan:function(t){this.handle&&(this._dragging=!0,this._handleSliderLogic(t.touch),t.stopPropagation())},_onTouchMoved:function(t){this._dragging&&(this._handleSliderLogic(t.touch),t.stopPropagation())},_onTouchEnded:function(t){this._dragging=!1,t.stopPropagation()},_onTouchCancelled:function(t){this._dragging=!1,t.stopPropagation()},_handleSliderLogic:function(t){this._updateProgress(t),this._emitSlideEvent()},_emitSlideEvent:function(){cc.Component.EventHandler.emitEvents(this.slideEvents,this),this.node.emit("slide",this)},_updateProgress:function(t){if(this.handle){var e=null,i=0,r=this.node.convertTouchToNodeSpaceAR(t);this.direction===n.Horizontal?(e=this.node.width/2-this.handle.node.width*this.handle.node.anchorX,i=cc.clamp01((r.x+e)/(2*e),0,1)):this.direction===n.Vertical&&(e=this.node.height/2-this.handle.node.height*this.handle.node.anchorY,i=cc.clamp01((r.y+e)/(2*e),0,1)),this.progress=i}},_updateHandlePosition:function(){if(this.handle){var t;t=this.direction===n.Horizontal?cc.p(-this.node.width*this.node.anchorX+this.progress*this.node.width,0):cc.p(0,-this.node.height*this.node.anchorY+this.progress*this.node.height);var e=this.node.convertToWorldSpaceAR(t);this.handle.node.position=this.handle.node.parent.convertToNodeSpaceAR(e)}}});cc.Slider=e.exports=r}),{"./CCComponent":76}],93:[(function(t,e,i){var n=t("./CCRendererUnderSG"),r=cc.Scale9Sprite.RenderingType,s=cc.Scale9Sprite.FillType,o=cc.BlendFunc.BlendFactor,a=cc.Enum({CUSTOM:0,TRIMMED:1,RAW:2}),c=cc.Class({name:"cc.Sprite",extends:n,editor:!1,ctor:function(){this._blendFunc=new cc.BlendFunc(this._srcBlendFactor,this._dstBlendFactor)},properties:{_spriteFrame:{default:null,type:cc.SpriteFrame},_type:r.SIMPLE,_sizeMode:a.TRIMMED,_fillType:0,_fillCenter:cc.v2(0,0),_fillStart:0,_fillRange:0,_isTrimmedMode:!0,_srcBlendFactor:o.SRC_ALPHA,_dstBlendFactor:o.ONE_MINUS_SRC_ALPHA,_atlas:{default:null,type:cc.SpriteAtlas,tooltip:!1,editorOnly:!0,visible:!0,animatable:!1},spriteFrame:{get:function(){return this._spriteFrame},set:function(t,e){var i=this._spriteFrame;i!==t&&(this._spriteFrame=t,this._applySpriteFrame(i))},type:cc.SpriteFrame},type:{get:function(){return this._type},set:function(t){this._type=t,this._sgNode.setRenderingType(t)},type:r,animatable:!1,tooltip:!1},fillType:{get:function(){return this._fillType},set:function(t){this._fillType=t,this._sgNode&&this._sgNode.setFillType(t)},type:s,tooltip:!1},fillCenter:{get:function(){return this._fillCenter},set:function(t){this._fillCenter=cc.v2(t),this._sgNode&&this._sgNode.setFillCenter(this._fillCenter)},tooltip:!1},fillStart:{get:function(){return this._fillStart},set:function(t){this._fillStart=cc.clampf(t,-1,1),this._sgNode&&this._sgNode.setFillStart(t)},tooltip:!1},fillRange:{get:function(){return this._fillRange},set:function(t){this._fillRange=cc.clampf(t,-1,1),this._sgNode&&this._sgNode.setFillRange(t)},tooltip:!1},trim:{get:function(){return this._isTrimmedMode},set:function(t){this._isTrimmedMode!==t&&(this._isTrimmedMode=t,this._sgNode.enableTrimmedContentSize(t))},animatable:!1,tooltip:!1},srcBlendFactor:{get:function(){return this._srcBlendFactor},set:function(t){this._srcBlendFactor=t,this._blendFunc.src=t,this._sgNode.setBlendFunc(this._blendFunc)},animatable:!1,type:o,tooltip:!1},dstBlendFactor:{get:function(){return this._dstBlendFactor},set:function(t){this._dstBlendFactor=t,this._blendFunc.dst=t,this._sgNode.setBlendFunc(this._blendFunc)},animatable:!1,type:o,tooltip:!1},sizeMode:{get:function(){return this._sizeMode},set:function(t){this._sizeMode=t,t!==a.CUSTOM&&this._applySpriteSize()},animatable:!1,type:a,tooltip:!1}},statics:{FillType:s,Type:r,SizeMode:a},setVisible:function(t){this.enabled=t},setInsetLeft:function(t){this._sgNode.setInsetLeft(t)},getInsetLeft:function(){return this._sgNode.getInsetLeft()},setInsetTop:function(t){this._sgNode.setInsetTop(t)},getInsetTop:function(){return this._sgNode.getInsetTop()},setInsetRight:function(t){this._sgNode.setInsetRight(t)},getInsetRight:function(){return this._sgNode.getInsetRight()},setInsetBottom:function(t){this._sgNode.setInsetBottom(t)},getInsetBottom:function(){return this._sgNode.getInsetBottom()},onEnable:function(){this._sgNode&&this._spriteFrame&&this._spriteFrame.textureLoaded()&&this._sgNode.setVisible(!0)},_applyAtlas:!1,_applySpriteFrameInsets:function(){var t=this._spriteFrame,e=this._sgNode;e.setInsetTop(t.insetTop),e.setInsetBottom(t.insetBottom),e.setInsetRight(t.insetRight),e.setInsetLeft(t.insetLeft)},_applySpriteSize:function(){if(this._spriteFrame)if(a.RAW===this._sizeMode){var t=this._spriteFrame.getOriginalSize();this.node.setContentSize(t)}else if(a.TRIMMED===this._sizeMode){var e=this._spriteFrame.getRect();this.node.setContentSize(e.width,e.height)}},_onTextureLoaded:function(t){if(this.isValid){var e=this._sgNode;e.setSpriteFrame(this._spriteFrame),this._applySpriteSize(),this.enabledInHierarchy&&!e.isVisible()&&e.setVisible(!0)}},_applySpriteFrame:function(t,e){var i=this._sgNode;t&&t.off&&t.off("load",this._onTextureLoaded,this);var n=this._spriteFrame;n?(e||this._applySpriteFrameInsets(),n.textureLoaded()?this._onTextureLoaded(null):(n.once("load",this._onTextureLoaded,this),n.ensureLoadTexture())):i.setVisible(!1)},_createSgNode:function(){return new cc.Scale9Sprite},_initSgNode:function(){var t=this._sgNode,e=0!==t.getInsetLeft()||0!==t.getInsetRight()||0!==t.getInsetTop()||0!==t.getInsetBottom();this._applySpriteFrame(null,e),t.setContentSize(this.node.getContentSize(!0)),this._applySpriteSize(),t.setRenderingType(this._type),t.setFillType(this._fillType),t.setFillCenter(this._fillCenter),t.setFillStart(this._fillStart),t.setFillRange(this._fillRange),t.enableTrimmedContentSize(this._isTrimmedMode),this._blendFunc.src=this._srcBlendFactor,this._blendFunc.dst=this._dstBlendFactor,t.setBlendFunc(this._blendFunc)},_resized:!1});t("../utils/misc").propertyDefine(c,["insetLeft","insetTop","insetRight","insetBottom"],{type:[null,"setRenderingType"]}),cc.Sprite=e.exports=c}),{"../utils/misc":226,"./CCRendererUnderSG":87}],94:[(function(t,e,i){var n=cc.Class({name:"cc.SpriteDistortion",extends:t("./CCComponent"),editor:!1,ctor:function(){this._spriteSGNode=null},properties:{_distortionOffset:cc.v2(0,0),offset:{get:function(){return this._distortionOffset},set:function(t){this._distortionOffset.x=t.x,this._distortionOffset.y=t.y,this._spriteSGNode&&this._spriteSGNode.setDistortionOffset(this._distortionOffset)}},_distortionTiling:cc.v2(1,1),tiling:{get:function(){return this._distortionTiling},set:function(t){this._distortionTiling.x=t.x,this._distortionTiling.y=t.y,this._spriteSGNode&&this._spriteSGNode.setDistortionTiling(this._distortionTiling)}}},onEnable:function(){var t=this.node.getComponent("cc.Sprite"),e=this._spriteSGNode=t&&t._sgNode;this._spriteSGNode&&(e.setState(cc.Scale9Sprite.state.DISTORTION),e.setDistortionOffset(this._distortionOffset),e.setDistortionTiling(this._distortionTiling))},onDisable:function(){this._spriteSGNode&&this._spriteSGNode.setState(cc.Scale9Sprite.state.NORMAL),this._spriteSGNode=null}});cc.SpriteDistortion=e.exports=n}),{"./CCComponent":76}],95:[(function(t,e,i){var n=cc.Enum({NONE:0,CHECKBOX:1,TEXT_ATLAS:2,SLIDER_BAR:3,LIST_VIEW:4,PAGE_VIEW:5}),r=cc.Enum({VERTICAL:0,HORIZONTAL:1}),s=cc.Enum({TOP:0,CENTER:1,BOTTOM:2}),o=cc.Enum({LEFT:0,CENTER:1,RIGHT:2}),a=cc.Class({name:"cc.StudioComponent",extends:cc.Component,editor:!1,properties:!1,statics:{ComponentType:n,ListDirection:r,VerticalAlign:s,HorizontalAlign:o}}),c=t("../utils/prefab-helper");a.PlaceHolder=cc.Class({name:"cc.StudioComponent.PlaceHolder",extends:cc.Component,properties:{_baseUrl:"",nestedPrefab:cc.Prefab},onLoad:function(){this.nestedPrefab&&this._replaceWithNestedPrefab()},_replaceWithNestedPrefab:function(){var t=this.node,e=t._prefab;e.root=t,e.asset=this.nestedPrefab,c.syncWithPrefab(t)}}),cc.StudioComponent=e.exports=a}),{"../utils/prefab-helper":228}],96:[(function(t,e,i){var n=cc.Class({name:"cc.Toggle",extends:t("./CCButton"),editor:!1,properties:{isChecked:{default:!0,tooltip:!1,notify:function(){this._updateCheckMark()}},toggleGroup:{default:null,tooltip:!1,type:t("./CCToggleGroup")},checkMark:{default:null,type:cc.Sprite,tooltip:!1},checkEvents:{default:[],type:cc.Component.EventHandler},_resizeToTarget:{animatable:!1,set:function(t){t&&this._resizeNodeToTargetNode()}}},onEnable:function(){this._super(),this._registerToggleEvent(),this.toggleGroup&&this.toggleGroup.enabled&&this.toggleGroup.addToggle(this)},onDisable:function(){this._super(),this._unregisterToggleEvent(),this.toggleGroup&&this.toggleGroup.enabled&&this.toggleGroup.removeToggle(this)},_updateCheckMark:function(){this.checkMark&&(this.checkMark.node.active=!!this.isChecked)},_updateDisabledState:function(){this._super(),this.checkMark&&this.checkMark._sgNode.setState(0),this.enableAutoGrayEffect&&this.checkMark&&!this.interactable&&this.checkMark._sgNode.setState(1)},_registerToggleEvent:function(){this.node.on("click",this.toggle,this)},_unregisterToggleEvent:function(){this.node.off("click",this.toggle,this)},toggle:function(t){var e=this.toggleGroup||this._toggleContainer;e&&e.enabled&&this.isChecked&&!e.allowSwitchOff||(this.isChecked=!this.isChecked,this._updateCheckMark(),e&&e.enabled&&e.updateToggles(this),this._emitToggleEvents(t))},_emitToggleEvents:function(){this.node.emit("toggle",this),this.checkEvents&&cc.Component.EventHandler.emitEvents(this.checkEvents,this)},check:function(){var t=this.toggleGroup||this._toggleContainer;t&&t.enabled&&this.isChecked&&!t.allowSwitchOff||(this.isChecked=!0,t&&t.enabled&&t.updateToggles(this),this._emitToggleEvents())},uncheck:function(){var t=this.toggleGroup||this._toggleContainer;t&&t.enabled&&this.isChecked&&!t.allowSwitchOff||(this.isChecked=!1,this._emitToggleEvents())}});cc.Toggle=e.exports=n;t("../platform/js").get(n.prototype,"_toggleContainer",(function(){var t=this.node.parent;return cc.Node.isNode(t)?t.getComponent(cc.ToggleContainer):null}))}),{"../platform/js":197,"./CCButton":74,"./CCToggleGroup":98}],97:[(function(t,e,i){var n=cc.Class({name:"cc.ToggleContainer",extends:cc.Component,editor:!1,properties:{allowSwitchOff:{tooltip:!1,default:!1}},updateToggles:function(t){this.toggleItems.forEach((function(e){t.isChecked&&e!==t&&(e.isChecked=!1)}))},_allowOnlyOneToggleChecked:function(){var t=!1;return this.toggleItems.forEach((function(e){t?e.isChecked=!1:e.isChecked&&(t=!0)})),t},_makeAtLeastOneToggleChecked:function(){if(!this._allowOnlyOneToggleChecked()&&!this.allowSwitchOff){var t=this.toggleItems;t.length>0&&t[0].check()}},onEnable:function(){this.node.on("child-added",this._allowOnlyOneToggleChecked,this),this.node.on("child-removed",this._makeAtLeastOneToggleChecked,this)},onDisable:function(){this.node.off("child-added",this._allowOnlyOneToggleChecked,this),this.node.off("child-removed",this._makeAtLeastOneToggleChecked,this)},start:function(){this._makeAtLeastOneToggleChecked()}});t("../platform/js").get(n.prototype,"toggleItems",(function(){return this.node.getComponentsInChildren(cc.Toggle)})),cc.ToggleContainer=e.exports=n}),{"../platform/js":197}],98:[(function(t,e,i){var n=cc.Class({name:"cc.ToggleGroup",extends:cc.Component,ctor:function(){this._toggleItems=[]},editor:!1,properties:{allowSwitchOff:{tooltip:!1,default:!1},toggleItems:{get:function(){return this._toggleItems}}},updateToggles:function(t){this.enabledInHierarchy&&this._toggleItems.forEach((function(e){t.isChecked&&e!==t&&e.isChecked&&e.enabled&&(e.isChecked=!1)}))},addToggle:function(t){-1===this._toggleItems.indexOf(t)&&this._toggleItems.push(t),this._allowOnlyOneToggleChecked()},removeToggle:function(t){var e=this._toggleItems.indexOf(t);e>-1&&this._toggleItems.splice(e,1),this._makeAtLeastOneToggleChecked()},_allowOnlyOneToggleChecked:function(){var t=!1;return this._toggleItems.forEach((function(e){t&&e.enabled&&(e.isChecked=!1),e.isChecked&&e.enabled&&(t=!0)})),t},_makeAtLeastOneToggleChecked:function(){this._allowOnlyOneToggleChecked()||this.allowSwitchOff||this._toggleItems.length>0&&(this._toggleItems[0].isChecked=!0)},start:function(){this._makeAtLeastOneToggleChecked()}}),r=(t("../platform/js"),!1);cc.js.get(cc,"ToggleGroup",(function(){return r||(cc.logID(1405,"cc.ToggleGroup","cc.ToggleContainer"),r=!0),n})),cc.ToggleGroup=e.exports=n}),{"../platform/js":197}],99:[(function(t,e,i){t("../videoplayer/CCSGVideoPlayer");var n=_ccsg.VideoPlayer.EventType,r=cc.Enum({REMOTE:0,LOCAL:1}),s=cc.Class({name:"cc.VideoPlayer",extends:cc._RendererUnderSG,editor:!1,properties:{_resourceType:r.REMOTE,resourceType:{tooltip:!1,type:r,set:function(t){this._resourceType=t,this._updateVideoSource()},get:function(){return this._resourceType}},_remoteURL:"",remoteURL:{tooltip:!1,type:cc.String,set:function(t){this._remoteURL=t,this._updateVideoSource()},get:function(){return this._remoteURL}},_clip:{default:null,url:cc.RawAsset},clip:{tooltip:!1,get:function(){return this._clip},set:function(t){"string"!=typeof t&&(t=""),this._clip=t,this._updateVideoSource()},url:cc.RawAsset},currentTime:{tooltip:!1,type:cc.Float,set:function(t){this._sgNode&&this._sgNode.seekTo(t)},get:function(){return this._sgNode?this._sgNode.currentTime():-1}},keepAspectRatio:{tooltip:!1,default:!0,type:cc.Boolean,notify:function(){this._sgNode.setKeepAspectRatioEnabled(this.keepAspectRatio)}},isFullscreen:{tooltip:!1,default:!1,type:cc.Boolean,notify:function(){this._sgNode.setFullScreenEnabled(this.isFullscreen)}},videoPlayerEvent:{default:[],type:cc.Component.EventHandler}},statics:{EventType:n,ResourceType:r},onLoad:function(){0},_createSgNode:function(){return new _ccsg.VideoPlayer},_updateVideoSource:function(){var t=this._sgNode;this.resourceType===r.REMOTE?t.setURL(this.remoteURL):t.setURL(this._clip||"")},_initSgNode:function(){var t=this._sgNode;t&&(t.createDomElementIfNeeded(),this._updateVideoSource(),t.seekTo(this.currentTime),t.setKeepAspectRatioEnabled(this.keepAspectRatio),t.setFullScreenEnabled(this.isFullscreen),t.setContentSize(this.node.getContentSize()),this.pause(),t.setEventListener(n.PLAYING,this.onPlaying.bind(this)),t.setEventListener(n.PAUSED,this.onPasued.bind(this)),t.setEventListener(n.STOPPED,this.onStopped.bind(this)),t.setEventListener(n.COMPLETED,this.onCompleted.bind(this)),t.setEventListener(n.META_LOADED,this.onMetaLoaded.bind(this)),t.setEventListener(n.CLICKED,this.onClicked.bind(this)),t.setEventListener(n.READY_TO_PLAY,this.onReadyToPlay.bind(this)))},onReadyToPlay:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.READY_TO_PLAY),this.node.emit("ready-to-play",this)},onMetaLoaded:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.META_LOADED),this.node.emit("meta-loaded",this)},onClicked:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.CLICKED),this.node.emit("clicked",this)},onPlaying:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.PLAYING),this.node.emit("playing",this)},onPasued:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.PAUSED),this.node.emit("paused",this)},onStopped:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.STOPPED),this.node.emit("stopped",this)},onCompleted:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.COMPLETED),this.node.emit("completed",this)},play:function(){this._sgNode&&this._sgNode.play()},resume:function(){this._sgNode&&this._sgNode.resume()},pause:function(){this._sgNode&&this._sgNode.pause()},stop:function(){this._sgNode&&this._sgNode.stop()},getDuration:function(){return this._sgNode?this._sgNode.duration():-1},isPlaying:function(){return!!this._sgNode&&this._sgNode.isPlaying()}});cc.VideoPlayer=e.exports=s}),{"../videoplayer/CCSGVideoPlayer":240}],100:[(function(t,e,i){var n=cc.Class({name:"cc.ViewGroup",extends:t("./CCComponent")});cc.ViewGroup=e.exports=n}),{"./CCComponent":76}],101:[(function(t,e,i){function n(){}t("../webview/CCSGWebView");var r=_ccsg.WebView.EventType,s=cc.Class({name:"cc.WebView",extends:cc._RendererUnderSG,editor:!1,properties:{_useOriginalSize:!0,_url:"",url:{type:String,tooltip:!1,get:function(){return this._url},set:function(t){this._url=t;var e=this._sgNode;e&&e.loadURL(t)}},webviewEvents:{default:[],type:cc.Component.EventHandler}},statics:{EventType:r},onLoad:!1,_createSgNode:function(){return new _ccsg.WebView},_initSgNode:function(){var t=this._sgNode;t&&(t.createDomElementIfNeeded(),t.loadURL(this._url),t.setContentSize(this.node.getContentSize()))},onEnable:function(){this._super();var t=this._sgNode;t.setEventListener(r.LOADED,this._onWebViewLoaded.bind(this)),t.setEventListener(r.LOADING,this._onWebViewLoading.bind(this)),t.setEventListener(r.ERROR,this._onWebViewLoadError.bind(this))},onDisable:function(){this._super();var t=this._sgNode;t.setEventListener(r.LOADED,n),t.setEventListener(r.LOADING,n),t.setEventListener(r.ERROR,n)},_onWebViewLoaded:function(){cc.Component.EventHandler.emitEvents(this.webviewEvents,this,r.LOADED),this.node.emit("loaded",this)},_onWebViewLoading:function(){return cc.Component.EventHandler.emitEvents(this.webviewEvents,this,r.LOADING),this.node.emit("loading",this),!0},_onWebViewLoadError:function(){cc.Component.EventHandler.emitEvents(this.webviewEvents,this,r.ERROR),this.node.emit("error",this)},setJavascriptInterfaceScheme:function(t){this._sgNode&&this._sgNode.setJavascriptInterfaceScheme(t)},setOnJSCallback:function(t){this._sgNode&&this._sgNode.setOnJSCallback(t)},evaluateJS:function(t){this._sgNode&&this._sgNode.evaluateJS(t)}});cc.WebView=e.exports=s}),{"../webview/CCSGWebView":241}],102:[(function(t,e,i){var n=t("../base-ui/CCWidgetManager"),r=n._AlignFlags,s=r.TOP,o=r.MID,a=r.BOT,c=r.LEFT,h=r.CENTER,l=r.RIGHT,u=s|a,_=c|l,d=cc.Class({name:"cc.Widget",extends:t("./CCComponent"),editor:!1,properties:{target:{get:function(){return this._target},set:function(t){this._target=t},type:cc.Node,tooltip:!1},isAlignTop:{get:function(){return(this._alignFlags&s)>0},set:function(t){this._setAlign(s,t)},animatable:!1,tooltip:!1},isAlignVerticalCenter:{get:function(){return(this._alignFlags&o)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=o):this._alignFlags&=~o},animatable:!1,tooltip:!1},isAlignBottom:{get:function(){return(this._alignFlags&a)>0},set:function(t){this._setAlign(a,t)},animatable:!1,tooltip:!1},isAlignLeft:{get:function(){return(this._alignFlags&c)>0},set:function(t){this._setAlign(c,t)},animatable:!1,tooltip:!1},isAlignHorizontalCenter:{get:function(){return(this._alignFlags&h)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=h):this._alignFlags&=~h},animatable:!1,tooltip:!1},isAlignRight:{get:function(){return(this._alignFlags&l)>0},set:function(t){this._setAlign(l,t)},animatable:!1,tooltip:!1},isStretchWidth:{get:function(){return(this._alignFlags&_)===_},visible:!1},isStretchHeight:{get:function(){return(this._alignFlags&u)===u},visible:!1},top:{get:function(){return this._top},set:function(t){this._top=t},tooltip:!1},bottom:{get:function(){return this._bottom},set:function(t){this._bottom=t},tooltip:!1},left:{get:function(){return this._left},set:function(t){this._left=t},tooltip:!1},right:{get:function(){return this._right},set:function(t){this._right=t},tooltip:!1},horizontalCenter:{get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t},tooltip:!1},verticalCenter:{get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t},tooltip:!1},isAbsoluteHorizontalCenter:{get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter=t},animatable:!1},isAbsoluteVerticalCenter:{get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter=t},animatable:!1},isAbsoluteTop:{get:function(){return this._isAbsTop},set:function(t){this._isAbsTop=t},animatable:!1},isAbsoluteBottom:{get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom=t},animatable:!1},isAbsoluteLeft:{get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft=t},animatable:!1},isAbsoluteRight:{get:function(){return this._isAbsRight},set:function(t){this._isAbsRight=t},animatable:!1},isAlignOnce:{default:!0,tooltip:!1,displayName:"AlignOnce"},_target:null,_alignFlags:0,_left:0,_right:0,_top:0,_bottom:0,_verticalCenter:0,_horizontalCenter:0,_isAbsLeft:!0,_isAbsRight:!0,_isAbsTop:!0,_isAbsBottom:!0,_isAbsHorizontalCenter:!0,_isAbsVerticalCenter:!0,_originalWidth:0,_originalHeight:0},onEnable:function(){n.add(this)},onDisable:function(){n.remove(this)},_setAlign:function(t,e){if(e!=(this._alignFlags&t)>0){var i=(t&_)>0;e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=this.node.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=this.node.height))):(i?this.isStretchWidth&&(this.node.width=this._originalWidth):this.isStretchHeight&&(this.node.height=this._originalHeight),this._alignFlags&=~t)}},updateAlignment:function(){n.updateAlignment(this.node)}});cc.Widget=e.exports=d}),{"../base-ui/CCWidgetManager":59,"./CCComponent":76}],103:[(function(t,e,i){t("./CCComponent"),t("./CCRendererInSG"),t("./CCRendererUnderSG"),t("./CCComponentEventHandler"),t("./missing-script"),e.exports=[t("./CCSprite"),t("./CCWidget"),t("./CCCanvas"),t("./CCAudioSource"),t("./CCAnimation"),t("./CCButton"),t("./CCLabel"),t("./CCProgressBar"),t("./CCMask"),t("./CCScrollBar"),t("./CCScrollView"),t("./CCPageViewIndicator"),t("./CCPageView"),t("./CCSlider"),t("./CCLayout"),t("./CCEditBox"),t("./CCVideoPlayer"),t("./CCWebView"),t("./CCSpriteDistortion"),t("./CCLabelOutline"),t("./CCRichText"),t("./CCToggleContainer"),t("./CCToggleGroup"),t("./CCToggle"),t("./CCBlockInputEvents")]}),{"./CCAnimation":71,"./CCAudioSource":72,"./CCBlockInputEvents":73,"./CCButton":74,"./CCCanvas":75,"./CCComponent":76,"./CCComponentEventHandler":77,"./CCEditBox":78,"./CCLabel":79,"./CCLabelOutline":80,"./CCLayout":81,"./CCMask":82,"./CCPageView":83,"./CCPageViewIndicator":84,"./CCProgressBar":85,"./CCRendererInSG":86,"./CCRendererUnderSG":87,"./CCRichText":88,"./CCScrollBar":90,"./CCScrollView":91,"./CCSlider":92,"./CCSprite":93,"./CCSpriteDistortion":94,"./CCToggle":96,"./CCToggleContainer":97,"./CCToggleGroup":98,"./CCVideoPlayer":99,"./CCWebView":101,"./CCWidget":102,"./missing-script":104}],104:[(function(t,e,i){var n=cc.js,r=t("../utils/misc").BUILTIN_CLASSID_RE,s=cc.Class({name:"cc.MissingClass",properties:{_$erialized:{default:null,visible:!1,editorOnly:!0}}}),o=cc.Class({name:"cc.MissingScript",extends:cc.Component,editor:{inspector:"packages://inspector/inspectors/comps/missing-script.js"},properties:{compiled:{default:!1,serializable:!1},_$erialized:{default:null,visible:!1,editorOnly:!0}},ctor:!1,statics:{safeFindClass:function(t,e){var i=n._getClassById(t);return i||(t?(cc.deserialize.reportMissingClass(t),o.getMissingWrapper(t,e)):null)},getMissingWrapper:function(t,e){return e.node&&(/^[0-9a-zA-Z+/]{23}$/.test(t)||r.test(t))?o:s}},onLoad:function(){cc.warnID(4600,this.node.name)}});cc._MissingScript=e.exports=o}),{"../utils/misc":226}],105:[(function(t,e,i){function n(t){var e=t.convertToWorldSpace(cc.p(0,0)),i=cc.visibleRect.height,n=.5;cc.visibleRect.width>i&&(n=.7),setTimeout((function(){if(window.scrollY<r&&e.y<i*n){var t=i*n-e.y-window.scrollY;t<35&&(t=35),t>320&&(t=320),window.scrollTo(t,t)}}),s)}var r=40,s=400,o=t("../platform/utils"),a=t("../platform/CCSys"),c=cc.Enum({DEFAULT:0,DONE:1,SEND:2,SEARCH:3,GO:4}),h=cc.Enum({ANY:0,EMAIL_ADDR:1,NUMERIC:2,PHONE_NUMBER:3,URL:4,DECIMAL:5,SINGLE_LINE:6}),l=cc.Enum({PASSWORD:0,SENSITIVE:1,INITIAL_CAPS_WORD:2,INITIAL_CAPS_SENTENCE:3,INITIAL_CAPS_ALL_CHARACTERS:4,DEFAULT:5});cc.EditBoxDelegate=cc._Class.extend({editBoxEditingDidBegan:function(t){},editBoxEditingDidEnded:function(t){},editBoxTextChanged:function(t,e){},editBoxEditingReturn:function(t){}}),_ccsg.EditBox=_ccsg.Node.extend({_backgroundSprite:null,_delegate:null,_editBoxInputMode:h.ANY,_editBoxInputFlag:l.DEFAULT,_keyboardReturnType:c.DEFAULT,_maxLength:50,_text:"",_placeholderText:"",_alwaysOnTop:!1,_placeholderFontName:"",_placeholderFontSize:14,__fullscreen:!1,__autoResize:!1,_placeholderColor:null,_className:"EditBox",ctor:function(t,e){_ccsg.Node.prototype.ctor.call(this),this._textColor=cc.Color.WHITE,this._placeholderColor=cc.Color.GRAY,this.initWithSizeAndBackgroundSprite(t,e),this._renderCmd._createLabels()},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.EditBox.CanvasRenderCmd(this):new _ccsg.EditBox.WebGLRenderCmd(this)},setContentSize:function(t,e){void 0!==t.width&&void 0!==t.height&&(e=t.height,t=t.width),_ccsg.Node.prototype.setContentSize.call(this,t,e),this._updateEditBoxSize(t,e)},setVisible:function(t){_ccsg.Node.prototype.setVisible.call(this,t),this._renderCmd.updateVisibility()},createDomElementIfNeeded:function(){this._renderCmd._edTxt||this._renderCmd.setInputMode(this._editBoxInputMode)},setTabIndex:function(t){this._renderCmd._edTxt&&(this._renderCmd._edTxt.tabIndex=t)},getTabIndex:function(){return this._renderCmd._edTxt?this._renderCmd._edTxt.tabIndex:(cc.warnID(4700),-1)},setFocus:function(){this._renderCmd._edTxt&&this._renderCmd._edTxt.focus()},isFocused:function(){return this._renderCmd._edTxt?document.activeElement===this._renderCmd._edTxt:(cc.warnID(4700),!1)},stayOnTop:function(t){this._alwaysOnTop!==t&&(this._alwaysOnTop=t,this._renderCmd.stayOnTop(this._alwaysOnTop))},cleanup:function(){this._super(),this._renderCmd.removeDom()},_onTouchBegan:function(t){var e=t.getLocation(),i=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return!!cc.rectContainsPoint(i,this.convertToNodeSpace(e))||(this._renderCmd._endEditing(),!1)},_onTouchEnded:function(){this._renderCmd._beginEditing()},_updateBackgroundSpriteSize:function(t,e){this._backgroundSprite&&this._backgroundSprite.setContentSize(t,e)},_updateEditBoxSize:function(t,e){var i="number"==typeof t.width?t.width:t,n="number"==typeof t.height?t.height:e;this._updateBackgroundSpriteSize(i,n),this._renderCmd.updateSize(i,n)},setLineHeight:function(t){this._renderCmd.setLineHeight(t)},setFont:function(t,e){this._renderCmd.setFont(t,e)},_setFont:function(t){this._renderCmd._setFont(t)},getBackgroundSprite:function(){return this._backgroundSprite},setFontName:function(t){this._renderCmd.setFontName(t)},setFontSize:function(t){this._renderCmd.setFontSize(t)},setString:function(t){t.length>=this._maxLength&&(t=t.slice(0,this._maxLength)),this._text=t,this._renderCmd.setString(t)},setFontColor:function(t){this._textColor=t,this._renderCmd.setFontColor(t)},setMaxLength:function(t){isNaN(t)||(t<0&&(t=65535),this._maxLength=t,this._renderCmd.setMaxLength(t))},getMaxLength:function(){return this._maxLength},setPlaceHolder:function(t){null!==t&&(this._renderCmd.setPlaceHolder(t),this._placeholderText=t)},setPlaceholderFont:function(t,e){this._placeholderFontName=t,this._placeholderFontSize=e,this._renderCmd._updateDOMPlaceholderFontStyle()},_setPlaceholderFont:function(t){var e=cc.LabelTTF._fontStyleRE.exec(t);e&&(this._placeholderFontName=e[2],this._placeholderFontSize=parseInt(e[1]),this._renderCmd._updateDOMPlaceholderFontStyle())},setPlaceholderFontName:function(t){this._placeholderFontName=t,this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontSize:function(t){this._placeholderFontSize=t,this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontColor:function(t){this._placeholderColor=t,this._renderCmd.setPlaceholderFontColor(t)},setInputFlag:function(t){this._editBoxInputFlag=t,this._renderCmd.setInputFlag(t)},getString:function(){return this._text},initWithSizeAndBackgroundSprite:function(t,e){return this._backgroundSprite&&this._backgroundSprite.removeFromParent(),this._backgroundSprite=e,_ccsg.Node.prototype.setContentSize.call(this,t),this._backgroundSprite&&!this._backgroundSprite.parent&&(this._backgroundSprite.setAnchorPoint(cc.p(0,0)),this.addChild(this._backgroundSprite),this._updateBackgroundSpriteSize(t.width,t.height)),this.x=0,this.y=0,!0},setDelegate:function(t){this._delegate=t},getPlaceHolder:function(){return this._placeholderText},setInputMode:function(t){if(this._editBoxInputMode!==t){var e=this.getString();this._editBoxInputMode=t,this._renderCmd.setInputMode(t),this._renderCmd.transform(),this.setString(e),this._renderCmd._updateLabelPosition(this.getContentSize())}},setReturnType:function(t){this._keyboardReturnType=t,this._renderCmd._updateDomInputType()},initWithBackgroundColor:function(t,e){this._edWidth=t.width,this.dom.style.width=this._edWidth.toString()+"px",this._edHeight=t.height,this.dom.style.height=this._edHeight.toString()+"px",this.dom.style.backgroundColor=cc.colorToHex(e)}});var u=_ccsg.EditBox.prototype;cc.defineGetterSetter(u,"font",null,u._setFont),cc.defineGetterSetter(u,"fontName",null,u.setFontName),cc.defineGetterSetter(u,"fontSize",null,u.setFontSize),cc.defineGetterSetter(u,"fontColor",null,u.setFontColor),cc.defineGetterSetter(u,"string",u.getString,u.setString),cc.defineGetterSetter(u,"maxLength",u.getMaxLength,u.setMaxLength),cc.defineGetterSetter(u,"placeholder",u.getPlaceHolder,u.setPlaceHolder),cc.defineGetterSetter(u,"placeholderFont",null,u._setPlaceholderFont),cc.defineGetterSetter(u,"placeholderFontName",null,u.setPlaceholderFontName),cc.defineGetterSetter(u,"placeholderFontSize",null,u.setPlaceholderFontSize),cc.defineGetterSetter(u,"placeholderFontColor",null,u.setPlaceholderFontColor),cc.defineGetterSetter(u,"inputFlag",null,u.setInputFlag),cc.defineGetterSetter(u,"delegate",null,u.setDelegate),cc.defineGetterSetter(u,"inputMode",null,u.setInputMode),cc.defineGetterSetter(u,"returnType",null,u.setReturnType),u=null,_ccsg.EditBox.InputMode=h,_ccsg.EditBox.InputFlag=l,_ccsg.EditBox.KeyboardReturnType=c,(function(t){t._polyfill={zoomInvalid:!1},a.OS_ANDROID!==a.os||a.browserType!==a.BROWSER_TYPE_SOUGOU&&a.browserType!==a.BROWSER_TYPE_360||(t._polyfill.zoomInvalid=!0)})(_ccsg.EditBox),(function(t){var e=function(){}.prototype=Object.create(Object.prototype);e.updateMatrix=function(){if(this._edTxt){var e=this._node,i=cc.view._scaleX,n=cc.view._scaleY,r=cc.view._devicePixelRatio,s=this._worldTransform;i/=r,n/=r;var o=cc.game.container,a=s.a*i,c=s.b,h=s.c,l=s.d*n,u=o&&o.style.paddingLeft&&parseInt(o.style.paddingLeft),_=o&&o.style.paddingBottom&&parseInt(o.style.paddingBottom),d=s.tx*i+u,f=s.ty*n+_;t.zoomInvalid&&(this.updateSize(e._contentSize.width*a,e._contentSize.height*l),a=1,l=1);var p="matrix("+a+","+-c+","+-h+","+l+","+d+","+-f+")";this._edTxt.style.transform=p,this._edTxt.style["-webkit-transform"]=p,this._edTxt.style["transform-origin"]="0px 100% 0px",this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}},e.updateVisibility=function(){this._edTxt&&(this._node.visible?this._edTxt.style.visibility="visible":this._edTxt.style.visibility="hidden")},e.stayOnTop=function(t){t?(this._removeLabels(),this._edTxt.style.display=""):(this._createLabels(),this._edTxt.style.display="none",this._showLabels())},e._beginEditingOnMobile=function(t){this.__orientationChanged=function(){n(t)},window.addEventListener("orientationchange",this.__orientationChanged),cc.view.isAutoFullScreenEnabled()?(this.__fullscreen=!0,cc.view.enableAutoFullScreen(!1),cc.screen.exitFullScreen()):this.__fullscreen=!1,this.__autoResize=cc.view.__resizeWithBrowserSize,cc.view.resizeWithBrowserSize(!1)},e._endEditingOnMobile=function(){if(this.__rotateScreen){cc.container.style["-webkit-transform"]="rotate(90deg)",cc.container.style.transform="rotate(90deg)";var t=cc.view,e=t._originalDesignResolutionSize.width,i=t._originalDesignResolutionSize.height;e>0&&t.setDesignResolutionSize(e,i,t._resolutionPolicy),this.__rotateScreen=!1}window.removeEventListener("orientationchange",this.__orientationChanged),window.scrollTo(0,0),this.__fullscreen&&cc.view.enableAutoFullScreen(!0),this.__autoResize&&cc.view.resizeWithBrowserSize(!0)},e._onFocusOnMobile=function(t){if(cc.view._isRotated){cc.container.style["-webkit-transform"]="rotate(0deg)",cc.container.style.transform="rotate(0deg)",cc.view._isRotated=!1;cc.view.getResolutionPolicy().apply(cc.view,cc.view.getDesignResolutionSize()),cc.view._isRotated=!0,window.scrollTo(35,35),this.__rotateScreen=!0}else this.__rotateScreen=!1;n(t)},e._createDomInput=function(){function t(t){var i=e._editBox;t.value.length>t.maxLength&&(t.value=t.value.slice(0,t.maxLength)),i._delegate&&i._delegate.editBoxTextChanged&&i._text!==t.value&&(i._text=t.value,e._updateDomTextCases(),i._delegate.editBoxTextChanged(i,i._text))}this.removeDom();var e=this,i=this._edTxt=document.createElement("input");i.type="text",i.style.fontSize=this._edFontSize+"px",i.style.color="#000000",i.style.border=0,i.style.background="transparent",i.style.width="100%",i.style.height="100%",i.style.active=0,i.style.outline="medium",i.style.padding="0",i.style.textTransform="uppercase",i.style.display="none",i.style.position="absolute",i.style.bottom="0px",i.style.left="2px",i.style["-moz-appearance"]="textfield",i.style.className="cocosEditBox";var n=!1;return i.addEventListener("compositionstart",(function(){n=!0})),i.addEventListener("compositionend",(function(){n=!1,t(this)})),i.addEventListener("input",(function(){n||t(this)})),i.addEventListener("keypress",(function(t){var i=e._editBox;t.keyCode===cc.KEY.enter&&(t.stopPropagation(),t.preventDefault(),""===this.value&&(this.style.fontSize=i._placeholderFontSize+"px",this.style.color=cc.colorToHex(i._placeholderColor)),i._text=this.value,e._updateDomTextCases(),e._endEditing(),i._delegate&&i._delegate.editBoxEditingReturn&&i._delegate.editBoxEditingReturn(i),cc._canvas.focus())})),i.addEventListener("focus",(function(){var t=e._editBox;this.style.fontSize=e._edFontSize+"px",this.style.color=cc.colorToHex(t._textColor),e._hiddenLabels(),a.isMobile&&e._onFocusOnMobile(t),t._delegate&&t._delegate.editBoxEditingDidBegan&&t._delegate.editBoxEditingDidBegan(t)})),i.addEventListener("blur",(function(){var t=e._editBox;t._text=this.value,e._updateDomTextCases(),t._delegate&&t._delegate.editBoxEditingDidEnded&&t._delegate.editBoxEditingDidEnded(t),""===this.value&&(this.style.fontSize=t._placeholderFontSize+"px",this.style.color=cc.colorToHex(t._placeholderColor)),e._endEditing()})),this._addDomToGameContainer(),i},e._createDomTextArea=function(){function t(t){t.value.length>t.maxLength&&(t.value=t.value.slice(0,t.maxLength));var i=e._editBox;i._delegate&&i._delegate.editBoxTextChanged&&i._text.toLowerCase()!==t.value.toLowerCase()&&(i._text=t.value,e._updateDomTextCases(),i._delegate.editBoxTextChanged(i,i._text))}this.removeDom();var e=this,i=this._edTxt=document.createElement("textarea");i.type="text",i.style.fontSize=this._edFontSize+"px",i.style.color="#000000",i.style.border=0,i.style.background="transparent",i.style.width="100%",i.style.height="100%",i.style.active=0,i.style.outline="medium",i.style.padding="0",i.style.resize="none",i.style.textTransform="uppercase",i.style.overflow_y="scroll",i.style.display="none",i.style.position="absolute",i.style.bottom="0px",i.style.left="2px",i.style.className="cocosEditBox";var n=!1;return i.addEventListener("compositionstart",(function(){n=!0})),i.addEventListener("compositionend",(function(){n=!1,t(this)})),i.addEventListener("input",(function(){n||t(this)})),i.addEventListener("focus",(function(){var t=e._editBox;e._hiddenLabels(),this.style.fontSize=e._edFontSize+"px",this.style.color=cc.colorToHex(t._textColor),a.isMobile&&e._onFocusOnMobile(t),t._delegate&&t._delegate.editBoxEditingDidBegan&&t._delegate.editBoxEditingDidBegan(t)})),i.addEventListener("keypress",(function(t){var i=e._editBox;t.keyCode===cc.KEY.enter&&(t.stopPropagation(),i._delegate&&i._delegate.editBoxEditingReturn&&i._delegate.editBoxEditingReturn(i))})),i.addEventListener("blur",(function(){var t=e._editBox;t._text=this.value,e._updateDomTextCases(),t._delegate&&t._delegate.editBoxEditingDidEnded&&t._delegate.editBoxEditingDidEnded(t),""===this.value&&(this.style.fontSize=t._placeholderFontSize+"px",this.style.color=cc.colorToHex(t._placeholderColor)),e._endEditing()})),this._addDomToGameContainer(),i},e._createWXInput=function(t){this.removeDom();var e=this,i=this._edTxt=document.createElement("input");i.type="text",i.focus=function(){var i=e._editBox;wx.showKeyboard({defaultValue:i._text,maxLength:140,multiple:t,confirmHold:!0,confirmType:"done",success:function(t){i._delegate&&i._delegate.editBoxEditingDidBegan&&i._delegate.editBoxEditingDidBegan(i)},fail:function(t){cc.warn(t.errMsg),e._endEditing()}}),wx.onKeyboardConfirm((function(t){i._text=t.value,e._updateDomTextCases(),i._delegate&&i._delegate.editBoxEditingReturn&&i._delegate.editBoxEditingReturn(i),wx.hideKeyboard({success:function(t){i._delegate&&i._delegate.editBoxEditingDidEnded&&i._delegate.editBoxEditingDidEnded(i)},fail:function(t){cc.warn(t.errMsg)}})})),wx.onKeyboardInput((function(t){i._delegate&&i._delegate.editBoxTextChanged&&i._text!==t.value&&(i._text=t.value,e._updateDomTextCases(),i._delegate.editBoxTextChanged(i,i._text))})),wx.onKeyboardComplete((function(){e._endEditing(),wx.offKeyboardConfirm(),wx.offKeyboardInput(),wx.offKeyboardComplete()}))}},e._createLabels=function(){var t=this._editBox.getContentSize();this._textLabel||(this._textLabel=_ccsg.Label.pool.get(),this._textLabel.setAnchorPoint(cc.p(0,1)),this._textLabel.setOverflow(_ccsg.Label.Overflow.CLAMP),this._editBox.addChild(this._textLabel,100)),this._placeholderLabel||(this._placeholderLabel=_ccsg.Label.pool.get(),this._placeholderLabel.setAnchorPoint(cc.p(0,1)),this._placeholderLabel.setColor(cc.Color.GRAY),this._editBox.addChild(this._placeholderLabel,100)),this._updateLabelPosition(t)},e._removeLabels=function(){this._textLabel&&(this._editBox.removeChild(this._textLabel),this._textLabel=null)},e._updateLabelPosition=function(t){if(this._textLabel&&this._placeholderLabel){var e=cc.size(t.width-2,t.height);this._textLabel.setContentSize(e),this._placeholderLabel.setLineHeight(t.height);var i=this._placeholderLabel.getContentSize();this._editBox._editBoxInputMode===h.ANY?(this._textLabel.setPosition(2,t.height),this._placeholderLabel.setPosition(2,t.height),this._placeholderLabel.setVerticalAlign(cc.VerticalTextAlignment.TOP),this._textLabel.setVerticalAlign(cc.VerticalTextAlignment.TOP),this._textLabel.enableWrapText(!0)):(this._textLabel.enableWrapText(!1),this._textLabel.setPosition(2,t.height),this._placeholderLabel.setPosition(2,(t.height+i.height)/2),this._placeholderLabel.setVerticalAlign(cc.VerticalTextAlignment.CENTER),this._textLabel.setVerticalAlign(cc.VerticalTextAlignment.CENTER))}},e.setLineHeight=function(t){this._textLabel&&this._textLabel.setLineHeight(t)},e._hiddenLabels=function(){this._textLabel&&this._textLabel.setVisible(!1),this._placeholderLabel&&this._placeholderLabel.setVisible(!1)},e._updateDomTextCases=function(){var t=this._editBox._editBoxInputFlag;t===l.INITIAL_CAPS_ALL_CHARACTERS?this._editBox._text=this._editBox._text.toUpperCase():t===l.INITIAL_CAPS_WORD?this._editBox._text=(function(t){return t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()}))})(this._editBox._text):t===l.INITIAL_CAPS_SENTENCE&&(this._editBox._text=(function(t){return t.charAt(0).toUpperCase()+t.slice(1)})(this._editBox._text))},e._updateLabelStringStyle=function(){if("password"===this._edTxt.type){for(var t="",e=this._editBox._text.length,i=0;i<e;++i)t+="●";this._textLabel&&this._textLabel.setString(t)}else this._updateDomTextCases(),this._textLabel&&this._textLabel.setString(this._editBox._text)},e._showLabels=function(){this._hiddenLabels();""===this._edTxt.value?this._placeholderLabel&&(this._placeholderLabel.setVisible(!0),this._placeholderLabel.setString(this._editBox._placeholderText)):this._textLabel&&(this._textLabel.setVisible(!0),this._textLabel.setString(this._editBox._text)),this._updateLabelStringStyle()},e._beginEditing=function(){var t=this;if(a.platform===a.WECHAT_GAME)this._edTxt.focus();else if(!t._editBox._alwaysOnTop&&a.platform!==a.QQ_PLAY&&"none"===t._edTxt.style.display){t._edTxt.style.display="";function e(){t._edTxt.focus()}a.browserType===a.BROWSER_TYPE_UC?setTimeout(e,400):a.browserType===a.BROWSER_TYPE_FIREFOX?setTimeout(e,0):e()}a.isMobile&&!t._editingMode&&a.platform!==a.QQ_PLAY&&t._beginEditingOnMobile(t._editBox),t._editingMode=!0},e._endEditing=function(){if(this._editBox._alwaysOnTop||a.platform===a.QQ_PLAY||(this._edTxt.style.display="none"),this._showLabels(),a.platform!==a.WECHAT_GAME&&a.platform!==a.QQ_PLAY&&a.isMobile&&this._editingMode){var t=this;setTimeout((function(){t._endEditingOnMobile()}),s)}this._editingMode=!1},e._setFont=function(t){var e=cc.LabelTTF._fontStyleRE.exec(t),i=e[2],n=parseInt(e[1]);e&&this.setFont(i,n)},e.setFont=function(t,e){this._edFontName=t||this._edFontName,this._edFontSize=e||this._edFontSize,this._updateDOMFontStyle()},e.setFontName=function(t){this._edFontName=t||this._edFontName,this._updateDOMFontStyle()},e.setFontSize=function(t){this._edFontSize=t||this._edFontSize,this._updateDOMFontStyle()},e.setFontColor=function(t){this._edTxt&&(this._edTxt.value!==this._editBox._placeholderText&&(this._edTxt.style.color=cc.colorToHex(t)),this._textLabel&&this._textLabel.setColor(t))},e.setPlaceHolder=function(t){this._placeholderLabel.setString(t)},e.setMaxLength=function(t){this._edTxt&&(this._edTxt.maxLength=t)},e._updateDOMPlaceholderFontStyle=function(){this._placeholderLabel.setFontFamily(this._editBox._placeholderFontName),this._placeholderLabel.setFontSize(this._editBox._placeholderFontSize)},e.setPlaceholderFontColor=function(t){this._placeholderLabel.setColor(t)},e._updateDomInputType=function(){if(this._edTxt){var t=this._editBox._editBoxInputMode;t===h.EMAIL_ADDR?this._edTxt.type="email":t===h.NUMERIC||t===h.DECIMAL?this._edTxt.type="number":t===h.PHONE_NUMBER?(this._edTxt.type="number",this._edTxt.pattern="[0-9]*"):t===h.URL?this._edTxt.type="url":(this._edTxt.type="text",this._editBox._keyboardReturnType===c.SEARCH&&(this._edTxt.type="search")),this._editBox._editBoxInputFlag===l.PASSWORD&&(this._edTxt.type="password")}},e.setInputFlag=function(t){this._edTxt&&(this._updateDomInputType(),this._edTxt.style.textTransform="none",t===l.INITIAL_CAPS_ALL_CHARACTERS?this._edTxt.style.textTransform="uppercase":t===l.INITIAL_CAPS_WORD&&(this._edTxt.style.textTransform="capitalize"),this._updateLabelStringStyle())},e.setInputMode=function(t){a.platform===a.WECHAT_GAME?this._createWXInput(t===h.ANY):t===h.ANY?this._createDomTextArea():this._createDomInput(),this._updateDomInputType();var e=this._node.getContentSize();this.updateSize(e.width,e.height)},e.setString=function(t){this._edTxt&&null!==t&&(this._edTxt.value=t,""===t?(this._placeholderLabel&&(this._placeholderLabel.setString(this._editBox._placeholderText),this._placeholderLabel.setColor(this._editBox._placeholderColor)),this._editingMode||(this._placeholderLabel&&this._placeholderLabel.setVisible(!0),this._textLabel&&this._textLabel.setVisible(!1))):(this._edTxt.style.color=cc.colorToHex(this._editBox._textColor),this._textLabel&&this._textLabel.setColor(this._editBox._textColor),this._editingMode||(this._placeholderLabel&&this._placeholderLabel.setVisible(!1),this._textLabel&&this._textLabel.setVisible(!0)),this._updateLabelStringStyle()))},e._updateDOMFontStyle=function(){this._edTxt&&(""!==this._edTxt.value&&(this._edTxt.style.fontFamily=this._edFontName,this._edTxt.style.fontSize=this._edFontSize+"px"),this._textLabel&&(this._textLabel.setFontSize(this._edFontSize),this._textLabel.setFontFamily(this._edFontName)))},e.updateSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px",this._updateLabelPosition(cc.size(t,e)))},e._addDomToGameContainer=function(){cc.game.container.appendChild(this._edTxt)},e.removeDom=function(){var t=this._edTxt;if(t){o.contains(cc.game.container,t)&&cc.game.container.removeChild(t)}this._edTxt=null},e.initializeRenderCmd=function(t){this._editBox=t,this._edFontSize=14,this._edFontName="Arial",this._textLabel=null,this._placeholderLabel=null,this._editingMode=!1,this.__fullscreen=!1,this.__autoResize=!1,this.__rotateScreen=!1,this.__orientationChanged=null},_ccsg.EditBox.CanvasRenderCmd=function(t){this._rootCtor(t),this.initializeRenderCmd(t)};var i=_ccsg.EditBox.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);cc.js.mixin(i,e),i.constructor=_ccsg.EditBox.CanvasRenderCmd,i.transform=function(t,e){this.originTransform(t,e),this.updateMatrix()},_ccsg.EditBox.WebGLRenderCmd=function(t){this._rootCtor(t),this.initializeRenderCmd(t)};var r=_ccsg.EditBox.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);cc.js.mixin(r,e),r.constructor=_ccsg.EditBox.WebGLRenderCmd,r.transform=function(t,e){this.originTransform(t,e),this.updateMatrix()}})(_ccsg.EditBox._polyfill)}),{"../platform/CCSys":185,"../platform/utils":201}],106:[(function(t,e,i){var n=cc.js;t("../event/event");var r=function(t,e){cc.Event.call(this,cc.Event.MOUSE,e),this._eventType=t,this._button=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this._scrollX=0,this._scrollY=0};n.extend(r,cc.Event);var s=r.prototype;s.setScrollData=function(t,e){this._scrollX=t,this._scrollY=e},s.getScrollX=function(){return this._scrollX},s.getScrollY=function(){return this._scrollY},s.setLocation=function(t,e){this._x=t,this._y=e},s.getLocation=function(){return{x:this._x,y:this._y}},s.getLocationInView=function(){return{x:this._x,y:cc.view._designResolutionSize.height-this._y}},s._setPrevCursor=function(t,e){this._prevX=t,this._prevY=e},s.getPreviousLocation=function(){return{x:this._prevX,y:this._prevY}},s.getDelta=function(){return{x:this._x-this._prevX,y:this._y-this._prevY}},s.getDeltaX=function(){return this._x-this._prevX},s.getDeltaY=function(){return this._y-this._prevY},s.setButton=function(t){this._button=t},s.getButton=function(){return this._button},s.getLocationX=function(){return this._x},s.getLocationY=function(){return this._y},r.NONE=0,r.DOWN=1,r.UP=2,r.MOVE=3,r.SCROLL=4,r.BUTTON_LEFT=0,r.BUTTON_RIGHT=2,r.BUTTON_MIDDLE=1,r.BUTTON_4=3,r.BUTTON_5=4,r.BUTTON_6=5,r.BUTTON_7=6,r.BUTTON_8=7;var o=function(t,e){cc.Event.call(this,cc.Event.TOUCH,e),this._eventCode=0,this._touches=t||[],this.touch=null,this.currentTouch=null};n.extend(o,cc.Event),(s=o.prototype).getEventCode=function(){return this._eventCode},s.getTouches=function(){return this._touches},s._setEventCode=function(t){this._eventCode=t},s._setTouches=function(t){this._touches=t},s.setLocation=function(t,e){this.touch&&this.touch.setTouchInfo(this.touch.getID(),t,e)},s.getLocation=function(){return this.touch?this.touch.getLocation():cc.v2()},s.getLocationInView=function(){return this.touch?this.touch.getLocationInView():cc.v2()},s.getPreviousLocation=function(){return this.touch?this.touch.getPreviousLocation():cc.v2()},s.getStartLocation=function(){return this.touch?this.touch.getStartLocation():cc.v2()},s.getID=function(){return this.touch?this.touch.getID():null},s.getDelta=function(){return this.touch?this.touch.getDelta():cc.v2()},s.getDeltaX=function(){return this.touch?this.touch.getDelta().x:0},s.getDeltaY=function(){return this.touch?this.touch.getDelta().y:0},s.getLocationX=function(){return this.touch?this.touch.getLocationX():0},s.getLocationY=function(){return this.touch?this.touch.getLocationY():0},o.MAX_TOUCHES=5,o.BEGAN=0,o.MOVED=1,o.ENDED=2,o.CANCELED=3;var a=function(t,e){cc.Event.call(this,cc.Event.ACCELERATION,e),this.acc=t};n.extend(a,cc.Event);var c=function(t,e,i){cc.Event.call(this,cc.Event.KEYBOARD,i),this.keyCode=t,this.isPressed=e};n.extend(c,cc.Event),cc.Event.EventMouse=r,cc.Event.EventTouch=o,cc.Event.EventAcceleration=a,cc.Event.EventKeyboard=c,e.exports=cc.Event}),{"../event/event":113}],107:[(function(t,e,i){cc.EventListener=cc._Class.extend({ctor:function(t,e,i){this._onEvent=i,this._type=t||0,this._listenerID=e||"",this._registered=!1,this._fixedPriority=0,this._node=null,this._target=null,this._paused=!0,this._isEnabled=!0},_setPaused:function(t){this._paused=t},_isPaused:function(){return this._paused},_setRegistered:function(t){this._registered=t},_isRegistered:function(){return this._registered},_getType:function(){return this._type},_getListenerID:function(){return this._listenerID},_setFixedPriority:function(t){this._fixedPriority=t},_getFixedPriority:function(){return this._fixedPriority},_setSceneGraphPriority:function(t){this._target=t,this._node=t},_getSceneGraphPriority:function(){return this._node},checkAvailable:function(){return null!==this._onEvent},clone:function(){return null},setEnabled:function(t){this._isEnabled=t},isEnabled:function(){return this._isEnabled},retain:function(){},release:function(){}}),cc.EventListener.UNKNOWN=0,cc.EventListener.TOUCH_ONE_BY_ONE=1,cc.EventListener.TOUCH_ALL_AT_ONCE=2,cc.EventListener.KEYBOARD=3,cc.EventListener.MOUSE=4,cc.EventListener.ACCELERATION=6,cc.EventListener.CUSTOM=8,cc._EventListenerCustom=cc.EventListener.extend({_onCustomEvent:null,ctor:function(t,e){this._onCustomEvent=e,cc.EventListener.prototype.ctor.call(this,cc.EventListener.CUSTOM,t,this._callback)},_callback:function(t){null!==this._onCustomEvent&&this._onCustomEvent(t)},checkAvailable:function(){return cc.EventListener.prototype.checkAvailable.call(this)&&null!==this._onCustomEvent},clone:function(){return new cc._EventListenerCustom(this._listenerID,this._onCustomEvent)}}),cc._EventListenerMouse=cc.EventListener.extend({onMouseDown:null,onMouseUp:null,onMouseMove:null,onMouseScroll:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.MOUSE,cc._EventListenerMouse.LISTENER_ID,this._callback)},_callback:function(t){var e=cc.Event.EventMouse;switch(t._eventType){case e.DOWN:this.onMouseDown&&this.onMouseDown(t);break;case e.UP:this.onMouseUp&&this.onMouseUp(t);break;case e.MOVE:this.onMouseMove&&this.onMouseMove(t);break;case e.SCROLL:this.onMouseScroll&&this.onMouseScroll(t)}},clone:function(){var t=new cc._EventListenerMouse;return t.onMouseDown=this.onMouseDown,t.onMouseUp=this.onMouseUp,t.onMouseMove=this.onMouseMove,t.onMouseScroll=this.onMouseScroll,t},checkAvailable:function(){return!0}}),cc._EventListenerMouse.LISTENER_ID="__cc_mouse",cc._EventListenerTouchOneByOne=cc.EventListener.extend({_claimedTouches:null,swallowTouches:!1,onTouchBegan:null,onTouchMoved:null,onTouchEnded:null,onTouchCancelled:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.TOUCH_ONE_BY_ONE,cc._EventListenerTouchOneByOne.LISTENER_ID,null),this._claimedTouches=[]},setSwallowTouches:function(t){this.swallowTouches=t},isSwallowTouches:function(){return this.swallowTouches},clone:function(){var t=new cc._EventListenerTouchOneByOne;return t.onTouchBegan=this.onTouchBegan,t.onTouchMoved=this.onTouchMoved,t.onTouchEnded=this.onTouchEnded,t.onTouchCancelled=this.onTouchCancelled,t.swallowTouches=this.swallowTouches,t},checkAvailable:function(){return!!this.onTouchBegan||(cc.logID(1801),!1)}}),cc._EventListenerTouchOneByOne.LISTENER_ID="__cc_touch_one_by_one",cc._EventListenerTouchAllAtOnce=cc.EventListener.extend({onTouchesBegan:null,onTouchesMoved:null,onTouchesEnded:null,onTouchesCancelled:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.TOUCH_ALL_AT_ONCE,cc._EventListenerTouchAllAtOnce.LISTENER_ID,null)},clone:function(){var t=new cc._EventListenerTouchAllAtOnce;return t.onTouchesBegan=this.onTouchesBegan,t.onTouchesMoved=this.onTouchesMoved,t.onTouchesEnded=this.onTouchesEnded,t.onTouchesCancelled=this.onTouchesCancelled,t},checkAvailable:function(){return null!==this.onTouchesBegan||null!==this.onTouchesMoved||null!==this.onTouchesEnded||null!==this.onTouchesCancelled||(cc.logID(1802),!1)}}),cc._EventListenerTouchAllAtOnce.LISTENER_ID="__cc_touch_all_at_once",cc.EventListener.create=function(t){cc.assertID(t&&t.event,1900);var e=t.event;delete t.event;var i=null;e===cc.EventListener.TOUCH_ONE_BY_ONE?i=new cc._EventListenerTouchOneByOne:e===cc.EventListener.TOUCH_ALL_AT_ONCE?i=new cc._EventListenerTouchAllAtOnce:e===cc.EventListener.MOUSE?i=new cc._EventListenerMouse:e===cc.EventListener.CUSTOM?(i=new cc._EventListenerCustom(t.eventName,t.callback),delete t.eventName,delete t.callback):e===cc.EventListener.KEYBOARD?i=new cc._EventListenerKeyboard:e===cc.EventListener.ACCELERATION&&(i=new cc._EventListenerAcceleration(t.callback),delete t.callback);for(var n in t)i[n]=t[n];return i},cc._EventListenerAcceleration=cc.EventListener.extend({_onAccelerationEvent:null,ctor:function(t){this._onAccelerationEvent=t,cc.EventListener.prototype.ctor.call(this,cc.EventListener.ACCELERATION,cc._EventListenerAcceleration.LISTENER_ID,this._callback)},_callback:function(t){this._onAccelerationEvent(t.acc,t)},checkAvailable:function(){return cc.assertID(this._onAccelerationEvent,1803),!0},clone:function(){return new cc._EventListenerAcceleration(this._onAccelerationEvent)}}),cc._EventListenerAcceleration.LISTENER_ID="__cc_acceleration",cc._EventListenerKeyboard=cc.EventListener.extend({onKeyPressed:null,onKeyReleased:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.KEYBOARD,cc._EventListenerKeyboard.LISTENER_ID,this._callback)},_callback:function(t){t.isPressed?this.onKeyPressed&&this.onKeyPressed(t.keyCode,t):this.onKeyReleased&&this.onKeyReleased(t.keyCode,t)},clone:function(){var t=new cc._EventListenerKeyboard;return t.onKeyPressed=this.onKeyPressed,t.onKeyReleased=this.onKeyReleased,t},checkAvailable:function(){return null!==this.onKeyPressed||null!==this.onKeyReleased||(cc.logID(1800),!1)}}),cc._EventListenerKeyboard.LISTENER_ID="__cc_keyboard"}),{}],108:[(function(t,e,i){var n=t("../platform/js"),r=cc._Class.extend({ctor:function(){this._fixedListeners=[],this._sceneGraphListeners=[],this.gt0Index=0},size:function(){return this._fixedListeners.length+this._sceneGraphListeners.length},empty:function(){return 0===this._fixedListeners.length&&0===this._sceneGraphListeners.length},push:function(t){0===t._getFixedPriority()?this._sceneGraphListeners.push(t):this._fixedListeners.push(t)},clearSceneGraphListeners:function(){this._sceneGraphListeners.length=0},clearFixedListeners:function(){this._fixedListeners.length=0},clear:function(){this._sceneGraphListeners.length=0,this._fixedListeners.length=0},getFixedPriorityListeners:function(){return this._fixedListeners},getSceneGraphPriorityListeners:function(){return this._sceneGraphListeners}}),s={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_nodePriorityMap:{},_globalZOrderNodeMap:{},_toAddedListeners:[],_toRemovedListeners:[],_dirtyNodes:[],_inDispatch:0,_isEnabled:!1,_nodePriorityIndex:0,_internalCustomListenerIDs:[],_setDirtyForNode:function(t){if(void 0!==this._nodeListenersMap[t.__instanceId]&&this._dirtyNodes.push(t),t.getChildren)for(var e=t.getChildren(),i=0,n=e?e.length:0;i<n;i++)this._setDirtyForNode(e[i])},pauseTarget:function(t,e){if(t instanceof cc._BaseNode||t instanceof _ccsg.Node){var i,n,r=this._nodeListenersMap[t.__instanceId];if(r)for(i=0,n=r.length;i<n;i++)r[i]._setPaused(!0);if(!0===e){var s=t.getChildren();for(i=0,n=s?s.length:0;i<n;i++)this.pauseTarget(s[i],!0)}}else cc.warnID(3506)},resumeTarget:function(t,e){if(t instanceof cc._BaseNode||t instanceof _ccsg.Node){var i,n,r=this._nodeListenersMap[t.__instanceId];if(r)for(i=0,n=r.length;i<n;i++)r[i]._setPaused(!1);if(this._setDirtyForNode(t),!0===e&&t.getChildren){var s=t.getChildren();for(i=0,n=s?s.length:0;i<n;i++)this.resumeTarget(s[i],!0)}}else cc.warnID(3506)},_addListener:function(t){0===this._inDispatch?this._forceAddEventListener(t):this._toAddedListeners.push(t)},_forceAddEventListener:function(t){var e=t._getListenerID(),i=this._listenersMap[e];if(i||(i=new r,this._listenersMap[e]=i),i.push(t),0===t._getFixedPriority()){this._setDirty(e,this.DIRTY_SCENE_GRAPH_PRIORITY);var n=t._getSceneGraphPriority();null===n&&cc.logID(3507),this._associateNodeAndEventListener(n,t),n.isRunning()&&this.resumeTarget(n)}else this._setDirty(e,this.DIRTY_FIXED_PRIORITY)},_getListeners:function(t){return this._listenersMap[t]},_updateDirtyFlagForSceneGraph:function(){if(0!==this._dirtyNodes.length){for(var t,e,i=this._dirtyNodes,n=this._nodeListenersMap,r=0,s=i.length;r<s;r++)if(t=n[i[r].__instanceId])for(var o=0,a=t.length;o<a;o++)(e=t[o])&&this._setDirty(e._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY);this._dirtyNodes.length=0}},_removeAllListenersInVector:function(t){if(t)for(var e,i=0;i<t.length;)(e=t[i])._setRegistered(!1),null!=e._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(e._getSceneGraphPriority(),e),e._setSceneGraphPriority(null)),0===this._inDispatch?cc.js.array.remove(t,e):++i},_removeListenersForListenerID:function(t){var e,i=this._listenersMap[t];if(i){var n=i.getFixedPriorityListeners(),r=i.getSceneGraphPriorityListeners();this._removeAllListenersInVector(r),this._removeAllListenersInVector(n),delete this._priorityDirtyFlagMap[t],this._inDispatch||(i.clear(),delete this._listenersMap[t])}var s,o=this._toAddedListeners;for(e=0;e<o.length;)(s=o[e])&&s._getListenerID()===t?cc.js.array.remove(o,s):++e},_sortEventListeners:function(t){var e=this.DIRTY_NONE,i=this._priorityDirtyFlagMap;if(i[t]&&(e=i[t]),e!==this.DIRTY_NONE&&(i[t]=this.DIRTY_NONE,e&this.DIRTY_FIXED_PRIORITY&&this._sortListenersOfFixedPriority(t),e&this.DIRTY_SCENE_GRAPH_PRIORITY)){var n=cc.director.getScene();n&&this._sortListenersOfSceneGraphPriority(t,n)}},_sortListenersOfSceneGraphPriority:function(t,e){var i=this._getListeners(t);if(i){var n=i.getSceneGraphPriorityListeners();n&&0!==n.length&&(this._nodePriorityIndex=0,this._nodePriorityMap={},this._visitTarget(e,!0),i.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))}},_sortEventListenersOfSceneGraphPriorityDes:function(t,e){var i=s._nodePriorityMap,n=t._getSceneGraphPriority(),r=e._getSceneGraphPriority();return e&&r&&i[r.__instanceId]?t&&n&&i[n.__instanceId]?i[r.__instanceId]-i[n.__instanceId]:1:-1},_sortListenersOfFixedPriority:function(t){var e=this._listenersMap[t];if(e){var i=e.getFixedPriorityListeners();if(i&&0!==i.length){i.sort(this._sortListenersOfFixedPriorityAsc);for(var n=0,r=i.length;n<r&&!(i[n]._getFixedPriority()>=0);)++n;e.gt0Index=n}}},_sortListenersOfFixedPriorityAsc:function(t,e){return t._getFixedPriority()-e._getFixedPriority()},_onUpdateListeners:function(t){var e,i,n,r=t.getFixedPriorityListeners(),s=t.getSceneGraphPriorityListeners(),o=this._toRemovedListeners;if(s)for(e=0;e<s.length;)(i=s[e])._isRegistered()?++e:(cc.js.array.remove(s,i),-1!==(n=o.indexOf(i))&&o.splice(n,1));if(r)for(e=0;e<r.length;)(i=r[e])._isRegistered()?++e:(cc.js.array.remove(r,i),-1!==(n=o.indexOf(i))&&o.splice(n,1));s&&0===s.length&&t.clearSceneGraphListeners(),r&&0===r.length&&t.clearFixedListeners()},frameUpdateListeners:function(){var t=this._listenersMap,e=this._priorityDirtyFlagMap;for(var i in t)t[i].empty()&&(delete e[i],delete t[i]);var n=this._toAddedListeners;if(0!==n.length){for(var r=0,s=n.length;r<s;r++)this._forceAddEventListener(n[r]);n.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()},_updateTouchListeners:function(t){var e=this._inDispatch;if(cc.assertID(e>0,3508),!(e>1)){var i;(i=this._listenersMap[cc._EventListenerTouchOneByOne.LISTENER_ID])&&this._onUpdateListeners(i),(i=this._listenersMap[cc._EventListenerTouchAllAtOnce.LISTENER_ID])&&this._onUpdateListeners(i),cc.assertID(1===e,3509);var n=this._toAddedListeners;if(0!==n.length){for(var r=0,s=n.length;r<s;r++)this._forceAddEventListener(n[r]);this._toAddedListeners.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()}},_cleanToRemovedListeners:function(){for(var t=this._toRemovedListeners,e=0;e<t.length;e++){var i=t[e],n=this._listenersMap[i._getListenerID()];if(n){var r,s=n.getFixedPriorityListeners(),o=n.getSceneGraphPriorityListeners();o&&-1!==(r=o.indexOf(i))&&o.splice(r,1),s&&-1!==(r=s.indexOf(i))&&s.splice(r,1)}}t.length=0},_onTouchEventCallback:function(t,e){if(!t._isRegistered)return!1;var i=e.event,n=i.currentTouch;i.currentTarget=t._node;var r,o=!1,a=i.getEventCode(),c=cc.Event.EventTouch;return a===c.BEGAN?t.onTouchBegan&&(o=t.onTouchBegan(n,i))&&t._registered&&t._claimedTouches.push(n):t._claimedTouches.length>0&&-1!==(r=t._claimedTouches.indexOf(n))&&(o=!0,a===c.MOVED&&t.onTouchMoved?t.onTouchMoved(n,i):a===c.ENDED?(t.onTouchEnded&&t.onTouchEnded(n,i),t._registered&&t._claimedTouches.splice(r,1)):a===c.CANCELLED&&(t.onTouchCancelled&&t.onTouchCancelled(n,i),t._registered&&t._claimedTouches.splice(r,1))),i.isStopped()?(s._updateTouchListeners(i),!0):!!(o&&t._registered&&t.swallowTouches)&&(e.needsMutableSet&&e.touches.splice(n,1),!0)},_dispatchTouchEvent:function(t){this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);var e=this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),i=this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);if(null!==e||null!==i){var n=t.getTouches(),r=cc.js.array.copy(n),s={event:t,needsMutableSet:e&&i,touches:r,selTouch:null};if(e)for(var o=0;o<n.length;o++)t.currentTouch=n[o],t._propagationStopped=t._propagationImmediateStopped=!1,this._dispatchEventToListeners(e,this._onTouchEventCallback,s);i&&r.length>0&&(this._dispatchEventToListeners(i,this._onTouchesEventCallback,{event:t,touches:r}),t.isStopped())||this._updateTouchListeners(t)}},_onTouchesEventCallback:function(t,e){if(!t._registered)return!1;var i=cc.Event.EventTouch,n=e.event,r=e.touches,o=n.getEventCode();return n.currentTarget=t._node,o===i.BEGAN&&t.onTouchesBegan?t.onTouchesBegan(r,n):o===i.MOVED&&t.onTouchesMoved?t.onTouchesMoved(r,n):o===i.ENDED&&t.onTouchesEnded?t.onTouchesEnded(r,n):o===i.CANCELLED&&t.onTouchesCancelled&&t.onTouchesCancelled(r,n),!!n.isStopped()&&(s._updateTouchListeners(n),!0)},_associateNodeAndEventListener:function(t,e){var i=this._nodeListenersMap[t.__instanceId];i||(i=[],this._nodeListenersMap[t.__instanceId]=i),i.push(e)},_dissociateNodeAndEventListener:function(t,e){var i=this._nodeListenersMap[t.__instanceId];i&&(cc.js.array.remove(i,e),0===i.length&&delete this._nodeListenersMap[t.__instanceId])},_dispatchEventToListeners:function(t,e,i){var n,r,s=!1,o=t.getFixedPriorityListeners(),a=t.getSceneGraphPriorityListeners(),c=0;if(o&&0!==o.length)for(;c<t.gt0Index;++c)if((r=o[c]).isEnabled()&&!r._isPaused()&&r._isRegistered()&&e(r,i)){s=!0;break}if(a&&!s)for(n=0;n<a.length;n++)if((r=a[n]).isEnabled()&&!r._isPaused()&&r._isRegistered()&&e(r,i)){s=!0;break}if(o&&!s)for(;c<o.length;++c)if((r=o[c]).isEnabled()&&!r._isPaused()&&r._isRegistered()&&e(r,i)){s=!0;break}},_setDirty:function(t,e){var i=this._priorityDirtyFlagMap;null==i[t]?i[t]=e:i[t]=e|i[t]},_visitTarget:function(t,e){t._reorderChildDirty&&t.sortAllChildren();var i=t.getChildren(),n=0,r=i.length,s=this._globalZOrderNodeMap,o=this._nodeListenersMap;if(r>0){for(var a;n<r&&((a=i[n])&&a.getLocalZOrder()<0);n++)this._visitTarget(a,!1);for(void 0!==o[t.__instanceId]&&(s[t.getGlobalZOrder()]||(s[t.getGlobalZOrder()]=[]),s[t.getGlobalZOrder()].push(t.__instanceId));n<r;n++)(a=i[n])&&this._visitTarget(a,!1)}else void 0!==o[t.__instanceId]&&(s[t.getGlobalZOrder()]||(s[t.getGlobalZOrder()]=[]),s[t.getGlobalZOrder()].push(t.__instanceId));if(e){var c=[];for(var h in s)c.push(h);c.sort(this._sortNumberAsc);var l,u,_=c.length,d=this._nodePriorityMap;for(n=0;n<_;n++)for(l=s[c[n]],u=0;u<l.length;u++)d[l[u]]=++this._nodePriorityIndex;this._globalZOrderNodeMap={}}},_sortNumberAsc:function(t,e){return t-e},hasEventListener:function(t){return!!this._getListeners(t)},addListener:function(t,e){if(cc.assertID(t&&e,3503),cc.js.isNumber(e)||e instanceof cc._BaseNode||e instanceof _ccsg.Node){if(t instanceof cc.EventListener){if(t._isRegistered())return void cc.logID(3505)}else cc.assertID(!cc.js.isNumber(e),3504),t=cc.EventListener.create(t);if(t.checkAvailable()){if(cc.js.isNumber(e)){if(0===e)return void cc.logID(3500);t._setSceneGraphPriority(null),t._setFixedPriority(e),t._setRegistered(!0),t._setPaused(!1),this._addListener(t)}else t._setSceneGraphPriority(e),t._setFixedPriority(0),t._setRegistered(!0),this._addListener(t);return t}}else cc.warnID(3506)},addCustomListener:function(t,e){var i=new cc._EventListenerCustom(t,e);return this.addListener(i,1),i},removeListener:function(t){if(null!=t){var e,i=this._listenersMap;for(var n in i){var r=i[n],s=r.getFixedPriorityListeners(),o=r.getSceneGraphPriorityListeners();if((e=this._removeListenerInVector(o,t))?this._setDirty(t._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY):(e=this._removeListenerInVector(s,t))&&this._setDirty(t._getListenerID(),this.DIRTY_FIXED_PRIORITY),r.empty()&&(delete this._priorityDirtyFlagMap[t._getListenerID()],delete i[n]),e)break}if(!e)for(var a=this._toAddedListeners,c=0,h=a.length;c<h;c++){var l=a[c];if(l===t){cc.js.array.remove(a,l),l._setRegistered(!1);break}}}},_removeListenerInCallback:function(t,e){if(null==t)return!1;for(var i=0,n=t.length;i<n;i++){var r=t[i];if(r._onCustomEvent===e||r._onEvent===e)return r._setRegistered(!1),null!=r._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(r._getSceneGraphPriority(),r),r._setSceneGraphPriority(null)),0===this._inDispatch?cc.js.array.remove(t,r):this._toRemovedListeners.push(r),!0}return!1},_removeListenerInVector:function(t,e){if(null==t)return!1;for(var i=0,n=t.length;i<n;i++){var r=t[i];if(r===e)return r._setRegistered(!1),null!=r._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(r._getSceneGraphPriority(),r),r._setSceneGraphPriority(null)),0===this._inDispatch?cc.js.array.remove(t,r):this._toRemovedListeners.push(r),!0}return!1},removeListeners:function(t,e){if(cc.js.isNumber(t)||t instanceof cc._BaseNode||t instanceof _ccsg.Node)if(void 0!==t.__instanceId){delete this._nodePriorityMap[t.__instanceId],cc.js.array.remove(this._dirtyNodes,t);var i,n=this._nodeListenersMap[t.__instanceId];if(n){var r=cc.js.array.copy(n);for(i=0;i<r.length;i++)this.removeListener(r[i]);delete this._nodeListenersMap[t.__instanceId]}var s=this._toAddedListeners;for(i=0;i<s.length;){var o=s[i];o._getSceneGraphPriority()===t?(o._setSceneGraphPriority(null),o._setRegistered(!1),s.splice(i,1)):++i}if(!0===e){var a,c=t.getChildren();for(i=0,a=c.length;i<a;i++)this.removeListeners(c[i],!0)}}else t===cc.EventListener.TOUCH_ONE_BY_ONE?this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID):t===cc.EventListener.TOUCH_ALL_AT_ONCE?this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID):t===cc.EventListener.MOUSE?this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID):t===cc.EventListener.ACCELERATION?this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID):t===cc.EventListener.KEYBOARD?this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID):cc.logID(3501);else cc.warnID(3506)},removeCustomListeners:function(t){this._removeListenersForListenerID(t)},removeAllListeners:function(){var t=this._listenersMap,e=this._internalCustomListenerIDs;for(var i in t)-1===e.indexOf(i)&&this._removeListenersForListenerID(i)},setPriority:function(t,e){if(null!=t){var i=this._listenersMap;for(var n in i){var r=i[n].getFixedPriorityListeners();if(r){if(-1!==r.indexOf(t))return null!=t._getSceneGraphPriority()&&cc.logID(3502),void(t._getFixedPriority()!==e&&(t._setFixedPriority(e),this._setDirty(t._getListenerID(),this.DIRTY_FIXED_PRIORITY)))}}}},setEnabled:function(t){this._isEnabled=t},isEnabled:function(){return this._isEnabled},dispatchEvent:function(t){if(this._isEnabled){if(this._updateDirtyFlagForSceneGraph(),this._inDispatch++,!t||!t.getType)throw new Error("event is undefined");if(t.getType().startsWith(cc.Event.TOUCH))return this._dispatchTouchEvent(t),void this._inDispatch--;var e=(function(t){var e=cc.Event,i=t.type;return i===e.ACCELERATION?cc._EventListenerAcceleration.LISTENER_ID:i===e.KEYBOARD?cc._EventListenerKeyboard.LISTENER_ID:i.startsWith(e.MOUSE)?cc._EventListenerMouse.LISTENER_ID:(i.startsWith(e.TOUCH)&&cc.logID(2e3),"")})(t);this._sortEventListeners(e);var i=this._listenersMap[e];null!=i&&(this._dispatchEventToListeners(i,this._onListenerCallback,t),this._onUpdateListeners(i)),this._inDispatch--}},_onListenerCallback:function(t,e){return e.currentTarget=t._target,t._onEvent(e),e.isStopped()},dispatchCustomEvent:function(t,e){var i=new cc.Event.EventCustom(t);i.setUserData(e),this.dispatchEvent(i)}};n.get(cc,"eventManager",(function(){return cc.warnID(1405,"cc.eventManager","cc.EventTarget or cc.systemEvent"),s})),e.exports=s}),{"../platform/js":197}],109:[(function(t,e,i){cc.Touch=cc._Class.extend({ctor:function(t,e,i){this._lastModified=0,this.setTouchInfo(i,t,e)},getLocation:function(){return{x:this._point.x,y:this._point.y}},getLocationX:function(){return this._point.x},getLocationY:function(){return this._point.y},getPreviousLocation:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocation:function(){return{x:this._startPoint.x,y:this._startPoint.y}},getDelta:function(){return cc.pSub(this._point,this._prevPoint)},getLocationInView:function(){return{x:this._point.x,y:cc.view._designResolutionSize.height-this._point.y}},getPreviousLocationInView:function(){return{x:this._prevPoint.x,y:cc.view._designResolutionSize.height-this._prevPoint.y}},getStartLocationInView:function(){return{x:this._startPoint.x,y:cc.view._designResolutionSize.height-this._startPoint.y}},getID:function(){return this._id},setTouchInfo:function(t,e,i){this._prevPoint=this._point,this._point=cc.p(e||0,i||0),this._id=t,this._startPointCaptured||(this._startPoint=cc.p(this._point),cc.view._convertPointWithScale(this._startPoint),this._startPointCaptured=!0)},_setPoint:function(t,e){void 0===e?(this._point.x=t.x,this._point.y=t.y):(this._point.x=t,this._point.y=e)},_setPrevPoint:function(t,e){this._prevPoint=void 0===e?cc.p(t.x,t.y):cc.p(t||0,e||0)}})}),{}],110:[(function(t,e,i){t("./CCEvent");var n;t("./CCTouch"),t("./CCEventListener"),n=t("./CCEventManager"),e.exports=n}),{"./CCEvent":106,"./CCEventListener":107,"./CCEventManager":108,"./CCTouch":109}],111:[(function(t,e,i){function n(){s.call(this)}var r=cc.js,s=t("../platform/callbacks-invoker").CallbacksHandler;r.extend(n,s),n.prototype.invoke=function(t,e){var i=t.type,n=this._callbackTable[i];if(n){var r=!n.isInvoking;n.isInvoking=!0;for(var s=n.callbacks,o=n.targets,a=0,c=s.length;a<c;++a){var h=s[a];if(h){var l=o[a]||t.currentTarget;if(h.call(l,t,e),t._propagationImmediateStopped)break}}r&&(n.isInvoking=!1,n.containCanceled&&n.purgeCanceled())}},e.exports=n}),{"../platform/callbacks-invoker":190}],112:[(function(t,e,i){function n(){this._capturingListeners=null,this._bubblingListeners=null,this._hasListenerCache=null}var r=t("./event-listeners");t("./event");var s=cc.js.array.fastRemove,o=new Array(16);o.length=0;var a=n.prototype;a._addEventFlag=function(t,e,i){var n=this._hasListenerCache;n||(n=this._hasListenerCache=cc.js.createMap()),void 0===n[t]&&(n[t]=0);var r=i?2:4;n[t]|=r},a._purgeEventFlag=function(t,e,i){var n=this._hasListenerCache;if(n&&!e.has(t)){var r=i?2:4;n[t]&=~r,0===n[t]&&delete n[t]}},a._resetFlagForTarget=function(t,e,i){var n=this._hasListenerCache;if(n){var r=i?2:4;for(var s in n)e.has(s)||(n[s]&=~r,0===n[s]&&delete n[s])}},a.hasEventListener=function(t,e){var i=this._hasListenerCache;if(!i)return!1;var n=e?2:4;return(i[t]&n)>0},a.on=function(t,e,i,n){"boolean"==typeof i?(n=i,i=void 0):n=!!n;if(e){var s=null;return(s=n?this._capturingListeners=this._capturingListeners||new r:this._bubblingListeners=this._bubblingListeners||new r).has(t,e,i)||(s.add(t,e,i),i&&i.__eventTargets&&i.__eventTargets.push(this),this._addEventFlag(t,s,n)),e}cc.errorID(6800)},a.off=function(t,e,i,n){if("boolean"==typeof i?(n=i,i=void 0):n=!!n,e){var r=n?this._capturingListeners:this._bubblingListeners;r&&(r.remove(t,e,i),i&&i.__eventTargets&&s(i.__eventTargets,this),this._purgeEventFlag(t,r,n))}else this._capturingListeners&&this._capturingListeners.removeAll(t),this._bubblingListeners&&this._bubblingListeners.removeAll(t),this._hasListenerCache&&delete this._hasListenerCache[t]},a.targetOff=function(t){this._capturingListeners&&(this._capturingListeners.removeAll(t),this._resetFlagForTarget(t,this._capturingListeners,!0)),this._bubblingListeners&&(this._bubblingListeners.removeAll(t),this._resetFlagForTarget(t,this._bubblingListeners,!1))},a.once=function(t,e,i,n){var r="__ONCE_FLAG:"+t,s=n?this._capturingListeners:this._bubblingListeners;if(!(s&&s.has(r,e,i))){var o=this,a=function(c){o.off(t,a,i,n),s.remove(r,e,i),e.call(this,c)};this.on(t,a,i,n),s||(s=n?this._capturingListeners:this._bubblingListeners),s.add(r,e,i)}},a.dispatchEvent=function(t){(function(t,e){var i,n;for(e.target=t,o.length=0,t._getCapturingTargets(e.type,o),e.eventPhase=1,n=o.length-1;n>=0;--n)if((i=o[n])._isTargetActive(e.type)&&i._capturingListeners&&(e.currentTarget=i,i._capturingListeners.invoke(e,o),e._propagationStopped))return void(o.length=0);if(o.length=0,t._isTargetActive(e.type)&&(e.eventPhase=2,e.currentTarget=t,t._capturingListeners&&t._capturingListeners.invoke(e),!e._propagationImmediateStopped&&t._bubblingListeners&&t._bubblingListeners.invoke(e)),!e._propagationStopped&&e.bubbles)for(t._getBubblingTargets(e.type,o),e.eventPhase=3,n=0;n<o.length;++n)if((i=o[n])._isTargetActive(e.type)&&i._bubblingListeners&&(e.currentTarget=i,i._bubblingListeners.invoke(e),e._propagationStopped))return void(o.length=0);o.length=0})(this,t),o.length=0},a.emit=function(t,e){var i=this._hasListenerCache;if(i){var n=i[t];if(n){var r=cc.Event.EventCustom.get(t);r.detail=e,r.eventPhase=2,r.target=r.currentTarget=this;var s=this._capturingListeners;s&&2&n&&s.invoke(r);var o=this._bubblingListeners;o&&4&n&&!r._propagationImmediateStopped&&o.invoke(r),cc.Event.EventCustom.put(r)}}},a._isTargetActive=function(t){return!0},a._getCapturingTargets=function(t,e){},a._getBubblingTargets=function(t,e){},n.prototype._EventTargetOn=n.prototype.on,n.prototype._EventTargetOnce=n.prototype.once,n.prototype._EventTargetOff=n.prototype.off,n.prototype._EventTargetTargetOff=n.prototype.targetOff,cc.EventTarget=e.exports=n}),{"./event":113,"./event-listeners":111}],113:[(function(t,e,i){var n=t("../platform/js");cc.Event=function(t,e){this.type=t,this.bubbles=!!e,this.target=null,this.currentTarget=null,this.eventPhase=0,this._propagationStopped=!1,this._propagationImmediateStopped=!1},cc.Event.prototype={constructor:cc.Event,unuse:function(){this.type=cc.Event.NO_TYPE,this.target=null,this.currentTarget=null,this.eventPhase=cc.Event.NONE,this._propagationStopped=!1,this._propagationImmediateStopped=!1},reuse:function(t,e){this.type=t,this.bubbles=e||!1},stopPropagation:function(){this._propagationStopped=!0},stopPropagationImmediate:function(){this._propagationImmediateStopped=!0},isStopped:function(){return this._propagationStopped||this._propagationImmediateStopped},getCurrentTarget:function(){return this.currentTarget},getType:function(){return this.type}},cc.Event.NO_TYPE="no_type",cc.Event.TOUCH="touch",cc.Event.MOUSE="mouse",cc.Event.KEYBOARD="keyboard",cc.Event.ACCELERATION="acceleration",cc.Event.NONE=0,cc.Event.CAPTURING_PHASE=1,cc.Event.AT_TARGET=2,cc.Event.BUBBLING_PHASE=3;var r=function(t,e){cc.Event.call(this,t,e),this.detail=null};n.extend(r,cc.Event),r.prototype.reset=r,r.prototype.setUserData=function(t){this.detail=t},r.prototype.getUserData=function(){return this.detail},r.prototype.getEventName=cc.Event.prototype.getType;var s=new n.Pool(10);r.put=function(t){s.put(t)},r.get=function(t,e){var i=s._get();return i?i.reset(t,e):i=new r(t,e),i},cc.Event.EventCustom=r,e.exports=cc.Event}),{"../platform/js":197}],114:[(function(t,e,i){t("./event"),t("./event-listeners"),t("./event-target"),t("./system-event")}),{"./event":113,"./event-listeners":111,"./event-target":112,"./system-event":115}],115:[(function(t,e,i){var n,r=t("../event/event-target"),s=t("../event-manager");n=t("../platform/CCInputManager");var o=cc.Enum({KEY_DOWN:"keydown",KEY_UP:"keyup",DEVICEMOTION:"devicemotion"}),a=null,c=null,h=0,l=cc.Class({name:"SystemEvent",extends:r,statics:{EventType:o},setAccelerometerEnabled:function(t){n.setAccelerometerEnabled(t)},setAccelerometerInterval:function(t){n.setAccelerometerInterval(t)},on:function(t,e,i,n){if(this._super(t,e,i,n),(t===o.KEY_DOWN||t===o.KEY_UP)&&(a||(a=cc.EventListener.create({event:cc.EventListener.KEYBOARD,onKeyPressed:function(t,e){e.type=o.KEY_DOWN,cc.systemEvent.dispatchEvent(e)},onKeyReleased:function(t,e){e.type=o.KEY_UP,cc.systemEvent.dispatchEvent(e)}})),!s.hasEventListener(cc._EventListenerKeyboard.LISTENER_ID))){var r=cc.director.getTotalFrames();r!==h&&(s.addListener(a,1),h=r)}t===o.DEVICEMOTION&&(c||(c=cc.EventListener.create({event:cc.EventListener.ACCELERATION,callback:function(t,e){e.type=o.DEVICEMOTION,cc.systemEvent.dispatchEvent(e)}})),s.hasEventListener(cc._EventListenerAcceleration.LISTENER_ID)||s.addListener(c,1))},off:function(t,e,i,n){if(this._super(t,e,i,n),a&&(t===o.KEY_DOWN||t===o.KEY_UP)){var r=this.hasEventListener(o.KEY_DOWN),h=this.hasEventListener(o.KEY_UP);r||h||s.removeListener(a)}c&&t===o.DEVICEMOTION&&s.removeListener(c)}});cc.SystemEvent=e.exports=l,cc.systemEvent=new cc.SystemEvent}),{"../event-manager":110,"../event/event-target":112,"../platform/CCInputManager":180}],116:[(function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n=e&&e.length,c=n?e[0]*i:t.length,l=r(t,0,c,i,!0),u=[];if(!l)return u;var _,p,m,g,y,v,x;if(n&&(l=(function(t,e,i,n){var o,c,l,u,_,p=[];for(o=0,c=e.length;o<c;o++)l=e[o]*n,u=o<c-1?e[o+1]*n:t.length,(_=r(t,l,u,n,!1))===_.next&&(_.steiner=!0),p.push(function(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}(_));for(p.sort(a),o=0;o<p.length;o++)(function(t,e){if(e=(function(t,e){var i,n=e,r=t.x,s=t.y,o=-1/0;do{if(s<=n.y&&s>=n.next.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o){if(o=a,a===r){if(s===n.y)return n;if(s===n.next.y)return n.next}i=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!i)return null;if(r===o)return i.prev;var c,l=i,u=i.x,_=i.y,f=1/0;for(n=i.next;n!==l;)r>=n.x&&n.x>=u&&h(s<_?r:o,s,u,_,s<_?o:r,s,n.x,n.y)&&((c=Math.abs(s-n.y)/(r-n.x))<f||c===f&&n.x>i.x)&&d(n,t)&&(i=n,f=c),n=n.next;return i})(t,e)){var i=f(e,t);s(i,i.next)}})(p[o],i),i=s(i,i.next);return i})(t,e,l,i)),t.length>80*i){_=m=t[0],p=g=t[1];for(var C=i;C<c;C+=i)y=t[C],v=t[C+1],y<_&&(_=y),v<p&&(p=v),y>m&&(m=y),v>g&&(g=v);x=Math.max(m-_,g-p)}return o(l,u,i,_,p,x),u}function r(t,e,i,n,r){var s,o;if(r===y(t,e,i,n)>0)for(s=e;s<i;s+=n)o=p(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=p(s,t[s],t[s+1],o);return o&&u(o,o.next)&&(m(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!u(n,n.next)&&0!==l(n.prev,n,n.next))n=n.next;else{if(m(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,r,a,p){if(t){!p&&a&&(function(t,e,i,n){var r=t;do{null===r.z&&(r.z=c(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,(function(t){var e,i,n,r,s,o,a,c,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<h&&(a++,n=n.nextZ);e++);for(c=h;a>0||c>0&&n;)0===a?(r=n,n=n.nextZ,c--):0!==c&&n?i.z<=n.z?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,c--):(r=i,i=i.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,h*=2}while(o>1)})(r)})(t,n,r,a);for(var g,y,v=t;t.prev!==t.next;)if(g=t.prev,y=t.next,a?(function(t,e,i,n){var r=t.prev,s=t,o=t.next;if(l(r,s,o)>=0)return!1;var a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,u=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,_=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,d=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,f=c(a,u,e,i,n),p=c(_,d,e,i,n),m=t.nextZ;for(;m&&m.z<=p;){if(m!==t.prev&&m!==t.next&&h(r.x,r.y,s.x,s.y,o.x,o.y,m.x,m.y)&&l(m.prev,m,m.next)>=0)return!1;m=m.nextZ}m=t.prevZ;for(;m&&m.z>=f;){if(m!==t.prev&&m!==t.next&&h(r.x,r.y,s.x,s.y,o.x,o.y,m.x,m.y)&&l(m.prev,m,m.next)>=0)return!1;m=m.prevZ}return!0})(t,n,r,a):(function(t){var e=t.prev,i=t,n=t.next;if(l(e,i,n)>=0)return!1;var r=t.next.next;for(;r!==t.prev;){if(h(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&l(r.prev,r,r.next)>=0)return!1;r=r.next}return!0})(t))e.push(g.i/i),e.push(t.i/i),e.push(y.i/i),m(t),t=y.next,v=y.next;else if((t=y)===v){p?1===p?o(t=(function(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!u(r,s)&&_(r,n,n.next,s)&&d(r,s)&&d(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),m(n),m(n.next),n=t=s),n=n.next}while(n!==t);return n})(t,e,i),e,i,n,r,a,2):2===p&&(function(t,e,i,n,r,a){var c=t;do{for(var h=c.next.next;h!==c.prev;){if(c.i!==h.i&&(function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!(function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&_(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1})(t,e)&&d(t,e)&&d(e,t)&&(function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n})(t,e)})(c,h)){var l=f(c,h);return c=s(c,c.next),l=s(l,l.next),o(c,e,i,n,r,a),void o(l,e,i,n,r,a)}h=h.next}c=c.next}while(c!==t)})(t,e,i,n,r,a):o(s(t),e,i,n,r,a,1);break}}}function a(t,e){return t.x-e.x}function c(t,e,i,n,r){return t=32767*(t-i)/r,e=32767*(e-n)/r,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function h(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function l(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function u(t,e){return t.x===e.x&&t.y===e.y}function _(t,e,i,n){return!!(u(t,e)&&u(i,n)||u(t,n)&&u(i,e))||l(t,e,i)>0!=l(t,e,n)>0&&l(i,n,t)>0!=l(i,n,e)>0}function d(t,e){return l(t.prev,t,t.next)<0?l(t,e,t.next)>=0&&l(t,t.prev,e)>=0:l(t,e,t.prev)<0||l(t,t.next,e)<0}function f(t,e){var i=new g(t.i,t.x,t.y),n=new g(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function p(t,e,i,n){var r=new g(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function m(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function g(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function y(t,e,i,n){for(var r=0,s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}e.exports=n,n.deviation=function(t,e,i,n){var r=e&&e.length,s=r?e[0]*i:t.length,o=Math.abs(y(t,0,s,i));if(r)for(var a=0,c=e.length;a<c;a++){var h=e[a]*i,l=a<c-1?e[a+1]*i:t.length;o-=Math.abs(y(t,h,l,i))}var u=0;for(a=0;a<n.length;a+=3){var _=n[a]*i,d=n[a+1]*i,f=n[a+2]*i;u+=Math.abs((t[_]-t[f])*(t[d+1]-t[_+1])-(t[_]-t[d])*(t[f+1]-t[_+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},n.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,r=0;r<t.length;r++){for(var s=0;s<t[r].length;s++)for(var o=0;o<e;o++)i.vertices.push(t[r][s][o]);r>0&&(n+=t[r-1].length,i.holes.push(n))}return i}}),{}],117:[(function(t,e,i){cc.js;var n=t("./types").LineCap,r=t("./types").LineJoin,s=t("./helper"),o=function(t){this._rootCtor(t),this._needDraw=!0,this.cmds=[],this.style={strokeStyle:"black",fillStyle:"white",lineCap:"butt",lineJoin:"miter",miterLimit:10}},a=o.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);a.constructor=o,a._updateCurrentRegions=function(){var t=this._currentRegion;this._currentRegion=this._oldRegion,this._oldRegion=t,this._currentRegion.setTo(0,0,cc.visibleRect.width,cc.visibleRect.height)},a.rendering=function(t,e,i){var n=t||cc._renderContext,r=n.getContext();n.setTransform(this._worldTransform,e,i),r.save(),r.scale(1,-1);var s=this.style;r.strokeStyle=s.strokeStyle,r.fillStyle=s.fillStyle,r.lineWidth=s.lineWidth,r.lineJoin=s.lineJoin,r.miterLimit=s.miterLimit;for(var o=!0,a=this.cmds,c=0,h=a.length;c<h;c++){var l=a[c],u=l[0],_=l[1];"moveTo"===u&&o?(r.beginPath(),o=!1):"fill"!==u&&"stroke"!==u&&"fillRect"!==u||(o=!0),"function"==typeof r[u]?r[u].apply(r,_):r[u]=_}r.restore()},a.setStrokeColor=function(t){var e="rgba("+(0|t.r)+","+(0|t.g)+","+(0|t.b)+","+t.a/255+")";this.cmds.push(["strokeStyle",e]),this.style.strokeStyle=e},a.setFillColor=function(t){var e="rgba("+(0|t.r)+","+(0|t.g)+","+(0|t.b)+","+t.a/255+")";this.cmds.push(["fillStyle",e]),this.style.fillStyle=e},a.setLineWidth=function(t){this.cmds.push(["lineWidth",t]),this.style.lineWidth=t},a.setLineCap=function(t){var e="butt";t===n.BUTT?e="butt":t===n.ROUND?e="round":t===n.SQUARE&&(e="square"),this.cmds.push(["lineCap",e]),this.style.lineCap=e},a.setLineJoin=function(t){var e="bevel";t===r.BEVEL?e="bevel":t===r.ROUND?e="round":t===r.MITER&&(e="miter"),this.cmds.push(["lineJoin",e]),this.style.lineJoin=e},a.setMiterLimit=function(t){this.cmds.push(["miterLimit",t]),this.style.miterLimit=t},a.beginPath=function(){},a.moveTo=function(t,e){this.cmds.push(["moveTo",[t,e]])},a.lineTo=function(t,e){this.cmds.push(["lineTo",[t,e]])},a.bezierCurveTo=function(t,e,i,n,r,s){this.cmds.push(["bezierCurveTo",[t,e,i,n,r,s]])},a.quadraticCurveTo=function(t,e,i,n){this.cmds.push(["quadraticCurveTo",[t,e,i,n]])},a.arc=function(t,e,i,n,r,o){s.arc(this,t,e,i,n,r,o)},a.ellipse=function(t,e,i,n){s.ellipse(this,t,e,i,n)},a.circle=function(t,e,i){s.ellipse(this,t,e,i,i)},a.rect=function(t,e,i,n){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+n),this.lineTo(t,e+n),this.close()},a.roundRect=function(t,e,i,n,r){s.roundRect(this,t,e,i,n,r)},a.fillRect=function(t,e,i,n){this.cmds.push(["fillRect",[t,e,i,n]]),this.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},a.close=function(){this.cmds.push(["closePath",[]])},a.stroke=function(){this.cmds.push(["stroke",[]]),this.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},a.fill=function(){this.cmds.push(["fill",[]]),this.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},a.clear=function(){this.cmds.length=0,this.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},e.exports=o}),{"./helper":121,"./types":123}],118:[(function(t,e,i){var n=t("./graphics-canvas-cmd"),r=t("./graphics-webgl-cmd"),s=t("./types").LineCap,o=t("./types").LineJoin,a=(cc.js,_ccsg.Node.extend({ctor:function(){this._super(),this.strokeColor=cc.Color.BLACK,this.fillColor=cc.Color.WHITE},clear:function(t){this._renderCmd.clear(t)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new n(this):new r(this)}})),c=a.prototype;c._strokeColor=null,c._fillColor=null,c._lineWidth=1,c._lineCap=s.BUTT,c._lineJoin=o.MITER,c._miterLimit=10,c.setStrokeColor=function(t){this._strokeColor=t,this._renderCmd.setStrokeColor(t)},c.getStrokeColor=function(){return this._strokeColor},c.setFillColor=function(t){this._fillColor=t,this._renderCmd.setFillColor(t)},c.getFillColor=function(){return this._fillColor},c.setLineWidth=function(t){this._lineWidth=t,this._renderCmd.setLineWidth(t)},c.getLineWidth=function(){return this._lineWidth},c.setLineCap=function(t){this._lineCap=t,this._renderCmd.setLineCap(t)},c.getLineCap=function(){return this._lineCap},c.setLineJoin=function(t){this._lineJoin=t,this._renderCmd.setLineJoin(t)},c.getLineJoin=function(){return this._lineJoin},c.setMiterLimit=function(t){this._miterLimit=t,this._renderCmd.setMiterLimit(t)},c.getMiterLimit=function(){return this._miterLimit},c.beginPath=function(){this._renderCmd.beginPath()},c.moveTo=function(t,e){this._renderCmd.moveTo(t,e)},c.lineTo=function(t,e){this._renderCmd.lineTo(t,e)},c.bezierCurveTo=function(t,e,i,n,r,s){this._renderCmd.bezierCurveTo(t,e,i,n,r,s)},c.quadraticCurveTo=function(t,e,i,n){this._renderCmd.quadraticCurveTo(t,e,i,n)},c.arc=function(t,e,i,n,r,s){this._renderCmd.arc(t,e,i,n,r,s)},c.ellipse=function(t,e,i,n){this._renderCmd.ellipse(t,e,i,n)},c.circle=function(t,e,i){this._renderCmd.circle(t,e,i)},c.rect=function(t,e,i,n){this._renderCmd.rect(t,e,i,n)},c.roundRect=function(t,e,i,n,r){this._renderCmd.roundRect(t,e,i,n,r)},c.fillRect=function(t,e,i,n){this._renderCmd.fillRect(t,e,i,n)},c.close=function(){this._renderCmd.close()},c.stroke=function(){this._renderCmd.stroke()},c.fill=function(){this._renderCmd.fill()},e.exports=a}),{"./graphics-canvas-cmd":117,"./graphics-webgl-cmd":119,"./types":123}],119:[(function(t,e,i){function n(t,e,i){return t<e?e:t>i?i:t}function r(t,e){_.call(this,t,e),this.reset()}function s(){this.reset()}function o(){this.vertsOffset=0,this.vertsVBO=gl.createBuffer(),this.vertsBuffer=null,this.uint32VertsBuffer=null,this.vertsDirty=!1,this.indicesOffset=0,this.indicesVBO=gl.createBuffer(),this.indicesBuffer=null,this.indicesDirty=!1}function a(t){this._rootCtor(t),this._needDraw=!0;cc._renderContext;this._buffers=[],this._buffer=null,this._allocBuffer(),this._matrix=new cc.math.Matrix4,this._matrix.identity(),this._paths=[],this._points=[],this._curColorValue=0,this._blendFunc=new cc.BlendFunc(cc.macro.BLEND_SRC,cc.macro.BLEND_DST);var e=new cc.GLProgram;e.initWithVertexShaderByteArray(cc.PresetShaders.POSITION_COLOR_VERT,cc.PresetShaders.POSITION_COLOR_FRAG),e.retain(),e.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION,cc.macro.VERTEX_ATTRIB_POSITION),e.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR,cc.macro.VERTEX_ATTRIB_COLOR),e.link(),e.updateUniforms(),this._shaderProgram=e,this._allocVerts(f)}var c=t("./types").LineCap,h=t("./types").LineJoin,l=t("./earcut"),u=t("./helper"),_=cc.Vec2,d=cc.js,f=32,p=Math.PI,m=Math.min,g=Math.max,y=Math.ceil,v=Math.acos,x=Math.cos,C=Math.sin,T=Math.atan2,b=Math.abs,A=cc.Enum({PT_CORNER:1,PT_LEFT:2,PT_BEVEL:4,PT_INNERBEVEL:8});d.extend(r,_),r.prototype.reset=function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0},s.prototype.reset=function(){this.closed=!1,this.nbevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]},o.prototype.clear=function(){this.vertsOffset=0,this.indicesOffset=0},o.prototype.alloc=function(t,e){var i=this.vertsOffset+t;if(i>65535)return!1;var n=this.vertsBuffer,r=n?n.length/3:0;if(i>r){for(0===r&&(r=f);i>r;)r*=2;var s=new Float32Array(3*r),o=new Uint32Array(s.buffer);if(n)for(var a=this.uint32VertsBuffer,c=0,h=n.length;c<h;c+=3)s[c]=n[c],s[c+1]=n[c+1],o[c+2]=a[c+2];this.vertsBuffer=s,this.uint32VertsBuffer=o}var l=this.indicesBuffer,u=this.indicesOffset+e,_=l?l.length:0;if(u>_){for(0===_&&(_=3*f);u>_;)_*=2;var d=new Uint16Array(_);if(l)for(c=0,h=l.length;c<h;c++)d[c]=l[c];this.indicesBuffer=d}return!0},(a.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype)).constructor=a;var S=a.prototype;S._tessTol=.25,S._distTol=.01,S.lineWidth=1,S.lineCap=c.BUTT,S.lineJoin=h.MITER,S.miterLimit=10,S.beginPath=function(){this._pathOffset=this._pathLength},S.moveTo=function(t,e){this._updatePathOffset&&(this._pathOffset=this._pathLength,this._updatePathOffset=!1),this._addPath(),this._addPoint(t,e,A.PT_CORNER),this._commandx=t,this._commandy=e},S.lineTo=function(t,e){this._addPoint(t,e,A.PT_CORNER),this._commandx=t,this._commandy=e},S.bezierCurveTo=function(t,e,i,n,r,s){var o=this._curPath,a=o.points[o.points.length-1];a.x!==t||a.y!==e||i!==r||n!==s?(this._tesselateBezier(a.x,a.y,t,e,i,n,r,s,0,A.PT_CORNER),this._commandx=r,this._commandy=s):this.lineTo(r,s)},S.quadraticCurveTo=function(t,e,i,n){var r=this._commandx,s=this._commandy;this.bezierCurveTo(r+2/3*(t-r),s+2/3*(e-s),i+2/3*(t-i),n+2/3*(e-n),i,n)},S.arc=function(t,e,i,n,r,s){u.arc(this,t,e,i,n,r,s)},S.ellipse=function(t,e,i,n){u.ellipse(this,t,e,i,n),this._curPath.complex=!1},S.circle=function(t,e,i){u.ellipse(this,t,e,i,i),this._curPath.complex=!1},S.rect=function(t,e,i,n){this.moveTo(t,e),this.lineTo(t,e+n),this.lineTo(t+i,e+n),this.lineTo(t+i,e),this.close(),this._curPath.complex=!1},S.roundRect=function(t,e,i,n,r){u.roundRect(this,t,e,i,n,r),this._curPath.complex=!1},S.fillRect=function(t,e,i,n){this.rect(t,e,i,n),this.fill()},S.close=function(){this._curPath.closed=!0},S.stroke=function(){this._flattenPaths();var t=this._strokeColor;this._curColorValue=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,this._expandStroke(),this._updatePathOffset=!0},S.fill=function(){var t=this._fillColor;this._curColorValue=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,this._expandFill(),this._updatePathOffset=!0,this._filling=!1},S._strokeColor=null,S._fillColor=null,S.setStrokeColor=function(t){this._strokeColor=t},S.getStrokeColor=function(){return this._strokeColor},S.setFillColor=function(t){this._fillColor=t},S.getFillColor=function(){return this._fillColor},S.setLineWidth=function(t){this.lineWidth=t},S.setLineJoin=function(t){this.lineJoin=t},S.setLineCap=function(t){this.lineCap=t},S.setMiterLimit=function(t){this.miterLimit=t},d.getset(S,"strokeColor",S.getStrokeColor,S.setStrokeColor),d.getset(S,"fillColor",S.getFillColor,S.setFillColor),S._render=function(){var t=this._buffers;if(0!==t.length){for(var e=cc._renderContext,i=0,n=t.length;i<n;i++){var r=t[i];e.bindBuffer(e.ARRAY_BUFFER,r.vertsVBO),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.indicesVBO),r.vertsDirty&&(e.bufferData(e.ARRAY_BUFFER,r.vertsBuffer,e.STREAM_DRAW),r.vertsDirty=!1),r.indicesDirty&&r.indicesBuffer&&(e.bufferData(e.ELEMENT_ARRAY_BUFFER,r.indicesBuffer,e.STREAM_DRAW),r.indicesDirty=!1),e.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION),e.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_COLOR),e.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION,2,e.FLOAT,!1,12,0),e.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR,4,e.UNSIGNED_BYTE,!0,12,8),e.drawElements(e.TRIANGLES,r.indicesOffset,e.UNSIGNED_SHORT,0),cc.g_NumberOfDraws++}0}},S.rendering=function(){cc.gl.blendFunc(this._blendFunc.src,this._blendFunc.dst);var t=this._worldTransform,e=this._matrix.mat;e[0]=t.a,e[4]=t.c,e[12]=t.tx,e[1]=t.b,e[5]=t.d,e[13]=t.ty;var i=this._shaderProgram;i.use(),i._setUniformForMVPMatrixWithMat4(this._matrix),this._render()},S.clear=function(t){if(this._pathLength=0,this._pathOffset=0,this._pointsOffset=0,this._curPath=null,t)this._paths.length=0,this._points.length=0,this._buffer=null,this._buffers=[];else{for(var e=this._buffers,i=0;i<e.length;i++)e[i].clear();this._buffer=e[0]}},S._updatePathOffset=!1,S._paths=null,S._pathLength=0,S._pathOffset=0,S._points=null,S._pointsOffset=0,S._commandx=0,S._commandy=0,S._addPath=function(){var t=this._pathLength,e=this._paths[t];return e?e.reset():(e=new s,this._paths.push(e)),this._pathLength++,this._curPath=e,e},S._addPoint=function(t,e,i){var n=this._curPath;if(n){var s,o=this._points,a=n.points;(s=o[this._pointsOffset++])?(s.x=t,s.y=e):(s=new r(t,e),o.push(s)),s.flags=i,a.push(s)}},S._flattenPaths=function(){for(var t=this._paths,e=this._pathOffset,i=this._pathLength;e<i;e++){var n=t[e],r=n.points,s=r[r.length-1],o=r[0];s.equals(o)&&(n.closed=!0,r.pop(),s=r[r.length-1]);for(var a=0,c=r.length;a<c;a++){var h=o.sub(s);s.len=h.mag(),(h.x||h.y)&&h.normalizeSelf(),s.dx=h.x,s.dy=h.y,s=o,o=r[a+1]}}},S._allocBuffer=function(){if(this._buffer){var t=this._buffers.indexOf(this._buffer);if(t<this._buffers.length-1)return void(this._buffer=this._buffers[t+1])}var e=new o;this._buffers.push(e),this._buffer=e},S._allocVerts=function(t){this._buffer||this._allocBuffer();var e=3*(t-2*(this._pathLength-this._pathOffset));this._buffer.alloc(t,e)||(this._allocBuffer(),this._buffer.alloc(t,e)),this._buffer.vertsDirty=!0},S._expandStroke=function(){var t=.5*this.lineWidth,e=this.lineCap,i=this.lineJoin,n=this.miterLimit,r=this._curveDivs(t,p,this._tessTol),s=this._paths;this._calculateJoins(t,i,n);for(var o=0,a=this._pathOffset,l=this._pathLength;a<l;a++){var u=(d=s[a]).points.length;i===h.ROUND?o+=2*(u+d.nbevel*(r+2)+1):o+=2*(u+5*d.nbevel+1),d.closed||(e===c.ROUND?o+=2*(2*r+2):o+=12)}this._allocVerts(o);var _=this._buffer;for(a=this._pathOffset,l=this._pathLength;a<l;a++){var d,f,m,g,y,v,x=(d=s[a]).points;u=d.points.length;v=d.closed;var C=_.vertsOffset;if(v?(f=x[u-1],m=x[0],g=0,y=u):(f=x[0],m=x[1],g=1,y=u-1),!v){(E=m.sub(f)).normalizeSelf();var T=E.x,b=E.y;e===c.BUTT?this._buttCap(f,T,b,t,0):e===c.SQUARE?this._buttCap(f,T,b,t,t):e===c.ROUND&&this._roundCapStart(f,T,b,t,r)}for(var S=g;S<y;++S)i===h.ROUND?this._roundJoin(f,m,t,t,r):0!=(m.flags&(A.PT_BEVEL|A.PT_INNERBEVEL))?this._bevelJoin(f,m,t,t):(this._vset(m.x+m.dmx*t,m.y+m.dmy*t),this._vset(m.x-m.dmx*t,m.y-m.dmy*t)),f=m,m=x[S+1];if(v){var w=_.vertsBuffer;this._vset(w[3*C],w[3*C+1]),this._vset(w[3*(C+1)],w[3*(C+1)+1])}else{var E;(E=m.sub(f)).normalizeSelf();T=E.x,b=E.y;e===c.BUTT?this._buttCap(m,T,b,t,0):e===c.BUTT||e===c.SQUARE?this._buttCap(m,T,b,t,t):e===c.ROUND&&this._roundCapEnd(m,T,b,t,r)}for(var I=_.indicesOffset,R=_.indicesBuffer,P=C+2,O=_.vertsOffset;P<O;P++)R[I++]=P-2,R[I++]=P-1,R[I++]=P;_.indicesOffset=I,_.indicesDirty=!0}},S._expandFill=function(){for(var t=this._paths,e=0,i=this._pathOffset,n=this._pathLength;i<n;i++){e+=o=(s=t[i]).points.length}this._allocVerts(e);var r=this._buffer;for(i=this._pathOffset,n=this._pathLength;i<n;i++){var s,o,a=(s=t[i]).points;if(0!==(o=a.length)){for(var c=r.vertsOffset,h=0;h<o;++h)this._vset(a[h].x,a[h].y,.5,1);var u=s.indicesOffset=r.indicesOffset,_=r.indicesBuffer,d=0;if(s.complex){var f=[],p=3*c,m=3*r.vertsOffset;for(h=p;h<m;h+=3)f.push(r.vertsBuffer[h]),f.push(r.vertsBuffer[h+1]);var g=l(f,null,2);if(!g||0===g.length)continue;h=0;for(var y=d=g.length;h<y;h++)_[u+h]=g[h]+c}else{var v=c;for(p=c+2,m=r.vertsOffset;p<m;p++)_[u++]=v,_[u++]=p-1,_[u++]=p;d=u-r.indicesOffset}r.indicesOffset+=d,r.indicesDirty=!0}}},S._curveDivs=function(t,e,i){var n=2*v(t/(t+i));return g(2,y(e/n))},S._calculateJoins=function(t,e,i){var n=0;t>0&&(n=1/t);for(var r=this._paths,s=this._pathOffset,o=this._pathLength;s<o;s++){var a=r[s],c=a.points,l=c.length,u=c[l-1],_=c[0];a.nbevel=0;for(var d=0;d<l;d++){var f,p,y=u.dy,v=-u.dx,x=_.dy,C=-_.dx;if(_.dmx=.5*(y+x),_.dmy=.5*(v+C),(f=_.dmx*_.dmx+_.dmy*_.dmy)>1e-6){var T=1/f;T>600&&(T=600),_.dmx*=T,_.dmy*=T}_.dx*u.dy-u.dx*_.dy>0&&(0,_.flags|=A.PT_LEFT),f*(p=g(11,m(u.len,_.len)*n))*p<1&&(_.flags|=A.PT_INNERBEVEL),_.flags&A.PT_CORNER&&(f*i*i<1||e===h.BEVEL||e===h.ROUND)&&(_.flags|=A.PT_BEVEL),0!=(_.flags&(A.PT_BEVEL|A.PT_INNERBEVEL))&&a.nbevel++,u=_,_=c[d+1]}}},S._vset=function(t,e){var i=this._buffer,n=3*i.vertsOffset,r=i.vertsBuffer;r[n]=t,r[n+1]=e,i.uint32VertsBuffer[n+2]=this._curColorValue,i.vertsOffset++},S._chooseBevel=function(t,e,i,n){var r,s,o,a,c=i.x,h=i.y;return 0!==t?(r=c+e.dy*n,s=h-e.dx*n,o=c+i.dy*n,a=h-i.dx*n):(r=o=c+i.dmx*n,s=a=h+i.dmy*n),[r,s,o,a]},S._buttCap=function(t,e,i,n,r){var s=t.x-e*r,o=t.y-i*r,a=i,c=-e;this._vset(s+a*n,o+c*n),this._vset(s-a*n,o-c*n)},S._roundCapStart=function(t,e,i,n,r){for(var s=t.x,o=t.y,a=i,c=-e,h=0;h<r;h++){var l=h/(r-1)*p,u=x(l)*n,_=C(l)*n;this._vset(s-a*u-e*_,o-c*u-i*_),this._vset(s,o)}this._vset(s+a*n,o+c*n),this._vset(s-a*n,o-c*n)},S._roundCapEnd=function(t,e,i,n,r){var s=t.x,o=t.y,a=i,c=-e;this._vset(s+a*n,o+c*n),this._vset(s-a*n,o-c*n);for(var h=0;h<r;h++){var l=h/(r-1)*p,u=x(l)*n,_=C(l)*n;this._vset(s,o),this._vset(s-a*u+e*_,o-c*u+i*_)}},S._roundJoin=function(t,e,i,r,s){var o=t.dy,a=-t.dx,c=e.dy,h=-e.dx,l=e.x,u=e.y;if(0!=(e.flags&A.PT_LEFT)){var _=(E=this._chooseBevel(e.flags&A.PT_INNERBEVEL,t,e,i))[0],d=E[1],f=E[2],m=E[3],g=T(-a,-o);(I=T(-h,-c))>g&&(I-=2*p),this._vset(_,d),this._vset(l-o*r,e.y-a*r);for(var v=n(y((g-I)/p)*s,2,s),b=0;b<v;b++){var S=l+x(D=g+b/(v-1)*(I-g))*r,w=u+C(D)*r;this._vset(l,u),this._vset(S,w)}this._vset(f,m),this._vset(l-c*r,u-h*r)}else{var E,I,R=(E=this._chooseBevel(e.flags&A.PT_INNERBEVEL,t,e,-r))[0],P=E[1],O=E[2],B=E[3];g=T(a,o);(I=T(h,c))<g&&(I+=2*p),this._vset(l+o*r,u+a*r),this._vset(R,P);for(v=n(y((I-g)/p)*s,2,s),b=0;b<v;b++){var D,M=l+x(D=g+b/(v-1)*(I-g))*i,L=u+C(D)*i;this._vset(M,L),this._vset(l,u)}this._vset(l+c*r,u+h*r),this._vset(O,B)}},S._bevelJoin=function(t,e,i,n){var r,s,o,a,c,h,l,u,_=t.dy,d=-t.dx,f=e.dy,p=-e.dx;if(e.flags&A.PT_LEFT){c=(m=this._chooseBevel(e.flags&A.PT_INNERBEVEL,t,e,i))[0],h=m[1],l=m[2],u=m[3],this._vset(c,h),this._vset(e.x-_*n,e.y-d*n),this._vset(l,u),this._vset(e.x-f*n,e.y-p*n)}else{var m;r=(m=this._chooseBevel(e.flags&A.PT_INNERBEVEL,t,e,-n))[0],s=m[1],o=m[2],a=m[3],this._vset(e.x+_*i,e.y+d*i),this._vset(r,s),this._vset(e.x+f*i,e.y+p*i),this._vset(o,a)}},S._tesselateBezier=function(t,e,i,n,r,s,o,a,c,h){var l,u,_,d,f,p,m,g,y,v,x,C,T,S,w,E;c>10||(f=.5*(r+o),p=.5*(s+a),m=.5*((l=.5*(t+i))+(_=.5*(i+r))),g=.5*((u=.5*(e+n))+(d=.5*(n+s))),((w=b((i-o)*(S=a-e)-(n-a)*(T=o-t)))+(E=b((r-o)*S-(s-a)*T)))*(w+E)<this._tessTol*(T*T+S*S)?this._addPoint(o,a,0===h?h|A.PT_BEVEL:h):(x=.5*(m+(y=.5*(_+f))),C=.5*(g+(v=.5*(d+p))),this._tesselateBezier(t,e,l,u,m,g,x,C,c+1,0),this._tesselateBezier(x,C,y,v,f,p,o,a,c+1,h)))},e.exports=a}),{"./earcut":116,"./helper":121,"./types":123}],120:[(function(t,e,i){var n=t("./types").LineCap,r=t("./types").LineJoin,s=cc.Class({name:"cc.Graphics",extends:cc._RendererUnderSG,editor:!1,properties:{_lineWidth:1,_strokeColor:cc.Color.BLACK,_lineJoin:r.MITER,_lineCap:n.BUTT,_fillColor:cc.Color.WHITE,_miterLimit:10,lineWidth:{get:function(){return this._lineWidth},set:function(t){this._sgNode.lineWidth=this._lineWidth=t}},lineJoin:{get:function(){return this._lineJoin},set:function(t){this._sgNode.lineJoin=this._lineJoin=t},type:r},lineCap:{get:function(){return this._lineCap},set:function(t){this._sgNode.lineCap=this._lineCap=t},type:n},strokeColor:{get:function(){return this._strokeColor},set:function(t){this._sgNode.strokeColor=this._strokeColor=t}},fillColor:{get:function(){return this._fillColor},set:function(t){this._sgNode.fillColor=this._fillColor=t}},miterLimit:{get:function(){return this._miterLimit},set:function(t){this._sgNode.miterLimit=this._miterLimit=t}}},statics:{LineJoin:r,LineCap:n},_createSgNode:function(){return new _ccsg.GraphicsNode},_initSgNode:function(){var t=this._sgNode;t.lineWidth=this._lineWidth,t.lineJoin=this._lineJoin,t.lineCap=this._lineCap,t.strokeColor=this._strokeColor,t.fillColor=this._fillColor,t.miterLimit=this._miterLimit,t.setContentSize(this.node.getContentSize(!0))},moveTo:function(t,e){this._sgNode.moveTo(t,e)},lineTo:function(t,e){this._sgNode.lineTo(t,e)},bezierCurveTo:function(t,e,i,n,r,s){this._sgNode.bezierCurveTo(t,e,i,n,r,s)},quadraticCurveTo:function(t,e,i,n){this._sgNode.quadraticCurveTo(t,e,i,n)},arc:function(t,e,i,n,r,s){s=s||!1,this._sgNode.arc(t,e,i,n,r,s)},ellipse:function(t,e,i,n){this._sgNode.ellipse(t,e,i,n)},circle:function(t,e,i){this._sgNode.circle(t,e,i)},rect:function(t,e,i,n){this._sgNode.rect(t,e,i,n)},roundRect:function(t,e,i,n,r){this._sgNode.roundRect(t,e,i,n,r)},fillRect:function(t,e,i,n){this._sgNode.fillRect(t,e,i,n)},clear:function(t){this._sgNode.clear(!!t)},close:function(){this._sgNode.close()},stroke:function(){this._sgNode.stroke()},fill:function(){this._sgNode.fill()}});cc.Graphics=e.exports=s}),{"./types":123}],121:[(function(t,e,i){var n=Math.PI,r=Math.min,s=Math.max,o=Math.cos,a=Math.sin,c=Math.abs,h=Math.sign,l=.5522847493;e.exports={arc:function(t,e,i,h,l,u,_){var d,f,p=0,m=0,g=0,y=0,v=0,x=0,C=0,T=0,b=0,A=0,S=0,w=0,E=0,I=0;if(m=u-l,_=_||!1)if(c(m)>=2*n)m=2*n;else for(;m<0;)m+=2*n;else if(c(m)>=2*n)m=2*-n;else for(;m>0;)m-=2*n;for(f=0|s(1,r(c(m)/(.5*n)+.5,5)),y=c(4/3*(1-o(g=m/f/2))/a(g)),_||(y=-y),d=0;d<=f;d++)C=e+(v=o(p=l+m*(d/f)))*h,T=i+(x=a(p))*h,b=-x*h*y,A=v*h*y,0===d?t.moveTo(C,T):t.bezierCurveTo(S+E,w+I,C-b,T-A,C,T),S=C,w=T,E=b,I=A},ellipse:function(t,e,i,n,r){t.moveTo(e-n,i),t.bezierCurveTo(e-n,i+r*l,e-n*l,i+r,e,i+r),t.bezierCurveTo(e+n*l,i+r,e+n,i+r*l,e+n,i),t.bezierCurveTo(e+n,i-r*l,e+n*l,i-r,e,i-r),t.bezierCurveTo(e-n*l,i-r,e-n,i-r*l,e-n,i),t.close()},roundRect:function(t,e,i,n,s,o){if(o<.1)t.rect(e,i,n,s);else{var a=r(o,.5*c(n))*h(n),u=r(o,.5*c(s))*h(s);t.moveTo(e,i+u),t.lineTo(e,i+s-u),t.bezierCurveTo(e,i+s-u*(1-l),e+a*(1-l),i+s,e+a,i+s),t.lineTo(e+n-a,i+s),t.bezierCurveTo(e+n-a*(1-l),i+s,e+n,i+s-u*(1-l),e+n,i+s-u),t.lineTo(e+n,i+u),t.bezierCurveTo(e+n,i+u*(1-l),e+n-a*(1-l),i,e+n-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-l),i,e,i+u*(1-l),e,i+u),t.close()}}}}),{}],122:[(function(t,e,i){"use strict";var n;if(n=_ccsg.GraphicsNode=t("./graphics-node")){t("../utils/misc").propertyDefine(n,["lineWidth","lineCap","lineJoin","miterLimit","strokeColor","fillColor"],{})}t("./graphics")}),{"../utils/misc":226,"./graphics":120,"./graphics-node":118}],123:[(function(t,e,i){"use strict";var n=cc.Enum({BUTT:0,ROUND:1,SQUARE:2}),r=cc.Enum({BEVEL:0,ROUND:1,MITER:2});e.exports={LineCap:n,LineJoin:r}}),{}],124:[(function(t,e,i){t("./platform"),t("./assets"),t("./CCNode"),t("./CCScene"),t("./components"),t("./graphics"),t("./collider"),t("./collider/CCIntersection"),t("./physics"),t("./camera/CCCamera"),t("./base-ui/CCWidgetManager")}),{"./CCNode":40,"./CCScene":41,"./assets":54,"./base-ui/CCWidgetManager":59,"./camera/CCCamera":60,"./collider":69,"./collider/CCIntersection":67,"./components":103,"./graphics":122,"./physics":158,"./platform":194}],125:[(function(t,e,i){var n=/^(click)(\s)*=/,r=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=/;cc.HtmlTextParser=function(){this._parsedObject={},this._specialSymbolArray=[],this._specialSymbolArray.push([/&lt;/g,"<"]),this._specialSymbolArray.push([/&gt;/g,">"]),this._specialSymbolArray.push([/&amp;/g,"&"]),this._specialSymbolArray.push([/&quot;/g,'"']),this._specialSymbolArray.push([/&apos;/g,"'"])},cc.HtmlTextParser.prototype={constructor:cc.HtmlTextParser,parse:function(t){this._resultObjectArray=[],this._stack=[];for(var e=0,i=t.length;e<i;){var n=t.indexOf("<",e);if(n<0)this._stack.pop(),this._processResult(t.substring(e)),e=i;else{this._processResult(t.substring(e,n));var r=t.indexOf(">",e);-1===r?r=n:"/"===t.charAt(n+1)?this._stack.pop():this._addToStack(t.substring(n+1,r)),e=r+1}}return this._resultObjectArray},_attributeToObject:function(t){var e,i,n,s,o={},a=(t=t.trim()).match(/^(color|size)(\s)*=/);if(a){if(e=a[0],""===(t=t.substring(e.length).trim()))return o;switch(i=t.indexOf(" "),e[0]){case"c":o.color=i>-1?t.substring(0,i).trim():t;break;case"s":o.size=parseInt(t)}return i>-1&&(s=t.substring(i+1).trim(),n=this._processEventHandler(s),o.event=n),o}if((a=t.match(/^(br(\s)*\/)/))&&a[0].length>0&&(e=a[0].trim()).startsWith("br")&&"/"===e[e.length-1])return o.isNewLine=!0,this._resultObjectArray.push({text:"",style:{newline:!0}}),o;if((a=t.match(/^(img(\s)*src(\s)*=[^>]+\/)/))&&a[0].length>0&&(e=a[0].trim()).startsWith("img")&&"/"===e[e.length-1]){a=t.match(r);for(var c,h=!1;a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),_=(i=(c=t.substring(e.length).trim()).indexOf(" "))>-1?c.substr(0,i):c,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=c.substring(i).trim(),"src"===e?(o.isImage=!0,_.endsWith("/")&&(_=_.substring(0,_.length-1)),0===_.indexOf("'")?(h=!0,_=_.substring(1,_.length-1)):0===_.indexOf('"')&&(h=!0,_=_.substring(1,_.length-1)),o.src=_):"height"===e?o.imageHeight=parseInt(_):"width"===e?o.imageWidth=parseInt(_):"click"===e&&(o.event=this._processEventHandler(e+"="+_)),a=t.match(r);return h&&o.isImage&&this._resultObjectArray.push({text:"",style:o}),{}}if(a=t.match(/^(outline(\s)*[^>]*)/)){var l={color:"#ffffff",width:1};if(t=a[0].substring("outline".length).trim()){var u=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=/;a=t.match(u);for(var _;a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),_=(i=(c=t.substring(e.length).trim()).indexOf(" "))>-1?c.substr(0,i):c,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=c.substring(i).trim(),"click"===e?o.event=this._processEventHandler(e+"="+_):"color"===e?l.color=_:"width"===e&&(l.width=parseInt(_)),a=t.match(u)}o.outline=l}if((a=t.match(/^(on|u|b|i)(\s)*/))&&a[0].length>0){switch(e=a[0],t=t.substring(e.length).trim(),e[0]){case"u":o.underline=!0;break;case"i":o.italic=!0;break;case"b":o.bold=!0}if(""===t)return o;n=this._processEventHandler(t),o.event=n}return o},_processEventHandler:function(t){for(var e=0,i={},r=t.match(n),s=!1;r;){var o=r[0],a="";if(s=!1,'"'===(t=t.substring(o.length).trim()).charAt(0))(e=t.indexOf('"',1))>-1&&(a=t.substring(1,e).trim(),s=!0),e++;else if("'"===t.charAt(0))(e=t.indexOf("'",1))>-1&&(a=t.substring(1,e).trim(),s=!0),e++;else{var c=t.match(/(\S)+/);e=(a=c?c[0]:"").length}s&&(i[o=o.substring(0,o.length-1).trim()]=a),r=(t=t.substring(e).trim()).match(n)}return i},_addToStack:function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var n in i)e[n]||(e[n]=i[n]);this._stack.push(e)}},_processResult:function(t){""!==t&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},_escapeSpecialSymbol:function(t){for(var e=0;e<this._specialSymbolArray.length;++e){var i=this._specialSymbolArray[e][0],n=this._specialSymbolArray[e][1];t=t.replace(i,n)}return t}},cc.htmlTextParser=new cc.HtmlTextParser}),{}],126:[(function(t,e,i){t("./CCTextUtils");var n=t("../event/event-target"),r=t("../platform/js"),s=function(){this._u=0,this._v=0,this._width=0,this._height=0,this._offsetX=0,this._offsetY=0,this._textureID=0,this._validDefinition=!1,this._xAdvance=0};cc.FontAtlas=function(t){this._lineHeight=t.commonHeight,this._fontSize=t.fontSize,this._letterDefinitions={},this._fntConfig=t},cc.FontAtlas.prototype={constructor:cc.FontAtlas,setFontSize:function(t){this._fontSize=t},getOriginalFontSize:function(){return this._fntConfig.fontSize},addLetterDefinitions:function(t,e){this._letterDefinitions[t]=e},cloneLetterDefinition:function(){var t={};for(var e in this._letterDefinitions){var i=new s;cc.js.mixin(i,this._letterDefinitions[e]),t[e]=i}return t},assignLetterDefinitions:function(t){for(var e in this._letterDefinitions){var i=t[e],n=this._letterDefinitions[e];cc.js.mixin(n,i)}},scaleFontLetterDefinition:function(t){for(var e in this._letterDefinitions){var i=this._letterDefinitions[e];i._width*=t,i._height*=t,i._offsetX*=t,i._offsetY*=t,i._xAdvance*=t}},getLetterDefinitionForChar:function(t){return this._letterDefinitions.hasOwnProperty(t.charCodeAt(0))?this._letterDefinitions[t.charCodeAt(0)]:null}};var o=function(){this._char="",this._valid=!0,this._positionX=0,this._positionY=0,this._lineIndex=0};_ccsg.Label=_ccsg.Node.extend({_hAlign:cc.TextAlignment.LEFT,_vAlign:cc.VerticalTextAlignment.TOP,_string:"",_fontSize:40,_drawFontsize:40,_overFlow:0,_isWrapText:!0,_spacingX:0,_blendFunc:null,_labelType:0,_fontHandle:"",_lineSpacing:0,_maxLineWidth:0,_labelDimensions:cc.size(0,0),_labelWidth:0,_labelHeight:0,_lineHeight:40,_outlined:!1,_outlineColor:null,_outlineWidth:1,_gradientEnabled:!1,_gradientStartColor:cc.color(255,255,255,255),_gradientEndColor:cc.color(255,255,255,255),_gradientDirection:0,_className:"Label",_margin:0,_isBold:!1,_isItalic:!1,_isUnderline:!1,_fontAsset:null,ctor:function(t,e){n.call(this);var i=e instanceof cc.Font,r=i?e.rawUrl:"";this._fontHandle=r,"string"!=typeof t&&(t=""+t),this._string=t,_ccsg.Node.prototype.ctor.call(this),this.setAnchorPoint(.5,.5),_ccsg.Node.prototype.setContentSize.call(this,128,128),this._blendFunc=cc.BlendFunc._alphaNonPremultiplied(),this._imageOffset=cc.p(0,0),this._numberOfLines=0,this._lettersInfo=[],this._linesWidth=[],this._linesOffsetX=[],this._horizontalKernings=[],this._reusedRect=cc.rect(0,0,0,0),i?this.setFontAsset(e):this.setFontFamily(r),this.setString(this._string)},_resetBMFont:function(){this._imageOffset.x=this._imageOffset.y=0,this._cascadeColorEnabled=!0,this._cascadeOpacityEnabled=!0,this._fontAtlas=null,this._config=null,this._numberOfLines=0,this._lettersInfo.length=0,this._linesWidth.length=0,this._linesOffsetX.length=0,this._textDesiredHeight=0,this._letterOffsetY=0,this._tailoredTopY=0,this._tailoredBottomY=0,this._bmfontScale=1,this._horizontalKernings.length=0,this._lineBreakWithoutSpaces=!1,this._reusedRect.x=this._reusedRect.y=this._reusedRect.width=this._reusedRect.height=0,this._textureLoaded=!1,this._spriteBatchNode&&(this.removeChild(this._spriteBatchNode),this._spriteBatchNode=null)},setHorizontalAlign:function(t){this._hAlign!==t&&(this._hAlign=t,this._notifyLabelSkinDirty())},getHorizontalAlign:function(){return this._hAlign},setVerticalAlign:function(t){this._vAlign!==t&&(this._vAlign=t,this._notifyLabelSkinDirty())},getVerticalAlign:function(){return this._vAlign},setString:function(t){"string"!=typeof t&&(t=""+t),this._string!==t&&(this._string=t,this._notifyLabelSkinDirty())},setMargin:function(t){this._margin!==t&&(this._margin=t,this._notifyLabelSkinDirty())},getString:function(){return this._string},getStringLength:function(){return this._string.length},enableWrapText:function(t){this._isWrapText!==t&&this._overFlow!==_ccsg.Label.Overflow.RESIZE_HEIGHT&&this._overFlow!==_ccsg.Label.Overflow.NONE&&(this._isWrapText=t,this._rescaleWithOriginalFontSize(),this._notifyLabelSkinDirty())},enableItalics:function(t){this._isItalic=t,t?this.setSkewX(12):this.setSkewX(0)},enableBold:function(t){this._isBold!==t&&(this._isBold=t,this._notifyLabelSkinDirty())},enableUnderline:function(t){this._isUnderline!==t&&(this._isUnderline=t,this._notifyLabelSkinDirty())},isWrapTextEnabled:function(){return this._isWrapText},getFontName:function(){return this._fontHandle},setFontSize:function(t){this._fontSize!==t&&(this._fontSize=t,this._drawFontsize=t,this._notifyLabelSkinDirty())},getFontSize:function(){return this._fontSize},isOutlined:function(){return this._outlined},setOutlined:function(t){this._outlined!==t&&(this._outlined=!!t,this._notifyLabelSkinDirty())},setFillColorGradientEnabled:function(t){this._gradientEnabled!==t&&(this._gradientEnabled=!!t,this._notifyLabelSkinDirty())},getFillColorGradientEnabled:function(){return this._gradientEnabled},setGradientStartColor:function(t){this._gradientStartColor!==t&&(this._gradientStartColor=t,this._notifyLabelSkinDirty())},getGradientStartColor:function(){return this._gradientStartColor},setGradientEndColor:function(t){this._gradientEndColor!==t&&(this._gradientEndColor=t,this._notifyLabelSkinDirty())},getGradientEndColor:function(){return this._gradientEndColor},setFillColorGradientDirection:function(t){this._gradientDirection=t,this._notifyLabelSkinDirty()},getFillColorGradientDirection:function(){return this._gradientDirection},getOutlineColor:function(){return this._outlineColor},setOutlineColor:function(t){this._outlineColor!==t&&(this._outlineColor=cc.color(t),this._notifyLabelSkinDirty())},setOutlineWidth:function(t){this._outlineWidth!==t&&(this._outlineWidth=t,this._notifyLabelSkinDirty())},getOutlineWidth:function(){return this._outlineWidth},_updateWrapText:function(t){t===_ccsg.Label.Overflow.RESIZE_HEIGHT&&(this._isWrapText=!0),t===_ccsg.Label.Overflow.NONE&&(this._isWrapText=!1)},_setOverflowBMFont:function(){this._labelType===_ccsg.Label.Type.BMFont&&(this._overFlow===_ccsg.Label.Overflow.RESIZE_HEIGHT&&this._setDimensions(this._labelDimensions.width,0),this._overFlow===_ccsg.Label.Overflow.NONE&&this._setDimensions(0,0),this._rescaleWithOriginalFontSize())},setOverflow:function(t){this._overFlow!==t&&(this._overFlow=t,this._updateWrapText(this._overFlow),this._setOverflowBMFont(),this._notifyLabelSkinDirty())},getOverflow:function(){return this._overFlow},setSpacingX:function(t){this._spacingX!==t&&(this._spacingX=t,this._notifyLabelSkinDirty())},setLineHeight:function(t){this._lineHeight!==t&&(this._lineHeight=t,this._notifyLabelSkinDirty())},setLineBreakWithoutSpace:function(t){this._lineBreakWithoutSpaces!==t&&(this._lineBreakWithoutSpaces=t,this._notifyLabelSkinDirty())},getSpacingX:function(){return this._spacingX},getLineHeight:function(){return this._lineHeight},getBMFontLineHeight:function(){if(this._fontAtlas)return this._fontAtlas._lineHeight},setFontFamily:function(t){this._resetBMFont(),this._fontHandle=t||"Arial",this._labelType=_ccsg.Label.Type.SystemFont,this._blendFunc=cc.BlendFunc._alphaPremultiplied(),this._renderCmd._needDraw=!0,this._notifyLabelSkinDirty(),this.emit("load")},setFontAsset:function(t){this._fontAsset=t;var e=t instanceof cc.Font;if(e){var i=e?t.rawUrl:"",n=cc.path.extname(i);this._resetBMFont(),".ttf"===n?(this._labelType=_ccsg.Label.Type.TTF,this._blendFunc=cc.BlendFunc._alphaPremultiplied(),this._renderCmd._needDraw=!0,this._fontHandle=this._loadTTFFont(i)):t.spriteFrame&&(this._labelType=_ccsg.Label.Type.BMFont,this._blendFunc=cc.BlendFunc._alphaNonPremultiplied(),this._renderCmd._needDraw=!1,this._initBMFontWithString(this._string,t)),this._notifyLabelSkinDirty()}else this.setFontFamily("")},_loadTTFFont:function(t){var e=this,i=function(){e._notifyLabelSkinDirty(),e.emit("load")},n="";return n=cc.CustomFontLoader._getFontFamily(t),cc.CustomFontLoader.loadTTF(t,i),n},setContentSize:function(t,e){this._overFlow!==_ccsg.Label.Overflow.NONE&&this._setDimensions(t,e)},setBlendFunc:function(t,e){var i=this._blendFunc;void 0===e?(i.src=t.src,i.dst=t.dst):(i.src=t,i.dst=e)},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},_setupBMFontOverflowMetrics:function(t,e){this._overFlow===_ccsg.Label.Overflow.RESIZE_HEIGHT&&(e=0),this._overFlow===_ccsg.Label.Overflow.NONE&&(t=0,e=0),this._labelWidth=t,this._labelHeight=e,this._labelDimensions.width=t,this._labelDimensions.height=e,this._maxLineWidth=t},_updateLabel:function(){if(this._labelType===_ccsg.Label.Type.BMFont){var t=this._contentSize,e=t.width,i=t.height;this._setupBMFontOverflowMetrics(e,i),this._updateContent(),this.setColor(this.color)}else this._labelType!==_ccsg.Label.Type.TTF&&this._labelType!==_ccsg.Label.Type.SystemFont||this._renderCmd._bakeLabel()},_notifyLabelSkinDirty:function(){this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.textDirty|_ccsg.Node._dirtyFlags.contentDirty)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new _ccsg.Label.WebGLRenderCmd(this):new _ccsg.Label.CanvasRenderCmd(this)},getContentSize:function(){return this._renderCmd._dirtyFlag&_ccsg.Node._dirtyFlags.textDirty&&(this._updateLabel(),this._renderCmd._dirtyFlag&=~_ccsg.Node._dirtyFlags.textDirty),_ccsg.Node.prototype.getContentSize.call(this)},_getWidth:function(){return this._renderCmd._dirtyFlag&_ccsg.Node._dirtyFlags.textDirty&&(this._updateLabel(),this._renderCmd._dirtyFlag&=~_ccsg.Node._dirtyFlags.textDirty),_ccsg.Node.prototype._getWidth.call(this)},_getHeight:function(){return this._renderCmd._dirtyFlag&_ccsg.Node._dirtyFlags.textDirty&&(this._updateLabel(),this._renderCmd._dirtyFlag&=~_ccsg.Node._dirtyFlags.textDirty),_ccsg.Node.prototype._getHeight.call(this)},_alignText:function(){var t=!0;do{if(!this._spriteBatchNode)return!0;if(this._textDesiredHeight=0,this._linesWidth=[],this._lineBreakWithoutSpaces?this._multilineTextWrapByChar():this._multilineTextWrapByWord(),this._computeAlignmentOffset(),this._overFlow===_ccsg.Label.Overflow.SHRINK){this.getFontSize()>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp.bind(this))}if(!this._updateQuads()){t=!1,this._overFlow===_ccsg.Label.Overflow.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp.bind(this));break}}while(0);return t},_isHorizontalClamped:function(t,e){var i=this._linesWidth[e],n=t>this._contentSize.width||t<0;return this._isWrapText?i>this._contentSize.width&&n:n},_updateQuads:function(){var t=!0;this._spriteBatchNode.removeAllChildren();for(var e=0;e<this._string.length;++e)if(this._lettersInfo[e]._valid){var i=this._fontAtlas._letterDefinitions[this._lettersInfo[e]._char];this._reusedRect.height=i._height,this._reusedRect.width=i._width,this._reusedRect.x=i._u,this._reusedRect.y=i._v;var n=this._lettersInfo[e]._positionY+this._letterOffsetY;if(this._labelHeight>0){if(n>this._tailoredTopY){var r=n-this._tailoredTopY;this._reusedRect.y+=r,this._reusedRect.height-=r,n-=r}n-i._height*this._bmfontScale<this._tailoredBottomY&&(this._reusedRect.height=n<this._tailoredBottomY?0:n-this._tailoredBottomY)}var s=this._lettersInfo[e]._lineIndex,o=this._lettersInfo[e]._positionX+i._width/2*this._bmfontScale+this._linesOffsetX[s];if(this._labelWidth>0&&this._isHorizontalClamped(o,s))if(this._overFlow===_ccsg.Label.Overflow.CLAMP)this._reusedRect.width=0;else if(this._overFlow===_ccsg.Label.Overflow.SHRINK){if(this._contentSize.width>i._width){t=!1;break}this._reusedRect.width=0}if(this._reusedRect.height>0&&this._reusedRect.width>0){var a=this.getChildByTag(e),c=this._spriteBatchNode._texture,h=this._spriteFrame,l=this._spriteFrame.isRotated(),u=h._originalSize,_=h._rect,d=h._offset,f=d.x+(u.width-_.width)/2,p=d.y-(u.height-_.height)/2;if(l){var m=this._reusedRect.x;this._reusedRect.x=_.x+_.height-this._reusedRect.y-this._reusedRect.height-p,this._reusedRect.y=m+_.y-f,this._reusedRect.y<0&&(this._reusedRect.height=this._reusedRect.height+p)}else this._reusedRect.x+=_.x-f,this._reusedRect.y+=_.y+p;a?a.setTextureRect(this._reusedRect,l):((a=new _ccsg.Sprite).initWithTexture(c,this._reusedRect,l),a.setAnchorPoint(cc.p(0,1)));var g=this._lettersInfo[e]._positionX+this._linesOffsetX[this._lettersInfo[e]._lineIndex];a.setPosition(g,n),this._updateLetterSpriteScale(a),this._spriteBatchNode.addChild(a)}}return t},_updateLetterSpriteScale:function(t){this._labelType===_ccsg.Label.Type.BMFont&&this._fontSize>0&&t.setScale(this._bmfontScale)},_recordPlaceholderInfo:function(t,e){if(t>=this._lettersInfo.length){var i=new o;this._lettersInfo.push(i)}this._lettersInfo[t]._char=e,this._lettersInfo[t]._valid=!1},_recordLetterInfo:function(t,e,i,n){if(i>=this._lettersInfo.length){var r=new o;this._lettersInfo.push(r)}e=e.charCodeAt(0),this._lettersInfo[i]._lineIndex=n,this._lettersInfo[i]._char=e,this._lettersInfo[i]._valid=this._fontAtlas._letterDefinitions[e]._validDefinition,this._lettersInfo[i]._positionX=t.x,this._lettersInfo[i]._positionY=t.y},_setDimensions:function(t,e){var i="number"==typeof t.width?t.width:t,n="number"==typeof t.height?t.height:e,r=this.getContentSize();_ccsg.Node.prototype.setContentSize.call(this,t,e),n===r.height&&i===r.width||(this._setupBMFontOverflowMetrics(i,n),this._drawFontsize>0&&this._restoreFontSize(),this._notifyLabelSkinDirty())},_restoreFontSize:function(){this._fontSize=this._drawFontsize},_multilineTextWrap:function(t){var e=this.getStringLength(),i=0,n=0,r=0,s=0,o=0,a=this._lineSpacing,c=0,h=0,l=null,u=cc.p(0,0);this._updateBMFontScale();for(var _=0;_<e;){var d=this._string.charAt(_);if("\n"!==d){for(var f=t(this._string,_,e),p=c,m=h,g=o,y=n,v=!1,x=0;x<f;++x){var C=_+x;if("\r"!==(d=this._string.charAt(C)))if(l=this._fontAtlas.getLetterDefinitionForChar(d)){var T=y+l._offsetX*this._bmfontScale;if(this._isWrapText&&this._maxLineWidth>0&&n>0&&T+l._width*this._bmfontScale>this._maxLineWidth&&!cc.TextUtils.isUnicodeSpace(d)){this._linesWidth.push(o),o=0,i++,n=0,r-=this._lineHeight*this._bmfontScale+a,v=!0;break}u.x=T,u.y=r-l._offsetY*this._bmfontScale,this._recordLetterInfo(u,d,C,i),C+1<this._horizontalKernings.length&&C<e-1&&(y+=this._horizontalKernings[C+1]),y+=l._xAdvance*this._bmfontScale+this._spacingX,g=u.x+l._width*this._bmfontScale,p<u.y&&(p=u.y),m>u.y-l._height*this._bmfontScale&&(m=u.y-l._height*this._bmfontScale)}else this._recordPlaceholderInfo(C,d),console.log("Can't find letter definition in texture atlas "+this._config.atlasName+" for letter:"+d);else this._recordPlaceholderInfo(C,d)}v||(n=y,o=g,c<p&&(c=p),h>m&&(h=m),s<o&&(s=o),_+=f)}else this._linesWidth.push(o),o=0,i++,n=0,r-=this._lineHeight*this._bmfontScale+a,this._recordPlaceholderInfo(_,d),_++}this._linesWidth.push(o),this._numberOfLines=i+1,this._textDesiredHeight=this._numberOfLines*this._lineHeight*this._bmfontScale,this._numberOfLines>1&&(this._textDesiredHeight+=(this._numberOfLines-1)*this._lineSpacing);var b=cc.size(this._labelWidth,this._labelHeight);return this._labelWidth<=0&&(b.width=parseFloat(s.toFixed(2))),this._labelHeight<=0&&(b.height=parseFloat(this._textDesiredHeight.toFixed(2))),_ccsg.Node.prototype.setContentSize.call(this,b),this._tailoredTopY=b.height,this._tailoredBottomY=0,c>0&&(this._tailoredTopY=b.height+c),h<-this._textDesiredHeight&&(this._tailoredBottomY=this._textDesiredHeight+h),!0},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen.bind(this))},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen.bind(this))},_isVerticalClamp:function(){return this._textDesiredHeight>this._contentSize.height},_isHorizontalClamp:function(){for(var t=!1,e=0;e<this.getStringLength();++e)if(this._lettersInfo[e]._valid){var i=this._fontAtlas._letterDefinitions[this._lettersInfo[e]._char],n=this._lettersInfo[e]._positionX+i._width/2*this._bmfontScale,r=this._lettersInfo[e]._lineIndex;if(this._labelWidth>0)if(this._isWrapText){if(this._linesWidth[r]>this._contentSize.width&&(n>this._contentSize.width||n<0)){t=!0;break}}else if(n>this._contentSize.width){t=!0;break}}return t},_shrinkLabelToContentSize:function(t){for(var e=this.getFontSize(),i=0,n=this._fontAtlas.cloneLetterDefinition(),r=this._lineHeight,s=!0;t();){var o=e-++i;if(s=!1,o<=0)break;var a=o/e;this._fontAtlas.assignLetterDefinitions(n),this._fontAtlas.scaleFontLetterDefinition(a),this._lineHeight=r*a,this._lineBreakWithoutSpaces?this._multilineTextWrapByChar():this._multilineTextWrapByWord(),this._computeAlignmentOffset()}this._lineHeight=r,this._fontAtlas.assignLetterDefinitions(n),s||e-i>=0&&this._scaleFontSizeDown(e-i)},_scaleFontSizeDown:function(t){var e=!0;this._labelType===_ccsg.Label.Type.BMFont&&(t||(t=.1,e=!1),this._fontSize=t,e&&this._updateContent())},_updateContent:function(){this._fontAtlas&&(this._computeHorizontalKerningForText(this._string),this._alignText())},_computeAlignmentOffset:function(){switch(this._linesOffsetX=[],this._hAlign){case cc.TextAlignment.LEFT:for(var t=0;t<this._numberOfLines;++t)this._linesOffsetX.push(0);break;case cc.TextAlignment.CENTER:this._linesWidth.forEach(function(t){this._linesOffsetX.push((this._contentSize.width-t)/2)}.bind(this));break;case cc.TextAlignment.RIGHT:this._linesWidth.forEach(function(t){this._linesOffsetX.push(this._contentSize.width-t)}.bind(this))}switch(this._vAlign){case cc.VerticalTextAlignment.TOP:this._letterOffsetY=this._contentSize.height;break;case cc.VerticalTextAlignment.CENTER:this._letterOffsetY=(this._contentSize.height+this._textDesiredHeight)/2;break;case cc.VerticalTextAlignment.BOTTOM:this._letterOffsetY=this._textDesiredHeight}},_getFirstCharLen:function(){return 1},_getFirstWordLen:function(t,e,i){var n=t.charAt(e);if(cc.TextUtils.isUnicodeCJK(n)||"\n"===n||cc.TextUtils.isUnicodeSpace(n))return 1;var r=1;if(!(s=this._fontAtlas.getLetterDefinitionForChar(n)))return r;for(var s,o=s._xAdvance*this._bmfontScale+this._spacingX,a=e+1;a<i&&(n=t.charAt(a),s=this._fontAtlas.getLetterDefinitionForChar(n));++a){if(o+s._offsetX*this._bmfontScale+s._width*this._bmfontScale>this._maxLineWidth&&!cc.TextUtils.isUnicodeSpace(n)&&this._maxLineWidth>0)return r;if(o+=s._xAdvance*this._bmfontScale+this._spacingX,"\n"===n||cc.TextUtils.isUnicodeSpace(n)||cc.TextUtils.isUnicodeCJK(n))break;r++}return r},_updateBMFontScale:function(){if(this._labelType===_ccsg.Label.Type.BMFont){var t=this._fontAtlas._fontSize;this._bmfontScale=this._fontSize/t}else this._bmfontScale=1},_initBMFontWithString:function(t,e){if(this._config)return cc.logID(4002),!1;this._string=t,this._setBMFontFile(e)},_createSpriteBatchNode:function(t){this._spriteBatchNode=new cc.SpriteBatchNode(t,this._string.length),this._spriteBatchNode.setCascadeColorEnabled(!0),this._spriteBatchNode.setCascadeOpacityEnabled(!0),this.addChild(this._spriteBatchNode),this._updateContent(),this.setColor(this.color)},_createFontChars:function(){if(this._config){this._fontAtlas=new cc.FontAtlas(this._config),this._lineHeight||(this._lineHeight=this._fontAtlas._lineHeight);var t=this._config.fontDefDictionary;for(var e in t){var i=new s,n=t[e].rect;i._offsetX=parseInt(t[e].xOffset),i._offsetY=parseInt(t[e].yOffset),i._width=parseInt(n.width),i._height=parseInt(n.height),i._u=parseInt(n.x)+this._imageOffset.x,i._v=parseInt(n.y)+this._imageOffset.y,i._textureID=0,i._validDefinition=!0,i._xAdvance=parseInt(t[e].xAdvance),this._fontAtlas.addLetterDefinitions(e,i)}}},_rescaleWithOriginalFontSize:function(){var t=this.getFontSize();this._drawFontsize-t>=1&&this._overFlow===_ccsg.Label.Overflow.SHRINK&&(this._labelType===_ccsg.Label.Type.BMFont?this._scaleFontSizeDown(this._drawFontsize):this._fontSize=this._drawFontsize)},_computeHorizontalKerningForText:function(){for(var t=this.getStringLength(),e=this._config.kerningDict,i=-1,n=0;n<t;++n){var r=this._string.charCodeAt(n),s=e[i<<16|65535&r]||0;this._horizontalKernings[n]=n<t-1?s:0,i=r}},_setBMFontFile:function(t){if(t&&this._labelType===_ccsg.Label.Type.BMFont){var e=this;this._resetBMFont();var i=this._fontAsset._fntConfig;i?e._config=i:cc.warn("Invalid BMFont Assets!");var n=t.spriteFrame;e._createFontChars(),e._spriteFrame=n;var r=function(){var t=n.getTexture();e._textureLoaded=t.loaded,e._createSpriteBatchNode(t),e.emit("load")};n.textureLoaded()?r():(n.once("load",r),n.ensureLoadTexture())}}}),_ccsg.Label.pool=new r.Pool(function(t){return t instanceof _ccsg.Label&&(t._string="",t._fontAsset=null,t._fontHandle="",t._labelType=0,t._resetBMFont(),t._renderCmd._labelCanvas.width=1,t._renderCmd._labelCanvas.height=1,t._updateLabel(),!0)},20),_ccsg.Label.pool.get=function(t,e){var i=this._get();if(i){var n=e instanceof cc.Font,r=n?e.rawUrl:"";return i._fontHandle=r,"string"!=typeof t&&(t=""+t),i._string=t,i._position.x=0,i._position.y=0,i.setAnchorPoint(.5,.5),_ccsg.Node.prototype.setContentSize.call(i,128,128),n?i.setFontAsset(e):i.setFontFamily("Arial"),i.setString(t),i.setHorizontalAlign(cc.TextAlignment.LEFT),i.setVerticalAlign(cc.VerticalTextAlignment.TOP),i.setFontSize(40),i.setOverflow(0),i.enableWrapText(!0),i.setVisible(!0),i.setLineHeight(40),i.setOutlined(!1),i.enableBold(!1),i.enableItalics(!1),i.enableUnderline(!1),i}return new _ccsg.Label(t||"",e)};var a=_ccsg.Label.prototype;cc.js.addon(a,n.prototype),_ccsg.Label.Type=cc.Enum({TTF:0,BMFont:1,SystemFont:2}),_ccsg.Label.Overflow=cc.Enum({NONE:0,CLAMP:1,SHRINK:2,RESIZE_HEIGHT:3});var c=_ccsg.Label.prototype;Object.defineProperty(c,"width",{get:c._getWidth,set:_ccsg.Node.prototype._setWidth}),Object.defineProperty(c,"height",{get:c._getHeight,set:_ccsg.Node.prototype._setHeight})}),{"../event/event-target":112,"../platform/js":197,"./CCTextUtils":129}],127:[(function(t,e,i){(function(){_ccsg.Label.TTFLabelBaker=function(){};var t=_ccsg.Label.TTFLabelBaker.prototype=Object.create(Object.prototype);t.updateStatus=function(){var t=_ccsg.Node._dirtyFlags,e=this._dirtyFlag,i=e&t.colorDirty,n=e&t.opacityDirty;i&&this._updateDisplayColor(),n&&(this._updateDisplayOpacity(),this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty)),e&t.contentDirty&&(this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty),this._dirtyFlag&=~t.contentDirty),(i||e&t.textDirty)&&(this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty),this._rebuildLabelSkin()),this._dirtyFlag&t.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag&=~t.transformDirty)},t._syncStatus=function(t){var e=_ccsg.Node._dirtyFlags,i=this._dirtyFlag,n=t?t._node:null;n&&n._cascadeColorEnabled&&t._dirtyFlag&e.colorDirty&&(i|=e.colorDirty),n&&n._cascadeOpacityEnabled&&t._dirtyFlag&e.opacityDirty&&(i|=e.opacityDirty),t&&t._dirtyFlag&e.transformDirty&&(i|=e.transformDirty);var r=i&e.colorDirty,s=i&e.opacityDirty;this._dirtyFlag=i,r&&this._syncDisplayColor(),s&&this._syncDisplayOpacity(),(r||s||this._dirtyFlag&e.textDirty)&&this._rebuildLabelSkin(),this._dirtyFlag&e.transformDirty&&this.transform(t)},t._getLineHeight=function(){var t=this._node.getLineHeight(),e=this._node;return 0|(t=0===t?e._fontSize:t*e._fontSize/this._drawFontsize)},t._constructFontDesc=function(){var t=this._node,e=t._fontSize.toString()+"px ";return e+=0===t._fontHandle.length?"serif":t._fontHandle,t._isBold&&(e="bold "+e),e},t._measureText=function(t){return function(e){return t.measureText(e).width}},t._calculateLabelFont=function(){var t=this._node,e=t._string.split("\n");t._fontSize=t._drawFontsize;var i=this._constructFontDesc();this._labelContext.font=i;var n=this._calculateParagraphLength(e,this._labelContext);if(_ccsg.Label.Overflow.SHRINK===t._overFlow){this._splitedStrings=e;var r=0,s=0,o=0;if(t._isWrapText){var a=this._canvasSize.width-2*this._getMargin(),c=this._canvasSize.height-2*this._getMargin();if(a<0||c<0)return i=this._constructFontDesc(),this._labelContext.font=i,i;s=c+1,o=a+1;for(var h=this._drawFontsize+1,l="",u=!0,_=0|h;s>c||o>a;){if(u?h=_/2|0:_=h=_-1,h<=0){cc.logID(4003);break}for(t._fontSize=h,i=this._constructFontDesc(),this._labelContext.font=i,this._splitedStrings=[],s=0,r=0;r<e.length;++r){var d=0,f=this._labelContext.measureText(e[r]).width;for(l=cc.TextUtils.fragmentText(e[r],f,a,this._measureText(this._labelContext));d<l.length;){o=this._labelContext.measureText(l[d]).width,s+=this._getLineHeight(),++d}this._splitedStrings=this._splitedStrings.concat(l)}u&&(s>c?_=0|h:(u=!1,s=c+1))}}else{for(s=e.length*this._getLineHeight(),r=0;r<e.length;++r)o<n[r]&&(o=n[r]);var p=(this._canvasSize.width-2*this._getMargin())/o,m=this._canvasSize.height/s;t._fontSize=this._drawFontsize*Math.min(1,p,m)|0,i=this._constructFontDesc(),this._labelContext.font=i}}return i},t._getMargin=function(){return this._node&&this._node._margin||0},t._calculateParagraphLength=function(t,e){for(var i=[],n=0;n<t.length;++n){var r=e.measureText(t[n]);i.push(r.width)}return i},t._calculateCanvasSize=function(){var t=this._node,e=t._contentSize.width,i=t._contentSize.height;return e<=0&&(e=1),i<=0&&(i=1),cc.size(e,i)},t._calculateSplitedStrings=function(){var t,e=this._node,i=e._string.split("\n");if(e._isWrapText){this._splitedStrings=[];var n=this._canvasSize.width-2*this._getMargin();for(t=0;t<i.length;++t){var r=this._labelContext.measureText(i[t]).width,s=cc.TextUtils.fragmentText(i[t],r,n,this._measureText(this._labelContext));this._splitedStrings=this._splitedStrings.concat(s)}}else this._splitedStrings=i},t._updateLabelDimensions=function(){var t,e=this._node,i=e._string.split("\n"),n=this._labelContext;if(_ccsg.Label.Overflow.RESIZE_HEIGHT===e._overFlow)this._canvasSize.height=this._splitedStrings.length*this._getLineHeight(),_ccsg.Node.prototype.setContentSize.call(e,this._canvasSize);else if(_ccsg.Label.Overflow.NONE===e._overFlow){this._splitedStrings=i;var r=0,s=0;for(t=0;t<i.length;++t){var o=n.measureText(i[t]).width;r=r>o?r:o}s=this._splitedStrings.length*this._getLineHeight(),this._canvasSize.width=Math.round(r.toFixed(2))+2*this._getMargin(),this._canvasSize.height=Math.round(s.toFixed(2)),e._isItalic&&(this._canvasSize.width+=e._drawFontsize*Math.tan(.20943951)),_ccsg.Node.prototype.setContentSize.call(e,this._canvasSize)}this._labelCanvas.width=this._canvasSize.width,this._labelCanvas.height=this._canvasSize.height},t._calculateFillTextStartPosition=function(){var t,e,i=this._node,n=this._getLineHeight(),r=this._splitedStrings.length;return t=cc.TextAlignment.RIGHT===i._hAlign?this._canvasSize.width-this._getMargin():cc.TextAlignment.CENTER===i._hAlign?this._canvasSize.width/2:0+this._getMargin(),e=cc.VerticalTextAlignment.TOP===i._vAlign?0:cc.VerticalTextAlignment.CENTER===i._vAlign?this._canvasSize.height/2-n*(r-1)/2:this._canvasSize.height-n*(r-1),cc.p(t,e)},t._calculateTextBaseline=function(){var t,e,i=this._node;t=cc.TextAlignment.RIGHT===i._hAlign?"right":cc.TextAlignment.CENTER===i._hAlign?"center":"left",this._labelContext.textAlign=t,e=cc.VerticalTextAlignment.TOP===i._vAlign?"top":cc.VerticalTextAlignment.CENTER===i._vAlign?"middle":"bottom",this._labelContext.textBaseline=e},t._bakeLabel=function(){var t=this._node;this._drawFontsize=t._drawFontsize,this._canvasSize=this._calculateCanvasSize(),this._fontDesc=this._calculateLabelFont(),this._calculateSplitedStrings(),this._updateLabelDimensions(),this._calculateTextBaseline(),this._updateTexture()},t._calculateUnderlineStartPosition=function(){var t,e,i=this._node,n=this._getLineHeight(),r=this._splitedStrings.length;return t=0+this._getMargin(),e=cc.VerticalTextAlignment.TOP===i._vAlign?i._fontSize:cc.VerticalTextAlignment.CENTER===i._vAlign?this._canvasSize.height/2-n*(r-1)/2+i._fontSize/2:this._canvasSize.height-n*(r-1),cc.p(t,e)},t._updateTexture=function(){this._labelContext.clearRect(0,0,this._labelCanvas.width,this._labelCanvas.height),this._labelContext.font=this._fontDesc;var t=this._calculateFillTextStartPosition(),e=this._getLineHeight();this._labelContext.lineJoin="round";var i=this._displayedColor;this._labelContext.fillStyle="rgb("+i.r+","+i.g+","+i.b+")";for(var n,r=0;r<this._splitedStrings.length;++r){if(this._node.isOutlined()){var s=this._node.getOutlineColor()||cc.color(255,255,255,255);this._labelContext.globalCompositeOperation="source-over",this._labelContext.strokeStyle="rgb("+s.r+","+s.g+","+s.b+")",this._labelContext.lineWidth=2*this._node.getOutlineWidth(),this._labelContext.strokeText(this._splitedStrings[r],t.x,t.y+r*e)}if(this._node.getFillColorGradientEnabled()){var o=this._node.getGradientStartColor()||cc.color(255,255,255,255),a=this._node.getGradientEndColor()||cc.color(255,255,255,255),c=this._getGradientArgs(),h=this._labelContext.createLinearGradient(c.left,c.top,c.right,c.bottom);h.addColorStop(0,cc.colorToHex(o)),h.addColorStop(1,cc.colorToHex(a)),this._labelContext.fillStyle=h}this._labelContext.fillText(this._splitedStrings[r],t.x,t.y+r*e),this._node._isUnderline&&(n=this._calculateUnderlineStartPosition(),this._labelContext.save(),this._labelContext.beginPath(),this._labelContext.lineWidth=this._node._fontSize/8,this._labelContext.strokeStyle="rgb("+i.r+","+i.g+","+i.b+")",this._labelContext.moveTo(n.x,n.y+r*e-1),this._labelContext.lineTo(n.x+this._labelCanvas.width,n.y+r*e-1),this._labelContext.stroke(),this._labelContext.restore())}this._texture.loaded=!1,this._texture._image=this._labelCanvas,this._texture.handleLoadedTexture(!0)},t._getGradientArgs=function(){this._gradientArgument={},this._gradientArgument.left=0,this._gradientArgument.top=0;var t=this._node._contentSize;switch(this._node.getFillColorGradientDirection()){case 0:this._gradientArgument.right=t.width,this._gradientArgument.bottom=0;break;case 1:this._gradientArgument.right=0,this._gradientArgument.bottom=t.height;break;case 2:this._gradientArgument.right=t.width,this._gradientArgument.bottom=t.height}return this._gradientArgument},t._rebuildLabelSkin=function(){this._dirtyFlag&=~_ccsg.Node._dirtyFlags.textDirty;this._node._updateLabel()}})(),(function(){_ccsg.Label.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._texture=new cc.Texture2D,this._labelCanvas=document.createElement("canvas"),this._labelCanvas.width=1,this._labelCanvas.height=1,this._labelContext=this._labelCanvas.getContext("2d"),this._texture.initWithElement(this._labelCanvas),this._splitedStrings=null};var t=_ccsg.Label.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);cc.js.mixin(t,_ccsg.Label.TTFLabelBaker.prototype),t.constructor=_ccsg.Label.CanvasRenderCmd,t._doCulling=function(){var t=cc.visibleRect,e=this._currentRegion,i=e._minX,n=e._maxX,r=e._minY,s=e._maxY,o=t.left.x,a=t.right.x,c=t.top.y,h=t.bottom.y;this._needDraw=!(n<o||i>a||s<h||r>c)},t.rendering=function(t,e,i){var n=this._node;if(n._labelType===_ccsg.Label.Type.TTF||n._labelType===_ccsg.Label.Type.SystemFont){var r=this._displayedOpacity,s=r/255;if(0===r)return;var o=t||cc._renderContext,a=o.getContext();if(o.setTransform(this._worldTransform,e,i),o.setCompositeOperation(_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(n._blendFunc)),o.setGlobalAlpha(s),this._texture){var c,h,l,u,_;0,l=-this._node._contentSize.height,u=this._node._contentSize.width,_=this._node._contentSize.height;0,0,c=this._texture.getPixelWidth(),h=this._texture.getPixelHeight();var d=this._texture._image;""!==this._texture._pattern?(o.setFillStyle(a.createPattern(d,this._texture._pattern)),a.fillRect(0,l,u,_)):0!==c&&0!==h&&0!==u&&0!==_&&a.drawImage(d,0,0,c,h,0,l,u,_)}cc.g_NumberOfDraws=cc.g_NumberOfDraws+1}}})()}),{}],128:[(function(t,e,i){_ccsg.Label.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._texture=new cc.Texture2D,this._labelCanvas=document.createElement("canvas"),this._texture.initWithElement(this._labelCanvas),this._labelContext=this._labelCanvas.getContext("2d"),this._labelCanvas.width=1,this._labelCanvas.height=1,this._splitedStrings=null,this._drawFontsize=0,this._vertices=[{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:1},{x:0,y:0,u:1,v:0},{x:0,y:0,u:1,v:1}],this._color=new Uint32Array(1),this._dirty=!1,this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var n=_ccsg.Label.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);cc.js.mixin(n,_ccsg.Label.TTFLabelBaker.prototype),n.constructor=_ccsg.Label.WebGLRenderCmd,n.updateTransform=function(t){this.originUpdateTransform(t);this._node;var e=this._labelCanvas.width,i=this._labelCanvas.height,n=this._worldTransform,r=this._vertices;r[0].x=0*n.a+i*n.c+n.tx,r[0].y=0*n.b+i*n.d+n.ty,r[1].x=0*n.a+0*n.c+n.tx,r[1].y=0*n.b+0*n.d+n.ty,r[2].x=e*n.a+i*n.c+n.tx,r[2].y=e*n.b+i*n.d+n.ty,r[3].x=e*n.a+0*n.c+n.tx,r[3].y=e*n.b+0*n.d+n.ty},n._doCulling=function(){var t=this._node;if(t._string&&(t._labelType===_ccsg.Label.Type.TTF||t._labelType===_ccsg.Label.Type.SystemFont)){var e=cc.visibleRect;this._cameraFlag>0&&(e=cc.Camera.main.visibleRect);var i=e.left.x,n=e.right.x,r=e.top.y,s=e.bottom.y,o=this._vertices;(o[0].x-i&o[1].x-i&o[2].x-i&o[3].x-i)>>31||(n-o[0].x&n-o[1].x&n-o[2].x&n-o[3].x)>>31||(o[0].y-s&o[1].y-s&o[2].y-s&o[3].y-s)>>31||(r-o[0].y&r-o[1].y&r-o[2].y&r-o[3].y)>>31?this._needDraw=!1:this._needDraw=!0}},n.uploadData=function(t,e,i){var n=this._node;if(!n._string||n._labelType!==_ccsg.Label.Type.TTF&&n._labelType!==_ccsg.Label.Type.SystemFont)return 0;var r=this._displayedOpacity;this._color[0]=~~r<<24>>>0|~~r<<16|~~r<<8|~~r;var s,o,a=n._vertexZ,c=this._vertices,h=c.length,l=i;for(s=0;s<h;++s)o=c[s],t[l]=o.x,t[l+1]=o.y,t[l+2]=a,e[l+3]=this._color[0],t[l+4]=o.u,t[l+5]=o.v,l+=6;return h}}),{}],129:[(function(t,e,i){var n=function(){this._status="unloaded",this._observers=[],this._isLoadWithCSS=!1};n.prototype.onLoaded=function(){this._status="loaded",this._observers.forEach((function(t){t()}))},n.prototype.isLoaded=function(){return"loaded"===this._status},n.prototype.addHandler=function(t){-1===this._observers.indexOf(t)&&this._observers.push(t)};var r={_fontCache:{},_fontWidthCache:{},_canvasContext:null,_testString:"BESbswy",_allFontsLoaded:!1,_intervalId:0,loadTTF:function(t,e){var i=this._getFontFamily(t),n=cc.loader.md5Pipe;n&&(t=n.transformURL(t));var r=cc.sys.browserType!==cc.sys.BROWSER_TYPE_BAIDU&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_BAIDU_APP&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_MOBILE_QQ;window.FontFace&&r?this._loadWithFontFace(i,t,e):this._loadWithCSS(i,t,e),0===this._intervalId&&(this._intervalId=setInterval(this._checkFontLoaded.bind(this),100))},_checkFontLoaded:function(){this._allFontsLoaded=!0;for(var t in this._fontCache){var e=this._fontCache[t];if(!e.isLoaded()&&e._isLoadWithCSS){var i=this._fontWidthCache[t];this._canvasContext.font="40px "+t;i!==this._canvasContext.measureText(this._testString).width?e.onLoaded():this._allFontsLoaded=!1}}this._allFontsLoaded&&(clearInterval(this._intervalId),this._intervalId=0)},_loadWithFontFace:function(t,e,i){var r=this._fontCache[t];if(r)r.isLoaded()||r.addHandler(i);else{var s=new FontFace(t,"url('"+e+"')");document.fonts.add(s),(r=new n).addHandler(i),this._fontCache[t]=r,s.loaded.then((function(){r.onLoaded()}))}},_loadWithCSS:function(t,e,i){var r=this._fontCache[t];if(r)r.isLoaded()||r.addHandler(i);else{var s=document,o=document.createElement("style");o.type="text/css",s.body.appendChild(o);var a="";isNaN(t-0)?a+="@font-face { font-family:"+t+"; src:":a+="@font-face { font-family:'"+t+"'; src:",a+="url('"+e+"');",o.textContent=a+"}";var c=document.createElement("div"),h=c.style;if(h.fontFamily=t,c.innerHTML=".",h.position="absolute",h.left="-100px",h.top="-100px",s.body.appendChild(c),(r=new n).addHandler(i),this._fontCache[t]=r,r._isLoadWithCSS=!0,!this._canvasContext){var l=document.createElement("canvas");l.width=100,l.height=100,this._canvasContext=l.getContext("2d")}var u="40px "+t;this._canvasContext.font=u;var _=this._canvasContext.measureText(this._testString).width;this._fontWidthCache[t]=_;var d=this;o.onload=function(){setTimeout((function(){d._allFontsLoaded||(cc.logID(4004),r.onLoaded(),cc.director.getScheduler().unschedule(this._checkFontLoaded,this))}),2e4)}}},_getFontFamily:function(t){var e=t.lastIndexOf(".ttf");if(-1===e)return t;var i=t.lastIndexOf("/");return-1===i?t.substring(0,e)+"_LABEL":t.substring(i+1,e)+"_LABEL"}};cc.TextUtils=e.exports={label_wordRex:/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,label_symbolRex:/^[!,.:;'}\]%\?>、‘“》?。,!]/,label_lastWordRex:/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,label_lastEnglish:/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,label_firstEnglish:/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/,label_wrapinspection:!0,isUnicodeCJK:function(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)},isUnicodeSpace:function(t){return(t=t.charCodeAt(0))>=9&&t<=13||32===t||133===t||160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t},fragmentText:function(t,e,i,n){var r=[];if(0===t.length||i<0)return r.push(""),r;for(var s=t;e>i&&s.length>1;){for(var o=s.length*(i/e)|0,a=s.substr(o),c=e-n(a),h=a,l=0,u=0;c>i&&u++<10;)o*=i/c,o|=0,c=e-n(a=s.substr(o));for(u=0;c<=i&&u++<10;){if(a){var _=this.label_wordRex.exec(a);l=_?_[0].length:1,h=a}o+=l,c=e-n(a=s.substr(o))}0==(o-=l)&&(o=1,h=h.substr(1));var d,f=s.substr(0,o);this.label_wrapinspection&&this.label_symbolRex.test(h||a)&&(0==(o-=(d=this.label_lastWordRex.exec(f))?d[0].length:0)&&(o=1),h=s.substr(o),f=s.substr(0,o)),this.label_firstEnglish.test(h)&&(d=this.label_lastEnglish.exec(f))&&f!==d[0]&&(o-=d[0].length,h=s.substr(o),f=s.substr(0,o)),0===r.length?r.push(f):(f=f.trim()).length>0&&r.push(f),e=n(s=h||a)}return 0===r.length?r.push(s):(s=s.trim()).length>0&&r.push(s),r}},cc.CustomFontLoader=e.exports=r}),{}],130:[(function(t,e,i){function n(t){var e,i,n;if("object"==typeof t){if(i=t,t.url)return i;e=t.uuid}else i={},e=t;return n=i.type?"uuid"===i.type:cc.AssetLibrary._getAssetUrl(e),cc.AssetLibrary._getAssetInfoInRuntime(e,m),i.url=n?m.url:e,m.url&&"uuid"===i.type&&m.raw?(i.type=null,i.isRawAsset=!0):n||(i.isRawAsset=!0),i}function r(){var t=new c,e=new h,i=new l;o.call(this,[t,e,i]),this.assetLoader=t,this.downloader=e,this.loader=i,this.onProgress=null,this._autoReleaseSetting={}}var s=t("../platform/js"),o=t("./pipeline"),a=t("./loading-items"),c=t("./asset-loader"),h=t("./downloader"),l=t("./loader"),u=t("./asset-table"),_=t("../platform/utils").callInNextTick,d=t("./auto-release-utils"),f=new u,p=["mp3","ogg","wav","m4a"],m={url:null,raw:!1},g=[],y=[];s.extend(r,o);var v=r.prototype;v.init=function(t){},v.getXMLHttpRequest=function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},v.addDownloadHandlers=function(t){this.downloader.addHandlers(t)},v.addLoadHandlers=function(t){this.loader.addHandlers(t)},v.load=function(t,e,i){void 0===i&&(i=e,e=this.onProgress||null);var r=this,s=!1;t instanceof Array||(s=!0,t=t?[t]:[]),g.length=0;for(var o=0;o<t.length;++o){var c=t[o];c&&c.id&&(cc.warnID(4920,c.id),c.uuid||c.url||(c.url=c.id));var h=n(c);if(h.url||h.uuid){var l=this._cache[h.url];g.push(l||h)}}var u=a.create(this,e,(function(t,e){_((function(){if(i){if(s){var n=h.url;i.call(r,e.getError(n),e.getContent(n))}else i.call(r,t,e);i=null}e.destroy()}))}));a.initQueueDeps(u),u.append(g),g.length=0},v.flowInDeps=function(t,e,i){y.length=0;for(var r=0;r<e.length;++r){var s=n(e[r]);if(s.url||s.uuid){var o=this._cache[s.url];o?y.push(o):y.push(s)}}var c=a.create(this,t?function(t,e,i){this._ownerQueue&&this._ownerQueue.onProgress&&this._ownerQueue._childOnProgress(i)}:null,(function(e,n){i(e,n),t&&t.deps&&(t.deps.length=0),n.destroy()}));if(t){var h=a.getQueue(t);c._ownerQueue=h._ownerQueue||h}var l=c.append(y,t);return y.length=0,l},v._resources=f,v._getResUuid=function(t,e,i){if(!t)return null;var n=t.indexOf("?");-1!==n&&(t=t.substr(0,n));var r=f.getUuid(t,e);if(!r){var s=cc.path.extname(t);s&&(t=t.slice(0,-s.length),(r=f.getUuid(t,e))&&!i&&cc.warnID(4901,t,s))}return r},v._getReferenceKey=function(t){var e;return"object"==typeof t?e=t._uuid||null:"string"==typeof t&&(e=this._getResUuid(t,null,!0)||t),e?(cc.AssetLibrary._getAssetInfoInRuntime(e,m),this._cache[m.url]?m.url:e):(cc.warnID(4800,t),e)},v._urlNotFound=function(t,e,i){_((function(){t=cc.url.normalize(t);var n=(e?s.getClassName(e):"Asset")+' in "resources/'+t+'" does not exist.';i&&i(new Error(n),[])}))},v._parseLoadResArgs=function(t,e,i){if(void 0===i){var n=cc.isChildClassOf(t,cc.RawAsset);e?(i=e,n&&(e=this.onProgress||null)):void 0!==e||n||(i=t,e=this.onProgress||null,t=null),void 0===e||n||(e=t,t=null)}return{type:t,onProgress:e,onComplete:i}},v.loadRes=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n);e=r.type,i=r.onProgress,n=r.onComplete;var s=this,o=s._getResUuid(t,e);o?this.load({type:"uuid",uuid:o},i,(function(t,e){e&&s.setAutoReleaseRecursively(o,!1),n&&n(t,e)})):s._urlNotFound(t,e,n)},v._loadResUuids=function(t,e,i,n){if(t.length>0){var r=this,s=t.map((function(t){return{type:"uuid",uuid:t}}));this.load(s,e,(function(t,e){if(i){for(var o=[],a=n&&[],c=0;c<s.length;++c){var h=s[c].uuid,l=this._getReferenceKey(h),u=e.getContent(l);u&&(r.setAutoReleaseRecursively(h,!1),o.push(u),a&&a.push(n[c]))}n?i(t,o,a):i(t,o)}}))}else i&&_((function(){n?i(null,[],[]):i(null,[])}))},v.loadResArray=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n);e=r.type,i=r.onProgress,n=r.onComplete;for(var s=[],o=0;o<t.length;o++){var a=t[o],c=this._getResUuid(a,e);if(!c)return void this._urlNotFound(a,e,n);s.push(c)}this._loadResUuids(s,i,n)},v.loadResDir=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n);e=r.type,i=r.onProgress,n=r.onComplete;var s=[],o=f.getUuidArray(t,e,s);this._loadResUuids(o,i,n,s)},v.getRes=function(t,e){var i=this._cache[t];if(!i){var n=this._getResUuid(t,e,!0);if(!n)return null;var r=this._getReferenceKey(n);i=this._cache[r]}return i&&i.alias&&(i=i.alias),i&&i.complete?i.content:null},v.getResCount=function(){return Object.keys(this._cache).length},v.getDependsRecursively=function(t){if(t){var e=this._getReferenceKey(t),i=d.getDependsRecursively(e);return i.push(e),i}return[]},v.release=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++){var i=t[e];this.release(i)}else if(t){var n=this._getReferenceKey(t),r=this.getItem(n);if(r){this.removeItem(n);if((t=r.content)instanceof cc.Asset){0;for(var s=t.rawUrls,o=0;o<s.length;o++)this.release(s[o])}else t instanceof cc.Texture2D?cc.textureCache.removeTextureForKey(r.rawUrl||r.url):-1!==p.indexOf(r.type)&&cc.audioEngine.uncache(r.rawUrl||r.url);0}}},v.releaseAsset=function(t){var e=t._uuid;e&&this.release(e)},v.releaseRes=function(t,e){var i=this._getResUuid(t,e);i?this.release(i):cc.errorID(4914,t)},v.releaseResDir=function(t,e){for(var i=f.getUuidArray(t,e),n=0;n<i.length;n++){var r=i[n];this.release(r)}},v.releaseAll=function(){for(var t in this._cache)this.release(t)},v.removeItem=function(t){var e=o.prototype.removeItem.call(this,t);return delete this._autoReleaseSetting[t],e},v.setAutoRelease=function(t,e){var i=this._getReferenceKey(t);i&&(this._autoReleaseSetting[i]=!!e)},v.setAutoReleaseRecursively=function(t,e){e=!!e;var i=this._getReferenceKey(t);if(i){this._autoReleaseSetting[i]=e;for(var n=d.getDependsRecursively(i),r=0;r<n.length;r++){var s=n[r];this._autoReleaseSetting[s]=e}}else 0},v.isAutoRelease=function(t){var e=this._getReferenceKey(t);return!!e&&!!this._autoReleaseSetting[e]},cc.loader=new r,e.exports=cc.loader}),{"../platform/js":197,"../platform/utils":201,"./asset-loader":131,"./asset-table":132,"./auto-release-utils":134,"./downloader":135,"./loader":138,"./loading-items":139,"./pipeline":142,"./released-asset-checker":143}],131:[(function(t,e,i){var n=t("../utils/CCPath"),r=t("./pipeline"),s=t("./loading-items"),o=function(t){this.id="AssetLoader",this.async=!0,this.pipeline=null};o.ID="AssetLoader";var a=[];o.prototype.handle=function(t,e){var i=t.uuid;if(!i)return t.content?t.content:null;cc.AssetLibrary.queryAssetInfo(i,(function(r,o,c){if(r)e(r);else if(t.url=t.rawUrl=o,t.isRawAsset=c,c){var h=n.extname(o).toLowerCase();if(!h)return void e(new Error("Download Uuid: can not find type of raw asset["+i+"]: "+o));h=h.substr(1);var l=s.getQueue(t);a[0]={queueId:t.queueId,id:o,url:o,type:h,error:null,alias:t,complete:!0},l.append(a),t.type=h,e(null,t.content)}else t.type="uuid",e(null,t.content)}))},r.AssetLoader=e.exports=o}),{"../utils/CCPath":219,"./loading-items":139,"./pipeline":142}],132:[(function(t,e,i){function n(){this._pathToUuid={}}function r(t,e){if(t.length>e.length){var i=t.charCodeAt(e.length);return 46===i||47===i}return!0}var s=t("../utils/misc").pushToMap,o=n.prototype;o.getUuid=function(t,e){t=cc.url.normalize(t);var i=this._pathToUuid[t];if(i)if(Array.isArray(i)){if(!e)return i[0].uuid;for(var n=0;n<i.length;n++){var r=i[n];if(cc.isChildClassOf(r.type,e))return r.uuid}}else if(!e||cc.isChildClassOf(i.type,e))return i.uuid;return""},o.getUuidArray=function(t,e,i){"/"===(t=cc.url.normalize(t))[t.length-1]&&(t=t.slice(0,-1));var n=this._pathToUuid,s=[],o=cc.isChildClassOf;for(var a in n)if(a.startsWith(t)&&r(a,t)||!t){var c=n[a];if(Array.isArray(c))for(var h=0;h<c.length;h++){var l=c[h];e&&!o(l.type,e)||(s.push(l.uuid),i&&i.push(a))}else e&&!o(c.type,e)||(s.push(c.uuid),i&&i.push(a))}return s},o.add=function(t,e,i,n){t=t.substring(0,t.length-cc.path.extname(t).length);var r=new function(t,e){this.uuid=t,this.type=e}(e,i);s(this._pathToUuid,t,r,n)},o._getInfo_DEBUG=!1,o.reset=function(){this._pathToUuid={}},e.exports=n}),{"../utils/misc":226}],133:[(function(t,e,i){t("../utils/CCPath");var n=t("../platform/CCSys"),r=(t("./pipeline"),t("../../audio/CCAudioEngine"),n.__audioSupport),s=r.format,o=r.context;e.exports=function(t,e){if(0===s.length)return new Error("Audio Downloader: audio not supported on this browser!");t.content=t.url,!r.WEB_AUDIO||t.urlParam&&t.urlParam.useDom?(function(t,e){var i=document.createElement("audio");if(i.src=t.url,n.platform===n.WECHAT_GAME)return t.element=i,void e(null,t.url);var s=function(){clearTimeout(o),i.removeEventListener("canplaythrough",a,!1),i.removeEventListener("error",c,!1),r.USE_LOADER_EVENT&&i.removeEventListener(r.USE_LOADER_EVENT,a,!1)},o=setTimeout((function(){0===i.readyState?c():a()}),8e3),a=function(){s(),t.element=i,e(null,t.url)},c=function(){s();var i="load audio failure - "+t.url;cc.log(i),e(i,t.url)};i.addEventListener("canplaythrough",a,!1),i.addEventListener("error",c,!1),r.USE_LOADER_EVENT&&i.addEventListener(r.USE_LOADER_EVENT,a,!1)})(t,e):(function(t,e){o||e(new Error("Audio Downloader: no web audio context."));var i=cc.loader.getXMLHttpRequest();i.open("GET",t.url,!0),i.responseType="arraybuffer",i.onload=function(){o.decodeAudioData(i.response,(function(i){t.buffer=i,e(null,t.id)}),(function(){e("decode error - "+t.id,null)}))},i.onerror=function(){e("request error - "+t.id,null)},i.send()})(t,e)}}),{"../../audio/CCAudioEngine":23,"../platform/CCSys":185,"../utils/CCPath":219,"./pipeline":142}],134:[(function(t,e,i){function n(t,e){var i=cc.loader.getItem(t);if(i){var r=i.dependKeys;if(r)for(var s=0;s<r.length;s++){var o=r[s];e[o]||(e[o]=!0,n(o,e))}}}function r(t,e){var i=cc.loader._getReferenceKey(t);e[i]||(e[i]=!0,n(i,e))}function s(t,e){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var s=t[i[n]];if("object"==typeof s&&s)if(Array.isArray(s))for(var o=0;o<s.length;o++){var a=s[o];a instanceof cc.RawAsset&&r(a,e)}else if(s.constructor&&s.constructor!==Object)s instanceof cc.RawAsset&&r(s,e);else for(var c=Object.getOwnPropertyNames(s),h=0;h<c.length;h++){var l=s[c[h]];l instanceof cc.RawAsset&&r(l,e)}}}function o(t,e){for(var i=0;i<t._components.length;i++)s(t._components[i],e);for(var n=0;n<t._children.length;n++)o(t._children[n],e)}var a=t("../platform/js");e.exports={autoRelease:function(t,e,i){var n=cc.loader._autoReleaseSetting,r=a.createMap();if(e)for(var s=0;s<e.length;s++)r[e[s]]=!0;for(var c=0;c<i.length;c++)o(i[c],r);if(t)for(var h=0;h<t.length;h++){var l=t[h];!1===n[l]||r[l]||cc.loader.release(l)}for(var u=Object.keys(n),_=0;_<u.length;_++){var d=u[_];!0!==n[d]||r[d]||cc.loader.release(d)}},getDependsRecursively:function(t){var e={};return n(t,e),Object.keys(e)}}}),{"../platform/js":197}],135:[(function(t,e,i){function n(t,e,i,r){void 0===i&&(i=!0);var s=f(t.url);if(r=r||l.imagePool.get(),i&&"file:"!==window.location.protocol?r.crossOrigin="anonymous":r.crossOrigin=null,r.complete&&r.naturalWidth>0&&r.src===s)return r;(function(){function i(){r.removeEventListener("load",i),r.removeEventListener("error",o),e(null,r)}function o(){r.removeEventListener("load",i),r.removeEventListener("error",o),"https:"!==window.location.protocol&&r.crossOrigin&&"anonymous"===r.crossOrigin.toLowerCase()?n(t,e,!1,r):e(new Error("Load image ("+s+") failed"))}r.addEventListener("load",i),r.addEventListener("error",o),r.src=s})()}function r(t,e,i){var n=document,r=document.createElement("style");r.type="text/css",n.body.appendChild(r);var s="";if(isNaN(t-0)?s+="@font-face { font-family:"+t+"; src:":s+="@font-face { font-family:'"+t+"'; src:",e instanceof Array)for(var o=0,a=e.length;o<a;o++){var c=e[o];i=h.extname(c).toLowerCase(),s+="url('"+e[o]+"') format('"+p[i]+"')",s+=o===a-1?";":","}else i=i.toLowerCase(),s+="url('"+e+"') format('"+p[i]+"');";r.textContent+=s+"}";var l=document.createElement("div"),u=l.style;u.fontFamily=t,l.innerHTML=".",u.position="absolute",u.left="-100px",u.top="-100px",n.body.appendChild(l)}function s(t,e){var i=t.url,n=t.type,s=t.name,o=t.srcs;if(s&&o?(-1===o.indexOf(i)&&o.push(i),r(s,o)):(n=h.extname(i),r(s=h.basename(i,n),i,n)),!document.fonts)return null;document.fonts.load("1em "+s).then((function(){e(null,null)}),(function(t){e(t)}))}var o,a=t("../platform/js"),c=t("../platform/CCSys"),h=t("../utils/CCPath"),l=t("../utils/misc"),u=t("./pipeline"),_=t("./pack-downloader"),d=t("./text-downloader"),f=t("./utils").urlAppendTimestamp,p={".eot":"embedded-opentype",".ttf":"truetype",".ttc":"truetype",".woff":"woff",".svg":"svg"},m={js:function(e,i,n){function r(){h.parentNode.removeChild(h),h.removeEventListener("load",r,!1),h.removeEventListener("error",s,!1),i(null,o)}function s(){h.parentNode.removeChild(h),h.removeEventListener("load",r,!1),h.removeEventListener("error",s,!1),i(new Error("Load "+o+" failed!"),o)}if(c.platform===c.WECHAT_GAME)return t(e.url),void i(null,e.url);var o=e.url,a=document,h=document.createElement("script");h.async=n,h.src=f(o),h.addEventListener("load",r,!1),h.addEventListener("error",s,!1),a.body.appendChild(h)},png:n,jpg:n,bmp:n,jpeg:n,gif:n,ico:n,tiff:n,webp:function(t,e,i,r){return cc.sys.capabilities.webp?n(t,e,i,r):new Error("Load Webp ( "+t.url+" ) failed")},image:n,mp3:o=t("./audio-downloader"),ogg:o,wav:o,m4a:o,txt:d,xml:d,vsh:d,fsh:d,atlas:d,tmx:d,tsx:d,json:d,ExportJson:d,plist:d,fnt:d,font:s,eot:s,ttf:s,woff:s,svg:s,ttc:s,uuid:function(t,e){var i=_.load(t,e);return void 0===i?this.extMap.json(t,e):i||void 0},default:d},g=function(t){this.id="Downloader",this.async=!0,this.pipeline=null,this._curConcurrent=0,this._loadQueue=[],this.extMap=a.mixin(t,m)};g.ID="Downloader",g.PackDownloader=_,g.prototype.addHandlers=function(t){a.mixin(this.extMap,t)},g.prototype._handleLoadQueue=function(){for(;this._curConcurrent<cc.macro.DOWNLOAD_MAX_CONCURRENT;){var t=this._loadQueue.shift();if(!t)break;var e=this.handle(t.item,t.callback);void 0!==e&&(e instanceof Error?t.callback(e):t.callback(null,e))}},g.prototype.handle=function(t,e){var i=this,n=this.extMap[t.type]||this.extMap.default,r=void 0;if(this._curConcurrent<cc.macro.DOWNLOAD_MAX_CONCURRENT){if(this._curConcurrent++,void 0!==(r=n.call(this,t,(function(t,n){i._curConcurrent=Math.max(0,i._curConcurrent-1),i._handleLoadQueue(),e&&e(t,n)}))))return this._curConcurrent=Math.max(0,this._curConcurrent-1),this._handleLoadQueue(),r}else if(t.ignoreMaxConcurrency){if(void 0!==(r=n.call(this,t,e)))return r}else this._loadQueue.push({item:t,callback:e})},u.Downloader=e.exports=g}),{"../platform/CCSys":185,"../platform/js":197,"../utils/CCPath":219,"../utils/misc":226,"./audio-downloader":133,"./pack-downloader":141,"./pipeline":142,"./text-downloader":144,"./utils":145}],136:[(function(t,e,i){t("./downloader"),t("./loader"),t("./json-unpacker"),t("./loading-items"),t("./pipeline"),t("./CCLoader")}),{"./CCLoader":130,"./downloader":135,"./json-unpacker":137,"./loader":138,"./loading-items":139,"./pipeline":142}],137:[(function(t,e,i){function n(){this.jsons={},this.state=-1}n.prototype.read=function(t,e){var i="string"==typeof e?JSON.parse(e):e;i.length!==t.length&&cc.errorID(4915);for(var n=0;n<t.length;n++){var r=t[n],s=i[n];this.jsons[r]=s}},n.prototype.retrieve=function(t){return this.jsons[t]||null},e.exports=n}),{}],138:[(function(t,e,i){function n(t,e){if("string"!=typeof t.content)return new Error("JSON Loader: Input item doesn't contain string content");try{return JSON.parse(t.content)}catch(e){return new Error("JSON Loader: Parse json ["+t.id+"] failed : "+e)}}function r(t,e){if(o.platform!==o.WECHAT_GAME&&o.platform!==o.QQ_PLAY&&!(t.content instanceof Image))return new Error("Image Loader: Input item doesn't contain Image content");var i=t.rawUrl,n=cc.textureCache.getTextureForKey(i)||new c;return n.url=i,n.initWithElement(t.content),n.handleLoadedTexture(),cc.textureCache.cacheImage(i,n),n}var s=t("../platform/js"),o=t("../platform/CCSys"),a=t("./pipeline"),c=t("../textures/CCTexture2D"),h=t("./uuid-loader"),l=(t("../utils/misc"),{png:r,jpg:r,bmp:r,jpeg:r,gif:r,ico:r,tiff:r,webp:r,image:r,json:n,ExportJson:n,plist:function(t,e){if("string"!=typeof t.content)return new Error("Plist Loader: Input item doesn't contain string content");var i=cc.plistParser.parse(t.content);return i||new Error("Plist Loader: Parse ["+t.id+"] failed")},uuid:h,prefab:h,fire:h,scene:h,default:function(t,e){return null}}),u=function(t){this.id="Loader",this.async=!0,this.pipeline=null,this.extMap=s.mixin(t,l)};u.ID="Loader",u.prototype.addHandlers=function(t){this.extMap=s.mixin(this.extMap,t)},u.prototype.handle=function(t,e){return(this.extMap[t.type]||this.extMap.default).call(this,t,e)},a.Loader=e.exports=u}),{"../platform/CCSys":185,"../platform/js":197,"../textures/CCTexture2D":216,"../utils/misc":226,"./pipeline":142,"./uuid-loader":146}],139:[(function(t,e,i){function n(t){return"string"==typeof(t.url||t)}function r(t,e){var i="object"==typeof t?t.url:t,n={queueId:e,id:i,url:i,rawUrl:void 0,urlParam:(function(t){if(t){var e=t.split("?");if(e&&e[0]&&e[1]){var i={};return e[1].split("&").forEach((function(t){var e=t.split("=");i[e[0]]=e[1]})),i}}})(i),type:"",error:null,content:null,complete:!1,states:{},deps:null};if("object"==typeof t&&(c.mixin(n,t),t.skips))for(var r=0;r<t.skips.length;r++){var s=t.skips[r];n.states[s]=_.COMPLETE}return n.rawUrl=n.url,i&&!n.type&&(n.type=a.extname(i).toLowerCase().substr(1)),n}function s(t,e,i){if(!t||!e)return!1;var n=!1;if(f.push(e.id),e.deps){var r,o,a=e.deps;for(r=0;r<a.length;r++){if((o=a[r]).id===t.id){n=!0;break}if(!(f.indexOf(o.id)>=0)&&(o.deps&&s(t,o,!0))){n=!0;break}}}return i||(f.length=0),n}var o=t("../platform/callbacks-invoker"),a=t("../utils/CCPath"),c=t("../platform/js"),h=0|998*Math.random(),l={},u=[],_={WORKING:1,COMPLETE:2,ERROR:3},d={},f=[],p=function(t,e,i,n){o.call(this),this._id=++h,l[this._id]=this,this._pipeline=t,this._errorUrls=[],this._appending=!1,this._ownerQueue=null,this.onProgress=i,this.onComplete=n,this.map={},this.completed={},this.totalCount=0,this.completedCount=0,this._pipeline?this.active=!0:this.active=!1,e&&(e.length>0?this.append(e):this.allComplete())};p.ItemState=new cc.Enum(_),p.create=function(t,e,i,n){void 0===i?"function"==typeof e&&(n=e,e=i=null):void 0===n&&("function"==typeof e?(n=i,i=e,e=null):(n=i,i=null));var r=u.pop();return r?(r._pipeline=t,r.onProgress=i,r.onComplete=n,l[r._id]=r,r._pipeline&&(r.active=!0),e&&r.append(e)):r=new p(t,e,i,n),r},p.getQueue=function(t){return t.queueId?l[t.queueId]:null},p.itemComplete=function(t){var e=l[t.queueId];e&&e.itemComplete(t.id)},p.initQueueDeps=function(t){var e=d[t._id];e?(e.completed.length=0,e.deps.length=0):e=d[t._id]={completed:[],deps:[]}},p.registerQueueDep=function(t,e){var i=t.queueId||t;if(!i)return!1;var n=d[i];if(n)-1===n.deps.indexOf(e)&&n.deps.push(e);else if(t.id)for(var r in d){var s=d[r];-1!==s.deps.indexOf(t.id)&&-1===s.deps.indexOf(e)&&s.deps.push(e)}},p.finishDep=function(t){for(var e in d){var i=d[e];-1!==i.deps.indexOf(t)&&-1===i.completed.indexOf(t)&&i.completed.push(t)}};var m=p.prototype;c.mixin(m,o.prototype),m.append=function(t,e){if(!this.active)return[];e&&!e.deps&&(e.deps=[]),this._appending=!0;var i,o,a,c=[];for(i=0;i<t.length;++i)if(!(o=t[i]).queueId||this.map[o.id]){if(n(o)){var h=(a=r(o,this._id)).id;this.map[h]||(this.map[h]=a,this.totalCount++,e&&e.deps.push(a),p.registerQueueDep(e||this._id,h),c.push(a))}}else{if(this.map[o.id]=o,e&&e.deps.push(o),o.complete||s(e,o)){this.totalCount++,this.itemComplete(o.id);continue}var u=this,_=l[o.queueId];_&&(this.totalCount++,p.registerQueueDep(e||this._id,o.id),_.addListener(o.id,(function(t){u.itemComplete(t.id)})))}return this._appending=!1,this.completedCount===this.totalCount?this.allComplete():this._pipeline.flowIn(c),c},m._childOnProgress=function(t){if(this.onProgress){var e=d[this._id];this.onProgress(e?e.completed.length:this.completedCount,e?e.deps.length:this.totalCount,t)}},m.allComplete=function(){var t=0===this._errorUrls.length?null:this._errorUrls;this.onComplete&&this.onComplete(t,this)},m.isCompleted=function(){return this.completedCount>=this.totalCount},m.isItemCompleted=function(t){return!!this.completed[t]},m.exists=function(t){return!!this.map[t]},m.getContent=function(t){var e=this.map[t],i=null;return e&&(e.content?i=e.content:e.alias&&(i=e.alias.content)),i},m.getError=function(t){var e=this.map[t],i=null;return e&&(e.error?i=e.error:e.alias&&(i=e.alias.error)),i},m.addListener=o.prototype.add,m.hasListener=o.prototype.has,m.removeListener=o.prototype.remove,m.removeAllListeners=o.prototype.removeAll,m.removeItem=function(t){var e=this.map[t];e&&this.completed[e.alias||t]&&(delete this.completed[t],delete this.map[t],e.alias&&(delete this.completed[e.alias.id],delete this.map[e.alias.id]),this.completedCount--,this.totalCount--)},m.itemComplete=function(t){var e=this.map[t];if(e){var i=this._errorUrls.indexOf(t);if(e.error&&-1===i?this._errorUrls.push(t):e.error||-1===i||this._errorUrls.splice(i,1),this.completed[t]=e,this.completedCount++,p.finishDep(e.id),this.onProgress){var n=d[this._id];this.onProgress(n?n.completed.length:this.completedCount,n?n.deps.length:this.totalCount,e)}this.invoke(t,e),this.removeAll(t),!this._appending&&this.completedCount>=this.totalCount&&this.allComplete()}},m.destroy=function(){this.active=!1,this._appending=!1,this._pipeline=null,this._ownerQueue=null,this._errorUrls.length=0,this.onProgress=null,this.onComplete=null,this.map={},this.completed={},this.totalCount=0,this.completedCount=0,o.call(this),l[this._id]=null,d[this._id]&&(d[this._id].completed.length=0,d[this._id].deps.length=0),-1===u.indexOf(this)&&u.length<10&&u.push(this)},cc.LoadingItems=e.exports=p}),{"../platform/callbacks-invoker":190,"../platform/js":197,"../utils/CCPath":219}],140:[(function(t,e,i){var n=t("./pipeline"),r=/(\.[^.\n\\/]*)$/,s=function(t,e,i){this.id="MD5Pipe",this.async=!1,this.pipeline=null,this.md5AssetsMap=t,this.libraryBase=e,this.rawAssetsBase=i};s.ID="MD5Pipe",s.prototype.handle=function(t){return t.url=this.transformURL(t.url),t},s.prototype.transformURL=function(t){var e=t.indexOf("?"),i=t;if(-1!==e&&(i=t.substr(0,e)),i.startsWith(this.libraryBase))i=i.slice(this.libraryBase.length);else{if(!i.startsWith(this.rawAssetsBase))return t;i=i.slice(this.rawAssetsBase.length)}var n=this.md5AssetsMap[i];if(n){var s=!1;t=t.replace(r,(function(t,e){return s=!0,"."+n+e})),s||(t=t+"."+n)}return t},n.MD5Pipe=e.exports=s}),{"./pipeline":142}],141:[(function(t,e,i){function n(t,e){return new Error("Can not retrieve "+t+" from packer "+e)}var r=t("./json-unpacker"),s=t("../utils/misc").pushToMap,o={},a={},c={},h=0,l=2,u=3;e.exports={initPacks:function(t){a=t;for(var e in t)for(var i=t[e],n=0;n<i.length;n++){var r=i[n],c=1===i.length;s(o,r,e,c)}},_loadNewPack:function(t,e,i){var r=this,s=cc.AssetLibrary.getLibUrlNoExt(e)+".json";cc.loader.load({url:s,ignoreMaxConcurrency:!0},(function(s,o){if(s)return cc.errorID(4916,t),i(s);var a=r._doLoadNewPack(t,e,o);a?i(null,a):i(n(t,e))}))},_doPreload:function(t,e){var i=c[t];i||(i=c[t]=new r),i.state!==u&&(i.read(a[t],e),i.state=u)},_doLoadNewPack:function(t,e,i){var n=c[e];return n.state!==u&&(n.read(a[e],i),n.state=u),n.retrieve(t)},_selectLoadedPack:function(t){for(var e=h,i="",n=0;n<t.length;n++){var r=t[n],s=c[r];if(s){var o=s.state;if(o===u)return r;o>e&&(e=o,i=r)}}return e!==h?i:t[0]},load:function(t,e){var i=t.uuid,s=o[i];if(s){Array.isArray(s)&&(s=this._selectLoadedPack(s));var a=c[s];if(a&&a.state===u){var h=a.retrieve(i);return h||n(i,s)}return a||(console.log("Create unpacker %s for %s",s,i),(a=c[s]=new r).state=l),this._loadNewPack(i,s,e),null}}}}),{"../utils/misc":226,"./json-unpacker":137}],142:[(function(t,e,i){function n(t,e){var i=t.id,r=e.states[i],o=t.next,a=t.pipeline;if(!e.error&&r!==s.WORKING&&r!==s.ERROR)if(r===s.COMPLETE)o?n(o,e):a.flowOut(e);else{e.states[i]=s.WORKING;var c=t.handle(e,(function(t,r){t?(e.error=t,e.states[i]=s.ERROR,a.flowOut(e)):(r&&(e.content=r),e.states[i]=s.COMPLETE,o?n(o,e):a.flowOut(e))}));c instanceof Error?(e.error=c,e.states[i]=s.ERROR,a.flowOut(e)):void 0!==c&&(null!==c&&(e.content=c),e.states[i]=s.COMPLETE,o?n(o,e):a.flowOut(e))}}t("../platform/js");var r=t("./loading-items"),s=r.ItemState,o=function(t){this._pipes=t,this._cache={};for(var e=0;e<t.length;++e){var i=t[e];i.handle&&i.id&&(i.pipeline=this,i.next=e<t.length-1?t[e+1]:null)}};o.ItemState=s;var a=o.prototype;a.insertPipe=function(t,e){if(!t.handle||!t.id||e>this._pipes.length)cc.warnID(4921);else if(this._pipes.indexOf(t)>0)cc.warnID(4922);else{t.pipeline=this;var i=null;e<this._pipes.length&&(i=this._pipes[e]);var n=null;e>0&&(n=this._pipes[e-1]),n&&(n.next=t),t.next=i,this._pipes.splice(e,0,t)}},a.insertPipeAfter=function(t,e){var i=this._pipes.indexOf(t);i<0||this.insertPipe(e,i+1)},a.appendPipe=function(t){t.handle&&t.id&&(t.pipeline=this,t.next=null,this._pipes.length>0&&(this._pipes[this._pipes.length-1].next=t),this._pipes.push(t))},a.flowIn=function(t){var e,i,r=this._pipes[0];if(r){for(e=0;e<t.length;e++)i=t[e],this._cache[i.id]=i;for(e=0;e<t.length;e++)n(r,i=t[e])}else for(e=0;e<t.length;e++)this.flowOut(t[e])},a.flowInDeps=function(t,e,i){return r.create(this,(function(t,e){i(t,e),e.destroy()})).append(e,t)},a.flowOut=function(t){t.error?delete this._cache[t.id]:this._cache[t.id]||(this._cache[t.id]=t),t.complete=!0,r.itemComplete(t)},a.copyItemStates=function(t,e){if(e instanceof Array)for(var i=0;i<e.length;++i)e[i].states=t.states;else e.states=t.states},a.isFlowing=function(){return!0},a.getItems=function(){return null},a.getItem=function(t){var e=this._cache[t];return e?(e.alias&&(e=e.alias),e):e},a.removeItem=function(t){var e=this._cache[t];return e&&e.complete&&delete this._cache[t],e},a.clear=function(){for(var t in this._cache){var e=this._cache[t];delete this._cache[t],e.complete||(e.error=new Error("Canceled manually"),this.flowOut(e))}},cc.Pipeline=e.exports=o}),{"../platform/js":197,"./loading-items":139}],143:[(function(t,e,i){}),{"../platform/js":197}],144:[(function(t,e,i){t("../platform/CCSys");var n=t("./utils").urlAppendTimestamp;e.exports=function(t,e){var i=t.url;i=n(i);var r=cc.loader.getXMLHttpRequest(),s="Load "+i+" failed!",o=window.navigator;r.open("GET",i,!0),/msie/i.test(o.userAgent)&&!/opera/i.test(o.userAgent)?(r.setRequestHeader("Accept-Charset","utf-8"),r.onreadystatechange=function(){4===r.readyState&&(200===r.status||0===r.status?e(null,r.responseText):e({status:r.status,errorMessage:s}))}):(r.overrideMimeType&&r.overrideMimeType("text/plain; charset=utf-8"),r.onload=function(){4===r.readyState&&(200===r.status||0===r.status?e(null,r.responseText):e({status:r.status,errorMessage:s}))},r.onerror=function(){e({status:r.status,errorMessage:s})}),r.send(null)}}),{"../platform/CCSys":185,"./utils":145}],145:[(function(t,e,i){var n=/\?/;e.exports={urlAppendTimestamp:function(t){return cc.game.config.noCache&&"string"==typeof t&&(n.test(t)?t+="&_t="+(new Date-0):t+="?_t="+(new Date-0)),t}}}),{}],146:[(function(t,e,i){function n(t){return t&&(t[0]&&"cc.Scene"===t[0].__type__||t[1]&&"cc.Scene"===t[1].__type__||t[0]&&"cc.Prefab"===t[0].__type__)}function r(t,e){var i;if("string"==typeof t.content)try{i=JSON.parse(t.content)}catch(e){return new Error("Uuid Loader: Parse asset ["+t.id+"] failed : "+e.stack)}else{if("object"!=typeof t.content)return new Error("JSON Loader: Input item doesn't contain string content");i=t.content}var r,a=n(i);r=a?cc._MissingScript.safeFindClass:function(t){var e=s._getClassById(t);return e||(cc.warnID(4903,t),Object)};var c,h=cc.deserialize.Details.pool.get();try{c=cc.deserialize(i,h,{classFinder:r,target:t.existingAsset,customEnv:t})}catch(e){cc.deserialize.Details.pool.put(h);var l=e.stack;return new Error("Uuid Loader: Deserialize asset ["+t.id+"] failed : "+l)}c._uuid=t.uuid;var u=(function(t,e,i){var n=e.deferredLoadRaw;return n?t instanceof cc.Asset&&t.constructor.preventDeferredLoadDependents&&(n=!1):i&&(t instanceof cc.SceneAsset||t instanceof cc.Prefab)&&(n=t.asyncLoadAssets),n})(c,t,a);(function(t,e,i,n,r,s){var a,c,h,l,u,_=n.uuidList,d=e.dependKeys=[];if(r)for(a=[],c=[],h=[],l=0;l<_.length;l++){u=_[l];var f=n.uuidObjList[l],p=n.uuidPropList[l],m=cc.AssetLibrary._getAssetInfoInRuntime(u);if(m.raw){var g=m.url;f[p]=g,d.push(g)}else a.push(f),c.push(p),h.push({type:"uuid",uuid:u,deferredLoadRaw:!0})}else for(a=n.uuidObjList,c=n.uuidPropList,h=new Array(_.length),l=0;l<_.length;l++)u=_[l],h[l]={type:"uuid",uuid:u};if(n.rawProp&&(a.push(i),c.push(n.rawProp),h.push(e.url)),i._preloadRawFiles){var y=s;s=function(){i._preloadRawFiles((function(t){y(t||null,i)}))}}if(0===h.length)return cc.deserialize.Details.pool.put(n),s(null,i);e.content=i,t.flowInDeps(e,h,(function(t,e){var r;for(var l in e.map)(r=e.map[l]).uuid&&r.content&&(r.content._uuid=r.uuid);for(var u=0;u<h.length;u++){var _=h[u].uuid,f=h[u].url,p=a[u],m=c[u];if(r=e.map[f]){var g={obj:p,prop:m};function y(t){var e=t.isRawAsset?t.rawUrl:t.content;this.obj[this.prop]=e,t.uuid!==i._uuid&&d.indexOf(t.id)<0&&d.push(t.id)}if(r.complete||r.content)r.error?cc._throw(r.error):y.call(g,r);else{var v=o.getQueue(r),x=v._callbackTable[_];x?x.unshift(y,g):v.addListener(_,y,g)}}}cc.deserialize.Details.pool.put(n),s(null,i)}))})(this.pipeline,t,c,h,u,e)}var s=t("../platform/js");t("../platform/deserialize");var o=t("./loading-items");e.exports=r,r.isSceneObj=n}),{"../platform/deserialize":192,"../platform/js":197,"./loading-items":139}],147:[(function(t,e,i){function n(t,e,i){e?t._removeComponent(e):a.array.removeAt(t._components,i)}function r(){this._activatingStack=[]}var s=t("./component-scheduler"),o=t("./platform/CCObject").Flags,a=t("./platform/js"),c=o.IsPreloadStarted,h=o.IsOnLoadStarted,l=o.IsOnLoadCalled,u=o.Deactivating,_="c.onLoad();c._objFlags|="+l,d=cc.Class({extends:s.LifeCycleInvoker,add:function(t){this._zero.array.push(t)},remove:function(t){this._zero.fastRemove(t)},cancelInactive:function(t){s.LifeCycleInvoker.stableRemoveInactive(this._zero,t)},invoke:function(){this._invoke(this._zero),this._zero.array.length=0}}),f=s.createInvokeImpl("c.__preload();"),p=s.createInvokeImpl(_),m=new a.Pool(4);m.get=function(){var t=this._get()||{preload:new d(f),onLoad:new s.OneOffInvoker(p),onEnable:new s.OneOffInvoker(s.invokeOnEnable)};t.preload._zero.i=-1;var e=t.onLoad;return e._zero.i=-1,e._neg.i=-1,e._pos.i=-1,e=t.onEnable,e._zero.i=-1,e._neg.i=-1,e._pos.i=-1,t};var g=cc.Class({ctor:r,reset:r,_activateNodeRecursively:function(t,e,i,r){if(t._objFlags&u)cc.errorID(3816,t.name);else{t._activeInHierarchy=!0;for(var s=t._components.length,o=0;o<s;++o){var a=t._components[o];a instanceof cc.Component?this.activateComp(a,e,i,r):(n(t,a,o),--o,--s)}for(var c=0,h=t._children.length;c<h;++c){var l=t._children[c];l._active&&this._activateNodeRecursively(l,e,i,r)}t._onPostActivated(!0)}},_deactivateNodeRecursively:function(t){t._objFlags|=u,t._activeInHierarchy=!1;for(var e=t._components.length,i=0;i<e;++i){var n=t._components[i];if(n._enabled&&(cc.director._compScheduler.disableComp(n),t._activeInHierarchy))return void(t._objFlags&=~u)}for(var r=0,s=t._children.length;r<s;++r){var o=t._children[r];if(o._activeInHierarchy&&(this._deactivateNodeRecursively(o),t._activeInHierarchy))return void(t._objFlags&=~u)}t._onPostActivated(!1),t._objFlags&=~u},activateNode:function(t,e){if(e){var i=m.get();this._activatingStack.push(i),this._activateNodeRecursively(t,i.preload,i.onLoad,i.onEnable),i.preload.invoke(),i.onLoad.invoke(),i.onEnable.invoke(),this._activatingStack.pop(),m.put(i)}else{this._deactivateNodeRecursively(t);for(var n=this._activatingStack,r=0;r<n.length;r++){var s=n[r];s.preload.cancelInactive(c),s.onLoad.cancelInactive(h),s.onEnable.cancelInactive()}}t.emit("active-in-hierarchy-changed",t)},activateComp:function(t,e,i,n){if(t._objFlags&c||(t._objFlags|=c,"function"==typeof t.__preload&&(e?e.add(t):t.__preload())),t._objFlags&h||(t._objFlags|=h,t.onLoad?i?i.add(t):(t.onLoad(),t._objFlags|=l):t._objFlags|=l),t._enabled){if(!t.node._activeInHierarchy)return;cc.director._compScheduler.enableComp(t,n)}},destroyComp:function(t){cc.director._compScheduler.disableComp(t),t.onDestroy&&t._objFlags&l&&t.onDestroy()},resetComp:!1});e.exports=g}),{"./component-scheduler":70,"./platform/CCObject":182,"./platform/js":197,"./utils/misc":226}],148:[(function(t,e,i){function n(){this.localPoint=cc.v2(),this.normalImpulse=0,this.tangentImpulse=0}function r(){}var s,o=t("./CCPhysicsTypes").PTM_RATIO,a=t("./CCPhysicsTypes").ContactType,c=[],h=[cc.v2(),cc.v2()];s=new b2.WorldManifold;var l={points:[],separations:[],normal:cc.v2()},u=[new n,new n];new b2.Manifold;var _={type:0,localPoint:cc.v2(),localNormal:cc.v2(),points:[]},d={normalImpulses:[],tangentImpulses:[]};r.prototype.init=function(t){this.colliderA=t.GetFixtureA().collider,this.colliderB=t.GetFixtureB().collider,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=t,t._contact=this},r.prototype.reset=function(){this.colliderA=null,this.colliderB=null,this.disabled=!1,this._impulse=null,this._b2contact._contact=null,this._b2contact=null},r.prototype.getWorldManifold=function(){var t=l.points,e=l.separations,i=l.normal;this._b2contact.GetWorldManifold(s);var n=s.points,r=s.separations,a=this._b2contact.GetManifold().pointCount;t.length=e.length=a;for(var c=0;c<a;c++){var u=h[c];u.x=n[c].x*o,u.y=n[c].y*o,t[c]=u,e[c]=r[c]*o}return i.x=s.normal.x,i.y=s.normal.y,this._inverted&&(i.x*=-1,i.y*=-1),l},r.prototype.getManifold=function(){for(var t=_.points,e=_.localNormal,i=_.localPoint,n=this._b2contact.GetManifold(),r=n.points,s=t.length=n.pointCount,a=0;a<s;a++){var c=u[a],h=r[a];c.localPoint.x=h.localPoint.x*o,c.localPoint.Y=h.localPoint.Y*o,c.normalImpulse=h.normalImpulse*o,c.tangentImpulse=h.tangentImpulse,t[a]=c}return i.x=n.localPoint.x*o,i.y=n.localPoint.y*o,e.x=n.localNormal.x,e.y=n.localNormal.y,_.type=n.type,this._inverted&&(e.x*=-1,e.y*=-1),_},r.prototype.getImpulse=function(){var t=this._impulse;if(!t)return null;var e,i=d.normalImpulses,n=d.tangentImpulses;e=t.count;for(var r=0;r<e;r++)i[r]=t.normalImpulses[r]*o,n[r]=t.tangentImpulses[r];return n.length=i.length=e,d},r.prototype.emit=function(t){var e;switch(t){case a.BEGIN_CONTACT:e="onBeginContact";break;case a.END_CONTACT:e="onEndContact";break;case a.PRE_SOLVE:e="onPreSolve";break;case a.POST_SOLVE:e="onPostSolve"}var i,n,r,s,o=this.colliderA,c=this.colliderB,h=o.body,l=c.body;if(h.enabledContactListener)for(i=h.node._components,this._inverted=!1,n=0,r=i.length;n<r;n++)(s=i[n])[e]&&s[e](this,o,c);if(l.enabledContactListener)for(i=l.node._components,this._inverted=!0,n=0,r=i.length;n<r;n++)(s=i[n])[e]&&s[e](this,c,o);(this.disabled||this.disabledOnce)&&(this.setEnabled(!1),this.disabledOnce=!1)},r.get=function(t){var e;return(e=0===c.length?new cc.PhysicsContact:c.pop()).init(t),e},r.put=function(t){var e=t._contact;e&&(c.push(e),e.reset())};var f=r.prototype;f.setEnabled=function(t){this._b2contact.SetEnabled(t)},f.isTouching=function(){return this._b2contact.IsTouching()},f.setTangentSpeed=function(t){this._b2contact.SetTangentSpeed(t/o)},f.getTangentSpeed=function(){return this._b2contact.GetTangentSpeed()*o},f.setFriction=function(t){this._b2contact.SetFriction(t)},f.getFriction=function(){return this._b2contact.GetFriction()},f.resetFriction=function(){return this._b2contact.ResetFriction()},f.setRestitution=function(t){this._b2contact.SetRestitution(t)},f.getRestitution=function(){return this._b2contact.GetRestitution()},f.resetRestitution=function(){return this._b2contact.ResetRestitution()},r.ContactType=a,cc.PhysicsContact=e.exports=r}),{"./CCPhysicsTypes":150}],149:[(function(t,e,i){var n=t("./CCPhysicsTypes").ContactType,r=t("./CCPhysicsTypes").BodyType,s=t("./CCPhysicsTypes").RayCastType,o=t("./CCPhysicsTypes").PTM_RATIO,a=(t("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,t("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,new b2.AABB),c=new b2.Vec2,h=new b2.Vec2,l=cc.Class({mixins:[cc.EventTarget],statics:{DrawBits:b2.Draw,PTM_RATIO:o,VELOCITY_ITERATIONS:10,POSITION_ITERATIONS:10,FIXED_TIME_STEP:1/60,MAX_ACCUMULATOR:.2},ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._debugDrawFlags=0,this._debugDrawer=null,this._world=null,this._bodies=[],this._contactMap={},this._contactID=0,this._delayEvents=[],this._accumulator=0,this.enabledAccumulator=!1},pushDelayEvent:function(t,e,i){this._steping?this._delayEvents.push({target:t,func:e,args:i}):t[e].apply(t,i)},update:function(t){var e=this._world;if(e&&this.enabled){this.emit("before-step"),this._steping=!0;var i=l.VELOCITY_ITERATIONS,n=l.POSITION_ITERATIONS;if(this.enabledAccumulator){this._accumulator+=t;var r=l.FIXED_TIME_STEP,s=l.MAX_ACCUMULATOR;for(this._accumulator>s&&(this._accumulator=s);this._accumulator>r;)e.Step(r,i,n),this._accumulator-=r}else{var o=1/cc.game.config.frameRate;e.Step(o,i,n)}e.DrawDebugData(),this._steping=!1;for(var a=this._delayEvents,c=0,h=a.length;c<h;c++){var u=a[c];u.target[u.func].apply(u.target,u.args)}a.length=0,this._syncNode()}},testPoint:function(t){var e=c.x=t.x/o,i=c.y=t.y/o,n=.2/o;a.lowerBound.x=e-n,a.lowerBound.y=i-n,a.upperBound.x=e+n,a.upperBound.y=i+n;var r=this._aabbQueryCallback;r.init(c),this._world.QueryAABB(r,a);var s=r.getFixture();return s?s.collider:null},testAABB:function(t){a.lowerBound.x=t.xMin/o,a.lowerBound.y=t.yMin/o,a.upperBound.x=t.xMax/o,a.upperBound.y=t.yMax/o;var e=this._aabbQueryCallback;e.init(),this._world.QueryAABB(e,a);return e.getFixtures().map((function(t){return t.collider}))},rayCast:function(t,e,i){if(t.equals(e))return[];i=i||s.Closest,c.x=t.x/o,c.y=t.y/o,h.x=e.x/o,h.y=e.y/o;var n=this._raycastQueryCallback;n.init(i),this._world.RayCast(n,c,h);var r=n.getFixtures();if(r.length>0){for(var a=n.getPoints(),l=n.getNormals(),u=n.getFractions(),_=[],d=0,f=r.length;d<f;d++){var p=r[d],m=p.collider;if(i===s.AllClosest){var g=_.find((function(t){return t.collider===m}));if(g){u[d]<g.fraction&&(g.fixtureIndex=m._getFixtureIndex(p),g.point.x=a[d].x*o,g.point.y=a[d].y*o,g.normal.x=l[d].x,g.normal.y=l[d].y,g.fraction=u[d]);continue}}_.push({collider:m,fixtureIndex:m._getFixtureIndex(p),point:cc.v2(a[d].x*o,a[d].y*o),normal:cc.v2(l[d]),fraction:u[d]})}return _}return[]},syncPosition:function(){for(var t=this._bodies,e=0;e<t.length;e++)t[e].syncPosition()},syncRotation:function(){for(var t=this._bodies,e=0;e<t.length;e++)t[e].syncRotation()},attachDebugDrawToCamera:function(t){this._debugDrawer&&t.addTarget(this._debugDrawer.getDrawer())},detachDebugDrawFromCamera:function(t){this._debugDrawer&&t.removeTarget(this._debugDrawer.getDrawer())},_registerContactFixture:function(t){this._contactListener.registerContactFixture(t)},_unregisterContactFixture:function(t){this._contactListener.unregisterContactFixture(t)},_addBody:function(t,e){var i=this._world,n=t.node;i&&n&&(t._b2Body=i.CreateBody(e),t._b2Body.body=t,this._utils.addB2Body(t._b2Body),this._bodies.push(t))},_removeBody:function(t){var e=this._world;if(e){0,t._b2Body.body=null,this._utils.removeB2Body(t._b2Body),e.DestroyBody(t._b2Body),t._b2Body=null;var i=this._bodies.indexOf(t);-1!==i&&this._bodies.splice(i,1)}},_initCallback:function(){if(this._world){if(!this._contactListener){var t=new cc.PhysicsContactListener;t.setBeginContact(this._onBeginContact),t.setEndContact(this._onEndContact),t.setPreSolve(this._onPreSolve),t.setPostSolve(this._onPostSolve),this._world.SetContactListener(t),this._contactListener=t,this._aabbQueryCallback=new cc.PhysicsAABBQueryCallback,this._raycastQueryCallback=new cc.PhysicsRayCastCallback}}else cc.warn("Please init PhysicsManager first")},_init:function(){this.enabled=!0,this.debugDrawFlags=b2.Draw.e_shapeBit},_getWorld:function(){return this._world},_syncNode:function(){this._utils.syncNode();for(var t=this._bodies,e=0,i=t.length;e<i;e++){var n=t[e];n.type===r.Animated&&n.resetVelocity()}},_onSceneLaunched:function(){this._debugDrawer.AddDrawerToNode(cc.director.getScene()._sgNode)},_onBeginContact:function(t){cc.PhysicsContact.get(t).emit(n.BEGIN_CONTACT)},_onEndContact:function(t){var e=t._contact;e&&(e.emit(n.END_CONTACT),cc.PhysicsContact.put(t))},_onPreSolve:function(t){var e=t._contact;e&&e.emit(n.PRE_SOLVE)},_onPostSolve:function(t,e){var i=t._contact;i&&(i._impulse=e,i.emit(n.POST_SOLVE),i._impulse=null)}});cc.js.getset(l.prototype,"enabled",(function(){return this._enabled}),(function(t){if(t&&!this._world){var e=new b2.World(new b2.Vec2(0,-10));e.SetAllowSleeping(!0),this._world=e,this._utils=new cc.PhysicsUtils,this._initCallback()}this._enabled=t})),cc.js.getset(l.prototype,"debugDrawFlags",(function(){return this._debugDrawFlags}),(function(t){if(t&&!this._debugDrawFlags){this._debugDrawer||(this._debugDrawer=new cc.PhysicsDebugDraw(o),this._world.SetDebugDraw(this._debugDrawer));cc.director.getScene()&&this._debugDrawer.AddDrawerToNode(cc.director.getScene()._sgNode),cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH,this._onSceneLaunched,this)}else!t&&this._debugDrawFlags&&cc.director.off(cc.Director.EVENT_AFTER_SCENE_LAUNCH,this._onSceneLaunched,this);this._debugDrawFlags=t,this._debugDrawer&&this._debugDrawer.SetFlags(t)})),cc.js.getset(l.prototype,"gravity",(function(){if(this._world){var t=this._world.GetGravity();return cc.v2(t.x*o,t.y*o)}return cc.v2()}),(function(t){this._world&&this._world.SetGravity(new b2.Vec2(t.x/o,t.y/o))})),cc.PhysicsManager=e.exports=l}),{"./CCPhysicsTypes":150}],150:[(function(t,e,i){var n=cc.Enum({Static:0,Kinematic:1,Dynamic:2,Animated:3});cc.RigidBodyType=n;var r=cc.Enum({Closest:0,Any:1,AllClosest:2,All:3});cc.RayCastType=r,e.exports={BodyType:n,ContactType:{BEGIN_CONTACT:"begin-contact",END_CONTACT:"end-contact",PRE_SOLVE:"pre-solve",POST_SOLVE:"post-solve"},RayCastType:r,PTM_RATIO:32,ANGLE_TO_PHYSICS_ANGLE:-Math.PI/180,PHYSICS_ANGLE_TO_ANGLE:-180/Math.PI}}),{}],151:[(function(t,e,i){function n(t,e){var i=e.length;return e[t<0?i- -t%i:t%i]}function r(t,e,i){for(var r=[];e<t;)e+=i.length;for(;t<=e;++t)r.push(n(t,i));return r}function s(t){_(t);for(var e,i,d,p,m,g,y=[],v=cc.v2(),x=cc.v2(),C=0,T=0,b=0;b<t.length;++b)if(o(b,t)){i=d=1e8;for(var A=0;A<t.length;++A)c(n(b-1,t),n(b,t),n(A,t))&&l(n(b-1,t),n(b,t),n(A-1,t))&&(p=f(n(b-1,t),n(b,t),n(A,t),n(A-1,t)),a(n(b+1,t),n(b,t),p)&&(e=u(n(b,t),p))<i&&(i=e,v=p,C=A)),c(n(b+1,t),n(b,t),n(A+1,t))&&l(n(b+1,t),n(b,t),n(A,t))&&(p=f(n(b+1,t),n(b,t),n(A,t),n(A+1,t)),c(n(b-1,t),n(b,t),p)&&(e=u(n(b,t),p))<d&&(d=e,T=A,x=p));if(C==(T+1)%t.length){var S=v.add(x).div(2);(m=r(b,T,t)).push(S),(g=r(C,b,t)).push(S)}else{for(var w=0,E=C;T<C;)T+=t.length;for(A=C;A<=T;++A)if(function(t,e,i){if(o(t,i)){if(h(n(t,i),n(t-1,i),n(e,i))&&l(n(t,i),n(t+1,i),n(e,i)))return!1}else if(l(n(t,i),n(t+1,i),n(e,i))||h(n(t,i),n(t-1,i),n(e,i)))return!1;if(o(e,i)){if(h(n(e,i),n(e-1,i),n(t,i))&&l(n(e,i),n(e+1,i),n(t,i)))return!1}else if(l(n(e,i),n(e+1,i),n(t,i))||h(n(e,i),n(e-1,i),n(t,i)))return!1;for(var r=0;r<i.length;++r)if((r+1)%i.length!=t&&r!=t&&(r+1)%i.length!=e&&r!=e){var s=cc.v2();if(function(t,e,i,n,r){if(t==i||t==n||e==i||e==n)return!1;var s=t.x,o=t.y,a=e.x,c=e.y,h=i.x,l=i.y,u=n.x,_=n.y;if(Math.max(s,a)<Math.min(h,u)||Math.max(h,u)<Math.min(s,a))return!1;if(Math.max(o,c)<Math.min(l,_)||Math.max(l,_)<Math.min(o,c))return!1;var d=(u-h)*(o-l)-(_-l)*(s-h),f=(a-s)*(o-l)-(c-o)*(s-h),p=(_-l)*(a-s)-(u-h)*(c-o);if(Math.abs(p)<1e-6)return!1;if(d/=p,f/=p,0<d&&d<1&&0<f&&f<1)return r.x=s+d*(a-s),r.y=o+d*(c-o),!0;return!1}(n(t,i),n(e,i),n(r,i),n(r+1,i),s))return!1}return!0}(b,A,t)){var I=1/(u(n(b,t),n(A,t))+1);o(A,t)?l(n(A-1,t),n(A,t),n(b,t))&&h(n(A+1,t),n(A,t),n(b,t))?I+=3:I+=2:I+=1,I>w&&(E=A,w=I)}m=r(b,E,t),g=r(E,b,t)}return y=y.concat(s(m)),y=y.concat(s(g))}y.push(t);for(b=y.length-1;b>=0;b--)0==y[b].length&&y.splice(b,0);return y}function o(t,e){return a(t,e)}function a(t,e,i){if(void 0===i){var r=t,s=e;t=n(r-1,s),e=n(r,s),i=n(r+1,s)}return p(t,e,i)<0}function c(t,e,i){return p(t,e,i)>0}function h(t,e,i){return p(t,e,i)>=0}function l(t,e,i){return p(t,e,i)<=0}function u(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function _(t){d(t)||t.reverse()}function d(t){return t.length<3||(function(t){var e,i=0;for(e=0;e<t.length;e++){var n=(e+1)%t.length;i+=t[e].x*t[n].y,i-=t[e].y*t[n].x}return i/=2})(t)>0}function f(t,e,i,n){var r=cc.v2(),s=e.y-t.y,o=t.x-e.x,a=s*t.x+o*t.y,c=n.y-i.y,h=i.x-n.x,l=c*i.x+h*i.y,u=s*h-c*o;return (function(t,e){return Math.abs(t-e)<=1e-6})(u,0)||(r.x=(h*a-o*l)/u,r.y=(s*l-c*a)/u),r}function p(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}e.exports={ConvexPartition:s,ForceCounterClockWise:_,IsCounterClockWise:d}}),{}],152:[(function(t,e,i){var n=t("./CCPhysicsTypes").PTM_RATIO,r=t("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=t("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,o=t("./utils").getWorldRotation,a=t("./CCPhysicsTypes").BodyType,c=new b2.Vec2,h=new b2.Vec2,l=cc.Vec2.ZERO,u=cc.Class({name:"cc.RigidBody",extends:cc.Component,editor:!1,properties:{_type:a.Dynamic,_allowSleep:!0,_gravityScale:1,_linearDamping:0,_angularDamping:0,_linearVelocity:cc.v2(0,0),_angularVelocity:0,_fixedRotation:!1,enabled:{get:function(){return this._enabled},set:function(){cc.warnID("8200")},visible:!1,override:!0},enabledContactListener:{default:!1,tooltip:!1},bullet:{default:!1,tooltip:!1},type:{type:a,tooltip:!1,get:function(){return this._type},set:function(t){this._type=t,this._b2Body&&(t===a.Animated?this._b2Body.SetType(a.Kinematic):this._b2Body.SetType(t))}},allowSleep:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.IsSleepingAllowed():this._allowSleep},set:function(t){this._allowSleep=t,this._b2Body&&this._b2Body.SetSleepingAllowed(t)}},gravityScale:{tooltip:!1,get:function(){return this._gravityScale},set:function(t){this._gravityScale=t,this._b2Body&&this._b2Body.SetGravityScale(t)}},linearDamping:{tooltip:!1,get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._b2Body&&this._b2Body.SetLinearDamping(this._linearDamping)}},angularDamping:{tooltip:!1,get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._b2Body&&this._b2Body.SetAngularDamping(t)}},linearVelocity:{tooltip:!1,type:cc.Vec2,get:function(){var t=this._linearVelocity;if(this._b2Body){var e=this._b2Body.GetLinearVelocity();t.x=e.x*n,t.y=e.y*n}return t},set:function(t){this._linearVelocity=t;var e=this._b2Body;if(e){var i=e.m_linearVelocity;i.Set(t.x/n,t.y/n),e.SetLinearVelocity(i)}}},angularVelocity:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.GetAngularVelocity()*s:this._angularVelocity},set:function(t){this._angularVelocity=t,this._b2Body&&this._b2Body.SetAngularVelocity(t*r)}},fixedRotation:{tooltip:!1,get:function(){return this._fixedRotation},set:function(t){this._fixedRotation=t,this._b2Body&&this._b2Body.SetFixedRotation(t)}},awake:{tooltip:!1,get:function(){return!!this._b2Body&&this._b2Body.IsAwake()},set:function(t){this._b2Body&&this._b2Body.SetAwake(t)}},active:{visible:!1,get:function(){return!!this._b2Body&&this._b2Body.IsActive()},set:function(t){this._b2Body&&this._b2Body.SetActive(t)}}},getLocalPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLocalPoint(c);e.x=i.x*n,e.y=i.y*n}return e},getWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetWorldPoint(c);e.x=i.x*n,e.y=i.y*n}return e},getWorldVector:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetWorldVector(c);e.x=i.x*n,e.y=i.y*n}return e},getLocalVector:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLocalVector(c);e.x=i.x*n,e.y=i.y*n}return e},getWorldPosition:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetPosition();t.x=e.x*n,t.y=e.y*n}return t},getWorldRotation:function(){return this._b2Body?this._b2Body.GetAngle()*s:0},getLocalCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetLocalCenter();t.x=e.x*n,t.y=e.y*n}return t},getWorldCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetWorldCenter();t.x=e.x*n,t.y=e.y*n}return t},getLinearVelocityFromWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLinearVelocityFromWorldPoint(c);e.x=i.x*n,e.y=i.y*n}return e},getMass:function(){return this._b2Body?this._b2Body.GetMass():0},getInertia:function(){return this._b2Body?this._b2Body.GetInertia()*n*n:0},getJointList:function(){if(!this._b2Body)return[];var t=[],e=this._b2Body.GetJointList();if(!e)return[];t.push(e.joint._joint);for(var i=e.prev;i;)t.push(i.joint._joint),i=i.prev;for(var n=e.next;n;)t.push(n.joint._joint),n=n.next;return t},applyForce:function(t,e,i){this._b2Body&&(c.Set(t.x/n,t.y/n),h.Set(e.x/n,e.y/n),this._b2Body.ApplyForce(c,h,i))},applyForceToCenter:function(t,e){this._b2Body&&(c.Set(t.x/n,t.y/n),this._b2Body.ApplyForceToCenter(c,e))},applyTorque:function(t,e){this._b2Body&&this._b2Body.ApplyTorque(t/n,e)},applyLinearImpulse:function(t,e,i){this._b2Body&&(c.Set(t.x/n,t.y/n),h.Set(e.x/n,e.y/n),this._b2Body.ApplyLinearImpulse(c,h,i))},applyAngularImpulse:function(t,e){this._b2Body&&this._b2Body.ApplyAngularImpulse(t/n/n,e)},syncPosition:function(t){var e=this._b2Body;if(e){var i,r=this.node.convertToWorldSpaceAR(l);if(i=this.type===a.Animated?e.GetLinearVelocity():e.GetPosition(),i.x=r.x/n,i.y=r.y/n,this.type===a.Animated&&t){var s=e.GetPosition(),o=cc.game.config.frameRate;i.x=(i.x-s.x)*o,i.y=(i.y-s.y)*o,e.SetAwake(!0),e.SetLinearVelocity(i)}else e.SetTransform(i,e.GetAngle())}},syncRotation:function(t){var e=this._b2Body;if(e){var i=r*o(this.node);if(this.type===a.Animated&&t){var n=e.GetAngle(),s=cc.game.config.frameRate;e.SetAwake(!0),e.SetAngularVelocity((i-n)*s)}else e.SetTransform(e.GetPosition(),i)}},resetVelocity:function(){var t=this._b2Body;if(t){var e=t.m_linearVelocity;e.Set(0,0),t.SetLinearVelocity(e),t.SetAngularVelocity(0)}},onEnable:function(){this._init()},onDisable:function(){this._destroy()},_registerNodeEvents:function(){var t=this.node;t.on("position-changed",this._onNodePositionChanged,this),t.on("rotation-changed",this._onNodeRotationChanged,this),t.on("scale-changed",this._onNodeScaleChanged,this)},_unregisterNodeEvents:function(){var t=this.node;t.off("position-changed",this._onNodePositionChanged,this),t.off("rotation-changed",this._onNodeRotationChanged,this),t.off("scale-changed",this._onNodeScaleChanged,this)},_onNodePositionChanged:function(){this.syncPosition(!0)},_onNodeRotationChanged:function(t){this.syncRotation(!0)},_onNodeScaleChanged:function(t){if(this._b2Body)for(var e=this.getComponents(cc.PhysicsCollider),i=0;i<e.length;i++)e[i].apply()},_init:function(){cc.director.getPhysicsManager().pushDelayEvent(this,"__init",[])},_destroy:function(){cc.director.getPhysicsManager().pushDelayEvent(this,"__destroy",[])},__init:function(){if(!this._inited){this._registerNodeEvents();var t=new b2.BodyDef;this.type===a.Animated?t.type=a.Kinematic:t.type=this.type,t.allowSleep=this.allowSleep,t.gravityScale=this.gravityScale,t.linearDamping=this.linearDamping,t.angularDamping=this.angularDamping;var e=this.linearVelocity;t.linearVelocity=new b2.Vec2(e.x/n,e.y/n),t.angularVelocity=this.angularVelocity*r,t.fixedRotation=this.fixedRotation,t.bullet=this.bullet;var i=this.node,s=i.convertToWorldSpaceAR(l);t.position=new b2.Vec2(s.x/n,s.y/n),t.angle=-Math.PI/180*o(i),cc.director.getPhysicsManager()._addBody(this,t),this._inited=!0}},__destroy:function(){this._inited&&(cc.director.getPhysicsManager()._removeBody(this),this._unregisterNodeEvents(),this._inited=!1)},_getBody:function(){return this._b2Body}});cc.RigidBody=e.exports=u}),{"./CCPhysicsTypes":150,"./utils":173}],153:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.PhysicsBoxCollider",extends:cc.PhysicsCollider,mixins:[cc.Collider.Box],editor:{menu:!1,requireComponent:cc.RigidBody},_createShape:function(t){var e=Math.abs(t.x),i=Math.abs(t.y),r=this.size.width/2/n*e,s=this.size.height/2/n*i,o=this.offset.x/n*e,a=this.offset.y/n*i,c=new b2.PolygonShape;return c.SetAsBox(r,s,new b2.Vec2(o,a),0),c}});cc.PhysicsBoxCollider=e.exports=r}),{"../CCPhysicsTypes":150}],154:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.PhysicsChainCollider",extends:cc.PhysicsCollider,editor:{menu:!1,inspector:!1,requireComponent:cc.RigidBody},properties:{loop:!1,points:{default:function(){return[cc.v2(-50,0),cc.v2(50,0)]},type:[cc.Vec2]},threshold:{default:1,serializable:!1,visible:!1}},_createShape:function(t){for(var e=new b2.ChainShape,i=this.points,r=[],s=0;s<i.length;s++){var o=i[s];r.push(new b2.Vec2(o.x/n*t.x,o.y/n*t.y))}return this.loop?e.CreateLoop(r,r.length):e.CreateChain(r,r.length),e},resetInEditor:!1,resetPointsByContour:!1});cc.PhysicsChainCollider=e.exports=r}),{"../CCPhysicsTypes":150}],155:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.PhysicsCircleCollider",extends:cc.PhysicsCollider,mixins:[cc.Collider.Circle],editor:{menu:!1,requireComponent:cc.RigidBody},_createShape:function(t){var e=Math.abs(t.x),i=Math.abs(t.y),r=this.offset.x/n*e,s=this.offset.y/n*i,o=new b2.CircleShape;return o.m_radius=this.radius/n*e,o.m_p=new b2.Vec2(r,s),o}});cc.PhysicsCircleCollider=e.exports=r}),{"../CCPhysicsTypes":150}],156:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../utils").getWorldScale,s=cc.Class({name:"cc.PhysicsCollider",extends:cc.Collider,ctor:function(){this._fixtures=[],this._shapes=[],this._inited=!1,this._rect=cc.rect()},properties:{_density:1,_sensor:!1,_friction:.2,_restitution:0,density:{tooltip:!1,get:function(){return this._density},set:function(t){this._density=t}},sensor:{tooltip:!1,get:function(){return this._sensor},set:function(t){this._sensor=t}},friction:{tooltip:!1,get:function(){return this._friction},set:function(t){this._friction=t}},restitution:{tooltip:!1,get:function(){return this._restitution},set:function(t){this._restitution=t}},body:{default:null,type:cc.RigidBody,visible:!1}},onDisable:function(){this._destroy()},onEnable:function(){this._init()},start:function(){this._init()},_getFixtureIndex:function(t){return this._fixtures.indexOf(t)},_init:function(){cc.director.getPhysicsManager().pushDelayEvent(this,"__init",[])},_destroy:function(){cc.director.getPhysicsManager().pushDelayEvent(this,"__destroy",[])},__init:function(){if(!this._inited){var t=this.body||this.getComponent(cc.RigidBody);if(t){var e=t._getBody();if(e){var i=t.node,n=r(i),s=0===n.x&&0===n.y?[]:this._createShape(n);s instanceof Array||(s=[s]);for(var o=1<<i.groupIndex,a=0,c=cc.game.collisionMatrix[i.groupIndex],h=0;h<c.length;h++)c[h]&&(a|=1<<h);for(var l={categoryBits:o,maskBits:a,groupIndex:0},u=cc.director.getPhysicsManager(),_=0;_<s.length;_++){var d=s[_],f=new b2.FixtureDef;f.density=this.density,f.isSensor=this.sensor,f.friction=this.friction,f.restitution=this.restitution,f.shape=d,f.filter=l;var p=e.CreateFixture(f);p.collider=this,t.enabledContactListener&&u._registerContactFixture(p),this._shapes.push(d),this._fixtures.push(p)}this.body=t,this._inited=!0}}}},__destroy:function(){if(this._inited){for(var t=this._fixtures,e=this.body._getBody(),i=cc.director.getPhysicsManager(),n=t.length-1;n>=0;n--){var r=t[n];r.collider=null,i._unregisterContactFixture(r),e&&e.DestroyFixture(r)}this.body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},_createShape:function(){},apply:function(){this._destroy(),this._init()},getAABB:function(){for(var t=1e7,e=1e7,i=-1e7,r=-1e7,s=this._fixtures,o=0;o<s.length;o++)for(var a=s[o],c=a.GetShape().GetChildCount(),h=0;h<c;h++){var l=a.GetAABB(h);l.lowerBound.x<t&&(t=l.lowerBound.x),l.lowerBound.y<e&&(e=l.lowerBound.y),l.upperBound.x>i&&(i=l.upperBound.x),l.upperBound.y>r&&(r=l.upperBound.y)}t*=n,e*=n,i*=n,r*=n;var u=this._rect;return u.x=t,u.y=e,u.width=i-t,u.height=r-e,u}});cc.PhysicsCollider=e.exports=s}),{"../CCPhysicsTypes":150,"../utils":173}],157:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPolygonSeparator"),s=cc.Class({name:"cc.PhysicsPolygonCollider",extends:cc.PhysicsCollider,mixins:[cc.Collider.Polygon],editor:{menu:!1,inspector:!1,requireComponent:cc.RigidBody},_createShape:function(t){var e=[],i=this.points;i.length>0&&i[0].equals(i[i.length-1])&&(i.length-=1);for(var s=r.ConvexPartition(i),o=this.offset,a=0;a<s.length;a++){for(var c=s[a],h=null,l=[],u=null,_=0,d=c.length;_<d;_++){h||(h=new b2.PolygonShape);var f=c[_],p=(f.x+o.x)/n*t.x,m=(f.y+o.y)/n*t.y,g=new b2.Vec2(p,m);l.push(g),u||(u=g),l.length===b2.maxPolygonVertices&&(h.Set(l,l.length),e.push(h),h=null,_<d-1&&(l=[u,l[l.length-1]]))}h&&(h.Set(l,l.length),e.push(h))}return e}});cc.PhysicsPolygonCollider=e.exports=s}),{"../CCPhysicsTypes":150,"../CCPolygonSeparator":151}],158:[(function(t,e,i){window.b2=t("../../../external/box2d/box2d"),t("./CCPhysicsManager"),t("./CCRigidBody"),t("./CCPhysicsContact"),t("./collider/CCPhysicsCollider"),t("./collider/CCPhysicsChainCollider"),t("./collider/CCPhysicsCircleCollider"),t("./collider/CCPhysicsBoxCollider"),t("./collider/CCPhysicsPolygonCollider"),t("./joint/CCJoint"),t("./joint/CCDistanceJoint"),t("./joint/CCRevoluteJoint"),t("./joint/CCMouseJoint"),t("./joint/CCMotorJoint"),t("./joint/CCPrismaticJoint"),t("./joint/CCWeldJoint"),t("./joint/CCWheelJoint"),t("./joint/CCRopeJoint"),t("./platform/CCPhysicsDebugDraw"),t("./platform/CCPhysicsUtils"),t("./platform/CCPhysicsContactListner"),t("./platform/CCPhysicsAABBQueryCallback"),t("./platform/CCPhysicsRayCastCallback")}),{"../../../external/box2d/box2d":310,"./CCPhysicsContact":148,"./CCPhysicsManager":149,"./CCRigidBody":152,"./collider/CCPhysicsBoxCollider":153,"./collider/CCPhysicsChainCollider":154,"./collider/CCPhysicsCircleCollider":155,"./collider/CCPhysicsCollider":156,"./collider/CCPhysicsPolygonCollider":157,"./joint/CCDistanceJoint":159,"./joint/CCJoint":160,"./joint/CCMotorJoint":161,"./joint/CCMouseJoint":162,"./joint/CCPrismaticJoint":163,"./joint/CCRevoluteJoint":164,"./joint/CCRopeJoint":165,"./joint/CCWeldJoint":166,"./joint/CCWheelJoint":167,"./platform/CCPhysicsAABBQueryCallback":168,"./platform/CCPhysicsContactListner":169,"./platform/CCPhysicsDebugDraw":170,"./platform/CCPhysicsRayCastCallback":171,"./platform/CCPhysicsUtils":172}],159:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.DistanceJoint",extends:cc.Joint,editor:!1,properties:{_distance:1,_frequency:0,_dampingRatio:0,distance:{tooltip:!1,get:function(){return this._distance},set:function(t){this._distance=t,this._joint&&this._joint.SetLength(t)}},frequency:{tooltip:!1,get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.SetFrequency(t)}},dampingRatio:{tooltip:!1,get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.SetDampingRatio(t)}}},_createJointDef:function(){var t=new b2.DistanceJointDef;return t.localAnchorA=new b2.Vec2(this.anchor.x/n,this.anchor.y/n),t.localAnchorB=new b2.Vec2(this.connectedAnchor.x/n,this.connectedAnchor.y/n),t.length=this.distance/n,t.dampingRatio=this.dampingRatio,t.frequencyHz=this.frequency,t}});cc.DistanceJoint=e.exports=r}),{"../CCPhysicsTypes":150}],160:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.Joint",extends:cc.Component,editor:{requireComponent:cc.RigidBody},properties:{anchor:{default:cc.v2(0,0),tooltip:!1},connectedAnchor:{default:cc.v2(0,0),tooltip:!1},connectedBody:{default:null,type:cc.RigidBody,tooltip:!1},collideConnected:{default:!1,tooltip:!1}},onDisable:function(){this._destroy()},onEnable:function(){this._init()},start:function(){this._init()},apply:function(){this._destroy(),this._init()},getWorldAnchor:function(){if(this._joint){var t=this._joint.GetAnchorA();return cc.v2(t.x*n,t.y*n)}return cc.Vec2.ZERO},getWorldConnectedAnchor:function(){if(this._joint){var t=this._joint.GetAnchorB();return cc.v2(t.x*n,t.y*n)}return cc.Vec2.ZERO},getReactionForce:function(t){return this._joint?this._joint.GetReactionForce(t):0},getReactionTorque:function(t){return this._joint?this._joint.GetReactionTorque(t):0},_init:function(){cc.director.getPhysicsManager().pushDelayEvent(this,"__init",[])},_destroy:function(){cc.director.getPhysicsManager().pushDelayEvent(this,"__destroy",[])},__init:function(){if(!this._inited&&(this.body=this.getComponent(cc.RigidBody),this._isValid())){var t=cc.director.getPhysicsManager()._getWorld(),e=this._createJointDef();if(!e)return;e.bodyA=this.body._getBody(),e.bodyB=this.connectedBody._getBody(),e.collideConnected=this.collideConnected,this._joint=t.CreateJoint(e),this._joint&&(this._joint._joint=this),this._inited=!0}},__destroy:function(){this._inited&&(this._isValid()&&cc.director.getPhysicsManager()._getWorld().DestroyJoint(this._joint),this._joint&&(this._joint._joint=null),this._joint=null,this._inited=!1)},_createJointDef:function(){return null},_isValid:function(){return this.body&&this.body._getBody()&&this.connectedBody&&this.connectedBody._getBody()}});cc.Joint=e.exports=r}),{"../CCPhysicsTypes":150}],161:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=cc.Class({name:"cc.MotorJoint",extends:cc.Joint,editor:!1,properties:{_linearOffset:cc.v2(0,0),_angularOffset:0,_maxForce:1,_maxTorque:1,_correctionFactor:.3,anchor:{tooltip:!1,default:cc.v2(0,0),override:!0,visible:!1},connectedAnchor:{tooltip:!1,default:cc.v2(0,0),override:!0,visible:!1},linearOffset:{tooltip:!1,get:function(){return this._linearOffset},set:function(t){this._linearOffset=t,this._joint&&this._joint.SetLinearOffset(new b2.Vec2(t.x/n,t.y/n))}},angularOffset:{tooltip:!1,get:function(){return this._angularOffset},set:function(t){this._angularOffset=t,this._joint&&this._joint.SetAngularOffset(t)}},maxForce:{tooltip:!1,get:function(){return this._maxForce},set:function(t){this._maxForce=t,this._joint&&this._joint.SetMaxForce(t)}},maxTorque:{tooltip:!1,get:function(){return this._maxTorque},set:function(t){this._maxTorque=t,this._joint&&this._joint.SetMaxTorque(t)}},correctionFactor:{tooltip:!1,get:function(){return this._correctionFactor},set:function(t){this._correctionFactor=t,this._joint&&this._joint.SetCorrectionFactor(t)}}},_createJointDef:function(){var t=new b2.MotorJointDef;return t.linearOffset=new b2.Vec2(this.linearOffset.x/n,this.linearOffset.y/n),t.angularOffset=this.angularOffset*r,t.maxForce=this.maxForce,t.maxTorque=this.maxTorque,t.correctionFactor=this.correctionFactor,t}});cc.MotorJoint=e.exports=s}),{"../CCPhysicsTypes":150}],162:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=new b2.Vec2,s=cc.Class({name:"cc.MouseJoint",extends:cc.Joint,editor:!1,properties:{_target:1,_frequency:5,_dampingRatio:.7,_maxForce:0,connectedBody:{default:null,type:cc.RigidBody,visible:!1,override:!0},collideConnected:{default:!0,visible:!1,override:!0},anchor:{tooltip:!1,default:cc.v2(0,0),override:!0,visible:!1},connectedAnchor:{tooltip:!1,default:cc.v2(0,0),override:!0,visible:!1},mouseRegion:{tooltip:!1,default:null,type:cc.Node},target:{tooltip:!1,visible:!1,get:function(){return this._target},set:function(t){this._target=t,this._joint&&(r.x=t.x/n,r.y=t.y/n,this._joint.SetTarget(r))}},frequency:{tooltip:!1,get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.SetFrequency(t)}},dampingRatio:{tooltip:!1,get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.SetDampingRatio(t)}},maxForce:{tooltip:!1,visible:!1,get:function(){return this._maxForce},set:function(t){this._maxForce=t,this._joint&&this._joint.SetMaxForce(t)}}},onLoad:function(){var t=this.mouseRegion||this.node;t.on(cc.Node.EventType.TOUCH_START,this.onTouchBegan,this),t.on(cc.Node.EventType.TOUCH_MOVE,this.onTouchMove,this),t.on(cc.Node.EventType.TOUCH_END,this.onTouchEnd,this)},onEnable:function(){},start:function(){},onTouchBegan:function(t){var e=cc.director.getPhysicsManager(),i=this._pressPoint=t.touch.getLocation();cc.Camera&&cc.Camera.main&&(i=cc.Camera.main.getCameraToWorldPoint(i));var n=e.testPoint(i);if(n){(this.connectedBody=n.body).awake=!0,this.maxForce=1e3*this.connectedBody.getMass(),this.target=i,this._init()}},onTouchMove:function(t){this._pressPoint=t.touch.getLocation()},onTouchEnd:function(t){this._destroy(),this._pressPoint=null},_createJointDef:function(){var t=new b2.MouseJointDef;return r.x=this.target.x/n,r.y=this.target.y/n,t.target=r,t.maxForce=this.maxForce,t.dampingRatio=this.dampingRatio,t.frequencyHz=this.frequency,t},update:function(){this._pressPoint&&this._isValid()&&(cc.Camera&&cc.Camera.main?this.target=cc.Camera.main.getCameraToWorldPoint(this._pressPoint):this.target=this._pressPoint)}});cc.MouseJoint=e.exports=s}),{"../CCPhysicsTypes":150}],163:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=cc.Class({name:"cc.PrismaticJoint",extends:cc.Joint,editor:!1,properties:{localAxisA:{default:cc.v2(1,0),tooltip:!1},referenceAngle:{default:0,tooltip:!1},enableLimit:{default:!1,tooltip:!1},enableMotor:{default:!1,tooltip:!1},lowerLimit:{default:0,tooltip:!1},upperLimit:{default:0,tooltip:!1},_maxMotorForce:0,_motorSpeed:0,maxMotorForce:{tooltip:!1,get:function(){return this._maxMotorForce},set:function(t){this._maxMotorForce=t,this._joint&&this._joint.SetMaxMotorForce(t)}},motorSpeed:{tooltip:!1,get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.SetMotorSpeed(t)}}},_createJointDef:function(){var t=new b2.PrismaticJointDef;return t.localAnchorA=new b2.Vec2(this.anchor.x/n,this.anchor.y/n),t.localAnchorB=new b2.Vec2(this.connectedAnchor.x/n,this.connectedAnchor.y/n),t.localAxisA=new b2.Vec2(this.localAxisA.x,this.localAxisA.y),t.referenceAngle=this.referenceAngle*r,t.enableLimit=this.enableLimit,t.lowerTranslation=this.lowerLimit/n,t.upperTranslation=this.upperLimit/n,t.enableMotor=this.enableMotor,t.maxMotorForce=this.maxMotorForce,t.motorSpeed=this.motorSpeed,t}});cc.PrismaticJoint=e.exports=s}),{"../CCPhysicsTypes":150}],164:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=t("../CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,o=cc.Class({name:"cc.RevoluteJoint",extends:cc.Joint,editor:!1,properties:{_maxMotorTorque:0,_motorSpeed:0,_enableLimit:!1,_enableMotor:!1,referenceAngle:{default:0,tooltip:!1},lowerAngle:{default:0,tooltip:!1},upperAngle:{default:0,tooltip:!1},maxMotorTorque:{tooltip:!1,get:function(){return this._maxMotorTorque},set:function(t){this._maxMotorTorque=t,this._joint&&this._joint.SetMaxMotorTorque(t)}},motorSpeed:{tooltip:!1,get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.SetMotorSpeed(t*r)}},enableLimit:{tooltip:!1,get:function(){return this._enableLimit},set:function(t){this._enableLimit=t,this._joint&&this._joint.EnableLimit(t)}},enableMotor:{tooltip:!1,get:function(){return this._enableMotor},set:function(t){this._enableMotor=t,this._joint&&this._joint.EnableMotor(t)}}},getJointAngle:function(){return this._joint?this._joint.GetJointAngle()*s:0},_createJointDef:function(){var t=new b2.RevoluteJointDef;return t.localAnchorA=new b2.Vec2(this.anchor.x/n,this.anchor.y/n),t.localAnchorB=new b2.Vec2(this.connectedAnchor.x/n,this.connectedAnchor.y/n),t.lowerAngle=(this.upperAngle+90)*r,t.upperAngle=(this.lowerAngle+90)*r,t.maxMotorTorque=this.maxMotorTorque,t.motorSpeed=this.motorSpeed*r,t.enableLimit=this.enableLimit,t.enableMotor=this.enableMotor,t.referenceAngle=this.referenceAngle*r,t}});cc.RevoluteJoint=e.exports=o}),{"../CCPhysicsTypes":150}],165:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.RopeJoint",extends:cc.Joint,editor:!1,properties:{_maxLength:1,maxLength:{tooltip:!1,get:function(){return this._maxLength},set:function(t){this._maxLength=t,this._joint&&this._joint.SetMaxLength(t)}}},_createJointDef:function(){var t=new b2.RopeJointDef;return t.localAnchorA=new b2.Vec2(this.anchor.x/n,this.anchor.y/n),t.localAnchorB=new b2.Vec2(this.connectedAnchor.x/n,this.connectedAnchor.y/n),t.maxLength=this.maxLength/n,t}});cc.RopeJoint=e.exports=r}),{"../CCPhysicsTypes":150}],166:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=cc.Class({name:"cc.WeldJoint",extends:cc.Joint,editor:!1,properties:{referenceAngle:{default:0,tooltip:!1},_frequency:0,_dampingRatio:0,frequency:{tooltip:!1,get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.SetFrequency(t)}},dampingRatio:{tooltip:!1,get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.SetDampingRatio(t)}}},_createJointDef:function(){var t=new b2.WeldJointDef;return t.localAnchorA=new b2.Vec2(this.anchor.x/n,this.anchor.y/n),t.localAnchorB=new b2.Vec2(this.connectedAnchor.x/n,this.connectedAnchor.y/n),t.referenceAngle=this.referenceAngle*r,t.frequencyHz=this.frequency,t.dampingRatio=this.dampingRatio,t}});cc.WeldJoint=e.exports=s}),{"../CCPhysicsTypes":150}],167:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=cc.Class({name:"cc.WheelJoint",extends:cc.Joint,editor:!1,properties:{_maxMotorTorque:0,_motorSpeed:0,_enableMotor:!1,_frequency:2,_dampingRatio:.7,localAxisA:{default:cc.v2(1,0),tooltip:!1},maxMotorTorque:{tooltip:!1,get:function(){return this._maxMotorTorque},set:function(t){this._maxMotorTorque=t,this._joint&&this._joint.SetMaxMotorTorque(t)}},motorSpeed:{tooltip:!1,get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.SetMotorSpeed(t*r)}},enableMotor:{tooltip:!1,get:function(){return this._enableMotor},set:function(t){this._enableMotor=t,this._joint&&this._joint.EnableMotor(t)}},frequency:{tooltip:!1,get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.SetFrequency(t)}},dampingRatio:{tooltip:!1,get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.SetDampingRatio(t)}}},_createJointDef:function(){var t=new b2.WheelJointDef;return t.localAnchorA=new b2.Vec2(this.anchor.x/n,this.anchor.y/n),t.localAnchorB=new b2.Vec2(this.connectedAnchor.x/n,this.connectedAnchor.y/n),t.localAxisA=new b2.Vec2(this.localAxisA.x,this.localAxisA.y),t.maxMotorTorque=this.maxMotorTorque,t.motorSpeed=this.motorSpeed*r,t.enableMotor=this.enableMotor,t.dampingRatio=this.dampingRatio,t.frequencyHz=this.frequency,t}});cc.WheelJoint=e.exports=s}),{"../CCPhysicsTypes":150}],168:[(function(t,e,i){function n(){this._point=new b2.Vec2,this._isPoint=!1,this._fixtures=[]}n.prototype.init=function(t){t?(this._isPoint=!0,this._point.x=t.x,this._point.y=t.y):this._isPoint=!1,this._fixtures.length=0},n.prototype.ReportFixture=function(t){if(t.GetBody().GetType()===b2.Body.b2_dynamicBody)if(this._isPoint){if(t.TestPoint(this._point))return this._fixtures.push(t),!1}else this._fixtures.push(t);return!0},n.prototype.getFixture=function(){return this._fixtures[0]},n.prototype.getFixtures=function(){return this._fixtures},cc.PhysicsAABBQueryCallback=e.exports=n}),{}],169:[(function(t,e,i){function n(){this._contactFixtures=[]}n.prototype.setBeginContact=function(t){this._BeginContact=t},n.prototype.setEndContact=function(t){this._EndContact=t},n.prototype.setPreSolve=function(t){this._PreSolve=t},n.prototype.setPostSolve=function(t){this._PostSolve=t},n.prototype.BeginContact=function(t){if(this._BeginContact){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=this._contactFixtures;t._shouldReport=!1,-1===n.indexOf(e)&&-1===n.indexOf(i)||(t._shouldReport=!0,this._BeginContact(t))}},n.prototype.EndContact=function(t){this._EndContact&&t._shouldReport&&(t._shouldReport=!1,this._EndContact(t))},n.prototype.PreSolve=function(t,e){this._PreSolve&&t._shouldReport&&this._PreSolve(t,e)},n.prototype.PostSolve=function(t,e){this._PostSolve&&t._shouldReport&&this._PostSolve(t,e)},n.prototype.registerContactFixture=function(t){this._contactFixtures.push(t)},n.prototype.unregisterContactFixture=function(t){cc.js.array.remove(this._contactFixtures,t)},cc.PhysicsContactListener=e.exports=n}),{}],170:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=cc.Class({name:"cc.PhysicsDebugDraw",mixins:[b2.Draw],ctor:function(){this._drawer=new _ccsg.GraphicsNode,this._drawer.retain()},getDrawer:function(){return this._drawer},AddDrawerToNode:function(t){this._drawer.removeFromParent(),t.addChild(this._drawer)},ClearDraw:function(){this._drawer.clear()},_DrawPolygon:function(t,e){for(var i=this._drawer,r=0;r<e;r++)0===r?i.moveTo(t[r].x*n,t[r].y*n):i.lineTo(t[r].x*n,t[r].y*n);i.close()},DrawPolygon:function(t,e,i){this._applyStrokeColor(i),this._DrawPolygon(t,e),this._drawer.stroke()},DrawSolidPolygon:function(t,e,i){this._applyFillColor(i),this._DrawPolygon(t,e),this._drawer.fill(),this._drawer.stroke()},_DrawCircle:function(t,e){this._drawer.circle(t.x*n,t.y*n,e*n)},DrawCircle:function(t,e,i){this._applyStrokeColor(i),this._DrawCircle(t,e),this._drawer.stroke()},DrawSolidCircle:function(t,e,i,n){this._applyFillColor(n),this._DrawCircle(t,e),this._drawer.fill()},DrawSegment:function(t,e,i){var r=this._drawer;if(t.x===e.x&&t.y===e.y)return this._applyFillColor(i),this._DrawCircle(t,2/n),void r.fill();this._applyStrokeColor(i),r.moveTo(t.x*n,t.y*n),r.lineTo(e.x*n,e.y*n),r.stroke()},DrawPoint:function(t,e,i){},_applyStrokeColor:function(t){this._drawer.setStrokeColor(cc.color(255*t.r,255*t.g,255*t.b,150))},_applyFillColor:function(t){this._drawer.setFillColor(cc.color(255*t.r,255*t.g,255*t.b,150))}});cc.PhysicsDebugDraw=e.exports=r}),{"../CCPhysicsTypes":150}],171:[(function(t,e,i){function n(){this._type=0,this._fixtures=[],this._points=[],this._normals=[],this._fractions=[]}n.prototype.init=function(t){this._type=t,this._fixtures.length=0,this._points.length=0,this._normals.length=0,this._fractions.length=0},n.prototype.ReportFixture=function(t,e,i,n){return 0===this._type?(this._fixtures[0]=t,this._points[0]=e,this._normals[0]=i,this._fractions[0]=n,n):(this._fixtures.push(t),this._points.push(e),this._normals.push(i),this._fractions.push(n),1===this._type?0:this._type>=2?1:n)},n.prototype.getFixtures=function(){return this._fixtures},n.prototype.getPoints=function(){return this._points},n.prototype.getNormals=function(){return this._normals},n.prototype.getFractions=function(){return this._fractions},cc.PhysicsRayCastCallback=e.exports=n}),{}],172:[(function(t,e,i){function n(){}var r=t("../CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,s=t("../CCPhysicsTypes").PTM_RATIO,o=t("../utils").convertToNodeRotation,a=cc.v2();n.prototype.addB2Body=function(t){},n.prototype.removeB2Body=function(t){},n.prototype.syncNode=function(){for(var t=cc.director.getPhysicsManager()._bodies,e=0,i=t.length;e<i;e++){var n=t[e],c=n.node,h=n._b2Body,l=h.GetPosition();a.x=l.x*s,a.y=l.y*s;var u=h.GetAngle()*r;null!==c.parent.parent&&(a=c.parent.convertToNodeSpaceAR(a),u=o(c.parent,u));var _=c._sgNode,d=c._position;d.x=a.x,d.y=a.y,_.setPosition(d),c._rotationX=c._rotationY=u,_.rotation=u}},cc.PhysicsUtils=e.exports=n}),{"../CCPhysicsTypes":150,"../utils":173}],173:[(function(t,e,i){e.exports={getWorldRotation:function(t){for(var e=t.rotationX,i=t.parent;i.parent;)e+=i.rotationX,i=i.parent;return e},getWorldScale:function(t){for(var e=t.scaleX,i=t.scaleY,n=t.parent;n.parent;)e*=n.scaleX,i*=n.scaleY,n=n.parent;return cc.v2(e,i)},convertToNodeRotation:function(t,e){e-=t.rotationX;for(var i=t.parent;i.parent;)e-=i.rotationX,i=i.parent;return e}}}),{}],174:[(function(t,e,i){}),{"../event-manager":110,"../platform/js":197,"./CCMacro":181,"./CCSys":185}],175:[(function(t,e,i){function n(t){return t&&(t.constructor===cc.SceneAsset||t instanceof cc.Scene)}function r(t,e){this.url=t,this.type=e}var s=t("../assets/CCAsset"),o=t("./utils").callInNextTick,a=t("../load-pipeline/CCLoader"),c=t("../load-pipeline/pack-downloader"),h=t("../load-pipeline/auto-release-utils"),l=t("../utils/decode-uuid"),u=t("../load-pipeline/md5-pipe"),_="",d="",f={},p={loadAsset:function(t,e,i){if("string"!=typeof t)return o(e,new Error("[AssetLibrary] uuid must be string"),null);var r={uuid:t,type:"uuid"};i&&i.existingAsset&&(r.existingAsset=i.existingAsset),a.load(r,(function(i,r){if(i||!r)i=new Error("[AssetLibrary] loading JSON or dependencies failed: "+(i?i.message:"Unknown error"));else{if(r.constructor===cc.SceneAsset){var s=cc.loader._getReferenceKey(t);r.scene.dependAssets=h.getDependsRecursively(s)}if(n(r)){var o=cc.loader._getReferenceKey(t);a.removeItem(o)}}e&&e(i,r)}))},getLibUrlNoExt:function(t){return t=l(t),_+t.slice(0,2)+"/"+t},_queryAssetInfoInEditor:function(t,e){0},_getAssetInfoInRuntime:function(t,e){e=e||{url:null,raw:!1};var i=f[t];return i&&!cc.isChildClassOf(i.type,cc.Asset)?(e.url=d+i.url,e.raw=!0):(e.url=this.getLibUrlNoExt(t)+".json",e.raw=!1),e},_getAssetUrl:function(t){var e=f[t];return e?d+e.url:null},queryAssetInfo:function(t,e){var i=this._getAssetInfoInRuntime(t);e(null,i.url,i.raw)},parseUuidInEditor:function(t){},loadJson:function(t,e){var i=""+((new Date).getTime()+Math.random()),r={uuid:i,type:"uuid",content:t,skips:[a.assetLoader.id,a.downloader.id]};a.load(r,(function(t,r){if(t)t=new Error("[AssetLibrary] loading JSON or dependencies failed: "+t.message);else{if(r.constructor===cc.SceneAsset){var s=cc.loader._getReferenceKey(i);r.scene.dependAssets=h.getDependsRecursively(s)}if(n(r)){var o=cc.loader._getReferenceKey(i);a.removeItem(o)}}r._uuid="",e&&e(t,r)}))},getAssetByUuid:function(t){return p._uuidToAsset[t]||null},init:function(t){var e=t.libraryPath;e=e.replace(/\\/g,"/"),_=cc.path.stripSep(e)+"/",d=t.rawAssetsBase;var i=t.md5AssetsMap;if(i){var n=new u(i,_,d);cc.loader.insertPipeAfter(cc.loader.assetLoader,n),cc.loader.md5Pipe=n}var o=a._resources;o.reset();var h=t.rawAssets;if(h){var l="resources/";for(var p in h){var m=h[p];for(var g in m){var y=m[g],v=y[0],x=y[1],C=cc.js._getClassById(x);if(C){if(f[g]=new r(p+"/"+v,C),"assets"===p&&v.startsWith(l)){if(cc.isChildClassOf(C,s)){var T=cc.path.extname(v);v=T?v.slice(l.length,-T.length):v.slice(l.length)}else v=v.slice(l.length);var b=1===y[2];o.add(v,g,C,!b)}}else cc.error("Cannot get",x)}}}t.packedAssets&&c.initPacks(t.packedAssets);var A=t.mountPaths;A||(A={assets:d+"assets",internal:d+"internal"}),cc.url._init(A)}};p._uuidToAsset={},e.exports=cc.AssetLibrary=p}),{"../assets/CCAsset":43,"../load-pipeline/CCLoader":130,"../load-pipeline/auto-release-utils":134,"../load-pipeline/md5-pipe":140,"../load-pipeline/pack-downloader":141,"../utils/decode-uuid":223,"./utils":201}],176:[(function(t,e,i){function n(t,e){t.indexOf(e)<0&&t.push(e)}function r(t,e){n(t.__props__,e)}function s(t,e,i,n,s){var o=n.default;x.setClassAttr(t,i,"default",o),r(t,i);var a=m(t,n,e,i,!1);if(a){for(var c=w,h=0;h<a.length;h++){var l=a[h];x.attr(t,i,l),l._onAfterProp&&c.push(l._onAfterProp)}for(var u=0;u<c.length;u++)c[u](t,i);w.length=0,a.length=0}}function o(t,e,i,n,r){var s=n.get,o=n.set,a=t.prototype,c=Object.getOwnPropertyDescriptor(a,i),h=!c;if(s){0;for(var l=m(t,n,e,i,!0),u=0;u<l.length;u++)x.attr(t,i,l[u]);l.length=0;x.setClassAttr(t,i,"serializable",!1),r||g.get(a,i,s,h,h)}o&&(r||g.set(a,i,o,h,h))}function a(t){return"function"==typeof t?t():t}function c(t,e,i){for(var n in e)t.hasOwnProperty(n)||i&&!i(n)||Object.defineProperty(t,n,g.getPropertyDescriptor(e,n))}function h(t,e,i,r){var s,o,a=r.__ctor__,h=r.ctor,l=r.__ES6__;l?(s=[h],o=h):(s=a?[a]:(function(t,e,i){function r(t){return p._isCCClass(t)?t.__ctors__||[]:[t]}for(var s=[],o=[t].concat(e),a=0;a<o.length;a++){var c=o[a];if(c)for(var h=r(c),l=0;l<h.length;l++)n(s,h[l])}var u=i.ctor;u&&s.push(u);return s})(e,i,r),o=I(s,e,t,r),g.value(o,"extend",(function(t){return t.extends=this,p(t)}),!0)),g.value(o,"__ctors__",s.length>0?s:null,!0);var u=o.prototype;if(e&&(l||(g.extend(o,e),u=o.prototype),g.value(o,"$super",e)),i){for(var d=i.length-1;d>=0;d--){var f=i[d];c(u,f.prototype),c(o,f,(function(t){return f.hasOwnProperty(t)&&!0})),p._isCCClass(f)&&c(x.getClassAttrs(o).constructor.prototype,x.getClassAttrs(f).constructor.prototype)}u.constructor=o}return l||(u.__initProps__=_),g.setClassName(t,o),o}function l(t){for(var e=g.getClassName(t),i=t.constructor,n="new "+e+"(",r=0;r<i.__props__.length;r++){var s=t[i.__props__[r]];if("object"==typeof s)return cc.errorID(3641,e),"new "+e+"()";n+=s,r<i.__props__.length-1&&(n+=",")}return n+")"}function u(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function _(t){var e=x.getClassAttrs(t),i=t.__props__;null===i&&(S.init(),i=t.__props__);var n=(function(t,e){for(var i=[],n="",r=0;r<e.length;r++){var s=e[r],o=s+C+"default";if(o in t){var a;a=E.test(s)?"this."+s+"=":"this["+u(s)+"]=";var c,h=t[o];if("object"==typeof h&&h)c=h instanceof cc.ValueType?l(h):Array.isArray(h)?"[]":"{}";else if("function"==typeof h){var _=i.length;i.push(h),c="F["+_+"]()"}else c="string"==typeof h?u(h):h;n+=a=a+c+";\n"}}return 0===i.length?Function(n):Function("F","return (function(){\n"+n+"})")(i)})(e,i);t.prototype.__initProps__=n,n.call(this)}function d(t,e,i){var n=!1;for(var r in e)if(!(A.indexOf(r)>=0)){var s=e[r];if("function"==typeof s){var o=g.getPropertyDescriptor(t.prototype,r);if(o){var a=o.value;if("function"==typeof a){R.test(s)&&(n=!0,e[r]=(function(t,e){return function(){var i=this._super;this._super=t;var n=e.apply(this,arguments);return this._super=i,n}})(a,s));continue}}0}}return n}function f(t,e,i,n,r,a){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),r)for(var c=0;c<r.length;++c){var h=r[c];h.__props__&&(t.__props__=t.__props__.concat(h.__props__.filter((function(e){return t.__props__.indexOf(e)<0}))))}if(i){b.preprocessAttrs(i,e,t,a);for(var l in i){var u=i[l];"default"in u?s(t,e,l,u):o(t,e,l,u,a)}}}function p(t){var e=(t=t||{}).name,i=t.extends,n=t.mixins,r=(function(t,e,i,n){var r=cc.Component,s=cc._RF.peek();if(s&&cc.isChildClassOf(e,r)){if(cc.isChildClassOf(s.cls,r))return cc.errorID(3615),null;t=t||s.script}var o=h(t,e,i,n);if(s)if(cc.isChildClassOf(e,r)){var a=s.uuid;a&&g._setClassId(a,o),s.cls=o}else cc.isChildClassOf(s.cls,r)||(s.cls=o);return o})(e,i,n,t);e||(e=cc.js.getClassName(r)),r._sealed=!0,i&&(i._sealed=!1);var s=t.properties;"function"==typeof s||i&&null===i.__props__||n&&n.some((function(t){return null===t.__props__}))?(S.push({cls:r,props:s,mixins:n}),r.__props__=null):f(r,e,s,i,t.mixins,t.__ES6__);var o=t.statics;if(o){var a;0;for(a in o)r[a]=o[a]}for(var c in t)if(!(A.indexOf(c)>=0)){var l=t[c];b.validateMethodWithProps(l,c,e,r,i)&&g.value(r.prototype,c,l,!0,!0)}var u=t.editor;return u&&cc.isChildClassOf(i,cc.Component)&&cc.Component._registerEditorProps(r,u),r}function m(t,e,i,n,r){function s(){return c=n+C,a=x.getClassAttrsProto(t)}function o(t,i){if(t in e){var n=e[t];typeof n===i&&((a||s())[c+t]=n)}}var a=null,c="";O.length=0;var h=O,l=e.type;if(l){var u=P[l];if(u)h.push({type:l,_onAfterProp:T(u,"cc."+l)});else if("Object"===l)0;else if(l===x.ScriptUuid){var _=x.ObjectType(cc.ScriptAsset);_.type="Script",h.push(_)}else"object"==typeof l?y.isEnum(l)&&h.push({type:"Enum",enumList:y.getList(l)}):"function"==typeof l&&(e.url?h.push({type:"Object",ctor:l,_onAfterProp:T("String","cc.String")}):h.push(e._short?{type:"Object",ctor:l}:x.ObjectType(l)))}e.editorOnly&&((a||s())[c+"editorOnly"]=!0),e.url&&((a||s())[c+"saveUrlAsAsset"]=!0),!1===e.serializable&&((a||s())[c+"serializable"]=!1),o("formerlySerializedAs","string");var d=e.range;return d&&Array.isArray(d)&&d.length>=2&&((a||s())[c+"min"]=d[0],a[c+"max"]=d[1],d.length>2&&(a[c+"step"]=d[2])),o("min","number"),o("max","number"),o("step","number"),h}var g=t("./js"),y=t("./CCEnum"),v=t("./utils"),x=(v.isPlainEmptyObj_DEV,v.cloneable_DEV,t("./attribute")),C=x.DELIMETER,T=x.getTypeChecker,b=t("./preprocess-class");t("./requiring-frame");var A=["name","extends","mixins","ctor","__ctor__","properties","statics","editor","__ES6__"],S={datas:null,push:function(t){if(this.datas)this.datas.push(t);else{this.datas=[t];var e=this;setTimeout((function(){e.init()}),0)}},init:function(){var t=this.datas;if(t){for(var e=0;e<t.length;++e){var i=t[e],n=i.cls,r=i.props;"function"==typeof r&&(r=r());var s=g.getClassName(n);r?f(n,s,r,n.$super,i.mixins):cc.errorID(3633,s)}this.datas=null}}},w=[],E=/^[$A-Za-z_][0-9A-Za-z_$]*$/,I=function(t,e,i,n){var r="return function CCClass(){\n";e&&d(e,n)&&(r+="this._super=null;\n"),r+="this.__initProps__(CCClass);\n";var s=t.length;if(s>0){var o=!(i&&i.startsWith("cc."));o&&(r+="try{\n");var a="].apply(this,arguments);\n";if(1===s)r+="CCClass.__ctors__[0"+a;else{r+="var cs=CCClass.__ctors__;\n";for(var c=0;c<s;c++)r+="cs["+c+a}o&&(r+="}catch(e){\ncc._throw(e);\n}\n")}return r+="}",Function(r)()},R=/xyz/.test((function(){xyz}))?/\b\._super\b/:/.*/;/xyz/.test((function(){xyz}));p._isCCClass=function(t){return t&&t.hasOwnProperty("__ctors__")},p._fastDefine=function(t,e,i){g.setClassName(t,e);for(var n=e.__props__=Object.keys(i),r=x.getClassAttrsProto(e),s=0;s<n.length;s++){var o=n[s];r[o+C+"visible"]=!1,r[o+C+"default"]=i[o]}},p.Attr=x,p.attr=x.attr,cc.isChildClassOf=function(t,e){if(t&&e){if("function"!=typeof t)return!1;if("function"!=typeof e)return!1;if(t===e)return!0;for(;;){if(!(t=g.getSuper(t)))return!1;if(t===e)return!0}}return!1},p.getInheritanceChain=function(t){for(var e=[];t=g.getSuper(t);)t!==Object&&e.push(t);return e};var P={Integer:"Number",Float:"Number",Boolean:"Boolean",String:"String"},O=[];cc.Class=p,e.exports={isArray:function(t){return t=a(t),Array.isArray(t)},fastDefine:p._fastDefine,getNewValueTypeCode:l,IDENTIFIER_RE:E,escapeForJS:u,getDefault:a}}),{"./CCEnum":178,"./attribute":189,"./js":197,"./preprocess-class":198,"./requiring-frame":199,"./utils":201}],177:[(function(t,e,i){function n(t){return t}function r(t,e){return t[e]||(t[e]={})}function s(t){return function(e){return"function"==typeof e?t(e):function(i){return t(i,e)}}}function o(t,e,i){return function(t){return function(i){return e(i,t)}}}function a(t){return o.bind(null,!1)}function c(t,e){return r(t,d)}function h(t,e,i){return t((function(t,n){var s=c(t);if(s){var o=void 0!==i?i:n;r(r(s,"proto"),"editor")[e]=o}}),e)}function l(t){return t(n)}t("./CCClass");var u=t("./preprocess-class"),_=t("./js"),d="__ccclassCache__",f=o.bind(null,!1),p=a(),m=a(),g=s((function(t,e){var i=_.getSuper(t);i===Object&&(i=null);var n={name:e,extends:i,ctor:t,__ES6__:!0},r=t[d];if(r){var s=r.proto;s&&_.mixin(n,s),t[d]=void 0}return cc.Class(n)})),y=l(s),v=h(f,"requireComponent"),x=l(p),C=h(m,"executionOrder"),T=l(s),b=l(s),A=l(p),S=l(p),w=l(p);cc._decorator=e.exports={ccclass:g,property:function(t,e,i){function n(t,e,i){var n=c(t.constructor);if(n){var o=r(r(n,"proto"),"properties");(function(t,e,i,n,r,s){var o=n&&(u.getFullFormOfProperty(n)||n),a=e[i],c=_.mixin(a||{},o||{});if(r&&(r.get||r.set))r.get&&(c.get=r.get),r.set&&(c.set=r.set);else{var h=void 0;if(r)r.initializer&&(h=(function(t){var e;try{e=t()}catch(e){return t}return"object"!=typeof e||null===e?e:t})(r.initializer));else{var l=s.default||(s.default=(function(t){var e;try{e=new t}catch(t){return{}}return e})(t));l.hasOwnProperty(i)&&(h=l[i])}c.default=h}e[i]=c})(t.constructor,o,e,s,i,n)}}var s=null;if(void 0===e)return s=t,n;n(t,e,i)},executeInEditMode:y,requireComponent:v,menu:x,executionOrder:C,disallowMultiple:T,playOnFocus:b,inspector:A,icon:S,help:w,mixins:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){var i=c(e);i&&(r(i,"proto").mixins=t)}}}}),{"./CCClass":176,"./js":197,"./preprocess-class":198,"./utils":201}],178:[(function(t,e,i){function n(t){if("__enums__"in t)return t;r.value(t,"__enums__",null,!0);for(var e=-1,i=Object.keys(t),n=0;n<i.length;n++){var s=i[n],o=t[s];if(-1===o)o=++e,t[s]=o;else if("number"==typeof o)e=o;else if("string"==typeof o&&Number.isInteger(parseFloat(s)))continue;var a=""+o;s!==a&&r.value(t,a,s)}return t}var r=t("./js");n.isEnum=function(t){return t&&t.hasOwnProperty("__enums__")},n.getList=function(t){if(t.__enums__)return t.__enums__;var e=t.__enums__=[];for(var i in t){var n=t[i];Number.isInteger(n)&&e.push({name:i,value:n})}return e.sort((function(t,e){return t.value-e.value})),e};e.exports=cc.Enum=n}),{"./js":197}],179:[(function(t,e,i){cc.ClassManager||t("./_CCClass");var n=t("../event-manager"),r=t("./CCInputManager");r.__instanceId=cc.ClassManager.getNewInstanceId(),r.setAccelerometerEnabled=function(t){if(this._accelEnabled!==t){this._accelEnabled=t;var e=cc.director.getScheduler();this._accelEnabled,this._accelCurTime=0,e.scheduleUpdate(this)}},r.setAccelerometerInterval=function(t){this._accelInterval!==t&&(this._accelInterval=t)},r._registerKeyboardEvent=function(){cc.game.canvas.addEventListener("keydown",(function(t){n.dispatchEvent(new cc.Event.EventKeyboard(t.keyCode,!0)),t.stopPropagation(),t.preventDefault()}),!1),cc.game.canvas.addEventListener("keyup",(function(t){n.dispatchEvent(new cc.Event.EventKeyboard(t.keyCode,!1)),t.stopPropagation(),t.preventDefault()}),!1)},r._registerAccelerometerEvent=function(){var t=window;this._acceleration=new cc.Acceleration,this._accelDeviceEvent=t.DeviceMotionEvent||t.DeviceOrientationEvent,cc.sys.browserType===cc.sys.BROWSER_TYPE_MOBILE_QQ&&(this._accelDeviceEvent=window.DeviceOrientationEvent);var e=this._accelDeviceEvent===t.DeviceMotionEvent?"devicemotion":"deviceorientation",i=navigator.userAgent;(/Android/.test(i)||/Adr/.test(i)&&cc.sys.browserType===cc.BROWSER_TYPE_UC)&&(this._minus=-1),t.addEventListener(e,this.didAccelerate.bind(this),!1)},r.didAccelerate=function(t){var e=window;if(this._accelEnabled){var i,n,r,s=this._acceleration;if(this._accelDeviceEvent===window.DeviceMotionEvent){var o=t.accelerationIncludingGravity;i=this._accelMinus*o.x*.1,n=this._accelMinus*o.y*.1,r=.1*o.z}else i=t.gamma/90*.981,n=-t.beta/90*.981,r=t.alpha/90*.981;s.x=i,s.y=n,s.z=r,s.timestamp=t.timeStamp||Date.now();var a=s.x;e.orientation===cc.macro.WEB_ORIENTATION_LANDSCAPE_RIGHT?(s.x=-s.y,s.y=a):e.orientation===cc.macro.WEB_ORIENTATION_LANDSCAPE_LEFT?(s.x=s.y,s.y=-a):e.orientation===cc.macro.WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN&&(s.x=-s.x,s.y=-s.y),cc.sys.os===cc.sys.OS_ANDROID&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_MOBILE_QQ&&(s.x=-s.x,s.y=-s.y)}}}),{"../event-manager":110,"./CCInputManager":180,"./_CCClass":188}],180:[(function(t,e,i){var n=t("../platform/js"),r=t("./CCMacro"),s=t("./CCSys"),o=t("../event-manager"),a=r.TOUCH_TIMEOUT,c={_mousePressed:!1,_isRegisterEvent:!1,_preTouchPoint:cc.p(0,0),_prevMousePoint:cc.p(0,0),_preTouchPool:[],_preTouchPoolPointer:0,_touches:[],_touchesIntegerDict:{},_indexBitsUsed:0,_maxTouches:5,_accelEnabled:!1,_accelInterval:1/30,_accelMinus:1,_accelCurTime:0,_acceleration:null,_accelDeviceEvent:null,_getUnUsedIndex:function(){for(var t=this._indexBitsUsed,e=cc.sys.now(),i=0;i<this._maxTouches;i++){if(!(1&t))return this._indexBitsUsed|=1<<i,i;var n=this._touches[i];if(e-n._lastModified>a)return this._removeUsedIndexBit(i),delete this._touchesIntegerDict[n.getID()],i;t>>=1}return-1},_removeUsedIndexBit:function(t){if(!(t<0||t>=this._maxTouches)){var e=1<<t;e=~e,this._indexBitsUsed&=e}},_glView:null,handleTouchesBegin:function(t){for(var e,i,n,r=[],a=this._touchesIntegerDict,c=s.now(),h=0,l=t.length;h<l;h++)if(e=t[h],n=e.getID(),null==a[n]){var u=this._getUnUsedIndex();if(-1===u){cc.logID(2300,u);continue}(i=this._touches[u]=new cc.Touch(e._point.x,e._point.y,e.getID()))._lastModified=c,i._setPrevPoint(e._prevPoint),a[n]=u,r.push(i)}if(r.length>0){this._glView._convertTouchesWithScale(r);var _=new cc.Event.EventTouch(r);_._eventCode=cc.Event.EventTouch.BEGAN,o.dispatchEvent(_)}},handleTouchesMove:function(t){for(var e,i,n,r=[],a=this._touches,c=s.now(),h=0,l=t.length;h<l;h++)n=(e=t[h]).getID(),null!=(i=this._touchesIntegerDict[n])&&a[i]&&(a[i]._setPoint(e._point),a[i]._setPrevPoint(e._prevPoint),a[i]._lastModified=c,r.push(a[i]));if(r.length>0){this._glView._convertTouchesWithScale(r);var u=new cc.Event.EventTouch(r);u._eventCode=cc.Event.EventTouch.MOVED,o.dispatchEvent(u)}},handleTouchesEnd:function(t){var e=this.getSetOfTouchesEndOrCancel(t);if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.Event.EventTouch(e);i._eventCode=cc.Event.EventTouch.ENDED,o.dispatchEvent(i)}},handleTouchesCancel:function(t){var e=this.getSetOfTouchesEndOrCancel(t);if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.Event.EventTouch(e);i._eventCode=cc.Event.EventTouch.CANCELLED,o.dispatchEvent(i)}},getSetOfTouchesEndOrCancel:function(t){for(var e,i,n,r=[],s=this._touches,o=this._touchesIntegerDict,a=0,c=t.length;a<c;a++)null!=(i=o[n=(e=t[a]).getID()])&&s[i]&&(s[i]._setPoint(e._point),s[i]._setPrevPoint(e._prevPoint),r.push(s[i]),this._removeUsedIndexBit(i),delete o[n]);return r},getHTMLElementPosition:function(t){if(s.platform===s.WECHAT_GAME)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};var e=document.documentElement,i=window.pageXOffset-e.clientLeft,n=window.pageYOffset-e.clientTop;if("function"==typeof t.getBoundingClientRect){var r=t.getBoundingClientRect();return{left:r.left+i,top:r.top+n,width:r.width,height:r.height}}return t instanceof HTMLCanvasElement?{left:i,top:n,width:t.width,height:t.height}:{left:i,top:n,width:parseInt(t.style.width),height:parseInt(t.style.height)}},getPreTouch:function(t){for(var e=null,i=this._preTouchPool,n=t.getID(),r=i.length-1;r>=0;r--)if(i[r].getID()===n){e=i[r];break}return e||(e=t),e},setPreTouch:function(t){for(var e=!1,i=this._preTouchPool,n=t.getID(),r=i.length-1;r>=0;r--)if(i[r].getID()===n){i[r]=t,e=!0;break}e||(i.length<=50?i.push(t):(i[this._preTouchPoolPointer]=t,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},getTouchByXY:function(t,e,i){var n=this._preTouchPoint,r=this._glView.convertToLocationInView(t,e,i),s=new cc.Touch(r.x,r.y);return s._setPrevPoint(n.x,n.y),n.x=r.x,n.y=r.y,s},getMouseEvent:function(t,e,i){var n=this._prevMousePoint,r=new cc.Event.EventMouse(i);return r._setPrevCursor(n.x,n.y),n.x=t.x,n.y=t.y,this._glView._convertMouseToLocationInView(n,e),r.setLocation(n.x,n.y),r},getPointByEvent:function(t,e){return null!=t.pageX?{x:t.pageX,y:t.pageY}:(s.platform===s.WECHAT_GAME?(e.left=0,e.top=0):(e.left-=document.body.scrollLeft,e.top-=document.body.scrollTop),{x:t.clientX,y:t.clientY})},getTouchesByEvent:function(t,e){for(var i,n,r,o=[],a=this._glView,c=this._preTouchPoint,h=t.changedTouches.length,l=0;l<h;l++)if(i=t.changedTouches[l]){var u;u=s.BROWSER_TYPE_FIREFOX===s.browserType?a.convertToLocationInView(i.pageX,i.pageY,e):a.convertToLocationInView(i.clientX,i.clientY,e),null!=i.identifier?(n=new cc.Touch(u.x,u.y,i.identifier),r=this.getPreTouch(n).getLocation(),n._setPrevPoint(r.x,r.y),this.setPreTouch(n)):(n=new cc.Touch(u.x,u.y))._setPrevPoint(c.x,c.y),c.x=u.x,c.y=u.y,o.push(n)}return o},registerSystemEvent:function(t){if(!this._isRegisterEvent){this._glView=cc.view;var e=this,i=s.isMobile,n="mouse"in s.capabilities,r="touches"in s.capabilities;if(s.platform===s.WECHAT_GAME&&(i=!1,r=!0,n=!1),n){i||(window.addEventListener("mousedown",(function(){e._mousePressed=!0}),!1),window.addEventListener("mouseup",(function(i){if(e._mousePressed){e._mousePressed=!1;var n=e.getHTMLElementPosition(t),r=e.getPointByEvent(i,n);if(!cc.rectContainsPoint(new cc.Rect(n.left,n.top,n.width,n.height),r)){e.handleTouchesEnd([e.getTouchByXY(r.x,r.y,n)]);var s=e.getMouseEvent(r,n,cc.Event.EventMouse.UP);s.setButton(i.button),o.dispatchEvent(s)}}}),!1));for(var a=cc.Event.EventMouse,c=[!i&&["mousedown",a.DOWN,function(i,n,r,s){e._mousePressed=!0,e.handleTouchesBegin([e.getTouchByXY(r.x,r.y,s)]),t.focus()}],!i&&["mouseup",a.UP,function(t,i,n,r){e._mousePressed=!1,e.handleTouchesEnd([e.getTouchByXY(n.x,n.y,r)])}],!i&&["mousemove",a.MOVE,function(t,i,n,r){e.handleTouchesMove([e.getTouchByXY(n.x,n.y,r)]),e._mousePressed||i.setButton(null)}],["mousewheel",a.SCROLL,function(t,e){e.setScrollData(0,t.wheelDelta)}],["DOMMouseScroll",a.SCROLL,function(t,e){e.setScrollData(0,-120*t.detail)}]],h=0;h<c.length;++h){var l=c[h];l&&(function(){var i=l[0],n=l[1],r=l[2];t.addEventListener(i,(function(i){var s=e.getHTMLElementPosition(t),a=e.getPointByEvent(i,s),c=e.getMouseEvent(a,s,n);c.setButton(i.button),r(i,c,a,s),o.dispatchEvent(c),i.stopPropagation(),i.preventDefault()}),!1)})()}}if(window.navigator.msPointerEnabled){var u={MSPointerDown:e.handleTouchesBegin,MSPointerMove:e.handleTouchesMove,MSPointerUp:e.handleTouchesEnd,MSPointerCancel:e.handleTouchesCancel},_=function(i){var n=u[i];t.addEventListener(i,(function(i){var r=e.getHTMLElementPosition(t);r.left-=document.documentElement.scrollLeft,r.top-=document.documentElement.scrollTop,n.call(e,[e.getTouchByXY(i.clientX,i.clientY,r)]),i.stopPropagation()}),!1)};for(var d in u)_(d)}if(r){var f,p={touchstart:function(i){e.handleTouchesBegin(i),s.platform!==s.WECHAT_GAME&&t.focus()},touchmove:function(t){e.handleTouchesMove(t)},touchend:function(t){e.handleTouchesEnd(t)},touchcancel:function(t){e.handleTouchesCancel(t)}};cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB?(p={onTouchStart:p.touchstart,onTouchMove:p.touchmove,onTouchEnd:p.touchend,onTouchCancel:p.touchcancel},f=function(i){var n=p[i];wx[i]((function(i){if(i.changedTouches){var r=e.getHTMLElementPosition(t),s=document.body;r.left-=s.scrollLeft||0,r.top-=s.scrollTop||0,n(e.getTouchesByEvent(i,r))}}))}):f=function(i){var n=p[i];t.addEventListener(i,(function(i){if(i.changedTouches){var r=e.getHTMLElementPosition(t),s=document.body;r.left-=s.scrollLeft||0,r.top-=s.scrollTop||0,n(e.getTouchesByEvent(i,r)),i.stopPropagation(),i.preventDefault()}}),!1)};for(var m in p)f(m)}cc.sys.browserType!==cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB&&(this._registerKeyboardEvent(),this._registerAccelerometerEvent()),this._isRegisterEvent=!0}},_registerKeyboardEvent:function(){},_registerAccelerometerEvent:function(){},update:function(t){this._accelCurTime>this._accelInterval&&(this._accelCurTime-=this._accelInterval,o.dispatchEvent(new cc.Event.EventAcceleration(this._acceleration))),this._accelCurTime+=t}};n.get(cc,"inputManager",(function(){return cc.warnID(1405,"cc.inputManager","cc.systemEvent"),c})),e.exports=c}),{"../event-manager":110,"../platform/js":197,"./CCMacro":181,"./CCSys":185}],181:[(function(t,e,i){t("./_CCClass"),cc.KEY={none:0,back:6,menu:18,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,select:41,insert:45,Delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,num0:96,num1:97,num2:98,num3:99,num4:100,num5:101,num6:102,num7:103,num8:104,num9:105,"*":106,"+":107,"-":109,numdel:110,"/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,";":186,semicolon:186,equal:187,"=":187,",":188,comma:188,dash:189,".":190,period:190,forwardslash:191,grave:192,"[":219,openbracket:219,backslash:220,"]":221,closebracket:221,quote:222,dpadLeft:1e3,dpadRight:1001,dpadUp:1003,dpadDown:1004,dpadCenter:1005},cc.ImageFormat=cc.Enum({JPG:0,PNG:1,TIFF:2,WEBP:3,PVR:4,ETC:5,S3TC:6,ATITC:7,TGA:8,RAWDATA:9,UNKNOWN:10}),cc.getImageFormatByData=function(t){return t.length>8&&137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]?cc.ImageFormat.PNG:t.length>2&&(73===t[0]&&73===t[1]||77===t[0]&&77===t[1]||255===t[0]&&216===t[1])?cc.ImageFormat.TIFF:cc.ImageFormat.UNKNOWN},cc.macro={INVALID_INDEX:-1,NODE_TAG_INVALID:-1,PI:Math.PI,PI2:2*Math.PI,FLT_MAX:parseFloat("3.402823466e+38F"),FLT_MIN:parseFloat("1.175494351e-38F"),RAD:Math.PI/180,DEG:180/Math.PI,UINT_MAX:4294967295,REPEAT_FOREVER:Number.MAX_VALUE-1,FLT_EPSILON:1.192092896e-7,ONE:1,ZERO:0,SRC_ALPHA:770,SRC_ALPHA_SATURATE:776,SRC_COLOR:768,DST_ALPHA:772,DST_COLOR:774,ONE_MINUS_SRC_ALPHA:771,ONE_MINUS_SRC_COLOR:769,ONE_MINUS_DST_ALPHA:773,ONE_MINUS_DST_COLOR:775,ONE_MINUS_CONSTANT_ALPHA:32772,ONE_MINUS_CONSTANT_COLOR:32770,LINEAR:9729,BLEND_DST:771,WEB_ORIENTATION_PORTRAIT:0,WEB_ORIENTATION_LANDSCAPE_LEFT:-90,WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN:180,WEB_ORIENTATION_LANDSCAPE_RIGHT:90,ORIENTATION_PORTRAIT:1,ORIENTATION_LANDSCAPE:2,ORIENTATION_AUTO:3,DENSITYDPI_DEVICE:"device-dpi",DENSITYDPI_HIGH:"high-dpi",DENSITYDPI_MEDIUM:"medium-dpi",DENSITYDPI_LOW:"low-dpi",VERTEX_ATTRIB_FLAG_NONE:0,VERTEX_ATTRIB_FLAG_POSITION:1,VERTEX_ATTRIB_FLAG_COLOR:2,VERTEX_ATTRIB_FLAG_TEX_COORDS:4,VERTEX_ATTRIB_FLAG_POS_COLOR_TEX:7,GL_ALL:0,VERTEX_ATTRIB_POSITION:0,VERTEX_ATTRIB_COLOR:1,VERTEX_ATTRIB_TEX_COORDS:2,VERTEX_ATTRIB_MAX:3,UNIFORM_PMATRIX:0,UNIFORM_MVMATRIX:1,UNIFORM_MVPMATRIX:2,UNIFORM_TIME:3,UNIFORM_SINTIME:4,UNIFORM_COSTIME:5,UNIFORM_RANDOM01:6,UNIFORM_SAMPLER:7,UNIFORM_MAX:8,SHADER_POSITION_TEXTURECOLOR:"ShaderPositionTextureColor",SHADER_SPRITE_POSITION_TEXTURECOLOR:"ShaderSpritePositionTextureColor",SHADER_POSITION_TEXTURECOLORALPHATEST:"ShaderPositionTextureColorAlphaTest",SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST:"ShaderSpritePositionTextureColorAlphaTest",SHADER_POSITION_COLOR:"ShaderPositionColor",SHADER_SPRITE_POSITION_COLOR:"ShaderSpritePositionColor",SHADER_POSITION_TEXTURE:"ShaderPositionTexture",SHADER_POSITION_TEXTURE_UCOLOR:"ShaderPositionTexture_uColor",SHADER_POSITION_TEXTUREA8COLOR:"ShaderPositionTextureA8Color",SHADER_POSITION_UCOLOR:"ShaderPosition_uColor",SHADER_POSITION_LENGTHTEXTURECOLOR:"ShaderPositionLengthTextureColor",UNIFORM_PMATRIX_S:"CC_PMatrix",UNIFORM_MVMATRIX_S:"CC_MVMatrix",UNIFORM_MVPMATRIX_S:"CC_MVPMatrix",UNIFORM_TIME_S:"CC_Time",UNIFORM_SINTIME_S:"CC_SinTime",UNIFORM_COSTIME_S:"CC_CosTime",UNIFORM_RANDOM01_S:"CC_Random01",UNIFORM_SAMPLER_S:"CC_Texture0",UNIFORM_ALPHA_TEST_VALUE_S:"CC_alpha_value",ATTRIBUTE_NAME_COLOR:"a_color",ATTRIBUTE_NAME_POSITION:"a_position",ATTRIBUTE_NAME_TEX_COORD:"a_texCoord",ITEM_SIZE:32,CURRENT_ITEM:3233828865,ZOOM_ACTION_TAG:3233828866,NORMAL_TAG:8801,SELECTED_TAG:8802,DISABLE_TAG:8803,FIX_ARTIFACTS_BY_STRECHING_TEXEL:0,FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX:1,DIRECTOR_STATS_POSITION:cc.p(0,0),DIRECTOR_FPS_INTERVAL:.5,COCOSNODE_RENDER_SUBPIXEL:1,SPRITEBATCHNODE_RENDER_SUBPIXEL:1,AUTO_PREMULTIPLIED_ALPHA_FOR_PNG:0,OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA:0,TEXTURE_NPOT_SUPPORT:0,USE_LA88_LABELS:1,SPRITE_DEBUG_DRAW:0,LABELBMFONT_DEBUG_DRAW:0,LABELATLAS_DEBUG_DRAW:0,ENABLE_STACKABLE_ACTIONS:1,ENABLE_GL_STATE_CACHE:1,TOUCH_TIMEOUT:5e3,BATCH_VERTEX_COUNT:2e4,ENABLE_GC_FOR_NATIVE_OBJECTS:!0,ENABLE_TILEDMAP_CULLING:!0,DOWNLOAD_MAX_CONCURRENT:64,ENABLE_TRANSPARENT_CANVAS:!1,ENABLE_WEBGL_ANTIALIAS:!1};var n=!0;cc.defineGetterSetter(cc.macro,"ENABLE_CULLING",(function(){return n}),(function(t){n=t;var e=cc.director.getScene();e&&(e._sgNode._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.cullingDirty),cc.renderer.childrenOrderDirty=!0)})),cc.defineGetterSetter(cc.macro,"BLEND_SRC",(function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.macro.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA?cc.macro.ONE:cc.macro.SRC_ALPHA})),cc.lerp=function(t,e,i){return t+(e-t)*i},cc.rand=function(){return 16777215*Math.random()},cc.randomMinus1To1=function(){return 2*(Math.random()-.5)},cc.random0To1=Math.random,cc.degreesToRadians=function(t){return t*cc.macro.RAD},cc.radiansToDegrees=function(t){return t*cc.macro.DEG},cc.nodeDrawSetup=function(t){t._shaderProgram&&(t._shaderProgram.use(),t._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())},cc.incrementGLDraws=function(t){cc.g_NumberOfDraws+=t},cc.checkGLErrorDebug=function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var t=cc._renderContext.getError();t&&cc.logID(2400,t)}},e.exports=cc.macro}),{"./_CCClass":188}],182:[(function(t,e,i){function n(){this._name="",this._objFlags=0}function r(){for(var t=c.length,e=0;e<t;++e){var i=c[e];i._objFlags&a||i._destroyImmediate()}t===c.length?c.length=0:c.splice(0,t)}var s=t("./js"),o=t("./CCClass"),a=1;o.fastDefine("cc.Object",n,{_name:"",_objFlags:0}),s.value(n,"Flags",{Destroyed:a,DontSave:8,EditorOnly:16,Dirty:32,DontDestroy:64,PersistentMask:-4192741,Destroying:128,Deactivating:256,IsPreloadStarted:8192,IsOnLoadStarted:32768,IsOnLoadCalled:16384,IsOnEnableCalled:2048,IsStartCalled:65536,IsEditorOnEnableCalled:4096,IsPositionLocked:1<<21,IsRotationLocked:1<<17,IsScaleLocked:1<<18,IsAnchorLocked:1<<19,IsSizeLocked:1<<20});var c=[];s.value(n,"_deferredDestroy",r);var h=n.prototype;s.getset(h,"name",(function(){return this._name}),(function(t){this._name=t})),s.get(h,"isValid",(function(){return!(this._objFlags&a)}));h.destroy=function(){return this._objFlags&a?(cc.warnID(5e3),!1):!(4&this._objFlags)&&(this._objFlags|=4,c.push(this),!0)},h._destruct=function(){var t=this.constructor,e=t.__destruct__;e||(e=(function(t,e){var i,n={};for(i in t)if(t.hasOwnProperty(i))switch(typeof t[i]){case"string":n[i]="";break;case"object":case"function":n[i]=null}if(cc.Class._isCCClass(e))for(var r=cc.Class.Attr.getClassAttrs(e),s=e.__props__,a=0;a<s.length;a++){var c=(i=s[a])+cc.Class.Attr.DELIMETER+"default";if(c in r)switch(typeof r[c]){case"string":n[i]="";break;case"object":case"function":n[i]=null;break;case"undefined":n[i]=void 0}}var h=t instanceof cc._BaseNode||t instanceof cc.Component,l="";for(i in n)if(!h||"_id"!==i){var u;u=o.IDENTIFIER_RE.test(i)?"o."+i+"=":"o["+o.escapeForJS(i)+"]=";var _=n[i];""===_&&(_='""'),l+=u+_+";\n"}return Function("o",l)})(this,t),s.value(t,"__destruct__",e,!0)),e(this)},h._onPreDestroy=null,h._destroyImmediate=function(){this._objFlags&a?cc.errorID(5e3):(this._onPreDestroy&&this._onPreDestroy(),this._destruct(),this._objFlags|=a)},h._deserialize=null,cc.isValid=function(t,e){return"object"==typeof t?!(!t||t._objFlags&(e?4|a:a)):void 0!==t},cc.Object=e.exports=n}),{"./CCClass":176,"./js":197}],183:[(function(t,e,i){cc.SAXParser=cc._Class.extend({ctor:function(){window.DOMParser?(this._isSupportDOMParser=!0,this._parser=new DOMParser):(this._isSupportDOMParser=!1,this._parser=null)},parse:function(t){return this._parseXML(t)},_parseXML:function(t){var e;return this._isSupportDOMParser?e=this._parser.parseFromString(t,"text/xml"):((e=new ActiveXObject("Microsoft.XMLDOM")).async="false",e.loadXML(t)),e}}),cc.PlistParser=cc.SAXParser.extend({parse:function(t){var e=this._parseXML(t),i=e.documentElement;if("plist"!==i.tagName)return cc.warnID(5100),{};for(var n=null,r=0,s=i.childNodes.length;r<s&&1!==(n=i.childNodes[r]).nodeType;r++);return e=null,this._parseNode(n)},_parseNode:function(t){var e=null,i=t.tagName;if("dict"===i)e=this._parseDict(t);else if("array"===i)e=this._parseArray(t);else if("string"===i)if(1===t.childNodes.length)e=t.firstChild.nodeValue;else{e="";for(var n=0;n<t.childNodes.length;n++)e+=t.childNodes[n].nodeValue}else"false"===i?e=!1:"true"===i?e=!0:"real"===i?e=parseFloat(t.firstChild.nodeValue):"integer"===i&&(e=parseInt(t.firstChild.nodeValue,10));return e},_parseArray:function(t){for(var e=[],i=0,n=t.childNodes.length;i<n;i++){var r=t.childNodes[i];1===r.nodeType&&e.push(this._parseNode(r))}return e},_parseDict:function(t){for(var e={},i=null,n=0,r=t.childNodes.length;n<r;n++){var s=t.childNodes[n];1===s.nodeType&&("key"===s.tagName?i=s.firstChild.nodeValue:e[i]=this._parseNode(s))}return e}}),cc.saxParser=new cc.SAXParser,cc.plistParser=new cc.PlistParser}),{}],184:[(function(t,e,i){cc.screen={_supportsFullScreen:!1,_preOnFullScreenChange:null,_touchEvent:"",_fn:null,_fnMap:[["requestFullscreen","exitFullscreen","fullscreenchange","fullscreenEnabled","fullscreenElement"],["requestFullScreen","exitFullScreen","fullScreenchange","fullScreenEnabled","fullScreenElement"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange","webkitIsFullScreen","webkitCurrentFullScreenElement"],["mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozFullScreen","mozFullScreenElement"],["msRequestFullscreen","msExitFullscreen","MSFullscreenChange","msFullscreenEnabled","msFullscreenElement"]],init:function(){this._fn={};var t,e,i,n,r=this._fnMap;for(t=0,e=r.length;t<e;t++)if((i=r[t])&&i[1]in document){for(t=0,n=i.length;t<n;t++)this._fn[r[0][t]]=i[t];break}this._supportsFullScreen=void 0!==this._fn.requestFullscreen,this._touchEvent="ontouchstart"in window?"touchstart":"mousedown"},fullScreen:function(){return!!this._supportsFullScreen&&(void 0!==document[this._fn.fullscreenElement]&&null!==document[this._fn.fullscreenElement])},requestFullScreen:function(t,e){if(this._supportsFullScreen){if(t=t||document.documentElement,e){var i=this._fn.fullscreenchange;this._preOnFullScreenChange&&document.removeEventListener(i,this._preOnFullScreenChange),this._preOnFullScreenChange=e,document.addEventListener(i,e,!1)}return t[this._fn.requestFullscreen]()}},exitFullScreen:function(){return!this._supportsFullScreen||document[this._fn.exitFullscreen]()},autoFullScreen:function(t,e){function i(){n.removeEventListener(r._touchEvent,i),r.requestFullScreen(t,e)}t=t||document.body;var n=cc.game.canvas||t,r=this;this.requestFullScreen(t,e),n.addEventListener(this._touchEvent,i)}},cc.screen.init()}),{}],185:[(function(t,e,i){if(!cc.sys){cc.sys={};var n=cc.sys;n.LANGUAGE_ENGLISH="en",n.LANGUAGE_CHINESE="zh",n.LANGUAGE_FRENCH="fr",n.LANGUAGE_ITALIAN="it",n.LANGUAGE_GERMAN="de",n.LANGUAGE_SPANISH="es",n.LANGUAGE_DUTCH="du",n.LANGUAGE_RUSSIAN="ru",n.LANGUAGE_KOREAN="ko",n.LANGUAGE_JAPANESE="ja",n.LANGUAGE_HUNGARIAN="hu",n.LANGUAGE_PORTUGUESE="pt",n.LANGUAGE_ARABIC="ar",n.LANGUAGE_NORWEGIAN="no",n.LANGUAGE_POLISH="pl",n.LANGUAGE_TURKISH="tr",n.LANGUAGE_UKRAINIAN="uk",n.LANGUAGE_ROMANIAN="ro",n.LANGUAGE_BULGARIAN="bg",n.LANGUAGE_UNKNOWN="unknown",n.OS_IOS="iOS",n.OS_ANDROID="Android",n.OS_WINDOWS="Windows",n.OS_MARMALADE="Marmalade",n.OS_LINUX="Linux",n.OS_BADA="Bada",n.OS_BLACKBERRY="Blackberry",n.OS_OSX="OS X",n.OS_WP8="WP8",n.OS_WINRT="WINRT",n.OS_UNKNOWN="Unknown",n.UNKNOWN=-1,n.WIN32=0,n.LINUX=1,n.MACOS=2,n.ANDROID=3,n.IPHONE=4,n.IPAD=5,n.BLACKBERRY=6,n.NACL=7,n.EMSCRIPTEN=8,n.TIZEN=9,n.WINRT=10,n.WP8=11,n.MOBILE_BROWSER=100,n.DESKTOP_BROWSER=101,n.EDITOR_PAGE=102,n.EDITOR_CORE=103,n.WECHAT_GAME=104,n.QQ_PLAY=105,n.BROWSER_TYPE_WECHAT="wechat",n.BROWSER_TYPE_WECHAT_GAME="wechatgame",n.BROWSER_TYPE_WECHAT_GAME_SUB="wechatgamesub",n.BROWSER_TYPE_QQ_PLAY="qqplay",n.BROWSER_TYPE_ANDROID="androidbrowser",n.BROWSER_TYPE_IE="ie",n.BROWSER_TYPE_QQ="qqbrowser",n.BROWSER_TYPE_MOBILE_QQ="mqqbrowser",n.BROWSER_TYPE_UC="ucbrowser",n.BROWSER_TYPE_360="360browser",n.BROWSER_TYPE_BAIDU_APP="baiduboxapp",n.BROWSER_TYPE_BAIDU="baidubrowser",n.BROWSER_TYPE_MAXTHON="maxthon",n.BROWSER_TYPE_OPERA="opera",n.BROWSER_TYPE_OUPENG="oupeng",n.BROWSER_TYPE_MIUI="miuibrowser",n.BROWSER_TYPE_FIREFOX="firefox",n.BROWSER_TYPE_SAFARI="safari",n.BROWSER_TYPE_CHROME="chrome",n.BROWSER_TYPE_LIEBAO="liebao",n.BROWSER_TYPE_QZONE="qzone",n.BROWSER_TYPE_SOUGOU="sogou",n.BROWSER_TYPE_UNKNOWN="unknown",n.isNative=!1,n.isBrowser="object"==typeof window&&"object"==typeof document&&!0,cc.create3DContext=function(t,e,i){if(!i)return cc.create3DContext(t,e,"webgl")||cc.create3DContext(t,e,"experimental-webgl")||cc.create3DContext(t,e,"webkit-3d")||cc.create3DContext(t,e,"moz-webgl")||null;try{return t.getContext(i,e)}catch(t){return null}};var r=window,s=r.navigator,o=document,a=o.documentElement,c=s.userAgent.toLowerCase();n.isMobile=/mobile|android|iphone|ipad/.test(c),n.platform=n.isMobile?n.MOBILE_BROWSER:n.DESKTOP_BROWSER;var h=s.language;h=(h=h||s.browserLanguage)?h.split("-")[0]:n.LANGUAGE_ENGLISH,n.language=h;var l=!1,u=!1,_="",d=0,f=/android (\d+(?:\.\d+)+)/i.exec(c)||/android (\d+(?:\.\d+)+)/i.exec(s.platform);f&&(l=!0,_=f[1]||"",d=parseInt(_)||0),(f=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(c))?(u=!0,_=f[2]||"",d=parseInt(_)||0):/(iPhone|iPad|iPod)/.exec(s.platform)&&(u=!0,_="",d=0);var p=n.OS_UNKNOWN;-1!==s.appVersion.indexOf("Win")?p=n.OS_WINDOWS:u?p=n.OS_IOS:-1!==s.appVersion.indexOf("Mac")?p=n.OS_OSX:-1!==s.appVersion.indexOf("X11")&&-1===s.appVersion.indexOf("Linux")?p=n.OS_UNIX:l?p=n.OS_ANDROID:-1===s.appVersion.indexOf("Linux")&&-1===c.indexOf("ubuntu")||(p=n.OS_LINUX),n.os=p,n.osVersion=_,n.osMainVersion=d,n.browserType=n.BROWSER_TYPE_UNKNOWN,(function(){var t=/mqqbrowser|micromessenger|qq|sogou|qzone|liebao|maxthon|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(c);t||(t=/qqbrowser|chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(c));var e=t?t[0].toLowerCase():n.BROWSER_TYPE_UNKNOWN;"micromessenger"===e?e=n.BROWSER_TYPE_WECHAT:"safari"===e&&l?e=n.BROWSER_TYPE_ANDROID:"qq"===e&&c.match(/android.*applewebkit/i)?e=n.BROWSER_TYPE_ANDROID:"trident"===e?e=n.BROWSER_TYPE_IE:"360 aphone"===e?e=n.BROWSER_TYPE_360:"mxbrowser"===e?e=n.BROWSER_TYPE_MAXTHON:"opr/"===e&&(e=n.BROWSER_TYPE_OPERA),n.browserType=e})(),n.browserVersion="",(function(){var t=c.match(/(mqqbrowser|micromessenger|qq|sogou|qzone|liebao|maxthon|uc|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui)(mobile)?(browser)?\/?([\d.]+)/i);t||(t=c.match(/(qqbrowser|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i)),n.browserVersion=t?t[4]:""})();var m=window.innerWidth||document.documentElement.clientWidth,g=window.innerHeight||document.documentElement.clientHeight,y=window.devicePixelRatio||1;n.windowPixelResolution={width:y*m,height:y*g},n._checkWebGLRenderMode=function(){if(cc._renderType!==cc.game.RENDER_TYPE_WEBGL)throw new Error("This feature supports WebGL render mode only.")};var v=document.createElement("canvas"),x=document.createElement("canvas");if(n._supportCanvasNewBlendModes=(function(){var t=v;t.width=1,t.height=1;var e=t.getContext("2d");e.fillStyle="#000",e.fillRect(0,0,1,1),e.globalCompositeOperation="multiply";var i=x;i.width=1,i.height=1;var n=i.getContext("2d");return n.fillStyle="#fff",n.fillRect(0,0,1,1),e.drawImage(i,0,0,1,1),0===e.getImageData(0,0,1,1).data[0]})(),cc.sys.isMobile){var C=document.createElement("style");C.type="text/css",document.body.appendChild(C),C.textContent="body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);}"}try{var T=n.localStorage=r.localStorage;T.setItem("storage",""),T.removeItem("storage"),T=null}catch(t){var b=function(){cc.warnID(5200)};n.localStorage={getItem:b,setItem:b,removeItem:b,clear:b}}var A=v.toDataURL("image/webp").startsWith("data:image/webp"),S=!!v.getContext("2d"),w=!1;if(r.WebGLRenderingContext&&(cc.create3DContext(document.createElement("CANVAS"))&&(w=!0),w&&n.os===n.OS_ANDROID)){var E=parseFloat(n.browserVersion);switch(n.browserType){case n.BROWSER_TYPE_MOBILE_QQ:case n.BROWSER_TYPE_BAIDU:case n.BROWSER_TYPE_BAIDU_APP:w=E>=6.2;break;case n.BROWSER_TYPE_ANDROID:n.osMainVersion&&n.osMainVersion>=5&&(w=!0);break;case n.BROWSER_TYPE_CHROME:w=E>=30;break;case n.BROWSER_TYPE_UC:w=E>11;case n.BROWSER_TYPE_360:w=!1}}var I=n.capabilities={canvas:S,opengl:w,webp:A};(void 0!==a.ontouchstart||void 0!==o.ontouchstart||s.msPointerEnabled)&&(I.touches=!0),void 0!==a.onmouseup&&(I.mouse=!0),void 0!==a.onkeyup&&(I.keyboard=!0),(r.DeviceMotionEvent||r.DeviceOrientationEvent)&&(I.accelerometer=!0);var R;(function(){n.browserVersion;var t=!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext);R={ONLY_ONE:!1,WEB_AUDIO:t,DELAY_CREATE_CTX:!1},n.os===n.OS_IOS&&(R.USE_LOADER_EVENT="loadedmetadata"),n.browserType===n.BROWSER_TYPE_FIREFOX&&(R.DELAY_CREATE_CTX=!0,R.USE_LOADER_EVENT="canplay"),n.os===n.OS_ANDROID&&n.browserType===n.BROWSER_TYPE_UC&&(R.ONE_SOURCE=!0)})();try{R.WEB_AUDIO&&(R.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),R.DELAY_CREATE_CTX&&setTimeout((function(){R.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}),0))}catch(t){R.WEB_AUDIO=!1,cc.logID(5201)}R.format=(function(){var t=[],e=document.createElement("audio");e.canPlayType&&(e.canPlayType('audio/ogg; codecs="vorbis"')&&t.push(".ogg"),e.canPlayType("audio/mpeg")&&t.push(".mp3"),e.canPlayType('audio/wav; codecs="1"')&&t.push(".wav"),e.canPlayType("audio/mp4")&&t.push(".mp4"),e.canPlayType("audio/x-m4a")&&t.push(".m4a"));return t})(),n.__audioSupport=R;n.garbageCollect=function(){},n.dumpRoot=function(){},n.restartVM=function(){},n.cleanScript=function(t){},n.isObjectValid=function(t){return!!t},n.dump=function(){var t="";t+="isMobile : "+this.isMobile+"\r\n",t+="language : "+this.language+"\r\n",t+="browserType : "+this.browserType+"\r\n",t+="browserVersion : "+this.browserVersion+"\r\n",t+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",t+="Using "+(cc._renderType===cc.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n",cc.log(t)},n.openURL=function(t){window.open(t)},n.now=function(){return Date.now?Date.now():+new Date},e.exports=n}}),{}],186:[(function(t,e,i){var n=t("../event-manager"),r={init:function(){this.html=document.getElementsByTagName("html")[0]},availWidth:function(t){return t&&t!==this.html?t.clientWidth:window.innerWidth},availHeight:function(t){return t&&t!==this.html?t.clientHeight:window.innerHeight},meta:{width:"device-width"},adaptationType:cc.sys.browserType};switch(cc.sys.os===cc.sys.OS_IOS&&(r.adaptationType=cc.sys.BROWSER_TYPE_SAFARI),r.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:r.meta["minimal-ui"]="true",r.availWidth=function(t){return t.clientWidth},r.availHeight=function(t){return t.clientHeight};break;case cc.sys.BROWSER_TYPE_CHROME:r.__defineGetter__("target-densitydpi",(function(){return cc.view._targetDensityDPI}));break;case cc.sys.BROWSER_TYPE_SOUGOU:case cc.sys.BROWSER_TYPE_UC:r.availWidth=function(t){return t.clientWidth},r.availHeight=function(t){return t.clientHeight};break;case cc.sys.BROWSER_TYPE_MIUI:r.init=function(t){if(!t.__resizeWithBrowserSize){var e=function(){t.setDesignResolutionSize(t._designResolutionSize.width,t._designResolutionSize.height,t._resolutionPolicy),window.removeEventListener("resize",e,!1)};window.addEventListener("resize",e,!1)}};break;case cc.sys.BROWSER_TYPE_WECHAT_GAME:r.availWidth=function(){return window.innerWidth},r.availHeight=function(){return window.innerHeight};break;case cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB:var s=wx.getSharedCanvas();r.availWidth=function(){return s.width},r.availHeight=function(){return s.height}}var o=null,a=cc._Class.extend({ctor:function(){var t=cc.ContainerStrategy,e=cc.ContentStrategy;r.init(this),this._frameSize=cc.size(0,0),this._initFrameSize();var i=cc.game.canvas.width,n=cc.game.canvas.height;this._designResolutionSize=cc.size(i,n),this._originalDesignResolutionSize=cc.size(i,n),this._viewPortRect=cc.rect(0,0,i,n),this._visibleRect=cc.rect(0,0,i,n),this._contentTranslateLeftTop={left:0,top:0},this._autoFullScreen=!1,this._devicePixelRatio=1,this._viewName="Cocos2dHTML5",this._resizeCallback=null,this._orientationChanging=!0,this._resizing=!1,this._scaleX=1,this._originalScaleX=1,this._scaleY=1,this._originalScaleY=1,this._isRotated=!1,this._orientation=3;var s=cc.sys;this.enableRetina(s.os===s.OS_IOS||s.os===s.OS_OSX),cc.visibleRect&&cc.visibleRect.init(this._visibleRect),this._resolutionPolicy=null,this._rpExactFit=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.EXACT_FIT),this._rpShowAll=new cc.ResolutionPolicy(t.PROPORTION_TO_FRAME,e.SHOW_ALL),this._rpNoBorder=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.NO_BORDER),this._rpFixedHeight=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.FIXED_HEIGHT),this._rpFixedWidth=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.FIXED_WIDTH),this._initialized=!1,this._contentTranslateLeftTop=null,this._frameZoomFactor=1,this.__resizeWithBrowserSize=!1,this._isAdjustViewPort=!0,this._targetDensityDPI=cc.macro.DENSITYDPI_HIGH,this.enableAntiAlias(!0)},_resizeEvent:function(){var t,e=(t=this.setDesignResolutionSize?this:cc.view)._frameSize.width,i=t._frameSize.height,r=t._isRotated;if(cc.sys.isMobile){var s=cc.game.container.style,o=s.margin;s.margin="0",s.display="none",t._initFrameSize(),s.margin=o,s.display="block"}else t._initFrameSize();if(t._isRotated!==r||t._frameSize.width!==e||t._frameSize.height!==i){var a=t._originalDesignResolutionSize.width,c=t._originalDesignResolutionSize.height;t._resizing=!0,a>0&&t.setDesignResolutionSize(a,c,t._resolutionPolicy),t._resizing=!1,n.dispatchCustomEvent("canvas-resize"),t._resizeCallback&&t._resizeCallback.call()}},_orientationChange:function(){cc.view._orientationChanging=!0,cc.view._resizeEvent()},setTargetDensityDPI:function(t){this._targetDensityDPI=t,this._adjustViewportMeta()},getTargetDensityDPI:function(){return this._targetDensityDPI},resizeWithBrowserSize:function(t){t?this.__resizeWithBrowserSize||(this.__resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent),window.addEventListener("orientationchange",this._orientationChange)):this.__resizeWithBrowserSize&&(this.__resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._orientationChange))},setResizeCallback:function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},setOrientation:function(t){if((t&=cc.macro.ORIENTATION_AUTO)&&this._orientation!==t){this._orientation=t;var e=this._originalDesignResolutionSize.width,i=this._originalDesignResolutionSize.height;this.setDesignResolutionSize(e,i,this._resolutionPolicy)}},_initFrameSize:function(){var t=this._frameSize,e=r.availWidth(cc.game.frame),i=r.availHeight(cc.game.frame),n=e>=i;!cc.sys.isMobile||n&&this._orientation&cc.macro.ORIENTATION_LANDSCAPE||!n&&this._orientation&cc.macro.ORIENTATION_PORTRAIT?(t.width=e,t.height=i,cc.container.style["-webkit-transform"]="rotate(0deg)",cc.container.style.transform="rotate(0deg)",this._isRotated=!1):(t.width=i,t.height=e,cc.container.style["-webkit-transform"]="rotate(90deg)",cc.container.style.transform="rotate(90deg)",cc.container.style["-webkit-transform-origin"]="0px 0px 0px",cc.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0),this._orientationChanging&&setTimeout((function(){cc.view._orientationChanging=!1}),1e3)},_adjustSizeKeepCanvasSize:function(){var t=this._originalDesignResolutionSize.width,e=this._originalDesignResolutionSize.height;t>0&&this.setDesignResolutionSize(t,e,this._resolutionPolicy)},_setViewportMeta:function(t,e){var i=document.getElementById("cocosMetaElement");i&&e&&document.head.removeChild(i);var n,r,s,o=document.getElementsByName("viewport"),a=o?o[0]:null;n=a?a.content:"",(i=i||document.createElement("meta")).id="cocosMetaElement",i.name="viewport",i.content="";for(r in t)-1==n.indexOf(r)?n+=","+r+"="+t[r]:e&&(s=new RegExp(r+"s*=s*[^,]+"),n.replace(s,r+"="+t[r]));/^,/.test(n)&&(n=n.substr(1)),i.content=n,a&&(a.content=n),document.head.appendChild(i)},_adjustViewportMeta:function(){this._isAdjustViewPort&&(this._setViewportMeta(r.meta,!1),this._isAdjustViewPort=!1)},_resetScale:function(){this._scaleX=this._originalScaleX,this._scaleY=this._originalScaleY},_adjustSizeToBrowser:function(){},initialize:function(){this._initialized=!0},adjustViewPort:function(t){this._isAdjustViewPort=t},enableRetina:function(t){this._retinaEnabled=!!t},isRetinaEnabled:function(){return this._retinaEnabled},enableAntiAlias:function(t){if(this._antiAliasEnabled!==t)if(this._antiAliasEnabled=t,cc._renderType===cc.game.RENDER_TYPE_WEBGL){var e=cc.loader._cache;for(var i in e){var n=e[i],r=n&&n.content instanceof cc.Texture2D?n.content:null;r&&(t?r.setAntiAliasTexParameters():r.setAliasTexParameters())}}else if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var s=cc._canvas.getContext("2d");s.imageSmoothingEnabled=t,s.mozImageSmoothingEnabled=t;var o=cc.rendererCanvas._dirtyRegion;if(o){var a=new cc.Region;a.setTo(0,0,cc.visibleRect.width,cc.visibleRect.height),o.addRegion(a)}}},isAntiAliasEnabled:function(){return this._antiAliasEnabled},enableAutoFullScreen:function(t){t&&t!==this._autoFullScreen&&cc.sys.isMobile&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_WECHAT?(this._autoFullScreen=!0,cc.screen.autoFullScreen(cc.game.frame)):this._autoFullScreen=!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},isViewReady:function(){return cc.game.canvas&&cc._renderContext},setFrameZoomFactor:function(t){this._frameZoomFactor=t,cc.director.setProjection(cc.director.getProjection())},setContentTranslateLeftTop:function(t,e){this._contentTranslateLeftTop={left:t,top:e}},getContentTranslateLeftTop:function(){return this._contentTranslateLeftTop},setCanvasSize:function(t,e){var i=cc.game.canvas,n=cc.game.container;i.width=t*this._devicePixelRatio,i.height=e*this._devicePixelRatio,i.style.width=t+"px",i.style.height=e+"px",n.style.width=t+"px",n.style.height=e+"px",this._resizeEvent()},getCanvasSize:function(){return cc.size(cc.game.canvas.width,cc.game.canvas.height)},getFrameSize:function(){return cc.size(this._frameSize.width,this._frameSize.height)},setFrameSize:function(t,e){this._frameSize.width=t,this._frameSize.height=e,cc.game.frame.style.width=t+"px",cc.game.frame.style.height=e+"px",this._resizeEvent(),cc.director.setProjection(cc.director.getProjection())},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleSizeInPixel:function(){return cc.size(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},getVisibleOrigin:function(){return cc.p(this._visibleRect.x,this._visibleRect.y)},getVisibleOriginInPixel:function(){return cc.p(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},canSetContentScaleFactor:function(){return!0},getResolutionPolicy:function(){return this._resolutionPolicy},setResolutionPolicy:function(t){if(t instanceof cc.ResolutionPolicy)this._resolutionPolicy=t;else{var e=cc.ResolutionPolicy;t===e.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),t===e.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),t===e.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),t===e.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),t===e.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},setDesignResolutionSize:function(t,e,i){if(t>0||e>0){this.setResolutionPolicy(i);var n=this._resolutionPolicy;if(n&&n.preApply(this),cc.sys.isMobile&&this._adjustViewportMeta(),this._orientationChanging=!0,this._resizing||this._initFrameSize(),n){this._originalDesignResolutionSize.width=this._designResolutionSize.width=t,this._originalDesignResolutionSize.height=this._designResolutionSize.height=e;var r=n.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var s=this._viewPortRect,o=this._visibleRect,a=r.viewport;s.x=a.x,s.y=a.y,s.width=a.width,s.height=a.height,o.x=-s.x/this._scaleX,o.y=-s.y/this._scaleY,o.width=cc.game.canvas.width/this._scaleX,o.height=cc.game.canvas.height/this._scaleY,cc._renderContext.setOffset&&cc._renderContext.setOffset(s.x,-s.y)}var c=cc.director;c._winSizeInPoints.width=this._designResolutionSize.width,c._winSizeInPoints.height=this._designResolutionSize.height,n.postApply(this),cc.winSize.width=c._winSizeInPoints.width,cc.winSize.height=c._winSizeInPoints.height,cc._renderType===cc.game.RENDER_TYPE_WEBGL?c.setGLDefaultValues():cc._renderType===cc.game.RENDER_TYPE_CANVAS&&(cc.renderer._allNeedDraw=!0),this._originalScaleX=this._scaleX,this._originalScaleY=this._scaleY,cc.visibleRect&&cc.visibleRect.init(this._visibleRect)}else cc.logID(2201)}else cc.logID(2200)},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setRealPixelResolution:function(t,e,i){this._setViewportMeta({width:t},!0),document.documentElement.style.width=t+"px",document.body.style.width=t+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(t,e,i)},setViewPortInPoints:function(t,e,i,n){var r=this._frameZoomFactor,s=this._scaleX,o=this._scaleY;cc._renderContext.viewport(t*s*r+this._viewPortRect.x*r,e*o*r+this._viewPortRect.y*r,i*s*r,n*o*r)},setScissorInPoints:function(t,e,i,n){var r=this._frameZoomFactor,s=this._scaleX,a=this._scaleY,c=Math.ceil(t*s*r+this._viewPortRect.x*r),h=Math.ceil(e*a*r+this._viewPortRect.y*r),l=Math.ceil(i*s*r),u=Math.ceil(n*a*r);if(!o){var _=gl.getParameter(gl.SCISSOR_BOX);o=cc.rect(_[0],_[1],_[2],_[3])}o.x===c&&o.y===h&&o.width===l&&o.height===u||(o.x=c,o.y=h,o.width=l,o.height=u,cc._renderContext.scissor(c,h,l,u))},isScissorEnabled:function(){return cc._renderContext.isEnabled(gl.SCISSOR_TEST)},getScissorRect:function(){if(!o){var t=gl.getParameter(gl.SCISSOR_BOX);o=cc.rect(t[0],t[1],t[2],t[3])}var e=1/this._scaleX,i=1/this._scaleY;return cc.rect((o.x-this._viewPortRect.x)*e,(o.y-this._viewPortRect.y)*i,o.width*e,o.height*i)},setViewName:function(t){null!=t&&t.length>0&&(this._viewName=t)},getViewName:function(){return this._viewName},getViewPortRect:function(){return this._viewPortRect},getScaleX:function(){return this._scaleX},getScaleY:function(){return this._scaleY},getDevicePixelRatio:function(){return this._devicePixelRatio},convertToLocationInView:function(t,e,i){var n=this._devicePixelRatio*(t-i.left),r=this._devicePixelRatio*(i.top+i.height-e);return this._isRotated?{x:this._viewPortRect.width-r,y:n}:{x:n,y:r}},_convertMouseToLocationInView:function(t,e){var i=this._viewPortRect;t.x=(this._devicePixelRatio*(t.x-e.left)-i.x)/this._scaleX,t.y=(this._devicePixelRatio*(e.top+e.height-t.y)-i.y)/this._scaleY},_convertPointWithScale:function(t){var e=this._viewPortRect;t.x=(t.x-e.x)/this._scaleX,t.y=(t.y-e.y)/this._scaleY},_convertTouchesWithScale:function(t){for(var e,i,n,r=this._viewPortRect,s=this._scaleX,o=this._scaleY,a=0;a<t.length;a++)i=(e=t[a])._point,n=e._prevPoint,i.x=(i.x-r.x)/s,i.y=(i.y-r.y)/o,n.x=(n.x-r.x)/s,n.y=(n.y-r.y)/o}});a._getInstance=function(){return this._instance||(this._instance=this._instance||new a,this._instance.initialize()),this._instance},cc.ContainerStrategy=cc._Class.extend({preApply:function(t){},apply:function(t,e){},postApply:function(t){},_setupContainer:function(t,e,i){var n=cc.game.canvas,r=cc.game.container;cc.sys.platform!==cc.sys.WECHAT_GAME&&(cc.sys.os===cc.sys.OS_ANDROID&&(document.body.style.width=(t._isRotated?i:e)+"px",document.body.style.height=(t._isRotated?e:i)+"px"),r.style.width=n.style.width=e+"px",r.style.height=n.style.height=i+"px");var s=t._devicePixelRatio=1;if(t.isRetinaEnabled()&&(s=t._devicePixelRatio=Math.min(2,window.devicePixelRatio||1)),n.width=e*s,n.height=i*s,cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT_GAME){var o=wx.getOpenDataContext().canvas;o&&(o.width=n.width,o.height=n.height)}cc._renderContext.resetCache&&cc._renderContext.resetCache()},_fixContainer:function(){document.body.insertBefore(cc.container,document.body.firstChild);var t=document.body.style;t.width=window.innerWidth+"px",t.height=window.innerHeight+"px",t.overflow="hidden";var e=cc.container.style;e.position="fixed",e.left=e.top="0px",document.body.scrollTop=0}}),cc.ContentStrategy=cc._Class.extend({_result:{scale:[1,1],viewport:null},_buildResult:function(t,e,i,n,r,s){Math.abs(t-i)<2&&(i=t),Math.abs(e-n)<2&&(n=e);var o=cc.rect(Math.round((t-i)/2),Math.round((e-n)/2),i,n);return cc._renderType,cc.game.RENDER_TYPE_CANVAS,this._result.scale=[r,s],this._result.viewport=o,this._result},preApply:function(t){},apply:function(t,e){return{scale:[1,1]}},postApply:function(t){}}),(function(){var t=cc.ContainerStrategy.extend({apply:function(t){var e=t._frameSize.height,i=cc.container.style;this._setupContainer(t,t._frameSize.width,t._frameSize.height),t._isRotated?i.margin="0 0 0 "+e+"px":i.margin="0px",i.padding="0px"}}),e=cc.ContainerStrategy.extend({apply:function(t,e){var i,n,r=t._frameSize.width,s=t._frameSize.height,o=cc.container.style,a=e.width,c=e.height,h=r/a,l=s/c;h<l?(i=r,n=c*h):(i=a*l,n=s);var u=Math.round((r-i)/2),_=Math.round((s-n)/2);i=r-2*u,n=s-2*_,this._setupContainer(t,i,n),t._isRotated?o.margin="0 0 0 "+s+"px":o.margin="0px",o.paddingLeft=u+"px",o.paddingRight=u+"px",o.paddingTop=_+"px",o.paddingBottom=_+"px"}}),i=(t.extend({preApply:function(t){this._super(t),cc.game.frame=document.documentElement},apply:function(t){this._super(t),this._fixContainer()}}),e.extend({preApply:function(t){this._super(t),cc.game.frame=document.documentElement},apply:function(t,e){this._super(t,e),this._fixContainer()}}),cc.ContainerStrategy.extend({apply:function(t){this._setupContainer(t,cc.game.canvas.width,cc.game.canvas.height)}}));cc.ContainerStrategy.EQUAL_TO_FRAME=new t,cc.ContainerStrategy.PROPORTION_TO_FRAME=new e,cc.ContainerStrategy.ORIGINAL_CONTAINER=new i;var n=cc.ContentStrategy.extend({apply:function(t,e){var i=cc.game.canvas.width,n=cc.game.canvas.height,r=i/e.width,s=n/e.height;return this._buildResult(i,n,i,n,r,s)}}),r=cc.ContentStrategy.extend({apply:function(t,e){var i,n,r=cc.game.canvas.width,s=cc.game.canvas.height,o=e.width,a=e.height,c=r/o,h=s/a,l=0;return c<h?(l=c,i=r,n=a*l):(l=h,i=o*l,n=s),this._buildResult(r,s,i,n,l,l)}}),s=cc.ContentStrategy.extend({apply:function(t,e){var i,n,r,s=cc.game.canvas.width,o=cc.game.canvas.height,a=e.width,c=e.height,h=s/a,l=o/c;return h<l?(i=l,n=a*i,r=o):(i=h,n=s,r=c*i),this._buildResult(s,o,n,r,i,i)}}),o=cc.ContentStrategy.extend({apply:function(t,e){var i=cc.game.canvas.width,n=cc.game.canvas.height,r=n/e.height,s=i,o=n;return this._buildResult(i,n,s,o,r,r)},postApply:function(t){cc.director._winSizeInPoints=t.getVisibleSize()}}),a=cc.ContentStrategy.extend({apply:function(t,e){var i=cc.game.canvas.width,n=cc.game.canvas.height,r=i/e.width,s=i,o=n;return this._buildResult(i,n,s,o,r,r)},postApply:function(t){cc.director._winSizeInPoints=t.getVisibleSize()}});cc.ContentStrategy.EXACT_FIT=new n,cc.ContentStrategy.SHOW_ALL=new r,cc.ContentStrategy.NO_BORDER=new s,cc.ContentStrategy.FIXED_HEIGHT=new o,cc.ContentStrategy.FIXED_WIDTH=new a})(),cc.ResolutionPolicy=cc._Class.extend({_containerStrategy:null,_contentStrategy:null,ctor:function(t,e){this.setContainerStrategy(t),this.setContentStrategy(e)},preApply:function(t){this._containerStrategy.preApply(t),this._contentStrategy.preApply(t)},apply:function(t,e){return this._containerStrategy.apply(t,e),this._contentStrategy.apply(t,e)},postApply:function(t){this._containerStrategy.postApply(t),this._contentStrategy.postApply(t)},setContainerStrategy:function(t){t instanceof cc.ContainerStrategy&&(this._containerStrategy=t)},setContentStrategy:function(t){t instanceof cc.ContentStrategy&&(this._contentStrategy=t)}}),cc.js.get(cc.ResolutionPolicy.prototype,"canvasSize",(function(){return cc.v2(cc.game.canvas.width,cc.game.canvas.height)})),cc.ResolutionPolicy.EXACT_FIT=0,cc.ResolutionPolicy.NO_BORDER=1,cc.ResolutionPolicy.SHOW_ALL=2,cc.ResolutionPolicy.FIXED_HEIGHT=3,cc.ResolutionPolicy.FIXED_WIDTH=4,cc.ResolutionPolicy.UNKNOWN=5,e.exports=a}),{"../event-manager":110}],187:[(function(t,e,i){cc.visibleRect={topLeft:cc.p(0,0),topRight:cc.p(0,0),top:cc.p(0,0),bottomLeft:cc.p(0,0),bottomRight:cc.p(0,0),bottom:cc.p(0,0),center:cc.p(0,0),left:cc.p(0,0),right:cc.p(0,0),width:0,height:0,init:function(t){var e=this.width=t.width,i=this.height=t.height,n=t.x,r=t.y,s=r+i,o=n+e;this.topLeft.x=n,this.topLeft.y=s,this.topRight.x=o,this.topRight.y=s,this.top.x=n+e/2,this.top.y=s,this.bottomLeft.x=n,this.bottomLeft.y=r,this.bottomRight.x=o,this.bottomRight.y=r,this.bottom.x=n+e/2,this.bottom.y=r,this.center.x=n+e/2,this.center.y=r+i/2,this.left.x=n,this.left.y=r+i/2,this.right.x=o,this.right.y=r+i/2}}}),{}],188:[(function(t,e,i){var n=cc.ClassManager={instanceId:0|998*Math.random(),getNewInstanceId:function(){return this.instanceId++}},r=/\b_super\b/,s=function(){};s.extend=function(t){var e,i=this.prototype,o=Object.create(i),a={writable:!0,enumerable:!1,configurable:!0};if(cc.game&&cc.game.config&&cc.game.config[cc.game.CONFIG_KEY.exposeClassName]){var c="return (function "+(t._className||"Class")+"(arg0,arg1,arg2,arg3,arg4) {\nthis.__instanceId = cc.ClassManager.getNewInstanceId();\nif (this.ctor) {\nswitch (arguments.length) {\ncase 0: this.ctor(); break;\ncase 1: this.ctor(arg0); break;\ncase 2: this.ctor(arg0,arg1); break;\ncase 3: this.ctor(arg0,arg1,arg2); break;\ncase 4: this.ctor(arg0,arg1,arg2,arg3); break;\ncase 5: this.ctor(arg0,arg1,arg2,arg3,arg4); break;\ndefault: this.ctor.apply(this, arguments);\n}\n}\n});";e=Function(c)()}else e=function(t,e,i,r,s){if(this.__instanceId=n.getNewInstanceId(),this.ctor)switch(arguments.length){case 0:this.ctor();break;case 1:this.ctor(t);break;case 2:this.ctor(t,e);break;case 3:this.ctor(t,e,i);break;case 4:this.ctor(t,e,i,r);break;case 5:this.ctor(t,e,i,r,s);break;default:this.ctor.apply(this,arguments)}};e.prototype=o,a.value=e,Object.defineProperty(o,"constructor",a);for(var h in t){var l="function"==typeof t[h];l&&"function"==typeof i[h]&&r.test(t[h])?(a.value=(function(t,e){return function(){var n=this._super;this._super=i[t];var r=e.apply(this,arguments);return this._super=n,r}})(h,t[h]),Object.defineProperty(o,h,a)):l?(a.value=t[h],Object.defineProperty(o,h,a)):o[h]=t[h]}return e.extend=s.extend,e.implement=function(t){for(var e in t)o[e]=t[e]},e},cc.defineGetterSetter=function(t,e,i,n,r,s){if(t.__defineGetter__)i&&t.__defineGetter__(e,i),n&&t.__defineSetter__(e,n);else{if(!Object.defineProperty)throw new Error("browser does not support getters");var o={configurable:!0};i&&(o.get=i),n&&(o.set=n),Object.defineProperty(t,e,o)}},cc.clone=function(t){var e=t.constructor?new t.constructor:{};for(var i in t){var n=t[i];"object"!=typeof n||!n||n instanceof _ccsg.Node||n instanceof HTMLElement?e[i]=n:e[i]=cc.clone(n)}return e},cc._Class=e.exports=s}),{}],189:[(function(t,e,i){function n(t,e,i){var n;n=function(){},i&&c.extend(n,i.constructor);var r=new n;return c.value(t,"__attrs__",r),r}function r(t,e,i){var r,o,a;if("function"==typeof t)o=(r=s(t)).constructor.prototype;else{var c=t;if(!(r=c.__attrs__)){r=n(c,0,s(t=c.constructor))}o=r}if(void 0===i){var l=e+h,u={};for(a in r)a.startsWith(l)&&(u[a.slice(l.length)]=r[a]);return u}if("object"==typeof i)for(a in i)95!==a.charCodeAt(0)&&(o[e+h+a]=i[a]);else 0}function s(t){return t.hasOwnProperty("__attrs__")&&t.__attrs__||(function(t){for(var e,i=cc.Class.getInheritanceChain(t),r=i.length-1;r>=0;r--){var s=i[r];s.hasOwnProperty("__attrs__")&&s.__attrs__||n(s,0,(e=i[r+1])&&e.__attrs__)}return e=i[0],n(t,0,e&&e.__attrs__),t.__attrs__})(t)}function o(t){return s(t).constructor.prototype}function a(t,e){0}var c=t("./js"),h=(t("./utils").isPlainEmptyObj_DEV,"$_$");cc.Integer="Integer",cc.Float="Float",cc.Boolean="Boolean",cc.String="String",e.exports={attr:r,getClassAttrs:s,getClassAttrsProto:o,setClassAttr:function(t,e,i,n){o(t)[e+h+i]=n},DELIMETER:h,getTypeChecker:a,ObjectType:function(t){return{type:"Object",ctor:t,_onAfterProp:!1}},ScriptUuid:{}}}),{"./CCClass":176,"./js":197,"./utils":201}],190:[(function(t,e,i){function n(){this.callbacks=[],this.targets=[],this.isInvoking=!1,this.containCanceled=!1}function r(){this._callbackTable=s.createMap(!0)}var s=t("./js"),o=s.array.fastRemoveAt,a=n.prototype;a.removeBy=function(t,e){for(var i=this.callbacks,n=this.targets,r=0;r<t.length;++r)t[r]===e&&(o(i,r),o(n,r),--r)},a.cancel=function(t){this.callbacks[t]=this.targets[t]=null,this.containCanceled=!0},a.cancelAll=function(){for(var t=this.callbacks,e=this.targets,i=0;i<t.length;i++)t[i]=e[i]=null;this.containCanceled=!0},a.purgeCanceled=function(){this.removeBy(this.callbacks,null),this.containCanceled=!1};var c=new s.Pool(function(t){t.callbacks.length=0,t.targets.length=0,t.isInvoking=!1,t.containCanceled=!1},16);c.get=function(){return this._get()||new n},(a=r.prototype).add=function(t,e,i){var n=this._callbackTable[t];n||(n=this._callbackTable[t]=c.get()),n.callbacks.push(e),n.targets.push(i||null)},a.has=function(t,e,i){var n=this._callbackTable[t];if(!n)return!1;var r=n.callbacks;if(!e){for(var s=0;s<r.length;s++)if(r[s])return!0;return!1}i=i||null;for(var o=n.targets,a=0;a<r.length;++a)if(r[a]===e&&o[a]===i)return!0;return!1},a.removeAll=function(t){if("string"==typeof t){var e=this._callbackTable[t];e&&(e.isInvoking?e.cancelAll():(c.put(e),delete this._callbackTable[t]))}else if(t)for(var i in this._callbackTable){var n=this._callbackTable[i];if(n.isInvoking)for(var r=n.targets,s=0;s<r.length;++s)r[s]===t&&n.cancel(s);else n.removeBy(n.targets,t)}},a.remove=function(t,e,i){var n=this._callbackTable[t];if(n){i=i||null;for(var r=n.callbacks,s=n.targets,a=0;a<r.length;++a)if(r[a]===e&&s[a]===i){n.isInvoking?n.cancel(a):(o(r,a),o(s,a));break}}};var h=function(){r.call(this)};s.extend(h,r),h.prototype.invoke=function(t,e,i,n,r,s){var o=this._callbackTable[t];if(o){var a=!o.isInvoking;o.isInvoking=!0;for(var c=o.callbacks,h=o.targets,l=0,u=c.length;l<u;++l){var _=c[l];if(_){var d=h[l];d?_.call(d,e,i,n,r,s):_(e,i,n,r,s)}}a&&(o.isInvoking=!1,o.containCanceled&&o.purgeCanceled())}},h.CallbacksHandler=r,e.exports=h}),{"./js":197}],191:[(function(t,e,i){function n(t,e){for(var i=0;i<e.length;i++){var r=e[i];Array.isArray(r)?n(t,r):t.push(r)}}e.exports={flattenCodeArray:function(t){var e=[];return n(e,t),e.join("")}}}),{}],192:[(function(t,e,i){var n=t("./js"),r=(t("./CCObject"),t("./attribute")),s=t("./CCClass"),o=t("../utils/misc"),a=function(){this.uuidList=[],this.uuidObjList=[],this.uuidPropList=[],this.rawProp=""};a.prototype.reset=function(){this.uuidList.length=0,this.uuidObjList.length=0,this.uuidPropList.length=0,this.rawProp=""},a.prototype.getUuidOf=function(t,e){for(var i=0;i<this.uuidObjList.length;i++)if(this.uuidObjList[i]===t&&this.uuidPropList[i]===e)return this.uuidList[i];return""},a.prototype.push=function(t,e,i){this.uuidList.push(i),this.uuidObjList.push(t),this.uuidPropList.push(e)},(a.pool=new n.Pool(function(t){t.reset()},10)).get=function(){return this._get()||new a};var c=(function(){function t(t,e,i,n,r){this.result=t,this.customEnv=n,this.deserializedList=[],this.deserializedData=null,this._classFinder=i,this._idList=[],this._idObjList=[],this._idPropList=[]}function e(t,e,i,r,s){var o;r.hasOwnProperty("__deserialize__")?o=r.__deserialize__:(o=c(t,r),n.value(r,"__deserialize__",o,!0)),o(t,e,i,r,s)}var i=t.prototype;i.deserialize=function(t){if(Array.isArray(t)){var e=t,i=e.length;this.deserializedList.length=i;for(var n=0;n<i;n++)if(e[n]){this.deserializedList[n]=this._deserializeObject(e[n])}this.deserializedData=i>0?this.deserializedList[0]:[]}else this.deserializedList.length=1,this.deserializedData=t?this._deserializeObject(t):null,this.deserializedList[0]=this.deserializedData;return (function(t){var e,i,n,r=t.deserializedList,s=t._idPropList,o=t._idList,a=t._idObjList;for(t._classFinder&&t._classFinder.onDereferenced,e=0;e<o.length;e++)i=s[e],n=o[e],a[e][i]=r[n]})(this),this.deserializedData},i._deserializeObject=function(t,i,r,s){var o,a=null,c=null,h=t.__type__;if(h){if(!(c=this._classFinder(h,t,r,s))){return this._classFinder===n._getClassById&&cc.deserialize.reportMissingClass(h),null}if((a=new c)._deserialize)return a._deserialize(t.content,this),a;cc.Class._isCCClass(c)?e(this,a,t,c,i):this._deserializeTypedObject(a,t,c)}else if(Array.isArray(t)){a=new Array(t.length);for(var l=0;l<t.length;l++)"object"==typeof(o=t[l])&&o?this._deserializeObjField(a,o,""+l):a[l]=o}else a={},this._deserializePrimitiveObject(a,t);return a},i._deserializeObjField=function(t,e,i,n){var r=e.__id__;if(void 0===r){var s=e.__uuid__;s?(this.result.uuidList.push(s),this.result.uuidObjList.push(t),this.result.uuidPropList.push(i)):t[i]=this._deserializeObject(e)}else{var o=this.deserializedList[r];o?t[i]=o:(this._idList.push(r),this._idObjList.push(t),this._idPropList.push(i))}},i._deserializePrimitiveObject=function(t,e){for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];"object"!=typeof n?"__type__"!==i&&(t[i]=n):n?this._deserializeObjField(t,n,i):t[i]=null}},i._deserializeTypedObject=function(t,e,i){if(i===cc.Vec2)return t.x=e.x||0,void(t.y=e.y||0);if(i!==cc.Color){if(i===cc.Size)return t.width=e.width||0,void(t.height=e.height||0);var n=i.__props__;n||(n=Object.keys(t));for(var r=0;r<n.length;r++){var s=n[r],o=e[s];void 0!==o&&e.hasOwnProperty(s)&&("object"!=typeof o?t[s]=o:o?this._deserializeObjField(t,o,s):t[s]=null)}}else{t.r=e.r||0,t.g=e.g||0,t.b=e.b||0;var a=e.a;t.a=void 0===a?255:a}};var a=function(t,e,i,r,s){if(e instanceof cc.ValueType){s||t.push("if(prop){");var o=n.getClassName(e);t.push("s._deserializeTypedObject(o"+i+",prop,"+o+");"),s||t.push("}else o"+i+"=null;")}else t.push("if(prop){"),t.push("s._deserializeObjField(o,prop,"+r+");"),t.push("}else o"+i+"=null;")},c=function(t,e){for(var i=r.DELIMETER+"type",c=r.DELIMETER+"rawType",h=(r.DELIMETER,r.DELIMETER+"serializable"),l=r.DELIMETER+"default",u=r.DELIMETER+"saveUrlAsAsset",_=r.DELIMETER+"formerlySerializedAs",d=r.getClassAttrs(e),f=e.__props__,p=["var prop;"],m=o.BUILTIN_CLASSID_RE.test(n._getClassId(e)),g=0;g<f.length;g++){var y,v=f[g];if(d[v+c])y=s.IDENTIFIER_RE.test(v)?'"'+v+'"':s.escapeForJS(v),p.push('if(s.result.rawProp)\ncc.error("not support multi raw object in a file");'),p.push("s.result.rawProp="+y+";");else{if(!1===d[v+h])continue;var x;s.IDENTIFIER_RE.test(v)?(y='"'+v+'"',x="."+v):x="["+(y=s.escapeForJS(v))+"]";var C=x;if(d[v+_]){var T=d[v+_];C=s.IDENTIFIER_RE.test(T)?"."+T:"["+s.escapeForJS(T)+"]"}p.push("prop=d"+C+";"),p.push('if(typeof prop!=="undefined"){');var b=s.getDefault(d[v+l]);if(m){var A,S=d[v+i];if(void 0===b&&S)A=S===cc.String||S===cc.Integer||S===cc.Float||S===cc.Boolean;else{var w=typeof b;A="string"===w&&!d[v+u]||"number"===w||"boolean"===w}A?p.push("o"+x+"=prop;"):a(p,b,x,y,!0)}else p.push('if(typeof prop!=="object"){o'+x+"=prop;}else{"),a(p,b,x,y,!1),p.push("}");p.push("}")}}return"_$erialized"===f[f.length-1]&&(p.push("o._$erialized=JSON.parse(JSON.stringify(d));"),p.push("s._deserializePrimitiveObject(o._$erialized,d);")),Function("s","o","d","k","t",p.join(""))};return t.pool=new n.Pool(function(t){t.result=null,t.customEnv=null,t.deserializedList.length=0,t.deserializedData=null,t._classFinder=null,t._idList.length=0,t._idObjList.length=0,t._idPropList.length=0},1),t.pool.get=function(e,i,n,r,s){var o=this._get();return o?(o.result=e,o.customEnv=r,o._classFinder=n,o):new t(e,i,n,r,s)},t})();cc.deserialize=function(t,e,i){var r=(i=i||{}).classFinder||n._getClassById,s=i.createAssetRefs||cc.sys.platform===cc.sys.EDITOR_CORE,o=i.customEnv,h=i.ignoreEditorOnly;"string"==typeof t&&(t=JSON.parse(t));var l=!e;e=e||a.pool.get();var u=c.pool.get(e,!1,r,o,h);cc.game._isCloning=!0;var _=u.deserialize(t);return cc.game._isCloning=!1,c.pool.put(u),s&&e.assignAssetsBy(Editor.serialize.asAsset),l&&a.pool.put(e),_},cc.deserialize.Details=a,cc.deserialize.reportMissingClass=function(t){cc.warnID(5302,t)}}),{"../utils/misc":226,"./CCClass":176,"./CCObject":182,"./attribute":189,"./js":197}],193:[(function(t,e,i){function n(t){this.id=0|998*Math.random(),this.prefix=t?t+r:""}var r=".";n.prototype.getNewId=function(){return this.prefix+ ++this.id},n.global=new n("global"),e.exports=n}),{}],194:[(function(t,e,i){t("./js"),t("./CCClass"),t("./CCClassDecorator"),t("./CCEnum"),t("./CCObject"),t("./callbacks-invoker"),t("./url"),t("./deserialize"),t("./instantiate"),t("./instantiate-jit"),t("./requiring-frame"),t("./CCSys"),t("./CCMacro"),t("./CCAssetLibrary"),t("./CCVisibleRect")}),{"./CCAssetLibrary":175,"./CCClass":176,"./CCClassDecorator":177,"./CCEnum":178,"./CCMacro":181,"./CCObject":182,"./CCSys":185,"./CCVisibleRect":187,"./callbacks-invoker":190,"./deserialize":192,"./instantiate":196,"./instantiate-jit":195,"./js":197,"./requiring-frame":199,"./url":200}],195:[(function(t,e,i){function n(t,e){this.varName=t,this.expression=e}function r(t,e){return e instanceof n?new n(e.varName,t+e.expression):t+e}function s(t,e,i){Array.isArray(i)?(i[0]=r(e,i[0]),t.push(i)):t.push(r(e,i)+";")}function o(t){this._exps=[],this._targetExp=t}function a(t,e){if("function"==typeof t)try{t=t()}catch(t){return!1}if(t===e)return!0;if(t&&e){if(t instanceof cc.ValueType&&t.equals(e))return!0;if(Array.isArray(t)&&Array.isArray(e)||t.constructor===Object&&e.constructor===Object)try{return JSON.stringify(t)===JSON.stringify(e)}catch(t){}}return!1}function c(t){return v.test(t)?"."+t:"["+x(t)+"]"}function h(t,e){this.parent=e,this.objsToClear_iN$t=[],this.codeArray=[],this.objs=[],this.funcs=[],this.funcModuleCache=f.createMap(),f.mixin(this.funcModuleCache,A),this.globalVariables=[],this.globalVariableId=0,this.localVariableId=0,this.codeArray.push(C+T+","+b+";","if(R){",T+"=R;","}else{",T+"=R=new "+this.getFuncModule(t.constructor,!0)+"();","}"),t._iN$t={globalVar:"R"},this.objsToClear_iN$t.push(t),this.enumerateObject(this.codeArray,t);var i;this.globalVariables.length>0&&(i=C+this.globalVariables.join(",")+";");var n=m.flattenCodeArray(["return (function(R){",i||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",n)(this.objs,this.funcs);for(var r=0,s=this.objsToClear_iN$t.length;r<s;++r)this.objsToClear_iN$t[r]._iN$t=null;this.objsToClear_iN$t.length=0}var l=t("./CCObject"),u=l.Flags.Destroyed,_=l.Flags.PersistentMask,d=t("./attribute"),f=t("./js"),p=t("./CCClass"),m=t("./compiler"),g=d.DELIMETER+"serializable",y=d.DELIMETER+"default",v=p.IDENTIFIER_RE,x=p.escapeForJS,C="var ",T="o",b="t",A={"cc.Node":"cc.Node","cc.Sprite":"cc.Sprite","cc.Label":"cc.Label","cc.Button":"cc.Button","cc.Widget":"cc.Widget","cc.Animation":"cc.Animation","cc.ClickEvent":!1,"cc.PrefabInfo":!1};n.prototype.toString=function(){return C+this.varName+"="+this.expression+";"},o.prototype.append=function(t,e){this._exps.push([t,e])},o.prototype.writeCode=function(t){var e;if(this._exps.length>1)t.push(b+"="+this._targetExp+";"),e=b;else{if(1!==this._exps.length)return;e=this._targetExp}for(var i=0;i<this._exps.length;i++){var n=this._exps[i];s(t,e+c(n[0])+"=",n[1])}},(o.pool=new f.Pool(function(t){t._exps.length=0,t._targetExp=null},1)).get=function(t){var e=this._get()||new o;return e._targetExp=t,e};var S=h.prototype;S.getFuncModule=function(t,e){var i=f.getClassName(t);if(i){var n=this.funcModuleCache[i];if(n)return n;if(void 0===n){var r=-1!==i.indexOf(".");if(r)try{if(r=t===Function("return "+i)())return this.funcModuleCache[i]=i,i}catch(t){}}}var s=this.funcs.indexOf(t);s<0&&(s=this.funcs.length,this.funcs.push(t));var o="F["+s+"]";return e&&(o="("+o+")"),this.funcModuleCache[i]=o,o},S.getObjRef=function(t){var e=this.objs.indexOf(t);return e<0&&(e=this.objs.length,this.objs.push(t)),"O["+e+"]"},S.setValueType=function(t,e,i,n){var r=o.pool.get(n),s=e.constructor.__props__;s||(s=Object.keys(e));for(var a=0;a<s.length;a++){var c=s[a],h=i[c];if(e[c]!==h){var l=this.enumerateField(i,c,h);r.append(c,l)}}r.writeCode(t),o.pool.put(r)},S.enumerateCCClass=function(t,e,i){for(var n=i.__props__,r=d.getClassAttrs(i),s=0;s<n.length;s++){var o=n[s];if(!1!==r[o+g]){var h=e[o];if(a(l=r[o+y],h))continue;if("object"==typeof h&&h instanceof cc.ValueType){var l;if(((l=p.getDefault(l))&&l.constructor)===h.constructor){var u=T+c(o);this.setValueType(t,l,h,u);continue}}this.setObjProp(t,e,o,h)}}},S.instantiateArray=function(t){if(0===t.length)return"[]";var e="a"+ ++this.localVariableId,i=[new n(e,"new Array("+t.length+")")];t._iN$t={globalVar:"",source:i},this.objsToClear_iN$t.push(t);for(var r=0;r<t.length;++r){s(i,e+"["+r+"]=",this.enumerateField(t,r,t[r]))}return i},S.enumerateField=function(t,e,i){if("object"==typeof i&&i){var n=i._iN$t;if(n){var s=n.globalVar;if(!s){s=n.globalVar="v"+ ++this.globalVariableId,this.globalVariables.push(s);var o=n.source[0];n.source[0]=r(s+"=",o)}return s}return Array.isArray(i)?this.instantiateArray(i):this.instantiateObj(i)}return"function"==typeof i?this.getFuncModule(i):"string"==typeof i?x(i):("_objFlags"===e&&t instanceof l&&(i&=_),i)},S.setObjProp=function(t,e,i,n){s(t,T+c(i)+"=",this.enumerateField(e,i,n))},S.enumerateObject=function(t,e){var i=e.constructor;if(cc.Class._isCCClass(i))this.enumerateCCClass(t,e,i);else for(var n in e)if(e.hasOwnProperty(n)&&(95!==n.charCodeAt(0)||95!==n.charCodeAt(1)||"__type__"===n)){var r=e[n];"object"==typeof r&&r&&r===e._iN$t||this.setObjProp(t,e,n,r)}},S.instantiateObj=function(t){if(t instanceof cc.ValueType)return p.getNewValueTypeCode(t);if(t instanceof cc.Asset)return this.getObjRef(t);if(t._objFlags&u)return null;var e,i=t.constructor;if(cc.Class._isCCClass(i)){if(this.parent)if(this.parent instanceof cc.Component){if(t instanceof cc._BaseNode||t instanceof cc.Component)return this.getObjRef(t)}else if(this.parent instanceof cc._BaseNode)if(t instanceof cc._BaseNode){if(!t.isChildOf(this.parent))return this.getObjRef(t)}else if(t instanceof cc.Component&&!t.node.isChildOf(this.parent))return this.getObjRef(t);e=new n(T,"new "+this.getFuncModule(i,!0)+"()")}else if(i===Object)e=new n(T,"{}");else{if(i)return this.getObjRef(t);e=new n(T,"Object.create(null)")}var r=[e];return t._iN$t={globalVar:"",source:r},this.objsToClear_iN$t.push(t),this.enumerateObject(r,t),["(function(){",r,"return o;})();"]},e.exports={compile:function(t){return new h(t,t instanceof cc._BaseNode&&t).result},equalsToDefault:a}}),{"./CCClass":176,"./CCObject":182,"./attribute":189,"./compiler":191,"./js":197}],196:[(function(t,e,i){function n(t,e){if(!e){if("object"!=typeof t||Array.isArray(t))return null;if(!t)return null;if(!cc.isValid(t))return null;0}var i;if(t instanceof a){if(t._instantiate)return cc.game._isCloning=!0,i=t._instantiate(),cc.game._isCloning=!1,i;if(t instanceof cc.Asset)return null}return cc.game._isCloning=!0,i=r(t),cc.game._isCloning=!1,i}function r(t,e){if(Array.isArray(t))return null;if(u&&u(t))return null;var i;if(t._iN$t)i=t._iN$t;else if(t.constructor){i=new(0,t.constructor)}else i=Object.create(null);s(t,i,e);for(var n=0,r=_.length;n<r;++n)_[n]._iN$t=null;return _.length=0,i}function s(t,e,i){t._iN$t=e,_.push(t);var n=t.constructor;if(cc.Class._isCCClass(n))(function(t,e,i,n){for(var r=t.__props__,s=l.getClassAttrs(t),a=0;a<r.length;a++){var c=r[a];if(!1!==s[c+d]){var h=e[c];i[c]="object"==typeof h&&h?h._iN$t||o(h,n):h}}})(n,t,e,i);else for(var r in t)if(t.hasOwnProperty(r)&&(95!==r.charCodeAt(0)||95!==r.charCodeAt(1)||"__type__"===r)){var s=t[r];if("object"==typeof s&&s){if(s===e)continue;e[r]=s._iN$t||o(s,i)}else e[r]=s}t instanceof a&&(e._objFlags&=h)}function o(t,e){if(t instanceof cc.ValueType)return t.clone();if(t instanceof cc.Asset)return t;var i;if(Array.isArray(t)){var n=t.length;i=new Array(n),t._iN$t=i;for(var r=0;r<n;++r){var a=t[r];i[r]="object"==typeof a&&a?a._iN$t||o(a,e):a}return _.push(t),i}if(t._objFlags&c)return null;var h=t.constructor;if(cc.Class._isCCClass(h)){if(e)if(e instanceof cc.Component){if(t instanceof cc._BaseNode||t instanceof cc.Component)return t}else if(e instanceof cc._BaseNode)if(t instanceof cc._BaseNode){if(!t.isChildOf(e))return t}else if(t instanceof cc.Component&&!t.node.isChildOf(e))return t;i=new h}else if(h===Object)i={};else{if(h)return t;i=Object.create(null)}return s(t,i,e),i}var a=t("./CCObject"),c=a.Flags.Destroyed,h=a.Flags.PersistentMask,l=t("./attribute"),u=t("./utils").isDomNode,_=[],d=l.DELIMETER+"serializable";n._clone=r,cc.instantiate=n,e.exports=n}),{"./CCObject":182,"./attribute":189,"./utils":201}],197:[(function(t,e,i){function n(t,e){for(;t;){var i=Object.getOwnPropertyDescriptor(t,e);if(i)return i;t=Object.getPrototypeOf(t)}return null}function r(t,e,i){var r=n(e,t);Object.defineProperty(i,t,r)}function s(t,e){t.splice(e,1)}function o(t,e){var i=t.indexOf(e);return i>=0&&(s(t,i),!0)}function a(t,e){"number"==typeof t&&(e=t,t=null),this.get=null,this.count=0,this._pool=new Array(e),this._cleanup=t}var c=new(t("./id-generater"))("TmpCId."),h={isNumber:function(t){return"number"==typeof t||t instanceof Number},isString:function(t){return"string"==typeof t||t instanceof String},addon:function(t){"use strict";t=t||{};for(var e=1,i=arguments.length;e<i;e++){var n=arguments[e];if(n){if("object"!=typeof n){cc.errorID(5402,n);continue}for(var s in n)s in t||r(s,n,t)}}return t},mixin:function(t){"use strict";t=t||{};for(var e=1,i=arguments.length;e<i;e++){var n=arguments[e];if(n){if("object"!=typeof n){cc.errorID(5403,n);continue}for(var s in n)r(s,n,t)}}return t},extend:function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.prototype=Object.create(e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),t},getSuper:function(t){var e=t.prototype,i=e&&Object.getPrototypeOf(e);return i&&i.constructor},clear:function(t){for(var e=Object.keys(t),i=0;i<e.length;i++)delete t[e[i]]},getPropertyDescriptor:n},l={value:void 0,enumerable:!1,writable:!1,configurable:!0};h.value=function(t,e,i,n,r){l.value=i,l.writable=n,l.enumerable=r,Object.defineProperty(t,e,l),l.value=void 0};var u={get:null,set:null,enumerable:!1};h.getset=function(t,e,i,n,r){"function"!=typeof n&&(r=n,n=void 0),u.get=i,u.set=n,u.enumerable=r,Object.defineProperty(t,e,u),u.get=null,u.set=null};var _={get:null,enumerable:!1,configurable:!1};h.get=function(t,e,i,n,r){_.get=i,_.enumerable=n,_.configurable=r,Object.defineProperty(t,e,_),_.get=null};var d={set:null,enumerable:!1,configurable:!1};h.set=function(t,e,i,n,r){d.set=i,d.enumerable=n,d.configurable=r,Object.defineProperty(t,e,d),d.set=null},h.getClassName=function(t){if("function"==typeof t){var e=t.prototype;if(e&&e.hasOwnProperty("__classname__")&&e.__classname__)return e.__classname__;var i="";if(t.name&&(i=t.name),t.toString){var n,r=t.toString();(n="["===r.charAt(0)?r.match(/\[\w+\s*(\w+)\]/):r.match(/function\s*(\w+)/))&&2===n.length&&(i=n[1])}return"Object"!==i?i:""}return t&&t.constructor?h.getClassName(t.constructor):""},(function(){function t(t,e){return function(i,n){if(n.prototype.hasOwnProperty(t)&&delete e[n.prototype[t]],h.value(n.prototype,t,i),i){var r=e[i];if(r&&r!==n){var s="A Class already exists with the same "+t+' : "'+i+'".';0,cc.error(s)}else e[i]=n}}}var e={},i={};h._setClassId=t("__cid__",e);var n=t("__classname__",i);h.setClassName=function(t,e){if(n(t,e),!e.prototype.hasOwnProperty("__cid__")){var i=t||c.getNewId();i&&h._setClassId(i,e)}},h.unregisterClass=function(){for(var t=0;t<arguments.length;t++){var n=arguments[t].prototype,r=n.__cid__;r&&delete e[r];var s=n.__classname__;s&&delete i[s]}},h._getClassById=function(t){return e[t]},h.getClassByName=function(t){return i[t]},h._getClassId=function(t,e){e=void 0===e||e;if("function"==typeof t&&t.prototype.hasOwnProperty("__cid__"))return t.prototype.__cid__;if(t&&t.constructor){var i=t.constructor.prototype;if(i&&i.hasOwnProperty("__cid__"))return t.__cid__}return""}})(),h.obsolete=function(t,e,i,n){function r(){return this[i]}var s=/([^.]+)$/.exec(e)[0];n?h.getset(t,s,r,(function(t){this[i]=t})):h.get(t,s,r)},h.obsoletes=function(t,e,i,n){for(var r in i){var s=i[r];h.obsolete(t,e+"."+r,s,n)}};var f=/(%d)|(%s)/,p=/%s/;h.formatStr=function(){var t=arguments.length;if(0===t)return"";var e=arguments[0];if(1===t)return""+e;if("string"==typeof e&&f.test(e))for(var i=1;i<t;++i){var n=arguments[i],r="number"==typeof n?f:p;r.test(e)?e=e.replace(r,n):e+=" "+n}else for(var s=1;s<t;++s)e+=" "+arguments[s];return e},h.shiftArguments=function(){for(var t=arguments.length-1,e=new Array(t),i=0;i<t;++i)e[i]=arguments[i+1];return e},h.createMap=function(t){var e=Object.create(null);if(t){e["."]=!0,e["/"]=!0,delete e["."],delete e["/"]}return e};var m=Array.prototype.indexOf;h.array={remove:o,fastRemove:function(t,e){var i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],--t.length)},removeAt:s,fastRemoveAt:function(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)},contains:function(t,e){return t.indexOf(e)>=0},verifyType:function(t,e){if(t&&t.length>0)for(var i=0;i<t.length;i++)if(!(t[i]instanceof e))return cc.logID(1300),!1;return!0},removeArray:function(t,e){for(var i=0,n=e.length;i<n;i++)o(t,e[i])},appendObjectsAt:function(t,e,i){return t.splice.apply(t,[i,0].concat(e)),t},copy:function(t){var e,i=t.length,n=new Array(i);for(e=0;e<i;e+=1)n[e]=t[e];return n},indexOf:m,MutableForwardIterator:t("../utils/mutable-forward-iterator")},a.prototype._get=function(){if(this.count>0){--this.count;var t=this._pool[this.count];return this._pool[this.count]=null,t}return null},a.prototype.put=function(t){var e=this._pool;if(this.count<e.length){if(this._cleanup&&!1===this._cleanup(t))return;e[this.count]=t,++this.count}},a.prototype.resize=function(t){t>=0&&(this._pool.length=t,this.count>t&&(this.count=t))},h.Pool=a,cc.js=h,e.exports=h}),{"../utils/mutable-forward-iterator":227,"./id-generater":193}],198:[(function(t,e,i){function n(t,e,i,n){if(!t.get&&!t.set)if(t.hasOwnProperty("default")){var r="_N$"+e;t.get=function(){return this[r]},t.set=function(t){var e=this[r];this[r]=t,i.call(this,e)};var s={};n[r]=s;for(var o in a){var c=a[o];t.hasOwnProperty(o)&&(s[o]=t[o],c.canUsedInGet||delete t[o])}}else 0}function r(t,e,i,n){Array.isArray(n)&&n.length>0&&(n=n[0]),t.type=n}function s(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return cc.errorID(5508,i,n);if(cc.RawAsset.isRawAssetType(e[0]))return t.url=e[0],void delete t.type;t.type=e=e[0]}}function o(t,e,i,n){0}var a={url:{canUsedInGet:!0},default:{},serializable:{},editorOnly:{},rawType:{},formerlySerializedAs:{}};i.getFullFormOfProperty=function(t){if(!(t&&t.constructor===Object)){if(Array.isArray(t)&&t.length>0)return{default:[],type:t,_short:!0};if("function"==typeof t){var e=t;return cc.RawAsset.isRawAssetType(e)?{default:"",url:e,_short:!0}:{default:cc.isChildClassOf(e,cc.ValueType)?new e:null,type:e,_short:!0}}return{default:t,_short:!0}}return null},i.preprocessAttrs=function(t,e,a,c){for(var h in t){var l=t[h],u=i.getFullFormOfProperty(l);if(u&&(l=t[h]=u),l){var _=l.notify;_&&n(l,h,_,t),"type"in l&&s(l,l.type,e,h),"url"in l&&r(l,0,0,l.url),"type"in l&&o(0,l.type)}}},i.validateMethodWithProps=function(t,e,i,n,r){if("function"!=typeof t&&null!==t){return!1}return!0}}),{"./CCClass":176}],199:[(function(t,e,i){var n=[];cc._RF={push:function(t,e,i){void 0===i&&(i=e,e=""),n.push({uuid:e,script:i,module:t,exports:t.exports,beh:null})},pop:function(){var t=n.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var r in i)return;e.exports=i=t.cls}},peek:function(){return n[n.length-1]}}}),{}],200:[(function(t,e,i){var n={};cc.url={_rawAssets:"",_builtinRawAssets:"",normalize:function(t){return 46===t.charCodeAt(0)&&47===t.charCodeAt(1)?t=t.slice(2):47===t.charCodeAt(0)&&(t=t.slice(1)),t},raw:function(t){return(t=this.normalize(t)).startsWith("resources/")||cc.errorID(7002,t),this._rawAssets+t},builtinRaw:!1,_init:function(t){for(var e in t){var i=t[e];i=cc.path.stripSep(i)+"/",n[e]=i}this._rawAssets=n.assets,this._builtinRawAssets=n.internal}},e.exports=cc.url}),{}],201:[(function(t,e,i){e.exports={contains:function(t,e){if("function"==typeof t.contains)return t.contains(e);if("function"==typeof t.compareDocumentPosition)return!!(16&t.compareDocumentPosition(e));var i=e.parentNode;if(i)do{if(i===t)return!0;i=i.parentNode}while(null!==i);return!1},isDomNode:"object"==typeof window&&("function"==typeof Node?function(t){return t instanceof Node}:function(t){return t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}),callInNextTick:function(t,e,i){t&&setTimeout((function(){t(e,i)}),0)}}}),{}],202:[(function(t,e,i){t("./platform/js"),t("./value-types"),t("./utils"),t("./platform/CCInputManager"),t("./platform/CCInputExtension"),t("./event"),t("./platform/CCSys"),t("./platform/CCMacro"),t("./load-pipeline"),t("./textures"),t("./CCDirector"),t("./CCDirectorWebGL"),t("./CCDirectorCanvas"),t("./platform/CCSAXParser"),t("./platform/CCView"),t("./platform/CCScreen"),t("./CCScheduler"),t("./event-manager"),t("./renderer")}),{"./CCDirector":33,"./CCDirectorCanvas":34,"./CCDirectorWebGL":35,"./CCScheduler":42,"./event":114,"./event-manager":110,"./load-pipeline":136,"./platform/CCInputExtension":179,"./platform/CCInputManager":180,"./platform/CCMacro":181,"./platform/CCSAXParser":183,"./platform/CCScreen":184,"./platform/CCSys":185,"./platform/CCView":186,"./platform/js":197,"./renderer":206,"./textures":218,"./utils":225,"./value-types":239}],203:[(function(t,e,i){function n(){var t=c.pop();return t||(t=new o),t}function r(t){c.push(t)}function s(t,e){var i=t._minX<e._minX?t._minX:e._minX,n=t._minY<e._minY?t._minY:e._minY;return((t._maxX>e._maxX?t._maxX:e._maxX)-i)*((t._maxY>e._maxY?t._maxY:e._maxY)-n)}var o=function(){this._minX=0,this._minY=0,this._maxX=0,this._maxY=0,this._width=0,this._height=0,this._area=0},a=o.prototype,c=[];a.setTo=function(t,e,i,n){return this._minX=t,this._minY=e,this._maxX=i,this._maxY=n,this.updateArea(),this},a.intValues=function(){this._minX=Math.floor(this._minX),this._minY=Math.floor(this._minY),this._maxX=Math.ceil(this._maxX),this._maxY=Math.ceil(this._maxY),this.updateArea()},a.updateArea=function(){this._width=this._maxX-this._minX,this._height=this._maxY-this._minY,this._area=this._width*this._height},a.union=function(t){this.isEmpty()?this.setTo(t._minX,t._minY,t._maxX,t._maxY):(this._minX>t._minX&&(this._minX=t._minX),this._minY>t._minY&&(this._minY=t._minY),this._maxX<t._maxX&&(this._maxX=t._maxX),this._maxY<t._maxY&&(this._maxY=t._maxY),this.updateArea())},a.setEmpty=function(){this._minX=0,this._minY=0,this._maxX=0,this._maxY=0,this._width=0,this._height=0,this._area=0},a.isEmpty=function(){return this._width<=0||this._height<=0},a.intersects=function(t){if(this.isEmpty()||t.isEmpty())return!1;var e=this._minX>t._minX?this._minX:t._minX,i=this._maxX<t._maxX?this._maxX:t._maxX;return!(e>i)&&(e=this._minY>t._minY?this._minY:t._minY,i=this._maxY<t._maxY?this._maxY:t._maxY,e<=i)},a.updateRegion=function(t,e){if(0!==t.width&&0!==t.height){var i,n,r,s,o=e,a=o.a,c=o.b,h=o.c,l=o.d,u=o.tx,_=o.ty,d=t.x,f=t.y,p=d+t.width,m=f+t.height;if(1===a&&0===c&&0===h&&1===l)i=d+u-1,n=f+_-1,r=p+u+1,s=m+_+1;else{var g=a*d+h*f+u,y=c*d+l*f+_,v=a*p+h*f+u,x=c*p+l*f+_,C=a*p+h*m+u,T=c*p+l*m+_,b=a*d+h*m+u,A=c*d+l*m+_,S=0;g>v&&(S=g,g=v,v=S),C>b&&(S=C,C=b,b=S),i=(g<C?g:C)-1,r=(v>b?v:b)+1,y>x&&(S=y,y=x,x=S),T>A&&(S=T,T=A,A=S),n=(y<T?y:T)-1,s=(x>A?x:A)+1}this._minX=i,this._minY=n,this._maxX=r,this._maxY=s,this._width=r-i,this._height=s-n,this._area=this._width*this._height}else this.setEmpty()};var h=function(){this.dirtyList=[],this.hasClipRect=!1,this.clipWidth=0,this.clipHeight=0,this.clipArea=0,this.clipRectChanged=!1},l=h.prototype;l.setClipRect=function(t,e){this.hasClipRect=!0,this.clipRectChanged=!0,this.clipWidth=Math.ceil(t),this.clipHeight=Math.ceil(e),this.clipArea=this.clipWidth*this.clipHeight},l.addRegion=function(t){var e=t._minX,i=t._minY,r=t._maxX,s=t._maxY;if(this.hasClipRect&&(e<0&&(e=0),i<0&&(i=0),r>this.clipWidth&&(r=this.clipWidth),s>this.clipHeight&&(s=this.clipHeight)),e>=r||i>=s)return!1;if(this.clipRectChanged)return!0;var o=this.dirtyList,a=n();return o.push(a.setTo(e,i,r,s)),this.mergeDirtyList(o),!0},l.clear=function(){for(var t=this.dirtyList,e=t.length,i=0;i<e;i++)r(t[i]);t.length=0},l.getDirtyRegions=function(){var t=this.dirtyList;if(this.clipRectChanged){this.clipRectChanged=!1,this.clear();var e=n();t.push(e.setTo(0,0,this.clipWidth,this.clipHeight))}else for(;this.mergeDirtyList(t););var i=this.dirtyList.length;if(i>0)for(var r=0;r<i;r++)this.dirtyList[r].intValues();return this.dirtyList},l.mergeDirtyList=function(t){var e=t.length;if(e<2)return!1;for(var i=this.hasClipRect,n=e>3?Number.POSITIVE_INFINITY:0,o=0,a=0,c=0,h=0;h<e-1;h++){var l=t[h];i&&(c+=l.area);for(var u=h+1;u<e;u++){var _=t[u],d=s(l,_)-l.area-_.area;n>d&&(o=h,a=u,n=d)}}if(i&&c/this.clipArea>.95&&(this.clipRectChanged=!0),o!==a){var f=t[a];return t[o].union(f),r(f),t.splice(a,1),!0}return!1},cc.Region=o,cc.DirtyRegion=h}),{}],204:[(function(t,e,i){cc.rendererCanvas={childrenOrderDirty:!0,assignedZ:0,assignedZStep:1e-4,_transformNodePool:[],_renderCmds:[],_isCacheToCanvasOn:!1,_cacheToCanvasCmds:{},_cacheInstanceIds:[],_currentID:0,_clearColor:cc.color(),_clearFillStyle:"rgb(0, 0, 0)",_dirtyRegion:null,_allNeedDraw:!0,_enableDirtyRegion:!1,_debugDirtyRegion:!1,_dirtyRegionCountThreshold:10,init:function(){cc.sys.browserType!==cc.sys.BROWSER_TYPE_IE&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_UC||this.enableDirtyRegion(!1)},getRenderCmd:function(t){return t._createRenderCmd()},enableDirtyRegion:function(t){this._enableDirtyRegion=t},isDirtyRegionEnabled:function(){return this._enableDirtyRegion},setDirtyRegionCountThreshold:function(t){this._dirtyRegionCountThreshold=t},_collectDirtyRegion:function(){var t,e,i=this._renderCmds,n=this._dirtyRegion,r=_ccsg.Node.CanvasRenderCmd.RegionStatus,s=0,o=!0;for(t=0,e=i.length;t<e;t++){var a=i[t],c=a._regionFlag,h=a._oldRegion,l=a._currentRegion;c>r.NotDirty&&(++s>this._dirtyRegionCountThreshold&&(o=!1),o&&(!l.isEmpty()&&n.addRegion(l),a._regionFlag>r.Dirty&&!h.isEmpty()&&n.addRegion(h)),a._regionFlag=r.NotDirty)}return o},_beginDrawDirtyRegion:function(t){var e=t.getContext(),i=this._dirtyRegion.getDirtyRegions();e.save(),t.setTransform({a:1,b:0,c:0,d:1,tx:0,ty:0},1,1),e.beginPath();for(var n=0,r=0,s=0,o=0,a=t._scaleX,c=t._scaleY,h=0,l=i.length;h<l;++h){var u=i[h];n=(u._minX*a|0)-1,r=(-u._maxY*a|0)-1,s=2+(u._width*a|0),o=2+(u._height*c|0),e.rect(n,r,s,o)}e.clip()},_endDrawDirtyRegion:function(t){t.restore()},_debugDrawDirtyRegion:function(t){if(this._debugDirtyRegion){var e=t.getContext(),i=this._dirtyRegion.getDirtyRegions();t.setTransform({a:1,b:0,c:0,d:1,tx:0,ty:0},1,1),e.beginPath();for(var n=0,r=0,s=0,o=0,a=t._scaleX,c=t._scaleY,h=0,l=i.length;h<l;++h){var u=i[h];n=(u._minX*a|0)-1,r=(-u._maxY*a|0)-1,s=2+(u._width*a|0),o=2+(u._height*c|0),e.rect(n,r,s,o)}var _=e.fillStyle;e.fillStyle="green",e.fill(),e.fillStyle=_}},rendering:function(t){var e=this._dirtyRegion=this._dirtyRegion||new cc.DirtyRegion,i=cc._canvas,n=t||cc._renderContext,r=n.getContext(),s=cc.view.getScaleX(),o=cc.view.getScaleY();n.setViewScale(s,o),n.computeRealOffsetY();var a,c,h=this._dirtyRegion.getDirtyRegions(),l=this._renderCmds,u=this._allNeedDraw||!this._enableDirtyRegion;for(u||(u=u||!this._collectDirtyRegion()),u||this._beginDrawDirtyRegion(n),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,i.width,i.height),0===this._clearColor.r&&0===this._clearColor.g&&0===this._clearColor.b||(n.setFillStyle(this._clearFillStyle),n.setGlobalAlpha(this._clearColor.a),r.fillRect(0,0,i.width,i.height)),a=0,c=l.length;a<c;a++){var _=l[a];if(_._needDraw){var d=!1,f=_._currentRegion;if(!f||u)d=!0;else for(var p=0,m=h.length;p<m;++p)if(h[p].intersects(f)){d=!0;break}d&&_.rendering(n,s,o)}}u||(this._debugDrawDirtyRegion(n),this._endDrawDirtyRegion(r)),e.clear(),this._allNeedDraw=!1},_renderingToCacheCanvas:function(t,e,i,n){t||cc.logID(7600),i=void 0===i?1:i,n=void 0===n?1:n,e=e||this._currentID;var r,s,o=this._cacheToCanvasCmds[e];for(t.computeRealOffsetY(),r=0,s=o.length;r<s;r++)o[r].rendering(t,i,n);this._removeCache(e);var a=this._cacheInstanceIds;0===a.length?this._isCacheToCanvasOn=!1:this._currentID=a[a.length-1]},_turnToCacheMode:function(t){this._isCacheToCanvasOn=!0,t=t||0,this._cacheToCanvasCmds[t]=[],-1===this._cacheInstanceIds.indexOf(t)&&this._cacheInstanceIds.push(t),this._currentID=t},_turnToNormalMode:function(){this._isCacheToCanvasOn=!1},_removeCache:function(t){t=t||this._currentID;var e=this._cacheToCanvasCmds[t];e&&(e.length=0,delete this._cacheToCanvasCmds[t]);var i=this._cacheInstanceIds;cc.js.array.remove(i,t)},resetFlag:function(){this.childrenOrderDirty=!1,this._transformNodePool.length=0},transform:function(){var t=this._transformNodePool;t.sort(this._sortNodeByLevelAsc);for(var e=0,i=t.length;e<i;e++)t[e].updateStatus();t.length=0},transformDirty:function(){return this._transformNodePool.length>0},_sortNodeByLevelAsc:function(t,e){return t._curLevel-e._curLevel},pushDirtyNode:function(t){this._transformNodePool.push(t)},clear:function(){},clearRenderCommands:function(){this._renderCmds.length=0,this._cacheInstanceIds.length=0,this._isCacheToCanvasOn=!1,this._allNeedDraw=!0},pushRenderCommand:function(t){if(t.rendering)if(this._isCacheToCanvasOn){var e=this._currentID,i=this._cacheToCanvasCmds[e];-1===i.indexOf(t)&&i.push(t)}else-1===this._renderCmds.indexOf(t)&&this._renderCmds.push(t)}},(function(){cc.CanvasContextWrapper=function(t){this._context=t,this._saveCount=0,this._currentAlpha=t.globalAlpha,this._currentCompositeOperation=t.globalCompositeOperation,this._currentFillStyle=t.fillStyle,this._currentStrokeStyle=t.strokeStyle,this._offsetX=0,this._offsetY=0,this._realOffsetY=this.height,this._armatureMode=0};var t=cc.CanvasContextWrapper.prototype;t.resetCache=function(){var t=this._context;this._currentAlpha=t.globalAlpha,this._currentCompositeOperation=t.globalCompositeOperation,this._currentFillStyle=t.fillStyle,this._currentStrokeStyle=t.strokeStyle,this._realOffsetY=this._context.canvas.height+this._offsetY},t.setOffset=function(t,e){this._offsetX=t,this._offsetY=e,this._realOffsetY=this._context.canvas.height+this._offsetY},t.computeRealOffsetY=function(){this._realOffsetY=this._context.canvas.height+this._offsetY},t.setViewScale=function(t,e){this._scaleX=t,this._scaleY=e},t.getContext=function(){return this._context},t.save=function(){this._context.save(),this._saveCount++},t.restore=function(){this._context.restore(),this._currentAlpha=this._context.globalAlpha,this._saveCount--},t.setGlobalAlpha=function(t){this._saveCount>0?this._context.globalAlpha=t:this._currentAlpha!==t&&(this._currentAlpha=t,this._context.globalAlpha=t)},t.setCompositeOperation=function(t){this._saveCount>0?this._context.globalCompositeOperation=t:this._currentCompositeOperation!==t&&(this._currentCompositeOperation=t,this._context.globalCompositeOperation=t)},t.setFillStyle=function(t){this._context.fillStyle=t},t.setStrokeStyle=function(t){this._saveCount>0?this._context.strokeStyle=t:this._currentStrokeStyle!==t&&(this._currentStrokeStyle=t,this._context.strokeStyle=t)},t.setTransform=function(t,e,i){this._armatureMode>0?(this.restore(),this.save(),this._context.transform(t.a,-t.b,-t.c,t.d,t.tx*e,-t.ty*i)):this._context.setTransform(t.a*e,-t.b*i,-t.c*e,t.d*i,this._offsetX+t.tx*e,this._realOffsetY-t.ty*i)},t._switchToArmatureMode=function(t,e,i,n){t?(this._armatureMode++,this._context.setTransform(e.a,e.c,e.b,e.d,this._offsetX+e.tx*i,this._realOffsetY-e.ty*n),this.save()):(this._armatureMode--,this.restore())}})()}),{}],205:[(function(t,e,i){function n(t){var e=cc._renderContext;null===o&&(a=e.createBuffer(),o=e.createBuffer()),(function(t){var e=cc._renderContext;if(o){var i=6*Math.ceil(t/4);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o),p=new Uint16Array(i);for(var n=0,r=0,s=i;r<s;r+=6)p[r]=n+0,p[r+1]=n+1,p[r+2]=n+2,p[r+3]=n+1,p[r+4]=n+2,p[r+5]=n+3,n+=4;e.bufferData(e.ELEMENT_ARRAY_BUFFER,p,e.DYNAMIC_DRAW)}if(a){var h=4*(t*u);_=new ArrayBuffer(h),d=new Float32Array(_),f=new Uint32Array(_),e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,d,e.DYNAMIC_DRAW)}c=t-200})(t)}var r={texture:null,blendSrc:null,blendDst:null,shader:null},s=!1,o=null,a=null,c=0,h=0,l=0,u=6,_=null,d=null,f=null,p=null,m=0,g=!0,y=cc.Enum({QUAD:0,TRIANGLE:1,CUSTOM:2});cc.rendererWebGL={mat4Identity:null,childrenOrderDirty:!0,assignedZ:0,assignedZStep:.01,VertexType:y,_transformNodePool:[],_renderCmds:[],_isCacheToBufferOn:!1,_cacheToBufferCmds:{},_cacheInstanceIds:[],_currentID:0,_clearColor:{r:0,g:0,b:0,a:1},init:function(){var t=cc._renderContext;t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),this._initExtensions(["OES_element_index_uint"]),this.mat4Identity=new cc.math.Matrix4,this.mat4Identity.identity(),n(cc.macro.BATCH_VERTEX_COUNT),cc.sys.os===cc.sys.OS_IOS&&!0},_initExtensions:function(t){this._extensions=this._extensions||{};for(var e=0;e<t.length;++e){var i=t[e];try{var n=gl.getExtension(i);n&&(this._extensions[i]=n)}catch(t){cc.error(t)}}},getVertexSize:function(){return c},getRenderCmd:function(t){return t._createRenderCmd()},_turnToCacheMode:function(t){this._isCacheToBufferOn=!0,t=t||0,this._cacheToBufferCmds[t]?this._cacheToBufferCmds[t].length=0:this._cacheToBufferCmds[t]=[],-1===this._cacheInstanceIds.indexOf(t)&&this._cacheInstanceIds.push(t),this._currentID=t},_turnToNormalMode:function(){this._isCacheToBufferOn=!1},_removeCache:function(t){t=t||this._currentID;var e=this._cacheToBufferCmds[t];e&&(e.length=0,delete this._cacheToBufferCmds[t]);var i=this._cacheInstanceIds;cc.js.array.remove(i,t)},_renderingToBuffer:function(t){t=t||this._currentID;var e=this._cacheToBufferCmds[t],i=cc._renderContext;this.rendering(i,e),this._removeCache(t);var n=this._cacheInstanceIds;0===n.length?this._isCacheToBufferOn=!1:this._currentID=n[n.length-1]},resetFlag:function(){this.childrenOrderDirty&&(this.childrenOrderDirty=!1),this._transformNodePool.length=0},transform:function(){var t=this._transformNodePool;t.sort(this._sortNodeByLevelAsc);var e,i;for(e=0,i=t.length;e<i;e++)t[e].updateStatus();t.length=0},transformDirty:function(){return this._transformNodePool.length>0},_sortNodeByLevelAsc:function(t,e){return t._curLevel-e._curLevel},pushDirtyNode:function(t){this._transformNodePool.push(t)},clearRenderCommands:function(){this._renderCmds.length=0},clear:function(){var t=cc._renderContext;t.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},setDepthTest:function(t){var e=cc._renderContext;t?(e.clearDepth(1),e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL)):e.disable(e.DEPTH_TEST)},pushRenderCommand:function(t){if(t.rendering||t.uploadData)if(this._isCacheToBufferOn){var e=this._currentID,i=this._cacheToBufferCmds[e];-1===i.indexOf(t)&&i.push(t)}else this._renderCmds.push(t)},_increaseBatchingSize:function(t,e,i){var n,r;switch(e=e||y.QUAD){case y.QUAD:for(n=0;n<t;n+=4)r=h+n,p[l++]=r+0,p[l++]=r+1,p[l++]=r+2,p[l++]=r+1,p[l++]=r+2,p[l++]=r+3;break;case y.TRIANGLE:for(g=!1,n=0;n<t;n+=3)r=h+n,p[l++]=r+0,p[l++]=r+1,p[l++]=r+2;break;case y.CUSTOM:g=!1;var s=i.length;for(n=0;n<s;n++)p[l++]=h+i[n];break;default:return}h+=t},_updateBatchedInfo:function(t,e,i){return(t!==r.texture||e.src!==r.blendSrc||e.dst!==r.blendDst||i!==r.shader)&&(this._batchRendering(),r.texture=t,r.blendSrc=e.src,r.blendDst=e.dst,r.shader=i,!0)},_breakBatch:function(){s=!0},_uploadBufferData:function(t){h>=c&&this._batchRendering();var e=t._node,i=t._texture||e._texture||e._spriteFrame&&e._spriteFrame._texture,n=e._blendFunc.src,o=e._blendFunc.dst,a=t._shaderProgram;(s||r.texture!==i||r.blendSrc!==n||r.blendDst!==o||r.shader!==a)&&(this._batchRendering(),r.texture=i,r.blendSrc=n,r.blendDst=o,r.shader=a,s=!1);var _=t.uploadData(d,f,h*u);if(_>0){var m,v;switch(t.vertexType||y.QUAD){case y.QUAD:for(m=0;m<_;m+=4)v=h+m,p[l++]=v+0,p[l++]=v+1,p[l++]=v+2,p[l++]=v+1,p[l++]=v+2,p[l++]=v+3;break;case y.TRIANGLE:for(g=!1,m=0;m<_;m+=3)v=h+m,p[l++]=v+0,p[l++]=v+1,p[l++]=v+2;break;case y.CUSTOM:g=!1,t.uploadIndexData&&(l+=t.uploadIndexData(p,l,h));break;default:return}h+=_}},_batchRendering:function(){if(0!==h&&r.texture){var t=cc._renderContext,e=r.texture,i=r.shader,n=h>.5*c;if(i&&(i.use(),i._updateProjectionUniform()),cc.gl.blendFunc(r.blendSrc,r.blendDst),cc.gl.bindTexture2DN(0,e),t.bindBuffer(t.ARRAY_BUFFER,a),n)t.bufferData(t.ARRAY_BUFFER,d,t.DYNAMIC_DRAW);else{var s=d.subarray(0,h*u);t.bufferData(t.ARRAY_BUFFER,s,t.DYNAMIC_DRAW)}t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_COLOR),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_TEX_COORDS),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION,3,t.FLOAT,!1,24,0),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR,4,t.UNSIGNED_BYTE,!0,24,12),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS,2,t.FLOAT,!1,24,16),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o),(!m||!g||l>m)&&(n?t.bufferData(t.ELEMENT_ARRAY_BUFFER,p,t.DYNAMIC_DRAW):t.bufferData(t.ELEMENT_ARRAY_BUFFER,p.subarray(0,l),t.DYNAMIC_DRAW)),t.drawElements(t.TRIANGLES,l,t.UNSIGNED_SHORT,0),cc.g_NumberOfDraws++,g?m=l:(m=0,g=!0),h=0,l=0}},rendering:function(t,e){var i,n,s,o=e||this._renderCmds,a=t||cc._renderContext;for(a.bindBuffer(a.ARRAY_BUFFER,null),cc.gl.bindTexture2DN(0,null),i=0,n=o.length;i<n;++i)(s=o[i])._needDraw&&(s.uploadData?this._uploadBufferData(s):(h>0&&this._batchRendering(),s.rendering(a)));this._batchRendering(),r.texture=null}}}),{}],206:[(function(t,e,i){t("./RendererCanvas"),t("./RendererWebGL"),t("./DirtyRegion")}),{"./DirtyRegion":203,"./RendererCanvas":204,"./RendererWebGL":205}],207:[(function(t,e,i){_ccsg.Scene=_ccsg.Node.extend({_className:"Scene",ctor:function(){_ccsg.Node.prototype.ctor.call(this),this._ignoreAnchorPointForPosition=!0,this.setAnchorPoint(.5,.5),this.setContentSize(cc.director.getWinSize())}})}),{}],208:[(function(t,e,i){var n=t("../event/event-target"),r=t("../utils/misc");_ccsg.Sprite=_ccsg.Node.extend({dirty:!1,_recursiveDirty:null,_shouldBeHidden:!1,_transformToBatch:null,_blendFunc:null,_texture:null,_rect:null,_rectRotated:!1,_offsetPosition:null,_unflippedOffsetPositionFromCenter:null,_opacityModifyRGB:!1,_flippedX:!1,_flippedY:!1,_textureLoaded:!1,_className:"Sprite",ctor:function(t,e,i){_ccsg.Node.prototype.ctor.call(this),n.call(this),this._shouldBeHidden=!1,this._offsetPosition=cc.p(0,0),this._unflippedOffsetPositionFromCenter=cc.p(0,0),this._blendFunc={src:cc.macro.BLEND_SRC,dst:cc.macro.BLEND_DST},this._rect=cc.rect(0,0,0,0),this._softInit(t,e,i)},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(t,e){this.once("load",t,e)},isDirty:function(){return this.dirty},setDirty:function(t){this.dirty=t},isTextureRectRotated:function(){return this._rectRotated},getTextureRect:function(){return cc.rect(this._rect)},getOffsetPosition:function(){return cc.p(this._offsetPosition)},_getOffsetX:function(){return this._offsetPosition.x},_getOffsetY:function(){return this._offsetPosition.y},getBlendFunc:function(){return this._blendFunc},initWithSpriteFrame:function(t){cc.assertID(t,2606),t.textureLoaded()||(this._textureLoaded=!1,t.once("load",this._renderCmd._spriteFrameLoadedCallback,this._renderCmd));var e=cc._renderType!==cc.game.RENDER_TYPE_CANVAS&&t._rotated,i=this.initWithTexture(t.getTexture(),t.getRect(),e);return this.setSpriteFrame(t),i},initWithSpriteFrameName:function(){cc.warnID(2608)},setVertexRect:function(t){var e=this._rect;e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},setFlippedX:function(t){this._flippedX!==t&&(this._flippedX=t,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},setFlippedY:function(t){this._flippedY!==t&&(this._flippedY=t,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},isFlippedX:function(){return this._flippedX},isFlippedY:function(){return this._flippedY},setOpacityModifyRGB:function(t){this._opacityModifyRGB!==t&&(this._opacityModifyRGB=t,this._renderCmd._setColorDirty())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setDisplayFrameWithAnimationName:function(t,e){cc.assertID(t,2610);var i=cc.spriteFrameAnimationCache.getAnimation(t);if(i){var n=i.getFrames()[e];n?this.setSpriteFrame(n.getSpriteFrame()):cc.logID(2603)}else cc.logID(2602)},getTexture:function(){return this._texture},_softInit:function(t,e,i){if(void 0===t)_ccsg.Sprite.prototype.init.call(this);else if(cc.js.isString(t))"#"===t[0]?cc.logID(2728,t):_ccsg.Sprite.prototype.init.call(this,t,e);else if("object"==typeof t)if(t instanceof cc.Texture2D)this.initWithTexture(t,e,i);else if(t instanceof cc.SpriteFrame)this.initWithSpriteFrame(t);else if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var n=new cc.Texture2D;n.initWithElement(t),n.handleLoadedTexture(),this.initWithTexture(n)}},getQuad:function(){return null},setBlendFunc:function(t,e){var i=this._blendFunc;void 0===e?(i.src=t.src,i.dst=t.dst):(i.src=t,i.dst=e),this._renderCmd.updateBlendFunc(i)},init:function(){return arguments.length>0?this.initWithFile(arguments[0],arguments[1]):(this.dirty=this._recursiveDirty=!1,this._blendFunc.src=cc.macro.BLEND_SRC,this._blendFunc.dst=cc.macro.BLEND_DST,this.texture=null,this._flippedX=this._flippedY=!1,this.anchorX=.5,this.anchorY=.5,this._offsetPosition.x=0,this._offsetPosition.y=0,this.setTextureRect(cc.rect(0,0,0,0),!1,cc.size(0,0)),!0)},initWithFile:function(t,e){cc.assertID(t,2609);var i=cc.textureCache.getTextureForKey(t);if(i){if(!e){var n=i.getContentSize();e=cc.rect(0,0,n.width,n.height)}return this.initWithTexture(i,e)}return i=cc.textureCache.addImage(t),this.initWithTexture(i,e||cc.rect(0,0,i.width,i.height))},initWithTexture:function(t,e,i,n){cc.assertID(0!==arguments.length,2710),i=i||!1,t=this._renderCmd._handleTextureForRotatedTexture(t,e,i,n),this._recursiveDirty=!1,this.dirty=!1,this._opacityModifyRGB=!0,this._blendFunc.src=cc.macro.BLEND_SRC,this._blendFunc.dst=cc.macro.BLEND_DST,this._flippedX=this._flippedY=!1,this.setAnchorPoint(.5,.5),this._offsetPosition.x=0,this._offsetPosition.y=0;var r=t.loaded;return this._textureLoaded=r,r?(e||(e=cc.rect(0,0,t.width,t.height)),this._renderCmd._checkTextureBoundary(t,e,i),this.setTexture(t),this.setTextureRect(e,i),this.emit("load"),!0):(this._rectRotated=i,e&&(this._rect.x=e.x,this._rect.y=e.y,this._rect.width=e.width,this._rect.height=e.height),this.texture&&this.texture.off("load",this._renderCmd._textureLoadedCallback,this._renderCmd),t.once("load",this._renderCmd._textureLoadedCallback,this._renderCmd),this.setTexture(t),!0)},setTextureRect:function(t,e,i,n){this._rectRotated=e||!1,this.setContentSize(i||t),this.setVertexRect(t),this._renderCmd._setTextureCoords(t,n);var r=this._unflippedOffsetPositionFromCenter.x,s=this._unflippedOffsetPositionFromCenter.y;this._flippedX&&(r=-r),this._flippedY&&(s=-s);var o=this._rect;this._offsetPosition.x=r+(this._contentSize.width-o.width)/2,this._offsetPosition.y=s+(this._contentSize.height-o.height)/2},setSpriteFrame:function(t){var e=this;cc.assertID(t,2712),this.setNodeDirty(!0);var i=t.getOffset();e._unflippedOffsetPositionFromCenter.x=i.x,e._unflippedOffsetPositionFromCenter.y=i.y;var n=t.getTexture();t.textureLoaded()?(e._textureLoaded=!0,n!==e._texture&&(e._setTexture(n),e.setColor(e._realColor)),e.setTextureRect(t.getRect(),t.isRotated(),t.getOriginalSize())):(e._textureLoaded=!1,t.once("load",(function(t){var i=t.currentTarget;e._textureLoaded=!0;var n=i.getTexture();n!==e._texture&&e._setTexture(n),e.setTextureRect(i.getRect(),i.isRotated(),i.getOriginalSize()),e.emit("load"),e.setColor(e._realColor)}),e)),this._renderCmd._updateForSetSpriteFrame(n)},setDisplayFrame:function(t){cc.logID(2604),this.setSpriteFrame(t)},isFrameDisplayed:function(t){return this._renderCmd.isFrameDisplayed(t)},displayFrame:function(){return this.getSpriteFrame()},getSpriteFrame:function(){return new cc.SpriteFrame(this._texture,this._rect,this._rectRotated,this._unflippedOffsetPositionFromCenter,this._contentSize)},setTexture:function(t){if(!t)return this._renderCmd._setTexture(null);var e=cc.js.isString(t);e&&(t=cc.textureCache.addImage(t)),t.loaded?(this._setTexture(t,e),this.setColor(this._realColor),this._textureLoaded=!0,this.emit("load")):(this._renderCmd._setTexture(t),t.once("load",(function(i){this._setTexture(t,e),this.setColor(this._realColor),this._textureLoaded=!0,this.emit("load")}),this))},_setTexture:function(t,e){this._renderCmd._setTexture(t),e&&this._changeRectWithTexture(t)},_changeRectWithTexture:function(t){var e=cc.rect(0,0,t.width,t.height);this.setTextureRect(e)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.Sprite.CanvasRenderCmd(this):new _ccsg.Sprite.WebGLRenderCmd(this)}}),cc.js.addon(_ccsg.Sprite.prototype,n.prototype);r.propertyDefine(_ccsg.Sprite,["opacity","color","texture","quad"],{opacityModifyRGB:["isOpacityModifyRGB","setOpacityModifyRGB"],flippedX:["isFlippedX","setFlippedX"],flippedY:["isFlippedY","setFlippedY"],offsetX:["_getOffsetX"],offsetY:["_getOffsetY"],textureRectRotated:["isTextureRectRotated"]})}),{"../event/event-target":112,"../utils/misc":226}],209:[(function(t,e,i){_ccsg.Sprite.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._textureCoord={renderX:0,renderY:0,x:0,y:0,width:0,height:0,validRect:!1},this._blendFuncStr="source-over",this._colorized=!1,this._textureToRender=null};var n=_ccsg.Sprite.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=_ccsg.Sprite.CanvasRenderCmd,n.setDirtyRecursively=function(t){},n._setTexture=function(t){var e=this._node;if(e._texture!==t){e._textureLoaded=!!t&&t.loaded,e._texture=t;var i=cc.rect(0,0,t.width,t.height);e.setTextureRect(i),this._updateColor()}},n._setColorDirty=function(){this.setDirtyFlag(_ccsg.Node._dirtyFlags.colorDirty|_ccsg.Node._dirtyFlags.opacityDirty)},n.isFrameDisplayed=function(t){var e=this._node;return t.getTexture()===e._texture&&cc.rectEqualToRect(t.getRect(),e._rect)},n.updateBlendFunc=function(t){this._blendFuncStr=_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(t)},n._handleTextureForRotatedTexture=function(t,e,i,n){if(i&&t.isLoaded()){var r=t.getHtmlElementObj();r=_ccsg.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(r,e,n);var s=new cc.Texture2D;s.initWithElement(r),s.handleLoadedTexture(),t=s,e.x=e.y=0,this._node._rect=cc.rect(0,0,e.width,e.height)}return t},n._checkTextureBoundary=function(t,e,i){if(t&&t.url){var n=e.x+e.width,r=e.y+e.height;n>t.width&&cc.errorID(3300,t.url),r>t.height&&cc.errorID(3400,t.url)}},n.rendering=function(t,e,i){var n=this._node,r=this._textureCoord,s=this._displayedOpacity/255,o=this._textureToRender||n._texture;if((!o||0!==r.width&&0!==r.height&&o.loaded)&&0!==s){var a,c=t||cc._renderContext,h=c.getContext(),l=n._offsetPosition.x,u=n._rect.height,_=n._rect.width,d=-n._offsetPosition.y-u;c.setTransform(this._worldTransform,e,i),c.setCompositeOperation(this._blendFuncStr),c.setGlobalAlpha(s),(n._flippedX||n._flippedY)&&c.save(),n._flippedX&&(l=-l-_,h.scale(-1,1)),n._flippedY&&(d=n._offsetPosition.y,h.scale(1,-1));var f,p,m,g,y,v,x,C;if(this._colorized?(f=0,p=0):(f=r.renderX,p=r.renderY),m=r.width,g=r.height,y=l,v=d,x=_,C=u,o&&o._image)a=o._image,""!==o._pattern?(c.setFillStyle(h.createPattern(a,o._pattern)),h.fillRect(y,v,x,C)):h.drawImage(a,f,p,m,g,y,v,x,C);else{var T=n._contentSize;if(r.validRect){var b=this._displayedColor;c.setFillStyle("rgba("+b.r+","+b.g+","+b.b+",1)"),h.fillRect(y,v,T.width,T.height)}}(n._flippedX||n._flippedY)&&c.restore(),cc.g_NumberOfDraws++}},n._updateColor=function(){var t=this._node._texture,e=this._textureCoord,i=this._displayedColor;t&&(255!==i.r||255!==i.g||255!==i.b?(this._textureToRender=t._generateColorTexture(i.r,i.g,i.b,e),this._colorized=!0):t&&(this._textureToRender=t,this._colorized=!1))},n._updateForSetSpriteFrame=function(t,e){if(this._colorized=!1,this._textureCoord.renderX=this._textureCoord.x,this._textureCoord.renderY=this._textureCoord.y,e=e||t.loaded){var i=this._node.getColor();255===i.r&&255===i.g&&255===i.b||this._updateColor()}},n._spriteFrameLoadedCallback=function(t){var e=this._node,i=t.currentTarget;e.setTextureRect(i.getRect(),i.isRotated(),i.getOriginalSize()),this._updateColor(),e.emit("load")},n._textureLoadedCallback=function(t){var e=this._node,i=t.currentTarget;if(!e._textureLoaded){e._textureLoaded=!0;var n=e._rect;n?cc._rectEqualToZero(n)&&(n.width=i.width,n.height=i.height):n=cc.rect(0,0,i.width,i.height),e.texture=i,e.setTextureRect(n,e._rectRotated);var r=this._displayedColor;255===r.r&&255===r.g&&255===r.b||this._updateColor(),e.emit("load")}},n._setTextureCoords=function(t){var e=this._textureCoord;e.renderX=e.x=0|t.x,e.renderY=e.y=0|t.y,e.width=0|t.width,e.height=0|t.height,e.validRect=!(0===e.width||0===e.height||e.x<0||e.y<0)},_ccsg.Sprite.CanvasRenderCmd._cutRotateImageToCanvas=function(t,e,i){if(!t)return null;if(!e)return t;i=null==i||i;var n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d");return r.translate(n.width/2,n.height/2),i?r.rotate(-1.5707963267948966):r.rotate(1.5707963267948966),r.drawImage(t,e.x,e.y,e.height,e.width,-e.height/2,-e.width/2,e.height,e.width),n}}),{}],210:[(function(t,e,i){var n=cc.macro;_ccsg.Sprite.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._vertices=[{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0}],this._dirty=!1,this._recursiveDirty=!1,this._shaderProgram=cc.shaderCache.programForKey(n.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var r=_ccsg.Sprite.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);r.constructor=_ccsg.Sprite.WebGLRenderCmd,r.updateBlendFunc=function(t){},r.setDirtyFlag=function(t){_ccsg.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this,t),this._dirty=!0},r.setDirtyRecursively=function(t){this._recursiveDirty=t,this._dirty=t;for(var e,i=this._node._children,n=i?i.length:0,r=0;r<n;r++)(e=i[r])instanceof _ccsg.Sprite&&e._renderCmd.setDirtyRecursively(t)},r._handleTextureForRotatedTexture=function(t){return t},r.isFrameDisplayed=function(t){var e=this._node;return cc.rectEqualToRect(t.getRect(),e._rect)&&t.getTexture().url===e._texture.url&&cc.pointEqualToPoint(t.getOffset(),e._unflippedOffsetPositionFromCenter)},r._updateForSetSpriteFrame=function(){},r._spriteFrameLoadedCallback=function(t){var e=t.currentTarget;this._node.setTextureRect(e.getRect(),e.isRotated(),e.getOriginalSize()),this._node.emit("load")},r._textureLoadedCallback=function(t){var e=this._node,i=t.currentTarget;if(!e._textureLoaded){e._textureLoaded=!0;var n=e._rect;n?cc._rectEqualToZero(n)&&(n.width=i.width,n.height=i.height):n=cc.rect(0,0,i.width,i.height),e.texture=i,e.setTextureRect(n,e._rectRotated),e.emit("load"),cc.renderer.childrenOrderDirty=!0}},r._setTextureCoords=function(t){var e=this._node,i=e._texture,r=this._vertices;if(i){var s,o,a,c,h,l=i.pixelWidth,u=i.pixelHeight;e._rectRotated?(n.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(o=(s=(2*t.x+1)/(2*l))+(2*t.height-2)/(2*l),c=(a=(2*t.y+1)/(2*u))+(2*t.width-2)/(2*u)):(s=t.x/l,o=(t.x+t.height)/l,a=t.y/u,c=(t.y+t.width)/u),e._flippedX&&(h=a,a=c,c=h),e._flippedY&&(h=s,s=o,o=h),r[0].u=o,r[0].v=a,r[1].u=s,r[1].v=a,r[2].u=o,r[2].v=c,r[3].u=s,r[3].v=c):(n.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(o=(s=(2*t.x+1)/(2*l))+(2*t.width-2)/(2*l),c=(a=(2*t.y+1)/(2*u))+(2*t.height-2)/(2*u)):(s=t.x/l,o=(t.x+t.width)/l,a=t.y/u,c=(t.y+t.height)/u),e._flippedX&&(h=s,s=o,o=h),e._flippedY&&(h=a,a=c,c=h),r[0].u=s,r[0].v=a,r[1].u=s,r[1].v=c,r[2].u=o,r[2].v=a,r[3].u=o,r[3].v=c)}},r._setColorDirty=function(){},r._updateBlendFunc=function(){var t=this._node;t._texture&&t._texture.hasPremultipliedAlpha()?(t._blendFunc.src=n.BLEND_SRC,t._blendFunc.dst=n.BLEND_DST,t.opacityModifyRGB=!0):(t._blendFunc.src=n.SRC_ALPHA,t._blendFunc.dst=n.ONE_MINUS_SRC_ALPHA,t.opacityModifyRGB=!1)},r._setTexture=function(t){var e=this._node;e._texture!==t&&(e._textureLoaded=!!t&&t.loaded,e._texture=t,this._updateBlendFunc(),e._textureLoaded&&(cc.renderer.childrenOrderDirty=!0))},r._checkTextureBoundary=function(t,e,i){if(t&&t.url){var n,r;i?(n=e.x+e.height,r=e.y+e.width):(n=e.x+e.width,r=e.y+e.height),n>t.width&&cc.errorID(3300,t.url),r>t.height&&cc.errorID(3400,t.url)}},r.transform=function(t,e){this.originTransform(t,e);var i=this._node,n=i._offsetPosition.x,r=n+i._rect.width,s=i._offsetPosition.y,o=s+i._rect.height,a=this._worldTransform,c=this._vertices;c[0].x=n*a.a+o*a.c+a.tx,c[0].y=n*a.b+o*a.d+a.ty,c[1].x=n*a.a+s*a.c+a.tx,c[1].y=n*a.b+s*a.d+a.ty,c[2].x=r*a.a+o*a.c+a.tx,c[2].y=r*a.b+o*a.d+a.ty,c[3].x=r*a.a+s*a.c+a.tx,c[3].y=r*a.b+s*a.d+a.ty},r.needDraw=function(){var t=this._node._texture;return this._needDraw&&t},r.uploadData=function(t,e,i){var n=this._node,r=n._texture;if(!(r&&r.loaded&&n._rect.width&&n._rect.height&&this._displayedOpacity))return 0;var s,o=this._displayedOpacity,a=this._displayedColor._val;if(n._opacityModifyRGB){var c=o/255,h=this._displayedColor.r*c,l=this._displayedColor.g*c;s=(o<<24>>>0)+(this._displayedColor.b*c<<16)+(l<<8)+h}else s=(o<<24>>>0)+((65280&a)<<8)+((16711680&a)>>8)+(a>>>24);var u,_,d=n._vertexZ,f=this._vertices,p=f.length,m=i;for(u=0;u<p;++u)_=f[u],t[m]=_.x,t[m+1]=_.y,t[m+2]=d,e[m+3]=s,t[m+4]=_.u,t[m+5]=_.v,m+=6;return p}}),{}],211:[(function(t,e,i){function n(t,e){return t-e}var r,s=t("../event/event-target"),o={_pool:{},_lengths:[],put:function(t){var e=t.length;this._pool[e]?this._pool[e].push(t):(this._pool[e]=[t],this._lengths.push(e),this._lengths.sort(n))},get:function(t){for(var e,i=0;i<this._lengths.length;i++)if(this._lengths[i]>=t){e=this._lengths[i];break}return e?this._pool[e].pop():void 0}},a=cc.macro,c={_rebuildQuads_base:function(t){var e,i,n,s,a=t._spriteFrame,c=t._contentSize,h=t._isTrimmedContentSize,l=t._vertices,u=t._corner;if(h)e=0,i=0,n=c.width,s=c.height;else{var _=a._originalSize,d=a._rect,f=a._offset,p=c.width,m=c.height,g=_.width,y=_.height,v=d.width,x=d.height,C=p/g,T=m/y,b=f.x+(g-v)/2,A=f.x-(g-v)/2;e=b*C,i=(f.y+(y-x)/2)*T,n=p+A*C,s=m+(f.y-(y-x)/2)*T}if(l.length<8&&(o.put(l),l=o.get(8)||new Float32Array(8),t._vertices=l),r){var S=t._renderCmd._worldTransform,w=S.a,E=S.b,I=S.c,R=S.d,P=S.tx,O=S.ty,B=e*w,D=e*E,M=n*w,L=n*E,N=s*I+P,F=s*R+O,k=i*I+P,z=i*R+O;l[0]=B+k,l[1]=D+z,l[2]=M+k,l[3]=L+z,l[4]=B+N,l[5]=D+F,l[6]=M+N,l[7]=L+F}else l[0]=e,l[1]=i,l[2]=n,l[3]=i,l[4]=e,l[5]=s,l[6]=n,l[7]=s;u[0]=0,u[1]=2,u[2]=4,u[3]=6,t._uvsDirty&&this._calculateUVs(t,a),t._vertCount=4},_calculateUVs:function(t,e){var i=t._uvs,n=e._texture.width,r=e._texture.height,s=e._rect;i.length<8&&(o.put(i),i=o.get(8)||new Float32Array(8),t._uvs=i);var c,h,l,u,_=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;e._rotated?(c=(s.x+_)/n,h=(s.y+s.width-_)/r,l=(s.x+s.height-_)/n,u=(s.y+_)/r,i[0]=c,i[1]=u,i[2]=c,i[3]=h,i[4]=l,i[5]=u,i[6]=l,i[7]=h):(c=(s.x+_)/n,h=(s.y+s.height-_)/r,l=(s.x+s.width-_)/n,u=(s.y+_)/r,i[0]=c,i[1]=h,i[2]=l,i[3]=h,i[4]=c,i[5]=u,i[6]=l,i[7]=u)}},h={x:new Array(4),y:new Array(4),_rebuildQuads_base:function(t){var e,i,n,s,a=t._spriteFrame,c=t._contentSize,h=t._insetLeft,l=t._insetRight,u=t._insetTop,_=t._insetBottom,d=t._vertices,f=t._renderCmd._worldTransform,p=a._rect,m=t._corner;e=h,i=l,p.width,n=u,s=_,p.height;var g=c,y=g.width-e-i,v=g.height-n-s,x=g.width/(e+i),C=g.height/(n+s);x=isNaN(x)||x>1?1:x,C=isNaN(C)||C>1?1:C,y=y<0?0:y,v=v<0?0:v;var T=this.x,b=this.y;T[0]=0,T[1]=e*x,T[2]=T[1]+y,T[3]=g.width,b[0]=0,b[1]=s*C,b[2]=b[1]+v,b[3]=g.height,d.length<32&&(o.put(d),d=o.get(32)||new Float32Array(32),t._vertices=d);var A,S,w=0;if(r)for(A=0;A<4;A++)for(S=0;S<4;S++)d[w]=T[S]*f.a+b[A]*f.c+f.tx,d[w+1]=T[S]*f.b+b[A]*f.d+f.ty,w+=2;else for(A=0;A<4;A++)for(S=0;S<4;S++)d[w]=T[S],d[w+1]=b[A],w+=2;m[0]=0,m[1]=6,m[2]=24,m[3]=30,t._uvsDirty&&this._calculateUVs(t,a,h,l,u,_)},_calculateUVs:function(t,e,i,n,r,s){var c,h,l,u,_,d,f=t._uvs,p=e._rect,m=e._texture.width,g=e._texture.height,y=e._rect;c=i,l=n,h=p.width-c-l,u=r,d=s,_=p.height-u-d,f.length<32&&(o.put(f),f=o.get(32)||new Float32Array(32),t._uvs=f);var v,x,C=this.x,T=this.y,b=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0,A=0;if(e._rotated)for(C[0]=(y.x+b)/m,C[1]=(d+y.x)/m,C[2]=(d+_+y.x)/m,C[3]=(y.x+y.height-b)/m,T[3]=(y.y+b)/g,T[2]=(c+y.y)/g,T[1]=(c+h+y.y)/g,T[0]=(y.y+y.width-b)/g,v=0;v<4;v++)for(x=0;x<4;x++)f[A]=C[v],f[A+1]=T[3-x],A+=2;else for(C[0]=(y.x+b)/m,C[1]=(c+y.x)/m,C[2]=(c+h+y.x)/m,C[3]=(y.x+y.width-b)/m,T[3]=(y.y+b)/g,T[2]=(u+y.y)/g,T[1]=(u+_+y.y)/g,T[0]=(y.y+y.height-b)/g,v=0;v<4;v++)for(x=0;x<4;x++)f[A]=C[x],f[A+1]=T[v],A+=2}},l={_rebuildQuads_base:function(t,e,i){e=t._spriteFrame,i=t._contentSize;var n,s,c,h,l=t._vertices,u=t._corner,_=t._renderCmd._worldTransform,d=t._uvs,f=e._texture.width,p=e._texture.height,m=e._rect,g=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;e._rotated?(n=(m.x+g)/f,c=(m.x+m.height-g)/f,s=(m.y+m.width-g)/p,h=(m.y+g)/p):(n=(m.x+g)/f,c=(m.x+m.width-g)/f,s=(m.y+m.height-g)/p,h=(m.y+g)/p);var y=m.width,v=m.height,x=i.width/y,C=i.height/v,T=Math.ceil(C),b=Math.ceil(x);T*b>16384&&cc.errorID(2625);var A=T*b*4*2;l.length<A&&(o.put(l),l=o.get(A)||new Float32Array(A),t._vertices=l),d.length<A&&(o.put(d),d=o.get(A)||new Float32Array(A),t._uvs=d);var S,w,E,I,R=0;t._vertCount=0;for(var P=0;P<T;++P)for(var O=0;O<b;++O){if(S=y*O,w=v*P,E=y*Math.min(O+1,x),I=v*Math.min(P+1,C),r){var B=S*_.a,D=S*_.b,M=E*_.a,L=E*_.b,N=I*_.c+_.tx,F=I*_.d+_.ty,k=w*_.c+_.tx,z=w*_.d+_.ty;l[R]=B+k,l[R+1]=D+z,l[R+2]=M+k,l[R+3]=L+z,l[R+4]=B+N,l[R+5]=D+F,l[R+6]=M+N,l[R+7]=L+F}else l[R]=S,l[R+1]=w,l[R+2]=E,l[R+3]=w,l[R+4]=S,l[R+5]=I,l[R+6]=E,l[R+7]=I;if(e._rotated?(d[R]=n,d[R+1]=h,d[R+2]=n,d[R+3]=I=h+(s-h)*Math.min(1,x-O),d[R+4]=E=n+(c-n)*Math.min(1,C-P),d[R+5]=h,d[R+6]=E,d[R+7]=I):(d[R]=n,d[R+1]=s,d[R+2]=E=n+(c-n)*Math.min(1,x-O),d[R+3]=s,d[R+4]=n,d[R+5]=I=s+(h-s)*Math.min(1,C-P),d[R+6]=E,d[R+7]=I),R+=8,t._vertCount+=4,R>A)return}u[0]=0,u[1]=8*(b-1)+2,u[2]=(T-1)*b*8+4,u[3]=A-2}},u={_rebuildQuads_base:function(t){var e=t._spriteFrame,i=t._contentSize,n=t._fillStart,s=t._fillRange;s<0&&(n+=s,s=-s),s=n+s,n=(n=n>1?1:n)<0?0:n,s=(s=s>1?1:s)<0?0:s,s-=n;var c,h,l,u,_,d=t._fillType,f=t._vertices,p=t._corner,g=t._renderCmd._worldTransform,y=t._uvs,v=0,x=0,C=i.width,T=i.height,b=e._texture.width,A=e._texture.height,S=e._rect,w=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;e._rotated?(h=(S.x+w)/b,l=(S.y+S.width-w)/A,u=(S.x+S.height-w)/b,_=(S.y+w)/A):(h=(S.x+w)/b,l=(S.y+S.height-w)/A,u=(S.x+S.width-w)/b,_=(S.y+w)/A),f.length<8&&(o.put(f),f=o.get(8)||new Float32Array(8),t._vertices=f),y.length<8&&(o.put(y),y=o.get(8)||new Float32Array(8),t._uvs=y);var E=new Array(8);e._rotated?(E[0]=E[2]=h,E[4]=E[6]=u,E[3]=E[7]=l,E[1]=E[5]=_):(E[0]=E[4]=h,E[2]=E[6]=u,E[1]=E[3]=l,E[5]=E[7]=_),c=(c=(n=(n=n>1?1:n)<0?0:n)+(s=s<0?0:s))>1?1:c;var I;switch(d){case m.HORIZONTAL:I=v+(C-v)*c,v=v+(C-v)*n,C=I,y[0]=E[0]+(E[2]-E[0])*n,y[1]=E[1],y[2]=E[0]+(E[2]-E[0])*c,y[3]=E[3],y[4]=E[4]+(E[6]-E[4])*n,y[5]=E[5],y[6]=E[4]+(E[6]-E[4])*c,y[7]=E[7];break;case m.VERTICAL:I=x+(T-x)*c,x=x+(T-x)*n,T=I,y[0]=E[0],y[1]=E[1]+(E[5]-E[1])*n,y[2]=E[2],y[3]=E[3]+(E[7]-E[3])*n,y[4]=E[4],y[5]=E[1]+(E[5]-E[1])*c,y[6]=E[6],y[7]=E[3]+(E[7]-E[3])*c;break;default:cc.errorID(2626)}if(r){var R=v*g.a,P=v*g.b,O=C*g.a,B=C*g.b,D=T*g.c+g.tx,M=T*g.d+g.ty,L=x*g.c+g.tx,N=x*g.d+g.ty;f[0]=R+L,f[1]=P+N,f[2]=O+L,f[3]=B+N,f[4]=R+D,f[5]=P+M,f[6]=O+D,f[7]=B+M}else f[0]=v,f[1]=x,f[2]=C,f[3]=x,f[4]=v,f[5]=T,f[6]=C,f[7]=T;t._vertCount=4,p[0]=0,p[1]=2,p[2]=4,p[3]=6}},_={_vertPos:[cc.v2(0,0),cc.v2(0,0),cc.v2(0,0),cc.v2(0,0)],_vertices:[cc.v2(0,0),cc.v2(0,0)],_uvs:[cc.v2(0,0),cc.v2(0,0)],_intersectPoint_1:[cc.v2(0,0),cc.v2(0,0),cc.v2(0,0),cc.v2(0,0)],_intersectPoint_2:[cc.v2(0,0),cc.v2(0,0),cc.v2(0,0),cc.v2(0,0)],outVerts:null,outUvs:null,rawVerts:null,rawUvs:null,_rebuildQuads_base:function(t){var e=t._spriteFrame,i=t._contentSize,n=t._fillStart,r=t._fillRange;r<0&&(n+=r,r=-r),t._isTriangle=!0,t._rawVerts||(t._rawVerts=o.get(8)||new Float32Array(8),t._rawUvs=o.get(8)||new Float32Array(8));for(var s=t._fillCenter,a=t._vertices,c=t._corner,h=t._uvs,l=t._rawVerts,u=t._rawUvs,_=t._renderCmd._worldTransform;n>=1;)n-=1;for(;n<0;)n+=1;var d=s.x*i.width,f=s.y*i.height,p=cc.v2(d,f),m=(n*=2*Math.PI)+(r*=2*Math.PI);this.outVerts=a,this.outUvs=h,this.rawVerts=l,this.rawUvs=u,this._calculateVertices(_,e,i),this._calculateUVs(e);var g=this._vertPos,y=this._vertices;g[0].x=g[3].x=y[0].x,g[1].x=g[2].x=y[1].x,g[0].y=g[1].y=y[0].y,g[2].y=g[3].y=y[1].y,p.x>y[1].x&&(p.x=y[1].x),p.x<y[0].x&&(p.x=y[0].x),p.y<y[0].y&&(p.y=y[0].y),p.y>y[1].y&&(p.y=y[1].y),l[0]=l[4]=this._vertices[0].x,l[2]=l[6]=this._vertices[1].x,l[1]=l[3]=this._vertices[0].y,l[5]=l[7]=this._vertices[1].y,e._rotated?(u[0]=u[2]=this._uvs[0].x,u[4]=u[6]=this._uvs[1].x,u[3]=u[7]=this._uvs[0].y,u[1]=u[5]=this._uvs[1].y):(u[0]=u[4]=this._uvs[0].x,u[2]=u[6]=this._uvs[1].x,u[1]=u[3]=this._uvs[0].y,u[5]=u[7]=this._uvs[1].y);var v=[null,null,null,null];p.x!==this._vertices[0].x&&(v[0]=[3,0]),p.x!==this._vertices[1].x&&(v[2]=[1,2]),p.y!==this._vertices[0].y&&(v[1]=[0,1]),p.y!==this._vertices[1].y&&(v[3]=[2,3]),this._getInsectedPoints(this._vertices[0].x,this._vertices[1].x,this._vertices[0].y,this._vertices[1].y,p,n,this._intersectPoint_1),this._getInsectedPoints(this._vertices[0].x,this._vertices[1].x,this._vertices[0].y,this._vertices[1].y,p,n+r,this._intersectPoint_2);a.length<30&&(o.put(a),a=o.get(30)||new Float32Array(30),this.outVerts=t._vertices=a),h.length<30&&(o.put(h),h=o.get(30)||new Float32Array(30),this.outUvs=t._uvs=h);for(var x=0,C=0,T=0;T<4;++T){var b=v[T];if(null!==b)if(r>=2*Math.PI)this._generateTriangle(_,x,p,this._vertPos[b[0]],this._vertPos[b[1]]),x+=6,C+=3;else{var A=this._getVertAngle(p,this._vertPos[b[0]]),S=this._getVertAngle(p,this._vertPos[b[1]]);S<A&&(S+=2*Math.PI),A-=2*Math.PI,S-=2*Math.PI;for(var w=0;w<3;++w)A>=m||(A>=n?(S>=m?this._generateTriangle(_,x,p,this._vertPos[b[0]],this._intersectPoint_2[T]):this._generateTriangle(_,x,p,this._vertPos[b[0]],this._vertPos[b[1]]),x+=6,C+=3):S<=n||(S<=m?(this._generateTriangle(_,x,p,this._intersectPoint_1[T],this._vertPos[b[1]]),x+=6,C+=3):(this._generateTriangle(_,x,p,this._intersectPoint_1[T],this._intersectPoint_2[T]),x+=6,C+=3))),A+=2*Math.PI,S+=2*Math.PI}}t._vertCount=C;for(var E,I,R=1/0,P=1/0,O=-1/0,B=-1/0,D=0,M=x;D<M;D+=2)E=a[D],I=a[D+1],E<=R?(R=E,c[0]=D):E>=O&&(O=E,c[1]=D),I<=P?(P=I,c[2]=D):I>=B&&(B=I,c[3]=D)},_generateTriangle:function(t,e,i,n,s){var o,a,c=this.rawVerts,h=this.rawUvs,l=this.outVerts,u=c[0],_=c[1],d=c[6],f=c[7];r?(l[e]=i.x*t.a+i.y*t.c+t.tx,l[e+1]=i.x*t.b+i.y*t.d+t.ty,l[e+2]=n.x*t.a+n.y*t.c+t.tx,l[e+3]=n.x*t.b+n.y*t.d+t.ty,l[e+4]=s.x*t.a+s.y*t.c+t.tx,l[e+5]=s.x*t.b+s.y*t.d+t.ty):(l[e]=i.x,l[e+1]=i.y,l[e+2]=n.x,l[e+3]=n.y,l[e+4]=s.x,l[e+5]=s.y),o=(i.x-u)/(d-u),a=(i.y-_)/(f-_),this._generateUV(o,a,h,e),o=(n.x-u)/(d-u),a=(n.y-_)/(f-_),this._generateUV(o,a,h,e+2),o=(s.x-u)/(d-u),a=(s.y-_)/(f-_),this._generateUV(o,a,h,e+4)},_generateUV:function(t,e,i,n){var r=this.outUvs,s=i[0]+(i[2]-i[0])*t,o=i[4]+(i[6]-i[4])*t,a=i[1]+(i[3]-i[1])*t,c=i[5]+(i[7]-i[5])*t;r[n]=s+(o-s)*e,r[n+1]=a+(c-a)*e},_isAngleIn:function(t,e,i){for(var n=2*Math.PI;t<e||t>=e+n;)t<e&&(t+=n),t>=e+n&&(t-=n);return t<=e+i},_getVertAngle:function(t,e){var i,n;if(i=e.x-t.x,n=e.y-t.y,0!==i||0!==n){if(0===i)return n>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(n/i);return i<0&&(r+=Math.PI),r}},_getInsectedPoints:function(t,e,i,n,r,s,o){var a,c,h=Math.sin(s),l=Math.cos(s);if(0!==Math.cos(s)){if(a=h/l,(t-r.x)*l>0){var u=r.y+a*(t-r.x);o[0].x=t,o[0].y=u}if((e-r.x)*l>0){var _=r.y+a*(e-r.x);o[2].x=e,o[2].y=_}}if(0!==Math.sin(s)){if(c=l/h,(n-r.y)*h>0){var d=r.x+c*(n-r.y);o[3].x=d,o[3].y=n}if((i-r.y)*h>0){var f=r.x+c*(i-r.y);o[1].x=f,o[1].y=i}}return[null,null,null,null]},_calculateVertices:function(t,e,i){var n,r;n=i.width,r=i.height,this._vertices[0].x=0,this._vertices[0].y=0,this._vertices[1].x=n,this._vertices[1].y=r},_calculateUVs:function(t){var e,i,n,r,s=t._texture.width,o=t._texture.height,c=t._rect,h=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;t._rotated?(e=(c.x+h)/s,i=(c.x+c.height-h)/s,n=(c.y+h)/o,r=(c.y+c.width-h)/o):(e=(c.x+h)/s,i=(c.x+c.width-h)/s,n=(c.y+h)/o,r=(c.y+c.height-h)/o),this._uvs[0].x=e,this._uvs[0].y=r,this._uvs[1].x=i,this._uvs[1].y=n}},d={_rebuildQuads_base:function(t,e,i){if(cc._renderType!==cc.game.RENDER_TYPE_CANVAS){t._spriteFrame;if(i=t._meshPolygonInfo){var n=t._renderCmd._worldTransform,r=i.triangles.verts,s=t._vertices,a=t._uvs,c=r.length,h=t._corner,l=2*c;s.length<l&&(o.put(s),s=o.get(l)||new Float32Array(l),t._vertices=s),a.length<l&&(o.put(a),a=o.get(l)||new Float32Array(l),t._uvs=a);for(var u=1/0,_=1/0,d=-1/0,f=-1/0,p=0;p<c;p++){var m=r[p].x*n.a+r[p].y*n.c+n.tx,g=r[p].x*n.b+r[p].y*n.d+n.ty;s[2*p]=m,s[2*p+1]=g,a[2*p]=r[p].u,a[2*p+1]=r[p].v,m<u&&(u=m,h[0]=2*p),m>d&&(d=m,h[1]=2*p),g<_&&(_=g,h[2]=2*p),g>f&&(f=g,h[3]=2*p)}t._vertCount=c}}}};cc.Scale9Sprite=_ccsg.Node.extend({_spriteFrame:null,_insetLeft:0,_insetRight:0,_insetTop:0,_insetBottom:0,_blendFunc:null,_renderingType:1,_brightState:0,_rawVerts:null,_rawUvs:null,_vertices:null,_uvs:null,_vertCount:0,_quadsDirty:!0,_uvsDirty:!0,_isTriangle:!1,_isTrimmedContentSize:!0,_fillType:0,_fillCenter:null,_fillStart:0,_fillRange:2*Math.PI,_distortionOffset:null,_distortionTiling:null,_meshPolygonInfo:null,ctor:function(t){_ccsg.Node.prototype.ctor.call(this),this._renderCmd.setState(this._brightState),this._blendFunc=cc.BlendFunc._alphaNonPremultiplied(),this._fillCenter=cc.v2(0,0),this.setAnchorPoint(cc.p(.5,.5)),this._rawVerts=null,this._rawUvs=null,this._vertices=o.get(8)||new Float32Array(8),this._uvs=o.get(8)||new Float32Array(8),"string"==typeof t||t instanceof cc.Texture2D?this.initWithTexture(t):t instanceof cc.SpriteFrame&&this.initWithSpriteFrame(t),void 0===r&&(r=cc._renderType===cc.game.RENDER_TYPE_WEBGL),this._corner=[]},loaded:function(){return null!==this._spriteFrame&&this._spriteFrame.textureLoaded()},initWithTexture:function(t){this.setTexture(t)},initWithSpriteFrame:function(t){this.setSpriteFrame(t)},setTexture:function(t){var e=new cc.SpriteFrame(t);this.setSpriteFrame(e)},setSpriteFrame:function(t){if(t){this._spriteFrame=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd._needDraw=!1;var e=this,i=function(){cc.sizeEqualToSize(e._contentSize,cc.size(0,0))&&e.setContentSize(e._spriteFrame._rect),e._renderCmd._needDraw=!0,e._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)};t.textureLoaded()?i():t.once("load",i,this)}},setBlendFunc:function(t,e){void 0===e?(this._blendFunc.src=t.src||cc.macro.BLEND_SRC,this._blendFunc.dst=t.dst||cc.macro.BLEND_DST):(this._blendFunc.src=t||cc.macro.BLEND_SRC,this._blendFunc.dst=e||cc.macro.BLEND_DST),this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},setContentSize:function(t,e){void 0===e&&(e=t.height,t=t.width),t===this._contentSize.width&&e===this._contentSize.height||(_ccsg.Node.prototype.setContentSize.call(this,t,e),this._quadsDirty=!0)},enableTrimmedContentSize:function(t){this._isTrimmedContentSize!==t&&(this._isTrimmedContentSize=t,this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty))},isTrimmedContentSizeEnabled:function(){return this._isTrimmedContentSize},setState:function(t){this._brightState=t,this._renderCmd.setState(t),this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getState:function(){return this._brightState},setRenderingType:function(t){this._renderingType!==t&&(this._renderingType=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty))},getRenderingType:function(){return this._renderingType},setInsetLeft:function(t){this._insetLeft=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetLeft:function(){return this._insetLeft},setInsetTop:function(t){this._insetTop=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetTop:function(){return this._insetTop},setInsetRight:function(t){this._insetRight=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetRight:function(){return this._insetRight},setInsetBottom:function(t){this._insetBottom=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetBottom:function(){return this._insetBottom},setFillType:function(t){this._fillType!==t&&(this._fillType=t,this._renderingType===p.FILLED&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)))},getFillType:function(){return this._fillType},setFillCenter:function(t,e){this._fillCenter=cc.v2(t,e),this._renderingType===p.FILLED&&this._fillType===m.RADIAL&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty))},setDistortionTiling:function(t,e){void 0===e&&(e=t.y,t=t.x),this._distortionTiling=this._distortionTiling||cc.v2(0,0),this._distortionTiling.x=t,this._distortionTiling.y=e},setDistortionOffset:function(t,e){void 0===e&&(e=t.y,t=t.x),this._distortionOffset=this._distortionOffset||cc.v2(0,0),this._distortionOffset.x=t,this._distortionOffset.y=e},getFillCenter:function(){return cc.v2(this._fillCenter)},setFillStart:function(t){this._fillStart!==t&&(this._fillStart=t,this._renderingType===p.FILLED&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)))},getFillStart:function(){return this._fillStart},setFillRange:function(t){this._fillRange!==t&&(this._fillRange=t,this._renderingType===p.FILLED&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)))},getFillRange:function(){return this._fillRange},_rebuildQuads:function(){if(this._spriteFrame&&this._spriteFrame._textureLoaded){this._isTriangle=!1;var t;switch(this._renderingType){case p.SIMPLE:t=c;break;case p.SLICED:t=h;break;case p.TILED:t=l;break;case p.FILLED:t=this._fillType===m.RADIAL?_:u;break;case p.MESH:t=d}t?t._rebuildQuads_base(this):(this._quadsDirty=!1,this._uvsDirty=!1,this._renderCmd._needDraw=!1,cc.errorID(2627)),this._quadsDirty=!1,this._uvsDirty=!1}else this._renderCmd._needDraw=!1},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.Scale9Sprite.CanvasRenderCmd(this):new cc.Scale9Sprite.WebGLRenderCmd(this)},setMeshPolygonInfo:function(t){this.setRenderingType(p.MESH),this._meshPolygonInfo=t,this._quadsDirty=!0,this._uvsDirty=!0},getMeshPolygonInfo:function(){return this._meshPolygonInfo}});var f=cc.Scale9Sprite.prototype;cc.js.addon(f,s.prototype),cc.defineGetterSetter(f,"insetLeft",f.getInsetLeft,f.setInsetLeft),cc.defineGetterSetter(f,"insetTop",f.getInsetTop,f.setInsetTop),cc.defineGetterSetter(f,"insetRight",f.getInsetRight,f.setInsetRight),cc.defineGetterSetter(f,"insetBottom",f.getInsetBottom,f.setInsetBottom),cc.Scale9Sprite.state={NORMAL:0,GRAY:1,DISTORTION:2};var p=cc.Scale9Sprite.RenderingType=cc.Enum({SIMPLE:0,SLICED:1,TILED:2,FILLED:3,MESH:4}),m=cc.Scale9Sprite.FillType=cc.Enum({HORIZONTAL:0,VERTICAL:1,RADIAL:2})}),{"../event/event-target":112}],212:[(function(t,e,i){cc.Scale9Sprite.CanvasRenderCmd=function(t){this._rootCtor(t),this._node.loaded()?this._needDraw=!0:this._needDraw=!1,this._state=cc.Scale9Sprite.state.NORMAL,this._originalTexture=this._textureToRender=null};var n=cc.Scale9Sprite.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=cc.Scale9Sprite.CanvasRenderCmd,n.updateTransform=function(t){this.originUpdateTransform(t),this._node._rebuildQuads()},n._doCulling=function(){var t=cc.visibleRect,e=this._currentRegion,i=e._minX,n=e._maxX,r=e._minY,s=e._maxY,o=t.left.x,a=t.right.x,c=t.top.y,h=t.bottom.y;this._needDraw=!(n<o||i>a||s<h||r>c)},n._updateDisplayColor=function(t){_ccsg.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this,t),this._originalTexture=this._textureToRender=null},n._syncDisplayColor=function(t){_ccsg.Node.WebGLRenderCmd.prototype._syncDisplayColor.call(this,t),this._originalTexture=this._textureToRender=null},n.setState=function(t){this._state!==t&&(this._state=t,this._originalTexture=this._textureToRender=null)},n.rendering=function(t,e,i){var n=this._node,r=this._displayedOpacity,s=r/255,o=null;if(n._spriteFrame&&(o=n._spriteFrame._texture),n.loaded()&&0!==r){if((null===this._textureToRender||this._originalTexture!==o)&&(this._textureToRender=this._originalTexture=o,cc.Scale9Sprite.state.GRAY===this._state&&(this._textureToRender=this._textureToRender._generateGrayTexture()),cc.sys.browserType!==cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB)){var a=n.getDisplayedColor();!o||255===a.r&&255===a.g&&255===a.b||(this._textureToRender=this._textureToRender._generateColorTexture(a.r,a.g,a.b))}var c=t||cc._renderContext,h=c.getContext();if(c.setTransform(this._worldTransform,e,i),c.setCompositeOperation(_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(n._blendFunc)),c.setGlobalAlpha(s),this._textureToRender){n._quadsDirty&&n._rebuildQuads();var l,u,_,d,f,p,m,g,y=this._textureToRender.width,v=this._textureToRender.height,x=this._textureToRender._image,C=n._vertices,T=n._uvs,b=0,A=0;if(n._isTriangle){var S=n._rawVerts,w=n._rawUvs;f=S[0],p=S[1],m=S[6]-f,p=-p-(g=S[7]-p),l=w[4]*y,u=w[5]*v,_=(w[6]-w[0])*y,d=(w[1]-w[7])*v,c.save(),h.beginPath();var E=Math.floor(n._vertCount/3);for(b=0,A=0;b<E;b++)h.moveTo(C[A++],-C[A++]),h.lineTo(C[A++],-C[A++]),h.lineTo(C[A++],-C[A++]);h.clip(),""!==this._textureToRender._pattern?(c.setFillStyle(h.createPattern(x,this._textureToRender._pattern)),h.fillRect(f,p,m,g)):_>0&&d>0&&m>0&&g>0&&h.drawImage(x,l,u,_,d,f,p,m,g),c.restore(),cc.g_NumberOfDraws+=E}else if(n._renderingType===cc.Scale9Sprite.RenderingType.SLICED){for(var I=0;I<3;++I)for(var R=0;R<3;++R)f=C[A=8*I+2*R],p=C[A+1],m=C[A+10]-f,p=-p-(g=C[A+11]-p),l=T[A]*y,u=T[A+11]*v,_=(T[A+10]-T[A])*y,d=(T[A+1]-T[A+11])*v,_>0&&d>0&&m>0&&g>0&&h.drawImage(x,l,u,_,d,f,p,m,g);cc.g_NumberOfDraws+=9}else{var P=Math.floor(n._vertCount/4);for(b=0,A=0;b<P;b++)f=C[A],p=C[A+1],m=C[A+6]-f,p=-p-(g=C[A+7]-p),l=T[A]*y,u=T[A+7]*v,_=(T[A+6]-T[A])*y,d=(T[A+1]-T[A+7])*v,""!==this._textureToRender._pattern?(c.setFillStyle(h.createPattern(x,this._textureToRender._pattern)),h.fillRect(f,p,m,g)):_>0&&d>0&&m>0&&g>0&&h.drawImage(x,l,u,_,d,f,p,m,g),A+=8;cc.g_NumberOfDraws+=P}}}}}),{}],213:[(function(t,e,i){cc.gl;cc.Scale9Sprite.WebGLRenderCmd=function(t){this._rootCtor(t),this._node.loaded()?this._needDraw=!0:this._needDraw=!1,this.vertexType=cc.renderer.VertexType.QUAD,this._dirty=!1,this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var n=cc.Scale9Sprite,r=n.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);r.constructor=n.WebGLRenderCmd,r._uploadSliced=function(t,e,i,n,r,s,o){for(var a,c=0;c<3;++c)for(var h=0;h<3;++h)a=8*c+2*h,r[o]=t[a],r[o+1]=t[a+1],r[o+2]=n,s[o+3]=i,r[o+4]=e[a],r[o+5]=e[a+1],r[o+=6]=t[a+2],r[o+1]=t[a+3],r[o+2]=n,s[o+3]=i,r[o+4]=e[a+2],r[o+5]=e[a+3],r[o+=6]=t[a+8],r[o+1]=t[a+9],r[o+2]=n,s[o+3]=i,r[o+4]=e[a+8],r[o+5]=e[a+9],r[o+=6]=t[a+10],r[o+1]=t[a+11],r[o+2]=n,s[o+3]=i,r[o+4]=e[a+10],r[o+5]=e[a+11],o+=6;return 36},r.updateTransform=function(t){this.originUpdateTransform(t),this._node._rebuildQuads()},r._doCulling=function(){var t=this._node,e=cc.visibleRect;this._cameraFlag>0&&(e=cc.Camera.main.visibleRect);var i=e.left.x,n=e.right.x,r=e.top.y,s=e.bottom.y,o=t._vertices,a=t._corner,c=a[0],h=a[1],l=a[2],u=a[3],_=o[c],d=o[h],f=o[l],p=o[u],m=o[c+1],g=o[h+1],y=o[l+1],v=o[u+1];this._needDraw=!((_-i&d-i&f-i&p-i)>>31||(n-_&n-d&n-f&n-p)>>31||(m-s&g-s&y-s&v-s)>>31||(r-m&r-g&r-y&r-v)>>31)},r.uploadData=function(t,e,i){var r=this._node;if(0===this._displayedOpacity)return 0;r._quadsDirty&&r._rebuildQuads(),r._distortionOffset&&this._shaderProgram===n.WebGLRenderCmd._distortionProgram&&(this._shaderProgram.use(),this._shaderProgram.setUniformLocationWith2f(n.WebGLRenderCmd._distortionOffset,r._distortionOffset.x,r._distortionOffset.y),this._shaderProgram.setUniformLocationWith2f(n.WebGLRenderCmd._distortionTiling,r._distortionTiling.x,r._distortionTiling.y),cc.renderer._breakBatch());var s,o=this._displayedOpacity,a=this._displayedColor._val;if(r._opacityModifyRGB){var c=o/255,h=this._displayedColor.r*c,l=this._displayedColor.g*c;s=(o<<24>>>0)+(this._displayedColor.b*c<<16)+(l<<8)+h}else s=(o<<24>>>0)+((65280&a)<<8)+((16711680&a)>>8)+(a>>>24);var u=r._vertexZ,_=r._vertices,d=r._uvs,f=n.RenderingType,p=i,m=0;switch(r._renderingType){case f.SIMPLE:case f.TILED:case f.FILLED:case f.MESH:m=this._node._vertCount;for(var g=0,y=0;g<m;g++,y+=2)t[p]=_[y],t[p+1]=_[y+1],t[p+2]=u,e[p+3]=s,t[p+4]=d[y],t[p+5]=d[y+1],p+=6;break;case f.SLICED:m=this._uploadSliced(_,d,s,u,t,e,p)}return r._renderingType===f.MESH?this.vertexType=cc.renderer.VertexType.CUSTOM:r._renderingType===f.FILLED&&r._fillType===n.FillType.RADIAL?this.vertexType=cc.renderer.VertexType.TRIANGLE:this.vertexType=cc.renderer.VertexType.QUAD,m},r.uploadIndexData=function(t,e,i){var n=this._node._meshPolygonInfo;if(!n)return 0;for(var r=n.triangles.indices,s=r.length,o=0;o<s;o++)t[e+o]=i+r[o];return s},r.setState=function(t){t===n.state.NORMAL?this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR):t===n.state.GRAY?this._shaderProgram=cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram():t===n.state.DISTORTION&&(this._shaderProgram=cc.Scale9Sprite.WebGLRenderCmd._getDistortionProgram())},n.WebGLRenderCmd._grayShaderProgram=null,n.WebGLRenderCmd._getGrayShaderProgram=function(){var t=n.WebGLRenderCmd._grayShaderProgram;return t||((t=new cc.GLProgram).initWithVertexShaderByteArray(cc.PresetShaders.SPRITE_POSITION_TEXTURE_COLOR_VERT,cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment),t.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION,cc.macro.VERTEX_ATTRIB_POSITION),t.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR,cc.macro.VERTEX_ATTRIB_COLOR),t.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD,cc.macro.VERTEX_ATTRIB_TEX_COORDS),t.link(),t.updateUniforms(),n.WebGLRenderCmd._grayShaderProgram=t,t)},n.WebGLRenderCmd._grayShaderFragment="precision lowp float;\nvarying vec4 v_fragmentColor;\nvarying vec2 v_texCoord;\nvoid main()\n{\nvec4 c = v_fragmentColor * texture2D(CC_Texture0, v_texCoord);\nfloat gray = 0.2126*c.r + 0.7152*c.g + 0.0722*c.b;\ngl_FragColor = vec4(gray, gray, gray, c.a);\n}",n.WebGLRenderCmd._distortionProgram=null,n.WebGLRenderCmd._getDistortionProgram=function(){var t=n.WebGLRenderCmd._distortionProgram;return t||((t=new cc.GLProgram).initWithVertexShaderByteArray(cc.PresetShaders.SPRITE_POSITION_TEXTURE_COLOR_VERT,s.fShader),t.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION,cc.macro.VERTEX_ATTRIB_POSITION),t.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR,cc.macro.VERTEX_ATTRIB_COLOR),t.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD,cc.macro.VERTEX_ATTRIB_TEX_COORDS),t.link(),t.updateUniforms(),n.WebGLRenderCmd._distortionProgram=t,n.WebGLRenderCmd._distortionOffset=t.getUniformLocationForName("u_offset"),n.WebGLRenderCmd._distortionTiling=t.getUniformLocationForName("u_offset_tiling"),t)};var s={shaderKey:"cc.Sprite.Shader.Distortion",fShader:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvarying vec2 v_texCoord;\nuniform vec2 u_offset;\nuniform vec2 u_offset_tiling;\nconst float PI = 3.14159265359;\nvoid main()\n{\nfloat halfPI = 0.5 * PI;\nfloat maxFactor = sin(halfPI);\nvec2 uv = v_texCoord;\nvec2 xy = 2.0 * uv.xy - 1.0;\nfloat d = length(xy);\nif (d < (2.0-maxFactor)) {\nd = length(xy * maxFactor);\nfloat z = sqrt(1.0 - d * d);\nfloat r = atan(d, z) / PI;\nfloat phi = atan(xy.y, xy.x);\nuv.x = r * cos(phi) + 0.5;\nuv.y = r * sin(phi) + 0.5;\n} else {\ndiscard;\n}\nuv = uv * u_offset_tiling + u_offset;\nuv = fract(uv);\ngl_FragColor = v_fragmentColor * texture2D(CC_Texture0, uv);\n}"}}),{}],214:[(function(t,e,i){cc.SpriteBatchNode=_ccsg.Node.extend({_blendFunc:null,_texture:null,_className:"SpriteBatchNode",ctor:function(t){_ccsg.Node.prototype.ctor.call(this),this._blendFunc=new cc.BlendFunc(cc.macro.BLEND_SRC,cc.macro.BLEND_DST);var e;cc.js.isString(t)?(e=cc.textureCache.getTextureForKey(t))||(e=cc.textureCache.addImage(t)):t instanceof cc.Texture2D&&(e=t),e&&this.initWithTexture(e)},initWithFile:function(t){var e=cc.textureCache.getTextureForKey(t)||cc.textureCache.addImage(t);return this.initWithTexture(e)},removeChildAtIndex:function(t,e){this.removeChild(this._children[t],e)},setBlendFunc:function(t,e){this._blendFunc=void 0===e?t:{src:t,dst:e}},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},updateQuadFromSprite:function(t,e){cc.assertID(t,2623),t instanceof _ccsg.Sprite?(t.dirty=!0,t._renderCmd.transform(this._renderCmd,!0)):cc.log(2616)},appendChild:function(t){this.sortAllChildren();this._children[this._children.length-1]._localZOrder;this.addChild(t.lastLocalZOrder+1)},initWithTexture:function(t){return this.setTexture(t),!0},getTexture:function(){return this._texture},setTexture:function(t){if(this._texture=t,t.loaded){var e,i=this._children,n=i.length;for(e=0;e<n;++e)i[e].setTexture(t)}else t.addEventListener("load",(function(){var e,i=this._children,n=i.length;for(e=0;e<n;++e)i[e].setTexture(t)}),this)},setShaderProgram:function(t){this._renderCmd.setShaderProgram(t);var e,i=this._children,n=i.length;for(e=0;e<n;++e)i[e].setShaderProgram(t)},addChild:function(t,e,i){cc.assertID(void 0!==t,2614),this._isValidChild(t)&&(e=void 0===e?t.zIndex:e,i=void 0===i?t.tag:i,_ccsg.Node.prototype.addChild.call(this,t,e,i),this._renderCmd._shaderProgram&&(t.shaderProgram=this._renderCmd._shaderProgram))},_isValidChild:function(t){return t instanceof _ccsg.Sprite?t.texture===this._texture||(cc.logID(2619),!1):(cc.logID(2618),!1)}});var n=cc.SpriteBatchNode.prototype;cc.defineGetterSetter(n,"texture",n.getTexture,n.setTexture),cc.defineGetterSetter(n,"shaderProgram",n.getShaderProgram,n.setShaderProgram)}),{}],215:[(function(t,e,i){var n=t("../event/event-target");cc.SpriteFrame=cc.Class({name:"cc.SpriteFrame",extends:t("../assets/CCAsset"),mixins:[n],properties:{_textureFilenameSetter:{set:function(t){this._textureFilename=t,t&&this._loadTexture()}}},ctor:function(){var t=arguments[0],e=arguments[1],i=arguments[2],n=arguments[3],r=arguments[4];this._rect=null,this._offset=null,this._originalSize=null,this._rotated=!1,this.insetTop=0,this.insetBottom=0,this.insetLeft=0,this.insetRight=0,this._texture=null,this._textureFilename="",this._textureLoaded=!1,void 0!==t&&this.initWithTexture(t,e,i,n,r)},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(t,e){this.once("load",t,e)},isRotated:function(){return this._rotated},setRotated:function(t){this._rotated=t},getRect:function(){return cc.rect(this._rect)},setRect:function(t){this._rect=t},getOriginalSize:function(){return cc.size(this._originalSize)},setOriginalSize:function(t){this._originalSize?(this._originalSize.width=t.width,this._originalSize.height=t.height):this._originalSize=cc.size(t)},getTexture:function(){return this._texture},_refreshTexture:function(t){var e=this;if(e._texture!==t){var i=t.loaded;this._textureLoaded=i,this._texture=t;function n(){if(e._texture){e._textureLoaded=!0;var i=t.width,n=t.height;if(e._rotated&&cc._renderType===cc.game.RENDER_TYPE_CANVAS){var r=t.getHtmlElementObj();r=_ccsg.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(r,e.getRect());var s=new cc.Texture2D;s.initWithElement(r),s.handleLoadedTexture(),e._texture=s,e._rotated=!1,i=e._texture.width,n=e._texture.height,e.setRect(cc.rect(0,0,i,n))}e._rect?e._checkRect(e._texture):e.setRect(cc.rect(0,0,i,n)),e._originalSize||e.setOriginalSize(cc.size(i,n)),e._offset||e.setOffset(cc.v2(0,0)),e.emit("load")}}i?n():t.once("load",n)}},getOffset:function(){return cc.v2(this._offset)},setOffset:function(t){this._offset=cc.v2(t)},clone:function(){return new cc.SpriteFrame(this._texture||this._textureFilename,this._rect,this._rotated,this._offset,this._originalSize)},setTexture:function(t,e,i,n,r){e?this.setRect(e):this._rect=null,n?this.setOffset(n):this._offset=null,r?this.setOriginalSize(r):this._originalSize=null,this._rotated=i||!1;var s=t;return cc.js.isString(s)?(this._textureFilename=s,this._loadTexture()):s instanceof cc.Texture2D&&this._refreshTexture(s),!0},_loadTexture:function(){if(this._textureFilename){var t=cc.textureCache.addImage(this._textureFilename);this._refreshTexture(t)}},ensureLoadTexture:function(){this._texture||this._loadTexture()},clearTexture:function(){this._textureLoaded=!1,this._texture=null},_checkRect:function(t){var e=this._rect,i=e.x,n=e.y;this._rotated?(i+=e.height,n+=e.width):(i+=e.width,n+=e.height),i>t.getPixelWidth()&&cc.errorID(3300,t.url+"/"+this.name),n>t.getPixelHeight()&&cc.errorID(3400,t.url+"/"+this.name)},_serialize:!1,_deserialize:function(t,e){var i=t.rect;i&&this.setRect(new cc.Rect(i[0],i[1],i[2],i[3])),t.offset&&this.setOffset(new cc.Vec2(t.offset[0],t.offset[1])),t.originalSize&&this.setOriginalSize(new cc.Size(t.originalSize[0],t.originalSize[1])),this._rotated=1===t.rotated,this._name=t.name;var n=t.capInsets;n&&(this.insetLeft=n[0],this.insetTop=n[1],this.insetRight=n[2],this.insetBottom=n[3]);var r=t.texture;if(r){var s=e.customEnv&&e.customEnv.deferredLoadRaw?"_textureFilename":"_textureFilenameSetter";e.result.push(this,s,r)}}});var r=cc.SpriteFrame.prototype;r.copyWithZone=r.clone,r.copy=r.clone,r.initWithTexture=r.setTexture}),{"../assets/CCAsset":43,"../event/event-target":112}],216:[(function(t,e,i){var n=t("../event/event-target"),r=t("../platform/CCSys"),s=(t("../platform/js"),t("../utils/misc"),t("../CCGame"));t("../platform/_CCClass"),t("../platform/CCClass");var o=[{format:6407,internalFormat:6407,pixelType:33635},{format:6408,internalFormat:6408,pixelType:32820},{format:6408,internalFormat:6408,pixelType:32819},{format:6407,internalFormat:6407,pixelType:5121},{format:6408,internalFormat:6408,pixelType:5121},{format:6406,internalFormat:6406,pixelType:5121},{format:6409,internalFormat:6409,pixelType:5121},{format:6410,internalFormat:6410,pixelType:5121}],a=cc.Enum({RGB565:0,RGB5A1:1,RGBA4444:2,RGB888:3,RGBA8888:4,A8:5,I8:6,AI8:7}),c=cc.Enum({REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648}),h=cc.Enum({LINEAR:9729,NEAREST:9728}),l=cc.Class({name:"cc.Texture2D",extends:t("../assets/CCRawAsset"),mixins:[n],properties:{_hasMipmap:!1,_format:a.RGBA8888,_compressed:!1,_premultiplyAlpha:!1,_minFilter:h.LINEAR,_magFilter:h.LINEAR,_wrapS:c.CLAMP_TO_EDGE,_wrapT:c.CLAMP_TO_EDGE},statics:{PixelFormat:a,WrapMode:c,Filter:h},ctor:function(t){this.url=null,this.loaded=!1,this.width=0,this.height=0,this._image=null,cc._renderType===s.RENDER_TYPE_CANVAS?(this._pattern="",this._grayElementObj=null,this._backupElement=null,this._isGray=!1):cc._renderType===s.RENDER_TYPE_WEBGL&&(this._gl=t||cc._renderContext,this._glID=null)},update:function(t){},getPixelWidth:function(){return this.width},getPixelHeight:function(){return this.height},getContentSize:function(){return cc.size(this.width,this.height)},getContentSizeInPixels:function(){return this.getContentSize()},initWithElement:function(t){t&&(this._image=t,this.width=t.width,this.height=t.height,this.loaded=!0)},initWithData:function(t,e,i,n,r){return!1},initWithImage:function(t){return!1},getHtmlElementObj:function(){return this._image},isLoaded:function(){return this.loaded},handleLoadedTexture:function(){if(this._image&&this._image.width&&this._image.height){var t=this._image;this.width=t.width,this.height=t.height,this.loaded=!0,this.emit("load")}},description:function(){return"<cc.Texture2D | Name = "+this.url+" | Dimensions = "+this.width+" x "+this.height+">"},releaseTexture:function(){this._gl&&null!==this._glID&&this._gl.deleteTexture(this._glID)},getPixelFormat:function(){return this._format},hasPremultipliedAlpha:function(){return this._premultiplyAlpha||!1},hasMipmaps:function(){return this._hasMipmap||!1},setTexParameters:function(t,e,i,n){void 0!==e&&(t={minFilter:t,magFilter:e,wrapS:i,wrapT:n}),t.wrapS!==c.REPEAT||t.wrapT!==c.REPEAT?t.wrapS!==c.REPEAT?t.wrapT!==c.REPEAT?this._pattern="":this._pattern="repeat-y":this._pattern="repeat-x":this._pattern="repeat"},setAntiAliasTexParameters:function(){},setAliasTexParameters:function(){}}),u=l.prototype;u.pixelFormat,cc.defineGetterSetter(u,"pixelFormat",u.getPixelFormat),u.pixelWidth,cc.defineGetterSetter(u,"pixelWidth",u.getPixelWidth),u.pixelHeight,cc.defineGetterSetter(u,"pixelHeight",u.getPixelHeight),s.once(s.EVENT_RENDERER_INITED,(function(){if(cc._renderType===s.RENDER_TYPE_CANVAS){var t=function(t,e,i){if(null===t)return null;i=i||document.createElement("canvas"),e=e||cc.rect(0,0,t.width,t.height),i.width=e.width,i.height=e.height;var n=i.getContext("2d");n.drawImage(t,e.x,e.y,e.width,e.height,0,0,e.width,e.height);for(var r=n.getImageData(0,0,e.width,e.height),s=r.data,o=0,a=s.length;o<a;o+=4)s[o]=s[o+1]=s[o+2]=.34*s[o]+.5*s[o+1]+.16*s[o+2];return n.putImageData(r,0,0),i};u._generateTextureCacheForColor=function(){if(this.channelCache)return this.channelCache;var t=[document.createElement("canvas"),document.createElement("canvas"),document.createElement("canvas"),document.createElement("canvas")];return (function(t,e){var i=t.width,n=t.height;e[0].width=i,e[0].height=n,e[1].width=i,e[1].height=n,e[2].width=i,e[2].height=n,e[3].width=i,e[3].height=n;var r=e[3].getContext("2d");r.drawImage(t,0,0);for(var s,o=r.getImageData(0,0,i,n).data,a=0;a<4;a++){for(var c=(s=e[a].getContext("2d")).getImageData(0,0,i,n),h=c.data,l=0;l<o.length;l+=4)h[l]=0===a?o[l]:0,h[l+1]=1===a?o[l+1]:0,h[l+2]=2===a?o[l+2]:0,h[l+3]=o[l+3];s.putImageData(c,0,0)}t.onload=null})(this._image,t),this.channelCache=t},u._switchToGray=function(e){this.loaded&&this._isGray!==e&&(this._isGray=e,this._isGray?(this._backupElement=this._image,this._grayElementObj||(this._grayElementObj=t(this._image)),this._image=this._grayElementObj):null!==this._backupElement&&(this._image=this._backupElement))},u._generateGrayTexture=function(){if(!this.loaded)return null;var e=t(this._image),i=new l;return i.initWithElement(e),i.handleLoadedTexture(),i},u._generateColorTexture=r._supportCanvasNewBlendModes?function(t,e,i,n,r){var s=!1;r?s=!0:r=document.createElement("canvas");var o=this._image;if(n||(n=cc.rect(0,0,o.width,o.height)),r.width=n.width,r.height=n.height,n.width&&n.height){var a=r.getContext("2d");a.globalCompositeOperation="source-over",a.fillStyle="rgb("+(0|t)+","+(0|e)+","+(0|i)+")",a.fillRect(0,0,n.width,n.height),a.globalCompositeOperation="multiply",a.drawImage(o,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(o,n.x,n.y,n.width,n.height,0,0,n.width,n.height)}if(s)return r;var c=new l;return c.initWithElement(r),c.handleLoadedTexture(),c}:function(t,e,i,n,r){var s=!1;r?s=!0:r=document.createElement("canvas");var o=this._image;if(n||(n=cc.rect(0,0,o.width,o.height)),r.width=n.width,r.height=n.height,n.width&&n.height){var a=r.getContext("2d");a.drawImage(o,n.x,n.y,n.width,n.height,0,0,n.width,n.height);var c=a.getImageData(0,0,r.width,r.height),h=c.data;t/=255,e/=255,i/=255;for(var u=0;u<h.length;u+=4)h[u]=h[u]*t,h[u+1]=h[u+1]*e,h[u+2]=h[u+2]*i;a.putImageData(c,0,0)}if(s)return r;var _=new l;return _.initWithElement(r),_.handleLoadedTexture(),_}}else if(cc._renderType===s.RENDER_TYPE_WEBGL){var e;(function(){function t(t){return!(t&t-1||!t)}function i(){for(var t in e)e[t]=void 0;return e}e={width:void 0,height:void 0,minFilter:void 0,magFilter:void 0,wrapS:void 0,wrapT:void 0,format:void 0,mipmap:void 0,image:void 0,premultiplyAlpha:void 0},u.update=function(e){var i=this._hasMipmap,n=this._gl,r=!1;e&&(void 0!==e.width&&(this.width=e.width),void 0!==e.height&&(this.height=e.height),void 0!==e.minFilter&&(this._minFilter=e.minFilter),void 0!==e.magFilter&&(this._magFilter=e.magFilter),void 0!==e.wrapS&&(this._wrapS=e.wrapS),void 0!==e.wrapT&&(this._wrapT=e.wrapT),void 0!==e.format&&(this._format=e.format,r=!0),void 0!==e.premultiplyAlpha&&(this._premultiplyAlpha=e.premultiplyAlpha,r=!0),void 0!==e.image&&(this._image=e.image,r=!0),void 0!==e.mipmap&&(i=this._hasMipmap=e.mipmap)),this._image&&(r?(this.releaseTexture(),this._glID=n.createTexture(),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this._glID),this._setImage(this._image,this.width,this.height,(function(t){var e=o[t];return cc.assertID(e,3113),e})(this._format),this._premultiplyAlpha)):(n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this._glID)),this._setTexInfo(),i&&(cc.assertID(t(this.width)&&t(this.height),3117),n.hint(n.GENERATE_MIPMAP_HINT,n.NICEST),n.generateMipmap(n.TEXTURE_2D)),n.bindTexture(n.TEXTURE_2D,null))},u._setImage=function(t,e,i,n,s){var o=this._gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s),r.platform===r.WECHAT_GAME||r.platform===r.QQ_PLAY||t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement?o.texImage2D(o.TEXTURE_2D,0,n.internalFormat,n.format,n.pixelType,t):o.texImage2D(o.TEXTURE_2D,0,n.internalFormat,e,i,0,n.format,n.pixelType,t)},u._setTexInfo=function(){var e=this._gl;t(this.width)&&t(this.height)||this._wrapS===c.CLAMP_TO_EDGE&&this._wrapT===c.CLAMP_TO_EDGE||(cc.warnID(3116),this._wrapS=c.CLAMP_TO_EDGE,this._wrapT=c.CLAMP_TO_EDGE),this._minFilter===h.LINEAR?e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,this._hasMipmap?e.LINEAR_MIPMAP_NEAREST:e.LINEAR):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,this._hasMipmap?e.NEAREST_MIPMAP_NEAREST:e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,this._magFilter),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,this._wrapS),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,this._wrapT)},u.initWithData=function(t,e,n,r,s){s&&cc.warnID(3118);var o=i();return o.image=t,o.format=e,o.width=n,o.height=r,this.update(o),this.width=n,this.height=r,this.loaded=!0,this.emit("load"),!0},u.initWithElement=function(t){if(t&&0!==t.width&&0!==t.height)return this._image=t,!0},u.handleLoadedTexture=function(t){if(this._image&&this._image.width&&this._image.height){var e=i();e.image=this._image,e.format=a.RGBA8888,e.width=this._image.width,e.height=this._image.height,e.premultiplyAlpha=!!t;var n=cc.view._antiAliasEnabled?h.LINEAR:h.NEAREST;e.minFilter=e.magFilter=n,this.update(e),this.loaded=!0,this.emit("load")}},u.setTexParameters=function(t,e,i,n){void 0!==e&&(t={minFilter:t,magFilter:e,wrapS:i,wrapT:n}),this.update(t)},u.setAntiAliasTexParameters=function(){var t=i();t.minFilter=h.LINEAR,t.magFilter=h.LINEAR,this.update(t)},u.setAliasTexParameters=function(){var t=i();t.minFilter=h.NEAREST,t.magFilter=h.NEAREST,this.update(t)}})()}})),cc.Texture2D=e.exports=l}),{"../CCGame":39,"../assets/CCRawAsset":49,"../event/event-target":112,"../platform/CCClass":176,"../platform/CCSys":185,"../platform/_CCClass":188,"../platform/js":197,"../utils/misc":226}],217:[(function(t,e,i){var n=t("../CCGame"),r=t("./CCTexture2D"),s={_textures:{},_textureColorsCache:{},_textureKeySeq:0|1e3*Math.random(),handleLoadedTexture:null,description:function(){return"<TextureCache | Number of textures = "+this._textures.length+">"},textureForKey:function(t){return cc.logID(3002),this.getTextureForKey(t)},getTextureForKey:function(t){return this._textures[t]},getKeyByTexture:function(t){for(var e in this._textures)if(this._textures[e]===t)return e;return null},_generalTextureKey:function(t){return"_textureKey_"+t},getTextureColors:function(t){var e=t._image,i=this.getKeyByTexture(e);return i||(i=e instanceof HTMLImageElement?e.src:this._generalTextureKey(t.__instanceId)),this._textureColorsCache[i]||(this._textureColorsCache[i]=t._generateTextureCacheForColor()),this._textureColorsCache[i]},getAllTextures:function(){var t=[];for(var e in this._textures){var i=this._textures[e];t.push(i)}return t},removeAllTextures:function(){var t=this._textures;for(var e in t)t[e]&&t[e].releaseTexture();this._textures={}},removeTexture:function(t){if(t){var e=this._textures;for(var i in e)e[i]===t&&(e[i].releaseTexture(),delete e[i])}},removeTextureForKey:function(t){if("string"==typeof t){var e=this._textures;e[t]&&(e[t].releaseTexture(),delete e[t])}},addImage:null,addImageAsync:null,cacheImage:function(t,e){if(cc.assertID(t,3009),e instanceof r)this._textures[t]=e;else{var i=new r;i.initWithElement(e),i.handleLoadedTexture(),this._textures[t]=i}},dumpCachedTextureInfo:function(){var t=0,e=0,i=this._textures;for(var n in i){var r=i[n];t++,r.getHtmlElementObj()instanceof HTMLImageElement?cc.logID(3005,n,r.getHtmlElementObj().src,r.getPixelWidth(),r.getPixelHeight()):cc.logID(3006,n,r.getPixelWidth(),r.getPixelHeight()),e+=r.getPixelWidth()*r.getPixelHeight()*4}var s=this._textureColorsCache;for(n in s){var o=s[n];for(var a in o){var c=o[a];t++,cc.logID(3006,n,c.width,c.height),e+=c.width*c.height*4}}cc.logID(3007,t,e/1024,(e/1048576).toFixed(2))},_clear:function(){this._textures={},this._textureColorsCache={},this._textureKeySeq=0|1e3*Math.random()}};n.once(n.EVENT_RENDERER_INITED,(function(){var t=s;cc._renderType===n.RENDER_TYPE_CANVAS?(t.handleLoadedTexture=function(t){var e=this._textures,i=e[t];i||(cc.assertID(t,3009),(i=e[t]=new r).url=t),i.handleLoadedTexture()},t.addImage=function(t,e,i){cc.assertID(t,3103);var n=this._textures,o=n[t];return o?o.isLoaded()?(e&&e.call(i,o),o):(o.once("load",(function(){e&&e.call(i,o)}),i),o):(o=n[t]=new r,o.url=t,cc.loader.load(t,(function(n,r){if(n)return e&&e.call(i,n||new Error("Unknown error"));s.handleLoadedTexture(t),e&&e.call(i,o)})),o)},t.addImageAsync=t.addImage):cc._renderType===n.RENDER_TYPE_WEBGL&&(t.handleLoadedTexture=function(t){var e,i=this._textures;(e=i[t])||(cc.assertID(t,3009),(e=i[t]=new r).url=t),e.handleLoadedTexture()},t.addImage=function(t,e,i){cc.assertID(t,3112);var n=this._textures,o=n[t];return o?o.isLoaded()?(e&&e.call(i,o),o):(o.once("load",(function(){e&&e.call(i,o)}),i),o):(o=n[t]=new r,o.url=t,cc.loader.load(t,(function(n,r){if(n)return e&&e.call(i,n||new Error("Unknown error"));s.handleLoadedTexture(t),e&&e.call(i,o)})),o)},t.addImageAsync=t.addImage)})),cc.textureCache=e.exports=s}),{"../CCGame":39,"./CCTexture2D":216}],218:[(function(t,e,i){t("./CCTexture2D"),t("./CCTextureCache")}),{"./CCTexture2D":216,"./CCTextureCache":217}],219:[(function(t,e,i){t("../platform/CCSys");var n=/(\.[^\.\/\?\\]*)(\?.*)?$/,r=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,s=/[^\.\/]+\/\.\.\//;cc.path={join:function(){for(var t=arguments.length,e="",i=0;i<t;i++)e=(e+(""===e?"":"/")+arguments[i]).replace(/(\/|\\\\)$/,"");return e},extname:function(t){var e=n.exec(t);return e?e[1]:""},mainFileName:function(t){if(t){var e=t.lastIndexOf(".");if(-1!==e)return t.substring(0,e)}return t},basename:function(t,e){var i=t.indexOf("?");i>0&&(t=t.substring(0,i));var n=/(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(t.replace(/(\/|\\\\)$/,""));if(!n)return null;var r=n[2];return e&&t.substring(t.length-e.length).toLowerCase()===e.toLowerCase()?r.substring(0,r.length-e.length):r},dirname:function(t){var e=r.exec(t);return e?e[2]:""},changeExtname:function(t,e){e=e||"";var i=t.indexOf("?"),n="";return i>0&&(n=t.substring(i),t=t.substring(0,i)),(i=t.lastIndexOf("."))<0?t+e+n:t.substring(0,i)+e+n},changeBasename:function(t,e,i){if(0===e.indexOf("."))return this.changeExtname(t,e);var n=t.indexOf("?"),r="",s=i?this.extname(t):"";return n>0&&(r=t.substring(n),t=t.substring(0,n)),n=t.lastIndexOf("/"),n=n<=0?0:n+1,t.substring(0,n)+e+s+r},_normalize:function(t){var e=t=String(t);do{e=t,t=t.replace(s,"")}while(e.length!==t.length);return t},sep:cc.sys.os===cc.sys.OS_WINDOWS?"\\":"/",stripSep:function(t){return t.replace(/[\/\\]$/,"")}},e.exports=cc.path}),{"../platform/CCSys":185}],220:[(function(t,e,i){function n(){h("frame").start(),h("logic").start()}function r(){cc.director.isPaused()?h("frame").start():h("logic").end(),h("render").start()}function s(){h("render").end(),h("draws").value=cc.g_NumberOfDraws,h("frame").end(),h("fps").frame(),h().tick()}var o=t("../../../external/pstats/pstats"),a=t("../platform/CCMacro"),c=document.createElement("div");c.id="fps";var h=null,l=!1;cc.profiler=e.exports={isShowingStats:function(){return l},hideStats:function(){l&&(c.parentElement===document.body&&document.body.removeChild(c),cc.director.off(cc.Director.EVENT_BEFORE_UPDATE,n),cc.director.off(cc.Director.EVENT_AFTER_VISIT,r),cc.director.off(cc.Director.EVENT_AFTER_DRAW,s),l=!1)},showStats:function(){l||(h||(h=o.new(c,{showGraph:!1,values:{frame:{desc:"Frame time (ms)",min:0,max:50,average:500},fps:{desc:"Framerate (FPS)",below:30,average:500},draws:{desc:"Draw call"},logic:{desc:"Game Logic (ms)",min:0,max:50,average:500,color:"#080"},render:{desc:"Renderer (ms)",min:0,max:50,average:500,color:"#f90"},mode:{desc:cc._renderType===cc.game.RENDER_TYPE_WEBGL?"WebGL":"Canvas",min:1}},css:".pstats {left: "+a.DIRECTOR_STATS_POSITION.x+"px; bottom: "+a.DIRECTOR_STATS_POSITION.y+"px;}"})),null===c.parentElement&&document.body.appendChild(c),cc.director.on(cc.Director.EVENT_BEFORE_UPDATE,n),cc.director.on(cc.Director.EVENT_AFTER_VISIT,r),cc.director.on(cc.Director.EVENT_AFTER_DRAW,s),l=!0)}}}),{"../../../external/pstats/pstats":312,"../platform/CCMacro":181}],221:[(function(t,e,i){function n(t){return t?"string"==typeof t?_.getClassByName(t):t:(cc.errorID(3804),null)}function r(t,e){if(e._sealed)for(var i=0;i<t._components.length;++i){var n=t._components[i];if(n.constructor===e)return n}else for(var r=0;r<t._components.length;++r){var s=t._components[r];if(s instanceof e)return s}return null}function s(t,e,i){if(e._sealed)for(var n=0;n<t._components.length;++n){var r=t._components[n];r.constructor===e&&i.push(r)}else for(var s=0;s<t._components.length;++s){var o=t._components[s];o instanceof e&&i.push(o)}}function o(t,e){for(var i=0;i<t.length;++i){var n=t[i],s=r(n,e);if(s)return s;if(n._children.length>0&&(s=o(n._children,e)))return s}return null}function a(t,e,i){for(var n=0;n<t.length;++n){var r=t[n];s(r,e,i),r._children.length>0&&a(r._children,e,i)}}var c=t("../platform/CCObject").Flags,h=t("./misc"),l=t("../platform/id-generater"),u=t("../event-manager"),_=cc.js,d=c.Destroying,f=c.DontDestroy,p=new l("Node"),m=cc.Class({name:"cc._BaseNode",extends:cc.Object,mixins:[cc.EventTarget],properties:{_parent:null,_children:[],_tag:cc.macro.NODE_TAG_INVALID,_active:!0,_components:[],_prefab:null,_persistNode:{get:function(){return(this._objFlags&f)>0},set:function(t){t?this._objFlags|=f:this._objFlags&=~f}},name:{get:function(){return this._name},set:function(t){this._name=t}},_id:{default:"",editorOnly:!0},uuid:{get:function(){var t=this._id;return t||(t=this._id=p.getNewId()),t}},children:{get:function(){return this._children}},childrenCount:{get:function(){return this._children.length}},active:{get:function(){return this._active},set:function(t){if(t=!!t,this._active!==t){this._active=t;var e=this._parent;if(e){e._activeInHierarchy&&cc.director._nodeActivator.activateNode(this,t)}}}},activeInHierarchy:{get:function(){return this._activeInHierarchy}}},ctor:function(t){this._name=void 0!==t?t:"New Node",this._activeInHierarchy=!1,this.__instanceId=this._id||cc.ClassManager.getNewInstanceId(),this.__eventTargets=[]},getTag:function(){return this._tag},setTag:function(t){this._tag=t},getParent:function(){return this._parent},setParent:function(t){if(this._parent!==t){0;var e=this._parent;if(this._parent=t||null,this._onSetParent(t),t&&(u._setDirtyForNode(this),t._children.push(this),t.emit("child-added",this)),e){if(!(e._objFlags&d)){var i=e._children.indexOf(this);0,e._children.splice(i,1),e.emit("child-removed",this),this._onHierarchyChanged(e)}}else t&&this._onHierarchyChanged(null)}},init:function(){return!0},attr:function(t){_.mixin(this,t)},getChildByTag:function(t){var e=this._children;if(null!==e)for(var i=0;i<e.length;i++){var n=e[i];if(n&&n._tag===t)return n}return null},getChildByUuid:function(t){if(!t)return cc.log("Invalid uuid"),null;for(var e=this._children,i=0,n=e.length;i<n;i++)if(e[i]._id===t)return e[i];return null},getChildByName:function(t){if(!t)return cc.log("Invalid name"),null;for(var e=this._children,i=0,n=e.length;i<n;i++)if(e[i]._name===t)return e[i];return null},addChild:function(t){cc.assertID(t,1606),cc.assertID(null===t._parent,1605),t.setParent(this)},insertChild:function(t,e){t.parent=this,t.setSiblingIndex(e)},getSiblingIndex:function(){return this._parent?this._parent._children.indexOf(this):0},setSiblingIndex:function(t){if(this._parent){var e=this._parent._children;t=-1!==t?t:e.length-1;var i=e.indexOf(this);t!==i&&(e.splice(i,1),t<e.length?e.splice(t,0,this):e.push(this),this._onSiblingIndexChanged&&this._onSiblingIndexChanged(t))}},cleanup:function(){},removeFromParent:function(t){this._parent&&(void 0===t&&(t=!0),this._parent.removeChild(this,t))},removeChild:function(t,e){this._children.indexOf(t)>-1&&((e||void 0===e)&&t.cleanup(),t.parent=null)},removeChildByTag:function(t,e){t===cc.macro.NODE_TAG_INVALID&&cc.logID(1609);var i=this.getChildByTag(t);i?this.removeChild(i,e):cc.logID(1610,t)},removeAllChildren:function(t){var e=this._children;void 0===t&&(t=!0);for(var i=e.length-1;i>=0;i--){var n=e[i];n&&(t&&n.cleanup(),n.parent=null)}this._children.length=0},isChildOf:function(t){var e=this;do{if(e===t)return!0;e=e._parent}while(e);return!1},getComponent:function(t){var e=n(t);return e?r(this,e):null},getComponents:function(t){var e=n(t),i=[];return e&&s(this,e,i),i},getComponentInChildren:function(t){var e=n(t);return e?o(this._children,e):null},getComponentsInChildren:function(t){var e=n(t),i=[];return e&&(s(this,e,i),a(this._children,e,i)),i},_checkMultipleComp:!1,addComponent:function(t){var e;if("string"==typeof t){if(!(e=_.getClassByName(t)))return cc.errorID(3807,t),cc._RFpeek()&&cc.errorID(3808,t),null}else{if(!t)return cc.errorID(3804),null;e=t}if("function"!=typeof e)return cc.errorID(3809),null;if(!cc.isChildClassOf(e,cc.Component))return cc.errorID(3810),null;var i=e._requireComponent;if(i&&!this.getComponent(i)){if(!this.addComponent(i))return null}var n=new e;return n.node=this,this._components.push(n),this._activeInHierarchy&&cc.director._nodeActivator.activateComp(n),n},_addComponentAt:!1,removeComponent:function(t){t?(t instanceof cc.Component||(t=this.getComponent(t)),t&&t.destroy()):cc.errorID(3813)},_getDependComponent:!1,_removeComponent:function(t){if(t){if(!(this._objFlags&d)){var e=this._components.indexOf(t);-1!==e?this._components.splice(e,1):t.node!==this&&cc.errorID(3815)}}else cc.errorID(3814)},_disableChildComps:function(){var t,e=this._components.length;for(t=0;t<e;++t){var i=this._components[t];i._enabled&&cc.director._compScheduler.disableComp(i)}for(t=0,e=this._children.length;t<e;++t){var n=this._children[t];n._active&&n._disableChildComps()}},destroy:function(){cc.Object.prototype.destroy.call(this)&&this._activeInHierarchy&&this._disableChildComps()},destroyAllChildren:function(){for(var t=this._children,e=0;e<t.length;++e)t[e].destroy()},_onSetParent:function(t){},_onPostActivated:function(){},_onHierarchyChanged:function(t){var e=this._parent;!this._persistNode||e instanceof cc.Scene||cc.game.removePersistRootNode(this);var i=this._active&&!(!e||!e._activeInHierarchy);this._activeInHierarchy!==i&&cc.director._nodeActivator.activateNode(this,i)},_onBatchCreated:function(){var t=this._prefab;t&&t.sync&&!t._synced&&t.root===this&&PrefabHelper.syncWithPrefab(this);for(var e=this._children,i=0,n=e.length;i<n;i++)e[i]._onBatchCreated()},_instantiate:function(t){t||(t=cc.instantiate._clone(this,this));var e=this._prefab;return e&&this===e.root&&e.sync&&(t._prefab._synced=e._synced),t._parent=null,t._onBatchCreated(),t},_registerIfAttached:!1,_onPreDestroy:function(){var t,e;this._objFlags|=d;var i=this._parent,n=i&&i._objFlags&d;var r=this._children;for(t=0,e=r.length;t<e;++t)r[t]._destroyImmediate();for(t=0,e=this._components.length;t<e;++t){this._components[t]._destroyImmediate()}var s=this.__eventTargets;for(t=0,e=s.length;t<e;++t){var o=s[t];o&&o.targetOff(this)}if(s.length=0,this._persistNode&&cc.game.removePersistRootNode(this),!n&&i){var a=i._children.indexOf(this);i._children.splice(a,1),i.emit("child-removed",this)}return n},onRestore:!1});m.prototype._onPreDestroyBase=m.prototype._onPreDestroy,m.prototype._onHierarchyChangedBase=m.prototype._onHierarchyChanged;h.propertyDefine(m,["name","children","childrenCount"],{}),cc._BaseNode=e.exports=m}),{"../event-manager":110,"../platform/CCObject":182,"../platform/id-generater":193,"./misc":226}],222:[(function(t,e,i){var n=1e-6;e.exports={binarySearchEpsilon:function(t,e){for(var i=0,r=t.length-1,s=r>>>1;i<=r;s=i+r>>>1){var o=t[s];if(o>e+n)r=s-1;else{if(!(o<e-n))return s;i=s+1}}return~i}}}),{}],223:[(function(t,e,i){var n=t("./misc").BASE64_VALUES,r="0123456789abcdef".split(""),s=["","","",""],o=s.concat(s,"-",s,"-",s,"-",s,"-",s,s,s),a=o.map((function(t,e){return"-"===t?NaN:e})).filter(isFinite);e.exports=function(t){if(22!==t.length)return t;o[0]=t[0],o[1]=t[1];for(var e=2,i=2;e<22;e+=2){var s=n[t.charCodeAt(e)],c=n[t.charCodeAt(e+1)];o[a[i++]]=r[s>>2],o[a[i++]]=r[(3&s)<<2|c>>4],o[a[i++]]=r[15&c]}return o.join("")}}),{"./misc":226}],224:[(function(t,e,i){cc.find=e.exports=function(t,e){if(null==t)return cc.errorID(5600),null;if(e)0;else{var i=cc.director.getScene();if(!i)return null;e=i}for(var n=e,r="/"!==t[0]?0:1,s=t.split("/"),o=r;o<s.length;o++){var a=s[o],c=n._children;n=null;for(var h=0,l=c.length;h<l;++h){var u=c[h];if(u.name===a){n=u;break}}if(!n)return null}return n}}),{}],225:[(function(t,e,i){t("./CCPath"),t("./CCProfiler"),t("./find"),t("./mutable-forward-iterator")}),{"./CCPath":219,"./CCProfiler":220,"./find":224,"./mutable-forward-iterator":227}],226:[(function(t,e,i){var n=t("../platform/js"),r=t("../platform/CCSys"),s=i;s.propertyDefine=function(t,e,i){function n(t,e,i,n){var r=Object.getOwnPropertyDescriptor(t,e);if(r)r.get&&(t[i]=r.get),r.set&&n&&(t[n]=r.set);else{var s=t[i];cc.js.getset(t,e,s,t[n])}}for(var r,s=t.prototype,o=0;o<e.length;o++){var a=(r=e[o])[0].toUpperCase()+r.slice(1);n(s,r,"get"+a,"set"+a)}for(r in i){var c=i[r];n(s,r,c[0],c[1])}},s.NextPOT=function(t){return t-=1,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,(t|=t>>16)+1},s.imagePool=new n.Pool(function(t){return t instanceof HTMLImageElement&&(t.src=this._smallImg,!0)},10),s.imagePool.get=function(){return this._get()||new Image},s.imagePool._smallImg="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=",r.os!==r.OS_WINDOWS&&r.os!==r.OS_LINUX||r.browserType===r.BROWSER_TYPE_CHROME||s.imagePool.resize(0),s.BUILTIN_CLASSID_RE=/^(?:cc|dragonBones|sp|ccsg)\..+/;for(var o=new Array(123),a=0;a<123;++a)o[a]=64;for(var c=0;c<64;++c)o["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(c)]=c;s.BASE64_VALUES=o,s.pushToMap=function(t,e,i,n){var r=t[e];r?Array.isArray(r)?n?(r.push(r[0]),r[0]=i):r.push(i):t[e]=n?[i,r]:[r,i]:t[e]=i}}),{"../platform/CCSys":185,"../platform/js":197}],227:[(function(t,e,i){function n(t){this.i=0,this.array=t}var r=n.prototype;r.remove=function(t){var e=this.array.indexOf(t);e>=0&&this.removeAt(e)},r.removeAt=function(t){this.array.splice(t,1),t<=this.i&&--this.i},r.fastRemove=function(t){var e=this.array.indexOf(t);e>=0&&this.fastRemoveAt(e)},r.fastRemoveAt=function(t){var e=this.array;e[t]=e[e.length-1],--e.length,t<=this.i&&--this.i},r.push=function(t){this.array.push(t)},e.exports=n}),{}],228:[(function(t,e,i){cc._PrefabInfo=cc.Class({name:"cc.PrefabInfo",properties:{root:null,asset:null,fileId:"",sync:!1,_synced:{default:!1,serializable:!1}}}),e.exports={syncWithPrefab:function(t){var e=t._prefab;if(e._synced=!0,!e.asset)return cc.errorID(3701,t.name),void(t._prefab=null);var i=t._objFlags,n=t._parent,r=t._id,s=t._name,o=t._active,a=t._position.x,c=t._position.y,h=t._rotationX,l=t._rotationY,u=t._localZOrder,_=t._globalZOrder;cc.game._isCloning=!0;e.asset._doInstantiate(t),cc.game._isCloning=!1,t._objFlags=i,t._parent=n,t._id=r,t._prefab=e,t._name=s,t._active=o,t._position.x=a,t._position.y=c,t._rotationX=h,t._rotationY=l,t._localZOrder=u,t._globalZOrder=_}}}),{}],229:[(function(t,e,i){var n={removeSgNode:function(){var t=this._sgNode;if(t){var e=t._parent;e?e.removeChild(t):t.performRecursive(_ccsg.Node.performType.cleanup),t._entity&&(t._entity=null)}}};e.exports=n}),{}],230:[(function(t,e,i){cc.AffineTransform=function(t,e,i,n,r,s){this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s},cc.affineTransformMake=function(t,e,i,n,r,s){return{a:t,b:e,c:i,d:n,tx:r,ty:s}},cc.affineTransformClone=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,tx:t.tx,ty:t.ty}},cc.pointApplyAffineTransform=function(t,e,i){var n,r;return void 0===i?(i=e,n=t.x,r=t.y):(n=t,r=e),{x:i.a*n+i.c*r+i.tx,y:i.b*n+i.d*r+i.ty}},cc._pointApplyAffineTransformIn=function(t,e,i,n){var r,s,o;void 0===n?(o=e,r=t.x,s=t.y,n=i):(r=t,s=e,o=i),n.x=o.a*r+o.c*s+o.tx,n.y=o.b*r+o.d*s+o.ty},cc._pointApplyAffineTransform=function(t,e,i){return cc.pointApplyAffineTransform(t,e,i)},cc.sizeApplyAffineTransform=function(t,e){return{width:e.a*t.width+e.c*t.height,height:e.b*t.width+e.d*t.height}},cc.affineTransformMakeIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},cc.affineTransformIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},cc.rectApplyAffineTransform=function(t,e){var i=t.x,n=t.y,r=i+t.width,s=n+t.height,o=e.a*i+e.c*n+e.tx,a=e.b*i+e.d*n+e.ty,c=e.a*r+e.c*n+e.tx,h=e.b*r+e.d*n+e.ty,l=e.a*i+e.c*s+e.tx,u=e.b*i+e.d*s+e.ty,_=e.a*r+e.c*s+e.tx,d=e.b*r+e.d*s+e.ty,f=Math.min(o,c,l,_),p=Math.max(o,c,l,_),m=Math.min(a,h,u,d),g=Math.max(a,h,u,d);return cc.rect(f,m,p-f,g-m)},cc._rectApplyAffineTransformIn=function(t,e){var i=t.x,n=t.y,r=i+t.width,s=n+t.height,o=e.a*i+e.c*n+e.tx,a=e.b*i+e.d*n+e.ty,c=e.a*r+e.c*n+e.tx,h=e.b*r+e.d*n+e.ty,l=e.a*i+e.c*s+e.tx,u=e.b*i+e.d*s+e.ty,_=e.a*r+e.c*s+e.tx,d=e.b*r+e.d*s+e.ty,f=Math.min(o,c,l,_),p=Math.max(o,c,l,_),m=Math.min(a,h,u,d),g=Math.max(a,h,u,d);return t.x=f,t.y=m,t.width=p-f,t.height=g-m,t},cc.obbApplyAffineTransform=function(t,e,i,n,r,s){var o=t.x,a=t.y,c=t.width,h=t.height,l=e.a*o+e.c*a+e.tx,u=e.b*o+e.d*a+e.ty,_=e.a*c,d=e.b*c,f=e.c*h,p=e.d*h;n.x=l,n.y=u,r.x=_+l,r.y=d+u,i.x=f+l,i.y=p+u,s.x=_+f+l,s.y=d+p+u},cc.affineTransformTranslate=function(t,e,i){return{a:t.a,b:t.b,c:t.c,d:t.d,tx:t.tx+t.a*e+t.c*i,ty:t.ty+t.b*e+t.d*i}},cc.affineTransformScale=function(t,e,i){return{a:t.a*e,b:t.b*e,c:t.c*i,d:t.d*i,tx:t.tx,ty:t.ty}},cc.affineTransformRotate=function(t,e){var i=Math.sin(e),n=Math.cos(e);return{a:t.a*n+t.c*i,b:t.b*n+t.d*i,c:t.c*n-t.a*i,d:t.d*n-t.b*i,tx:t.tx,ty:t.ty}},cc.affineTransformConcat=function(t,e){return{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,tx:t.tx*e.a+t.ty*e.c+e.tx,ty:t.tx*e.b+t.ty*e.d+e.ty}},cc.affineTransformConcatIn=function(t,e){var i=t.a,n=t.b,r=t.c,s=t.d,o=t.tx,a=t.ty;return t.a=i*e.a+n*e.c,t.b=i*e.b+n*e.d,t.c=r*e.a+s*e.c,t.d=r*e.b+s*e.d,t.tx=o*e.a+a*e.c+e.tx,t.ty=o*e.b+a*e.d+e.ty,t},cc.affineTransformEqualToTransform=function(t,e){return t.a===e.a&&t.b===e.b&&t.c===e.c&&t.d===e.d&&t.tx===e.tx&&t.ty===e.ty},cc.affineTransformInvert=function(t){var e=1/(t.a*t.d-t.b*t.c);return{a:e*t.d,b:-e*t.b,c:-e*t.c,d:e*t.a,tx:e*(t.c*t.ty-t.d*t.tx),ty:e*(t.b*t.tx-t.a*t.ty)}},cc.affineTransformInvertIn=function(t){var e=t.a,i=t.b,n=t.c,r=t.d,s=1/(e*r-i*n),o=t.tx,a=t.ty;return t.a=s*r,t.b=-s*i,t.c=-s*n,t.d=s*e,t.tx=s*(n*a-r*o),t.ty=s*(i*o-e*a),t},cc.affineTransformInvertOut=function(t,e){var i=t.a,n=t.b,r=t.c,s=t.d,o=1/(i*s-n*r);e.a=o*s,e.b=-o*n,e.c=-o*r,e.d=o*i,e.tx=o*(r*t.ty-s*t.tx),e.ty=o*(n*t.tx-i*t.ty)}}),{}],231:[(function(t,e,i){var n=t("./CCValueType"),r=t("../platform/js"),s=(function(){function e(t,e,i,n){"object"==typeof t&&(e=t.g,i=t.b,n=t.a,t=t.r),t=t||0,e=e||0,i=i||0,n="number"==typeof n?n:255,this._val=(~~t<<24>>>0)+(~~e<<16)+(~~i<<8)+~~n}r.extend(e,n),t("../platform/CCClass").fastDefine("cc.Color",e,{r:0,g:0,b:0,a:255});var i={WHITE:[255,255,255,255],BLACK:[0,0,0,255],TRANSPARENT:[0,0,0,0],GRAY:[127.5,127.5,127.5],RED:[255,0,0],GREEN:[0,255,0],BLUE:[0,0,255],YELLOW:[255,235,4],ORANGE:[255,127,0],CYAN:[0,255,255],MAGENTA:[255,0,255]};for(var s in i)r.get(e,s,(function(t){return function(){return new e(t[0],t[1],t[2],t[3])}})(i[s]));var o=e.prototype;return o.clone=function(){var t=new e;return t._val=this._val,t},o.equals=function(t){return t&&this._val===t._val},o.lerp=function(t,i,n){n=n||new e;var r=this.r,s=this.g,o=this.b,a=this.a;return n.r=r+(t.r-r)*i,n.g=s+(t.g-s)*i,n.b=o+(t.b-o)*i,n.a=a+(t.a-a)*i,n},o.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},o.getR=function(){return(4278190080&this._val)>>>24},o.setR=function(t){return this._val=(16777215&this._val|~~t<<24>>>0)>>>0,this},o.getG=function(){return(16711680&this._val)>>16},o.setG=function(t){return this._val=(4278255615&this._val|~~t<<16)>>>0,this},o.getB=function(){return(65280&this._val)>>8},o.setB=function(t){return this._val=(4294902015&this._val|~~t<<8)>>>0,this},o.getA=function(){return 255&this._val},o.setA=function(t){return this._val=(4294967040&this._val|~~t)>>>0,this},r.getset(o,"r",o.getR,o.setR,!0),r.getset(o,"g",o.getG,o.setG,!0),r.getset(o,"b",o.getB,o.setB,!0),r.getset(o,"a",o.getA,o.setA,!0),o.toCSS=function(t){return"rgba"===t?"rgba("+(0|this.r)+","+(0|this.g)+","+(0|this.b)+","+(this.a/255).toFixed(2)+")":"rgb"===t?"rgb("+(0|this.r)+","+(0|this.g)+","+(0|this.b)+")":"#"+this.toHEX(t)},o.clamp=function(){},o.fromHEX=function(t){t.length<8&&(t+="FF");var e=parseInt(t.indexOf("#")>-1?t.substring(1):t,16);return this._val=(0&this._val|e)>>>0,this},o.toHEX=function(t){var e=[(0|this.r).toString(16),(0|this.g).toString(16),(0|this.b).toString(16)],i=-1;if("#rgb"===t)for(i=0;i<e.length;++i)e[i].length>1&&(e[i]=e[i][0]);else if("#rrggbb"===t)for(i=0;i<e.length;++i)1===e[i].length&&(e[i]="0"+e[i]);return e.join("")},o.toRGBValue=function(){return 16777215&this._val},o.fromHSV=function(t,i,n){var r=e.hsv2rgb(t,i,n);return this._val=(r.r<<24>>>0)+(r.g<<16)+(r.b<<8)+this.a,this},o.toHSV=function(){return e.rgb2hsv(this.r,this.g,this.b)},o.fromColor=function(t){t._val?this._val=t._val:(this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a)},e})();s.rgb2hsv=function(t,e,i){t/=255,e/=255,i/=255;var n={h:0,s:0,v:0},r=Math.max(t,e,i),s=Math.min(t,e,i),o=0;return n.v=r,n.s=r?(r-s)/r:0,n.s?(o=r-s,n.h=t===r?(e-i)/o:e===r?2+(i-t)/o:4+(t-e)/o,n.h/=6,n.h<0&&(n.h+=1)):n.h=0,n},s.hsv2rgb=function(t,e,i){var n={r:0,g:0,b:0};if(0===e)n.r=n.g=n.b=i;else if(0===i)n.r=n.g=n.b=0;else{1===t&&(t=0),t*=6,e=e,i=i;var r=Math.floor(t),s=t-r,o=i*(1-e),a=i*(1-e*s),c=i*(1-e*(1-s));switch(r){case 0:n.r=i,n.g=c,n.b=o;break;case 1:n.r=a,n.g=i,n.b=o;break;case 2:n.r=o,n.g=i,n.b=c;break;case 3:n.r=o,n.g=a,n.b=i;break;case 4:n.r=c,n.g=o,n.b=i;break;case 5:n.r=i,n.g=o,n.b=a}}return n.r*=255,n.g*=255,n.b*=255,n},cc.Color=s,cc.color=function(t,e,i,n){if("string"==typeof t){return(new cc.Color).fromHEX(t)}return"object"==typeof t?new cc.Color(t.r,t.g,t.b,t.a):new cc.Color(t,e,i,n)},cc.colorEqual=function(t,e){return void 0!==t._val&&void 0!==e._val?t._val===e._val:t.r===e.r&&t.g===e.g&&t.b===e.b},cc.hexToColor=function(t){t=t.replace(/^#?/,"0x");var e=parseInt(t),i=e>>16,n=(65280&e)>>8,r=255&e;return cc.color(i,n,r)},cc.colorToHex=function(t){var e=t.r.toString(16),i=t.g.toString(16),n=t.b.toString(16);return"#"+(t.r<16?"0"+e:e)+(t.g<16?"0"+i:i)+(t.b<16?"0"+n:n)},e.exports=cc.Color}),{"../platform/CCClass":176,"../platform/js":197,"./CCValueType":237}],232:[(function(t,e,i){var n=parseFloat("1.192092896e-07F");cc.pNeg=function(t){return cc.p(-t.x,-t.y)},cc.pAdd=function(t,e){return cc.p(t.x+e.x,t.y+e.y)},cc.pSub=function(t,e){return cc.p(t.x-e.x,t.y-e.y)},cc.pMult=function(t,e){return cc.p(t.x*e,t.y*e)},cc.pMidpoint=function(t,e){return cc.pMult(cc.pAdd(t,e),.5)},cc.pDot=function(t,e){return t.x*e.x+t.y*e.y},cc.pCross=function(t,e){return t.x*e.y-t.y*e.x},cc.pPerp=function(t){return cc.p(-t.y,t.x)},cc.pRPerp=function(t){return cc.p(t.y,-t.x)},cc.pProject=function(t,e){return cc.pMult(e,cc.pDot(t,e)/cc.pDot(e,e))},cc.pLengthSQ=function(t){return cc.pDot(t,t)},cc.pDistanceSQ=function(t,e){return cc.pLengthSQ(cc.pSub(t,e))},cc.pLength=function(t){return Math.sqrt(cc.pLengthSQ(t))},cc.pDistance=function(t,e){return cc.pLength(cc.pSub(t,e))},cc.pNormalize=function(t){var e=cc.pLength(t);return 0===e?cc.p(t):cc.pMult(t,1/e)},cc.pForAngle=function(t){return cc.p(Math.cos(t),Math.sin(t))},cc.pToAngle=function(t){return Math.atan2(t.y,t.x)},cc.clampf=function(t,e,i){if(e>i){var n=e;e=i,i=n}return t<e?e:t<i?t:i},cc.clamp01=function(t){return t<0?0:t<1?t:1},cc.pClamp=function(t,e,i){return cc.p(cc.clampf(t.x,e.x,i.x),cc.clampf(t.y,e.y,i.y))},cc.pFromSize=function(t){return cc.p(t.width,t.height)},cc.pCompOp=function(t,e){return cc.p(e(t.x),e(t.y))},cc.pLerp=function(t,e,i){return cc.pAdd(cc.pMult(t,1-i),cc.pMult(e,i))},cc.pFuzzyEqual=function(t,e,i){return t.x-i<=e.x&&e.x<=t.x+i&&t.y-i<=e.y&&e.y<=t.y+i},cc.pCompMult=function(t,e){return cc.p(t.x*e.x,t.y*e.y)},cc.pAngleSigned=function(t,e){var i=cc.pNormalize(t),r=cc.pNormalize(e),s=Math.atan2(i.x*r.y-i.y*r.x,cc.pDot(i,r));return Math.abs(s)<n?0:s},cc.pAngle=function(t,e){var i=Math.acos(cc.pDot(cc.pNormalize(t),cc.pNormalize(e)));return Math.abs(i)<n?0:i},cc.pRotateByAngle=function(t,e,i){var n=cc.pSub(t,e),r=Math.cos(i),s=Math.sin(i),o=n.x;return n.x=o*r-n.y*s+e.x,n.y=o*s+n.y*r+e.y,n},cc.pLineIntersect=function(t,e,i,n,r){if(t.x===e.x&&t.y===e.y||i.x===n.x&&i.y===n.y)return!1;var s=e.x-t.x,o=e.y-t.y,a=n.x-i.x,c=n.y-i.y,h=t.x-i.x,l=t.y-i.y,u=c*s-a*o;return r.x=a*l-c*h,r.y=s*l-o*h,0===u?0===r.x||0===r.y:(r.x=r.x/u,r.y=r.y/u,!0)},cc.pSegmentIntersect=function(t,e,i,n){var r=cc.p(0,0);return!!(cc.pLineIntersect(t,e,i,n,r)&&r.x>=0&&r.x<=1&&r.y>=0&&r.y<=1)},cc.pIntersectPoint=function(t,e,i,n){var r=cc.p(0,0);if(cc.pLineIntersect(t,e,i,n,r)){var s=cc.p(0,0);return s.x=t.x+r.x*(e.x-t.x),s.y=t.y+r.x*(e.y-t.y),s}return cc.p(0,0)},cc.pSameAs=function(t,e){return null!=t&&null!=e&&(t.x===e.x&&t.y===e.y)},cc.pZeroIn=function(t){t.x=0,t.y=0},cc.pIn=function(t,e){t.x=e.x,t.y=e.y},cc.pMultIn=function(t,e){t.x*=e,t.y*=e},cc.pSubIn=function(t,e){t.x-=e.x,t.y-=e.y},cc.pAddIn=function(t,e){t.x+=e.x,t.y+=e.y},cc.pNormalizeIn=function(t){cc.pMultIn(t,1/Math.sqrt(t.x*t.x+t.y*t.y))}}),{}],233:[(function(t,e,i){function n(t,e,i,n){t&&"object"==typeof t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0}var r=t("./CCValueType"),s=t("../platform/js");s.extend(n,r),t("../platform/CCClass").fastDefine("cc.Rect",n,{x:0,y:0,width:0,height:0}),n.fromMinMax=function(t,e){var i=Math.min(t.x,e.x),r=Math.min(t.y,e.y);return new n(i,r,Math.max(t.x,e.x)-i,Math.max(t.y,e.y)-r)},n.contain=function(t,e){return t.x<e.x&&t.x+t.width>e.x+e.width&&t.y<e.y&&t.y+t.height>e.y+e.height?1:e.x<t.x&&e.x+e.width>t.x+t.width&&e.y<t.y&&e.y+e.height>t.y+t.height?-1:0};var o=n.prototype;o.clone=function(){return new n(this.x,this.y,this.width,this.height)},o.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},o.lerp=function(t,e,i){i=i||new n;var r=this.x,s=this.y,o=this.width,a=this.height;return i.x=r+(t.x-r)*e,i.y=s+(t.y-s)*e,i.width=o+(t.width-o)*e,i.height=a+(t.height-a)*e,i},o.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},s.getset(o,"xMin",(function(){return this.x}),(function(t){this.width+=this.x-t,this.x=t})),s.getset(o,"yMin",(function(){return this.y}),(function(t){this.height+=this.y-t,this.y=t})),s.getset(o,"xMax",(function(){return this.x+this.width}),(function(t){this.width=t-this.x})),s.getset(o,"yMax",(function(){return this.y+this.height}),(function(t){this.height=t-this.y})),s.getset(o,"center",(function(){return new cc.Vec2(this.x+.5*this.width,this.y+.5*this.height)}),(function(t){this.x=t.x-.5*this.width,this.y=t.y-.5*this.height})),s.getset(o,"origin",(function(){return new cc.Vec2(this.x,this.y)}),(function(t){this.x=t.x,this.y=t.y})),s.getset(o,"size",(function(){return new cc.Size(this.width,this.height)}),(function(t){this.width=t.width,this.height=t.height})),o.intersects=function(t){return cc.rectIntersectsRect(this,t)},o.contains=function(t){return this.x<=t.x&&this.x+this.width>=t.x&&this.y<=t.y&&this.y+this.height>=t.y},o.containsRect=function(t){return this.x<=t.x&&this.x+this.width>=t.x+t.width&&this.y<=t.y&&this.y+this.height>=t.y+t.height},cc.Rect=n,cc.rect=function(t,e,i,r){return new n(t,e,i,r)},cc.rectEqualToRect=function(t,e){return t&&e&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},cc._rectEqualToZero=function(t){return t&&0===t.x&&0===t.y&&0===t.width&&0===t.height},cc.rectContainsRect=function(t,e){return!(!t||!e)&&!(t.x>=e.x||t.y>=e.y||t.x+t.width<=e.x+e.width||t.y+t.height<=e.y+e.height)},cc.rectGetMaxX=function(t){return t.x+t.width},cc.rectGetMidX=function(t){return t.x+t.width/2},cc.rectGetMinX=function(t){return t.x},cc.rectGetMaxY=function(t){return t.y+t.height},cc.rectGetMidY=function(t){return t.y+t.height/2},cc.rectGetMinY=function(t){return t.y},cc.rectContainsPoint=function(t,e){return e.x>=cc.rectGetMinX(t)&&e.x<=cc.rectGetMaxX(t)&&e.y>=cc.rectGetMinY(t)&&e.y<=cc.rectGetMaxY(t)},cc.rectIntersectsRect=function(t,e){var i=t.x+t.width,n=t.y+t.height,r=e.x+e.width,s=e.y+e.height;return!(i<e.x||r<t.x||n<e.y||s<t.y)},cc.rectOverlapsRect=function(t,e){return!(t.x+t.width<e.x||e.x+e.width<t.x||t.y+t.height<e.y||e.y+e.height<t.y)},cc.rectUnion=function(t,e){var i=cc.rect(0,0,0,0);return i.x=Math.min(t.x,e.x),i.y=Math.min(t.y,e.y),i.width=Math.max(t.x+t.width,e.x+e.width)-i.x,i.height=Math.max(t.y+t.height,e.y+e.height)-i.y,i},cc.rectIntersection=function(t,e){var i=cc.rect(Math.max(cc.rectGetMinX(t),cc.rectGetMinX(e)),Math.max(cc.rectGetMinY(t),cc.rectGetMinY(e)),0,0);return i.width=Math.min(cc.rectGetMaxX(t),cc.rectGetMaxX(e))-cc.rectGetMinX(i),i.height=Math.min(cc.rectGetMaxY(t),cc.rectGetMaxY(e))-cc.rectGetMinY(i),i},e.exports=cc.Rect}),{"../platform/CCClass":176,"../platform/js":197,"./CCValueType":237}],234:[(function(t,e,i){function n(t,e){t&&"object"==typeof t&&(e=t.height,t=t.width),this.width=t||0,this.height=e||0}var r=t("./CCValueType"),s=t("../platform/js");s.extend(n,r),t("../platform/CCClass").fastDefine("cc.Size",n,{width:0,height:0}),s.get(n,"ZERO",(function(){return new n(0,0)}));var o=n.prototype;o.clone=function(){return new n(this.width,this.height)},o.equals=function(t){return t&&this.width===t.width&&this.height===t.height},o.lerp=function(t,e,i){i=i||new n;var r=this.width,s=this.height;return i.width=r+(t.width-r)*e,i.height=s+(t.height-s)*e,i},o.toString=function(){return"("+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},cc.size=function(t,e){return new n(t,e)},cc.sizeEqualToSize=function(t,e){return t&&e&&t.width===e.width&&t.height===e.height},cc.Size=e.exports=n}),{"../platform/CCClass":176,"../platform/js":197,"./CCValueType":237}],235:[(function(t,e,i){cc.Acceleration=function(t,e,i,n){this.x=t||0,this.y=e||0,this.z=i||0,this.timestamp=n||0},cc.BlendFunc=function(t,e){this.src=t,this.dst=e};var n=cc.Enum({ONE:1,ZERO:0,SRC_ALPHA:770,SRC_COLOR:768,DST_ALPHA:772,DST_COLOR:774,ONE_MINUS_SRC_ALPHA:771,ONE_MINUS_SRC_COLOR:769,ONE_MINUS_DST_ALPHA:773,ONE_MINUS_DST_COLOR:775});cc.BlendFunc._disable=function(){return new cc.BlendFunc(n.ONE,n.ZERO)},cc.BlendFunc._alphaPremultiplied=function(){return new cc.BlendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA)},cc.BlendFunc._alphaNonPremultiplied=function(){return new cc.BlendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA)},cc.BlendFunc._additive=function(){return new cc.BlendFunc(n.SRC_ALPHA,n.ONE)},cc.BlendFunc.BlendFactor=n,cc.BlendFunc.DISABLE,cc.js.get(cc.BlendFunc,"DISABLE",cc.BlendFunc._disable),cc.BlendFunc.ALPHA_PREMULTIPLIED,cc.js.get(cc.BlendFunc,"ALPHA_PREMULTIPLIED",cc.BlendFunc._alphaPremultiplied),cc.BlendFunc.ALPHA_NON_PREMULTIPLIED,cc.js.get(cc.BlendFunc,"ALPHA_NON_PREMULTIPLIED",cc.BlendFunc._alphaNonPremultiplied),cc.BlendFunc.ADDITIVE,cc.js.get(cc.BlendFunc,"ADDITIVE",cc.BlendFunc._additive),cc.blendFuncDisable=cc.BlendFunc._disable,cc.TextAlignment=cc.Enum({LEFT:0,CENTER:1,RIGHT:2}),cc.VerticalTextAlignment=cc.Enum({TOP:0,CENTER:1,BOTTOM:2})}),{}],236:[(function(t,e,i){cc.WebGLColor=function(t,e,i,n,r,s){this._arrayBuffer=r||new ArrayBuffer(cc.WebGLColor.BYTES_PER_ELEMENT),this._offset=s||0;var o=this._arrayBuffer,a=this._offset;this._view=new Uint8Array(o,a,4),this._view[0]=t||0,this._view[1]=e||0,this._view[2]=i||0,"number"==typeof n?this._view[3]=n:(this._view[3]=255,this.a_undefined=!0)},cc.WebGLColor.BYTES_PER_ELEMENT=4;(n=cc.WebGLColor.prototype)._getR=function(){return this._view[0]},n._setR=function(t){this._view[0]=t<0?0:t},n._getG=function(){return this._view[1]},n._setG=function(t){this._view[1]=t<0?0:t},n._getB=function(){return this._view[2]},n._setB=function(t){this._view[2]=t<0?0:t},n._getA=function(){return this._view[3]},n._setA=function(t){this._view[3]=t<0?0:t},n.r,cc.js.getset(n,"r",n._getR,n._setR),n.g,cc.js.getset(n,"g",n._getG,n._setG),n.b,cc.js.getset(n,"b",n._getB,n._setB),n.a,cc.js.getset(n,"a",n._getA,n._setA),cc.Vertex2F=function(t,e,i,n){this._arrayBuffer=i||new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT),this._offset=n||0,this._view=new Float32Array(this._arrayBuffer,this._offset,2),this._view[0]=t||0,this._view[1]=e||0},cc.Vertex2F.BYTES_PER_ELEMENT=8;var n;(n=cc.Vertex2F.prototype)._getX=function(){return this._view[0]},n._setX=function(t){this._view[0]=t},n._getY=function(){return this._view[1]},n._setY=function(t){this._view[1]=t},cc.js.getset(n,"x",n._getX,n._setX),cc.js.getset(n,"y",n._getY,n._setY),cc.Vertex3F=function(t,e,i,n,r){this._arrayBuffer=n||new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT),this._offset=r||0;var s=this._arrayBuffer,o=this._offset;this._view=new Float32Array(s,o,3),this._view[0]=t||0,this._view[1]=e||0,this._view[2]=i||0},cc.Vertex3F.BYTES_PER_ELEMENT=12,(n=cc.Vertex3F.prototype)._getX=function(){return this._view[0]},n._setX=function(t){this._view[0]=t},n._getY=function(){return this._view[1]},n._setY=function(t){this._view[1]=t},n._getZ=function(){return this._view[2]},n._setZ=function(t){this._view[2]=t},cc.js.getset(n,"x",n._getX,n._setX),cc.js.getset(n,"y",n._getY,n._setY),cc.js.getset(n,"z",n._getZ,n._setZ),cc.Tex2F=function(t,e,i,n){this._arrayBuffer=i||new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT),this._offset=n||0,this._view=new Float32Array(this._arrayBuffer,this._offset,2),this._view[0]=t||0,this._view[1]=e||0},cc.Tex2F.BYTES_PER_ELEMENT=8,(n=cc.Tex2F.prototype)._getU=function(){return this._view[0]},n._setU=function(t){this._view[0]=t},n._getV=function(){return this._view[1]},n._setV=function(t){this._view[1]=t},cc.js.getset(n,"u",n._getU,n._setU),cc.js.getset(n,"v",n._getV,n._setV),cc.Quad2=function(t,e,i,n,r,s){this._arrayBuffer=r||new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT),this._offset=s||0;var o=this._arrayBuffer,a=this._offset,c=cc.Vertex2F.BYTES_PER_ELEMENT;this._tl=t?new cc.Vertex2F(t.x,t.y,o,a):new cc.Vertex2F(0,0,o,a),a+=c,this._tr=e?new cc.Vertex2F(e.x,e.y,o,a):new cc.Vertex2F(0,0,o,a),a+=c,this._bl=i?new cc.Vertex2F(i.x,i.y,o,a):new cc.Vertex2F(0,0,o,a),a+=c,this._br=n?new cc.Vertex2F(n.x,n.y,o,a):new cc.Vertex2F(0,0,o,a)},cc.Quad2.BYTES_PER_ELEMENT=32,(n=cc.Quad2.prototype)._getTL=function(){return this._tl},n._setTL=function(t){this._tl._view[0]=t.x,this._tl._view[1]=t.y},n._getTR=function(){return this._tr},n._setTR=function(t){this._tr._view[0]=t.x,this._tr._view[1]=t.y},n._getBL=function(){return this._bl},n._setBL=function(t){this._bl._view[0]=t.x,this._bl._view[1]=t.y},n._getBR=function(){return this._br},n._setBR=function(t){this._br._view[0]=t.x,this._br._view[1]=t.y},cc.js.getset(n,"tl",n._getTL,n._setTL),cc.js.getset(n,"tr",n._getTR,n._setTR),cc.js.getset(n,"bl",n._getBL,n._setBL),cc.js.getset(n,"br",n._getBR,n._setBR),cc.Quad3=function(t,e,i,n,r,s){this._arrayBuffer=r||new ArrayBuffer(cc.Quad3.BYTES_PER_ELEMENT),this._offset=s||0;var o=this._arrayBuffer,a=this._offset,c=cc.Vertex3F.BYTES_PER_ELEMENT;this.bl=bl?new cc.Vertex3F(bl.x,bl.y,bl.z,o,a):new cc.Vertex3F(0,0,0,o,a),a+=c,this.br=br?new cc.Vertex3F(br.x,br.y,br.z,o,a):new cc.Vertex3F(0,0,0,o,a),a+=c,this.tl=tl?new cc.Vertex3F(tl.x,tl.y,tl.z,o,a):new cc.Vertex3F(0,0,0,o,a),a+=c,this.tr=tr?new cc.Vertex3F(tr.x,tr.y,tr.z,o,a):new cc.Vertex3F(0,0,0,o,a)},cc.Quad3.BYTES_PER_ELEMENT=48,cc.V3F_C4B_T2F=function(t,e,i,n,r){this._arrayBuffer=n||new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT),this._offset=r||0;var s=this._arrayBuffer,o=this._offset;this._vertices=t?new cc.Vertex3F(t.x,t.y,t.z,s,o):new cc.Vertex3F(0,0,0,s,o),o+=cc.Vertex3F.BYTES_PER_ELEMENT,this._colors=e?new cc.WebGLColor(e.r,e.g,e.b,e.a,s,o):new cc.WebGLColor(0,0,0,0,s,o),o+=cc.WebGLColor.BYTES_PER_ELEMENT,this._texCoords=i?new cc.Tex2F(i.u,i.v,s,o):new cc.Tex2F(0,0,s,o)},cc.V3F_C4B_T2F.BYTES_PER_ELEMENT=24,(n=cc.V3F_C4B_T2F.prototype)._getVertices=function(){return this._vertices},n._setVertices=function(t){var e=this._vertices;e._view[0]=t.x,e._view[1]=t.y,e._view[2]=t.z},n._getColor=function(){return this._colors},n._setColor=function(t){var e=this._colors;e._view[0]=t.r,e._view[1]=t.g,e._view[2]=t.b,e._view[3]=t.a},n._getTexCoords=function(){return this._texCoords},n._setTexCoords=function(t){this._texCoords._view[0]=t.u,this._texCoords._view[1]=t.v},cc.js.getset(n,"vertices",n._getVertices,n._setVertices),cc.js.getset(n,"colors",n._getColor,n._setColor),cc.js.getset(n,"texCoords",n._getTexCoords,n._setTexCoords),cc.V3F_C4B_T2F_Quad=function(t,e,i,n,r,s){this._arrayBuffer=r||new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT),this._offset=s||0;var o=this._arrayBuffer,a=this._offset,c=cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;this._tl=t?new cc.V3F_C4B_T2F(t.vertices,t.colors,t.texCoords,o,a):new cc.V3F_C4B_T2F(null,null,null,o,a),a+=c,this._bl=e?new cc.V3F_C4B_T2F(e.vertices,e.colors,e.texCoords,o,a):new cc.V3F_C4B_T2F(null,null,null,o,a),a+=c,this._tr=i?new cc.V3F_C4B_T2F(i.vertices,i.colors,i.texCoords,o,a):new cc.V3F_C4B_T2F(null,null,null,o,a),a+=c,this._br=n?new cc.V3F_C4B_T2F(n.vertices,n.colors,n.texCoords,o,a):new cc.V3F_C4B_T2F(null,null,null,o,a)},cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT=96,(n=cc.V3F_C4B_T2F_Quad.prototype)._getTL=function(){return this._tl},n._setTL=function(t){var e=this._tl;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},n._getBL=function(){return this._bl},n._setBL=function(t){var e=this._bl;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},n._getTR=function(){return this._tr},n._setTR=function(t){var e=this._tr;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},n._getBR=function(){return this._br},n._setBR=function(t){var e=this._br;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},n._getArrayBuffer=function(){return this._arrayBuffer},cc.js.getset(n,"tl",n._getTL,n._setTL),cc.js.getset(n,"tr",n._getTR,n._setTR),cc.js.getset(n,"bl",n._getBL,n._setBL),cc.js.getset(n,"br",n._getBR,n._setBR),cc.js.get(n,"arrayBuffer",n._getArrayBuffer),cc.V3F_C4B_T2F_QuadZero=function(){return new cc.V3F_C4B_T2F_Quad},cc.V3F_C4B_T2F_QuadCopy=function(t){if(!t)return cc.V3F_C4B_T2F_QuadZero();var e=t.tl,i=t.bl,n=t.tr,r=t.br;return{tl:{vertices:{x:e.vertices.x,y:e.vertices.y,z:e.vertices.z},colors:{r:e.colors.r,g:e.colors.g,b:e.colors.b,a:e.colors.a},texCoords:{u:e.texCoords.u,v:e.texCoords.v}},bl:{vertices:{x:i.vertices.x,y:i.vertices.y,z:i.vertices.z},colors:{r:i.colors.r,g:i.colors.g,b:i.colors.b,a:i.colors.a},texCoords:{u:i.texCoords.u,v:i.texCoords.v}},tr:{vertices:{x:n.vertices.x,y:n.vertices.y,z:n.vertices.z},colors:{r:n.colors.r,g:n.colors.g,b:n.colors.b,a:n.colors.a},texCoords:{u:n.texCoords.u,v:n.texCoords.v}},br:{vertices:{x:r.vertices.x,y:r.vertices.y,z:r.vertices.z},colors:{r:r.colors.r,g:r.colors.g,b:r.colors.b,a:r.colors.a},texCoords:{u:r.texCoords.u,v:r.texCoords.v}}}},cc.V3F_C4B_T2F_QuadsCopy=function(t){if(!t)return[];for(var e=[],i=0;i<t.length;i++)e.push(cc.V3F_C4B_T2F_QuadCopy(t[i]));return e},cc.V2F_C4B_T2F=function(t,e,i,n,r){this._arrayBuffer=n||new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT),this._offset=r||0;var s=this._arrayBuffer,o=this._offset;this._vertices=t?new cc.Vertex2F(t.x,t.y,s,o):new cc.Vertex2F(0,0,s,o),o+=cc.Vertex2F.BYTES_PER_ELEMENT,this._colors=e?new cc.WebGLColor(e.r,e.g,e.b,e.a,s,o):new cc.WebGLColor(0,0,0,0,s,o),o+=cc.WebGLColor.BYTES_PER_ELEMENT,this._texCoords=i?new cc.Tex2F(i.u,i.v,s,o):new cc.Tex2F(0,0,s,o)},cc.V2F_C4B_T2F.BYTES_PER_ELEMENT=20,(n=cc.V2F_C4B_T2F.prototype)._getVertices=function(){return this._vertices},n._setVertices=function(t){this._vertices._view[0]=t.x,this._vertices._view[1]=t.y},n._getColor=function(){return this._colors},n._setColor=function(t){var e=this._colors;e._view[0]=t.r,e._view[1]=t.g,e._view[2]=t.b,e._view[3]=t.a},n._getTexCoords=function(){return this._texCoords},n._setTexCoords=function(t){this._texCoords._view[0]=t.u,this._texCoords._view[1]=t.v},cc.js.getset(n,"vertices",n._getVertices,n._setVertices),cc.js.getset(n,"colors",n._getColor,n._setColor),cc.js.getset(n,"texCoords",n._getTexCoords,n._setTexCoords),cc.V2F_C4B_T2F_Triangle=function(t,e,i,n,r){this._arrayBuffer=n||new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT),this._offset=r||0;var s=this._arrayBuffer,o=this._offset,a=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;this._a=t?new cc.V2F_C4B_T2F(t.vertices,t.colors,t.texCoords,s,o):new cc.V2F_C4B_T2F(null,null,null,s,o),o+=a,this._b=e?new cc.V2F_C4B_T2F(e.vertices,e.colors,e.texCoords,s,o):new cc.V2F_C4B_T2F(null,null,null,s,o),o+=a,this._c=i?new cc.V2F_C4B_T2F(i.vertices,i.colors,i.texCoords,s,o):new cc.V2F_C4B_T2F(null,null,null,s,o)},cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT=60,(n=cc.V2F_C4B_T2F_Triangle.prototype)._getA=function(){return this._a},n._setA=function(t){var e=this._a;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},n._getB=function(){return this._b},n._setB=function(t){var e=this._b;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},n._getC=function(){return this._c},n._setC=function(t){var e=this._c;e.vertices=t.vertices,e.colors=t.colors,e.texCoords=t.texCoords},cc.js.getset(n,"a",n._getA,n._setA),cc.js.getset(n,"b",n._getB,n._setB),cc.js.getset(n,"c",n._getC,n._setC)}),{}],237:[(function(t,e,i){function n(){}var r=t("../platform/js");r.setClassName("cc.ValueType",n);var s=n.prototype;s.toString=function(){return""+{}},cc.ValueType=n,e.exports=n}),{"../platform/js":197}],238:[(function(t,e,i){function n(t,e){t&&"object"==typeof t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0}var r=t("./CCValueType"),s=t("../platform/js"),o=t("../platform/CCClass");s.extend(n,r),o.fastDefine("cc.Vec2",n,{x:0,y:0});var a=n.prototype;a.clone=function(){return new n(this.x,this.y)},a.set=function(t){return this.x=t.x,this.y=t.y,this},a.equals=function(t){return t&&this.x===t.x&&this.y===t.y},a.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+")"},a.lerp=function(t,e,i){i=i||new n;var r=this.x,s=this.y;return i.x=r+(t.x-r)*e,i.y=s+(t.y-s)*e,i},a.addSelf=function(t){return this.x+=t.x,this.y+=t.y,this},a.add=function(t,e){return e=e||new n,e.x=this.x+t.x,e.y=this.y+t.y,e},a.subSelf=function(t){return this.x-=t.x,this.y-=t.y,this},a.sub=function(t,e){return e=e||new n,e.x=this.x-t.x,e.y=this.y-t.y,e},a.mulSelf=function(t){return this.x*=t,this.y*=t,this},a.mul=function(t,e){return e=e||new n,e.x=this.x*t,e.y=this.y*t,e},a.scaleSelf=function(t){return this.x*=t.x,this.y*=t.y,this},a.scale=function(t,e){return e=e||new n,e.x=this.x*t.x,e.y=this.y*t.y,e},a.divSelf=function(t){return this.x/=t,this.y/=t,this},a.div=function(t,e){return e=e||new n,e.x=this.x/t,e.y=this.y/t,e},a.negSelf=function(){return this.x=-this.x,this.y=-this.y,this},a.neg=function(t){return t=t||new n,t.x=-this.x,t.y=-this.y,t},a.dot=function(t){return this.x*t.x+this.y*t.y},a.cross=function(t){return this.y*t.x-this.x*t.y},a.mag=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},a.magSqr=function(){return this.x*this.x+this.y*this.y},a.normalizeSelf=function(){var t=this.x*this.x+this.y*this.y;if(1===t)return this;if(0===t)return console.warn("Can't normalize zero vector"),this;var e=1/Math.sqrt(t);return this.x*=e,this.y*=e,this},a.normalize=function(t){return t=t||new n,t.x=this.x,t.y=this.y,t.normalizeSelf(),t},a.angle=function(t){var e=this.magSqr(),i=t.magSqr();if(0===e||0===i)return console.warn("Can't get angle between zero vector"),0;var n=this.dot(t)/Math.sqrt(e*i);return n=cc.clampf(n,-1,1),Math.acos(n)},a.signAngle=function(t){return Math.atan2(this.y,this.x)-Math.atan2(t.y,t.x)},a.rotate=function(t,e){return e=e||new n,e.x=this.x,e.y=this.y,e.rotateSelf(t)},a.rotateSelf=function(t){var e=Math.sin(t),i=Math.cos(t),n=this.x;return this.x=i*n-e*this.y,this.y=e*n+i*this.y,this},s.get(n,"ONE",(function(){return new n(1,1)})),s.get(n,"ZERO",(function(){return new n(0,0)})),s.get(n,"UP",(function(){return new n(0,1)})),s.get(n,"RIGHT",(function(){return new n(1,0)})),cc.Vec2=n,cc.v2=function(t,e){return new n(t,e)},cc.p=cc.v2,cc.pointEqualToPoint=function(t,e){return t&&e&&t.x===e.x&&t.y===e.y},e.exports=cc.Vec2}),{"../platform/CCClass":176,"../platform/js":197,"./CCValueType":237}],239:[(function(t,e,i){t("./CCValueType"),t("./CCVec2"),t("./CCPointExtension"),t("./CCSize"),t("./CCRect"),t("./CCColor"),t("./CCTypes"),t("./CCAffineTransform"),t("./CCTypesWebGL")}),{"./CCAffineTransform":230,"./CCColor":231,"./CCPointExtension":232,"./CCRect":233,"./CCSize":234,"./CCTypes":235,"./CCTypesWebGL":236,"./CCValueType":237,"./CCVec2":238}],240:[(function(t,e,i){var n=t("../platform/utils"),r=t("../platform/CCSys"),s=t("../event-manager");_ccsg.VideoPlayer=_ccsg.Node.extend({ctor:function(){_ccsg.Node.prototype.ctor.call(this),this._EventList={}},_createRenderCmd:function(){return new _ccsg.VideoPlayer.RenderCmd(this)},setURL:function(t){this._renderCmd.updateURL(t)},getURL:function(){return this._renderCmd._url},play:function(){this._renderCmd.play()},pause:function(){this._renderCmd.pause()},_resume:function(){this._renderCmd.play()},stop:function(){this._renderCmd.stop()},seekTo:function(t){this._renderCmd.seekTo(t)},isPlaying:function(){return this._renderCmd.isPlaying()},duration:function(){return this._renderCmd.duration()},currentTime:function(){return this._renderCmd.currentTime()},createDomElementIfNeeded:function(){this._renderCmd._video||this._renderCmd.createDom()},setKeepAspectRatioEnabled:function(){cc.logID(7700)},isKeepAspectRatioEnabled:function(){return!0},setFullScreenEnabled:function(t){var e=this._renderCmd._video;e&&(t?cc.screen.requestFullScreen(e):cc.screen.exitFullScreen(e))},isFullScreenEnabled:function(){cc.logID(7701)},setEventListener:function(t,e){this._EventList[t]=e},removeEventListener:function(t){this._EventList[t]=null},_dispatchEvent:function(t){var e=this._EventList[t];e&&e.call(this,this,this._renderCmd._video.src)},onPlayEvent:function(){this._EventList[_ccsg.VideoPlayer.EventType.PLAYING].call(this,this,this._renderCmd._video.src)},setContentSize:function(t,e){void 0!==t.width&&void 0!==t.height&&(e=t.height,t=t.width),_ccsg.Node.prototype.setContentSize.call(this,t,e),this._renderCmd.updateSize(t,e)},onEnter:function(){_ccsg.Node.prototype.onEnter.call(this);var t=_ccsg.VideoPlayer.elements;-1===t.indexOf(this)&&t.push(this)},cleanup:function(){this._super(),this._renderCmd.removeDom()},onExit:function(){_ccsg.Node.prototype.onExit.call(this);var t=_ccsg.VideoPlayer.elements,e=t.indexOf(this);-1!==e&&t.splice(e,1)},setVisible:function(t){_ccsg.Node.prototype.setVisible.call(this,t),this._renderCmd.updateVisibility()}}),_ccsg.VideoPlayer.elements=[],_ccsg.VideoPlayer.pauseElements=[],s.addCustomListener(cc.game.EVENT_HIDE,(function(){for(var t,e=_ccsg.VideoPlayer.elements,i=0;i<e.length;i++)t=e[i],e[i]._playing&&(t.pause(),_ccsg.VideoPlayer.pauseElements.push(t))})),cc.game.on(cc.game.EVENT_SHOW,(function(){for(var t=_ccsg.VideoPlayer.pauseElements,e=t.pop();e;)e.play(),e=t.pop()})),_ccsg.VideoPlayer.EventType={PLAYING:0,PAUSED:1,STOPPED:2,COMPLETED:3,META_LOADED:4,CLICKED:5,READY_TO_PLAY:6},(function(t){t._polyfill={devicePixelRatio:!1,event:"canplay",canPlayType:[]},(function(){var e=document.createElement("video");r.platform!==r.WECHAT_GAME&&r.platform!==r.QQ_PLAY&&(e.canPlayType("video/ogg")&&(t._polyfill.canPlayType.push(".ogg"),t._polyfill.canPlayType.push(".ogv")),e.canPlayType("video/mp4")&&t._polyfill.canPlayType.push(".mp4"),e.canPlayType("video/webm")&&t._polyfill.canPlayType.push(".webm"))})(),cc.sys.browserType===cc.sys.BROWSER_TYPE_FIREFOX&&(t._polyfill.autoplayAfterOperation=!0),cc.sys.OS_ANDROID!==cc.sys.os||cc.sys.browserType!==cc.sys.BROWSER_TYPE_SOUGOU&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_360||(t._polyfill.zoomInvalid=!0);var e=document.createElement("style");e.innerHTML=".cocosVideo:-moz-full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:full-screen{transform:matrix(1,0,0,1,0,0) !important;}.cocosVideo:-webkit-full-screen{transform:matrix(1,0,0,1,0,0) !important;}",document.head.appendChild(e)})(_ccsg.VideoPlayer),(function(t){_ccsg.VideoPlayer.RenderCmd=function(t){this._rootCtor(t),this._video=null,this._url="",this._played=!1,this._playing=!1,this._ignorePause=!1};var e=_ccsg.VideoPlayer.RenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);e.constructor=_ccsg.VideoPlayer.RenderCmd,e.transform=function(t,e){this.originTransform(t,e),this.updateMatrix()},e.updateMatrix=function(){if(this._video){var e=this._node,i=cc.view._scaleX,n=cc.view._scaleY,r=cc.view._devicePixelRatio,s=this._worldTransform;i/=r,n/=r;var o=cc.game.container,a=s.a*i,c=s.b,h=s.c,l=s.d*n,u=o&&o.style.paddingLeft&&parseInt(o.style.paddingLeft),_=o&&o.style.paddingBottom&&parseInt(o.style.paddingBottom),d=s.tx*i+u,f=s.ty*n+_;t.zoomInvalid&&(this.updateSize(e._contentSize.width*a,e._contentSize.height*l),a=1,l=1);var p="matrix("+a+","+-c+","+-h+","+l+","+d+","+-f+")";this._video.style.transform=p,this._video.style["-webkit-transform"]=p,this._video.style["transform-origin"]="0px 100% 0px",this._video.style["-webkit-transform-origin"]="0px 100% 0px"}},e.updateURL=function(e){cc.loader.md5Pipe&&(e=cc.loader.md5Pipe.transformURL(e));var i,n,r,s=this._node;if(this._url!=e){this._url=e,cc.loader.resPath&&!/^http/.test(e)&&(e=cc.path.join(cc.loader.resPath,e)),this.removeDom(),this.createDom(),this.bindEvent(),n=this._video;var o=function(){1!=this._loaded&&(this._loaded=!0,s.setContentSize(s._contentSize.width,s._contentSize.height),n.currentTime=0,s._dispatchEvent(_ccsg.VideoPlayer.EventType.READY_TO_PLAY),this.updateVisibility(),this.updateMatrix())}.bind(this);n.oncanplay=o,n.style.visibility="hidden",this._loaded=!1,this._played=!1,this._playing=!1,(i=document.createElement("source")).src=e,n.appendChild(i),r=cc.path.extname(e);for(var a=0;a<t.canPlayType.length;a++)r!==t.canPlayType[a]&&((i=document.createElement("source")).src=e.replace(r,t.canPlayType[a]),n.appendChild(i))}},e.bindEvent=function(){var t=this._node,e=this._video,i=this;e.onloadedmetadata=function(){t._dispatchEvent(_ccsg.VideoPlayer.EventType.META_LOADED)},e.addEventListener("ended",function(){i._video===e&&(this._playing=!1,t._dispatchEvent(_ccsg.VideoPlayer.EventType.COMPLETED))}.bind(this)),e.addEventListener("play",(function(){i._video===e&&t._dispatchEvent(_ccsg.VideoPlayer.EventType.PLAYING)})),e.addEventListener("pause",(function(){i._ignorePause||i._video!==e||t._dispatchEvent(_ccsg.VideoPlayer.EventType.PAUSED)})),e.addEventListener("click",(function(){t._dispatchEvent(_ccsg.VideoPlayer.EventType.CLICKED)}))},e.updateVisibility=function(){var t=this._node;if(this._video){var e=this._video;t.visible?e.style.visibility="visible":(e.style.visibility="hidden",e.pause(),this._playing=!1)}},e.createDom=function(){var t=document.createElement("video");t.style.position="absolute",t.style.bottom="0px",t.style.left="0px",t.className="cocosVideo",t.setAttribute("preload",!0),t.setAttribute("webkit-playsinline",""),t.setAttribute("playsinline",""),this._video=t,cc.game.container.appendChild(t)},e.removeDom=function(){var t=this._video;if(t){n.contains(cc.game.container,t)&&cc.game.container.removeChild(t)}this._video=null,this._url=""},e.updateSize=function(t,e){var i=this._video;i&&(i.style.width=t+"px",i.style.height=e+"px")},e.play=function(){var t=this._video;if(t&&this._node.isVisible()&&(this._played=!0,!this._playing))if(_ccsg.VideoPlayer._polyfill.autoplayAfterOperation){var e=this;setTimeout((function(){t.play(),e._playing=!0}),20)}else t.play(),this._playing=!0},e.pause=function(){var t=this._video;this._playing&&(this._playing=!1,t&&t.pause())},e.stop=function(){var t=this._video;if(t&&this._node.isVisible()){this._ignorePause=!0,t.pause();var e=this._node;setTimeout(function(){e._dispatchEvent(_ccsg.VideoPlayer.EventType.STOPPED),this._ignorePause=!1}.bind(this),0),t.currentTime=0,this._playing=!1}},e.seekTo=function(e){var i=this._video;if(i){if(this._loaded)i.currentTime=e;else{var n=function(){i.currentTime=e,i.removeEventListener(t.event,n)};i.addEventListener(t.event,n)}_ccsg.VideoPlayer._polyfill.autoplayAfterOperation&&this.isPlaying()&&setTimeout((function(){i.play()}),20)}},e.isPlaying=function(){var t=this._video;return _ccsg.VideoPlayer._polyfill.autoplayAfterOperation&&this._playing&&setTimeout((function(){t.play()}),20),this._playing},e.duration=function(){var t=this._video,e=-1;return t?((e=t.duration)<=0&&cc.logID(7702),e):e},e.currentTime=function(){var t=this._video;return t?t.currentTime:-1}})(_ccsg.VideoPlayer._polyfill)}),{"../event-manager":110,"../platform/CCSys":185,"../platform/utils":201}],241:[(function(t,e,i){var n=t("../platform/utils"),r=t("../event-manager");_ccsg.WebView=_ccsg.Node.extend({ctor:function(){_ccsg.Node.prototype.ctor.call(this),this.setContentSize(cc.size(300,200)),this._EventList={}},createDomElementIfNeeded:function(){this._renderCmd._div||this._renderCmd.createNativeControl()},setOnJSCallback:function(t){},setJavascriptInterfaceScheme:function(t){},loadData:function(t,e,i,n){},loadHTMLString:function(t,e){},loadURL:function(t){this._renderCmd.updateURL(t),this._dispatchEvent(_ccsg.WebView.EventType.LOADING)},stopLoading:function(){cc.logID(7800)},reload:function(){var t=this._renderCmd._iframe;if(t){var e=t.contentWindow;e&&e.location&&e.location.reload()}},canGoBack:function(){return cc.logID(7801),!0},canGoForward:function(){return cc.logID(7802),!0},goBack:function(){try{if(_ccsg.WebView._polyfill.closeHistory)return cc.logID(7803);var t=this._renderCmd._iframe;if(t){var e=t.contentWindow;e&&e.location&&e.history.back.call(e)}}catch(t){cc.log(t)}},goForward:function(){try{if(_ccsg.WebView._polyfill.closeHistory)return cc.logID(7804);var t=this._renderCmd._iframe;if(t){var e=t.contentWindow;e&&e.location&&e.history.forward.call(e)}}catch(t){cc.log(t)}},evaluateJS:function(t){var e=this._renderCmd._iframe;if(e){var i=e.contentWindow;try{i.eval(t),this._dispatchEvent(_ccsg.WebView.EventType.JS_EVALUATED)}catch(t){console.error(t)}}},setScalesPageToFit:function(){cc.logID(7805)},setEventListener:function(t,e){this._EventList[t]=e},removeEventListener:function(t){this._EventList[t]=null},_dispatchEvent:function(t){var e=this._EventList[t];e&&e.call(this,this,this._renderCmd._iframe.src)},_createRenderCmd:function(){return new _ccsg.WebView.RenderCmd(this)},setContentSize:function(t,e){void 0!==t.width&&void 0!==t.height&&(e=t.height,t=t.width),_ccsg.Node.prototype.setContentSize.call(this,t,e),this._renderCmd.updateSize(t,e)},cleanup:function(){this._super(),this._renderCmd.removeDom()},setVisible:function(t){_ccsg.Node.prototype.setVisible.call(this,t),this._renderCmd.updateVisibility()}}),_ccsg.WebView.EventType={LOADING:0,LOADED:1,ERROR:2,JS_EVALUATED:3},(function(){var t=_ccsg.WebView._polyfill={devicePixelRatio:!1,enableDiv:!1};cc.sys.os===cc.sys.OS_IOS&&(t.enableDiv=!0),cc.sys.isMobile?cc.sys.browserType===cc.sys.BROWSER_TYPE_FIREFOX&&(t.enableBG=!0):cc.sys.browserType===cc.sys.BROWSER_TYPE_IE&&(t.closeHistory=!0)})(),(function(t){var e;e=cc._renderType===cc.game.RENDER_TYPE_CANVAS?_ccsg.Node.CanvasRenderCmd:_ccsg.Node.WebGLRenderCmd,_ccsg.WebView.RenderCmd=function(t){this._rootCtor(t),this._parent=null,this._div=null,this._iframe=null,this._listener=null};var i=_ccsg.WebView.RenderCmd.prototype=Object.create(e.prototype);i.constructor=_ccsg.WebView.RenderCmd,i.transform=function(t,e){this.originTransform(t,e),this.updateMatrix()},i.updateStatus=function(){t.devicePixelRatio=cc.view.isRetinaEnabled();var e=_ccsg.Node._dirtyFlags;this._dirtyFlag&e.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this.updateMatrix(),this._dirtyFlag&=~_ccsg.Node._dirtyFlags.transformDirty)},i.initEvent=function(){var t=this._node;this._iframe.addEventListener("load",(function(){t._dispatchEvent(_ccsg.WebView.EventType.LOADED)})),this._iframe.addEventListener("error",(function(){t._dispatchEvent(_ccsg.WebView.EventType.ERROR)}))},i.resize=function(t){t=t||cc.view;var e=this._node;if(e._parent&&e._visible)this.updateMatrix();else{var i=r._listenersMap[cc.game.EVENT_RESIZE].getFixedPriorityListeners();r._removeListenerInVector(i,this._listener),this._listener=null}},i.updateMatrix=function(){if(this._div){this._node;var t=cc.view._scaleX,e=cc.view._scaleY,i=cc.view._devicePixelRatio,n=this._worldTransform;t/=i,e/=i;var r=cc.game.container,s=n.a*t,o=n.b,a=n.c,c=n.d*e,h=r&&r.style.paddingLeft&&parseInt(r.style.paddingLeft),l=r&&r.style.paddingBottom&&parseInt(r.style.paddingBottom),u="matrix("+s+","+-o+","+-a+","+c+","+(n.tx*t+h)+","+-(n.ty*e+l)+")";this._div.style.transform=u,this._div.style["-webkit-transform"]=u,this._div.style["transform-origin"]="0px 100% 0px",this._div.style["-webkit-transform-origin"]="0px 100% 0px"}},i.initStyle=function(){if(this._div){var t=this._div;t.style.position="absolute",t.style.bottom="0px",t.style.left="0px"}},i.updateURL=function(t){var e=this._iframe;e.src=t;var i=this,n=function(){i._loaded=!0,i.updateVisibility(),e.removeEventListener("load",n)};e.addEventListener("load",n)},i.updateSize=function(t,e){var i=this._div;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.createDom=function(){t.enableDiv?(this._div=document.createElement("div"),this._div.style["-webkit-overflow"]="auto",this._div.style["-webkit-overflow-scrolling"]="touch",this._iframe=document.createElement("iframe"),this._div.appendChild(this._iframe),this._iframe.style.width="100%",this._iframe.style.height="100%"):this._div=this._iframe=document.createElement("iframe"),t.enableBG&&(this._div.style.background="#FFF"),this._div.style.background="#FFF";var e=this._node._contentSize;this._div.style.height=e.height+"px",this._div.style.width=e.width+"px",this._div.style.overflow="scroll",this._iframe.style.border="none",cc.game.container.appendChild(this._div),this.updateVisibility()},i.createNativeControl=function(){this.createDom(),this.initStyle(),this.initEvent()},i.removeDom=function(){var t=this._div;if(t){n.contains(cc.game.container,t)&&cc.game.container.removeChild(t)}this._div=null},i.updateVisibility=function(){var t=this._node;if(this._div){var e=this._div;t.visible?e.style.visibility="visible":e.style.visibility="hidden"}}})(_ccsg.WebView._polyfill)}),{"../event-manager":110,"../platform/utils":201}],242:[(function(t,e,i){cc.js}),{}],243:[(function(t,e,i){t("./core/CCGame"),t("./actions"),t("./core/base-nodes/CCSGNode"),t("./core/base-nodes/CCSGNodeBaseRenderCmd"),t("./core/base-nodes/CCSGNodeCanvasRenderCmd"),t("./core/base-nodes/CCSGNodeWebGLRenderCmd"),t("./core/scenes/CCSGScene"),t("./core/CCConfiguration"),t("./core/sprites/CCSGSprite"),t("./core/sprites/CCSGSpriteCanvasRenderCmd"),t("./core/sprites/CCSGSpriteWebGLRenderCmd"),t("./core/sprites/CCScale9Sprite"),t("./core/sprites/CCScale9SpriteCanvasRenderCmd"),t("./core/sprites/CCScale9SpriteWebGLRenderCmd"),t("./core/sprites/CCSpriteBatchNode"),t("./render-texture/CCRenderTexture"),t("./render-texture/CCRenderTextureCanvasRenderCmd"),t("./render-texture/CCRenderTextureWebGLRenderCmd")}),{"./actions":10,"./core/CCConfiguration":32,"./core/CCGame":39,"./core/base-nodes/CCSGNode":55,"./core/base-nodes/CCSGNodeBaseRenderCmd":56,"./core/base-nodes/CCSGNodeCanvasRenderCmd":57,"./core/base-nodes/CCSGNodeWebGLRenderCmd":58,"./core/scenes/CCSGScene":207,"./core/sprites/CCSGSprite":208,"./core/sprites/CCSGSpriteCanvasRenderCmd":209,"./core/sprites/CCSGSpriteWebGLRenderCmd":210,"./core/sprites/CCScale9Sprite":211,"./core/sprites/CCScale9SpriteCanvasRenderCmd":212,"./core/sprites/CCScale9SpriteWebGLRenderCmd":213,"./core/sprites/CCSpriteBatchNode":214,"./render-texture/CCRenderTexture":267,"./render-texture/CCRenderTextureCanvasRenderCmd":268,"./render-texture/CCRenderTextureWebGLRenderCmd":269}],244:[(function(t,e,i){cc.math.AABB=function(t,e){this.min=t||new cc.math.Vec3,this.max=e||new cc.math.Vec3},cc.math.AABB.prototype.containsPoint=function(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z},cc.math.AABB.containsPoint=function(t,e){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y&&t.z>=e.min.z&&t.z<=e.max.z},cc.math.AABB.prototype.assignFrom=function(t){this.min.assignFrom(t.min),this.max.assignFrom(t.max)},cc.math.AABB.assign=function(t,e){return t.min.assignFrom(e.min),t.max.assignFrom(e.max),t}}),{}],245:[(function(t,e,i){cc.math.Matrix4Stack=function(t,e){this.top=t,this.stack=e||[],this.lastUpdated=0};var n=cc.math.Matrix4Stack.prototype;n.initialize=function(){this.stack.length=0,this.top=null},n.push=function(t){t=t||this.top,this.stack.push(this.top),this.top=new cc.math.Matrix4(t),this.update()},n.pop=function(){this.top=this.stack.pop(),this.update()},n.update=function(){this.lastUpdated++},n.release=function(){this.stack=null,this.top=null,this._matrixPool=null},n._getFromPool=function(t){var e=this._matrixPool;if(0===e.length)return new cc.math.Matrix4(t);var i=e.pop();return i.assignFrom(t),i},n._putInPool=function(t){this._matrixPool.push(t)}}),{}],246:[(function(t,e,i){var n=cc.math;n.KM_GL_MODELVIEW=5888,n.KM_GL_PROJECTION=5889,n.KM_GL_TEXTURE=5890,n.modelview_matrix_stack=new n.Matrix4Stack,n.projection_matrix_stack=new n.Matrix4Stack,n.texture_matrix_stack=new n.Matrix4Stack,cc.current_stack=null;var r=!1;(function(){if(!r){var t=new n.Matrix4;n.modelview_matrix_stack.initialize(),n.projection_matrix_stack.initialize(),n.texture_matrix_stack.initialize(),cc.current_stack=n.modelview_matrix_stack,r=!0,t.identity(),n.modelview_matrix_stack.push(t),n.projection_matrix_stack.push(t),n.texture_matrix_stack.push(t)}})(),n.glFreeAll=function(){n.modelview_matrix_stack.release(),n.modelview_matrix_stack=null,n.projection_matrix_stack.release(),n.projection_matrix_stack=null,n.texture_matrix_stack.release(),n.texture_matrix_stack=null,r=!1,cc.current_stack=null},n.glPushMatrix=function(){cc.current_stack.push(cc.current_stack.top),cc.current_stack.update()},n.glPushMatrixWitMat4=function(t){cc.current_stack.stack.push(cc.current_stack.top),t.assignFrom(cc.current_stack.top),cc.current_stack.top=t,cc.current_stack.update()},n.glPopMatrix=function(){cc.current_stack.top=cc.current_stack.stack.pop(),cc.current_stack.update()},n.glMatrixMode=function(t){switch(t){case n.KM_GL_MODELVIEW:cc.current_stack=n.modelview_matrix_stack;break;case n.KM_GL_PROJECTION:cc.current_stack=n.projection_matrix_stack;break;case n.KM_GL_TEXTURE:cc.current_stack=n.texture_matrix_stack;break;default:throw new Error("Invalid matrix mode specified")}},n.glLoadIdentity=function(){cc.current_stack.top.identity(),cc.current_stack.update()},n.glLoadMatrix=function(t){cc.current_stack.top.assignFrom(t),cc.current_stack.update()},n.glMultMatrix=function(t){cc.current_stack.top.multiply(t),cc.current_stack.update()};var s=new n.Matrix4;n.glTranslatef=function(t,e,i){var r=n.Matrix4.createByTranslation(t,e,i,s);cc.current_stack.top.multiply(r),cc.current_stack.update()};var o=new n.Vec3;n.glRotatef=function(t,e,i,r){o.fill(e,i,r);var a=n.Matrix4.createByAxisAndAngle(o,cc.degreesToRadians(t),s);cc.current_stack.top.multiply(a),cc.current_stack.update()},n.glScalef=function(t,e,i){var r=n.Matrix4.createByScale(t,e,i,s);cc.current_stack.top.multiply(r),cc.current_stack.update()},n.glGetMatrix=function(t,e){switch(t){case n.KM_GL_MODELVIEW:e.assignFrom(n.modelview_matrix_stack.top);break;case n.KM_GL_PROJECTION:e.assignFrom(n.projection_matrix_stack.top);break;case n.KM_GL_TEXTURE:e.assignFrom(n.texture_matrix_stack.top);break;default:throw new Error("Invalid matrix mode specified")}}}),{}],247:[(function(t,e,i){t("./utility"),t("./vec2"),t("./vec3"),t("./vec4"),t("./ray2"),t("./mat3"),t("./mat4"),t("./plane"),t("./quaternion"),t("./aabb"),t("./gl/mat4stack"),t("./gl/matrix")}),{"./aabb":244,"./gl/mat4stack":245,"./gl/matrix":246,"./mat3":248,"./mat4":249,"./plane":250,"./quaternion":251,"./ray2":252,"./utility":253,"./vec2":254,"./vec3":255,"./vec4":256}],248:[(function(t,e,i){window.Uint16Array=window.Uint16Array||window.Array,window.Float32Array=window.Float32Array||window.Array,cc.math.Matrix3=function(t){t&&t.mat?this.mat=new Float32Array(t.mat):this.mat=new Float32Array(9)};var n=cc.math.Matrix3.prototype;n.fill=function(t){var e=this.mat,i=t.mat;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},n.adjugate=function(){var t=this.mat,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return t[0]=s*h-o*c,t[1]=n*c-i*h,t[2]=i*o-n*s,t[3]=o*a-r*h,t[4]=e*h-n*a,t[5]=n*r-e*o,t[6]=r*c-s*a,t[8]=e*s-i*r,this},n.identity=function(){var t=this.mat;return t[1]=t[2]=t[3]=t[5]=t[6]=t[7]=0,t[0]=t[4]=t[8]=1,this};var r=new cc.math.Matrix3;n.inverse=function(t){if(0===t)return this;r.assignFrom(this);var e=1/t;return this.adjugate(),this.multiplyScalar(e),this},n.isIdentity=function(){var t=this.mat;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]},n.transpose=function(){var t=this.mat,e=t[1],i=t[2],n=t[3],r=t[5],s=t[6],o=t[7];return t[1]=n,t[2]=s,t[3]=e,t[5]=o,t[6]=i,t[7]=r,this},n.determinant=function(){var t=this.mat,e=t[0]*t[4]*t[8]+t[1]*t[5]*t[6]+t[2]*t[3]*t[7];return e-=t[2]*t[4]*t[6]+t[0]*t[5]*t[7]+t[1]*t[3]*t[8]},n.multiply=function(t){var e=this.mat,i=t.mat,n=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],h=e[6],l=e[7],u=e[8],_=i[0],d=i[1],f=i[2],p=i[3],m=i[4],g=i[5],y=i[6],v=i[7],x=i[8];return e[0]=n*_+o*d+h*f,e[1]=r*_+a*d+l*f,e[2]=s*_+c*d+u*f,e[3]=s*_+c*d+u*f,e[4]=r*p+a*m+l*g,e[5]=s*p+c*m+u*g,e[6]=n*y+o*v+h*x,e[7]=r*y+a*v+l*x,e[8]=s*y+c*v+u*x,this},n.multiplyScalar=function(t){var e=this.mat;return e[0]*=t,e[1]*=t,e[2]*=t,e[3]*=t,e[4]*=t,e[5]*=t,e[6]*=t,e[7]*=t,e[8]*=t,this},cc.math.Matrix3.rotationAxisAngle=function(t,e){var i=Math.cos(e),n=Math.sin(e),r=new cc.math.Matrix3,s=r.mat;return s[0]=i+t.x*t.x*(1-i),s[1]=t.z*n+t.y*t.x*(1-i),s[2]=-t.y*n+t.z*t.x*(1-i),s[3]=-t.z*n+t.x*t.y*(1-i),s[4]=i+t.y*t.y*(1-i),s[5]=t.x*n+t.z*t.y*(1-i),s[6]=t.y*n+t.x*t.z*(1-i),s[7]=-t.x*n+t.y*t.z*(1-i),s[8]=i+t.z*t.z*(1-i),r},n.assignFrom=function(t){if(this===t)return cc.logID(7900),this;var e=this.mat,i=t.mat;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},n.equals=function(t){if(this===t)return!0;for(var e=cc.math.EPSILON,i=this.mat,n=t.mat,r=0;r<9;++r)if(!(i[r]+e>n[r]&&i[r]-e<n[r]))return!1;return!0},cc.math.Matrix3.createByRotationX=function(t){var e=new cc.math.Matrix3,i=e.mat;return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=Math.cos(t),i[5]=Math.sin(t),i[6]=0,i[7]=-Math.sin(t),i[8]=Math.cos(t),e},cc.math.Matrix3.createByRotationY=function(t){var e=new cc.math.Matrix3,i=e.mat;return i[0]=Math.cos(t),i[1]=0,i[2]=-Math.sin(t),i[3]=0,i[4]=1,i[5]=0,i[6]=Math.sin(t),i[7]=0,i[8]=Math.cos(t),e},cc.math.Matrix3.createByRotationZ=function(t){var e=new cc.math.Matrix3,i=e.mat;return i[0]=Math.cos(t),i[1]=-Math.sin(t),i[2]=0,i[3]=Math.sin(t),i[4]=Math.cos(t),i[5]=0,i[6]=0,i[7]=0,i[8]=1,e},cc.math.Matrix3.createByRotation=function(t){var e=new cc.math.Matrix3,i=e.mat;return i[0]=Math.cos(t),i[1]=Math.sin(t),i[2]=0,i[3]=-Math.sin(t),i[4]=Math.cos(t),i[5]=0,i[6]=0,i[7]=0,i[8]=1,e},cc.math.Matrix3.createByScale=function(t,e){var i=new cc.math.Matrix3;return i.identity(),i.mat[0]=t,i.mat[4]=e,i},cc.math.Matrix3.createByTranslation=function(t,e){var i=new cc.math.Matrix3;return i.identity(),i.mat[6]=t,i.mat[7]=e,i},cc.math.Matrix3.createByQuaternion=function(t){if(!t)return null;var e=new cc.math.Matrix3,i=e.mat;return i[0]=1-2*(t.y*t.y+t.z*t.z),i[1]=2*(t.x*t.y-t.w*t.z),i[2]=2*(t.x*t.z+t.w*t.y),i[3]=2*(t.x*t.y+t.w*t.z),i[4]=1-2*(t.x*t.x+t.z*t.z),i[5]=2*(t.y*t.z-t.w*t.x),i[6]=2*(t.x*t.z-t.w*t.y),i[7]=2*(t.y*t.z+t.w*t.x),i[8]=1-2*(t.x*t.x+t.y*t.y),e},n.rotationToAxisAngle=function(){return cc.math.Quaternion.rotationMatrix(this).toAxisAndAngle()}}),{}],249:[(function(t,e,i){cc.math.Matrix4=function(t){t&&t.mat?this.mat=new Float32Array(t.mat):this.mat=new Float32Array(16)};var n=cc.math.Matrix4.prototype;n.fill=function(t){for(var e=this.mat,i=0;i<16;i++)e[i]=t[i];return this},cc.math.mat4Identity=function(t){var e=t.mat;return e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1,t},n.identity=function(){var t=this.mat;return t[1]=t[2]=t[3]=t[4]=t[6]=t[7]=t[8]=t[9]=t[11]=t[12]=t[13]=t[14]=0,t[0]=t[5]=t[10]=t[15]=1,this},n.get=function(t,e){return this.mat[t+4*e]},n.set=function(t,e,i){this.mat[t+4*e]=i},n.swap=function(t,e,i,n){var r=this.mat,s=r[t+4*e];r[t+4*e]=r[i+4*n],r[i+4*n]=s},cc.math.Matrix4._gaussj=function(t,e){var i,n,r,s,o,a,c,h,l,u=0,_=0,d=[0,0,0,0],f=[0,0,0,0],p=[0,0,0,0];for(i=0;i<4;i++){for(c=0,n=0;n<4;n++)if(1!==p[n])for(r=0;r<4;r++)0===p[r]&&(a=Math.abs(t.get(n,r)))>=c&&(c=a,_=n,u=r);if(++p[u],_!==u){for(s=0;s<4;s++)t.swap(_,s,u,s);for(s=0;s<4;s++)e.swap(_,s,u,s)}if(f[i]=_,d[i]=u,0===t.get(u,u))return!1;for(l=1/t.get(u,u),t.set(u,u,1),s=0;s<4;s++)t.set(u,s,t.get(u,s)*l);for(s=0;s<4;s++)e.set(u,s,e.get(u,s)*l);for(o=0;o<4;o++)if(o!==u){for(h=t.get(o,u),t.set(o,u,0),s=0;s<4;s++)t.set(o,s,t.get(o,s)-t.get(u,s)*h);for(s=0;s<4;s++)e.set(o,s,t.get(o,s)-e.get(u,s)*h)}}for(s=3;s>=0;s--)if(f[s]!==d[s])for(r=0;r<4;r++)t.swap(r,f[s],r,d[s]);return!0};var r=(new cc.math.Matrix4).identity();cc.math.mat4Inverse=function(t,e){var i=new cc.math.Matrix4(e),n=new cc.math.Matrix4(r);return!1===cc.math.Matrix4._gaussj(i,n)?null:(t.assignFrom(i),t)},n.inverse=function(){var t=new cc.math.Matrix4(this),e=new cc.math.Matrix4(r);return!1===cc.math.Matrix4._gaussj(t,e)?null:t},n.isIdentity=function(){var t=this.mat;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]},n.transpose=function(){var t=this.mat,e=t[1],i=t[2],n=t[3],r=t[4],s=t[6],o=t[7],a=t[8],c=t[9],h=t[11],l=t[12],u=t[13],_=t[14];return t[1]=r,t[2]=a,t[3]=l,t[4]=e,t[6]=c,t[7]=u,t[8]=i,t[9]=s,t[11]=_,t[12]=n,t[13]=o,t[14]=h,this},cc.math.mat4Multiply=function(t,e,i){var n=t.mat,r=e.mat,s=i.mat,o=r[0],a=r[1],c=r[2],h=r[3],l=r[4],u=r[5],_=r[6],d=r[7],f=r[8],p=r[9],m=r[10],g=r[11],y=r[12],v=r[13],x=r[14],C=r[15],T=s[0],b=s[1],A=s[2],S=s[3],w=s[4],E=s[5],I=s[6],R=s[7],P=s[8],O=s[9],B=s[10],D=s[11],M=s[12],L=s[13],N=s[14],F=s[15];return n[0]=T*o+b*l+A*f+S*y,n[1]=T*a+b*u+A*p+S*v,n[2]=T*c+b*_+A*m+S*x,n[3]=T*h+b*d+A*g+S*C,n[4]=w*o+E*l+I*f+R*y,n[5]=w*a+E*u+I*p+R*v,n[6]=w*c+E*_+I*m+R*x,n[7]=w*h+E*d+I*g+R*C,n[8]=P*o+O*l+B*f+D*y,n[9]=P*a+O*u+B*p+D*v,n[10]=P*c+O*_+B*m+D*x,n[11]=P*h+O*d+B*g+D*C,n[12]=M*o+L*l+N*f+F*y,n[13]=M*a+L*u+N*p+F*v,n[14]=M*c+L*_+N*m+F*x,n[15]=M*h+L*d+N*g+F*C,t},n.multiply=function(t){var e=this.mat,i=t.mat,n=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],h=e[6],l=e[7],u=e[8],_=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],y=e[15],v=i[0],x=i[1],C=i[2],T=i[3],b=i[4],A=i[5],S=i[6],w=i[7],E=i[8],I=i[9],R=i[10],P=i[11],O=i[12],B=i[13],D=i[14],M=i[15];return e[0]=v*n+x*a+C*u+T*p,e[1]=v*r+x*c+C*_+T*m,e[2]=v*s+x*h+C*d+T*g,e[3]=v*o+x*l+C*f+T*y,e[4]=b*n+A*a+S*u+w*p,e[5]=b*r+A*c+S*_+w*m,e[6]=b*s+A*h+S*d+w*g,e[7]=b*o+A*l+S*f+w*y,e[8]=E*n+I*a+R*u+P*p,e[9]=E*r+I*c+R*_+P*m,e[10]=E*s+I*h+R*d+P*g,e[11]=E*o+I*l+R*f+P*y,e[12]=O*n+B*a+D*u+M*p,e[13]=O*r+B*c+D*_+M*m,e[14]=O*s+B*h+D*d+M*g,e[15]=O*o+B*l+D*f+M*y,this},cc.math.getMat4MultiplyValue=function(t,e){var i=t.mat,n=e.mat,r=new Float32Array(16);return r[0]=i[0]*n[0]+i[4]*n[1]+i[8]*n[2]+i[12]*n[3],r[1]=i[1]*n[0]+i[5]*n[1]+i[9]*n[2]+i[13]*n[3],r[2]=i[2]*n[0]+i[6]*n[1]+i[10]*n[2]+i[14]*n[3],r[3]=i[3]*n[0]+i[7]*n[1]+i[11]*n[2]+i[15]*n[3],r[4]=i[0]*n[4]+i[4]*n[5]+i[8]*n[6]+i[12]*n[7],r[5]=i[1]*n[4]+i[5]*n[5]+i[9]*n[6]+i[13]*n[7],r[6]=i[2]*n[4]+i[6]*n[5]+i[10]*n[6]+i[14]*n[7],r[7]=i[3]*n[4]+i[7]*n[5]+i[11]*n[6]+i[15]*n[7],r[8]=i[0]*n[8]+i[4]*n[9]+i[8]*n[10]+i[12]*n[11],r[9]=i[1]*n[8]+i[5]*n[9]+i[9]*n[10]+i[13]*n[11],r[10]=i[2]*n[8]+i[6]*n[9]+i[10]*n[10]+i[14]*n[11],r[11]=i[3]*n[8]+i[7]*n[9]+i[11]*n[10]+i[15]*n[11],r[12]=i[0]*n[12]+i[4]*n[13]+i[8]*n[14]+i[12]*n[15],r[13]=i[1]*n[12]+i[5]*n[13]+i[9]*n[14]+i[13]*n[15],r[14]=i[2]*n[12]+i[6]*n[13]+i[10]*n[14]+i[14]*n[15],r[15]=i[3]*n[12]+i[7]*n[13]+i[11]*n[14]+i[15]*n[15],r},cc.math.mat4Assign=function(t,e){if(t===e)return cc.logID(7901),t;var i=t.mat,n=e.mat;return i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],i[9]=n[9],i[10]=n[10],i[11]=n[11],i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15],t},n.assignFrom=function(t){if(this===t)return cc.logID(7902),this;var e=this.mat,i=t.mat;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},n.equals=function(t){if(this===t)return cc.logID(7903),!0;for(var e=this.mat,i=t.mat,n=cc.math.EPSILON,r=0;r<16;r++)if(!(e[r]+n>i[r]&&e[r]-n<i[r]))return!1;return!0},cc.math.Matrix4.createByRotationX=function(t,e){var i=(e=e||new cc.math.Matrix4).mat;return i[0]=1,i[3]=i[2]=i[1]=0,i[4]=0,i[5]=Math.cos(t),i[6]=Math.sin(t),i[7]=0,i[8]=0,i[9]=-Math.sin(t),i[10]=Math.cos(t),i[11]=0,i[14]=i[13]=i[12]=0,i[15]=1,e},cc.math.Matrix4.createByRotationY=function(t,e){var i=(e=e||new cc.math.Matrix4).mat;return i[0]=Math.cos(t),i[1]=0,i[2]=-Math.sin(t),i[3]=0,i[7]=i[6]=i[4]=0,i[5]=1,i[8]=Math.sin(t),i[9]=0,i[10]=Math.cos(t),i[11]=0,i[14]=i[13]=i[12]=0,i[15]=1,e},cc.math.Matrix4.createByRotationZ=function(t,e){var i=(e=e||new cc.math.Matrix4).mat;return i[0]=Math.cos(t),i[1]=Math.sin(t),i[3]=i[2]=0,i[4]=-Math.sin(t),i[5]=Math.cos(t),i[7]=i[6]=0,i[11]=i[9]=i[8]=0,i[10]=1,i[14]=i[13]=i[12]=0,i[15]=1,e},cc.math.Matrix4.createByPitchYawRoll=function(t,e,i,n){n=n||new cc.math.Matrix4;var r=Math.cos(t),s=Math.sin(t),o=Math.cos(e),a=Math.sin(e),c=Math.cos(i),h=Math.sin(i),l=s*a,u=r*a,_=n.mat;return _[0]=o*c,_[4]=o*h,_[8]=-a,_[1]=l*c-r*h,_[5]=l*h+r*c,_[9]=s*o,_[2]=u*c+s*h,_[6]=u*h-s*c,_[10]=r*o,_[3]=_[7]=_[11]=0,_[15]=1,n},cc.math.Matrix4.createByQuaternion=function(t,e){var i=(e=e||new cc.math.Matrix4).mat;return i[0]=1-2*(t.y*t.y+t.z*t.z),i[1]=2*(t.x*t.y+t.z*t.w),i[2]=2*(t.x*t.z-t.y*t.w),i[3]=0,i[4]=2*(t.x*t.y-t.z*t.w),i[5]=1-2*(t.x*t.x+t.z*t.z),i[6]=2*(t.z*t.y+t.x*t.w),i[7]=0,i[8]=2*(t.x*t.z+t.y*t.w),i[9]=2*(t.y*t.z-t.x*t.w),i[10]=1-2*(t.x*t.x+t.y*t.y),i[11]=0,i[14]=i[13]=i[12]=0,i[15]=1,e},cc.math.Matrix4.createByRotationTranslation=function(t,e,i){var n=(i=i||new cc.math.Matrix4).mat,r=t.mat;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=0,n[4]=r[3],n[5]=r[4],n[6]=r[5],n[7]=0,n[8]=r[6],n[9]=r[7],n[10]=r[8],n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,i},cc.math.Matrix4.createByScale=function(t,e,i,n){var r=(n=n||new cc.math.Matrix4).mat;return r[0]=t,r[5]=e,r[10]=i,r[15]=1,r[1]=r[2]=r[3]=r[4]=r[6]=r[7]=r[8]=r[9]=r[11]=r[12]=r[13]=r[14]=0,n},cc.math.mat4Translation=function(t,e,i,n){return t.mat[0]=t.mat[5]=t.mat[10]=t.mat[15]=1,t.mat[1]=t.mat[2]=t.mat[3]=t.mat[4]=t.mat[6]=t.mat[7]=t.mat[8]=t.mat[9]=t.mat[11]=0,t.mat[12]=e,t.mat[13]=i,t.mat[14]=n,t},cc.math.Matrix4.createByTranslation=function(t,e,i,n){return(n=n||new cc.math.Matrix4).identity(),n.mat[12]=t,n.mat[13]=e,n.mat[14]=i,n},n.getUpVec3=function(){var t=this.mat;return new cc.math.Vec3(t[4],t[5],t[6]).normalize()},n.getRightVec3=function(){var t=this.mat;return new cc.math.Vec3(t[0],t[1],t[2]).normalize()},n.getForwardVec3=function(){var t=this.mat;return new cc.math.Vec3(t[8],t[9],t[10]).normalize()},cc.math.mat4PerspectiveProjection=function(t,e,i,n,r){var s=cc.degreesToRadians(e/2),o=r-n,a=Math.sin(s);if(0===o||0===a||0===i)return null;var c=Math.cos(s)/a;return t.identity(),t.mat[0]=c/i,t.mat[5]=c,t.mat[10]=-(r+n)/o,t.mat[11]=-1,t.mat[14]=-2*n*r/o,t.mat[15]=0,t},cc.math.Matrix4.createPerspectiveProjection=function(t,e,i,n){var r=cc.degreesToRadians(t/2),s=n-i,o=Math.sin(r);if(0===s||0===o||0===e)return null;var a=Math.cos(r)/o,c=new cc.math.Matrix4,h=c.mat;return c.identity(),h[0]=a/e,h[5]=a,h[10]=-(n+i)/s,h[11]=-1,h[14]=-2*i*n/s,h[15]=0,c},cc.math.mat4OrthographicProjection=function(t,e,i,n,r,s,o){return t.identity(),t.mat[0]=2/(i-e),t.mat[5]=2/(r-n),t.mat[10]=-2/(o-s),t.mat[12]=-(i+e)/(i-e),t.mat[13]=-(r+n)/(r-n),t.mat[14]=-(o+s)/(o-s),t},cc.math.Matrix4.createOrthographicProjection=function(t,e,i,n,r,s){var o=new cc.math.Matrix4,a=o.mat;return o.identity(),a[0]=2/(e-t),a[5]=2/(n-i),a[10]=-2/(s-r),a[12]=-(e+t)/(e-t),a[13]=-(n+i)/(n-i),a[14]=-(s+r)/(s-r),o},cc.math.mat4LookAt=function(t,e,i,n){var r=new cc.math.Vec3(i),s=new cc.math.Vec3(n);r.subtract(e),r.normalize(),s.normalize();var o=new cc.math.Vec3(r);o.cross(s),o.normalize();var a=new cc.math.Vec3(o);a.cross(r),o.normalize(),t.identity(),t.mat[0]=o.x,t.mat[4]=o.y,t.mat[8]=o.z,t.mat[1]=a.x,t.mat[5]=a.y,t.mat[9]=a.z,t.mat[2]=-r.x,t.mat[6]=-r.y,t.mat[10]=-r.z;var c=cc.math.Matrix4.createByTranslation(-e.x,-e.y,-e.z);return t.multiply(c),t};var s=new cc.math.Matrix4;n.lookAt=function(t,e,i){var n=new cc.math.Vec3(e),r=new cc.math.Vec3(i),o=this.mat;n.subtract(t),n.normalize(),r.normalize();var a=new cc.math.Vec3(n);a.cross(r),a.normalize();var c=new cc.math.Vec3(a);return c.cross(n),a.normalize(),this.identity(),o[0]=a.x,o[4]=a.y,o[8]=a.z,o[1]=c.x,o[5]=c.y,o[9]=c.z,o[2]=-n.x,o[6]=-n.y,o[10]=-n.z,s=cc.math.Matrix4.createByTranslation(-t.x,-t.y,-t.z,s),this.multiply(s),this},cc.math.mat4RotationAxisAngle=function(t,e,i){var n=Math.cos(i),r=Math.sin(i),s=new cc.math.Vec3(e);return s.normalize(),t.mat[0]=n+s.x*s.x*(1-n),t.mat[1]=s.z*r+s.y*s.x*(1-n),t.mat[2]=-s.y*r+s.z*s.x*(1-n),t.mat[3]=0,t.mat[4]=-s.z*r+s.x*s.y*(1-n),t.mat[5]=n+s.y*s.y*(1-n),t.mat[6]=s.x*r+s.z*s.y*(1-n),t.mat[7]=0,t.mat[8]=s.y*r+s.x*s.z*(1-n),t.mat[9]=-s.x*r+s.y*s.z*(1-n),t.mat[10]=n+s.z*s.z*(1-n),t.mat[11]=0,t.mat[12]=0,t.mat[13]=0,t.mat[14]=0,t.mat[15]=1,t},cc.math.Matrix4.createByAxisAndAngle=function(t,e,i){i=i||new cc.math.Matrix4;var n=this.mat,r=Math.cos(e),s=Math.sin(e),o=new cc.math.Vec3(t);return o.normalize(),n[0]=r+o.x*o.x*(1-r),n[1]=o.z*s+o.y*o.x*(1-r),n[2]=-o.y*s+o.z*o.x*(1-r),n[3]=0,n[4]=-o.z*s+o.x*o.y*(1-r),n[5]=r+o.y*o.y*(1-r),n[6]=o.x*s+o.z*o.y*(1-r),n[7]=0,n[8]=o.y*s+o.x*o.z*(1-r),n[9]=-o.x*s+o.y*o.z*(1-r),n[10]=r+o.z*o.z*(1-r),n[11]=0,n[12]=n[13]=n[14]=0,n[15]=1,i},n.extractRotation=function(){var t=new cc.math.Matrix3,e=this.mat,i=t.mat;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],t},n.extractPlane=function(t){var e=new cc.math.Plane,i=this.mat;switch(t){case cc.math.Plane.RIGHT:e.a=i[3]-i[0],e.b=i[7]-i[4],e.c=i[11]-i[8],e.d=i[15]-i[12];break;case cc.math.Plane.LEFT:e.a=i[3]+i[0],e.b=i[7]+i[4],e.c=i[11]+i[8],e.d=i[15]+i[12];break;case cc.math.Plane.BOTTOM:e.a=i[3]+i[1],e.b=i[7]+i[5],e.c=i[11]+i[9],e.d=i[15]+i[13];break;case cc.math.Plane.TOP:e.a=i[3]-i[1],e.b=i[7]-i[5],e.c=i[11]-i[9],e.d=i[15]-i[13];break;case cc.math.Plane.FAR:e.a=i[3]-i[2],e.b=i[7]-i[6],e.c=i[11]-i[10],e.d=i[15]-i[14];break;case cc.math.Plane.NEAR:e.a=i[3]+i[2],e.b=i[7]+i[6],e.c=i[11]+i[10],e.d=i[15]+i[14];break;default:cc.logID(7904)}var n=Math.sqrt(e.a*e.a+e.b*e.b+e.c*e.c);return e.a/=n,e.b/=n,e.c/=n,e.d/=n,e},n.toAxisAndAngle=function(){var t=this.extractRotation();return cc.math.Quaternion.rotationMatrix(t).toAxisAndAngle()}}),{}],250:[(function(t,e,i){cc.math.Plane=function(t,e,i,n){t&&void 0===e?(this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d):(this.a=t||0,this.b=e||0,this.c=i||0,this.d=n||0)};var n=cc.math.Plane.prototype;cc.math.Plane.LEFT=0,cc.math.Plane.RIGHT=1,cc.math.Plane.BOTTOM=2,cc.math.Plane.TOP=3,cc.math.Plane.NEAR=4,cc.math.Plane.FAR=5,cc.math.Plane.POINT_INFRONT_OF_PLANE=0,cc.math.Plane.POINT_BEHIND_PLANE=1,cc.math.Plane.POINT_ON_PLANE=2,n.dot=function(t){return this.a*t.x+this.b*t.y+this.c*t.z+this.d*t.w},n.dotCoord=function(t){return this.a*t.x+this.b*t.y+this.c*t.z+this.d},n.dotNormal=function(t){return this.a*t.x+this.b*t.y+this.c*t.z},cc.math.Plane.fromPointNormal=function(t,e){return new cc.math.Plane(e.x,e.y,e.z,-e.dot(t))},cc.math.Plane.fromPoints=function(t,e,i){var n=new cc.math.Vec3(e),r=new cc.math.Vec3(i),s=new cc.math.Plane;return n.subtract(t),r.subtract(t),n.cross(r),n.normalize(),s.a=n.x,s.b=n.y,s.c=n.z,s.d=n.scale(-1).dot(t),s},n.normalize=function(){var t=new cc.math.Vec3(this.a,this.b,this.c),e=1/t.length();return t.normalize(),this.a=t.x,this.b=t.y,this.c=t.z,this.d=this.d*e,this},n.classifyPoint=function(t){var e=this.a*t.x+this.b*t.y+this.c*t.z+this.d;return e>.001?cc.math.Plane.POINT_INFRONT_OF_PLANE:e<-.001?cc.math.Plane.POINT_BEHIND_PLANE:cc.math.Plane.POINT_ON_PLANE}}),{}],251:[(function(t,e,i){cc.math.Quaternion=function(t,e,i,n){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)};var n=cc.math.Quaternion.prototype;n.conjugate=function(t){return this.x=-t.x,this.y=-t.y,this.z=-t.z,this.w=t.w,this},n.dot=function(t){return this.w*t.w+this.x*t.x+this.y*t.y+this.z*t.z},n.exponential=function(){return this},n.identity=function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},n.inverse=function(){var t=this.length();return Math.abs(t)>cc.math.EPSILON?(this.x=0,this.y=0,this.z=0,this.w=0,this):(this.conjugate(this).scale(1/t),this)},n.isIdentity=function(){return 0===this.x&&0===this.y&&0===this.z&&1===this.w},n.length=function(){return Math.sqrt(this.lengthSq())},n.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},n.multiply=function(t){var e=this.x,i=this.y,n=this.z,r=this.w;return this.w=r*t.w-e*t.x-i*t.y-n*t.z,this.x=r*t.x+e*t.w+i*t.z-n*t.y,this.y=r*t.y+i*t.w+n*t.x-e*t.z,this.z=r*t.z+n*t.w+e*t.y-i*t.x,this},n.normalize=function(){var t=this.length();if(Math.abs(t)<=cc.math.EPSILON)throw new Error("current quaternion is an invalid value");return this.scale(1/t),this},n.rotationAxis=function(t,e){var i=.5*e,n=Math.sin(i);return this.w=Math.cos(i),this.x=t.x*n,this.y=t.y*n,this.z=t.z*n,this},cc.math.Quaternion.rotationMatrix=function(t){if(!t)return null;var e,i,n,r,s=[],o=t.mat,a=0;s[0]=o[0],s[1]=o[3],s[2]=o[6],s[4]=o[1],s[5]=o[4],s[6]=o[7],s[8]=o[2],s[9]=o[5],s[10]=o[8],s[15]=1;var c=s[0],h=c[0]+c[5]+c[10]+1;return h>cc.math.EPSILON?(a=2*Math.sqrt(h),e=(c[9]-c[6])/a,i=(c[2]-c[8])/a,n=(c[4]-c[1])/a,r=.25*a):c[0]>c[5]&&c[0]>c[10]?(e=.25*(a=2*Math.sqrt(1+c[0]-c[5]-c[10])),i=(c[4]+c[1])/a,n=(c[2]+c[8])/a,r=(c[9]-c[6])/a):c[5]>c[10]?(a=2*Math.sqrt(1+c[5]-c[0]-c[10]),e=(c[4]+c[1])/a,i=.25*a,n=(c[9]+c[6])/a,r=(c[2]-c[8])/a):(a=2*Math.sqrt(1+c[10]-c[0]-c[5]),e=(c[2]+c[8])/a,i=(c[9]+c[6])/a,n=.25*a,r=(c[4]-c[1])/a),new cc.math.Quaternion(e,i,n,r)},cc.math.Quaternion.rotationYawPitchRoll=function(t,e,i){var n,r,s,o,a,c,h,l,u,_,d;n=cc.degreesToRadians(e)/2,r=cc.degreesToRadians(t)/2,s=cc.degreesToRadians(i)/2,o=Math.cos(n),a=Math.cos(r),c=Math.cos(s),h=Math.sin(n),_=a*c,d=(l=Math.sin(r))*(u=Math.sin(s));var f=new cc.math.Quaternion;return f.w=o*_+h*d,f.x=h*_-o*d,f.y=o*l*c+h*a*u,f.z=o*a*u-h*l*c,f.normalize(),f},n.slerp=function(t,e){if(this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w)return this;var i=this.dot(t),n=Math.acos(i),r=Math.sqrt(1-cc.math.square(i)),s=Math.sin(e*n)/r,o=Math.sin((1-e)*n)/r,a=new cc.math.Quaternion(t);return this.scale(o),a.scale(s),this.add(a),this},n.toAxisAndAngle=function(){var t,e,i,n=new cc.math.Vec3;return t=Math.acos(this.w),(e=Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)))>-cc.math.EPSILON&&e<cc.math.EPSILON||e<2*Math.PI+cc.math.EPSILON&&e>2*Math.PI-cc.math.EPSILON?(i=0,n.x=0,n.y=0,n.z=1):(i=2*t,n.x=this.x/e,n.y=this.y/e,n.z=this.z/e,n.normalize()),{axis:n,angle:i}},n.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.assignFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},cc.math.Quaternion.rotationBetweenVec3=function(t,e,i){var n=new cc.math.Vec3(t),r=new cc.math.Vec3(e);n.normalize(),r.normalize();var s=n.dot(r),o=new cc.math.Quaternion;if(s>=1)return o.identity(),o;if(s<1e-6-1)if(Math.abs(i.lengthSq())<cc.math.EPSILON)o.rotationAxis(i,Math.PI);else{var a=new cc.math.Vec3(1,0,0);a.cross(t),Math.abs(a.lengthSq())<cc.math.EPSILON&&(a.fill(0,1,0),a.cross(t)),a.normalize(),o.rotationAxis(a,Math.PI)}else{var c=Math.sqrt(2*(1+s)),h=1/c;n.cross(r),o.x=n.x*h,o.y=n.y*h,o.z=n.z*h,o.w=.5*c,o.normalize()}return o},n.multiplyVec3=function(t){var e=this.x,i=this.y,n=this.z,r=new cc.math.Vec3(t),s=new cc.math.Vec3(e,i,n),o=new cc.math.Vec3(e,i,n);return s.cross(t),o.cross(s),s.scale(2*q.w),o.scale(2),r.add(s),r.add(o),r}}),{}],252:[(function(t,e,i){function n(t,e,i){var n=new cc.math.Vec2(e);n.subtract(t),i.x=-n.y,i.y=n.x,i.normalize()}cc.math.Ray2=function(t,e){this.start=t||new cc.math.Vec2,this.dir=e||new cc.math.Vec2},cc.math.Ray2.prototype.fill=function(t,e,i,n){this.start.x=t,this.start.y=e,this.dir.x=i,this.dir.y=n},cc.math.Ray2.prototype.intersectLineSegment=function(t,e,i){var n,r,s,o=this.start.x,a=this.start.y,c=this.start.x+this.dir.x,h=this.start.y+this.dir.y,l=t.x,u=t.y,_=e.x,d=e.y,f=(d-u)*(c-o)-(_-l)*(h-a);return!(f>-cc.math.EPSILON&&f<cc.math.EPSILON)&&(n=((_-l)*(a-u)-(d-u)*(o-l))/f,r=o+n*(c-o),s=a+n*(h-a),!(r<Math.min(t.x,e.x)-cc.math.EPSILON||r>Math.max(t.x,e.x)+cc.math.EPSILON||s<Math.min(t.y,e.y)-cc.math.EPSILON||s>Math.max(t.y,e.y)+cc.math.EPSILON)&&(!(r<Math.min(o,c)-cc.math.EPSILON||r>Math.max(o,c)+cc.math.EPSILON||s<Math.min(a,h)-cc.math.EPSILON||s>Math.max(a,h)+cc.math.EPSILON)&&(i.x=r,i.y=s,!0)))},cc.math.Ray2.prototype.intersectTriangle=function(t,e,i,r,s){var o,a=new cc.math.Vec2,c=new cc.math.Vec2,h=new cc.math.Vec2,l=1e4,u=!1;return this.intersectLineSegment(t,e,a)&&(u=!0,(o=a.subtract(this.start).length())<l&&(c.x=a.x,c.y=a.y,l=o,n(t,e,h))),this.intersectLineSegment(e,i,a)&&(u=!0,(o=a.subtract(this.start).length())<l&&(c.x=a.x,c.y=a.y,l=o,n(e,i,h))),this.intersectLineSegment(i,t,a)&&(u=!0,(o=a.subtract(this.start).length())<l&&(c.x=a.x,c.y=a.y,l=o,n(i,t,h))),u&&(r.x=c.x,r.y=c.y,s&&(s.x=h.x,s.y=h.y)),u}}),{}],253:[(function(t,e,i){cc.math=cc.math||{},cc.math.EPSILON=1/64,cc.math.square=function(t){return t*t},cc.math.almostEqual=function(t,e){return t+cc.math.EPSILON>e&&t-cc.math.EPSILON<e}}),{}],254:[(function(t,e,i){cc.math.Vec2=function(t,e){void 0===e?(this.x=t.x,this.y=t.y):(this.x=t||0,this.y=e||0)};var n=cc.math.Vec2.prototype;n.fill=function(t,e){this.x=t,this.y=e},n.length=function(){return Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y))},n.lengthSq=function(){return cc.math.square(this.x)+cc.math.square(this.y)},n.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this},cc.math.Vec2.add=function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t},n.add=function(t){return this.x+=t.x,this.y+=t.y,this},n.dot=function(t){return this.x*t.x+this.y*t.y},cc.math.Vec2.subtract=function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t},n.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},n.transform=function(t){var e=this.x,i=this.y;return this.x=e*t.mat[0]+i*t.mat[3]+t.mat[6],this.y=e*t.mat[1]+i*t.mat[4]+t.mat[7],this},cc.math.Vec2.scale=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t},n.scale=function(t){return this.x*=t,this.y*=t,this},n.equals=function(t){return this.x<t.x+cc.math.EPSILON&&this.x>t.x-cc.math.EPSILON&&this.y<t.y+cc.math.EPSILON&&this.y>t.y-cc.math.EPSILON}}),{}],255:[(function(t,e,i){cc.math.Vec3=cc.math.Vec3=function(t,e,i){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z):(this.x=t||0,this.y=e||0,this.z=i||0)},cc.math.vec3=function(t,e,i){return new cc.math.Vec3(t,e,i)};var n=cc.math.Vec3.prototype;n.fill=function(t,e,i){return t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z):(this.x=t,this.y=e,this.z=i),this},n.length=function(){return Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z))},n.lengthSq=function(){return cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)},n.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this},n.cross=function(t){var e=this.x,i=this.y,n=this.z;return this.x=i*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-i*t.x,this},n.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},n.subtract=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.transform=function(t){var e=this.x,i=this.y,n=this.z,r=t.mat;return this.x=e*r[0]+i*r[4]+n*r[8]+r[12],this.y=e*r[1]+i*r[5]+n*r[9]+r[13],this.z=e*r[2]+i*r[6]+n*r[10]+r[14],this},n.transformNormal=function(t){var e=this.x,i=this.y,n=this.z,r=t.mat;return this.x=e*r[0]+i*r[4]+n*r[8],this.y=e*r[1]+i*r[5]+n*r[9],this.z=e*r[2]+i*r[6]+n*r[10],this},n.transformCoord=function(t){var e=new cc.math.Vec4(this.x,this.y,this.z,1);return e.transform(t),this.x=e.x/e.w,this.y=e.y/e.w,this.z=e.z/e.w,this},n.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.equals=function(t){var e=cc.math.EPSILON;return this.x<t.x+e&&this.x>t.x-e&&this.y<t.y+e&&this.y>t.y-e&&this.z<t.z+e&&this.z>t.z-e},n.inverseTransform=function(t){var e=t.mat,i=new cc.math.Vec3(this.x-e[12],this.y-e[13],this.z-e[14]);return this.x=i.x*e[0]+i.y*e[1]+i.z*e[2],this.y=i.x*e[4]+i.y*e[5]+i.z*e[6],this.z=i.x*e[8]+i.y*e[9]+i.z*e[10],this},n.inverseTransformNormal=function(t){var e=this.x,i=this.y,n=this.z,r=t.mat;return this.x=e*r[0]+i*r[1]+n*r[2],this.y=e*r[4]+i*r[5]+n*r[6],this.z=e*r[8]+i*r[9]+n*r[10],this},n.assignFrom=function(t){return t?(this.x=t.x,this.y=t.y,this.z=t.z,this):this},cc.math.Vec3.zero=function(t){return t.x=t.y=t.z=0,t},n.toTypeArray=function(){var t=new Float32Array(3);return t[0]=this.x,t[1]=this.y,t[2]=this.z,t}}),{}],256:[(function(t,e,i){cc.math.Vec4=function(t,e,i,n){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)};var n=cc.math.Vec4.prototype;n.fill=function(t,e,i,n){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t,this.y=e,this.z=i,this.w=n)},n.add=function(t){return t?(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this):this},n.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},n.length=function(){return Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)+cc.math.square(this.w))},n.lengthSq=function(){return cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)+cc.math.square(this.w)},n.lerp=function(t,e){return this},n.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.scale=function(t){return this.normalize(),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.subtract=function(t){this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w},n.transform=function(t){var e=this.x,i=this.y,n=this.z,r=this.w,s=t.mat;return this.x=e*s[0]+i*s[4]+n*s[8]+r*s[12],this.y=e*s[1]+i*s[5]+n*s[9]+r*s[13],this.z=e*s[2]+i*s[6]+n*s[10]+r*s[14],this.w=e*s[3]+i*s[7]+n*s[11]+r*s[15],this},cc.math.Vec4.transformArray=function(t,e){for(var i=[],n=0;n<t.length;n++){var r=new cc.math.Vec4(t[n]);r.transform(e),i.push(r)}return i},n.equals=function(t){var e=cc.math.EPSILON;return this.x<t.x+e&&this.x>t.x-e&&this.y<t.y+e&&this.y>t.y-e&&this.z<t.z+e&&this.z>t.z-e&&this.w<t.w+e&&this.w>t.w-e},n.assignFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.toTypeArray=function(){var t=new Float32Array(4);return t[0]=this.x,t[1]=this.y,t[2]=this.z,t[3]=this.w,t}}),{}],257:[(function(t,e,i){t("./CCSGMotionStreak"),t("./CCSGMotionStreakWebGLRenderCmd");var n=cc.Class({name:"cc.MotionStreak",extends:cc.Component,editor:!1,ctor:function(){this._root=null,this._motionStreak=null},properties:{preview:{default:!1,editorOnly:!0,notify:!1,animatable:!1},_fadeTime:1,fadeTime:{get:function(){return this._fadeTime},set:function(t){this._fadeTime=t,this._motionStreak&&this._motionStreak.setFadeTime(t)},animatable:!1,tooltip:!1},_minSeg:1,minSeg:{get:function(){return this._minSeg},set:function(t){this._minSeg=t,this._motionStreak&&this._motionStreak.setMinSeg(t)},animatable:!1,tooltip:!1},_stroke:64,stroke:{get:function(){return this._stroke},set:function(t){this._stroke=t,this._motionStreak&&this._motionStreak.setStroke(t)},animatable:!1,tooltip:!1},_texture:{default:"",url:cc.Texture2D},texture:{get:function(){return this._texture},set:function(t){this._texture=t,this._motionStreak&&(t&&cc.js.isString(t)&&(t=cc.textureCache.addImage(t)),this._motionStreak.setTexture(t))},url:cc.Texture2D,animatable:!1,tooltip:!1},_color:cc.Color.WHITE,color:{get:function(){return this._color},set:function(t){this._color=t,this._motionStreak&&this._motionStreak.tintWithColor(t)},tooltip:!1},_fastMode:!1,fastMode:{get:function(){return this._fastMode},set:function(t){this._fastMode=t,this._motionStreak&&this._motionStreak.setFastMode(t)},animatable:!1,tooltip:!1}},onFocusInEditor:!1,onLostFocusInEditor:!1,reset:function(){this._motionStreak.reset()},__preload:function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){this._root=new _ccsg.Node;var t=new _ccsg.MotionStreak;t.initWithFade(this._fadeTime,this._minSeg,this._stroke,this.node.color,this._texture||null),t.setFastMode(this._fastMode),this._root.addChild(t);var e=this.node._sgNode;e&&e.addChild(this._root,-10),this._motionStreak=t}else cc.warnID(5900)},onEnable:function(){this.node.on("position-changed",this._onNodePositionChanged,this)},onDisable:function(){this.node.off("position-changed",this._onNodePositionChanged,this)},_onNodePositionChanged:function(){if(this._motionStreak){var t=this.node,e=t.getNodeToWorldTransform(),i=e.tx-(t.width/2+t.anchorX*t.width),n=e.ty-(t.height/2+t.anchorY*t.height);this._root.setPosition(-i,-n),this._motionStreak.setPosition(i,n)}}});cc.MotionStreak=e.exports=n}),{"./CCSGMotionStreak":258,"./CCSGMotionStreakWebGLRenderCmd":259}],258:[(function(t,e,i){function n(t,e,i,n,r){if(!((r+=n)<=1)){e*=.5;for(var s,o=r-1,a=n;a<r;a++){s=2*a;var c,h=cc.p(t[2*a],t[2*a+1]);if(0===a)c=cc.pPerp(cc.pNormalize(cc.pSub(h,cc.p(t[2*(a+1)],t[2*(a+1)+1]))));else if(a===o)c=cc.pPerp(cc.pNormalize(cc.pSub(cc.p(t[2*(a-1)],t[2*(a-1)+1]),h)));else{var l=cc.p(t[2*(a-1)],t[2*(a-1)+1]),u=cc.p(t[2*(a+1)],t[2*(a+1)+1]),_=cc.pNormalize(cc.pSub(u,h)),d=cc.pNormalize(cc.pSub(l,h)),f=Math.acos(cc.pDot(_,d));c=f<cc.degreesToRadians(70)?cc.pPerp(cc.pNormalize(cc.pMidpoint(_,d))):f<cc.degreesToRadians(170)?cc.pNormalize(cc.pMidpoint(_,d)):cc.pPerp(cc.pNormalize(cc.pSub(u,l)))}c=cc.pMult(c,e),i[2*s]=h.x+c.x,i[2*s+1]=h.y+c.y,i[2*(s+1)]=h.x-c.x,i[2*(s+1)+1]=h.y-c.y}for(a=n=0===n?0:n-1;a<o;a++){var p=(s=2*a)+2,m=cc.v2(i[2*s],i[2*s+1]),g=cc.v2(i[2*(s+1)],i[2*(s+1)+1]),y=cc.v2(i[2*p],i[2*p+1]),v=cc.v2(i[2*(p+1)],i[2*(p+1)+1]),x=(function(t,e,i,n,r,s,o,a){var c,h,l,u;if(t===i&&e===n||r===o&&s===a)return{isSuccess:!1,value:0};if(i-=t,n-=e,r-=t,s-=e,o-=t,a-=e,c=Math.sqrt(i*i+n*n),h=i/c,l=n/c,u=r*h+s*l,s=s*h-r*l,r=u,u=o*h+a*l,a=a*h-o*l,o=u,s===a)return{isSuccess:!1,value:0};return{isSuccess:!0,value:(o+(r-o)*a/(a-s))/c}})(m.x,m.y,v.x,v.y,g.x,g.y,y.x,y.y),C=!x.isSuccess;C||(x.value<0||x.value>1)&&(C=!0),C&&(i[2*p]=v.x,i[2*p+1]=v.y,i[2*(p+1)]=y.x,i[2*(p+1)+1]=y.y)}}}_ccsg.MotionStreak=_ccsg.Node.extend({texture:null,fastMode:!1,startingPositionInitialized:!1,_blendFunc:null,_stroke:0,_fadeDelta:0,_minSeg:0,_maxPoints:0,_nuPoints:0,_previousNuPoints:0,_pointVertexes:null,_pointState:null,_vertices:null,_colorPointer:null,_texCoords:null,_verticesBuffer:null,_colorPointerBuffer:null,_texCoordsBuffer:null,_className:"MotionStreak",ctor:function(t,e,i,n,r){_ccsg.Node.prototype.ctor.call(this),this._positionR=cc.p(0,0),this._blendFunc=new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA),this.fastMode=!1,this.startingPositionInitialized=!1,this.texture=null,this._stroke=0,this._fadeDelta=0,this._minSeg=0,this._maxPoints=0,this._nuPoints=0,this._previousNuPoints=0,this._pointVertexes=null,this._pointState=null,this._vertices=null,this._colorPointer=null,this._texCoords=null,this._verticesBuffer=null,this._colorPointerBuffer=null,this._texCoordsBuffer=null,void 0!==r&&this.initWithFade(t,e,i,n,r)},initWithFade:function(t,e,i,n,r){return cc.js.isString(r)&&(r=cc.textureCache.addImage(r)),this.anchorX=0,this.anchorY=0,this.ignoreAnchor=!0,this.startingPositionInitialized=!1,this.fastMode=!0,this._stroke=i,this.setMinSeg(e),this.setFadeTime(t),this._blendFunc.src=gl.SRC_ALPHA,this._blendFunc.dst=gl.ONE_MINUS_SRC_ALPHA,this.setTexture(r),this.color=n,this.scheduleUpdate(),!0},getTexture:function(){return this.texture},setTexture:function(t){this.texture!==t&&(this.texture=t)},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(t,e){void 0===e?this._blendFunc=t:(this._blendFunc.src=t,this._blendFunc.dst=e)},getOpacity:function(){return cc.logID(5901),0},setOpacity:function(t){cc.logID(5902)},setOpacityModifyRGB:function(t){},isOpacityModifyRGB:function(){return!1},getFadeTime:function(){return 1/this._fadeDelta},setFadeTime:function(t){this._fadeDelta=1/t;var e=2+(0|60*t);this._maxPoints=e,this._nuPoints=0,this._pointState=new Float32Array(e),this._pointVertexes=new Float32Array(2*e),this._vertices=new Float32Array(4*e),this._texCoords=new Float32Array(4*e),this._colorPointer=new Uint8Array(8*e),this._verticesBuffer=gl.createBuffer(),this._texCoordsBuffer=gl.createBuffer(),this._colorPointerBuffer=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,this._verticesBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._vertices,gl.DYNAMIC_DRAW),gl.bindBuffer(gl.ARRAY_BUFFER,this._texCoordsBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._texCoords,gl.DYNAMIC_DRAW),gl.bindBuffer(gl.ARRAY_BUFFER,this._colorPointerBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._colorPointer,gl.DYNAMIC_DRAW)},getMinSeg:function(){return this._minSeg},setMinSeg:function(t){this._minSeg=-1===t?this._stroke/5:t,this._minSeg*=this._minSeg},isFastMode:function(){return this.fastMode},setFastMode:function(t){this.fastMode=t},isStartingPositionInitialized:function(){return this.startingPositionInitialized},setStartingPositionInitialized:function(t){this.startingPositionInitialized=t},getStroke:function(){return this._stroke},setStroke:function(t){this._stroke=t},tintWithColor:function(t){this.color=t;for(var e=this._colorPointer,i=0,n=2*this._nuPoints;i<n;i++)e[4*i]=t.r,e[4*i+1]=t.g,e[4*i+2]=t.b},reset:function(){this._nuPoints=0},setPosition:function(t,e){this.startingPositionInitialized=!0,void 0===e?(this._positionR.x=t.x,this._positionR.y=t.y):(this._positionR.x=t,this._positionR.y=e)},getPositionX:function(){return this._positionR.x},setPositionX:function(t){this._positionR.x=t,this.startingPositionInitialized||(this.startingPositionInitialized=!0)},getPositionY:function(){return this._positionR.y},setPositionY:function(t){this._positionR.y=t,this.startingPositionInitialized||(this.startingPositionInitialized=!0)},update:function(t){if(this.startingPositionInitialized){t*=this._fadeDelta;var e,i,r,s,o=0,a=this._nuPoints,c=this._pointState,h=this._pointVertexes,l=this._vertices,u=this._colorPointer;for(r=0;r<a;r++)if(c[r]-=t,c[r]<=0)o++;else{e=r-o,o>0?(c[e]=c[r],h[2*e]=h[2*r],h[2*e+1]=h[2*r+1],s=2*r,l[2*(i=2*e)]=l[2*s],l[2*i+1]=l[2*s+1],l[2*(i+1)]=l[2*(s+1)],l[2*(i+1)+1]=l[2*(s+1)+1],s*=4,u[(i*=4)+0]=u[s+0],u[i+1]=u[s+1],u[i+2]=u[s+2],u[i+4]=u[s+4],u[i+5]=u[s+5],u[i+6]=u[s+6]):i=8*e;var _=255*c[e];u[i+3]=_,u[i+7]=_}var d=!0;if((a-=o)>=this._maxPoints)d=!1;else if(a>0){var f=cc.p(h[2*(a-1)],h[2*(a-1)+1]),p=cc.pDistanceSQ(f,this._positionR)<this._minSeg,m=cc.p(h[2*(a-2)],h[2*(a-2)+1]),g=1!==a&&cc.pDistanceSQ(m,this._positionR)<2*this._minSeg;(p||g)&&(d=!1)}if(d){h[2*a]=this._positionR.x,h[2*a+1]=this._positionR.y,c[a]=1;var y=8*a,v=this.getDisplayedColor();u[y]=v.r,u[y+1]=v.g,u[y+2]=v.b,u[y+4]=v.r,u[y+5]=v.g,u[y+6]=v.b,u[y+3]=255,u[y+7]=255,a>0&&this.fastMode&&(a>1?n(h,this._stroke,this._vertices,a,1):n(h,this._stroke,this._vertices,0,2)),a++}if(this.fastMode||n(h,this._stroke,this._vertices,0,a),a&&this._previousNuPoints!==a){var x=1/a,C=this._texCoords;for(r=0;r<a;r++)C[4*r]=0,C[4*r+1]=x*r,C[2*(2*r+1)]=1,C[2*(2*r+1)+1]=x*r;this._previousNuPoints=a}this._nuPoints=a}},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new _ccsg.MotionStreak.WebGLRenderCmd(this):null}});var r=_ccsg.MotionStreak.prototype;Object.defineProperty(r,"x",{get:r.getPositionX,set:r.setPositionX}),Object.defineProperty(r,"y",{get:r.getPositionY,set:r.setPositionY})}),{}],259:[(function(t,e,i){_ccsg.MotionStreak.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._matrix=new cc.math.Matrix4,this._matrix.identity(),this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)},_ccsg.MotionStreak.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype),_ccsg.MotionStreak.WebGLRenderCmd.prototype.constructor=_ccsg.Sprite.WebGLRenderCmd,_ccsg.MotionStreak.WebGLRenderCmd.prototype.rendering=function(t){var e=this._node;if(!(e._nuPoints<=1)&&e.texture&&e.texture.isLoaded()){t=t||cc._renderContext,this._updateDisplayColor();var i=this._worldTransform,n=this._matrix.mat;n[0]=i.a,n[4]=i.c,n[12]=i.tx,n[1]=i.b,n[5]=i.d,n[13]=i.ty,this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._matrix),cc.gl.blendFunc(e._blendFunc.src,e._blendFunc.dst),cc.gl.bindTexture2DN(0,e.texture),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_COLOR),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_TEX_COORDS),t.bindBuffer(t.ARRAY_BUFFER,e._verticesBuffer),t.bufferData(t.ARRAY_BUFFER,e._vertices,t.DYNAMIC_DRAW),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,e._texCoordsBuffer),t.bufferData(t.ARRAY_BUFFER,e._texCoords,t.DYNAMIC_DRAW),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,e._colorPointerBuffer),t.bufferData(t.ARRAY_BUFFER,e._colorPointer,t.DYNAMIC_DRAW),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR,4,t.UNSIGNED_BYTE,!0,0,0),t.drawArrays(t.TRIANGLE_STRIP,0,2*e._nuPoints),cc.g_NumberOfDraws++}}}),{}],260:[(function(t,e,i){var n=t("../compression/zlib.min"),r=cc._Class.extend({ctor:function(t){var e,i,n,r,s,o,a,c,h,l,u,_,d;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},s=null;;){switch(e=this.readUInt32(),c=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join("")){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":s&&this.animation.frames.push(s),this.pos+=4,s={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},r=this.readUInt16(),n=this.readUInt16()||100,s.delay=1e3*r/n,s.disposeOp=this.data[this.pos++],s.blendOp=this.data[this.pos++],s.data=[];break;case"IDAT":case"fdAT":for("fdAT"===c&&(this.pos+=4,e-=4),t=(null!=s?s.data:void 0)||this.imgData,u=0;0<=e?u<e:u>e;0<=e?++u:--u)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(h=255-this.transparency.indexed.length)>0)for(_=0;0<=h?_<h:_>h;0<=h?++_:--_)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":o=(l=this.read(e)).indexOf(0),a=String.fromCharCode.apply(String,l.slice(0,o)),this.text[a]=String.fromCharCode.apply(String,l.slice(o+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(d=this.colorType)||6===d,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}},read:function(t){var e,i;for(i=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},readUInt32:function(){var t,e,i,n;return t=this.data[this.pos++]<<24,e=this.data[this.pos++]<<16,i=this.data[this.pos++]<<8,n=this.data[this.pos++],t|e|i|n},readUInt16:function(){var t,e;return t=this.data[this.pos++]<<8,e=this.data[this.pos++],t|e},decodePixels:function(t){var e,i,r,s,o,a,c,h,l,u,_,d,f,p,m,g,y,v,x,C,T,b,A;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=new n.Inflate(t,{index:0,verify:!1}).decompress(),g=(d=this.pixelBitlength/8)*this.width,f=new Uint8Array(g*this.height),a=t.length,m=0,p=0,i=0;p<a;){switch(t[p++]){case 0:for(s=x=0;x<g;s=x+=1)f[i++]=t[p++];break;case 1:for(s=C=0;C<g;s=C+=1)e=t[p++],o=s<d?0:f[i-d],f[i++]=(e+o)%256;break;case 2:for(s=T=0;T<g;s=T+=1)e=t[p++],r=(s-s%d)/d,y=m&&f[(m-1)*g+r*d+s%d],f[i++]=(y+e)%256;break;case 3:for(s=b=0;b<g;s=b+=1)e=t[p++],r=(s-s%d)/d,o=s<d?0:f[i-d],y=m&&f[(m-1)*g+r*d+s%d],f[i++]=(e+Math.floor((o+y)/2))%256;break;case 4:for(s=A=0;A<g;s=A+=1)e=t[p++],r=(s-s%d)/d,o=s<d?0:f[i-d],0===m?y=v=0:(y=f[(m-1)*g+r*d+s%d],v=r&&f[(m-1)*g+(r-1)*d+s%d]),c=o+y-v,h=Math.abs(c-o),u=Math.abs(c-y),_=Math.abs(c-v),l=h<=u&&h<=_?o:u<=_?y:v,f[i++]=(e+l)%256;break;default:throw new Error("Invalid filter algorithm: "+t[p-1])}m++}return f},copyToImageData:function(t,e){var i,n,r,s,o,a,c,h,l,u,_;if(n=this.colors,l=null,i=this.hasAlphaChannel,this.palette.length&&(l=null!=(_=this._decodedPalette)?_:this._decodedPalette=this.decodePalette(),n=4,i=!0),r=t.data||t,h=r.length,o=l||e,s=a=0,1===n)for(;s<h;)c=l?4*e[s/4]:a,u=o[c++],r[s++]=u,r[s++]=u,r[s++]=u,r[s++]=i?o[c++]:255,a=c;else for(;s<h;)c=l?4*e[s/4]:a,r[s++]=o[c++],r[s++]=o[c++],r[s++]=o[c++],r[s++]=i?o[c++]:255,a=c},decodePalette:function(){var t,e,i,n,r,s,o,a,c;for(i=this.palette,s=this.transparency.indexed||[],r=new Uint8Array((s.length||0)+i.length),n=0,t=0,e=o=0,a=i.length;o<a;e=o+=3)r[n++]=i[e],r[n++]=i[e+1],r[n++]=i[e+2],r[n++]=null!=(c=s[t++])?c:255;return r},render:function(t){var e,i;return t.width=this.width,t.height=this.height,e=t.getContext("2d"),i=e.createImageData(this.width,this.height),this.copyToImageData(i,this.decodePixels()),e.putImageData(i,0,0)}});e.exports=r}),{"../compression/zlib.min":31}],261:[(function(t,e,i){var n=cc.Class({name:"cc.ParticleAsset",extends:cc.RawAsset});cc.ParticleAsset=e.exports=n}),{}],262:[(function(t,e,i){t("./CCParticleAsset"),t("./CCSGParticleSystem"),t("./CCSGParticleSystemCanvasRenderCmd"),t("./CCSGParticleSystemWebGLRenderCmd");var n=cc.BlendFunc.BlendFactor,r=cc.Enum({GRAVITY:0,RADIUS:1}),s=cc.Enum({FREE:0,RELATIVE:1,GROUPED:2}),o={preview:{default:!0,editorOnly:!0,notify:!1,animatable:!1,tooltip:!1},_custom:!1,custom:{get:function(){return this._custom},set:function(t){this._custom!==t&&(this._custom=t,t?this._applyCustoms():this._applyFile())},animatable:!1,tooltip:!1},_file:{default:"",url:cc.ParticleAsset},file:{get:function(){return this._file},set:function(t,e){this._file!==t&&(this._file=t,t?this._applyFile():this.custom=!0)},animatable:!1,url:cc.ParticleAsset,tooltip:!1},_texture:{default:"",url:cc.Texture2D},texture:{get:function(){return this._texture},set:function(t){this._texture=t,this._sgNode.texture=t?cc.textureCache.addImage(t):null,!t&&this._file&&this._applyFile()},url:cc.Texture2D,tooltip:!1},particleCount:{get:function(){return this._sgNode.particleCount},set:function(t){this._sgNode.particleCount=t},visible:!1,tooltip:!1},_srcBlendFactor:n.SRC_ALPHA,srcBlendFactor:{get:function(){return this._srcBlendFactor},set:function(t){this._srcBlendFactor=t,this._blendFunc.src=t,this._sgNode.setBlendFunc(this._blendFunc)},animatable:!1,type:n,tooltip:!1},_dstBlendFactor:n.ONE_MINUS_SRC_ALPHA,dstBlendFactor:{get:function(){return this._dstBlendFactor},set:function(t){this._dstBlendFactor=t,this._blendFunc.dst=t,this._sgNode.setBlendFunc(this._blendFunc)},animatable:!1,type:n,tooltip:!1},playOnLoad:!0,_autoRemoveOnFinish:!1,autoRemoveOnFinish:{get:function(){return this._autoRemoveOnFinish},set:function(t){this._autoRemoveOnFinish!==t&&(this._autoRemoveOnFinish=t,this._applyAutoRemove())},animatable:!1,tooltip:!1},active:{get:function(){return!!this._sgNode&&this._sgNode.isActive()},visible:!1}},a=(function(){for(var t={totalParticles:150,duration:-1,emissionRate:10,life:1,lifeVar:0,startColor:cc.Color.WHITE,startColorVar:cc.Color.BLACK,endColor:cc.color(255,255,255,0),endColorVar:cc.color(0,0,0,0),angle:90,angleVar:20,startSize:50,startSizeVar:0,endSize:0,endSizeVar:0,startSpin:0,startSpinVar:0,endSpin:0,endSpinVar:0,sourcePos:cc.p(0,0),posVar:cc.p(0,0),positionType:s.FREE,emitterMode:r.GRAVITY,gravity:cc.p(0,0),speed:180,speedVar:50,tangentialAccel:80,tangentialAccelVar:0,radialAccel:0,radialAccelVar:0,rotationIsDir:!1,startRadius:0,startRadiusVar:0,endRadius:0,endRadiusVar:0,rotatePerS:0,rotatePerSVar:0},e=Object.keys(t),i=0;i<e.length;++i){var n=e[i];(function(t,e){var i="_"+t;o[i]=e;var n=e.constructor,r=o[t]={};cc.isChildClassOf(n,cc.ValueType)?(r.get=function(){return new n(this[i])},r.type=n):r.get=function(){return this[i]},cc.isChildClassOf(n,cc.ValueType)?r.set=function(e){this[i]=new n(e),this._sgNode[t]=e}:r.set=function(e){this[i]=e,this._sgNode[t]=e}})(n,t[n])}return e})();o.positionType.type=s,o.emitterMode.type=r;var c=cc.Class({name:"cc.ParticleSystem",extends:cc._RendererUnderSG,editor:!1,ctor:function(){this._previewTimer=null,this._focused=!1,this._willStart=!1,this._blendFunc=new cc.BlendFunc(0,0),this._originOnExit=null},properties:o,statics:{DURATION_INFINITY:-1,START_SIZE_EQUAL_TO_END_SIZE:-1,START_RADIUS_EQUAL_TO_END_RADIUS:-1,EmitterMode:r,PositionType:s},__preload:function(){this._super(),this.playOnLoad&&this.resetSystem(),this._applyAutoRemove()},onDestroy:function(){this._autoRemoveOnFinish&&(this.autoRemoveOnFinish=!1),this._super()},onFocusInEditor:!1,onLostFocusInEditor:!1,_createSgNode:function(){return new _ccsg.ParticleSystem},_initSgNode:function(){var t=this._sgNode;if(this._file)if(this._custom){!this._texture?this._applyFile():this._applyCustoms()}else this._applyFile();else this._custom&&this._applyCustoms();t.stopSystem()},addParticle:function(){return this._sgNode.addParticle()},stopSystem:function(){this._sgNode.stopSystem()},resetSystem:function(){this._sgNode.resetSystem()},isFull:function(){return this.particleCount>=this._totalParticles},setDisplayFrame:function(t){if(t){var e=t.getTexture();e&&(this._texture=e.url),this._sgNode.setDisplayFrame(t)}},setTextureWithRect:function(t,e){t instanceof cc.Texture2D&&(this._texture=t.url),this._sgNode.setTextureWithRect(t,e)},_applyFile:function(){var t=this._file;if(t){var e=this;cc.loader.load(t,(function(i,n){if(i||!n)throw i||new Error("Unkown error");if(e.isValid){var r=e._sgNode;r.particleCount=0;var s=r.isActive();r.initWithFile(t),n.textureUuid&&cc.AssetLibrary.queryAssetInfo(n.textureUuid,(function(t,i,n){t?cc.error(t):e.texture=i})),n.emissionRate&&(e.emissionRate=n.emissionRate),r.setPosition(0,0),s||r.stopSystem(),e._applyAutoRemove(),e._custom&&e._applyCustoms()}}))}},_applyCustoms:function(){for(var t=this._sgNode,e=t.isActive(),i=0;i<a.length;i++){var n=a[i];t[n]=this["_"+n]}this._blendFunc.src=this._srcBlendFactor,this._blendFunc.dst=this._dstBlendFactor,t.setBlendFunc(this._blendFunc),this._texture&&(t.texture=cc.textureCache.addImage(this._texture)),e||t.stopSystem(),this._applyAutoRemove()},_applyAutoRemove:function(){var t=this._sgNode,e=this._autoRemoveOnFinish;if(t.autoRemoveOnFinish=e,e){if(this._originOnExit)return;this._originOnExit=t.onExit;var i=this;t.onExit=function(){i._originOnExit.call(this),i.node.destroy()}}else this._originOnExit&&(t.onExit=this._originOnExit,this._originOnExit=null)}});cc.ParticleSystem=e.exports=c}),{"./CCParticleAsset":261,"./CCSGParticleSystem":263,"./CCSGParticleSystemCanvasRenderCmd":264,"./CCSGParticleSystemWebGLRenderCmd":265}],263:[(function(t,e,i){var n=t("./CCPNGReader"),r=t("./CCTIFFReader");t("../compression/ZipUtils"),cc.Particle=function(t,e,i,n,r,s,o,a,c,h,l){this.pos=t||cc.v2(0,0),this.startPos=e||cc.v2(0,0),this.color=i||cc.color(0,0,0,255),this.deltaColor=n||{r:0,g:0,b:0,a:255},this.size=r||0,this.deltaSize=s||0,this.rotation=o||0,this.deltaRotation=a||0,this.timeToLive=c||0,this.modeA=h||new cc.Particle.ModeA,this.modeB=l||new cc.Particle.ModeB,this.isChangeColor=!1,this.drawPos=cc.p(0,0)},cc.Particle.ModeA=function(t,e,i){this.dir=t||cc.p(0,0),this.radialAccel=e||0,this.tangentialAccel=i||0},cc.Particle.ModeB=function(t,e,i,n){this.angle=t||0,this.degreesPerSecond=e||0,this.radius=i||0,this.deltaRadius=n||0},cc.Particle.TemporaryPoints=[cc.p(),cc.p(),cc.p(),cc.p()],_ccsg.ParticleSystem=_ccsg.Node.extend({_className:"ParticleSystem",_plistFile:"",_elapsed:0,_dontTint:!1,modeA:null,modeB:null,_pointZeroForParticle:cc.p(0,0),_particles:null,_emitCounter:0,_particleIdx:0,_allocatedParticles:0,_isActive:!1,particleCount:0,duration:0,_sourcePosition:null,_posVar:null,life:0,lifeVar:0,angle:0,angleVar:0,startSize:0,startSizeVar:0,endSize:0,endSizeVar:0,_startColor:null,_startColorVar:null,_endColor:null,_endColorVar:null,startSpin:0,startSpinVar:0,endSpin:0,endSpinVar:0,emissionRate:0,_totalParticles:0,_texture:null,_blendFunc:null,_opacityModifyRGB:!1,positionType:null,autoRemoveOnFinish:!1,emitterMode:0,_textureLoaded:null,ctor:function(t){if(_ccsg.Node.prototype.ctor.call(this),this.emitterMode=_ccsg.ParticleSystem.Mode.GRAVITY,this.modeA=new _ccsg.ParticleSystem.ModeA,this.modeB=new _ccsg.ParticleSystem.ModeB,this._blendFunc={src:cc.macro.BLEND_SRC,dst:cc.macro.BLEND_DST},this._particles=[],this._sourcePosition=cc.p(0,0),this._posVar=cc.p(0,0),this._startColor=cc.color(255,255,255,255),this._startColorVar=cc.color(255,255,255,255),this._endColor=cc.color(255,255,255,255),this._endColorVar=cc.color(255,255,255,255),this._plistFile="",this._elapsed=0,this._dontTint=!1,this._pointZeroForParticle=cc.p(0,0),this._emitCounter=0,this._particleIdx=0,this._allocatedParticles=0,this._isActive=!1,this.particleCount=0,this.duration=0,this.life=0,this.lifeVar=0,this.angle=0,this.angleVar=0,this.startSize=0,this.startSizeVar=0,this.endSize=0,this.endSizeVar=0,this.startSpin=0,this.startSpinVar=0,this.endSpin=0,this.endSpinVar=0,this.emissionRate=0,this._totalParticles=0,this._texture=null,this._opacityModifyRGB=!1,this.positionType=_ccsg.ParticleSystem.Type.FREE,this.autoRemoveOnFinish=!1,this._textureLoaded=!0,!t||cc.js.isNumber(t)){var e=t||100;this.initWithTotalParticles(e)}else"string"==typeof t?this.initWithFile(t):"object"==typeof t&&this.initWithDictionary(t,"")},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.ParticleSystem.CanvasRenderCmd(this):new _ccsg.ParticleSystem.WebGLRenderCmd(this)},onEnter:function(){this.scheduleUpdateWithPriority(1),_ccsg.Node.prototype.onEnter.call(this)},ignoreColor:function(t){this._dontTint=t},initTexCoordsWithRect:function(t){this._renderCmd.initTexCoordsWithRect(t)},isActive:function(){return this._isActive},getParticleCount:function(){return this.particleCount},setParticleCount:function(t){this.particleCount=t},getDuration:function(){return this.duration},setDuration:function(t){this.duration=t},getSourcePosition:function(){return{x:this._sourcePosition.x,y:this._sourcePosition.y}},setSourcePosition:function(t){this._sourcePosition.x=t.x,this._sourcePosition.y=t.y},getPosVar:function(){return{x:this._posVar.x,y:this._posVar.y}},setPosVar:function(t){this._posVar.x=t.x,this._posVar.y=t.y},getLife:function(){return this.life},setLife:function(t){this.life=t},getLifeVar:function(){return this.lifeVar},setLifeVar:function(t){this.lifeVar=t},getAngle:function(){return this.angle},setAngle:function(t){this.angle=t},getAngleVar:function(){return this.angleVar},setAngleVar:function(t){this.angleVar=t},getGravity:function(){var t=this.modeA.gravity;return cc.p(t.x,t.y)},setGravity:function(t){this.modeA.gravity=t},getSpeed:function(){return this.modeA.speed},setSpeed:function(t){this.modeA.speed=t},getSpeedVar:function(){return this.modeA.speedVar},setSpeedVar:function(t){this.modeA.speedVar=t},getTangentialAccel:function(){return this.modeA.tangentialAccel},setTangentialAccel:function(t){this.modeA.tangentialAccel=t},getTangentialAccelVar:function(){return this.modeA.tangentialAccelVar},setTangentialAccelVar:function(t){this.modeA.tangentialAccelVar=t},getRadialAccel:function(){return this.modeA.radialAccel},setRadialAccel:function(t){this.modeA.radialAccel=t},getRadialAccelVar:function(){return this.modeA.radialAccelVar},setRadialAccelVar:function(t){this.modeA.radialAccelVar=t},getRotationIsDir:function(){return this.modeA.rotationIsDir},setRotationIsDir:function(t){this.modeA.rotationIsDir=t},getStartRadius:function(){return this.modeB.startRadius},setStartRadius:function(t){this.modeB.startRadius=t},getStartRadiusVar:function(){return this.modeB.startRadiusVar},setStartRadiusVar:function(t){this.modeB.startRadiusVar=t},getEndRadius:function(){return this.modeB.endRadius},setEndRadius:function(t){this.modeB.endRadius=t},getEndRadiusVar:function(){return this.modeB.endRadiusVar},setEndRadiusVar:function(t){this.modeB.endRadiusVar=t},getRotatePerSecond:function(){return this.modeB.rotatePerSecond},setRotatePerSecond:function(t){this.modeB.rotatePerSecond=t},getRotatePerSecondVar:function(){return this.modeB.rotatePerSecondVar},setRotatePerSecondVar:function(t){this.modeB.rotatePerSecondVar=t},getStartSize:function(){return this.startSize},setStartSize:function(t){this.startSize=t},getStartSizeVar:function(){return this.startSizeVar},setStartSizeVar:function(t){this.startSizeVar=t},getEndSize:function(){return this.endSize},setEndSize:function(t){this.endSize=t},getEndSizeVar:function(){return this.endSizeVar},setEndSizeVar:function(t){this.endSizeVar=t},getStartColor:function(){return cc.color(this._startColor.r,this._startColor.g,this._startColor.b,this._startColor.a)},setStartColor:function(t){this._startColor.fromColor(t)},getStartColorVar:function(){return cc.color(this._startColorVar.r,this._startColorVar.g,this._startColorVar.b,this._startColorVar.a)},setStartColorVar:function(t){this._startColorVar.fromColor(t)},getEndColor:function(){return cc.color(this._endColor.r,this._endColor.g,this._endColor.b,this._endColor.a)},setEndColor:function(t){this._endColor.fromColor(t)},getEndColorVar:function(){return cc.color(this._endColorVar.r,this._endColorVar.g,this._endColorVar.b,this._endColorVar.a)},setEndColorVar:function(t){this._endColorVar.fromColor(t)},getStartSpin:function(){return this.startSpin},setStartSpin:function(t){this.startSpin=t},getStartSpinVar:function(){return this.startSpinVar},setStartSpinVar:function(t){this.startSpinVar=t},getEndSpin:function(){return this.endSpin},setEndSpin:function(t){this.endSpin=t},getEndSpinVar:function(){return this.endSpinVar},setEndSpinVar:function(t){this.endSpinVar=t},getEmissionRate:function(){return this.emissionRate},setEmissionRate:function(t){this.emissionRate=t},getTotalParticles:function(){return this._totalParticles},setTotalParticles:function(t){this._renderCmd.setTotalParticles(t)},getTexture:function(){return this._texture},setTexture:function(t){t&&(t.loaded?this.setTextureWithRect(t,cc.rect(0,0,t.width,t.height)):(this._textureLoaded=!1,t.once("load",(function(e){this._textureLoaded=!0,this.setTextureWithRect(t,cc.rect(0,0,t.width,t.height))}),this)))},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(t,e){void 0===e?this._blendFunc!==t&&(this._blendFunc=t,this._updateBlendFunc()):this._blendFunc.src===t&&this._blendFunc.dst===e||(this._blendFunc={src:t,dst:e},this._updateBlendFunc())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setOpacityModifyRGB:function(t){this._opacityModifyRGB=t},isBlendAdditive:function(){return this._blendFunc.src===cc.macro.SRC_ALPHA&&this._blendFunc.dst===cc.macro.ONE||this._blendFunc.src===cc.macro.ONE&&this._blendFunc.dst===cc.macro.ONE},setBlendAdditive:function(t){var e=this._blendFunc;t?(e.src=cc.macro.SRC_ALPHA,e.dst=cc.macro.ONE):this._renderCmd._setBlendAdditive()},getPositionType:function(){return this.positionType},setPositionType:function(t){this.positionType=t},isAutoRemoveOnFinish:function(){return this.autoRemoveOnFinish},setAutoRemoveOnFinish:function(t){this.autoRemoveOnFinish=t},getEmitterMode:function(){return this.emitterMode},setEmitterMode:function(t){this.emitterMode=t},init:function(){return this.initWithTotalParticles(150)},initWithFile:function(t){this._plistFile=t;var e=cc.loader.getRes(t);return e?this.initWithDictionary(e,""):(cc.logID(6008),!1)},getBoundingBoxToWorld:function(){return cc.rect(0,0,cc._canvas.width,cc._canvas.height)},initWithDictionary:function(t,e){var i=!1,s=null,o=this._valueForKey,a=parseInt(o("maxParticles",t));if(this.initWithTotalParticles(a)){this.angle=parseFloat(o("angle",t)),this.angleVar=parseFloat(o("angleVariance",t)),this.duration=parseFloat(o("duration",t)),this._blendFunc.src=parseInt(o("blendFuncSource",t)),this._blendFunc.dst=parseInt(o("blendFuncDestination",t));var c=this._startColor;c.r=255*parseFloat(o("startColorRed",t)),c.g=255*parseFloat(o("startColorGreen",t)),c.b=255*parseFloat(o("startColorBlue",t)),c.a=255*parseFloat(o("startColorAlpha",t));var h=this._startColorVar;h.r=255*parseFloat(o("startColorVarianceRed",t)),h.g=255*parseFloat(o("startColorVarianceGreen",t)),h.b=255*parseFloat(o("startColorVarianceBlue",t)),h.a=255*parseFloat(o("startColorVarianceAlpha",t));var l=this._endColor;l.r=255*parseFloat(o("finishColorRed",t)),l.g=255*parseFloat(o("finishColorGreen",t)),l.b=255*parseFloat(o("finishColorBlue",t)),l.a=255*parseFloat(o("finishColorAlpha",t));var u=this._endColorVar;if(u.r=255*parseFloat(o("finishColorVarianceRed",t)),u.g=255*parseFloat(o("finishColorVarianceGreen",t)),u.b=255*parseFloat(o("finishColorVarianceBlue",t)),u.a=255*parseFloat(o("finishColorVarianceAlpha",t)),this.startSize=parseFloat(o("startParticleSize",t)),this.startSizeVar=parseFloat(o("startParticleSizeVariance",t)),this.endSize=parseFloat(o("finishParticleSize",t)),this.endSizeVar=parseFloat(o("finishParticleSizeVariance",t)),this.setPosition(parseFloat(o("sourcePositionx",t)),parseFloat(o("sourcePositiony",t))),this._posVar.x=parseFloat(o("sourcePositionVariancex",t)),this._posVar.y=parseFloat(o("sourcePositionVariancey",t)),this.startSpin=parseFloat(o("rotationStart",t)),this.startSpinVar=parseFloat(o("rotationStartVariance",t)),this.endSpin=parseFloat(o("rotationEnd",t)),this.endSpinVar=parseFloat(o("rotationEndVariance",t)),this.emitterMode=parseInt(o("emitterType",t)),this.emitterMode===_ccsg.ParticleSystem.Mode.GRAVITY){var _=this.modeA;_.gravity.x=parseFloat(o("gravityx",t)),_.gravity.y=parseFloat(o("gravityy",t)),_.speed=parseFloat(o("speed",t)),_.speedVar=parseFloat(o("speedVariance",t));var d=o("radialAcceleration",t);_.radialAccel=d?parseFloat(d):0,d=o("radialAccelVariance",t),_.radialAccelVar=d?parseFloat(d):0,d=o("tangentialAcceleration",t),_.tangentialAccel=d?parseFloat(d):0,d=o("tangentialAccelVariance",t),_.tangentialAccelVar=d?parseFloat(d):0;var f=o("rotationIsDir",t);null!==f?(f=f.toString().toLowerCase(),_.rotationIsDir="true"===f||"1"===f):_.rotationIsDir=!1}else{if(this.emitterMode!==_ccsg.ParticleSystem.Mode.RADIUS)return cc.logID(6009),!1;var p=this.modeB;p.startRadius=parseFloat(o("maxRadius",t)),p.startRadiusVar=parseFloat(o("maxRadiusVariance",t)),p.endRadius=parseFloat(o("minRadius",t)),p.endRadiusVar=0,p.rotatePerSecond=parseFloat(o("rotatePerSecond",t)),p.rotatePerSecondVar=parseFloat(o("rotatePerSecondVariance",t))}this.life=parseFloat(o("particleLifespan",t)),this.lifeVar=parseFloat(o("particleLifespanVariance",t)),this.emissionRate=this._totalParticles/this.life,this._opacityModifyRGB=!1;var m=o("textureFileName",t),g=cc.path.changeBasename(this._plistFile,m),y=cc.textureCache.getTextureForKey(g);if(y)this.setTexture(y);else{var v=o("textureImageData",t);if(v&&0!==v.length){if(!(s=cc.Codec.unzipBase64AsArray(v,1)))return cc.logID(6010),!1;var x=cc.getImageFormatByData(s);if(x!==cc.ImageFormat.TIFF&&x!==cc.ImageFormat.PNG)return cc.logID(6011),!1;var C=document.createElement("canvas");if(x===cc.ImageFormat.PNG){new n(s).render(C)}else r.parseTIFF(s,C);cc.textureCache.cacheImage(g,C);var T=cc.textureCache.getTextureForKey(g);T||cc.logID(6012),this.setTexture(T)}else{if(!(y=cc.textureCache.addImage(g)))return!1;this.setTexture(y)}}i=!0}return i},initWithTotalParticles:function(t){this._totalParticles=t;var e=this._particles;if(!e)return cc.logID(6013),!1;e.length=t;for(var i=0;i<t;i++)e[i]=new cc.Particle;return this._allocatedParticles=t,this._isActive=!0,this._blendFunc.src=cc.macro.BLEND_SRC,this._blendFunc.dst=cc.macro.BLEND_DST,this.positionType=_ccsg.ParticleSystem.Type.FREE,this.emitterMode=_ccsg.ParticleSystem.Mode.GRAVITY,this.autoRemoveOnFinish=!1,this._renderCmd._initWithTotalParticles(t),!0},addParticle:function(){if(this.isFull())return!1;var t=this._renderCmd.addParticle();return this.initParticle(t),++this.particleCount,!0},initParticle:function(t){var e=cc.randomMinus1To1;t.timeToLive=this.life+this.lifeVar*e(),t.timeToLive=Math.max(0,t.timeToLive),t.pos.x=this._sourcePosition.x+this._posVar.x*e(),t.pos.y=this._sourcePosition.y+this._posVar.y*e();var i,n,r=this._startColor,s=this._startColorVar,o=this._endColor,a=this._endColorVar;i={r:cc.clampf(r.r+s.r*e(),0,255),g:cc.clampf(r.g+s.g*e(),0,255),b:cc.clampf(r.b+s.b*e(),0,255),a:cc.clampf(r.a+s.a*e(),0,255)},n={r:cc.clampf(o.r+a.r*e(),0,255),g:cc.clampf(o.g+a.g*e(),0,255),b:cc.clampf(o.b+a.b*e(),0,255),a:cc.clampf(o.a+a.a*e(),0,255)},t.color=i;var c=t.deltaColor,h=t.timeToLive;c.r=(n.r-i.r)/h,c.g=(n.g-i.g)/h,c.b=(n.b-i.b)/h,c.a=(n.a-i.a)/h;var l=this.startSize+this.startSizeVar*e();if(l=Math.max(0,l),t.size=l,this.endSize===_ccsg.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE)t.deltaSize=0;else{var u=this.endSize+this.endSizeVar*e();u=Math.max(0,u),t.deltaSize=(u-l)/h}var _=this.startSpin+this.startSpinVar*e(),d=this.endSpin+this.endSpinVar*e();t.rotation=_,t.deltaRotation=(d-_)/h,this.positionType===_ccsg.ParticleSystem.Type.FREE?t.startPos=this.convertToWorldSpace(this._pointZeroForParticle):this.positionType===_ccsg.ParticleSystem.Type.RELATIVE&&(t.startPos.x=this._position.x,t.startPos.y=this._position.y);var f=cc.degreesToRadians(this.angle+this.angleVar*e());if(this.emitterMode===_ccsg.ParticleSystem.Mode.GRAVITY){var p=this.modeA,m=t.modeA,g=p.speed+p.speedVar*e();m.dir.x=Math.cos(f),m.dir.y=Math.sin(f),cc.pMultIn(m.dir,g),m.radialAccel=p.radialAccel+p.radialAccelVar*e(),m.tangentialAccel=p.tangentialAccel+p.tangentialAccelVar*e(),p.rotationIsDir&&(t.rotation=-cc.radiansToDegrees(cc.pToAngle(m.dir)))}else{var y=this.modeB,v=t.modeB,x=y.startRadius+y.startRadiusVar*e(),C=y.endRadius+y.endRadiusVar*e();v.radius=x,v.deltaRadius=y.endRadius===_ccsg.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS?0:(C-x)/h,v.angle=f,v.degreesPerSecond=cc.degreesToRadians(y.rotatePerSecond+y.rotatePerSecondVar*e())}},stopSystem:function(){this._isActive=!1,this._elapsed=this.duration,this._emitCounter=0},resetSystem:function(){this._isActive=!0,this._elapsed=0;var t=this._particles;for(this._particleIdx=0;this._particleIdx<this.particleCount;++this._particleIdx)t[this._particleIdx].timeToLive=0},isFull:function(){return this.particleCount>=this._totalParticles},updateQuadWithParticle:function(t,e){this._renderCmd.updateQuadWithParticle(t,e)},postStep:function(){this._renderCmd.postStep()},update:function(t){if(this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty),this._isActive&&this.emissionRate){var e=1/this.emissionRate;for(this.particleCount<this._totalParticles&&(this._emitCounter+=t);this.particleCount<this._totalParticles&&this._emitCounter>e;)this.addParticle(),this._emitCounter-=e;this._elapsed+=t,-1!==this.duration&&this.duration<this._elapsed&&this.stopSystem()}this._particleIdx=0;var i=this.getWorldToNodeTransform(),n=cc.Particle.TemporaryPoints[0];if(this.positionType===_ccsg.ParticleSystem.Type.FREE?cc.pIn(n,this.convertToWorldSpace(this._pointZeroForParticle)):this.positionType===_ccsg.ParticleSystem.Type.RELATIVE&&(n.x=this._position.x,n.y=this._position.y),this._visible){for(var r=cc.Particle.TemporaryPoints[1],s=cc.Particle.TemporaryPoints[2],o=cc.Particle.TemporaryPoints[3],a=this._particles;this._particleIdx<this.particleCount;){cc.pZeroIn(r),cc.pZeroIn(s),cc.pZeroIn(o);var c=a[this._particleIdx];if(c.timeToLive-=t,c.timeToLive>0){if(this.emitterMode===_ccsg.ParticleSystem.Mode.GRAVITY){var h=o,l=r,u=s;c.pos.x||c.pos.y?(cc.pIn(l,c.pos),cc.pNormalizeIn(l)):cc.pZeroIn(l),cc.pIn(u,l),cc.pMultIn(l,c.modeA.radialAccel);var _=u.x;u.x=-u.y,u.y=_,cc.pMultIn(u,c.modeA.tangentialAccel),cc.pIn(h,l),cc.pAddIn(h,u),cc.pAddIn(h,this.modeA.gravity),cc.pMultIn(h,t),cc.pAddIn(c.modeA.dir,h),cc.pIn(h,c.modeA.dir),cc.pMultIn(h,t),cc.pAddIn(c.pos,h)}else{var d=c.modeB;d.angle+=d.degreesPerSecond*t,d.radius+=d.deltaRadius*t,c.pos.x=-Math.cos(d.angle)*d.radius,c.pos.y=-Math.sin(d.angle)*d.radius}this._renderCmd._updateDeltaColor(c,t),c.size+=c.deltaSize*t,c.size=Math.max(0,c.size),c.rotation+=c.deltaRotation*t;var f=r;if(this.positionType===_ccsg.ParticleSystem.Type.FREE||this.positionType===_ccsg.ParticleSystem.Type.RELATIVE){var p=s,m=o;cc._pointApplyAffineTransformIn(n,i,p),cc._pointApplyAffineTransformIn(c.startPos,i,m),cc.pSubIn(p,m),cc.pIn(f,c.pos),cc.pSubIn(f,p)}else cc.pIn(f,c.pos);this._renderCmd.updateParticlePosition(c,f),++this._particleIdx}else{if(this._particleIdx!==this.particleCount-1){var g=a[this._particleIdx];a[this._particleIdx]=a[this.particleCount-1],a[this.particleCount-1]=g}if(--this.particleCount,0===this.particleCount&&this.autoRemoveOnFinish)return this.unscheduleUpdate(),this._parent.removeChild(this,!0),void(this._renderCmd.updateLocalBB&&this._renderCmd.updateLocalBB())}}this._renderCmd.updateLocalBB&&this._renderCmd.updateLocalBB()}this.postStep()},updateWithNoTime:function(){this.update(0)},_valueForKey:function(t,e){if(e){var i=e[t];return null!=i?i:""}return""},_updateBlendFunc:function(){var t=this._texture;if(t&&t instanceof cc.Texture2D){this._opacityModifyRGB=!1;var e=this._blendFunc;e.src===cc.macro.BLEND_SRC&&e.dst===cc.macro.BLEND_DST&&(t.hasPremultipliedAlpha()?this._opacityModifyRGB=!0:(e.src=cc.macro.SRC_ALPHA,e.dst=cc.macro.ONE_MINUS_SRC_ALPHA))}},clone:function(){var t=new _ccsg.ParticleSystem;if(t.initWithTotalParticles(this.getTotalParticles())){t.setAngle(this.getAngle()),t.setAngleVar(this.getAngleVar()),t.setDuration(this.getDuration());var e=this.getBlendFunc();if(t.setBlendFunc(e.src,e.dst),t.setStartColor(this.getStartColor()),t.setStartColorVar(this.getStartColorVar()),t.setEndColor(this.getEndColor()),t.setEndColorVar(this.getEndColorVar()),t.setStartSize(this.getStartSize()),t.setStartSizeVar(this.getStartSizeVar()),t.setEndSize(this.getEndSize()),t.setEndSizeVar(this.getEndSizeVar()),t.setPosition(cc.p(this.x,this.y)),t.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y)),t.setPositionType(this.getPositionType()),t.setStartSpin(this.getStartSpin()||0),t.setStartSpinVar(this.getStartSpinVar()||0),t.setEndSpin(this.getEndSpin()||0),t.setEndSpinVar(this.getEndSpinVar()||0),t.setEmitterMode(this.getEmitterMode()),this.getEmitterMode()===_ccsg.ParticleSystem.Mode.GRAVITY){var i=this.getGravity();t.setGravity(cc.p(i.x,i.y)),t.setSpeed(this.getSpeed()),t.setSpeedVar(this.getSpeedVar()),t.setRadialAccel(this.getRadialAccel()),t.setRadialAccelVar(this.getRadialAccelVar()),t.setTangentialAccel(this.getTangentialAccel()),t.setTangentialAccelVar(this.getTangentialAccelVar())}else this.getEmitterMode()===_ccsg.ParticleSystem.Mode.RADIUS&&(t.setStartRadius(this.getStartRadius()),t.setStartRadiusVar(this.getStartRadiusVar()),t.setEndRadius(this.getEndRadius()),t.setEndRadiusVar(this.getEndRadiusVar()),t.setRotatePerSecond(this.getRotatePerSecond()),t.setRotatePerSecondVar(this.getRotatePerSecondVar()));t.setLife(this.getLife()),t.setLifeVar(this.getLifeVar()),t.setEmissionRate(this.getEmissionRate()),t.setOpacityModifyRGB(this.isOpacityModifyRGB());var n=this.getTexture();if(n){var r=n.getContentSize();t.setTextureWithRect(n,cc.rect(0,0,r.width,r.height))}}return t},setDisplayFrame:function(t){if(t){var e=t.getOffset();0===e.x&&0===e.y||cc.logID(6015);var i=t.getTexture();this._texture!==i&&this.setTexture(i)}},setTextureWithRect:function(t,e){this._texture!==t&&(this._texture=t,this._updateBlendFunc()),this.initTexCoordsWithRect(e)},listenBackToForeground:function(t){}});var s=_ccsg.ParticleSystem.prototype;s.opacityModifyRGB,cc.defineGetterSetter(s,"opacityModifyRGB",s.isOpacityModifyRGB,s.setOpacityModifyRGB),s.active,cc.defineGetterSetter(s,"active",s.isActive),s.sourcePos,cc.defineGetterSetter(s,"sourcePos",s.getSourcePosition,s.setSourcePosition),s.posVar,cc.defineGetterSetter(s,"posVar",s.getPosVar,s.setPosVar),s.gravity,cc.defineGetterSetter(s,"gravity",s.getGravity,s.setGravity),s.speed,cc.defineGetterSetter(s,"speed",s.getSpeed,s.setSpeed),s.speedVar,cc.defineGetterSetter(s,"speedVar",s.getSpeedVar,s.setSpeedVar),s.tangentialAccel,cc.defineGetterSetter(s,"tangentialAccel",s.getTangentialAccel,s.setTangentialAccel),s.tangentialAccelVar,cc.defineGetterSetter(s,"tangentialAccelVar",s.getTangentialAccelVar,s.setTangentialAccelVar),s.radialAccel,cc.defineGetterSetter(s,"radialAccel",s.getRadialAccel,s.setRadialAccel),s.radialAccelVar,cc.defineGetterSetter(s,"radialAccelVar",s.getRadialAccelVar,s.setRadialAccelVar),s.rotationIsDir,cc.defineGetterSetter(s,"rotationIsDir",s.getRotationIsDir,s.setRotationIsDir),s.startRadius,cc.defineGetterSetter(s,"startRadius",s.getStartRadius,s.setStartRadius),s.startRadiusVar,cc.defineGetterSetter(s,"startRadiusVar",s.getStartRadiusVar,s.setStartRadiusVar),s.endRadius,cc.defineGetterSetter(s,"endRadius",s.getEndRadius,s.setEndRadius),s.endRadiusVar,cc.defineGetterSetter(s,"endRadiusVar",s.getEndRadiusVar,s.setEndRadiusVar),s.rotatePerS,cc.defineGetterSetter(s,"rotatePerS",s.getRotatePerSecond,s.setRotatePerSecond),s.rotatePerSVar,cc.defineGetterSetter(s,"rotatePerSVar",s.getRotatePerSecondVar,s.setRotatePerSecondVar),s.startColor,cc.defineGetterSetter(s,"startColor",s.getStartColor,s.setStartColor),s.startColorVar,cc.defineGetterSetter(s,"startColorVar",s.getStartColorVar,s.setStartColorVar),s.endColor,cc.defineGetterSetter(s,"endColor",s.getEndColor,s.setEndColor),s.endColorVar,cc.defineGetterSetter(s,"endColorVar",s.getEndColorVar,s.setEndColorVar),s.totalParticles,cc.defineGetterSetter(s,"totalParticles",s.getTotalParticles,s.setTotalParticles),s.texture,cc.defineGetterSetter(s,"texture",s.getTexture,s.setTexture),_ccsg.ParticleSystem.ModeA=function(t,e,i,n,r,s,o,a){this.gravity=t||cc.p(0,0),this.speed=e||0,this.speedVar=i||0,this.tangentialAccel=n||0,this.tangentialAccelVar=r||0,this.radialAccel=s||0,this.radialAccelVar=o||0,this.rotationIsDir=a||!1},_ccsg.ParticleSystem.ModeB=function(t,e,i,n,r,s){this.startRadius=t||0,this.startRadiusVar=e||0,this.endRadius=i||0,this.endRadiusVar=n||0,this.rotatePerSecond=r||0,this.rotatePerSecondVar=s||0},_ccsg.ParticleSystem.DURATION_INFINITY=-1,_ccsg.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE=-1,_ccsg.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS=-1,_ccsg.ParticleSystem.Mode=cc.Enum({GRAVITY:0,RADIUS:1}),_ccsg.ParticleSystem.Type=cc.Enum({FREE:0,RELATIVE:1,GROUPED:2})}),{"../compression/ZipUtils":28,"./CCPNGReader":260,"./CCTIFFReader":266}],264:[(function(t,e,i){_ccsg.ParticleSystem.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._pointRect=cc.rect(0,0,0,0),this._localRegion=new cc.Region,this._tintCache=null};var n=_ccsg.ParticleSystem.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=_ccsg.ParticleSystem.CanvasRenderCmd,n.updateQuadWithParticle=function(t,e){},n.updateParticlePosition=function(t,e){cc.pIn(t.drawPos,e)};var r=new cc.Region,s=new cc.Rect;n.updateLocalBB=function(){var t=this._localRegion,e=this._node._particles;t.setEmpty();for(var i=e.length-1;i>=0;--i){var n=e[i],o=n.drawPos,a=1.415*n.size;r.setTo(o.x-a,o.y-a,o.x+a,o.y+a),t.union(r)}s.x=t._minX,s.y=t._minY,s.width=t._maxX-t._minX,s.height=t._maxY-t._minY},n.getLocalBB=function(){return s},n.updateStatus=function(){this.originUpdateStatus(),this._updateCurrentRegions(),this._regionFlag=_ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble,this._dirtyFlag&=~_ccsg.Node._dirtyFlags.contentDirty},n.rendering=function(t,e,i){var n=t||cc._renderContext,r=n.getContext(),s=this._node,o=this._pointRect;n.setTransform(this._worldTransform,e,i),n.save(),s.isBlendAdditive()?r.globalCompositeOperation="lighter":r.globalCompositeOperation="source-over";var a,c,h,l=this._node.particleCount,u=this._node._particles;if(s._texture){if(!s._texture.loaded)return void n.restore();var _=s._texture.getHtmlElementObj();if(!_.width||!_.height)return void n.restore();var d=_;for(a=0;a<l;a++)if(c=u[a],0|.5*c.size,0!==(h=c.color.a/255)){r.globalAlpha=h,r.save(),r.translate(0|c.drawPos.x,-(0|c.drawPos.y));var f=4*Math.floor(c.size/4),p=o.width,m=o.height;r.scale(Math.max(1/p*f,1e-6),Math.max(1/m*f,1e-6)),c.rotation&&r.rotate(cc.degreesToRadians(c.rotation)),d=c.isChangeColor?this._changeTextureColor(s._texture,c.color,this._pointRect):_,r.drawImage(d,-(0|p/2),-(0|m/2)),r.restore()}cc.g_NumberOfDraws++}n.restore()},n._changeTextureColor=function(t,e,i){this._tintCache||(this._tintCache=document.createElement("canvas"));var n=this._tintCache,r=t.getContentSize();return n.width=r.width,n.height=r.height,t._generateColorTexture(e.r,e.g,e.b,i,n)},n.initTexCoordsWithRect=function(t){this._pointRect=t},n.setTotalParticles=function(t){this._node._totalParticles=t<200?t:200},n.addParticle=function(){var t,e=this._node,i=e._particles;return e.particleCount<i.length?t=i[e.particleCount]:(t=new cc.Particle,i.push(t)),t},n._setupVBO=function(){},n._allocMemory=function(){return!0},n.postStep=function(){},n._setBlendAdditive=function(){var t=this._node._blendFunc;t.src=cc.macro.BLEND_SRC,t.dst=cc.macro.BLEND_DST},n._initWithTotalParticles=function(t){},n._updateDeltaColor=function(t,e){this._node._dontTint||(t.color.r+=t.deltaColor.r*e,t.color.g+=t.deltaColor.g*e,t.color.b+=t.deltaColor.b*e,t.color.a+=t.deltaColor.a*e,t.isChangeColor=!0)}}),{}],265:[(function(t,e,i){_ccsg.ParticleSystem.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._matrix=new cc.math.Matrix4,this._matrix.identity(),this._buffersVBO=[0,0],this._quads=[],this._indices=[],this._quadsArrayBuffer=null};var n=_ccsg.ParticleSystem.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);n.constructor=_ccsg.ParticleSystem.WebGLRenderCmd,n.initIndices=function(t){for(var e=this._indices,i=0,n=t;i<n;++i){var r=6*i,s=4*i;e[r+0]=s+0,e[r+1]=s+1,e[r+2]=s+2,e[r+5]=s+1,e[r+4]=s+2,e[r+3]=s+3}},n.isDifferentTexture=function(t,e){return t===e},n.updateParticlePosition=function(t,e){this.updateQuadWithParticle(t,e)},n.updateQuadWithParticle=function(t,e){var i=null,n=this._node;i=this._quads[n._particleIdx];var r,s,o,a;n._opacityModifyRGB?(r=0|t.color.r*t.color.a/255,s=0|t.color.g*t.color.a/255,o=0|t.color.b*t.color.a/255):(r=0|t.color.r,s=0|t.color.g,o=0|t.color.b),a=0|t.color.a;var c=i.bl.colors,h=i.br.colors,l=i.tl.colors,u=i.tr.colors;c.r=h.r=l.r=u.r=r,c.g=h.g=l.g=u.g=s,c.b=h.b=l.b=u.b=o,c.a=h.a=l.a=u.a=a;var _=t.size/2;if(t.rotation){var d=-_,f=-_,p=_,m=_,g=e.x,y=e.y,v=-cc.degreesToRadians(t.rotation),x=Math.cos(v),C=Math.sin(v),T=d*x-f*C+g,b=d*C+f*x+y,A=p*x-f*C+g,S=p*C+f*x+y,w=p*x-m*C+g,E=p*C+m*x+y,I=d*x-m*C+g,R=d*C+m*x+y;i.bl.vertices.x=T,i.bl.vertices.y=b,i.br.vertices.x=A,i.br.vertices.y=S,i.tl.vertices.x=I,i.tl.vertices.y=R,i.tr.vertices.x=w,i.tr.vertices.y=E}else i.bl.vertices.x=e.x-_,i.bl.vertices.y=e.y-_,i.br.vertices.x=e.x+_,i.br.vertices.y=e.y-_,i.tl.vertices.x=e.x-_,i.tl.vertices.y=e.y+_,i.tr.vertices.x=e.x+_,i.tr.vertices.y=e.y+_},n.rendering=function(t){var e=this._node;if(e._texture){var i=t||cc._renderContext,n=this._worldTransform,r=this._matrix.mat;r[0]=n.a,r[4]=n.c,r[12]=n.tx,r[1]=n.b,r[5]=n.d,r[13]=n.ty,this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._matrix),cc.gl.bindTexture2DN(0,e._texture),cc.gl.blendFuncForParticle(e._blendFunc.src,e._blendFunc.dst),i.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION),i.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_COLOR),i.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_TEX_COORDS),i.bindBuffer(i.ARRAY_BUFFER,this._buffersVBO[0]),i.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION,3,i.FLOAT,!1,24,0),i.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR,4,i.UNSIGNED_BYTE,!0,24,12),i.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS,2,i.FLOAT,!1,24,16),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]),i.drawElements(i.TRIANGLES,6*e._particleIdx,i.UNSIGNED_SHORT,0)}},n.initTexCoordsWithRect=function(t){var e=this._node,i=e.texture,n=t.width,r=t.height;i&&(n=i.getPixelWidth(),r=i.getPixelHeight());var s,o,a,c;cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(s=(2*t.x+1)/(2*n),o=(2*t.y+1)/(2*r),a=s+(2*t.width-2)/(2*n),c=o+(2*t.height-2)/(2*r)):(s=t.x/n,o=t.y/r,a=s+t.width/n,c=o+t.height/r);var h=c;c=o,o=h;for(var l=this._quads,u=e._totalParticles,_=0;_<u;_++){l[_]||(l[_]=cc.V3F_C4B_T2F_QuadZero());var d=l[_];d.bl.texCoords.u=s,d.bl.texCoords.v=o,d.br.texCoords.u=a,d.br.texCoords.v=o,d.tl.texCoords.u=s,d.tl.texCoords.v=c,d.tr.texCoords.u=a,d.tr.texCoords.v=c}},n.setTotalParticles=function(t){var e=this._node;if(t>e._allocatedParticles){var i=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;this._indices=new Uint16Array(6*t);var n=new ArrayBuffer(t*i),r=e._particles;r.length=0;var s=this._quads;s.length=0;for(var o=0;o<t;o++)r[o]=new cc.Particle,s[o]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,n,o*i);e._allocatedParticles=t,e._totalParticles=t,this._quadsArrayBuffer=n,this.initIndices(t),this._setupVBO(),e._texture&&this.initTexCoordsWithRect(cc.rect(0,0,e._texture.width,e._texture.height))}else e._totalParticles=t;e.resetSystem()},n.addParticle=function(){var t=this._node;return t._particles[t.particleCount]},n._setupVBO=function(){var t=cc._renderContext;this._buffersVBO[0]=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._buffersVBO[0]),t.bufferData(t.ARRAY_BUFFER,this._quadsArrayBuffer,t.DYNAMIC_DRAW),this._buffersVBO[1]=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indices,t.STATIC_DRAW)},n._allocMemory=function(){var t=this._node,e=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,i=t._totalParticles,n=this._quads;n.length=0,this._indices=new Uint16Array(6*i);for(var r=new ArrayBuffer(e*i),s=0;s<i;s++)n[s]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,r,s*e);return n&&this._indices?(this._quadsArrayBuffer=r,!0):(cc.logID(6013),!1)},n.postStep=function(){var t=cc._renderContext;t.bindBuffer(t.ARRAY_BUFFER,this._buffersVBO[0]),t.bufferSubData(t.ARRAY_BUFFER,0,this._quadsArrayBuffer)},n._setBlendAdditive=function(){var t=this._node._blendFunc;this._texture&&!this._texture.hasPremultipliedAlpha()?(t.src=cc.macro.SRC_ALPHA,t.dst=cc.macro.ONE_MINUS_SRC_ALPHA):(t.src=cc.macro.BLEND_SRC,t.dst=cc.macro.BLEND_DST)},n._initWithTotalParticles=function(t){if(!this._allocMemory())return!1;this.initIndices(t),this._setupVBO(),this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)},n._updateDeltaColor=function(t,e){t.color.r+=t.deltaColor.r*e,t.color.g+=t.deltaColor.g*e,t.color.b+=t.deltaColor.b*e,t.color.a+=t.deltaColor.a*e,t.isChangeColor=!0}}),{}],266:[(function(t,e,i){var n={_littleEndian:!1,_tiffData:null,_fileDirectories:[],getUint8:function(t){return this._tiffData[t]},getUint16:function(t){return this._littleEndian?this._tiffData[t+1]<<8|this._tiffData[t]:this._tiffData[t]<<8|this._tiffData[t+1]},getUint32:function(t){var e=this._tiffData;return this._littleEndian?e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]:e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]},checkLittleEndian:function(){var t=this.getUint16(0);if(18761===t)this.littleEndian=!0;else{if(19789!==t)throw console.log(t),TypeError("Invalid byte order value.");this.littleEndian=!1}return this.littleEndian},hasTowel:function(){if(42!==this.getUint16(2))throw RangeError("You forgot your towel!");return!0},getFieldTypeName:function(t){var e=this.fieldTypeNames;return t in e?e[t]:null},getFieldTagName:function(t){var e=this.fieldTagNames;return t in e?e[t]:(console.log("Unknown Field Tag:",t),"Tag"+t)},getFieldTypeLength:function(t){return-1!==["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(t)?1:-1!==["SHORT","SSHORT"].indexOf(t)?2:-1!==["LONG","SLONG","FLOAT"].indexOf(t)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(t)?8:null},getFieldValues:function(t,e,i,n){var r=[],s=this.getFieldTypeLength(e);if(s*i<=4)!1===this.littleEndian?r.push(n>>>8*(4-s)):r.push(n);else for(var o=0;o<i;o++){var a=s*o;s>=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(r.push(this.getUint32(n+a)),r.push(this.getUint32(n+a+4))):cc.logID(8e3):r.push(this.getBytes(s,n+a))}return"ASCII"===e&&r.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),r},getBytes:function(t,e){if(t<=0)cc.logID(8001);else{if(t<=1)return this.getUint8(e);if(t<=2)return this.getUint16(e);if(t<=3)return this.getUint32(e)>>>8;if(t<=4)return this.getUint32(e);cc.logID(8002)}},getBits:function(t,e,i){i=i||0;var n,r,s=e+Math.floor(i/8),o=i+t,a=32-t;return o<=0?console.log("No bits requested"):o<=8?(n=24+i,r=this.getUint8(s)):o<=16?(n=16+i,r=this.getUint16(s)):o<=32?(n=i,r=this.getUint32(s)):console.log("Too many bits requested"),{bits:r<<n>>>a,byteOffset:s+Math.floor(o/8),bitOffset:o%8}},parseFileDirectory:function(t){for(var e=this.getUint16(t),i=[],n=t+2,r=0;r<e;n+=12,r++){var s=this.getUint16(n),o=this.getUint16(n+2),a=this.getUint32(n+4),c=this.getUint32(n+8),h=this.getFieldTagName(s),l=this.getFieldTypeName(o),u=this.getFieldValues(h,l,a,c);i[h]={type:l,values:u}}this._fileDirectories.push(i);var _=this.getUint32(n);0!==_&&this.parseFileDirectory(_)},clampColorSample:function(t,e){var i=Math.pow(2,8-e);return Math.floor(t*i+(i-1))},parseTIFF:function(t,e){if(e=e||document.createElement("canvas"),this._tiffData=t,this.canvas=e,this.checkLittleEndian(),this.hasTowel()){var i=this.getUint32(4);this._fileDirectories.length=0,this.parseFileDirectory(i);var n=this._fileDirectories[0],r=n.ImageWidth.values[0],s=n.ImageLength.values[0];this.canvas.width=r,this.canvas.height=s;var o=[],a=n.Compression?n.Compression.values[0]:1,c=n.SamplesPerPixel.values[0],h=[],l=0,u=!1;if(n.BitsPerSample.values.forEach((function(t,e,i){h[e]={bitsPerSample:t,hasBytesPerSample:!1,bytesPerSample:void 0},t%8==0&&(h[e].hasBytesPerSample=!0,h[e].bytesPerSample=t/8),l+=t}),this),l%8==0){u=!0;var _=l/8}var d=n.StripOffsets.values,f=d.length;if(n.StripByteCounts)var p=n.StripByteCounts.values;else{if(cc.logID(8003),1!==f)throw Error("Cannot recover from missing StripByteCounts");p=[Math.ceil(r*s*l/8)]}for(var m=0;m<f;m++){var g=d[m];o[m]=[];for(var y=p[m],v=0,x=0,C=1,T=!0,b=[],A=0,S=0,w=0;v<y;v+=C)switch(a){case 1:var E=0;for(b=[];E<c;E++){if(!h[E].hasBytesPerSample){var I=this.getBits(h[E].bitsPerSample,g+v,x);throw b.push(I.bits),v=I.byteOffset-g,x=I.bitOffset,RangeError("Cannot handle sub-byte bits per sample")}var R=h[E].bytesPerSample*E;b.push(this.getBytes(h[E].bytesPerSample,g+v+R))}if(o[m].push(b),!u)throw C=0,RangeError("Cannot handle sub-byte bits per pixel");C=_;break;case 2:case 3:case 4:case 5:case 6:case 7:break;case 32773:if(T){T=!1;var P=1,O=1,B=this.getInt8(g+v);B>=0&&B<=127?P=B+1:B>=-127&&B<=-1?O=1-B:T=!0}else{var D=this.getUint8(g+v);for(E=0;E<O;E++){if(!h[S].hasBytesPerSample)throw RangeError("Cannot handle sub-byte bits per sample");w=w<<8*A|D,++A===h[S].bytesPerSample&&(b.push(w),w=A=0,S++),S===c&&(o[m].push(b),b=[],S=0)}0===--P&&(T=!0)}C=1}}if(e.getContext){var M=this.canvas.getContext("2d");M.fillStyle="rgba(255, 255, 255, 0)";var L=n.RowsPerStrip?n.RowsPerStrip.values[0]:s,N=o.length,F=s%L,k=0===F?L:F,z=L,V=0,G=n.PhotometricInterpretation.values[0],W=[],U=0;if(n.ExtraSamples&&(U=(W=n.ExtraSamples.values).length),n.ColorMap)var j=n.ColorMap.values,X=Math.pow(2,h[0].bitsPerSample);for(m=0;m<N;m++){m+1===N&&(z=k);for(var Y=o[m].length,H=V*m,q=0,J=0;J<Y;q++)for(var Z=0;Z<r;Z++,J++){var Q=o[m][J],K=0,$=0,tt=0,et=1;if(U>0)for(var it=0;it<U;it++)if(1===W[it]||2===W[it]){et=Q[3+it]/256;break}switch(G){case 0:if(h[0].hasBytesPerSample)var nt=Math.pow(16,2*h[0].bytesPerSample);Q.forEach((function(t,e,i){i[e]=nt-t}));case 1:K=$=tt=this.clampColorSample(Q[0],h[0].bitsPerSample);break;case 2:K=this.clampColorSample(Q[0],h[0].bitsPerSample),$=this.clampColorSample(Q[1],h[1].bitsPerSample),tt=this.clampColorSample(Q[2],h[2].bitsPerSample);break;case 3:if(void 0===j)throw Error("Palette image missing color map");var rt=Q[0];K=this.clampColorSample(j[rt],16),$=this.clampColorSample(j[X+rt],16),tt=this.clampColorSample(j[2*X+rt],16);break;default:throw RangeError("Unknown Photometric Interpretation:",G)}M.fillStyle="rgba("+K+", "+$+", "+tt+", "+et+")",M.fillRect(Z,H+q,1,1)}V=z}}return this.canvas}},fieldTagNames:{315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop"},fieldTypeNames:{1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"}};e.exports=n}),{}],267:[(function(t,e,i){cc.RenderTexture=_ccsg.Node.extend({sprite:null,clearFlags:0,clearDepthVal:0,autoDraw:!1,_texture:null,_pixelFormat:0,clearStencilVal:0,_clearColor:null,_className:"RenderTexture",ctor:function(t,e,i,n){_ccsg.Node.prototype.ctor.call(this),this._cascadeColorEnabled=!0,this._cascadeOpacityEnabled=!0,this._pixelFormat=cc.Texture2D.PixelFormat.RGBA8888,this._clearColor=new cc.Color(0,0,0,255),void 0!==t&&void 0!==e&&(i=i||cc.Texture2D.PixelFormat.RGBA8888,n=n||0,this.initWithWidthAndHeight(t,e,i,n)),this.setAnchorPoint(0,0)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.RenderTexture.CanvasRenderCmd(this):new cc.RenderTexture.WebGLRenderCmd(this)},visit:function(t){var e=this._renderCmd,i=t?t._renderCmd:null;if(this._visible){var n=cc.renderer;e.visit(i),n.pushRenderCommand(e),this.sprite.visit(this),e._dirtyFlag=0}else e._propagateFlagsDown(i)},cleanup:function(){_ccsg.Node.prototype.onExit.call(this),this._renderCmd.cleanup()},getSprite:function(){return this.sprite},setSprite:function(t){this.sprite=t},setVirtualViewport:function(t,e,i){this._renderCmd.setVirtualViewport(t,e,i)},initWithWidthAndHeight:function(t,e,i,n){return this._renderCmd.initWithWidthAndHeight(t,e,i,n)},begin:function(){cc.renderer._turnToCacheMode(this.__instanceId),this._renderCmd.begin()},beginWithClear:function(t,e,i,n,r,s){var o=cc._renderContext;r=r||o.COLOR_BUFFER_BIT,s=s||o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT,this._beginWithClear(t,e,i,n,r,s,o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)},_beginWithClear:function(t,e,i,n,r,s,o){this.begin(),this._renderCmd._beginWithClear(t,e,i,n,r,s,o)},end:function(){this._renderCmd.end()},clear:function(t,e,i,n){this.beginWithClear(t,e,i,n),this.end()},clearRect:function(t,e,i,n){this._renderCmd.clearRect(t,e,i,n)},clearDepth:function(t){this._renderCmd.clearDepth(t)},clearStencil:function(t){this._renderCmd.clearStencil(t)},getClearFlags:function(){return this.clearFlags},setClearFlags:function(t){this.clearFlags=t},getClearColor:function(){return this._clearColor},setClearColor:function(t){var e=this._clearColor;e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a,this._renderCmd.updateClearColor(t)},getClearDepth:function(){return this.clearDepthVal},setClearDepth:function(t){this.clearDepthVal=t},getClearStencil:function(){return this.clearStencilVal},setClearStencil:function(t){this.clearStencilVal=t},isAutoDraw:function(){return this.autoDraw},setAutoDraw:function(t){this.autoDraw=t},saveToFile:function(t,e){cc.log("saveToFile isn't supported on Cocos2d-Html5")},newCCImage:function(t){return cc.log("saveToFile isn't supported on cocos2d-html5"),null},listenToBackground:function(t){},listenToForeground:function(t){}});var n=cc.RenderTexture.prototype;n.clearColorVal,cc.defineGetterSetter(n,"clearColorVal",n.getClearColor,n.setClearColor),cc.RenderTexture.create=function(t,e,i,n){return new cc.RenderTexture(t,e,i,n)}}),{}],268:[(function(t,e,i){cc.RenderTexture.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!1,this._clearColorStr="rgba(255,255,255,1)",this._cacheCanvas=document.createElement("canvas"),this._cacheContext=new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"))};var n=cc.RenderTexture.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=cc.RenderTexture.CanvasRenderCmd,n.cleanup=function(){this._cacheContext=null,this._cacheCanvas=null},n.clearStencil=function(t){},n.setVirtualViewport=function(t,e,i){},n.updateClearColor=function(t){this._clearColorStr="rgba("+(0|t.r)+","+(0|t.g)+","+(0|t.b)+","+t.a/255+")"},n.initWithWidthAndHeight=function(t,e,i,n){var r=this._node,s=this._cacheCanvas;s.width=0|t,s.height=0|e;var o=new cc.Texture2D;o.initWithElement(s),o.handleLoadedTexture();var a=r.sprite=new _ccsg.Sprite(o);return a.setBlendFunc(cc.macro.ONE,cc.macro.ONE_MINUS_SRC_ALPHA),r.autoDraw=!1,r.addChild(a),!0},n.begin=function(){},n._beginWithClear=function(t,e,i,n,r,s,o){t=t||0,e=e||0,i=i||0,n=isNaN(n)?255:n;var a=this._cacheContext.getContext(),c=this._cacheCanvas;a.setTransform(1,0,0,1,0,0),this._cacheContext.setFillStyle("rgba("+(0|t)+","+(0|e)+","+(0|i)+","+n/255+")"),a.clearRect(0,0,c.width,c.height),a.fillRect(0,0,c.width,c.height)},n.end=function(){var t=this._node;cc.renderer._renderingToCacheCanvas(this._cacheContext,t.__instanceId);var e=t.sprite._renderCmd;e._notifyRegionStatus&&e._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty)},n.clearRect=function(t,e,i,n){this._cacheContext.clearRect(t,e,i,-n)},n.clearDepth=function(t){cc.log("clearDepth isn't supported on Cocos2d-Html5")}}),{}],269:[(function(t,e,i){var n=t("../core/utils/misc");cc.RenderTexture.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._fBO=null,this._oldFBO=null,this._textureCopy=null,this._depthRenderBuffer=null,this._rtTextureRect=new cc.Rect,this._fullRect=new cc.Rect,this._fullViewport=new cc.Rect};var r=cc.RenderTexture.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);r.constructor=cc.RenderTexture.WebGLRenderCmd,r.setVirtualViewport=function(t,e,i){this._rtTextureRect.x=t.x,this._rtTextureRect.y=t.y,this._fullRect=e,this._fullViewport=i},r.needDraw=function(){return this._needDraw&&this._node.autoDraw},r.rendering=function(t){var e=t||cc._renderContext,i=this._node;if(i.autoDraw){i.begin();var n=i.clearFlags;if(n){var r=[0,0,0,0],s=0,o=0;n&e.COLOR_BUFFER_BIT&&(r=e.getParameter(e.COLOR_CLEAR_VALUE),e.clearColor(i._clearColor.r/255,i._clearColor.g/255,i._clearColor.b/255,i._clearColor.a/255)),n&e.DEPTH_BUFFER_BIT&&(s=e.getParameter(e.DEPTH_CLEAR_VALUE),e.clearDepth(i.clearDepthVal)),n&e.STENCIL_BUFFER_BIT&&(o=e.getParameter(e.STENCIL_CLEAR_VALUE),e.clearStencil(i.clearStencilVal)),e.clear(n),n&e.COLOR_BUFFER_BIT&&e.clearColor(r[0],r[1],r[2],r[3]),n&e.DEPTH_BUFFER_BIT&&e.clearDepth(s),n&e.STENCIL_BUFFER_BIT&&e.clearStencil(o)}i.sortAllChildren();for(var a=i._children,c=0;c<a.length;c++){var h=a[c];h!==i.sprite&&h.visit(i.sprite)}i.end()}},r.clearStencil=function(t){var e=cc._renderContext,i=e.getParameter(e.STENCIL_CLEAR_VALUE);e.clearStencil(t),e.clear(e.STENCIL_BUFFER_BIT),e.clearStencil(i)},r.cleanup=function(){this._node;this._textureCopy=null;var t=cc._renderContext;t.deleteFramebuffer(this._fBO),this._depthRenderBuffer&&t.deleteRenderbuffer(this._depthRenderBuffer)},r.updateClearColor=function(t){},r.initWithWidthAndHeight=function(t,e,i,r){var s=this._node;i===cc.Texture2D.PixelFormat.A8&&cc.log("cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;");var o=cc._renderContext;this._fullRect=new cc.Rect(0,0,t,e),t|=0,e|=0,this._oldFBO=o.getParameter(o.FRAMEBUFFER_BINDING);var a,c;cc.configuration.supportsNPOT()?(a=t,c=e):(a=n.NextPOT(t),c=n.NextPOT(e)),this._fullViewport=new cc.Rect(0,0,a,c);for(var h=a*c*4,l=new Uint8Array(h),u=0;u<a*c*4;u++)l[u]=0;this._pixelFormat=i;var _=s._texture=new cc.Texture2D;if(!s._texture)return!1;_.initWithData(l,s._pixelFormat,a,c);var d=o.getParameter(o.RENDERBUFFER_BINDING);if(cc.configuration.checkForGLExtension("GL_QCOM")){if(this._textureCopy=new cc.Texture2D,!this._textureCopy)return!1;this._textureCopy.initWithData(l,s._pixelFormat,a,c)}this._fBO=o.createFramebuffer(),o.bindFramebuffer(o.FRAMEBUFFER,this._fBO),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,_._glID,0),0!==r&&(this._depthRenderBuffer=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,this._depthRenderBuffer),o.renderbufferStorage(o.RENDERBUFFER,r,a,c),r===o.DEPTH_STENCIL?o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,this._depthRenderBuffer):r===o.STENCIL_INDEX||r===o.STENCIL_INDEX8?o.framebufferRenderbuffer(o.FRAMEBUFFER,o.STENCIL_ATTACHMENT,o.RENDERBUFFER,this._depthRenderBuffer):r===o.DEPTH_COMPONENT16&&o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,this._depthRenderBuffer)),o.checkFramebufferStatus(o.FRAMEBUFFER)!==o.FRAMEBUFFER_COMPLETE&&cc.log("Could not attach texture to the framebuffer"),_.setAliasTexParameters();var f=s.sprite=new _ccsg.Sprite(_);return f.scaleY=-1,f.setBlendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA),o.bindRenderbuffer(o.RENDERBUFFER,d),o.bindFramebuffer(o.FRAMEBUFFER,this._oldFBO),s.autoDraw=!1,s.addChild(f),!0},r.begin=function(){var t=this._node;cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),cc.math.glPushMatrix(),cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW),cc.math.glPushMatrix();var e=cc._renderContext,i=cc.director;i.setProjection(i.getProjection());var n=cc.director.getWinSizeInPixels(),r=n.width/t._texture.width,s=n.height/t._texture.height,o=cc.math.Matrix4.createOrthographicProjection(-1/r,1/r,-1/s,1/s,-1,1);cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),cc.math.glMultMatrix(o);var a=new cc.Rect(0,0,0,0);a.width=this._fullViewport.width,a.height=this._fullViewport.height;var c=a.width/this._fullRect.width,h=a.height/this._fullRect.height;a.x=(this._fullRect.x-this._rtTextureRect.x)*c,a.y=(this._fullRect.y-this._rtTextureRect.y)*h,e.viewport(a.x,a.y,a.width,a.height),this._oldFBO=e.getParameter(e.FRAMEBUFFER_BINDING),e.bindFramebuffer(e.FRAMEBUFFER,this._fBO),cc.configuration.checkForGLExtension("GL_QCOM")&&(e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this._textureCopy._glID,0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t._texture._glID,0))},r._beginWithClear=function(t,e,i,n,r,s,o){t/=255,e/=255,i/=255,n/=255;var a=cc._renderContext,c=[0,0,0,0],h=0,l=0;o&a.COLOR_BUFFER_BIT&&(c=a.getParameter(a.COLOR_CLEAR_VALUE),a.clearColor(t,e,i,n)),o&a.DEPTH_BUFFER_BIT&&(h=a.getParameter(a.DEPTH_CLEAR_VALUE),a.clearDepth(r)),o&a.STENCIL_BUFFER_BIT&&(l=a.getParameter(a.STENCIL_CLEAR_VALUE),a.clearStencil(s)),a.clear(o),o&a.COLOR_BUFFER_BIT&&a.clearColor(c[0],c[1],c[2],c[3]),o&a.DEPTH_BUFFER_BIT&&a.clearDepth(h),o&a.STENCIL_BUFFER_BIT&&a.clearStencil(l)},r.end=function(){var t=this._node;cc.renderer._renderingToBuffer(t.__instanceId);var e=cc._renderContext,i=cc.director;e.bindFramebuffer(e.FRAMEBUFFER,this._oldFBO),i.setViewport(),cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),cc.math.glPopMatrix(),cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW),cc.math.glPopMatrix()},r.clearRect=function(t,e,i,n){},r.clearDepth=function(t){var e=this._node;e.begin();var i=cc._renderContext,n=i.getParameter(i.DEPTH_CLEAR_VALUE);i.clearDepth(t),i.clear(i.DEPTH_BUFFER_BIT),i.clearDepth(n),e.end()}}),{"../core/utils/misc":226}],270:[(function(t,e,i){var n=cc.macro,r=cc.math;cc.GLProgram=cc._Class.extend({_updateUniformLocation:function(t){if(!t)return!1;var e,i=this._hashForUniforms[t];if(i){e=!1;for(var n=arguments.length-1,r=0;r<n;++r)arguments[r+1]!==i[r]&&(i[r]=arguments[r+1],e=!0)}else i=[arguments[1],arguments[2],arguments[3],arguments[4]],this._hashForUniforms[t]=i,e=!0;return e},_description:function(){return"<CCGLProgram = "+this.toString()+" | Program = "+this._programObj.toString()+", VertexShader = "+this._vertShader.toString()+", FragmentShader = "+this._fragShader.toString()+">"},_compileShader:function(t,e,i){if(!i||!t)return!1;i=(cc.GLProgram._isHighpSupported()?"precision highp float;\n":"precision mediump float;\n")+"uniform mat4 CC_PMatrix;\nuniform mat4 CC_MVMatrix;\nuniform mat4 CC_MVPMatrix;\nuniform vec4 CC_Time;\nuniform vec4 CC_SinTime;\nuniform vec4 CC_CosTime;\nuniform vec4 CC_Random01;\nuniform sampler2D CC_Texture0;\n//CC INCLUDES END\n"+i,this._glContext.shaderSource(t,i),this._glContext.compileShader(t);var n=this._glContext.getShaderParameter(t,this._glContext.COMPILE_STATUS);return n||(cc.logID(8100,this._glContext.getShaderSource(t)),e===this._glContext.VERTEX_SHADER?cc.log("cocos2d: \n"+this.vertexShaderLog()):cc.log("cocos2d: \n"+this.fragmentShaderLog())),!!n},ctor:function(t,e,i){this._uniforms={},this._hashForUniforms={},this._glContext=i||cc._renderContext,this._programObj=null,this._vertShader=null,this._fragShader=null,this._usesTime=!1,this._projectionUpdated=-1,t&&e&&this.init(t,e)},destroyProgram:function(){this._vertShader=null,this._fragShader=null,this._uniforms=null,this._hashForUniforms=null,this._glContext.deleteProgram(this._programObj)},initWithVertexShaderByteArray:function(t,e){var i=this._glContext;this._programObj=i.createProgram(),this._projectionUpdated=-1,this._vertShader=null,this._fragShader=null,t&&(this._vertShader=i.createShader(i.VERTEX_SHADER),this._compileShader(this._vertShader,i.VERTEX_SHADER,t)||cc.logID(8101)),e&&(this._fragShader=i.createShader(i.FRAGMENT_SHADER),this._compileShader(this._fragShader,i.FRAGMENT_SHADER,e)||cc.logID(8102)),this._vertShader&&i.attachShader(this._programObj,this._vertShader),this._fragShader&&i.attachShader(this._programObj,this._fragShader);for(var n in this._hashForUniforms)delete this._hashForUniforms[n];return!0},initWithString:function(t,e){return this.initWithVertexShaderByteArray(t,e)},initWithVertexShaderFilename:function(t,e){var i=cc.loader.getRes(t);if(!i)throw new Error("Please load the resource firset : "+t);var n=cc.loader.getRes(e);if(!n)throw new Error("Please load the resource firset : "+e);return this.initWithVertexShaderByteArray(i,n)},init:function(t,e){return this.initWithVertexShaderFilename(t,e)},addAttribute:function(t,e){this._glContext.bindAttribLocation(this._programObj,e,t)},link:function(){if(!this._programObj)return cc.logID(8103),!1;if(this._glContext.linkProgram(this._programObj),this._vertShader&&this._glContext.deleteShader(this._vertShader),this._fragShader&&this._glContext.deleteShader(this._fragShader),this._vertShader=null,this._fragShader=null,cc.game.config[cc.game.CONFIG_KEY.debugMode]){if(!this._glContext.getProgramParameter(this._programObj,this._glContext.LINK_STATUS))return cc.logID(8104,this._glContext.getProgramInfoLog(this._programObj)),cc.gl.deleteProgram(this._programObj),this._programObj=null,!1}return!0},use:function(){cc.gl.useProgram(this._programObj)},updateUniforms:function(){this._uniforms[n.UNIFORM_PMATRIX]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_PMATRIX_S),this._uniforms[n.UNIFORM_MVMATRIX]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_MVMATRIX_S),this._uniforms[n.UNIFORM_MVPMATRIX]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_MVPMATRIX_S),this._uniforms[n.UNIFORM_TIME]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_TIME_S),this._uniforms[n.UNIFORM_SINTIME]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_SINTIME_S),this._uniforms[n.UNIFORM_COSTIME]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_COSTIME_S),this._usesTime=null!=this._uniforms[n.UNIFORM_TIME]||null!=this._uniforms[n.UNIFORM_SINTIME]||null!=this._uniforms[n.UNIFORM_COSTIME],this._uniforms[n.UNIFORM_RANDOM01]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_RANDOM01_S),this._uniforms[n.UNIFORM_SAMPLER]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_SAMPLER_S),this.use(),this.setUniformLocationWith1i(this._uniforms[n.UNIFORM_SAMPLER],0)},_addUniformLocation:function(t){var e=this._glContext.getUniformLocation(this._programObj,t);this._uniforms[t]=e},getUniformLocationForName:function(t){if(!t)throw new Error("cc.GLProgram.getUniformLocationForName(): uniform name should be non-null");if(!this._programObj)throw new Error("cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized");return this._uniforms[t]||this._glContext.getUniformLocation(this._programObj,t)},getUniformMVPMatrix:function(){return this._uniforms[n.UNIFORM_MVPMATRIX]},getUniformSampler:function(){return this._uniforms[n.UNIFORM_SAMPLER]},setUniformLocationWith1i:function(t,e){var i=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e)){var n=this.getUniformLocationForName(t);i.uniform1i(n,e)}}else i.uniform1i(t,e)},setUniformLocationWith2i:function(t,e,i){var n=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i)){var r=this.getUniformLocationForName(t);n.uniform2i(r,e,i)}}else n.uniform2i(t,e,i)},setUniformLocationWith3i:function(t,e,i,n){var r=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n)){var s=this.getUniformLocationForName(t);r.uniform3i(s,e,i,n)}}else r.uniform3i(t,e,i,n)},setUniformLocationWith4i:function(t,e,i,n,r){var s=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n,r)){var o=this.getUniformLocationForName(t);s.uniform4i(o,e,i,n,r)}}else s.uniform4i(t,e,i,n,r)},setUniformLocationWith2iv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform2iv(i,e)},setUniformLocationWith3iv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform3iv(i,e)},setUniformLocationWith4iv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform4iv(i,e)},setUniformLocationI32:function(t,e){this.setUniformLocationWith1i(t,e)},setUniformLocationWith1f:function(t,e){var i=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e)){var n=this.getUniformLocationForName(t);i.uniform1f(n,e)}}else i.uniform1f(t,e)},setUniformLocationWith2f:function(t,e,i){var n=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i)){var r=this.getUniformLocationForName(t);n.uniform2f(r,e,i)}}else n.uniform2f(t,e,i)},setUniformLocationWith3f:function(t,e,i,n){var r=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n)){var s=this.getUniformLocationForName(t);r.uniform3f(s,e,i,n)}}else r.uniform3f(t,e,i,n)},setUniformLocationWith4f:function(t,e,i,n,r){var s=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n,r)){var o=this.getUniformLocationForName(t);s.uniform4f(o,e,i,n,r)}}else s.uniform4f(t,e,i,n,r)},setUniformLocationWith2fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform2fv(i,e)},setUniformLocationWith3fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform3fv(i,e)},setUniformLocationWith4fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform4fv(i,e)},setUniformLocationWithMatrix3fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniformMatrix3fv(i,!1,e)},setUniformLocationWithMatrix4fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniformMatrix4fv(i,!1,e)},setUniformLocationF32:function(t,e,i,n,r){"use strict";switch(arguments.length){case 0:case 1:return;case 2:this.setUniformLocationWith1f(t,e);break;case 3:this.setUniformLocationWith2f(t,e,i);break;case 4:this.setUniformLocationWith3f(t,e,i,n);break;case 5:this.setUniformLocationWith4f(t,e,i,n,r)}},setUniformsForBuiltins:function(){var t=new r.Matrix4,e=new r.Matrix4,i=new r.Matrix4;if(r.glGetMatrix(r.KM_GL_PROJECTION,t),r.glGetMatrix(r.KM_GL_MODELVIEW,e),r.mat4Multiply(i,t,e),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],t.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],e.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],i.mat,1),this._usesTime){var s=cc.director,o=s.getTotalFrames()*s.getAnimationInterval();this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_TIME],o/10,o,2*o,4*o),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_SINTIME],o/8,o/4,o/2,Math.sin(o)),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_COSTIME],o/8,o/4,o/2,Math.cos(o))}-1!==this._uniforms[n.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())},_setUniformsForBuiltinsForRenderer:function(t){if(t&&t._renderCmd){var e=new r.Matrix4,i=new r.Matrix4;if(r.glGetMatrix(r.KM_GL_PROJECTION,e),r.mat4Multiply(i,e,t._renderCmd._stackMatrix),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],e.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],t._renderCmd._stackMatrix.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],i.mat,1),this._usesTime){var s=cc.director,o=s.getTotalFrames()*s.getAnimationInterval();this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_TIME],o/10,o,2*o,4*o),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_SINTIME],o/8,o/4,o/2,Math.sin(o)),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_COSTIME],o/8,o/4,o/2,Math.cos(o))}-1!==this._uniforms[n.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())}},setUniformForModelViewProjectionMatrix:function(){this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],!1,r.getMat4MultiplyValue(r.projection_matrix_stack.top,r.modelview_matrix_stack.top))},setUniformForModelViewProjectionMatrixWithMat4:function(t){r.mat4Multiply(t,r.projection_matrix_stack.top,r.modelview_matrix_stack.top),this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],!1,t.mat)},setUniformForModelViewAndProjectionMatrixWithMat4:function(){this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],!1,r.modelview_matrix_stack.top.mat),this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],!1,r.projection_matrix_stack.top.mat)},_setUniformForMVPMatrixWithMat4:function(t){if(!t)throw new Error("modelView matrix is undefined.");this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],!1,t.mat),this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],!1,r.projection_matrix_stack.top.mat)},_updateProjectionUniform:function(){var t=r.projection_matrix_stack;t.lastUpdated!==this._projectionUpdated&&(this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],!1,t.top.mat),this._projectionUpdated=t.lastUpdated)},vertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getVertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getFragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},fragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._fragShader)},programLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},getProgramLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},reset:function(){this._vertShader=null,this._fragShader=null,this._uniforms.length=0,this._glContext.deleteProgram(this._programObj),this._programObj=null;for(var t in this._hashForUniforms)this._hashForUniforms[t].length=0,delete this._hashForUniforms[t]},getProgram:function(){return this._programObj},retain:function(){},release:function(){}}),cc.GLProgram._highpSupported=null,cc.GLProgram._isHighpSupported=function(){var t=cc._renderContext;if(t.getShaderPrecisionFormat&&null==cc.GLProgram._highpSupported){var e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);cc.GLProgram._highpSupported=0!==e.precision}return cc.GLProgram._highpSupported}}),{}],271:[(function(t,e,i){var n=cc.macro.ENABLE_GL_STATE_CACHE,r=0,s=0,o=null,a=0,c=0;n&&(r=16,s=-1,o=new Array(r),a=-1,c=-1),cc.gl={},cc.gl.invalidateStateCache=function(){if(cc.math.glFreeAll(),-1,n){s=-1;for(var t=0;t<r;t++)o[t]=null;a=-1,c=-1,0}},cc.gl.useProgram=n?function(t){t!==s&&(s=t,cc._renderContext.useProgram(t))}:function(t){cc._renderContext.useProgram(t)},cc.gl.deleteProgram=function(t){n&&t===s&&(s=-1),gl.deleteProgram(t)},cc.gl.setBlending=function(t,e){var i=cc._renderContext;t===i.ONE&&e===i.ZERO?i.disable(i.BLEND):(i.enable(i.BLEND),i.blendFunc(t,e))},cc.gl.blendFunc=n?function(t,e){t===a&&e===c||(a=t,c=e,cc.gl.setBlending(t,e))}:cc.gl.setBlending,cc.gl.blendFuncForParticle=function(t,e){if(t!==a||e!==c){a=t,c=e;var i=cc._renderContext;t===i.ONE&&e===i.ZERO?i.disable(i.BLEND):(i.enable(i.BLEND),i.blendFuncSeparate(i.SRC_ALPHA,e,t,e))}},cc.gl.blendResetToCache=function(){var t=cc._renderContext;t.blendEquation(t.FUNC_ADD),n?cc.gl.setBlending(a,c):cc.gl.setBlending(t.BLEND_SRC,t.BLEND_DST)},cc.gl.setProjectionMatrixDirty=function(){-1},cc.gl.bindTexture2D=function(t){cc.gl.bindTexture2DN(0,t)},cc.gl.bindTexture2DN=n?function(t,e){if(o[t]!==e){o[t]=e;var i=cc._renderContext;i.activeTexture(i.TEXTURE0+t),e?i.bindTexture(i.TEXTURE_2D,e._glID):i.bindTexture(i.TEXTURE_2D,null)}}:function(t,e){var i=cc._renderContext;i.activeTexture(i.TEXTURE0+t),e?i.bindTexture(i.TEXTURE_2D,e._glID):i.bindTexture(i.TEXTURE_2D,null)},cc.gl.deleteTexture2D=function(t){cc.gl.deleteTexture2DN(0,t)},cc.gl.deleteTexture2DN=function(t,e){n&&e===o[t]&&(o[t]=null),cc._renderContext.deleteTexture(e._glID)},cc.gl.enable=function(t){}}),{}],272:[(function(t,e,i){var n=cc.PresetShaders,r=cc.macro;cc.shaderCache={TYPE_POSITION_TEXTURECOLOR:0,TYPE_POSITION_TEXTURECOLOR_ALPHATEST:1,TYPE_POSITION_COLOR:2,TYPE_POSITION_TEXTURE:3,TYPE_POSITION_TEXTURE_UCOLOR:4,TYPE_POSITION_TEXTURE_A8COLOR:5,TYPE_POSITION_UCOLOR:6,TYPE_POSITION_LENGTH_TEXTURECOLOR:7,TYPE_SPRITE_POSITION_TEXTURECOLOR:8,TYPE_SPRITE_POSITION_TEXTURECOLOR_ALPHATEST:9,TYPE_SPRITE_POSITION_COLOR:10,TYPE_MAX:10,_programs:{},_init:function(){return this.loadDefaultShaders(),!0},_loadDefaultShader:function(t,e){switch(e){case r.SHADER_POSITION_TEXTURECOLOR:t.initWithVertexShaderByteArray(n.POSITION_TEXTURE_COLOR_VERT,n.POSITION_TEXTURE_COLOR_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_SPRITE_POSITION_TEXTURECOLOR:t.initWithVertexShaderByteArray(n.SPRITE_POSITION_TEXTURE_COLOR_VERT,n.POSITION_TEXTURE_COLOR_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_POSITION_TEXTURECOLORALPHATEST:t.initWithVertexShaderByteArray(n.POSITION_TEXTURE_COLOR_VERT,n.POSITION_TEXTURE_COLOR_ALPHATEST_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST:t.initWithVertexShaderByteArray(n.SPRITE_POSITION_TEXTURE_COLOR_VERT,n.POSITION_TEXTURE_COLOR_ALPHATEST_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_POSITION_COLOR:t.initWithVertexShaderByteArray(n.POSITION_COLOR_VERT,n.POSITION_COLOR_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR);break;case r.SHADER_SPRITE_POSITION_COLOR:t.initWithVertexShaderByteArray(n.SPRITE_POSITION_COLOR_VERT,n.POSITION_COLOR_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR);break;case r.SHADER_POSITION_TEXTURE:t.initWithVertexShaderByteArray(n.POSITION_TEXTURE_VERT,n.POSITION_TEXTURE_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_POSITION_TEXTURE_UCOLOR:t.initWithVertexShaderByteArray(n.POSITION_TEXTURE_UCOLOR_VERT,n.POSITION_TEXTURE_UCOLOR_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_POSITION_TEXTUREA8COLOR:t.initWithVertexShaderByteArray(n.POSITION_TEXTURE_A8COLOR_VERT,n.POSITION_TEXTURE_A8COLOR_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS);break;case r.SHADER_POSITION_UCOLOR:t.initWithVertexShaderByteArray(n.POSITION_UCOLOR_VERT,n.POSITION_UCOLOR_FRAG),t.addAttribute("aVertex",r.VERTEX_ATTRIB_POSITION);break;case r.SHADER_POSITION_LENGTHTEXTURECOLOR:t.initWithVertexShaderByteArray(n.POSITION_COLOR_LENGTH_TEXTURE_VERT,n.POSITION_COLOR_LENGTH_TEXTURE_FRAG),t.addAttribute(r.ATTRIBUTE_NAME_POSITION,r.VERTEX_ATTRIB_POSITION),t.addAttribute(r.ATTRIBUTE_NAME_TEX_COORD,r.VERTEX_ATTRIB_TEX_COORDS),t.addAttribute(r.ATTRIBUTE_NAME_COLOR,r.VERTEX_ATTRIB_COLOR);break;default:return void cc.logID(8105)}t.link(),t.updateUniforms()},_reloadShader:function(t){var e=this.programForKey(t);e.reset(),this._loadDefaultShader(e,t)},loadDefaultShaders:function(){},reloadDefaultShaders:function(){this._reloadShader(r.SHADER_POSITION_TEXTURECOLOR),this._reloadShader(r.SHADER_SPRITE_POSITION_TEXTURECOLOR),this._reloadShader(r.SHADER_POSITION_TEXTURECOLORALPHATEST),this._reloadShader(r.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST),this._reloadShader(r.SHADER_POSITION_COLOR),this._reloadShader(r.SHADER_POSITION_TEXTURE),this._reloadShader(r.SHADER_POSITION_TEXTURE_UCOLOR),this._reloadShader(r.SHADER_POSITION_TEXTUREA8COLOR),this._reloadShader(r.SHADER_POSITION_UCOLOR)},programForKey:function(t){if(!this._programs[t]){var e=new cc.GLProgram;this._loadDefaultShader(e,t),this._programs[t]=e}return this._programs[t]},getProgram:function(t){return this.programForKey(t)},addProgram:function(t,e){this._programs[e]=t}}}),{}],273:[(function(t,e,i){cc.PresetShaders={POSITION_UCOLOR_FRAG:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main()\n{\ngl_FragColor = v_fragmentColor;\n}",POSITION_UCOLOR_VERT:"attribute vec4 a_position;\nuniform vec4 u_color;\nuniform float u_pointSize;\nvarying lowp vec4 v_fragmentColor;\nvoid main(void)\n{\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\ngl_PointSize = u_pointSize;\nv_fragmentColor = u_color;\n}",POSITION_COLOR_FRAG:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main()\n{\ngl_FragColor = v_fragmentColor;\n}",POSITION_COLOR_VERT:"attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\nv_fragmentColor = a_color;\n}",SPRITE_POSITION_COLOR_VERT:"attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\ngl_Position = CC_PMatrix * a_position;\nv_fragmentColor = a_color;\n}",POSITION_COLOR_LENGTH_TEXTURE_FRAG:"//#extension GL_OES_standard_derivatives : enable\nvarying mediump vec4 v_color;\nvarying mediump vec2 v_texcoord;\nvoid main()\n{\n//#if defined GL_OES_standard_derivatives\n//gl_FragColor=v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0-length(v_texcoord));\n//#else\ngl_FragColor = v_color * step(0.0, 1.0 - length(v_texcoord));\n//#endif\n}",POSITION_COLOR_LENGTH_TEXTURE_VERT:"attribute mediump vec4 a_position;\nattribute mediump vec2 a_texcoord;\nattribute mediump vec4 a_color;\nvarying mediump vec4 v_color;\nvarying mediump vec2 v_texcoord;\nvoid main()\n{\nv_color = a_color;\nv_texcoord = a_texcoord;\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\n}",POSITION_TEXTURE_FRAG:"precision lowp float;\nvarying vec2 v_texCoord;\nvoid main()\n{\ngl_FragColor = texture2D(CC_Texture0, v_texCoord);\n}",POSITION_TEXTURE_VERT:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying mediump vec2 v_texCoord;\nvoid main()\n{\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\nv_texCoord = a_texCoord;\n}",POSITION_TEXTURE_UCOLOR_FRAG:"precision lowp float;\nuniform vec4 u_color;\nvarying vec2 v_texCoord;\nvoid main()\n{\ngl_FragColor=texture2D(CC_Texture0, v_texCoord) * u_color;\n}",POSITION_TEXTURE_UCOLOR_VERT:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying mediump vec2 v_texCoord;\nvoid main()\n{\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\nv_texCoord = a_texCoord;\n}",POSITION_TEXTURE_A8COLOR_FRAG:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvarying vec2 v_texCoord;\nvoid main()\n{\ngl_FragColor = vec4(v_fragmentColor.rgb,\nv_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a);\n}",POSITION_TEXTURE_A8COLOR_VERT:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvarying mediump vec2 v_texCoord;\nvoid main()\n{\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\nv_fragmentColor = a_color;\nv_texCoord = a_texCoord;\n}",POSITION_TEXTURE_COLOR_FRAG:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvarying vec2 v_texCoord;\nvoid main()\n{\ngl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord);\n}",POSITION_TEXTURE_COLOR_VERT:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvarying mediump vec2 v_texCoord;\nvoid main()\n{\ngl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;\nv_fragmentColor = a_color;\nv_texCoord = a_texCoord;\n}",SPRITE_POSITION_TEXTURE_COLOR_VERT:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvarying mediump vec2 v_texCoord;\nvoid main()\n{\ngl_Position = CC_PMatrix * a_position;\nv_fragmentColor = a_color;\nv_texCoord = a_texCoord;\n}",POSITION_TEXTURE_COLOR_ALPHATEST_FRAG:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvarying vec2 v_texCoord;\nuniform float CC_alpha_value;\nvoid main()\n{\nvec4 texColor=texture2D(CC_Texture0, v_texCoord);\nif(texColor.a <= CC_alpha_value)\n discard; \ngl_FragColor=texColor*v_fragmentColor;\n}",EX_SWITCHMASK_FRAG:"precision lowp float;\nvarying vec4 v_fragmentColor;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\nuniform sampler2D u_mask;\nvoid main()\n{\nvec4 texColorc=texture2D(u_texture, v_texCoord);\nvec4 maskColor=texture2D(u_mask, v_texCoord);\nvec4 finalColor=vec4(texColor.r, texColor.g, texColor.b, maskColor.a*texColor.a);\ngl_FragColor=v_fragmentColor*finalColor;\n}"}}),{}],274:[(function(t,e,i){t("./CCShaders"),t("./CCShaderCache"),t("./CCGLProgram"),t("./CCGLStateCache")}),{"./CCGLProgram":270,"./CCGLStateCache":271,"./CCShaderCache":272,"./CCShaders":273}],275:[(function(t,e,i){var n=function(t){return{u:t.x,v:t.y}};cc.DrawNode=_ccsg.Node.extend({_buffer:null,_blendFunc:null,_lineWidth:1,_drawColor:null,getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(t,e){void 0===e?(this._blendFunc.src=t.src,this._blendFunc.dst=t.dst):(this._blendFunc.src=t,this._blendFunc.dst=e)},setLineWidth:function(t){this._lineWidth=t},getLineWidth:function(){return this._lineWidth},setDrawColor:function(t){var e=this._drawColor;e.r=t.r,e.g=t.g,e.b=t.b,e.a=null==t.a?255:t.a},getDrawColor:function(){return cc.color(this._drawColor.r,this._drawColor.g,this._drawColor.b,this._drawColor.a)}}),cc.DrawNode.TYPE_DOT=0,cc.DrawNode.TYPE_SEGMENT=1,cc.DrawNode.TYPE_POLY=2,cc.game.once(cc.game.EVENT_RENDERER_INITED,(function(){var e=cc.DrawNode.prototype;cc._renderType===cc.game.RENDER_TYPE_CANVAS?(cc._DrawNodeElement=function(t,e,i,n,r,s,o,a,c){this.type=t,this.verts=e||null,this.fillColor=i||null,this.lineWidth=n||0,this.lineColor=r||null,this.lineCap=s||"butt",this.isClosePolygon=o||!1,this.isFill=a||!1,this.isStroke=c||!1},e._className="DrawNodeCanvas",e.ctor=function(){_ccsg.Node.prototype.ctor.call(this);var t=this._renderCmd;t._buffer=this._buffer=[],t._drawColor=this._drawColor=cc.color(255,255,255,255),t._blendFunc=this._blendFunc=new cc.BlendFunc(cc.macro.SRC_ALPHA,cc.macro.ONE_MINUS_SRC_ALPHA),this.init()},e.drawRect=function(t,e,i,n,r){n=null==n?this._lineWidth:n,null==(r=r||this.getDrawColor()).a&&(r.a=255);var s=[t,cc.p(e.x,t.y),e,cc.p(t.x,e.y)],o=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);o.verts=s,o.lineWidth=n,o.lineColor=r,o.isClosePolygon=!0,o.isStroke=!0,o.lineCap="butt",o.fillColor=i,i&&(null==i.a&&(i.a=255),o.isFill=!0),this._buffer.push(o)},e.drawCircle=function(t,e,i,n,r,s,o){s=s||this._lineWidth,null==(o=o||this.getDrawColor()).a&&(o.a=255);for(var a=2*Math.PI/n,c=[],h=0;h<=n;h++){var l=h*a,u=e*Math.cos(l+i)+t.x,_=e*Math.sin(l+i)+t.y;c.push(cc.p(u,_))}r&&c.push(cc.p(t.x,t.y));var d=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);d.verts=c,d.lineWidth=s,d.lineColor=o,d.isClosePolygon=!0,d.isStroke=!0,this._buffer.push(d)},e.drawQuadBezier=function(t,e,i,n,r,s){r=r||this._lineWidth,null==(s=s||this.getDrawColor()).a&&(s.a=255);for(var o=[],a=0,c=0;c<n;c++){var h=Math.pow(1-a,2)*t.x+2*(1-a)*a*e.x+a*a*i.x,l=Math.pow(1-a,2)*t.y+2*(1-a)*a*e.y+a*a*i.y;o.push(cc.p(h,l)),a+=1/n}o.push(cc.p(i.x,i.y));var u=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);u.verts=o,u.lineWidth=r,u.lineColor=s,u.isStroke=!0,u.lineCap="round",this._buffer.push(u)},e.drawCubicBezier=function(t,e,i,n,r,s,o){s=s||this._lineWidth,null==(o=o||this.getDrawColor()).a&&(o.a=255);for(var a=[],c=0,h=0;h<r;h++){var l=Math.pow(1-c,3)*t.x+3*Math.pow(1-c,2)*c*e.x+3*(1-c)*c*c*i.x+c*c*c*n.x,u=Math.pow(1-c,3)*t.y+3*Math.pow(1-c,2)*c*e.y+3*(1-c)*c*c*i.y+c*c*c*n.y;a.push(cc.p(l,u)),c+=1/r}a.push(cc.p(n.x,n.y));var _=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);_.verts=a,_.lineWidth=s,_.lineColor=o,_.isStroke=!0,_.lineCap="round",this._buffer.push(_)},e.drawCatmullRom=function(t,e,i,n){this.drawCardinalSpline(t,.5,e,i,n)},e.drawCardinalSpline=function(t,e,i,n,r){n=n||this._lineWidth,null==(r=r||this.getDrawColor()).a&&(r.a=255);for(var s,o,a=[],c=1/t.length,h=0;h<i+1;h++){var l=h/i;1===l?(s=t.length-1,o=1):o=(l-c*(s=0|l/c))/c;var u=cc.cardinalSplineAt(cc.getControlPointAt(t,s-1),cc.getControlPointAt(t,s-0),cc.getControlPointAt(t,s+1),cc.getControlPointAt(t,s+2),e,o);a.push(u)}var _=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);_.verts=a,_.lineWidth=n,_.lineColor=r,_.isStroke=!0,_.lineCap="round",this._buffer.push(_)},e.drawDot=function(t,e,i){null==(i=i||this.getDrawColor()).a&&(i.a=255);var n=new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);n.verts=[t],n.lineWidth=e,n.fillColor=i,this._buffer.push(n)},e.drawDots=function(t,e,i){if(t&&0!=t.length){null==(i=i||this.getDrawColor()).a&&(i.a=255);for(var n=0,r=t.length;n<r;n++)this.drawDot(t[n],e,i)}},e.drawSegment=function(t,e,i,n){i=i||this._lineWidth,null==(n=n||this.getDrawColor()).a&&(n.a=255);var r=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);r.verts=[t,e],r.lineWidth=2*i,r.lineColor=n,r.isStroke=!0,r.lineCap="round",this._buffer.push(r)},e.drawPoly_=function(t,e,i,n,r){i=null==i?this._lineWidth:i,null==(n=n||this.getDrawColor()).a&&(n.a=255);var s=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);s.verts=t,s.fillColor=e,s.lineWidth=i,s.lineColor=n,s.isClosePolygon=!r,s.isStroke=!0,s.lineCap="round",e&&(s.isFill=!0),this._buffer.push(s)},e.drawPoly=function(t,e,i,n,r){for(var s=[],o=0;o<t.length;o++)s.push(cc.p(t[o].x,t[o].y));return this.drawPoly_(s,e,i,n,r)},e.clear=function(){this._buffer.length=0},t("./CCDrawNodeCanvasRenderCmd"),e._createRenderCmd=function(){return new cc.DrawNode.CanvasRenderCmd(this)}):cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(e._bufferCapacity=0,e._trianglesArrayBuffer=null,e._trianglesWebBuffer=null,e._trianglesReader=null,e._dirty=!1,e._className="DrawNodeWebGL",e.ctor=function(){_ccsg.Node.prototype.ctor.call(this),this._buffer=[],this._blendFunc=new cc.BlendFunc(cc.macro.SRC_ALPHA,cc.macro.ONE_MINUS_SRC_ALPHA),this._drawColor=cc.color(255,255,255,255),this.init()},e.init=function(){return!!_ccsg.Node.prototype.init.call(this)&&(this.shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_LENGTHTEXTURECOLOR),this._ensureCapacity(64),this._trianglesWebBuffer=cc._renderContext.createBuffer(),this._dirty=!0,!0)},e.drawRect=function(t,e,i,n,r){n=null==n?this._lineWidth:n,null==(r=r||this.getDrawColor()).a&&(r.a=255);var s=[t,cc.p(e.x,t.y),e,cc.p(t.x,e.y)];null==i?this._drawSegments(s,n,r,!0):this.drawPoly(s,i,n,r)},e.drawCircle=function(t,e,i,n,r,s,o){s=s||this._lineWidth,null==(o=o||this.getDrawColor()).a&&(o.a=255);var a,c,h=2*Math.PI/n,l=[];for(a=0;a<=n;a++){var u=a*h,_=e*Math.cos(u+i)+t.x,d=e*Math.sin(u+i)+t.y;l.push(cc.p(_,d))}for(r&&l.push(cc.p(t.x,t.y)),s*=.5,a=0,c=l.length;a<c-1;a++)this.drawSegment(l[a],l[a+1],s,o)},e.drawQuadBezier=function(t,e,i,n,r,s){r=r||this._lineWidth,null==(s=s||this.getDrawColor()).a&&(s.a=255);for(var o=[],a=0,c=0;c<n;c++){var h=Math.pow(1-a,2)*t.x+2*(1-a)*a*e.x+a*a*i.x,l=Math.pow(1-a,2)*t.y+2*(1-a)*a*e.y+a*a*i.y;o.push(cc.p(h,l)),a+=1/n}o.push(cc.p(i.x,i.y)),this._drawSegments(o,r,s,!1)},e.drawCubicBezier=function(t,e,i,n,r,s,o){s=s||this._lineWidth,null==(o=o||this.getDrawColor()).a&&(o.a=255);for(var a=[],c=0,h=0;h<r;h++){var l=Math.pow(1-c,3)*t.x+3*Math.pow(1-c,2)*c*e.x+3*(1-c)*c*c*i.x+c*c*c*n.x,u=Math.pow(1-c,3)*t.y+3*Math.pow(1-c,2)*c*e.y+3*(1-c)*c*c*i.y+c*c*c*n.y;a.push(cc.p(l,u)),c+=1/r}a.push(cc.p(n.x,n.y)),this._drawSegments(a,s,o,!1)},e.drawCatmullRom=function(t,e,i,n){this.drawCardinalSpline(t,.5,e,i,n)},e.drawCardinalSpline=function(t,e,i,n,r){n=n||this._lineWidth,null==(r=r||this.getDrawColor()).a&&(r.a=255);for(var s,o,a=[],c=1/t.length,h=0;h<i+1;h++){var l=h/i;1===l?(s=t.length-1,o=1):o=(l-c*(s=0|l/c))/c;var u=cc.cardinalSplineAt(cc.getControlPointAt(t,s-1),cc.getControlPointAt(t,s-0),cc.getControlPointAt(t,s+1),cc.getControlPointAt(t,s+2),e,o);a.push(u)}n*=.5;for(var _=0,d=a.length;_<d-1;_++)this.drawSegment(a[_],a[_+1],n,r)},e._render=function(){var t=cc._renderContext;t.bindBuffer(t.ARRAY_BUFFER,this._trianglesWebBuffer),this._dirty&&(t.bufferData(t.ARRAY_BUFFER,this._trianglesArrayBuffer,t.STREAM_DRAW),this._dirty=!1);var e=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_COLOR),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_TEX_COORDS),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION,2,t.FLOAT,!1,e,0),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR,4,t.UNSIGNED_BYTE,!0,e,8),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS,2,t.FLOAT,!1,e,12),t.drawArrays(t.TRIANGLES,0,3*this._buffer.length),cc.incrementGLDraws(1)},e._ensureCapacity=function(t){var e=this._buffer;if(e.length+t>this._bufferCapacity){var i=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;if(this._bufferCapacity+=Math.max(this._bufferCapacity,t),null==e||0===e.length)this._buffer=[],this._trianglesArrayBuffer=new ArrayBuffer(i*this._bufferCapacity),this._trianglesReader=new Uint8Array(this._trianglesArrayBuffer);else{for(var n=[],r=new ArrayBuffer(i*this._bufferCapacity),s=0;s<e.length;s++)n[s]=new cc.V2F_C4B_T2F_Triangle(e[s].a,e[s].b,e[s].c,r,s*i);this._trianglesReader=new Uint8Array(r),this._trianglesArrayBuffer=r,this._buffer=n}}},e.drawDot=function(t,e,i){null==(i=i||this.getDrawColor()).a&&(i.a=255);var n={r:0|i.r,g:0|i.g,b:0|i.b,a:0|i.a},r={vertices:{x:t.x-e,y:t.y-e},colors:n,texCoords:{u:-1,v:-1}},s={vertices:{x:t.x-e,y:t.y+e},colors:n,texCoords:{u:-1,v:1}},o={vertices:{x:t.x+e,y:t.y+e},colors:n,texCoords:{u:1,v:1}},a={vertices:{x:t.x+e,y:t.y-e},colors:n,texCoords:{u:1,v:-1}};this._ensureCapacity(6),this._buffer.push(new cc.V2F_C4B_T2F_Triangle(r,s,o,this._trianglesArrayBuffer,this._buffer.length*cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT)),this._buffer.push(new cc.V2F_C4B_T2F_Triangle(r,o,a,this._trianglesArrayBuffer,this._buffer.length*cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT)),this._dirty=!0},e.drawDots=function(t,e,i){if(t&&0!==t.length){null==(i=i||this.getDrawColor()).a&&(i.a=255);for(var n=0,r=t.length;n<r;n++)this.drawDot(t[n],e,i)}},e.drawSegment=function(t,e,i,r){null==(r=r||this.getDrawColor()).a&&(r.a=255),i=i||.5*this._lineWidth;this._ensureCapacity(18);var s={r:0|r.r,g:0|r.g,b:0|r.b,a:0|r.a},o=cc.v2(t),a=cc.v2(e),c=cc.pNormalize(cc.pPerp(cc.pSub(a,o))),h=cc.pPerp(c),l=cc.pMult(c,i),u=cc.pMult(h,i),_=cc.pSub(a,cc.pAdd(l,u)),d=cc.pAdd(a,cc.pSub(l,u)),f=cc.pSub(a,l),p=cc.pAdd(a,l),m=cc.pSub(o,l),g=cc.pAdd(o,l),y=cc.pSub(o,cc.pSub(l,u)),v=cc.pAdd(o,cc.pAdd(l,u)),x=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,C=this._trianglesArrayBuffer,T=this._buffer;T.push(new cc.V2F_C4B_T2F_Triangle({vertices:_,colors:s,texCoords:n(cc.pNeg(cc.pAdd(c,h)))},{vertices:d,colors:s,texCoords:n(cc.pSub(c,h))},{vertices:f,colors:s,texCoords:n(cc.pNeg(c))},C,T.length*x)),T.push(new cc.V2F_C4B_T2F_Triangle({vertices:p,colors:s,texCoords:n(c)},{vertices:d,colors:s,texCoords:n(cc.pSub(c,h))},{vertices:f,colors:s,texCoords:n(cc.pNeg(c))},C,T.length*x)),T.push(new cc.V2F_C4B_T2F_Triangle({vertices:p,colors:s,texCoords:n(c)},{vertices:m,colors:s,texCoords:n(cc.pNeg(c))},{vertices:f,colors:s,texCoords:n(cc.pNeg(c))},C,T.length*x)),T.push(new cc.V2F_C4B_T2F_Triangle({vertices:p,colors:s,texCoords:n(c)},{vertices:m,colors:s,texCoords:n(cc.pNeg(c))},{vertices:g,colors:s,texCoords:n(c)},C,T.length*x)),T.push(new cc.V2F_C4B_T2F_Triangle({vertices:y,colors:s,texCoords:n(cc.pSub(h,c))},{vertices:m,colors:s,texCoords:n(cc.pNeg(c))},{vertices:g,colors:s,texCoords:n(c)},C,T.length*x)),T.push(new cc.V2F_C4B_T2F_Triangle({vertices:y,colors:s,texCoords:n(cc.pSub(h,c))},{vertices:v,colors:s,texCoords:n(cc.pAdd(c,h))},{vertices:g,colors:s,texCoords:n(c)},C,T.length*x)),this._dirty=!0},e.drawPoly=function(t,e,i,r,s){if(null!=e){null==e.a&&(e.a=255),null==r.a&&(r.a=255),i=null==i?this._lineWidth:i,i*=.5;var o,a,c,h,l={r:0|e.r,g:0|e.g,b:0|e.b,a:0|e.a},u={r:0|r.r,g:0|r.g,b:0|r.b,a:0|r.a},_=[],d=t.length;for(o=0;o<d;o++){a=cc.v2(t[(o-1+d)%d]),c=cc.v2(t[o]),h=cc.v2(t[(o+1)%d]);var f=cc.pNormalize(cc.pPerp(cc.pSub(c,a))),p=cc.pNormalize(cc.pPerp(cc.pSub(h,c))),m=cc.pMult(cc.pAdd(f,p),1/(cc.pDot(f,p)+1));_[o]={offset:m,n:p}}var g=i>0,y=3*(3*d-2);this._ensureCapacity(y);var v,x,C,T=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,b=this._trianglesArrayBuffer,A=this._buffer;for(o=0;o<d-2;o++)v={vertices:t[0],colors:l,texCoords:n(cc.v2())},x={vertices:t[o+1],colors:l,texCoords:n(cc.v2())},C={vertices:t[o+2],colors:l,texCoords:n(cc.v2())},A.push(new cc.V2F_C4B_T2F_Triangle(v,x,C,b,A.length*T));if(g)for(o=0;o<d;o++){var S=(o+1)%d;a=cc.v2(t[o]),c=cc.v2(t[S]);var w=_[o].n,E=_[o].offset,I=_[S].offset,R=cc.pSub(a,cc.pMult(E,i)),P=cc.pSub(c,cc.pMult(I,i)),O=cc.pAdd(a,cc.pMult(E,i)),B=cc.pAdd(c,cc.pMult(I,i));v={vertices:R,colors:u,texCoords:n(cc.pNeg(w))},x={vertices:P,colors:u,texCoords:n(cc.pNeg(w))},C={vertices:B,colors:u,texCoords:n(w)},A.push(new cc.V2F_C4B_T2F_Triangle(v,x,C,b,A.length*T)),v={vertices:R,colors:u,texCoords:n(cc.pNeg(w))},x={vertices:O,colors:u,texCoords:n(w)},C={vertices:B,colors:u,texCoords:n(w)},A.push(new cc.V2F_C4B_T2F_Triangle(v,x,C,b,A.length*T))}_=null,this._dirty=!0}else this._drawSegments(t,i,r,!s)},e._drawSegments=function(t,e,i,r){if(e=null==e?this._lineWidth:e,null==(i=i||this._drawColor).a&&(i.a=255),!((e*=.5)<=0)){var s,o,a,c,h={r:0|i.r,g:0|i.g,b:0|i.b,a:0|i.a},l=[],u=t.length;for(s=0;s<u;s++){o=cc.v2(t[(s-1+u)%u]),a=cc.v2(t[s]),c=cc.v2(t[(s+1)%u]);var _=cc.pNormalize(cc.pPerp(cc.pSub(a,o))),d=cc.pNormalize(cc.pPerp(cc.pSub(c,a))),f=cc.pMult(cc.pAdd(_,d),1/(cc.pDot(_,d)+1));l[s]={offset:f,n:d}}var p=3*(3*u-2);this._ensureCapacity(p);var m=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,g=this._trianglesArrayBuffer,y=this._buffer,v=r?u:u-1;for(s=0;s<v;s++){var x=(s+1)%u;o=cc.v2(t[s]),a=cc.v2(t[x]);var C=l[s].n,T=l[s].offset,b=l[x].offset,A=cc.pSub(o,cc.pMult(T,e)),S=cc.pSub(a,cc.pMult(b,e)),w=cc.pAdd(o,cc.pMult(T,e)),E=cc.pAdd(a,cc.pMult(b,e));y.push(new cc.V2F_C4B_T2F_Triangle({vertices:A,colors:h,texCoords:n(cc.pNeg(C))},{vertices:S,colors:h,texCoords:n(cc.pNeg(C))},{vertices:E,colors:h,texCoords:n(C)},g,y.length*m)),y.push(new cc.V2F_C4B_T2F_Triangle({vertices:A,colors:h,texCoords:n(cc.pNeg(C))},{vertices:w,colors:h,texCoords:n(C)},{vertices:E,colors:h,texCoords:n(C)},g,y.length*m))}l=null,this._dirty=!0}},e.clear=function(){this._buffer.length=0,this._dirty=!0},t("./CCDrawNodeWebGLRenderCmd"),e._createRenderCmd=function(){return new cc.DrawNode.WebGLRenderCmd(this)})}))}),{"./CCDrawNodeCanvasRenderCmd":276,"./CCDrawNodeWebGLRenderCmd":277}],276:[(function(t,e,i){cc.DrawNode.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._buffer=null,this._drawColor=null,this._blendFunc=null};var n=cc.DrawNode.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=cc.DrawNode.CanvasRenderCmd,n.rendering=function(t,e,i){var n=t||cc._renderContext,r=(n.getContext(),this._node._displayedOpacity/255);if(0!==r){n.setTransform(this._worldTransform,e,i),n.setGlobalAlpha(r),this._blendFunc&&this._blendFunc.src===cc.macro.SRC_ALPHA&&this._blendFunc.dst===cc.macro.ONE&&n.setCompositeOperation("lighter");for(var s=this._buffer,o=0,a=s.length;o<a;o++){var c=s[o];switch(c.type){case cc.DrawNode.TYPE_DOT:this._drawDot(n,c,e,i);break;case cc.DrawNode.TYPE_SEGMENT:this._drawSegment(n,c,e,i);break;case cc.DrawNode.TYPE_POLY:this._drawPoly(n,c,e,i)}}}},n._drawDot=function(t,e,i,n){var r=e.fillColor,s=e.verts[0],o=e.lineWidth,a=t.getContext();t.setFillStyle("rgba("+(0|r.r)+","+(0|r.g)+","+(0|r.b)+","+r.a/255+")"),a.beginPath(),a.arc(s.x,-s.y,o,0,2*Math.PI,!1),a.closePath(),a.fill()},n._drawSegment=function(t,e,i,n){var r=e.lineColor,s=e.verts[0],o=e.verts[1],a=e.lineWidth,c=e.lineCap,h=t.getContext();t.setStrokeStyle("rgba("+(0|r.r)+","+(0|r.g)+","+(0|r.b)+","+r.a/255+")"),h.lineWidth=a*i,h.beginPath(),h.lineCap=c,h.moveTo(s.x,-s.y),h.lineTo(o.x,-o.y),h.stroke()},n._drawPoly=function(t,e,i,n){var r=e.verts,s=e.lineCap;if(null!=r){var o=e.fillColor,a=e.lineWidth,c=e.lineColor,h=e.isClosePolygon,l=e.isFill,u=e.isStroke,_=t.getContext(),d=r[0];_.lineCap=s,o&&t.setFillStyle("rgba("+(0|o.r)+","+(0|o.g)+","+(0|o.b)+","+o.a/255+")"),a&&(_.lineWidth=a*i),c&&t.setStrokeStyle("rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b)+","+c.a/255+")"),_.beginPath(),_.moveTo(d.x,-d.y);for(var f=1,p=r.length;f<p;f++)_.lineTo(r[f].x,-r[f].y);h&&_.closePath(),l&&_.fill(),u&&_.stroke()}}}),{}],277:[(function(t,e,i){cc.DrawNode.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._matrix=new cc.math.Matrix4,this._matrix.identity()},cc.DrawNode.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype),cc.DrawNode.WebGLRenderCmd.prototype.constructor=cc.DrawNode.WebGLRenderCmd,cc.DrawNode.WebGLRenderCmd.prototype.rendering=function(t){var e=this._node;if(e._buffer.length>0){var i=this._worldTransform,n=this._matrix.mat;n[0]=i.a,n[4]=i.c,n[12]=i.tx,n[1]=i.b,n[5]=i.d,n[13]=i.ty,cc.gl.blendFunc(e._blendFunc.src,e._blendFunc.dst),this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._matrix),e._render()}}}),{}],278:[(function(t,e,i){_ccsg.TMXLayer=_ccsg.Node.extend({tiles:null,tileset:null,layerOrientation:null,properties:null,layerName:"",_texture:null,_textures:null,_texGrids:null,_spriteTiles:null,_layerSize:null,_mapTileSize:null,_opacity:255,_minGID:null,_maxGID:null,_vertexZvalue:null,_useAutomaticVertexZ:null,_reusedTile:null,_contentScaleFactor:null,_staggerAxis:null,_staggerIndex:null,_hexSideLength:0,_className:"TMXLayer",ctor:function(t,e,i){cc.SpriteBatchNode.prototype.ctor.call(this),this._layerSize=cc.size(0,0),this._mapTileSize=cc.size(0,0),this._spriteTiles={},this._staggerAxis=cc.TiledMap.StaggerAxis.STAGGERAXIS_Y,this._staggerIndex=cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN,void 0!==i&&this.initWithTilesetInfo(t,e,i)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.TMXLayer.CanvasRenderCmd(this):new _ccsg.TMXLayer.WebGLRenderCmd(this)},_fillTextureGrids:function(t,e){var i=this._textures[e];if(i.isLoaded()){t.imageSize.width&&t.imageSize.height||(t.imageSize.width=i.width,t.imageSize.height=i.height);for(var n=t._tileSize.width,r=t._tileSize.height,s=i.width,o=i.height,a=t.spacing,c=t.margin,h=Math.floor((s-2*c+a)/(n+a)),l=Math.floor((o-2*c+a)/(r+a))*h,u=t.firstGid,_=t.firstGid+l,d=this._texGrids,f=null,p=!!d[u],m=cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX?.5:0;u<_&&(p&&!d[u]&&(p=!1),p||!d[u]);++u)f={texId:e,x:0,y:0,width:n,height:r,t:0,l:0,r:0,b:0},t.rectForGID(u,f),f.x+=m,f.y+=m,f.width-=2*m,f.height-=2*m,f.t=f.y/o,f.l=f.x/s,f.r=(f.x+f.width)/s,f.b=(f.y+f.height)/o,d[u]=f}else i.once("load",(function(){this._fillTextureGrids(t,e)}),this)},initWithTilesetInfo:function(t,e,i){var n=e._layerSize;this.layerName=e.name,this.tiles=e._tiles,this.properties=e.properties,this._layerSize=n,this._minGID=e._minGID,this._maxGID=e._maxGID,this._opacity=e._opacity,this._staggerAxis=i.getStaggerAxis(),this._staggerIndex=i.getStaggerIndex(),this._hexSideLength=i.getHexSideLength(),this.tileset=t,this.layerOrientation=i.orientation,this._mapTileSize=i.getTileSize();var r=i._tilesets;if(r){var s,o,a,c=r.length;for(this._textures=new Array(c),this._texGrids=[],s=0;s<c;++s)o=r[s],a=cc.textureCache.addImage(o.sourceImage,(function(t){t.setAliasTexParameters()})),this._textures[s]=a,this._fillTextureGrids(o,s),o===t&&(this._texture=a)}var h=this._calculateLayerOffset(e.offset);if(this.setPosition(h),this._parseInternalProperties(),this.layerOrientation===cc.TiledMap.Orientation.HEX){var l=0,u=0;this._staggerAxis===cc.TiledMap.StaggerAxis.STAGGERAXIS_X?(u=i._tileSize.height*(this._layerSize.height+.5),l=(i._tileSize.width+this._hexSideLength)*Math.floor(this._layerSize.width/2)+i._tileSize.width*(this._layerSize.width%2)):(l=i._tileSize.width*(this._layerSize.width+.5),u=(i._tileSize.height+this._hexSideLength)*Math.floor(this._layerSize.height/2)+i._tileSize.height*(this._layerSize.height%2)),this.setContentSize(l,u)}else this.setContentSize(this._layerSize.width*this._mapTileSize.width,this._layerSize.height*this._mapTileSize.height);return this._useAutomaticVertexZ=!1,this._vertexZvalue=0,!0},visit:function(t){var e=this._renderCmd,i=t?t._renderCmd:null;if(this._visible){var n=cc.renderer;e.visit(i);var r,s,o=this._children,a=o.length,c=cc._renderType===cc.game.RENDER_TYPE_CANVAS,h=this._spriteTiles;if(a>0){for(this._reorderChildDirty&&this.sortAllChildren(),r=0;r<a&&(s=o[r])._localZOrder<0;r++)s.visit(this);for(n.pushRenderCommand(e);r<a;r++)s=o[r],c&&0===s._localZOrder&&h[s.tag]?(isNaN(s._customZ)&&(s._vertexZ=n.assignedZ,n.assignedZ+=n.assignedZStep),s._renderCmd.updateStatus()):s.visit(this)}else n.pushRenderCommand(e);cc._renderType===cc.game.RENDER_TYPE_WEBGL&&n.pushRenderCommand(this._renderCmd._disableDepthTestCmd),e._dirtyFlag=0}else e._propagateFlagsDown(i)},getLayerSize:function(){return cc.size(this._layerSize.width,this._layerSize.height)},setLayerSize:function(t){this._layerSize.width=t.width,this._layerSize.height=t.height},_getLayerWidth:function(){return this._layerSize.width},_setLayerWidth:function(t){this._layerSize.width=t},_getLayerHeight:function(){return this._layerSize.height},_setLayerHeight:function(t){this._layerSize.height=t},getMapTileSize:function(){return cc.size(this._mapTileSize.width,this._mapTileSize.height)},setMapTileSize:function(t){this._mapTileSize.width=t.width,this._mapTileSize.height=t.height},_getTileWidth:function(){return this._mapTileSize.width},_setTileWidth:function(t){this._mapTileSize.width=t},_getTileHeight:function(){return this._mapTileSize.height},_setTileHeight:function(t){this._mapTileSize.height=t},getTiles:function(){return this.tiles},setTiles:function(t){this.tiles=t},getTileSet:function(){return this.tileset},setTileSet:function(t){this.tileset=t},getLayerOrientation:function(){return this.layerOrientation},setLayerOrientation:function(t){this.layerOrientation=t},getProperties:function(){return this.properties},setProperties:function(t){this.properties=t},getProperty:function(t){return this.properties[t]},getLayerName:function(){return this.layerName},setLayerName:function(t){this.layerName=t},releaseMap:function(){this._spriteTiles={}},getTileAt:function(t,e){if(void 0===t)throw new Error("_ccsg.TMXLayer.getTileAt(): pos should be non-null");var i=t;if(void 0===e&&(i=t.x,e=t.y),i>=this._layerSize.width||e>=this._layerSize.height||i<0||e<0)throw new Error("_ccsg.TMXLayer.getTileAt(): invalid position");if(!this.tiles)return cc.logID(7204),null;var n=null,r=this.getTileGIDAt(i,e);if(0===r)return n;var s=Math.floor(i)+Math.floor(e)*this._layerSize.width;if(!(n=this._spriteTiles[s])){var o=this._texGrids[r],a=this._textures[o.texId];(n=new _ccsg.Sprite(a,o)).setPosition(this.getPositionAt(i,e));var c=this._vertexZForPos(i,e);n.setVertexZ(c),n.setAnchorPoint(0,0),n.setOpacity(this._opacity),this.addChild(n,c,s)}return n},getTileGIDAt:function(t,e){if(void 0===t)throw new Error("_ccsg.TMXLayer.getTileGIDAt(): pos should be non-null");var i=t;if(void 0===e&&(i=t.x,e=t.y),i>=this._layerSize.width||e>=this._layerSize.height||i<0||e<0)throw new Error("_ccsg.TMXLayer.getTileGIDAt(): invalid position");if(!this.tiles)return cc.logID(7205),null;var n=Math.floor(i)+Math.floor(e)*this._layerSize.width;return(this.tiles[n]&cc.TiledMap.TileFlag.FLIPPED_MASK)>>>0},setTileGID:function(t,e,i,n){if(void 0===e)throw new Error("_ccsg.TMXLayer.setTileGID(): pos should be non-null");var r;if(void 0===n&&e instanceof cc.Vec2?(r=e,n=i):r=cc.p(e,i),r.x=Math.floor(r.x),r.y=Math.floor(r.y),r.x>=this._layerSize.width||r.y>=this._layerSize.height||r.x<0||r.y<0)throw new Error("_ccsg.TMXLayer.setTileGID(): invalid position");if(this.tiles)if(0!==t&&t<this.tileset.firstGid)cc.logID(7207,t);else{n=n||0;var s=this.getTileFlagsAt(r),o=this.getTileGIDAt(r);if(o!==t||s!==n){var a=(t|n)>>>0;if(0===t)this.removeTileAt(r);else if(0===o)this._updateTileForGID(a,r);else{var c=r.x+r.y*this._layerSize.width,h=this.getChildByTag(c);if(h){var l=this._texGrids[t],u=this._textures[l.texId];h.setTexture(u),h.setTextureRect(l,!1),null!=n&&this._setupTileSprite(h,r,a),this.tiles[c]=a}else this._updateTileForGID(a,r)}}}else cc.logID(7206)},addChild:function(t,e,i){_ccsg.Node.prototype.addChild.call(this,t,e,i),void 0!==i&&(this._spriteTiles[i]=t,t._vertexZ=this._vertexZ+cc.renderer.assignedZStep*i/this.tiles.length)},removeChild:function(t,e){this._spriteTiles[t.tag]&&(this._spriteTiles[t.tag]=null),_ccsg.Node.prototype.removeChild.call(this,t,e)},getTileFlagsAt:function(t,e){if(!t)throw new Error("_ccsg.TMXLayer.getTileFlagsAt(): pos should be non-null");if(void 0!==e&&(t=cc.p(t,e)),t.x>=this._layerSize.width||t.y>=this._layerSize.height||t.x<0||t.y<0)throw new Error("_ccsg.TMXLayer.getTileFlagsAt(): invalid position");if(!this.tiles)return cc.logID(7208),null;var i=Math.floor(t.x)+Math.floor(t.y)*this._layerSize.width;return(this.tiles[i]&cc.TiledMap.TileFlag.FLIPPED_ALL)>>>0},removeTileAt:function(t,e){if(!t)throw new Error("_ccsg.TMXLayer.removeTileAt(): pos should be non-null");if(void 0!==e&&(t=cc.p(t,e)),t.x>=this._layerSize.width||t.y>=this._layerSize.height||t.x<0||t.y<0)throw new Error("_ccsg.TMXLayer.removeTileAt(): invalid position");if(this.tiles){if(0!==this.getTileGIDAt(t)){var i=Math.floor(t.x)+Math.floor(t.y)*this._layerSize.width;this.tiles[i]=0;var n=this._spriteTiles[i];n&&this.removeChild(n,!0)}}else cc.logID(7209)},getPositionAt:function(t,e){void 0!==e&&(t=cc.p(t,e)),t.x=Math.floor(t.x),t.y=Math.floor(t.y);var i=cc.p(0,0);switch(this.layerOrientation){case cc.TiledMap.Orientation.ORTHO:i=this._positionForOrthoAt(t);break;case cc.TiledMap.Orientation.ISO:i=this._positionForIsoAt(t);break;case cc.TiledMap.Orientation.HEX:i=this._positionForHexAt(t)}return i},_positionForIsoAt:function(t){return cc.p(this._mapTileSize.width/2*(this._layerSize.width+t.x-t.y-1),this._mapTileSize.height/2*(2*this._layerSize.height-t.x-t.y-2))},_positionForOrthoAt:function(t){return cc.p(t.x*this._mapTileSize.width,(this._layerSize.height-t.y-1)*this._mapTileSize.height)},_positionForHexAt:function(t){var e=cc.p(0,0),i=this.tileset.tileOffset,n=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?1:-1;switch(this._staggerAxis){case cc.TiledMap.StaggerAxis.STAGGERAXIS_Y:var r=0;t.y%2==1&&(r=this._mapTileSize.width/2*n),e=cc.p(t.x*this._mapTileSize.width+r+i.x,(this._layerSize.height-t.y-1)*(this._mapTileSize.height-(this._mapTileSize.height-this._hexSideLength)/2)-i.y);break;case cc.TiledMap.StaggerAxis.STAGGERAXIS_X:var s=0;t.x%2==1&&(s=this._mapTileSize.height/2*-n),e=cc.p(t.x*(this._mapTileSize.width-(this._mapTileSize.width-this._hexSideLength)/2)+i.x,(this._layerSize.height-t.y-1)*this._mapTileSize.height+s-i.y)}return e},_calculateLayerOffset:function(t){var e=cc.p(0,0);switch(this.layerOrientation){case cc.TiledMap.Orientation.ORTHO:e=cc.p(t.x*this._mapTileSize.width,-t.y*this._mapTileSize.height);break;case cc.TiledMap.Orientation.ISO:e=cc.p(this._mapTileSize.width/2*(t.x-t.y),this._mapTileSize.height/2*(-t.x-t.y));break;case cc.TiledMap.Orientation.HEX:if(this._staggerAxis===cc.TiledMap.StaggerAxis.STAGGERAXIS_Y){var i=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN?this._mapTileSize.width/2:0;e=cc.p(t.x*this._mapTileSize.width+i,-t.y*(this._mapTileSize.height-(this._mapTileSize.width-this._hexSideLength)/2))}else if(this._staggerAxis===cc.TiledMap.StaggerAxis.STAGGERAXIS_X){var n=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?this._mapTileSize.height/2:0;e=cc.p(t.x*(this._mapTileSize.width-(this._mapTileSize.width-this._hexSideLength)/2),-t.y*this._mapTileSize.height+n)}}return e},_updateTileForGID:function(t,e){if(this._texGrids[t]){var i=0|e.x+e.y*this._layerSize.width;i<this.tiles.length&&(this.tiles[i]=t)}},_parseInternalProperties:function(){var t=this.getProperty("cc_vertexz");if(t)if("automatic"===t){this._useAutomaticVertexZ=!0;var e=this.getProperty("cc_alpha_func"),i=0;e&&(i=parseFloat(e)),cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(this.shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST),this.shaderProgram.use(),this.shaderProgram.setUniformLocationWith1f(cc.UNIFORM_ALPHA_TEST_VALUE_S,i))}else this._vertexZvalue=parseInt(t,10)},_setupTileSprite:function(t,e,i){var n=this.getPositionAt(e);if(t.setPosition(n),t.setVertexZ(this._vertexZForPos(e)),t.setAnchorPoint(0,0),t.setOpacity(this._opacity),t.setFlippedX(!1),t.setFlippedY(!1),t.setRotation(0),(i&cc.TiledMap.TileFlag.DIAGONAL)>>>0){t.setAnchorPoint(.5,.5),t.setPosition(n.x+t.width/2,n.y+t.height/2);var r=(i&(cc.TiledMap.TileFlag.HORIZONTAL|cc.TiledMap.TileFlag.VERTICAL)>>>0)>>>0;r===cc.TiledMap.TileFlag.HORIZONTAL?t.setRotation(90):r===cc.TiledMap.TileFlag.VERTICAL?t.setRotation(270):r===(cc.TiledMap.TileFlag.VERTICAL|cc.TiledMap.TileFlag.HORIZONTAL)>>>0?(t.setRotation(90),t.setFlippedX(!0)):(t.setRotation(270),t.setFlippedX(!0))}else(i&cc.TiledMap.TileFlag.HORIZONTAL)>>>0&&t.setFlippedX(!0),(i&cc.TiledMap.TileFlag.VERTICAL)>>>0&&t.setFlippedY(!0)},_vertexZForPos:function(t,e){void 0===e&&(e=t.y,t=t.x);var i=0;if(this._useAutomaticVertexZ)switch(this.layerOrientation){case cc.TiledMap.Orientation.ISO:i=-(this._layerSize.width+this._layerSize.height-(t+e));break;case cc.TiledMap.Orientation.ORTHO:i=-(this._layerSize.height-e);break;case cc.TiledMap.Orientation.HEX:cc.logID(7210);break;default:cc.logID(7211)}else i=this._vertexZvalue;return i}})}),{}],279:[(function(t,e,i){t("../shape-nodes/CCDrawNode"),_ccsg.TMXObject=cc.Class({properties:{sgNode:null,offset:cc.p(0,0),gid:0,name:"",type:null,id:0,objectVisible:!0,objectSize:cc.size(0,0),objectRotation:0,_properties:null,_groupSize:cc.size(0,0)},initWithInfo:function(t,e,i,n){this.setProperties(t),this.setObjectName(t.name),this.id=t.id,this.gid=t.gid,this.type=t.type,this.offset=cc.p(t.x,t.y),this.objectSize=cc.size(t.width,t.height),this.objectVisible=t.visible,this.objectRotation=t.rotation,this._groupSize=i,this.type===cc.TiledMap.TMXObjectType.IMAGE?this.sgNode=new _ccsg.TMXObjectImage(this,e):this.sgNode=new _ccsg.TMXObjectShape(this,e,n)},getObjectName:function(){return this.name},getProperty:function(t){return this._properties[t]},getProperties:function(){return this._properties},setObjectName:function(t){this.name=t},setProperties:function(t){this._properties=t}}),_ccsg.TMXObjectImage=_ccsg.Sprite.extend({_container:null,ctor:function(t,e){_ccsg.Sprite.prototype.ctor.call(this),this._container=t,this.initWithMapInfo(e)},initWithMapInfo:function(t){if(!this._container.gid)return!1;for(var e,i=t.getTilesets(),n=i.length-1;n>=0;n--){var r=i[n];if((this._container.gid&cc.TiledMap.TileFlag.FLIPPED_MASK)>>>0>=r.firstGid){e=r;break}}if(!e)return!1;this.setVisible(this._container.objectVisible);var s=cc.textureCache.addImage(cc.path._normalize(r.sourceImage));return this._initWithTileset(s,e),this._initPosWithMapInfo(t),this.setRotation(this._container.objectRotation),(this._container.gid&cc.TiledMap.TileFlag.HORIZONTAL)>>>0&&this.setFlippedX(!0),(this._container.gid&cc.TiledMap.TileFlag.VERTICAL)>>>0&&this.setFlippedY(!0),!0},_initWithTileset:function(t,e){if(t.isLoaded()){e.imageSize.width=t.width,e.imageSize.height=t.height;var i=e.rectForGID(this._container.gid);this.initWithTexture(t,i),this.setScaleX(this._container.objectSize.width/i.size.width),this.setScaleY(this._container.objectSize.height/i.size.height)}else t.once("load",(function(){this._initWithTileset(t,e)}),this)},_initPosWithMapInfo:function(t){switch(t.getOrientation()){case cc.TiledMap.Orientation.ORTHO:case cc.TiledMap.Orientation.HEX:this.setAnchorPoint(cc.p(0,0)),this.setPosition(this._container.offset.x,this._container._groupSize.height-this._container.offset.y);break;case cc.TiledMap.Orientation.ISO:this.setAnchorPoint(cc.p(.5,0));var e=cc.p(this._container.offset.x/t._tileSize.height,this._container.offset.y/t._tileSize.height),i=cc.p(t._tileSize.width/2*(t._mapSize.width+e.x-e.y),t._tileSize.height/2*(2*t._mapSize.height-e.x-e.y));this.setPosition(i)}}}),_ccsg.TMXObjectShape=cc.DrawNode.extend({_container:null,_color:cc.Color.WHITE,_mapOrientation:0,_mapInfo:null,ctor:function(t,e,i){cc.DrawNode.prototype.ctor.call(this),this.setLineWidth(1),this._container=t,this._color=i,this._mapInfo=e,this._mapOrientation=e.getOrientation(),this._initShape()},_initShape:function(){var t;if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){var e=cc.p(0,this._container._groupSize.height);t=cc.p(e.x+this._container.offset.x,e.y-this._container.offset.y)}else t=this._getPosByOffset(cc.p(0,0));switch(this.setPosition(t),this.setRotation(this._container.objectRotation),this._container.type){case cc.TiledMap.TMXObjectType.RECT:this._drawRect();break;case cc.TiledMap.TMXObjectType.ELLIPSE:this._drawEllipse();break;case cc.TiledMap.TMXObjectType.POLYGON:this._drawPoly(t,!0);break;case cc.TiledMap.TMXObjectType.POLYLINE:this._drawPoly(t,!1)}this.setVisible(this._container.objectVisible)},_getPosByOffset:function(t){var e=this._mapInfo.getMapSize(),i=this._mapInfo.getTileSize(),n=cc.p((this._container.offset.x+t.x)/i.width*2,(this._container.offset.y+t.y)/i.height);return cc.p(i.width/2*(e.width+n.x-n.y),i.height/2*(2*e.height-n.x-n.y))},_drawRect:function(){if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){var t=this._container.objectSize;t.equals(cc.Size.ZERO)?(t=cc.size(20,20),this.setAnchorPoint(cc.p(.5,.5))):this.setAnchorPoint(cc.p(0,1));var e=cc.p(0,0),i=cc.p(t.width,t.height);this.drawRect(e,i,null,this.getLineWidth(),this._color),this.setContentSize(t)}else{if(this._container.objectSize.equals(cc.Size.ZERO))return;var n=this._getPosByOffset(cc.p(0,0)),r=this._getPosByOffset(cc.p(this._container.objectSize.width,0)),s=this._getPosByOffset(cc.p(this._container.objectSize.width,this._container.objectSize.height)),o=this._getPosByOffset(cc.p(0,this._container.objectSize.height)),a=r.x-o.x,c=n.y-s.y;this.setContentSize(cc.size(a,c)),this.setAnchorPoint(cc.p((n.x-o.x)/a,1));var h=cc.p(o.x,s.y);n.subSelf(h),r.subSelf(h),s.subSelf(h),o.subSelf(h),this._container.objectSize.width>0&&(this.drawSegment(n,r,this.getLineWidth(),this._color),this.drawSegment(s,o,this.getLineWidth(),this._color)),this._container.objectSize.height>0&&(this.drawSegment(n,o,this.getLineWidth(),this._color),this.drawSegment(s,r,this.getLineWidth(),this._color))}},_drawEllipse:function(){var t=1,e=1,i=0,n=cc.p(0,0),r=null;if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){var s=this._container.objectSize;s.equals(cc.Size.ZERO)?(s=cc.size(20,20),this.setAnchorPoint(cc.p(.5,.5))):this.setAnchorPoint(cc.p(0,1)),n=cc.p(s.width/2,s.height/2),s.width>s.height?(t=s.width/s.height,i=s.height/2):(e=s.height/s.width,i=s.width/2),r=this,this.setContentSize(s)}else{if(this._container.objectSize.equals(cc.Size.ZERO))return;var o=this._getPosByOffset(cc.p(0,0)),a=this._getPosByOffset(cc.p(this._container.objectSize.width,0)),c=this._getPosByOffset(cc.p(this._container.objectSize.width,this._container.objectSize.height)),h=this._getPosByOffset(cc.p(0,this._container.objectSize.height)),l=a.x-h.x,u=o.y-c.y;this.setContentSize(cc.size(l,u)),this.setAnchorPoint(cc.p((o.x-h.x)/l,1));var _=cc.p(h.x,c.y);o.subSelf(_),a.subSelf(_),c.subSelf(_),h.subSelf(_),this._container.objectSize.width>0&&(this.drawSegment(o,a,this.getLineWidth(),this._color),this.drawSegment(c,h,this.getLineWidth(),this._color)),this._container.objectSize.height>0&&(this.drawSegment(o,h,this.getLineWidth(),this._color),this.drawSegment(c,a,this.getLineWidth(),this._color)),(n=this._getPosByOffset(cc.p(this._container.objectSize.width/2,this._container.objectSize.height/2))).subSelf(_),(r=new cc.DrawNode).setLineWidth(this.getLineWidth()),r.setContentSize(cc.size(l,u)),r.setAnchorPoint(cc.p(.5,.5)),r.setPosition(n),this.addChild(r),this._container.objectSize.width>this._container.objectSize.height?(t=this._container.objectSize.width/this._container.objectSize.height,i=this._container.objectSize.height/2):(e=this._container.objectSize.height/this._container.objectSize.width,i=this._container.objectSize.width/2);var d=this._mapInfo.getTileSize(),f=Math.atan(d.width/d.height);i/=Math.sin(f),r.setRotationX(cc.radiansToDegrees(f)),r.setRotationY(90-cc.radiansToDegrees(f))}r.drawCircle(n,i,0,50,!1,this.getLineWidth(),this._color),r.setScaleX(t),r.setScaleY(e)},_drawPoly:function(t,e){for(var i,n=this._container.getProperties(),r=[],s=0,o=0,a=0,c=0,h=0,l=(i=e?n.points:n.polylinePoints).length;h<l;h++){var u=i[h];r.push(cc.p(u.x,u.y)),s=Math.min(s,u.x),o=Math.min(o,u.y),a=Math.max(a,u.x),c=Math.max(c,u.y)}var _=0,d=0;if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){_=a-s,d=c-o,this.setAnchorPoint(cc.p(-s/_,c/d));for(var f=0;f<r.length;f++)r[f]=cc.p(r[f].x-s,-r[f].y+c)}else{var p=this._getPosByOffset(cc.p(s,c)),m=this._getPosByOffset(cc.p(a,o)),g=this._getPosByOffset(cc.p(0,0));_=m.x-p.x,d=m.y-p.y,this.setAnchorPoint(cc.p((g.x-p.x)/_,(g.y-p.y)/d));for(var y=0;y<r.length;y++){var v=this._getPosByOffset(r[y]);r[y]=cc.p(v.x-p.x,v.y-p.y)}}this.setContentSize(cc.size(_,d)),this.drawPoly(r,null,this.getLineWidth(),this._color,!e)}})}),{"../shape-nodes/CCDrawNode":275}],280:[(function(t,e,i){_ccsg.TMXObjectGroup=_ccsg.Node.extend({properties:null,groupName:"",_positionOffset:null,_mapInfo:null,_objects:[],ctor:function(t,e){_ccsg.Node.prototype.ctor.call(this),this._initGroup(t,e)},_initGroup:function(t,e){this.groupName=t.name,this._positionOffset=t.offset,this._mapInfo=e,this.properties=t.getProperties();var i=e._mapSize,n=e._tileSize;if(e.orientation===cc.TiledMap.Orientation.HEX){var r=0,s=0;e.getStaggerAxis()===cc.TiledMap.StaggerAxis.STAGGERAXIS_X?(s=n.height*(i.height+.5),r=(n.width+e.getHexSideLength())*Math.floor(i.width/2)+n.width*(i.width%2)):(r=n.width*(i.width+.5),s=(n.height+e.getHexSideLength())*Math.floor(i.height/2)+n.height*(i.height%2)),this.setContentSize(r,s)}else this.setContentSize(i.width*n.width,i.height*n.height);this.setAnchorPoint(cc.p(0,0)),this.setPosition(this._positionOffset.x,-this._positionOffset.y),this.setVisible(t.visible);var o=[];t._objects instanceof Array&&(o=t._objects),this._objects=[];for(var a=0,c=o.length;a<c;a++){var h=o[a],l=new _ccsg.TMXObject;l.initWithInfo(h,e,this.getContentSize(),t._color),this._objects.push(l),l.sgNode&&(l.sgNode.setOpacity(t._opacity),this.addChild(l.sgNode,a,a))}},getPositionOffset:function(){return cc.p(this._positionOffset)},setPositionOffset:function(t){this._positionOffset.x=t.x,this._positionOffset.y=t.y},getProperties:function(){return this.properties},setProperties:function(t){this.properties=t},getGroupName:function(){return this.groupName},setGroupName:function(t){this.groupName=t},propertyNamed:function(t){return this.properties[t]},objectNamed:function(t){return this.getObject(t)},getObject:function(t){for(var e=0,i=this._objects.length;e<i;e++){var n=this._objects[e];if(n&&n.getObjectName()===t)return n}return null},getObjects:function(){return this._objects}})}),{}],281:[(function(t,e,i){t("./CCSGTMXObject"),t("./CCTMXXMLParser"),_ccsg.TMXTiledMap=_ccsg.Node.extend({properties:null,mapOrientation:null,_mapSize:null,_tileSize:null,_tileProperties:null,_className:"TMXTiledMap",ctor:function(t,e){_ccsg.Node.prototype.ctor.call(this),this._mapSize=cc.size(0,0),this._tileSize=cc.size(0,0),void 0!==e?this.initWithXML(t,e):void 0!==t&&this.initWithTMXFile(t)},getMapSize:function(){return cc.size(this._mapSize.width,this._mapSize.height)},setMapSize:function(t){this._mapSize.width=t.width,this._mapSize.height=t.height},_getMapWidth:function(){return this._mapSize.width},_setMapWidth:function(t){this._mapSize.width=t},_getMapHeight:function(){return this._mapSize.height},_setMapHeight:function(t){this._mapSize.height=t},getTileSize:function(){return cc.size(this._tileSize.width,this._tileSize.height)},setTileSize:function(t){this._tileSize.width=t.width,this._tileSize.height=t.height},_getTileWidth:function(){return this._tileSize.width},_setTileWidth:function(t){this._tileSize.width=t},_getTileHeight:function(){return this._tileSize.height},_setTileHeight:function(t){this._tileSize.height=t},getMapOrientation:function(){return this.mapOrientation},setMapOrientation:function(t){this.mapOrientation=t},getObjectGroups:function(){for(var t=[],e=this._children,i=0,n=e.length;i<n;i++){var r=e[i];r&&r instanceof _ccsg.TMXObjectGroup&&t.push(r)}return t},getProperties:function(){return this.properties},setProperties:function(t){this.properties=t},initWithTMXFile:function(t){if(!t||0===t.length)return!1;this.width=0,this.height=0;var e=new cc.TMXMapInfo(t);if(!e)return!1;var i=e.getTilesets();return i&&0!==i.length||cc.logID(7212),this._buildWithMapInfo(e),!0},initWithXML:function(t,e){this.width=0,this.height=0;var i=new cc.TMXMapInfo(t,e),n=i.getTilesets();return n&&0!==n.length||cc.logID(7213),this._buildWithMapInfo(i),!0},_buildWithMapInfo:function(t){this._mapSize=t.getMapSize(),this._tileSize=t.getTileSize(),this.mapOrientation=t.orientation,this.properties=t.properties,this._tileProperties=t.getTileProperties();for(var e=this._children,i=e.length-1;i>=0;i--){var n=e[i];n&&(n instanceof _ccsg.TMXLayer||n instanceof _ccsg.TMXObjectGroup)&&this.removeChild(n)}var r=0,s=t.getAllChildren();if(s&&s.length>0)for(var o=0,a=s.length;o<a;o++){var c,h=s[o];h instanceof cc.TMXLayerInfo&&h.visible&&(c=this._parseLayer(h,t),this.addChild(c,r,r),this.width=Math.max(this.width,c.width),this.height=Math.max(this.height,c.height),r++),h instanceof cc.TMXObjectGroupInfo&&(c=new _ccsg.TMXObjectGroup(h,t),this.addChild(c,r,r),r++)}},allLayers:function(){for(var t=[],e=this._children,i=0,n=e.length;i<n;i++){var r=e[i];r&&r instanceof _ccsg.TMXLayer&&t.push(r)}return t},getLayer:function(t){if(!t||0===t.length)throw new Error("_ccsg.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string.");for(var e=this._children,i=0;i<e.length;i++){var n=e[i];if(n&&n instanceof _ccsg.TMXLayer&&n.layerName===t)return n}return null},getObjectGroup:function(t){if(!t||0===t.length)throw new Error("_ccsg.TMXTiledMap.getObjectGroup(): groupName should be non-null or non-empty string.");for(var e=this._children,i=0;i<e.length;i++){var n=e[i];if(n&&n instanceof _ccsg.TMXObjectGroup&&n.groupName===t)return n}return null},getProperty:function(t){return this.properties[t.toString()]},propertiesForGID:function(t){return cc.logID(7214),this.getPropertiesForGID[t]},getPropertiesForGID:function(t){return this._tileProperties[t]},_parseLayer:function(t,e){var i=this._tilesetForLayer(t,e),n=new _ccsg.TMXLayer(i,t,e);return t.ownTiles=!1,n},_tilesetForLayer:function(t,e){var i=t._layerSize,n=e.getTilesets();if(n)for(var r=n.length-1;r>=0;r--){var s=n[r];if(s)for(var o=0;o<i.height;o++)for(var a=0;a<i.width;a++){var c=a+i.width*o,h=t._tiles[c];if(0!==h&&(h&cc.TiledMap.TileFlag.FLIPPED_MASK)>>>0>=s.firstGid)return s}}return cc.logID(7215,t.name),null}});var n=_ccsg.TMXTiledMap.prototype;n.mapWidth,cc.defineGetterSetter(n,"mapWidth",n._getMapWidth,n._setMapWidth),n.mapHeight,cc.defineGetterSetter(n,"mapHeight",n._getMapHeight,n._setMapHeight),n.tileWidth,cc.defineGetterSetter(n,"tileWidth",n._getTileWidth,n._setTileWidth),n.tileHeight,cc.defineGetterSetter(n,"tileHeight",n._getTileHeight,n._setTileHeight)}),{"./CCSGTMXObject":279,"./CCTMXXMLParser":284}],282:[(function(t,e,i){var n=null,r=null,s=null,o=null,a=null;_ccsg.TMXLayer.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,n||(n=cc.TiledMap.Orientation,r=cc.TiledMap.TileFlag,s=r.FLIPPED_MASK,o=cc.TiledMap.StaggerAxis,a=cc.TiledMap.StaggerIndex)};var c=_ccsg.TMXLayer.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);c.constructor=_ccsg.TMXLayer.CanvasRenderCmd,c.rendering=function(t,e,i){var c=this._node,h=c.layerOrientation,l=c.tiles,u=c._opacity/255;if(l&&!(u<=0)&&c.tileset){var _=c._mapTileSize.width,d=c._mapTileSize.height,f=c.tileset._tileSize.width/cc.director._contentScaleFactor,p=c.tileset._tileSize.height/cc.director._contentScaleFactor,m=f-_,g=p-d,y=cc.winSize.width,v=cc.winSize.height,x=c._layerSize.height,C=c._layerSize.width,T=c._texGrids,b=c._spriteTiles,A=this._worldTransform,S=c._position.x,w=c._position.y,E=A.a,I=A.b,R=A.c,P=A.d,O=S*E+w*R+A.tx,B=S*I+w*P+A.ty,D=t||cc._renderContext,M=D.getContext(),L=0,N=0,F=C,k=x;cc.macro.ENABLE_TILEDMAP_CULLING&&h===n.ORTHO&&(L=Math.floor(-(O-m*E)/(_*E)),N=Math.floor((B-g*P+d*x*P-v)/(d*P)),F=Math.ceil((y-O+m*E)/(_*E)),k=x-Math.floor(-(B+g*P)/(d*P)),L<0&&(L=0),N<0&&(N=0),F>C&&(F=C),k>x&&(k=x));var z,V,G,W,U,j,X,Y,H,q,J,Z,Q,K,$,tt,et=N*C,it=f,nt=p,rt=f*E,st=p*P,ot=!1,at=!1;W=et+L;for(z in b)if(z<W&&b[z])Y=b[z]._renderCmd,0===b[z]._localZOrder&&Y.rendering&&b[z]._visible&&Y.rendering(t,e,i);else if(z>=W)break;D.setTransform(A,e,i),D.setGlobalAlpha(u);var ct,ht,lt,ut,_t;if(h===n.HEX){var dt=c._staggerIndex,ft=c._hexSideLength;ct=c._staggerAxis,ht=c.tileset.tileOffset,lt=dt===a.STAGGERINDEX_ODD?1:-1,ut=ct===o.STAGGERAXIS_X?(_-ft)/2:0,_t=ct===o.STAGGERAXIS_Y?(d-ft)/2:0}for(V=N;V<k;++V){for(G=L;G<F;++G)if(W=et+G,b[W])Y=b[W]._renderCmd,0===b[W]._localZOrder&&Y.rendering&&b[W]._visible&&(Y.rendering(t,e,i),D.setTransform(A,e,i),D.setGlobalAlpha(u));else if(U=c.tiles[W],(j=T[(U&s)>>>0])&&(X=c._textures[j.texId])&&X._image){switch(h){case n.ORTHO:q=G*_,J=-(x-V-1)*d;break;case n.ISO:q=_/2*(C+G-V-1),J=-d/2*(2*x-G-V-2);break;case n.HEX:q=G*(_-ut)+(ct===o.STAGGERAXIS_Y&&V%2==1?_/2*lt:0)+ht.x;J=-(x-V-1)*(d-_t)-(ct===o.STAGGERAXIS_X&&G%2==1?d/2*-lt:0)+ht.y}if(Z=q+f,H=J-p,h===n.ISO){if(($=J*P-B)<-v-st){G+=Math.floor(2*(-v-$)/st)-1;continue}if((tt=O+Z*E)<-rt){G+=Math.floor(2*-tt/rt)-1;continue}if(K=O+q*E,Q=H*P-B,K>y||Q>0){G=F;continue}}U>r.DIAGONAL&&(ot=(U&r.HORIZONTAL)>>>0,at=(U&r.VERTICAL)>>>0),ot&&(q=-Z,M.scale(-1,1)),at&&(H=-J,M.scale(1,-1)),M.drawImage(X._image,j.x,j.y,j.width,j.height,q,H,it,nt),ot&&M.scale(-1,1),at&&M.scale(1,-1),cc.g_NumberOfDraws++}et+=C}for(z in b)z>W&&b[z]&&(Y=b[z]._renderCmd,0===b[z]._localZOrder&&Y.rendering&&b[z]._visible&&Y.rendering(t,e,i))}}}),{}],283:[(function(t,e,i){function n(){cc.renderer.setDepthTest(!1)}var r=null,s=null,o=null,a=null,c=null;_ccsg.TMXLayer.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._vertices=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],this._color=new Uint32Array(1),this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST);var e=90*Math.PI/180;this._sin90=Math.sin(e),this._cos90=Math.cos(e),e*=3,this._sin270=Math.sin(e),this._cos270=Math.cos(e),r||(r=cc.TiledMap.Orientation,s=cc.TiledMap.TileFlag,o=s.FLIPPED_MASK,a=cc.TiledMap.StaggerAxis,c=cc.TiledMap.StaggerIndex),this._disableDepthTestCmd=new cc.CustomRenderCmd(this,n)};var h=_ccsg.TMXLayer.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);h.constructor=_ccsg.TMXLayer.WebGLRenderCmd,h.uploadData=function(t,e,i){var n=this._node,h=n.layerOrientation,l=n.tiles,u=n._opacity/255;if(cc.renderer.setDepthTest(n.layerOrientation===r.ORTHO),!l||u<=0||!n.tileset)return 0;var _=n._mapTileSize.width,d=n._mapTileSize.height,f=n.tileset._tileSize.width/cc.director._contentScaleFactor,p=n.tileset._tileSize.height/cc.director._contentScaleFactor,m=f-_,g=p-d,y=cc.winSize.width,v=cc.winSize.height,x=n._layerSize.height,C=n._layerSize.width,T=n._texGrids,b=n._spriteTiles,A=this._worldTransform,S=A.a,w=A.b,E=A.c,I=A.d,R=A.tx,P=A.ty,O=n._position.x,B=n._position.y,D=O*S+B*E+R,M=O*w+B*I+P,L=f*S,N=p*I,F=n._opacity,k=this._displayedColor.r,z=this._displayedColor.g,V=this._displayedColor.b;if(n._opacityModifyRGB){var G=F/255;k*=G,z*=G,V*=G}this._color[0]=F<<24|V<<16|z<<8|k;var W=0,U=0,j=C,X=x,Y=S,H=I,q=D,J=M,Z=L,Q=N,K=cc.macro.ENABLE_TILEDMAP_CULLING;if(K){if(this._cameraFlag>0){var $=cc.affineTransformConcat(A,cc.Camera.main.viewMatrix);Y=$.a,H=$.d,q=O*Y+B*$.c+$.tx,J=O*$.b+B*H+$.ty,Z=f*Y,Q=p*H}h===r.ORTHO&&(W=Math.floor(-(q-m*Y)/(_*Y)),U=Math.floor((J-g*H+d*x*H-v)/(d*H)),j=Math.ceil((y-q+m*Y)/(_*Y)),X=x-Math.floor(-(J+g*H)/(d*H)),W<0&&(W=0),U<0&&(U=0),j>C&&(j=C),X>x&&(X=x))}var tt,et,it,nt,rt,st,ot,at,ct,ht,lt,ut,_t,dt,ft,pt,mt,gt,yt,vt=i,xt=U*C,Ct=S,Tt=w,bt=E,At=I,St=R,wt=P,Et=!1,It=!1,Rt=!1,Pt=this._vertices;if(h===r.HEX){var Ot=n._staggerIndex,Bt=n._hexSideLength;ft=n._staggerAxis,pt=n.tileset.tileOffset,yt=Ot===c.STAGGERINDEX_ODD?1:-1,mt=ft===a.STAGGERAXIS_X?(_-Bt)/2:0,gt=ft===a.STAGGERAXIS_Y?(d-Bt)/2:0}for(tt=U;tt<X;++tt){for(et=W;et<j;++et)if(vt+24>t.length&&(cc.renderer._increaseBatchingSize((vt-i)/6,cc.renderer.VertexType.QUAD),cc.renderer._batchRendering(),i=0,vt=0),it=xt+et,b[it])b[it]._vertexZ=n._vertexZ+cc.renderer.assignedZStep*it/l.length;else if(nt=n.tiles[it],rt=T[(nt&o)>>>0]){switch(h){case r.ORTHO:at=et*_,ct=(x-tt-1)*d,it=n._vertexZ+cc.renderer.assignedZStep*it/l.length;break;case r.ISO:at=_/2*(C+et-tt-1),ct=d/2*(2*x-et-tt-2),it=n._vertexZ+cc.renderer.assignedZStep*(n.height-ct)/n.height;break;case r.HEX:at=et*(_-mt)+(ft===a.STAGGERAXIS_Y&&tt%2==1?_/2*yt:0)+pt.x;ct=(x-tt-1)*(d-gt)+(ft===a.STAGGERAXIS_X&&et%2==1?d/2*-yt:0)-pt.y,it=n._vertexZ+cc.renderer.assignedZStep*(n.height-ct)/n.height}if(ht=at+f,ot=ct+p,K&&h===r.ISO){if((_t=J+ct*H)>v+Q){et+=Math.floor(2*(_t-v)/Q)-1;continue}if((dt=q+ht*Y)<-Z){et+=Math.floor(2*-dt/Z)-1;continue}if(ut=q+at*Y,lt=J+ot*H,ut>y||lt<0){et=j;continue}}for(nt>s.DIAGONAL&&(Et=!0,It=(nt&s.HORIZONTAL)>>>0,Rt=(nt&s.VERTICAL)>>>0),Pt[0].x=at*Ct+ot*bt+St,Pt[0].y=at*Tt+ot*At+wt,Pt[1].x=at*Ct+ct*bt+St,Pt[1].y=at*Tt+ct*At+wt,Pt[2].x=ht*Ct+ot*bt+St,Pt[2].y=ht*Tt+ot*At+wt,Pt[3].x=ht*Ct+ct*bt+St,Pt[3].y=ht*Tt+ct*At+wt,st=0;st<4;++st){switch(t[vt]=Pt[st].x,t[vt+1]=Pt[st].y,t[vt+2]=it,e[vt+3]=this._color[0],st){case 0:t[vt+4]=It?rt.r:rt.l,t[vt+5]=Rt?rt.b:rt.t;break;case 1:t[vt+4]=It?rt.r:rt.l,t[vt+5]=Rt?rt.t:rt.b;break;case 2:t[vt+4]=It?rt.l:rt.r,t[vt+5]=Rt?rt.b:rt.t;break;case 3:t[vt+4]=It?rt.l:rt.r,t[vt+5]=Rt?rt.t:rt.b}vt+=6}Et&&(Ct=S,Tt=w,bt=E,At=I,St=R,wt=P,It=!1,Rt=!1,Et=!1)}xt+=C}return(vt-i)/6}}),{}],284:[(function(t,e,i){function n(t){for(var e=[],i=t.getElementsByTagName("properties"),n=0;n<i.length;++n)for(var r=i[n].getElementsByTagName("property"),s=0;s<r.length;++s)e.push(r[s]);return e.length?e:null}t("../compression/ZipUtils");var r=t("../compression/zlib.min");cc.TMXLayerInfo=cc._Class.extend({ctor:function(){this.properties={},this.name="",this._layerSize=null,this._tiles=[],this.visible=!0,this._opacity=0,this.ownTiles=!0,this._minGID=1e5,this._maxGID=0,this.offset=cc.p(0,0)},getProperties:function(){return this.properties},setProperties:function(t){this.properties=t}}),cc.TMXObjectGroupInfo=cc._Class.extend({ctor:function(){this.properties={},this.name="",this._objects=[],this.visible=!0,this._opacity=0,this._color=new cc.Color(255,255,255,255),this.offset=cc.p(0,0),this._draworder="topdown"},getProperties:function(){return this.properties},setProperties:function(t){this.properties=t}}),cc.TMXTilesetInfo=cc._Class.extend({ctor:function(){this.name="",this.firstGid=0,this.spacing=0,this.margin=0,this.sourceImage="",this.imageSize=cc.size(0,0),this.tileOffset=cc.p(0,0),this._tileSize=cc.size(0,0)},rectForGID:function(t,e){var i=e||cc.rect(0,0,0,0);i.width=this._tileSize.width,i.height=this._tileSize.height,t&=cc.TiledMap.TileFlag.FLIPPED_MASK,t-=parseInt(this.firstGid,10);var n=parseInt((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing),10);return i.x=parseInt(t%n*(this._tileSize.width+this.spacing)+this.margin,10),i.y=parseInt(parseInt(t/n,10)*(this._tileSize.height+this.spacing)+this.margin,10),i}}),cc.TMXMapInfo=cc.SAXParser.extend({properties:null,orientation:null,parentElement:null,parentGID:null,layerAttrs:0,storingCharacters:!1,tmxFileName:null,currentString:null,_objectGroups:null,_allChildren:null,_mapSize:null,_tileSize:null,_layers:null,_tilesets:null,_tileProperties:null,_resources:"",_staggerAxis:null,_staggerIndex:null,_hexSideLength:0,ctor:function(t,e){cc.SAXParser.prototype.ctor.apply(this),this._mapSize=cc.size(0,0),this._tileSize=cc.size(0,0),this._layers=[],this._tilesets=[],this._objectGroups=[],this._allChildren=[],this.properties=[],this._tileProperties={},void 0!==e?this.initWithXML(t,e):void 0!==t&&this.initWithTMXFile(t)},getOrientation:function(){return this.orientation},setOrientation:function(t){this.orientation=t},getStaggerAxis:function(){return this._staggerAxis},setStaggerAxis:function(t){this._staggerAxis=t},getStaggerIndex:function(){return this._staggerIndex},setStaggerIndex:function(t){this._staggerIndex=t},getHexSideLength:function(){return this._hexSideLength},setHexSideLength:function(t){this._hexSideLength=t},getMapSize:function(){return cc.size(this._mapSize.width,this._mapSize.height)},setMapSize:function(t){this._mapSize.width=t.width,this._mapSize.height=t.height},_getMapWidth:function(){return this._mapSize.width},_setMapWidth:function(t){this._mapSize.width=t},_getMapHeight:function(){return this._mapSize.height},_setMapHeight:function(t){this._mapSize.height=t},getTileSize:function(){return cc.size(this._tileSize.width,this._tileSize.height)},setTileSize:function(t){this._tileSize.width=t.width,this._tileSize.height=t.height},_getTileWidth:function(){return this._tileSize.width},_setTileWidth:function(t){this._tileSize.width=t},_getTileHeight:function(){return this._tileSize.height},_setTileHeight:function(t){this._tileSize.height=t},getLayers:function(){return this._layers},setLayers:function(t){this._allChildren.push(t),this._layers.push(t)},getTilesets:function(){return this._tilesets},setTilesets:function(t){this._tilesets.push(t)},getObjectGroups:function(){return this._objectGroups},setObjectGroups:function(t){this._allChildren.push(t),this._objectGroups.push(t)},getAllChildren:function(){return this._allChildren},getParentElement:function(){return this.parentElement},setParentElement:function(t){this.parentElement=t},getParentGID:function(){return this.parentGID},setParentGID:function(t){this.parentGID=t},getLayerAttribs:function(){return this.layerAttrs},setLayerAttribs:function(t){this.layerAttrs=t},getStoringCharacters:function(){return this.storingCharacters},setStoringCharacters:function(t){this.storingCharacters=t},getProperties:function(){return this.properties},setProperties:function(t){this.properties=t},initWithTMXFile:function(t){return this._internalInit(t,null),this.parseXMLFile(t)},initWithXML:function(t,e){return this._internalInit(null,e),this.parseXMLString(t)},parseXMLFile:function(t,e,i){var r=(e=e||!1)?t:cc.loader.getRes(t);r||cc.errorID(7220,t);var s,o,a=this._parseXML(r).documentElement,c=a.getAttribute("version"),h=a.getAttribute("orientation"),l=a.getAttribute("staggeraxis"),u=a.getAttribute("staggerindex"),_=a.getAttribute("hexsidelength");if("map"===a.nodeName){"1.0"!==c&&null!==c&&cc.logID(7216,c),"orthogonal"===h?this.orientation=cc.TiledMap.Orientation.ORTHO:"isometric"===h?this.orientation=cc.TiledMap.Orientation.ISO:"hexagonal"===h?this.orientation=cc.TiledMap.Orientation.HEX:null!==h&&cc.logID(7217,h),"x"===l?this.setStaggerAxis(cc.TiledMap.StaggerAxis.STAGGERAXIS_X):"y"===l&&this.setStaggerAxis(cc.TiledMap.StaggerAxis.STAGGERAXIS_Y),"odd"===u?this.setStaggerIndex(cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD):"even"===u&&this.setStaggerIndex(cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN),_&&this.setHexSideLength(parseFloat(_));var d=cc.size(0,0);d.width=parseFloat(a.getAttribute("width")),d.height=parseFloat(a.getAttribute("height")),this.setMapSize(d),(d=cc.size(0,0)).width=parseFloat(a.getAttribute("tilewidth")),d.height=parseFloat(a.getAttribute("tileheight")),this.setTileSize(d);var f=n(a);if(f){var p={};for(s=0;s<f.length;s++)p[f[s].getAttribute("name")]=f[s].getAttribute("value");this.properties=p}}var m=a.getElementsByTagName("tileset");for("map"!==a.nodeName&&(m=[]).push(a),s=0;s<m.length;s++){var g=m[s],y=g.getAttribute("source");if(y){var v=parseInt(g.getAttribute("firstgid")),x=e?cc.path.join(this._resources,y):cc.path.changeBasename(t,y);this.parseXMLFile(x,!1,v)}else{var C=new cc.TMXTilesetInfo;C.name=g.getAttribute("name")||"",C.firstGid=i||(parseInt(g.getAttribute("firstgid"))||0),C.spacing=parseInt(g.getAttribute("spacing"))||0,C.margin=parseInt(g.getAttribute("margin"))||0;var T=cc.size(0,0);T.width=parseFloat(g.getAttribute("tilewidth")),T.height=parseFloat(g.getAttribute("tileheight")),C._tileSize=T;var b=g.getElementsByTagName("image")[0].getAttribute("source"),A=-1;if(this.tmxFileName&&(A=this.tmxFileName.lastIndexOf("/")),-1!==A){var S=this.tmxFileName.substr(0,A+1);C.sourceImage=S+b}else C.sourceImage=this._resources+(this._resources?"/":"")+b;this.setTilesets(C);var w=g.getElementsByTagName("tileoffset")[0];if(w){var E=parseFloat(w.getAttribute("x")),I=parseFloat(w.getAttribute("y"));C.tileOffset=cc.p(E,I)}var R=g.getElementsByTagName("tile");if(R)for(var P=0;P<R.length;P++){var O=R[P];this.parentGID=parseInt(C.firstGid)+parseInt(O.getAttribute("id")||0);var B=n(O);if(B){var D={};for(o=0;o<B.length;o++){D[B[o].getAttribute("name")]=B[o].getAttribute("value")}this._tileProperties[this.parentGID]=D}}}}var M=a.childNodes;for(s=0;s<M.length;s++){var L=M[s];if(!this._shouldIgnoreNode(L)){if("layer"===L.nodeName){var N=this._parseLayer(L);this.setLayers(N)}if("objectgroup"===L.nodeName){var F=this._parseObjectGroup(L);this.setObjectGroups(F)}}}return a},_shouldIgnoreNode:function(t){return 3===t.nodeType||8===t.nodeType||4===t.nodeType},_parseLayer:function(t){var e=t.getElementsByTagName("data")[0],i=new cc.TMXLayerInfo;i.name=t.getAttribute("name");var s=cc.size(0,0);s.width=parseFloat(t.getAttribute("width")),s.height=parseFloat(t.getAttribute("height")),i._layerSize=s;var o=t.getAttribute("visible");i.visible=!("0"==o);var a=t.getAttribute("opacity")||1;i._opacity=a?parseInt(255*parseFloat(a)):255,i.offset=cc.p(parseFloat(t.getAttribute("x"))||0,parseFloat(t.getAttribute("y"))||0);for(var c="",h=0;h<e.childNodes.length;h++)c+=e.childNodes[h].nodeValue;c=c.trim();var l=e.getAttribute("compression"),u=e.getAttribute("encoding");if(l&&"gzip"!==l&&"zlib"!==l)return cc.logID(7218),null;var _;switch(l){case"gzip":_=cc.Codec.unzipBase64AsArray(c,4);break;case"zlib":_=(function(t){if(t.length%4!=0)return null;for(var e=t.length/4,i=window.Uint32Array?new Uint32Array(e):[],n=0;n<e;n++){var r=4*n;i[n]=t[r]+256*t[r+1]+65536*t[r+2]+t[r+3]*(1<<24)}return i})(new r.Inflate(cc.Codec.Base64.decodeAsArray(c,1)).decompress());break;case null:case"":if("base64"===u)_=cc.Codec.Base64.decodeAsArray(c,4);else if("csv"===u){_=[];for(var d=c.split(","),f=0;f<d.length;f++)_.push(parseInt(d[f]))}else{var p=e.getElementsByTagName("tile");_=[];for(var m=0;m<p.length;m++)_.push(parseInt(p[m].getAttribute("gid")))}break;default:this.layerAttrs===cc.TMXLayerInfo.ATTRIB_NONE&&cc.logID(7219)}_&&(i._tiles=new Uint32Array(_));var g=n(t);if(g){for(var y={},v=0;v<g.length;v++)y[g[v].getAttribute("name")]=g[v].getAttribute("value");i.properties=y}return i},_parseObjectGroup:function(t){var e=new cc.TMXObjectGroupInfo;e.name=t.getAttribute("name")||"",e.offset=cc.p(parseFloat(t.getAttribute("offsetx")),parseFloat(t.getAttribute("offsety")));var i=t.getAttribute("opacity")||1;e._opacity=i?parseInt(255*parseFloat(i)):255;var r=t.getAttribute("visible");r&&0===parseInt(r)&&(e.visible=!1);var s=t.getAttribute("color");s&&(e._color=cc.hexToColor(s));var o=t.getAttribute("draworder");o&&(e._draworder=o);var a=n(t);if(a){for(var c={},h=0;h<a.length;h++)c[a[h].getAttribute("name")]=a[h].getAttribute("value");e.setProperties(c)}var l=t.getElementsByTagName("object"),u=cc.director.getContentScaleFactor();if(l)for(var _=0;_<l.length;_++){var d=l[_],f={};f.id=d.getAttribute("id")||0,f.name=d.getAttribute("name")||"",f.width=parseFloat(d.getAttribute("width"))||0,f.height=parseFloat(d.getAttribute("height"))||0,f.x=(d.getAttribute("x")||0)/u,f.y=(d.getAttribute("y")||0)/u,f.rotation=parseFloat(d.getAttribute("rotation"))||0;var p=n(d);if(p)for(var m=0;m<p.length;m++)f[p[m].getAttribute("name")]=p[m].getAttribute("value");var g=d.getAttribute("visible");f.visible=!(g&&0===parseInt(g));var y=d.getAttribute("gid");y&&(f.gid=parseInt(y),f.type=cc.TiledMap.TMXObjectType.IMAGE);var v=d.getElementsByTagName("ellipse");v&&v.length>0&&(f.type=cc.TiledMap.TMXObjectType.ELLIPSE);var x=d.getElementsByTagName("polygon");if(x&&x.length>0){f.type=cc.TiledMap.TMXObjectType.POLYGON;var C=x[0].getAttribute("points");C&&(f.points=this._parsePointsString(C))}var T=d.getElementsByTagName("polyline");if(T&&T.length>0){f.type=cc.TiledMap.TMXObjectType.POLYLINE;var b=T[0].getAttribute("points");b&&(f.polylinePoints=this._parsePointsString(b))}f.type||(f.type=cc.TiledMap.TMXObjectType.RECT),e._objects.push(f)}return e},_parsePointsString:function(t){if(!t)return null;for(var e=[],i=t.split(" "),n=0;n<i.length;n++){var r=i[n].split(",");e.push({x:parseFloat(r[0]),y:parseFloat(r[1])})}return e},parseXMLString:function(t){return this.parseXMLFile(t,!0)},getTileProperties:function(){return this._tileProperties},setTileProperties:function(t){this._tileProperties.push(t)},getCurrentString:function(){return this.currentString},setCurrentString:function(t){this.currentString=t},getTMXFileName:function(){return this.tmxFileName},setTMXFileName:function(t){this.tmxFileName=t},_internalInit:function(t,e){this._tilesets.length=0,this._layers.length=0,this.tmxFileName=t,e&&(this._resources=e),this._objectGroups.length=0,this._allChildren.length=0,this.properties.length=0,this._tileProperties.length=0,this.currentString="",this.storingCharacters=!1,this.layerAttrs=cc.TMXLayerInfo.ATTRIB_NONE,this.parentElement=cc.TiledMap.NONE}});var s=cc.TMXMapInfo.prototype;s.mapWidth,cc.defineGetterSetter(s,"mapWidth",s._getMapWidth,s._setMapWidth),s.mapHeight,cc.defineGetterSetter(s,"mapHeight",s._getMapHeight,s._setMapHeight),s.tileWidth,cc.defineGetterSetter(s,"tileWidth",s._getTileWidth,s._setTileWidth),s.tileHeight,cc.defineGetterSetter(s,"tileHeight",s._getTileHeight,s._setTileHeight),cc.TMXMapInfo.create=function(t,e){return new cc.TMXMapInfo(t,e)},cc.TMXLayerInfo.ATTRIB_NONE=1,cc.TMXLayerInfo.ATTRIB_BASE64=2,cc.TMXLayerInfo.ATTRIB_GZIP=4,cc.TMXLayerInfo.ATTRIB_ZLIB=8}),{"../compression/ZipUtils":28,"../compression/zlib.min":31}],285:[(function(t,e,i){t("./CCSGTMXLayer"),t("./CCTMXLayerCanvasRenderCmd"),t("./CCTMXLayerWebGLRenderCmd");var n=cc.Class({name:"cc.TiledLayer",extends:cc._SGComponent,onEnable:function(){this._sgNode&&this._sgNode.setVisible(!0)},onDisable:function(){this._sgNode&&this._sgNode.setVisible(!1)},onDestroy:function(){this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null)},_initSgNode:function(){var t=this._sgNode;if(t){this.enabledInHierarchy||t.setVisible(!1),this._registSizeProvider();var e=this.node;t.setAnchorPoint(e.getAnchorPoint())}},_replaceSgNode:function(t){t!==this._sgNode&&(this._removeSgNode(),this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),t&&t instanceof _ccsg.TMXLayer?(this._sgNode=t,this._initSgNode()):this._sgNode=null)},getLayerName:function(){return this._sgNode?this._sgNode.getLayerName():""},setLayerName:function(t){this._sgNode&&this._sgNode.setLayerName(t)},getProperty:function(t){return this._sgNode?this._sgNode.getProperty(t):null},getPositionAt:function(t,e){return this._sgNode?(void 0!==e&&(t=cc.p(t,e)),this._sgNode.getPositionAt(t)):null},removeTileAt:function(t,e){this._sgNode&&(void 0!==e&&(t=cc.p(t,e)),this._sgNode.removeTileAt(t))},setTileGID:function(t,e,i,n){if(this._sgNode){if(void 0===e)throw new Error("_ccsg.TMXLayer.setTileGID(): pos should be non-null");var r;void 0===n&&e instanceof cc.Vec2?(r=e,n=i):r=cc.p(e,i),this._sgNode.setTileGID(t,r,n)}},getTileGIDAt:function(t,e){return this._sgNode?(void 0!==e&&(t=cc.p(t,e)),this._sgNode.getTileGIDAt(t)):0},getTileAt:function(t,e){return this._sgNode?(void 0!==e&&(t=cc.p(t,e)),this._sgNode.getTileAt(t)):null},releaseMap:function(){this._sgNode&&this._sgNode.releaseMap()},setContentSize:function(t,e){this._sgNode&&(void 0!==e&&(t=cc.size(t,e)),this._sgNode.setContentSize(t))},getTexture:function(){return this._sgNode?this._sgNode.getTexture():null},setTexture:function(t){this._sgNode&&this._sgNode.setTexture(t)},setTileOpacity:function(t){this._sgNode&&(this._sgNode._opacity=t)},getLayerSize:function(){return this._sgNode?this._sgNode.getLayerSize():cc.size(0,0)},setLayerSize:function(t){this._sgNode&&this._sgNode.setLayerSize(t)},getMapTileSize:function(){return this._sgNode?this._sgNode.getMapTileSize():cc.size(0,0)},setMapTileSize:function(t){this._sgNode&&this._sgNode.setMapTileSize(t)},getTiles:function(){return this._sgNode?this._sgNode.getTiles():null},setTiles:function(t){this._sgNode&&this._sgNode.setTiles(t)},getTileSet:function(){return this._sgNode?this._sgNode.getTileSet():null},setTileSet:function(t){this._sgNode&&this._sgNode.setTileSet(t)},getLayerOrientation:function(){return this._sgNode?this._sgNode.getLayerOrientation():0},setLayerOrientation:function(t){this._sgNode&&this._sgNode.setLayerOrientation(t)},getProperties:function(){return this._sgNode?this._sgNode.getProperties():null},setProperties:function(t){this._sgNode&&this._sgNode.setProperties(t)},_tryRemoveNode:function(){this.node.removeComponent(cc.TiledLayer),1===this.node._components.length&&0===this.node.getChildren().length&&this.node.removeFromParent()}});cc.TiledLayer=e.exports=n}),{"./CCSGTMXLayer":278,"./CCTMXLayerCanvasRenderCmd":282,"./CCTMXLayerWebGLRenderCmd":283}],286:[(function(t,e,i){t("./CCTiledMapAsset"),t("./CCTiledLayer"),t("./CCTiledObjectGroup"),t("./CCSGTMXTiledMap");var n=cc.Enum({ORTHO:0,HEX:1,ISO:2}),r=cc.Enum({NONE:0,MAP:1,LAYER:2,OBJECTGROUP:3,OBJECT:4,TILE:5}),s=cc.Enum({HORIZONTAL:2147483648,VERTICAL:1073741824,DIAGONAL:536870912,FLIPPED_ALL:3758096384,FLIPPED_MASK:536870911}),o=cc.Enum({STAGGERAXIS_X:0,STAGGERAXIS_Y:1}),a=cc.Enum({STAGGERINDEX_ODD:0,STAGGERINDEX_EVEN:1}),c=cc.Enum({RECT:0,ELLIPSE:1,POLYGON:2,POLYLINE:3,IMAGE:4}),h=cc.Class({name:"cc.TiledMap",extends:cc._RendererInSG,editor:!1,statics:{Orientation:n,Property:r,TileFlag:s,StaggerAxis:o,StaggerIndex:a,TMXObjectType:c},properties:{_detachedChildren:{default:[],serializable:!1},_tmxFile:{default:null,type:cc.TiledMapAsset},tmxAsset:{get:function(){return this._tmxFile},set:function(t,e){this._tmxFile!==t&&(this._tmxFile=t,this._applyFile())},type:cc.TiledMapAsset}},getMapSize:function(){return this._sgNode.getMapSize()},setMapSize:function(t){this._sgNode.setMapSize(t)},getTileSize:function(){return this._sgNode.getTileSize()},setTileSize:function(t){this._sgNode.setTileSize(t)},getMapOrientation:function(){return this._sgNode.getMapOrientation()},setMapOrientation:function(t){this._sgNode.setMapOrientation(t)},getObjectGroups:function(){for(var t=this.node.children,e=[],i=0,n=t.length;i<n;i++){var r=t[i].getComponent(cc.TiledObjectGroup);r&&e.push(r)}return e},getProperties:function(){return this._sgNode.getProperties()},setProperties:function(t){this._sgNode.setProperties(t)},initWithTMXFile:function(t){cc.errorID(7200)},initWithXML:function(t,e){cc.errorID(7201)},allLayers:function(){for(var t=this.node.children,e=[],i=0,n=t.length;i<n;i++){var r=t[i].getComponent(cc.TiledLayer);r&&e.push(r)}return e},getLayer:function(t){for(var e=this.node.children,i=0,n=e.length;i<n;i++){var r=e[i].getComponent(cc.TiledLayer);if(r&&r.getLayerName()===t)return r}return null},getObjectGroup:function(t){for(var e=this.node.children,i=0,n=e.length;i<n;i++){var r=e[i].getComponent(cc.TiledObjectGroup);if(r&&r.getGroupName()===t)return r}return null},getProperty:function(t){return this._sgNode.getProperty(t)},getPropertiesForGID:function(t){return this._sgNode.getPropertiesForGID(t)},onEnable:function(){0===this._detachedChildren.length&&this._moveLayersInSgNode(this._sgNode),this._super(),this._tmxFile&&this._refreshLayerEntities(),this.node.on("anchor-changed",this._anchorChanged,this),this.node.on("child-added",this._childAdded,this),this.node.on("child-reorder",this._syncChildrenOrder,this)},onDisable:function(){this._super(),this._setLayersEnabled(!1);var t=this._plainNode;this._moveLayersInSgNode(t),this.node.off("anchor-changed",this._anchorChanged,this),this.node.off("child-added",this._childAdded,this),this.node.off("child-reorder",this._syncChildrenOrder,this)},onDestroy:function(){this._super(),this._removeLayerEntities()},_createSgNode:function(){return new _ccsg.TMXTiledMap},_initSgNode:function(){this._applyFile()},_resetSgSize:function(){this.node.setContentSize(this._sgNode.getContentSize()),this._sgNode.setContentSize(0,0)},_onMapLoaded:function(){this._refreshLayerEntities(),this._enabled?this._anchorChanged():this._moveLayersInSgNode(this._sgNode),this._setLayersEnabled(this._enabled),this._resetSgSize()},_setLayersEnabled:function(t){for(var e=this.node.getChildren(),i=e.length-1;i>=0;i--){var n=e[i].getComponent(cc.TiledLayer);n&&(n.enabled=t)}},_moveLayersInSgNode:function(t){this._detachedChildren.length=0;for(var e=t.getChildren(),i=e.length-1;i>=0;i--){var n=e[i];if(n instanceof _ccsg.TMXLayer||n instanceof _ccsg.TMXObjectGroup){t.removeChild(n);var r=n.getLocalZOrder();this._detachedChildren.push({sgNode:n,zorder:r})}}},_removeLayerEntities:function(){for(var t=this.node.getChildren(),e=t.length-1;e>=0;e--){var i=t[e];if(i.isValid){var n=i.getComponent(cc.TiledLayer);n&&n._tryRemoveNode();var r=i.getComponent(cc.TiledObjectGroup);r&&r._tryRemoveNode()}}},_refreshLayerEntities:function(){var t,e,i=this.node.getChildren(),n=[],r=[],s=[];for(t=0;t<this._detachedChildren.length;t++){var o=this._detachedChildren[t];this._sgNode.addChild(o.sgNode,o.zorder,o.zorder)}this._detachedChildren.length=0;var a=this._sgNode.allLayers().map((function(t){return t.getLayerName()})),c=this._sgNode.getObjectGroups().map((function(t){return t.getGroupName()}));for(t=i.length-1;t>=0;t--){var h=i[t],l=h.getComponent(cc.TiledLayer),u=h.getComponent(cc.TiledObjectGroup);if(l){var _=l.getLayerName();if(_||(_=h._name),a.indexOf(_)<0)l._tryRemoveNode();else{n.push(h);var d=this._sgNode.getLayer(_);l._replaceSgNode(d),l.enabled=!0}}else if(u){var f=u.getGroupName();if(f||(f=h._name),c.indexOf(f)<0)u._tryRemoveNode();else{r.push(h);var p=this._sgNode.getObjectGroup(f);u._replaceSgNode(p),u.enabled=p.isVisible()}}else s.push({child:h,index:h.getSiblingIndex()})}var m=n.map((function(t){return t.getComponent(cc.TiledLayer).getLayerName()}));for(t=0,e=a.length;t<e;t++){var g=a[t],y=this._sgNode.getLayer(g),v=m.indexOf(g);if(v<0){var x=this.node.getChildByName(g),C=null;x&&!x.getComponent(cc._SGComponent)?C=x.addComponent(cc.TiledLayer):(x=new cc.Node(g),this.node.addChild(x),C=x.addComponent(cc.TiledLayer)),x&&C||cc.errorID(7202),C._replaceSgNode(y),x.setSiblingIndex(y.getLocalZOrder()),x.setAnchorPoint(this.node.getAnchorPoint())}}var T=r.map((function(t){return t.getComponent(cc.TiledObjectGroup).getGroupName()}));for(t=0,e=c.length;t<e;t++){g=c[t];var b=this._sgNode.getObjectGroup(g);if((v=T.indexOf(g))<0){var A=null;(x=this.node.getChildByName(g))&&!x.getComponent(cc._SGComponent)?A=x.addComponent(cc.TiledObjectGroup):(x=new cc.Node(g),this.node.addChild(x),A=x.addComponent(cc.TiledObjectGroup)),x&&A||cc.errorID(7202),A._replaceSgNode(b),x.setSiblingIndex(b.getLocalZOrder()),x.setAnchorPoint(this.node.getAnchorPoint()),A.enabled=b.isVisible()}}var S=this.node.getChildren(),w=[];for(t=0,e=S.length;t<e;t++)l=(h=S[t]).getComponent(cc.TiledLayer),u=h.getComponent(cc.TiledObjectGroup),(l||u)&&w.push(h._name);var E=[],I=[],R=this._sgNode.getChildren();for(t=0,e=R.length;t<e;t++)(h=R[t])instanceof _ccsg.TMXLayer?(E.push(h.getLayerName()),I.push(h)):h instanceof _ccsg.TMXObjectGroup&&(E.push(h.getGroupName()),I.push(h));for(t=E.length-1;t>=0;t--){var P=E[t];if(t!==w.indexOf(P)){this.node.getChildByName(P).setSiblingIndex(I[t].getLocalZOrder())}}for(t=0,e=s.length;t<e;t++)(o=s[t]).child.setSiblingIndex(o.index);this._syncChildrenOrder()},_anchorChanged:function(){for(var t=this.node.children,e=this.node.getAnchorPoint(),i=0,n=t.length;i<n;i++){var r=t[i];r.getComponent(cc.TiledLayer)&&r.setAnchorPoint(e)}},_childAdded:function(t){var e=t.detail;if(e){var i=e.getComponent(cc.TiledLayer),n=e.getComponent(cc.TiledObjectGroup);if(!i&&!n){var r=this.node.getChildrenCount();e.setSiblingIndex(r),e._sgNode&&e._sgNode.setLocalZOrder(r)}}},_syncChildrenOrder:function(){for(var t=this.node.children,e=0,i=t.length;e<i;e++){var n=t[e],r=n.getComponent(cc.TiledLayer),s=n.getComponent(cc.TiledObjectGroup),o=n.getSiblingIndex();r&&r._sgNode&&r._sgNode.setLocalZOrder(o),s&&s._sgNode&&s._sgNode.setLocalZOrder(o),n._sgNode&&n._sgNode.setLocalZOrder(o)}},_applyFile:function(){var t=this._sgNode,e=this._tmxFile;if(e){var i=cc.url._rawAssets+e.tmxFolderPath;i=cc.path.stripSep(i);t.initWithXML(e.tmxXmlStr,i)&&(this._detachedChildren.length=0,this._onMapLoaded())}else{for(var n=t.allLayers(),r=0,s=n.length;r<s;r++)t.removeChild(n[r]);var o=t.getObjectGroups();for(r=0,s=o.length;r<s;r++)t.removeChild(o[r]);this._detachedChildren.length=0,this._removeLayerEntities()}}});cc.TiledMap=e.exports=h,cc.js.obsolete(cc.TiledMap.prototype,"cc.TiledMap.tmxFile","tmxAsset",!0),cc.js.get(cc.TiledMap.prototype,"mapLoaded",(function(){return cc.errorID(7203),[]}),!1)}),{"./CCSGTMXTiledMap":281,"./CCTiledLayer":285,"./CCTiledMapAsset":287,"./CCTiledObjectGroup":288}],287:[(function(t,e,i){var n=cc.Class({name:"cc.TiledMapAsset",extends:cc.Asset,properties:{tmxXmlStr:{default:""},tmxFolderPath:{default:""},textures:{default:[],url:[cc.Texture2D]},tsxFiles:{default:[],url:[cc.RawAsset]}},statics:{preventDeferredLoadDependents:!0},createNode:!1});cc.TiledMapAsset=n,e.exports=n}),{}],288:[(function(t,e,i){t("./CCSGTMXObjectGroup");var n=cc.Class({name:"cc.TiledObjectGroup",extends:cc._SGComponent,onEnable:function(){this._sgNode&&this._sgNode.setVisible(!0)},onDisable:function(){this._sgNode&&this._sgNode.setVisible(!1)},onDestroy:function(){this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null)},_initSgNode:function(){var t=this._sgNode;t&&(this._registSizeProvider(),t.setAnchorPoint(this.node.getAnchorPoint()))},_replaceSgNode:function(t){t!==this._sgNode&&(this._removeSgNode(),this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),t&&t instanceof _ccsg.TMXObjectGroup?(this._sgNode=t,this._initSgNode()):this._sgNode=null)},getPositionOffset:function(){return this._sgNode?this._sgNode.getPositionOffset():cc.p(0,0)},setPositionOffset:function(t){this._sgNode&&this._sgNode.setPositionOffset(t)},getProperties:function(){return this._sgNode?this._sgNode.getProperties():null},setProperties:function(t){this._sgNode&&this._sgNode.setProperties(t)},getGroupName:function(){return this._sgNode?this._sgNode.getGroupName():""},setGroupName:function(t){this._sgNode&&this._sgNode.setGroupName(t)},getProperty:function(t){return this._sgNode?this._sgNode.propertyNamed(t):null},getObject:function(t){return this._sgNode?this._sgNode.getObject(t):null},getObjects:function(){return this._sgNode?this._sgNode.getObjects():[]},_tryRemoveNode:function(){this.node.removeComponent(cc.TiledObjectGroup),1===this.node._components.length&&0===this.node.getChildren().length&&this.node.removeFromParent()}});cc.TiledObjectGroup=e.exports=n}),{"./CCSGTMXObjectGroup":280}],289:[(function(t,e,i){t("./cocos2d/core"),t("./cocos2d/animation"),t("./cocos2d/particle/CCParticleSystem"),t("./cocos2d/tilemap/CCTiledMap"),t("./cocos2d/motion-streak/CCMotionStreak"),t("./cocos2d/core/components/CCStudioComponent"),t("./extensions/ccpool/CCNodePool"),t("./extensions/ccpool/CCPool"),t("./cocos2d/actions"),t("./external/chipmunk/chipmunk"),t("./extensions/spine"),t("./extensions/dragonbones"),t("./cocos2d/deprecated")}),{"./cocos2d/actions":10,"./cocos2d/animation":18,"./cocos2d/core":124,"./cocos2d/core/components/CCStudioComponent":95,"./cocos2d/deprecated":242,"./cocos2d/motion-streak/CCMotionStreak":257,"./cocos2d/particle/CCParticleAsset":261,"./cocos2d/particle/CCParticleSystem":262,"./cocos2d/tilemap/CCTiledMap":286,"./cocos2d/tilemap/CCTiledMapAsset":287,"./extensions/ccpool/CCNodePool":290,"./extensions/ccpool/CCPool":291,"./extensions/dragonbones":299,"./extensions/spine":308,"./external/chipmunk/chipmunk":311}],290:[(function(t,e,i){cc.NodePool=function(t){this.poolHandlerComp=t,this._pool=[]},cc.NodePool.prototype={constructor:cc.NodePool,size:function(){return this._pool.length},clear:function(){for(var t=this._pool.length,e=0;e<t;++e)this._pool[e].destroy();this._pool.length=0},put:function(t){if(t&&-1===this._pool.indexOf(t)){t.removeFromParent(!1);var e=this.poolHandlerComp?t.getComponent(this.poolHandlerComp):null;e&&e.unuse&&e.unuse(),this._pool.push(t)}},get:function(){var t=this._pool.length-1;if(t<0)return null;var e=this._pool[t];this._pool.length=t;var i=this.poolHandlerComp?e.getComponent(this.poolHandlerComp):null;return i&&i.reuse&&i.reuse.apply(i,arguments),e}},e.exports=cc.NodePool}),{}],291:[(function(t,e,i){var n=[];cc.pool={_pool:{},_releaseCB:function(){this.release()},_autoRelease:function(t){var e=void 0!==t._running&&!t._running;cc.director.getScheduler().schedule(this._releaseCB,t,0,0,0,e)},putInPool:function(t){var e=cc.js._getClassId(t.constructor);e&&(this._pool[e]||(this._pool[e]=[]),t.unuse&&t.unuse(),this._pool[e].push(t))},hasObject:function(t){var e=cc.js._getClassId(t),i=this._pool[e];return!(!i||0===i.length)},removeObject:function(t){var e=cc.js._getClassId(t.constructor);if(e){var i=this._pool[e];if(i)for(var n=0;n<i.length;n++)t===i[n]&&i.splice(n,1)}},getFromPool:function(t){if(this.hasObject(t)){var e=cc.js._getClassId(t),i=this._pool[e];n.length=arguments.length-1;for(var r=0;r<n.length;r++)n[r]=arguments[r+1];var s=i.pop();return s.reuse&&s.reuse.apply(s,n),n.length=0,s}},drainAllPools:function(){this._pool={}}}}),{}],292:[(function(t,e,i){var n=cc.Enum({default:-1}),r=cc.Enum({"<None>":0});dragonBones.ArmatureDisplay=cc.Class({name:"dragonBones.ArmatureDisplay",extends:cc._RendererUnderSG,editor:!1,properties:{_factory:{default:null,type:dragonBones.CCFactory,serializable:!1},_dragonBonesData:{default:null,type:dragonBones.DragonBonesData,serializable:!1},dragonAsset:{default:null,type:dragonBones.DragonBonesAsset,notify:function(){this._parseDragonAsset(),this._refresh()},tooltip:!1},dragonAtlasAsset:{default:null,type:dragonBones.DragonBonesAtlasAsset,notify:function(){this._parseDragonAtlasAsset(),this._refreshSgNode()},tooltip:!1},_armatureName:"",armatureName:{get:function(){return this._armatureName},set:function(t){this._armatureName=t;var e=this.getAnimationNames(this._armatureName);(!this.animationName||e.indexOf(this.animationName)<0)&&(this.animationName=""),this._refresh()},visible:!1},_animationName:"",animationName:{get:function(){return this._animationName},set:function(t){this._animationName=t},visible:!1},_defaultArmatureIndex:{default:0,notify:function(){var t="";if(this.dragonAsset){var e;if(this.dragonAsset&&(e=this.dragonAsset.getArmatureEnum()),!e)return cc.errorID(7400,this.name);t=e[this._defaultArmatureIndex]}void 0!==t?this.armatureName=t:cc.errorID(7401,this.name)},type:n,visible:!0,editorOnly:!0,displayName:"Armature",tooltip:!1},_animationIndex:{default:0,notify:function(){if(0!==this._animationIndex){var t;if(this.dragonAsset&&(t=this.dragonAsset.getAnimsEnum(this.armatureName)),t){var e=t[this._animationIndex];void 0!==e?this.animationName=e:cc.errorID(7402,this.name)}}else this.animationName=""},type:r,visible:!0,editorOnly:!0,displayName:"Animation",tooltip:!1},timeScale:{default:1,notify:function(){this._sgNode&&(this._sgNode.animation().timeScale=this.timeScale)},tooltip:!1},playTimes:{default:-1,tooltip:!1},debugBones:{default:!1,notify:function(){this._sgNode&&this._sgNode.setDebugBones(this.debugBones)},editorOnly:!0,tooltip:!1}},ctor:function(){this._factory=dragonBones.CCFactory.getInstance()},__preload:function(){this._parseDragonAsset(),this._parseDragonAtlasAsset(),this._refresh()},_createSgNode:function(){return this.dragonAsset&&this.dragonAtlasAsset&&this.armatureName?this._factory.buildArmatureDisplay(this.armatureName,this._dragonBonesData.name):null},_initSgNode:function(){var t=this._sgNode;t.animation().timeScale=this.timeScale,this.animationName&&this.playAnimation(this.animationName,this.playTimes)},_removeSgNode:function(){var t=this._sgNode;this._super(),t&&t.armature().dispose()},_parseDragonAsset:function(){if(this.dragonAsset){var t=JSON.parse(this.dragonAsset.dragonBonesJson),e=this._factory.getDragonBonesData(t.name);if(e){for(var i,n,r=0,s=t.armature.length;r<s;r++)i=t.armature[r],e.armatures[i.name]||(n||(n=this._factory._dataParser.parseDragonBonesData(t)),e.addArmature(n.armatures[i.name]));return void(this._dragonBonesData=e)}this._dragonBonesData=this._factory.parseDragonBonesData(t)}},_parseDragonAtlasAsset:function(){if(this.dragonAtlasAsset){var t=JSON.parse(this.dragonAtlasAsset.atlasJson),e=t.name,i=null,n=this._factory.getTextureAtlasData(e),r=this.dragonAtlasAsset.texture;if(n&&n.length>0)for(var s in n){var o=n[s];if(o&&o.texture&&o.texture.url===r){i=o;break}}var a=cc.textureCache.getTextureForKey(r);i?i.texture=a:this._factory.parseTextureAtlasData(t,a)}},_refreshSgNode:function(){var t=null,e=null;this._sgNode&&(t=this._sgNode._bubblingListeners,e=this._sgNode._hasListenerCache,this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),this._removeSgNode(),this._sgNode=null);var i=this._sgNode=this._createSgNode();i&&(this.enabledInHierarchy||i.setVisible(!1),t&&(i._bubblingListeners=t,i._hasListenerCache=e),this._initSgNode(),this._appendSgNode(i),this._registSizeProvider())},_refresh:function(){this._refreshSgNode()},_updateAnimEnum:!1,_updateArmatureEnum:!1,playAnimation:function(t,e){return this._sgNode?(this.playTimes=void 0===e?-1:e,this.animationName=t,this._sgNode.animation().play(t,this.playTimes)):null},getArmatureNames:function(){return this._dragonBonesData?this._dragonBonesData.armatureNames:[]},getAnimationNames:function(t){var e=[];if(this._dragonBonesData){var i=this._dragonBonesData.getArmature(t);if(i)for(var n in i.animations)i.animations.hasOwnProperty(n)&&e.push(n)}return e},addEventListener:function(t,e,i){this._sgNode&&this._sgNode.addEvent(t,e,i)},removeEventListener:function(t,e,i){this._sgNode&&this._sgNode.removeEvent(t,e,i)},buildArmature:function(t){return this._factory?this._factory.buildArmature(t):null},armature:function(){return this._sgNode?this._sgNode.armature():null}})}),{}],293:[(function(t,e,i){var n=t("../../cocos2d/core/event/event-target");t("../../cocos2d/shape-nodes/CCDrawNode"),dragonBones.CCArmatureDisplay=cc.Class({name:"dragonBones.CCArmatureDisplay",extends:_ccsg.Node,mixins:[n],_armature:null,_debugDrawer:null,_onClear:function(){this._armature=null},_dispatchEvent:function(t){this.emit(t.type,t)},_debugDraw:function(){if(this._armature){this._debugDrawer||(this._debugDrawer=new cc.DrawNode,this.addChild(this._debugDrawer),this._debugDrawer.setDrawColor(cc.color(255,0,0,255)),this._debugDrawer.setLineWidth(1)),this._debugDrawer.clear();for(var t=this._armature.getBones(),e=0,i=t.length;e<i;++e){var n=t[e],r=Math.max(n.length,5),s=n.globalTransformMatrix.tx,o=-n.globalTransformMatrix.ty,a=s+n.globalTransformMatrix.a*r,c=o-n.globalTransformMatrix.b*r;this._debugDrawer.drawSegment(cc.p(s,o),cc.p(a,c))}}},update:function(t){this._armature&&this._armature.advanceTime(t)},advanceTimeBySelf:function(t){t?this.scheduleUpdate():this.unscheduleUpdate()},hasEvent:function(t){return this.hasEventListener(t,!1)},addEvent:function(t,e,i){this.on(t,e,i)},removeEvent:function(t,e,i){this.off(t,e,i)},dispose:function(){this._armature&&(this.advanceTimeBySelf(!1),this._armature.dispose(),this._armature=null)},armature:function(){return this._armature},animation:function(){return this._armature.animation},setDebugBones:function(t){dragonBones.DragonBones.debugDraw=t,t?this.armature().advanceTime(0):this._debugDrawer&&this._debugDrawer.clear()}})}),{"../../cocos2d/core/event/event-target":112,"../../cocos2d/shape-nodes/CCDrawNode":275}],294:[(function(t,e,i){var n=dragonBones.BaseObject;dragonBones.CCFactory=cc.Class({name:"dragonBones.CCFactory",extends:dragonBones.BaseFactory,buildArmatureDisplay:function(t,e,i){var n=this.buildArmature(t,e,i),r=n?n._display:null;return r&&r.advanceTimeBySelf(!0),r},_generateTextureAtlasData:function(t,e){return t||(t=n.borrowObject(dragonBones.CCTextureAtlasData)),t.texture=e,t},_generateArmature:function(t){var e=n.borrowObject(dragonBones.Armature),i=new dragonBones.CCArmatureDisplay;return e._armatureData=t.armature,e._skinData=t.skin,e._animation=n.borrowObject(dragonBones.Animation),e._display=i,i.setCascadeOpacityEnabled(!0),i.setCascadeColorEnabled(!0),i._armature=e,e._animation._armature=e,e.animation.animations=t.armature.animations,e},_generateSlot:function(t,e){var i=n.borrowObject(dragonBones.CCSlot),r=e.slot,s=[];i.name=r.name,i._rawDisplay=new cc.Scale9Sprite,i._rawDisplay.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE),i._rawDisplay.setAnchorPoint(cc.p(0,0)),i._meshDisplay=i._rawDisplay;for(var o=0,a=e.displays.length;o<a;++o){var c=e.displays[o];switch(c.type){case dragonBones.DisplayType.Image:c.texture||(c.texture=this._getTextureData(t.dataName,c.name)),s.push(i._rawDisplay);break;case dragonBones.DisplayType.Mesh:c.texture||(c.texture=this._getTextureData(t.dataName,c.name)),cc._renderType===cc.game.RENDER_TYPE_WEBGL?(i._meshDisplay.setRenderingType(cc.Scale9Sprite.RenderingType.MESH),s.push(i._meshDisplay)):cc.warnID(6200);break;case dragonBones.DisplayType.Armature:var h=this.buildArmature(c.name,t.dataName);if(h){if(!i.inheritAnimation){var l=r.actions.length>0?r.actions:h.armatureData.actions;if(l.length>0)for(var u=0,_=l.length;u<_;++u)h._bufferAction(l[u]);else h.animation.play()}c.armature=h.armatureData}s.push(h);break;default:s.push(null)}}return i._setDisplayList(s),i._rawDisplay.setLocalZOrder(r.zOrder),i},getTextureDisplay:function(t,e){var i=this._getTextureData(e,t);if(i){if(!i.texture){var n=i.parent.texture,r=cc.rect(i.region.x,i.region.y,i.region.width,i.region.height),s=cc.p(0,0),o=cc.size(i.region.width,i.region.height);i.texture=new cc.SpriteFrame,i.texture.setTexture(n,r,i.rotated,s,o)}var a=new cc.Scale9Sprite;return a.initWithSpriteFrame(i.texture),a}return null}}),dragonBones.CCFactory._factory=null,dragonBones.CCFactory.getInstance=function(){return dragonBones.CCFactory._factory||(dragonBones.CCFactory._factory=new dragonBones.CCFactory),dragonBones.CCFactory._factory}}),{}],295:[(function(t,e,i){dragonBones.CCSlot=cc.Class({name:"dragonBones.CCSlot",extends:dragonBones.Slot,_renderDisplay:null,statics:{toString:function(){return"[class dragonBones.CCSlot]"}},_onClear:function(){dragonBones.Slot.prototype._onClear.call(this),this._renderDisplay=null},_onUpdateDisplay:function(){this._rawDisplay||(this._rawDisplay=new cc.Scale9Sprite),this._renderDisplay=this._display||this._rawDisplay},_initDisplay:function(t){},_addDisplay:function(){this._armature._display.addChild(this._renderDisplay)},_replaceDisplay:function(t){var e=this._armature._display,i=t;e.addChild(this._renderDisplay,i.getLocalZOrder()),e.removeChild(i)},_removeDisplay:function(){this._renderDisplay.removeFromParent()},_disposeDisplay:function(t){},_updateVisible:function(){this._renderDisplay.setVisible(this._parent.visible)},_updateZOrder:function(){if(this._renderDisplay._parent)this._renderDisplay.setLocalZOrder(this._zOrder);else{this._armature._display.addChild(this._renderDisplay,this._zOrder)}},_updateBlendMode:function(){if(this._renderDisplay instanceof cc.Scale9Sprite)switch(this._blendMode){case 0:break;case 1:var t=this._renderDisplay._spriteFrame.getTexture();t&&t.hasPremultipliedAlpha()?this._renderDisplay.setBlendFunc(cc.BlendFunc.BlendFactor.ONE,cc.BlendFunc.BlendFactor.ONE):this._renderDisplay.setBlendFunc(cc.BlendFunc.BlendFactor.SRC_ALPHA,cc.BlendFunc.BlendFactor.ONE)}else if(this._childArmature)for(var e=this._childArmature.getSlots(),i=0,n=e.length;i<n;i++){var r=e[i];r._blendMode=this._blendMode,r._updateBlendMode()}},_updateColor:function(){this._renderDisplay.setOpacity(255*this._colorTransform.alphaMultiplier);var t=255*this._colorTransform.redMultiplier,e=255*this._colorTransform.greenMultiplier,i=255*this._colorTransform.blueMultiplier;this._renderDisplay.setColor(cc.color(t,e,i))},_updateFilters:function(){},_updateFrame:function(){if(this._display&&this._displayIndex>=0){var t=this._displayIndex<this._displayDataSet.displays.length?this._displayDataSet.displays[this._displayIndex]:null,e=(this._displayIndex<this._replacedDisplayDataSet.length?this._replacedDisplayDataSet[this._displayIndex]:null)||t,i=e.texture;if(i){var n=i.parent.texture;if(n&&(!i.texture||i.texture.getTexture()!==n)){var r=cc.rect(i.region.x,i.region.y,i.region.width,i.region.height),s=cc.p(0,0),o=cc.size(i.region.width,i.region.height);i.texture=new cc.SpriteFrame,i.texture.setTexture(n,r,!1,s,o)}var a=this._armature._replacedTexture||(i.texture?i.texture.getTexture():null);if(this._meshData&&this._display===this._meshDisplay){var c=i.region,h=i.texture.getTexture().getContentSize(),l=[],u=[],_=cc.rect(999999,999999,-999999,-999999);this._meshData!==t.mesh&&t&&t!==e?(this._pivotX=t.transform.x-e.transform.x,this._pivotY=t.transform.y-e.transform.y):(this._pivotX=0,this._pivotY=0);var d,f;for(d=0,f=this._meshData.uvs.length;d<f;d+=2){var p=this._meshData.vertices[d],m=this._meshData.vertices[d+1],g=(c.x+this._meshData.uvs[d]*c.width)/h.width,y=(c.y+this._meshData.uvs[d+1]*c.height)/h.height;l.push({x:p,y:-m,u:g,v:y}),_.x>p&&(_.x=p),_.width<p&&(_.width=p),_.y>-m&&(_.y=-m),_.height<-m&&(_.height=-m)}for(_.width-=_.x,_.height-=_.y,d=0,f=this._meshData.vertexIndices.length;d<f;++d)u.push(this._meshData.vertexIndices[d]);var v={triangles:{verts:l,indices:u},rect:_};this._meshDisplay.setSpriteFrame(i.texture),a!=i.texture.getTexture()&&this._meshDisplay.setTexture(a),this._meshDisplay.setMeshPolygonInfo(v),this._meshDisplay.setContentSize(cc.size(_.width,_.height)),this._meshData.skinned&&(this._meshDisplay.setScale(1,1),this._meshDisplay.setRotationX(0),this._meshDisplay.setRotationY(0),this._meshDisplay.setPosition(0,0)),this._meshDisplay.setAnchorPoint(cc.p(0,0))}else{var x=this._armature.armatureData.scale;if(this._pivotX=e.pivot.x,this._pivotY=e.pivot.y,e.isRelativePivot){var C=i.frame||i.region,T=C.width*x,b=C.height*x;!i.frame&&i.rotated&&(T=C.height,b=C.width),this._pivotX*=T,this._pivotY*=b}i.frame&&(this._pivotX+=i.frame.x*x,this._pivotY+=i.frame.y*x),t&&t!==e&&(this._pivotX+=t.transform.x-e.transform.x,this._pivotY+=t.transform.y-e.transform.y),this._pivotY-=i.region.height*x,this._rawDisplay.setSpriteFrame(i.texture),this._rawDisplay.setContentSize(i.texture.getOriginalSize()),a!==i.texture.getTexture()&&this._rawDisplay.setTexture(a),this._blendModeDirty=!0}return void this._updateVisible()}}this._pivotX=0,this._pivotY=0,this._rawDisplay.setTexture(null),this._rawDisplay.setVisible(!1),this._rawDisplay.setPosition(this.origin.x,this.origin.y)},_updateMesh:function(){var t=this._meshDisplay,e=t.getMeshPolygonInfo();if(t&&e){var i,n,r=this._ffdVertices.length>0,s=e.triangles.verts,o=cc.rect(999999,999999,-999999,-999999),a=0,c=0,h=0;if(this._meshData.skinned){var l=0;for(i=0,n=this._meshData.vertices.length;i<n;i+=2){a=Math.floor(i/2);var u=this._meshData.boneIndices[a],_=this._meshData.boneVertices[a],d=this._meshData.weights[a];c=0,h=0;for(var f=0,p=u.length;f<p;++f){var m=this._meshBones[u[f]].globalTransformMatrix,g=d[f],y=0,v=0;r?(y=_[2*f]+this._ffdVertices[l],v=_[2*f+1]+this._ffdVertices[l+1]):(y=_[2*f],v=_[2*f+1]),c+=(m.a*y+m.c*v+m.tx)*g,h+=(m.b*y+m.d*v+m.ty)*g,l+=2}s[a].x=c,s[a].y=-h,o.x>c&&(o.x=c),o.width<c&&(o.width=c),o.y>-h&&(o.y=-h),o.height<-h&&(o.height=-h)}}else if(r){var x=this._meshData.vertices;for(i=0,n=this._meshData.vertices.length;i<n;i+=2)a=Math.floor(i/2),c=x[i]+this._ffdVertices[i],h=x[i+1]+this._ffdVertices[i+1],s[a].x=c,s[a].y=-h,o.x>c&&(o.x=c),o.width<c&&(o.width=c),o.y>-h&&(o.y=-h),o.height<-h&&(o.height=-h)}o.width-=o.x,o.height-=o.y,e.rect=o;var C=t.getNodeToParentTransform();t.setContentSize(cc.size(o.width,o.height)),t.setMeshPolygonInfo(e),this._renderDisplay._renderCmd.setNodeToParentTransform(C)}},_updateTransform:function(){var t={a:this.globalTransformMatrix.a,b:-this.globalTransformMatrix.b,c:-this.globalTransformMatrix.c,d:this.globalTransformMatrix.d,tx:this.globalTransformMatrix.tx-(this.globalTransformMatrix.a*this._pivotX+this.globalTransformMatrix.c*this._pivotY),ty:-(this.globalTransformMatrix.ty-(this.globalTransformMatrix.b*this._pivotX+this.globalTransformMatrix.d*this._pivotY))};this._renderDisplay._renderCmd.setNodeToParentTransform(t)}})}),{}],296:[(function(t,e,i){dragonBones.CCTextureAtlasData=cc.Class({name:"dragonBones.CCTextureAtlasData",extends:dragonBones.TextureAtlasData,texture:null,statics:{toString:function(){return"[class dragonBones.CCTextureAtlasData]"}},_onClear:function(){dragonBones.TextureAtlasData.prototype._onClear.call(this),this.texture=null},generateTextureData:function(){return dragonBones.BaseObject.borrowObject(dragonBones.CCTextureData)}}),dragonBones.CCTextureData=cc.Class({name:"dragonBones.CCTextureData",extends:dragonBones.TextureData,texture:null,statics:{toString:function(){return"[class dragonBones.CCTextureData]"}},_onClear:function(){dragonBones.TextureData.prototype._onClear.call(this),this.texture&&(this.texture.dispose(),this.texture=null)}})}),{}],297:[(function(t,e,i){var n=cc.Class({name:"dragonBones.DragonBonesAsset",extends:cc.Asset,properties:{_dragonBonesJson:"",dragonBonesJson:{get:function(){return this._dragonBonesJson},set:function(t){this._dragonBonesJson=t,this.reset()}}},statics:{preventDeferredLoadDependents:!0},createNode:!1,reset:function(){0},getRuntimeData:!1,getArmatureEnum:!1,getAnimsEnum:!1});dragonBones.DragonBonesAsset=e.exports=n}),{}],298:[(function(t,e,i){var n=cc.Class({name:"dragonBones.DragonBonesAtlasAsset",extends:cc.Asset,properties:{_atlasJson:"",atlasJson:{get:function(){return this._atlasJson},set:function(t){this._atlasJson=t}},texture:{default:"",url:cc.Texture2D}},statics:{preventDeferredLoadDependents:!0},createNode:!1});dragonBones.DragonBonesAtlasAsset=e.exports=n}),{}],299:[(function(t,e,i){dragonBones=t("./lib/dragonBones"),dragonBones.DisplayType={Image:0,Armature:1,Mesh:2},dragonBones.ArmatureType={Armature:0,MovieClip:1,Stage:2},dragonBones.ExtensionType={FFD:0,AdjustColor:10,BevelFilter:11,BlurFilter:12,DropShadowFilter:13,GlowFilter:14,GradientBevelFilter:15,GradientGlowFilter:16},dragonBones.EventType={Frame:0,Sound:1},dragonBones.ActionType={Play:0,Stop:1,GotoAndPlay:2,GotoAndStop:3,FadeIn:4,FadeOut:5},dragonBones.AnimationFadeOutMode={None:0,SameLayer:1,SameGroup:2,SameLayerAndGroup:3,All:4},t("./CCFactory"),t("./CCSlot"),t("./CCTextureData"),t("./CCArmatureDisplay"),t("./DragonBonesAsset"),t("./DragonBonesAtlasAsset"),t("./ArmatureDisplay")}),{"./ArmatureDisplay":292,"./CCArmatureDisplay":293,"./CCFactory":294,"./CCSlot":295,"./CCTextureData":296,"./DragonBonesAsset":297,"./DragonBonesAtlasAsset":298,"./lib/dragonBones":300}],300:[(function(t,e,i){var n=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)};(function(t){var e=(function(){function t(){}return t.hasArmature=function(e){return t._armatures.indexOf(e)>=0},t.addArmature=function(e){e&&t._armatures.indexOf(e)<0&&t._armatures.push(e)},t.removeArmature=function(e){if(e){var i=t._armatures.indexOf(e);i>=0&&t._armatures.splice(i,1)}},t.PI_D=2*Math.PI,t.PI_H=Math.PI/2,t.PI_Q=Math.PI/4,t.ANGLE_TO_RADIAN=Math.PI/180,t.RADIAN_TO_ANGLE=180/Math.PI,t.SECOND_TO_MILLISECOND=1e3,t.NO_TWEEN=100,t.VERSION="4.7.2",t.debug=!1,t.debugDraw=!1,t._armatures=[],t})();t.DragonBones=e})(r||(r={}));(function(t){var e=(function(){function t(){this.hashCode=t._hashCode++}return t._returnObject=function(e){var i=String(e.constructor),n=null==t._maxCountMap[i]?t._defaultMaxCount:t._maxCountMap[i],r=t._poolsMap[i]=t._poolsMap[i]||[];if(r.length<n){if(!(r.indexOf(e)<0))throw new Error;r.push(e)}},t.setMaxCount=function(e,i){if((i<0||i!=i)&&(i=0),e){var n=String(e);t._maxCountMap[n]=i;(r=t._poolsMap[n])&&r.length>i&&(r.length=i)}else{t._defaultMaxCount=i;for(var n in t._poolsMap)if(null!=t._maxCountMap[n]){t._maxCountMap[n]=i;var r;(r=t._poolsMap[n]).length>i&&(r.length=i)}}},t.clearPool=function(e){if(void 0===e&&(e=null),e){(n=t._poolsMap[String(e)])&&n.length&&(n.length=0)}else for(var i in t._poolsMap){var n;(n=t._poolsMap[i]).length=0}},t.borrowObject=function(e){var i=t._poolsMap[String(e)];if(i&&i.length)return i.pop();var n=new e;return n._onClear(),n},t.prototype.returnToPool=function(){this._onClear(),t._returnObject(this)},t._hashCode=0,t._defaultMaxCount=5e3,t._maxCountMap={},t._poolsMap={},t})();t.BaseObject=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=1),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),this.alphaMultiplier=t,this.redMultiplier=e,this.greenMultiplier=i,this.blueMultiplier=n,this.alphaOffset=r,this.redOffset=s,this.greenOffset=o,this.blueOffset=a}return t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.redOffset=t.redOffset,this.greenOffset=t.blueOffset},t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0},t})();t.ColorTransform=e})(r||(r={}));(function(t){var e=(function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t.prototype.clear=function(){this.x=this.y=0},t})();t.Point=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n,r,s){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}return t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty},t.prototype.copyFrom=function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty},t.prototype.identity=function(){this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0},t.prototype.concat=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=this.tx,o=this.ty,a=t.a,c=t.b,h=t.c,l=t.d,u=t.tx,_=t.ty;this.a=e*a+i*h,this.b=e*c+i*l,this.c=n*a+r*h,this.d=n*c+r*l,this.tx=a*s+h*o+u,this.ty=l*o+c*s+_},t.prototype.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=this.ty,o=t*n-e*i;this.a=n/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*s-n*r)/o,this.ty=-(t*s-e*r)/o},t.prototype.transformPoint=function(t,e,i,n){void 0===n&&(n=!1),i.x=this.a*t+this.c*e,i.y=this.b*t+this.d*e,n||(i.x+=this.tx,i.y+=this.ty)},t})();t.Matrix=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},t.prototype.clear=function(){this.x=this.y=0,this.width=this.height=0},t})();t.Rectangle=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=1),this.x=t,this.y=e,this.skewX=i,this.skewY=n,this.scaleX=r,this.scaleY=s}return t.normalizeRadian=function(t){return t=(t+Math.PI)%(2*Math.PI),t+=t>0?-Math.PI:Math.PI},t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skewX/Math.PI+" skewY:"+180*this.skewY/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.skewX=t.skewX,this.skewY=t.skewY,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this},t.prototype.identity=function(){return this.x=this.y=this.skewX=this.skewY=0,this.scaleX=this.scaleY=1,this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.skewX+=t.skewX,this.skewY+=t.skewY,this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this},t.prototype.minus=function(e){return this.x-=e.x,this.y-=e.y,this.skewX=t.normalizeRadian(this.skewX-e.skewX),this.skewY=t.normalizeRadian(this.skewY-e.skewY),this.scaleX/=e.scaleX,this.scaleY/=e.scaleY,this},t.prototype.fromMatrix=function(t){var e=.25*Math.PI,i=this.scaleX,n=this.scaleY;return this.x=t.tx,this.y=t.ty,this.skewX=Math.atan(-t.c/t.d),this.skewY=Math.atan(t.b/t.a),this.skewX!=this.skewX&&(this.skewX=0),this.skewY!=this.skewY&&(this.skewY=0),this.scaleY=this.skewX>-e&&this.skewX<e?t.d/Math.cos(this.skewX):-t.c/Math.sin(this.skewX),this.scaleX=this.skewY>-e&&this.skewY<e?t.a/Math.cos(this.skewY):t.b/Math.sin(this.skewY),i>=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.skewY=this.skewY-Math.PI),n>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,this.skewX=this.skewX-Math.PI),this},t.prototype.toMatrix=function(t){return t.a=this.scaleX*Math.cos(this.skewY),t.b=this.scaleX*Math.sin(this.skewY),t.c=-this.scaleY*Math.sin(this.skewX),t.d=this.scaleY*Math.cos(this.skewX),t.tx=this.x,t.ty=this.y,this},Object.defineProperty(t.prototype,"rotation",{get:function(){return this.skewY},set:function(t){var e=t-this.skewY;this.skewX+=e,this.skewY+=e},enumerable:!0,configurable:!0}),t})();t.Transform=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this)}return n(e,t),e.prototype._onClear=function(){this._isCompleted=!1,this._currentPlayTimes=0,this._currentTime=-1,this._timeline=null,this._isReverse=!1,this._hasAsynchronyTimeline=!1,this._frameRate=0,this._keyFrameCount=0,this._frameCount=0,this._position=0,this._duration=0,this._animationDutation=0,this._timeScale=1,this._timeOffset=0,this._currentFrame=null,this._armature=null,this._animationState=null},e.prototype._onUpdateFrame=function(t){},e.prototype._onArriveAtFrame=function(t){},e.prototype._setCurrentTime=function(t){var e=0;if(1==this._keyFrameCount&&this!=this._animationState._timeline)this._isCompleted=this._animationState._fadeState>=0,e=1;else if(this._hasAsynchronyTimeline){var i=this._animationState.playTimes,n=i*this._duration;t*=this._timeScale,0!=this._timeOffset&&(t+=this._timeOffset*this._animationDutation),i>0&&(t>=n||t<=-n)?(this._isCompleted=!0,e=i,t=t<0?0:this._duration):(this._isCompleted=!1,t<0?(e=Math.floor(-t/this._duration),t=this._duration- -t%this._duration):(e=Math.floor(t/this._duration),t%=this._duration),i>0&&e>i&&(e=i)),t+=this._position}else this._isCompleted=this._animationState._timeline._isCompleted,e=this._animationState._timeline._currentPlayTimes;return this._currentTime!=t&&(this._isReverse=this._currentTime>t&&this._currentPlayTimes==e,this._currentTime=t,this._currentPlayTimes=e,this._animationState._onFadeInComplete&&(this._currentFrame=null),!0)},e.prototype.fadeIn=function(t,e,i,n){this._armature=t,this._animationState=e,this._timeline=i;var r=this==this._animationState._timeline;this._hasAsynchronyTimeline=r||this._animationState.animationData.hasAsynchronyTimeline,this._frameRate=this._armature.armatureData.frameRate,this._keyFrameCount=this._timeline.frames.length,this._frameCount=this._animationState.animationData.frameCount,this._position=this._animationState._position,this._duration=this._animationState._duration,this._animationDutation=this._animationState.animationData.duration,this._timeScale=r?1:1/this._timeline.scale,this._timeOffset=r?0:this._timeline.offset},e.prototype.fadeOut=function(){},e.prototype.update=function(t){if(!this._isCompleted&&this._setCurrentTime(t)){var e=this._keyFrameCount>1?Math.floor(this._currentTime*this._frameRate):0,i=this._timeline.frames[e];this._currentFrame!=i&&(this._currentFrame=i,this._onArriveAtFrame(!0)),this._onUpdateFrame(!0)}},e})(t.BaseObject);t.TimelineState=e;var i=(function(e){function i(){e.call(this)}return n(i,e),i._getEasingValue=function(t,e){if(t<=0)return 0;if(t>=1)return 1;var i=1;if(e>2)return t;if(e>1)i=.5*(1-Math.cos(t*Math.PI)),e-=1;else if(e>0)i=1-Math.pow(1-t,2);else if(e>=-1)e*=-1,i=Math.pow(t,2);else{if(!(e>=-2))return t;e*=-1,i=Math.acos(1-2*t)/Math.PI,e-=1}return(i-t)*e+t},i._getEasingCurveValue=function(t,e){if(t<=0)return 0;if(t>=1)return 1;var i=e.length+1,n=Math.floor(t*i),r=0==n?0:e[n-1];return r+((n==i-1?1:e[n])-r)*(t-n/i)},i.prototype._onClear=function(){e.prototype._onClear.call(this),this._tweenProgress=0,this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null},i.prototype._onArriveAtFrame=function(e){this._tweenEasing=this._currentFrame.tweenEasing,this._curve=this._currentFrame.curve,(this._keyFrameCount<=1||this._currentFrame.next==this._timeline.frames[0]&&(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)&&this._animationState.playTimes>0&&this._animationState.currentPlayTimes==this._animationState.playTimes-1)&&(this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null)},i.prototype._onUpdateFrame=function(e){this._tweenEasing!=t.DragonBones.NO_TWEEN?(this._tweenProgress=(this._currentTime-this._currentFrame.position+this._position)/this._currentFrame.duration,0!=this._tweenEasing&&(this._tweenProgress=i._getEasingValue(this._tweenProgress,this._tweenEasing))):this._curve?(this._tweenProgress=(this._currentTime-this._currentFrame.position+this._position)/this._currentFrame.duration,this._tweenProgress=i._getEasingCurveValue(this._tweenProgress,this._curve)):this._tweenProgress=0},i.prototype._updateExtensionKeyFrame=function(t,e,i){var n=0;if(t.type==e.type)for(var r=0,s=t.tweens.length;r<s;++r){var o=e.tweens[r]-t.tweens[r];i.tweens[r]=o,o>0&&(n=2)}if(0==n){i.type!=t.type&&(n=1,i.type=t.type),i.tweens.length!=t.tweens.length&&(n=1,i.tweens.length=t.tweens.length),i.keys.length!=t.keys.length&&(n=1,i.keys.length=t.keys.length);for(r=0,s=t.keys.length;r<s;++r){var a=t.keys[r];i.keys[r]!=a&&(n=1,i.keys[r]=a)}}return n},i})(e);t.TweenTimelineState=i})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this._animations={},this._animationNames=[],this._animationStates=[]}return n(i,e),i._sortAnimationState=function(t,e){return t.layer>e.layer?-1:1},i.toString=function(){return"[class dragonBones.Animation]"},i.prototype._onClear=function(){for(var t in this._animations)delete this._animations[t];t=0;for(var e=this._animationStates.length;t<e;++t)this._animationStates[t].returnToPool();this.timeScale=1,this._animationStateDirty=!1,this._armature=null,this._isPlaying=!1,this._time=0,this._duration=0,this._lastAnimationState=null,this._animationNames.length=0,this._animationStates.length=0},i.prototype._fadeOut=function(t,e,i,n,r){var s=0,o=this._animationStates.length,a=null;switch(n){case 1:for(;s<o;++s)(a=this._animationStates[s]).layer==e&&a.fadeOut(t,r);break;case 2:for(;s<o;++s)(a=this._animationStates[s]).group==i&&a.fadeOut(t,r);break;case 4:for(;s<o;++s)a=this._animationStates[s],0==t?a.returnToPool():a.fadeOut(t,r);0==t&&(this._animationStates.length=0);break;case 3:for(;s<o;++s)(a=this._animationStates[s]).layer==e&&a.group==i&&a.fadeOut(t,r)}},i.prototype._updateFFDTimelineStates=function(){for(var t=0,e=this._animationStates.length;t<e;++t)this._animationStates[t]._updateFFDTimelineStates()},i.prototype._advanceTime=function(t){if(this._isPlaying){t<0&&(t=-t);var e=this._animationStates.length;if(1==e){(c=this._animationStates[0])._fadeState>0&&c._fadeProgress<=0?(c.returnToPool(),this._animationStates.length=0,this._animationStateDirty=!0,this._lastAnimationState=null):c._advanceTime(t,1,0)}else if(e>1)for(var i=this._animationStates[0]._layer,n=1,r=0,s=1,o=0,a=0;o<e;++o){var c;(c=this._animationStates[o])._fadeState>0&&c._fadeProgress<=0?(a++,c.returnToPool(),this._animationStateDirty=!0,this._lastAnimationState==c&&(this._lastAnimationState=o-a>=0?this._animationStates[o-a]:null)):(a>0&&(this._animationStates[o-a]=c),i!=c._layer&&(i=c._layer,r>=n?n=0:n-=r,r=0),c._advanceTime(t,n,s),c._weightResult>0&&(r+=c._weightResult,s++)),o==e-1&&a>0&&(this._animationStates.length-=a)}}},i.prototype.reset=function(){for(var t=0,e=this._animationStates.length;t<e;++t)this._animationStates[t].returnToPool();this._isPlaying=!1,this._lastAnimationState=null,this._animationStates.length=0},i.prototype.stop=function(t){if(void 0===t&&(t=null),t){var e=this.getState(t);e&&e.stop()}else this._isPlaying=!1},i.prototype.play=function(t,e){void 0===t&&(t=null),void 0===e&&(e=-1);var i=null;if(t)i=this.fadeIn(t,0,e,0,null,4);else if(this._lastAnimationState)this._isPlaying&&(this._lastAnimationState.isPlaying||this._lastAnimationState.isCompleted)?i=this.fadeIn(this._lastAnimationState.name,0,e,0,null,4):(this._isPlaying=!0,this._lastAnimationState.play());else{var n=this._armature.armatureData.defaultAnimation;n&&(i=this.fadeIn(n.name,0,e,0,null,4))}return i},i.prototype.fadeIn=function(e,n,r,s,o,a,c,h,l,u){void 0===n&&(n=-1),void 0===r&&(r=-1),void 0===s&&(s=0),void 0===o&&(o=null),void 0===a&&(a=3),void 0===c&&(c=!1),void 0===h&&(h=!0),void 0===l&&(l=!0),void 0===u&&(u=!0);var _=this._animations[e];if(!_)return this._time=0,this._duration=0,console.warn("Non-existent animation.","DragonBones: "+this._armature.armatureData.parent.name,"Armature: "+this._armature.name,"Animation: "+e),null;this._isPlaying=!0,this._time!=this._time&&(this._time=0),this._duration!=this._duration&&(this._duration=0),(n!=n||n<0)&&(n=this._lastAnimationState?_.fadeInTime:0),r<0&&(r=_.playTimes),this._fadeOut(n,s,o,a,l);var d=this._duration>0?0:this._time,f=this._duration>0?this._time:_.position,p=this._duration>0?this._duration:_.duration;this._lastAnimationState=t.BaseObject.borrowObject(t.AnimationState),this._lastAnimationState._layer=s,this._lastAnimationState._group=o,this._lastAnimationState.additiveBlending=c,this._lastAnimationState.displayControl=h,this._lastAnimationState._fadeIn(this._armature,_.animation||_,e,r,f,p,d,1/_.scale,n,u),this._animationStates.push(this._lastAnimationState),this._animationStateDirty=!0,this._time=0,this._duration=0,this._armature._cacheFrameIndex=-1,this._animationStates.length>1&&this._animationStates.sort(i._sortAnimationState);for(var m=this._armature.getSlots(),g=0,y=m.length;g<y;++g){var v=m[g];if(v.inheritAnimation){var x=v.childArmature;x&&x.animation.hasAnimation(e)&&!x.animation.getState(e)&&x.animation.fadeIn(e)}}return n<=0&&this._armature.advanceTime(0),this._lastAnimationState},i.prototype.gotoAndPlayByTime=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=-1),void 0===n&&(n=0);var r=this._animations[t];return r&&(this._time=e,this._duration=n-e,this._duration<0?this._duration=0:this._duration>r.duration-this._time&&(this._duration=r.duration-this._time)),this.fadeIn(t,0,i,0,null,4)},i.prototype.gotoAndPlayByFrame=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=-1),void 0===n&&(n=0);var r=this._animations[t];return r&&(this._time=r.duration*e/r.frameCount,this._duration<0?this._duration=0:this._duration>r.duration-this._time&&(this._duration=r.duration-this._time)),this.fadeIn(t,0,i,0,null,4)},i.prototype.gotoAndPlayByProgress=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=-1),void 0===n&&(n=0);var r=this._animations[t];return r&&(this._time=r.duration*(e>0?e:0),this._duration<0?this._duration=0:this._duration>r.duration-this._time&&(this._duration=r.duration-this._time)),this.fadeIn(t,0,i,0,null,4)},i.prototype.gotoAndStopByTime=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByTime(t,e,1);return i&&i.stop(),i},i.prototype.gotoAndStopByFrame=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByFrame(t,e,1);return i&&i.stop(),i},i.prototype.gotoAndStopByProgress=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByProgress(t,e,1);return i&&i.stop(),i},i.prototype.getState=function(t){for(var e=0,i=this._animationStates.length;e<i;++e){var n=this._animationStates[e];if(n.name==t)return n}return null},i.prototype.hasAnimation=function(t){return null!=this._animations[t]},Object.defineProperty(i.prototype,"isPlaying",{get:function(){return this._animationStates.length>1?this._isPlaying&&!this.isCompleted:this._lastAnimationState?this._isPlaying&&this._lastAnimationState.isPlaying:this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isCompleted",{get:function(){if(this._lastAnimationState){if(!this._lastAnimationState.isCompleted)return!1;for(var t=0,e=this._animationStates.length;t<e;++t)if(!this._animationStates[t].isCompleted)return!1;return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState?this._lastAnimationState.name:null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations!=t){for(var e in this._animations)delete this._animations[e];if(this._animationNames.length=0,t)for(var e in t)this._animations[e]=t[e],this._animationNames.push(e)}},enumerable:!0,configurable:!0}),i.prototype.gotoAndPlay=function(t,e,i,n,r,s,o,a,c){void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===n&&(n=-1),void 0===r&&(r=0),void 0===s&&(s=null),void 0===o&&(o=3),void 0===a&&(a=!0),void 0===c&&(c=!0);var h=this.fadeIn(t,e,n,r,s,o,!1,!0,a,c);return h&&i&&i>0&&(h.timeScale=h.totalTime/i),h},i.prototype.gotoAndStop=function(t,e){return void 0===e&&(e=0),this.gotoAndStopByTime(t,e)},Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationDataList",{get:function(){for(var t=[],e=0,i=this._animationNames.length;e<i;++e)t.push(this._animations[this._animationNames[e]]);return t},enumerable:!0,configurable:!0}),i})(t.BaseObject);t.Animation=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this._boneMask=[],this._boneTimelines=[],this._slotTimelines=[],this._ffdTimelines=[],this.autoTween=!1}return n(i,e),i.toString=function(){return"[class dragonBones.AnimationState]"},i.prototype._onClear=function(){for(var t=0,e=this._boneTimelines.length;t<e;++t)this._boneTimelines[t].returnToPool();for(t=0,e=this._slotTimelines.length;t<e;++t)this._slotTimelines[t].returnToPool();for(t=0,e=this._ffdTimelines.length;t<e;++t)this._ffdTimelines[t].returnToPool();this._timeline&&this._timeline.returnToPool(),this._zOrderTimeline&&this._zOrderTimeline.returnToPool(),this.displayControl=!0,this.additiveBlending=!1,this.actionEnabled=!1,this.playTimes=1,this.timeScale=1,this.weight=1,this.autoFadeOutTime=-1,this.fadeTotalTime=0,this._onFadeInComplete=!1,this._fadeState=0,this._layer=0,this._position=0,this._duration=0,this._weightResult=0,this._fadeProgress=0,this._group=null,this._timeline=null,this._isPlaying=!0,this._isPausePlayhead=!1,this._fadeTime=0,this._time=0,this._name=null,this._armature=null,this._animationData=null,this._zOrderTimeline=null,this._boneMask.length=0,this._boneTimelines.length=0,this._slotTimelines.length=0,this._ffdTimelines.length=0},i.prototype._updateTimelineStates=function(){var e=this._time;this._animationData.hasAsynchronyTimeline||(e=this._timeline._currentTime);for(var i={},n={},r=0,s=this._boneTimelines.length;r<s;++r){i[(l=this._boneTimelines[r]).bone.name]=l}var o=this._armature.getBones();for(r=0,s=o.length;r<s;++r){var a=o[r],c=a.name,h=this._animationData.getBoneTimeline(c);if(h&&this.containsBoneMask(c)){(l=i[c])?delete i[c]:((l=t.BaseObject.borrowObject(t.BoneTimelineState)).bone=a,l.fadeIn(this._armature,this,h,e),this._boneTimelines.push(l))}}for(var r in i){var l;(l=i[r]).bone.invalidUpdate(),this._boneTimelines.splice(this._boneTimelines.indexOf(l),1),l.returnToPool()}for(r=0,s=this._slotTimelines.length;r<s;++r){n[(m=this._slotTimelines[r]).slot.name]=m}var u=this._armature.getSlots();for(r=0,s=u.length;r<s;++r){var _=u[r],d=_.name,f=_.parent.name,p=this._animationData.getSlotTimeline(d);if(p&&this.containsBoneMask(f)&&this._fadeState<=0){(m=n[d])?delete n[d]:((m=t.BaseObject.borrowObject(t.SlotTimelineState)).slot=_,m.fadeIn(this._armature,this,p,e),this._slotTimelines.push(m))}}for(var r in n){var m=n[r];this._slotTimelines.splice(this._slotTimelines.indexOf(m),1),m.returnToPool()}this._updateFFDTimelineStates()},i.prototype._advanceFadeTime=function(e){e<0&&(e=-e),this._fadeTime+=e;var i=0;if(i=this._fadeTime>=this.fadeTotalTime?this._fadeState>0?0:1:this._fadeTime>0?this._fadeState>0?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeState>0?1:0,this._fadeProgress!=i){this._fadeProgress=i;var n=this._armature._display;if(this._fadeTime<=e)if(this._fadeState>0){if(n.hasEvent(t.EventObject.FADE_OUT)){var r=t.BaseObject.borrowObject(t.EventObject);r.animationState=this,this._armature._bufferEvent(r,t.EventObject.FADE_OUT)}}else if(n.hasEvent(t.EventObject.FADE_IN)){var s=t.BaseObject.borrowObject(t.EventObject);s.animationState=this,this._armature._bufferEvent(s,t.EventObject.FADE_IN)}if(this._fadeTime>=this.fadeTotalTime)if(this._fadeState>0){if(n.hasEvent(t.EventObject.FADE_OUT_COMPLETE)){var o=t.BaseObject.borrowObject(t.EventObject);o.animationState=this,this._armature._bufferEvent(o,t.EventObject.FADE_OUT_COMPLETE)}}else if(this._onFadeInComplete=!0,this._isPausePlayhead=!1,this._fadeState=0,n.hasEvent(t.EventObject.FADE_IN_COMPLETE)){var a=t.BaseObject.borrowObject(t.EventObject);a.animationState=this,this._armature._bufferEvent(a,t.EventObject.FADE_IN_COMPLETE)}}},i.prototype._isDisabled=function(t){return!(this.displayControl&&(!t.displayController||t.displayController==this._name||t.displayController==this._group))},i.prototype._fadeIn=function(e,n,r,s,o,a,c,h,l,u){this._armature=e,this._animationData=n,this._name=r,this.actionEnabled=i.stateActionEnabled,this.playTimes=s,this.timeScale=h,this.fadeTotalTime=l,this._fadeState=-1,this._position=o,this._duration=a,this._time=c,this._isPausePlayhead=u,this.fadeTotalTime<=0&&(this._fadeProgress=.999999),this._timeline=t.BaseObject.borrowObject(t.AnimationTimelineState),this._timeline.fadeIn(this._armature,this,this._animationData,this._time),this._animationData.zOrderTimeline&&(this._zOrderTimeline=t.BaseObject.borrowObject(t.ZOrderTimelineState),this._zOrderTimeline.fadeIn(this._armature,this,this._animationData.zOrderTimeline,this._time)),this._updateTimelineStates()},i.prototype._updateFFDTimelineStates=function(){var e=this._time;this._animationData.hasAsynchronyTimeline||(e=this._timeline._currentTime);for(var i={},n=0,r=this._ffdTimelines.length;n<r;++n){i[(d=this._ffdTimelines[n]).slot.name]=d}var s=this._armature.getSlots();for(n=0,r=s.length;n<r;++n){var o=s[n],a=o.name,c=o.parent.name,h=o.displayData;if(h&&(o._meshData&&o._meshData==h.mesh)){var l=this._animationData.getFFDTimeline(this._armature._skinData.name,a,h.share&&h.inheritAnimation?h.share.name:h.name);if(l&&this.containsBoneMask(c)){(d=i[a])&&d._timeline==l?delete i[a]:((d=t.BaseObject.borrowObject(t.FFDTimelineState)).slot=o,d.fadeIn(this._armature,this,l,e),this._ffdTimelines.push(d))}else{for(var u=0,_=o._ffdVertices.length;u<_;++u)o._ffdVertices[u]=0;o._ffdDirty=!0}}}for(var n in i){var d=i[n];this._ffdTimelines.splice(this._ffdTimelines.indexOf(d),1),d.returnToPool()}},i.prototype._advanceTime=function(t,e,i){if(this._onFadeInComplete=!1,0!=this._fadeState&&this._advanceFadeTime(t),0!=(t*=this.timeScale)&&this._isPlaying&&!this._isPausePlayhead&&(this._time+=t),this._weightResult=this.weight*this._fadeProgress*e,0!=this._weightResult){var n=this._animationData.cacheFrameRate,r=this._fadeProgress>=1&&0==i&&n>0,s=!0,o=!0,a=2*n;if(a=r?Math.floor(this._time*a)/a:this._time,this._timeline.update(a),this._animationData.hasAsynchronyTimeline||(a=this._timeline._currentTime),this._zOrderTimeline&&this._zOrderTimeline.update(a),r){var c=Math.floor(this._timeline._currentTime*n);if(this._armature._cacheFrameIndex==c)s=!1,o=!1;else{if(this._armature._cacheFrameIndex=c,this._armature._animation._animationStateDirty){this._armature._animation._animationStateDirty=!1;for(var h=0,l=this._boneTimelines.length;h<l;++h){var u=this._boneTimelines[h];u.bone._cacheFrames=u._timeline.cachedFrames}for(h=0,l=this._slotTimelines.length;h<l;++h){var _=this._slotTimelines[h];_.slot._cacheFrames=_._timeline.cachedFrames}}this._animationData.cachedFrames[c]?o=!1:this._animationData.cachedFrames[c]=!0}}else this._armature._cacheFrameIndex=-1;if(s){if(o)for(h=0,l=this._boneTimelines.length;h<l;++h)this._boneTimelines[h].update(a);for(h=0,l=this._slotTimelines.length;h<l;++h)this._slotTimelines[h].update(a);for(h=0,l=this._ffdTimelines.length;h<l;++h)this._ffdTimelines[h].update(a)}}this.autoFadeOutTime>=0&&this._fadeProgress>=1&&this._timeline._isCompleted&&this.fadeOut(this.autoFadeOutTime)},i.prototype.play=function(){this._isPlaying=!0},i.prototype.stop=function(){this._isPlaying=!1},i.prototype.fadeOut=function(t,e){if(void 0===e&&(e=!0),(t<0||t!=t)&&(t=0),this._isPausePlayhead=e,this._fadeState>0){if(t>t-this._fadeTime)return}else{this._fadeState=1,(t<=0||this._fadeProgress<=0)&&(this._fadeProgress=1e-6);for(var i=0,n=this._boneTimelines.length;i<n;++i)this._boneTimelines[i].fadeOut();for(i=0,n=this._slotTimelines.length;i<n;++i)this._slotTimelines[i].fadeOut()}this.displayControl=!1,this.fadeTotalTime=this._fadeProgress>1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)},i.prototype.containsBoneMask=function(t){return!this._boneMask.length||this._boneMask.indexOf(t)>=0},i.prototype.addBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._armature.getBone(t);if(i){if(this._boneMask.indexOf(t)<0&&this._animationData.getBoneTimeline(t)&&this._boneMask.push(t),e)for(var n=this._armature.getBones(),r=0,s=n.length;r<s;++r){var o=n[r],a=o.name;this._boneMask.indexOf(a)<0&&this._animationData.getBoneTimeline(a)&&i.contains(o)&&this._boneMask.push(a)}this._updateTimelineStates()}},i.prototype.removeBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._boneMask.indexOf(t);if(i>=0&&this._boneMask.splice(i,1),e){var n=this._armature.getBone(t);if(n)for(var r=this._armature.getBones(),s=0,o=r.length;s<o;++s){var a=r[s],c=a.name,h=this._boneMask.indexOf(c);h>=0&&n.contains(a)&&this._boneMask.splice(h,1)}}this._updateTimelineStates()},i.prototype.removeAllBoneMask=function(){this._boneMask.length=0,this._updateTimelineStates()},Object.defineProperty(i.prototype,"layer",{get:function(){return this._layer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"group",{get:function(){return this._group},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationData",{get:function(){return this._animationData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isCompleted",{get:function(){return this._timeline._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPlaying",{get:function(){return this._isPlaying&&!this._timeline._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentPlayTimes",{get:function(){return this._timeline._currentPlayTimes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"totalTime",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentTime",{get:function(){return this._timeline._currentTime},set:function(t){(t<0||t!=t)&&(t=0);var e=this._timeline._currentPlayTimes-(this._timeline._isCompleted?1:0);if(t=t%this._duration+e*this._duration,this._time!=t){this._time=t,this._timeline.setCurrentTime(this._time),this._zOrderTimeline&&(this._zOrderTimeline._isCompleted=!1);for(var i=0,n=this._boneTimelines.length;i<n;++i)this._boneTimelines[i]._isCompleted=!1;for(i=0,n=this._slotTimelines.length;i<n;++i)this._slotTimelines[i]._isCompleted=!1;for(i=0,n=this._ffdTimelines.length;i<n;++i)this._ffdTimelines[i]._isCompleted=!1}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"clip",{get:function(){return this._animationData},enumerable:!0,configurable:!0}),i.stateActionEnabled=!0,i})(t.BaseObject);t.AnimationState=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this)}return n(i,e),i.toString=function(){return"[class dragonBones.AnimationTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this._isStarted=!1},i.prototype._onCrossFrame=function(e){if(!(this._animationState._fadeState<0)){if(this._animationState.actionEnabled)for(var i=e.actions,n=0,r=i.length;n<r;++n)this._armature._bufferAction(i[n]);var s=this._armature._display,o=e.events;for(n=0,r=o.length;n<r;++n){var a=o[n],c="";switch(a.type){case 10:c=t.EventObject.FRAME_EVENT;break;case 11:c=t.EventObject.SOUND_EVENT}if((11==a.type?this._armature._eventManager:s).hasEvent(c)){var h=t.BaseObject.borrowObject(t.EventObject);h.name=a.name,h.animationState=this._animationState,h.frame=e,h.data=a,a.bone&&(h.bone=this._armature.getBone(a.bone.name)),a.slot&&(h.slot=this._armature.getSlot(a.slot.name)),this._armature._bufferEvent(h,c)}}}},i.prototype.fadeIn=function(t,i,n,r){e.prototype.fadeIn.call(this,t,i,n,r),this._currentTime=r},i.prototype.update=function(e){var i=this._currentTime,n=this._currentPlayTimes;if(!this._isCompleted&&this._setCurrentTime(e)){var r=this._armature._display;if(!this._isStarted&&(this._isStarted=!0,r.hasEvent(t.EventObject.START))){(h=t.BaseObject.borrowObject(t.EventObject)).animationState=this._animationState,this._armature._bufferEvent(h,t.EventObject.START)}if(this._keyFrameCount>0){var s=this._keyFrameCount>1?Math.floor(this._currentTime*this._frameRate):0,o=this._timeline.frames[s];if(this._currentFrame!=o)if(this._keyFrameCount>1){var a=this._currentFrame;if(this._currentFrame=o,!a){var c=Math.floor(i*this._frameRate);a=this._timeline.frames[c],this._isReverse||(i<=a.position||n!=this._currentPlayTimes)&&(a=a.prev)}if(this._isReverse)for(;a!=o;)this._onCrossFrame(a),a=a.prev;else for(;a!=o;)a=a.next,this._onCrossFrame(a)}else this._currentFrame=o,this._onCrossFrame(this._currentFrame)}if(n!=this._currentPlayTimes){if(r.hasEvent(t.EventObject.LOOP_COMPLETE)){(h=t.BaseObject.borrowObject(t.EventObject)).animationState=this._animationState,this._armature._bufferEvent(h,t.EventObject.LOOP_COMPLETE)}if(this._isCompleted&&r.hasEvent(t.EventObject.COMPLETE)){var h;(h=t.BaseObject.borrowObject(t.EventObject)).animationState=this._animationState,this._armature._bufferEvent(h,t.EventObject.COMPLETE)}this._currentFrame=null}}},i.prototype.setCurrentTime=function(t){this._setCurrentTime(t),this._currentFrame=null},i})(t.TimelineState);t.AnimationTimelineState=e;var i=(function(t){function e(){t.call(this)}return n(e,t),e.toString=function(){return"[class dragonBones.ZOrderTimelineState]"},e.prototype._onArriveAtFrame=function(e){t.prototype._onArriveAtFrame.call(this,e),this._armature._sortZOrder(this._currentFrame.zOrder)},e})(t.TimelineState);t.ZOrderTimelineState=i;var r=(function(e){function i(){e.call(this),this._transform=new t.Transform,this._currentTransform=new t.Transform,this._durationTransform=new t.Transform}return n(i,e),i.toString=function(){return"[class dragonBones.BoneTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.bone=null,this._tweenTransform=0,this._tweenRotate=0,this._tweenScale=0,this._boneTransform=null,this._originalTransform=null,this._transform.identity(),this._currentTransform.identity(),this._durationTransform.identity()},i.prototype._onArriveAtFrame=function(i){if(e.prototype._onArriveAtFrame.call(this,i),this._currentTransform.copyFrom(this._currentFrame.transform),this._tweenTransform=1,this._tweenRotate=1,this._tweenScale=1,this._keyFrameCount>1&&(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)){var n=this._currentFrame.next.transform;this._durationTransform.x=n.x-this._currentTransform.x,this._durationTransform.y=n.y-this._currentTransform.y,0==this._durationTransform.x&&0==this._durationTransform.y||(this._tweenTransform=2);var r=this._currentFrame.tweenRotate;if(r==r){if(r)if(r>0?n.skewY>=this._currentTransform.skewY:n.skewY<=this._currentTransform.skewY){var s=r>0?r-1:r+1;this._durationTransform.skewX=n.skewX-this._currentTransform.skewX+t.DragonBones.PI_D*s,this._durationTransform.skewY=n.skewY-this._currentTransform.skewY+t.DragonBones.PI_D*s}else this._durationTransform.skewX=n.skewX-this._currentTransform.skewX+t.DragonBones.PI_D*r,this._durationTransform.skewY=n.skewY-this._currentTransform.skewY+t.DragonBones.PI_D*r;else this._durationTransform.skewX=t.Transform.normalizeRadian(n.skewX-this._currentTransform.skewX),this._durationTransform.skewY=t.Transform.normalizeRadian(n.skewY-this._currentTransform.skewY);0==this._durationTransform.skewX&&0==this._durationTransform.skewY||(this._tweenRotate=2)}else this._durationTransform.skewX=0,this._durationTransform.skewY=0;this._currentFrame.tweenScale?(this._durationTransform.scaleX=n.scaleX-this._currentTransform.scaleX,this._durationTransform.scaleY=n.scaleY-this._currentTransform.scaleY,0==this._durationTransform.scaleX&&0==this._durationTransform.scaleY||(this._tweenScale=2)):(this._durationTransform.scaleX=0,this._durationTransform.scaleY=0)}else this._durationTransform.x=0,this._durationTransform.y=0,this._durationTransform.skewX=0,this._durationTransform.skewY=0,this._durationTransform.scaleX=0,this._durationTransform.scaleY=0},i.prototype._onUpdateFrame=function(t){if(this._tweenTransform||this._tweenRotate||this._tweenScale){e.prototype._onUpdateFrame.call(this,t);var i=0;this._tweenTransform&&(1==this._tweenTransform?(this._tweenTransform=0,i=0):i=this._tweenProgress,this._animationState.additiveBlending?(this._transform.x=this._currentTransform.x+this._durationTransform.x*i,this._transform.y=this._currentTransform.y+this._durationTransform.y*i):(this._transform.x=this._originalTransform.x+this._currentTransform.x+this._durationTransform.x*i,this._transform.y=this._originalTransform.y+this._currentTransform.y+this._durationTransform.y*i)),this._tweenRotate&&(1==this._tweenRotate?(this._tweenRotate=0,i=0):i=this._tweenProgress,this._animationState.additiveBlending?(this._transform.skewX=this._currentTransform.skewX+this._durationTransform.skewX*i,this._transform.skewY=this._currentTransform.skewY+this._durationTransform.skewY*i):(this._transform.skewX=this._originalTransform.skewX+this._currentTransform.skewX+this._durationTransform.skewX*i,this._transform.skewY=this._originalTransform.skewY+this._currentTransform.skewY+this._durationTransform.skewY*i)),this._tweenScale&&(1==this._tweenScale?(this._tweenScale=0,i=0):i=this._tweenProgress,this._animationState.additiveBlending?(this._transform.scaleX=this._currentTransform.scaleX+this._durationTransform.scaleX*i,this._transform.scaleY=this._currentTransform.scaleY+this._durationTransform.scaleY*i):(this._transform.scaleX=this._originalTransform.scaleX*(this._currentTransform.scaleX+this._durationTransform.scaleX*i),this._transform.scaleY=this._originalTransform.scaleY*(this._currentTransform.scaleY+this._durationTransform.scaleY*i))),this.bone.invalidUpdate()}},i.prototype.fadeIn=function(t,i,n,r){e.prototype.fadeIn.call(this,t,i,n,r),this._originalTransform=this._timeline.originalTransform,this._boneTransform=this.bone._animationPose},i.prototype.fadeOut=function(){this._transform.skewX=t.Transform.normalizeRadian(this._transform.skewX),this._transform.skewY=t.Transform.normalizeRadian(this._transform.skewY)},i.prototype.update=function(t){e.prototype.update.call(this,t);var i=this._animationState._weightResult;i>0&&(0==this.bone._blendIndex?(this._boneTransform.x=this._transform.x*i,this._boneTransform.y=this._transform.y*i,this._boneTransform.skewX=this._transform.skewX*i,this._boneTransform.skewY=this._transform.skewY*i,this._boneTransform.scaleX=(this._transform.scaleX-1)*i+1,this._boneTransform.scaleY=(this._transform.scaleY-1)*i+1):(this._boneTransform.x+=this._transform.x*i,this._boneTransform.y+=this._transform.y*i,this._boneTransform.skewX+=this._transform.skewX*i,this._boneTransform.skewY+=this._transform.skewY*i,this._boneTransform.scaleX+=(this._transform.scaleX-1)*i,this._boneTransform.scaleY+=(this._transform.scaleY-1)*i),this.bone._blendIndex++,0!=this._animationState._fadeState&&this.bone.invalidUpdate())},i})(t.TweenTimelineState);t.BoneTimelineState=r;var s=(function(e){function i(){e.call(this),this._color=new t.ColorTransform,this._durationColor=new t.ColorTransform}return n(i,e),i.toString=function(){return"[class dragonBones.SlotTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this._colorDirty=!1,this._tweenColor=0,this._slotColor=null,this._color.identity(),this._durationColor.identity()},i.prototype._onArriveAtFrame=function(i){if(e.prototype._onArriveAtFrame.call(this,i),this._animationState._isDisabled(this.slot))return this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null,void(this._tweenColor=0);this._animationState._fadeState>=0&&(this.slot._setDisplayIndex(this._currentFrame.displayIndex),this.slot._updateMeshData(!0)),this._tweenColor=0;var n=this._currentFrame.color;if(this._keyFrameCount>1&&(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)){var r=this._currentFrame.next,s=r.color;n!=s&&r.displayIndex>=0&&(this._durationColor.alphaMultiplier=s.alphaMultiplier-n.alphaMultiplier,this._durationColor.redMultiplier=s.redMultiplier-n.redMultiplier,this._durationColor.greenMultiplier=s.greenMultiplier-n.greenMultiplier,this._durationColor.blueMultiplier=s.blueMultiplier-n.blueMultiplier,this._durationColor.alphaOffset=s.alphaOffset-n.alphaOffset,this._durationColor.redOffset=s.redOffset-n.redOffset,this._durationColor.greenOffset=s.greenOffset-n.greenOffset,this._durationColor.blueOffset=s.blueOffset-n.blueOffset,0==this._durationColor.alphaMultiplier&&0==this._durationColor.redMultiplier&&0==this._durationColor.greenMultiplier&&0==this._durationColor.blueMultiplier&&0==this._durationColor.alphaOffset&&0==this._durationColor.redOffset&&0==this._durationColor.greenOffset&&0==this._durationColor.blueOffset||(this._tweenColor=2))}0==this._tweenColor&&(this._slotColor.alphaMultiplier==n.alphaMultiplier&&this._slotColor.redMultiplier==n.redMultiplier&&this._slotColor.greenMultiplier==n.greenMultiplier&&this._slotColor.blueMultiplier==n.blueMultiplier&&this._slotColor.alphaOffset==n.alphaOffset&&this._slotColor.redOffset==n.redOffset&&this._slotColor.greenOffset==n.greenOffset&&this._slotColor.blueOffset==n.blueOffset||(this._tweenColor=1))},i.prototype._onUpdateFrame=function(t){e.prototype._onUpdateFrame.call(this,t);var i=0;if(this._tweenColor){1==this._tweenColor?(this._tweenColor=0,i=0):i=this._tweenProgress;var n=this._currentFrame.color;this._color.alphaMultiplier=n.alphaMultiplier+this._durationColor.alphaMultiplier*i,this._color.redMultiplier=n.redMultiplier+this._durationColor.redMultiplier*i,this._color.greenMultiplier=n.greenMultiplier+this._durationColor.greenMultiplier*i,this._color.blueMultiplier=n.blueMultiplier+this._durationColor.blueMultiplier*i,this._color.alphaOffset=n.alphaOffset+this._durationColor.alphaOffset*i,this._color.redOffset=n.redOffset+this._durationColor.redOffset*i,this._color.greenOffset=n.greenOffset+this._durationColor.greenOffset*i,this._color.blueOffset=n.blueOffset+this._durationColor.blueOffset*i,this._colorDirty=!0}},i.prototype.fadeIn=function(t,i,n,r){e.prototype.fadeIn.call(this,t,i,n,r),this._slotColor=this.slot._colorTransform},i.prototype.fadeOut=function(){this._tweenColor=0},i.prototype.update=function(t){if(e.prototype.update.call(this,t),0!=this._tweenColor||this._colorDirty){if(this._animationState._weightResult>0)if(0!=this._animationState._fadeState){var i=Math.pow(this._animationState._fadeProgress,4);this._slotColor.alphaMultiplier+=(this._color.alphaMultiplier-this._slotColor.alphaMultiplier)*i,this._slotColor.redMultiplier+=(this._color.redMultiplier-this._slotColor.redMultiplier)*i,this._slotColor.greenMultiplier+=(this._color.greenMultiplier-this._slotColor.greenMultiplier)*i,this._slotColor.blueMultiplier+=(this._color.blueMultiplier-this._slotColor.blueMultiplier)*i,this._slotColor.alphaOffset+=(this._color.alphaOffset-this._slotColor.alphaOffset)*i,this._slotColor.redOffset+=(this._color.redOffset-this._slotColor.redOffset)*i,this._slotColor.greenOffset+=(this._color.greenOffset-this._slotColor.greenOffset)*i,this._slotColor.blueOffset+=(this._color.blueOffset-this._slotColor.blueOffset)*i,this.slot._colorDirty=!0}else this._colorDirty&&(this._colorDirty=!1,this._slotColor.alphaMultiplier=this._color.alphaMultiplier,this._slotColor.redMultiplier=this._color.redMultiplier,this._slotColor.greenMultiplier=this._color.greenMultiplier,this._slotColor.blueMultiplier=this._color.blueMultiplier,this._slotColor.alphaOffset=this._color.alphaOffset,this._slotColor.redOffset=this._color.redOffset,this._slotColor.greenOffset=this._color.greenOffset,this._slotColor.blueOffset=this._color.blueOffset,this.slot._colorDirty=!0)}},i})(t.TweenTimelineState);t.SlotTimelineState=s;var o=(function(e){function i(){e.call(this),this._ffdVertices=[]}return n(i,e),i.toString=function(){return"[class dragonBones.FFDTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this._tweenFFD=0,this._slotFFDVertices=null,this._durationFFDFrame&&(this._durationFFDFrame.returnToPool(),this._durationFFDFrame=null),this._ffdVertices.length=0},i.prototype._onArriveAtFrame=function(i){if(e.prototype._onArriveAtFrame.call(this,i),this._tweenFFD=0,(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)&&(this._tweenFFD=this._updateExtensionKeyFrame(this._currentFrame,this._currentFrame.next,this._durationFFDFrame)),0==this._tweenFFD)for(var n=this._currentFrame.tweens,r=0,s=n.length;r<s;++r)if(this._slotFFDVertices[r]!=n[r]){this._tweenFFD=1;break}},i.prototype._onUpdateFrame=function(t){e.prototype._onUpdateFrame.call(this,t);var i=0;if(0!=this._tweenFFD){1==this._tweenFFD?(this._tweenFFD=0,i=0):i=this._tweenProgress;for(var n=this._currentFrame.tweens,r=this._durationFFDFrame.tweens,s=0,o=n.length;s<o;++s)this._ffdVertices[s]=n[s]+r[s]*i;this.slot._ffdDirty=!0}},i.prototype.fadeIn=function(i,n,r,s){e.prototype.fadeIn.call(this,i,n,r,s),this._slotFFDVertices=this.slot._ffdVertices,this._durationFFDFrame=t.BaseObject.borrowObject(t.ExtensionFrameData),this._durationFFDFrame.tweens.length=this._slotFFDVertices.length,this._ffdVertices.length=this._slotFFDVertices.length;for(var o=0,a=this._durationFFDFrame.tweens.length;o<a;++o)this._durationFFDFrame.tweens[o]=0;for(o=0,a=this._ffdVertices.length;o<a;++o)this._ffdVertices[o]=0},i.prototype.update=function(t){e.prototype.update.call(this,t);var i=this._animationState._weightResult;if(i>0){if(0==this.slot._blendIndex)for(var n=0,r=this._ffdVertices.length;n<r;++n)this._slotFFDVertices[n]=this._ffdVertices[n]*i;else for(n=0,r=this._ffdVertices.length;n<r;++n)this._slotFFDVertices[n]+=this._ffdVertices[n]*i;this.slot._blendIndex++,0!=this._animationState._fadeState&&(this.slot._ffdDirty=!0)}},i})(t.TweenTimelineState);t.FFDTimelineState=o})(r||(r={}));(function(t){var e=(function(){function e(){this.time=(new Date).getTime()/t.DragonBones.SECOND_TO_MILLISECOND,this.timeScale=1,this._animatebles=[]}return Object.defineProperty(e,"clock",{get:function(){return e._clock||(e._clock=new e),e._clock},enumerable:!0,configurable:!0}),e.prototype.advanceTime=function(e){if(e!=e&&(e=0),e<0&&(e=(new Date).getTime()/t.DragonBones.SECOND_TO_MILLISECOND-this.time),(e*=this.timeScale)<0?this.time-=e:this.time+=e,e){for(var i=0,n=0,r=this._animatebles.length;i<r;++i){(s=this._animatebles[i])?(n>0&&(this._animatebles[i-n]=s,this._animatebles[i]=null),s.advanceTime(e)):n++}if(n>0){for(r=this._animatebles.length;i<r;++i){var s;(s=this._animatebles[i])?this._animatebles[i-n]=s:n++}this._animatebles.length-=n}}},e.prototype.contains=function(t){return this._animatebles.indexOf(t)>=0},e.prototype.add=function(e){e&&this._animatebles.indexOf(e)<0&&(this._animatebles.push(e),t.DragonBones.debug&&e instanceof t.Armature&&t.DragonBones.addArmature(e))},e.prototype.remove=function(e){var i=this._animatebles.indexOf(e);i>=0&&(this._animatebles[i]=null,t.DragonBones.debug&&e instanceof t.Armature&&t.DragonBones.removeArmature(e))},e.prototype.clear=function(){for(var t=0,e=this._animatebles.length;t<e;++t)this._animatebles[t]=null},e._clock=null,e})();t.WorldClock=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this.global=new t.Transform,this.origin=new t.Transform,this.offset=new t.Transform,this._globalTransformMatrix=new t.Matrix}return n(i,e),i.prototype._onClear=function(){this.userData=null,this.name=null,this.globalTransformMatrix=this._globalTransformMatrix,this.global.identity(),this.origin.identity(),this.offset.identity(),this._armature=null,this._parent=null,this._globalTransformMatrix.identity()},i.prototype._setArmature=function(t){this._armature=t},i.prototype._setParent=function(t){this._parent=t},Object.defineProperty(i.prototype,"armature",{get:function(){return this._armature},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),i})(t.BaseObject);t.TransformObject=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this._bones=[],this._slots=[],this._actions=[],this._events=[],this.enableCache=!1}return n(i,e),i.toString=function(){return"[class dragonBones.Armature]"},i._onSortSlots=function(t,e){return t._zOrder>e._zOrder?1:-1},i.prototype._onClear=function(){for(var t=0,e=this._bones.length;t<e;++t)this._bones[t].returnToPool();for(t=0,e=this._slots.length;t<e;++t)this._slots[t].returnToPool();for(t=0,e=this._events.length;t<e;++t)this._events[t].returnToPool();this._animation&&this._animation.returnToPool(),this._display&&this._display._onClear(),this.userData=null,this._cacheFrameIndex=-1,this._armatureData=null,this._skinData=null,this._animation=null,this._display=null,this._parent=null,this._eventManager=null,this._delayDispose=!1,this._lockDispose=!1,this._debugDraw=!1,this._bonesDirty=!1,this._slotsDirty=!1,this._replacedTexture=null,this._bones.length=0,this._slots.length=0,this._actions.length=0,this._events.length=0},i.prototype._sortBones=function(){var t=this._bones.length;if(!(t<=0)){var e=this._bones.concat(),i=0,n=0;for(this._bones.length=0;n<t;){var r=e[i++];i>=t&&(i=0),this._bones.indexOf(r)>=0||(r.parent&&this._bones.indexOf(r.parent)<0||r.ik&&this._bones.indexOf(r.ik)<0||(r.ik&&r.ikChain>0&&r.ikChainIndex==r.ikChain?this._bones.splice(this._bones.indexOf(r.parent)+1,0,r):this._bones.push(r),n++))}}},i.prototype._sortSlots=function(){this._slots.sort(i._onSortSlots)},i.prototype._doAction=function(t){switch(t.type){case 0:this._animation.play(t.data[0],t.data[1]);break;case 1:this._animation.stop(t.data[0]);break;case 2:this._animation.gotoAndPlayByTime(t.data[0],t.data[1],t.data[2]);break;case 3:this._animation.gotoAndStopByTime(t.data[0],t.data[1]);break;case 4:this._animation.fadeIn(t.data[0],t.data[1],t.data[2])}},i.prototype._addBoneToBoneList=function(t){this._bones.indexOf(t)<0&&(this._bonesDirty=!0,this._bones.push(t))},i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);e>=0&&this._bones.splice(e,1)},i.prototype._addSlotToSlotList=function(t){this._slots.indexOf(t)<0&&(this._slotsDirty=!0,this._slots.push(t))},i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);e>=0&&this._slots.splice(e,1)},i.prototype._sortZOrder=function(t){for(var e=this._armatureData.sortedSlots,i=t.length<1,n=0,r=e.length;n<r;++n){var s=e[i?n:t[n]],o=this.getSlot(s.name);o&&o._setZorder(n)}this._slotsDirty=!0},i.prototype._bufferAction=function(t){this._actions.push(t)},i.prototype._bufferEvent=function(t,e){t.type=e,t.armature=this,this._events.push(t)},i.prototype.dispose=function(){this._delayDispose=!0,!this._lockDispose&&this._animation&&this.returnToPool()},i.prototype.advanceTime=function(e){if(!this._animation)throw new Error("The armature has been disposed.");var i=e*this._animation.timeScale;this._animation._advanceTime(i),this._bonesDirty&&(this._bonesDirty=!1,this._sortBones()),this._slotsDirty&&(this._slotsDirty=!1,this._sortSlots());for(var n=0,r=this._bones.length;n<r;++n)this._bones[n]._update(this._cacheFrameIndex);for(n=0,r=this._slots.length;n<r;++n){(a=this._slots[n])._update(this._cacheFrameIndex);(l=a._childArmature)&&(a.inheritAnimation?l.advanceTime(i):l.advanceTime(e))}if((t.DragonBones.debugDraw||this._debugDraw)&&(this._debugDraw=t.DragonBones.debugDraw,this._display._debugDraw(this._debugDraw)),!this._lockDispose){if(this._lockDispose=!0,this._events.length>0){for(n=0,r=this._events.length;n<r;++n){var s=this._events[n];s.type==t.EventObject.SOUND_EVENT?this._eventManager._dispatchEvent(s):this._display._dispatchEvent(s),s.returnToPool()}this._events.length=0}if(this._actions.length>0){for(n=0,r=this._actions.length;n<r;++n){var o=this._actions[n];if(o.slot){var a;if(a=this.getSlot(o.slot.name)){(l=a._childArmature)&&l._doAction(o)}}else if(o.bone)for(var c=0,h=this._slots.length;c<h;++c){var l;(l=this._slots[c]._childArmature)&&l._doAction(o)}else this._doAction(o)}this._actions.length=0}this._lockDispose=!1}this._delayDispose&&this.returnToPool()},i.prototype.containsPoint=function(t,e,i){void 0===i&&(i=0);for(var n=0,r=this._slots.length;n<r;++n){var s=this._slots[n];if(s.containsPoint(t,e,i))return s}return null},i.prototype.intersectsSegment=function(t,e,i,n,r,s,o,a){void 0===r&&(r=0),void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null);for(var c=t==i,h=0,l=0,u=0,_=0,d=0,f=0,p=0,m=0,g=null,y=null,v=0,x=this._slots.length;v<x;++v){var C=this._slots[v];if(C.intersectsSegment(t,e,i,n,r,s,o,a)>0){if(!s&&!o){g=C;break}if(s){(T=c?s.y-e:s.x-t)<0&&(T=-T),(!g||T<h)&&(h=T,u=s.x,_=s.y,g=C,a&&(p=a.x))}if(o){var T;(T=o.x-t)<0&&(T=-T),(!y||T>l)&&(l=T,d=o.x,f=o.y,y=C,a&&(m=a.y))}}}return g&&s&&(s.x=u,s.y=_,a&&(a.x=p)),y&&o&&(o.x=d,o.y=f,a&&(a.y=m)),g},i.prototype.invalidUpdate=function(t,e){if(void 0===t&&(t=null),void 0===e&&(e=!1),t){var i=this.getBone(t);if(i&&(i.invalidUpdate(),e))for(var n=0,r=this._slots.length;n<r;++n){var s=this._slots[n];s.parent==i&&s.invalidUpdate()}}else{for(n=0,r=this._bones.length;n<r;++n)this._bones[n].invalidUpdate();if(e)for(n=0,r=this._slots.length;n<r;++n)this._slots[n].invalidUpdate()}},i.prototype.getBone=function(t){for(var e=0,i=this._bones.length;e<i;++e){var n=this._bones[e];if(n.name==t)return n}return null},i.prototype.getBoneByDisplay=function(t){var e=this.getSlotByDisplay(t);return e?e.parent:null},i.prototype.getSlot=function(t){for(var e=0,i=this._slots.length;e<i;++e){var n=this._slots[e];if(n.name==t)return n}return null},i.prototype.getSlotByDisplay=function(t){if(t)for(var e=0,i=this._slots.length;e<i;++e){var n=this._slots[e];if(n.display==t)return n}return null},i.prototype.replaceTexture=function(t){this.replacedTexture=t},i.prototype.getBones=function(){return this._bones},i.prototype.getSlots=function(){return this._slots},Object.defineProperty(i.prototype,"name",{get:function(){return this._armatureData?this._armatureData.name:null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"armatureData",{get:function(){return this._armatureData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"display",{get:function(){return this._display},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cacheFrameRate",{get:function(){return this._armatureData.cacheFrameRate},set:function(t){if(this._armatureData.cacheFrameRate!=t){this._armatureData.cacheFrames(t);for(var e=0,i=this._slots.length;e<i;++e){var n=this._slots[e].childArmature;n&&0==n.cacheFrameRate&&(n.cacheFrameRate=t)}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"replacedTexture",{get:function(){return this._replacedTexture},set:function(t){this._display._onReplaceTexture(t),this._replacedTexture=t;for(var e=0,i=this._slots.length;e<i;++e)this._slots[e].invalidUpdate()},enumerable:!0,configurable:!0}),i.prototype.enableAnimationCache=function(t){this.cacheFrameRate=t},i.prototype.hasEventListener=function(t){return this._display.hasEvent(t)},i.prototype.addEventListener=function(t,e,i){this._display.addEvent(t,e,i)},i.prototype.removeEventListener=function(t,e,i){this._display.removeEvent(t,e,i)},i.prototype.addBone=function(t,e){if(void 0===e&&(e=null),!t)throw new Error;t._setArmature(this),t._setParent(e?this.getBone(e):null)},i.prototype.addSlot=function(t,e){var i=this.getBone(e);if(!i)throw new Error;t._setArmature(this),t._setParent(i)},i.prototype.removeBone=function(t){if(!t||t.armature!=this)throw new Error;t._setParent(null),t._setArmature(null)},i.prototype.removeSlot=function(t){if(!t||t.armature!=this)throw new Error;t._setParent(null),t._setArmature(null)},i.prototype.getDisplay=function(){return this._display},i})(t.BaseObject);t.Armature=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this._animationPose=new t.Transform,this._bones=[],this._slots=[]}return n(i,e),i.toString=function(){return"[class dragonBones.Bone]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.ikBendPositive=!1,this.ikWeight=0,this.length=0,this._transformDirty=2,this._blendIndex=0,this._cacheFrames=null,this._animationPose.identity(),this._visible=!0,this._ikChain=0,this._ikChainIndex=0,this._ik=null,this._bones.length=0,this._slots.length=0},i.prototype._updateGlobalTransformMatrix=function(){if(this._parent){var t=this._parent.global.skewY,e=this._parent.globalTransformMatrix;if(this.inheritScale)this.inheritRotation||(this.global.skewX-=t,this.global.skewY-=t),this.global.toMatrix(this.globalTransformMatrix),this.globalTransformMatrix.concat(e),this.inheritTranslation||(this.globalTransformMatrix.tx=this.global.x,this.globalTransformMatrix.ty=this.global.y),this.global.fromMatrix(this.globalTransformMatrix);else{if(this.inheritTranslation){var i=this.global.x,n=this.global.y;this.global.x=e.a*i+e.c*n+e.tx,this.global.y=e.d*n+e.b*i+e.ty}this.inheritRotation&&(this.global.skewX+=t,this.global.skewY+=t),this.global.toMatrix(this.globalTransformMatrix)}}else this.global.toMatrix(this.globalTransformMatrix)},i.prototype._computeIKA=function(){var t=this._ik.global,e=this.globalTransformMatrix.a*this.length,i=this.globalTransformMatrix.b*this.length,n=(Math.atan2(t.y-this.global.y,t.x-this.global.x)+this.offset.skewY-2*this.global.skewY+Math.atan2(i,e))*this.ikWeight;this.global.skewX+=n,this.global.skewY+=n,this.global.toMatrix(this.globalTransformMatrix)},i.prototype._computeIKB=function(){var t=this._parent.global,e=this._ik.global,i=this.globalTransformMatrix.a*this.length,n=this.globalTransformMatrix.b*this.length,r=i*i+n*n,s=Math.sqrt(r),o=this.global.x-t.x,a=this.global.y-t.y,c=o*o+a*a,h=Math.sqrt(c),l=(o=e.x-t.x)*o+(a=e.y-t.y)*a,u=Math.sqrt(l),_=0;if(s+h<=u||u+s<=h||u+h<=s)_=Math.atan2(e.y-t.y,e.x-t.x)+this._parent.offset.skewY,s+h<=u||h<s&&(_+=Math.PI);else{var d=(c-r+l)/(2*l),f=Math.sqrt(c-d*d*l)/u,p=t.x+o*d,m=t.y+a*d,g=-a*f,y=o*f;this.ikBendPositive?(this.global.x=p-g,this.global.y=m-y):(this.global.x=p+g,this.global.y=m+y),_=Math.atan2(this.global.y-t.y,this.global.x-t.x)+this._parent.offset.skewY}_=(_-t.skewY)*this.ikWeight,t.skewX+=_,t.skewY+=_,t.toMatrix(this._parent.globalTransformMatrix),this._parent._transformDirty=1,this.global.x=t.x+Math.cos(t.skewY)*h,this.global.y=t.y+Math.sin(t.skewY)*h;var v=(Math.atan2(e.y-this.global.y,e.x-this.global.x)+this.offset.skewY-2*this.global.skewY+Math.atan2(n,i))*this.ikWeight;this.global.skewX+=v,this.global.skewY+=v,this.global.toMatrix(this.globalTransformMatrix)},i.prototype._setArmature=function(t){if(this._armature!=t){this._ik=null;var e=null,i=null;if(this._armature&&(e=this.getSlots(),i=this.getBones(),this._armature._removeBoneFromBoneList(this)),this._armature=t,this._armature&&this._armature._addBoneToBoneList(this),e)for(var n=0,r=e.length;n<r;++n){var s=e[n];s.parent==this&&s._setArmature(this._armature)}if(i)for(n=0,r=i.length;n<r;++n){var o=i[n];o.parent==this&&o._setArmature(this._armature)}}},i.prototype._setIK=function(t,e,i){if(t){if(e==i){var n=this._parent;if(e&&n?e=1:(e=0,i=0,n=this),n==t||n.contains(t))t=null,e=0,i=0;else for(var r=t;r.ik&&r.ikChain;){if(n.contains(r.ik)){t=null,e=0,i=0;break}r=r.parent}}}else e=0,i=0;this._ik=t,this._ikChain=e,this._ikChainIndex=i,this._armature&&(this._armature._bonesDirty=!0)},i.prototype._update=function(e){if(this._blendIndex=0,e>=0){var i=this._cacheFrames[e];this.globalTransformMatrix==i?this._transformDirty=0:i?(this._transformDirty=2,this.globalTransformMatrix=i):2==this._transformDirty||this._parent&&0!=this._parent._transformDirty||this._ik&&this.ikWeight>0&&0!=this._ik._transformDirty?(this._transformDirty=2,this.globalTransformMatrix=this._globalTransformMatrix):this.globalTransformMatrix!=this._globalTransformMatrix?(this._transformDirty=0,this._cacheFrames[e]=this.globalTransformMatrix):(this._transformDirty=2,this.globalTransformMatrix=this._globalTransformMatrix)}else(2==this._transformDirty||this._parent&&0!=this._parent._transformDirty||this._ik&&this.ikWeight>0&&0!=this._ik._transformDirty)&&(this._transformDirty=2,this.globalTransformMatrix=this._globalTransformMatrix);0!=this._transformDirty&&(2==this._transformDirty?(this._transformDirty=1,this.globalTransformMatrix==this._globalTransformMatrix&&(this.global.x=this.origin.x+this.offset.x+this._animationPose.x,this.global.y=this.origin.y+this.offset.y+this._animationPose.y,this.global.skewX=this.origin.skewX+this.offset.skewX+this._animationPose.skewX,this.global.skewY=this.origin.skewY+this.offset.skewY+this._animationPose.skewY,this.global.scaleX=this.origin.scaleX*this.offset.scaleX*this._animationPose.scaleX,this.global.scaleY=this.origin.scaleY*this.offset.scaleY*this._animationPose.scaleY,this._updateGlobalTransformMatrix(),this._ik&&this._ikChainIndex==this._ikChain&&this.ikWeight>0&&(this.inheritTranslation&&this._ikChain>0&&this._parent?this._computeIKB():this._computeIKA()),e>=0&&!this._cacheFrames[e]&&(this.globalTransformMatrix=t.BoneTimelineData.cacheFrame(this._cacheFrames,e,this._globalTransformMatrix)))):this._transformDirty=0)},i.prototype.invalidUpdate=function(){this._transformDirty=2},i.prototype.contains=function(t){if(t){if(t==this)return!1;for(var e=t;e!=this&&e;)e=e.parent;return e==this}return!1},i.prototype.getBones=function(){this._bones.length=0;for(var t=this._armature.getBones(),e=0,i=t.length;e<i;++e){var n=t[e];n.parent==this&&this._bones.push(n)}return this._bones},i.prototype.getSlots=function(){this._slots.length=0;for(var t=this._armature.getSlots(),e=0,i=t.length;e<i;++e){var n=t[e];n.parent==this&&this._slots.push(n)}return this._slots},Object.defineProperty(i.prototype,"ikChain",{get:function(){return this._ikChain},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"ikChainIndex",{get:function(){return this._ikChainIndex},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"ik",{get:function(){return this._ik},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible!=t){this._visible=t;for(var e=this._armature.getSlots(),i=0,n=e.length;i<n;++i){var r=e[i];r._parent==this&&r._updateVisible()}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"slot",{get:function(){for(var t=this._armature.getSlots(),e=0,i=t.length;e<i;++e){var n=t[e];if(n.parent==this)return n}return null},enumerable:!0,configurable:!0}),i})(t.TransformObject);t.Bone=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this._colorTransform=new t.ColorTransform,this._ffdVertices=[],this._replacedDisplayDataSet=[],this._localMatrix=new t.Matrix,this._displayList=[],this._meshBones=[]}return n(i,e),i.prototype._onClear=function(){e.prototype._onClear.call(this);for(var i=[],n=0,r=this._displayList.length;n<r;++n){(s=this._displayList[n])!=this._rawDisplay&&s!=this._meshDisplay&&i.indexOf(s)<0&&i.push(s)}for(n=0,r=i.length;n<r;++n){var s;(s=i[n])instanceof t.Armature?s.dispose():this._disposeDisplay(s)}this._meshDisplay&&this._meshDisplay!=this._rawDisplay&&this._disposeDisplay(this._meshDisplay),this._rawDisplay&&this._disposeDisplay(this._rawDisplay),this.inheritAnimation=!0,this.displayController=null,this._blendIndex=0,this._displayDataSet=null,this._meshData=null,this._childArmature=null,this._rawDisplay=null,this._meshDisplay=null,this._cacheFrames=null,this._colorTransform.identity(),this._ffdVertices.length=0,this._replacedDisplayDataSet.length=0,this._zOrderDirty=!1,this._displayDirty=!1,this._colorDirty=!1,this._blendModeDirty=!1,this._originDirty=!1,this._transformDirty=!1,this._ffdDirty=!1,this._zOrder=0,this._displayIndex=-2,this._pivotX=0,this._pivotY=0,this._blendMode=0,this._display=null,this._localMatrix.identity(),this._displayList.length=0,this._meshBones.length=0},i.prototype._isMeshBonesUpdate=function(){for(var t=0,e=this._meshBones.length;t<e;++t)if(0!=this._meshBones[t]._transformDirty)return!0;return!1},i.prototype._updatePivot=function(t,e,n){var r=t&&t!=e&&(!this._meshData||this._meshData!=t.mesh);if(this._meshData&&this._display==this._meshDisplay)this._pivotX=0,this._pivotY=0;else{var s=this._armature.armatureData.scale;if(this._pivotX=e.pivot.x,this._pivotY=e.pivot.y,e.isRelativePivot){var o=n.frame||n.region,a=o.width*s,c=o.height*s;n.rotated&&(a=o.height,c=o.width),this._pivotX*=a,this._pivotY*=c}n.frame&&(this._pivotX+=n.frame.x*s,this._pivotY+=n.frame.y*s)}r&&(t.transform.toMatrix(i._helpMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(0,0,i._helpPoint),this._pivotX-=i._helpPoint.x,this._pivotY-=i._helpPoint.y,e.transform.toMatrix(i._helpMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(0,0,i._helpPoint),this._pivotX+=i._helpPoint.x,this._pivotY+=i._helpPoint.y)},i.prototype._updateDisplay=function(){var e=this._display||this._rawDisplay,i=this._childArmature;this._displayIndex>=0&&this._displayIndex<this._displayList.length?(this._display=this._displayList[this._displayIndex],this._display instanceof t.Armature?(this._childArmature=this._display,this._display=this._childArmature._display):this._childArmature=null):(this._display=null,this._childArmature=null);var n=this._display||this._rawDisplay;if(n!=e&&(this._onUpdateDisplay(),e?this._replaceDisplay(e):this._addDisplay(),this._blendModeDirty=!0,this._colorDirty=!0),this._displayDataSet&&this._displayIndex>=0&&this._displayIndex<this._displayDataSet.displays.length&&(this.origin.copyFrom(this._displayDataSet.displays[this._displayIndex].transform),this._originDirty=!0),this._updateMeshData(!1),n!=this._rawDisplay&&n!=this._meshDisplay||this._updateFrame(),this._childArmature!=i&&(i&&(i._parent=null,this.inheritAnimation&&i.animation.reset()),this._childArmature&&(this._childArmature._parent=this,this.inheritAnimation))){if(0==this._childArmature.cacheFrameRate){var r=this._armature.cacheFrameRate;0!=r&&(this._childArmature.cacheFrameRate=r)}var s=this._armature.armatureData.getSlot(this.name),o=s.actions.length>0?s.actions:this._childArmature.armatureData.actions;if(o.length>0)for(var a=0,c=o.length;a<c;++a)this._childArmature._bufferAction(o[a]);else this._childArmature.animation.play()}},i.prototype._updateLocalTransformMatrix=function(){this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix)},i.prototype._updateGlobalTransformMatrix=function(){this.globalTransformMatrix.copyFrom(this._localMatrix),this.globalTransformMatrix.concat(this._parent.globalTransformMatrix),this.global.fromMatrix(this.globalTransformMatrix)},i.prototype._setArmature=function(t){this._armature!=t&&(this._armature&&this._armature._removeSlotFromSlotList(this),this._armature=t,this._onUpdateDisplay(),this._armature?(this._armature._addSlotToSlotList(this),this._addDisplay()):this._removeDisplay())},i.prototype._updateMeshData=function(t){var e=this._meshData,i=null;if(this._display&&this._display==this._meshDisplay&&this._displayIndex>=0){i=this._displayDataSet&&this._displayIndex<this._displayDataSet.displays.length?this._displayDataSet.displays[this._displayIndex].mesh:null;var n=this._displayIndex<this._replacedDisplayDataSet.length?this._replacedDisplayDataSet[this._displayIndex]:null,r=n?n.mesh:null;this._meshData=r||i}else this._meshData=null;if(this._meshData!=e){if(this._meshData&&this._meshData==i){if(this._meshData.skinned){this._meshBones.length=this._meshData.bones.length;for(var s=0,o=this._meshBones.length;s<o;++s)this._meshBones[s]=this._armature.getBone(this._meshData.bones[s].name);var a=0;for(s=0,o=this._meshData.boneIndices.length;s<o;++s)a+=this._meshData.boneIndices[s].length;this._ffdVertices.length=2*a}else this._meshBones.length=0,this._ffdVertices.length=this._meshData.vertices.length;for(s=0,o=this._ffdVertices.length;s<o;++s)this._ffdVertices[s]=0;this._ffdDirty=!0}else this._meshBones.length=0,this._ffdVertices.length=0;t&&this._armature.animation._updateFFDTimelineStates()}},i.prototype._update=function(e){if(this._blendIndex=0,this._zOrderDirty&&(this._zOrderDirty=!1,this._updateZOrder()),this._displayDirty&&(this._displayDirty=!1,this._updateDisplay()),this._display&&(this._blendModeDirty&&(this._blendModeDirty=!1,this._updateBlendMode()),this._colorDirty&&(this._colorDirty=!1,this._updateColor()),!this._meshData||((this._ffdDirty||this._meshData.skinned&&this._isMeshBonesUpdate())&&(this._ffdDirty=!1,this._updateMesh()),!this._meshData.skinned))){if(this._originDirty&&(this._originDirty=!1,this._transformDirty=!0,this._updateLocalTransformMatrix()),e>=0&&this._cacheFrames){var i=this._cacheFrames[e];this.globalTransformMatrix==i?this._transformDirty=!1:i?(this._transformDirty=!0,this.globalTransformMatrix=i):this._transformDirty||0!=this._parent._transformDirty?(this._transformDirty=!0,this.globalTransformMatrix=this._globalTransformMatrix):this.globalTransformMatrix!=this._globalTransformMatrix?(this._transformDirty=!1,this._cacheFrames[e]=this.globalTransformMatrix):(this._transformDirty=!0,this.globalTransformMatrix=this._globalTransformMatrix)}else(this._transformDirty||0!=this._parent._transformDirty)&&(this._transformDirty=!0,this.globalTransformMatrix=this._globalTransformMatrix);this._transformDirty&&(this._transformDirty=!1,this.globalTransformMatrix==this._globalTransformMatrix&&(this._updateGlobalTransformMatrix(),e>=0&&this._cacheFrames&&!this._cacheFrames[e]&&(this.globalTransformMatrix=t.SlotTimelineData.cacheFrame(this._cacheFrames,e,this._globalTransformMatrix))),this._updateTransform())}},i.prototype._setDisplayList=function(e){if(e&&e.length>0){this._displayList.length!=e.length&&(this._displayList.length=e.length);for(var i=0,n=e.length;i<n;++i){var r=e[i];r&&r!=this._rawDisplay&&r!=this._meshDisplay&&!(r instanceof t.Armature)&&this._displayList.indexOf(r)<0&&this._initDisplay(r),this._displayList[i]=r}}else this._displayList.length>0&&(this._displayList.length=0);return this._displayIndex>=0&&this._displayIndex<this._displayList.length?this._displayDirty=this._display!=this._displayList[this._displayIndex]:this._displayDirty=null!=this._display,this._displayDirty},i.prototype._setZorder=function(t){return this._zOrder,this._zOrder=t,this._zOrderDirty=!0,this._zOrderDirty},i.prototype._setDisplayIndex=function(t){return this._displayIndex!=t&&(this._displayIndex=t,this._displayDirty=!0,this._displayDirty)},i.prototype._setBlendMode=function(t){return this._blendMode!=t&&(this._blendMode=t,this._blendModeDirty=!0,!0)},i.prototype._setColor=function(t){return this._colorTransform.copyFrom(t),this._colorDirty=!0,!0},i.prototype.containsPoint=function(t,e,n){void 0===n&&(n=0);var r=this.displayData;return!(!r||!r.boundingBox||n&&r.color!=n)&&(0==this._blendIndex&&(this._blendIndex=1,this._updateLocalTransformMatrix(),this._updateGlobalTransformMatrix()),i._helpMatrix.copyFrom(this.globalTransformMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(t,e,i._helpPoint),r.boundingBox.containsPoint(i._helpPoint.x,i._helpPoint.y))},i.prototype.intersectsSegment=function(t,e,n,r,s,o,a,c){void 0===s&&(s=0),void 0===o&&(o=null),void 0===a&&(a=null),void 0===c&&(c=null);var h=this.displayData;if(!h||!h.boundingBox||s&&h.color!=s)return 0;0==this._blendIndex&&(this._blendIndex=1,this._updateLocalTransformMatrix(),this._updateGlobalTransformMatrix()),i._helpMatrix.copyFrom(this.globalTransformMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(t,e,i._helpPoint),t=i._helpPoint.x,e=i._helpPoint.y,i._helpMatrix.transformPoint(n,r,i._helpPoint),n=i._helpPoint.x,r=i._helpPoint.y;var l=h.boundingBox.intersectsSegment(t,e,n,r,o,a,c);return l>0&&(1==l||2==l?o?(this.globalTransformMatrix.transformPoint(o.x,o.y,o),a&&(a.x=o.x,a.y=o.y)):a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a):(o&&this.globalTransformMatrix.transformPoint(o.x,o.y,o),a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a)),c&&(this.globalTransformMatrix.transformPoint(Math.cos(c.x),Math.sin(c.x),i._helpPoint,!0),c.x=Math.atan2(i._helpPoint.y,i._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(c.y),Math.sin(c.y),i._helpPoint,!0),c.y=Math.atan2(i._helpPoint.y,i._helpPoint.x))),l},i.prototype.invalidUpdate=function(){this._displayDirty=!0},Object.defineProperty(i.prototype,"displayData",{get:function(){return this._displayIndex<0||this._displayIndex>=this._displayDataSet.displays.length?null:this._displayDataSet.displays[this._displayIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rawDisplay",{get:function(){return this._rawDisplay},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshDisplay",{get:function(){return this._meshDisplay},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){this._setDisplayIndex(t)&&this._update(-1)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat(),n=[];this._setDisplayList(e)&&this._update(-1);for(var r=0,s=i.length;r<s;++r){(o=i[r])&&o!=this._rawDisplay&&o!=this._meshDisplay&&this._displayList.indexOf(o)<0&&n.indexOf(o)<0&&n.push(o)}for(r=0,s=n.length;r<s;++r){var o;(o=n[r])instanceof t.Armature?o.dispose():this._disposeDisplay(o)}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"display",{get:function(){return this._display},set:function(t){if(this._display!=t){var e=this._displayList.length;if(this._displayIndex<0&&0==e&&(this._displayIndex=0),!(this._displayIndex<0)){var i=this.displayList;e<=this._displayIndex&&(i.length=this._displayIndex+1),i[this._displayIndex]=t,this.displayList=i}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"childArmature",{get:function(){return this._childArmature},set:function(t){this._childArmature!=t&&(t&&t.display.advanceTimeBySelf(!1),this.display=t)},enumerable:!0,configurable:!0}),i.prototype.getDisplay=function(){return this._display},i.prototype.setDisplay=function(t){this.display=t},i._helpPoint=new t.Point,i._helpMatrix=new t.Matrix,i})(t.TransformObject);t.Slot=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this)}return n(e,t),e.toString=function(){return"[class dragonBones.EventObject]"},e.prototype._onClear=function(){this.type=null,this.name=null,this.armature=null,this.bone=null,this.slot=null,this.animationState=null,this.frame=null,this.data=null,this.userData=null},e.prototype.getInt=function(t){return this.data?this.data.ints[t]:0},e.prototype.getFloat=function(t){return this.data?this.data.floats[t]:0},e.prototype.getString=function(t){return this.data?this.data.strings[t]:null},e.START="start",e.LOOP_COMPLETE="loopComplete",e.COMPLETE="complete",e.FADE_IN="fadeIn",e.FADE_IN_COMPLETE="fadeInComplete",e.FADE_OUT="fadeOut",e.FADE_OUT_COMPLETE="fadeOutComplete",e.FRAME_EVENT="frameEvent",e.SOUND_EVENT="soundEvent",e})(t.BaseObject);t.EventObject=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.frames=[]}return n(e,t),e.toString=function(){return"[class dragonBones.TimelineData]"},e.prototype._onClear=function(){for(var t=null,e=0,i=this.frames.length;e<i;++e){var n=this.frames[e];t&&n!=t&&t.returnToPool(),t=n}this.scale=1,this.offset=0,this.frames.length=0},e})(t.BaseObject);t.TimelineData=e;var i=(function(t){function e(){t.apply(this,arguments)}return n(e,t),e.toString=function(){return"[class dragonBones.ZOrderTimelineData]"},e})(e);t.ZOrderTimelineData=i;var r=(function(e){function i(){e.call(this),this.originalTransform=new t.Transform,this.cachedFrames=[]}return n(i,e),i.cacheFrame=function(e,i,n){var r=e[i]=new t.Matrix;return r.copyFrom(n),r},i.toString=function(){return"[class dragonBones.BoneTimelineData]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.bone=null,this.originalTransform.identity(),this.cachedFrames.length=0},i.prototype.cacheFrames=function(t){this.cachedFrames.length=0,this.cachedFrames.length=t},i})(e);t.BoneTimelineData=r;var s=(function(e){function i(){e.call(this),this.cachedFrames=[]}return n(i,e),i.cacheFrame=function(e,i,n){var r=e[i]=new t.Matrix;return r.copyFrom(n),r},i.toString=function(){return"[class dragonBones.SlotTimelineData]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this.cachedFrames.length=0},i.prototype.cacheFrames=function(t){this.cachedFrames.length=0,this.cachedFrames.length=t},i})(e);t.SlotTimelineData=s;var o=(function(t){function e(){t.call(this)}return n(e,t),e.toString=function(){return"[class dragonBones.FFDTimelineData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.skin=null,this.slot=null,this.display=null},e})(e);t.FFDTimelineData=o})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.boneTimelines={},this.slotTimelines={},this.ffdTimelines={},this.cachedFrames=[]}return n(e,t),e.toString=function(){return"[class dragonBones.AnimationData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.zOrderTimeline&&this.zOrderTimeline.returnToPool();for(var e in this.boneTimelines)this.boneTimelines[e].returnToPool(),delete this.boneTimelines[e];for(var e in this.slotTimelines)this.slotTimelines[e].returnToPool(),delete this.slotTimelines[e];for(var e in this.ffdTimelines){for(var i in this.ffdTimelines[e])for(var n in this.ffdTimelines[e][i])this.ffdTimelines[e][i][n].returnToPool();delete this.ffdTimelines[e]}this.hasAsynchronyTimeline=!1,this.frameCount=0,this.playTimes=0,this.position=0,this.duration=0,this.fadeInTime=0,this.cacheFrameRate=0,this.name=null,this.animation=null,this.zOrderTimeline=null,this.cachedFrames.length=0},e.prototype.cacheFrames=function(t){if(!this.animation){this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=0,this.cachedFrames.length=e;for(var i in this.boneTimelines)this.boneTimelines[i].cacheFrames(e);for(var i in this.slotTimelines)this.slotTimelines[i].cacheFrames(e)}},e.prototype.addBoneTimeline=function(t){if(!t||!t.bone||this.boneTimelines[t.bone.name])throw new Error;this.boneTimelines[t.bone.name]=t},e.prototype.addSlotTimeline=function(t){if(!t||!t.slot||this.slotTimelines[t.slot.name])throw new Error;this.slotTimelines[t.slot.name]=t},e.prototype.addFFDTimeline=function(t){if(!(t&&t.skin&&t.slot&&t.display))throw new Error;var e=this.ffdTimelines[t.skin.name]=this.ffdTimelines[t.skin.name]||{},i=e[t.slot.slot.name]=e[t.slot.slot.name]||{};if(i[t.display.name])throw new Error;i[t.display.name]=t},e.prototype.getBoneTimeline=function(t){return this.boneTimelines[t]},e.prototype.getSlotTimeline=function(t){return this.slotTimelines[t]},e.prototype.getFFDTimeline=function(t,e,i){var n=this.ffdTimelines[t];if(n){var r=n[e];if(r)return r[i]}return null},e})(t.TimelineData);t.AnimationData=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this),this.aabb=new t.Rectangle,this.bones={},this.slots={},this.skins={},this.animations={},this.actions=[],this._sortedBones=[],this._sortedSlots=[],this._bonesChildren={}}return n(i,e),i._onSortSlots=function(t,e){return t.zOrder>e.zOrder?1:-1},i.toString=function(){return"[class dragonBones.ArmatureData]"},i.prototype._onClear=function(){for(var t in this.bones)this.bones[t].returnToPool(),delete this.bones[t];for(var t in this.slots)this.slots[t].returnToPool(),delete this.slots[t];for(var t in this.skins)this.skins[t].returnToPool(),delete this.skins[t];for(var t in this.animations)this.animations[t].returnToPool(),delete this.animations[t];t=0;for(var e=this.actions.length;t<e;++t)this.actions[t].returnToPool();this.frameRate=0,this.type=-1,this.name=null,this.parent=null,this.userData=null,this.aabb.clear(),this.actions.length=0,this.cacheFrameRate=0,this.scale=1;for(var t in this._bonesChildren)delete this._bonesChildren[t];this._boneDirty=!1,this._slotDirty=!1,this._defaultSkin=null,this._defaultAnimation=null,this._sortedBones.length=0,this._sortedSlots.length=0},i.prototype._sortBones=function(){var t=this._sortedBones.length;if(!(t<1)){var e=this._sortedBones.concat(),i=0,n=0;for(this._sortedBones.length=0;n<t;){var r=e[i++];i>=t&&(i=0),this._sortedBones.indexOf(r)>=0||(r.parent&&this._sortedBones.indexOf(r.parent)<0||r.ik&&this._sortedBones.indexOf(r.ik)<0||(r.ik&&r.chain>0&&r.chainIndex==r.chain?this._sortedBones.splice(this._sortedBones.indexOf(r.parent)+1,0,r):this._sortedBones.push(r),n++))}}},i.prototype._sortSlots=function(){this._sortedSlots.sort(i._onSortSlots)},i.prototype.cacheFrames=function(t){if(this.cacheFrameRate!=t){this.cacheFrameRate=t;for(var e in this.animations)this.animations[e].cacheFrames(this.cacheFrameRate)}},i.prototype.addBone=function(t,e){if(!t||!t.name||this.bones[t.name])throw new Error;if(e){var i=this.getBone(e);i?t.parent=i:(this._bonesChildren[e]=this._bonesChildren[e]||[]).push(t)}var n=this._bonesChildren[t.name];if(n){for(var r=0,s=n.length;r<s;++r)n[r].parent=t;delete this._bonesChildren[t.name]}this.bones[t.name]=t,this._sortedBones.push(t),this._boneDirty=!0},i.prototype.addSlot=function(t){if(!t||!t.name||this.slots[t.name])throw new Error;this.slots[t.name]=t,this._sortedSlots.push(t),this._slotDirty=!0},i.prototype.addSkin=function(t){if(!t||!t.name||this.skins[t.name])throw new Error;this.skins[t.name]=t,this._defaultSkin||(this._defaultSkin=t)},i.prototype.addAnimation=function(t){if(!t||!t.name||this.animations[t.name])throw new Error;this.animations[t.name]=t,this._defaultAnimation||(this._defaultAnimation=t)},i.prototype.getBone=function(t){return this.bones[t]},i.prototype.getSlot=function(t){return this.slots[t]},i.prototype.getSkin=function(t){return t?this.skins[t]:this._defaultSkin},i.prototype.getAnimation=function(t){return t?this.animations[t]:this._defaultAnimation},Object.defineProperty(i.prototype,"sortedBones",{get:function(){return this._boneDirty&&(this._boneDirty=!1,this._sortBones()),this._sortedBones},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sortedSlots",{get:function(){return this._slotDirty&&(this._slotDirty=!1,this._sortSlots()),this._sortedSlots},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"defaultSkin",{get:function(){return this._defaultSkin},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"defaultAnimation",{get:function(){return this._defaultAnimation},enumerable:!0,configurable:!0}),i})(t.BaseObject);t.ArmatureData=e;var i=(function(e){function i(){e.call(this),this.transform=new t.Transform}return n(i,e),i.toString=function(){return"[class dragonBones.BoneData]"},i.prototype._onClear=function(){this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.bendPositive=!1,this.chain=0,this.chainIndex=0,this.weight=0,this.length=0,this.name=null,this.parent=null,this.ik=null,this.transform.identity()},i})(t.BaseObject);t.BoneData=i;var r=(function(e){function i(){e.call(this),this.actions=[]}return n(i,e),i.generateColor=function(){return new t.ColorTransform},i.toString=function(){return"[class dragonBones.SlotData]"},i.prototype._onClear=function(){for(var t=0,e=this.actions.length;t<e;++t)this.actions[t].returnToPool();this.displayIndex=0,this.zOrder=0,this.blendMode=0,this.name=null,this.parent=null,this.color=null,this.actions.length=0},i.DEFAULT_COLOR=new t.ColorTransform,i})(t.BaseObject);t.SlotData=r;var s=(function(t){function e(){t.call(this),this.slots={}}return n(e,t),e.toString=function(){return"[class dragonBones.SkinData]"},e.prototype._onClear=function(){for(var t in this.slots)this.slots[t].returnToPool(),delete this.slots[t];this.name=null},e.prototype.addSlot=function(t){if(!t||!t.slot||this.slots[t.slot.name])throw new Error;this.slots[t.slot.name]=t},e.prototype.getSlot=function(t){return this.slots[t]},e})(t.BaseObject);t.SkinData=s;var o=(function(t){function e(){t.call(this),this.displays=[]}return n(e,t),e.toString=function(){return"[class dragonBones.SlotDisplayDataSet]"},e.prototype._onClear=function(){for(var t=0,e=this.displays.length;t<e;++t)this.displays[t].returnToPool();this.slot=null,this.displays.length=0},e})(t.BaseObject);t.SlotDisplayDataSet=o;var a=(function(e){function i(){e.call(this),this.pivot=new t.Point,this.transform=new t.Transform}return n(i,e),i.toString=function(){return"[class dragonBones.DisplayData]"},i.prototype._onClear=function(){this.mesh&&!this.share&&this.mesh.returnToPool(),this.boundingBox&&this.boundingBox.returnToPool(),this.isRelativePivot=!1,this.type=-1,this.inheritAnimation=!0,this.color=0,this.name=null,this.path=null,this.texture=null,this.armature=null,this.mesh=null,this.share=null,this.boundingBox=null,this.pivot.clear(),this.transform.identity()},i})(t.BaseObject);t.DisplayData=a;var c=(function(e){function i(){e.call(this),this.slotPose=new t.Matrix,this.uvs=[],this.vertices=[],this.vertexIndices=[],this.boneIndices=[],this.weights=[],this.boneVertices=[],this.bones=[],this.inverseBindPose=[]}return n(i,e),i.toString=function(){return"[class dragonBones.MeshData]"},i.prototype._onClear=function(){this.skinned=!1,this.slotPose.identity(),this.uvs.length=0,this.vertices.length=0,this.vertexIndices.length=0,this.boneIndices.length=0,this.weights.length=0,this.boneVertices.length=0,this.bones.length=0,this.inverseBindPose.length=0},i})(t.BaseObject);t.MeshData=c;var h=(function(t){function e(){t.call(this),this.x=0,this.y=0,this.width=0,this.height=0,this.vertices=[]}return n(e,t),e.toString=function(){return"[class dragonBones.BoundingBoxData]"},e._computeOutCode=function(t,e,i,n,r,s){var o=0;return t<i?o|=1:t>r&&(o|=2),e<n?o|=4:e>s&&(o|=8),o},e.segmentIntersectsRectangle=function(t,i,n,r,s,o,a,c,h,l,u){void 0===h&&(h=null),void 0===l&&(l=null),void 0===u&&(u=null);var _=t>s&&t<a&&i>o&&i<c,d=n>s&&n<a&&r>o&&r<c;if(_&&d)return-1;for(var f=0,p=e._computeOutCode(t,i,s,o,a,c),m=e._computeOutCode(n,r,s,o,a,c);;){if(!(p|m)){f=2;break}if(p&m)break;var g=0,y=0,v=0,x=p||m;4&x?(g=t+(n-t)*(o-i)/(r-i),y=o,u&&(v=.5*-Math.PI)):8&x?(g=t+(n-t)*(c-i)/(r-i),y=c,u&&(v=.5*Math.PI)):2&x?(y=i+(r-i)*(a-t)/(n-t),g=a,u&&(v=0)):1&x&&(y=i+(r-i)*(s-t)/(n-t),g=s,u&&(v=Math.PI)),x==p?(p=e._computeOutCode(t=g,i=y,s,o,a,c),u&&(u.x=v)):(m=e._computeOutCode(n=g,r=y,s,o,a,c),u&&(u.y=v))}return f&&(_?(f=2,h&&(h.x=n,h.y=r),l&&(l.x=n,l.y=n),u&&(u.x=u.y+Math.PI)):d?(f=1,h&&(h.x=t,h.y=i),l&&(l.x=t,l.y=i),u&&(u.y=u.x+Math.PI)):(f=3,h&&(h.x=t,h.y=i),l&&(l.x=n,l.y=r))),f},e.segmentIntersectsEllipse=function(t,e,i,n,r,s,o,a,c,h,l){void 0===c&&(c=null),void 0===h&&(h=null),void 0===l&&(l=null);var u=o/a,_=u*u,d=i-t,f=(n*=u)-(e*=u),p=Math.sqrt(d*d+f*f),m=d/p,g=f/p,y=(r-t)*m+(s-e)*g,v=o*o,x=v-(t*t+e*e)+y*y,C=0;if(x>=0){var T=Math.sqrt(x),b=y-T,A=y+T,S=b<0?-1:b<=p?0:1,w=A<0?-1:A<=p?0:1,E=S*w;if(E<0)return-1;0==E&&(-1==S?(C=2,i=t+A*m,n=(e+A*g)/u,c&&(c.x=i,c.y=n),h&&(h.x=i,h.y=n),l&&(l.x=Math.atan2(n/v*_,i/v),l.y=l.x+Math.PI)):1==w?(C=1,t+=b*m,e=(e+b*g)/u,c&&(c.x=t,c.y=e),h&&(h.x=t,h.y=e),l&&(l.x=Math.atan2(e/v*_,t/v),l.y=l.x+Math.PI)):(C=3,c&&(c.x=t+b*m,c.y=(e+b*g)/u,l&&(l.x=Math.atan2(c.y/v*_,c.x/v))),h&&(h.x=t+A*m,h.y=(e+A*g)/u,l&&(l.y=Math.atan2(h.y/v*_,h.x/v)))))}return C},e.segmentIntersectsPolygon=function(t,e,i,n,r,s,o,a){void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null),t==i&&(t=i+.01),e==n&&(e=n+.01);for(var c=r.length,h=t-i,l=e-n,u=t*n-e*i,_=0,d=r[c-2],f=r[c-1],p=0,m=0,g=0,y=0,v=0,x=0,C=0;C<c;C+=2){var T=r[C],b=r[C+1];d==T&&(d=T+.01),f==b&&(f=b+.01);var A=d-T,S=f-b,w=d*b-f*T,E=h*S-l*A,I=(u*A-h*w)/E;if((I>=d&&I<=T||I>=T&&I<=d)&&(0==h||I>=t&&I<=i||I>=i&&I<=t)){var R=(u*S-l*w)/E;if((R>=f&&R<=b||R>=b&&R<=f)&&(0==l||R>=e&&R<=n||R>=n&&R<=e)){if(!o){g=I,y=R,v=I,x=R,_++,a&&(a.x=Math.atan2(b-f,T-d)-.5*Math.PI,a.y=a.x);break}var P=I-t;P<0&&(P=-P),0==_?(p=P,m=P,g=I,y=R,v=I,x=R,a&&(a.x=Math.atan2(b-f,T-d)-.5*Math.PI,a.y=a.x)):(P<p&&(p=P,g=I,y=R,a&&(a.x=Math.atan2(b-f,T-d)-.5*Math.PI)),P>m&&(m=P,v=I,x=R,a&&(a.y=Math.atan2(b-f,T-d)-.5*Math.PI))),_++}}d=T,f=b}return 1==_?(s&&(s.x=g,s.y=y),o&&(o.x=g,o.y=y),a&&(a.y=a.x+Math.PI)):_>1&&(_++,s&&(s.x=g,s.y=y),o&&(o.x=v,o.y=x)),_},e.prototype._onClear=function(){this.type=-1,this.x=0,this.y=0,this.width=0,this.height=0,this.vertices.length=0},e.prototype.containsPoint=function(t,e){var i=!1;if(2==this.type){if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height)for(var n=0,r=this.vertices.length,s=r-2;n<r;n+=2){var o=this.vertices[s+1],a=this.vertices[n+1];if(a<e&&o>=e||o<e&&a>=e){var c=this.vertices[s],h=this.vertices[n];(e-a)*(c-h)/(o-a)+h<t&&(i=!i)}s=n}}else{var l=.5*this.width;if(t>=-l&&t<=l){var u=.5*this.height;e>=-u&&e<=u&&(1==this.type?(e*=l/u,i=Math.sqrt(t*t+e*e)<=l):i=!0)}}return i},e.prototype.intersectsSegment=function(t,i,n,r,s,o,a){void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null);var c=0;switch(this.type){case 0:var h=.5*this.width,l=.5*this.height;c=e.segmentIntersectsRectangle(t,i,n,r,-h,-l,h,l,s,o,a);break;case 1:c=e.segmentIntersectsEllipse(t,i,n,r,0,0,.5*this.width,.5*this.height,s,o,a);break;case 2:0!=e.segmentIntersectsRectangle(t,i,n,r,this.x,this.y,this.width,this.height,null,null)&&(c=e.segmentIntersectsPolygon(t,i,n,r,this.vertices,s,o,a))}return c},e})(t.BaseObject);t.BoundingBoxData=h})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.armatures={},this._armatureNames=[]}return n(e,t),e.toString=function(){return"[class dragonBones.DragonBonesData]"},e.prototype._onClear=function(){for(var t in this.armatures)this.armatures[t].returnToPool(),delete this.armatures[t];this.autoSearch=!1,this.frameRate=0,this.name=null,this._armatureNames.length=0},e.prototype.getArmature=function(t){return this.armatures[t]},e.prototype.addArmature=function(t){if(!t||!t.name||this.armatures[t.name])throw new Error;this.armatures[t.name]=t,this._armatureNames.push(t.name),t.parent=this},Object.defineProperty(e.prototype,"armatureNames",{get:function(){return this._armatureNames},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.returnToPool()},e})(t.BaseObject);t.DragonBonesData=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.data=[]}return n(e,t),e.toString=function(){return"[class dragonBones.ActionData]"},e.prototype._onClear=function(){this.type=-1,this.bone=null,this.slot=null,this.data.length=0},e})(t.BaseObject);t.ActionData=e;var i=(function(t){function e(){t.call(this),this.ints=[],this.floats=[],this.strings=[]}return n(e,t),e.toString=function(){return"[class dragonBones.EventData]"},e.prototype._onClear=function(){this.type=-1,this.name=null,this.ints.length=0,this.floats.length=0,this.strings.length=0,this.bone=null,this.slot=null},e})(t.BaseObject);t.EventData=i;var r=(function(t){function e(){t.call(this)}return n(e,t),e.prototype._onClear=function(){this.position=0,this.duration=0,this.prev=null,this.next=null},e})(t.BaseObject);t.FrameData=r;var s=(function(e){function i(){e.call(this)}return n(i,e),i._getCurvePoint=function(t,e,i,n,r,s,o,a,c,h){var l=1-c,u=l*l,_=c*c,d=l*u,f=3*c*u,p=3*l*_,m=c*_;h.x=d*t+f*i+p*r+m*o,h.y=d*e+f*n+p*s+m*a},i.samplingEasingCurve=function(e,n){for(var r=e.length,s=new t.Point,o=-2,a=0,c=n.length;a<c;++a){for(var h=(a+1)/(c+1);(o+6<r?e[o+6]:1)<h;)o+=6;for(var l=o>=0&&o+6<r,u=l?e[o]:0,_=l?e[o+1]:0,d=e[o+2],f=e[o+3],p=e[o+4],m=e[o+5],g=l?e[o+6]:1,y=l?e[o+7]:1,v=0,x=1;x-v>.01;){var C=(x+v)/2;i._getCurvePoint(u,_,d,f,p,m,g,y,C,s),h-s.x>0?v=C:x=C}n[a]=s.y}},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.tweenEasing=0,this.curve=null},i})(r);t.TweenFrameData=s;var o=(function(t){function e(){t.call(this),this.actions=[],this.events=[]}return n(e,t),e.toString=function(){return"[class dragonBones.AnimationFrameData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this);for(var e=0,i=this.actions.length;e<i;++e)this.actions[e].returnToPool();for(e=0,i=this.events.length;e<i;++e)this.events[e].returnToPool();this.actions.length=0,this.events.length=0},e})(r);t.AnimationFrameData=o;var a=(function(t){function e(){t.call(this),this.zOrder=[]}return n(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.zOrder.length=0},e})(r);t.ZOrderFrameData=a;var c=(function(e){function i(){e.call(this),this.transform=new t.Transform}return n(i,e),i.toString=function(){return"[class dragonBones.BoneFrameData]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.tweenScale=!1,this.tweenRotate=0,this.transform.identity()},i})(s);t.BoneFrameData=c;var h=(function(e){function i(){e.call(this)}return n(i,e),i.generateColor=function(){return new t.ColorTransform},i.toString=function(){return"[class dragonBones.SlotFrameData]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.displayIndex=0,this.color=null},i.DEFAULT_COLOR=new t.ColorTransform,i})(s);t.SlotFrameData=h;var l=(function(t){function e(){t.call(this),this.tweens=[],this.keys=[]}return n(e,t),e.toString=function(){return"[class dragonBones.ExtensionFrameData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=-1,this.tweens.length=0,this.keys.length=0},e})(s);t.ExtensionFrameData=l})(r||(r={}));(function(t){var e=(function(){function e(){this._data=null,this._armature=null,this._skin=null,this._slotDisplayDataSet=null,this._animation=null,this._timeline=null,this._isOldData=!1,this._isGlobalTransform=!1,this._isAutoTween=!1,this._animationTweenEasing=0,this._timelinePivot=new t.Point,this._helpPoint=new t.Point,this._helpTransformA=new t.Transform,this._helpTransformB=new t.Transform,this._helpMatrix=new t.Matrix,this._rawBones=[]}return e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return-1}},e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;default:return-1}},e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return-1}},e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return-1}},e._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"stop":return 1;case"gotoandplay":return 2;case"gotoandstop":return 3;case"fadein":return 4;case"fadeout":return 5;default:return-1}},e.prototype._getTimelineFrameMatrix=function(e,i,n,r){var s=Math.floor(n*e.frameCount/e.duration);if(1==i.frames.length||s>=i.frames.length)r.copyFrom(i.frames[0].transform);else{var o=i.frames[s],a=0;o.tweenEasing!=t.DragonBones.NO_TWEEN?(a=(n-o.position)/o.duration,0!=o.tweenEasing&&(a=t.TweenTimelineState._getEasingValue(a,o.tweenEasing))):o.curve&&(a=(n-o.position)/o.duration,a=t.TweenTimelineState._getEasingCurveValue(a,o.curve));var c=o.next;r.x=c.transform.x-o.transform.x,r.y=c.transform.y-o.transform.y,r.skewX=t.Transform.normalizeRadian(c.transform.skewX-o.transform.skewX),r.skewY=t.Transform.normalizeRadian(c.transform.skewY-o.transform.skewY),r.scaleX=c.transform.scaleX-o.transform.scaleX,r.scaleY=c.transform.scaleY-o.transform.scaleY,r.x=o.transform.x+r.x*a,r.y=o.transform.y+r.y*a,r.skewX=o.transform.skewX+r.skewX*a,r.skewY=o.transform.skewY+r.skewY*a,r.scaleX=o.transform.scaleX+r.scaleX*a,r.scaleY=o.transform.scaleY+r.scaleY*a}r.add(i.originalTransform)},e.prototype._globalToLocal=function(t){for(var e=new Array,i=t.sortedBones.concat().reverse(),n=0,r=i.length;n<r;++n){var s=i[n];s.parent&&(s.parent.transform.toMatrix(this._helpMatrix),this._helpMatrix.invert(),this._helpMatrix.transformPoint(s.transform.x,s.transform.y,this._helpPoint),s.transform.x=this._helpPoint.x,s.transform.y=this._helpPoint.y,s.transform.rotation-=s.parent.transform.rotation);for(var o in t.animations){var a=t.animations[o],c=a.getBoneTimeline(s.name);if(c){var h=s.parent?a.getBoneTimeline(s.parent.name):null;this._helpTransformB.copyFrom(c.originalTransform),e.length=0;for(var l=0,u=c.frames.length;l<u;++l){var _=c.frames[l];e.indexOf(_)>=0||(e.push(_),h?(this._getTimelineFrameMatrix(a,h,_.position,this._helpTransformA),_.transform.add(this._helpTransformB),this._helpTransformA.toMatrix(this._helpMatrix),this._helpMatrix.invert(),this._helpMatrix.transformPoint(_.transform.x,_.transform.y,this._helpPoint),_.transform.x=this._helpPoint.x,_.transform.y=this._helpPoint.y,_.transform.rotation-=this._helpTransformA.rotation):_.transform.add(this._helpTransformB),_.transform.minus(s.transform),0==l?(c.originalTransform.copyFrom(_.transform),_.transform.identity()):_.transform.minus(c.originalTransform))}}}}},e.prototype._mergeFrameToAnimationTimeline=function(e,i,n){var r=Math.floor(e*this._armature.frameRate),s=this._animation.frames;if(0==s.length){var o=t.BaseObject.borrowObject(t.AnimationFrameData);if(o.position=0,this._animation.frameCount>1){s.length=this._animation.frameCount+1;var a=t.BaseObject.borrowObject(t.AnimationFrameData);a.position=this._animation.frameCount/this._armature.frameRate,s[0]=o,s[this._animation.frameCount]=a}}var c=null,h=s[r];if(!h||0!=r&&s[r-1]!=h.prev){(c=t.BaseObject.borrowObject(t.AnimationFrameData)).position=r/this._armature.frameRate,s[r]=c;for(var l=r+1,u=s.length;l<u;++l)h&&s[l]==h&&(s[l]=null)}else c=h;if(i)for(l=0,u=i.length;l<u;++l)c.actions.push(i[l]);if(n)for(l=0,u=n.length;l<u;++l)c.events.push(n[l]);var _=null,d=null;for(l=0,u=s.length;l<u;++l){var f=s[l];f&&d!=f?(d=f,_&&(d.prev=_,_.next=d,_.duration=d.position-_.position),_=d):s[l]=_}d.duration=this._animation.duration-d.position,d=s[0],_.next=d,d.prev=_},e.parseDragonBonesData=function(e){return t.ObjectDataParser.getInstance().parseDragonBonesData(e)},e.parseTextureAtlasData=function(i,n){void 0===n&&(n=1);for(var r={},s=i[e.SUB_TEXTURE],o=0,a=s.length;o<a;o++){var c=s[o],h=c[e.NAME],l=new t.Rectangle,u=null;l.x=c[e.X]/n,l.y=c[e.Y]/n,l.width=c[e.WIDTH]/n,l.height=c[e.HEIGHT]/n,e.FRAME_WIDTH in c&&((u=new t.Rectangle).x=c[e.FRAME_X]/n,u.y=c[e.FRAME_Y]/n,u.width=c[e.FRAME_WIDTH]/n,u.height=c[e.FRAME_HEIGHT]/n),r[h]={region:l,frame:u,rotated:!1}}return r},e.DATA_VERSION_2_3="2.3",e.DATA_VERSION_3_0="3.0",e.DATA_VERSION_4_0="4.0",e.DATA_VERSION="4.5",e.TEXTURE_ATLAS="TextureAtlas",e.SUB_TEXTURE="SubTexture",e.FORMAT="format",e.IMAGE_PATH="imagePath",e.WIDTH="width",e.HEIGHT="height",e.ROTATED="rotated",e.FRAME_X="frameX",e.FRAME_Y="frameY",e.FRAME_WIDTH="frameWidth",e.FRAME_HEIGHT="frameHeight",e.DRADON_BONES="dragonBones",e.ARMATURE="armature",e.BONE="bone",e.IK="ik",e.SLOT="slot",e.SKIN="skin",e.DISPLAY="display",e.ANIMATION="animation",e.Z_ORDER="zOrder",e.FFD="ffd",e.FRAME="frame",e.EVENTS="events",e.ACTIONS="actions",e.INTS="ints",e.FLOATS="floats",e.STRINGS="strings",e.PIVOT="pivot",e.TRANSFORM="transform",e.AABB="aabb",e.COLOR="color",e.FILTER="filter",e.VERSION="version",e.IS_GLOBAL="isGlobal",e.FRAME_RATE="frameRate",e.TYPE="type",e.SUB_TYPE="subType",e.NAME="name",e.PARENT="parent",e.SHARE="share",e.LENGTH="length",e.DATA="data",e.DISPLAY_INDEX="displayIndex",e.BLEND_MODE="blendMode",e.INHERIT_TRANSLATION="inheritTranslation",e.INHERIT_ROTATION="inheritRotation",e.INHERIT_SCALE="inheritScale",e.INHERIT_ANIMATION="inheritAnimation",e.TARGET="target",e.BEND_POSITIVE="bendPositive",e.CHAIN="chain",e.WEIGHT="weight",e.FADE_IN_TIME="fadeInTime",e.PLAY_TIMES="playTimes",e.SCALE="scale",e.OFFSET="offset",e.POSITION="position",e.DURATION="duration",e.TWEEN_EASING="tweenEasing",e.TWEEN_ROTATE="tweenRotate",e.TWEEN_SCALE="tweenScale",e.CURVE="curve",e.GUIDE_CURVE="guideCurve",e.EVENT="event",e.SOUND="sound",e.ACTION="action",e.DEFAULT_ACTIONS="defaultActions",e.X="x",e.Y="y",e.SKEW_X="skX",e.SKEW_Y="skY",e.SCALE_X="scX",e.SCALE_Y="scY",e.ALPHA_OFFSET="aO",e.RED_OFFSET="rO",e.GREEN_OFFSET="gO",e.BLUE_OFFSET="bO",e.ALPHA_MULTIPLIER="aM",e.RED_MULTIPLIER="rM",e.GREEN_MULTIPLIER="gM",e.BLUE_MULTIPLIER="bM",e.UVS="uvs",e.VERTICES="vertices",e.TRIANGLES="triangles",e.WEIGHTS="weights",e.SLOT_POSE="slotPose",e.BONE_POSE="bonePose",e.TWEEN="tween",e.KEY="key",e.COLOR_TRANSFORM="colorTransform",e.TIMELINE="timeline",e.PIVOT_X="pX",e.PIVOT_Y="pY",e.Z="z",e.LOOP="loop",e.AUTO_TWEEN="autoTween",e.HIDE="hide",e})();t.DataParser=e})(r||(r={}));(function(t){var e=(function(e){function i(){e.call(this)}return n(i,e),i._getBoolean=function(t,e,i){if(e in t){var n=t[e],r=typeof n;if("boolean"==r)return n;if("string"!=r)return!!n;switch(n){case"0":case"NaN":case"":case"false":case"null":case"undefined":return!1;default:return!0}}return i},i._getNumber=function(t,e,i){if(e in t){var n=t[e];return null==n||"NaN"==n?i:+n||0}return i},i._getString=function(t,e,i){return e in t?String(t[e]):i},i._getParameter=function(t,e,i){return t.length>e?t[e]:i},i.prototype._parseArmature=function(e,n){var r=t.BaseObject.borrowObject(t.ArmatureData);if(r.name=i._getString(e,i.NAME,null),r.frameRate=i._getNumber(e,i.FRAME_RATE,this._data.frameRate)||this._data.frameRate,r.scale=n,i.TYPE in e&&"string"==typeof e[i.TYPE]?r.type=i._getArmatureType(e[i.TYPE]):r.type=i._getNumber(e,i.TYPE,0),this._armature=r,this._rawBones.length=0,i.AABB in e){var s=e[i.AABB];r.aabb.x=i._getNumber(s,i.X,0),r.aabb.y=i._getNumber(s,i.Y,0),r.aabb.width=i._getNumber(s,i.WIDTH,0),r.aabb.height=i._getNumber(s,i.HEIGHT,0)}if(i.BONE in e)for(var o=e[i.BONE],a=0,c=o.length;a<c;++a){var h=o[a],l=this._parseBone(h);r.addBone(l,i._getString(h,i.PARENT,null)),this._rawBones.push(l)}if(i.IK in e){var u=e[i.IK];for(a=0,c=u.length;a<c;++a)this._parseIK(u[a])}if(i.SLOT in e){var _=e[i.SLOT],d=0;for(a=0,c=_.length;a<c;++a)r.addSlot(this._parseSlot(_[a],d++))}if(i.SKIN in e){var f=e[i.SKIN];for(a=0,c=f.length;a<c;++a)r.addSkin(this._parseSkin(f[a]))}if(i.ANIMATION in e){var p=e[i.ANIMATION];for(a=0,c=p.length;a<c;++a)r.addAnimation(this._parseAnimation(p[a]))}return(i.ACTIONS in e||i.DEFAULT_ACTIONS in e)&&this._parseActionData(e,r.actions,null,null),this._isOldData&&this._isGlobalTransform&&this._globalToLocal(r),this._armature=null,this._rawBones.length=0,r},i.prototype._parseBone=function(e){var n=t.BaseObject.borrowObject(t.BoneData);return n.name=i._getString(e,i.NAME,null),n.inheritTranslation=i._getBoolean(e,i.INHERIT_TRANSLATION,!0),n.inheritRotation=i._getBoolean(e,i.INHERIT_ROTATION,!0),n.inheritScale=i._getBoolean(e,i.INHERIT_SCALE,!0),n.length=i._getNumber(e,i.LENGTH,0)*this._armature.scale,i.TRANSFORM in e&&this._parseTransform(e[i.TRANSFORM],n.transform),this._isOldData&&(n.inheritScale=!1),n},i.prototype._parseIK=function(t){var e=this._armature.getBone(i._getString(t,i.BONE in t?i.BONE:i.NAME,null));e&&(e.ik=this._armature.getBone(i._getString(t,i.TARGET,null)),e.bendPositive=i._getBoolean(t,i.BEND_POSITIVE,!0),e.chain=i._getNumber(t,i.CHAIN,0),e.weight=i._getNumber(t,i.WEIGHT,1),e.chain>0&&e.parent&&!e.parent.ik?(e.parent.ik=e.ik,e.parent.chainIndex=0,e.parent.chain=0,e.chainIndex=1):(e.chain=0,e.chainIndex=0))},i.prototype._parseSlot=function(e,n){var r=t.BaseObject.borrowObject(t.SlotData);return r.name=i._getString(e,i.NAME,null),r.parent=this._armature.getBone(i._getString(e,i.PARENT,null)),r.displayIndex=i._getNumber(e,i.DISPLAY_INDEX,0),r.zOrder=i._getNumber(e,i.Z,n),i.COLOR in e||i.COLOR_TRANSFORM in e?(r.color=t.SlotData.generateColor(),this._parseColorTransform(e[i.COLOR]||e[i.COLOR_TRANSFORM],r.color)):r.color=t.SlotData.DEFAULT_COLOR,i.BLEND_MODE in e&&"string"==typeof e[i.BLEND_MODE]?r.blendMode=i._getBlendMode(e[i.BLEND_MODE]):r.blendMode=i._getNumber(e,i.BLEND_MODE,0),(i.ACTIONS in e||i.DEFAULT_ACTIONS in e)&&this._parseActionData(e,r.actions,null,null),this._isOldData&&(i.COLOR_TRANSFORM in e?(r.color=t.SlotData.generateColor(),this._parseColorTransform(e[i.COLOR_TRANSFORM],r.color)):r.color=t.SlotData.DEFAULT_COLOR),r},i.prototype._parseSkin=function(e){var n=t.BaseObject.borrowObject(t.SkinData);if(n.name=i._getString(e,i.NAME,"__default")||"__default",i.SLOT in e){this._skin=n;for(var r=e[i.SLOT],s=0,o=0,a=r.length;o<a;++o)this._isOldData&&this._armature.addSlot(this._parseSlot(r[o],s++)),n.addSlot(this._parseSlotDisplaySet(r[o]));this._skin=null}return n},i.prototype._parseSlotDisplaySet=function(e){var n=t.BaseObject.borrowObject(t.SlotDisplayDataSet);if(n.slot=this._armature.getSlot(i._getString(e,i.NAME,null)),i.DISPLAY in e){var r=e[i.DISPLAY],s=n.displays;this._slotDisplayDataSet=n;for(var o=0,a=r.length;o<a;++o)s.push(this._parseDisplay(r[o]));this._slotDisplayDataSet=null}return n},i.prototype._parseDisplay=function(e){var n=t.BaseObject.borrowObject(t.DisplayData);if(n.name=i._getString(e,i.NAME,null),n.path=i._getString(e,i.SHARE,n.name),n.inheritAnimation=i._getBoolean(e,i.INHERIT_ANIMATION,!0),i.TYPE in e&&"string"==typeof e[i.TYPE]?n.type=i._getDisplayType(e[i.TYPE]):n.type=i._getNumber(e,i.TYPE,0),n.isRelativePivot=!0,i.PIVOT in e){var r=e[i.PIVOT];n.pivot.x=i._getNumber(r,i.X,0),n.pivot.y=i._getNumber(r,i.Y,0)}else if(this._isOldData){var s=e[i.TRANSFORM];n.isRelativePivot=!1,n.pivot.x=i._getNumber(s,i.PIVOT_X,0)*this._armature.scale,n.pivot.y=i._getNumber(s,i.PIVOT_Y,0)*this._armature.scale}else n.pivot.x=.5,n.pivot.y=.5;switch(i.TRANSFORM in e&&this._parseTransform(e[i.TRANSFORM],n.transform),n.type){case 0:case 1:break;case 2:var o=i._getString(e,i.SHARE,null);if(o)for(var a=0,c=this._slotDisplayDataSet.displays.length;a<c;++a){var h=this._slotDisplayDataSet.displays[a];if(h.name==o){n.share=h,n.mesh=h.mesh;break}}else n.mesh=this._parseMesh(e);break;case 3:n.boundingBox=this._BoundingBox(e)}return n},i.prototype._BoundingBox=function(e){var n=t.BaseObject.borrowObject(t.BoundingBoxData);switch(i.SUB_TYPE in e&&"string"==typeof e[i.SUB_TYPE]?n.type=i._getBoundingBoxType(e[i.SUB_TYPE]):n.type=i._getNumber(e,i.SUB_TYPE,0),n.type){case 0:case 1:n.width=i._getNumber(e,i.WIDTH,0),n.height=i._getNumber(e,i.HEIGHT,0);break;case 2:if(i.VERTICES in e){var r=e[i.VERTICES];n.vertices.length=r.length;for(var s=0,o=r.length;s<o;s+=2){var a=s+1,c=r[s],h=r[a];n.vertices[s]=c,n.vertices[a]=h,0==s?(n.x=c,n.y=h,n.width=c,n.height=h):(c<n.x?n.x=c:c>n.width&&(n.width=c),h<n.y?n.y=h:h>n.height&&(n.height=h))}}}return n},i.prototype._parseMesh=function(e){var n=t.BaseObject.borrowObject(t.MeshData),r=e[i.VERTICES],s=e[i.UVS],o=e[i.TRIANGLES],a=Math.floor(r.length/2),c=Math.floor(o.length/3),h=new Array(this._armature.sortedBones.length);if(n.skinned=i.WEIGHTS in e&&e[i.WEIGHTS].length>0,n.uvs.length=2*a,n.vertices.length=2*a,n.vertexIndices.length=3*c,n.skinned){if(n.boneIndices.length=a,n.weights.length=a,n.boneVertices.length=a,i.SLOT_POSE in e){var l=e[i.SLOT_POSE];n.slotPose.a=l[0],n.slotPose.b=l[1],n.slotPose.c=l[2],n.slotPose.d=l[3],n.slotPose.tx=l[4]*this._armature.scale,n.slotPose.ty=l[5]*this._armature.scale}if(i.BONE_POSE in e)for(var u=e[i.BONE_POSE],_=0,d=u.length;_<d;_+=7){var f=h[E=u[_]]=new t.Matrix;f.a=u[_+1],f.b=u[_+2],f.c=u[_+3],f.d=u[_+4],f.tx=u[_+5]*this._armature.scale,f.ty=u[_+6]*this._armature.scale,f.invert()}}_=0;var p=0;for(d=r.length;_<d;_+=2){var m=_+1,g=_/2,y=n.vertices[_]=r[_]*this._armature.scale,v=n.vertices[m]=r[m]*this._armature.scale;if(n.uvs[_]=s[_],n.uvs[m]=s[m],n.skinned){var x=e[i.WEIGHTS],C=x[p],T=n.boneIndices[g]=new Array(C),b=n.weights[g]=new Array(C),A=n.boneVertices[g]=new Array(2*C);n.slotPose.transformPoint(y,v,this._helpPoint),y=n.vertices[_]=this._helpPoint.x,v=n.vertices[m]=this._helpPoint.y;for(var S=0;S<C;++S){var w=p+1+2*S,E=x[w],I=this._rawBones[E],R=n.bones.indexOf(I);R<0&&(R=n.bones.length,n.bones[R]=I,n.inverseBindPose[R]=h[E]),n.inverseBindPose[R].transformPoint(y,v,this._helpPoint),T[S]=R,b[S]=x[w+1],A[2*S]=this._helpPoint.x,A[2*S+1]=this._helpPoint.y}p+=2*C+1}}for(_=0,d=o.length;_<d;++_)n.vertexIndices[_]=o[_];return n},i.prototype._parseAnimation=function(e){var n=t.BaseObject.borrowObject(t.AnimationData);n.name=i._getString(e,i.NAME,"__default")||"__default",n.frameCount=Math.max(i._getNumber(e,i.DURATION,1),1),n.position=i._getNumber(e,i.POSITION,0)/this._armature.frameRate,n.duration=n.frameCount/this._armature.frameRate,n.playTimes=i._getNumber(e,i.PLAY_TIMES,1),n.fadeInTime=i._getNumber(e,i.FADE_IN_TIME,0),this._animation=n;var r=i._getString(e,i.ANIMATION,null);if(r)return n.animation=this._armature.getAnimation(r),n.animation,n;if(this._parseTimeline(e,n,this._parseAnimationFrame),i.Z_ORDER in e&&(n.zOrderTimeline=t.BaseObject.borrowObject(t.ZOrderTimelineData),this._parseTimeline(e[i.Z_ORDER],n.zOrderTimeline,this._parseZOrderFrame)),i.BONE in e)for(var s=e[i.BONE],o=0,a=s.length;o<a;++o)n.addBoneTimeline(this._parseBoneTimeline(s[o]));if(i.SLOT in e){var c=e[i.SLOT];for(o=0,a=c.length;o<a;++o)n.addSlotTimeline(this._parseSlotTimeline(c[o]))}if(i.FFD in e){var h=e[i.FFD];for(o=0,a=h.length;o<a;++o)n.addFFDTimeline(this._parseFFDTimeline(h[o]))}if(this._isOldData){if(this._isAutoTween=i._getBoolean(e,i.AUTO_TWEEN,!0),this._animationTweenEasing=i._getNumber(e,i.TWEEN_EASING,0)||0,n.playTimes=i._getNumber(e,i.LOOP,1),i.TIMELINE in e){var l=e[i.TIMELINE];for(o=0,a=l.length;o<a;++o){var u=l[o];n.addBoneTimeline(this._parseBoneTimeline(u)),n.addSlotTimeline(this._parseSlotTimeline(u))}}}else this._isAutoTween=!1,this._animationTweenEasing=0;for(var o in this._armature.bones){var _=this._armature.bones[o];if(!n.getBoneTimeline(_.name)){var d=t.BaseObject.borrowObject(t.BoneTimelineData),f=t.BaseObject.borrowObject(t.BoneFrameData);d.bone=_,d.frames[0]=f,n.addBoneTimeline(d)}}for(var o in this._armature.slots){var p=this._armature.slots[o];if(!n.getSlotTimeline(p.name)){var m=t.BaseObject.borrowObject(t.SlotTimelineData),g=t.BaseObject.borrowObject(t.SlotFrameData);m.slot=p,g.displayIndex=p.displayIndex,p.color==t.SlotData.DEFAULT_COLOR?g.color=t.SlotFrameData.DEFAULT_COLOR:(g.color=t.SlotFrameData.generateColor(),g.color.copyFrom(p.color)),m.frames[0]=g,n.addSlotTimeline(m),this._isOldData&&(g.displayIndex=-1)}}return this._animation=null,n},i.prototype._parseBoneTimeline=function(e){var n=t.BaseObject.borrowObject(t.BoneTimelineData);n.bone=this._armature.getBone(i._getString(e,i.NAME,null)),this._parseTimeline(e,n,this._parseBoneFrame);for(var r=n.originalTransform,s=null,o=0,a=n.frames.length;o<a;++o){var c=n.frames[o];s?s!=c&&c.transform.minus(r):(r.copyFrom(c.transform),c.transform.identity(),0==r.scaleX&&(r.scaleX=.001),0==r.scaleY&&(r.scaleY=.001)),s=c}return 1==n.scale&&0==n.offset||(this._animation.hasAsynchronyTimeline=!0),this._isOldData&&(i.PIVOT_X in e||i.PIVOT_Y in e)?(this._timelinePivot.x=i._getNumber(e,i.PIVOT_X,0),this._timelinePivot.y=i._getNumber(e,i.PIVOT_Y,0)):this._timelinePivot.clear(),n},i.prototype._parseSlotTimeline=function(e){var n=t.BaseObject.borrowObject(t.SlotTimelineData);return n.slot=this._armature.getSlot(i._getString(e,i.NAME,null)),this._parseTimeline(e,n,this._parseSlotFrame),1==n.scale&&0==n.offset||(this._animation.hasAsynchronyTimeline=!0),n},i.prototype._parseFFDTimeline=function(e){var n=t.BaseObject.borrowObject(t.FFDTimelineData);n.skin=this._armature.getSkin(i._getString(e,i.SKIN,null)),n.slot=n.skin.getSlot(i._getString(e,i.SLOT,null));for(var r=i._getString(e,i.NAME,null),s=0,o=n.slot.displays.length;s<o;++s){var a=n.slot.displays[s];if(a.mesh&&a.name==r){n.display=a;break}}return this._parseTimeline(e,n,this._parseFFDFrame),n},i.prototype._parseAnimationFrame=function(e,n,r){var s=t.BaseObject.borrowObject(t.AnimationFrameData);return this._parseFrame(e,s,n,r),(i.ACTION in e||i.ACTIONS in e)&&this._parseActionData(e,s.actions,null,null),(i.EVENT in e||i.SOUND in e)&&this._parseEventData(e,s.events,null,null),s},i.prototype._parseZOrderFrame=function(e,n,r){var s=t.BaseObject.borrowObject(t.ZOrderFrameData);this._parseFrame(e,s,n,r);var o=e[i.Z_ORDER];if(o&&o.length>0){var a=this._armature.sortedSlots.length,c=new Array(a-o.length/2);s.zOrder.length=a;for(var h=0;h<a;++h)s.zOrder[h]=-1;for(var l=0,u=0,_=0,d=o.length;_<d;_+=2){for(var f=o[_],p=o[_+1];l!=f;)c[u++]=l++;s.zOrder[l+p]=l++}for(;l<a;)c[u++]=l++;for(var m=a;m--;)-1==s.zOrder[m]&&(s.zOrder[m]=c[--u])}return s},i.prototype._parseBoneFrame=function(e,n,r){var s=t.BaseObject.borrowObject(t.BoneFrameData);if(s.tweenRotate=i._getNumber(e,i.TWEEN_ROTATE,0),s.tweenScale=i._getBoolean(e,i.TWEEN_SCALE,!0),this._parseTweenFrame(e,s,n,r),i.TRANSFORM in e){var o=e[i.TRANSFORM];this._parseTransform(o,s.transform),this._isOldData&&(this._helpPoint.x=this._timelinePivot.x+i._getNumber(o,i.PIVOT_X,0),this._helpPoint.y=this._timelinePivot.y+i._getNumber(o,i.PIVOT_Y,0),s.transform.toMatrix(this._helpMatrix),this._helpMatrix.transformPoint(this._helpPoint.x,this._helpPoint.y,this._helpPoint,!0),s.transform.x+=this._helpPoint.x,s.transform.y+=this._helpPoint.y)}var a=this._timeline.bone,c=new Array,h=new Array;if(i.ACTION in e||i.ACTIONS in e){var l=this._armature.getSlot(a.name);this._parseActionData(e,c,a,l)}return(i.EVENT in e||i.SOUND in e)&&this._parseEventData(e,h,a,null),(c.length>0||h.length>0)&&this._mergeFrameToAnimationTimeline(s.position,c,h),s},i.prototype._parseSlotFrame=function(e,n,r){var s=t.BaseObject.borrowObject(t.SlotFrameData);if(s.displayIndex=i._getNumber(e,i.DISPLAY_INDEX,0),this._parseTweenFrame(e,s,n,r),i.COLOR in e||i.COLOR_TRANSFORM in e?(s.color=t.SlotFrameData.generateColor(),this._parseColorTransform(e[i.COLOR]||e[i.COLOR_TRANSFORM],s.color)):s.color=t.SlotFrameData.DEFAULT_COLOR,this._isOldData)i._getBoolean(e,i.HIDE,!1)&&(s.displayIndex=-1);else if(i.ACTION in e||i.ACTIONS in e){var o=this._timeline.slot,a=new Array;this._parseActionData(e,a,o.parent,o),this._mergeFrameToAnimationTimeline(s.position,a,null)}return s},i.prototype._parseFFDFrame=function(e,n,r){var s=this._timeline.display.mesh,o=t.BaseObject.borrowObject(t.ExtensionFrameData);o.type=i._getNumber(e,i.TYPE,0),this._parseTweenFrame(e,o,n,r);for(var a=e[i.VERTICES],c=i._getNumber(e,i.OFFSET,0),h=0,l=0,u=0,_=s.vertices.length;u<_;u+=2)if(!a||u<c||u-c>=a.length?(h=0,l=0):(h=a[u-c]*this._armature.scale,l=a[u+1-c]*this._armature.scale),s.skinned){s.slotPose.transformPoint(h,l,this._helpPoint,!0),h=this._helpPoint.x,l=this._helpPoint.y;for(var d=s.boneIndices[u/2],f=0,p=d.length;f<p;++f){var m=d[f];s.inverseBindPose[m].transformPoint(h,l,this._helpPoint,!0),o.tweens.push(this._helpPoint.x,this._helpPoint.y)}}else o.tweens.push(h,l);return o},i.prototype._parseTweenFrame=function(e,n,r,s){this._parseFrame(e,n,r,s),n.duration>0?(i.TWEEN_EASING in e?n.tweenEasing=i._getNumber(e,i.TWEEN_EASING,t.DragonBones.NO_TWEEN):this._isOldData?n.tweenEasing=this._isAutoTween?this._animationTweenEasing:t.DragonBones.NO_TWEEN:n.tweenEasing=t.DragonBones.NO_TWEEN,this._isOldData&&1==this._animation.scale&&1==this._timeline.scale&&n.duration*this._armature.frameRate<2&&(n.tweenEasing=t.DragonBones.NO_TWEEN),s>0&&i.CURVE in e&&(n.curve=new Array(2*s-1),t.TweenFrameData.samplingEasingCurve(e[i.CURVE],n.curve))):(n.tweenEasing=t.DragonBones.NO_TWEEN,n.curve=null)},i.prototype._parseFrame=function(t,e,i,n){e.position=i/this._armature.frameRate,e.duration=n/this._armature.frameRate},i.prototype._parseTimeline=function(e,n,r){if(n.scale=i._getNumber(e,i.SCALE,1),n.offset=i._getNumber(e,i.OFFSET,0),i.FRAME in e){this._timeline=n;var s=e[i.FRAME];if(1==s.length)n.frames.length=1,n.frames[0]=r.call(this,s[0],0,i._getNumber(s[0],i.DURATION,1));else if(s.length>1){n.frames.length=this._animation.frameCount+1;for(var o=0,a=0,c=null,h=null,l=0,u=0,_=n.frames.length;l<_;++l){if(o+a<=l&&u<s.length){var d=s[u++];o=l,a=i._getNumber(d,i.DURATION,1),c=r.call(this,d,o,a),h&&(h.next=c,c.prev=h,this._isOldData&&h instanceof t.TweenFrameData&&-1==i._getNumber(d,i.DISPLAY_INDEX,0)&&(h.tweenEasing=t.DragonBones.NO_TWEEN)),h=c}n.frames[l]=c}c.duration=this._animation.duration-c.position,c=n.frames[0],h.next=c,c.prev=h,this._isOldData&&h instanceof t.TweenFrameData&&-1==i._getNumber(s[0],i.DISPLAY_INDEX,0)&&(h.tweenEasing=t.DragonBones.NO_TWEEN)}this._timeline=null}},i.prototype._parseActionData=function(e,n,r,s){var o=e[i.ACTION]||e[i.ACTIONS]||e[i.DEFAULT_ACTIONS];if("string"==typeof o){(u=t.BaseObject.borrowObject(t.ActionData)).type=4,u.bone=r,u.slot=s,u.data[0]=o,u.data[1]=-1,u.data[2]=-1,n.push(u)}else if(o instanceof Array)for(var a=0,c=o.length;a<c;++a){var h=o[a],l=h instanceof Array,u=t.BaseObject.borrowObject(t.ActionData),_=l?i._getParameter(h,1,null):i._getString(h,"gotoAndPlay",null);if(l){var d=h[0];u.type="string"==typeof d?i._getActionType(d):i._getParameter(h,0,4)}else u.type=2;switch(u.type){case 0:u.data[0]=_,u.data[1]=l?i._getParameter(h,2,-1):-1;break;case 1:u.data[0]=_;break;case 2:u.data[0]=_,u.data[1]=l?i._getParameter(h,2,0):0,u.data[2]=l?i._getParameter(h,3,-1):-1;break;case 3:u.data[0]=_,u.data[1]=l?i._getParameter(h,2,0):0;break;case 4:u.data[0]=_,u.data[1]=l?i._getParameter(h,2,-1):-1,u.data[2]=l?i._getParameter(h,3,-1):-1;break;case 5:u.data[0]=_,u.data[1]=l?i._getParameter(h,2,0):0}u.bone=r,u.slot=s,n.push(u)}},i.prototype._parseEventData=function(e,n,r,s){if(i.SOUND in e){var o=t.BaseObject.borrowObject(t.EventData);o.type=11,o.name=i._getString(e,i.SOUND,null),o.bone=r,o.slot=s,n.push(o)}if(i.EVENT in e){(l=t.BaseObject.borrowObject(t.EventData)).type=10,l.name=i._getString(e,i.EVENT,null),l.bone=r,l.slot=s,n.push(l)}if(i.EVENTS in e)for(var a=e[i.EVENTS],c=0,h=a.length;c<h;++c){var l,u=a[c],_=i._getString(u,i.BONE,null);if((l=t.BaseObject.borrowObject(t.EventData)).type=10,l.name=i._getString(u,i.NAME,null),l.bone=this._armature.getBone(_),i.INTS in u)for(var d=u[i.INTS],f=0,p=d.length;f<p;++f)l.ints.push(i._getParameter(d,f,0));if(i.FLOATS in u)for(var m=u[i.FLOATS],g=0,y=m.length;g<y;++g)l.floats.push(i._getParameter(m,g,0));if(i.STRINGS in u)for(var v=u[i.STRINGS],x=0,C=v.length;x<C;++x)l.strings.push(i._getParameter(v,x,null));n.push(l)}},i.prototype._parseTransform=function(e,n){n.x=i._getNumber(e,i.X,0)*this._armature.scale,n.y=i._getNumber(e,i.Y,0)*this._armature.scale,n.skewX=i._getNumber(e,i.SKEW_X,0)*t.DragonBones.ANGLE_TO_RADIAN,n.skewY=i._getNumber(e,i.SKEW_Y,0)*t.DragonBones.ANGLE_TO_RADIAN,n.scaleX=i._getNumber(e,i.SCALE_X,1),n.scaleY=i._getNumber(e,i.SCALE_Y,1)},i.prototype._parseColorTransform=function(t,e){e.alphaMultiplier=.01*i._getNumber(t,i.ALPHA_MULTIPLIER,100),e.redMultiplier=.01*i._getNumber(t,i.RED_MULTIPLIER,100),e.greenMultiplier=.01*i._getNumber(t,i.GREEN_MULTIPLIER,100),e.blueMultiplier=.01*i._getNumber(t,i.BLUE_MULTIPLIER,100),e.alphaOffset=i._getNumber(t,i.ALPHA_OFFSET,0),e.redOffset=i._getNumber(t,i.RED_OFFSET,0),e.greenOffset=i._getNumber(t,i.GREEN_OFFSET,0),e.blueOffset=i._getNumber(t,i.BLUE_OFFSET,0)},i.prototype.parseDragonBonesData=function(e,n){if(void 0===n&&(n=1),e){var r=i._getString(e,i.VERSION,null);if(this._isOldData=r==i.DATA_VERSION_2_3||r==i.DATA_VERSION_3_0,this._isOldData?this._isGlobalTransform=i._getBoolean(e,i.IS_GLOBAL,!0):this._isGlobalTransform=!1,r==i.DATA_VERSION||r==i.DATA_VERSION_4_0||this._isOldData){var s=t.BaseObject.borrowObject(t.DragonBonesData);if(s.name=i._getString(e,i.NAME,null),s.frameRate=i._getNumber(e,i.FRAME_RATE,24)||24,i.ARMATURE in e){this._data=s;for(var o=e[i.ARMATURE],a=0,c=o.length;a<c;++a)s.addArmature(this._parseArmature(o[a],n));this._data=null}return s}throw new Error("Nonsupport data version.")}throw new Error("No data.")},i.prototype.parseTextureAtlasData=function(e,n,r){if(void 0===r&&(r=0),!e)throw new Error("No data.");if(n.name=i._getString(e,i.NAME,null),n.imagePath=i._getString(e,i.IMAGE_PATH,null),r>0?n.scale=r:r=n.scale=i._getNumber(e,i.SCALE,n.scale),r=1/r,i.SUB_TEXTURE in e)for(var s=e[i.SUB_TEXTURE],o=0,a=s.length;o<a;++o){var c=s[o],h=n.generateTextureData();h.name=i._getString(c,i.NAME,null),h.rotated=i._getBoolean(c,i.ROTATED,!1),h.region.x=i._getNumber(c,i.X,0)*r,h.region.y=i._getNumber(c,i.Y,0)*r,h.region.width=i._getNumber(c,i.WIDTH,0)*r,h.region.height=i._getNumber(c,i.HEIGHT,0)*r;var l=i._getNumber(c,i.FRAME_WIDTH,-1),u=i._getNumber(c,i.FRAME_HEIGHT,-1);l>0&&u>0&&(h.frame=t.TextureData.generateRectangle(),h.frame.x=i._getNumber(c,i.FRAME_X,0)*r,h.frame.y=i._getNumber(c,i.FRAME_Y,0)*r,h.frame.width=l*r,h.frame.height=u*r),n.addTexture(h)}},i.getInstance=function(){return i._instance||(i._instance=new i),i._instance},i._instance=null,i})(t.DataParser);t.ObjectDataParser=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.textures={}}return n(e,t),e.prototype._onClear=function(){for(var t in this.textures)this.textures[t].returnToPool(),delete this.textures[t];this.autoSearch=!1,this.scale=1,this.name=null,this.imagePath=null},e.prototype.addTexture=function(t){if(!t||!t.name||this.textures[t.name])throw new Error;this.textures[t.name]=t,t.parent=this},e.prototype.getTexture=function(t){return this.textures[t]},e})(t.BaseObject);t.TextureAtlasData=e;var i=(function(e){function i(){e.call(this),this.region=new t.Rectangle}return n(i,e),i.generateRectangle=function(){return new t.Rectangle},i.prototype._onClear=function(){this.rotated=!1,this.name=null,this.frame=null,this.parent=null,this.region.clear()},i})(t.BaseObject);t.TextureData=i})(r||(r={}));var r;(function(t){var e=(function(){function e(i){void 0===i&&(i=null),this.autoSearch=!1,this._dataParser=null,this._dragonBonesDataMap={},this._textureAtlasDataMap={},this._dataParser=i,this._dataParser||(e._defaultParser||(e._defaultParser=new t.ObjectDataParser),this._dataParser=e._defaultParser)}return e.prototype._getTextureData=function(t,e){var i=this._textureAtlasDataMap[t];if(i)for(var n=0,r=i.length;n<r;++n){if(c=i[n].getTexture(e))return c}if(this.autoSearch)for(var n in this._textureAtlasDataMap)for(var s=0,o=(i=this._textureAtlasDataMap[n]).length;s<o;++s){var a=i[s];if(a.autoSearch){var c;if(c=a.getTexture(e))return c}}return null},e.prototype._fillBuildArmaturePackage=function(t,e,i,n,r){var s=null,o=null;if(e&&(s=this._dragonBonesDataMap[e])&&(o=s.getArmature(i)),!o&&(!e||this.autoSearch))for(var a in this._dragonBonesDataMap)if(s=this._dragonBonesDataMap[a],(!e||s.autoSearch)&&(o=s.getArmature(i))){e=a;break}return!!o&&(t.dataName=e,t.textureAtlasName=r,t.data=s,t.armature=o,t.skin=o.getSkin(n),t.skin||(t.skin=o.defaultSkin),!0)},e.prototype._buildBones=function(e,i){for(var n=e.armature.sortedBones,r=0,s=n.length;r<s;++r){var o=n[r],a=t.BaseObject.borrowObject(t.Bone);a.name=o.name,a.inheritTranslation=o.inheritTranslation,a.inheritRotation=o.inheritRotation,a.inheritScale=o.inheritScale,a.length=o.length,a.origin.copyFrom(o.transform),o.parent?i.addBone(a,o.parent.name):i.addBone(a),o.ik&&(a.ikBendPositive=o.bendPositive,a.ikWeight=o.weight,a._setIK(i.getBone(o.ik.name),o.chain,o.chainIndex))}},e.prototype._buildSlots=function(t,e){var i=t.skin,n=t.armature.defaultSkin,r={};for(var s in n.slots){r[(c=n.slots[s]).slot.name]=c}if(i!=n)for(var s in i.slots){r[(c=i.slots[s]).slot.name]=c}for(var o=t.armature.sortedSlots,a=(s=0,o.length);s<a;++s){var c,h=o[s];if(c=r[h.name]){var l=this._generateSlot(t,c,e);l&&(l._displayDataSet=c,l._setDisplayIndex(h.displayIndex),l._setBlendMode(h.blendMode),l._setColor(h.color),e.addSlot(l,h.parent.name))}}},e.prototype._replaceSlotDisplay=function(t,e,i,n){if(n<0&&(n=i.displayIndex),n>=0){var r=i.displayList;if(r.length<=n&&(r.length=n+1),i._replacedDisplayDataSet.length<=n&&(i._replacedDisplayDataSet.length=n+1),i._replacedDisplayDataSet[n]=e,1==e.type){var s=this.buildArmature(e.path,t.dataName,null,t.textureAtlasName);r[n]=s}else e.texture&&!t.textureAtlasName||(e.texture=this._getTextureData(t.textureAtlasName||t.dataName,e.path)),e.mesh||n<i._displayDataSet.displays.length&&i._displayDataSet.displays[n].mesh?r[n]=i.meshDisplay:r[n]=i.rawDisplay;i.displayList=r,i.invalidUpdate()}},e.prototype.parseDragonBonesData=function(t,e,i){void 0===e&&(e=null),void 0===i&&(i=1);var n=this._dataParser.parseDragonBonesData(t,i);return this.addDragonBonesData(n,e),n},e.prototype.parseTextureAtlasData=function(t,e,i,n){void 0===i&&(i=null),void 0===n&&(n=0);var r=this._generateTextureAtlasData(null,null);return this._dataParser.parseTextureAtlasData(t,r,n),this._generateTextureAtlasData(r,e),this.addTextureAtlasData(r,i),r},e.prototype.getDragonBonesData=function(t){return this._dragonBonesDataMap[t]},e.prototype.addDragonBonesData=function(t,e){if(void 0===e&&(e=null),!t)throw new Error;(e=e||t.name)?this._dragonBonesDataMap[e]?console.warn("Same name data.",e):this._dragonBonesDataMap[e]=t:console.warn("Unnamed data.")},e.prototype.removeDragonBonesData=function(e,i){void 0===i&&(i=!0);var n=this._dragonBonesDataMap[e];if(n){if(i){if(t.DragonBones.debug)for(var r=0,s=t.DragonBones._armatures.length;r<s;++r){var o=t.DragonBones._armatures[r];if(o.armatureData.parent==n)throw new Error("ArmatureData: "+o.armatureData.name+" DragonBonesData: "+e)}n.returnToPool()}delete this._dragonBonesDataMap[e]}},e.prototype.getTextureAtlasData=function(t){return this._textureAtlasDataMap[t]},e.prototype.addTextureAtlasData=function(t,e){if(void 0===e&&(e=null),!t)throw new Error;if(e=e||t.name){var i=this._textureAtlasDataMap[e]=this._textureAtlasDataMap[e]||[];i.indexOf(t)<0&&i.push(t)}else console.warn("Unnamed data.")},e.prototype.removeTextureAtlasData=function(t,e){void 0===e&&(e=!0);var i=this._textureAtlasDataMap[t];if(i){if(e)for(var n=0,r=i.length;n<r;++n)i[n].returnToPool();delete this._textureAtlasDataMap[t]}},e.prototype.clear=function(t){void 0===t&&(t=!0);for(var e in this._dragonBonesDataMap)t&&this._dragonBonesDataMap[e].returnToPool(),delete this._dragonBonesDataMap[e];for(var e in this._textureAtlasDataMap){if(t)for(var i=this._textureAtlasDataMap[e],n=0,r=i.length;n<r;++n)i[n].returnToPool();delete this._textureAtlasDataMap[e]}},e.prototype.buildArmature=function(t,e,i,n){void 0===e&&(e=null),void 0===i&&(i=null),void 0===n&&(n=null);var r={};if(this._fillBuildArmaturePackage(r,e,t,i,n)){var s=this._generateArmature(r);return this._buildBones(r,s),this._buildSlots(r,s),s.advanceTime(0),s}return console.warn("No armature data.",t,e||""),null},e.prototype.copyAnimationsToArmature=function(e,i,n,r,s){void 0===n&&(n=null),void 0===r&&(r=null),void 0===s&&(s=!0);var o={};if(this._fillBuildArmaturePackage(o,r,i,n,null)){var a=o.armature;if(s)e.animation.animations=a.animations;else{var c={};for(var h in e.animation.animations)c[h]=e.animation.animations[h];for(var h in a.animations)c[h]=a.animations[h];e.animation.animations=c}if(o.skin){for(var l=e.getSlots(),u=0,_=l.length;u<_;++u)for(var d=l[u],f=d.displayList,p=0,m=f.length;p<m;++p){var g=f[p];if(g instanceof t.Armature){var y=o.skin.getSlot(d.name).displays;if(p<y.length){var v=y[p];1==v.type&&this.copyAnimationsToArmature(g,v.path,n,r,s)}}}return!0}}return!1},e.prototype.replaceSlotDisplay=function(t,e,i,n,r,s){void 0===s&&(s=-1);var o={};if(this._fillBuildArmaturePackage(o,t,e,null,null)){var a=o.skin.getSlot(i);if(a)for(var c=0,h=a.displays.length;c<h;++c){var l=a.displays[c];if(l.path==n){this._replaceSlotDisplay(o,l,r,s);break}}}},e.prototype.replaceSlotDisplayList=function(t,e,i,n){var r={};if(this._fillBuildArmaturePackage(r,t,e,null,null)){var s=r.skin.getSlot(i);if(s)for(var o=0,a=0,c=s.displays.length;a<c;++a){var h=s.displays[a];this._replaceSlotDisplay(r,h,n,o++)}}},e.prototype.getAllDragonBonesData=function(){return this._dragonBonesDataMap},e.prototype.getAllTextureAtlasData=function(){return this._textureAtlasDataMap},e._defaultParser=null,e})();t.BaseFactory=e})(r||(r={})),e.exports=r}),{}],301:[(function(t,e,i){var n=sp.spine;sp._SGSkeleton=_ccsg.Node.extend({_skeleton:null,_rootBone:null,_timeScale:1,_debugSlots:!1,_debugBones:!1,_premultipliedAlpha:!1,_ownsSkeletonData:null,_atlas:null,ctor:function(t,e,i){_ccsg.Node.prototype.ctor.call(this),0===arguments.length?this.init():this.initWithArgs(t,e,i)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new sp._SGSkeleton.CanvasRenderCmd(this):new sp._SGSkeleton.WebGLRenderCmd(this)},init:function(){_ccsg.Node.prototype.init.call(this),this._premultipliedAlpha=cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA,this.scheduleUpdate()},setDebugSlotsEnabled:function(t){this._debugSlots=t},getDebugSlotsEnabled:function(){return this._debugSlots},setDebugBonesEnabled:function(t){this._debugBones=t},getDebugBonesEnabled:function(){return this._debugBones},setTimeScale:function(t){this._timeScale=t},getTimeScale:function(){return this._timeScale},initWithArgs:function(t,e,i){var r,s,o,a=t,c=e;if(cc.js.isString(a)){if(cc.js.isString(c)){var h=cc.loader.getRes(c);sp._atlasLoader.setAtlasFile(c),s=new n.TextureAtlas(h,sp._atlasLoader.load.bind(sp._atlasLoader))}else s=e;i=i||1/cc.director.getContentScaleFactor();var l=new n.AtlasAttachmentLoader(s),u=new n.SkeletonJson(l);u.scale=i;var _=cc.loader.getRes(a);r=u.readSkeletonData(_),s.dispose(u),o=!0}else r=t,o=e;this.setSkeletonData(r,o),this.init()},getBoundingBox:function(){for(var t,e=cc.macro.FLT_MAX,i=cc.macro.FLT_MAX,r=cc.macro.FLT_MIN,s=cc.macro.FLT_MIN,o=this.getScaleX(),a=this.getScaleY(),c=this._skeleton.slots,h=n.RegionAttachment,l=0,u=c.length;l<u;++l){var _=c[l],d=_.attachment;d&&d instanceof n.RegionAttachment&&(t=d.updateWorldVertices(_,!1),e=Math.min(e,t[h.X1]*o,t[h.X4]*o,t[h.X2]*o,t[h.X3]*o),i=Math.min(i,t[h.Y1]*a,t[h.Y4]*a,t[h.Y2]*a,t[h.Y3]*a),r=Math.max(r,t[h.X1]*o,t[h.X4]*o,t[h.X2]*o,t[h.X3]*o),s=Math.max(s,t[h.Y1]*a,t[h.Y4]*a,t[h.Y2]*a,t[h.Y3]*a))}var f=this.getPosition();return cc.rect(f.x+e,f.y+i,r-e,s-i)},updateWorldTransform:function(){this._skeleton.updateWorldTransform()},setToSetupPose:function(){this._skeleton.setToSetupPose()},setBonesToSetupPose:function(){this._skeleton.setBonesToSetupPose()},setSlotsToSetupPose:function(){this._skeleton.setSlotsToSetupPose()},findBone:function(t){return this._skeleton.findBone(t)},findSlot:function(t){return this._skeleton.findSlot(t)},setSkin:function(t){return this._skeleton.setSkinByName(t)},getAttachment:function(t,e){return this._skeleton.getAttachmentByName(t,e)},setAttachment:function(t,e){this._skeleton.setAttachment(t,e)},setPremultipliedAlpha:function(t){this._premultipliedAlpha=t},isPremultipliedAlpha:function(){return this._premultipliedAlpha},setSkeletonData:function(t,e){null!=t.width&&null!=t.height&&this.setContentSize(t.width/cc.director.getContentScaleFactor(),t.height/cc.director.getContentScaleFactor()),this._skeleton=new n.Skeleton(t),this._skeleton.updateWorldTransform(),this._rootBone=this._skeleton.getRootBone(),this._ownsSkeletonData=e,this._renderCmd._createChildFormSkeletonData()},getTextureAtlas:function(t){return t.region},getBlendFunc:function(){var t=this._skeleton.drawOrder[0];if(t){return this._renderCmd._getBlendFunc(t.data.blendMode,this._premultipliedAlpha)}return{}},setBlendFunc:function(t,e){},update:function(t){this._skeleton.update(t)}});var r=sp._SGSkeleton.prototype;Object.defineProperty(r,"opacityModifyRGB",{get:r.isOpacityModifyRGB}),Object.defineProperty(r,"_blendFunc",{get:r.getBlendFunc}),Object.defineProperty(r,"_texture",{get:function(){return this._renderCmd._currTexture}})}),{}],302:[(function(t,e,i){var n=sp.spine,r=sp.AnimationEventType;sp._atlasLoader={spAtlasFile:null,setAtlasFile:function(t){this.spAtlasFile=t},load:function(t){var e=cc.path.join(cc.path.dirname(this.spAtlasFile),t),i=cc.textureCache.addImage(e),n=new sp.SkeletonTexture({width:i.getPixelWidth(),height:i.getPixelHeight()});return n.setRealTexture(i),n},unload:function(t){}},sp.TrackEntryListeners=function(t,e,i,n,r,s){this.startListener=t||null,this.endListener=e||null,this.completeListener=i||null,this.eventListener=n||null,this.interruptListener=r||null,this.disposeListener=s||null,this.callback=null,this.callbackTarget=null,this.skeletonNode=null};var s=sp.TrackEntryListeners.prototype;s.start=function(t){this.startListener&&this.startListener(t),this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,t,r.START,null,0)},s.interrupt=function(t){this.interruptListener&&this.interruptListener(t),this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,t,r.INTERRUPT,null,0)},s.end=function(t){this.endListener&&this.endListener(t),this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,t,r.END,null,0)},s.dispose=function(t){this.disposeListener&&this.disposeListener(t),this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,t,r.DISPOSE,null,0)},s.complete=function(t){var e=Math.floor(t.trackTime/t.animationEnd);this.completeListener&&this.completeListener(t,e),this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,t,r.COMPLETE,null,e)},s.event=function(t,e){this.eventListener&&this.eventListener(t,e),this.callback&&this.callback.call(this.callbackTarget,this.skeletonNode,t,r.EVENT,e,0)},sp.TrackEntryListeners.getListeners=function(t){return t.listener||(t.listener=new sp.TrackEntryListeners),t.listener},sp._SGSkeletonAnimation=sp._SGSkeleton.extend({_state:null,_ownsAnimationStateData:!1,_listener:null,init:function(){sp._SGSkeleton.prototype.init.call(this),this._ownsAnimationStateData=!0,this.setAnimationStateData(new n.AnimationStateData(this._skeleton.data))},setAnimationStateData:function(t){var e=new n.AnimationState(t);this._listener=new sp.TrackEntryListeners,e.rendererObject=this,e.addListener(this._listener),this._state=e},setMix:function(t,e,i){this._state.data.setMixWith(t,e,i)},setAnimationListener:function(t,e){this._listener.callbackTarget=t,this._listener.callback=e,this._listener.skeletonNode=this},setAnimation:function(t,e,i){var n=this._skeleton.data.findAnimation(e);return n?this._state.setAnimationWith(t,n,i):(cc.logID(7509,e),null)},addAnimation:function(t,e,i,n){n=null==n?0:n;var r=this._skeleton.data.findAnimation(e);return r?this._state.addAnimationWith(t,r,i,n):(cc.logID(7510,e),null)},findAnimation:function(t){return this._skeleton.data.findAnimation(t)},getCurrent:function(t){return this._state.getCurrent(t)},clearTracks:function(){this._state.clearTracks()},clearTrack:function(t){this._state.clearTrack(t)},update:function(t){this._super(t),t*=this._timeScale,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty),this._state.update(t),this._state.apply(this._skeleton),this._skeleton.updateWorldTransform(),this._renderCmd._updateChild()},setStartListener:function(t){this._listener.startListener=t},setInterruptListener:function(t){this._listener.interruptListener=t},setEndListener:function(t){this._listener.endListener=t},setDisposeListener:function(t){this._listener.disposeListener=t},setCompleteListener:function(t){this._listener.completeListener=t},setEventListener:function(t){this._listener.eventListener=t},setTrackStartListener:function(t,e){sp.TrackEntryListeners.getListeners(t).startListener=e},setTrackInterruptListener:function(t,e){sp.TrackEntryListeners.getListeners(t).interruptListener=e},setTrackEndListener:function(t,e){sp.TrackEntryListeners.getListeners(t).endListener=e},setTrackDisposeListener:function(t,e){sp.TrackEntryListeners.getListeners(t).disposeListener=e},setTrackCompleteListener:function(t,e){sp.TrackEntryListeners.getListeners(t).completeListener=e},setTrackEventListener:function(t,e){sp.TrackEntryListeners.getListeners(t).eventListener=e},getState:function(){return this._state}})}),{}],303:[(function(t,e,i){t("../../cocos2d/core/CCDrawingPrimitives");var n=sp.spine;sp._SGSkeleton.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0};var r=sp._SGSkeleton.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);r.constructor=sp._SGSkeleton.CanvasRenderCmd,r.rendering=function(t,e,i){var r,s,o,a,c=this._node;t=t||cc._renderContext;var h=c._skeleton,l=h.drawOrder;for(r=0,s=l.length;r<s;r++)(a=(o=l[r])._slotNode)._visible&&a._renderCmd&&o.currentSprite&&(a._renderCmd.transform(this,!0),o.currentSprite._renderCmd.rendering(t,e,i),a._renderCmd._dirtyFlag=o.currentSprite._renderCmd._dirtyFlag=0);if(c._debugSlots||c._debugBones){t.setTransform(this._worldTransform,e,i),t.setGlobalAlpha(1);var u,_=cc._drawingUtil;if(c._debugSlots){_.setDrawColor(0,0,255,255),_.setLineWidth(1);var d=[];for(r=0,s=h.slots.length;r<s;r++)(o=h.drawOrder[r]).attachment&&o.attachment instanceof n.RegionAttachment&&(u=o.attachment,this._updateRegionAttachmentSlot(u,o,d),_.drawPoly(d,4,!0))}if(c._debugBones){var f;for(_.setLineWidth(2),_.setDrawColor(255,0,0,255),r=0,s=h.bones.length;r<s;r++){var p=(f=h.bones[r]).data.length*f.a+f.worldX,m=f.data.length*f.c+f.worldY;_.drawLine({x:f.worldX,y:f.worldY},{x:p,y:m})}for(_.setPointSize(4),_.setDrawColor(0,0,255,255),r=0,s=h.bones.length;r<s;r++)f=h.bones[r],_.drawPoint({x:f.worldX,y:f.worldY}),0===r&&_.setDrawColor(0,255,0,255)}}},r.updateStatus=function(){this.originUpdateStatus(),this._updateCurrentRegions(),this._regionFlag=_ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble,this._dirtyFlag&=~_ccsg.Node._dirtyFlags.contentDirty},r.getLocalBB=function(){return this._node.getBoundingBox()},r._updateRegionAttachmentSlot=function(t,e,i){if(i){var r=t.updateWorldVertices(e,!1),s=n.RegionAttachment;i.length=0,i.push(cc.p(r[s.X1],r[s.Y1])),i.push(cc.p(r[s.X4],r[s.Y4])),i.push(cc.p(r[s.X3],r[s.Y3])),i.push(cc.p(r[s.X2],r[s.Y2]))}},r._createChildFormSkeletonData=function(){for(var t,e,i=this._node._skeleton,r=0,s=i.slots.length;r<s;r++){var o=i.slots[r],a=o.attachment,c=new _ccsg.Node;o._slotNode=c,a instanceof n.RegionAttachment?(t=a.region.name,e=this._createSprite(o,a),o.currentSprite=e,o.currentSpriteName=t,c.addChild(e)):n.MeshAttachment}},r._createSprite=function(t,e){var i=e.region,n=i.texture.getRealTexture(),r=new cc.Rect(i.x,i.y,i.width,i.height),s=new _ccsg.Sprite;return s.initWithTexture(n,r,i.rotate,!1),s._rect.width=e.width,s._rect.height=e.height,s.setContentSize(e.width,e.height),s.setRotation(-e.rotation),s.setScale(i.width/i.originalWidth*e.scaleX,i.height/i.originalHeight*e.scaleY),t.sprites=t.sprites||{},t.sprites[i.name]=s,s},r._updateChild=function(){var t,e,i,r,s,o,a,c,h=this._node._skeleton.slots,l=this._displayedColor,u=this._displayedOpacity;for(t=0,e=h.length;t<e;t++)if(o=h[t],a=o.attachment,c=o._slotNode,a){if(a instanceof n.RegionAttachment){if(a.region&&(!o.currentSpriteName||o.currentSpriteName!==a.name)){var _=a.region.name;if(void 0!==o.currentSprite&&o.currentSprite.setVisible(!1),o.sprites=o.sprites||{},void 0!==o.sprites[_])o.sprites[_].setVisible(!0);else{var d=this._createSprite(o,a);c.addChild(d)}o.currentSprite=o.sprites[_],o.currentSpriteName=_}var f=o.bone;0===a.region.offsetX&&0===a.region.offsetY?(r=a.x,s=a.y):(r=.5*(a.offset[0]+a.offset[4]),s=.5*(a.offset[1]+a.offset[5])),c.setPosition(f.worldX+r*f.a+s*f.b,f.worldY+r*f.c+s*f.d),c.setScale(f.getWorldScaleX(),f.getWorldScaleY()),(i=o.currentSprite)._flippedX=f.skeleton.flipX,i._flippedY=f.skeleton.flipY,i._flippedY||i._flippedX?(c.setRotation(f.getWorldRotationX()),i.setRotation(a.rotation)):(c.setRotation(-f.getWorldRotationX()),i.setRotation(-a.rotation)),i._renderCmd._displayedOpacity=0|u*o.color.a;var p=0|l.r*o.color.r,m=0|l.g*o.color.g,g=0|l.b*o.color.b;i.setColor(cc.color(p,m,g)),i._renderCmd._updateColor()}else if(!(a instanceof n.MeshAttachment)){c.setVisible(!1);continue}c.setVisible(!0)}else c.setVisible(!1)}}),{"../../cocos2d/core/CCDrawingPrimitives":36}],304:[(function(t,e,i){sp.SkeletonTexture=cc.Class({name:"sp.SkeletonTexture",extends:sp.spine.Texture,_texture:null,setRealTexture:function(t){this._texture=t},getRealTexture:function(){return this._texture},setFilters:function(t,e){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var i=cc._renderContext;this.bind(),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e)}},setWraps:function(t,e){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var i=cc._renderContext;this.bind(),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e)}},dispose:function(){},bind:function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.gl.bindTexture2DN(0,this._texture)}})}),{}],305:[(function(t,e,i){t("../../cocos2d/core/CCDrawingPrimitives");var n=sp.spine;sp._SGSkeleton.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._matrix=new cc.math.Matrix4,this._matrix.identity(),this._currTexture=null,this._currBlendFunc={},this.vertexType=cc.renderer.VertexType.CUSTOM,this.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR))};var r=sp._SGSkeleton.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);r.constructor=sp._SGSkeleton.WebGLRenderCmd,r.uploadData=function(t,e,i){var r,s,o,a,c=this._node,h=this._displayedColor,l=c._skeleton,u=c._premultipliedAlpha;l.r=h.r/255,l.g=h.g/255,l.b=h.b/255,l.a=this._displayedOpacity/255,u&&(l.r*=l.a,l.g*=l.a,l.b*=l.a);var _=null;for(this._node._debugSlots&&(_=[]),o=0,a=l.drawOrder.length;o<a;o++)if((s=l.drawOrder[o]).attachment){var d=0;if((r=s.attachment)instanceof n.RegionAttachment)d=6;else{if(!(r instanceof n.MeshAttachment))continue;d=r.regionUVs.length/2}if(0!==d){var f=c.getTextureAtlas(r);this._currTexture=f.texture.getRealTexture();var p=cc.renderer._updateBatchedInfo(this._currTexture,this._getBlendFunc(s.data.blendMode,u),this._shaderProgram);!p&&i+6*d>t.length&&(cc.renderer._batchRendering(),p=!0),p&&(i=0);var m=null;if(r instanceof n.RegionAttachment)m=this._uploadRegionAttachmentData(r,s,u,t,e,i);else{if(!(r instanceof n.MeshAttachment))continue;this._uploadMeshAttachmentData(r,s,u,t,e,i)}this._node._debugSlots&&(_[o]=m),r instanceof n.RegionAttachment?cc.renderer._increaseBatchingSize(d,cc.renderer.VertexType.TRIANGLE):cc.renderer._increaseBatchingSize(d,cc.renderer.VertexType.CUSTOM,r.triangles),i+=6*d}}if(c._debugBones||c._debugSlots){cc.renderer._batchRendering();var g=this._worldTransform,y=this._matrix.mat;y[0]=g.a,y[4]=g.c,y[12]=g.tx,y[1]=g.b,y[5]=g.d,y[13]=g.ty,cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW),cc.current_stack.stack.push(cc.current_stack.top),cc.current_stack.top=this._matrix;var v=cc._drawingUtil;if(c._debugSlots&&_&&_.length>0)for(v.setDrawColor(0,0,255,255),v.setLineWidth(1),o=0,a=l.slots.length;o<a;o++){var x=_[o];x&&v.drawPoly(x,4,!0)}if(c._debugBones){var C;for(v.setLineWidth(2),v.setDrawColor(255,0,0,255),o=0,a=l.bones.length;o<a;o++){var T=(C=l.bones[o]).data.length*C.a+C.worldX,b=C.data.length*C.c+C.worldY;v.drawLine(cc.p(C.worldX,C.worldY),cc.p(T,b))}for(v.setPointSize(4),v.setDrawColor(0,0,255,255),o=0,a=l.bones.length;o<a;o++)C=l.bones[o],v.drawPoint(cc.p(C.worldX,C.worldY)),0==o&&v.setDrawColor(0,255,0,255)}cc.math.glPopMatrix()}return 0},r._getBlendFunc=function(t,e){var i=this._currBlendFunc;switch(t){case n.BlendMode.Normal:i.src=e?cc.macro.ONE:cc.macro.SRC_ALPHA,i.dst=cc.macro.ONE_MINUS_SRC_ALPHA;break;case n.BlendMode.Additive:i.src=e?cc.macro.ONE:cc.macro.SRC_ALPHA,i.dst=cc.macro.ONE;break;case n.BlendMode.Multiply:i.src=cc.macro.DST_COLOR,i.dst=cc.macro.ONE_MINUS_SRC_ALPHA;break;case n.BlendMode.Screen:i.src=cc.macro.ONE,i.dst=cc.macro.ONE_MINUS_SRC_COLOR;break;default:i=this._node._blendFunc}return i},r._createChildFormSkeletonData=function(){},r._updateChild=function(){},r._uploadRegionAttachmentData=function(t,e,i,r,s,o){for(var a=this._displayedColor,c=a.r,h=a.g,l=a.b,u=this._displayedOpacity,_=t.updateWorldVertices(e,i),d=this._worldTransform,f=d.a,p=d.b,m=d.c,g=d.d,y=d.tx,v=d.ty,x=this._node.vertexZ,C=o,T=0;T<6;T++){var b=T<4?T%3:T-2,A=_[8*b],S=_[8*b+1],w=A*f+S*m+y,E=A*p+S*g+v,I=_[8*b+2]*c,R=_[8*b+3]*h,P=_[8*b+4]*l,O=_[8*b+5]*u<<24|P<<16|R<<8|I;r[C]=w,r[C+1]=E,r[C+2]=x,s[C+3]=O,r[C+4]=_[8*b+6],r[C+5]=_[8*b+7],C+=6}if(this._node._debugSlots){var B=n.RegionAttachment;return[cc.p(_[B.X1],_[B.Y1]),cc.p(_[B.X2],_[B.Y2]),cc.p(_[B.X3],_[B.Y3]),cc.p(_[B.X4],_[B.Y4])]}},r._uploadMeshAttachmentData=function(t,e,i,n,r,s){for(var o=this._worldTransform,a=o.a,c=o.b,h=o.c,l=o.d,u=o.tx,_=o.ty,d=this._node.vertexZ,f=t.updateWorldVertices(e,i),p=s,m=this._displayedColor,g=m.r,y=m.g,v=m.b,x=this._displayedOpacity,C=0,T=f.length;C<T;C+=8){var b=f[C],A=f[C+1],S=b*a+A*h+u,w=b*c+A*l+_,E=f[C+2]*g,I=f[C+3]*y,R=f[C+4]*v,P=f[C+5]*x<<24|R<<16|I<<8|E;n[p]=S,n[p+1]=w,n[p+2]=d,r[p+3]=P,n[p+4]=f[C+6],n[p+5]=f[C+7],p+=6}}}),{"../../cocos2d/core/CCDrawingPrimitives":36}],306:[(function(t,e,i){var n=cc.Enum({default:-1}),r=cc.Enum({"<None>":0});sp.Skeleton=cc.Class({name:"sp.Skeleton",extends:cc._RendererUnderSG,editor:!1,properties:{_startListener:{default:null,serializable:!1},_endListener:{default:null,serializable:!1},_completeListener:{default:null,serializable:!1},_eventListener:{default:null,serializable:!1},_disposeListener:{default:null,serializable:!1},_interruptListener:{default:null,serializable:!1},_paused:!1,paused:{get:function(){return this._paused},set:function(t){this._paused=t,this._sgNode&&(t?this._sgNode.pause():this._sgNode.resume())},visible:!1},skeletonData:{default:null,type:sp.SkeletonData,notify:function(){this.defaultSkin="",this.defaultAnimation="",this._refresh()},tooltip:!1},defaultSkin:{default:"",visible:!1},defaultAnimation:{default:"",visible:!1},animation:{get:function(){var t=this.getCurrent(0);return t&&t.animation.name||""},set:function(t){this.defaultAnimation=t,t?this.setAnimation(0,t,this.loop):(this.clearTrack(0),this.setToSetupPose())},visible:!1},_defaultSkinIndex:{get:function(){if(this.skeletonData&&this.defaultSkin){var t=this.skeletonData.getSkinsEnum();if(t){var e=t[this.defaultSkin];if(void 0!==e)return e}}return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getSkinsEnum()),!e)return cc.errorID("",this.name);var i=e[t];void 0!==i?this.defaultSkin=i:cc.errorID(7501,this.name)},type:n,visible:!0,displayName:"Default Skin",tooltip:!1},_animationIndex:{get:function(){var t=this.animation;if(this.skeletonData&&t){var e=this.skeletonData.getAnimsEnum();if(e){var i=e[t];if(void 0!==i)return i}}return 0},set:function(t){if(0!==t){var e;if(this.skeletonData&&(e=this.skeletonData.getAnimsEnum()),!e)return cc.errorID(7502,this.name);var i=e[t];void 0!==i?this.animation=i:cc.errorID(7503,this.name)}else this.animation=""},type:r,visible:!0,displayName:"Animation",tooltip:!1},loop:{default:!0,tooltip:!1},_premultipliedAlpha:!0,premultipliedAlpha:{get:function(){return this._premultipliedAlpha},set:function(t){this._premultipliedAlpha=t,this._sgNode&&this._sgNode.setPremultipliedAlpha(t)},tooltip:!1},timeScale:{default:1,notify:function(){this._sgNode&&this._sgNode.setTimeScale(this.timeScale)},tooltip:!1},debugSlots:{default:!1,notify:function(){this._sgNode&&this._sgNode.setDebugSlotsEnabled(this.debugSlots)},editorOnly:!0,tooltip:!1},debugBones:{default:!1,notify:function(){this._sgNode&&this._sgNode.setDebugBonesEnabled(this.debugBones)},editorOnly:!0,tooltip:!1}},__preload:function(){this.node.setContentSize(0,0),this._refresh()},_createSgNode:function(){if(this.skeletonData){var t=this.skeletonData.getRuntimeData();if(t)try{return new sp._SGSkeletonAnimation(t,null,this.skeletonData.scale)}catch(t){cc._throw(t)}}return null},_initSgNode:function(){var t=this._sgNode;t.setTimeScale(this.timeScale);var e=this;if(t.onEnter=function(){_ccsg.Node.prototype.onEnter.call(this),e._paused&&this.pause()},this._startListener&&this.setStartListener(this._startListener),this._endListener&&this.setEndListener(this._endListener),this._completeListener&&this.setCompleteListener(this._completeListener),this._eventListener&&this.setEventListener(this._eventListener),this._interruptListener&&this.setInterruptListener(this._interruptListener),this._disposeListener&&this.setDisposeListener(this._disposeListener),this.defaultSkin)try{t.setSkin(this.defaultSkin)}catch(t){cc._throw(t)}t.setPremultipliedAlpha(this._premultipliedAlpha),this.animation=this.defaultAnimation},_getLocalBounds:!1,updateWorldTransform:function(){this._sgNode&&this._sgNode.updateWorldTransform()},setToSetupPose:function(){this._sgNode&&this._sgNode.setToSetupPose()},setBonesToSetupPose:function(){this._sgNode&&this._sgNode.setBonesToSetupPose()},setSlotsToSetupPose:function(){this._sgNode&&this._sgNode.setSlotsToSetupPose()},findBone:function(t){return this._sgNode?this._sgNode.findBone(t):null},findSlot:function(t){return this._sgNode?this._sgNode.findSlot(t):null},setSkin:function(t){return this._sgNode?this._sgNode.setSkin(t):null},getAttachment:function(t,e){return this._sgNode?this._sgNode.getAttachment(t,e):null},setAttachment:function(t,e){this._sgNode&&this._sgNode.setAttachment(t,e)},setSkeletonData:function(t,e){this._sgNode&&this._sgNode.setSkeletonData(t,e)},setAnimationStateData:function(t){if(this._sgNode)return this._sgNode.setAnimationStateData(t)},setMix:function(t,e,i){this._sgNode&&this._sgNode.setMix(t,e,i)},setAnimationListener:function(t,e){this._sgNode&&this._sgNode.setAnimationListener(t,e)},setAnimation:function(t,e,i){if(this._sgNode){return this._sgNode.setAnimation(t,e,i)}return null},_sample:function(){this._sgNode&&this._sgNode.update(0)},addAnimation:function(t,e,i,n){return this._sgNode?this._sgNode.addAnimation(t,e,i,n||0):null},findAnimation:function(t){return this._sgNode?this._sgNode.findAnimation(t):null},getCurrent:function(t){return this._sgNode?this._sgNode.getCurrent(t):null},clearTracks:function(){this._sgNode&&this._sgNode.clearTracks()},clearTrack:function(t){this._sgNode&&this._sgNode.clearTrack(t)},_updateAnimEnum:!1,_updateSkinEnum:!1,setStartListener:function(t){this._startListener=t,this._sgNode&&this._sgNode.setStartListener(t)},setInterruptListener:function(t){this._interruptListener=t,this._sgNode&&this._sgNode.setInterruptListener(t)},setEndListener:function(t){this._endListener=t,this._sgNode&&this._sgNode.setEndListener(t)},setDisposeListener:function(t){this._disposeListener=t,this._sgNode&&this._sgNode.setDisposeListener(t)},setCompleteListener:function(t){this._completeListener=t,this._sgNode&&this._sgNode.setCompleteListener(t)},setEventListener:function(t){this._eventListener=t,this._sgNode&&this._sgNode.setEventListener(t)},setTrackStartListener:function(t,e){this._sgNode&&this._sgNode.setTrackStartListener(t,e)},setTrackInterruptListener:function(t,e){this._sgNode&&this._sgNode.setTrackInterruptListener(t,e)},setTrackEndListener:function(t,e){this._sgNode&&this._sgNode.setTrackEndListener(t,e)},setTrackDisposeListener:function(t,e){this._sgNode&&this._sgNode.setTrackDisposeListener(t,e)},setTrackCompleteListener:function(t,e){this._sgNode&&this._sgNode.setTrackCompleteListener(t,e)},setTrackEventListener:function(t,e){this._sgNode&&this._sgNode.setTrackEventListener(t,e)},getState:function(){if(this._sgNode)return this._sgNode.getState()},_refresh:function(){this._sgNode&&(this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),this._removeSgNode(),this._sgNode=null);var t=this._sgNode=this._createSgNode();t&&(this.enabledInHierarchy||t.setVisible(!1),t.setContentSize(0,0),this._initSgNode(),this._appendSgNode(t),this._registSizeProvider())}})}),{}],307:[(function(t,e,i){var n=cc.Class({ctor:function(){this.asset=arguments[0]},getTexture:function(t){for(var e=this.asset.textures,i=0;i<e.length;i++){var n=e[i];if(n.endsWith(t)){var r=cc.textureCache.addImage(n),s=new sp.SkeletonTexture({width:r.getPixelWidth(),height:r.getPixelHeight()});return s.setRealTexture(r),s}}return null},load:function(t){var e=this.getTexture(t);return e||(cc.errorID(7506,t),null)},unload:function(t){}}),r=cc.Class({name:"sp.SkeletonData",extends:cc.Asset,ctor:function(){this.reset()},properties:{_skeletonJson:null,skeletonJson:{get:function(){return this._skeletonJson},set:function(t){this._skeletonJson=t,this.reset()}},_atlasText:"",atlasText:{get:function(){return this._atlasText},set:function(t){this._atlasText=t,this.reset()}},atlasUrl:{default:"",url:cc.RawAsset},textures:{default:[],url:[cc.Texture2D]},scale:1},statics:{preventDeferredLoadDependents:!0},createNode:!1,reset:function(){this._skeletonCache=null,this._atlasCache=null},getRuntimeData:function(t){if(this._skeletonCache)return this._skeletonCache;if(!(this.textures&&this.textures.length>0))return t||cc.errorID(7507,this.name),null;var e=this._getAtlas(t);if(!e)return null;var i=new sp.spine.AtlasAttachmentLoader(e),n=new sp.spine.SkeletonJson(i);n.scale=this.scale;var r=this.skeletonJson;return this._skeletonCache=n.readSkeletonData(r),e.dispose(n),this._skeletonCache},getSkinsEnum:!1,getAnimsEnum:!1,_getAtlas:function(t){if(this._atlasCache)return this._atlasCache;if(!this.atlasText)return t||cc.errorID(7508,this.name),null;var e=new n(this);return this._atlasCache=new sp.spine.TextureAtlas(this.atlasText,e.load.bind(e))}});sp.SkeletonData=e.exports=r}),{}],308:[(function(t,e,i){sp={},sp.VERTEX_INDEX={X1:0,Y1:1,X2:2,Y2:3,X3:4,Y3:5,X4:6,Y4:7},sp.ATTACHMENT_TYPE={REGION:0,BOUNDING_BOX:1,MESH:2,SKINNED_MESH:3},sp.AnimationEventType=cc.Enum({START:0,INTERRUPT:1,END:2,DISPOSE:3,COMPLETE:4,EVENT:5}),sp.spine=t("./lib/spine"),t("./SGSkeletonTexture"),t("./SGSkeleton"),t("./SGSkeletonCanvasRenderCmd"),t("./SGSkeletonWebGLRenderCmd"),t("./SGSkeletonAnimation"),t("./SkeletonData"),t("./Skeleton")}),{"./SGSkeleton":301,"./SGSkeletonAnimation":302,"./SGSkeletonCanvasRenderCmd":303,"./SGSkeletonTexture":304,"./SGSkeletonWebGLRenderCmd":305,"./Skeleton":306,"./SkeletonData":307,"./lib/spine":309}],309:[(function(t,e,i){var n=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)};(function(t){var e=(function(){function t(t,e,i){if(null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=i}return t.prototype.apply=function(t,e,i,n,r,s,o,a){if(null==t)throw new Error("skeleton cannot be null.");n&&0!=this.duration&&(i%=this.duration,e>0&&(e%=this.duration));for(var c=this.timelines,h=0,l=c.length;h<l;h++)c[h].apply(t,e,i,r,s,o,a)},t.binarySearch=function(t,e,i){void 0===i&&(i=1);var n=0,r=t.length/i-2;if(0==r)return i;for(var s=r>>>1;;){if(t[(s+1)*i]<=e?n=s+1:r=s,n==r)return(n+1)*i;s=n+r>>>1}},t.linearSearch=function(t,e,i){for(var n=0,r=t.length-i;n<=r;n+=i)if(t[n]>e)return n;return-1},t})();t.Animation=e,(function(t){t[t.rotate=0]="rotate",t[t.translate=1]="translate",t[t.scale=2]="scale",t[t.shear=3]="shear",t[t.attachment=4]="attachment",t[t.color=5]="color",t[t.deform=6]="deform",t[t.event=7]="event",t[t.drawOrder=8]="drawOrder",t[t.ikConstraint=9]="ikConstraint",t[t.transformConstraint=10]="transformConstraint",t[t.pathConstraintPosition=11]="pathConstraintPosition",t[t.pathConstraintSpacing=12]="pathConstraintSpacing",t[t.pathConstraintMix=13]="pathConstraintMix"})(t.TimelineType||(t.TimelineType={}));var i=t.TimelineType,r=(function(){function e(i){if(i<=0)throw new Error("frameCount must be > 0: "+i);this.curves=t.Utils.newFloatArray((i-1)*e.BEZIER_SIZE)}return e.prototype.getFrameCount=function(){return this.curves.length/e.BEZIER_SIZE+1},e.prototype.setLinear=function(t){this.curves[t*e.BEZIER_SIZE]=e.LINEAR},e.prototype.setStepped=function(t){this.curves[t*e.BEZIER_SIZE]=e.STEPPED},e.prototype.getCurveType=function(t){var i=t*e.BEZIER_SIZE;if(i==this.curves.length)return e.LINEAR;var n=this.curves[i];return n==e.LINEAR?e.LINEAR:n==e.STEPPED?e.STEPPED:e.BEZIER},e.prototype.setCurve=function(t,i,n,r,s){var o=.03*(2*-i+r),a=.03*(2*-n+s),c=.006*(3*(i-r)+1),h=.006*(3*(n-s)+1),l=2*o+c,u=2*a+h,_=.3*i+o+.16666667*c,d=.3*n+a+.16666667*h,f=t*e.BEZIER_SIZE,p=this.curves;p[f++]=e.BEZIER;for(var m=_,g=d,y=f+e.BEZIER_SIZE-1;f<y;f+=2)p[f]=m,p[f+1]=g,_+=l,d+=u,l+=c,u+=h,m+=_,g+=d},e.prototype.getCurvePercent=function(i,n){n=t.MathUtils.clamp(n,0,1);var r=this.curves,s=i*e.BEZIER_SIZE,o=r[s];if(o==e.LINEAR)return n;if(o==e.STEPPED)return 0;for(var a=0,c=++s,h=s+e.BEZIER_SIZE-1;s<h;s+=2)if((a=r[s])>=n){var l=void 0,u=void 0;return s==c?(l=0,u=0):(l=r[s-2],u=r[s-1]),u+(r[s+1]-u)*(n-l)/(a-l)}var _=r[s-1];return _+(1-_)*(n-a)/(1-a)},e.LINEAR=0,e.STEPPED=1,e.BEZIER=2,e.BEZIER_SIZE=19,e})();t.CurveTimeline=r;var s=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e<<1)}return n(s,r),s.prototype.getPropertyId=function(){return(i.rotate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i){t<<=1,this.frames[t]=e,this.frames[t+s.ROTATION]=i},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.bones[this.boneIndex];if(n<h[0])a&&(l.rotation=l.data.rotation);else if(n>=h[h.length-s.ENTRIES])if(a)l.rotation=l.data.rotation+h[h.length+s.PREV_ROTATION]*o;else{var u=l.data.rotation+h[h.length+s.PREV_ROTATION]-l.rotation;u-=360*(16384-(16384.499999999996-u/360|0)),l.rotation+=u*o}else{var _=e.binarySearch(h,n,s.ENTRIES),d=h[_+s.PREV_ROTATION],f=h[_],p=this.getCurvePercent((_>>1)-1,1-(n-f)/(h[_+s.PREV_TIME]-f)),m=h[_+s.ROTATION]-d;m=d+(m-=360*(16384-(16384.499999999996-m/360|0)))*p,a?(m-=360*(16384-(16384.499999999996-m/360|0)),l.rotation=l.data.rotation+m*o):(m=l.data.rotation+m-l.rotation,m-=360*(16384-(16384.499999999996-m/360|0)),l.rotation+=m*o)}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_ROTATION=-1,s.ROTATION=1,s})(r);t.RotateTimeline=s;var o=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.translate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.X]=i,this.frames[t+s.Y]=n},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.bones[this.boneIndex];if(n<h[0])a&&(l.x=l.data.x,l.y=l.data.y);else{var u=0,_=0;if(n>=h[h.length-s.ENTRIES])u=h[h.length+s.PREV_X],_=h[h.length+s.PREV_Y];else{var d=e.binarySearch(h,n,s.ENTRIES);u=h[d+s.PREV_X],_=h[d+s.PREV_Y];var f=h[d],p=this.getCurvePercent(d/s.ENTRIES-1,1-(n-f)/(h[d+s.PREV_TIME]-f));u+=(h[d+s.X]-u)*p,_+=(h[d+s.Y]-_)*p}a?(l.x=l.data.x+u*o,l.y=l.data.y+_*o):(l.x+=(l.data.x+u-l.x)*o,l.y+=(l.data.y+_-l.y)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_X=-2,s.PREV_Y=-1,s.X=1,s.Y=2,s})(r);t.TranslateTimeline=o;var a=(function(r){function s(t){r.call(this,t)}return n(s,r),s.prototype.getPropertyId=function(){return(i.scale<<24)+this.boneIndex},s.prototype.apply=function(i,n,r,o,a,c,h){var l=this.frames,u=i.bones[this.boneIndex];if(r<l[0])c&&(u.scaleX=u.data.scaleX,u.scaleY=u.data.scaleY);else{var _=0,d=0;if(r>=l[l.length-s.ENTRIES])_=l[l.length+s.PREV_X]*u.data.scaleX,d=l[l.length+s.PREV_Y]*u.data.scaleY;else{var f=e.binarySearch(l,r,s.ENTRIES);_=l[f+s.PREV_X],d=l[f+s.PREV_Y];var p=l[f],m=this.getCurvePercent(f/s.ENTRIES-1,1-(r-p)/(l[f+s.PREV_TIME]-p));_=(_+(l[f+s.X]-_)*m)*u.data.scaleX,d=(d+(l[f+s.Y]-d)*m)*u.data.scaleY}if(1==a)u.scaleX=_,u.scaleY=d;else{var g=0,y=0;c?(g=u.data.scaleX,y=u.data.scaleY):(g=u.scaleX,y=u.scaleY),h?(_=Math.abs(_)*t.MathUtils.signum(g),d=Math.abs(d)*t.MathUtils.signum(y)):(g=Math.abs(g)*t.MathUtils.signum(_),y=Math.abs(y)*t.MathUtils.signum(d)),u.scaleX=g+(_-g)*a,u.scaleY=y+(d-y)*a}}},s})(o);t.ScaleTimeline=a;var c=(function(t){function r(e){t.call(this,e)}return n(r,t),r.prototype.getPropertyId=function(){return(i.shear<<24)+this.boneIndex},r.prototype.apply=function(t,i,n,s,o,a,c){var h=this.frames,l=t.bones[this.boneIndex];if(n<h[0])a&&(l.shearX=l.data.shearX,l.shearY=l.data.shearY);else{var u=0,_=0;if(n>=h[h.length-r.ENTRIES])u=h[h.length+r.PREV_X],_=h[h.length+r.PREV_Y];else{var d=e.binarySearch(h,n,r.ENTRIES);u=h[d+r.PREV_X],_=h[d+r.PREV_Y];var f=h[d],p=this.getCurvePercent(d/r.ENTRIES-1,1-(n-f)/(h[d+r.PREV_TIME]-f));u+=(h[d+r.X]-u)*p,_+=(h[d+r.Y]-_)*p}a?(l.shearX=l.data.shearX+u*o,l.shearY=l.data.shearY+_*o):(l.shearX+=(l.data.shearX+u-l.shearX)*o,l.shearY+=(l.data.shearY+_-l.shearY)*o)}},r})(o);t.ShearTimeline=c;var h=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.color<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,n,r,o){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=n,this.frames[t+s.B]=r,this.frames[t+s.A]=o},s.prototype.apply=function(t,i,n,r,o,a,c){var h=t.slots[this.slotIndex],l=this.frames;if(n<l[0])a&&h.color.setFromColor(h.data.color);else{var u=0,_=0,d=0,f=0;if(n>=l[l.length-s.ENTRIES]){var p=l.length;u=l[p+s.PREV_R],_=l[p+s.PREV_G],d=l[p+s.PREV_B],f=l[p+s.PREV_A]}else{var m=e.binarySearch(l,n,s.ENTRIES);u=l[m+s.PREV_R],_=l[m+s.PREV_G],d=l[m+s.PREV_B],f=l[m+s.PREV_A];var g=l[m],y=this.getCurvePercent(m/s.ENTRIES-1,1-(n-g)/(l[m+s.PREV_TIME]-g));u+=(l[m+s.R]-u)*y,_+=(l[m+s.G]-_)*y,d+=(l[m+s.B]-d)*y,f+=(l[m+s.A]-f)*y}if(1==o)h.color.set(u,_,d,f);else{var v=h.color;a&&v.setFromColor(h.data.color),v.add((u-v.r)*o,(_-v.g)*o,(d-v.b)*o,(f-v.a)*o)}}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_R=-4,s.PREV_G=-3,s.PREV_B=-2,s.PREV_A=-1,s.R=1,s.G=2,s.B=3,s.A=4,s})(r);t.ColorTimeline=h;var l=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.attachmentNames=new Array(e)}return n.prototype.getPropertyId=function(){return(i.attachment<<24)+this.slotIndex},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},n.prototype.apply=function(t,i,n,r,s,o,a){var c=t.slots[this.slotIndex];if(a&&o){var h=c.data.attachmentName;c.setAttachment(null==h?null:t.getAttachment(this.slotIndex,h))}else{var l=this.frames;if(n<l[0]){if(o){var u=c.data.attachmentName;c.setAttachment(null==u?null:t.getAttachment(this.slotIndex,u))}}else{var _=0;_=n>=l[l.length-1]?l.length-1:e.binarySearch(l,n,1)-1;var d=this.attachmentNames[_];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}},n})();t.AttachmentTimeline=l;var u=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e),this.frameVertices=new Array(e)}return n(s,r),s.prototype.getPropertyId=function(){return(i.deform<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.frameVertices[t]=i},s.prototype.apply=function(i,n,r,s,o,a,c){var h=i.slots[this.slotIndex],l=h.getAttachment();if(l instanceof t.VertexAttachment&&l.applyDeform(this.attachment)){var u=this.frames,_=h.attachmentVertices;if(r<u[0])a&&t.Utils.setArraySize(_,0);else{var d=this.frameVertices,f=d[0].length;_.length!=f&&(o=1);var p=t.Utils.setArraySize(_,f);if(r>=u[u.length-1]){var m=d[u.length-1];if(1==o)t.Utils.arrayCopy(m,0,p,0,f);else if(a){if(null==(w=l).bones)for(var g=w.vertices,y=0;y<f;y++){var v=g[y];p[y]=v+(m[y]-v)*o}else for(y=0;y<f;y++)p[y]=m[y]*o}else for(y=0;y<f;y++)p[y]+=(m[y]-p[y])*o}else{var x=e.binarySearch(u,r),C=d[x-1],T=d[x],b=u[x],A=this.getCurvePercent(x-1,1-(r-b)/(u[x-1]-b));if(1==o)for(y=0;y<f;y++){var S=C[y];p[y]=S+(T[y]-S)*A}else if(a){var w;if(null==(w=l).bones)for(g=w.vertices,y=0;y<f;y++){S=C[y],v=g[y];p[y]=v+(S+(T[y]-S)*A-v)*o}else for(y=0;y<f;y++){S=C[y];p[y]=(S+(T[y]-S)*A)*o}}else for(y=0;y<f;y++){S=C[y];p[y]+=(S+(T[y]-S)*A-p[y])*o}}}}},s})(r);t.DeformTimeline=u;var _=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.events=new Array(e)}return n.prototype.getPropertyId=function(){return i.event<<24},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e){this.frames[t]=e.time,this.events[t]=e},n.prototype.apply=function(t,i,n,r,s,o,a){if(null!=r){var c=this.frames,h=this.frames.length;if(i>n)this.apply(t,i,Number.MAX_VALUE,r,s,o,a),i=-1;else if(i>=c[h-1])return;if(!(n<c[0])){var l=0;if(i<c[0])l=0;else for(var u=c[l=e.binarySearch(c,i)];l>0&&c[l-1]==u;)l--;for(;l<h&&n>=c[l];l++)r.push(this.events[l])}}},n})();t.EventTimeline=_;var d=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.drawOrders=new Array(e)}return n.prototype.getPropertyId=function(){return i.drawOrder<<24},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.drawOrders[t]=i},n.prototype.apply=function(i,n,r,s,o,a,c){var h=i.drawOrder,l=i.slots;if(c&&a)t.Utils.arrayCopy(i.slots,0,i.drawOrder,0,i.slots.length);else{var u=this.frames;if(r<u[0])a&&t.Utils.arrayCopy(i.slots,0,i.drawOrder,0,i.slots.length);else{var _=0;_=r>=u[u.length-1]?u.length-1:e.binarySearch(u,r)-1;var d=this.drawOrders[_];if(null==d)t.Utils.arrayCopy(l,0,h,0,l.length);else for(var f=0,p=d.length;f<p;f++)h[f]=l[d[f]]}}},n})();t.DrawOrderTimeline=d;var f=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.ikConstraint<<24)+this.ikConstraintIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.MIX]=i,this.frames[t+s.BEND_DIRECTION]=n},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.ikConstraints[this.ikConstraintIndex];if(n<h[0])a&&(l.mix=l.data.mix,l.bendDirection=l.data.bendDirection);else if(n>=h[h.length-s.ENTRIES])a?(l.mix=l.data.mix+(h[h.length+s.PREV_MIX]-l.data.mix)*o,l.bendDirection=c?l.data.bendDirection:h[h.length+s.PREV_BEND_DIRECTION]):(l.mix+=(h[h.length+s.PREV_MIX]-l.mix)*o,c||(l.bendDirection=h[h.length+s.PREV_BEND_DIRECTION]));else{var u=e.binarySearch(h,n,s.ENTRIES),_=h[u+s.PREV_MIX],d=h[u],f=this.getCurvePercent(u/s.ENTRIES-1,1-(n-d)/(h[u+s.PREV_TIME]-d));a?(l.mix=l.data.mix+(_+(h[u+s.MIX]-_)*f-l.data.mix)*o,l.bendDirection=c?l.data.bendDirection:h[u+s.PREV_BEND_DIRECTION]):(l.mix+=(_+(h[u+s.MIX]-_)*f-l.mix)*o,c||(l.bendDirection=h[u+s.PREV_BEND_DIRECTION]))}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_MIX=-2,s.PREV_BEND_DIRECTION=-1,s.MIX=1,s.BEND_DIRECTION=2,s})(r);t.IkConstraintTimeline=f;var p=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.transformConstraint<<24)+this.transformConstraintIndex},s.prototype.setFrame=function(t,e,i,n,r,o){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n,this.frames[t+s.SCALE]=r,this.frames[t+s.SHEAR]=o},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.transformConstraints[this.transformConstraintIndex];if(n<h[0]){if(a){var u=l.data;l.rotateMix=u.rotateMix,l.translateMix=u.rotateMix,l.scaleMix=u.scaleMix,l.shearMix=u.shearMix}}else{var _=0,d=0,f=0,p=0;if(n>=h[h.length-s.ENTRIES]){var m=h.length;_=h[m+s.PREV_ROTATE],d=h[m+s.PREV_TRANSLATE],f=h[m+s.PREV_SCALE],p=h[m+s.PREV_SHEAR]}else{var g=e.binarySearch(h,n,s.ENTRIES);_=h[g+s.PREV_ROTATE],d=h[g+s.PREV_TRANSLATE],f=h[g+s.PREV_SCALE],p=h[g+s.PREV_SHEAR];var y=h[g],v=this.getCurvePercent(g/s.ENTRIES-1,1-(n-y)/(h[g+s.PREV_TIME]-y));_+=(h[g+s.ROTATE]-_)*v,d+=(h[g+s.TRANSLATE]-d)*v,f+=(h[g+s.SCALE]-f)*v,p+=(h[g+s.SHEAR]-p)*v}if(a){u=l.data;l.rotateMix=u.rotateMix+(_-u.rotateMix)*o,l.translateMix=u.translateMix+(d-u.translateMix)*o,l.scaleMix=u.scaleMix+(f-u.scaleMix)*o,l.shearMix=u.shearMix+(p-u.shearMix)*o}else l.rotateMix+=(_-l.rotateMix)*o,l.translateMix+=(d-l.translateMix)*o,l.scaleMix+=(f-l.scaleMix)*o,l.shearMix+=(p-l.shearMix)*o}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_ROTATE=-4,s.PREV_TRANSLATE=-3,s.PREV_SCALE=-2,s.PREV_SHEAR=-1,s.ROTATE=1,s.TRANSLATE=2,s.SCALE=3,s.SHEAR=4,s})(r);t.TransformConstraintTimeline=p;var m=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.pathConstraintPosition<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.VALUE]=i},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(n<h[0])a&&(l.position=l.data.position);else{var u=0;if(n>=h[h.length-s.ENTRIES])u=h[h.length+s.PREV_VALUE];else{var _=e.binarySearch(h,n,s.ENTRIES);u=h[_+s.PREV_VALUE];var d=h[_],f=this.getCurvePercent(_/s.ENTRIES-1,1-(n-d)/(h[_+s.PREV_TIME]-d));u+=(h[_+s.VALUE]-u)*f}a?l.position=l.data.position+(u-l.data.position)*o:l.position+=(u-l.position)*o}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_VALUE=-1,s.VALUE=1,s})(r);t.PathConstraintPositionTimeline=m;var g=(function(t){function r(e){t.call(this,e)}return n(r,t),r.prototype.getPropertyId=function(){return(i.pathConstraintSpacing<<24)+this.pathConstraintIndex},r.prototype.apply=function(t,i,n,s,o,a,c){var h=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(n<h[0])a&&(l.spacing=l.data.spacing);else{var u=0;if(n>=h[h.length-r.ENTRIES])u=h[h.length+r.PREV_VALUE];else{var _=e.binarySearch(h,n,r.ENTRIES);u=h[_+r.PREV_VALUE];var d=h[_],f=this.getCurvePercent(_/r.ENTRIES-1,1-(n-d)/(h[_+r.PREV_TIME]-d));u+=(h[_+r.VALUE]-u)*f}a?l.spacing=l.data.spacing+(u-l.data.spacing)*o:l.spacing+=(u-l.spacing)*o}},r})(m);t.PathConstraintSpacingTimeline=g;var y=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.pathConstraintMix<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(n<h[0])a&&(l.rotateMix=l.data.rotateMix,l.translateMix=l.data.translateMix);else{var u=0,_=0;if(n>=h[h.length-s.ENTRIES])u=h[h.length+s.PREV_ROTATE],_=h[h.length+s.PREV_TRANSLATE];else{var d=e.binarySearch(h,n,s.ENTRIES);u=h[d+s.PREV_ROTATE],_=h[d+s.PREV_TRANSLATE];var f=h[d],p=this.getCurvePercent(d/s.ENTRIES-1,1-(n-f)/(h[d+s.PREV_TIME]-f));u+=(h[d+s.ROTATE]-u)*p,_+=(h[d+s.TRANSLATE]-_)*p}a?(l.rotateMix=l.data.rotateMix+(u-l.data.rotateMix)*o,l.translateMix=l.data.translateMix+(_-l.data.translateMix)*o):(l.rotateMix+=(u-l.rotateMix)*o,l.translateMix+=(_-l.translateMix)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_ROTATE=-2,s.PREV_TRANSLATE=-1,s.ROTATE=1,s.TRANSLATE=2,s})(r);t.PathConstraintMixTimeline=y})(r||(r={}));(function(t){var e=(function(){function e(e){this.tracks=new Array,this.events=new Array,this.listeners=new Array,this.queue=new n(this),this.propertyIDs=new t.IntSet,this.animationsChanged=!1,this.timeScale=1,this.trackEntryPool=new t.Pool(function(){return new i}),this.data=e}return e.prototype.update=function(t){t*=this.timeScale;for(var e=this.tracks,i=0,n=e.length;i<n;i++){var r=e[i];if(null!=r){r.animationLast=r.nextAnimationLast,r.trackLast=r.nextTrackLast;var s=t*r.timeScale;if(r.delay>0){if(r.delay-=s,r.delay>0)continue;s=-r.delay,r.delay=0}var o=r.next;if(null!=o){var a=r.trackLast-o.delay;if(a>=0){for(o.delay=0,o.trackTime=a+t*o.timeScale,r.trackTime+=s,this.setCurrent(i,o,!0);null!=o.mixingFrom;)o.mixTime+=s,o=o.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&null==r.mixingFrom){e[i]=null,this.queue.end(r),this.disposeNext(r);continue}this.updateMixingFrom(r,t),r.trackTime+=s}}this.queue.drain()},e.prototype.updateMixingFrom=function(t,e){var i=t.mixingFrom;if(null!=i){if(this.updateMixingFrom(i,e),t.mixTime>=t.mixDuration&&null!=i.mixingFrom&&t.mixTime>0)return t.mixingFrom=null,void this.queue.end(i);i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast,i.trackTime+=e*i.timeScale,t.mixTime+=e*i.timeScale}},e.prototype.apply=function(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var i=this.events,n=this.tracks,r=0,s=n.length;r<s;r++){var o=n[r];if(!(null==o||o.delay>0)){var a=o.alpha;null!=o.mixingFrom?a*=this.applyMixingFrom(o,e):o.trackTime>=o.trackEnd&&(a=0);var c=o.animationLast,h=o.getAnimationTime(),l=o.animation.timelines.length,u=o.animation.timelines;if(1==a)for(var _=0;_<l;_++)u[_].apply(e,c,h,i,1,!0,!1);else{var d=0==o.timelinesRotation.length;d&&t.Utils.setArraySize(o.timelinesRotation,l<<1,null);var f=o.timelinesRotation,p=o.timelinesFirst;for(_=0;_<l;_++){var m=u[_];m instanceof t.RotateTimeline?this.applyRotateTimeline(m,e,h,a,p[_],f,_<<1,d):m.apply(e,c,h,i,a,p[_],!1)}}this.queueEvents(o,h),i.length=0,o.nextAnimationLast=h,o.nextTrackLast=o.trackTime}}this.queue.drain()},e.prototype.applyMixingFrom=function(e,i){var n=e.mixingFrom;null!=n.mixingFrom&&this.applyMixingFrom(n,i);var r=0;0==e.mixDuration?r=1:(r=e.mixTime/e.mixDuration)>1&&(r=1);var s=r<n.eventThreshold?this.events:null,o=r<n.attachmentThreshold,a=r<n.drawOrderThreshold,c=n.animationLast,h=n.getAnimationTime(),l=n.animation.timelines.length,u=n.animation.timelines,_=n.timelinesFirst,d=n.alpha*e.mixAlpha*(1-r),f=0==n.timelinesRotation.length;f&&t.Utils.setArraySize(n.timelinesRotation,l<<1,null);for(var p=n.timelinesRotation,m=0;m<l;m++){var g=u[m],y=_[m];if(g instanceof t.RotateTimeline)this.applyRotateTimeline(g,i,h,d,y,p,m<<1,f);else{if(!y){if(!o&&g instanceof t.AttachmentTimeline)continue;if(!a&&g instanceof t.DrawOrderTimeline)continue}g.apply(i,c,h,s,d,y,!0)}}return e.mixDuration>0&&this.queueEvents(n,h),this.events.length=0,n.nextAnimationLast=h,n.nextTrackLast=n.trackTime,r},e.prototype.applyRotateTimeline=function(e,i,n,r,s,o,a,c){if(c&&(o[a]=0),1!=r){var h=e,l=h.frames,u=i.bones[h.boneIndex];if(n<l[0])s&&(u.rotation=u.data.rotation);else{var _=0;if(n>=l[l.length-t.RotateTimeline.ENTRIES])_=u.data.rotation+l[l.length+t.RotateTimeline.PREV_ROTATION];else{var d=t.Animation.binarySearch(l,n,t.RotateTimeline.ENTRIES),f=l[d+t.RotateTimeline.PREV_ROTATION],p=l[d],m=h.getCurvePercent((d>>1)-1,1-(n-p)/(l[d+t.RotateTimeline.PREV_TIME]-p));_=l[d+t.RotateTimeline.ROTATION]-f,_=f+(_-=360*(16384-(16384.499999999996-_/360|0)))*m+u.data.rotation,_-=360*(16384-(16384.499999999996-_/360|0))}var g=s?u.data.rotation:u.rotation,y=0,v=_-g;if(0==v)y=o[a];else{v-=360*(16384-(16384.499999999996-v/360|0));var x=0,C=0;c?(x=0,C=v):(x=o[a],C=o[a+1]);var T=v>0,b=x>=0;t.MathUtils.signum(C)!=t.MathUtils.signum(v)&&Math.abs(C)<=90&&(Math.abs(x)>180&&(x+=360*t.MathUtils.signum(x)),b=T),y=v+x-x%360,b!=T&&(y+=360*t.MathUtils.signum(x)),o[a]=y}o[a+1]=v,g+=y*r,u.rotation=g-360*(16384-(16384.499999999996-g/360|0))}}else e.apply(i,0,n,null,1,s,!1)},e.prototype.queueEvents=function(t,e){for(var i=t.animationStart,n=t.animationEnd,r=n-i,s=t.trackLast%r,o=this.events,a=0,c=o.length;a<c;a++){var h=o[a];if(h.time<s)break;h.time>n||this.queue.event(t,h)}for((t.loop?s>t.trackTime%r:e>=n&&t.animationLast<n)&&this.queue.complete(t);a<c;a++){o[a].time<i||this.queue.event(t,o[a])}},e.prototype.clearTracks=function(){this.queue.drainDisabled=!0;for(var t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=!1,this.queue.drain()},e.prototype.clearTrack=function(t){if(!(t>=this.tracks.length)){var e=this.tracks[t];if(null!=e){this.queue.end(e),this.disposeNext(e);for(var i=e;;){var n=i.mixingFrom;if(null==n)break;this.queue.end(n),i.mixingFrom=null,i=n}this.tracks[e.trackIndex]=null,this.queue.drain()}}},e.prototype.setCurrent=function(t,e,i){var n=this.expandToIndex(t);this.tracks[t]=e,null!=n&&(i&&this.queue.interrupt(n),e.mixingFrom=n,e.mixTime=0,n.timelinesRotation.length=0,null!=n.mixingFrom&&n.mixDuration>0&&(e.mixAlpha*=Math.min(n.mixTime/n.mixDuration,1))),this.queue.start(e)},e.prototype.setAnimation=function(t,e,i){var n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,n,i)},e.prototype.setAnimationWith=function(t,e,i){if(null==e)throw new Error("animation cannot be null.");var n=!0,r=this.expandToIndex(t);null!=r&&(-1==r.nextTrackLast?(this.tracks[t]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.disposeNext(r),r=r.mixingFrom,n=!1):this.disposeNext(r));var s=this.trackEntry(t,e,i,r);return this.setCurrent(t,s,n),this.queue.drain(),s},e.prototype.addAnimation=function(t,e,i,n){var r=this.data.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,r,i,n)},e.prototype.addAnimationWith=function(t,e,i,n){if(null==e)throw new Error("animation cannot be null.");var r=this.expandToIndex(t);if(null!=r)for(;null!=r.next;)r=r.next;var s=this.trackEntry(t,e,i,r);if(null==r)this.setCurrent(t,s,!0),this.queue.drain();else if(r.next=s,n<=0){var o=r.animationEnd-r.animationStart;0!=o?n+=o*(1+(r.trackTime/o|0))-this.data.getMix(r.animation,e):n=0}return s.delay=n,s},e.prototype.setEmptyAnimation=function(t,i){var n=this.setAnimationWith(t,e.emptyAnimation,!1);return n.mixDuration=i,n.trackEnd=i,n},e.prototype.addEmptyAnimation=function(t,i,n){n<=0&&(n-=i);var r=this.addAnimationWith(t,e.emptyAnimation,!1,n);return r.mixDuration=i,r.trackEnd=i,r},e.prototype.setEmptyAnimations=function(t){this.queue.drainDisabled=!0;for(var e=0,i=this.tracks.length;e<i;e++){var n=this.tracks[e];null!=n&&this.setEmptyAnimation(n.trackIndex,t)}this.queue.drainDisabled=!1,this.queue.drain()},e.prototype.expandToIndex=function(e){return e<this.tracks.length?this.tracks[e]:(t.Utils.ensureArrayCapacity(this.tracks,e-this.tracks.length+1,null),this.tracks.length=e+1,null)},e.prototype.trackEntry=function(t,e,i,n){var r=this.trackEntryPool.obtain();return r.trackIndex=t,r.animation=e,r.loop=i,r.eventThreshold=0,r.attachmentThreshold=0,r.drawOrderThreshold=0,r.animationStart=0,r.animationEnd=e.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.mixAlpha=1,r.mixTime=0,r.mixDuration=null==n?0:this.data.getMix(n.animation,e),r},e.prototype.disposeNext=function(t){for(var e=t.next;null!=e;)this.queue.dispose(e),e=e.next;t.next=null},e.prototype._animationsChanged=function(){this.animationsChanged=!1;var t=this.propertyIDs,e=0,i=this.tracks.length;for(t.clear();e<i;e++){if(null!=(n=this.tracks[e])){this.setTimelinesFirst(n),e++;break}}for(;e<i;e++){var n;null!=(n=this.tracks[e])&&this.checkTimelinesFirst(n)}},e.prototype.setTimelinesFirst=function(e){if(null!=e.mixingFrom)return this.setTimelinesFirst(e.mixingFrom),void this.checkTimelinesUsage(e,e.timelinesFirst);for(var i=this.propertyIDs,n=e.animation.timelines,r=n.length,s=t.Utils.setArraySize(e.timelinesFirst,r,!1),o=0;o<r;o++)i.add(n[o].getPropertyId()),s[o]=!0},e.prototype.checkTimelinesFirst=function(t){null!=t.mixingFrom&&this.checkTimelinesFirst(t.mixingFrom),this.checkTimelinesUsage(t,t.timelinesFirst)},e.prototype.checkTimelinesUsage=function(e,i){for(var n=this.propertyIDs,r=e.animation.timelines,s=r.length,o=t.Utils.setArraySize(i,s),a=0;a<s;a++)o[a]=n.add(r[a].getPropertyId())},e.prototype.getCurrent=function(t){return t>=this.tracks.length?null:this.tracks[t]},e.prototype.addListener=function(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)},e.prototype.removeListener=function(t){var e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)},e.prototype.clearListeners=function(){this.listeners.length=0},e.prototype.clearListenerNotifications=function(){this.queue.clear()},e.emptyAnimation=new t.Animation("<empty>",[],0),e})();t.AnimationState=e;var i=(function(){function t(){this.timelinesFirst=new Array,this.timelinesRotation=new Array}return t.prototype.reset=function(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelinesFirst.length=0,this.timelinesRotation.length=0},t.prototype.getAnimationTime=function(){if(this.loop){var t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)},t.prototype.setAnimationLast=function(t){this.animationLast=t,this.nextAnimationLast=t},t.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart},t.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0},t})();t.TrackEntry=i;var n=(function(){function t(t){this.objects=[],this.drainDisabled=!1,this.animState=t}return t.prototype.start=function(t){this.objects.push(r.start),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.interrupt=function(t){this.objects.push(r.interrupt),this.objects.push(t)},t.prototype.end=function(t){this.objects.push(r.end),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.dispose=function(t){this.objects.push(r.dispose),this.objects.push(t)},t.prototype.complete=function(t){this.objects.push(r.complete),this.objects.push(t)},t.prototype.event=function(t,e){this.objects.push(r.event),this.objects.push(t),this.objects.push(e)},t.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var t=this.objects,e=this.animState.listeners,i=0;i<t.length;i+=2){var n=t[i],s=t[i+1];switch(n){case r.start:null!=s.listener&&s.listener.start&&s.listener.start(s);for(var o=0;o<e.length;o++)e[o].start&&e[o].start(s);break;case r.interrupt:null!=s.listener&&s.listener.interrupt&&s.listener.interrupt(s);for(o=0;o<e.length;o++)e[o].interrupt&&e[o].interrupt(s);break;case r.end:null!=s.listener&&s.listener.end&&s.listener.end(s);for(o=0;o<e.length;o++)e[o].end&&e[o].end(s);case r.dispose:null!=s.listener&&s.listener.dispose&&s.listener.dispose(s);for(o=0;o<e.length;o++)e[o].dispose&&e[o].dispose(s);this.animState.trackEntryPool.free(s);break;case r.complete:null!=s.listener&&s.listener.complete&&s.listener.complete(s);for(o=0;o<e.length;o++)e[o].complete&&e[o].complete(s);break;case r.event:var a=t[2+i++];null!=s.listener&&s.listener.event&&s.listener.event(s,a);for(o=0;o<e.length;o++)e[o].event&&e[o].event(s,a)}}this.clear(),this.drainDisabled=!1}},t.prototype.clear=function(){this.objects.length=0},t})();t.EventQueue=n,(function(t){t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event"})(t.EventType||(t.EventType={}));var r=t.EventType,s=(function(){function t(){}return t.prototype.start=function(t){},t.prototype.interrupt=function(t){},t.prototype.end=function(t){},t.prototype.dispose=function(t){},t.prototype.complete=function(t){},t.prototype.event=function(t,e){},t})();t.AnimationStateAdapter2=s})(r||(r={}));(function(t){var e=(function(){function t(t){if(this.animationToMixTime={},this.defaultMix=0,null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}return t.prototype.setMix=function(t,e,i){var n=this.skeletonData.findAnimation(t);if(null==n)throw new Error("Animation not found: "+t);var r=this.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);this.setMixWith(n,r,i)},t.prototype.setMixWith=function(t,e,i){if(null==t)throw new Error("from cannot be null.");if(null==e)throw new Error("to cannot be null.");var n=t.name+e.name;this.animationToMixTime[n]=i},t.prototype.getMix=function(t,e){var i=t.name+e.name,n=this.animationToMixTime[i];return void 0===n?this.defaultMix:n},t})();t.AnimationStateData=e})(r||(r={}));(function(t){var e=(function(){function t(t,e){void 0===e&&(e=""),this.assets={},this.errors={},this.toLoad=0,this.loaded=0,this.textureLoader=t,this.pathPrefix=e}return t.prototype.loadText=function(t,e,i){var n=this;void 0===e&&(e=null),void 0===i&&(i=null),t=this.pathPrefix+t,this.toLoad++;var r=new XMLHttpRequest;r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&(r.status>=200&&r.status<300?(n.assets[t]=r.responseText,e&&e(t,r.responseText)):(n.errors[t]="Couldn't load text "+t+": status "+r.status+", "+r.responseText,i&&i(t,"Couldn't load text "+t+": status "+r.status+", "+r.responseText)),n.toLoad--,n.loaded++)},r.open("GET",t,!0),r.send()},t.prototype.loadTexture=function(t,e,i){var n=this;void 0===e&&(e=null),void 0===i&&(i=null),t=this.pathPrefix+t,this.toLoad++;var r=new Image;r.crossOrigin="anonymous",r.src=t,r.onload=function(i){var s=n.textureLoader(r);n.assets[t]=s,n.toLoad--,n.loaded++,e&&e(t,r)},r.onerror=function(e){n.errors[t]="Couldn't load image "+t,n.toLoad--,n.loaded++,i&&i(t,"Couldn't load image "+t)}},t.prototype.get=function(t){return t=this.pathPrefix+t,this.assets[t]},t.prototype.remove=function(t){t=this.pathPrefix+t;var e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null},t.prototype.removeAll=function(){for(var t in this.assets){var e=this.assets[t];e.dispose&&e.dispose()}this.assets={}},t.prototype.isLoadingComplete=function(){return 0==this.toLoad},t.prototype.getToLoad=function(){return this.toLoad},t.prototype.getLoaded=function(){return this.loaded},t.prototype.dispose=function(){this.removeAll()},t.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},t.prototype.getErrors=function(){return this.errors},t})();t.AssetManager=e})(r||(r={}));(function(t){var e=(function(){function e(t){this.atlas=t}return e.prototype.newRegionAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)throw new Error("Region not found in atlas: "+n+" (region attachment: "+i+")");r.renderObject=r;var s=new t.RegionAttachment(i);return s.setRegion(r),s},e.prototype.newMeshAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)throw new Error("Region not found in atlas: "+n+" (mesh attachment: "+i+")");r.renderObject=r;var s=new t.MeshAttachment(i);return s.region=r,s},e.prototype.newBoundingBoxAttachment=function(e,i){return new t.BoundingBoxAttachment(i)},e.prototype.newPathAttachment=function(e,i){return new t.PathAttachment(i)},e})();t.AtlasAttachmentLoader=e})(r||(r={}));(function(t){var e=(function(){return function(t){if(null==t)throw new Error("name cannot be null.");this.name=t}})();t.Attachment=e;var i=(function(t){function e(e){t.call(this,e),this.worldVerticesLength=0}return n(e,t),e.prototype.computeWorldVertices=function(t,e){this.computeWorldVerticesWith(t,0,this.worldVerticesLength,e,0)},e.prototype.computeWorldVerticesWith=function(t,e,i,n,r){i+=r;var s=t.bone.skeleton,o=t.attachmentVertices,a=this.vertices,c=this.bones;if(null!=c){for(var h=0,l=0,u=0;u<e;u+=2){h+=(p=c[h])+1,l+=p}var _=s.bones;if(0==o.length)for(E=r,b=3*l;E<i;E+=2){var d=0,f=0,p=c[h++];for(p+=h;h<p;h++,b+=3){v=_[c[h]],I=a[b],R=a[b+1];var m=a[b+2];d+=(I*v.a+R*v.b+v.worldX)*m,f+=(I*v.c+R*v.d+v.worldY)*m}n[E]=d,n[E+1]=f}else for(var g=o,y=(E=r,b=3*l,l<<1);E<i;E+=2){d=0,f=0,p=c[h++];for(p+=h;h<p;h++,b+=3,y+=2){v=_[c[h]],I=a[b]+g[y],R=a[b+1]+g[y+1],m=a[b+2];d+=(I*v.a+R*v.b+v.worldX)*m,f+=(I*v.c+R*v.d+v.worldY)*m}n[E]=d,n[E+1]=f}}else{o.length>0&&(a=o);for(var v,x=(v=t.bone).worldX,C=v.worldY,T=v.a,b=v.b,A=v.c,S=v.d,w=e,E=r;E<i;w+=2,E+=2){var I=a[w],R=a[w+1];n[E]=I*T+R*b+x,n[E+1]=I*A+R*S+C}}},e.prototype.applyDeform=function(t){return this==t},e})(e);t.VertexAttachment=i})(r||(r={}));(function(t){(function(t){t[t.Region=0]="Region",t[t.BoundingBox=1]="BoundingBox",t[t.Mesh=2]="Mesh",t[t.LinkedMesh=3]="LinkedMesh",t[t.Path=4]="Path"})(t.AttachmentType||(t.AttachmentType={}));t.AttachmentType})(r||(r={}));(function(t){var e=(function(e){function i(i){e.call(this,i),this.color=new t.Color(1,1,1,1)}return n(i,e),i})(t.VertexAttachment);t.BoundingBoxAttachment=e})(r||(r={}));(function(t){var e=(function(e){function i(i){e.call(this,i),this.color=new t.Color(1,1,1,1),this.inheritDeform=!1,this.tempColor=new t.Color(0,0,0,0)}return n(i,e),i.prototype.updateUVs=function(){var e=this.regionUVs,i=e.length,n=8*(i>>1);null!=this.worldVertices&&this.worldVertices.length==n||(this.worldVertices=t.Utils.newFloatArray(n));var r=0,s=0,o=0,a=0;if(null==this.region?(r=s=0,o=a=1):(r=this.region.u,s=this.region.v,o=this.region.u2-r,a=this.region.v2-s),this.region.rotate)for(var c=0,h=6;c<i;c+=2,h+=8)this.worldVertices[h]=r+e[c+1]*o,this.worldVertices[h+1]=s+a-e[c]*a;else for(c=0,h=6;c<i;c+=2,h+=8)this.worldVertices[h]=r+e[c]*o,this.worldVertices[h+1]=s+e[c+1]*a},i.prototype.updateWorldVertices=function(t,e){var i=t.bone.skeleton,n=i.color,r=t.color,s=this.color,o=n.a*r.a*s.a,a=e?o:1,c=this.tempColor;c.set(n.r*r.r*s.r*a,n.g*r.g*s.g*a,n.b*r.b*s.b*a,o);var h=t.attachmentVertices,l=this.vertices,u=this.worldVertices,_=this.bones;if(null==_){var d=l.length;h.length>0&&(l=h);for(var f=(R=t.bone).worldX,p=R.worldY,m=R.a,g=R.b,y=R.c,v=R.d,x=0,C=0;x<d;x+=2,C+=8){var T=l[x],b=l[x+1];u[C]=T*m+b*g+f,u[C+1]=T*y+b*v+p,u[C+2]=c.r,u[C+3]=c.g,u[C+4]=c.b,u[C+5]=c.a}return u}var A=i.bones;if(0==h.length){C=0,x=0,g=0;for(var S=_.length;x<S;C+=8){for(var w=0,E=0,I=_[x++]+x;x<I;x++,g+=3){var R=A[_[x]],P=(T=l[g],b=l[g+1],l[g+2]);w+=(T*R.a+b*R.b+R.worldX)*P,E+=(T*R.c+b*R.d+R.worldY)*P}u[C]=w,u[C+1]=E,u[C+2]=c.r,u[C+3]=c.g,u[C+4]=c.b,u[C+5]=c.a}}else{var O=h,B=(C=0,x=0,g=0,0);for(S=_.length;x<S;C+=8){for(w=0,E=0,I=_[x++]+x;x<I;x++,g+=3,B+=2){R=A[_[x]],T=l[g]+O[B],b=l[g+1]+O[B+1],P=l[g+2];w+=(T*R.a+b*R.b+R.worldX)*P,E+=(T*R.c+b*R.d+R.worldY)*P}u[C]=w,u[C+1]=E,u[C+2]=c.r,u[C+3]=c.g,u[C+4]=c.b,u[C+5]=c.a}}return u},i.prototype.applyDeform=function(t){return this==t||this.inheritDeform&&this.parentMesh==t},i.prototype.getParentMesh=function(){return this.parentMesh},i.prototype.setParentMesh=function(t){this.parentMesh=t,null!=t&&(this.bones=t.bones,this.vertices=t.vertices,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength)},i})(t.VertexAttachment);t.MeshAttachment=e})(r||(r={}));(function(t){var e=(function(e){function i(i){e.call(this,i),this.closed=!1,this.constantSpeed=!1,this.color=new t.Color(1,1,1,1)}return n(i,e),i})(t.VertexAttachment);t.PathAttachment=e})(r||(r={}));(function(t){var e=(function(e){function i(i){e.call(this,i),this.x=0,this.y=0,this.scaleX=1,this.scaleY=1,this.rotation=0,this.width=0,this.height=0,this.color=new t.Color(1,1,1,1),this.offset=t.Utils.newFloatArray(8),this.vertices=t.Utils.newFloatArray(32),this.tempColor=new t.Color(1,1,1,1)}return n(i,e),i.prototype.setRegion=function(t){var e=this.vertices;t.rotate?(e[i.U2]=t.u,e[i.V2]=t.v2,e[i.U3]=t.u,e[i.V3]=t.v,e[i.U4]=t.u2,e[i.V4]=t.v,e[i.U1]=t.u2,e[i.V1]=t.v2):(e[i.U1]=t.u,e[i.V1]=t.v2,e[i.U2]=t.u,e[i.V2]=t.v,e[i.U3]=t.u2,e[i.V3]=t.v,e[i.U4]=t.u2,e[i.V4]=t.v2),this.region=t},i.prototype.updateOffset=function(){var t=this.width/this.region.originalWidth*this.scaleX,e=this.height/this.region.originalHeight*this.scaleY,n=-this.width/2*this.scaleX+this.region.offsetX*t,r=-this.height/2*this.scaleY+this.region.offsetY*e,s=n+this.region.width*t,o=r+this.region.height*e,a=this.rotation*Math.PI/180,c=Math.cos(a),h=Math.sin(a),l=n*c+this.x,u=n*h,_=r*c+this.y,d=r*h,f=s*c+this.x,p=s*h,m=o*c+this.y,g=o*h,y=this.offset;y[i.OX1]=l-d,y[i.OY1]=_+u,y[i.OX2]=l-g,y[i.OY2]=m+u,y[i.OX3]=f-g,y[i.OY3]=m+p,y[i.OX4]=f-d,y[i.OY4]=_+p},i.prototype.updateWorldVertices=function(t,e){var n=t.bone.skeleton.color,r=t.color,s=this.color,o=n.a*r.a*s.a,a=e?o:1,c=this.tempColor;c.set(n.r*r.r*s.r*a,n.g*r.g*s.g*a,n.b*r.b*s.b*a,o);var h=this.vertices,l=this.offset,u=t.bone,_=u.worldX,d=u.worldY,f=u.a,p=u.b,m=u.c,g=u.d,y=0,v=0;return y=l[i.OX1],v=l[i.OY1],h[i.X1]=y*f+v*p+_,h[i.Y1]=y*m+v*g+d,h[i.C1R]=c.r,h[i.C1G]=c.g,h[i.C1B]=c.b,h[i.C1A]=c.a,y=l[i.OX2],v=l[i.OY2],h[i.X2]=y*f+v*p+_,h[i.Y2]=y*m+v*g+d,h[i.C2R]=c.r,h[i.C2G]=c.g,h[i.C2B]=c.b,h[i.C2A]=c.a,y=l[i.OX3],v=l[i.OY3],h[i.X3]=y*f+v*p+_,h[i.Y3]=y*m+v*g+d,h[i.C3R]=c.r,h[i.C3G]=c.g,h[i.C3B]=c.b,h[i.C3A]=c.a,y=l[i.OX4],v=l[i.OY4],h[i.X4]=y*f+v*p+_,h[i.Y4]=y*m+v*g+d,h[i.C4R]=c.r,h[i.C4G]=c.g,h[i.C4B]=c.b,h[i.C4A]=c.a,h},i.OX1=0,i.OY1=1,i.OX2=2,i.OY2=3,i.OX3=4,i.OY3=5,i.OX4=6,i.OY4=7,i.X1=0,i.Y1=1,i.C1R=2,i.C1G=3,i.C1B=4,i.C1A=5,i.U1=6,i.V1=7,i.X2=8,i.Y2=9,i.C2R=10,i.C2G=11,i.C2B=12,i.C2A=13,i.U2=14,i.V2=15,i.X3=16,i.Y3=17,i.C3R=18,i.C3G=19,i.C3B=20,i.C3A=21,i.U3=22,i.V3=23,i.X4=24,i.Y4=25,i.C4R=26,i.C4G=27,i.C4B=28,i.C4A=29,i.U4=30,i.V4=31,i})(t.Attachment);t.RegionAttachment=e})(r||(r={}));(function(t){(function(t){t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen"})(t.BlendMode||(t.BlendMode={}));t.BlendMode})(r||(r={}));(function(t){var e=(function(){function e(t,e,i){if(this.children=new Array,this.x=0,this.y=0,this.rotation=0,this.scaleX=0,this.scaleY=0,this.shearX=0,this.shearY=0,this.ax=0,this.ay=0,this.arotation=0,this.ascaleX=0,this.ascaleY=0,this.ashearX=0,this.ashearY=0,this.appliedValid=!1,this.a=0,this.b=0,this.worldX=0,this.c=0,this.d=0,this.worldY=0,this.sorted=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=i,this.setToSetupPose()}return e.prototype.update=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},e.prototype.updateWorldTransform=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},e.prototype.updateWorldTransformWith=function(e,i,n,r,s,o,a){this.ax=e,this.ay=i,this.arotation=n,this.ascaleX=r,this.ascaleY=s,this.ashearX=o,this.ashearY=a,this.appliedValid=!0;var c=this.parent;if(null==c){var h=n+90+a,l=t.MathUtils.cosDeg(n+o)*r,u=t.MathUtils.cosDeg(h)*s,_=t.MathUtils.sinDeg(n+o)*r,d=t.MathUtils.sinDeg(h)*s,f=this.skeleton;return f.flipX&&(e=-e,l=-l,u=-u),f.flipY&&(i=-i,_=-_,d=-d),this.a=l,this.b=u,this.c=_,this.d=d,this.worldX=e+f.x,void(this.worldY=i+f.y)}var p=c.a,m=c.b,g=c.c,y=c.d;switch(this.worldX=p*e+m*i+c.worldX,this.worldY=g*e+y*i+c.worldY,this.data.transformMode){case t.TransformMode.Normal:h=n+90+a,l=t.MathUtils.cosDeg(n+o)*r,u=t.MathUtils.cosDeg(h)*s,_=t.MathUtils.sinDeg(n+o)*r,d=t.MathUtils.sinDeg(h)*s;return this.a=p*l+m*_,this.b=p*u+m*d,this.c=g*l+y*_,void(this.d=g*u+y*d);case t.TransformMode.OnlyTranslation:h=n+90+a;this.a=t.MathUtils.cosDeg(n+o)*r,this.b=t.MathUtils.cosDeg(h)*s,this.c=t.MathUtils.sinDeg(n+o)*r,this.d=t.MathUtils.sinDeg(h)*s;break;case t.TransformMode.NoRotationOrReflection:var v=0;(T=p*p+g*g)>1e-4?(m=g*(T=Math.abs(p*y-m*g)/T),y=p*T,v=Math.atan2(g,p)*t.MathUtils.radDeg):(p=0,g=0,v=90-Math.atan2(y,m)*t.MathUtils.radDeg);var x=n+o-v,C=n+a-v+90;l=t.MathUtils.cosDeg(x)*r,u=t.MathUtils.cosDeg(C)*s,_=t.MathUtils.sinDeg(x)*r,d=t.MathUtils.sinDeg(C)*s;this.a=p*l-m*_,this.b=p*u-m*d,this.c=g*l+y*_,this.d=g*u+y*d;break;case t.TransformMode.NoScale:case t.TransformMode.NoScaleOrReflection:var T,b=t.MathUtils.cosDeg(n),A=t.MathUtils.sinDeg(n),S=p*b+m*A,w=g*b+y*A;(T=Math.sqrt(S*S+w*w))>1e-5&&(T=1/T),S*=T,w*=T,T=Math.sqrt(S*S+w*w);var E=Math.PI/2+Math.atan2(w,S),I=Math.cos(E)*T,R=Math.sin(E)*T;l=t.MathUtils.cosDeg(o)*r,u=t.MathUtils.cosDeg(90+a)*s,_=t.MathUtils.sinDeg(o)*r,d=t.MathUtils.sinDeg(90+a)*s;return this.a=S*l+I*_,this.b=S*u+I*d,this.c=w*l+R*_,this.d=w*u+R*d,void((this.data.transformMode!=t.TransformMode.NoScaleOrReflection?p*y-m*g<0:this.skeleton.flipX!=this.skeleton.flipY)&&(this.b=-this.b,this.d=-this.d))}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)},e.prototype.setToSetupPose=function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY},e.prototype.getWorldRotationX=function(){return Math.atan2(this.c,this.a)*t.MathUtils.radDeg},e.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*t.MathUtils.radDeg},e.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)},e.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)},e.prototype.worldToLocalRotationX=function(){var e=this.parent;if(null==e)return this.arotation;var i=e.a,n=e.b,r=e.c,s=e.d,o=this.a,a=this.c;return Math.atan2(i*a-r*o,s*o-n*a)*t.MathUtils.radDeg},e.prototype.worldToLocalRotationY=function(){var e=this.parent;if(null==e)return this.arotation;var i=e.a,n=e.b,r=e.c,s=e.d,o=this.b,a=this.d;return Math.atan2(i*a-r*o,s*o-n*a)*t.MathUtils.radDeg},e.prototype.rotateWorld=function(e){var i=this.a,n=this.b,r=this.c,s=this.d,o=t.MathUtils.cosDeg(e),a=t.MathUtils.sinDeg(e);this.a=o*i-a*r,this.b=o*n-a*s,this.c=a*i+o*r,this.d=a*n+o*s,this.appliedValid=!1},e.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var e=this.parent;if(null==e)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*t.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*t.MathUtils.radDeg);var i=e.a,n=e.b,r=e.c,s=e.d,o=1/(i*s-n*r),a=this.worldX-e.worldX,c=this.worldY-e.worldY;this.ax=a*s*o-c*n*o,this.ay=c*i*o-a*r*o;var h=o*s,l=o*i,u=o*n,_=o*r,d=h*this.a-u*this.c,f=h*this.b-u*this.d,p=l*this.c-_*this.a,m=l*this.d-_*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(d*d+p*p),this.ascaleX>1e-4){var g=d*m-f*p;this.ascaleY=g/this.ascaleX,this.ashearY=Math.atan2(d*f+p*m,g)*t.MathUtils.radDeg,this.arotation=Math.atan2(p,d)*t.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(f*f+m*m),this.ashearY=0,this.arotation=90-Math.atan2(m,f)*t.MathUtils.radDeg},e.prototype.worldToLocal=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=1/(e*r-i*n),o=t.x-this.worldX,a=t.y-this.worldY;return t.x=o*r*s-a*i*s,t.y=a*e*s-o*n*s,t},e.prototype.localToWorld=function(t){var e=t.x,i=t.y;return t.x=e*this.a+i*this.b+this.worldX,t.y=e*this.c+i*this.d+this.worldY,t},e})();t.Bone=e})(r||(r={}));(function(t){var e=(function(){return function(t,e,n){if(this.x=0,this.y=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.shearX=0,this.shearY=0,this.transformMode=i.Normal,t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=n}})();t.BoneData=e,(function(t){t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection"})(t.TransformMode||(t.TransformMode={}));var i=t.TransformMode})(r||(r={}));(function(t){var e=(function(){return function(t,e){if(null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}})();t.Event=e})(r||(r={}));(function(t){var e=(function(){return function(t){this.name=t}})();t.EventData=e})(r||(r={}));(function(t){var e=(function(){function e(t,e){if(this.mix=1,this.bendDirection=0,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(var i=0;i<t.bones.length;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findBone(t.target.name)}return e.prototype.getOrder=function(){return this.data.order},e.prototype.apply=function(){this.update()},e.prototype.update=function(){var t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.mix)}},e.prototype.apply1=function(e,i,n,r){e.appliedValid||e.updateAppliedTransform();var s=e.parent,o=1/(s.a*s.d-s.b*s.c),a=i-s.worldX,c=n-s.worldY,h=(a*s.d-c*s.b)*o-e.ax,l=(c*s.a-a*s.c)*o-e.ay,u=Math.atan2(l,h)*t.MathUtils.radDeg-e.ashearX-e.arotation;e.ascaleX<0&&(u+=180),u>180?u-=360:u<-180&&(u+=360),e.updateWorldTransformWith(e.ax,e.ay,e.arotation+u*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)},e.prototype.apply2=function(e,i,n,r,s,o){if(0!=o){e.appliedValid||e.updateAppliedTransform(),i.appliedValid||i.updateAppliedTransform();var a=e.ax,c=e.ay,h=e.ascaleX,l=e.ascaleY,u=i.ascaleX,_=0,d=0,f=0;h<0?(h=-h,_=180,f=-1):(_=0,f=1),l<0&&(l=-l,f=-f),u<0?(u=-u,d=180):d=0;var p=i.ax,m=0,g=0,y=0,v=e.a,x=e.b,C=e.c,T=e.d,b=Math.abs(h-l)<=1e-4;b?(g=v*p+x*(m=i.ay)+e.worldX,y=C*p+T*m+e.worldY):(m=0,g=v*p+e.worldX,y=C*p+e.worldY);var A=e.parent;v=A.a,x=A.b,C=A.c;var S=1/(v*(T=A.d)-x*C),w=n-A.worldX,E=r-A.worldY,I=(w*T-E*x)*S-a,R=(E*v-w*C)*S-c,P=((w=g-A.worldX)*T-(E=y-A.worldY)*x)*S-a,O=(E*v-w*C)*S-c,B=Math.sqrt(P*P+O*O),D=i.data.length*u,M=0,L=0;t:if(b){var N=(I*I+R*R-B*B-(D*=h)*D)/(2*B*D);N<-1?N=-1:N>1&&(N=1),L=Math.acos(N)*s,v=B+D*N,x=D*Math.sin(L),M=Math.atan2(R*v-I*x,I*v+R*x)}else{var F=(v=h*D)*v,k=(x=l*D)*x,z=I*I+R*R,V=Math.atan2(R,I),G=-2*k*B,W=k-F;if((T=G*G-4*W*(C=k*B*B+F*z-F*k))>=0){var U=Math.sqrt(T);G<0&&(U=-U);var j=(U=-(G+U)/2)/W,X=C/U,Y=Math.abs(j)<Math.abs(X)?j:X;if(Y*Y<=z){E=Math.sqrt(z-Y*Y)*s,M=V-Math.atan2(E,Y),L=Math.atan2(E/l,(Y-B)/h);break t}}var H=0,q=Number.MAX_VALUE,J=0,Z=0,Q=0,K=0,$=0,tt=0;(T=(w=B+v)*w)>K&&(Q=0,K=T,$=w),(T=(w=B-v)*w)<q&&(H=t.MathUtils.PI,q=T,J=w);var et=Math.acos(-v*B/(F-k));(T=(w=v*Math.cos(et)+B)*w+(E=x*Math.sin(et))*E)<q&&(H=et,q=T,J=w,Z=E),T>K&&(Q=et,K=T,$=w,tt=E),z<=(q+K)/2?(M=V-Math.atan2(Z*s,J),L=H*s):(M=V-Math.atan2(tt*s,$),L=Q*s)}var it=Math.atan2(m,p)*f,nt=e.arotation;(M=(M-it)*t.MathUtils.radDeg+_-nt)>180?M-=360:M<-180&&(M+=360),e.updateWorldTransformWith(a,c,nt+M*o,e.ascaleX,e.ascaleY,0,0),nt=i.arotation,(L=((L+it)*t.MathUtils.radDeg-i.ashearX)*f+d-nt)>180?L-=360:L<-180&&(L+=360),i.updateWorldTransformWith(p,m,nt+L*o,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY)}else i.updateWorldTransform()},e})();t.IkConstraint=e})(r||(r={}));(function(t){var e=(function(){return function(t){this.order=0,this.bones=new Array,this.bendDirection=1,this.mix=1,this.name=t}})();t.IkConstraintData=e})(r||(r={}));(function(t){var e=(function(){function e(t,e){if(this.position=0,this.spacing=0,this.rotateMix=0,this.translateMix=0,this.spaces=new Array,this.positions=new Array,this.world=new Array,this.curves=new Array,this.lengths=new Array,this.segments=new Array,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(var i=0,n=t.bones.length;i<n;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}return e.prototype.apply=function(){this.update()},e.prototype.update=function(){var e=this.target.getAttachment();if(e instanceof t.PathAttachment){var i=this.rotateMix,n=this.translateMix,r=i>0;if(n>0||r){var s=this.data,o=s.spacingMode,a=o==t.SpacingMode.Length,c=s.rotateMode,h=c==t.RotateMode.Tangent,l=c==t.RotateMode.ChainScale,u=this.bones.length,_=h?u:u+1,d=this.bones,f=t.Utils.setArraySize(this.spaces,_),p=null,m=this.spacing;if(l||a){l&&(p=t.Utils.setArraySize(this.lengths,u));for(var g=0,y=_-1;g<y;){var v=(I=d[g]).data.length,x=v*I.a,C=v*I.c;v=Math.sqrt(x*x+C*C),l&&(p[g]=v),f[++g]=a?Math.max(0,v+m):m}}else for(g=1;g<_;g++)f[g]=m;var T=this.computeWorldPositions(e,_,h,s.positionMode==t.PositionMode.Percent,o==t.SpacingMode.Percent),b=T[0],A=T[1],S=s.offsetRotation,w=!1;if(0==S)w=c==t.RotateMode.Chain;else{w=!1;S*=(E=this.target.bone).a*E.d-E.b*E.c>0?t.MathUtils.degRad:-t.MathUtils.degRad}g=0;for(var E=3;g<u;g++,E+=3){var I;(I=d[g]).worldX+=(b-I.worldX)*n,I.worldY+=(A-I.worldY)*n;var R=(x=T[E])-b,P=(C=T[E+1])-A;if(l){var O=p[g];if(0!=O){var B=(Math.sqrt(R*R+P*P)/O-1)*i+1;I.a*=B,I.c*=B}}if(b=x,A=C,r){var D=I.a,M=I.b,L=I.c,N=I.d,F=0,k=0,z=0;if(F=h?T[E-1]:0==f[g+1]?T[E+2]:Math.atan2(P,R),F-=Math.atan2(L,D),w){k=Math.cos(F),z=Math.sin(F);var V=I.data.length;b+=(V*(k*D-z*L)-R)*i,A+=(V*(z*D+k*L)-P)*i}else F+=S;F>t.MathUtils.PI?F-=t.MathUtils.PI2:F<-t.MathUtils.PI&&(F+=t.MathUtils.PI2),F*=i,k=Math.cos(F),z=Math.sin(F),I.a=k*D-z*L,I.b=k*M-z*N,I.c=z*D+k*L,I.d=z*M+k*N}I.appliedValid=!1}}}},e.prototype.computeWorldPositions=function(i,n,r,s,o){var a=this.target,c=this.position,h=this.spaces,l=t.Utils.setArraySize(this.positions,3*n+2),u=null,_=i.closed,d=i.worldVerticesLength,f=d/6,p=e.NONE;if(!i.constantSpeed){var m=i.lengths,g=m[f-=_?1:2];if(s&&(c*=g),o)for(var y=0;y<n;y++)h[y]*=g;u=t.Utils.setArraySize(this.world,8);y=0;for(var v=0,x=0;y<n;y++,v+=3){var C=c+=X=h[y];if(_)(C%=g)<0&&(C+=g),x=0;else{if(C<0){p!=e.BEFORE&&(p=e.BEFORE,i.computeWorldVerticesWith(a,2,4,u,0)),this.addBeforePosition(C,u,0,l,v);continue}if(C>g){p!=e.AFTER&&(p=e.AFTER,i.computeWorldVerticesWith(a,d-6,4,u,0)),this.addAfterPosition(C-g,u,0,l,v);continue}}for(;;x++){var T=m[x];if(!(C>T)){if(0==x)C/=T;else{C=(C-(J=m[x-1]))/(T-J)}break}}x!=p&&(p=x,_&&x==f?(i.computeWorldVerticesWith(a,d-4,4,u,0),i.computeWorldVerticesWith(a,0,4,u,4)):i.computeWorldVerticesWith(a,6*x+2,8,u,0)),this.addCurvePosition(C,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],l,v,r||y>0&&0==X)}return l}_?(d+=2,u=t.Utils.setArraySize(this.world,d),i.computeWorldVerticesWith(a,2,d-4,u,0),i.computeWorldVerticesWith(a,0,2,u,d-4),u[d-2]=u[0],u[d-1]=u[1]):(f--,d-=4,u=t.Utils.setArraySize(this.world,d),i.computeWorldVerticesWith(a,2,d,u,0));for(var b=t.Utils.setArraySize(this.curves,f),A=0,S=u[0],w=u[1],E=0,I=0,R=0,P=0,O=0,B=0,D=0,M=0,L=0,N=0,F=0,k=0,z=0,V=0,G=(y=0,2);y<f;y++,G+=6)E=u[G],I=u[G+1],R=u[G+2],P=u[G+3],F=2*(D=.1875*(S-2*E+R))+(L=.09375*(3*(E-R)-S+(O=u[G+4]))),k=2*(M=.1875*(w-2*I+P))+(N=.09375*(3*(I-P)-w+(B=u[G+5]))),z=.75*(E-S)+D+.16666667*L,V=.75*(I-w)+M+.16666667*N,A+=Math.sqrt(z*z+V*V),z+=F,V+=k,F+=L,k+=N,A+=Math.sqrt(z*z+V*V),z+=F,V+=k,A+=Math.sqrt(z*z+V*V),z+=F+L,V+=k+N,A+=Math.sqrt(z*z+V*V),b[y]=A,S=O,w=B;if(s&&(c*=A),o)for(y=0;y<n;y++)h[y]*=A;for(var W=this.segments,U=0,j=(y=0,v=0,x=0,0);y<n;y++,v+=3){var X;C=c+=X=h[y];if(_)(C%=A)<0&&(C+=A),x=0;else{if(C<0){this.addBeforePosition(C,u,0,l,v);continue}if(C>A){this.addAfterPosition(C-A,u,d-4,l,v);continue}}for(;;x++){var Y=b[x];if(!(C>Y)){if(0==x)C/=Y;else{C=(C-(J=b[x-1]))/(Y-J)}break}}if(x!=p){p=x;var H=6*x;for(S=u[H],w=u[H+1],E=u[H+2],I=u[H+3],R=u[H+4],P=u[H+5],F=2*(D=.03*(S-2*E+R))+(L=.006*(3*(E-R)-S+(O=u[H+6]))),k=2*(M=.03*(w-2*I+P))+(N=.006*(3*(I-P)-w+(B=u[H+7]))),z=.3*(E-S)+D+.16666667*L,V=.3*(I-w)+M+.16666667*N,U=Math.sqrt(z*z+V*V),W[0]=U,H=1;H<8;H++)z+=F,V+=k,F+=L,k+=N,U+=Math.sqrt(z*z+V*V),W[H]=U;z+=F,V+=k,U+=Math.sqrt(z*z+V*V),W[8]=U,z+=F+L,V+=k+N,U+=Math.sqrt(z*z+V*V),W[9]=U,j=0}for(C*=U;;j++){var q=W[j];if(!(C>q)){if(0==j)C/=q;else{var J;C=j+(C-(J=W[j-1]))/(q-J)}break}}this.addCurvePosition(.1*C,S,w,E,I,R,P,O,B,l,v,r||y>0&&0==X)}return l},e.prototype.addBeforePosition=function(t,e,i,n,r){var s=e[i],o=e[i+1],a=e[i+2]-s,c=e[i+3]-o,h=Math.atan2(c,a);n[r]=s+t*Math.cos(h),n[r+1]=o+t*Math.sin(h),n[r+2]=h},e.prototype.addAfterPosition=function(t,e,i,n,r){var s=e[i+2],o=e[i+3],a=s-e[i],c=o-e[i+1],h=Math.atan2(c,a);n[r]=s+t*Math.cos(h),n[r+1]=o+t*Math.sin(h),n[r+2]=h},e.prototype.addCurvePosition=function(t,e,i,n,r,s,o,a,c,h,l,u){(0==t||isNaN(t))&&(t=1e-4);var _=t*t,d=_*t,f=1-t,p=f*f,m=p*f,g=f*t,y=3*g,v=f*y,x=y*t,C=e*m+n*v+s*x+a*d,T=i*m+r*v+o*x+c*d;h[l]=C,h[l+1]=T,u&&(h[l+2]=Math.atan2(T-(i*p+r*g*2+o*_),C-(e*p+n*g*2+s*_)))},e.prototype.getOrder=function(){return this.data.order},e.NONE=-1,e.BEFORE=-2,e.AFTER=-3,e})();t.PathConstraint=e})(r||(r={}));(function(t){var e=(function(){return function(t){this.order=0,this.bones=new Array,this.name=t}})();t.PathConstraintData=e,(function(t){t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent"})(t.PositionMode||(t.PositionMode={}));t.PositionMode;(function(t){t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent"})(t.SpacingMode||(t.SpacingMode={}));t.SpacingMode;(function(t){t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale"})(t.RotateMode||(t.RotateMode={}));t.RotateMode})(r||(r={}));(function(t){var e=(function(){function t(t){this.toLoad=new Array,this.assets={},this.clientId=t}return t.prototype.loaded=function(){var t=0;for(var e in this.assets)t++;return t},t})(),i=(function(){function t(t){void 0===t&&(t=""),this.clientAssets={},this.queuedAssets={},this.rawAssets={},this.errors={},this.pathPrefix=t}return t.prototype.queueAsset=function(t,i,n){var r=this.clientAssets[t];return null!==r&&void 0!==r||(r=new e(t),this.clientAssets[t]=r),null!==i&&(r.textureLoader=i),r.toLoad.push(n),this.queuedAssets[n]!==n&&(this.queuedAssets[n]=n,!0)},t.prototype.loadText=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=n.responseText:i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadJson=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=JSON.parse(n.responseText):i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadTexture=function(t,e,i){var n=this;if(i=this.pathPrefix+i,this.queueAsset(t,e,i)){var r=new Image;r.src=i,r.crossOrigin="anonymous",r.onload=function(t){n.rawAssets[i]=r},r.onerror=function(t){n.errors[i]="Couldn't load image "+i}}},t.prototype.get=function(t,e){e=this.pathPrefix+e;var i=this.clientAssets[t];return null===i||void 0===i||i.assets[e]},t.prototype.updateClientAssets=function(t){for(var e=0;e<t.toLoad.length;e++){var i=t.toLoad[e],n=t.assets[i];if(null===n||void 0===n){var r=this.rawAssets[i];if(null===r||void 0===r)continue;r instanceof HTMLImageElement?t.assets[i]=t.textureLoader(r):t.assets[i]=r}}},t.prototype.isLoadingComplete=function(t){var e=this.clientAssets[t];return null===e||void 0===e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())},t.prototype.dispose=function(){},t.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},t.prototype.getErrors=function(){return this.errors},t})();t.SharedAssetManager=i})(r||(r={}));(function(t){var e=(function(){function e(e){if(this._updateCache=new Array,this.updateCacheReset=new Array,this.time=0,this.flipX=!1,this.flipY=!1,this.x=0,this.y=0,null==e)throw new Error("data cannot be null.");this.data=e,this.bones=new Array;for(var i=0;i<e.bones.length;i++){var n=e.bones[i],r=void 0;if(null==n.parent)r=new t.Bone(n,this,null);else{var s=this.bones[n.parent.index];r=new t.Bone(n,this,s),s.children.push(r)}this.bones.push(r)}this.slots=new Array,this.drawOrder=new Array;for(i=0;i<e.slots.length;i++){var o=e.slots[i],a=(r=this.bones[o.boneData.index],new t.Slot(o,r));this.slots.push(a),this.drawOrder.push(a)}this.ikConstraints=new Array;for(i=0;i<e.ikConstraints.length;i++){var c=e.ikConstraints[i];this.ikConstraints.push(new t.IkConstraint(c,this))}this.transformConstraints=new Array;for(i=0;i<e.transformConstraints.length;i++){var h=e.transformConstraints[i];this.transformConstraints.push(new t.TransformConstraint(h,this))}this.pathConstraints=new Array;for(i=0;i<e.pathConstraints.length;i++){var l=e.pathConstraints[i];this.pathConstraints.push(new t.PathConstraint(l,this))}this.color=new t.Color(1,1,1,1),this.updateCache()}return e.prototype.updateCache=function(){this._updateCache.length=0;for(var t=this.bones,e=0,i=t.length;e<i;e++)t[e].sorted=!1;var n=this.ikConstraints,r=this.transformConstraints,s=this.pathConstraints,o=n.length,a=r.length,c=s.length,h=o+a+c;t:for(e=0;e<h;e++){for(var l=0;l<o;l++){if((u=n[l]).data.order==e){this.sortIkConstraint(u);continue t}}for(l=0;l<a;l++){if((u=r[l]).data.order==e){this.sortTransformConstraint(u);continue t}}for(l=0;l<c;l++){var u;if((u=s[l]).data.order==e){this.sortPathConstraint(u);continue t}}}for(e=0,i=t.length;e<i;e++)this.sortBone(t[e])},e.prototype.sortIkConstraint=function(t){var e=t.target;this.sortBone(e);var i=t.bones,n=i[0];if(this.sortBone(n),i.length>1){var r=i[i.length-1];this._updateCache.indexOf(r)>-1||this.updateCacheReset.push(r)}this._updateCache.push(t),this.sortReset(n.children),i[i.length-1].sorted=!0},e.prototype.sortPathConstraint=function(e){var i=e.target,n=i.data.index,r=i.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,n,r),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,n,r);for(var s=0,o=this.data.skins.length;s<o;s++)this.sortPathConstraintAttachment(this.data.skins[s],n,r);var a=i.getAttachment();a instanceof t.PathAttachment&&this.sortPathConstraintAttachmentWith(a,r);var c=e.bones,h=c.length;for(s=0;s<h;s++)this.sortBone(c[s]);this._updateCache.push(e);for(s=0;s<h;s++)this.sortReset(c[s].children);for(s=0;s<h;s++)c[s].sorted=!0},e.prototype.sortTransformConstraint=function(t){this.sortBone(t.target);for(var e=t.bones,i=e.length,n=0;n<i;n++)this.sortBone(e[n]);this._updateCache.push(t);for(n=0;n<i;n++)this.sortReset(e[n].children);for(n=0;n<i;n++)e[n].sorted=!0},e.prototype.sortPathConstraintAttachment=function(t,e,i){var n=t.attachments[e];if(n)for(var r in n)this.sortPathConstraintAttachmentWith(n[r],i)},e.prototype.sortPathConstraintAttachmentWith=function(e,i){if(e instanceof t.PathAttachment){var n=e.bones;if(null==n)this.sortBone(i);else for(var r=this.bones,s=0;s<n.length;)for(var o=n[s++],a=s+o;s<a;s++){var c=n[s];this.sortBone(r[c])}}},e.prototype.sortBone=function(t){if(!t.sorted){var e=t.parent;null!=e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}},e.prototype.sortReset=function(t){for(var e=0,i=t.length;e<i;e++){var n=t[e];n.sorted&&this.sortReset(n.children),n.sorted=!1}},e.prototype.updateWorldTransform=function(){for(var t=this.updateCacheReset,e=0,i=t.length;e<i;e++){var n=t[e];n.ax=n.x,n.ay=n.y,n.arotation=n.rotation,n.ascaleX=n.scaleX,n.ascaleY=n.scaleY,n.ashearX=n.shearX,n.ashearY=n.shearY,n.appliedValid=!0}var r=this._updateCache;for(e=0,i=r.length;e<i;e++)r[e].update()},e.prototype.setToSetupPose=function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},e.prototype.setBonesToSetupPose=function(){for(var t=this.bones,e=0,i=t.length;e<i;e++)t[e].setToSetupPose();var n=this.ikConstraints;for(e=0,i=n.length;e<i;e++){(a=n[e]).bendDirection=a.data.bendDirection,a.mix=a.data.mix}var r=this.transformConstraints;for(e=0,i=r.length;e<i;e++){var s=(a=r[e]).data;a.rotateMix=s.rotateMix,a.translateMix=s.translateMix,a.scaleMix=s.scaleMix,a.shearMix=s.shearMix}var o=this.pathConstraints;for(e=0,i=o.length;e<i;e++){var a;s=(a=o[e]).data;a.position=s.position,a.spacing=s.spacing,a.rotateMix=s.rotateMix,a.translateMix=s.translateMix}},e.prototype.setSlotsToSetupPose=function(){var e=this.slots;t.Utils.arrayCopy(e,0,this.drawOrder,0,e.length);for(var i=0,n=e.length;i<n;i++)e[i].setToSetupPose()},e.prototype.getRootBone=function(){return 0==this.bones.length?null:this.bones[0]},e.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findBoneIndex=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++)if(e[i].data.name==t)return i;return-1},e.prototype.findSlot=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findSlotIndex=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++)if(e[i].data.name==t)return i;return-1},e.prototype.setSkinByName=function(t){var e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)},e.prototype.setSkin=function(t){if(null!=t)if(null!=this.skin)t.attachAll(this,this.skin);else for(var e=this.slots,i=0,n=e.length;i<n;i++){var r=e[i],s=r.data.attachmentName;if(null!=s){var o=t.getAttachment(i,s);null!=o&&r.setAttachment(o)}}this.skin=t},e.prototype.getAttachmentByName=function(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)},e.prototype.getAttachment=function(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){var i=this.skin.getAttachment(t,e);if(null!=i)return i}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null},e.prototype.setAttachment=function(t,e){if(null==t)throw new Error("slotName cannot be null.");for(var i=this.slots,n=0,r=i.length;n<r;n++){var s=i[n];if(s.data.name==t){var o=null;if(null!=e&&null==(o=this.getAttachment(n,e)))throw new Error("Attachment not found: "+e+", for slot: "+t);return void s.setAttachment(o)}}throw new Error("Slot not found: "+t)},e.prototype.findIkConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.ikConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findTransformConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.transformConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.findPathConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.pathConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.data.name==t)return r}return null},e.prototype.getBounds=function(e,i){if(null==e)throw new Error("offset cannot be null.");if(null==i)throw new Error("size cannot be null.");for(var n=this.drawOrder,r=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=0,h=n.length;c<h;c++){var l=n[c],u=null,_=l.getAttachment();if(_ instanceof t.RegionAttachment?u=_.updateWorldVertices(l,!1):_ instanceof t.MeshAttachment&&(u=_.updateWorldVertices(l,!0)),null!=u)for(var d=0,f=u.length;d<f;d+=8){var p=u[d],m=u[d+1];r=Math.min(r,p),s=Math.min(s,m),o=Math.max(o,p),a=Math.max(a,m)}}e.set(r,s),i.set(o-r,a-s)},e.prototype.update=function(t){this.time+=t},e})();t.Skeleton=e})(r||(r={}));(function(t){var e=(function(){function e(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.boundingBoxes=new Array,this.polygons=new Array,this.polygonPool=new t.Pool(function(){return t.Utils.newFloatArray(16)})}return e.prototype.update=function(e,i){if(null==e)throw new Error("skeleton cannot be null.");var n=this.boundingBoxes,r=this.polygons,s=this.polygonPool,o=e.slots,a=o.length;n.length=0,s.freeAll(r),r.length=0;for(var c=0;c<a;c++){var h=o[c],l=h.getAttachment();if(l instanceof t.BoundingBoxAttachment){var u=l;n.push(u);var _=s.obtain();_.length!=u.worldVerticesLength&&(_=t.Utils.newFloatArray(u.worldVerticesLength)),r.push(_),u.computeWorldVertices(h,_)}}i?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)},e.prototype.aabbCompute=function(){for(var t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,r=this.polygons,s=0,o=r.length;s<o;s++)for(var a=r[s],c=a,h=0,l=a.length;h<l;h+=2){var u=c[h],_=c[h+1];t=Math.min(t,u),e=Math.min(e,_),i=Math.max(i,u),n=Math.max(n,_)}this.minX=t,this.minY=e,this.maxX=i,this.maxY=n},e.prototype.aabbContainsPoint=function(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY},e.prototype.aabbIntersectsSegment=function(t,e,i,n){var r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;if(t<=r&&i<=r||e<=s&&n<=s||t>=o&&i>=o||e>=a&&n>=a)return!1;var c=(n-e)/(i-t),h=c*(r-t)+e;if(h>s&&h<a)return!0;if((h=c*(o-t)+e)>s&&h<a)return!0;var l=(s-e)/c+t;return l>r&&l<o||(l=(a-e)/c+t)>r&&l<o},e.prototype.aabbIntersectsSkeleton=function(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY},e.prototype.containsPoint=function(t,e){for(var i=this.polygons,n=0,r=i.length;n<r;n++)if(this.containsPointPolygon(i[n],t,e))return this.boundingBoxes[n];return null},e.prototype.containsPointPolygon=function(t,e,i){for(var n=t,r=t.length,s=r-2,o=!1,a=0;a<r;a+=2){var c=n[a+1],h=n[s+1];if(c<i&&h>=i||h<i&&c>=i){var l=n[a];l+(i-c)/(h-c)*(n[s]-l)<e&&(o=!o)}s=a}return o},e.prototype.intersectsSegment=function(t,e,i,n){for(var r=this.polygons,s=0,o=r.length;s<o;s++)if(this.intersectsSegmentPolygon(r[s],t,e,i,n))return this.boundingBoxes[s];return null},e.prototype.intersectsSegmentPolygon=function(t,e,i,n,r){for(var s=t,o=t.length,a=e-n,c=i-r,h=e*r-i*n,l=s[o-2],u=s[o-1],_=0;_<o;_+=2){var d=s[_],f=s[_+1],p=l*f-u*d,m=l-d,g=u-f,y=a*g-c*m,v=(h*m-a*p)/y;if((v>=l&&v<=d||v>=d&&v<=l)&&(v>=e&&v<=n||v>=n&&v<=e)){var x=(h*g-c*p)/y;if((x>=u&&x<=f||x>=f&&x<=u)&&(x>=i&&x<=r||x>=r&&x<=i))return!0}l=d,u=f}return!1},e.prototype.getPolygon=function(t){if(null==t)throw new Error("boundingBox cannot be null.");var e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]},e.prototype.getWidth=function(){return this.maxX-this.minX},e.prototype.getHeight=function(){return this.maxY-this.minY},e})();t.SkeletonBounds=e})(r||(r={}));(function(t){var e=(function(){function t(){this.bones=new Array,this.slots=new Array,this.skins=new Array,this.events=new Array,this.animations=new Array,this.ikConstraints=new Array,this.transformConstraints=new Array,this.pathConstraints=new Array,this.fps=0}return t.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findBoneIndex=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i<n;i++)if(e[i].name==t)return i;return-1},t.prototype.findSlot=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findSlotIndex=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,n=e.length;i<n;i++)if(e[i].name==t)return i;return-1},t.prototype.findSkin=function(t){if(null==t)throw new Error("skinName cannot be null.");for(var e=this.skins,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findEvent=function(t){if(null==t)throw new Error("eventDataName cannot be null.");for(var e=this.events,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findAnimation=function(t){if(null==t)throw new Error("animationName cannot be null.");for(var e=this.animations,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findIkConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.ikConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findTransformConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.transformConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findPathConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.pathConstraints,i=0,n=e.length;i<n;i++){var r=e[i];if(r.name==t)return r}return null},t.prototype.findPathConstraintIndex=function(t){if(null==t)throw new Error("pathConstraintName cannot be null.");for(var e=this.pathConstraints,i=0,n=e.length;i<n;i++)if(e[i].name==t)return i;return-1},t})();t.SkeletonData=e})(r||(r={}));(function(t){var e=(function(){function e(t){this.scale=1,this.linkedMeshes=new Array,this.attachmentLoader=t}return e.prototype.readSkeletonData=function(i){var n=this.scale,r=new t.SkeletonData,s="string"==typeof i?JSON.parse(i):i,o=s.skeleton;if(null!=o&&(r.hash=o.hash,r.version=o.spine,r.width=o.width,r.height=o.height,r.fps=o.fps,r.imagesPath=o.images),s.bones)for(var a=0;a<s.bones.length;a++){var c=s.bones[a],h=null,l=this.getValue(c,"parent",null);if(null!=l&&null==(h=r.findBone(l)))throw new Error("Parent bone not found: "+l);(f=new t.BoneData(r.bones.length,c.name,h)).length=this.getValue(c,"length",0)*n,f.x=this.getValue(c,"x",0)*n,f.y=this.getValue(c,"y",0)*n,f.rotation=this.getValue(c,"rotation",0),f.scaleX=this.getValue(c,"scaleX",1),f.scaleY=this.getValue(c,"scaleY",1),f.shearX=this.getValue(c,"shearX",0),f.shearY=this.getValue(c,"shearY",0),f.transformMode=e.transformModeFromString(this.getValue(c,"transform","normal")),r.bones.push(f)}if(s.slots)for(a=0;a<s.slots.length;a++){var u=(A=s.slots[a]).name,_=A.bone,d=r.findBone(_);if(null==d)throw new Error("Slot bone not found: "+_);var f=new t.SlotData(r.slots.length,u,d),p=this.getValue(A,"color",null);null!=p&&f.color.setFromString(p),f.attachmentName=this.getValue(A,"attachment",null),f.blendMode=e.blendModeFromString(this.getValue(A,"blend","normal")),r.slots.push(f)}if(s.ik)for(a=0;a<s.ik.length;a++){var m=s.ik[a];(f=new t.IkConstraintData(m.name)).order=this.getValue(m,"order",0);for(var g=0;g<m.bones.length;g++){_=m.bones[g];if(null==(v=r.findBone(_)))throw new Error("IK bone not found: "+_);f.bones.push(v)}var y=m.target;if(f.target=r.findBone(y),null==f.target)throw new Error("IK target bone not found: "+y);f.bendDirection=this.getValue(m,"bendPositive",!0)?1:-1,f.mix=this.getValue(m,"mix",1),r.ikConstraints.push(f)}if(s.transform)for(a=0;a<s.transform.length;a++){m=s.transform[a];(f=new t.TransformConstraintData(m.name)).order=this.getValue(m,"order",0);for(g=0;g<m.bones.length;g++){_=m.bones[g];if(null==(v=r.findBone(_)))throw new Error("Transform constraint bone not found: "+_);f.bones.push(v)}y=m.target;if(f.target=r.findBone(y),null==f.target)throw new Error("Transform constraint target bone not found: "+y);f.offsetRotation=this.getValue(m,"rotation",0),f.offsetX=this.getValue(m,"x",0)*n,f.offsetY=this.getValue(m,"y",0)*n,f.offsetScaleX=this.getValue(m,"scaleX",0),f.offsetScaleY=this.getValue(m,"scaleY",0),f.offsetShearY=this.getValue(m,"shearY",0),f.rotateMix=this.getValue(m,"rotateMix",1),f.translateMix=this.getValue(m,"translateMix",1),f.scaleMix=this.getValue(m,"scaleMix",1),f.shearMix=this.getValue(m,"shearMix",1),r.transformConstraints.push(f)}if(s.path)for(a=0;a<s.path.length;a++){m=s.path[a];(f=new t.PathConstraintData(m.name)).order=this.getValue(m,"order",0);for(g=0;g<m.bones.length;g++){var v;_=m.bones[g];if(null==(v=r.findBone(_)))throw new Error("Transform constraint bone not found: "+_);f.bones.push(v)}y=m.target;if(f.target=r.findSlot(y),null==f.target)throw new Error("Path target slot not found: "+y);f.positionMode=e.positionModeFromString(this.getValue(m,"positionMode","percent")),f.spacingMode=e.spacingModeFromString(this.getValue(m,"spacingMode","length")),f.rotateMode=e.rotateModeFromString(this.getValue(m,"rotateMode","tangent")),f.offsetRotation=this.getValue(m,"rotation",0),f.position=this.getValue(m,"position",0),f.positionMode==t.PositionMode.Fixed&&(f.position*=n),f.spacing=this.getValue(m,"spacing",0),f.spacingMode!=t.SpacingMode.Length&&f.spacingMode!=t.SpacingMode.Fixed||(f.spacing*=n),f.rotateMix=this.getValue(m,"rotateMix",1),f.translateMix=this.getValue(m,"translateMix",1),r.pathConstraints.push(f)}if(s.skins)for(var x in s.skins){var C=s.skins[x],T=new t.Skin(x);for(var u in C){var b=r.findSlotIndex(u);if(-1==b)throw new Error("Slot not found: "+u);var A=C[u];for(var S in A){var w=this.readAttachment(A[S],T,b,S);null!=w&&T.addAttachment(b,S,w)}}r.skins.push(T),"default"==T.name&&(r.defaultSkin=T)}a=0;for(var E=this.linkedMeshes.length;a<E;a++){var I=this.linkedMeshes[a];if(null==(T=null==I.skin?r.defaultSkin:r.findSkin(I.skin)))throw new Error("Skin not found: "+I.skin);var R=T.getAttachment(I.slotIndex,I.parent);if(null==R)throw new Error("Parent mesh not found: "+I.parent);I.mesh.setParentMesh(R),I.mesh.updateUVs()}if(this.linkedMeshes.length=0,s.events)for(var P in s.events){var O=s.events[P];(f=new t.EventData(P)).intValue=this.getValue(O,"int",0),f.floatValue=this.getValue(O,"float",0),f.stringValue=this.getValue(O,"string",""),r.events.push(f)}if(s.animations)for(var B in s.animations){var D=s.animations[B];this.readAnimation(D,B,r)}return r},e.prototype.readAttachment=function(e,n,r,s){var o=this.scale;s=this.getValue(e,"name",s);switch(this.getValue(e,"type","region")){case"region":var a=this.getValue(e,"path",s),c=this.attachmentLoader.newRegionAttachment(n,s,a);if(null==c)return null;c.path=a,c.x=this.getValue(e,"x",0)*o,c.y=this.getValue(e,"y",0)*o,c.scaleX=this.getValue(e,"scaleX",1),c.scaleY=this.getValue(e,"scaleY",1),c.rotation=this.getValue(e,"rotation",0),c.width=e.width*o,c.height=e.height*o;return null!=(m=this.getValue(e,"color",null))&&c.color.setFromString(m),c.updateOffset(),c;case"boundingbox":var h=this.attachmentLoader.newBoundingBoxAttachment(n,s);if(null==h)return null;this.readVertices(e,h,e.vertexCount<<1);return null!=(m=this.getValue(e,"color",null))&&h.color.setFromString(m),h;case"mesh":case"linkedmesh":a=this.getValue(e,"path",s);var l=this.attachmentLoader.newMeshAttachment(n,s,a);if(null==l)return null;l.path=a;null!=(m=this.getValue(e,"color",null))&&l.color.setFromString(m);var u=this.getValue(e,"parent",null);if(null!=u)return l.inheritDeform=this.getValue(e,"deform",!0),this.linkedMeshes.push(new i(l,this.getValue(e,"skin",null),r,u)),l;var _=e.uvs;return this.readVertices(e,l,_.length),l.triangles=e.triangles,l.regionUVs=_,l.updateUVs(),l.hullLength=2*this.getValue(e,"hull",0),l;case"path":if(null==(a=this.attachmentLoader.newPathAttachment(n,s)))return null;a.closed=this.getValue(e,"closed",!1),a.constantSpeed=this.getValue(e,"constantSpeed",!0);var d=e.vertexCount;this.readVertices(e,a,d<<1);for(var f=t.Utils.newArray(d/3,0),p=0;p<e.lengths.length;p++)f[p++]=e.lengths[p]*o;a.lengths=f;var m;return null!=(m=this.getValue(e,"color",null))&&a.color.setFromString(m),a}return null},e.prototype.readVertices=function(e,i,n){var r=this.scale;i.worldVerticesLength=n;var s=e.vertices;if(n!=s.length){var o=new Array,a=new Array;for(l=0,u=s.length;l<u;){var c=s[l++];a.push(c);for(var h=l+4*c;l<h;l+=4)a.push(s[l]),o.push(s[l+1]*r),o.push(s[l+2]*r),o.push(s[l+3])}i.bones=a,i.vertices=t.Utils.toFloatArray(o)}else{if(1!=r)for(var l=0,u=s.length;l<u;l++)s[l]*=r;i.vertices=t.Utils.toFloatArray(s)}},e.prototype.readAnimation=function(e,i,n){var r=this.scale,s=new Array,o=0;if(e.slots)for(var a in e.slots){var c=e.slots[a];if(-1==(H=n.findSlotIndex(a)))throw new Error("Slot not found: "+a);for(var h in c){var l=c[h];if("color"==h){(y=new t.ColorTimeline(l.length)).slotIndex=H;for(var u=0,_=0;_<l.length;_++){var d=l[_],f=new t.Color;f.setFromString(d.color),y.setFrame(u,d.time,f.r,f.g,f.b,f.a),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.ColorTimeline.ENTRIES])}else{if(!(h="attachment"))throw new Error("Invalid timeline type for a slot: "+h+" ("+a+")");(y=new t.AttachmentTimeline(l.length)).slotIndex=H;for(u=0,_=0;_<l.length;_++){d=l[_];y.setFrame(u++,d.time,d.name)}s.push(y),o=Math.max(o,y.frames[y.getFrameCount()-1])}}}if(e.bones)for(var p in e.bones){var m=e.bones[p],g=n.findBoneIndex(p);if(-1==g)throw new Error("Bone not found: "+p);for(var h in m){l=m[h];if("rotate"===h){(y=new t.RotateTimeline(l.length)).boneIndex=g;for(u=0,_=0;_<l.length;_++){d=l[_];y.setFrame(u,d.time,d.angle),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.RotateTimeline.ENTRIES])}else{if("translate"!==h&&"scale"!==h&&"shear"!==h)throw new Error("Invalid timeline type for a bone: "+h+" ("+p+")");var y=null,v=1;"scale"===h?y=new t.ScaleTimeline(l.length):"shear"===h?y=new t.ShearTimeline(l.length):(y=new t.TranslateTimeline(l.length),v=r),y.boneIndex=g;for(u=0,_=0;_<l.length;_++){d=l[_];var x=this.getValue(d,"x",0),C=this.getValue(d,"y",0);y.setFrame(u,d.time,x*v,C*v),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.TranslateTimeline.ENTRIES])}}}if(e.ik)for(var T in e.ik){var b=e.ik[T],A=n.findIkConstraint(T);(y=new t.IkConstraintTimeline(b.length)).ikConstraintIndex=n.ikConstraints.indexOf(A);for(u=0,_=0;_<b.length;_++){d=b[_];y.setFrame(u,d.time,this.getValue(d,"mix",1),this.getValue(d,"bendPositive",!0)?1:-1),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.IkConstraintTimeline.ENTRIES])}if(e.transform)for(var T in e.transform){b=e.transform[T],A=n.findTransformConstraint(T);(y=new t.TransformConstraintTimeline(b.length)).transformConstraintIndex=n.transformConstraints.indexOf(A);for(u=0,_=0;_<b.length;_++){d=b[_];y.setFrame(u,d.time,this.getValue(d,"rotateMix",1),this.getValue(d,"translateMix",1),this.getValue(d,"scaleMix",1),this.getValue(d,"shearMix",1)),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.TransformConstraintTimeline.ENTRIES])}if(e.paths)for(var T in e.paths){b=e.paths[T];var S=n.findPathConstraintIndex(T);if(-1==S)throw new Error("Path constraint not found: "+T);var w=n.pathConstraints[S];for(var h in b){l=b[h];if("position"===h||"spacing"===h){y=null,v=1;"spacing"===h?(y=new t.PathConstraintSpacingTimeline(l.length),w.spacingMode!=t.SpacingMode.Length&&w.spacingMode!=t.SpacingMode.Fixed||(v=r)):(y=new t.PathConstraintPositionTimeline(l.length),w.positionMode==t.PositionMode.Fixed&&(v=r)),y.pathConstraintIndex=S;for(u=0,_=0;_<l.length;_++){d=l[_];y.setFrame(u,d.time,this.getValue(d,h,0)*v),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.PathConstraintPositionTimeline.ENTRIES])}else if("mix"===h){(y=new t.PathConstraintMixTimeline(l.length)).pathConstraintIndex=S;for(u=0,_=0;_<l.length;_++){d=l[_];y.setFrame(u,d.time,this.getValue(d,"rotateMix",1),this.getValue(d,"translateMix",1)),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[(y.getFrameCount()-1)*t.PathConstraintMixTimeline.ENTRIES])}}}if(e.deform)for(var E in e.deform){var I=e.deform[E],R=n.findSkin(E);if(null==R)throw new Error("Skin not found: "+E);for(var a in I){c=I[a];if(-1==(H=n.findSlotIndex(a)))throw new Error("Slot not found: "+c.name);for(var h in c){l=c[h];var P=R.getAttachment(H,h);if(null==P)throw new Error("Deform attachment not found: "+l.name);var O=null!=P.bones,B=P.vertices,D=O?B.length/3*2:B.length;(y=new t.DeformTimeline(l.length)).slotIndex=H,y.attachment=P;u=0;for(var M=0;M<l.length;M++){d=l[M];var L=void 0,N=this.getValue(d,"vertices",null);if(null==N)L=O?t.Utils.newFloatArray(D):B;else{L=t.Utils.newFloatArray(D);var F=this.getValue(d,"offset",0);if(t.Utils.arrayCopy(N,0,L,F,N.length),1!=r)for(var k=(_=F)+N.length;_<k;_++)L[_]*=r;if(!O)for(_=0;_<D;_++)L[_]+=B[_]}y.setFrame(u,d.time,L),this.readCurve(d,y,u),u++}s.push(y),o=Math.max(o,y.frames[y.getFrameCount()-1])}}}var z=e.drawOrder;if(null==z&&(z=e.draworder),null!=z){y=new t.DrawOrderTimeline(z.length);var V=n.slots.length;for(u=0,M=0;M<z.length;M++){var G=z[M],W=null,U=this.getValue(G,"offsets",null);if(null!=U){W=t.Utils.newArray(V,-1);var j=t.Utils.newArray(V-U.length,0),X=0,Y=0;for(_=0;_<U.length;_++){var H,q=U[_];if(-1==(H=n.findSlotIndex(q.slot)))throw new Error("Slot not found: "+q.slot);for(;X!=H;)j[Y++]=X++;W[X+q.offset]=X++}for(;X<V;)j[Y++]=X++;for(_=V-1;_>=0;_--)-1==W[_]&&(W[_]=j[--Y])}y.setFrame(u++,G.time,W)}s.push(y),o=Math.max(o,y.frames[y.getFrameCount()-1])}if(e.events){for(y=new t.EventTimeline(e.events.length),u=0,_=0;_<e.events.length;_++){var J=e.events[_],Z=n.findEvent(J.name);if(null==Z)throw new Error("Event not found: "+J.name);var Q=new t.Event(J.time,Z);Q.intValue=this.getValue(J,"int",Z.intValue),Q.floatValue=this.getValue(J,"float",Z.floatValue),Q.stringValue=this.getValue(J,"string",Z.stringValue),y.setFrame(u++,Q)}s.push(y),o=Math.max(o,y.frames[y.getFrameCount()-1])}if(isNaN(o))throw new Error("Error while parsing animation, duration is NaN");n.animations.push(new t.Animation(i,s,o))},e.prototype.readCurve=function(t,e,i){if(t.curve)if("stepped"===t.curve)e.setStepped(i);else if("[object Array]"===Object.prototype.toString.call(t.curve)){var n=t.curve;e.setCurve(i,n[0],n[1],n[2],n[3])}},e.prototype.getValue=function(t,e,i){return void 0!==t[e]?t[e]:i},e.blendModeFromString=function(e){if("normal"==(e=e.toLowerCase()))return t.BlendMode.Normal;if("additive"==e)return t.BlendMode.Additive;if("multiply"==e)return t.BlendMode.Multiply;if("screen"==e)return t.BlendMode.Screen;throw new Error("Unknown blend mode: "+e)},e.positionModeFromString=function(e){if("fixed"==(e=e.toLowerCase()))return t.PositionMode.Fixed;if("percent"==e)return t.PositionMode.Percent;throw new Error("Unknown position mode: "+e)},e.spacingModeFromString=function(e){if("length"==(e=e.toLowerCase()))return t.SpacingMode.Length;if("fixed"==e)return t.SpacingMode.Fixed;if("percent"==e)return t.SpacingMode.Percent;throw new Error("Unknown position mode: "+e)},e.rotateModeFromString=function(e){if("tangent"==(e=e.toLowerCase()))return t.RotateMode.Tangent;if("chain"==e)return t.RotateMode.Chain;if("chainscale"==e)return t.RotateMode.ChainScale;throw new Error("Unknown rotate mode: "+e)},e.transformModeFromString=function(e){if("normal"==(e=e.toLowerCase()))return t.TransformMode.Normal;if("onlytranslation"==e)return t.TransformMode.OnlyTranslation;if("norotationorreflection"==e)return t.TransformMode.NoRotationOrReflection;if("noscale"==e)return t.TransformMode.NoScale;if("noscaleorreflection"==e)return t.TransformMode.NoScaleOrReflection;throw new Error("Unknown transform mode: "+e)},e})();t.SkeletonJson=e;var i=(function(){return function(t,e,i,n){this.mesh=t,this.skin=e,this.slotIndex=i,this.parent=n}})()})(r||(r={}));(function(t){var e=(function(){function t(t){if(this.attachments=new Array,null==t)throw new Error("name cannot be null.");this.name=t}return t.prototype.addAttachment=function(t,e,i){if(null==i)throw new Error("attachment cannot be null.");var n=this.attachments;t>=n.length&&(n.length=t+1),n[t]||(n[t]={}),n[t][e]=i},t.prototype.getAttachment=function(t,e){var i=this.attachments[t];return i?i[e]:null},t.prototype.attachAll=function(t,e){for(var i=0,n=0;n<t.slots.length;n++){var r=t.slots[n],s=r.getAttachment();if(s&&i<e.attachments.length){var o=e.attachments[i];for(var a in o){if(s==o[a]){var c=this.getAttachment(i,a);null!=c&&r.setAttachment(c);break}}}i++}},t})();t.Skin=e})(r||(r={}));(function(t){var e=(function(){function e(e,i){if(this.attachmentVertices=new Array,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("bone cannot be null.");this.data=e,this.bone=i,this.color=new t.Color,this.setToSetupPose()}return e.prototype.getAttachment=function(){return this.attachment},e.prototype.setAttachment=function(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0)},e.prototype.setAttachmentTime=function(t){this.attachmentTime=this.bone.skeleton.time-t},e.prototype.getAttachmentTime=function(){return this.bone.skeleton.time-this.attachmentTime},e.prototype.setToSetupPose=function(){this.color.setFromColor(this.data.color),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))},e})();t.Slot=e})(r||(r={}));(function(t){var e=(function(){return function(e,i,n){if(this.color=new t.Color(1,1,1,1),e<0)throw new Error("index must be >= 0.");if(null==i)throw new Error("name cannot be null.");if(null==n)throw new Error("boneData cannot be null.");this.index=e,this.name=i,this.boneData=n}})();t.SlotData=e})(r||(r={}));(function(t){var e=(function(){function t(t){this._image=t}return t.prototype.getImage=function(){return this._image},t.filterFromString=function(t){switch(t.toLowerCase()){case"nearest":return i.Nearest;case"linear":return i.Linear;case"mipmap":return i.MipMap;case"mipmapnearestnearest":return i.MipMapNearestNearest;case"mipmaplinearnearest":return i.MipMapLinearNearest;case"mipmapnearestlinear":return i.MipMapNearestLinear;case"mipmaplinearlinear":return i.MipMapLinearLinear;default:throw new Error("Unknown texture filter "+t)}},t.wrapFromString=function(t){switch(t.toLowerCase()){case"mirroredtepeat":return n.MirroredRepeat;case"clamptoedge":return n.ClampToEdge;case"repeat":return n.Repeat;default:throw new Error("Unknown texture wrap "+t)}},t})();t.Texture=e,(function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear"})(t.TextureFilter||(t.TextureFilter={}));var i=t.TextureFilter;(function(t){t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat"})(t.TextureWrap||(t.TextureWrap={}));var n=t.TextureWrap,r=(function(){return function(){this.u=0,this.v=0,this.u2=0,this.v2=0,this.width=0,this.height=0,this.rotate=!1,this.offsetX=0,this.offsetY=0,this.originalWidth=0,this.originalHeight=0}})();t.TextureRegion=r})(r||(r={}));(function(t){var e=(function(){function e(t,e){this.pages=new Array,this.regions=new Array,this.load(t,e)}return e.prototype.load=function(e,n){if(null==n)throw new Error("textureLoader cannot be null.");for(var o=new i(e),a=new Array(4),c=null;;){var h=o.readLine();if(null==h)break;if(0==(h=h.trim()).length)c=null;else if(c){var l=new s;l.name=h,l.page=c,l.rotate="true"==o.readValue(),o.readTuple(a);var u=parseInt(a[0]),_=parseInt(a[1]);o.readTuple(a);var d=parseInt(a[0]),f=parseInt(a[1]);l.u=u/c.width,l.v=_/c.height,l.rotate?(l.u2=(u+f)/c.width,l.v2=(_+d)/c.height):(l.u2=(u+d)/c.width,l.v2=(_+f)/c.height),l.x=u,l.y=_,l.width=Math.abs(d),l.height=Math.abs(f),4==o.readTuple(a)&&4==o.readTuple(a)&&o.readTuple(a),l.originalWidth=parseInt(a[0]),l.originalHeight=parseInt(a[1]),o.readTuple(a),l.offsetX=parseInt(a[0]),l.offsetY=parseInt(a[1]),l.index=parseInt(o.readValue()),l.texture=c.texture,this.regions.push(l)}else{(c=new r).name=h,2==o.readTuple(a)&&(c.width=parseInt(a[0]),c.height=parseInt(a[1]),o.readTuple(a)),o.readTuple(a),c.minFilter=t.Texture.filterFromString(a[0]),c.magFilter=t.Texture.filterFromString(a[1]);var p=o.readValue();c.uWrap=t.TextureWrap.ClampToEdge,c.vWrap=t.TextureWrap.ClampToEdge,"x"==p?c.uWrap=t.TextureWrap.Repeat:"y"==p?c.vWrap=t.TextureWrap.Repeat:"xy"==p&&(c.uWrap=c.vWrap=t.TextureWrap.Repeat),c.texture=n(h),c.texture.setFilters(c.minFilter,c.magFilter),c.texture.setWraps(c.uWrap,c.vWrap),c.width=c.texture.getImage().width,c.height=c.texture.getImage().height,this.pages.push(c)}}},e.prototype.findRegion=function(t){for(var e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null},e.prototype.dispose=function(){for(var t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()},e})();t.TextureAtlas=e;var i=(function(){function t(t){this.index=0,this.lines=t.split(/\r\n|\r|\n/)}return t.prototype.readLine=function(){return this.index>=this.lines.length?null:this.lines[this.index++]},t.prototype.readValue=function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()},t.prototype.readTuple=function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw new Error("Invalid line: "+e);for(var n=0,r=i+1;n<3;n++){var s=e.indexOf(",",r);if(-1==s)break;t[n]=e.substr(r,s-r).trim(),r=s+1}return t[n]=e.substring(r).trim(),n+1},t})(),r=(function(){return function(){}})();t.TextureAtlasPage=r;var s=(function(t){function e(){t.apply(this,arguments)}return n(e,t),e})(t.TextureRegion);t.TextureAtlasRegion=s})(r||(r={}));(function(t){var e=(function(){function e(e,i){if(this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.temp=new t.Vector2,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("skeleton cannot be null.");this.data=e,this.rotateMix=e.rotateMix,this.translateMix=e.translateMix,this.scaleMix=e.scaleMix,this.shearMix=e.shearMix,this.bones=new Array;for(var n=0;n<e.bones.length;n++)this.bones.push(i.findBone(e.bones[n].name));this.target=i.findBone(e.target.name)}return e.prototype.apply=function(){this.update()},e.prototype.update=function(){for(var e=this.rotateMix,i=this.translateMix,n=this.scaleMix,r=this.shearMix,s=this.target,o=s.a,a=s.b,c=s.c,h=s.d,l=o*h-a*c>0?t.MathUtils.degRad:-t.MathUtils.degRad,u=this.data.offsetRotation*l,_=this.data.offsetShearY*l,d=this.bones,f=0,p=d.length;f<p;f++){var m=d[f],g=!1;if(0!=e){var y=m.a,v=m.b,x=m.c,C=m.d;(E=Math.atan2(c,o)-Math.atan2(x,y)+u)>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E*=e;var T=Math.cos(E),b=Math.sin(E);m.a=T*y-b*x,m.b=T*v-b*C,m.c=b*y+T*x,m.d=b*v+T*C,g=!0}if(0!=i){var A=this.temp;s.localToWorld(A.set(this.data.offsetX,this.data.offsetY)),m.worldX+=(A.x-m.worldX)*i,m.worldY+=(A.y-m.worldY)*i,g=!0}if(n>0){var S=Math.sqrt(m.a*m.a+m.c*m.c),w=Math.sqrt(o*o+c*c);S>1e-5&&(S=(S+(w-S+this.data.offsetScaleX)*n)/S),m.a*=S,m.c*=S,S=Math.sqrt(m.b*m.b+m.d*m.d),w=Math.sqrt(a*a+h*h),S>1e-5&&(S=(S+(w-S+this.data.offsetScaleY)*n)/S),m.b*=S,m.d*=S,g=!0}if(r>0){v=m.b,C=m.d;var E,I=Math.atan2(C,v);(E=Math.atan2(h,a)-Math.atan2(c,o)-(I-Math.atan2(m.c,m.a)))>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E=I+(E+_)*r;S=Math.sqrt(v*v+C*C);m.b=Math.cos(E)*S,m.d=Math.sin(E)*S,g=!0}g&&(m.appliedValid=!1)}},e.prototype.getOrder=function(){return this.data.order},e})();t.TransformConstraint=e})(r||(r={}));(function(t){var e=(function(){return function(t){if(this.order=0,this.bones=new Array,this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.offsetRotation=0,this.offsetX=0,this.offsetY=0,this.offsetScaleX=0,this.offsetScaleY=0,this.offsetShearY=0,null==t)throw new Error("name cannot be null.");this.name=t}})();t.TransformConstraintData=e})(r||(r={}));var r;(function(t){var e=(function(){function t(){this.array=new Array}return t.prototype.add=function(t){var e=this.contains(t);return this.array[0|t]=0|t,!e},t.prototype.contains=function(t){return void 0!=this.array[0|t]},t.prototype.remove=function(t){this.array[0|t]=void 0},t.prototype.clear=function(){this.array.length=0},t})();t.IntSet=e;var i=(function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.r=t,this.g=e,this.b=i,this.a=n}return t.prototype.set=function(t,e,i,n){return this.r=t,this.g=e,this.b=i,this.a=n,this.clamp(),this},t.prototype.setFromColor=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.setFromString=function(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this},t.prototype.add=function(t,e,i,n){return this.r+=t,this.g+=e,this.b+=i,this.a+=n,this.clamp(),this},t.prototype.clamp=function(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this},t.WHITE=new t(1,1,1,1),t.RED=new t(1,0,0,1),t.GREEN=new t(0,1,0,1),t.BLUE=new t(0,0,1,1),t.MAGENTA=new t(1,0,1,1),t})();t.Color=i;var n=(function(){function t(){}return t.clamp=function(t,e,i){return t<e?e:t>i?i:t},t.cosDeg=function(e){return Math.cos(e*t.degRad)},t.sinDeg=function(e){return Math.sin(e*t.degRad)},t.signum=function(t){return t>0?1:t<0?-1:0},t.toInt=function(t){return t>0?Math.floor(t):Math.ceil(t)},t.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},t.PI=3.1415927,t.PI2=2*t.PI,t.radiansToDegrees=180/t.PI,t.radDeg=t.radiansToDegrees,t.degreesToRadians=t.PI/180,t.degRad=t.degreesToRadians,t})();t.MathUtils=n;var r=(function(){function t(){}return t.arrayCopy=function(t,e,i,n,r){for(var s=e,o=n;s<e+r;s++,o++)i[o]=t[s]},t.setArraySize=function(t,e,i){void 0===i&&(i=0);var n=t.length;if(n==e)return t;if(t.length=e,n<e)for(var r=n;r<e;r++)t[r]=i;return t},t.ensureArrayCapacity=function(e,i,n){return void 0===n&&(n=0),e.length>=i?e:t.setArraySize(e,i,n)},t.newArray=function(t,e){for(var i=new Array(t),n=0;n<t;n++)i[n]=e;return i},t.newFloatArray=function(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);for(var i=new Array(e),n=0;n<i.length;n++)i[n]=0;return i},t.toFloatArray=function(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e},t.SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array,t})();t.Utils=r;var s=(function(){function t(){}return t.logBones=function(t){for(var e=0;e<t.bones.length;e++){var i=t.bones[e];console.log(i.data.name+", "+i.a+", "+i.b+", "+i.c+", "+i.d+", "+i.worldX+", "+i.worldY)}},t})();t.DebugUtils=s;var o=(function(){function t(t){this.items=new Array,this.instantiator=t}return t.prototype.obtain=function(){return this.items.length>0?this.items.pop():this.instantiator()},t.prototype.free=function(t){t.reset&&t.reset(),this.items.push(t)},t.prototype.freeAll=function(t){for(var e=0;e<t.length;e++)t[e].reset&&t[e].reset(),this.items[e]=t[e]},t.prototype.clear=function(){this.items.length=0},t})();t.Pool=o;var a=(function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.set=function(t,e){return this.x=t,this.y=e,this},t.prototype.length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},t.prototype.normalize=function(){var t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this},t})();t.Vector2=a;var c=(function(){function t(){this.maxDelta=.064,this.framesPerSecond=0,this.delta=0,this.totalTime=0,this.lastTime=Date.now()/1e3,this.frameCount=0,this.frameTime=0}return t.prototype.update=function(){var t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)},t})();t.TimeKeeper=c})(r||(r={})),e.exports=r}),{}],310:[(function(t,e,i){(function(){"use strict";function t(t){t||console.log("Assertion failed! Pls debug.")}function i(t,e,i){this.major=t,this.minor=e,this.revision=i}function n(t){return isFinite(t)&&!isNaN(t)}function r(t,e){void 0!==t?(this.x=t,this.y=e):this.x=this.y=0}function s(t,e,i){void 0!==t&&(this.x=t,this.y=e,this.z=i)}function o(t,e){this.ex=t?t.Clone():new r,this.ey=e?e.Clone():new r}function a(t,e,i){this.ex=t?t.Clone():new s,this.ey=e?e.Clone():new s,this.ez=i?i.Clone():new s}function c(t,e){void 0!==e?(this.s=t,this.c=e):void 0!==t&&this.Set(t)}function h(t,e){this.p=new r,this.q=new c,t&&(this.p.Assign(t),this.q.Assign(e))}function l(){this.localCenter=new r,this.c0=new r,this.c=new r}function u(t,e){return t.x*e.x+t.y*e.y}function _(t,e){return t.x*e.y-t.y*e.x}function d(t,e){return new r(e*t.y,-e*t.x)}function f(t,e){return new r(-t*e.y,t*e.x)}function p(t,e){return new r(t.ex.x*e.x+t.ey.x*e.y,t.ex.y*e.x+t.ey.y*e.y)}function m(t,e){return r.Subtract(t,e).Length()}function g(t,e){var i=r.Subtract(t,e);return u(i,i)}function y(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function v(t,e){return new s(t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x)}function x(t,e){return s.Add(s.Add(s.Multiply(e.x,t.ex),s.Multiply(e.y,t.ey)),s.Multiply(e.z,t.ez))}function C(t,e){return new r(t.ex.x*e.x+t.ey.x*e.y,t.ex.y*e.x+t.ey.y*e.y)}function T(t,e){var i=new c;return i.s=t.s*e.c+t.c*e.s,i.c=t.c*e.c-t.s*e.s,i}function b(t,e){var i=new c;return i.s=t.c*e.s-t.s*e.c,i.c=t.c*e.c+t.s*e.s,i}function A(t,e){return new r(t.c*e.x-t.s*e.y,t.s*e.x+t.c*e.y)}function S(t,e){return new r(t.c*e.x+t.s*e.y,-t.s*e.x+t.c*e.y)}function w(t,e){return new r(t.q.c*e.x-t.q.s*e.y+t.p.x,t.q.s*e.x+t.q.c*e.y+t.p.y)}function E(t,e){var i=e.x-t.p.x,n=e.y-t.p.y;return new r(t.q.c*i+t.q.s*n,-t.q.s*i+t.q.c*n)}function I(t,e){var i=new h;i.q=b(t.q,e.q);var n=e.p.x-t.p.x,r=e.p.y-t.p.y;return i.p.x=t.q.c*n+t.q.s*r,i.p.y=-t.q.s*n+t.q.c*r,i}function R(t){return new r(ri(t.x),ri(t.y))}function P(t,e){return new r(si(t.x,e.x),si(t.y,e.y))}function O(t,e){return new r(oi(t.x,e.x),oi(t.y,e.y))}function B(t,e,i){return oi(e,si(t,i))}function D(t,e,i){this.r=t||0,this.g=e||0,this.b=i||0}function M(){}function L(){this.Reset()}function N(){this.mass=0,this.center=new r,this.I=0}function F(){this.m_type=0,this.m_radius=0}function k(){this.parent.call(this),this.m_type=F.e_circle,this.m_radius=0,this.m_p=new r,Object.seal(this)}function z(){this.parent.call(this),this.m_type=F.e_edge,this.m_radius=Xe,this.m_vertex0=new r,this.m_vertex1=new r,this.m_vertex2=new r,this.m_vertex3=new r,this.m_hasVertex0=!1,this.m_hasVertex3=!1,Object.seal(this)}function V(){this.parent.call(this),this.m_type=F.e_chain,this.m_radius=Xe,this.m_prevVertex=new r,this.m_nextVertex=new r,this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,this.Clear(),Object.seal(this)}function G(){this.parent.call(this),this.m_type=F.e_polygon,this.m_radius=Xe,this.m_count=0,this.m_centroid=new r,this.m_vertices=new Array(We),this.m_normals=new Array(We),Object.seal(this)}function W(){this.proxyIdA=0,this.proxyIdB=0}function U(t,e){return t.proxyIdA==e.proxyIdA?t.proxyIdB-e.proxyIdB:t.proxyIdA-e.proxyIdA}function j(){this.m_tree=new Ct,this.m_queryProxyId=0,this.m_proxyCount=0,this.m_pairCount=0,this.m_pairBuffer=[],this.m_moveCount=0,this.m_moveBuffer=[]}function X(){this.m_vertices=null,this.m_count=0,this.m_radius=0}function Y(){this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}function H(){this.proxyA=new X,this.proxyB=new X,this.transformA=new h,this.transformB=new h,this.useRadii=!1}function q(){this.pointA=new r,this.pointB=new r,this.distance=0,this.iterations=0}function J(){this.wA=new r,this.wB=new r,this.w=new r,this.a=0,this.indexA=0,this.indexB=0}function Z(){this.m_v=[new J,new J,new J],this.m_count=0}function Q(e,i,n){++Q.b2_gjkCalls;var r=n.proxyA,s=n.proxyB,o=n.transformA,a=n.transformB;ai.ReadCache(i,r,o,s,a);for(var c=ai.m_v,h=[0,0,0],l=[0,0,0],u=0,_=ke,d=_,f=0;f<20;){u=ai.m_count;for(var p=0;p<u;++p)h[p]=c[p].indexA,l[p]=c[p].indexB;switch(ai.m_count){case 1:break;case 2:ai.Solve2();break;case 3:ai.Solve3();break;default:t(!1)}if(3==ai.m_count)break;if(ai.GetClosestPoint(hi),d=hi.LengthSquared(),_=d,ai.GetSearchDirection(hi),hi.LengthSquared()<ze*ze)break;var g=c[ai.m_count];g.indexA=r.GetSupport(o.q.c*-hi.x+o.q.s*-hi.y,-o.q.s*-hi.x+o.q.c*-hi.y);var y=r.GetVertex(g.indexA);g.wA.x=o.q.c*y.x-o.q.s*y.y+o.p.x,g.wA.y=o.q.s*y.x+o.q.c*y.y+o.p.y,g.indexB=s.GetSupport(a.q.c*hi.x+a.q.s*hi.y,-a.q.s*hi.x+a.q.c*hi.y);var v=s.GetVertex(g.indexB);g.wB.x=a.q.c*v.x-a.q.s*v.y+a.p.x,g.wB.y=a.q.s*v.x+a.q.c*v.y+a.p.y,g.w.x=g.wB.x-g.wA.x,g.w.y=g.wB.y-g.wA.y,++f,++Q.b2_gjkIters;var x=!1;for(p=0;p<u;++p)if(g.indexA==h[p]&&g.indexB==l[p]){x=!0;break}if(x)break;++ai.m_count}if(Q.b2_gjkMaxIters=oi(Q.b2_gjkMaxIters,f),ai.GetWitnessPoints(e.pointA,e.pointB),e.distance=m(e.pointA,e.pointB),e.iterations=f,ai.WriteCache(i),n.useRadii){var C=r.m_radius,T=s.m_radius;if(e.distance>C+T&&e.distance>ze)e.distance-=C+T,ci.x=e.pointB.x-e.pointA.x,ci.y=e.pointB.y-e.pointA.y,ci.Normalize(),e.pointA.x+=C*ci.x,e.pointA.y+=C*ci.y,e.pointB.x-=T*ci.x,e.pointB.y-=T*ci.y;else{var b=.5*(e.pointA.x+e.pointB.x),A=.5*(e.pointA.y+e.pointB.y);e.pointA.x=b,e.pointA.y=A,e.pointB.x=b,e.pointB.y=A,e.distance=0}}}function K(){}function $(){this.localPoint=new r,this.normalImpulse=0,this.tangentImpulse=0,this.id=new K}function tt(){this.points=new Array(Ge),this.localNormal=new r,this.localPoint=new r,this.type=0,this.pointCount=0}function et(){this.normal=new r,this.points=new Array(Ge),this.separations=new Array(Ge)}function it(){this.v=new r,this.id=new K}function nt(){this.p1=new r,this.p2=new r,this.maxFraction=0}function rt(){this.normal=new r,this.fraction=0}function st(){this.lowerBound=new r,this.upperBound=new r}function ot(t,e,i,n,r){t.pointCount=0;var s=w(i,e.m_p),o=w(r,n.m_p),a=o.x-s.x,c=o.y-s.y,h=a*a+c*c,l=e.m_radius+n.m_radius;h>l*l||(t.type=tt.e_circles,t.localPoint.x=e.m_p.x,t.localPoint.y=e.m_p.y,t.localNormal.x=t.localNormal.y=0,t.pointCount=1,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset())}function at(t,e,i,n,r){t.pointCount=0;for(var s=E(i,w(r,n.m_p)),o=0,a=-ke,c=e.m_radius+n.m_radius,h=e.m_count,l=e.m_vertices,u=e.m_normals,_=0;_<h;++_){var d=u[_].x*(s.x-l[_].x)+u[_].y*(s.y-l[_].y);if(d>c)return;d>a&&(a=d,o=_)}var f=o,p=f+1<h?f+1:0,m=l[f],y=l[p];if(a<ze)return t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=u[o].x,t.localNormal.y=u[o].y,t.localPoint.x=.5*(m.x+y.x),t.localPoint.y=.5*(m.y+y.y),t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,void t.points[0].id.Reset();var v=(s.x-m.x)*(y.x-m.x)+(s.y-m.y)*(y.y-m.y),x=(s.x-y.x)*(m.x-y.x)+(s.y-y.y)*(m.y-y.y);if(v<=0){if(g(s,m)>c*c)return;t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=s.x-m.x,t.localNormal.y=s.y-m.y,t.localNormal.Normalize(),t.localPoint.x=m.x,t.localPoint.y=m.y,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset()}else if(x<=0){if(g(s,y)>c*c)return;t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=s.x-y.x,t.localNormal.y=s.y-y.y,t.localNormal.Normalize(),t.localPoint.x=y.x,t.localPoint.y=y.y,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset()}else{var C=.5*(m.x+y.x),T=.5*(m.y+y.y);if((a=(s.x-C)*u[f].x+(s.y-T)*u[f].y)>c)return;t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=u[f].x,t.localNormal.y=u[f].y,t.localPoint.x=C,t.localPoint.y=T,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset()}}function ct(t,e,i,n,r){for(var s=e.m_count,o=n.m_count,a=e.m_normals,c=e.m_vertices,h=n.m_vertices,l=I(r,i),u=0,_=-ke,d=0;d<s;++d){for(var f=l.q.c*a[d].x-l.q.s*a[d].y,p=l.q.s*a[d].x+l.q.c*a[d].y,m=l.q.c*c[d].x-l.q.s*c[d].y+l.p.x,g=l.q.s*c[d].x+l.q.c*c[d].y+l.p.y,y=ke,v=0;v<o;++v){var x=f*(h[v].x-m)+p*(h[v].y-g);x<y&&(y=x)}y>_&&(_=y,u=d)}return t[0]=u,_}function ht(e,i,n,r,s,o){var a=i.m_normals,c=s.m_count,h=s.m_vertices,l=s.m_normals;t(0<=r&&r<i.m_count);for(var u=n.q.c*a[r].x-n.q.s*a[r].y,_=n.q.s*a[r].x+n.q.c*a[r].y,d=o.q.c*u+o.q.s*_,f=-o.q.s*u+o.q.c*_,p=0,m=ke,g=0;g<c;++g){var y=d*l[g].x+f*l[g].y;y<m&&(m=y,p=g)}var v=p,x=v+1<c?v+1:0;e[0].v.x=o.q.c*h[v].x-o.q.s*h[v].y+o.p.x,e[0].v.y=o.q.s*h[v].x+o.q.c*h[v].y+o.p.y,e[0].id.indexA=r,e[0].id.indexB=v,e[0].id.typeA=K.e_face,e[0].id.typeB=K.e_vertex,e[1].v.x=o.q.c*h[x].x-o.q.s*h[x].y+o.p.x,e[1].v.y=o.q.s*h[x].x+o.q.c*h[x].y+o.p.y,e[1].id.indexA=r,e[1].id.indexB=x,e[1].id.typeA=K.e_face,e[1].id.typeB=K.e_vertex}function lt(t,e,i,n,r){t.pointCount=0;var s=e.m_radius+n.m_radius,o=[0],a=ct(o,e,i,n,r);if(!(a>s)){var c=[0],h=ct(c,n,r,e,i);if(!(h>s)){var l,u,_,d,f=0,p=0;h>a+.1*Ue?(l=n,u=e,_=r,d=i,f=c[0],t.type=tt.e_faceB,p=1):(l=e,u=n,_=i,d=r,f=o[0],t.type=tt.e_faceA,p=0),ht(lt._local_incidentEdges,l,_,f,u,d);var m=l.m_count,g=l.m_vertices,y=f,v=f+1<m?f+1:0,x=g[y],C=g[v];lt._localTangent.x=C.x-x.x,lt._localTangent.y=C.y-x.y,lt._localTangent.Normalize();var T=1*lt._localTangent.y,b=-1*lt._localTangent.x,A=.5*(x.x+C.x),S=.5*(x.y+C.y),I=_.q.c*lt._localTangent.x-_.q.s*lt._localTangent.y,R=_.q.s*lt._localTangent.x+_.q.c*lt._localTangent.y,P=1*R,O=-1*I;x=w(_,x),C=w(_,C);var B=P*x.x+O*x.y,D=-(I*x.x+R*x.y)+s,M=I*C.x+R*C.y+s,L=new Array(2),N=new Array(2);if(!(gt(L,lt._local_incidentEdges,-I,-R,D,y)<2||gt(N,L,I,R,M,v)<2)){t.localNormal.x=T,t.localNormal.y=b,t.localPoint.x=A,t.localPoint.y=S;for(var F=0,k=0;k<Ge;++k){if(P*N[k].v.x+O*N[k].v.y-B<=s){var z=t.points[F]=new $;if(z.localPoint.Assign(E(d,N[k].v)),z.id.Assign(N[k].id),p){var V=new K;V.Assign(z.id),z.id.indexA=V.indexB,z.id.indexB=V.indexA,z.id.typeA=V.typeB,z.id.typeB=V.typeA}++F}}t.pointCount=F}}}}function ut(e,i,n,r,s){e.pointCount=0;var o=E(n,w(s,r.m_p)),a=i.m_vertex1,c=i.m_vertex2,h=c.x-a.x,l=c.y-a.y,u=h*(c.x-o.x)+l*(c.y-o.y),_=h*(o.x-a.x)+l*(o.y-a.y),d=i.m_radius+r.m_radius,f=new K;if(f.indexB=0,f.typeB=K.e_vertex,_<=0){var p=a;if((S=o.x-p.x)*S+(I=o.y-p.y)*I>d*d)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=a,y=g.x-m.x,v=g.y-m.y;if(y*(g.x-o.x)+v*(g.y-o.y)>0)return}return f.indexA=0,f.typeA=K.e_vertex,e.pointCount=1,e.type=tt.e_circles,e.localNormal.x=e.localNormal.y=0,e.localPoint.x=p.x,e.localPoint.y=p.y,e.points[0]=new $,e.points[0].id.Assign(f),e.points[0].localPoint.x=r.m_p.x,void(e.points[0].localPoint.y=r.m_p.y)}if(u<=0){p=c;if((S=o.x-p.x)*S+(I=o.y-p.y)*I>d*d)return;if(i.m_hasVertex3){var x=i.m_vertex3,C=c,T=x.x-C.x,b=x.y-C.y;if(T*(o.x-C.x)+b*(o.y-C.y)>0)return}return f.indexA=1,f.typeA=K.e_vertex,e.pointCount=1,e.type=tt.e_circles,e.localNormal.x=e.localNormal.y=0,e.localPoint.x=p.x,e.localPoint.y=p.y,e.points[0]=new $,e.points[0].id.Assign(f),e.points[0].localPoint.x=r.m_p.x,void(e.points[0].localPoint.y=r.m_p.y)}var A=h*h+l*l;t(A>0);var S,I,R=1/A*(u*a.x+_*c.x),P=1/A*(u*a.y+_*c.y);if(!((S=o.x-R)*S+(I=o.y-P)*I>d*d)){var O=-l,B=h;O*(o.x-a.x)+B*(o.y-a.y)<0&&(O=-O,B=-B),f.indexA=0,f.typeA=K.e_face,e.pointCount=1,e.type=tt.e_faceA,e.localNormal.x=O,e.localNormal.y=B,e.localNormal.Normalize(),e.localPoint.x=a.x,e.localPoint.y=a.y,e.points[0]=new $,e.points[0].id.Assign(f),e.points[0].localPoint.x=r.m_p.x,e.points[0].localPoint.y=r.m_p.y}}function _t(){this.type=0,this.index=0,this.separation=0}function dt(){this.vertices=new Array(We),this.normals=new Array(We),this.count=0}function ft(){this.i1=0,this.i2=0,this.v1=new r,this.v2=new r,this.normal=new r,this.sideNormal1=new r,this.sideOffset1=0,this.sideNormal2=new r,this.sideOffset2=0}function pt(){this.m_polygonB=new dt,this.m_xf=new h,this.m_centroidB=new r,this.m_v0=new r,this.m_v1=new r,this.m_v2=new r,this.m_v3=new r,this.m_normal0=new r,this.m_normal1=new r,this.m_normal2=new r,this.m_normal=new r,this.m_type1=0,this.m_type2=0,this.m_lowerLimit=new r,this.m_upperLimit=new r,this.m_radius=0,this.m_front=!1}function mt(t,e,i,n,r){mt.collider.Collide(t,e,i,n,r)}function gt(t,e,i,n,r,s){var o=0,a=i*e[0].v.x+n*e[0].v.y-r,c=i*e[1].v.x+n*e[1].v.y-r;if(a<=0&&(t[o++]=e[0]),c<=0&&(t[o++]=e[1]),a*c<0){var h=a/(a-c);t[o]=new it,t[o].v.x=e[0].v.x+h*(e[1].v.x-e[0].v.x),t[o].v.y=e[0].v.y+h*(e[1].v.y-e[0].v.y),t[o].id.indexA=s,t[o].id.indexB=e[0].id.indexB,t[o].id.typeA=K.e_vertex,t[o].id.typeB=K.e_face,++o}return o}function yt(t,e,i,n,r,s){return yt.input.proxyA.Set(t,e),yt.input.proxyB.Set(i,n),yt.input.transformA=r,yt.input.transformB=s,yt.input.useRadii=!0,yt.cache.count=0,Q(yt.output,yt.cache,yt.input),yt.output.distance<10*ze}function vt(t,e){return!(e.lowerBound.x-t.upperBound.x>0||e.lowerBound.y-t.upperBound.y>0||t.lowerBound.x-e.upperBound.x>0||t.lowerBound.y-e.upperBound.y>0)}function xt(){this.aabb=new st,this.userData=null,this.parent=0,this.child1=this.child2=this.height=0}function Ct(){this.m_root=li,this.m_nodeCapacity=16,this.m_nodeCount=0,this.m_nodes=new Array(this.m_nodeCapacity);for(var t=0;t<this.m_nodeCapacity-1;++t)this.m_nodes[t]=new xt,this.m_nodes[t].parent=t+1,this.m_nodes[t].height=-1;this.m_nodes[this.m_nodeCapacity-1]=new xt,this.m_nodes[this.m_nodeCapacity-1].parent=li,this.m_nodes[this.m_nodeCapacity-1].height=-1,this.m_freeList=0,this.m_path=0,this.m_insertionCount=0}function Tt(){this.proxyA=new X,this.proxyB=new X,this.sweepA=new l,this.sweepB=new l,this.tMax=0}function bt(){this.state=0,this.t=0}function At(){this.m_proxyA=null,this.m_proxyB=null,this.m_sweepA=null,this.m_sweepB=null,this.m_type=0,this.m_localPoint=new r,this.m_axis=new r}function St(e,i){di.start(),++St.b2_toiCalls,e.state=bt.e_unknown,e.t=i.tMax;var n=i.proxyA,r=i.proxyB;St._temp_sweepA.Assign(i.sweepA),St._temp_sweepB.Assign(i.sweepB),St._temp_sweepA.Normalize(),St._temp_sweepB.Normalize();var s=i.tMax,o=n.m_radius+r.m_radius,a=oi(Ue,o-3*Ue),c=.25*Ue;t(a>c);var h=0,l=0,u=new Y;u.count=0;var _=new H;for(_.proxyA.Assign(i.proxyA),_.proxyB.Assign(i.proxyB),_.useRadii=!1;;){St._temp_sweepA.GetTransform(_.transformA,h),St._temp_sweepB.GetTransform(_.transformB,h);var d=new q;if(Q(d,u,_),d.distance<=0){e.state=bt.e_overlapped,e.t=0;break}if(d.distance<a+c){e.state=bt.e_touching,e.t=h;break}var f=new At;f.Initialize(u,n,St._temp_sweepA,r,St._temp_sweepB,h);for(var p=!1,m=s,g=0;;){var y=[],v=f.FindMinSeparation(y,m);if(v>a+c){e.state=bt.e_separated,e.t=s,p=!0;break}if(v>a-c){h=m;break}var x=f.Evaluate(y[0],y[1],h);if(x<a-c){e.state=bt.e_failed,e.t=h,p=!0;break}if(x<=a+c){e.state=bt.e_touching,e.t=h,p=!0;break}for(var C=0,T=h,b=m;;){var A;A=1&C?T+(a-x)*(b-T)/(v-x):.5*(T+b),++C,++St.b2_toiRootIters;var S=f.Evaluate(y[0],y[1],A);if(ri(S-a)<c){m=A;break}if(S>a?(T=A,x=S):(b=A,v=S),50==C)break}if(St.b2_toiMaxRootIters=oi(St.b2_toiMaxRootIters,C),++g==We)break}if(++l,++St.b2_toiIters,p)break;if(20==l){e.state=bt.e_failed,e.t=h;break}}St.b2_toiMaxIters=oi(St.b2_toiMaxIters,l),di.stop(),St.b2_toiMaxTime=oi(St.b2_toiMaxTime,di.elapsedTime),St.b2_toiTime+=di.elapsedTime}function wt(){this.type=Et.b2_staticBody,this.position=new r(0,0),this.angle=0,this.linearVelocity=new r(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.active=!0,this.userData=null,this.gravityScale=1,Object.seal(this)}function Et(e,i){t(e.position.IsValid()),t(e.linearVelocity.IsValid()),t(n(e.angle)),t(n(e.angularVelocity)),t(n(e.angularDamping)&&e.angularDamping>=0),t(n(e.linearDamping)&&e.linearDamping>=0),this.m_islandIndex=0,this.m_flags=0,e.bullet&&(this.m_flags|=Et.e_bulletFlag),e.fixedRotation&&(this.m_flags|=Et.e_fixedRotationFlag),e.allowSleep&&(this.m_flags|=Et.e_autoSleepFlag),e.awake&&(this.m_flags|=Et.e_awakeFlag),e.active&&(this.m_flags|=Et.e_activeFlag),this.m_world=i,this.m_xf=new h,this.m_xf.p.Assign(e.position),this.m_xf.q.Set(e.angle),this.m_sweep=new l,this.m_sweep.localCenter.SetZero(),this.m_sweep.c0.Assign(this.m_xf.p),this.m_sweep.c.Assign(this.m_xf.p),this.m_sweep.a0=e.angle,this.m_sweep.a=e.angle,this.m_sweep.alpha0=0,this.m_jointList=null,this.m_contactList=null,this.m_prev=null,this.m_next=null,this.m_linearVelocity=e.linearVelocity.Clone(),this.m_angularVelocity=e.angularVelocity,this.m_linearDamping=e.linearDamping,this.m_angularDamping=e.angularDamping,this.m_gravityScale=e.gravityScale,this.m_force=new r,this.m_torque=0,this.m_sleepTime=0,this.m_type=e.type,this.m_type==Et.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_userData=e.userData,this.m_fixtureList=null,this.m_fixtureCount=0}function It(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0}function Rt(){this.shape=null,this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.isSensor=!1,this.filter=new It,Object.seal(this)}function Pt(){this.aabb=new st,this.fixture=null,this.childIndex=0,this.proxyId=0}function Ot(){this.m_userData=null,this.m_body=null,this.m_next=null,this.m_proxies=null,this.m_proxyCount=0,this.m_shape=null,this.m_density=0,this.m_filter=new It,this.m_isSensor=!1,this.m_friction=0,this.m_restitution=0}function Bt(){}function Dt(){}function Mt(){this.normalImpulses=new Array(Ge),this.tangentImpulses=new Array(Ge),this.count=0}function Lt(){}function Nt(){}function Ft(){}function kt(){this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.warmStarting=!1}function zt(){this.c=new r,this.a=0}function Vt(){this.v=new r,this.w=0}function Gt(){this.step=new kt,this.positions=null,this.velocities=null}function Wt(t){this.m_contactManager=new ne,this.m_destructionListener=null,this.g_debugDraw=null,this.m_bodyList=null,this.m_jointList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_allowSleep=!0,this.m_gravity=t,this.m_flags=Wt.e_clearForces,this.m_inv_dt0=0,this.p_step=new kt,this.p_island=new le}function Ut(){this.broadPhase=null,this.callback=null}function jt(){this.broadPhase=null,this.callback=null}function Xt(t,e){return ii(t*e)}function Yt(t,e){return t>e?t:e}function Ht(){this.fcn=null,this.primary=!1}function qt(){this.other=null,this.contact=null,this.prev=null,this.next=null}function Jt(){this.m_nodeA=new qt,this.m_nodeB=new qt,this.m_manifold=new tt}function Zt(){this.parent.call(this)}function Qt(){this.parent.call(this)}function Kt(){this.parent.call(this)}function $t(){this.parent.call(this)}function te(){this.parent.call(this)}function ee(){this.parent.call(this)}function ie(){this.parent.call(this)}function ne(){this.m_broadPhase=new j,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=xi,this.m_contactListener=Ci}function re(){this.rA=new r,this.rB=new r,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}function se(){this.localPoints=new Array(Ge),this.localNormal=new r,this.localPoint=new r,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new r,this.localCenterB=new r,this.invIA=0,this.invIB=0,this.type=0,this.radiusA=0,this.radiusB=0,this.pointCount=0}function oe(){this.points=new Array(Ge);for(var t=0;t<this.points.length;++t)this.points[t]=new re;this.normal=new r,this.normalMass=new o,this.K=new o,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}function ae(){this.normal=new r,this.point=new r,this.separation=0}function ce(){this.step=new kt,this.contacts=null,this.count=0,this.positions=null,this.velocities=null}function he(){this.m_positionConstraints=[],this.m_velocityConstraints=[]}function le(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_velocities=[],this.m_positions=[]}function ue(){this.other=null,this.joint=null,this.prev=null,this.next=null}function _e(){this.type=de.e_unknownJoint,this.userData=null,this.bodyA=null,this.bodyB=null,this.collideConnected=!1}function de(e){t(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_index=0,this.m_collideConnected=e.collideConnected,this.m_islandFlag=!1,this.m_userData=e.userData,this.m_edgeA=new ue,this.m_edgeA.joint=null,this.m_edgeA.other=null,this.m_edgeA.prev=null,this.m_edgeA.next=null,this.m_edgeB=new ue,this.m_edgeB.joint=null,this.m_edgeB.other=null,this.m_edgeB.prev=null,this.m_edgeB.next=null}function fe(){this.parent.call(this),this.type=de.e_revoluteJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.referenceAngle=0,this.lowerAngle=0,this.upperAngle=0,this.maxMotorTorque=0,this.motorSpeed=0,this.enableLimit=!1,this.enableMotor=!1,Object.seal(this)}function pe(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_referenceAngle=t.referenceAngle,this.m_impulse=new s,this.m_motorImpulse=0,this.m_lowerAngle=t.lowerAngle,this.m_upperAngle=t.upperAngle,this.m_maxMotorTorque=t.maxMotorTorque,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=de.e_inactiveLimit,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=new a,this.m_motorMass=0}function me(){this.parent.call(this),this.type=de.e_mouseJoint,this.target=new r(0,0),this.maxForce=0,this.frequencyHz=5,this.dampingRatio=.7,Object.seal(this)}function ge(e){this.parent.call(this,e),t(e.target.IsValid()),t(n(e.maxForce)&&e.maxForce>=0),t(n(e.frequencyHz)&&e.frequencyHz>=0),t(n(e.dampingRatio)&&e.dampingRatio>=0),this.m_targetA=e.target.Clone(),this.m_localAnchorB=E(this.m_bodyB.GetTransform(),this.m_targetA),this.m_maxForce=e.maxForce,this.m_impulse=new r,this.m_frequencyHz=e.frequencyHz,this.m_dampingRatio=e.dampingRatio,this.m_beta=0,this.m_gamma=0,this.m_indexA=0,this.m_indexB=0,this.m_rB=new r,this.m_localCenterB=new r,this.m_invMassB=0,this.m_invIB=0,this.m_mass=new o,this.m_C=new r}function ye(){this.parent.call(this),this.type=de.e_distanceJoint,this.localAnchorA=new r(0,0),this.localAnchorB=new r(0,0),this.length=1,this.frequencyHz=0,this.dampingRatio=0,Object.seal(this)}function ve(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_length=t.length,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=0,this.m_gamma=0,this.m_bias=0,this.m_indexA=0,this.m_indexB=0,this.m_u=new r,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=0}function xe(){this.parent.call(this),this.type=de.e_prismaticJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.localAxisA=new r(1,0),this.referenceAngle=0,this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0,Object.seal(this)}function Ce(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_localXAxisA=t.localAxisA.Clone(),this.m_localXAxisA.Normalize(),this.m_localYAxisA=f(1,this.m_localXAxisA),this.m_referenceAngle=t.referenceAngle,this.m_impulse=new s,this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=t.lowerTranslation,this.m_upperTranslation=t.upperTranslation,this.m_maxMotorForce=t.maxMotorForce,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=de.e_inactiveLimit,this.m_axis=new r,this.m_perp=new r,this.m_indexA=0,this.m_indexB=0,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_s1=0,this.m_s2=0,this.m_a1=0,this.m_a2=0,this.m_K=new a,this.m_motorMass=0}function Te(){this.parent.call(this),this.type=de.e_frictionJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.maxForce=0,this.maxTorque=0,Object.seal(this)}function be(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_linearImpulse=new r,this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_linearMass=new o,this.m_angularMass=0}function Ae(){this.parent.call(this),this.type=de.e_weldJoint,this.localAnchorA=new r(0,0),this.localAnchorB=new r(0,0),this.referenceAngle=0,this.frequencyHz=0,this.dampingRatio=0,Object.seal(this)}function Se(t){this.parent.call(this,t),this.m_bias=0,this.m_gamma=0,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=new a,this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_referenceAngle=t.referenceAngle,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=new s}function we(){this.parent.call(this),this.type=de.e_wheelJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.localAxisA=new r(1,0),this.enableMotor=!1,this.maxMotorTorque=0,this.motorSpeed=0,this.frequencyHz=2,this.dampingRatio=.7,Object.seal(this)}function Ee(t){this.parent.call(this,t),this.m_indexA=0,this.m_indexB=0,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_localXAxisA=t.localAxisA.Clone(),this.m_localYAxisA=f(1,this.m_localXAxisA),this.m_mass=0,this.m_impulse=0,this.m_motorMass=0,this.m_motorImpulse=0,this.m_springMass=0,this.m_springImpulse=0,this.m_maxMotorTorque=t.maxMotorTorque,this.m_motorSpeed=t.motorSpeed,this.m_enableMotor=t.enableMotor,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_bias=0,this.m_gamma=0,this.m_ax=new r,this.m_ay=new r,this.m_sAx=this.m_sBx=0,this.m_sAy=this.m_sBy=0}function Ie(){this.parent.call(this),this.type=de.e_gearJoint,this.joint1=null,this.joint2=null,this.ratio=1,Object.seal(this)}function Re(e){this.parent.call(this,e),this.m_joint1=e.joint1,this.m_joint2=e.joint2,this.m_typeA=this.m_joint1.GetType(),this.m_typeB=this.m_joint2.GetType(),t(this.m_typeA==de.e_revoluteJoint||this.m_typeA==de.e_prismaticJoint),t(this.m_typeB==de.e_revoluteJoint||this.m_typeB==de.e_prismaticJoint);var i,n;this.m_bodyC=this.m_joint1.GetBodyA(),this.m_bodyA=this.m_joint1.GetBodyB();var s=this.m_bodyA.m_xf,o=this.m_bodyA.m_sweep.a,a=this.m_bodyC.m_xf,c=this.m_bodyC.m_sweep.a;if(this.m_localAnchorA=new r,this.m_localAnchorB=new r,this.m_localAnchorC=new r,this.m_localAnchorD=new r,this.m_localAxisC=new r,this.m_localAxisD=new r,this.m_typeA==de.e_revoluteJoint){var h=e.joint1;this.m_localAnchorC.Assign(h.m_localAnchorA),this.m_localAnchorA.Assign(h.m_localAnchorB),this.m_referenceAngleA=h.m_referenceAngle,this.m_localAxisC.SetZero(),i=o-c-this.m_referenceAngleA}else{var l=e.joint1;this.m_localAnchorC.Assign(l.m_localAnchorA),this.m_localAnchorA.Assign(l.m_localAnchorB),this.m_referenceAngleA=l.m_referenceAngle,this.m_localAxisC.Assign(l.m_localXAxisA);var _=this.m_localAnchorC,d=S(a.q,r.Add(A(s.q,this.m_localAnchorA),r.Subtract(s.p,a.p)));i=u(r.Subtract(d,_),this.m_localAxisC)}this.m_bodyD=this.m_joint2.GetBodyA(),this.m_bodyB=this.m_joint2.GetBodyB();var f=this.m_bodyB.m_xf,p=this.m_bodyB.m_sweep.a,m=this.m_bodyD.m_xf,g=this.m_bodyD.m_sweep.a;if(this.m_typeB==de.e_revoluteJoint){h=e.joint2;this.m_localAnchorD.Assign(h.m_localAnchorA),this.m_localAnchorB.Assign(h.m_localAnchorB),this.m_referenceAngleB=h.m_referenceAngle,this.m_localAxisD.SetZero(),n=p-g-this.m_referenceAngleB}else{l=e.joint2;this.m_localAnchorD.Assign(l.m_localAnchorA),this.m_localAnchorB.Assign(l.m_localAnchorB),this.m_referenceAngleB=l.m_referenceAngle,this.m_localAxisD.Assign(l.m_localXAxisA);var y=this.m_localAnchorD,v=S(m.q,r.Add(A(f.q,this.m_localAnchorB),r.Subtract(f.p,m.p)));n=u(r.Subtract(v,y),this.m_localAxisD)}this.m_ratio=e.ratio,this.m_constant=i+this.m_ratio*n,this.m_impulse=0,this.m_indexA=this.m_indexB=this.m_indexC=this.m_indexD=0,this.m_lcA=new r,this.m_lcB=new r,this.m_lcC=new r,this.m_lcD=new r,this.m_mA=this.m_mB=this.m_mC=this.m_mD=0,this.m_iA=this.m_iB=this.m_iC=this.m_iD=0,this.m_JvAC=new r,this.m_JvBD=new r,this.m_JwA=this.m_JwB=this.m_JwC=this.m_JwD=0,this.m_mass=0}function Pe(){this.parent.call(this),this.type=de.e_motorJoint,this.linearOffset=new r,this.angularOffset=0,this.maxForce=1,this.maxTorque=1,this.correctionFactor=.3,Object.seal(this)}function Oe(t){this.parent.call(this,t),this.m_linearOffset=t.linearOffset.Clone(),this.m_angularOffset=t.angularOffset,this.m_linearImpulse=new r,this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque,this.m_correctionFactor=t.correctionFactor,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_linearError=new r,this.m_angularError=0,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_linearMass=new o,this.m_angularMass=0}function Be(){this.parent.call(this),this.type=de.e_pulleyJoint,this.groundAnchorA=new r(-1,1),this.groundAnchorB=new r(1,1),this.localAnchorA=new r(-1,0),this.localAnchorB=new r(1,0),this.lengthA=0,this.lengthB=0,this.ratio=1,this.collideConnected=!0,Object.seal(this)}function De(e){this.parent.call(this,e),this.m_indexA=0,this.m_indexB=0,this.m_uA=new r,this.m_uB=new r,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=0,this.m_groundAnchorA=e.groundAnchorA.Clone(),this.m_groundAnchorB=e.groundAnchorB.Clone(),this.m_localAnchorA=e.localAnchorA.Clone(),this.m_localAnchorB=e.localAnchorB.Clone(),this.m_lengthA=e.lengthA,this.m_lengthB=e.lengthB,t(0!=e.ratio),this.m_ratio=e.ratio,this.m_constant=e.lengthA+this.m_ratio*e.lengthB,this.m_impulse=0}function Me(){this.parent.call(this),this.type=de.e_ropeJoint,this.localAnchorA=new r(-1,0),this.localAnchorB=new r(1,0),this.maxLength=0,Object.seal(this)}function Le(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_maxLength=t.maxLength,this.m_mass=0,this.m_impulse=0,this.m_state=de.e_inactiveLimit,this.m_length=0,this.m_indexA=0,this.m_indexB=0,this.m_u=new r,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0}function Ne(){this.m_count=0,this.m_ps=null,this.m_p0s=null,this.m_vs=null,this.m_ims=null,this.m_Ls=null,this.m_as=null,this.m_damping=0,this.m_gravity=new r,this.m_k2=1,this.m_k3=.1}Function.prototype._extend=function(t){this.prototype.parent=t;for(var e in t.prototype)this.prototype[e]||(this.prototype[e]=t.prototype[e])},Function.prototype._implement=function(t){return this._extend(t)};var Fe=(function(){function t(t,e){this.name=t,this.parent=e,this.children={},this.startTime=0,this.elapsedTime=0,this.totalTime=0,this.running=!1,this.childrenCount=0}function e(t,i){if(t.name===i.parent)return t;for(var n in t.children){var r;if(r=e(t.children[n],i))return r}return null}"undefined"==typeof performance&&(window.performance={now:function(){return+new Date}}),t.prototype={start:function(){this.startTime=performance.now(),this.running=!0},stop:function(t){if(this.running){this.running=!1,this.elapsedTime+=performance.now()-this.startTime,t&&this.start();for(var e in this.children)this.children[e].stop()}},reset:function(t){t||(this.running=!0,this.totalTime+=this.elapsedTime,this.start()),this.elapsedTime=0;for(var e in this.children)this.children[e].reset(!0)}};var i=[],n=new t("root");return{create:function(e,n){if(!i)throw new Error("late profile creation not allowed");var r=new t(e,n||"root");return i.push(r),r},destroy:function(t){t.childrenCount--,delete t.children[t.name]},init:function(){for(;i.length;){var t=i.pop();(t.parentNode=e(n,t))?(t.parentNode.children[t.name]=t,t.parentNode.childrenCount++):i.unshift(t)}i=null},reset:function(){n.reset(!0)},profileRoot:n}})(),ke=Number.MAX_VALUE,ze=2.220446049250313e-16,Ve=Math.PI,Ge=2,We=8,Ue=.005,je=2/180*Ve,Xe=2*Ue,Ye=8/180*Ve,He=.5*Ve,qe=He*He,Je=2/180*Ve;i.prototype={toString:function(){return this.major+"."+this.minor+"."+this.revision}};var Ze=new i(2,3,1),Qe=Math.sqrt,Ke=Math.atan2,$e=Math.sin,ti=Math.cos,ei=Math.floor,ii=(Math.ceil,Qe),ni=Ke;r.prototype={Clone:function(){return new r(this.x,this.y)},SetZero:function(){return this.x=0,this.y=0,this},Set:function(t,e){return this.x=t,this.y=e,this},Assign:function(t){return this.x=t.x,this.y=t.y,this},Negate:function(){var t=new r;return t.Set(-this.x,-this.y),t},get_i:function(t){switch(t){case 0:return this.x;case 1:return this.y}},set_i:function(t,e){switch(t){case 0:return this.x=e;case 1:return this.y=e}},Add:function(t){return this.x+=t.x,this.y+=t.y,this},Subtract:function(t){return this.x-=t.x,this.y-=t.y,this},Multiply:function(t){return this.x*=t,this.y*=t,this},Length:function(){return ii(this.x*this.x+this.y*this.y)},LengthSquared:function(){return this.x*this.x+this.y*this.y},Normalize:function(){var t=this.Length();if(t<ze)return 0;var e=1/t;return this.x*=e,this.y*=e,t},IsValid:function(){return n(this.x)&&n(this.y)},Skew:function(){return new r(-this.y,this.x)},_serialize:function(t){var e=t||[];return e[0]=this.x,e[1]=this.y,e},_deserialize:function(t){this.x=t[0],this.y=t[1]}},r.Add=function(t,e){return new r(t.x+e.x,t.y+e.y)},r.Subtract=function(t,e){return new r(t.x-e.x,t.y-e.y)},r.Equals=function(t,e){return t.x==e.x&&t.y==e.y},r.Multiply=function(t,e){return new r(t*e.x,t*e.y)},r.Negate=function(t){return new r(-t.x,-t.y)},s.prototype={Clone:function(){return new s(this.x,this.y,this.z)},SetZero:function(){this.x=0,this.y=0,this.z=0},Set:function(t,e,i){this.x=t,this.y=e,this.z=i},Negate:function(){var t=new s;return t.Set(-this.x,-this.y,-this.z),t},Add:function(t){this.x+=t.x,this.y+=t.y,this.z+=t.z},Subtract:function(t){this.x-=t.x,this.y-=t.y,this.z-=t.z},Multiply:function(t){this.x*=t,this.y*=t,this.z*=t},Invert:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},x:0,y:0,z:0},s.Multiply=function(t,e){return new s(t*e.x,t*e.y,t*e.z)},s.Add=function(t,e){return new s(t.x+e.x,t.y+e.y,t.z+e.z)},s.Subtract=function(t,e){return new s(t.x-e.x,t.y-e.y,t.z-e.z)},o.prototype={Set:function(t,e){this.ex.Assign(t),this.ey.Assign(e)},Assign:function(t){this.ex.Assign(t.ex),this.ey.Assign(t.ey)},SetIdentity:function(){this.ex.x=1,this.ey.x=0,this.ex.y=0,this.ey.y=1},SetZero:function(){this.ex.x=0,this.ey.x=0,this.ex.y=0,this.ey.y=0},GetInverse:function(){var t=this.ex.x,e=this.ey.x,i=this.ex.y,n=this.ey.y,r=new o,s=t*n-e*i;return 0!=s&&(s=1/s),r.ex.x=s*n,r.ey.x=-s*e,r.ex.y=-s*i,r.ey.y=s*t,r},Solve:function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,s=this.ey.y,o=e*s-i*n;0!=o&&(o=1/o);var a=new r;return a.x=o*(s*t.x-i*t.y),a.y=o*(e*t.y-n*t.x),a}},o.Add=function(t,e){return new o(r.Add(t.ex,e.ex),r.Add(t.ey,e.ey))},a.prototype={SetZero:function(){this.ex.SetZero(),this.ey.SetZero(),this.ez.SetZero()},Solve33:function(t){var e=y(this.ex,v(this.ey,this.ez));0!=e&&(e=1/e);var i=new s;return i.x=e*y(t,v(this.ey,this.ez)),i.y=e*y(this.ex,v(t,this.ez)),i.z=e*y(this.ex,v(this.ey,t)),i},Solve22:function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,s=this.ey.y,o=e*s-i*n;0!=o&&(o=1/o);var a=new r;return a.x=o*(s*t.x-i*t.y),a.y=o*(e*t.y-n*t.x),a},GetInverse22:function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,r=this.ey.y,s=e*r-i*n;0!=s&&(s=1/s),t.ex.x=s*r,t.ey.x=-s*i,t.ex.z=0,t.ex.y=-s*n,t.ey.y=s*e,t.ey.z=0,t.ez.x=0,t.ez.y=0,t.ez.z=0},GetSymInverse33:function(t){var e=y(this.ex,v(this.ey,this.ez));0!=e&&(e=1/e);var i=this.ex.x,n=this.ey.x,r=this.ez.x,s=this.ey.y,o=this.ez.y,a=this.ez.z;t.ex.x=e*(s*a-o*o),t.ex.y=e*(r*o-n*a),t.ex.z=e*(n*o-r*s),t.ey.x=t.ex.y,t.ey.y=e*(i*a-r*r),t.ey.z=e*(r*n-i*o),t.ez.x=t.ex.z,t.ez.y=t.ey.z,t.ez.z=e*(i*s-n*n)}},c.prototype={Clone:function(){return new c(this.s,this.c)},Assign:function(t){this.s=t.s,this.c=t.c},Set:function(t){this.s=$e(t),this.c=ti(t)},SetIdentity:function(){this.s=0,this.c=1},GetAngle:function(){return ni(this.s,this.c)},GetXAxis:function(){return new r(this.c,this.s)},GetYAxis:function(){return new r(-this.s,this.c)},s:0,c:1},h.prototype={Clone:function(){return new h(this.p,this.q)},Assign:function(t){this.p.Assign(t.p),this.q.Assign(t.q)},SetIdentity:function(){this.p.SetZero(),this.q.SetIdentity()},Set:function(t,e){this.p.Assign(t),this.q.Set(e)}},l.prototype={Assign:function(t){this.localCenter.Assign(t.localCenter),this.c0.Assign(t.c0),this.c.Assign(t.c),this.a=t.a,this.a0=t.a0,this.alpha0=t.alpha0},Clone:function(){var t=new l;return t.localCenter.Assign(this.localCenter),t.c0.Assign(this.c0),t.c.Assign(this.c),t.a=this.a,t.a0=this.a0,t.alpha0=this.alpha0,t},GetTransform:function(t,e){t.p.x=(1-e)*this.c0.x+e*this.c.x,t.p.y=(1-e)*this.c0.y+e*this.c.y;var i=(1-e)*this.a0+e*this.a;t.q.Set(i),t.p.x-=t.q.c*this.localCenter.x-t.q.s*this.localCenter.y,t.p.y-=t.q.s*this.localCenter.x+t.q.c*this.localCenter.y},Advance:function(e){t(this.alpha0<1);var i=(e-this.alpha0)/(1-this.alpha0);this.c0.Add(r.Multiply(i,r.Subtract(this.c,this.c0))),this.a0+=i*(this.a-this.a0),this.alpha0=e},Normalize:function(){var t=2*Ve,e=t*ei(this.a0/t);this.a0-=e,this.a-=e},a0:0,a:0,alpha0:0};var ri=Math.abs,si=Math.min,oi=Math.max;D.prototype={Set:function(t,e,i){this.r=t,this.g=e,this.b=i}},M.prototype={ClearDraw:function(){},SetFlags:function(t){this.m_drawFlags=t},GetFlags:function(){return this.m_drawFlags},AppendFlags:function(t){this.m_drawFlags|=t},ClearFlags:function(t){this.m_drawFlags&=~t},ToggleFlags:function(t){this.m_drawFlags^=t},DrawPolygon:function(t,e,i){},DrawSolidPolygon:function(t,e,i){},DrawCircle:function(t,e,i){},DrawSolidCircle:function(t,e,i,n){},DrawSegment:function(t,e,i){},DrawTransform:function(t){},m_drawFlags:0},M.e_shapeBit=1,M.e_jointBit=2,M.e_aabbBit=4,M.e_centerOfMassBit=8,M.e_contactPoints=16,M.e_contactNormals=32,M.e_contactImpulses=64,M.e_frictionImpulses=128,M.e_statistics=256,M.e_profile=512,M.e_pairBit=1024,"undefined"==typeof performance&&(window.performance={now:function(){return+new Date}}),L.prototype={Reset:function(){this.m_start=performance.now()},GetMilliseconds:function(){return performance.now()-this.m_start}},F.prototype={Clone:function(){},GetType:function(){return this.m_type},GetChildCount:function(){},TestPoint:function(t,e){},RayCast:function(t,e,i,n){},ComputeAABB:function(t,e,i){},ComputeMass:function(t,e){},_serialize:function(t){var e=t||{};return e.m_type=this.m_type,e.m_radius=this.m_radius,e},_deserialize:function(t){this.m_radius=t.m_radius}},F.e_circle=0,F.e_edge=1,F.e_polygon=2,F.e_chain=3,F.e_typeCount=4,k.prototype={Clone:function(){var t=new k;return t.m_radius=this.m_radius,t.m_p=this.m_p.Clone(),t},GetChildCount:function(){return 1},TestPoint:function(t,e){var i=r.Add(t.p,A(t.q,this.m_p)),n=r.Subtract(e,i);return u(n,n)<=this.m_radius*this.m_radius},RayCast:function(t,e,i,n){var s=r.Add(i.p,A(i.q,this.m_p)),o=r.Subtract(e.p1,s),a=u(o,o)-this.m_radius*this.m_radius,c=r.Subtract(e.p2,e.p1),h=u(o,c),l=u(c,c),_=h*h-l*a;if(_<0||l<ze)return!1;var d=-(h+ii(_));return 0<=d&&d<=e.maxFraction*l&&(d/=l,t.fraction=d,t.normal=r.Add(o,r.Multiply(d,c)),t.normal.Normalize(),!0)},ComputeAABB:function(t,e,i){var n=e.p.x+(e.q.c*this.m_p.x-e.q.s*this.m_p.y),r=e.p.y+(e.q.s*this.m_p.x+e.q.c*this.m_p.y);t.lowerBound.x=n-this.m_radius,t.lowerBound.y=r-this.m_radius,t.upperBound.x=n+this.m_radius,t.upperBound.y=r+this.m_radius},ComputeMass:function(t,e){t.mass=e*Ve*this.m_radius*this.m_radius,t.center=this.m_p,t.I=t.mass*(.5*this.m_radius*this.m_radius+u(this.m_p,this.m_p))},GetSupport:function(t){return 0},GetSupportVertex:function(t){return this.m_p},GetVertexCount:function(){return 1},GetVertex:function(e){return t(0==e),this.m_p},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.m_p=this.m_p._serialize(),e},_deserialize:function(t){this.parent.prototype._deserialize.call(this,t),this.m_p._deserialize(t.m_p)}},k._extend(F),z.prototype={Set:function(t,e){this.m_vertex1.Assign(t),this.m_vertex2.Assign(e),this.m_hasVertex0=!1,this.m_hasVertex3=!1},Clone:function(){var t=new z;return t.m_vertex0=this.m_vertex0.Clone(),t.m_vertex1=this.m_vertex1.Clone(),t.m_vertex2=this.m_vertex2.Clone(),t.m_vertex3=this.m_vertex3.Clone(),t.m_hasVertex0=this.m_hasVertex0,t.m_hasVertex3=this.m_hasVertex3,t},GetChildCount:function(){return 1},TestPoint:function(t,e){return!1},RayCast:function(t,e,i,n){var s=S(i.q,r.Subtract(e.p1,i.p)),o=S(i.q,r.Subtract(e.p2,i.p)),a=r.Subtract(o,s),c=this.m_vertex1,h=this.m_vertex2,l=r.Subtract(h,c),_=new r(l.y,-l.x);_.Normalize();var d=u(_,r.Subtract(c,s)),f=u(_,a);if(0==f)return!1;var p=d/f;if(p<0||e.maxFraction<p)return!1;var m=r.Add(s,r.Multiply(p,a)),g=r.Subtract(h,c),y=u(g,g);if(0==y)return!1;var v=u(r.Subtract(m,c),g)/y;return!(v<0||1<v)&&(t.fraction=p,t.normal=d>0?A(i.q,_).Negate():A(i.q,_),!0)},ComputeAABB:function(t,e,i){var n=e.q.c*this.m_vertex1.x-e.q.s*this.m_vertex1.y+e.p.x,r=e.q.s*this.m_vertex1.x+e.q.c*this.m_vertex1.y+e.p.y,s=e.q.c*this.m_vertex2.x-e.q.s*this.m_vertex2.y+e.p.x,o=e.q.s*this.m_vertex2.x+e.q.c*this.m_vertex2.y+e.p.y,a=si(n,s),c=si(r,o),h=oi(n,s),l=oi(r,o);t.lowerBound.x=a-this.m_radius,t.lowerBound.y=c-this.m_radius,t.upperBound.x=h+this.m_radius,t.upperBound.y=l+this.m_radius},ComputeMass:function(t,e){t.mass=0,t.center=r.Multiply(.5,r.Add(this.m_vertex1,this.m_vertex2)),t.I=0},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.m_vertex1=this.m_vertex1._serialize(),e.m_vertex2=this.m_vertex2._serialize(),e.m_hasVertex0=this.m_hasVertex0,this.m_hasVertex0&&(e.m_vertex0=this.m_vertex0._serialize()),e.m_hasVertex3=this.m_hasVertex3,this.m_hasVertex3&&(e.m_vertex3=this.m_vertex3._serialize()),e},_deserialize:function(t){this.parent.prototype._deserialize.call(this,t),this.m_vertex1._deserialize(t.m_vertex1),this.m_vertex2._deserialize(t.m_vertex2),this.m_hasVertex0=t.m_hasVertex0,this.m_hasVertex0&&this.m_vertex0._deserialize(t.m_vertex0),this.m_hasVertex3=t.m_hasVertex3,this.m_hasVertex3&&this.m_vertex3._deserialize(t.m_vertex3)}},z._extend(F),V._tempEdge=new z,V.prototype={Clear:function(){this.m_vertices=null,this.m_count=0},CreateLoop:function(e,i){t(null==this.m_vertices&&0==this.m_count),t(i>=3);for(var n=1;n<i;++n)t(g(e[n-1],e[n])>Ue*Ue);this.m_count=i+1,this.m_vertices=new Array(this.m_count);for(n=0;n<i;++n)this.m_vertices[n]=e[n].Clone();this.m_vertices[i]=this.m_vertices[0].Clone(),this.m_prevVertex.Assign(this.m_vertices[this.m_count-2]),this.m_nextVertex.Assign(this.m_vertices[1]),this.m_hasPrevVertex=!0,this.m_hasNextVertex=!0},CreateChain:function(e,i){t(null==this.m_vertices&&0==this.m_count),t(i>=2);for(var n=1;n<i;++n){t(g(e[n-1],e[n])>Ue*Ue)}this.m_count=i,this.m_vertices=new Array(i);for(n=0;n<i;++n)this.m_vertices[n]=e[n].Clone();this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,this.m_prevVertex.SetZero(),this.m_nextVertex.SetZero()},SetPrevVertex:function(t){this.m_prevVertex.Assign(t),this.m_hasPrevVertex=!0},SetNextVertex:function(t){this.m_nextVertex.Assign(t),this.m_hasNextVertex=!0},Clone:function(){var t=new V;t.m_count=this.m_count,t.m_vertices=new Array(this.m_count);for(var e=0;e<this.m_count;++e)t.m_vertices[e]=this.m_vertices[e].Clone();return t.m_prevVertex=this.m_prevVertex.Clone(),t.m_nextVertex=this.m_nextVertex.Clone(),t.m_hasPrevVertex=this.m_hasPrevVertex,t.m_hasNextVertex=this.m_hasNextVertex,t},GetChildCount:function(){return this.m_count-1},GetChildEdge:function(e,i){t(0<=i&&i<this.m_count-1),e.m_type=F.e_edge,e.m_radius=this.m_radius,e.m_vertex1=this.m_vertices[i+0],e.m_vertex2=this.m_vertices[i+1],i>0?(e.m_vertex0=this.m_vertices[i-1],e.m_hasVertex0=!0):(e.m_vertex0=this.m_prevVertex,e.m_hasVertex0=this.m_hasPrevVertex),i<this.m_count-2?(e.m_vertex3=this.m_vertices[i+2],e.m_hasVertex3=!0):(e.m_vertex3=this.m_nextVertex,e.m_hasVertex3=this.m_hasNextVertex)},TestPoint:function(t,e){return!1},RayCast:function(e,i,n,r){t(r<this.m_count);var s=r,o=r+1;return o==this.m_count&&(o=0),V._tempEdge.m_vertex1=this.m_vertices[s].Clone(),V._tempEdge.m_vertex2=this.m_vertices[o].Clone(),V._tempEdge.RayCast(e,i,n,0)},ComputeAABB:function(e,i,n){t(n<this.m_count);var r=n,s=n+1;s==this.m_count&&(s=0);var o=i.q.c*this.m_vertices[r].x-i.q.s*this.m_vertices[r].y+i.p.x,a=i.q.s*this.m_vertices[r].x+i.q.c*this.m_vertices[r].y+i.p.y,c=i.q.c*this.m_vertices[s].x-i.q.s*this.m_vertices[s].y+i.p.x,h=i.q.s*this.m_vertices[s].x+i.q.c*this.m_vertices[s].y+i.p.y;e.lowerBound.x=si(o,c),e.lowerBound.y=si(a,h),e.upperBound.x=oi(o,c),e.upperBound.y=oi(a,h)},ComputeMass:function(t,e){t.mass=0,t.center.SetZero(),t.I=0},_serialize:function(t){var e=t||{};this.parent.prototype._serialize.call(this,e),e.m_count=this.m_count,e.m_vertices=[];for(var i=0;i<this.m_count;++i)e.m_vertices.push(this.m_vertices[i]._serialize());return e.m_hasPrevVertex=this.m_hasPrevVertex,this.m_hasPrevVertex&&(e.m_prevVertex=this.m_prevVertex._serialize()),e.m_hasNextVertex=this.m_hasNextVertex,this.m_hasNextVertex&&(e.m_nextVertex=this.m_nextVertex._serialize()),e},_deserialize:function(t){this.parent.prototype._deserialize.call(this,t),this.m_count=t.m_count,this.m_vertices=[];for(var e=0;e<this.m_count;++e)this.m_vertices[e]=new r,this.m_vertices[e]._deserialize(t.m_vertices[e]);this.m_hasPrevVertex=t.m_hasPrevVertex,this.m_hasPrevVertex&&this.m_prevVertex._deserialize(t.m_prevVertex),this.m_hasNextVertex=t.m_hasNextVertex,this.m_hasNextVertex&&this.m_nextVertex._deserialize(t.m_nextVertex)}},V._extend(F),G.prototype={Clone:function(){var t=new G;t.m_count=this.m_count,t.m_centroid=this.m_centroid.Clone();for(var e=0;e<this.m_count;++e)t.m_vertices[e]=this.m_vertices[e].Clone(),t.m_normals[e]=this.m_normals[e].Clone();return t},GetChildCount:function(){return 1},Set:function(e,i){if(t(3<=i&&i<=We),i<3)this.SetAsBox(1,1);else{for(var n=si(i,We),s=new Array(We),o=0,a=0;a<n;++a){for(var c=e[a],h=!0,l=0;l<o;++l)if(g(c,s[l])<.5*Ue){h=!1;break}h&&(s[o++]=c.Clone())}if((n=o)<3)return t(!1),void this.SetAsBox(1,1);var u=0,f=s[0].x;for(a=1;a<n;++a){var p=s[a].x;(p>f||p==f&&s[a].y<s[u].y)&&(u=a,f=p)}for(var m=new Array(We),y=0,v=u;;){m[y]=v;var x=0;for(l=1;l<n;++l)if(x!=v){var C=r.Subtract(s[x],s[m[y]]),T=_(C,c=r.Subtract(s[l],s[m[y]]));T<0&&(x=l),0==T&&c.LengthSquared()>C.LengthSquared()&&(x=l)}else x=l;if(++y,v=x,x==u)break}if(y<3)return t(!1),void this.SetAsBox(1,1);for(this.m_count=y,a=0;a<y;++a)this.m_vertices[a]=s[m[a]].Clone();for(a=0;a<y;++a){var b=a,A=a+1<y?a+1:0,S=r.Subtract(this.m_vertices[A],this.m_vertices[b]);t(S.LengthSquared()>ze*ze),this.m_normals[a]=d(S,1).Clone(),this.m_normals[a].Normalize()}this.m_centroid=G.ComputeCentroid(this.m_vertices,y)}},SetAsBox:function(t,e,i,n){if(this.m_count=4,this.m_vertices[0]=new r(-t,-e),this.m_vertices[1]=new r(t,-e),this.m_vertices[2]=new r(t,e),this.m_vertices[3]=new r(-t,e),this.m_normals[0]=new r(0,-1),this.m_normals[1]=new r(1,0),this.m_normals[2]=new r(0,1),this.m_normals[3]=new r(-1,0),i){this.m_centroid.Assign(i);var s=new h;s.p=i,s.q.Set(n);for(var o=0;o<this.m_count;++o)this.m_vertices[o].Assign(w(s,this.m_vertices[o])),this.m_normals[o].Assign(A(s.q,this.m_normals[o]))}},TestPoint:function(t,e){for(var i=S(t.q,r.Subtract(e,t.p)),n=0;n<this.m_count;++n){if(u(this.m_normals[n],r.Subtract(i,this.m_vertices[n]))>0)return!1}return!0},RayCast:function(e,i,n,s){for(var o=S(n.q,r.Subtract(i.p1,n.p)),a=S(n.q,r.Subtract(i.p2,n.p)),c=r.Subtract(a,o),h=0,l=i.maxFraction,_=-1,d=0;d<this.m_count;++d){var f=u(this.m_normals[d],r.Subtract(this.m_vertices[d],o)),p=u(this.m_normals[d],c);if(0==p){if(f<0)return!1}else p<0&&f<h*p?(h=f/p,_=d):p>0&&f<l*p&&(l=f/p);if(l<h)return!1}return t(0<=h&&h<=i.maxFraction),_>=0&&(e.fraction=h,e.normal=A(n.q,this.m_normals[_]),!0)},ComputeAABB:function(t,e,i){for(var n=e.q.c*this.m_vertices[0].x-e.q.s*this.m_vertices[0].y+e.p.x,r=e.q.s*this.m_vertices[0].x+e.q.c*this.m_vertices[0].y+e.p.y,s=n,o=r,a=1;a<this.m_count;++a){var c=e.q.c*this.m_vertices[a].x-e.q.s*this.m_vertices[a].y+e.p.x,h=e.q.s*this.m_vertices[a].x+e.q.c*this.m_vertices[a].y+e.p.y;n=si(n,c),r=si(r,h),s=oi(s,c),o=oi(o,h)}t.lowerBound.x=n-this.m_radius,t.lowerBound.y=r-this.m_radius,t.upperBound.x=s+this.m_radius,t.upperBound.y=o+this.m_radius},ComputeMass:function(e,i){t(this.m_count>=3);for(var n=new r(0,0),s=0,o=0,a=new r(0,0),c=0;c<this.m_count;++c)a.Add(this.m_vertices[c]);a.Multiply(1/this.m_count);for(c=0;c<this.m_count;++c){var h=r.Subtract(this.m_vertices[c],a),l=c+1<this.m_count?r.Subtract(this.m_vertices[c+1],a):r.Subtract(this.m_vertices[0],a),d=_(h,l),f=.5*d;s+=f,n.Add(r.Multiply(f*(1/3),r.Add(h,l)));var p=h.x,m=h.y,g=l.x,y=l.y;o+=1/3*.25*d*(p*p+g*p+g*g+(m*m+y*m+y*y))}e.mass=i*s,t(s>ze),n.Multiply(1/s),e.center=r.Add(n,a),e.I=i*o,e.I+=e.mass*(u(e.center,e.center)-u(n,n))},GetVertexCount:function(){return this.m_count},GetVertex:function(e){return t(0<=e&&e<this.m_count),this.m_vertices[e]},Validate:function(){for(var t=0;t<this.m_count;++t)for(var e=t,i=t<this.m_count-1?e+1:0,n=this.m_vertices[e],s=r.Subtract(this.m_vertices[i],n),o=0;o<this.m_count;++o)if(o!=e&&o!=i){if(_(s,r.Subtract(this.m_vertices[o],n))<0)return!1}return!0},_serialize:function(t){var e=t||{};this.parent.prototype._serialize.call(this,e),e.m_count=this.m_count,e.m_centroid=this.m_centroid._serialize(),e.m_vertices=[],e.m_normals=[];for(var i=0;i<this.m_count;++i)e.m_vertices.push(this.m_vertices[i]._serialize()),e.m_normals.push(this.m_normals[i]._serialize());return e},_deserialize:function(t){this.parent.prototype._deserialize.call(this,t),this.m_count=t.m_count,this.m_centroid._deserialize(t.m_centroid),this.m_vertices=[],this.m_normals=[];for(var e=0;e<this.m_count;++e)this.m_vertices[e]=new r,this.m_vertices[e]._deserialize(t.m_vertices[e]),this.m_normals[e]=new r,this.m_normals[e]._deserialize(t.m_normals[e])}},G.ComputeCentroid=function(e,i){t(i>=3);for(var n=new r,s=0,o=new r(0,0),a=0;a<i;++a){var c=o,h=e[a],l=a+1<i?e[a+1]:e[0],u=.5*_(r.Subtract(h,c),r.Subtract(l,c));s+=u,n.Add(r.Multiply(u,r.Multiply(1/3,r.Add(r.Add(c,h),l))))}return t(s>ze),n.Multiply(1/s),n},G._extend(F),j.prototype={CreateProxy:function(t,e){var i=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(i),i},DestroyProxy:function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)},MoveProxy:function(t,e,i){this.m_tree.MoveProxy(t,e,i)&&this.BufferMove(t)},TouchProxy:function(t){this.BufferMove(t)},GetFatAABB:function(t){return this.m_tree.GetFatAABB(t)},GetUserData:function(t){return this.m_tree.GetUserData(t)},TestOverlap:function(t,e){return vt(this.m_tree.GetFatAABB(t),this.m_tree.GetFatAABB(e))},GetProxyCount:function(){return this.m_proxyCount},UpdatePairs:function(t){this.m_pairCount=0,this.m_pairBuffer.length=0;for(var e=0;e<this.m_moveCount;++e)if(this.m_queryProxyId=this.m_moveBuffer[e],this.m_queryProxyId!=j.e_nullProxy){var i=this.m_tree.GetFatAABB(this.m_queryProxyId);this.m_tree.Query(this,i)}this.m_moveCount=0,this.m_pairBuffer.sort(U);for(e=0;e<this.m_pairCount;){var n=this.m_pairBuffer[e],r=this.m_tree.GetUserData(n.proxyIdA),s=this.m_tree.GetUserData(n.proxyIdB);for(t.AddPair(r,s),++e;e<this.m_pairCount;){var o=this.m_pairBuffer[e];if(o.proxyIdA!=n.proxyIdA||o.proxyIdB!=n.proxyIdB)break;++e}}},Query:function(t,e){this.m_tree.Query(t,e)},RayCast:function(t,e){this.m_tree.RayCast(t,e)},GetTreeHeight:function(){return this.m_tree.GetHeight()},GetTreeBalance:function(){return this.m_tree.GetMaxBalance()},GetTreeQuality:function(){return this.m_tree.GetAreaRatio()},ShiftOrigin:function(t){this.m_tree.ShiftOrigin(t)},BufferMove:function(t){this.m_moveBuffer[this.m_moveCount]=t,++this.m_moveCount},UnBufferMove:function(t){for(var e=0;e<this.m_moveCount;++e)this.m_moveBuffer[e]==t&&(this.m_moveBuffer[e]=j.e_nullProxy)},QueryCallback:function(t){return t==this.m_queryProxyId||(this.m_pairBuffer[this.m_pairCount]=new W,this.m_pairBuffer[this.m_pairCount].proxyIdA=si(t,this.m_queryProxyId),this.m_pairBuffer[this.m_pairCount].proxyIdB=oi(t,this.m_queryProxyId),++this.m_pairCount,!0)}},j.e_nullProxy=-1,X.prototype={Assign:function(t){this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius},Set:function(e,i){switch(e.GetType()){case F.e_circle:var n=e;this.m_vertices=[n.m_p],this.m_count=1,this.m_radius=n.m_radius;break;case F.e_polygon:var r=e;this.m_vertices=r.m_vertices,this.m_count=r.m_count,this.m_radius=r.m_radius;break;case F.e_chain:var s=e;t(0<=i&&i<s.m_count),this.m_vertices=[s.m_vertices[i]],i+1<s.m_count?this.m_vertices[1]=s.m_vertices[i+1]:this.m_vertices[1]=s.m_vertices[0],this.m_count=2,this.m_radius=s.m_radius;break;case F.e_edge:var o=e;this.m_vertices=[o.m_vertex1,o.m_vertex2],this.m_count=2,this.m_radius=o.m_radius;break;default:t(!1)}},GetSupport:function(t,e){for(var i=0,n=this.m_vertices[0].x*t+this.m_vertices[0].y*e,r=1;r<this.m_count;++r){var s=this.m_vertices[r].x*t+this.m_vertices[r].y*e;s>n&&(i=r,n=s)}return i},GetSupportVertex:function(t,e){return this.m_vertices[this.GetSupport(t,e)]},GetVertexCount:function(){return this.m_count},GetVertex:function(e){return t(0<=e&&e<this.m_count),this.m_vertices[e]}},J.prototype={Assign:function(t){this.wA.x=t.wA.x,this.wA.y=t.wA.y,this.wB.x=t.wB.x,this.wB.y=t.wB.y,this.w.x=t.w.x,this.w.y=t.w.y,this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB}},Z.prototype={ReadCache:function(e,i,n,r,s){t(e.count<=3),this.m_count=e.count;for(var o=this.m_v,a=0;a<this.m_count;++a){(_=o[a]).indexA=e.indexA[a],_.indexB=e.indexB[a];var c=i.GetVertex(_.indexA),h=r.GetVertex(_.indexB);_.wA.x=n.q.c*c.x-n.q.s*c.y+n.p.x,_.wA.y=n.q.s*c.x+n.q.c*c.y+n.p.y,_.wB.x=s.q.c*h.x-s.q.s*h.y+s.p.x,_.wB.y=s.q.s*h.x+s.q.c*h.y+s.p.y,_.w.x=_.wB.x-_.wA.x,_.w.y=_.wB.y-_.wA.y,_.a=0}if(this.m_count>1){var l=e.metric,u=this.GetMetric();(u<.5*l||2*l<u||u<ze)&&(this.m_count=0)}if(0==this.m_count){var _;(_=o[0]).indexA=0,_.indexB=0;c=i.GetVertex(0),h=r.GetVertex(0);_.wA.x=n.q.c*c.x-n.q.s*c.y+n.p.x,_.wA.y=n.q.s*c.x+n.q.c*c.y+n.p.y,_.wB.x=s.q.c*h.x-s.q.s*h.y+s.p.x,_.wB.y=s.q.s*h.x+s.q.c*h.y+s.p.y,_.w.x=_.wB.x-_.wA.x,_.w.y=_.wB.y-_.wA.y,_.a=1,this.m_count=1}},WriteCache:function(t){t.metric=this.GetMetric(),t.count=this.m_count;for(var e=this.m_v,i=0;i<this.m_count;++i)t.indexA[i]=e[i].indexA,t.indexB[i]=e[i].indexB},GetSearchDirection:function(e){switch(this.m_count){case 1:e.x=-this.m_v[0].w.x,e.y=-this.m_v[0].w.y;break;case 2:var i=this.m_v[1].w.x-this.m_v[0].w.x,n=this.m_v[1].w.y-this.m_v[0].w.y;i*-this.m_v[0].w.y-n*-this.m_v[0].w.x>0?(e.x=-1*n,e.y=1*i):(e.x=1*n,e.y=-1*i);break;default:t(!1),e.x=e.y=0}},GetClosestPoint:function(e){switch(this.m_count){case 1:e.x=this.m_v[0].w.x,e.y=this.m_v[0].w.y;break;case 2:e.x=this.m_v[0].a*this.m_v[0].w.x+this.m_v[1].a*this.m_v[1].w.x,e.y=this.m_v[0].a*this.m_v[0].w.y+this.m_v[1].a*this.m_v[1].w.y;break;case 3:e.x=e.y=0;break;default:t(!1),e.x=e.y=0}},GetWitnessPoints:function(e,i){switch(this.m_count){case 1:e.x=this.m_v[0].wA.x,e.y=this.m_v[0].wA.y,i.x=this.m_v[0].wB.x,i.y=this.m_v[0].wB.y;break;case 2:e.x=this.m_v[0].a*this.m_v[0].wA.x+this.m_v[1].a*this.m_v[1].wA.x,e.y=this.m_v[0].a*this.m_v[0].wA.y+this.m_v[1].a*this.m_v[1].wA.y,i.x=this.m_v[0].a*this.m_v[0].wB.x+this.m_v[1].a*this.m_v[1].wB.x,i.y=this.m_v[0].a*this.m_v[0].wB.y+this.m_v[1].a*this.m_v[1].wB.y;break;case 3:e.x=this.m_v[0].a*this.m_v[0].wA.x+this.m_v[1].a*this.m_v[1].wA.x+this.m_v[2].a*this.m_v[2].wA.x,e.y=this.m_v[0].a*this.m_v[0].wA.y+this.m_v[1].a*this.m_v[1].wA.y+this.m_v[2].a*this.m_v[2].wA.y,i.x=e.x,i.y=e.y;break;default:t(!1)}},GetMetric:function(){switch(this.m_count){case 1:return 0;case 2:return m(this.m_v[0].w,this.m_v[1].w);case 3:return(this.m_v[1].w.x-this.m_v[0].w.x)*(this.m_v[2].w.y-this.m_v[0].w.y)-(this.m_v[1].w.y-this.m_v[0].w.y)*(this.m_v[2].w.x-this.m_v[0].w.x);default:return t(!1),0}},Solve2:function(){var t=this.m_v[0].w,e=this.m_v[1].w,i=e.x-t.x,n=e.y-t.y,r=-(t.x*i+t.y*n);if(r<=0)return this.m_v[0].a=1,void(this.m_count=1);var s=e.x*i+e.y*n;if(s<=0)return this.m_v[1].a=1,this.m_count=1,void this.m_v[0].Assign(this.m_v[1]);var o=1/(s+r);this.m_v[0].a=s*o,this.m_v[1].a=r*o,this.m_count=2},Solve3:function(){var t=this.m_v[0].w,e=this.m_v[1].w,i=this.m_v[2].w,n=e.x-t.x,r=e.y-t.y,s=t.x*n+t.y*r,o=e.x*n+e.y*r,a=-s,c=i.x-t.x,h=i.y-t.y,l=t.x*c+t.y*h,u=i.x*c+i.y*h,_=-l,d=i.x-e.x,f=i.y-e.y,p=e.x*d+e.y*f,m=i.x*d+i.y*f,g=-p,y=n*h-r*c,v=y*(e.x*i.y-e.y*i.x),x=y*(i.x*t.y-i.y*t.x),C=y*(t.x*e.y-t.y*e.x);if(a<=0&&_<=0)return this.m_v[0].a=1,void(this.m_count=1);if(o>0&&a>0&&C<=0){var T=1/(o+a);return this.m_v[0].a=o*T,this.m_v[1].a=a*T,void(this.m_count=2)}if(u>0&&_>0&&x<=0){var b=1/(u+_);return this.m_v[0].a=u*b,this.m_v[2].a=_*b,this.m_count=2,void this.m_v[1].Assign(this.m_v[2])}if(o<=0&&g<=0)return this.m_v[1].a=1,this.m_count=1,void this.m_v[0].Assign(this.m_v[1]);if(u<=0&&m<=0)return this.m_v[2].a=1,this.m_count=1,void this.m_v[0].Assign(this.m_v[2]);if(m>0&&g>0&&v<=0){var A=1/(m+g);return this.m_v[1].a=m*A,this.m_v[2].a=g*A,this.m_count=2,void this.m_v[0].Assign(this.m_v[2])}var S=1/(v+x+C);this.m_v[0].a=v*S,this.m_v[1].a=x*S,this.m_v[2].a=C*S,this.m_count=3}};var ai=new Z,ci=new r,hi=new r;Q.b2_gjkCalls=0,Q.b2_gjkIters=0,Q.b2_gjkMaxIters=0;K.prototype={indexA:0,indexB:0,typeA:0,typeB:0,Reset:function(){this.indexA=this.indexB=this.typeA=this.typeB=0},Get:function(){return this.indexA|this.indexB<<8|this.typeA<<16|this.typeB<<24},Assign:function(t){this.indexA=t.indexA,this.indexB=t.indexB,this.typeA=t.typeA,this.typeB=t.typeB}},K.e_vertex=0,K.e_face=1,$.prototype={Clone:function(){var t=new $;return t.localPoint.x=this.localPoint.x,t.localPoint.y=this.localPoint.y,t.normalImpulse=this.normalImpulse,t.tangentImpulse=this.tangentImpulse,t.id.Assign(this.id),t}},tt.prototype={Clone:function(){var t=new tt;t.pointCount=this.pointCount,t.type=this.type,t.localPoint.x=this.localPoint.x,t.localPoint.y=this.localPoint.y,t.localNormal.x=this.localNormal.x,t.localNormal.y=this.localNormal.y;for(var e=0;e<this.pointCount;++e)t.points[e]=this.points[e].Clone();return t},Assign:function(t){this.pointCount=t.pointCount,this.type=t.type,this.localPoint.x=t.localPoint.x,this.localPoint.y=t.localPoint.y,this.localNormal.x=t.localNormal.x,this.localNormal.y=t.localNormal.y;for(var e=0;e<this.pointCount;++e)this.points[e]=t.points[e].Clone()}},tt.e_circles=0,tt.e_faceA=1,tt.e_faceB=2,tt.b2_nullState=0,tt.b2_addState=1,tt.b2_persistState=2,tt.b2_removeState=3,et.prototype={Initialize:function(t,e,i,n,s){if(0!=t.pointCount)switch(t.type){case tt.e_circles:this.normal.x=1,this.normal.y=0;var o=e.q.c*t.localPoint.x-e.q.s*t.localPoint.y+e.p.x,a=e.q.s*t.localPoint.x+e.q.c*t.localPoint.y+e.p.y,c=n.q.c*t.points[0].localPoint.x-n.q.s*t.points[0].localPoint.y+n.p.x,h=n.q.s*t.points[0].localPoint.x+n.q.c*t.points[0].localPoint.y+n.p.y,l=o-c,u=a-h;l*l+u*u>ze*ze&&(this.normal.x=c-o,this.normal.y=h-a,this.normal.Normalize());var _=o+i*this.normal.x,d=a+i*this.normal.y,f=c-s*this.normal.x,p=h-s*this.normal.y;this.points[0]=new r(.5*(_+f),.5*(d+p)),this.separations[0]=(f-_)*this.normal.x+(p-d)*this.normal.y;break;case tt.e_faceA:this.normal.x=e.q.c*t.localNormal.x-e.q.s*t.localNormal.y,this.normal.y=e.q.s*t.localNormal.x+e.q.c*t.localNormal.y;for(var m=e.q.c*t.localPoint.x-e.q.s*t.localPoint.y+e.p.x,g=e.q.s*t.localPoint.x+e.q.c*t.localPoint.y+e.p.y,y=0;y<t.pointCount;++y){var v=n.q.c*t.points[y].localPoint.x-n.q.s*t.points[y].localPoint.y+n.p.x,x=n.q.s*t.points[y].localPoint.x+n.q.c*t.points[y].localPoint.y+n.p.y;_=v+(i-(C=(v-m)*this.normal.x+(x-g)*this.normal.y))*this.normal.x,d=x+(i-C)*this.normal.y,f=v-s*this.normal.x,p=x-s*this.normal.y;this.points[y]=new r(.5*(_+f),.5*(d+p)),this.separations[y]=(f-_)*this.normal.x+(p-d)*this.normal.y}break;case tt.e_faceB:this.normal.x=n.q.c*t.localNormal.x-n.q.s*t.localNormal.y,this.normal.y=n.q.s*t.localNormal.x+n.q.c*t.localNormal.y;for(m=n.q.c*t.localPoint.x-n.q.s*t.localPoint.y+n.p.x,g=n.q.s*t.localPoint.x+n.q.c*t.localPoint.y+n.p.y,y=0;y<t.pointCount;++y){var C;v=e.q.c*t.points[y].localPoint.x-e.q.s*t.points[y].localPoint.y+e.p.x,x=e.q.s*t.points[y].localPoint.x+e.q.c*t.points[y].localPoint.y+e.p.y,f=v+(s-(C=(v-m)*this.normal.x+(x-g)*this.normal.y))*this.normal.x,p=x+(s-C)*this.normal.y,_=v-i*this.normal.x,d=x-i*this.normal.y;this.points[y]=new r(.5*(_+f),.5*(d+p)),this.separations[y]=(_-f)*this.normal.x+(d-p)*this.normal.y}this.normal.x=-this.normal.x,this.normal.y=-this.normal.y}}},st.prototype={Assign:function(t){this.lowerBound.x=t.lowerBound.x,this.lowerBound.y=t.lowerBound.y,this.upperBound.x=t.upperBound.x,this.upperBound.y=t.upperBound.y},Clone:function(){var t=new st;return t.lowerBound.x=this.lowerBound.x,t.lowerBound.y=this.lowerBound.y,t.upperBound.x=this.upperBound.x,t.upperBound.y=this.upperBound.y,t},IsValid:function(){return this.upperBound.x-this.lowerBound.x>=0&&this.upperBound.y-this.lowerBound.y>=0&&this.lowerBound.IsValid()&&this.upperBound.IsValid()},GetCenter:function(){return new r(.5*(this.lowerBound.x+this.upperBound.x),.5*(this.lowerBound.y+this.upperBound.y))},GetExtents:function(){return new r(.5*(this.upperBound.x-this.lowerBound.x),.5*(this.upperBound.y-this.lowerBound.y))},GetPerimeter:function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))},Combine:function(t,e){e?(this.lowerBound.x=si(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=si(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=oi(t.upperBound.x,e.upperBound.x),this.upperBound.y=oi(t.upperBound.y,e.upperBound.y)):(this.lowerBound.x=si(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=si(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=oi(this.upperBound.x,t.upperBound.x),this.upperBound.y=oi(this.upperBound.y,t.upperBound.y))},Contains:function(t){return this.lowerBound.x<=t.lowerBound.x&&this.lowerBound.y<=t.lowerBound.y&&t.upperBound.x<=this.upperBound.x&&t.upperBound.y<=this.upperBound.y},RayCast:function(t,e){for(var i=-ke,n=ke,s=e.p1,o=r.Subtract(e.p2,e.p1),a=R(o),c=new r,h=0;h<2;++h)if(a.get_i(h)<ze){if(s.get_i(h)<this.lowerBound.get_i(h)||this.upperBound.get_i(h)<s.get_i(h))return!1}else{var l=1/o.get_i(h),u=(this.lowerBound.get_i(h)-s.get_i(h))*l,_=(this.upperBound.get_i(h)-s.get_i(h))*l,d=-1;if(u>_){var f=_;_=u,u=f,d=1}if(u>i&&(c.x=c.y=0,c.set_i(h,d),i=u),n=si(n,_),i>n)return!1}return!(i<0||e.maxFraction<i)&&(t.fraction=i,t.normal.x=c.x,t.normal.y=c.y,!0)}},lt._localTangent=new r,lt._local_incidentEdges=[new it,new it],_t.e_unknown=0,_t.e_edgeA=1,_t.e_edgeB=2,pt._temp_edge=new r,pt._temp_edge0=new r,pt._temp_edge2=new r,pt.prototype={Collide:function(t,e,i,n,r){this.m_xf.Assign(I(i,r)),this.m_centroidB.x=this.m_xf.q.c*n.m_centroid.x-this.m_xf.q.s*n.m_centroid.y+this.m_xf.p.x,this.m_centroidB.y=this.m_xf.q.s*n.m_centroid.x+this.m_xf.q.c*n.m_centroid.y+this.m_xf.p.y,this.m_v0.x=e.m_vertex0.x,this.m_v0.y=e.m_vertex0.y,this.m_v1.x=e.m_vertex1.x,this.m_v1.y=e.m_vertex1.y,this.m_v2.x=e.m_vertex2.x,this.m_v2.y=e.m_vertex2.y,this.m_v3.x=e.m_vertex3.x,this.m_v3.y=e.m_vertex3.y;var s=e.m_hasVertex0,o=e.m_hasVertex3;pt._temp_edge.x=this.m_v2.x-this.m_v1.x,pt._temp_edge.y=this.m_v2.y-this.m_v1.y,pt._temp_edge.Normalize(),this.m_normal1.x=pt._temp_edge.y,this.m_normal1.y=-pt._temp_edge.x;var a=this.m_normal1.x*(this.m_centroidB.x-this.m_v1.x)+this.m_normal1.y*(this.m_centroidB.y-this.m_v1.y),c=0,h=0,l=!1,u=!1;s&&(pt._temp_edge0.x=this.m_v1.x-this.m_v0.x,pt._temp_edge0.y=this.m_v1.y-this.m_v0.y,pt._temp_edge0.Normalize(),this.m_normal0.x=pt._temp_edge0.y,this.m_normal0.y=-pt._temp_edge0.x,l=pt._temp_edge0.x*pt._temp_edge.y-pt._temp_edge0.y*pt._temp_edge.x>=0,c=this.m_normal0.x*(this.m_centroidB.x-this.m_v0.x)+this.m_normal0.y*(this.m_centroidB.y-this.m_v0.y)),o&&(pt._temp_edge2.x=this.m_v3.x-this.m_v2.x,pt._temp_edge2.y=this.m_v3.y-this.m_v2.y,pt._temp_edge2.Normalize(),this.m_normal2.x=pt._temp_edge2.y,this.m_normal2.y=-pt._temp_edge2.x,u=pt._temp_edge.x*pt._temp_edge2.y-pt._temp_edge.y*pt._temp_edge2.x>0,h=this.m_normal2.x*(this.m_centroidB.x-this.m_v2.x)+this.m_normal2.y*(this.m_centroidB.y-this.m_v2.y)),s&&o?l&&u?(this.m_front=c>=0||a>=0||h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal0.x,this.m_lowerLimit.y=this.m_normal0.y,this.m_upperLimit.x=this.m_normal2.x,this.m_upperLimit.y=this.m_normal2.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y)):l?(this.m_front=c>=0||a>=0&&h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal0.x,this.m_lowerLimit.y=this.m_normal0.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal2.x,this.m_lowerLimit.y=-this.m_normal2.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y)):u?(this.m_front=h>=0||c>=0&&a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=this.m_normal2.x,this.m_upperLimit.y=this.m_normal2.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=-this.m_normal0.x,this.m_upperLimit.y=-this.m_normal0.y)):(this.m_front=c>=0&&a>=0&&h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal2.x,this.m_lowerLimit.y=-this.m_normal2.y,this.m_upperLimit.x=-this.m_normal0.x,this.m_upperLimit.y=-this.m_normal0.y)):s?l?(this.m_front=c>=0||a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal0.x,this.m_lowerLimit.y=this.m_normal0.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y)):(this.m_front=c>=0&&a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=-this.m_normal0.x,this.m_upperLimit.y=-this.m_normal0.y)):o?u?(this.m_front=a>=0||h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=this.m_normal2.x,this.m_upperLimit.y=this.m_normal2.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y)):(this.m_front=a>=0&&h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal2.x,this.m_lowerLimit.y=-this.m_normal2.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y)):(this.m_front=a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y)),this.m_polygonB.count=n.m_count;for(var _=0;_<n.m_count;++_)this.m_polygonB.vertices[_]=w(this.m_xf,n.m_vertices[_]),this.m_polygonB.normals[_]=A(this.m_xf.q,n.m_normals[_]);this.m_radius=2*Xe,t.pointCount=0;var d=this.ComputeEdgeSeparation();if(d.type!=_t.e_unknown&&!(d.separation>this.m_radius)){var f=this.ComputePolygonSeparation();if(!(f.type!=_t.e_unknown&&f.separation>this.m_radius)){var p=new _t;p=f.type==_t.e_unknown?d:f.separation>.98*d.separation+.001?f:d;var m=new Array(2),g=new ft;if(p.type==_t.e_edgeA){t.type=tt.e_faceA;var y=0,v=this.m_normal.x*this.m_polygonB.normals[0].x+this.m_normal.y*this.m_polygonB.normals[0].y;for(_=1;_<this.m_polygonB.count;++_){var x=this.m_normal.x*this.m_polygonB.normals[_].x+this.m_normal.y*this.m_polygonB.normals[_].y;x<v&&(v=x,y=_)}var C=y,T=C+1<this.m_polygonB.count?C+1:0;m[0]=new it,m[0].v.x=this.m_polygonB.vertices[C].x,m[0].v.y=this.m_polygonB.vertices[C].y,m[0].id.indexA=0,m[0].id.indexB=C,m[0].id.typeA=K.e_face,m[0].id.typeB=K.e_vertex,m[1]=new it,m[1].v.x=this.m_polygonB.vertices[T].x,m[1].v.y=this.m_polygonB.vertices[T].y,m[1].id.indexA=0,m[1].id.indexB=T,m[1].id.typeA=K.e_face,m[1].id.typeB=K.e_vertex,this.m_front?(g.i1=0,g.i2=1,g.v1.x=this.m_v1.x,g.v1.y=this.m_v1.y,g.v2.x=this.m_v2.x,g.v2.y=this.m_v2.y,g.normal.x=this.m_normal1.x,g.normal.y=this.m_normal1.y):(g.i1=1,g.i2=0,g.v1.x=this.m_v2.x,g.v1.y=this.m_v2.y,g.v2.x=this.m_v1.x,g.v2.y=this.m_v1.y,g.normal.x=-this.m_normal1.x,g.normal.y=-this.m_normal1.y)}else t.type=tt.e_faceB,m[0]=new it,m[0].v=this.m_v1,m[0].id.indexA=0,m[0].id.indexB=p.index,m[0].id.typeA=K.e_vertex,m[0].id.typeB=K.e_face,m[1]=new it,m[1].v=this.m_v2,m[1].id.indexA=0,m[1].id.indexB=p.index,m[1].id.typeA=K.e_vertex,m[1].id.typeB=K.e_face,g.i1=p.index,g.i2=g.i1+1<this.m_polygonB.count?g.i1+1:0,g.v1.x=this.m_polygonB.vertices[g.i1].x,g.v1.y=this.m_polygonB.vertices[g.i1].y,g.v2.x=this.m_polygonB.vertices[g.i2].x,g.v2.y=this.m_polygonB.vertices[g.i2].y,g.normal.x=this.m_polygonB.normals[g.i1].x,g.normal.y=this.m_polygonB.normals[g.i1].y;g.sideNormal1.x=g.normal.y,g.sideNormal1.y=-g.normal.x,g.sideNormal2.x=-g.sideNormal1.x,g.sideNormal2.y=-g.sideNormal1.y,g.sideOffset1=g.sideNormal1.x*g.v1.x+g.sideNormal1.y*g.v1.y,g.sideOffset2=g.sideNormal2.x*g.v2.x+g.sideNormal2.y*g.v2.y;var b=new Array(2),S=new Array(2);if(!(gt(b,m,g.sideNormal1.x,g.sideNormal1.y,g.sideOffset1,g.i1)<Ge||gt(S,b,g.sideNormal2.x,g.sideNormal2.y,g.sideOffset2,g.i2)<Ge)){p.type==_t.e_edgeA?(t.localNormal.x=g.normal.x,t.localNormal.y=g.normal.y,t.localPoint.x=g.v1.x,t.localPoint.y=g.v1.y):(t.localNormal.x=n.m_normals[g.i1].x,t.localNormal.y=n.m_normals[g.i1].y,t.localPoint.x=n.m_vertices[g.i1].x,t.localPoint.y=n.m_vertices[g.i1].y);var R=0;for(_=0;_<Ge;++_){if(g.normal.x*(S[_].v.x-g.v1.x)+g.normal.y*(S[_].v.y-g.v1.y)<=this.m_radius){var P=t.points[R]=new $;p.type==_t.e_edgeA?(P.localPoint.Assign(E(this.m_xf,S[_].v)),P.id.Assign(S[_].id)):(P.localPoint.x=S[_].v.x,P.localPoint.y=S[_].v.y,P.id.typeA=S[_].id.typeB,P.id.typeB=S[_].id.typeA,P.id.indexA=S[_].id.indexB,P.id.indexB=S[_].id.indexA),++R}}t.pointCount=R}}}},ComputeEdgeSeparation:function(){var t=new _t;t.type=_t.e_edgeA,t.index=this.m_front?0:1,t.separation=Number.MAX_VALUE;for(var e=0;e<this.m_polygonB.count;++e){var i=this.m_normal.x*(this.m_polygonB.vertices[e].x-this.m_v1.x)+this.m_normal.y*(this.m_polygonB.vertices[e].y-this.m_v1.y);i<t.separation&&(t.separation=i)}return t},ComputePolygonSeparation:function(){var t=new _t;t.type=_t.e_unknown,t.index=-1,t.separation=-Number.MAX_VALUE;for(var e=-this.m_normal.y,i=this.m_normal.x,n=0;n<this.m_polygonB.count;++n){var r=-this.m_polygonB.normals[n].x,s=-this.m_polygonB.normals[n].y,o=r*(this.m_polygonB.vertices[n].x-this.m_v1.x)+s*(this.m_polygonB.vertices[n].y-this.m_v1.y),a=r*(this.m_polygonB.vertices[n].x-this.m_v2.x)+s*(this.m_polygonB.vertices[n].y-this.m_v2.y),c=si(o,a);if(c>this.m_radius)return t.type=_t.e_edgeB,t.index=n,t.separation=c,t;if(r*e+s*i>=0){if((r-this.m_upperLimit.x)*this.m_normal.x+(s-this.m_upperLimit.y)*this.m_normal.y<-je)continue}else if((r-this.m_lowerLimit.x)*this.m_normal.x+(s-this.m_lowerLimit.y)*this.m_normal.y<-je)continue;c>t.separation&&(t.type=_t.e_edgeB,t.index=n,t.separation=c)}return t}},pt.e_isolated=0,pt.e_concave=1,pt.e_convex=2,mt.collider=new pt,yt.input=new H,yt.cache=new Y,yt.output=new q;var li=-1;xt.prototype={IsLeaf:function(){return this.child1==li}},Ct.aabbExtensionFattener=new r(.1,.1),Ct.prototype={CreateProxy:function(t,e){var i=this.AllocateNode();return this.m_nodes[i].aabb.lowerBound.Assign(r.Subtract(t.lowerBound,Ct.aabbExtensionFattener)),this.m_nodes[i].aabb.upperBound.Assign(r.Add(t.upperBound,Ct.aabbExtensionFattener)),this.m_nodes[i].userData=e,this.m_nodes[i].height=0,this.InsertLeaf(i),i},DestroyProxy:function(e){t(0<=e&&e<this.m_nodeCapacity),t(this.m_nodes[e].IsLeaf()),this.RemoveLeaf(e),this.FreeNode(e)},MoveProxy:function(e,i,n){if(t(0<=e&&e<this.m_nodeCapacity),t(this.m_nodes[e].IsLeaf()),this.m_nodes[e].aabb.Contains(i))return!1;this.RemoveLeaf(e),this.m_nodes[e].aabb.Assign(i),this.m_nodes[e].aabb.lowerBound.Subtract(Ct.aabbExtensionFattener),this.m_nodes[e].aabb.upperBound.Add(Ct.aabbExtensionFattener);var s=r.Multiply(2,n);return s.x<0?this.m_nodes[e].aabb.lowerBound.x+=s.x:this.m_nodes[e].aabb.upperBound.x+=s.x,s.y<0?this.m_nodes[e].aabb.lowerBound.y+=s.y:this.m_nodes[e].aabb.upperBound.y+=s.y,this.InsertLeaf(e),!0},GetUserData:function(e){return t(0<=e&&e<this.m_nodeCapacity),this.m_nodes[e].userData},GetFatAABB:function(e){return t(0<=e&&e<this.m_nodeCapacity),this.m_nodes[e].aabb},Query:function(t,e){var i=[];for(i.push(this.m_root);i.length>0;){var n=i.pop();if(n!=li){var r=this.m_nodes[n];if(vt(r.aabb,e))if(r.IsLeaf()){if(0==t.QueryCallback(n))return}else i.push(r.child1),i.push(r.child2)}}},RayCast:function(e,i){var n=i.p1,s=i.p2,o=r.Subtract(s,n);t(o.LengthSquared()>0),o.Normalize();var a=f(1,o),c=R(a),h=i.maxFraction,l=new st,_=r.Add(n,r.Multiply(h,r.Subtract(s,n)));l.lowerBound.Assign(P(n,_)),l.upperBound.Assign(O(n,_));var d=[];for(d.push(this.m_root);d.length>0;){var p=d.pop();if(p!=li){var m=this.m_nodes[p];if(0!=vt(m.aabb,l)){var g=m.aabb.GetCenter(),y=m.aabb.GetExtents();if(!(ri(u(a,r.Subtract(n,g)))-u(c,y)>0))if(m.IsLeaf()){var v=new nt;v.p1.Assign(i.p1),v.p2.Assign(i.p2),v.maxFraction=h;var x=e.RayCastCallback(v,p);if(0==x)return;if(x>0){_=r.Add(n,r.Multiply(h=x,r.Subtract(s,n)));l.lowerBound.Assign(P(n,_)),l.upperBound.Assign(O(n,_))}}else d.push(m.child1),d.push(m.child2)}}}},Validate:function(){this.ValidateStructure(this.m_root),this.ValidateMetrics(this.m_root);for(var e=0,i=this.m_freeList;i!=li;)t(0<=i&&i<this.m_nodeCapacity),i=this.m_nodes[i].parent,++e;t(this.GetHeight()==this.ComputeHeight()),t(this.m_nodeCount+e==this.m_nodeCapacity)},GetHeight:function(){return this.m_root==li?0:this.m_nodes[this.m_root].height},GetMaxBalance:function(){for(var e=0,i=0;i<this.m_nodeCapacity;++i){var n=this.m_nodes[i];if(!(n.height<=1)){t(0==n.IsLeaf());var r=n.child1,s=n.child2,o=ri(this.m_nodes[s].height-this.m_nodes[r].height);e=oi(e,o)}}return e},GetAreaRatio:function(){if(this.m_root==li)return 0;for(var t=this.m_nodes[this.m_root].aabb.GetPerimeter(),e=0,i=0;i<this.m_nodeCapacity;++i){var n=this.m_nodes[i];n.height<0||(e+=n.aabb.GetPerimeter())}return e/t},RebuildBottomUp:function(){for(var t=new Array(this.m_nodeCount),e=0,i=0;i<this.m_nodeCapacity;++i)this.m_nodes[i].height<0||(this.m_nodes[i].IsLeaf()?(this.m_nodes[i].parent=li,t[e]=i,++e):this.FreeNode(i));for(;e>1;){var n=ke,r=-1,s=-1;for(i=0;i<e;++i)for(var o=this.m_nodes[t[i]].aabb,a=i+1;a<e;++a){var c=this.m_nodes[t[a]].aabb,h=new st;h.Combine(o,c);var l=h.GetPerimeter();l<n&&(r=i,s=a,n=l)}var u=t[r],_=t[s],d=this.m_nodes[u],f=this.m_nodes[_],p=this.AllocateNode(),m=this.m_nodes[p];m.child1=u,m.child2=_,m.height=1+oi(d.height,f.height),m.aabb.Combine(d.aabb,f.aabb),m.parent=li,d.parent=p,f.parent=p,t[s]=t[e-1],t[r]=p,--e}this.m_root=t[0],this.Validate()},ShiftOrigin:function(t){for(var e=0;e<this.m_nodeCapacity;++e)this.m_nodes[e].aabb.lowerBound.Subtract(t),this.m_nodes[e].aabb.upperBound.Subtract(t)},AllocateNode:function(){if(this.m_freeList==li){t(this.m_nodeCount==this.m_nodeCapacity);var e=this.m_nodes;this.m_nodeCapacity*=2,this.m_nodes=e.concat(new Array(this.m_nodeCapacity-this.m_nodeCount));for(var i=this.m_nodeCount;i<this.m_nodeCapacity-1;++i)this.m_nodes[i]=new xt,this.m_nodes[i].parent=i+1,this.m_nodes[i].height=-1;this.m_nodes[this.m_nodeCapacity-1]=new xt,this.m_nodes[this.m_nodeCapacity-1].parent=li,this.m_nodes[this.m_nodeCapacity-1].height=-1,this.m_freeList=this.m_nodeCount}var n=this.m_freeList;return this.m_freeList=this.m_nodes[n].parent,this.m_nodes[n].parent=li,this.m_nodes[n].child1=li,this.m_nodes[n].child2=li,this.m_nodes[n].height=0,this.m_nodes[n].userData=null,++this.m_nodeCount,n},FreeNode:function(e){t(0<=e&&e<this.m_nodeCapacity),t(0<this.m_nodeCount),this.m_nodes[e].parent=this.m_freeList,this.m_nodes[e].height=-1,this.m_freeList=e,--this.m_nodeCount},InsertLeaf:function(e){if(++this.m_insertionCount,this.m_root==li)return this.m_root=e,void(this.m_nodes[this.m_root].parent=li);for(var i=this.m_nodes[e].aabb,n=this.m_root;0==this.m_nodes[n].IsLeaf();){var r=this.m_nodes[n].child1,s=this.m_nodes[n].child2,o=this.m_nodes[n].aabb.GetPerimeter(),a=new st;a.Combine(this.m_nodes[n].aabb,i);var c,h,l=a.GetPerimeter(),u=2*l,_=2*(l-o);if(this.m_nodes[r].IsLeaf())(h=new st).Combine(i,this.m_nodes[r].aabb),c=h.GetPerimeter()+_;else{(h=new st).Combine(i,this.m_nodes[r].aabb);var d=this.m_nodes[r].aabb.GetPerimeter();c=h.GetPerimeter()-d+_}var f;if(this.m_nodes[s].IsLeaf())(h=new st).Combine(i,this.m_nodes[s].aabb),f=h.GetPerimeter()+_;else{(h=new st).Combine(i,this.m_nodes[s].aabb);d=this.m_nodes[s].aabb.GetPerimeter();f=h.GetPerimeter()-d+_}if(u<c&&u<f)break;n=c<f?r:s}var p=n,m=this.m_nodes[p].parent,g=this.AllocateNode();for(this.m_nodes[g].parent=m,this.m_nodes[g].userData=null,this.m_nodes[g].aabb.Combine(i,this.m_nodes[p].aabb),this.m_nodes[g].height=this.m_nodes[p].height+1,m!=li?(this.m_nodes[m].child1==p?this.m_nodes[m].child1=g:this.m_nodes[m].child2=g,this.m_nodes[g].child1=p,this.m_nodes[g].child2=e,this.m_nodes[p].parent=g,this.m_nodes[e].parent=g):(this.m_nodes[g].child1=p,this.m_nodes[g].child2=e,this.m_nodes[p].parent=g,this.m_nodes[e].parent=g,this.m_root=g),n=this.m_nodes[e].parent;n!=li;){n=this.Balance(n);r=this.m_nodes[n].child1,s=this.m_nodes[n].child2;t(r!=li),t(s!=li),this.m_nodes[n].height=1+oi(this.m_nodes[r].height,this.m_nodes[s].height),this.m_nodes[n].aabb.Combine(this.m_nodes[r].aabb,this.m_nodes[s].aabb),n=this.m_nodes[n].parent}},RemoveLeaf:function(t){if(t!=this.m_root){var e,i=this.m_nodes[t].parent,n=this.m_nodes[i].parent;if(e=this.m_nodes[i].child1==t?this.m_nodes[i].child2:this.m_nodes[i].child1,n!=li){this.m_nodes[n].child1==i?this.m_nodes[n].child1=e:this.m_nodes[n].child2=e,this.m_nodes[e].parent=n,this.FreeNode(i);for(var r=n;r!=li;){r=this.Balance(r);var s=this.m_nodes[r].child1,o=this.m_nodes[r].child2;this.m_nodes[r].aabb.Combine(this.m_nodes[s].aabb,this.m_nodes[o].aabb),this.m_nodes[r].height=1+oi(this.m_nodes[s].height,this.m_nodes[o].height),r=this.m_nodes[r].parent}}else this.m_root=e,this.m_nodes[e].parent=li,this.FreeNode(i)}else this.m_root=li},Balance:function(e){t(e!=li);var i=this.m_nodes[e];if(i.IsLeaf()||i.height<2)return e;var n=i.child1,r=i.child2;t(0<=n&&n<this.m_nodeCapacity),t(0<=r&&r<this.m_nodeCapacity);var s=this.m_nodes[n],o=this.m_nodes[r],a=o.height-s.height;if(a>1){var c=o.child1,h=o.child2,l=this.m_nodes[c],u=this.m_nodes[h];return t(0<=c&&c<this.m_nodeCapacity),t(0<=h&&h<this.m_nodeCapacity),o.child1=e,o.parent=i.parent,i.parent=r,o.parent!=li?this.m_nodes[o.parent].child1==e?this.m_nodes[o.parent].child1=r:(t(this.m_nodes[o.parent].child2==e),this.m_nodes[o.parent].child2=r):this.m_root=r,l.height>u.height?(o.child2=c,i.child2=h,u.parent=e,i.aabb.Combine(s.aabb,u.aabb),o.aabb.Combine(i.aabb,l.aabb),i.height=1+oi(s.height,u.height),o.height=1+oi(i.height,l.height)):(o.child2=h,i.child2=c,l.parent=e,i.aabb.Combine(s.aabb,l.aabb),o.aabb.Combine(i.aabb,u.aabb),i.height=1+oi(s.height,l.height),o.height=1+oi(i.height,u.height)),r}if(a<-1){var _=s.child1,d=s.child2,f=this.m_nodes[_],p=this.m_nodes[d];return t(0<=_&&_<this.m_nodeCapacity),t(0<=d&&d<this.m_nodeCapacity),s.child1=e,s.parent=i.parent,i.parent=n,s.parent!=li?this.m_nodes[s.parent].child1==e?this.m_nodes[s.parent].child1=n:(t(this.m_nodes[s.parent].child2==e),this.m_nodes[s.parent].child2=n):this.m_root=n,f.height>p.height?(s.child2=_,i.child1=d,p.parent=e,i.aabb.Combine(o.aabb,p.aabb),s.aabb.Combine(i.aabb,f.aabb),i.height=1+oi(o.height,p.height),s.height=1+oi(i.height,f.height)):(s.child2=d,i.child1=_,f.parent=e,i.aabb.Combine(o.aabb,f.aabb),s.aabb.Combine(i.aabb,p.aabb),i.height=1+oi(o.height,f.height),s.height=1+oi(i.height,p.height)),n}return e},ComputeHeight:function(e){void 0===e&&(e=this.m_root),t(0<=e&&e<this.m_nodeCapacity);var i=this.m_nodes[e];if(i.IsLeaf())return 0;var n=this.ComputeHeight(i.child1),r=this.ComputeHeight(i.child2);return 1+oi(n,r)},ValidateStructure:function(e){if(e!=li){e==this.m_root&&t(this.m_nodes[e].parent==li);var i=this.m_nodes[e],n=i.child1,r=i.child2;if(i.IsLeaf())return t(n==li),t(r==li),void t(0==i.height);t(0<=n&&n<this.m_nodeCapacity),t(0<=r&&r<this.m_nodeCapacity),t(this.m_nodes[n].parent==e),t(this.m_nodes[r].parent==e),this.ValidateStructure(n),this.ValidateStructure(r)}},ValidateMetrics:function(e){if(e!=li){var i=this.m_nodes[e],n=i.child1,s=i.child2;if(i.IsLeaf())return t(n==li),t(s==li),void t(0==i.height);t(0<=n&&n<this.m_nodeCapacity),t(0<=s&&s<this.m_nodeCapacity);var o,a=this.m_nodes[n].height,c=this.m_nodes[s].height;o=1+oi(a,c),t(i.height==o);var h=new st;h.Combine(this.m_nodes[n].aabb,this.m_nodes[s].aabb),t(r.Equals(h.lowerBound,i.aabb.lowerBound)),t(r.Equals(h.upperBound,i.aabb.upperBound)),this.ValidateMetrics(n),this.ValidateMetrics(s)}}},bt.e_unknown=0,bt.e_failed=1,bt.e_overlapped=2,bt.e_touching=3,bt.e_separated=4;var ui=new h,_i=new h;At.prototype={Initialize:function(e,i,n,r,s,o){this.m_proxyA=i,this.m_proxyB=r;var a=e.count;if(t(0<a&&a<3),this.m_sweepA=n,this.m_sweepB=s,this.m_sweepA.GetTransform(ui,o),this.m_sweepB.GetTransform(_i,o),1==a){this.m_type=At.e_points;var c=this.m_proxyA.GetVertex(e.indexA[0]),h=this.m_proxyB.GetVertex(e.indexB[0]),l=ui.q.c*c.x-ui.q.s*c.y+ui.p.x,u=ui.q.s*c.x+ui.q.c*c.y+ui.p.y,_=_i.q.c*h.x-_i.q.s*h.y+_i.p.x,d=_i.q.s*h.x+_i.q.c*h.y+_i.p.y;this.m_axis.x=_-l,this.m_axis.y=d-u;return x=this.m_axis.Normalize()}if(e.indexA[0]==e.indexA[1]){this.m_type=At.e_faceB;var f=r.GetVertex(e.indexB[0]),p=r.GetVertex(e.indexB[1]);this.m_axis.x=1*(p.y-f.y),this.m_axis.y=-1*(p.x-f.x),this.m_axis.Normalize();var m=_i.q.c*this.m_axis.x-_i.q.s*this.m_axis.y,g=_i.q.s*this.m_axis.x+_i.q.c*this.m_axis.y;this.m_localPoint.x=.5*(f.x+p.x),this.m_localPoint.y=.5*(f.y+p.y);_=_i.q.c*this.m_localPoint.x-_i.q.s*this.m_localPoint.y+_i.p.x,d=_i.q.s*this.m_localPoint.x+_i.q.c*this.m_localPoint.y+_i.p.y,c=i.GetVertex(e.indexA[0]);return(x=((l=ui.q.c*c.x-ui.q.s*c.y+ui.p.x)-_)*m+((u=ui.q.s*c.x+ui.q.c*c.y+ui.p.y)-d)*g)<0&&(this.m_axis.x=-this.m_axis.x,this.m_axis.y=-this.m_axis.y,x=-x),x}this.m_type=At.e_faceA;var y=this.m_proxyA.GetVertex(e.indexA[0]),v=this.m_proxyA.GetVertex(e.indexA[1]);this.m_axis.x=1*(v.y-y.y),this.m_axis.y=-1*(v.x-y.x),this.m_axis.Normalize();m=ui.q.c*this.m_axis.x-ui.q.s*this.m_axis.y,g=ui.q.s*this.m_axis.x+ui.q.c*this.m_axis.y;this.m_localPoint.x=.5*(y.x+v.x),this.m_localPoint.y=.5*(y.y+v.y);var x;l=ui.q.c*this.m_localPoint.x-ui.q.s*this.m_localPoint.y+ui.p.x,u=ui.q.s*this.m_localPoint.x+ui.q.c*this.m_localPoint.y+ui.p.y,h=this.m_proxyB.GetVertex(e.indexB[0]);return(x=((_=_i.q.c*h.x-_i.q.s*h.y+_i.p.x)-l)*m+((d=_i.q.s*h.x+_i.q.c*h.y+_i.p.y)-u)*g)<0&&(this.m_axis.x=-this.m_axis.x,this.m_axis.y=-this.m_axis.y,x=-x),x},FindMinSeparation:function(e,i){switch(this.m_sweepA.GetTransform(ui,i),this.m_sweepB.GetTransform(_i,i),this.m_type){case At.e_points:var n=ui.q.c*this.m_axis.x+ui.q.s*this.m_axis.y,r=-ui.q.s*this.m_axis.x+ui.q.c*this.m_axis.y,s=_i.q.c*-this.m_axis.x+_i.q.s*-this.m_axis.y,o=-_i.q.s*-this.m_axis.x+_i.q.c*-this.m_axis.y;e[0]=this.m_proxyA.GetSupport(n,r),e[1]=this.m_proxyB.GetSupport(s,o);var a=this.m_proxyA.GetVertex(e[0]),c=this.m_proxyB.GetVertex(e[1]),h=ui.q.c*a.x-ui.q.s*a.y+ui.p.x,l=ui.q.s*a.x+ui.q.c*a.y+ui.p.y,u=_i.q.c*c.x-_i.q.s*c.y+_i.p.x,_=_i.q.s*c.x+_i.q.c*c.y+_i.p.y;return(u-h)*this.m_axis.x+(_-l)*this.m_axis.y;case At.e_faceA:var d=ui.q.c*this.m_axis.x-ui.q.s*this.m_axis.y,f=ui.q.s*this.m_axis.x+ui.q.c*this.m_axis.y;h=ui.q.c*this.m_localPoint.x-ui.q.s*this.m_localPoint.y+ui.p.x,l=ui.q.s*this.m_localPoint.x+ui.q.c*this.m_localPoint.y+ui.p.y,s=_i.q.c*-d+_i.q.s*-f,o=-_i.q.s*-d+_i.q.c*-f;e[0]=-1,e[1]=this.m_proxyB.GetSupport(s,o);c=this.m_proxyB.GetVertex(e[1]);return((u=_i.q.c*c.x-_i.q.s*c.y+_i.p.x)-h)*d+((_=_i.q.s*c.x+_i.q.c*c.y+_i.p.y)-l)*f;case At.e_faceB:d=_i.q.c*this.m_axis.x-_i.q.s*this.m_axis.y,f=_i.q.s*this.m_axis.x+_i.q.c*this.m_axis.y,u=_i.q.c*this.m_localPoint.x-_i.q.s*this.m_localPoint.y+_i.p.x,_=_i.q.s*this.m_localPoint.x+_i.q.c*this.m_localPoint.y+_i.p.y,n=ui.q.c*-d+ui.q.s*-f,o=-ui.q.s*-d+ui.q.c*-f;e[1]=-1,e[0]=this.m_proxyA.GetSupport(n,o);a=this.m_proxyA.GetVertex(e[0]);return((h=ui.q.c*a.x-ui.q.s*a.y+ui.p.x)-u)*d+((l=ui.q.s*a.x+ui.q.c*a.y+ui.p.y)-_)*f;default:return t(!1),e[0]=-1,e[1]=-1,0}},Evaluate:function(e,i,n){switch(this.m_sweepA.GetTransform(ui,n),this.m_sweepB.GetTransform(_i,n),this.m_type){case At.e_points:var r=this.m_proxyA.GetVertex(e),s=this.m_proxyB.GetVertex(i),o=ui.q.c*r.x-ui.q.s*r.y+ui.p.x,a=ui.q.s*r.x+ui.q.c*r.y+ui.p.y,c=_i.q.c*s.x-_i.q.s*s.y+_i.p.x,h=_i.q.s*s.x+_i.q.c*s.y+_i.p.y;return(c-o)*this.m_axis.x+(h-a)*this.m_axis.y;case At.e_faceA:var l=ui.q.c*this.m_axis.x-ui.q.s*this.m_axis.y,u=ui.q.s*this.m_axis.x+ui.q.c*this.m_axis.y;o=ui.q.c*this.m_localPoint.x-ui.q.s*this.m_localPoint.y+ui.p.x,a=ui.q.s*this.m_localPoint.x+ui.q.c*this.m_localPoint.y+ui.p.y,s=this.m_proxyB.GetVertex(i);return((c=_i.q.c*s.x-_i.q.s*s.y+_i.p.x)-o)*l+((h=_i.q.s*s.x+_i.q.c*s.y+_i.p.y)-a)*u;case At.e_faceB:l=_i.q.c*this.m_axis.x-_i.q.s*this.m_axis.y,u=_i.q.s*this.m_axis.x+_i.q.c*this.m_axis.y,c=_i.q.c*this.m_localPoint.x-_i.q.s*this.m_localPoint.y+_i.p.x,h=_i.q.s*this.m_localPoint.x+_i.q.c*this.m_localPoint.y+_i.p.y,r=this.m_proxyA.GetVertex(e);return((o=ui.q.c*r.x-ui.q.s*r.y+ui.p.x)-c)*l+((a=ui.q.s*r.x+ui.q.c*r.y+ui.p.y)-h)*u;default:return t(!1),0}}},At.e_points=0,At.e_faceA=1,At.e_faceB=2;var di=Fe.create("toi","solveTOI");St._temp_sweepA=new l,St._temp_sweepB=new l,St.b2_toiTime=0,St.b2_toiMaxTime=0,St.b2_toiCalls=0,St.b2_toiIters=0,St.b2_toiMaxIters=0,St.b2_toiRootIters=0,St.b2_toiMaxRootIters=0,wt.prototype={_deserialize:function(t){this.type=t.type,this.position._deserialize(t.position),this.angle=t.angle,this.linearVelocity._deserialize(t.linearVelocity),this.angularVelocity=t.angularVelocity,this.linearDamping=t.linearDamping,this.angularDamping=t.angularDamping,this.allowSleep=t.allowSleep,this.awake=t.awake,this.fixedRotation=t.fixedRotation,this.bullet=t.bullet,this.active=t.active,this.gravityScale=t.gravityScale}},Et.b2_staticBody=0,Et.b2_kinematicBody=1,Et.b2_dynamicBody=2,Et.e_islandFlag=1,Et.e_awakeFlag=2,Et.e_autoSleepFlag=4,Et.e_bulletFlag=8,Et.e_fixedRotationFlag=16,Et.e_activeFlag=32,Et.e_toiFlag=64,Et.m_local_oldCenter=new r,Et.m_local_xf1=new h,Et.prototype={CreateFixture:function(e,i){if(void 0!==i){var n=new Rt;return n.shape=e,n.density=i,this.CreateFixture(n)}if(t(0==this.m_world.IsLocked()),1==this.m_world.IsLocked())return null;var r=new Ot;if(r.Create(this,e),this.m_flags&Et.e_activeFlag){var s=this.m_world.m_contactManager.m_broadPhase;r.CreateProxies(s,this.m_xf)}return r.m_next=this.m_fixtureList,this.m_fixtureList=r,++this.m_fixtureCount,r.m_body=this,r.m_density>0&&this.ResetMassData(),this.m_world.m_flags|=Wt.e_newFixture,r},DestroyFixture:function(e){if(t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()){t(e.m_body==this),t(this.m_fixtureCount>0);for(var i=this.m_fixtureList,n=!1;null!=i;){if(i==e){this.m_fixtureList=i=e.m_next,n=!0;break}i=i.m_next}t(n);for(var r=this.m_contactList;r;){var s=r.contact;r=r.next;var o=s.GetFixtureA(),a=s.GetFixtureB();e!=o&&e!=a||this.m_world.m_contactManager.Destroy(s)}if(this.m_flags&Et.e_activeFlag){var c=this.m_world.m_contactManager.m_broadPhase;e.DestroyProxies(c)}e.Destroy(),e.m_body=null,e.m_next=null,--this.m_fixtureCount,this.ResetMassData()}},SetTransform:function(e,i){if(t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()){this.m_xf.q.Set(i),this.m_xf.p.Assign(e),this.m_sweep.c.Assign(w(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.a=i,this.m_sweep.c0.Assign(this.m_sweep.c),this.m_sweep.a0=i;for(var n=this.m_world.m_contactManager.m_broadPhase,r=this.m_fixtureList;r;r=r.m_next)r.Synchronize(n,this.m_xf,this.m_xf)}},GetTransform:function(){return this.m_xf},GetPosition:function(){return this.m_xf.p},GetAngle:function(){return this.m_sweep.a},GetWorldCenter:function(){return this.m_sweep.c},GetLocalCenter:function(){return this.m_sweep.localCenter},SetLinearVelocity:function(t){this.m_type!=Et.b2_staticBody&&(u(t,t)>0&&this.SetAwake(!0),this.m_linearVelocity=t)},GetLinearVelocity:function(){return this.m_linearVelocity},SetAngularVelocity:function(t){this.m_type!=Et.b2_staticBody&&(t*t>0&&this.SetAwake(!0),this.m_angularVelocity=t)},GetAngularVelocity:function(){return this.m_angularVelocity},ApplyForce:function(t,e,i){this.m_type==Et.b2_dynamicBody&&(i&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_force.Add(t),this.m_torque+=_(r.Subtract(e,this.m_sweep.c),t)))},ApplyForceToCenter:function(t,e){this.m_type==Et.b2_dynamicBody&&(e&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&this.m_force.Add(t))},ApplyTorque:function(t,e){this.m_type==Et.b2_dynamicBody&&(e&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_torque+=t))},ApplyLinearImpulse:function(t,e,i){this.m_type==Et.b2_dynamicBody&&(i&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_linearVelocity.Add(r.Multiply(this.m_invMass,t)),this.m_angularVelocity+=this.m_invI*_(r.Subtract(e,this.m_sweep.c),t)))},ApplyAngularImpulse:function(t,e){this.m_type==Et.b2_dynamicBody&&(e&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_angularVelocity+=this.m_invI*t))},GetMass:function(){return this.m_mass},GetInertia:function(){return this.m_I+this.m_mass*u(this.m_sweep.localCenter,this.m_sweep.localCenter)},GetMassData:function(t){t.mass=this.m_mass,t.I=this.m_I+this.m_mass*u(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center=this.m_sweep.localCenter},SetMassData:function(e){t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()&&this.m_type==Et.b2_dynamicBody&&(this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&0==(this.m_flags&Et.e_fixedRotationFlag)&&(this.m_I=e.I-this.m_mass*u(e.center,e.center),t(this.m_I>0),this.m_invI=1/this.m_I),Et.m_local_oldCenter.Assign(this.m_sweep.c),this.m_sweep.localCenter.Assign(e.center),this.m_sweep.c0.Assign(w(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.Assign(this.m_sweep.c0),this.m_linearVelocity.Add(f(this.m_angularVelocity,r.Subtract(this.m_sweep.c,Et.m_local_oldCenter))))},ResetMassData:function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type==Et.b2_staticBody||this.m_type==Et.b2_kinematicBody)return this.m_sweep.c0.Assign(this.m_xf.p),this.m_sweep.c.Assign(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);t(this.m_type==Et.b2_dynamicBody);for(var e=new r(0,0),i=this.m_fixtureList;i;i=i.m_next)if(0!=i.m_density){var n=new N;i.GetMassData(n),this.m_mass+=n.mass,e.Add(r.Multiply(n.mass,n.center)),this.m_I+=n.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.Multiply(this.m_invMass)):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&0==(this.m_flags&Et.e_fixedRotationFlag)?(this.m_I-=this.m_mass*u(e,e),t(this.m_I>0),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0),Et.m_local_oldCenter.Assign(this.m_sweep.c),this.m_sweep.localCenter.Assign(e),this.m_sweep.c0.Assign(w(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.Assign(this.m_sweep.c0),this.m_linearVelocity.Add(f(this.m_angularVelocity,r.Subtract(this.m_sweep.c,Et.m_local_oldCenter)))},GetWorldPoint:function(t){return w(this.m_xf,t)},GetWorldVector:function(t){return A(this.m_xf.q,t)},GetLocalPoint:function(t){return E(this.m_xf,t)},GetLocalVector:function(t){return S(this.m_xf.q,t)},GetLinearVelocityFromWorldPoint:function(t){return r.Add(this.m_linearVelocity,f(this.m_angularVelocity,r.Subtract(t,this.m_sweep.c)))},GetLinearVelocityFromLocalPoint:function(t){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t))},GetLinearDamping:function(){return this.m_linearDamping},SetLinearDamping:function(t){this.m_linearDamping=t},GetAngularDamping:function(){return this.m_angularDamping},SetAngularDamping:function(t){this.m_angularDamping=t},GetGravityScale:function(){return this.m_gravityScale},SetGravityScale:function(t){this.m_gravityScale=t},SetType:function(e){if(t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()&&this.m_type!=e){this.m_type=e,this.ResetMassData(),this.m_type==Et.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Assign(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null;for(var r=this.m_world.m_contactManager.m_broadPhase,s=this.m_fixtureList;s;s=s.m_next)for(var o=s.m_proxyCount,a=0;a<o;++a)r.TouchProxy(s.m_proxies[a].proxyId)}},GetType:function(){return this.m_type},SetBullet:function(t){t?this.m_flags|=Et.e_bulletFlag:this.m_flags&=~Et.e_bulletFlag},IsBullet:function(){return(this.m_flags&Et.e_bulletFlag)==Et.e_bulletFlag},SetSleepingAllowed:function(t){t?this.m_flags|=Et.e_autoSleepFlag:(this.m_flags&=~Et.e_autoSleepFlag,this.SetAwake(!0))},IsSleepingAllowed:function(){return(this.m_flags&Et.e_autoSleepFlag)==Et.e_autoSleepFlag},SetAwake:function(t){t?0==(this.m_flags&Et.e_awakeFlag)&&(this.m_flags|=Et.e_awakeFlag,this.m_sleepTime=0):(this.m_flags&=~Et.e_awakeFlag,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},IsAwake:function(){return(this.m_flags&Et.e_awakeFlag)==Et.e_awakeFlag},SetActive:function(e){if(t(0==this.m_world.IsLocked()),e!=this.IsActive())if(e){this.m_flags|=Et.e_activeFlag;for(var i=this.m_world.m_contactManager.m_broadPhase,n=this.m_fixtureList;n;n=n.m_next)n.CreateProxies(i,this.m_xf)}else{this.m_flags&=~Et.e_activeFlag;for(i=this.m_world.m_contactManager.m_broadPhase,n=this.m_fixtureList;n;n=n.m_next)n.DestroyProxies(i);for(var r=this.m_contactList;r;){var s=r;r=r.next,this.m_world.m_contactManager.Destroy(s.contact)}this.m_contactList=null}},IsActive:function(){return(this.m_flags&Et.e_activeFlag)==Et.e_activeFlag},SetFixedRotation:function(t){(this.m_flags&Et.e_fixedRotationFlag)==Et.e_fixedRotationFlag!=t&&(t?this.m_flags|=Et.e_fixedRotationFlag:this.m_flags&=~Et.e_fixedRotationFlag,this.m_angularVelocity=0,this.ResetMassData())},IsFixedRotation:function(){return(this.m_flags&Et.e_fixedRotationFlag)==Et.e_fixedRotationFlag},GetFixtureList:function(){return this.m_fixtureList},GetJointList:function(){return this.m_jointList},GetContactList:function(){return this.m_contactList},GetNext:function(){return this.m_next},GetUserData:function(){return this.m_userData},SetUserData:function(t){this.m_userData=t},GetWorld:function(){return this.m_world},SynchronizeFixtures:function(){Et.m_local_xf1.q.Set(this.m_sweep.a0),Et.m_local_xf1.p.Assign(r.Subtract(this.m_sweep.c0,A(Et.m_local_xf1.q,this.m_sweep.localCenter)));for(var t=this.m_world.m_contactManager.m_broadPhase,e=this.m_fixtureList;e;e=e.m_next)e.Synchronize(t,Et.m_local_xf1,this.m_xf)},SynchronizeTransform:function(){this.m_xf.q.Set(this.m_sweep.a),this.m_xf.p.Assign(r.Subtract(this.m_sweep.c,A(this.m_xf.q,this.m_sweep.localCenter)))},ShouldCollide:function(t){if(this.m_type!=Et.b2_dynamicBody&&t.m_type!=Et.b2_dynamicBody)return!1;for(var e=this.m_jointList;e;e=e.next)if(e.other==t&&0==e.joint.m_collideConnected)return!1;return!0},Advance:function(t){this.m_sweep.Advance(t),this.m_sweep.c.Assign(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.Set(this.m_sweep.a),this.m_xf.p.Assign(r.Subtract(this.m_sweep.c,A(this.m_xf.q,this.m_sweep.localCenter)))},_serialize:function(t){var e=t||{};return e.fixtures=null,e.type=this.m_type,e.position=this.GetPosition()._serialize(),e.angle=this.GetAngle(),e.linearVelocity=this.GetLinearVelocity()._serialize(),e.angularVelocity=this.GetAngularVelocity(),e.linearDamping=this.GetLinearDamping(),e.angularDamping=this.GetAngularDamping(),e.allowSleep=this.IsSleepingAllowed(),e.awake=this.IsAwake(),e.fixedRotation=this.IsFixedRotation(),e.bullet=this.IsBullet(),e.active=this.IsActive(),e.gravityScale=this.GetGravityScale(),e}},It.prototype={Clone:function(){var t=new It;return t.categoryBits=this.categoryBits,t.maskBits=this.maskBits,t.groupIndex=this.groupIndex,t},Assign:function(t){this.categoryBits=t.categoryBits,this.maskBits=t.maskBits,this.groupIndex=t.groupIndex},_serialize:function(t){var e=t||{};return e.categoryBits=this.categoryBits,e.maskBits=this.maskBits,e.groupIndex=this.groupIndex,e},_deserialize:function(t){this.categoryBits=t.categoryBits,this.maskBits=t.maskBits,this.groupIndex=t.groupIndex}},Rt.prototype={_deserialize:function(t){this.friction=t.friction,this.restitution=t.restitution,this.density=t.density,this.isSensor=t.isSensor,this.filter._deserialize(t.filter)}},Ot.prototype={GetType:function(){return this.m_shape.GetType()},GetShape:function(){return this.m_shape},SetSensor:function(t){t!=this.m_isSensor&&(this.m_body.SetAwake(!0),this.m_isSensor=t)},IsSensor:function(){return this.m_isSensor},SetFilterData:function(t){this.m_filter=t,this.Refilter()},GetFilterData:function(){return this.m_filter},Refilter:function(){if(null!=this.m_body){for(var t=this.m_body.GetContactList();t;){var e=t.contact,i=e.GetFixtureA(),n=e.GetFixtureB();i!=this&&n!=this||e.FlagForFiltering(),t=t.next}var r=this.m_body.GetWorld();if(null!=r)for(var s=r.m_contactManager.m_broadPhase,o=0;o<this.m_proxyCount;++o)s.TouchProxy(this.m_proxies[o].proxyId)}},GetBody:function(){return this.m_body},GetNext:function(){return this.m_next},GetUserData:function(){return this.m_userData},SetUserData:function(t){this.m_userData=t},TestPoint:function(t){return this.m_shape.TestPoint(this.m_body.GetTransform(),t)},RayCast:function(t,e,i){return this.m_shape.RayCast(t,e,this.m_body.GetTransform(),i)},GetMassData:function(t){this.m_shape.ComputeMass(t,this.m_density)},SetDensity:function(e){t(n(e)&&e>=0),this.m_density=e},GetDensity:function(){return this.m_density},GetFriction:function(){return this.m_friction},SetFriction:function(t){this.m_friction=t},GetRestitution:function(){return this.m_restitution},SetRestitution:function(t){this.m_restitution=t},GetAABB:function(e){return t(0<=e&&e<this.m_proxyCount),this.m_proxies[e].aabb},Create:function(t,e){this.m_userData=e.userData,this.m_friction=e.friction,this.m_restitution=e.restitution,this.m_body=t,this.m_next=null,this.m_filter.Assign(e.filter),this.m_isSensor=e.isSensor,this.m_shape=e.shape.Clone();var i=this.m_shape.GetChildCount();this.m_proxies=new Array(i);for(var n=0;n<i;++n)this.m_proxies[n]=new Pt,this.m_proxies[n].fixture=null,this.m_proxies[n].proxyId=j.e_nullProxy;this.m_proxyCount=0,this.m_density=e.density},Destroy:function(){t(0==this.m_proxyCount),this.m_proxies=null,this.m_shape=null},CreateProxies:function(e,i){t(0==this.m_proxyCount),this.m_proxyCount=this.m_shape.GetChildCount();for(var n=0;n<this.m_proxyCount;++n){var r=this.m_proxies[n];this.m_shape.ComputeAABB(r.aabb,i,n),r.proxyId=e.CreateProxy(r.aabb,r),r.fixture=this,r.childIndex=n}},DestroyProxies:function(t){for(var e=0;e<this.m_proxyCount;++e){var i=this.m_proxies[e];t.DestroyProxy(i.proxyId),i.proxyId=j.e_nullProxy}this.m_proxyCount=0},Synchronize:function(t,e,i){if(0!=this.m_proxyCount)for(var n=0;n<this.m_proxyCount;++n){var s=this.m_proxies[n],o=new st,a=new st;this.m_shape.ComputeAABB(o,e,s.childIndex),this.m_shape.ComputeAABB(a,i,s.childIndex),s.aabb.Combine(o,a);var c=r.Subtract(i.p,e.p);t.MoveProxy(s.proxyId,s.aabb,c)}},_serialize:function(t){var e=t||{};return e.shape=null,e.friction=this.m_friction,e.restitution=this.m_restitution,e.density=this.m_density,e.isSensor=this.m_isSensor,e.filter=this.m_filter._serialize(),e}},Bt.prototype={SayGoodbyeJoint:function(t){},SayGoodbyeFixture:function(t){}},Dt.prototype={ShouldCollide:function(t,e){var i=t.GetFilterData(),n=e.GetFilterData();if(i.groupIndex==n.groupIndex&&0!=i.groupIndex)return i.groupIndex>0;return 0!=(i.maskBits&n.categoryBits)&&0!=(i.categoryBits&n.maskBits)}},Lt.prototype={BeginContact:function(t){},EndContact:function(t){},PreSolve:function(t,e){},PostSolve:function(t,e){}},Nt.prototype={ReportFixture:function(t){return!1}},Ft.prototype={ReportFixture:function(t,e,i,n){}};var fi=Fe.create("step"),pi=Fe.create("collide","step"),mi=Fe.create("solve","step"),gi=Fe.create("solveTOI","step"),yi=Fe.create("broadphase","step");Ut.prototype={QueryCallback:function(t){var e=this.broadPhase.GetUserData(t);return this.callback.ReportFixture(e.fixture)}},jt.prototype={RayCastCallback:function(t,e){var i=this.broadPhase.GetUserData(e),n=i.fixture,s=i.childIndex,o=new rt;if(n.RayCast(o,t,s)){var a=o.fraction,c=r.Add(r.Multiply(1-a,t.p1),r.Multiply(a,t.p2));return this.callback.ReportFixture(n,c,o.normal,a)}return t.maxFraction}},Wt.m_local_sweep_backupA=new l,Wt.m_local_sweep_backupB=new l,Wt.m_local_sweep_backupC=new l,Wt.prototype={Destroy:function(){for(var t=this.m_bodyList;t;){for(var e=t.m_next,i=t.m_fixtureList;i;){var n=i.m_next;i.m_proxyCount=0,i.Destroy(),i=n}t=e}},SetDestructionListener:function(t){this.m_destructionListener=t},SetContactFilter:function(t){this.m_contactManager.m_contactFilter=t},SetContactListener:function(t){this.m_contactManager.m_contactListener=t},SetDebugDraw:function(t){this.g_debugDraw=t},CreateBody:function(e){if(t(0==this.IsLocked()),this.IsLocked())return null;var i=new Et(e,this);return i.m_prev=null,i.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=i),this.m_bodyList=i,++this.m_bodyCount,i},DestroyBody:function(e){if(t(this.m_bodyCount>0),t(0==this.IsLocked()),!this.IsLocked()){for(var i=e.m_jointList;i;){var n=i;i=i.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(n.joint),this.DestroyJoint(n.joint),e.m_jointList=i}e.m_jointList=null;for(var r=e.m_contactList;r;){var s=r;r=r.next,this.m_contactManager.Destroy(s.contact)}e.m_contactList=null;for(var o=e.m_fixtureList;o;){var a=o;o=o.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(a),a.DestroyProxies(this.m_contactManager.m_broadPhase),a.Destroy(),e.m_fixtureList=o,e.m_fixtureCount-=1}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),e.m_destroyed=!0,--this.m_bodyCount}},CreateJoint:function(e){if(t(0==this.IsLocked()),this.IsLocked())return null;var i=de.Create(e);i.m_prev=null,i.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=i),this.m_jointList=i,++this.m_jointCount,i.m_edgeA.joint=i,i.m_edgeA.other=i.m_bodyB,i.m_edgeA.prev=null,i.m_edgeA.next=i.m_bodyA.m_jointList,i.m_bodyA.m_jointList&&(i.m_bodyA.m_jointList.prev=i.m_edgeA),i.m_bodyA.m_jointList=i.m_edgeA,i.m_edgeB.joint=i,i.m_edgeB.other=i.m_bodyA,i.m_edgeB.prev=null,i.m_edgeB.next=i.m_bodyB.m_jointList,i.m_bodyB.m_jointList&&(i.m_bodyB.m_jointList.prev=i.m_edgeB),i.m_bodyB.m_jointList=i.m_edgeB;var n=e.bodyA,r=e.bodyB;if(0==e.collideConnected)for(var s=r.GetContactList();s;)s.other==n&&s.contact.FlagForFiltering(),s=s.next;return i},DestroyJoint:function(e){if(t(0==this.IsLocked()),!this.IsLocked()){var i=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;if(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,de.Destroy(e),t(this.m_jointCount>0),--this.m_jointCount,0==i)for(var s=r.GetContactList();s;)s.other==n&&s.contact.FlagForFiltering(),s=s.next}},Step:function(t,e,i){fi.start(),this.m_flags&Wt.e_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_flags&=~Wt.e_newFixture),this.m_flags|=Wt.e_locked,this.p_step.dt=t,this.p_step.velocityIterations=e,this.p_step.positionIterations=i,this.p_step.inv_dt=t>0?1/t:0,this.p_step.dtRatio=this.m_inv_dt0*t,this.p_step.warmStarting=this.m_warmStarting,pi.start(),this.m_contactManager.Collide(),pi.stop(),this.m_stepComplete&&this.p_step.dt>0&&(mi.start(),this.Solve(this.p_step),mi.stop()),this.m_continuousPhysics&&this.p_step.dt>0&&(gi.start(),this.SolveTOI(this.p_step),gi.stop()),this.p_step.dt>0&&(this.m_inv_dt0=this.p_step.inv_dt),this.m_flags&Wt.e_clearForces&&this.ClearForces(),this.m_flags&=~Wt.e_locked,fi.stop()},ClearForces:function(){for(var t=this.m_bodyList;t;t=t.GetNext())t.m_force.x=t.m_force.y=0,t.m_torque=0},DrawDebugData:function(){if(null!=this.g_debugDraw){this.g_debugDraw.ClearDraw();var t=this.g_debugDraw.GetFlags();if(t&M.e_shapeBit)for(var e=this.m_bodyList;e;e=e.GetNext())for(var i=e.GetTransform(),n=e.GetFixtureList();n;n=n.GetNext())0==e.IsActive()?this.DrawShape(n,i,new D(.5,.5,.3)):e.GetType()==Et.b2_staticBody?this.DrawShape(n,i,new D(.5,.9,.5)):e.GetType()==Et.b2_kinematicBody?this.DrawShape(n,i,new D(.5,.5,.9)):0==e.IsAwake()?this.DrawShape(n,i,new D(.6,.6,.6)):this.DrawShape(n,i,new D(.9,.7,.7));if(t&M.e_jointBit)for(var s=this.m_jointList;s;s=s.GetNext())this.DrawJoint(s);if(t&M.e_pairBit)for(var o=new D(.3,.9,.9),a=this.m_contactManager.m_contactList;a;a=a.GetNext()){var c=a.GetFixtureA(),h=a.GetFixtureB(),l=c.GetAABB(a.GetChildIndexA()).GetCenter(),u=h.GetAABB(a.GetChildIndexB()).GetCenter();this.g_debugDraw.DrawSegment(l,u,o)}if(t&M.e_aabbBit){o=new D(.9,.3,.9);var _=new D(.3,.3,.9),d=this.m_contactManager.m_broadPhase;for(e=this.m_bodyList;e;e=e.GetNext())if(0!=e.IsActive())for(n=e.GetFixtureList();n;n=n.GetNext())for(var f=0;f<n.m_proxyCount;++f){var p=n.m_proxies[f],m=d.GetFatAABB(p.proxyId);(y=[])[0]=new r(m.lowerBound.x,m.lowerBound.y),y[1]=new r(m.upperBound.x,m.lowerBound.y),y[2]=new r(m.upperBound.x,m.upperBound.y),y[3]=new r(m.lowerBound.x,m.upperBound.y),this.g_debugDraw.DrawPolygon(y,4,o);var g=new st;n.GetShape().ComputeAABB(g,e.GetTransform(),0);var y;(y=[])[0]=new r(g.lowerBound.x,g.lowerBound.y),y[1]=new r(g.upperBound.x,g.lowerBound.y),y[2]=new r(g.upperBound.x,g.upperBound.y),y[3]=new r(g.lowerBound.x,g.upperBound.y),this.g_debugDraw.DrawPolygon(y,4,_)}}if(t&M.e_centerOfMassBit)for(e=this.m_bodyList;e;e=e.GetNext()){(i=e.GetTransform().Clone()).p=e.GetWorldCenter(),this.g_debugDraw.DrawTransform(i)}}},QueryAABB:function(t,e){var i=new Ut;i.broadPhase=this.m_contactManager.m_broadPhase,i.callback=t,this.m_contactManager.m_broadPhase.Query(i,e)},RayCast:function(t,e,i){var n=new jt;n.broadPhase=this.m_contactManager.m_broadPhase,n.callback=t;var r=new nt;r.maxFraction=1,r.p1=e,r.p2=i,this.m_contactManager.m_broadPhase.RayCast(n,r)},GetBodyList:function(){return this.m_bodyList},GetJointList:function(){return this.m_jointList},GetContactList:function(){return this.m_contactManager.m_contactList},SetAllowSleeping:function(t){if(t!=this.m_allowSleep&&(this.m_allowSleep=t,0==this.m_allowSleep))for(var e=this.m_bodyList;e;e=e.m_next)e.SetAwake(!0)},GetAllowSleeping:function(){return this.m_allowSleep},SetWarmStarting:function(t){this.m_warmStarting=t},GetWarmStarting:function(){return this.m_warmStarting},SetContinuousPhysics:function(t){this.m_continuousPhysics=t},GetContinuousPhysics:function(){return this.m_continuousPhysics},SetSubStepping:function(t){this.m_subStepping=t},GetSubStepping:function(){return this.m_subStepping},GetProxyCount:function(){return this.m_contactManager.m_broadPhase.GetProxyCount()},GetBodyCount:function(){return this.m_bodyCount},GetJointCount:function(){return this.m_jointCount},GetContactCount:function(){return this.m_contactManager.m_contactCount},GetTreeHeight:function(){return this.m_contactManager.m_broadPhase.GetTreeHeight()},GetTreeBalance:function(){return this.m_contactManager.m_broadPhase.GetTreeBalance()},GetTreeQuality:function(){return this.m_contactManager.m_broadPhase.GetTreeQuality()},SetGravity:function(t){this.m_gravity=t},GetGravity:function(){return this.m_gravity},IsLocked:function(){return(this.m_flags&Wt.e_locked)==Wt.e_locked},SetAutoClearForces:function(t){t?this.m_flags|=Wt.e_clearForces:this.m_flags&=~Wt.e_clearForces},GetAutoClearForces:function(){return(this.m_flags&Wt.e_clearForces)==Wt.e_clearForces},ShiftOrigin:function(e){if(t(0==(this.m_flags&Wt.e_locked)),(this.m_flags&Wt.e_locked)!=Wt.e_locked){for(var i=this.m_bodyList;i;i=i.m_next)i.m_xf.p.Subtract(e),i.m_sweep.c0.Subtract(e),i.m_sweep.c.Subtract(e);for(var n=this.m_jointList;n;n=n.m_next)n.ShiftOrigin(e);this.m_contactManager.m_broadPhase.ShiftOrigin(e)}},GetContactManager:function(){return this.m_contactManager},Solve:function(e){this.p_island.Initialize(this.m_bodyCount,this.m_contactManager.m_contactCount,this.m_jointCount,this.m_contactManager.m_contactListener);for(var i=this.m_bodyList;i;i=i.m_next)i.m_flags&=~Et.e_islandFlag;for(var n=this.m_contactManager.m_contactList;n;n=n.m_next)n.m_flags&=~Jt.e_islandFlag;for(var r=this.m_jointList;r;r=r.m_next)r.m_islandFlag=!1;for(var s=this.m_bodyCount,o=new Array(s),a=this.m_bodyList;a;a=a.m_next)if(!(a.m_flags&Et.e_islandFlag)&&0!=a.IsAwake()&&0!=a.IsActive()&&a.GetType()!=Et.b2_staticBody){this.p_island.Clear();var c=0;for(o[c++]=a,a.m_flags|=Et.e_islandFlag;c>0;){if(t(1==(i=o[--c]).IsActive()),this.p_island.AddBody(i),i.SetAwake(!0),i.GetType()!=Et.b2_staticBody){for(var h=i.m_contactList;h;h=h.next){var l=h.contact;if(!(l.m_flags&Jt.e_islandFlag)&&(0!=l.IsEnabled()&&0!=l.IsTouching())){var u=l.m_fixtureA.m_isSensor,_=l.m_fixtureB.m_isSensor;if(!u&&!_){this.p_island.AddContact(l),l.m_flags|=Jt.e_islandFlag;(f=h.other).m_flags&Et.e_islandFlag||(t(c<s),o[c++]=f,f.m_flags|=Et.e_islandFlag)}}}for(var d=i.m_jointList;d;d=d.next)if(1!=d.joint.m_islandFlag){var f;0!=(f=d.other).IsActive()&&(this.p_island.AddJoint(d.joint),d.joint.m_islandFlag=!0,f.m_flags&Et.e_islandFlag||(t(c<s),o[c++]=f,f.m_flags|=Et.e_islandFlag))}}}this.p_island.Solve(e,this.m_gravity,this.m_allowSleep);for(var p=0;p<this.p_island.m_bodyCount;++p){(i=this.p_island.m_bodies[p]).GetType()==Et.b2_staticBody&&(i.m_flags&=~Et.e_islandFlag)}}yi.start();for(i=this.m_bodyList;i;i=i.GetNext())0!=(i.m_flags&Et.e_islandFlag)&&i.GetType()!=Et.b2_staticBody&&i.SynchronizeFixtures();this.m_contactManager.FindNewContacts(),yi.stop()},SolveTOI:function(e){if(this.p_island.Initialize(64,32,0,this.m_contactManager.m_contactListener),this.m_stepComplete){for(var i=this.m_bodyList;i;i=i.m_next)i.m_flags&=~Et.e_islandFlag,i.m_sweep.alpha0=0;for(var n=this.m_contactManager.m_contactList;n;n=n.m_next)n.m_flags&=~(Jt.e_toiFlag|Jt.e_islandFlag),n.m_toiCount=0,n.m_toi=1}for(;;){var r=null,s=1;for(n=this.m_contactManager.m_contactList;n;n=n.m_next)if(0!=n.IsEnabled()&&!(n.m_toiCount>8)){var o=1;if(n.m_flags&Jt.e_toiFlag)o=n.m_toi;else{var a=n.GetFixtureA(),c=n.GetFixtureB();if(a.IsSensor()||c.IsSensor())continue;var h=a.GetBody(),l=c.GetBody(),u=h.m_type,_=l.m_type;t(u==Et.b2_dynamicBody||_==Et.b2_dynamicBody);var d=h.IsAwake()&&u!=Et.b2_staticBody,f=l.IsAwake()&&_!=Et.b2_staticBody;if(0==d&&0==f)continue;var p=h.IsBullet()||u!=Et.b2_dynamicBody,m=l.IsBullet()||_!=Et.b2_dynamicBody;if(0==p&&0==m)continue;var g=h.m_sweep.alpha0;h.m_sweep.alpha0<l.m_sweep.alpha0?(g=l.m_sweep.alpha0,h.m_sweep.Advance(g)):l.m_sweep.alpha0<h.m_sweep.alpha0&&(g=h.m_sweep.alpha0,l.m_sweep.Advance(g)),t(g<1);var y=n.GetChildIndexA(),v=n.GetChildIndexB(),x=new Tt;x.proxyA.Set(a.GetShape(),y),x.proxyB.Set(c.GetShape(),v),x.sweepA.Assign(h.m_sweep),x.sweepB.Assign(l.m_sweep),x.tMax=1;var C=new bt;St(C,x);var T=C.t;o=C.state==bt.e_touching?si(g+(1-g)*T,1):1,n.m_toi=o,n.m_flags|=Jt.e_toiFlag}o<s&&(r=n,s=o)}if(null==r||1-10*ze<s){this.m_stepComplete=!0;break}a=r.GetFixtureA(),c=r.GetFixtureB(),h=a.GetBody(),l=c.GetBody();if(Wt.m_local_sweep_backupA.Assign(h.m_sweep),Wt.m_local_sweep_backupB.Assign(l.m_sweep),h.Advance(s),l.Advance(s),r.Update(this.m_contactManager.m_contactListener),r.m_flags&=~Jt.e_toiFlag,++r.m_toiCount,0!=r.IsEnabled()&&0!=r.IsTouching()){h.SetAwake(!0),l.SetAwake(!0),this.p_island.Clear(),this.p_island.AddBody(h),this.p_island.AddBody(l),this.p_island.AddContact(r),h.m_flags|=Et.e_islandFlag,l.m_flags|=Et.e_islandFlag,r.m_flags|=Jt.e_islandFlag;for(var b=[h,l],A=0;A<2;++A){if((O=b[A]).m_type==Et.b2_dynamicBody)for(var S=O.m_contactList;S&&this.p_island.m_bodyCount!=this.p_island.m_bodyCapacity&&this.p_island.m_contactCount!=this.p_island.m_contactCapacity;S=S.next){var w=S.contact;if(!(w.m_flags&Jt.e_islandFlag)){var E=S.other;if(E.m_type!=Et.b2_dynamicBody||0!=O.IsBullet()||0!=E.IsBullet()){var I=w.m_fixtureA.m_isSensor,R=w.m_fixtureB.m_isSensor;I||R||(Wt.m_local_sweep_backupC.Assign(E.m_sweep),0==(E.m_flags&Et.e_islandFlag)&&E.Advance(s),w.Update(this.m_contactManager.m_contactListener),0!=w.IsEnabled()&&0!=w.IsTouching()?(w.m_flags|=Jt.e_islandFlag,this.p_island.AddContact(w),E.m_flags&Et.e_islandFlag||(E.m_flags|=Et.e_islandFlag,E.m_type!=Et.b2_staticBody&&E.SetAwake(!0),this.p_island.AddBody(E))):(E.m_sweep.Assign(Wt.m_local_sweep_backupC),E.SynchronizeTransform()))}}}}var P=new kt;P.dt=(1-s)*e.dt,P.inv_dt=1/P.dt,P.dtRatio=1,P.positionIterations=20,P.velocityIterations=e.velocityIterations,P.warmStarting=!1,this.p_island.SolveTOI(P,h.m_islandIndex,l.m_islandIndex);for(A=0;A<this.p_island.m_bodyCount;++A){var O;if((O=this.p_island.m_bodies[A]).m_flags&=~Et.e_islandFlag,O.m_type==Et.b2_dynamicBody){O.SynchronizeFixtures();for(S=O.m_contactList;S;S=S.next)S.contact.m_flags&=~(Jt.e_toiFlag|Jt.e_islandFlag)}}if(this.m_contactManager.FindNewContacts(),this.m_subStepping){this.m_stepComplete=!1;break}}else r.SetEnabled(!1),h.m_sweep.Assign(Wt.m_local_sweep_backupA),l.m_sweep.Assign(Wt.m_local_sweep_backupB),h.SynchronizeTransform(),l.SynchronizeTransform()}},DrawJoint:function(t){var e=t.GetBodyA(),i=t.GetBodyB(),n=e.GetTransform(),r=i.GetTransform(),s=n.p,o=r.p,a=t.GetAnchorA(),c=t.GetAnchorB(),h=new D(.5,.8,.8);switch(t.GetType()){case de.e_distanceJoint:this.g_debugDraw.DrawSegment(a,c,h);break;case de.e_pulleyJoint:var l=t,u=l.GetGroundAnchorA(),_=l.GetGroundAnchorB();this.g_debugDraw.DrawSegment(u,a,h),this.g_debugDraw.DrawSegment(_,c,h),this.g_debugDraw.DrawSegment(u,_,h);break;case de.e_mouseJoint:break;case de.e_motorJoint:this.g_debugDraw.DrawPoint(t.GetLinearOffset(),5,h);default:this.g_debugDraw.DrawSegment(s,a,h),this.g_debugDraw.DrawSegment(a,c,h),this.g_debugDraw.DrawSegment(o,c,h)}},DrawShape:function(e,i,n){switch(e.GetType()){case F.e_circle:var s=e.GetShape(),o=w(i,s.m_p),a=s.m_radius,c=A(i.q,new r(1,0));this.g_debugDraw.DrawSolidCircle(o,a,c,n);break;case F.e_edge:var h=e.GetShape(),l=w(i,h.m_vertex1),u=w(i,h.m_vertex2);this.g_debugDraw.DrawSegment(l,u,n);break;case F.e_chain:for(var _=e.GetShape(),d=_.m_count,f=(l=w(i,(g=_.m_vertices)[0]),1);f<d;++f){u=w(i,g[f]);this.g_debugDraw.DrawSegment(l,u,n),l=u}break;case F.e_polygon:var p=e.GetShape(),m=p.m_count;t(m<=We);var g=new Array(We);for(f=0;f<m;++f)g[f]=w(i,p.m_vertices[f]);this.g_debugDraw.DrawSolidPolygon(g,m,n)}}},Wt.e_newFixture=1,Wt.e_locked=2,Wt.e_clearForces=4,qt.prototype={Clear:function(){this.other=this.prev=this.next=null}},Jt.m_local_tempManifold=new tt,Jt.prototype={Create:function(t,e,i,n){this.m_toi=0,this.m_flags=Jt.e_enabledFlag,this.m_fixtureA=t||null,this.m_fixtureB=i||null,this.m_indexA=e||0,this.m_indexB=n||0,this.m_manifold.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,this.m_toiCount=0,t?(this.m_friction=Xt(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=Yt(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)):(this.m_friction=0,this.m_restitution=0),this.m_tangentSpeed=0},GetManifold:function(){return this.m_manifold},GetWorldManifold:function(t){var e=this.m_fixtureA.GetBody(),i=this.m_fixtureB.GetBody(),n=this.m_fixtureA.GetShape(),r=this.m_fixtureB.GetShape();t.Initialize(this.m_manifold,e.GetTransform(),n.m_radius,i.GetTransform(),r.m_radius)},IsTouching:function(){return(this.m_flags&Jt.e_touchingFlag)==Jt.e_touchingFlag},SetEnabled:function(t){t?this.m_flags|=Jt.e_enabledFlag:this.m_flags&=~Jt.e_enabledFlag},IsEnabled:function(){return(this.m_flags&Jt.e_enabledFlag)==Jt.e_enabledFlag},GetNext:function(){return this.m_next},GetFixtureA:function(){return this.m_fixtureA},GetChildIndexA:function(){return this.m_indexA},GetFixtureB:function(){return this.m_fixtureB},GetChildIndexB:function(){return this.m_indexB},SetFriction:function(t){this.m_friction=t},GetFriction:function(){return this.m_friction},ResetFriction:function(){this.m_friction=Xt(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)},SetRestitution:function(t){this.m_restitution=t},GetRestitution:function(){return this.m_restitution},ResetRestitution:function(){this.m_restitution=Yt(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},SetTangentSpeed:function(t){this.m_tangentSpeed=t},GetTangentSpeed:function(){return this.m_tangentSpeed},Evaluate:function(t,e,i){},FlagForFiltering:function(){this.m_flags|=Jt.e_filterFlag},m_oldManifold:null,Update:function(t){Jt.m_local_tempManifold.Assign(this.m_manifold),this.m_flags|=Jt.e_enabledFlag;var e=!1,i=(this.m_flags&Jt.e_touchingFlag)==Jt.e_touchingFlag,n=this.m_fixtureA.IsSensor(),r=this.m_fixtureB.IsSensor(),s=n||r,o=this.m_fixtureA.GetBody(),a=this.m_fixtureB.GetBody(),c=o.GetTransform(),h=a.GetTransform();if(s){var l=this.m_fixtureA.GetShape(),u=this.m_fixtureB.GetShape();e=yt(l,this.m_indexA,u,this.m_indexB,c,h),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,c,h),e=this.m_manifold.pointCount>0;for(var _=0;_<this.m_manifold.pointCount;++_){var d=this.m_manifold.points[_];d.normalImpulse=0,d.tangentImpulse=0;for(var f=d.id,p=0;p<Jt.m_local_tempManifold.pointCount;++p){var m=Jt.m_local_tempManifold.points[p];if(m.id.Get()==f.Get()){d.normalImpulse=m.normalImpulse,d.tangentImpulse=m.tangentImpulse;break}}}e!=i&&(o.SetAwake(!0),a.SetAwake(!0))}e?this.m_flags|=Jt.e_touchingFlag:this.m_flags&=~Jt.e_touchingFlag,0==i&&1==e&&t&&t.BeginContact(this),1==i&&0==e&&t&&t.EndContact(this),0==s&&e&&t&&t.PreSolve(this,Jt.m_local_tempManifold)}},Jt.e_islandFlag=1,Jt.e_touchingFlag=2,Jt.e_enabledFlag=4,Jt.e_filterFlag=8,Jt.e_bulletHitFlag=16,Jt.e_toiFlag=32,Zt.prototype={Evaluate:function(t,e,i){ot(t,this.m_fixtureA.GetShape(),e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,0,n,0),t(this.m_fixtureA.GetType()==F.e_circle),t(this.m_fixtureB.GetType()==F.e_circle)}},Zt._extend(Jt);var vi=new z;Qt.prototype={Evaluate:function(t,e,i){this.m_fixtureA.GetShape().GetChildEdge(vi,this.m_indexA),ut(t,vi,e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,i,n,r),t(this.m_fixtureA.GetType()==F.e_chain),t(this.m_fixtureB.GetType()==F.e_circle)}},Qt._extend(Jt),Kt.prototype={Evaluate:function(t,e,i){this.m_fixtureA.GetShape().GetChildEdge(vi,this.m_indexA),mt(t,vi,e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,i,n,r),t(this.m_fixtureA.GetType()==F.e_chain),t(this.m_fixtureB.GetType()==F.e_polygon)}},Kt.Create=function(t,e,i,n){return new Kt(t,e,i,n)},Kt._extend(Jt),$t.prototype={Evaluate:function(t,e,i){ut(t,this.m_fixtureA.GetShape(),e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,0,n,0),t(this.m_fixtureA.GetType()==F.e_edge),t(this.m_fixtureB.GetType()==F.e_circle)}},$t.Create=function(t,e,i,n){return new $t(t,i)},$t._extend(Jt),te.prototype={Evaluate:function(t,e,i){mt(t,this.m_fixtureA.GetShape(),e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,0,n,0),t(this.m_fixtureA.GetType()==F.e_edge),t(this.m_fixtureB.GetType()==F.e_polygon)}},te.Create=function(t,e,i,n){return new te(t,i)},te._extend(Jt),ee.prototype={Evaluate:function(t,e,i){at(t,this.m_fixtureA.GetShape(),e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,0,n,0),t(this.m_fixtureA.GetType()==F.e_polygon),t(this.m_fixtureB.GetType()==F.e_circle)}},ee.Create=function(t,e,i,n){return new ee(t,i)},ee._extend(Jt),ie.prototype={Evaluate:function(t,e,i){lt(t,this.m_fixtureA.GetShape(),e,this.m_fixtureB.GetShape(),i)},Create:function(e,i,n,r){this.parent.prototype.Create.call(this,e,0,n,0),t(this.m_fixtureA.GetType()==F.e_polygon),t(this.m_fixtureB.GetType()==F.e_polygon)}},ie.Create=function(t,e,i,n){return new ie(t,i)},ie._extend(Jt),Jt.AddType=function(e,i,n){t(0<=i&&i<F.e_typeCount),t(0<=n&&n<F.e_typeCount),Jt.s_registers[i]||(Jt.s_registers[i]=[]),Jt.s_registers[i][n]=new Ht,Jt.s_registers[i][n].fcn=e,Jt.s_registers[i][n].primary=!0,i!=n&&(Jt.s_registers[n]||(Jt.s_registers[n]=[]),Jt.s_registers[n][i]=new Ht,Jt.s_registers[n][i].fcn=e,Jt.s_registers[n][i].primary=!1),e.garbage=[],e.alloc=2},Jt.InitializeRegisters=function(){Jt.AddType(Zt,F.e_circle,F.e_circle),Jt.AddType(ee,F.e_polygon,F.e_circle),Jt.AddType(ie,F.e_polygon,F.e_polygon),Jt.AddType($t,F.e_edge,F.e_circle),Jt.AddType(te,F.e_edge,F.e_polygon),Jt.AddType(Qt,F.e_chain,F.e_circle),Jt.AddType(Kt,F.e_chain,F.e_polygon)},Jt.RetrieveGarbage=function(t){var e;if(e=t.garbage.pop())return e;for(var i=0;i<t.alloc-1;++i)t.garbage.push(new t);return t.alloc+=32,new t},Jt.Create=function(e,i,n,r){0==Jt.s_initialized&&(Jt.InitializeRegisters(),Jt.s_initialized=!0);var s=e.GetType(),o=n.GetType();t(0<=s&&s<F.e_typeCount),t(0<=o&&o<F.e_typeCount);var a=Jt.s_registers[s]&&Jt.s_registers[s][o]?Jt.s_registers[s][o].fcn:null;if(a){var c=Jt.RetrieveGarbage(a);return Jt.s_registers[s][o].primary?c.Create(e,i,n,r):c.Create(n,r,e,i),c}return null},Jt.Destroy=function(e){t(1==Jt.s_initialized);var i=e.m_fixtureA,n=e.m_fixtureB;e.m_manifold.pointCount>0&&0==i.IsSensor()&&0==n.IsSensor()&&(i.GetBody().SetAwake(!0),n.GetBody().SetAwake(!0));var r=i.GetType(),s=n.GetType();t(0<=r&&s<F.e_typeCount),t(0<=r&&s<F.e_typeCount),e.m_nodeA.Clear(),e.m_nodeB.Clear(),Jt.s_registers[r][s].fcn.garbage.push(e)},Jt.s_registers=[],Jt.s_initialized=!1;var xi=new Dt,Ci=new Lt;ne.prototype={AddPair:function(t,e){var i=t,n=e,r=i.fixture,s=n.fixture,o=i.childIndex,a=n.childIndex,c=r.GetBody(),h=s.GetBody();if(c!=h){for(var l=h.GetContactList();l;){if(l.other==c){var u=l.contact.GetFixtureA(),_=l.contact.GetFixtureB(),d=l.contact.GetChildIndexA(),f=l.contact.GetChildIndexB();if(u==r&&_==s&&d==o&&f==a)return;if(u==s&&_==r&&d==a&&f==o)return}l=l.next}if(0!=h.ShouldCollide(c)&&(!this.m_contactFilter||0!=this.m_contactFilter.ShouldCollide(r,s))){var p=Jt.Create(r,o,s,a);null!=p&&(r=p.GetFixtureA(),s=p.GetFixtureB(),o=p.GetChildIndexA(),a=p.GetChildIndexB(),c=r.GetBody(),h=s.GetBody(),p.m_prev=null,p.m_next=this.m_contactList,null!=this.m_contactList&&(this.m_contactList.m_prev=p),this.m_contactList=p,p.m_nodeA.contact=p,p.m_nodeA.other=h,p.m_nodeA.prev=null,p.m_nodeA.next=c.m_contactList,null!=c.m_contactList&&(c.m_contactList.prev=p.m_nodeA),c.m_contactList=p.m_nodeA,p.m_nodeB.contact=p,p.m_nodeB.other=c,p.m_nodeB.prev=null,p.m_nodeB.next=h.m_contactList,null!=h.m_contactList&&(h.m_contactList.prev=p.m_nodeB),h.m_contactList=p.m_nodeB,0==r.IsSensor()&&0==s.IsSensor()&&(c.SetAwake(!0),h.SetAwake(!0)),++this.m_contactCount)}}},FindNewContacts:function(){this.m_broadPhase.UpdatePairs(this)},Destroy:function(t){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=e.GetBody(),r=i.GetBody();this.m_contactListener&&t.IsTouching()&&this.m_contactListener.EndContact(t),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_contactList&&(this.m_contactList=t.m_next),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA==n.m_contactList&&(n.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB==r.m_contactList&&(r.m_contactList=t.m_nodeB.next),Jt.Destroy(t),--this.m_contactCount},Collide:function(){for(var t=this.m_contactList;t;){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=t.GetChildIndexA(),r=t.GetChildIndexB(),s=e.GetBody(),o=i.GetBody();if(t.m_flags&Jt.e_filterFlag){if(0==o.ShouldCollide(s)){t=(u=t).GetNext(),this.Destroy(u);continue}if(this.m_contactFilter&&0==this.m_contactFilter.ShouldCollide(e,i)){t=(u=t).GetNext(),this.Destroy(u);continue}t.m_flags&=~Jt.e_filterFlag}var a=s.IsAwake()&&s.m_type!=Et.b2_staticBody,c=o.IsAwake()&&o.m_type!=Et.b2_staticBody;if(0!=a||0!=c){var h=e.m_proxies[n].proxyId,l=i.m_proxies[r].proxyId;if(0!=this.m_broadPhase.TestOverlap(h,l))t.Update(this.m_contactListener),t=t.GetNext();else{var u;t=(u=t).GetNext(),this.Destroy(u)}}else t=t.GetNext()}}},ae.prototype={Initialize:function(e,i,n,r){switch(t(e.pointCount>0),e.type){case tt.e_circles:var s=i.q.c*e.localPoint.x-i.q.s*e.localPoint.y+i.p.x,o=i.q.s*e.localPoint.x+i.q.c*e.localPoint.y+i.p.y,a=n.q.c*e.localPoints[0].x-n.q.s*e.localPoints[0].y+n.p.x,c=n.q.s*e.localPoints[0].x+n.q.c*e.localPoints[0].y+n.p.y;this.point.x=.5*(s+a),this.point.y=.5*(o+c),this.normal.x=a-s,this.normal.y=c-o;var h=this.normal.x,l=this.normal.y;this.normal.Normalize(),this.separation=h*this.normal.x+l*this.normal.y-e.radiusA-e.radiusB;break;case tt.e_faceA:this.normal.x=i.q.c*e.localNormal.x-i.q.s*e.localNormal.y,this.normal.y=i.q.s*e.localNormal.x+i.q.c*e.localNormal.y;var u=i.q.c*e.localPoint.x-i.q.s*e.localPoint.y+i.p.x,_=i.q.s*e.localPoint.x+i.q.c*e.localPoint.y+i.p.y,d=n.q.c*e.localPoints[r].x-n.q.s*e.localPoints[r].y+n.p.x,f=n.q.s*e.localPoints[r].x+n.q.c*e.localPoints[r].y+n.p.y;this.separation=(d-u)*this.normal.x+(f-_)*this.normal.y-e.radiusA-e.radiusB,this.point.x=d,this.point.y=f;break;case tt.e_faceB:this.normal.x=n.q.c*e.localNormal.x-n.q.s*e.localNormal.y,this.normal.y=n.q.s*e.localNormal.x+n.q.c*e.localNormal.y;u=n.q.c*e.localPoint.x-n.q.s*e.localPoint.y+n.p.x,_=n.q.s*e.localPoint.x+n.q.c*e.localPoint.y+n.p.y,d=i.q.c*e.localPoints[r].x-i.q.s*e.localPoints[r].y+i.p.x,f=i.q.s*e.localPoints[r].x+i.q.c*e.localPoints[r].y+i.p.y;this.separation=(d-u)*this.normal.x+(f-_)*this.normal.y-e.radiusA-e.radiusB,this.point.x=d,this.point.y=f,this.normal.x=-this.normal.x,this.normal.y=-this.normal.y}}},he.cs_xfA=new h,he.cs_xfB=new h,he.temp_solver_manifold=new ae,he.prototype={Init:function(e){this.m_step=e.step,this.m_count=e.count,this.m_positionConstraints.length=this.m_count,this.m_velocityConstraints.length=this.m_count,this.m_positions=e.positions,this.m_velocities=e.velocities,this.m_contacts=e.contacts;for(var i=0;i<this.m_count;++i){var n=this.m_contacts[i],r=n.m_fixtureA,s=n.m_fixtureB,o=r.GetShape(),a=s.GetShape(),c=o.m_radius,h=a.m_radius,l=r.GetBody(),u=s.GetBody(),_=n.GetManifold(),d=_.pointCount;t(d>0);var f=this.m_velocityConstraints[i]||new oe;f.friction=n.m_friction,f.restitution=n.m_restitution,f.tangentSpeed=n.m_tangentSpeed,f.indexA=l.m_islandIndex,f.indexB=u.m_islandIndex,f.invMassA=l.m_invMass,f.invMassB=u.m_invMass,f.invIA=l.m_invI,f.invIB=u.m_invI,f.contactIndex=i,f.pointCount=d,f.K.SetZero(),f.normalMass.SetZero(),this.m_velocityConstraints[i]=f;var p=this.m_positionConstraints[i]||new se;p.indexA=l.m_islandIndex,p.indexB=u.m_islandIndex,p.invMassA=l.m_invMass,p.invMassB=u.m_invMass,p.localCenterA.x=l.m_sweep.localCenter.x,p.localCenterA.y=l.m_sweep.localCenter.y,p.localCenterB.x=u.m_sweep.localCenter.x,p.localCenterB.y=u.m_sweep.localCenter.y,p.invIA=l.m_invI,p.invIB=u.m_invI,p.localNormal.x=_.localNormal.x,p.localNormal.y=_.localNormal.y,p.localPoint.x=_.localPoint.x,p.localPoint.y=_.localPoint.y,p.pointCount=d,p.radiusA=c,p.radiusB=h,p.type=_.type,this.m_positionConstraints[i]=p;for(var m=0;m<d;++m){var g=_.points[m],y=f.points[m];this.m_step.warmStarting?(y.normalImpulse=this.m_step.dtRatio*g.normalImpulse,y.tangentImpulse=this.m_step.dtRatio*g.tangentImpulse):(y.normalImpulse=0,y.tangentImpulse=0),y.rA.SetZero(),y.rB.SetZero(),y.normalMass=0,y.tangentMass=0,y.velocityBias=0,p.localPoints[m]=g.localPoint}}},InitializeVelocityConstraints:function(){for(var e=0;e<this.m_count;++e){var i=this.m_velocityConstraints[e],n=this.m_positionConstraints[e],r=n.radiusA,s=n.radiusB,o=this.m_contacts[i.contactIndex].GetManifold(),a=i.indexA,c=i.indexB,h=i.invMassA,l=i.invMassB,u=i.invIA,_=i.invIB,d=n.localCenterA,f=n.localCenterB,p=this.m_positions[a].c,m=this.m_positions[a].a,g=this.m_velocities[a].v,y=this.m_velocities[a].w,v=this.m_positions[c].c,x=this.m_positions[c].a,C=this.m_velocities[c].v,T=this.m_velocities[c].w;t(o.pointCount>0),he.cs_xfA.q.Set(m),he.cs_xfB.q.Set(x),he.cs_xfA.p.x=p.x-(he.cs_xfA.q.c*d.x-he.cs_xfA.q.s*d.y),he.cs_xfA.p.y=p.y-(he.cs_xfA.q.s*d.x+he.cs_xfA.q.c*d.y),he.cs_xfB.p.x=v.x-(he.cs_xfB.q.c*f.x-he.cs_xfB.q.s*f.y),he.cs_xfB.p.y=v.y-(he.cs_xfB.q.s*f.x+he.cs_xfB.q.c*f.y);var b=new et;b.Initialize(o,he.cs_xfA,r,he.cs_xfB,s),i.normal.x=b.normal.x,i.normal.y=b.normal.y;for(var A=i.pointCount,S=0;S<A;++S){var w=i.points[S];w.rA.x=b.points[S].x-p.x,w.rA.y=b.points[S].y-p.y,w.rB.x=b.points[S].x-v.x,w.rB.y=b.points[S].y-v.y;var E=w.rA.x*i.normal.y-w.rA.y*i.normal.x,I=w.rB.x*i.normal.y-w.rB.y*i.normal.x,R=h+l+u*E*E+_*I*I;w.normalMass=R>0?1/R:0;var P=1*i.normal.y,O=-1*i.normal.x,B=w.rA.x*O-w.rA.y*P,D=w.rB.x*O-w.rB.y*P,M=h+l+u*B*B+_*D*D;w.tangentMass=M>0?1/M:0,w.velocityBias=0;var L=i.normal.x*(C.x+-T*w.rB.y-g.x- -y*w.rA.y)+i.normal.y*(C.y+T*w.rB.x-g.y-y*w.rA.x);L<-1&&(w.velocityBias=-i.restitution*L)}if(2==i.pointCount){var N=i.points[0],F=i.points[1],k=N.rA.x*i.normal.y-N.rA.y*i.normal.x,z=N.rB.x*i.normal.y-N.rB.y*i.normal.x,V=F.rA.x*i.normal.y-F.rA.y*i.normal.x,G=F.rB.x*i.normal.y-F.rB.y*i.normal.x,W=h+l+u*k*k+_*z*z,U=h+l+u*V*V+_*G*G,j=h+l+u*k*V+_*z*G;W*W<1e3*(W*U-j*j)?(i.K.ex.x=W,i.K.ex.y=j,i.K.ey.x=j,i.K.ey.y=U,i.normalMass.Assign(i.K.GetInverse())):i.pointCount=1}}},WarmStart:function(){for(var t=0;t<this.m_count;++t){for(var e=this.m_velocityConstraints[t],i=e.indexA,n=e.indexB,r=e.invMassA,s=e.invIA,o=e.invMassB,a=e.invIB,c=e.pointCount,h=this.m_velocities[i].v,l=this.m_velocities[i].w,u=this.m_velocities[n].v,_=this.m_velocities[n].w,d=e.normal,f=1*d.y,p=-1*d.x,m=0;m<c;++m){var g=e.points[m],y=g.normalImpulse*d.x+g.tangentImpulse*f,v=g.normalImpulse*d.y+g.tangentImpulse*p;l-=s*(g.rA.x*v-g.rA.y*y),h.x-=r*y,h.y-=r*v,_+=a*(g.rB.x*v-g.rB.y*y),u.x+=o*y,u.y+=o*v}this.m_velocities[i].w=l,this.m_velocities[n].w=_}},SolveVelocityConstraints:function(){for(var e=0;e<this.m_count;++e){var i=this.m_velocityConstraints[e],n=i.indexA,r=i.indexB,s=i.invMassA,o=i.invIA,a=i.invMassB,c=i.invIB,h=i.pointCount,l=this.m_velocities[n].v,u=this.m_velocities[n].w,_=this.m_velocities[r].v,d=this.m_velocities[r].w,f=i.normal,p=1*f.y,m=-1*f.x,g=i.friction;t(1==h||2==h);for(var y=0;y<h;++y){var v=i.points[y],x=_.x+-d*v.rB.y-l.x- -u*v.rA.y,C=_.y+d*v.rB.x-l.y-u*v.rA.x,T=x*p+C*m-i.tangentSpeed,b=v.tangentMass*-T,A=g*v.normalImpulse;b=(E=B(v.tangentImpulse+b,-A,A))-v.tangentImpulse,v.tangentImpulse=E;var S=b*p,w=b*m;l.x-=s*S,l.y-=s*w,u-=o*(v.rA.x*w-v.rA.y*S),_.x+=a*S,_.y+=a*w,d+=c*(v.rB.x*w-v.rB.y*S)}if(1==i.pointCount){v=i.points[0],x=_.x+-d*v.rB.y-l.x- -u*v.rA.y,C=_.y+d*v.rB.x-l.y-u*v.rA.x;var E,I=x*f.x+C*f.y;b=-v.normalMass*(I-v.velocityBias);b=(E=oi(v.normalImpulse+b,0))-v.normalImpulse,v.normalImpulse=E,S=b*f.x,w=b*f.y,l.x-=s*S,l.y-=s*w,u-=o*(v.rA.x*w-v.rA.y*S),_.x+=a*S,_.y+=a*w,d+=c*(v.rB.x*w-v.rB.y*S)}else{var R=i.points[0],P=i.points[1],O=R.normalImpulse,D=P.normalImpulse;t(O>=0&&D>=0);var M=_.x+-d*R.rB.y-l.x- -u*R.rA.y,L=_.y+d*R.rB.x-l.y-u*R.rA.x,N=_.x+-d*P.rB.y-l.x- -u*P.rA.y,F=_.y+d*P.rB.x-l.y-u*P.rA.x,k=M*f.x+L*f.y,z=N*f.x+F*f.y,V=k-R.velocityBias,G=z-P.velocityBias;for(V-=i.K.ex.x*O+i.K.ey.x*D,G-=i.K.ex.y*O+i.K.ey.y*D;;){var W=-(i.normalMass.ex.x*V+i.normalMass.ey.x*G),U=-(i.normalMass.ex.y*V+i.normalMass.ey.y*G);if(W>=0&&U>=0){var j=W-O,X=U-D,Y=j*f.x,H=j*f.y,q=X*f.x,J=X*f.y;l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}if(W=-R.normalMass*V,U=0,k=0,z=i.K.ex.y*W+G,W>=0&&z>=0){X=U-D,Y=(j=W-O)*f.x,H=j*f.y,q=X*f.x,J=X*f.y,l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}if(W=0,U=-P.normalMass*G,k=i.K.ey.x*U+V,z=0,U>=0&&k>=0){X=U-D,Y=(j=W-O)*f.x,H=j*f.y,q=X*f.x,J=X*f.y,l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}if(W=0,U=0,k=V,z=G,k>=0&&z>=0){X=U-D,Y=(j=W-O)*f.x,H=j*f.y,q=X*f.x,J=X*f.y,l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}break}}this.m_velocities[n].w=u,this.m_velocities[r].w=d}},StoreImpulses:function(){for(var t=0;t<this.m_count;++t)for(var e=this.m_velocityConstraints[t],i=this.m_contacts[e.contactIndex].GetManifold(),n=0;n<e.pointCount;++n)i.points[n].normalImpulse=e.points[n].normalImpulse,i.points[n].tangentImpulse=e.points[n].tangentImpulse},SolvePositionConstraints:function(){for(var t=0,e=0;e<this.m_count;++e){for(var i=this.m_positionConstraints[e],n=i.indexA,r=i.indexB,s=i.localCenterA,o=i.invMassA,a=i.invIA,c=i.localCenterB,h=i.invMassB,l=i.invIB,u=i.pointCount,_=this.m_positions[n].c,d=this.m_positions[n].a,f=this.m_positions[r].c,p=this.m_positions[r].a,m=0;m<u;++m){he.cs_xfA.q.Set(d),he.cs_xfB.q.Set(p),he.cs_xfA.p.x=_.x-(he.cs_xfA.q.c*s.x-he.cs_xfA.q.s*s.y),he.cs_xfA.p.y=_.y-(he.cs_xfA.q.s*s.x+he.cs_xfA.q.c*s.y),he.cs_xfB.p.x=f.x-(he.cs_xfB.q.c*c.x-he.cs_xfB.q.s*c.y),he.cs_xfB.p.y=f.y-(he.cs_xfB.q.s*c.x+he.cs_xfB.q.c*c.y),he.temp_solver_manifold.Initialize(i,he.cs_xfA,he.cs_xfB,m);var g=he.temp_solver_manifold.normal,y=he.temp_solver_manifold.point,v=he.temp_solver_manifold.separation,x=y.x-_.x,C=y.y-_.y,T=y.x-f.x,b=y.y-f.y;t=si(t,v);var A=B(.2*(v+Ue),-.2,0),S=x*g.y-C*g.x,w=T*g.y-b*g.x,E=o+h+a*S*S+l*w*w,I=E>0?-A/E:0,R=I*g.x,P=I*g.y;_.x-=o*R,_.y-=o*P,d-=a*(x*P-C*R),f.x+=h*R,f.y+=h*P,p+=l*(T*P-b*R)}this.m_positions[n].a=d,this.m_positions[r].a=p}return t>=-3*Ue},SolveTOIPositionConstraints:function(t,e){for(var i=0,n=0;n<this.m_count;++n){var s=this.m_positionConstraints[n],o=s.indexA,a=s.indexB,c=s.localCenterA,h=s.localCenterB,l=s.pointCount,u=0,d=0;o!=t&&o!=e||(u=s.invMassA,d=s.invIA);var f=0,p=0;a!=t&&a!=e||(f=s.invMassB,p=s.invIB);for(var m=this.m_positions[o].c,g=this.m_positions[o].a,y=this.m_positions[a].c,v=this.m_positions[a].a,x=0;x<l;++x){he.cs_xfA.q.Set(g),he.cs_xfB.q.Set(v),he.cs_xfA.p.Assign(r.Subtract(m,A(he.cs_xfA.q,c))),he.cs_xfB.p.Assign(r.Subtract(y,A(he.cs_xfB.q,h))),he.temp_solver_manifold.Initialize(s,he.cs_xfA,he.cs_xfB,x);var C=he.temp_solver_manifold.normal,T=he.temp_solver_manifold.point,b=he.temp_solver_manifold.separation,S=r.Subtract(T,m),w=r.Subtract(T,y);i=si(i,b);var E=B(.75*(b+Ue),-.2,0),I=_(S,C),R=_(w,C),P=u+f+d*I*I+p*R*R,O=r.Multiply(P>0?-E/P:0,C);m.Subtract(r.Multiply(u,O)),g-=d*_(S,O),y.Add(r.Multiply(f,O)),v+=p*_(w,O)}this.m_positions[o].a=g,this.m_positions[a].a=v}return i>=-1.5*Ue}};var Ti=Fe.create("solve initialization","solve"),bi=Fe.create("warm starting","solve initialization"),Ai=Fe.create("solve velocities","solve"),Si=Fe.create("solve positions","solve");le._solverData=new Gt,le._solverDef=new ce,le._solver=new he,le.prototype={Clear:function(){this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0},Initialize:function(t,e,i,n){this.m_listener=n,this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_bodies.length=t,this.m_contacts.length=e,this.m_joints.length=i,this.m_velocities.length=t,this.m_positions.length=t},Solve:function(t,e,i){Ti.start();for(var n=t.dt,r=0;r<this.m_bodyCount;++r){var s=this.m_bodies[r];this.m_positions[r].c.Assign(s.m_sweep.c);var o=s.m_sweep.a;this.m_velocities[r].v.Assign(s.m_linearVelocity);var a=s.m_angularVelocity;s.m_sweep.c0.Assign(s.m_sweep.c),s.m_sweep.a0=s.m_sweep.a,s.m_type==Et.b2_dynamicBody&&(this.m_velocities[r].v.x+=n*(s.m_gravityScale*e.x+s.m_invMass*s.m_force.x),this.m_velocities[r].v.y+=n*(s.m_gravityScale*e.y+s.m_invMass*s.m_force.y),a+=n*s.m_invI*s.m_torque,this.m_velocities[r].v.x*=1/(1+n*s.m_linearDamping),this.m_velocities[r].v.y*=1/(1+n*s.m_linearDamping),a*=1/(1+n*s.m_angularDamping)),this.m_positions[r].a=o,this.m_velocities[r].w=a}le._solverData.step=t,le._solverData.positions=this.m_positions,le._solverData.velocities=this.m_velocities,le._solverDef.step=t,le._solverDef.contacts=this.m_contacts,le._solverDef.count=this.m_contactCount,le._solverDef.positions=this.m_positions,le._solverDef.velocities=this.m_velocities,le._solverDef.allocator=this.m_allocator,le._solver.Init(le._solverDef),le._solver.InitializeVelocityConstraints(),t.warmStarting&&(bi.start(),le._solver.WarmStart(),bi.stop());for(r=0;r<this.m_jointCount;++r)this.m_joints[r].InitVelocityConstraints(le._solverData);Ti.stop(),Ai.start();for(r=0;r<t.velocityIterations;++r){for(var c=0;c<this.m_jointCount;++c)this.m_joints[c].SolveVelocityConstraints(le._solverData);le._solver.SolveVelocityConstraints()}le._solver.StoreImpulses(),Ai.stop(),Si.start();for(r=0;r<this.m_bodyCount;++r){var h=this.m_positions[r].c,l=(o=this.m_positions[r].a,this.m_velocities[r].v),_=(a=this.m_velocities[r].w,n*l.x),d=n*l.y,f=_*_+d*d;if(f>4){var p=2/ii(f);l.x*=p,l.y*=p}var m=n*a;if(m*m>qe){a*=p=He/ri(m)}h.x+=n*l.x,h.y+=n*l.y,o+=n*a,this.m_positions[r].a=o,this.m_velocities[r].w=a}var g=!1;for(r=0;r<t.positionIterations;++r){var y=le._solver.SolvePositionConstraints(),v=!0;for(c=0;c<this.m_jointCount;++c){var x=this.m_joints[c].SolvePositionConstraints(le._solverData);v=v&&x}if(y&&v){g=!0;break}}for(r=0;r<this.m_bodyCount;++r){var C=this.m_bodies[r];C.m_sweep.c.Assign(this.m_positions[r].c),C.m_sweep.a=this.m_positions[r].a,C.m_linearVelocity.Assign(this.m_velocities[r].v),C.m_angularVelocity=this.m_velocities[r].w,C.SynchronizeTransform()}if(Si.stop(),this.Report(le._solver.m_velocityConstraints),i){var T=ke,b=Je*Je;for(r=0;r<this.m_bodyCount;++r){(s=this.m_bodies[r]).GetType()!=Et.b2_staticBody&&(0==(s.m_flags&Et.e_autoSleepFlag)||s.m_angularVelocity*s.m_angularVelocity>b||u(s.m_linearVelocity,s.m_linearVelocity)>1e-4?(s.m_sleepTime=0,T=0):(s.m_sleepTime+=n,T=si(T,s.m_sleepTime)))}if(T>=.5&&g)for(r=0;r<this.m_bodyCount;++r){(s=this.m_bodies[r]).SetAwake(!1)}}},SolveTOI:function(e,i,n){t(i<this.m_bodyCount),t(n<this.m_bodyCount);for(var s=0;s<this.m_bodyCount;++s){var o=this.m_bodies[s];this.m_positions[s].c.Assign(o.m_sweep.c),this.m_positions[s].a=o.m_sweep.a,this.m_velocities[s].v.Assign(o.m_linearVelocity),this.m_velocities[s].w=o.m_angularVelocity}le._solverDef.contacts=this.m_contacts,le._solverDef.count=this.m_contactCount,le._solverDef.step=e,le._solverDef.positions=this.m_positions,le._solverDef.velocities=this.m_velocities,le._solver.Init(le._solverDef);for(s=0;s<e.positionIterations;++s){if(le._solver.SolveTOIPositionConstraints(i,n))break}this.m_bodies[i].m_sweep.c0.Assign(this.m_positions[i].c),this.m_bodies[i].m_sweep.a0=this.m_positions[i].a,this.m_bodies[n].m_sweep.c0.Assign(this.m_positions[n].c),this.m_bodies[n].m_sweep.a0=this.m_positions[n].a,le._solver.InitializeVelocityConstraints();for(s=0;s<e.velocityIterations;++s)le._solver.SolveVelocityConstraints();var a=e.dt;for(s=0;s<this.m_bodyCount;++s){var c=this.m_positions[s].c,h=this.m_positions[s].a,l=this.m_velocities[s].v,_=this.m_velocities[s].w,d=r.Multiply(a,l);if(u(d,d)>4){var f=2/d.Length();l.Multiply(f)}var p=a*_;if(p*p>qe){_*=f=He/ri(p)}c.Add(r.Multiply(a,l)),h+=a*_,this.m_positions[s].a=h,this.m_velocities[s].w=_;var m=this.m_bodies[s];m.m_sweep.c.Assign(c),m.m_sweep.a=h,m.m_linearVelocity.Assign(l),m.m_angularVelocity=_,m.SynchronizeTransform()}this.Report(le._solver.m_velocityConstraints)},AddBody:function(e){t(this.m_bodyCount<this.m_bodyCapacity),e.m_islandIndex=this.m_bodyCount,this.m_bodies[this.m_bodyCount]=e,this.m_positions[this.m_bodyCount]||(this.m_positions[this.m_bodyCount]=new zt,this.m_velocities[this.m_bodyCount]=new Vt),++this.m_bodyCount},AddContact:function(e){t(this.m_contactCount<this.m_contactCapacity),this.m_contacts[this.m_contactCount++]=e},AddJoint:function(e){t(this.m_jointCount<this.m_jointCapacity),this.m_joints[this.m_jointCount++]=e},Report:function(t){if(null!=this.m_listener)for(var e=0;e<this.m_contactCount;++e){var i=this.m_contacts[e],n=t[e],r=new Mt;r.count=n.pointCount;for(var s=0;s<n.pointCount;++s)r.normalImpulses[s]=n.points[s].normalImpulse,r.tangentImpulses[s]=n.points[s].tangentImpulse;this.m_listener.PostSolve(i,r)}}},_e.prototype={_deserialize:function(t,e,i){this.bodyA=e[t.bodyA],this.bodyB=e[t.bodyB],this.collideConnected=t.collideConnected}},de.prototype={GetType:function(){return this.m_type},GetBodyA:function(){return this.m_bodyA},GetBodyB:function(){return this.m_bodyB},GetAnchorA:function(){},GetAnchorB:function(){},GetReactionForce:function(t){},GetReactionTorque:function(t){},GetNext:function(){return this.m_next},GetUserData:function(){return this.m_userData},SetUserData:function(t){this.m_userData=t},IsActive:function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()},GetCollideConnected:function(){return this.m_collideConnected},ShiftOrigin:function(t){},InitVelocityConstraints:function(t){},SolveVelocityConstraints:function(t){},SolvePositionConstraints:function(t){},_serialize:function(t){var e=t||{};return e.bodyA=null,e.bodyB=null,e.type=this.m_type,e.collideConnected=this.m_collideConnected,e}},de.e_inactiveLimit=0,de.e_atLowerLimit=1,de.e_atUpperLimit=2,de.e_equalLimits=3,de.e_unknownJoint=0,de.e_revoluteJoint=1,de.e_prismaticJoint=2,de.e_distanceJoint=3,de.e_pulleyJoint=4,de.e_mouseJoint=5,de.e_gearJoint=6,de.e_wheelJoint=7,de.e_weldJoint=8,de.e_frictionJoint=9,de.e_ropeJoint=10,de.e_motorJoint=11,de.Create=function(e){var i=null;switch(e.type){case de.e_distanceJoint:i=new ve(e);break;case de.e_mouseJoint:i=new ge(e);break;case de.e_prismaticJoint:i=new Ce(e);break;case de.e_revoluteJoint:i=new pe(e);break;case de.e_pulleyJoint:i=new De(e);break;case de.e_gearJoint:i=new Re(e);break;case de.e_wheelJoint:i=new Ee(e);break;case de.e_weldJoint:i=new Se(e);break;case de.e_frictionJoint:i=new be(e);break;case de.e_ropeJoint:i=new Le(e);break;case de.e_motorJoint:i=new Oe(e);break;default:t(!1)}return i},de.Destroy=function(t){},fe.prototype={Initialize:function(t,e,i){this.bodyA=t,this.bodyB=e,this.localAnchorA=this.bodyA.GetLocalPoint(i),this.localAnchorB=this.bodyB.GetLocalPoint(i),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.referenceAngle=t.referenceAngle,this.lowerAngle=t.lowerAngle,this.upperAngle=t.upperAngle,this.maxMotorTorque=t.maxMotorTorque,this.motorSpeed=t.motorSpeed,this.enableLimit=t.enableLimit,this.enableMotor=t.enableMotor}},fe._extend(_e),pe.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},GetReferenceAngle:function(){return this.m_referenceAngle},GetJointAngle:function(){var t=this.m_bodyA;return this.m_bodyB.m_sweep.a-t.m_sweep.a-this.m_referenceAngle},GetJointSpeed:function(){var t=this.m_bodyA;return this.m_bodyB.m_angularVelocity-t.m_angularVelocity},IsLimitEnabled:function(){return this.m_enableLimit},EnableLimit:function(t){t!=this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},GetLowerLimit:function(){return this.m_lowerAngle},GetUpperLimit:function(){return this.m_upperAngle},SetLimits:function(e,i){t(e<=i),e==this.m_lowerAngle&&i==this.m_upperAngle||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=e,this.m_upperAngle=i)},IsMotorEnabled:function(){return this.m_enableMotor},EnableMotor:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t},SetMotorSpeed:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t},GetMotorSpeed:function(){return this.m_motorSpeed},SetMaxMotorTorque:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t},GetMaxMotorTorque:function(){return this.m_maxMotorTorque},GetReactionForce:function(t){var e=new r(this.m_impulse.x,this.m_impulse.y);return r.Multiply(t,e)},GetReactionTorque:function(t){return t*this.m_impulse.z},GetMotorTorque:function(t){return t*this.m_motorImpulse},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v.Clone(),a=t.velocities[this.m_indexB].w,h=new c(e),l=new c(s);this.m_rA=A(h,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=A(l,r.Subtract(this.m_localAnchorB,this.m_localCenterB));var u=this.m_invMassA,d=this.m_invMassB,f=this.m_invIA,p=this.m_invIB,m=f+p==0;if(this.m_mass.ex.x=u+d+this.m_rA.y*this.m_rA.y*f+this.m_rB.y*this.m_rB.y*p,this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*f-this.m_rB.y*this.m_rB.x*p,this.m_mass.ez.x=-this.m_rA.y*f-this.m_rB.y*p,this.m_mass.ex.y=this.m_mass.ey.x,this.m_mass.ey.y=u+d+this.m_rA.x*this.m_rA.x*f+this.m_rB.x*this.m_rB.x*p,this.m_mass.ez.y=this.m_rA.x*f+this.m_rB.x*p,this.m_mass.ex.z=this.m_mass.ez.x,this.m_mass.ey.z=this.m_mass.ez.y,this.m_mass.ez.z=f+p,this.m_motorMass=f+p,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),(0==this.m_enableMotor||m)&&(this.m_motorImpulse=0),this.m_enableLimit&&0==m){var g=s-e-this.m_referenceAngle;ri(this.m_upperAngle-this.m_lowerAngle)<2*je?this.m_limitState=de.e_equalLimits:g<=this.m_lowerAngle?(this.m_limitState!=de.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=de.e_atLowerLimit):g>=this.m_upperAngle?(this.m_limitState!=de.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=de.e_atUpperLimit):(this.m_limitState=de.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=de.e_inactiveLimit;if(t.step.warmStarting){this.m_impulse.Multiply(t.step.dtRatio),this.m_motorImpulse*=t.step.dtRatio;var y=new r(this.m_impulse.x,this.m_impulse.y);i.Subtract(r.Multiply(u,y)),n-=f*(_(this.m_rA,y)+this.m_motorImpulse+this.m_impulse.z),o.Add(r.Multiply(d,y)),a+=p*(_(this.m_rB,y)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(o),t.velocities[this.m_indexB].w=a},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),o=t.velocities[this.m_indexB].w,a=this.m_invMassA,c=this.m_invMassB,h=this.m_invIA,l=this.m_invIB,u=h+l==0;if(this.m_enableMotor&&this.m_limitState!=de.e_equalLimits&&0==u){var d=o-i-this.m_motorSpeed,p=-this.m_motorMass*d,m=this.m_motorImpulse,g=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=B(this.m_motorImpulse+p,-g,g),i-=h*(p=this.m_motorImpulse-m),o+=l*p}if(this.m_enableLimit&&this.m_limitState!=de.e_inactiveLimit&&0==u){var y=r.Subtract(r.Subtract(r.Add(n,f(o,this.m_rB)),e),f(i,this.m_rA)),v=o-i;d=new s(y.x,y.y,v),p=this.m_mass.Solve33(d).Negate();if(this.m_limitState==de.e_equalLimits)this.m_impulse.Add(p);else if(this.m_limitState==de.e_atLowerLimit){if(this.m_impulse.z+p.z<0){var x=r.Add(y.Negate(),r.Multiply(this.m_impulse.z,new r(this.m_mass.ez.x,this.m_mass.ez.y))),C=this.m_mass.Solve22(x);p.x=C.x,p.y=C.y,p.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0}else this.m_impulse.Add(p)}else if(this.m_limitState==de.e_atUpperLimit){if(this.m_impulse.z+p.z>0){x=r.Add(y.Negate(),r.Multiply(this.m_impulse.z,new r(this.m_mass.ez.x,this.m_mass.ez.y))),C=this.m_mass.Solve22(x);p.x=C.x,p.y=C.y,p.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0}else this.m_impulse.Add(p)}var T=new r(p.x,p.y);e.Subtract(r.Multiply(a,T)),i-=h*(_(this.m_rA,T)+p.z),n.Add(r.Multiply(c,T)),o+=l*(_(this.m_rB,T)+p.z)}else{d=r.Subtract(r.Subtract(r.Add(n,f(o,this.m_rB)),e),f(i,this.m_rA)),p=this.m_mass.Solve22(d.Negate());this.m_impulse.x+=p.x,this.m_impulse.y+=p.y,e.Subtract(r.Multiply(a,p)),i-=h*_(this.m_rA,p),n.Add(r.Multiply(c,p)),o+=l*_(this.m_rB,p)}t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=o},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,a=new c(i),h=new c(s),l=0,u=0,d=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=de.e_inactiveLimit&&0==d){var f=s-i-this.m_referenceAngle,p=0;if(this.m_limitState==de.e_equalLimits){var m=B(f-this.m_lowerAngle,-Ye,Ye);p=-this.m_motorMass*m,l=ri(m)}else if(this.m_limitState==de.e_atLowerLimit){l=-(m=f-this.m_lowerAngle),m=B(m+je,-Ye,0),p=-this.m_motorMass*m}else if(this.m_limitState==de.e_atUpperLimit){l=m=f-this.m_upperAngle,m=B(m-je,0,Ye),p=-this.m_motorMass*m}i-=this.m_invIA*p,s+=this.m_invIB*p}a.Set(i),h.Set(s);var g=A(a,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),y=A(h,r.Subtract(this.m_localAnchorB,this.m_localCenterB));u=(m=r.Subtract(r.Subtract(r.Add(n,y),e),g)).Length();var v=this.m_invMassA,x=this.m_invMassB,C=this.m_invIA,T=this.m_invIB,b=new o;b.ex.x=v+x+C*g.y*g.y+T*y.y*y.y,b.ex.y=-C*g.x*g.y-T*y.x*y.y,b.ey.x=b.ex.y,b.ey.y=v+x+C*g.x*g.x+T*y.x*y.x;var S=b.Solve(m).Negate();return e.Subtract(r.Multiply(v,S)),i-=C*_(g,S),n.Add(r.Multiply(x,S)),s+=T*_(y,S),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,u<=Ue&&l<=je},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.referenceAngle=this.m_referenceAngle,e.lowerAngle=this.m_lowerAngle,e.upperAngle=this.m_upperAngle,e.maxMotorTorque=this.m_maxMotorTorque,e.motorSpeed=this.m_motorSpeed,e.enableLimit=this.m_enableLimit,e.enableMotor=this.m_enableMotor,e}},pe._extend(de),me._extend(_e),ge.prototype={GetAnchorA:function(){return this.m_targetA},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,this.m_impulse)},GetReactionTorque:function(t){return 0*t},SetTarget:function(t){0==this.m_bodyB.IsAwake()&&this.m_bodyB.SetAwake(!0),this.m_targetA.Assign(t)},GetTarget:function(){return this.m_targetA},SetMaxForce:function(t){this.m_maxForce=t},GetMaxForce:function(){return this.m_maxForce},SetFrequency:function(t){this.m_frequencyHz=t},GetFrequency:function(){return this.m_frequencyHz},SetDampingRatio:function(t){this.m_dampingRatio=t},GetDampingRatio:function(){return this.m_dampingRatio},ShiftOrigin:function(t){this.m_targetA.Subtract(t)},InitVelocityConstraints:function(e){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexB].c.Clone(),n=e.positions[this.m_indexB].a,s=e.velocities[this.m_indexB].v.Clone(),a=e.velocities[this.m_indexB].w,h=new c(n),l=this.m_bodyB.GetMass(),u=2*Ve*this.m_frequencyHz,d=2*l*this.m_dampingRatio*u,f=l*(u*u),p=e.step.dt;t(d+p*f>ze),this.m_gamma=p*(d+p*f),0!=this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=p*f*this.m_gamma,this.m_rB.Assign(A(h,r.Subtract(this.m_localAnchorB,this.m_localCenterB)));var m=new o;m.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,m.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,m.ey.x=m.ex.y,m.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,this.m_mass.Assign(m.GetInverse()),this.m_C.Assign(r.Subtract(r.Add(i,this.m_rB),this.m_targetA)),this.m_C.Multiply(this.m_beta),a*=.98,e.step.warmStarting?(this.m_impulse.Multiply(e.step.dtRatio),s.Add(r.Multiply(this.m_invMassB,this.m_impulse)),a+=this.m_invIB*_(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),e.velocities[this.m_indexB].v.Assign(s),e.velocities[this.m_indexB].w=a},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexB].v.Clone(),i=t.velocities[this.m_indexB].w,n=r.Add(e,f(i,this.m_rB)),s=p(this.m_mass,r.Add(r.Add(n,this.m_C),r.Multiply(this.m_gamma,this.m_impulse)).Negate()),o=this.m_impulse.Clone();this.m_impulse.Add(s);var a=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.Multiply(a/this.m_impulse.Length()),s.Assign(r.Subtract(this.m_impulse,o)),e.Add(r.Multiply(this.m_invMassB,s)),i+=this.m_invIB*_(this.m_rB,s),t.velocities[this.m_indexB].v.Assign(e),t.velocities[this.m_indexB].w=i},SolvePositionConstraints:function(t){return!0}},ge._extend(de),ye.prototype={Initialize:function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.localAnchorA=this.bodyA.GetLocalPoint(i),this.localAnchorB=this.bodyB.GetLocalPoint(n);var s=r.Subtract(n,i);this.length=s.Length()},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.length=t.length,this.frequencyHz=t.frequencyHz,this.dampingRatio=t.dampingRatio}},ye._extend(_e),ve.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t*this.m_impulse,this.m_u)},GetReactionTorque:function(t){return 0},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},SetLength:function(t){this.m_length=t},GetLength:function(){return this.m_length},SetFrequency:function(t){this.m_frequencyHz=t},GetFrequency:function(){return this.m_frequencyHz},SetDampingRatio:function(t){this.m_dampingRatio=t},GetDampingRatio:function(){return this.m_dampingRatio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c.Clone(),a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v.Clone(),l=t.velocities[this.m_indexB].w,u=new c(i),d=new c(a);this.m_rA=A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),this.m_u=r.Subtract(r.Subtract(r.Add(o,this.m_rB),e),this.m_rA);var f=this.m_u.Length();f>Ue?this.m_u.Multiply(1/f):this.m_u.Set(0,0);var p=_(this.m_rA,this.m_u),m=_(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!=g?1/g:0,this.m_frequencyHz>0){var y=f-this.m_length,v=2*Ve*this.m_frequencyHz,x=2*this.m_mass*this.m_dampingRatio*v,C=this.m_mass*v*v,T=t.step.dt;this.m_gamma=T*(x+T*C),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=y*T*C*this.m_gamma,g+=this.m_gamma,this.m_mass=0!=g?1/g:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var b=r.Multiply(this.m_impulse,this.m_u);n.Subtract(r.Multiply(this.m_invMassA,b)),s-=this.m_invIA*_(this.m_rA,b),h.Add(r.Multiply(this.m_invMassB,b)),l+=this.m_invIB*_(this.m_rB,b)}else this.m_impulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=r.Add(e,f(i,this.m_rA)),a=r.Add(n,f(s,this.m_rB)),c=u(this.m_u,r.Subtract(a,o)),h=-this.m_mass*(c+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=h;var l=r.Multiply(h,this.m_u);e.Subtract(r.Multiply(this.m_invMassA,l)),i-=this.m_invIA*_(this.m_rA,l),n.Add(r.Multiply(this.m_invMassB,l)),s+=this.m_invIB*_(this.m_rB,l),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,o=new c(i),a=new c(s),h=A(o,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),l=A(a,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),u=r.Subtract(r.Subtract(r.Add(n,l),e),h),d=u.Normalize()-this.m_length;d=B(d,-.2,.2);var f=-this.m_mass*d,p=r.Multiply(f,u);return e.Subtract(r.Multiply(this.m_invMassA,p)),i-=this.m_invIA*_(h,p),n.Add(r.Multiply(this.m_invMassB,p)),s+=this.m_invIB*_(l,p),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,ri(d)<Ue},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.length=this.m_length,e.frequencyHz=this.m_frequencyHz,e.dampingRatio=this.m_dampingRatio,e}},ve._extend(de),xe.prototype={Initialize:function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.localAnchorA=this.bodyA.GetLocalPoint(i),this.localAnchorB=this.bodyB.GetLocalPoint(i),this.localAxisA=this.bodyA.GetLocalVector(n),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.localAxisA._deserialize(t.localAxisA),this.referenceAngle=t.referenceAngle,this.enableLimit=t.enableLimit,this.lowerTranslation=t.lowerTranslation,this.upperTranslation=t.upperTranslation,this.enableMotor=t.enableMotor,this.maxMotorForce=t.maxMotorForce,this.motorSpeed=t.motorSpeed}},xe._extend(_e),Ce.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,r.Add(r.Multiply(this.m_impulse.x,this.m_perp),r.Multiply(this.m_motorImpulse+this.m_impulse.z,this.m_axis)))},GetReactionTorque:function(t){return t*this.m_impulse.y},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},GetLocalAxisA:function(){return this.m_localXAxisA},GetReferenceAngle:function(){return this.m_referenceAngle},GetJointTranslation:function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA),e=this.m_bodyB.GetWorldPoint(this.m_localAnchorB);return u(r.Subtract(e,t),this.m_bodyA.GetWorldVector(this.m_localXAxisA))},GetJointSpeed:function(){var t=this.m_bodyA,e=this.m_bodyB,i=A(t.m_xf.q,r.Subtract(this.m_localAnchorA,t.m_sweep.localCenter)),n=A(e.m_xf.q,r.Subtract(this.m_localAnchorB,e.m_sweep.localCenter)),s=r.Add(t.m_sweep.c,i),o=r.Add(e.m_sweep.c,n),a=r.Subtract(o,s),c=A(t.m_xf.q,this.m_localXAxisA),h=t.m_linearVelocity,l=e.m_linearVelocity,_=t.m_angularVelocity,d=e.m_angularVelocity;return u(a,f(_,c))+u(c,r.Subtract(r.Subtract(r.Add(l,f(d,n)),h),f(_,i)))},IsLimitEnabled:function(){return this.m_enableLimit},EnableLimit:function(t){t!=this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},GetLowerLimit:function(){return this.m_lowerTranslation},GetUpperLimit:function(){return this.m_upperTranslation},SetLimits:function(e,i){t(e<=i),e==this.m_lowerTranslation&&i==this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=e,this.m_upperTranslation=i,this.m_impulse.z=0)},IsMotorEnabled:function(){return this.m_enableMotor},EnableMotor:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t},SetMotorSpeed:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t},GetMotorSpeed:function(){return this.m_motorSpeed},SetMaxMotorForce:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t},GetMaxMotorForce:function(){return this.m_maxMotorForce},GetMotorForce:function(t){return t*this.m_motorImpulse},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c.Clone(),a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v.Clone(),l=t.velocities[this.m_indexB].w,d=new c(i),f=new c(a),p=A(d,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),m=A(f,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),g=r.Add(r.Subtract(o,e),r.Subtract(m,p)),y=this.m_invMassA,v=this.m_invMassB,x=this.m_invIA,C=this.m_invIB;this.m_axis=A(d,this.m_localXAxisA),this.m_a1=_(r.Add(g,p),this.m_axis),this.m_a2=_(m,this.m_axis),this.m_motorMass=y+v+x*this.m_a1*this.m_a1+C*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),this.m_perp=A(d,this.m_localYAxisA),this.m_s1=_(r.Add(g,p),this.m_perp),this.m_s2=_(m,this.m_perp);var T=y+v+x*this.m_s1*this.m_s1+C*this.m_s2*this.m_s2,b=x*this.m_s1+C*this.m_s2,S=x*this.m_s1*this.m_a1+C*this.m_s2*this.m_a2,w=x+C;0==w&&(w=1);var E=x*this.m_a1+C*this.m_a2,I=y+v+x*this.m_a1*this.m_a1+C*this.m_a2*this.m_a2;if(this.m_K.ex.Set(T,b,S),this.m_K.ey.Set(b,w,E),this.m_K.ez.Set(S,E,I),this.m_enableLimit){var R=u(this.m_axis,g);ri(this.m_upperTranslation-this.m_lowerTranslation)<2*Ue?this.m_limitState=de.e_equalLimits:R<=this.m_lowerTranslation?this.m_limitState!=de.e_atLowerLimit&&(this.m_limitState=de.e_atLowerLimit,this.m_impulse.z=0):R>=this.m_upperTranslation?this.m_limitState!=de.e_atUpperLimit&&(this.m_limitState=de.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=de.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=de.e_inactiveLimit,this.m_impulse.z=0;if(0==this.m_enableMotor&&(this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse.Multiply(t.step.dtRatio),this.m_motorImpulse*=t.step.dtRatio;var P=r.Add(r.Multiply(this.m_impulse.x,this.m_perp),r.Multiply(this.m_motorImpulse+this.m_impulse.z,this.m_axis)),O=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,B=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;n.Subtract(r.Multiply(y,P)),s-=x*O,h.Add(r.Multiply(v,P)),l+=C*B}else this.m_impulse.SetZero(),this.m_motorImpulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),o=t.velocities[this.m_indexB].w,a=this.m_invMassA,c=this.m_invMassB,h=this.m_invIA,l=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!=de.e_equalLimits){var _=u(this.m_axis,r.Subtract(n,e))+this.m_a2*o-this.m_a1*i,d=this.m_motorMass*(this.m_motorSpeed-_),f=this.m_motorImpulse,p=t.step.dt*this.m_maxMotorForce;this.m_motorImpulse=B(this.m_motorImpulse+d,-p,p),d=this.m_motorImpulse-f;var m=r.Multiply(d,this.m_axis),g=d*this.m_a1,y=d*this.m_a2;e.Subtract(r.Multiply(a,m)),i-=h*g,n.Add(r.Multiply(c,m)),o+=l*y}var v=new r;if(v.x=u(this.m_perp,r.Subtract(n,e))+this.m_s2*o-this.m_s1*i,v.y=o-i,this.m_enableLimit&&this.m_limitState!=de.e_inactiveLimit){var x;x=u(this.m_axis,r.Subtract(n,e))+this.m_a2*o-this.m_a1*i;_=new s(v.x,v.y,x);var C=this.m_impulse.Clone(),T=this.m_K.Solve33(_.Negate());this.m_impulse.Add(T),this.m_limitState==de.e_atLowerLimit?this.m_impulse.z=oi(this.m_impulse.z,0):this.m_limitState==de.e_atUpperLimit&&(this.m_impulse.z=si(this.m_impulse.z,0));var b=r.Subtract(v.Negate(),r.Multiply(this.m_impulse.z-C.z,new r(this.m_K.ez.x,this.m_K.ez.y))),A=r.Add(this.m_K.Solve22(b),new r(C.x,C.y));this.m_impulse.x=A.x,this.m_impulse.y=A.y,T=s.Subtract(this.m_impulse,C);m=r.Add(r.Multiply(T.x,this.m_perp),r.Multiply(T.z,this.m_axis)),g=T.x*this.m_s1+T.y+T.z*this.m_a1,y=T.x*this.m_s2+T.y+T.z*this.m_a2;e.Subtract(r.Multiply(a,m)),i-=h*g,n.Add(r.Multiply(c,m)),o+=l*y}else{T=this.m_K.Solve22(v.Negate());this.m_impulse.x+=T.x,this.m_impulse.y+=T.y;m=r.Multiply(T.x,this.m_perp),g=T.x*this.m_s1+T.y,y=T.x*this.m_s2+T.y;e.Subtract(r.Multiply(a,m)),i-=h*g,n.Add(r.Multiply(c,m)),o+=l*y}t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=o},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),h=t.positions[this.m_indexB].a,l=new c(i),d=new c(h),f=this.m_invMassA,p=this.m_invMassB,m=this.m_invIA,g=this.m_invIB,y=A(l,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),v=A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),x=r.Subtract(r.Subtract(r.Add(n,v),e),y),C=A(l,this.m_localXAxisA),T=_(r.Add(x,y),C),b=_(v,C),S=A(l,this.m_localYAxisA),w=_(r.Add(x,y),S),E=_(v,S),I=new s,R=new r;R.x=u(S,x),R.y=h-i-this.m_referenceAngle;var P=ri(R.x),O=ri(R.y),D=!1,M=0;if(this.m_enableLimit){var L=u(C,x);ri(this.m_upperTranslation-this.m_lowerTranslation)<2*Ue?(M=B(L,-.2,.2),P=oi(P,ri(L)),D=!0):L<=this.m_lowerTranslation?(M=B(L-this.m_lowerTranslation+Ue,-.2,0),P=oi(P,this.m_lowerTranslation-L),D=!0):L>=this.m_upperTranslation&&(M=B(L-this.m_upperTranslation-Ue,0,.2),P=oi(P,L-this.m_upperTranslation),D=!0)}if(D){var N=f+p+m*w*w+g*E*E,F=m*w+g*E,k=m*w*T+g*E*b;0==(W=m+g)&&(W=1);var z=m*T+g*b,V=f+p+m*T*T+g*b*b;(U=new a).ex.Set(N,F,k),U.ey.Set(F,W,z),U.ez.Set(k,z,V);var G=new s;G.x=R.x,G.y=R.y,G.z=M,I=U.Solve33(G.Negate())}else{var W;N=f+p+m*w*w+g*E*E,F=m*w+g*E;0==(W=m+g)&&(W=1);var U;(U=new o).ex.Set(N,F),U.ey.Set(F,W);var j=U.Solve(R.Negate());I.x=j.x,I.y=j.y,I.z=0}var X=r.Add(r.Multiply(I.x,S),r.Multiply(I.z,C)),Y=I.x*w+I.y+I.z*T,H=I.x*E+I.y+I.z*b;return e.Subtract(r.Multiply(f,X)),i-=m*Y,n.Add(r.Multiply(p,X)),h+=g*H,t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=h,P<=Ue&&O<=je},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.localAxisA=this.m_localXAxisA._serialize(),e.referenceAngle=this.m_referenceAngle,e.enableLimit=this.m_enableLimit,e.lowerTranslation=this.m_lowerTranslation,e.upperTranslation=this.m_upperTranslation,e.enableMotor=this.m_enableMotor,e.maxMotorForce=this.m_maxMotorForce,e.motorSpeed=this.m_motorSpeed,e}},Ce._extend(de),Te.prototype={Initialize:function(t,e,i){this.bodyA=t,this.bodyB=e,this.localAnchorA.Assign(this.bodyA.GetLocalPoint(i)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(i))},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.maxForce=t.maxForce,this.maxTorque=t.maxTorque}},Te._extend(_e),be.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,this.m_linearImpulse)},GetReactionTorque:function(t){return t*this.m_angularImpulse},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},SetMaxForce:function(e){t(n(e)&&e>=0),this.m_maxForce=e},GetMaxForce:function(){return this.m_maxForce},SetMaxTorque:function(e){t(n(e)&&e>=0),this.m_maxTorque=e},GetMaxTorque:function(){return this.m_maxTorque},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,a=t.velocities[this.m_indexB].v.Clone(),h=t.velocities[this.m_indexB].w,l=new c(e),u=new c(s);this.m_rA=A(l,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=A(u,r.Subtract(this.m_localAnchorB,this.m_localCenterB));var d=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=new o;if(g.ex.x=d+f+p*this.m_rA.y*this.m_rA.y+m*this.m_rB.y*this.m_rB.y,g.ex.y=-p*this.m_rA.x*this.m_rA.y-m*this.m_rB.x*this.m_rB.y,g.ey.x=g.ex.y,g.ey.y=d+f+p*this.m_rA.x*this.m_rA.x+m*this.m_rB.x*this.m_rB.x,this.m_linearMass=g.GetInverse(),this.m_angularMass=p+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.Multiply(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var y=new r(this.m_linearImpulse.x,this.m_linearImpulse.y);i.Subtract(r.Multiply(d,y)),n-=p*(_(this.m_rA,y)+this.m_angularImpulse),a.Add(r.Multiply(f,y)),h+=m*(_(this.m_rB,y)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(a),t.velocities[this.m_indexB].w=h},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,c=this.m_invIA,h=this.m_invIB,l=t.step.dt,u=s-i,d=-this.m_angularMass*u,m=this.m_angularImpulse,g=l*this.m_maxTorque;this.m_angularImpulse=B(this.m_angularImpulse+d,-g,g),i-=c*(d=this.m_angularImpulse-m);u=r.Add(n,r.Subtract(f(s+=h*d,this.m_rB),r.Subtract(e,f(i,this.m_rA)))),d=p(this.m_linearMass,u).Negate(),m=this.m_linearImpulse.Clone();this.m_linearImpulse.Add(d);g=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>g*g&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(g)),d=r.Subtract(this.m_linearImpulse,m),e.Subtract(r.Multiply(o,d)),i-=c*_(this.m_rA,d),n.Add(r.Multiply(a,d)),s+=h*_(this.m_rB,d),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){return!0},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.maxForce=this.m_maxForce,e.maxTorque=this.m_maxTorque,e}},be._extend(de),Ae.prototype={Initialize:function(t,e,i){this.bodyA=t,this.bodyB=e,this.localAnchorA.Assign(this.bodyA.GetLocalPoint(i)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(i)),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.referenceAngle=t.referenceAngle,this.frequencyHz=t.frequencyHz,this.dampingRatio=t.dampingRatio}},Ae._extend(_e),Se.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){var e=new r(this.m_impulse.x,this.m_impulse.y);return r.Multiply(t,e)},GetReactionTorque:function(t){return t*this.m_impulse.z},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},GetReferenceAngle:function(){return this.m_referenceAngle},SetFrequency:function(t){this.m_frequencyHz=t},GetFrequency:function(){return this.m_frequencyHz},SetDampingRatio:function(t){this.m_dampingRatio=t},GetDampingRatio:function(){return this.m_dampingRatio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v.Clone(),h=t.velocities[this.m_indexB].w,l=new c(e),u=new c(s);this.m_rA.Assign(A(l,r.Subtract(this.m_localAnchorA,this.m_localCenterA))),this.m_rB.Assign(A(u,r.Subtract(this.m_localAnchorB,this.m_localCenterB)));var d=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=new a;if(g.ex.x=d+f+this.m_rA.y*this.m_rA.y*p+this.m_rB.y*this.m_rB.y*m,g.ey.x=-this.m_rA.y*this.m_rA.x*p-this.m_rB.y*this.m_rB.x*m,g.ez.x=-this.m_rA.y*p-this.m_rB.y*m,g.ex.y=g.ey.x,g.ey.y=d+f+this.m_rA.x*this.m_rA.x*p+this.m_rB.x*this.m_rB.x*m,g.ez.y=this.m_rA.x*p+this.m_rB.x*m,g.ex.z=g.ez.x,g.ey.z=g.ez.y,g.ez.z=p+m,this.m_frequencyHz>0){g.GetInverse22(this.m_mass);var y=p+m,v=y>0?1/y:0,x=s-e-this.m_referenceAngle,C=2*Ve*this.m_frequencyHz,T=2*v*this.m_dampingRatio*C,b=v*C*C,S=t.step.dt;this.m_gamma=S*(T+S*b),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=x*S*b*this.m_gamma,y+=this.m_gamma,this.m_mass.ez.z=0!=y?1/y:0}else 0==g.ez.z?(g.GetInverse22(this.m_mass),this.m_gamma=0,this.m_bias=0):(g.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0);if(t.step.warmStarting){this.m_impulse.Multiply(t.step.dtRatio);var w=new r(this.m_impulse.x,this.m_impulse.y);i.Subtract(r.Multiply(d,w)),n-=p*(_(this.m_rA,w)+this.m_impulse.z),o.Add(r.Multiply(f,w)),h+=m*(_(this.m_rB,w)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(o),t.velocities[this.m_indexB].w=h},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),o=t.velocities[this.m_indexB].w,a=this.m_invMassA,c=this.m_invMassB,h=this.m_invIA,l=this.m_invIB;if(this.m_frequencyHz>0){var u=o-i,d=-this.m_mass.ez.z*(u+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=d,i-=h*d;var p=r.Subtract(r.Subtract(r.Add(n,f(o+=l*d,this.m_rB)),e),f(i,this.m_rA)),m=C(this.m_mass,p).Negate();this.m_impulse.x+=m.x,this.m_impulse.y+=m.y;var g=m.Clone();e.Subtract(r.Multiply(a,g)),i-=h*_(this.m_rA,g),n.Add(r.Multiply(c,g)),o+=l*_(this.m_rB,g)}else{u=o-i;var y=new s((p=r.Subtract(r.Subtract(r.Add(n,f(o,this.m_rB)),e),f(i,this.m_rA))).x,p.y,u),v=x(this.m_mass,y).Negate();this.m_impulse.Add(v);g=new r(v.x,v.y);e.Subtract(r.Multiply(a,g)),i-=h*(_(this.m_rA,g)+v.z),n.Add(r.Multiply(c,g)),o+=l*(_(this.m_rB,g)+v.z)}t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=o},SolvePositionConstraints:function(t){var e,i,n=t.positions[this.m_indexA].c.Clone(),o=t.positions[this.m_indexA].a,h=t.positions[this.m_indexB].c.Clone(),l=t.positions[this.m_indexB].a,u=new c(o),d=new c(l),f=this.m_invMassA,p=this.m_invMassB,m=this.m_invIA,g=this.m_invIB,y=A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),v=A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),x=new a;if(x.ex.x=f+p+y.y*y.y*m+v.y*v.y*g,x.ey.x=-y.y*y.x*m-v.y*v.x*g,x.ez.x=-y.y*m-v.y*g,x.ex.y=x.ey.x,x.ey.y=f+p+y.x*y.x*m+v.x*v.x*g,x.ez.y=y.x*m+v.x*g,x.ex.z=x.ez.x,x.ey.z=x.ez.y,x.ez.z=m+g,this.m_frequencyHz>0){e=(T=r.Subtract(r.Subtract(r.Add(h,v),n),y)).Length(),i=0;var C=x.Solve22(T).Negate();n.Subtract(r.Multiply(f,C)),o-=m*_(y,C),h.Add(r.Multiply(p,C)),l+=g*_(v,C)}else{var T=r.Subtract(r.Subtract(r.Add(h,v),n),y),b=l-o-this.m_referenceAngle;e=T.Length(),i=ri(b);var S,w=new s(T.x,T.y,b);if(x.ez.z>0)S=x.Solve33(w).Invert();else{var E=x.Solve22(T).Invert();S=new s(E.x,E.y,0)}C=new r(S.x,S.y);n.Subtract(r.Multiply(f,C)),o-=m*(_(y,C)+S.z),h.Add(r.Multiply(p,C)),l+=g*(_(v,C)+S.z)}return t.positions[this.m_indexA].c.Assign(n),t.positions[this.m_indexA].a=o,t.positions[this.m_indexB].c.Assign(h),t.positions[this.m_indexB].a=l,e<=Ue&&i<=je},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.referenceAngle=this.m_referenceAngle,e.frequencyHz=this.m_frequencyHz,e.dampingRatio=this.m_dampingRatio,e}},Se._extend(de),we.prototype={Initialize:function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.localAnchorA.Assign(this.bodyA.GetLocalPoint(i)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(i)),this.localAxisA.Assign(this.bodyA.GetLocalVector(n))},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.localAxisA._deserialize(t.localAxisA),this.enableMotor=t.enableMotor,this.maxMotorTorque=t.maxMotorTorque,this.motorSpeed=t.motorSpeed,this.frequencyHz=t.frequencyHz,this.dampingRatio=t.dampingRatio}},we._extend(_e),Ee.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,r.Add(r.Multiply(this.m_impulse,this.m_ay),r.Multiply(this.m_springImpulse,this.m_ax)))},GetReactionTorque:function(t){return t*this.m_motorImpulse},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},GetLocalAxisA:function(){return this.m_localXAxisA},GetJointTranslation:function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA),n=e.GetWorldPoint(this.m_localAnchorB);return u(r.Subtract(n,i),t.GetWorldVector(this.m_localXAxisA))},GetJointSpeed:function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},IsMotorEnabled:function(){return this.m_enableMotor},EnableMotor:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t},SetMotorSpeed:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t},GetMotorSpeed:function(){return this.m_motorSpeed},SetMaxMotorTorque:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t},GetMaxMotorTorque:function(){return this.m_maxMotorTorque},GetMotorTorque:function(t){return t*this.m_motorImpulse},SetSpringFrequencyHz:function(t){this.m_frequencyHz=t},GetSpringFrequencyHz:function(){return this.m_frequencyHz},SetSpringDampingRatio:function(t){this.m_dampingRatio=t},GetSpringDampingRatio:function(){return this.m_dampingRatio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,i=this.m_invMassB,n=this.m_invIA,s=this.m_invIB,o=t.positions[this.m_indexA].c.Clone(),a=t.positions[this.m_indexA].a,h=t.velocities[this.m_indexA].v.Clone(),l=t.velocities[this.m_indexA].w,d=t.positions[this.m_indexB].c.Clone(),f=t.positions[this.m_indexB].a,p=t.velocities[this.m_indexB].v.Clone(),m=t.velocities[this.m_indexB].w,g=new c(a),y=new c(f),v=A(g,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),x=A(y,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),C=r.Subtract(r.Subtract(r.Add(d,x),o),v);if(this.m_ay.Assign(A(g,this.m_localYAxisA)),this.m_sAy=_(r.Add(C,v),this.m_ay),this.m_sBy=_(x,this.m_ay),this.m_mass=e+i+n*this.m_sAy*this.m_sAy+s*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){this.m_ax.Assign(A(g,this.m_localXAxisA)),this.m_sAx=_(r.Add(C,v),this.m_ax),this.m_sBx=_(x,this.m_ax);var T=e+i+n*this.m_sAx*this.m_sAx+s*this.m_sBx*this.m_sBx;if(T>0){this.m_springMass=1/T;var b=u(C,this.m_ax),S=2*Ve*this.m_frequencyHz,w=(C=2*this.m_springMass*this.m_dampingRatio*S,this.m_springMass*S*S),E=t.step.dt;this.m_gamma=E*(C+E*w),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=b*E*w*this.m_gamma,this.m_springMass=T+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=n+s,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var I=r.Add(r.Multiply(this.m_impulse,this.m_ay),r.Multiply(this.m_springImpulse,this.m_ax)),R=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,P=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;h.Subtract(r.Multiply(this.m_invMassA,I)),l-=this.m_invIA*R,p.Add(r.Multiply(this.m_invMassB,I)),m+=this.m_invIB*P}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].v.Assign(h),t.velocities[this.m_indexA].w=l,t.velocities[this.m_indexB].v.Assign(p),t.velocities[this.m_indexB].w=m},SolveVelocityConstraints:function(t){var e=this.m_invMassA,i=this.m_invMassB,n=this.m_invIA,s=this.m_invIB,o=t.velocities[this.m_indexA].v.Clone(),a=t.velocities[this.m_indexA].w,c=t.velocities[this.m_indexB].v.Clone(),h=t.velocities[this.m_indexB].w,l=u(this.m_ax,r.Subtract(c,o))+this.m_sBx*h-this.m_sAx*a,_=-this.m_springMass*(l+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=_;var d=r.Multiply(_,this.m_ax),f=_*this.m_sAx,p=_*this.m_sBx;o.Subtract(r.Multiply(e,d)),a-=n*f,c.Add(r.Multiply(i,d));l=(h+=s*p)-a-this.m_motorSpeed,_=-this.m_motorMass*l;var m=this.m_motorImpulse,g=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=B(this.m_motorImpulse+_,-g,g),a-=n*(_=this.m_motorImpulse-m),h+=s*_;l=u(this.m_ay,r.Subtract(c,o))+this.m_sBy*h-this.m_sAy*a,_=-this.m_mass*l;this.m_impulse+=_;d=r.Multiply(_,this.m_ay),f=_*this.m_sAy,p=_*this.m_sBy;o.Subtract(r.Multiply(e,d)),a-=n*f,c.Add(r.Multiply(i,d)),h+=s*p,t.velocities[this.m_indexA].v.Assign(o),t.velocities[this.m_indexA].w=a,t.velocities[this.m_indexB].v.Assign(c),t.velocities[this.m_indexB].w=h},SolvePositionConstraints:function(t){var e,i=t.positions[this.m_indexA].c.Clone(),n=t.positions[this.m_indexA].a,s=t.positions[this.m_indexB].c.Clone(),o=t.positions[this.m_indexB].a,a=new c(n),h=new c(o),l=A(a,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),d=A(h,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),f=r.Add(r.Subtract(s,i),r.Subtract(d,l)),p=A(a,this.m_localYAxisA),m=_(r.Add(f,l),p),g=_(d,p),y=u(f,p),v=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy,x=r.Multiply(e=0!=v?-y/v:0,p),C=e*m,T=e*g;return i.Subtract(r.Multiply(this.m_invMassA,x)),n-=this.m_invIA*C,s.Add(r.Multiply(this.m_invMassB,x)),o+=this.m_invIB*T,t.positions[this.m_indexA].c.Assign(i),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].c.Assign(s),t.positions[this.m_indexB].a=o,ri(y)<=Ue},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.localAxisA=this.m_localAxisA._serialize(),e.enableMotor=this.m_enableMotor,e.maxMotorTorque=this.m_maxMotorTorque,e.motorSpeed=this.m_motorSpeed,e.frequencyHz=this.m_frequencyHz,e.dampingRatio=this.m_dampingRatio,e}},Ee._extend(de),Ie.prototype={_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.joint1=t.joint1,this.joint2=t.joint2,this.ratio=t.ratio}},Ie._extend(_e),Re.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){var e=r.Multiply(this.m_impulse,this.m_JvAC);return r.Multiply(t,e)},GetReactionTorque:function(t){return t*(this.m_impulse*this.m_JwA)},GetJoint1:function(){return this.m_joint1},GetJoint2:function(){return this.m_joint2},SetRatio:function(e){t(n(e)),this.m_ratio=e},GetRatio:function(){return this.m_ratio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Assign(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Assign(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v.Clone(),a=t.velocities[this.m_indexB].w,h=t.positions[this.m_indexC].a,l=t.velocities[this.m_indexC].v.Clone(),u=t.velocities[this.m_indexC].w,d=t.positions[this.m_indexD].a,f=t.velocities[this.m_indexD].v.Clone(),p=t.velocities[this.m_indexD].w,m=new c(e),g=new c(s),y=new c(h),v=new c(d);if(this.m_mass=0,this.m_typeA==de.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var x=A(y,this.m_localAxisC),C=A(y,r.Subtract(this.m_localAnchorC,this.m_lcC)),T=A(m,r.Subtract(this.m_localAnchorA,this.m_lcA));this.m_JvAC.Assign(x),this.m_JwC=_(C,x),this.m_JwA=_(T,x),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB==de.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{x=A(v,this.m_localAxisD);var b=A(v,r.Subtract(this.m_localAnchorD,this.m_lcD)),S=A(g,r.Subtract(this.m_localAnchorB,this.m_lcB));this.m_JvBD.Assign(r.Multiply(this.m_ratio,x)),this.m_JwD=this.m_ratio*_(b,x),this.m_JwB=this.m_ratio*_(S,x),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,t.step.warmStarting?(i.Add(r.Multiply(this.m_mA*this.m_impulse,this.m_JvAC)),n+=this.m_iA*this.m_impulse*this.m_JwA,o.Add(r.Multiply(this.m_mB*this.m_impulse,this.m_JvBD)),a+=this.m_iB*this.m_impulse*this.m_JwB,l.Subtract(r.Multiply(this.m_mC*this.m_impulse,this.m_JvAC)),u-=this.m_iC*this.m_impulse*this.m_JwC,f.Subtract(r.Multiply(this.m_mD*this.m_impulse,this.m_JvBD)),p-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(o),t.velocities[this.m_indexB].w=a,t.velocities[this.m_indexC].v.Assign(l),t.velocities[this.m_indexC].w=u,t.velocities[this.m_indexD].v.Assign(f),t.velocities[this.m_indexD].w=p},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=t.velocities[this.m_indexC].v.Clone(),a=t.velocities[this.m_indexC].w,c=t.velocities[this.m_indexD].v.Clone(),h=t.velocities[this.m_indexD].w,l=u(this.m_JvAC,r.Subtract(e,o))+u(this.m_JvBD,r.Subtract(n,c));l+=this.m_JwA*i-this.m_JwC*a+(this.m_JwB*s-this.m_JwD*h);var _=-this.m_mass*l;this.m_impulse+=_,e.Add(r.Multiply(this.m_mA*_,this.m_JvAC)),i+=this.m_iA*_*this.m_JwA,n.Add(r.Multiply(this.m_mB*_,this.m_JvBD)),s+=this.m_iB*_*this.m_JwB,o.Subtract(r.Multiply(this.m_mC*_,this.m_JvAC)),a-=this.m_iC*_*this.m_JwC,c.Subtract(r.Multiply(this.m_mD*_,this.m_JvBD)),h-=this.m_iD*_*this.m_JwD,t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s,t.velocities[this.m_indexC].v.Assign(o),t.velocities[this.m_indexC].w=a,t.velocities[this.m_indexD].v.Assign(c),t.velocities[this.m_indexD].w=h},SolvePositionConstraints:function(t){var e,i,n,s,o,a,h=t.positions[this.m_indexA].c.Clone(),l=t.positions[this.m_indexA].a,d=t.positions[this.m_indexB].c.Clone(),f=t.positions[this.m_indexB].a,p=t.positions[this.m_indexC].c.Clone(),m=t.positions[this.m_indexC].a,g=t.positions[this.m_indexD].c.Clone(),y=t.positions[this.m_indexD].a,v=new c(l),x=new c(f),C=new c(m),T=new c(y),b=new r,w=new r,E=0;if(this.m_typeA==de.e_revoluteJoint)b.SetZero(),n=1,o=1,E+=this.m_iA+this.m_iC,e=l-m-this.m_referenceAngleA;else{var I=A(C,this.m_localAxisC),R=A(C,r.Subtract(this.m_localAnchorC,this.m_lcC)),P=A(v,r.Subtract(this.m_localAnchorA,this.m_lcA));b.Assign(I),o=_(R,I),n=_(P,I),E+=this.m_mC+this.m_mA+this.m_iC*o*o+this.m_iA*n*n;var O=r.Subtract(this.m_localAnchorC,this.m_lcC),B=S(C,r.Add(P,r.Subtract(h,p)));e=u(r.Subtract(B,O),this.m_localAxisC)}if(this.m_typeB==de.e_revoluteJoint)w.SetZero(),s=this.m_ratio,a=this.m_ratio,E+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),i=f-y-this.m_referenceAngleB;else{I=A(T,this.m_localAxisD);var D=A(T,r.Subtract(this.m_localAnchorD,this.m_lcD)),M=A(x,r.Subtract(this.m_localAnchorB,this.m_lcB));w.Assign(r.Multiply(this.m_ratio,I)),a=this.m_ratio*_(D,I),s=this.m_ratio*_(M,I),E+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*a*a+this.m_iB*s*s;var L=r.Subtract(this.m_localAnchorD,this.m_lcD),N=S(T,r.Add(M,r.Subtract(d,g)));i=u(r.Subtract(N,L),this.m_localAxisD)}var F=e+this.m_ratio*i-this.m_constant,k=0;return E>0&&(k=-F/E),h.Add(r.Multiply(this.m_mA,r.Multiply(k,b))),l+=this.m_iA*k*n,d.Add(r.Multiply(this.m_mB,r.Multiply(k,w))),f+=this.m_iB*k*s,p.Subtract(r.Multiply(this.m_mC,r.Multiply(k,b))),m-=this.m_iC*k*o,g.Subtract(r.Multiply(this.m_mD,r.Multiply(k,w))),y-=this.m_iD*k*a,t.positions[this.m_indexA].c.Assign(h),t.positions[this.m_indexA].a=l,t.positions[this.m_indexB].c.Assign(d),t.positions[this.m_indexB].a=f,t.positions[this.m_indexC].c.Assign(p),t.positions[this.m_indexC].a=m,t.positions[this.m_indexD].c.Assign(g),t.positions[this.m_indexD].a=y,0<Ue},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.joint1=this.m_joint1.__temp_joint_id,e.joint2=this.m_joint2.__temp_joint_id,e.ratio=this.m_ratio,e}},Re._extend(de),Pe.prototype={Initialize:function(t,e){this.bodyA=t,this.bodyB=e;var i=this.bodyB.GetPosition();this.linearOffset.Assign(this.bodyA.GetLocalPoint(i));var n=this.bodyA.GetAngle(),r=this.bodyB.GetAngle();this.angularOffset=r-n},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.linearOffset._deserialize(t.linearOffset),this.angularOffset=t.angularOffset,this.maxForce=t.maxForce,this.maxTorque=t.maxTorque,this.correctionFactor=t.correctionFactor}},Pe._extend(_e),Oe.prototype={GetAnchorA:function(){return this.m_bodyA.GetPosition()},GetAnchorB:function(){return this.m_bodyB.GetPosition()},GetReactionForce:function(t){return r.Multiply(t,this.m_linearImpulse)},GetReactionTorque:function(t){return t*this.m_angularImpulse},SetLinearOffset:function(t){t.x==this.m_linearOffset.x&&t.y==this.m_linearOffset.y||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Assign(t))},GetLinearOffset:function(){return this.m_linearOffset},SetAngularOffset:function(t){t!=this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=t)},GetAngularOffset:function(){return this.m_angularOffset},SetMaxForce:function(e){t(n(e)&&e>=0),this.m_maxForce=e},GetMaxForce:function(){return this.m_maxForce},SetMaxTorque:function(e){t(n(e)&&e>=0),this.m_maxTorque=e},GetMaxTorque:function(){return this.m_maxTorque},SetCorrectionFactor:function(e){t(n(e)&&0<=e&&e<=1),this.m_correctionFactor=e},GetCorrectionFactor:function(){return this.m_correctionFactor},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c.Clone(),h=t.positions[this.m_indexB].a,l=t.velocities[this.m_indexB].v.Clone(),u=t.velocities[this.m_indexB].w,d=new c(i),f=new c(h);this.m_rA.Assign(A(d,this.m_localCenterA.Negate())),this.m_rB.Assign(A(f,this.m_localCenterB.Negate()));var p=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,y=this.m_invIB,v=new o;if(v.ex.x=p+m+g*this.m_rA.y*this.m_rA.y+y*this.m_rB.y*this.m_rB.y,v.ex.y=-g*this.m_rA.x*this.m_rA.y-y*this.m_rB.x*this.m_rB.y,v.ey.x=v.ex.y,v.ey.y=p+m+g*this.m_rA.x*this.m_rA.x+y*this.m_rB.x*this.m_rB.x,this.m_linearMass.Assign(v.GetInverse()),this.m_angularMass=g+y,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),this.m_linearError.x=a.x+this.m_rB.x-e.x-this.m_rA.x-(d.c*this.m_linearOffset.x-d.s*this.m_linearOffset.y),this.m_linearError.y=a.y+this.m_rB.y-e.y-this.m_rA.y-(d.s*this.m_linearOffset.x+d.c*this.m_linearOffset.y),this.m_angularError=h-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.Multiply(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var x=new r(this.m_linearImpulse.x,this.m_linearImpulse.y);n.Subtract(r.Multiply(p,x)),s-=g*(_(this.m_rA,x)+this.m_angularImpulse),l.Add(r.Multiply(m,x)),u+=y*(_(this.m_rB,x)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(l),t.velocities[this.m_indexB].w=u},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,c=this.m_invIA,h=this.m_invIB,l=t.step.dt,u=t.step.inv_dt,d=s-i+u*this.m_correctionFactor*this.m_angularError,f=-this.m_angularMass*d,m=this.m_angularImpulse,g=l*this.m_maxTorque;this.m_angularImpulse=B(this.m_angularImpulse+f,-g,g),i-=c*(f=this.m_angularImpulse-m),s+=h*f;d=new r(n.x+-s*this.m_rB.x-e.x- -i*this.m_rA.x+u*this.m_correctionFactor*this.m_linearError.x,n.y+s*this.m_rB.y-e.y-i*this.m_rA.y+u*this.m_correctionFactor*this.m_linearError.y),f=p(this.m_linearMass,d).Negate(),m=this.m_linearImpulse.Clone();this.m_linearImpulse.Add(f);g=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>g*g&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(g)),f.Assign(r.Subtract(this.m_linearImpulse,m)),e.Subtract(r.Multiply(o,f)),i-=c*_(this.m_rA,f),n.Add(r.Multiply(a,f)),s+=h*_(this.m_rB,f),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){return!0},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.linearOffset=this.m_linearOffset._serialize(),e.angularOffset=this.m_angularOffset,e.maxForce=this.m_maxForce,e.maxTorque=this.m_maxTorque,e.correctionFactor=this.m_correctionFactor,e}},Oe._extend(de);Be.prototype={Initialize:function(e,i,n,s,o,a,c){this.bodyA=e,this.bodyB=i,this.groundAnchorA.Assign(n),this.groundAnchorB.Assign(s),this.localAnchorA.Assign(this.bodyA.GetLocalPoint(o)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(a));var h=r.Subtract(o,n);this.lengthA=h.Length();var l=r.Subtract(a,s);this.lengthB=l.Length(),this.ratio=c,t(this.ratio>ze)},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.groundAnchorA._deserialize(t.groundAnchorA),this.groundAnchorB._deserialize(t.groundAnchorB),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.lengthA=t.lengthA,this.lengthB=t.lengthB,this.ratio=t.ratio}},Be._extend(_e),De.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){var e=r.Multiply(this.m_impulse,this.m_uB);return r.Multiply(t,e)},GetReactionTorque:function(t){return 0},GetGroundAnchorA:function(){return this.m_groundAnchorA},GetGroundAnchorB:function(){return this.m_groundAnchorB},GetLengthA:function(){return this.m_lengthA},GetLengthB:function(){return this.m_lengthB},GetRatio:function(){return this.m_ratio},GetCurrentLengthA:function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA),e=this.m_groundAnchorA;return r.Subtract(t,e).Length()},GetCurrentLengthB:function(){var t=this.m_bodyB.GetWorldPoint(this.m_localAnchorB),e=this.m_groundAnchorB;return r.Subtract(t,e).Length()},ShiftOrigin:function(t){this.m_groundAnchorA.Subtract(t),this.m_groundAnchorB.Subtract(t)},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c.Clone(),a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v.Clone(),l=t.velocities[this.m_indexB].w,u=new c(i),d=new c(a);this.m_rA.Assign(A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA))),this.m_rB.Assign(A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB))),this.m_uA.Assign(r.Add(e,r.Subtract(this.m_rA,this.m_groundAnchorA))),this.m_uB.Assign(r.Add(o,r.Subtract(this.m_rB,this.m_groundAnchorB)));var f=this.m_uA.Length(),p=this.m_uB.Length();f>10*Ue?this.m_uA.Multiply(1/f):this.m_uA.SetZero(),p>10*Ue?this.m_uB.Multiply(1/p):this.m_uB.SetZero();var m=_(this.m_rA,this.m_uA),g=_(this.m_rB,this.m_uB),y=this.m_invMassA+this.m_invIA*m*m,v=this.m_invMassB+this.m_invIB*g*g;if(this.m_mass=y+this.m_ratio*this.m_ratio*v,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var x=r.Multiply(-this.m_impulse,this.m_uA),C=r.Multiply(-this.m_ratio*this.m_impulse,this.m_uB);n.Add(r.Multiply(this.m_invMassA,x)),s+=this.m_invIA*_(this.m_rA,x),h.Add(r.Multiply(this.m_invMassB,C)),l+=this.m_invIB*_(this.m_rB,C)}else this.m_impulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=r.Add(e,f(i,this.m_rA)),a=r.Add(n,f(s,this.m_rB)),c=-u(this.m_uA,o)-this.m_ratio*u(this.m_uB,a),h=-this.m_mass*c;this.m_impulse+=h;var l=r.Multiply(-h,this.m_uA),d=r.Multiply(-this.m_ratio,r.Multiply(h,this.m_uB));e.Add(r.Multiply(this.m_invMassA,l)),i+=this.m_invIA*_(this.m_rA,l),n.Add(r.Multiply(this.m_invMassB,d)),s+=this.m_invIB*_(this.m_rB,d),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,o=new c(i),a=new c(s),h=A(o,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),l=A(a,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),u=r.Add(e,r.Subtract(h,this.m_groundAnchorA)),d=r.Add(n,r.Subtract(l,this.m_groundAnchorB)),f=u.Length(),p=d.Length();f>10*Ue?u.Multiply(1/f):u.SetZero(),p>10*Ue?d.Multiply(1/p):d.SetZero();var m=_(h,u),g=_(l,d),y=this.m_invMassA+this.m_invIA*m*m,v=this.m_invMassB+this.m_invIB*g*g,x=y+this.m_ratio*this.m_ratio*v;x>0&&(x=1/x);var C=this.m_constant-f-this.m_ratio*p,T=ri(C),b=-x*C,S=r.Multiply(-b,u),w=r.Multiply(-this.m_ratio,r.Multiply(b,d));return e.Add(r.Multiply(this.m_invMassA,S)),i+=this.m_invIA*_(h,S),n.Add(r.Multiply(this.m_invMassB,w)),s+=this.m_invIB*_(l,w),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,T<Ue},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.groundAnchorA=this.m_groundAnchorA._serialize(),e.groundAnchorB=this.m_groundAnchorB._serialize(),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.lengthA=this.m_lengthA,e.lengthB=this.m_lengthB,e.ratio=this.m_ratio,e}},De._extend(de),Me.prototype={_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.maxLength=t.maxLength}},Me._extend(_e),Le.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t*this.m_impulse,this.m_u)},GetReactionTorque:function(t){return 0},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},SetMaxLength:function(t){this.m_maxLength=t},GetMaxLength:function(){return this.m_maxLength},GetLimitState:function(){return this.m_state},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c.Clone(),a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v.Clone(),l=t.velocities[this.m_indexB].w,u=new c(i),d=new c(a);this.m_rA.Assign(A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA))),this.m_rB.Assign(A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB))),this.m_u.Assign(r.Subtract(r.Subtract(r.Add(o,this.m_rB),e),this.m_rA)),this.m_length=this.m_u.Length();var f=this.m_length-this.m_maxLength;if(this.m_state=f>0?de.e_atUpperLimit:de.e_inactiveLimit,!(this.m_length>Ue))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.Multiply(1/this.m_length);var p=_(this.m_rA,this.m_u),m=_(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!=g?1/g:0,t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var y=r.Multiply(this.m_impulse,this.m_u);n.Subtract(r.Multiply(this.m_invMassA,y)),s-=this.m_invIA*_(this.m_rA,y),h.Add(r.Multiply(this.m_invMassB,y)),l+=this.m_invIB*_(this.m_rB,y)}else this.m_impulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=r.Add(e,f(i,this.m_rA)),a=r.Add(n,f(s,this.m_rB)),c=this.m_length-this.m_maxLength,h=u(this.m_u,r.Subtract(a,o));c<0&&(h+=t.step.inv_dt*c);var l=-this.m_mass*h,d=this.m_impulse;this.m_impulse=si(0,this.m_impulse+l),l=this.m_impulse-d;var p=r.Multiply(l,this.m_u);e.Subtract(r.Multiply(this.m_invMassA,p)),i-=this.m_invIA*_(this.m_rA,p),n.Add(r.Multiply(this.m_invMassB,p)),s+=this.m_invIB*_(this.m_rB,p),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,o=new c(i),a=new c(s),h=A(o,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),l=A(a,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),u=r.Subtract(r.Subtract(r.Add(n,l),e),h),d=u.Normalize(),f=d-this.m_maxLength;f=B(f,0,.2);var p=-this.m_mass*f,m=r.Multiply(p,u);return e.Subtract(r.Multiply(this.m_invMassA,m)),i-=this.m_invIA*_(h,m),n.Add(r.Multiply(this.m_invMassB,m)),s+=this.m_invIB*_(l,m),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,d-this.m_maxLength<Ue},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.maxLength=this.m_maxLength,e}},Le._extend(de);var wi=Math.exp;Ne.prototype={Initialize:function(e){t(e.count>=3),this.m_count=e.count,this.m_ps=new Array(this.m_count),this.m_p0s=new Array(this.m_count),this.m_vs=new Array(this.m_count),this.m_ims=new Array(this.m_count);for(var i=0;i<this.m_count;++i){this.m_ps[i]=e.vertices[i].Clone(),this.m_p0s[i]=e.vertices[i].Clone(),this.m_vs[i]=new r;var n=e.masses[i];this.m_ims[i]=n>0?1/n:0}var s=this.m_count-1,o=this.m_count-2;this.m_Ls=new Array(s),this.m_as=new Array(o);for(i=0;i<s;++i){var a=this.m_ps[i],c=this.m_ps[i+1];this.m_Ls[i]=m(a,c)}for(i=0;i<o;++i){a=this.m_ps[i],c=this.m_ps[i+1];var h=this.m_ps[i+2],l=r.Subtract(c,a),d=r.Subtract(h,c),f=_(l,d),p=u(l,d);this.m_as[i]=ni(f,p)}this.m_gravity=e.gravity.Clone(),this.m_damping=e.damping,this.m_k2=e.k2,this.m_k3=e.k3},Step:function(t,e){if(0!=t){for(var i=wi(-t*this.m_damping),n=0;n<this.m_count;++n)this.m_p0s[n].Assign(this.m_ps[n]),this.m_ims[n]>0&&this.m_vs[n].Add(r.Multiply(t,this.m_gravity)),this.m_vs[n].Multiply(i),this.m_ps[n].Add(r.Multiply(t,this.m_vs[n]));for(n=0;n<e;++n)this.SolveC2(),this.SolveC3(),this.SolveC2();var s=1/t;for(n=0;n<this.m_count;++n)this.m_vs[n]=r.Multiply(s,r.Subtract(this.m_ps[n],this.m_p0s[n]))}},GetVertexCount:function(){return this.m_count},GetVertices:function(){return this.m_ps},Draw:function(t){for(var e=new D(.4,.5,.7),i=0;i<this.m_count-1;++i)t.DrawSegment(this.m_ps[i],this.m_ps[i+1],e)},SetAngle:function(t){for(var e=this.m_count-2,i=0;i<e;++i)this.m_as[i]=t},SolveC2:function(){for(var t=this.m_count-1,e=0;e<t;++e){var i=this.m_ps[e],n=this.m_ps[e+1],s=r.Subtract(n,i),o=s.Normalize(),a=this.m_ims[e],c=this.m_ims[e+1];if(a+c!=0){var h=a/(a+c),l=c/(a+c);i.Subtract(r.Multiply(this.m_k2*h*(this.m_Ls[e]-o),s)),n.Add(r.Multiply(this.m_k2*l*(this.m_Ls[e]-o),s))}}},SolveC3:function(){for(var t=this.m_count-2,e=0;e<t;++e){var i=this.m_ps[e],n=this.m_ps[e+1],s=this.m_ps[e+2],o=this.m_ims[e],a=this.m_ims[e+1],c=this.m_ims[e+2],h=r.Subtract(n,i),l=r.Subtract(s,n),d=h.LengthSquared(),f=l.LengthSquared();if(d*f!=0){var p=_(h,l),m=u(h,l),g=ni(p,m),y=r.Multiply(-1/d,h.Skew()),v=r.Multiply(1/f,l.Skew()),x=r.Negate(y),C=r.Subtract(y,v),T=v,b=o*u(x,x)+a*u(C,C)+c*u(T,T);if(0!=b){b=1/b;for(var A=g-this.m_as[e];A>Ve;)A=(g-=2*Ve)-this.m_as[e];for(;A<-Ve;)A=(g+=2*Ve)-this.m_as[e];var S=-this.m_k3*b*A;i.Add(r.Multiply(o*S,x)),n.Add(r.Multiply(a*S,C)),s.Add(r.Multiply(c*S,T))}}}}};var Ei={serialize:function(t){var e,i,n,r,s,o=[];for(n=t.GetBodyList();n;n=n.GetNext())for(r=n.GetFixtureList();r;r=r.GetNext())s=r.GetShape(),r.__temp_shape_id=o.length,o.push(s._serialize());var a=[];for(n=t.GetBodyList();n;n=n.GetNext())for(n.__temp_fixture_ids=[],r=n.GetFixtureList();r;r=r.GetNext())(i=r._serialize()).shape=r.__temp_shape_id,delete r.__temp_shape_id,n.__temp_fixture_ids.push(a.length),a.push(i);var c=[];for(n=t.GetBodyList();n;n=n.GetNext()){for((i=n._serialize()).fixtures=[],e=0;e<n.__temp_fixture_ids.length;++e)i.fixtures.push(n.__temp_fixture_ids[e]);delete n.__temp_fixture_ids,n.__temp_body_id=c.length,c.push(i)}var h,l=[];for(h=t.GetJointList(),e=0;h;h=h.GetNext(),++e)h.__temp_joint_id=e;for(h=t.GetJointList();h;h=h.GetNext())h.GetType()!==de.e_mouseJoint&&((i=h._serialize()).bodyA=h.GetBodyA().__temp_body_id,i.bodyB=h.GetBodyB().__temp_body_id,l.push(i));for(h=t.GetJointList();h;h=h.GetNext())delete h.__temp_joint_id;for(n=t.GetBodyList();n;n=n.GetNext())delete n.__temp_body_id;return{shapes:o,fixtures:a,bodies:c,joints:l}},deserialize:function(t,e,i){var n=JSON.parse(t);if(i){for(var r=e.GetBodyList();r;){var s=r.GetNext();e.DestroyBody(r),r=s}for(var o=e.GetJointList();o;){s=o.GetNext();e.DestroyJoint(o),o=s}}for(var a=[],c=0;c<n.shapes.length;++c){var h,l=n.shapes[c];switch(l.m_type){case F.e_circle:h=new k;break;case F.e_edge:h=new z;break;case F.e_chain:h=new V;break;case F.e_polygon:h=new G}h._deserialize(l),a.push(h)}var u=[];for(c=0;c<n.fixtures.length;++c){var _=n.fixtures[c],d=new Rt;d._deserialize(_),d.shape=a[_.shape],u.push(d)}var f=[];for(c=0;c<n.bodies.length;++c){var p=n.bodies[c],m=new wt;m._deserialize(p);for(var g=e.CreateBody(m),y=0;y<p.fixtures.length;++y)g.CreateFixture(u[p.fixtures[y]]);f.push(g)}var v=[],x=[];for(c=0;c<n.joints.length;++c){var C,T=n.joints[c];switch(T.type){case de.e_revoluteJoint:C=new fe;break;case de.e_prismaticJoint:C=new xe;break;case de.e_distanceJoint:C=new ye;break;case de.e_pulleyJoint:C=new Be;break;case de.e_gearJoint:C=new Ie;break;case de.e_wheelJoint:C=new we;break;case de.e_weldJoint:C=new Ae;break;case de.e_frictionJoint:C=new Te;break;case de.e_ropeJoint:C=new Me;break;case de.e_motorJoint:C=new Pe;break;default:throw new Error("unknown joint")}if(C._deserialize(T,f),T.type===de.e_gearJoint)x.push([C,v.length]),v.push(null);else{var b=e.CreateJoint(C);v.push(b)}}for(c=0;c<x.length;++c)x[c][0].joint1=v[x[c][0].joint1],x[c][0].joint2=v[x[c][0].joint2],b=e.CreateJoint(x[c][0]),v[x[c][1]]=b}},Ii=(function(){function t(t){return new r(t?t.x||0:0,t?t.y||0:0)}function e(t){for(var e=new Array(t.x.length),i=0;i<e.length;++i)e[i]=new r(t.x[i],t.y[i]);return e}function i(e,i){var n,r=e.name;if(void 0!==e.int)n=e.int;else if(void 0!==e.float)n=e.float;else if(void 0!==e.string)n=e.string;else if(void 0!==e.bool)n=e.bool;else{if(void 0===e.vec2)throw new Error("unknown property type");n=t(e.vec2)}if(i.hasOwnProperty(r))throw new Error("custom property possibly overwriting an existing one");i[r]=n}function n(n,r){var s=new Rt;s.density=n.density||0,s.filter.categoryBits=void 0===n["filter-categoryBits"]?1:n["filter-categoryBits"],s.filter.maskBits=void 0===n["filter-maskBits"]?65535:n["filter-maskBits"],s.filter.groupIndex=void 0===n["filter-groupIndex"]?0:n["filter-groupIndex"],s.friction=n.friction||0,s.restitution=n.restitution||0,s.isSensor=n.sensor||0;var o;if(void 0!==n.circle)(o=new k).m_p=t(n.circle.center),o.m_radius=n.circle.radius||0;else if(void 0!==n.polygon){var a=e(n.polygon.vertices);(o=new G).Set(a,a.length)}else{if(void 0===n.chain)throw new Error("unknown shape type");a=e(n.chain.vertices);(o=new V).m_count=a.length,o.m_vertices=a,(o.m_hasNextVertex=n.chain.hasNextVertex)&&(o.m_nextVertex=t(n.chain.nextVertex)),(o.m_hasPrevVertex=n.chain.hasPrevVertex)&&(o.m_prevVertex=t(n.chain.prevVertex))}s.shape=o;var c=r.CreateFixture(s);if(c.name=n.name,n.customProperties)for(var h=0;h<n.customProperties.length;++h)i(n,c)}function s(e,r){var s=new wt;s.type=e.type||Et.b2_staticBody,s.angle=e.angle||0,s.angularDamping=e.angularDamping||0,s.angularVelocity=e.angularVelocity||0,s.awake=e.awake||!1,s.bullet=e.bullet||!1,s.fixedRotation=e.fixedRotation||!1,s.linearDamping=e.linearDamping||!1,s.linearVelocity=t(e.linearVelocity),s.gravityScale=void 0!==e.gravityScale?e.gravityScale:1;var o=new N;o.mass=e["massData-mass"]||0,o.center=t(e["massData-center"]),o.I=e["massData-I"]||0,s.position=t(e.position);var a=r.CreateBody(s);if(a.name=e.name,a.SetMassData(o),e.fixture)for(var c=0;c<e.fixture.length;++c)n(e.fixture[c],a);if(e.customProperties)for(c=0;c<e.customProperties.length;++c)i(e,a);return a}function o(e,n,r){if(!a[e.type])throw new Error("unknown joint type");var s=new a[e.type];switch(s.type){case de.e_revoluteJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.enableLimit=e.enableLimit||!1,s.enableMotor=e.enableMotor||!1,s.lowerAngle=e.lowerLimit||0,s.maxMotorTorque=e.maxMotorTorque||0,s.motorSpeed=e.motorSpeed||0,s.referenceAngle=e.refAngle||0,s.upperAngle=e.upperLimit||0;break;case de.e_distanceJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.dampingRatio=e.dampingRatio||0,s.frequencyHz=e.frequency||0,s.length=e.length||0;break;case de.e_prismaticJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.enableLimit=e.enableLimit||!1,s.enableMotor=e.enableMotor||!1,s.localAxisA=t(e.localAxisA),s.lowerTranslation=e.lowerLimit||0,s.maxMotorForce=e.maxMotorForce||0,s.motorSpeed=e.motorSpeed||0,s.referenceAngle=e.refAngle||0,s.upperTranslation=e.upperLimit||0;break;case de.e_wheelJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.enableMotor=e.enableMotor||!1,s.localAxisA=t(e.localAxisA),s.maxMotorTorque=e.maxMotorTorque||0,s.motorSpeed=e.motorSpeed||0,s.dampingRatio=e.springDampingRatio||0,s.frequencyHz=e.springFrequency||0;break;case de.e_ropeJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.maxLength=e.maxLength||0;break;case de.e_motorJoint:s.linearOffset=t(e.anchorA),s.angularOffset=e.refAngle||0,s.maxForce=e.maxForce||0,s.maxTorque=e.maxTorque||0,s.correctionFactor=e.correctionFactor||0;break;case de.e_weldJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.referenceAngle=e.refAngle||0,s.dampingRatio=e.dampingRatio||0,s.frequencyHz=e.frequencyHz||0;break;case de.e_frictionJoint:s.localAnchorA=t(e.anchorA),s.localAnchorB=t(e.anchorB),s.maxForce=e.maxForce||0,s.maxTorque=e.maxTorque||0;break;default:throw new Error("wat?")}s.bodyA=r[e.bodyA||0],s.bodyB=r[e.bodyB||0],s.collideConnected=e.collideConnected||!1;var o=n.CreateJoint(s);if(o.name=e.name,e.customProperties)for(var c=0;c<e.customProperties.length;++c)i(e,o);return o}var a={revolute:fe,distance:ye,prismatic:xe,wheel:we,rope:Me,motor:Pe,weld:Ae,friction:Te};return{parseWorld:function(e,i){var n=new function(){this.world=null,this.positionIterations=0,this.velocityIterations=0,this.stepsPerSecond=0,this.fixtures={},this.bodies={},this.joints={},Object.seal(this)};n.world=i=i||new Wt(new r(0,0)),n.positionIterations=e.positionIterations||0,n.velocityIterations=e.velocityIterations||0,n.stepsPerSecond=e.stepsPerSecond||0,e.gravity&&i.SetGravity(t(e.gravity)),i.SetAllowSleeping(e.allowSleep||!1),i.SetAutoClearForces(e.autoClearForces||!1),i.SetWarmStarting(e.warmStarting||!1),i.SetContinuousPhysics(e.continuousPhysics||!1),i.SetSubStepping(e.subStepping||!1);var a=[],c=e.body;if(c)for(var h=0;h<c.length;++h){var l=s(c[h],i);a.push(l);for(var u=l.GetFixtureList();u;u=u.GetNext())n.fixtures[u.name]||(n.fixtures[u.name]=[]),n.fixtures[u.name].push(u);n.bodies[l.name]||(n.bodies[l.name]=[]),n.bodies[l.name].push(l)}var _=[],d=e.joint;if(d)for(h=0;h<d.length;++h){var f=o(d[h],i,a);_.push(f),n.joints[f.name]||(n.joints[f.name]=[]),n.joints[f.name].push(f)}return n}}})(),Ri=[{trimmed:"version",name:"b2_version",def:Ze},{trimmed:"Vec2",name:"b2Vec2",def:r},{trimmed:"Vec3",name:"b2Vec3",def:s},{trimmed:"Mat22",name:"b2Mat22",def:o},{trimmed:"Mat33",name:"b2Mat33",def:a},{trimmed:"Rot",name:"b2Rot",def:c},{trimmed:"Transform",name:"b2Transform",def:h},{trimmed:"Sweep",name:"b2Sweep",def:l},{trimmed:"Dot_v2_v2",name:"b2Dot_v2_v2",def:u},{trimmed:"Cross_v2_v2",name:"b2Cross_v2_v2",def:_},{trimmed:"Cross_v2_f",name:"b2Cross_v2_f",def:d},{trimmed:"Cross_f_v2",name:"b2Cross_f_v2",def:f},{trimmed:"Mul_m22_v2",name:"b2Mul_m22_v2",def:p},{trimmed:"MulT_m22_v2",name:"b2MulT_m22_v2",def:function(t,e){return new r(u(e,t.ex),u(e,t.ey))}},{trimmed:"Distance",name:"b2Distance",def:m},{trimmed:"DistanceSquared",name:"b2DistanceSquared",def:g},{trimmed:"Dot_v3_v3",name:"b2Dot_v3_v3",def:y},{trimmed:"Cross_v3_v3",name:"b2Cross_v3_v3",def:v},{trimmed:"Mul_m22_m22",name:"b2Mul_m22_m22",def:function(t,e){return new o(p(t,e.ex),p(t,e.ey))}},{trimmed:"MulT_m22_m22",name:"b2MulT_m22_m22",def:function(t,e){return new o(new r(u(t.ex,e.ex),u(t.ey,e.ex)),new r(u(t.ex,e.ey),u(t.ey,e.ey)))}},{trimmed:"Mul_m33_v3",name:"b2Mul_m33_v3",def:x},{trimmed:"Mul22_m33_v2",name:"b2Mul22_m33_v2",def:C},{trimmed:"Mul_r_r",name:"b2Mul_r_r",def:T},{trimmed:"MulT_r_r",name:"b2MulT_r_r",def:b},{trimmed:"Mul_r_v2",name:"b2Mul_r_v2",def:A},{trimmed:"MulT_r_v2",name:"b2MulT_r_v2",def:S},{trimmed:"Mul_t_v2",name:"b2Mul_t_v2",def:w},{trimmed:"Min_v2",name:"b2Min_v2",def:P},{trimmed:"Max_v2",name:"b2Max_v2",def:O},{trimmed:"Clamp",name:"b2Clamp",def:B},{trimmed:"MulT_t_v2",name:"b2MulT_t_v2",def:E},{trimmed:"Mul_t_t",name:"b2Mul_t_t",def:function(t,e){var i=new h;return i.q=T(t.q,e.q),i.p=r.Add(A(t.q,e.p),t.p),i}},{trimmed:"MulT_t_t",name:"b2MulT_t_t",def:I},{trimmed:"Clamp_v2",name:"b2Clamp_v2",def:function(t,e,i){return O(e,P(t,i))}},{trimmed:"NextPowerOfTwo",name:"b2NextPowerOfTwo",def:function(t){return t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,1+(t|=t>>16)}},{trimmed:"Abs_v2",name:"b2Abs_v2",def:R},{trimmed:"Abs_m22",name:"b2Abs_m22",def:function(t){return new o(R(t.ex),R(t.ey))}},{trimmed:"IsPowerOfTwo",name:"b2IsPowerOfTwo",def:function(t){return t>0&&0==(t&t-1)}},{trimmed:"RandomFloat",name:"b2RandomFloat",def:function(t,e){var i=Math.random();return i=void 0!==t?(e-t)*i+t:2*i-1}},{trimmed:"Timer",name:"b2Timer",def:L},{trimmed:"Color",name:"b2Color",def:D},{trimmed:"Draw",name:"b2Draw",def:M},{trimmed:"ContactID",name:"b2ContactID",def:K},{trimmed:"ManifoldPoint",name:"b2ManifoldPoint",def:$},{trimmed:"Manifold",name:"b2Manifold",def:tt},{trimmed:"WorldManifold",name:"b2WorldManifold",def:et},{trimmed:"GetPointStates",name:"b2GetPointStates",def:function(t,e,i,n){for(var r=0;r<Ge;++r)t[r]=tt.b2_nullState,e[r]=tt.b2_nullState;for(r=0;r<i.pointCount;++r){var s=i.points[r].id;t[r]=tt.b2_removeState;for(var o=0;o<n.pointCount;++o)if(n.points[o].id.Get()==s.Get()){t[r]=tt.b2_persistState;break}}for(r=0;r<n.pointCount;++r)for(s=n.points[r].id,e[r]=tt.b2_addState,o=0;o<i.pointCount;++o)if(i.points[o].id.Get()==s.Get()){e[r]=tt.b2_persistState;break}}},{trimmed:"ClipVertex",name:"b2ClipVertex",def:it},{trimmed:"RayCastInput",name:"b2RayCastInput",def:nt},{trimmed:"RayCastOutput",name:"b2RayCastOutput",def:rt},{trimmed:"AABB",name:"b2AABB",def:st},{trimmed:"CollideCircles",name:"b2CollideCircles",def:ot},{trimmed:"CollidePolygonAndCircle",name:"b2CollidePolygonAndCircle",def:at},{trimmed:"FindMaxSeparation",name:"b2FindMaxSeparation",def:ct},{trimmed:"FindIncidentEdge",name:"b2FindIncidentEdge",def:ht},{trimmed:"CollidePolygons",name:"b2CollidePolygons",def:lt},{trimmed:"CollideEdgeAndCircle",name:"b2CollideEdgeAndCircle",def:ut},{trimmed:"EPAxis",name:"b2EPAxis",def:_t},{trimmed:"TempPolygon",name:"b2TempPolygon",def:dt},{trimmed:"ReferenceFace",name:"b2ReferenceFace",def:ft},{trimmed:"EPCollider",name:"b2EPCollider",def:pt},{trimmed:"CollideEdgeAndPolygon",name:"b2CollideEdgeAndPolygon",def:mt},{trimmed:"ClipSegmentToLine",name:"b2ClipSegmentToLine",def:gt},{trimmed:"TestShapeOverlap",name:"b2TestShapeOverlap",def:yt},{trimmed:"TestOverlap",name:"b2TestOverlap",def:vt},{trimmed:"Shape",name:"b2Shape",def:F},{trimmed:"CircleShape",name:"b2CircleShape",def:k},{trimmed:"EdgeShape",name:"b2EdgeShape",def:z},{trimmed:"ChainShape",name:"b2ChainShape",def:V},{trimmed:"PolygonShape",name:"b2PolygonShape",def:G},{trimmed:"Pair",name:"b2Pair",def:W},{trimmed:"PairLessThan",name:"b2PairLessThan",def:U},{trimmed:"BroadPhase",name:"b2BroadPhase",def:j},{trimmed:"DistanceProxy",name:"b2DistanceProxy",def:X},{trimmed:"SimplexCache",name:"b2SimplexCache",def:Y},{trimmed:"DistanceInput",name:"b2DistanceInput",def:H},{trimmed:"DistanceOutput",name:"b2DistanceOutput",def:q},{trimmed:"SimplexVertex",name:"b2SimplexVertex",def:J},{trimmed:"Simplex",name:"b2Simplex",def:Z},{trimmed:"DistanceFunc",name:"b2DistanceFunc",def:Q},{trimmed:"TreeNode",name:"b2TreeNode",def:xt},{trimmed:"DynamicTree",name:"b2DynamicTree",def:Ct},{trimmed:"TOIInput",name:"b2TOIInput",def:Tt},{trimmed:"TOIOutput",name:"b2TOIOutput",def:bt},{trimmed:"SeparationFunction",name:"b2SeparationFunction",def:At},{trimmed:"TimeOfImpact",name:"b2TimeOfImpact",def:St},{trimmed:"BodyDef",name:"b2BodyDef",def:wt},{trimmed:"Body",name:"b2Body",def:Et},{trimmed:"Filter",name:"b2Filter",def:It},{trimmed:"FixtureDef",name:"b2FixtureDef",def:Rt},{trimmed:"Fixture",name:"b2Fixture",def:Ot},{trimmed:"DestructionListener",name:"b2DestructionListener",def:Bt},{trimmed:"ContactFilter",name:"b2ContactFilter",def:Dt},{trimmed:"ContactImpulse",name:"b2ContactImpulse",def:Mt},{trimmed:"ContactListener",name:"b2ContactListener",def:Lt},{trimmed:"QueryCallback",name:"b2QueryCallback",def:Nt},{trimmed:"RayCastCallback",name:"b2RayCastCallback",def:Ft},{trimmed:"TimeStep",name:"b2TimeStep",def:kt},{trimmed:"Position",name:"b2Position",def:zt},{trimmed:"Velocity",name:"b2Velocity",def:Vt},{trimmed:"SolverData",name:"b2SolverData",def:Gt},{trimmed:"World",name:"b2World",def:Wt},{trimmed:"MixFriction",name:"b2MixFriction",def:Xt},{trimmed:"MixRestitution",name:"b2MixRestitution",def:Yt},{trimmed:"ContactRegister",name:"b2ContactRegister",def:Ht},{trimmed:"ContactEdge",name:"b2ContactEdge",def:qt},{trimmed:"Contact",name:"b2Contact",def:Jt},{trimmed:"CircleContact",name:"b2CircleContact",def:Zt},{trimmed:"PolygonContact",name:"b2PolygonContact",def:ie},{trimmed:"ChainAndCircleContact",name:"b2ChainAndCircleContact",def:Qt},{trimmed:"ChainAndPolygonContact",name:"b2ChainAndPolygonContact",def:Kt},{trimmed:"EdgeAndCircleContact",name:"b2EdgeAndCircleContact",def:$t},{trimmed:"EdgeAndPolygonContact",name:"b2EdgeAndPolygonContact",def:te},{trimmed:"PolygonAndCircleContact",name:"b2PolygonAndCircleContact",def:ee},{trimmed:"defaultFilter",name:"b2_defaultFilter",def:xi},{trimmed:"defaultListener",name:"b2_defaultListener",def:Ci},{trimmed:"ContactManager",name:"b2ContactManager",def:ne},{trimmed:"VelocityConstraintPoint",name:"b2VelocityConstraintPoint",def:re},{trimmed:"ContactPositionConstraint",name:"b2ContactPositionConstraint",def:se},{trimmed:"ContactVelocityConstraint",name:"b2ContactVelocityConstraint",def:oe},{trimmed:"PositionSolverManifold",name:"b2PositionSolverManifold",def:ae},{trimmed:"ContactSolverDef",name:"b2ContactSolverDef",def:ce},{trimmed:"ContactSolver",name:"b2ContactSolver",def:he},{trimmed:"Island",name:"b2Island",def:le},{trimmed:"Jacobian",name:"b2Jacobian",def:function(){this.linear=new r,this.angularA=0,this.angularB=0}},{trimmed:"JointEdge",name:"b2JointEdge",def:ue},{trimmed:"JointDef",name:"b2JointDef",def:_e},{trimmed:"Joint",name:"b2Joint",def:de},{trimmed:"RevoluteJointDef",name:"b2RevoluteJointDef",def:fe},{trimmed:"RevoluteJoint",name:"b2RevoluteJoint",def:pe},{trimmed:"MouseJointDef",name:"b2MouseJointDef",def:me},{trimmed:"MouseJoint",name:"b2MouseJoint",def:ge},{trimmed:"DistanceJointDef",name:"b2DistanceJointDef",def:ye},{trimmed:"DistanceJoint",name:"b2DistanceJoint",def:ve},{trimmed:"PrismaticJointDef",name:"b2PrismaticJointDef",def:xe},{trimmed:"PrismaticJoint",name:"b2PrismaticJoint",def:Ce},{trimmed:"FrictionJointDef",name:"b2FrictionJointDef",def:Te},{trimmed:"FrictionJoint",name:"b2FrictionJoint",def:be},{trimmed:"WeldJointDef",name:"b2WeldJointDef",def:Ae},{trimmed:"WeldJoint",name:"b2WeldJoint",def:Se},{trimmed:"WheelJointDef",name:"b2WheelJointDef",def:we},{trimmed:"WheelJoint",name:"b2WheelJoint",def:Ee},{trimmed:"GearJointDef",name:"b2GearJointDef",def:Ie},{trimmed:"GearJoint",name:"b2GearJoint",def:Re},{trimmed:"MotorJointDef",name:"b2MotorJointDef",def:Pe},{trimmed:"MotorJoint",name:"b2MotorJoint",def:Oe},{trimmed:"PulleyJointDef",name:"b2PulleyJointDef",def:Be},{trimmed:"PulleyJoint",name:"b2PulleyJoint",def:De},{trimmed:"RopeJointDef",name:"b2RopeJointDef",def:Me},{trimmed:"RopeJoint",name:"b2RopeJoint",def:Le},{trimmed:"RopeDef",name:"b2RopeDef",def:function(){this.vertices=null,this.count=0,this.masses=null,this.gravity=new r,this.damping=.1,this.k2=.9,this.k3=.1}},{trimmed:"Rope",name:"b2Rope",def:Ne},{trimmed:"maxManifoldPoints",name:"b2_maxManifoldPoints",def:Ge},{trimmed:"maxPolygonVertices",name:"b2_maxPolygonVertices",def:We},{trimmed:"aabbExtension",name:"b2_aabbExtension",def:.1},{trimmed:"aabbMultiplier",name:"b2_aabbMultiplier",def:2},{trimmed:"linearSlop",name:"b2_linearSlop",def:Ue},{trimmed:"angularSlop",name:"b2_angularSlop",def:je},{trimmed:"polygonRadius",name:"b2_polygonRadius",def:Xe},{trimmed:"maxSubSteps",name:"b2_maxSubSteps",def:8},{trimmed:"maxTOIContacts",name:"b2_maxTOIContacts",def:32},{trimmed:"velocityThreshold",name:"b2_velocityThreshold",def:1},{trimmed:"maxLinearCorrection",name:"b2_maxLinearCorrection",def:.2},{trimmed:"maxAngularCorrection",name:"b2_maxAngularCorrection",def:Ye},{trimmed:"maxTranslation",name:"b2_maxTranslation",def:2},{trimmed:"maxTranslationSquared",name:"b2_maxTranslationSquared",def:4},{trimmed:"maxRotation",name:"b2_maxRotation",def:He},{trimmed:"maxRotationSquared",name:"b2_maxRotationSquared",def:qe},{trimmed:"baumgarte",name:"b2_baumgarte",def:.2},{trimmed:"toiBaugarte",name:"b2_toiBaugarte",def:.75},{trimmed:"timeToSleep",name:"b2_timeToSleep",def:.5},{trimmed:"linearSleepTolerance",name:"b2_linearSleepTolerance",def:.01},{trimmed:"angularSleepTolerance",name:"b2_angularSleepTolerance",def:Je},{trimmed:"epsilon",name:"b2_epsilon",def:ze},{trimmed:"JsonSerializer",name:"b2JsonSerializer",def:Ei},{trimmed:"RUBELoader",name:"b2RUBELoader",def:Ii},{trimmed:"Profiler",name:"b2Profiler",def:Fe}];if("undefined"!=typeof b2_compatibility&&"undefined"!=typeof window)for(var Pi=0;Pi<Ri.length;++Pi)window[Ri[Pi].name]=Ri[Pi].def;else{var Oi={};for(Pi=0;Pi<Ri.length;++Pi)Oi[Ri[Pi].trimmed]=Ri[Pi].def;void 0!==e?e.exports=Oi:window.b2=Oi}})()}),{}],311:[(function(t,e,i){Object.create=Object.create||function(t){function e(){}return e.prototype=t,new e};var n,r,s=function(t,e){if(!t)throw new Error("Assertion failed: "+e)},o=function(t,e){!t&&console&&console.warn&&(console.warn("ASSERTION FAILED: "+e),console.trace&&console.trace())},a=function(t,e){return t<e?t:e},c=function(t,e){return t>e?t:e};"object"==typeof window&&window.navigator.userAgent.indexOf("Firefox")>-1?(n=Math.min,r=Math.max):(n=a,r=c);var h=function(t,e){return t<e?t+" "+e:e+" "+t},l=function(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return t[i]=t[t.length-1],void t.length--},u=function(t,e,i,n,r,s){var o=i-r,a=n-s,c=g(C(o,a,t-r,e-s)/L(o,a));return new y(r+o*c,s+a*c)};cp.momentForCircle=function(t,e,i,n){return t*(.5*(e*e+i*i)+M(n))},cp.areaForCircle=function(t,e){return Math.PI*Math.abs(t*t-e*e)},cp.momentForSegment=function(t,e,i){var n=E(A(e,i),.5);return t*(G(i,e)/12+M(n))},cp.areaForSegment=function(t,e,i){return i*(Math.PI*i+2*V(t,e))},cp.momentForPoly=function(t,e,i){for(var n=0,r=0,s=e.length,o=0;o<s;o+=2){var a=e[o]+i.x,c=e[o+1]+i.y,h=e[(o+2)%s]+i.x,l=e[(o+3)%s]+i.y,u=R(h,l,a,c);n+=u*(C(a,c,a,c)+C(a,c,h,l)+C(h,l,h,l)),r+=u}return t*n/(6*r)},cp.areaForPoly=function(t){for(var e=0,i=0,n=t.length;i<n;i+=2)e+=I(new y(t[i],t[i+1]),new y(t[(i+2)%n],t[(i+3)%n]));return-e/2},cp.centroidForPoly=function(t){for(var e=0,i=new y(0,0),n=0,r=t.length;n<r;n+=2){var s=new y(t[n],t[n+1]),o=new y(t[(n+2)%r],t[(n+3)%r]),a=I(s,o);e+=a,i=A(i,E(A(s,o),a))}return E(i,1/(3*e))},cp.recenterPoly=function(t){for(var e=cp.centroidForPoly(t),i=0;i<t.length;i+=2)t[i]-=e.x,t[i+1]-=e.y},cp.momentForBox=function(t,e,i){return t*(e*e+i*i)/12},cp.momentForBox2=function(t,e){var i=e.r-e.l,n=e.t-e.b,r=E([e.l+e.r,e.b+e.t],.5);return cp.momentForBox(t,i,n)+t*M(r)};var _=cp.loopIndexes=function(t){var e,i,n,r,s=0,o=0;e=n=t[0],i=r=t[1];for(var a=t.length>>1,c=1;c<a;c++){var h=t[2*c],l=t[2*c+1];h<e||h==e&&l<i?(e=h,i=l,s=c):(h>n||h==n&&l>r)&&(n=h,r=l,o=c)}return[s,o]},d=function(t,e,i){var n=t[2*e];t[2*e]=t[2*i],t[2*i]=n,n=t[2*e+1],t[2*e+1]=t[2*i+1],t[2*i+1]=n},f=function(t,e,i,n,r,s){if(0===i)return 0;for(var o=0,a=e,c=S(r,n),h=s*T(c),l=e,u=e+i-1;l<=u;){var _=new y(t[2*l],t[2*l+1]),f=I(c,S(_,n));f>h?(f>o&&(o=f,a=l),l++):(d(t,l,u),u--)}return a!=e&&d(t,e,a),l-e},p=function(t,e,i,n,r,s,o,a){if(n<0)return 0;if(0==n)return e[2*a]=s.x,e[2*a+1]=s.y,1;var c=f(e,i,n,r,s,t),h=new y(e[2*i],e[2*i+1]),l=p(t,e,i+1,c-1,r,h,s,a),u=a+l++;e[2*u]=s.x,e[2*u+1]=s.y;var _=f(e,i+c,n-c,s,o,t),d=new y(e[2*(i+c)],e[2*(i+c)+1]);return l+p(t,e,i+c+1,_-1,s,d,o,a+l)};cp.convexHull=function(t,e,i){if(e)for(var n=0;n<t.length;n++)e[n]=t[n];else e=t;var r=_(t),s=r[0],a=r[1];if(s==a)return e.length=2,e;d(e,0,s),d(e,1,0==a?s:a);var c=new y(e[0],e[1]),h=new y(e[2],e[3]),l=t.length>>1,u=p(i,e,2,l-2,c,h,c,1)+1;return e.length=2*u,o($(e),"Internal error: cpConvexHull() and cpPolyValidate() did not agree.Please report this error with as much info as you can."),e};var m=function(t,e,i){return n(r(t,e),i)},g=function(t){return r(0,n(t,1))},y=cp.Vect=function(t,e){this.x=t,this.y=e};cp.v=function(t,e){return new y(t,e)};var v=cp.vzero=new y(0,0),x=cp.v.dot=function(t,e){return t.x*e.x+t.y*e.y},C=function(t,e,i,n){return t*i+e*n},T=cp.v.len=function(t){return Math.sqrt(x(t,t))},b=cp.v.len2=function(t,e){return Math.sqrt(t*t+e*e)},A=(cp.v.eql=function(t,e){return t.x===e.x&&t.y===e.y},cp.v.add=function(t,e){return new y(t.x+e.x,t.y+e.y)});y.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this};var S=cp.v.sub=function(t,e){return new y(t.x-e.x,t.y-e.y)};y.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this};var w=cp.v.neg=function(t){return new y(-t.x,-t.y)};y.prototype.neg=function(){return this.x=-this.x,this.y=-this.y,this};var E=cp.v.mult=function(t,e){return new y(t.x*e,t.y*e)};y.prototype.mult=function(t){return this.x*=t,this.y*=t,this};var I=cp.v.cross=function(t,e){return t.x*e.y-t.y*e.x},R=function(t,e,i,n){return t*n-e*i},P=cp.v.perp=function(t){return new y(-t.y,t.x)},O=(cp.v.pvrperp=function(t){return new y(t.y,-t.x)},cp.v.project=function(t,e){return E(e,x(t,e)/M(e))});y.prototype.project=function(t){return this.mult(x(this,t)/M(t)),this};var B=cp.v.rotate=function(t,e){return new y(t.x*e.x-t.y*e.y,t.x*e.y+t.y*e.x)};y.prototype.rotate=function(t){return this.x=this.x*t.x-this.y*t.y,this.y=this.x*t.y+this.y*t.x,this};var D=cp.v.unrotate=function(t,e){return new y(t.x*e.x+t.y*e.y,t.y*e.x-t.x*e.y)},M=cp.v.lengthsq=function(t){return x(t,t)},L=cp.v.lengthsq2=function(t,e){return t*t+e*e},N=cp.v.lerp=function(t,e,i){return A(E(t,1-i),E(e,i))},F=cp.v.normalize=function(t){return E(t,1/T(t))},k=cp.v.normalize_safe=function(t){return 0===t.x&&0===t.y?v:F(t)},z=cp.v.clamp=function(t,e){return x(t,t)>e*e?E(F(t),e):t},V=(cp.v.lerpconst=function(t,e,i){return A(t,z(S(e,t),i))},cp.v.dist=function(t,e){return T(S(t,e))}),G=cp.v.distsq=function(t,e){return M(S(t,e))},W=(cp.v.near=function(t,e,i){return G(t,e)<i*i},cp.v.slerp=function(t,e,i){var n=Math.acos(x(t,e));if(n){var r=1/Math.sin(n);return A(E(t,Math.sin((1-i)*n)*r),E(e,Math.sin(i*n)*r))}return t}),U=(cp.v.slerpconst=function(t,e,i){var r=Math.acos(x(t,e));return W(t,e,n(i,r)/r)},cp.v.forangle=function(t){return new y(Math.cos(t),Math.sin(t))},cp.v.toangle=function(t){return Math.atan2(t.y,t.x)},cp.v.str=function(t){return"("+t.x.toFixed(3)+", "+t.y.toFixed(3)+")"},cp.BB=function(t,e,i,n){this.l=t,this.b=e,this.r=i,this.t=n,0});cp.bb=function(t,e,i,n){return new U(t,e,i,n)};var j=function(t,e){return new U(t.x-e,t.y-e,t.x+e,t.y+e)},X=0,Y=(cp.NO_GROUP=0,cp.ALL_LAYERS=-1);cp.resetShapeIdCounter=function(){X=0};var H=cp.Shape=function(t){this.body=t,this.bb_l=this.bb_b=this.bb_r=this.bb_t=0,this.hashid=X++,this.sensor=!1,this.e=0,this.u=0,this.surface_v=v,this.collision_type=0,this.group=0,this.layers=Y,this.space=null,this.collisionCode=this.collisionCode};H.prototype.setElasticity=function(t){this.e=t},H.prototype.setFriction=function(t){this.body.activate(),this.u=t},H.prototype.setLayers=function(t){this.body.activate(),this.layers=t},H.prototype.setSensor=function(t){this.body.activate(),this.sensor=t},H.prototype.setCollisionType=function(t){this.body.activate(),this.collision_type=t},H.prototype.getBody=function(){return this.body},H.prototype.active=function(){return this.body&&-1!==this.body.shapeList.indexOf(this)},H.prototype.setBody=function(t){s(!this.active(),"You cannot change the body on an active shape. You must remove the shape from the space before changing the body."),this.body=t},H.prototype.cacheBB=function(){return this.update(this.body.p,this.body.rot)},H.prototype.update=function(t,e){s(!isNaN(e.x),"Rotation is NaN"),s(!isNaN(t.x),"Position is NaN"),this.cacheData(t,e)},H.prototype.pointQuery=function(t){var e=this.nearestPointQuery(t);if(e.d<0)return e},H.prototype.getBB=function(){return new U(this.bb_l,this.bb_b,this.bb_r,this.bb_t)};var q=function(t,e,i){this.shape=t,this.p=e,this.d=i},J=function(t,e,i){this.shape=t,this.t=e,this.n=i};J.prototype.hitPoint=function(t,e){return N(t,e,this.t)},J.prototype.hitDist=function(t,e){return V(t,e)*this.t};var Z=cp.CircleShape=function(t,e,i){this.c=this.tc=i,this.r=e,this.type="circle",H.call(this,t)};Z.prototype=Object.create(H.prototype),Z.prototype.cacheData=function(t,e){var i=this.tc=B(this.c,e).add(t),n=this.r;this.bb_l=i.x-n,this.bb_b=i.y-n,this.bb_r=i.x+n,this.bb_t=i.y+n},Z.prototype.nearestPointQuery=function(t){var e=t.x-this.tc.x,i=t.y-this.tc.y,n=b(e,i),r=this.r,s=new y(this.tc.x+e*r/n,this.tc.y+i*r/n);return new q(this,s,n-r)};var Q=function(t,e,i,n,r,s){n=S(n,e),r=S(r,e);var o=x(n,n)-2*x(n,r)+x(r,r),a=-2*x(n,n)+2*x(n,r),c=a*a-4*o*(x(n,n)-i*i);if(c>=0){var h=(-a-Math.sqrt(c))/(2*o);if(0<=h&&h<=1)return new J(t,h,F(N(n,r,h)))}};Z.prototype.segmentQuery=function(t,e){return Q(this,this.tc,this.r,t,e)};var K=cp.SegmentShape=function(t,e,i,n){this.a=e,this.b=i,this.n=P(F(S(i,e))),this.ta=this.tb=this.tn=null,this.r=n,this.a_tangent=v,this.b_tangent=v,this.type="segment",H.call(this,t)};K.prototype=Object.create(H.prototype),K.prototype.cacheData=function(t,e){this.ta=A(t,B(this.a,e)),this.tb=A(t,B(this.b,e)),this.tn=B(this.n,e);var i,n,r,s;this.ta.x<this.tb.x?(i=this.ta.x,n=this.tb.x):(i=this.tb.x,n=this.ta.x),this.ta.y<this.tb.y?(r=this.ta.y,s=this.tb.y):(r=this.tb.y,s=this.ta.y);var o=this.r;this.bb_l=i-o,this.bb_b=r-o,this.bb_r=n+o,this.bb_t=s+o},K.prototype.nearestPointQuery=function(t){var e=(function(t,e,i){var n=S(e,i),r=g(x(n,S(t,i))/M(n));return A(i,E(n,r))})(t,this.ta,this.tb),i=t.x-e.x,n=t.y-e.y,r=b(i,n),s=this.r,o=r?A(e,E(new y(i,n),s/r)):e;return new q(this,o,r-s)},K.prototype.segmentQuery=function(t,e){var i=this.tn,n=x(S(this.ta,t),i),r=this.r,s=n>0?w(i):i,o=S(E(s,r),t),a=A(this.ta,o),c=A(this.tb,o),h=S(e,t);if(I(h,a)*I(h,c)<=0){var l=n+(n>0?-r:r),u=-l,_=x(h,i)-l;if(u*_<0)return new J(this,u/(u-_),s)}else if(0!==r){var d=Q(this,this.ta,this.r,t,e),f=Q(this,this.tb,this.r,t,e);return d?f&&f.t<d.t?f:d:f}},K.prototype.setNeighbors=function(t,e){this.a_tangent=S(t,this.a),this.b_tangent=S(e,this.b)},K.prototype.setEndpoints=function(t,e){this.a=t,this.b=e,this.n=P(F(S(e,t)))};var $=function(t){for(var e=t.length,i=0;i<e;i+=2){var n=t[i],r=t[i+1],s=t[(i+2)%e],o=t[(i+3)%e],a=t[(i+4)%e],c=t[(i+5)%e];if(R(s-n,o-r,a-s,c-o)>0)return!1}return!0},tt=cp.PolyShape=function(t,e,i){this.setVerts(e,i),this.type="poly",H.call(this,t)};tt.prototype=Object.create(H.prototype);var et=function(t,e){this.n=t,this.d=e};et.prototype.compare=function(t){return x(this.n,t)-this.d},tt.prototype.setVerts=function(t,e){s(t.length>=4,"Polygons require some verts"),s("number"==typeof t[0],"Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])"),s($(t),"Polygon is concave or has a reversed winding. Consider using cpConvexHull()");var i=t.length,n=i>>1;this.verts=new Array(i),this.tVerts=new Array(i),this.planes=new Array(n),this.tPlanes=new Array(n);for(var r=0;r<i;r+=2){var o=t[r]+e.x,a=t[r+1]+e.y,c=t[(r+2)%i]+e.x,h=t[(r+3)%i]+e.y,l=F(P(new y(c-o,h-a)));this.verts[r]=o,this.verts[r+1]=a,this.planes[r>>1]=new et(l,C(l.x,l.y,o,a)),this.tPlanes[r>>1]=new et(new y(0,0),0)}};cp.BoxShape=function(t,e,i){var n=e/2,r=i/2;return it(t,new U(-n,-r,n,r))};var it=cp.BoxShape2=function(t,e){var i=[e.l,e.b,e.l,e.t,e.r,e.t,e.r,e.b];return new tt(t,i,v)};tt.prototype.transformVerts=function(t,e){for(var i=this.verts,s=this.tVerts,o=1/0,a=-1/0,c=1/0,h=-1/0,l=0;l<i.length;l+=2){var u=i[l],_=i[l+1],d=t.x+u*e.x-_*e.y,f=t.y+u*e.y+_*e.x;s[l]=d,s[l+1]=f,o=n(o,d),a=r(a,d),c=n(c,f),h=r(h,f)}this.bb_l=o,this.bb_b=c,this.bb_r=a,this.bb_t=h},tt.prototype.transformAxes=function(t,e){for(var i=this.planes,n=this.tPlanes,r=0;r<i.length;r++){var s=B(i[r].n,e);n[r].n=s,n[r].d=x(t,s)+i[r].d}},tt.prototype.cacheData=function(t,e){this.transformAxes(t,e),this.transformVerts(t,e)},tt.prototype.nearestPointQuery=function(t){for(var e=this.tPlanes,i=this.tVerts,n=i[i.length-2],r=i[i.length-1],s=1/0,o=v,a=!1,c=0;c<e.length;c++){e[c].compare(t)>0&&(a=!0);var h=i[2*c],l=i[2*c+1],_=u(t.x,t.y,n,r,h,l),d=V(t,_);d<s&&(s=d,o=_),n=h,r=l}return new q(this,o,a?s:-s)},tt.prototype.segmentQuery=function(t,e){for(var i=this.tPlanes,n=this.tVerts,r=i.length,s=2*r,o=0;o<r;o++){var a=i[o].n,c=x(t,a);if(!(i[o].d>c)){var h=x(e,a),l=(i[o].d-c)/(h-c);if(!(l<0||1<l)){var u=N(t,e,l),_=-I(a,u),d=-R(a.x,a.y,n[2*o],n[2*o+1]),f=-R(a.x,a.y,n[(2*o+2)%s],n[(2*o+3)%s]);if(d<=_&&_<=f)return new J(this,l,a)}}}},tt.prototype.valueOnAxis=function(t,e){for(var i=this.tVerts,r=C(t.x,t.y,i[0],i[1]),s=2;s<i.length;s+=2)r=n(r,C(t.x,t.y,i[s],i[s+1]));return r-e},tt.prototype.containsVert=function(t,e){for(var i=this.tPlanes,n=0;n<i.length;n++){var r=i[n].n;if(C(r.x,r.y,t,e)-i[n].d>0)return!1}return!0},tt.prototype.containsVertPartial=function(t,e,i){for(var n=this.tPlanes,r=0;r<n.length;r++){var s=n[r].n;if(!(x(s,i)<0)){if(C(s.x,s.y,t,e)-n[r].d>0)return!1}}return!0},tt.prototype.getNumVerts=function(){return this.verts.length/2},tt.prototype.getVert=function(t){return new y(this.verts[2*t],this.verts[2*t+1])};var nt=cp.Body=function(t,e){this.p=new y(0,0),this.vx=this.vy=0,this.f=new y(0,0),this.w=0,this.t=0,this.v_limit=1/0,this.w_limit=1/0,this.v_biasx=this.v_biasy=0,this.w_bias=0,this.space=null,this.shapeList=[],this.arbiterList=null,this.constraintList=null,this.nodeRoot=null,this.nodeNext=null,this.nodeIdleTime=0,this.setMass(t),this.setMoment(e),this.rot=new y(0,0),this.setAngle(0)};if(cp.StaticBody=function(){var t=new nt(1/0,1/0);return t.nodeIdleTime=1/0,t},"undefined"!=typeof DEBUG&&DEBUG){var rt=function(t,e){(function(t,e){s(t.x==t.x&&t.y==t.y,e)})(t,e),(function(t,e){s(Math.abs(t.x)!==1/0&&Math.abs(t.y)!==1/0,e)})(t,e)};nt.prototype.sanityCheck=function(){s(this.m==this.m&&this.m_inv==this.m_inv,"Body's mass is invalid."),s(this.i==this.i&&this.i_inv==this.i_inv,"Body's moment is invalid."),rt(this.p,"Body's position is invalid."),rt(this.f,"Body's force is invalid."),s(this.vx==this.vx&&Math.abs(this.vx)!==1/0,"Body's velocity is invalid."),s(this.vy==this.vy&&Math.abs(this.vy)!==1/0,"Body's velocity is invalid."),s(this.a==this.a&&Math.abs(this.a)!==1/0,"Body's angle is invalid."),s(this.w==this.w&&Math.abs(this.w)!==1/0,"Body's angular velocity is invalid."),s(this.t==this.t&&Math.abs(this.t)!==1/0,"Body's torque is invalid."),rt(this.rot,"Body's rotation vector is invalid."),s(this.v_limit==this.v_limit,"Body's velocity limit is invalid."),s(this.w_limit==this.w_limit,"Body's angular velocity limit is invalid.")}}else nt.prototype.sanityCheck=function(){};nt.prototype.getPos=function(){return this.p},nt.prototype.getVel=function(){return new y(this.vx,this.vy)},nt.prototype.getAngVel=function(){return this.w},nt.prototype.isSleeping=function(){return null!==this.nodeRoot},nt.prototype.isStatic=function(){return this.nodeIdleTime===1/0},nt.prototype.isRogue=function(){return null===this.space},nt.prototype.setMass=function(t){s(t>0,"Mass must be positive and non-zero."),this.activate(),this.m=t,this.m_inv=1/t},nt.prototype.setMoment=function(t){s(t>0,"Moment of Inertia must be positive and non-zero."),this.activate(),this.i=t,this.i_inv=1/t},nt.prototype.addShape=function(t){this.shapeList.push(t)},nt.prototype.removeShape=function(t){l(this.shapeList,t)};var st=function(t,e,i){return t===i?t.next(e):(t.a===e?t.next_a=st(t.next_a,e,i):t.next_b=st(t.next_b,e,i),t)};nt.prototype.removeConstraint=function(t){this.constraintList=st(this.constraintList,this,t)},nt.prototype.setPos=function(t){this.activate(),this.sanityCheck(),t===v&&(t=cp.v(0,0)),this.p=t},nt.prototype.setVel=function(t){this.activate(),this.vx=t.x,this.vy=t.y},nt.prototype.setAngVel=function(t){this.activate(),this.w=t},nt.prototype.setAngleInternal=function(t){s(!isNaN(t),"Internal Error: Attempting to set body's angle to NaN"),this.a=t,this.rot.x=Math.cos(t),this.rot.y=Math.sin(t)},nt.prototype.setAngle=function(t){this.activate(),this.sanityCheck(),this.setAngleInternal(t)},nt.prototype.velocity_func=function(t,e,i){var n=this.vx*e+(t.x+this.f.x*this.m_inv)*i,r=this.vy*e+(t.y+this.f.y*this.m_inv)*i,s=this.v_limit,o=n*n+r*r,a=o>s*s?s/Math.sqrt(o):1;this.vx=n*a,this.vy=r*a;var c=this.w_limit;this.w=m(this.w*e+this.t*this.i_inv*i,-c,c),this.sanityCheck()},nt.prototype.position_func=function(t){this.p.x+=(this.vx+this.v_biasx)*t,this.p.y+=(this.vy+this.v_biasy)*t,this.setAngleInternal(this.a+(this.w+this.w_bias)*t),this.v_biasx=this.v_biasy=0,this.w_bias=0,this.sanityCheck()},nt.prototype.resetForces=function(){this.activate(),this.f=new y(0,0),this.t=0},nt.prototype.applyForce=function(t,e){this.activate(),this.f=A(this.f,t),this.t+=I(e,t)},nt.prototype.applyImpulse=function(t,e){this.activate(),Ht(this,t.x,t.y,e)},nt.prototype.getVelAtPoint=function(t){return A(new y(this.vx,this.vy),E(P(t),this.w))},nt.prototype.getVelAtWorldPoint=function(t){return this.getVelAtPoint(S(t,this.p))},nt.prototype.getVelAtLocalPoint=function(t){return this.getVelAtPoint(B(t,this.rot))},nt.prototype.eachShape=function(t){for(var e=0,i=this.shapeList.length;e<i;e++)t(this.shapeList[e])},nt.prototype.eachConstraint=function(t){for(var e=this.constraintList;e;){var i=e.next(this);t(e),e=i}},nt.prototype.eachArbiter=function(t){for(var e=this.arbiterList;e;){var i=e.next(this);e.swappedColl=this===e.body_b,t(e),e=i}},nt.prototype.local2World=function(t){return A(this.p,B(t,this.rot))},nt.prototype.world2Local=function(t){return D(S(t,this.p),this.rot)},nt.prototype.kineticEnergy=function(){var t=this.vx*this.vx+this.vy*this.vy,e=this.w*this.w;return(t?t*this.m:0)+(e?e*this.i:0)};var ot=cp.SpatialIndex=function(t){if(this.staticIndex=t,t){if(t.dynamicIndex)throw new Error("This static index is already associated with a dynamic index.");t.dynamicIndex=this}};ot.prototype.collideStatic=function(t,e){if(t.count>0){var i=t.query;this.each((function(t){i(t,new U(t.bb_l,t.bb_b,t.bb_r,t.bb_t),e)}))}};var at=cp.BBTree=function(t){ot.call(this,t),this.velocityFunc=null,this.leaves={},this.count=0,this.root=null,this.pooledNodes=null,this.pooledPairs=null,this.stamp=0};at.prototype=Object.create(ot.prototype);var ct=function(t,e,i){this.obj=null,this.bb_l=n(e.bb_l,i.bb_l),this.bb_b=n(e.bb_b,i.bb_b),this.bb_r=r(e.bb_r,i.bb_r),this.bb_t=r(e.bb_t,i.bb_t),this.parent=null,this.setA(e),this.setB(i)};at.prototype.makeNode=function(t,e){var i=this.pooledNodes;return i?(this.pooledNodes=i.parent,i.constructor(this,t,e),i):(0,new ct(this,t,e))};var ht=function(t,e){this.obj=e,t.getBB(e,this),this.parent=null,this.stamp=1,this.pairs=null,0};at.prototype.getBB=function(t,e){var i=this.velocityFunc;if(i){var s=.1*(t.bb_r-t.bb_l),o=.1*(t.bb_t-t.bb_b),a=E(i(t),.1);e.bb_l=t.bb_l+n(-s,a.x),e.bb_b=t.bb_b+n(-o,a.y),e.bb_r=t.bb_r+r(s,a.x),e.bb_t=t.bb_t+r(o,a.y)}else e.bb_l=t.bb_l,e.bb_b=t.bb_b,e.bb_r=t.bb_r,e.bb_t=t.bb_t},at.prototype.getStamp=function(){var t=this.dynamicIndex;return t&&t.stamp?t.stamp:this.stamp},at.prototype.incrementStamp=function(){this.dynamicIndex&&this.dynamicIndex.stamp?this.dynamicIndex.stamp++:this.stamp++};var lt=function(t,e,i,n){this.prevA=null,this.leafA=t,this.nextA=e,this.prevB=null,this.leafB=i,this.nextB=n};at.prototype.makePair=function(t,e,i,n){var r=this.pooledPairs;return r?(this.pooledPairs=r.prevA,r.prevA=null,r.leafA=t,r.nextA=e,r.prevB=null,r.leafB=i,r.nextB=n,r):(0,new lt(t,e,i,n))},lt.prototype.recycle=function(t){this.prevA=t.pooledPairs,t.pooledPairs=this};var ut=function(t,e,i){i&&(i.leafA===e?i.prevA=t:i.prevB=t),t?t.leafA===e?t.nextA=i:t.nextB=i:e.pairs=i};ht.prototype.clearPairs=function(t){var e,i=this.pairs;for(this.pairs=null;i;)i.leafA===this?(e=i.nextA,ut(i.prevB,i.leafB,i.nextB)):(e=i.nextB,ut(i.prevA,i.leafA,i.nextA)),i.recycle(t),i=e};var _t=function(t,e,i){var n=t.pairs,r=e.pairs,s=i.makePair(t,n,e,r);t.pairs=e.pairs=s,n&&(n.leafA===t?n.prevA=s:n.prevB=s),r&&(r.leafA===e?r.prevA=s:r.prevB=s)};ct.prototype.recycle=function(t){this.parent=t.pooledNodes,t.pooledNodes=this},ht.prototype.recycle=function(t){},ct.prototype.setA=function(t){this.A=t,t.parent=this},ct.prototype.setB=function(t){this.B=t,t.parent=this},ht.prototype.isLeaf=!0,ct.prototype.isLeaf=!1,ct.prototype.otherChild=function(t){return this.A==t?this.B:this.A},ct.prototype.replaceChild=function(t,e,i){o(t==this.A||t==this.B,"Node is not a child of parent."),this.A==t?(this.A.recycle(i),this.setA(e)):(this.B.recycle(i),this.setB(e));for(var s=this;s;s=s.parent){var a=s.A,c=s.B;s.bb_l=n(a.bb_l,c.bb_l),s.bb_b=n(a.bb_b,c.bb_b),s.bb_r=r(a.bb_r,c.bb_r),s.bb_t=r(a.bb_t,c.bb_t)}},ct.prototype.bbArea=ht.prototype.bbArea=function(){return(this.bb_r-this.bb_l)*(this.bb_t-this.bb_b)};var dt=function(t,e){return(r(t.bb_r,e.bb_r)-n(t.bb_l,e.bb_l))*(r(t.bb_t,e.bb_t)-n(t.bb_b,e.bb_b))},ft=function(t,e){return Math.abs(t.bb_l+t.bb_r-e.bb_l-e.bb_r)+Math.abs(t.bb_b+t.bb_t-e.bb_b-e.bb_t)},pt=function(t,e,i){if(null==t)return e;if(t.isLeaf)return i.makeNode(e,t);var s=t.B.bbArea()+dt(t.A,e),o=t.A.bbArea()+dt(t.B,e);return s===o&&(s=ft(t.A,e),o=ft(t.B,e)),o<s?t.setB(pt(t.B,e,i)):t.setA(pt(t.A,e,i)),t.bb_l=n(t.bb_l,e.bb_l),t.bb_b=n(t.bb_b,e.bb_b),t.bb_r=r(t.bb_r,e.bb_r),t.bb_t=r(t.bb_t,e.bb_t),t};ct.prototype.intersectsBB=ht.prototype.intersectsBB=function(t){return this.bb_l<=t.r&&t.l<=this.bb_r&&this.bb_b<=t.t&&t.b<=this.bb_t};var mt=function(t,e,i){t.intersectsBB(e)&&(t.isLeaf?i(t.obj):(mt(t.A,e,i),mt(t.B,e,i)))},gt=function(t,e,i){var s=1/(i.x-e.x),o=t.bb_l==e.x?-1/0:(t.bb_l-e.x)*s,a=t.bb_r==e.x?1/0:(t.bb_r-e.x)*s,c=n(o,a),h=r(o,a),l=1/(i.y-e.y),u=t.bb_b==e.y?-1/0:(t.bb_b-e.y)*l,_=t.bb_t==e.y?1/0:(t.bb_t-e.y)*l,d=n(u,_),f=r(u,_);if(d<=h&&c<=f){var p=r(c,d);if(0<=n(h,f)&&p<=1)return r(p,0)}return 1/0},yt=function(t,e,i,r,s){if(t.isLeaf)return s(t.obj);var o=gt(t.A,e,i),a=gt(t.B,e,i);return o<a?(o<r&&(r=n(r,yt(t.A,e,i,r,s))),a<r&&(r=n(r,yt(t.B,e,i,r,s)))):(a<r&&(r=n(r,yt(t.B,e,i,r,s))),o<r&&(r=n(r,yt(t.A,e,i,r,s)))),r};at.prototype.subtreeRecycle=function(t){t.isLeaf&&(this.subtreeRecycle(t.A),this.subtreeRecycle(t.B),t.recycle(this))};var vt=function(t,e,i){if(e==t)return null;var n=e.parent;if(n==t){var r=t.otherChild(e);return r.parent=t.parent,t.recycle(i),r}return n.parent.replaceChild(n,n.otherChild(e),i),t},xt=function(t,e){return t.bb_l<=e.bb_r&&e.bb_l<=t.bb_r&&t.bb_b<=e.bb_t&&e.bb_b<=t.bb_t};ht.prototype.markLeafQuery=function(t,e,i,n){xt(t,this)&&(e?_t(t,this,i):(this.stamp<t.stamp&&_t(this,t,i),n&&n(t.obj,this.obj)))},ct.prototype.markLeafQuery=function(t,e,i,n){xt(t,this)&&(this.A.markLeafQuery(t,e,i,n),this.B.markLeafQuery(t,e,i,n))},ht.prototype.markSubtree=function(t,e,i){if(this.stamp==t.getStamp()){e&&e.markLeafQuery(this,!1,t,i);for(var n=this;n.parent;n=n.parent)n==n.parent.A?n.parent.B.markLeafQuery(this,!0,t,i):n.parent.A.markLeafQuery(this,!1,t,i)}else for(var r=this.pairs;r;)this===r.leafB?(i&&i(r.leafA.obj,this.obj),r=r.nextB):r=r.nextA},ct.prototype.markSubtree=function(t,e,i){this.A.markSubtree(t,e,i),this.B.markSubtree(t,e,i)},ht.prototype.containsObj=function(t){return this.bb_l<=t.bb_l&&this.bb_r>=t.bb_r&&this.bb_b<=t.bb_b&&this.bb_t>=t.bb_t},ht.prototype.update=function(t){var e=t.root,i=this.obj;return!this.containsObj(i)&&(t.getBB(this.obj,this),e=vt(e,this,t),t.root=pt(e,this,t),this.clearPairs(t),this.stamp=t.getStamp(),!0)},ht.prototype.addPairs=function(t){var e=t.dynamicIndex;if(e){var i=e.root;i&&i.markLeafQuery(this,!0,e,null)}else{var n=t.staticIndex.root;this.markSubtree(t,n,null)}},at.prototype.insert=function(t,e){var i=new ht(this,t);this.leaves[e]=i,this.root=pt(this.root,i,this),this.count++,i.stamp=this.getStamp(),i.addPairs(this),this.incrementStamp()},at.prototype.remove=function(t,e){var i=this.leaves[e];delete this.leaves[e],this.root=vt(this.root,i,this),this.count--,i.clearPairs(this),i.recycle(this)},at.prototype.contains=function(t,e){return null!=this.leaves[e]};var Ct=function(t,e){};at.prototype.reindexQuery=function(t){if(this.root){var e,i=this.leaves;for(e in i)i[e].update(this);var n=this.staticIndex,r=n&&n.root;this.root.markSubtree(this,r,t),n&&!r&&this.collideStatic(this,n,t),this.incrementStamp()}},at.prototype.reindex=function(){this.reindexQuery(Ct)},at.prototype.reindexObject=function(t,e){var i=this.leaves[e];i&&(i.update(this)&&i.addPairs(this),this.incrementStamp())},at.prototype.pointQuery=function(t,e){this.query(new U(t.x,t.y,t.x,t.y),e)},at.prototype.segmentQuery=function(t,e,i,n){this.root&&yt(this.root,t,e,i,n)},at.prototype.query=function(t,e){this.root&&mt(this.root,t,e)},at.prototype.count=function(){return this.count},at.prototype.each=function(t){var e;for(e in this.leaves)t(this.leaves[e].obj)};var Tt=function(t,e,i,s,o){return(r(t.bb_r,s)-n(t.bb_l,e))*(r(t.bb_t,o)-n(t.bb_b,i))},bt=function(t,e,i,s){if(1==s)return e[i];if(2==s)return t.makeNode(e[i],e[i+1]);for(var o=(S=e[i]).bb_l,a=S.bb_b,c=S.bb_r,h=S.bb_t,l=i+s,u=i+1;u<l;u++)S=e[u],o=n(o,S.bb_l),a=n(a,S.bb_b),c=r(c,S.bb_r),h=r(h,S.bb_t);var _=c-o>h-a,d=new Array(2*s);if(_)for(u=i;u<l;u++)d[2*u+0]=e[u].bb_l,d[2*u+1]=e[u].bb_r;else for(u=i;u<l;u++)d[2*u+0]=e[u].bb_b,d[2*u+1]=e[u].bb_t;d.sort((function(t,e){return t-e}));var f=.5*(d[s-1]+d[s]),p=o,m=a,g=c,y=h,v=o,x=a,C=c,T=h;_?g=v=f:y=x=f;for(var b=l,A=i;A<b;){var S=e[A];Tt(S,v,x,C,T)<Tt(S,p,m,g,y)?(b--,e[A]=e[b],e[b]=S):A++}if(b==s){for(S=null,u=i;u<l;u++)S=pt(S,e[u],t);return S}return NodeNew(t,bt(t,e,i,b-i),bt(t,e,b,l-b))};at.prototype.optimize=function(){var t=new Array(this.count),e=0;for(var i in this.leaves)t[e++]=this.nodes[i];tree.subtreeRecycle(root),this.root=bt(tree,t,t.length)};var At=function(t,e){!t.isLeaf&&e<=10&&(At(t.A,e+1),At(t.B,e+1));for(var i="",n=0;n<e;n++)i+=" ";console.log(i+t.bb_b+" "+t.bb_t)};at.prototype.log=function(){this.root&&At(this.root,0)};var St=cp.CollisionHandler=function(){this.a=this.b=0};St.prototype.begin=function(t,e){return!0},St.prototype.preSolve=function(t,e){return!0},St.prototype.postSolve=function(t,e){},St.prototype.separate=function(t,e){};var wt=function(t,e){this.e=0,this.u=0,this.surface_vr=v,this.a=t,this.body_a=t.body,this.b=e,this.body_b=e.body,this.thread_a_next=this.thread_a_prev=null,this.thread_b_next=this.thread_b_prev=null,this.contacts=null,this.stamp=0,this.handler=null,this.swappedColl=!1,this.state="first coll"};wt.prototype.getShapes=function(){return this.swappedColl?[this.b,this.a]:[this.a,this.b]},wt.prototype.totalImpulse=function(){for(var t=this.contacts,e=new y(0,0),i=0,n=t.length;i<n;i++){var r=t[i];e.add(E(r.n,r.jnAcc))}return this.swappedColl?e:e.neg()},wt.prototype.totalImpulseWithFriction=function(){for(var t=this.contacts,e=new y(0,0),i=0,n=t.length;i<n;i++){var r=t[i];e.add(new y(r.jnAcc,r.jtAcc).rotate(r.n))}return this.swappedColl?e:e.neg()},wt.prototype.totalKE=function(){for(var t=(1-this.e)/(1+this.e),e=0,i=this.contacts,n=0,r=i.length;n<r;n++){var s=i[n],o=s.jnAcc,a=s.jtAcc;e+=t*o*o/s.nMass+a*a/s.tMass}return e},wt.prototype.ignore=function(){this.state="ignore"},wt.prototype.getA=function(){return this.swappedColl?this.b:this.a},wt.prototype.getB=function(){return this.swappedColl?this.a:this.b},wt.prototype.isFirstContact=function(){return"first coll"===this.state};var Et=function(t,e,i){this.point=t,this.normal=e,this.dist=i};wt.prototype.getContactPointSet=function(){var t,e=new Array(this.contacts.length);for(t=0;t<e.length;t++)e[t]=new Et(this.contacts[t].p,this.contacts[t].n,this.contacts[t].dist);return e},wt.prototype.getNormal=function(t){var e=this.contacts[t].n;return this.swappedColl?w(e):e},wt.prototype.getPoint=function(t){return this.contacts[t].p},wt.prototype.getDepth=function(t){return this.contacts[t].dist};var It=function(t,e,i,n){i?i.body_a===e?i.thread_a_next=n:i.thread_b_next=n:e.arbiterList=n,n&&(n.body_a===e?n.thread_a_prev=i:n.thread_b_prev=i)};wt.prototype.unthread=function(){It(0,this.body_a,this.thread_a_prev,this.thread_a_next),It(0,this.body_b,this.thread_b_prev,this.thread_b_next),this.thread_a_prev=this.thread_a_next=null,this.thread_b_prev=this.thread_b_next=null},wt.prototype.update=function(t,e,i,n){if(this.contacts)for(var r=0;r<this.contacts.length;r++)for(var s=this.contacts[r],o=0;o<t.length;o++){var a=t[o];a.hash===s.hash&&(a.jnAcc=s.jnAcc,a.jtAcc=s.jtAcc)}this.contacts=t,this.handler=e,this.swappedColl=i.collision_type!==e.a,this.e=i.e*n.e,this.u=i.u*n.u,this.surface_vr=S(i.surface_v,n.surface_v),this.a=i,this.body_a=i.body,this.b=n,this.body_b=n.body,"cached"==this.state&&(this.state="first coll")},wt.prototype.preStep=function(t,e,i){for(var r=this.body_a,s=this.body_b,o=0;o<this.contacts.length;o++){var a=this.contacts[o];a.r1=S(a.p,r.p),a.r2=S(a.p,s.p),a.nMass=1/Qt(r,s,a.r1,a.r2,a.n),a.tMass=1/Qt(r,s,a.r1,a.r2,P(a.n)),a.bias=-i*n(0,a.dist+e)/t,a.jBias=0,a.bounce=Yt(r,s,a.r1,a.r2,a.n)*this.e}},wt.prototype.applyCachedImpulse=function(t){if(!this.isFirstContact())for(var e=this.body_a,i=this.body_b,n=0;n<this.contacts.length;n++){var r=this.contacts[n],s=r.n.x,o=r.n.y,a=s*r.jnAcc-o*r.jtAcc,c=s*r.jtAcc+o*r.jnAcc;qt(e,i,r.r1,r.r2,a*t,c*t)}};wt.prototype.applyImpulse=function(){0;for(var t=this.body_a,e=this.body_b,i=this.surface_vr,n=this.u,s=0;s<this.contacts.length;s++){0;var o=this.contacts[s],a=o.nMass,c=o.n,h=o.r1,l=o.r2,u=e.vx-l.y*e.w-(t.vx-h.y*t.w),_=e.vy+l.x*e.w-(t.vy+h.x*t.w),d=c.x*(e.v_biasx-l.y*e.w_bias-t.v_biasx+h.y*t.w_bias)+c.y*(l.x*e.w_bias+e.v_biasy-h.x*t.w_bias-t.v_biasy),f=C(u,_,c.x,c.y),p=C(u+i.x,_+i.y,-c.y,c.x),g=(o.bias-d)*a,y=o.jBias;o.jBias=r(y+g,0);var v=-(o.bounce+f)*a,x=o.jnAcc;o.jnAcc=r(x+v,0);var T=n*o.jnAcc,b=-p*o.tMass,A=o.jtAcc;o.jtAcc=m(A+b,-T,T);var S=c.x*(o.jBias-y),w=c.y*(o.jBias-y);Jt(t,-S,-w,h),Jt(e,S,w,l);var E=o.jnAcc-x,I=o.jtAcc-A;qt(t,e,h,l,c.x*E-c.y*I,c.x*I+c.y*E)}},wt.prototype.callSeparate=function(t){t.lookupHandler(this.a.collision_type,this.b.collision_type).separate(this,t)},wt.prototype.next=function(t){return this.body_a==t?this.thread_a_next:this.thread_b_next};var Rt=function(t,e,i,n){this.p=t,this.n=e,this.dist=i,this.r1=this.r2=v,this.nMass=this.tMass=this.bounce=this.bias=0,this.jnAcc=this.jtAcc=this.jBias=0,this.hash=n,0},Pt=[],Ot=function(t,e,i,n){var r=i+n,s=S(e,t),o=M(s);if(!(o>=r*r)){var a=Math.sqrt(o);return new Rt(A(t,E(s,.5+(i-.5*r)/(a||1/0))),a?E(s,1/a):new y(1,0),a-r,0)}},Bt=0,Dt=function(t,e){var i=0,n=t.valueOnAxis(e[0].n,e[0].d);if(n>0)return-1;for(var r=1;r<e.length;r++){var s=t.valueOnAxis(e[r].n,e[r].d);if(s>0)return-1;s>n&&(n=s,i=r)}return Bt=n,i},Mt=function(t,e,i,n){for(var r=[],s=t.tVerts,o=0;o<s.length;o+=2){var a=s[o],c=s[o+1];e.containsVert(a,c)&&r.push(new Rt(new y(a,c),i,n,h(t.hashid,o>>1)))}var l=e.tVerts;for(o=0;o<l.length;o+=2){a=l[o],c=l[o+1];t.containsVert(a,c)&&r.push(new Rt(new y(a,c),i,n,h(e.hashid,o>>1)))}return r.length?r:(function(t,e,i,n){for(var r=[],s=t.tVerts,o=0;o<s.length;o+=2){var a=s[o],c=s[o+1];e.containsVertPartial(a,c,w(i))&&r.push(new Rt(new y(a,c),i,n,h(t.hashid,o)))}var l=e.tVerts;for(o=0;o<l.length;o+=2)a=l[o],c=l[o+1],t.containsVertPartial(a,c,i)&&r.push(new Rt(new y(a,c),i,n,h(e.hashid,o)));return r})(t,e,i,n)},Lt=function(t,e,i){var r=x(e,t.ta)-t.r,s=x(e,t.tb)-t.r;return n(r,s)-i},Nt=function(t,e,i,n,r){for(var s=I(e.tn,e.ta),o=I(e.tn,e.tb),a=E(e.tn,r),c=i.tVerts,l=0;l<c.length;l+=2){var u=c[l],_=c[l+1];if(C(u,_,a.x,a.y)<x(e.tn,e.ta)*r+e.r){var d=R(e.tn.x,e.tn.y,u,_);s>=d&&d>=o&&t.push(new Rt(new y(u,_),a,n,h(i.hashid,l)))}}};Z.prototype.collisionCode=0,K.prototype.collisionCode=1,tt.prototype.collisionCode=2,Z.prototype.collisionTable=[function(t,e){var i=Ot(t.tc,e.tc,t.r,e.r);return i?[i]:Pt},function(t,e){var i=e.ta,n=e.tb,r=t.tc,s=S(n,i),o=g(x(s,S(r,i))/M(s)),a=A(i,E(s,o)),c=Ot(r,a,t.r,e.r);if(c){var h=c.n;return 0===o&&x(h,e.a_tangent)<0||1===o&&x(h,e.b_tangent)<0?Pt:[c]}return Pt},function(t,e){for(var i=e.tPlanes,n=0,r=x(i[0].n,t.tc)-i[0].d-t.r,s=0;s<i.length;s++){var o=x(i[s].n,t.tc)-i[s].d-t.r;if(o>0)return Pt;o>r&&(r=o,n=s)}var a=i[n].n,c=e.tVerts,h=c.length,l=n<<1,u=c[l],_=c[l+1],d=c[(l+2)%h],f=c[(l+3)%h],p=R(a.x,a.y,u,_),m=R(a.x,a.y,d,f),g=I(a,t.tc);if(g<m)return(v=Ot(t.tc,new y(d,f),t.r,0))?[v]:Pt;if(g<p)return[new Rt(S(t.tc,E(a,t.r+r/2)),w(a),r,0)];var v;return(v=Ot(t.tc,new y(u,_),t.r,0))?[v]:Pt}],K.prototype.collisionTable=[null,function(t,e){return Pt},function(t,e){var i=[],n=e.tPlanes,r=n.length,s=x(t.tn,t.ta),o=e.valueOnAxis(t.tn,s)-t.r,a=e.valueOnAxis(w(t.tn),-s)-t.r;if(a>0||o>0)return Pt;var c=0,l=Lt(t,n[0].n,n[0].d);if(l>0)return Pt;for(var u=0;u<r;u++){var _=Lt(t,n[u].n,n[u].d);if(_>0)return Pt;_>l&&(l=_,c=u)}var d=w(n[c].n),f=A(t.ta,E(d,t.r)),p=A(t.tb,E(d,t.r));if(e.containsVert(f.x,f.y)&&i.push(new Rt(f,d,l,h(t.hashid,0))),e.containsVert(p.x,p.y)&&i.push(new Rt(p,d,l,h(t.hashid,1))),(o>=l||a>=l)&&(o>a?Nt(i,t,e,o,1):Nt(i,t,e,a,-1)),0===i.length){var m,g=2*c,v=e.tVerts,C=new y(v[g],v[g+1]);if(m=Ot(t.ta,C,t.r,0))return[m];if(m=Ot(t.tb,C,t.r,0))return[m];var T=2*r,b=new y(v[(g+2)%T],v[(g+3)%T]);if(m=Ot(t.ta,b,t.r,0))return[m];if(m=Ot(t.tb,b,t.r,0))return[m]}return i}],tt.prototype.collisionTable=[null,null,function(t,e){var i=Dt(e,t.tPlanes);if(-1==i)return Pt;var n=Bt,r=Dt(t,e.tPlanes);if(-1==r)return Pt;var s=Bt;return n>s?Mt(t,e,t.tPlanes[i].n,n):Mt(t,e,w(e.tPlanes[r].n),s)}];var Ft=cp.collideShapes=function(t,e){return s(t.collisionCode<=e.collisionCode,"Collided shapes must be sorted by type"),t.collisionTable[e.collisionCode](t,e)},kt=new St,zt=cp.Space=function(){this.stamp=0,this.curr_dt=0,this.bodies=[],this.rousedBodies=[],this.sleepingComponents=[],this.staticShapes=new at(null),this.activeShapes=new at(this.staticShapes),this.arbiters=[],this.contactBuffersHead=null,this.cachedArbiters={},this.constraints=[],this.locked=0,this.collisionHandlers={},this.defaultHandler=kt,this.postStepCallbacks=[],this.iterations=10,this.gravity=v,this.damping=1,this.idleSpeedThreshold=0,this.sleepTimeThreshold=1/0,this.collisionSlop=.1,this.collisionBias=Math.pow(.9,60),this.collisionPersistence=3,this.enableContactGraph=!1,this.staticBody=new nt(1/0,1/0),this.staticBody.nodeIdleTime=1/0,this.collideShapes=this.makeCollideShapes()};zt.prototype.getCurrentTimeStep=function(){return this.curr_dt},zt.prototype.setIterations=function(t){this.iterations=t},zt.prototype.isLocked=function(){return this.locked};var Vt=function(t){s(!t.locked,"This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. Put these calls into a post-step callback.")};zt.prototype.addCollisionHandler=function(t,e,i,n,r,s){Vt(this),this.removeCollisionHandler(t,e);var o=new St;o.a=t,o.b=e,i&&(o.begin=i),n&&(o.preSolve=n),r&&(o.postSolve=r),s&&(o.separate=s),this.collisionHandlers[h(t,e)]=o},zt.prototype.removeCollisionHandler=function(t,e){Vt(this),delete this.collisionHandlers[h(t,e)]},zt.prototype.setDefaultCollisionHandler=function(t,e,i,n){Vt(this);var r=new St;t&&(r.begin=t),e&&(r.preSolve=e),i&&(r.postSolve=i),n&&(r.separate=n),this.defaultHandler=r},zt.prototype.lookupHandler=function(t,e){return this.collisionHandlers[h(t,e)]||this.defaultHandler},zt.prototype.addShape=function(t){var e=t.body;return e.isStatic()?this.addStaticShape(t):(s(!t.space,"This shape is already added to a space and cannot be added to another."),Vt(this),e.activate(),e.addShape(t),t.update(e.p,e.rot),this.activeShapes.insert(t,t.hashid),t.space=this,t)},zt.prototype.addStaticShape=function(t){s(!t.space,"This shape is already added to a space and cannot be added to another."),Vt(this);var e=t.body;return e.addShape(t),t.update(e.p,e.rot),this.staticShapes.insert(t,t.hashid),t.space=this,t},zt.prototype.addBody=function(t){return s(!t.isStatic(),"Static bodies cannot be added to a space as they are not meant to be simulated."),s(!t.space,"This body is already added to a space and cannot be added to another."),Vt(this),this.bodies.push(t),t.space=this,t},zt.prototype.addConstraint=function(t){s(!t.space,"This shape is already added to a space and cannot be added to another."),Vt(this);var e=t.a,i=t.b;return e.activate(),i.activate(),this.constraints.push(t),t.next_a=e.constraintList,e.constraintList=t,t.next_b=i.constraintList,i.constraintList=t,t.space=this,t},zt.prototype.filterArbiters=function(t,e){for(var i in this.cachedArbiters){var n=this.cachedArbiters[i];(t!==n.body_a||e!==n.a&&null!==e)&&(t!==n.body_b||e!==n.b&&null!==e)||(e&&"cached"!==n.state&&n.callSeparate(this),n.unthread(),l(this.arbiters,n),delete this.cachedArbiters[i])}},zt.prototype.removeShape=function(t){var e=t.body;e.isStatic()?this.removeStaticShape(t):(s(this.containsShape(t),"Cannot remove a shape that was not added to the space. (Removed twice maybe?)"),Vt(this),e.activate(),e.removeShape(t),this.filterArbiters(e,t),this.activeShapes.remove(t,t.hashid),t.space=null)},zt.prototype.removeStaticShape=function(t){s(this.containsShape(t),"Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"),Vt(this);var e=t.body;e.isStatic()&&e.activateStatic(t),e.removeShape(t),this.filterArbiters(e,t),this.staticShapes.remove(t,t.hashid),t.space=null},zt.prototype.removeBody=function(t){s(this.containsBody(t),"Cannot remove a body that was not added to the space. (Removed twice maybe?)"),Vt(this),t.activate(),l(this.bodies,t),t.space=null},zt.prototype.removeConstraint=function(t){s(this.containsConstraint(t),"Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"),Vt(this),t.a.activate(),t.b.activate(),l(this.constraints,t),t.a.removeConstraint(t),t.b.removeConstraint(t),t.space=null},zt.prototype.containsShape=function(t){return t.space===this},zt.prototype.containsBody=function(t){return t.space==this},zt.prototype.containsConstraint=function(t){return t.space==this},zt.prototype.uncacheArbiter=function(t){delete this.cachedArbiters[h(t.a.hashid,t.b.hashid)],l(this.arbiters,t)},zt.prototype.eachBody=function(t){this.lock();for(var e=this.bodies,i=0;i<e.length;i++)t(e[i]);var n=this.sleepingComponents;for(i=0;i<n.length;i++)for(var r=n[i];r;){var s=r.nodeNext;t(r),r=s}this.unlock(!0)},zt.prototype.eachShape=function(t){this.lock(),this.activeShapes.each(t),this.staticShapes.each(t),this.unlock(!0)},zt.prototype.eachConstraint=function(t){this.lock();for(var e=this.constraints,i=0;i<e.length;i++)t(e[i]);this.unlock(!0)},zt.prototype.reindexStatic=function(){s(!this.locked,"You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."),this.staticShapes.each((function(t){var e=t.body;t.update(e.p,e.rot)})),this.staticShapes.reindex()},zt.prototype.reindexShape=function(t){s(!this.locked,"You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");var e=t.body;t.update(e.p,e.rot),this.activeShapes.reindexObject(t,t.hashid),this.staticShapes.reindexObject(t,t.hashid)},zt.prototype.reindexShapesForBody=function(t){for(var e=t.shapeList;e;e=e.next)this.reindexShape(e)},zt.prototype.useSpatialHash=function(t,e){throw new Error("Spatial Hash not implemented.")},zt.prototype.activateBody=function(t){if(s(!t.isRogue(),"Internal error: Attempting to activate a rogue body."),this.locked)-1===this.rousedBodies.indexOf(t)&&this.rousedBodies.push(t);else{this.bodies.push(t);for(var e=0;e<t.shapeList.length;e++){var i=t.shapeList[e];this.staticShapes.remove(i,i.hashid),this.activeShapes.insert(i,i.hashid)}for(var n=t.arbiterList;n;n=n.next(t)){if(t===(c=n.body_a)||c.isStatic()){var r=n.a,o=n.b;this.cachedArbiters[h(r.hashid,o.hashid)]=n,n.stamp=this.stamp,n.handler=this.lookupHandler(r.collision_type,o.collision_type),this.arbiters.push(n)}}for(var a=t.constraintList;a;a=a.nodeNext){var c;(t===(c=a.a)||c.isStatic())&&this.constraints.push(a)}}},zt.prototype.deactivateBody=function(t){s(!t.isRogue(),"Internal error: Attempting to deactivate a rogue body."),l(this.bodies,t);for(var e=0;e<t.shapeList.length;e++){var i=t.shapeList[e];this.activeShapes.remove(i,i.hashid),this.staticShapes.insert(i,i.hashid)}for(var n=t.arbiterList;n;n=n.next(t)){(t===(o=n.body_a)||o.isStatic())&&this.uncacheArbiter(n)}for(var r=t.constraintList;r;r=r.nodeNext){var o;(t===(o=r.a)||o.isStatic())&&l(this.constraints,r)}};var Gt=function(t){return t?t.nodeRoot:null};nt.prototype.activate=function(){this.isRogue()||(this.nodeIdleTime=0,(function(t){if(t&&t.isSleeping(t)){s(!t.isRogue(),"Internal Error: componentActivate() called on a rogue body.");for(var e=t.space,i=t;i;){var n=i.nodeNext;i.nodeIdleTime=0,i.nodeRoot=null,i.nodeNext=null,e.activateBody(i),i=n}l(e.sleepingComponents,t)}})(Gt(this)))},nt.prototype.activateStatic=function(t){s(this.isStatic(),"Body.activateStatic() called on a non-static body.");for(var e=this.arbiterList;e;e=e.next(this))t&&t!=e.a&&t!=e.b||(e.body_a==this?e.body_b:e.body_a).activate()},nt.prototype.pushArbiter=function(t){o(null===(t.body_a===this?t.thread_a_next:t.thread_b_next),"Internal Error: Dangling contact graph pointers detected. (A)"),o(null===(t.body_a===this?t.thread_a_prev:t.thread_b_prev),"Internal Error: Dangling contact graph pointers detected. (B)");var e=this.arbiterList;o(null===e||null===(e.body_a===this?e.thread_a_prev:e.thread_b_prev),"Internal Error: Dangling contact graph pointers detected. (C)"),t.body_a===this?t.thread_a_next=e:t.thread_b_next=e,e&&(e.body_a===this?e.thread_a_prev=t:e.thread_b_prev=t),this.arbiterList=t};var Wt=function(t,e){if(!e.isRogue()){var i=Gt(e);if(null==i){(function(t,e){e.nodeRoot=t,e!==t&&(e.nodeNext=t.nodeNext,t.nodeNext=e)})(t,e);for(var n=e.arbiterList;n;n=n.next(e))Wt(t,e==n.body_a?n.body_b:n.body_a);for(var r=e.constraintList;r;r=r.next(e))Wt(t,e==r.a?r.b:r.a)}else o(i===t,"Internal Error: Inconsistency detected in the contact graph.")}},Ut=function(t,e){for(var i=t;i;i=i.nodeNext)if(i.nodeIdleTime<e)return!0;return!1};zt.prototype.processComponents=function(t){for(var e=this.sleepTimeThreshold!==1/0,i=this.bodies,n=0;n<i.length;n++){var r=i[n];o(null===r.nodeNext,"Internal Error: Dangling next pointer detected in contact graph."),o(null===r.nodeRoot,"Internal Error: Dangling root pointer detected in contact graph.")}if(e){var s=this.idleSpeedThreshold,a=s?s*s:M(this.gravity)*t*t;for(n=0;n<i.length;n++){r=i[n];var c=a?r.m*a:0;r.nodeIdleTime=r.kineticEnergy()>c?0:r.nodeIdleTime+t}}for(var h=this.arbiters,l=(n=0,h.length);n<l;n++){var u=h[n],_=u.body_a,d=u.body_b;e&&((d.isRogue()&&!d.isStatic()||_.isSleeping())&&_.activate(),(_.isRogue()&&!_.isStatic()||d.isSleeping())&&d.activate()),_.pushArbiter(u),d.pushArbiter(u)}if(e){var f=this.constraints;for(n=0;n<f.length;n++){var p=f[n];_=p.a;(d=p.b).isRogue()&&!d.isStatic()&&_.activate(),_.isRogue()&&!_.isStatic()&&d.activate()}for(n=0;n<i.length;){r=i[n];if(null!==Gt(r)||(Wt(r,r),Ut(r,this.sleepTimeThreshold)))n++,r.nodeRoot=null,r.nodeNext=null;else{this.sleepingComponents.push(r);for(var m=r;m;m=m.nodeNext)this.deactivateBody(m)}}}},nt.prototype.sleep=function(){this.sleepWithGroup(null)},nt.prototype.sleepWithGroup=function(t){s(!this.isStatic()&&!this.isRogue(),"Rogue and static bodies cannot be put to sleep.");var e=this.space;if(s(e,"Cannot put a rogue body to sleep."),s(!e.locked,"Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback."),s(null===t||t.isSleeping(),"Cannot use a non-sleeping body as a group identifier."),this.isSleeping())s(Gt(this)===Gt(t),"The body is already sleeping and it's group cannot be reassigned.");else{for(var i=0;i<this.shapeList.length;i++)this.shapeList[i].update(this.p,this.rot);if(e.deactivateBody(this),t){var n=Gt(t);this.nodeRoot=n,this.nodeNext=n.nodeNext,this.nodeIdleTime=0,n.nodeNext=this}else this.nodeRoot=this,this.nodeNext=null,this.nodeIdleTime=0,e.sleepingComponents.push(this);l(e.bodies,this)}},zt.prototype.activateShapesTouchingShape=function(t){this.sleepTimeThreshold!==1/0&&this.shapeQuery(t,(function(t,e){t.body.activate()}))},zt.prototype.pointQuery=function(t,e,i,n){var r=function(r){(!r.group||i!==r.group)&&e&r.layers&&r.pointQuery(t)&&n(r)},s=new U(t.x,t.y,t.x,t.y);this.lock(),this.activeShapes.query(s,r),this.staticShapes.query(s,r),this.unlock(!0)},zt.prototype.pointQueryFirst=function(t,e,i){var n=null;return this.pointQuery(t,e,i,(function(t){t.sensor||(n=t)})),n},zt.prototype.nearestPointQuery=function(t,e,i,n,r){var s=function(s){if((!s.group||n!==s.group)&&i&s.layers){var o=s.nearestPointQuery(t);o.d<e&&r(s,o.d,o.p)}},o=j(t,e);this.lock(),this.activeShapes.query(o,s),this.staticShapes.query(o,s),this.unlock(!0)},zt.prototype.nearestPointQueryNearest=function(t,e,i,n){var r,s=function(s){if((!s.group||n!==s.group)&&i&s.layers&&!s.sensor){var o=s.nearestPointQuery(t);o.d<e&&(!r||o.d<r.d)&&(r=o)}},o=j(t,e);return this.activeShapes.query(o,s),this.staticShapes.query(o,s),r},zt.prototype.segmentQuery=function(t,e,i,n,r){var s=function(s){var o;return(!s.group||n!==s.group)&&i&s.layers&&(o=s.segmentQuery(t,e))&&r(s,o.t,o.n),1};this.lock(),this.staticShapes.segmentQuery(t,e,1,s),this.activeShapes.segmentQuery(t,e,1,s),this.unlock(!0)},zt.prototype.segmentQueryFirst=function(t,e,i,n){var r=null,s=function(s){var o;return(!s.group||n!==s.group)&&i&s.layers&&!s.sensor&&(o=s.segmentQuery(t,e))&&(null===r||o.t<r.t)&&(r=o),r?r.t:1};return this.staticShapes.segmentQuery(t,e,1,s),this.activeShapes.segmentQuery(t,e,r?r.t:1,s),r},zt.prototype.bbQuery=function(t,e,i,n){var r=function(r){(!r.group||i!==r.group)&&e&r.layers&&(function(t,e,i,n,r){return t.l<=n&&e<=t.r&&t.b<=r&&i<=t.t})(t,r.bb_l,r.bb_b,r.bb_r,r.bb_t)&&n(r)};this.lock(),this.activeShapes.query(t,r),this.staticShapes.query(t,r),this.unlock(!0)},zt.prototype.shapeQuery=function(t,e){var i=t.body;i&&t.update(i.p,i.rot);var n=new U(t.bb_l,t.bb_b,t.bb_r,t.bb_t),r=!1,s=function(i){var n=t;if((!n.group||n.group!==i.group)&&n.layers&i.layers&&n!==i){var s;if(n.collisionCode<=i.collisionCode)s=Ft(n,i);else{s=Ft(i,n);for(var o=0;o<s.length;o++)s[o].n=w(s[o].n)}if(s.length&&(r=!(n.sensor||i.sensor),e)){var a=new Array(s.length);for(o=0;o<s.length;o++)a[o]=new Et(s[o].p,s[o].n,s[o].dist);e(i,a)}}};return this.lock(),this.activeShapes.query(n,s),this.staticShapes.query(n,s),this.unlock(!0),r},zt.prototype.addPostStepCallback=function(t){o(this.locked,"Adding a post-step callback when the space is not locked is unnecessary. Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query."),this.postStepCallbacks.push(t)},zt.prototype.runPostStepCallbacks=function(){for(var t=0;t<this.postStepCallbacks.length;t++)this.postStepCallbacks[t]();this.postStepCallbacks=[]},zt.prototype.lock=function(){this.locked++},zt.prototype.unlock=function(t){if(this.locked--,s(this.locked>=0,"Internal Error: Space lock underflow."),0===this.locked&&t){for(var e=this.rousedBodies,i=0;i<e.length;i++)this.activateBody(e[i]);e.length=0,this.runPostStepCallbacks()}},zt.prototype.makeCollideShapes=function(){var t=this;return function(e,i){var n=t;if(e.bb_l<=i.bb_r&&i.bb_l<=e.bb_r&&e.bb_b<=i.bb_t&&i.bb_b<=e.bb_t&&e.body!==i.body&&(!e.group||e.group!==i.group)&&e.layers&i.layers){var r=n.lookupHandler(e.collision_type,i.collision_type),s=e.sensor||i.sensor;if(!s||r!==kt){if(e.collisionCode>i.collisionCode){var o=e;e=i,i=o}var a=Ft(e,i);if(0!==a.length){var c=h(e.hashid,i.hashid),l=n.cachedArbiters[c];l||(l=n.cachedArbiters[c]=new wt(e,i)),l.update(a,r,e,i),"first coll"!=l.state||r.begin(l,n)||l.ignore(),"ignore"!==l.state&&r.preSolve(l,n)&&!s?n.arbiters.push(l):(l.contacts=null,"ignore"!==l.state&&(l.state="normal")),l.stamp=n.stamp}}}}},zt.prototype.arbiterSetFilter=function(t){var e=this.stamp-t.stamp,i=t.body_a,n=t.body_b;return!(!i.isStatic()&&!i.isSleeping()||!n.isStatic()&&!n.isSleeping())||(e>=1&&"cached"!=t.state&&(t.callSeparate(this),t.state="cached"),!(e>=this.collisionPersistence)||(t.contacts=null,!1))};var jt=function(t){var e=t.body;t.update(e.p,e.rot)};zt.prototype.step=function(t){if(0!==t){s(0===v.x&&0===v.y,"vzero is invalid"),this.stamp++;var e=this.curr_dt;this.curr_dt=t;var i,n,r,o=this.bodies,a=this.constraints,c=this.arbiters;for(i=0;i<c.length;i++){var h=c[i];h.state="normal",h.body_a.isSleeping()||h.body_b.isSleeping()||h.unthread()}for(c.length=0,this.lock(),i=0;i<o.length;i++)o[i].position_func(t);this.activeShapes.each(jt),this.activeShapes.reindexQuery(this.collideShapes),this.unlock(!1),this.processComponents(t),this.lock();for(r in this.cachedArbiters)this.arbiterSetFilter(this.cachedArbiters[r])||delete this.cachedArbiters[r];var l=this.collisionSlop,u=1-Math.pow(this.collisionBias,t);for(i=0;i<c.length;i++)c[i].preStep(t,l,u);for(i=0;i<a.length;i++){var _=a[i];_.preSolve(this),_.preStep(t)}var d=Math.pow(this.damping,t),f=this.gravity;for(i=0;i<o.length;i++)o[i].velocity_func(f,d,t);var p=0===e?0:t/e;for(i=0;i<c.length;i++)c[i].applyCachedImpulse(p);for(i=0;i<a.length;i++)a[i].applyCachedImpulse(p);for(i=0;i<this.iterations;i++){for(n=0;n<c.length;n++)c[n].applyImpulse();for(n=0;n<a.length;n++)a[n].applyImpulse()}for(i=0;i<a.length;i++)a[i].postSolve(this);for(i=0;i<c.length;i++)c[i].handler.postSolve(c[i],this);this.unlock(!0)}};var Xt=function(t,e,i,n){var r=t.vx+-i.y*t.w,s=t.vy+i.x*t.w,o=e.vx+-n.y*e.w,a=e.vy+n.x*e.w;return new y(o-r,a-s)},Yt=function(t,e,i,n,r){var s=t.vx+-i.y*t.w,o=t.vy+i.x*t.w,a=e.vx+-n.y*e.w,c=e.vy+n.x*e.w;return C(a-s,c-o,r.x,r.y)},Ht=function(t,e,i,n){t.vx+=e*t.m_inv,t.vy+=i*t.m_inv,t.w+=t.i_inv*(n.x*i-n.y*e)},qt=function(t,e,i,n,r,s){Ht(t,-r,-s,i),Ht(e,r,s,n)},Jt=function(t,e,i,n){t.v_biasx+=e*t.m_inv,t.v_biasy+=i*t.m_inv,t.w_bias+=t.i_inv*R(n.x,n.y,e,i)},Zt=function(t,e,i){var n=I(e,i);return t.m_inv+t.i_inv*n*n},Qt=function(t,e,i,n,r){var s=Zt(t,i,r)+Zt(e,n,r);return o(0!==s,"Unsolvable collision or constraint."),s},Kt=function(t,e,i,n,r,s){var a,c,h,l,u=t.m_inv+e.m_inv;a=u,c=0,h=0,l=u;var _=t.i_inv,d=i.x*i.x*_,f=i.y*i.y*_,p=-i.x*i.y*_;a+=f,c+=p,h+=p,l+=d;var m=e.i_inv,g=n.x*n.x*m,y=n.y*n.y*m,v=-n.x*n.y*m,x=(a+=y)*(l+=g)-(c+=v)*(h+=v);o(0!==x,"Unsolvable constraint.");var C=1/x;r.x=l*C,r.y=-c*C,s.x=-h*C,s.y=a*C},$t=function(t,e,i){return new y(x(t,e),x(t,i))},te=function(t,e){return 1-Math.pow(t,e)},ee=cp.Constraint=function(t,e){this.a=t,this.b=e,this.space=null,this.next_a=null,this.next_b=null,this.maxForce=1/0,this.errorBias=Math.pow(.9,60),this.maxBias=1/0};ee.prototype.activateBodies=function(){this.a&&this.a.activate(),this.b&&this.b.activate()},ee.prototype.preStep=function(t){},ee.prototype.applyCachedImpulse=function(t){},ee.prototype.applyImpulse=function(){},ee.prototype.getImpulse=function(){return 0},ee.prototype.preSolve=function(t){},ee.prototype.postSolve=function(t){},ee.prototype.next=function(t){return this.a===t?this.next_a:this.next_b};var ie=cp.PinJoint=function(t,e,i,n){ee.call(this,t,e),this.anchr1=i,this.anchr2=n;var r=t?A(t.p,B(i,t.rot)):i,s=e?A(e.p,B(n,e.rot)):n;this.dist=T(S(s,r)),o(this.dist>0,"You created a 0 length pin joint. A pivot joint will be much more stable."),this.r1=this.r2=null,this.n=null,this.nMass=0,this.jnAcc=this.jnMax=0,this.bias=0};ie.prototype=Object.create(ee.prototype),ie.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot);var n=S(A(i.p,this.r2),A(e.p,this.r1)),r=T(n);this.n=E(n,1/(r||1/0)),this.nMass=1/Qt(e,i,this.r1,this.r2,this.n);var s=this.maxBias;this.bias=m(-te(this.errorBias,t)*(r-this.dist)/t,-s,s),this.jnMax=this.maxForce*t},ie.prototype.applyCachedImpulse=function(t){var e=E(this.n,this.jnAcc*t);qt(this.a,this.b,this.r1,this.r2,e.x,e.y)},ie.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.n,n=Yt(t,e,this.r1,this.r2,i),r=(this.bias-n)*this.nMass,s=this.jnAcc;this.jnAcc=m(s+r,-this.jnMax,this.jnMax),r=this.jnAcc-s,qt(t,e,this.r1,this.r2,i.x*r,i.y*r)},ie.prototype.getImpulse=function(){return Math.abs(this.jnAcc)};var ne=cp.SlideJoint=function(t,e,i,n,r,s){ee.call(this,t,e),this.anchr1=i,this.anchr2=n,this.min=r,this.max=s,this.r1=this.r2=this.n=null,this.nMass=0,this.jnAcc=this.jnMax=0,this.bias=0};ne.prototype=Object.create(ee.prototype),ne.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot);var n=S(A(i.p,this.r2),A(e.p,this.r1)),r=T(n),s=0;r>this.max?(s=r-this.max,this.n=k(n)):r<this.min?(s=this.min-r,this.n=w(k(n))):(this.n=v,this.jnAcc=0),this.nMass=1/Qt(e,i,this.r1,this.r2,this.n);var o=this.maxBias;this.bias=m(-te(this.errorBias,t)*s/t,-o,o),this.jnMax=this.maxForce*t},ne.prototype.applyCachedImpulse=function(t){var e=this.jnAcc*t;qt(this.a,this.b,this.r1,this.r2,this.n.x*e,this.n.y*e)},ne.prototype.applyImpulse=function(){if(0!==this.n.x||0!==this.n.y){var t=this.a,e=this.b,i=this.n,n=this.r1,r=this.r2,s=Xt(t,e,n,r),o=x(s,i),a=(this.bias-o)*this.nMass,c=this.jnAcc;this.jnAcc=m(c+a,-this.jnMax,0),a=this.jnAcc-c,qt(t,e,this.r1,this.r2,i.x*a,i.y*a)}},ne.prototype.getImpulse=function(){return Math.abs(this.jnAcc)};var re=cp.PivotJoint=function(t,e,i,n){if(ee.call(this,t,e),void 0===n){var r=i;i=t?t.world2Local(r):r,n=e?e.world2Local(r):r}this.anchr1=i,this.anchr2=n,this.r1=this.r2=v,this.k1=new y(0,0),this.k2=new y(0,0),this.jAcc=v,this.jMaxLen=0,this.bias=v};re.prototype=Object.create(ee.prototype),re.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot),Kt(e,i,this.r1,this.r2,this.k1,this.k2),this.jMaxLen=this.maxForce*t;var n=S(A(i.p,this.r2),A(e.p,this.r1));this.bias=z(E(n,-te(this.errorBias,t)/t),this.maxBias)},re.prototype.applyCachedImpulse=function(t){qt(this.a,this.b,this.r1,this.r2,this.jAcc.x*t,this.jAcc.y*t)},re.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.r1,n=this.r2,r=Xt(t,e,i,n),s=$t(S(this.bias,r),this.k1,this.k2),o=this.jAcc;this.jAcc=z(A(this.jAcc,s),this.jMaxLen),qt(t,e,this.r1,this.r2,this.jAcc.x-o.x,this.jAcc.y-o.y)},re.prototype.getImpulse=function(){return T(this.jAcc)};var se=cp.GrooveJoint=function(t,e,i,n,r){ee.call(this,t,e),this.grv_a=i,this.grv_b=n,this.grv_n=P(F(S(n,i))),this.anchr2=r,this.grv_tn=null,this.clamp=0,this.r1=this.r2=null,this.k1=new y(0,0),this.k2=new y(0,0),this.jAcc=v,this.jMaxLen=0,this.bias=null};se.prototype=Object.create(ee.prototype),se.prototype.preStep=function(t){var e=this.a,i=this.b,n=e.local2World(this.grv_a),r=e.local2World(this.grv_b),s=B(this.grv_n,e.rot),o=x(n,s);this.grv_tn=s,this.r2=B(this.anchr2,i.rot);var a=I(A(i.p,this.r2),s);a<=I(n,s)?(this.clamp=1,this.r1=S(n,e.p)):a>=I(r,s)?(this.clamp=-1,this.r1=S(r,e.p)):(this.clamp=0,this.r1=S(A(E(P(s),-a),E(s,o)),e.p)),Kt(e,i,this.r1,this.r2,this.k1,this.k2),this.jMaxLen=this.maxForce*t;var c=S(A(i.p,this.r2),A(e.p,this.r1));this.bias=z(E(c,-te(this.errorBias,t)/t),this.maxBias)},se.prototype.applyCachedImpulse=function(t){qt(this.a,this.b,this.r1,this.r2,this.jAcc.x*t,this.jAcc.y*t)},se.prototype.grooveConstrain=function(t){var e=this.grv_tn,i=this.clamp*I(t,e)>0?t:O(t,e);return z(i,this.jMaxLen)},se.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.r1,n=this.r2,r=Xt(t,e,i,n),s=$t(S(this.bias,r),this.k1,this.k2),o=this.jAcc;this.jAcc=this.grooveConstrain(A(o,s)),qt(t,e,this.r1,this.r2,this.jAcc.x-o.x,this.jAcc.y-o.y)},se.prototype.getImpulse=function(){return T(this.jAcc)},se.prototype.setGrooveA=function(t){this.grv_a=t,this.grv_n=P(F(S(this.grv_b,t))),this.activateBodies()},se.prototype.setGrooveB=function(t){this.grv_b=t,this.grv_n=P(F(S(t,this.grv_a))),this.activateBodies()};var oe=function(t,e){return(t.restLength-e)*t.stiffness},ae=cp.DampedSpring=function(t,e,i,n,r,s,o){ee.call(this,t,e),this.anchr1=i,this.anchr2=n,this.restLength=r,this.stiffness=s,this.damping=o,this.springForceFunc=oe,this.target_vrn=this.v_coef=0,this.r1=this.r2=null,this.nMass=0,this.n=null};ae.prototype=Object.create(ee.prototype),ae.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot);var n=S(A(i.p,this.r2),A(e.p,this.r1)),r=T(n);this.n=E(n,1/(r||1/0));var s=Qt(e,i,this.r1,this.r2,this.n);o(0!==s,"Unsolvable this."),this.nMass=1/s,this.target_vrn=0,this.v_coef=1-Math.exp(-this.damping*t*s);var a=this.springForceFunc(this,r);qt(e,i,this.r1,this.r2,this.n.x*a*t,this.n.y*a*t)},ae.prototype.applyCachedImpulse=function(t){},ae.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.n,n=this.r1,r=this.r2,s=Yt(t,e,n,r,i),o=(this.target_vrn-s)*this.v_coef;this.target_vrn=s+o,o*=this.nMass,qt(t,e,this.r1,this.r2,this.n.x*o,this.n.y*o)},ae.prototype.getImpulse=function(){return 0};var ce=function(t,e){return(e-t.restAngle)*t.stiffness},he=cp.DampedRotarySpring=function(t,e,i,n,r){ee.call(this,t,e),this.restAngle=i,this.stiffness=n,this.damping=r,this.springTorqueFunc=ce,this.target_wrn=0,this.w_coef=0,this.iSum=0};he.prototype=Object.create(ee.prototype),he.prototype.preStep=function(t){var e=this.a,i=this.b,n=e.i_inv+i.i_inv;o(0!==n,"Unsolvable spring."),this.iSum=1/n,this.w_coef=1-Math.exp(-this.damping*t*n),this.target_wrn=0;var r=this.springTorqueFunc(this,e.a-i.a)*t;e.w-=r*e.i_inv,i.w+=r*i.i_inv},he.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=t.w-e.w,n=(this.target_wrn-i)*this.w_coef;this.target_wrn=i+n;var r=n*this.iSum;t.w+=r*t.i_inv,e.w-=r*e.i_inv};var le=cp.RotaryLimitJoint=function(t,e,i,n){ee.call(this,t,e),this.min=i,this.max=n,this.jAcc=0,this.iSum=this.bias=this.jMax=0};le.prototype=Object.create(ee.prototype),le.prototype.preStep=function(t){var e=this.a,i=this.b,n=i.a-e.a,r=0;n>this.max?r=this.max-n:n<this.min&&(r=this.min-n),this.iSum=1/(1/e.i+1/i.i);var s=this.maxBias;this.bias=m(-te(this.errorBias,t)*r/t,-s,s),this.jMax=this.maxForce*t,this.bias||(this.jAcc=0)},le.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv,i.w+=n*i.i_inv},le.prototype.applyImpulse=function(){if(this.bias){var t=this.a,e=this.b,i=e.w-t.w,n=-(this.bias+i)*this.iSum,r=this.jAcc;this.bias<0?this.jAcc=m(r+n,0,this.jMax):this.jAcc=m(r+n,-this.jMax,0),n=this.jAcc-r,t.w-=n*t.i_inv,e.w+=n*e.i_inv}},le.prototype.getImpulse=function(){return Math.abs(joint.jAcc)};var ue=cp.RatchetJoint=function(t,e,i,n){ee.call(this,t,e),this.angle=0,this.phase=i,this.ratchet=n,this.angle=(e?e.a:0)-(t?t.a:0),this.iSum=this.bias=this.jAcc=this.jMax=0};ue.prototype=Object.create(ee.prototype),ue.prototype.preStep=function(t){var e=this.a,i=this.b,n=this.angle,r=this.phase,s=this.ratchet,o=i.a-e.a,a=n-o,c=0;a*s>0?c=a:this.angle=Math.floor((o-r)/s)*s+r,this.iSum=1/(e.i_inv+i.i_inv);var h=this.maxBias;this.bias=m(-te(this.errorBias,t)*c/t,-h,h),this.jMax=this.maxForce*t,this.bias||(this.jAcc=0)},ue.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv,i.w+=n*i.i_inv},ue.prototype.applyImpulse=function(){if(this.bias){var t=this.a,e=this.b,i=e.w-t.w,n=this.ratchet,r=-(this.bias+i)*this.iSum,s=this.jAcc;this.jAcc=m((s+r)*n,0,this.jMax*Math.abs(n))/n,r=this.jAcc-s,t.w-=r*t.i_inv,e.w+=r*e.i_inv}},ue.prototype.getImpulse=function(t){return Math.abs(t.jAcc)};var _e=cp.GearJoint=function(t,e,i,n){ee.call(this,t,e),this.phase=i,this.ratio=n,this.ratio_inv=1/n,this.jAcc=0,this.iSum=this.bias=this.jMax=0};_e.prototype=Object.create(ee.prototype),_e.prototype.preStep=function(t){var e=this.a,i=this.b;this.iSum=1/(e.i_inv*this.ratio_inv+this.ratio*i.i_inv);var n=this.maxBias;this.bias=m(-te(this.errorBias,t)*(i.a*this.ratio-e.a-this.phase)/t,-n,n),this.jMax=this.maxForce*t},_e.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv*this.ratio_inv,i.w+=n*i.i_inv},_e.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=e.w*this.ratio-t.w,n=(this.bias-i)*this.iSum,r=this.jAcc;this.jAcc=m(r+n,-this.jMax,this.jMax),n=this.jAcc-r,t.w-=n*t.i_inv*this.ratio_inv,e.w+=n*e.i_inv},_e.prototype.getImpulse=function(){return Math.abs(this.jAcc)},_e.prototype.setRatio=function(t){this.ratio=t,this.ratio_inv=1/t,this.activateBodies()};var de=cp.SimpleMotor=function(t,e,i){ee.call(this,t,e),this.rate=i,this.jAcc=0,this.iSum=this.jMax=0};de.prototype=Object.create(ee.prototype),de.prototype.preStep=function(t){this.iSum=1/(this.a.i_inv+this.b.i_inv),this.jMax=this.maxForce*t},de.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv,i.w+=n*i.i_inv},de.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=-(e.w-t.w+this.rate)*this.iSum,n=this.jAcc;this.jAcc=m(n+i,-this.jMax,this.jMax),i=this.jAcc-n,t.w-=i*t.i_inv,e.w+=i*e.i_inv},de.prototype.getImpulse=function(){return Math.abs(this.jAcc)}}),{}],312:[(function(t,e,i){e.exports=(function(){"use strict";var t=Math.round(window.devicePixelRatio||1),e=function(t,e){this._color=e||"#666",this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._canvas.className="pstats-canvas",t.appendChild(this._canvas)};e.prototype.init=function(e,i){var n=e*t,r=i*t;this._canvas.width=n,this._canvas.height=r,this._canvas.style.width=e+"px",this._canvas.style.height=i+"px",this._ctx.globalAlpha=1,this._ctx.fillStyle="#444",this._ctx.fillRect(0,0,n,r)};var i=Math.round(window.devicePixelRatio||1),n=(function(t){function e(e,i){t.call(this,e,i),this._current=0,this._max=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t,e){var n=this._canvas.width,r=this._canvas.height;this._current+=.1*(t-this._current),this._max*=.99,this._current>this._max&&(this._max=this._current);var s=Math.round((1-this._current/this._max)*r);this._ctx.globalAlpha=1,this._ctx.drawImage(this._canvas,i,0,n-i,r,0,0,n-i,r),e?(this._ctx.fillStyle="#444",this._ctx.fillRect(n-i,0,i,r),this._ctx.fillStyle="#b70000",this._ctx.fillRect(n-i,s,i,r-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(n-i,s,i,i)):(this._ctx.fillStyle="#444",this._ctx.fillRect(n-i,0,i,r),this._ctx.fillStyle=this._color,this._ctx.fillRect(n-i,s,i,r-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(n-i,s,i,i))},e})(e),r=Math.round(window.devicePixelRatio||1),s=(function(t){function e(e,i){t.call(this,e,i),this._threshold=0,this._canvas2=document.createElement("canvas"),this._ctx2=this._canvas2.getContext("2d")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e,i){t.prototype.init.call(this,e,i);var n=e*r,s=i*r;this._canvas2.width=n,this._canvas2.height=s,this._canvas2.style.width=e+"px",this._canvas2.style.height=i+"px",this._ctx2.globalAlpha=1,this._ctx2.fillStyle="#444",this._ctx2.fillRect(0,0,n,s)},e.prototype.draw=function(t,e){var i=this._canvas.width,n=this._canvas.height;if(this._ctx.globalAlpha=1,this._ctx2.globalAlpha=1,t>this._threshold){var s=n*((t-t%n)/n+1),o=this._threshold;this._threshold=s;var a=o/s;this._ctx2.drawImage(this._canvas,0,0),this._ctx.fillStyle="#444",this._ctx.fillRect(0,0,i,n),this._ctx.drawImage(this._canvas2,r,0,i-r,n,0,Math.round((1-a)*n),i-r,n)}else this._ctx.drawImage(this._canvas,r,0,i-r,n,0,0,i-r,n);var c=Math.round(n*(1-t/this._threshold));e?(this._ctx.fillStyle="#444",this._ctx.fillRect(i-r,0,r,n),this._ctx.fillStyle="#b70000",this._ctx.fillRect(i-r,c,r,n-c),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-r,c,r,r)):(this._ctx.fillStyle="#444",this._ctx.fillRect(i-r,0,r,n),this._ctx.fillStyle=this._color,this._ctx.fillRect(i-r,c,r,n-c),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-r,c,r,r))},e})(e),o=Math.round(window.devicePixelRatio||1),a=(function(t){function e(e,i,n,r){t.call(this,e,i),this._min=n,this._max=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t,e){var i=this._canvas.width,n=this._canvas.height,r=(t-this._min)/(this._max-this._min),s=Math.round((1-r)*n);this._ctx.globalAlpha=1,this._ctx.drawImage(this._canvas,o,0,i-o,n,0,0,i-o,n),e?(this._ctx.fillStyle="#444",this._ctx.fillRect(i-o,0,o,n),this._ctx.fillStyle="#b70000",this._ctx.fillRect(i-o,s,o,n-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-o,s,o,o)):(this._ctx.fillStyle="#444",this._ctx.fillRect(i-o,0,o,n),this._ctx.fillStyle=this._color,this._ctx.fillRect(i-o,s,o,n-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-o,s,o,o))},e})(e),c=Math.round(window.devicePixelRatio||1),h=function(t,e){this._colors=e,this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._canvas.className="pstats-canvas",t.appendChild(this._canvas)};h.prototype.init=function(t,e,i){var n=t*c,r=e*c;this._canvas.width=n,this._canvas.height=r*i,this._canvas.style.width=t+"px",this._canvas.style.height=e*i+"px",this._ctx.globalAlpha=1,this._ctx.fillStyle="#444",this._ctx.fillRect(0,0,n,r*i)},h.prototype.draw=function(t){var e=this._canvas.width,i=this._canvas.height;this._ctx.globalAlpha=1,this._ctx.drawImage(this._canvas,c,0,e-c,i,0,0,e-c,i);for(var n=0,r=0;r<t.length;++r){var s=t[r]*i;this._ctx.fillStyle=this._colors[r],this._ctx.fillRect(e-c,n,c,s),n+=s}};var l=function(t,e){this._id=t,this._opts=e||{},this._value=0,this._total=0,this._averageValue=0,this._accumValue=0,this._accumSamples=0,this._accumStart=window.performance.now()},u={value:{}};l.prototype._average=function(t){if(this._opts.average){this._accumValue+=t,++this._accumSamples;var e=performance.now();e-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=e,this._accumSamples=0)}},u.value.get=function(){return this._value},u.value.set=function(t){this._value=t},l.prototype.sample=function(){this._average(this._value)},l.prototype.human=function(){var t=this._opts.average?this._averageValue:this._value;return Math.round(100*t)/100},l.prototype.alarm=function(){return this._opts.below&&this._value<this._opts.below||this._opts.over&&this._value>this._opts.over},Object.defineProperties(l.prototype,u);var _=(function(t){function e(e,i){t.call(this,e,i),this._time=window.performance.now()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.start=function(){this._time=window.performance.now()},e.prototype.end=function(){this._value=window.performance.now()-this._time,this._average(this._value)},e.prototype.tick=function(){this.end(),this.start()},e.prototype.frame=function(){var t=window.performance.now(),e=t-this._time;this._total++;e>(this._opts.average||1e3)&&(this._value=1e3*this._total/e,this._total=0,this._time=t,this._average(this._value))},e})(l),d=Math.log(1024),f=["Bytes","KB","MB","GB","TB"],p=(function(t){function e(e,i,n){t.call(this,i,n),this._stats=e,this._start=0,0===n.extension.indexOf("memory.")&&(this._field=n.extension.substring(7))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapshot=function(){this._value=this._stats[this._field]},e.prototype.start=function(){this._start=this._stats[this._field]},e.prototype.end=function(){this._value=this._stats[this._field]-this._start},e.prototype.human=function(){return (function(t){var e=Math.floor(Math.log(t)/d);return 0===t?"n/a":Math.round(100*t/Math.pow(1024,e))/100+" "+f[e]})(t.prototype.human.call(this))},e})(l),m=function(){0===window.performance.memory.totalJSHeapSize&&console.warn("totalJSHeapSize === 0, performance.memory is only available in Chrome."),this._used=0,this._total=0,this._lastUsed=0},g={alarm:{},used:{},total:{}};m.prototype.tick=function(){this._lastUsed=this._used,this._used=window.performance.memory.usedJSHeapSize,this._total=window.performance.memory.totalJSHeapSize},g.alarm.get=function(){return this._used-this._lastUsed<0},g.used.get=function(){return window.performance.memory.usedJSHeapSize},g.total.get=function(){return this._total},m.prototype.counter=function(t,e){return new p(this,t,e)},Object.defineProperties(m.prototype,g);var y={memory:m},v=document.createElement("style");v.type="text/css",v.textContent="\n .pstats {\n position: fixed;\n z-index: 9999;\n\n padding: 5px;\n width: 250px;\n right: 5px;\n bottom: 5px;\n\n font-size: 10px;\n font-family: 'Roboto Condensed', tahoma, sans-serif;\n overflow: hidden;\n user-select: none;\n cursor: default;\n\n background: #222;\n border-radius: 3px;\n }\n\n .pstats-container {\n display: block;\n position: relative;\n color: #888;\n white-space: nowrap;\n }\n\n .pstats-item {\n position: absolute;\n width: 250px;\n height: 12px;\n left: 0px;\n }\n\n .pstats-label {\n position: absolute;\n width: 150px;\n height: 12px;\n text-align: left;\n transition: background 0.3s;\n }\n\n .pstats-label.alarm {\n color: #ccc;\n background: #800;\n\n transition: background 0s;\n }\n\n .pstats-counter-id {\n position: absolute;\n width: 90px;\n left: 0px;\n }\n\n .pstats-counter-value {\n position: absolute;\n width: 60px;\n left: 90px;\n text-align: right;\n }\n\n .pstats-canvas {\n display: block;\n position: absolute;\n right: 0px;\n top: 1px;\n }\n\n .pstats-fraction {\n position: absolute;\n width: 250px;\n left: 0px;\n }\n\n .pstats-legend {\n position: absolute;\n width: 150px;\n\n text-align: right;\n }\n\n .pstats-legend > span {\n position: absolute;\n right: 0px;\n }\n",document.head.appendChild(v);var x=function(t,e){if(e=e||{},this._showGraph=void 0===e.showGraph||e._showGraph,this._values=e.values||{},this._fractions=e.fractions||[],this._id2counter={},this._id2item={},this._name2extStats={},e.css){var i=document.createElement("style");i.type="text/css",i.textContent=e.css,document.head.appendChild(i)}if(e.extensions)for(var r=0;r<e.extensions.length;++r){var o=e.extensions[r],c=y[o];c?this._name2extStats[o]=new c:console.warn("Can not find extensions "+o+", please register your extension via pstats.register().")}this._root=document.createElement("div"),this._root.className="pstats";var l=document.createElement("div");l.className="pstats-container",this._root.appendChild(l);var u=0;for(var _ in this._values){var d=this._values[_],f=document.createElement("div");f.className="pstats-item";var p=document.createElement("div");p.className="pstats-label";var m=document.createElement("span");m.className="pstats-counter-id",m.textContent=d.desc||_;var g=document.createElement("div");g.className="pstats-counter-value";var v=document.createTextNode("");v.nodeValue="0",p.appendChild(m),p.appendChild(g),g.appendChild(v),f.appendChild(p);var x=void 0;this._showGraph&&(x=void 0!==d.min||void 0!==d.max?new a(f,d.color,d.min||0,d.max||9999):d.threshold?new s(f,d.color):new n(f,d.color)).init(95,10),this._id2item[_]={label:p,valueText:v,graph:x},f.style.top=u+"px",l.appendChild(f),u+=12}if(this._showGraph&&e.fractions)for(var C=0;C<e.fractions.length;++C){var T=e.fractions[C],b=T.steps,A=10*b.length+2;T.colors=T.colors||["#850700","#c74900","#fcb300","#284280","#4c7c0c"];var S=document.createElement("div");S.className="pstats-fraction";var w=document.createElement("div");w.className="pstats-legend",w.style.height=A+"px";for(var E=0;E<b.length;++E){var I=document.createElement("span");I.textContent=b[E],I.style.color=T.colors[E],I.style.top=10*E+"px",w.appendChild(I)}S.appendChild(w),S.style.height=A+"px",S.style.top=u+"px";var R=new h(S,T.colors);R.init(95,10,b.length),T.graph=R,T.values=new Array(b.length),l.appendChild(S),u+=10*b.length+2}l.style.height=u+"px",this._root.style.height=u+"px",this._showGraph||(this._root.style.width="150px"),t.appendChild(this._root)};x.prototype.item=function(t){if(!t)return null;var e=this._id2counter[t];if(e)return e;var i=this._values[t];if(!i)return null;if(i.extension){var n=i.extension.indexOf("."),r=i.extension.substring(0,n),s=this._name2extStats[r];if(!s)return console.error("extension "+r+" not found, make sure you have register and enable it."),null;e=s.counter(t,i)}else e=new _(t,i);return this._id2counter[t]=e,e},x.prototype.tick=function(){for(var t in this._name2extStats){this._name2extStats[t].tick()}for(var e in this._values){var i=this._id2counter[e];if(i){i.sample();var n=i.alarm(),r=i.human(),s=this._id2item[e];s.label.classList.toggle("alarm",n>0),s.valueText.nodeValue=r,this._showGraph&&s.graph.draw(i.value,n)}}if(this._showGraph)for(var o=0;o<this._fractions.length;++o){var a=this._fractions[o],c=this._id2counter[a.base];if(c){for(var h=a.steps,l=0;l<h.length;++l){var u=h[l],_=this._id2counter[u];_&&(a.values[l]=_.value/c.value)}a.graph.draw(a.values)}}},(function(){if(void 0===window.performance&&(window.performance={}),!window.performance.now){var t=Date.now();performance.timing&&performance.timing.navigationStart&&(t=performance.timing.navigationStart),window.performance.now=function(){return Date.now()-t}}window.performance.mark||(window.performance.mark=function(){}),window.performance.measure||(window.performance.measure=function(){}),window.performance.memory||(window.performance.memory={usedJSHeapSize:0,totalJSHeapSize:0})})();return{new:function(t,e){var i=new x(t,e);return function(t){return t?i.item(t):i}},register:function(t,e){y[t]=e}}})()}),{}],313:[(function(t,e,i){function n(t,e){void 0===s[t]&&(s[t]=e)}function r(t){return"object"==typeof s[t]}var s="undefined"==typeof window?global:window;n("CC_TEST",r("tap")||r("QUnit")),n("CC_EDITOR",r("Editor")&&r("process")&&"electron"in process.versions),n("CC_PREVIEW",!0),n("CC_DEV",!0),n("CC_DEBUG",!0),n("CC_JSB",r("jsb")),n("CC_BUILD",!1),n("CC_WECHATGAME",!1),n("CC_QQPLAY",!1),n("CC_SUPPORT_JIT",!0),cc={},_ccsg={},t("./CCDebugger"),cc._initDebugSetting(cc.DebugMode.INFO),t("./polyfill/string"),t("./polyfill/misc"),t("./polyfill/array"),t("./polyfill/typescript"),t("./cocos2d/kazmath"),t("./cocos2d/core/predefine"),ccs={},cp={},t("./cocos2d/shaders"),t("./CCBoot"),t("./cocos2d"),t("./extends"),e.exports=cc}),{"./CCBoot":1,"./CCDebugger":2,"./DebugInfos":3,"./cocos2d":243,"./cocos2d/core/predefine":202,"./cocos2d/kazmath":247,"./cocos2d/shaders":274,"./extends":289,"./package.json":void 0,"./polyfill/array":314,"./polyfill/misc":315,"./polyfill/string":316,"./polyfill/typescript":317}],314:[(function(t,e,i){Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)})}),{}],315:[(function(t,e,i){if(Math.sign||(Math.sign=function(t){return 0==(t=+t)||isNaN(t)?t:t>0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),!console.time){var n=window.performance||Date,r=Object.create(null);console.time=function(t){r[t]=n.now()},console.timeEnd=function(t){var e=r[t],i=n.now()-e;console.log(t+": "+i+"ms")}}}),{}],316:[(function(t,e,i){String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.lastIndexOf(t,e)===e}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){(void 0===e||e>this.length)&&(e=this.length),e-=t.length;var i=this.indexOf(t,e);return-1!==i&&i===e})}),{}],317:[(function(t,e,i){var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};window.__extends=function(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)},window.__assign=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},window.__rest=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&(i[n[r]]=t[n[r]])}return i},window.__decorate=function(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o},window.__param=function(t,e){return function(i,n){e(i,n,t)}},window.__metadata=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},window.__awaiter=function(t,e,i,n){return new(i||(i=Promise))(function(r,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,a)}c((n=n.apply(t,e||[])).next())})},window.__generator=function(t,e){function i(i){return function(o){return (function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(s=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(s=s.call(r,i[1])).done)return s;switch(r=0,s&&(i=[0,s.value]),i[0]){case 0:case 1:s=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(s=a.trys,!(s=s.length>0&&s[s.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){a.label=i[1];break}if(6===i[0]&&a.label<s[1]){a.label=s[1],s=i;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(i);break}s[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}})([i,o])}}var n,r,s,o,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o},window.__exportStar=function(t,e){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])},window.__values=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],i=0;return e?e.call(t):{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}},window.__read=function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,s=i.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return o},window.__spread=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(__read(arguments[e]));return t},window.__await=function(t){return this instanceof __await?(this.v=t,this):new __await(t)},window.__asyncGenerator=function(t,e,i){function n(t){h[t]&&(c[t]=function(e){return new Promise(function(i,n){l.push([t,e,i,n])>1||r(t,e)})})}function r(t,e){try{(function(t){t.value instanceof __await?Promise.resolve(t.value.v).then(s,o):a(l[0][2],t)})(h[t](e))}catch(t){a(l[0][3],t)}}function s(t){r("next",t)}function o(t){r("throw",t)}function a(t,e){t(e),l.shift(),l.length&&r(l[0][0],l[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var c,h=i.apply(t,e||[]),l=[];return c={},n("next"),n("throw"),n("return"),c[Symbol.asyncIterator]=function(){return this},c},window.__asyncDelegator=function(t){function e(e,r){t[e]&&(i[e]=function(i){return(n=!n)?{value:__await(t[e](i)),done:"return"===e}:r?r(i):i})}var i,n;return i={},e("next"),e("throw",(function(t){throw t})),e("return"),i[Symbol.iterator]=function(){return this},i},window.__asyncValues=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator];return e?e.call(t):"function"==typeof __values?__values(t):t[Symbol.iterator]()}}),{}]},{},[313]);