require=function t(e,i,r){function n(o,a){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=i[o]={exports:{}};e[o][0].call(u.exports,function(t){var i=e[o][1][t];return n(i?i:t)},u,u.exports,t,e,i,r)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)n(r[o]);return n}({pixi:[function(t,e,i){(function(){var t=this,r=r||{};r.WEBGL_RENDERER=0,r.CANVAS_RENDERER=1,r.VERSION="v2.2.3",r.blendModes={NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},r.scaleModes={DEFAULT:0,LINEAR:0,NEAREST:1},r._UID=0,"undefined"!=typeof Float32Array?(r.Float32Array=Float32Array,r.Uint16Array=Uint16Array,r.Uint32Array=Uint32Array,r.ArrayBuffer=ArrayBuffer):(r.Float32Array=Array,r.Uint16Array=Array),r.INTERACTION_FREQUENCY=30,r.AUTO_PREVENT_DEFAULT=!0,r.PI_2=2*Math.PI,r.RAD_TO_DEG=180/Math.PI,r.DEG_TO_RAD=Math.PI/180,r.RETINA_PREFIX="@2x",r.dontSayHello=!1,r.defaultRenderOptions={view:null,transparent:!1,antialias:!1,preserveDrawingBuffer:!1,resolution:1,clearBeforeRender:!0,autoResize:!1},r.sayHello=function(t){if(!r.dontSayHello){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var e=["%c %c %c Pixi.js "+r.VERSION+" - "+t+" %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ ","background: #ff66a5","background: #ff66a5","color: #ff66a5; background: #030307;","background: #ff66a5","background: #ffc3dc","background: #ff66a5","color: #ff2424; background: #fff","color: #ff2424; background: #fff","color: #ff2424; background: #fff"];console.log.apply(console,e)}else window.console&&console.log("Pixi.js "+r.VERSION+" - http://www.pixijs.com/");r.dontSayHello=!0}},r.Point=function(t,e){this.x=t||0,this.y=e||0},r.Point.prototype.clone=function(){return new r.Point(this.x,this.y)},r.Point.prototype.set=function(t,e){this.x=t||0,this.y=e||(0!==e?this.x:0)},r.Point.prototype.constructor=r.Point,r.Rectangle=function(t,e,i,r){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0},r.Rectangle.prototype.clone=function(){return new r.Rectangle(this.x,this.y,this.width,this.height)},r.Rectangle.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var r=this.y;if(e>=r&&e<=r+this.height)return!0}return!1},r.Rectangle.prototype.constructor=r.Rectangle,r.EmptyRectangle=new r.Rectangle(0,0,0,0),r.Polygon=function(t){if(t instanceof Array||(t=Array.prototype.slice.call(arguments)),t[0]instanceof r.Point){for(var e=[],i=0,n=t.length;n>i;i++)e.push(t[i].x,t[i].y);t=e}this.closed=!0,this.points=t},r.Polygon.prototype.clone=function(){var t=this.points.slice();return new r.Polygon(t)},r.Polygon.prototype.contains=function(t,e){for(var i=!1,r=this.points.length/2,n=0,s=r-1;r>n;s=n++){var o=this.points[2*n],a=this.points[2*n+1],h=this.points[2*s],l=this.points[2*s+1],u=a>e!=l>e&&(h-o)*(e-a)/(l-a)+o>t;u&&(i=!i)}return i},r.Polygon.prototype.constructor=r.Polygon,r.Circle=function(t,e,i){this.x=t||0,this.y=e||0,this.radius=i||0},r.Circle.prototype.clone=function(){return new r.Circle(this.x,this.y,this.radius)},r.Circle.prototype.contains=function(t,e){if(this.radius<=0)return!1;var i=this.x-t,r=this.y-e,n=this.radius*this.radius;return i*=i,r*=r,n>=i+r},r.Circle.prototype.getBounds=function(){return new r.Rectangle(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)},r.Circle.prototype.constructor=r.Circle,r.Ellipse=function(t,e,i,r){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0},r.Ellipse.prototype.clone=function(){return new r.Ellipse(this.x,this.y,this.width,this.height)},r.Ellipse.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,1>=i+r},r.Ellipse.prototype.getBounds=function(){return new r.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},r.Ellipse.prototype.constructor=r.Ellipse,r.RoundedRectangle=function(t,e,i,r,n){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0,this.radius=n||20},r.RoundedRectangle.prototype.clone=function(){return new r.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},r.RoundedRectangle.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var r=this.y;if(e>=r&&e<=r+this.height)return!0}return!1},r.RoundedRectangle.prototype.constructor=r.RoundedRectangle,r.Matrix=function(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0},r.Matrix.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},r.Matrix.prototype.toArray=function(t){this.array||(this.array=new r.Float32Array(9));var e=this.array;return t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},r.Matrix.prototype.apply=function(t,e){return e=e||new r.Point,e.x=this.a*t.x+this.c*t.y+this.tx,e.y=this.b*t.x+this.d*t.y+this.ty,e},r.Matrix.prototype.applyInverse=function(t,e){e=e||new r.Point;var i=1/(this.a*this.d+this.c*-this.b);return e.x=this.d*i*t.x+-this.c*i*t.y+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*t.y+-this.b*i*t.x+(-this.ty*this.a+this.tx*this.b)*i,e},r.Matrix.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},r.Matrix.prototype.scale=function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},r.Matrix.prototype.rotate=function(t){var e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,s=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=s*e-this.ty*i,this.ty=s*i+this.ty*e,this},r.Matrix.prototype.append=function(t){var e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this},r.Matrix.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},r.identityMatrix=new r.Matrix,r.DisplayObject=function(){this.position=new r.Point,this.scale=new r.Point(1,1),this.pivot=new r.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.defaultCursor="pointer",this.worldTransform=new r.Matrix,this._sr=0,this._cr=1,this.filterArea=null,this._bounds=new r.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},r.DisplayObject.prototype.constructor=r.DisplayObject,Object.defineProperty(r.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(t){this._interactive=t,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(r.DisplayObject.prototype,"worldVisible",{get:function(){var t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}}),Object.defineProperty(r.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.isMask=!1),this._mask=t,this._mask&&(this._mask.isMask=!0)}}),Object.defineProperty(r.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(t){if(t){for(var e=[],i=0;i<t.length;i++)for(var r=t[i].passes,n=0;n<r.length;n++)e.push(r[n]);this._filterBlock={target:this,filterPasses:e}}this._filters=t}}),Object.defineProperty(r.DisplayObject.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(t?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=t)}}),r.DisplayObject.prototype.updateTransform=function(){var t,e,i,n,s,o,a=this.parent.worldTransform,h=this.worldTransform;this.rotation%r.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),t=this._cr*this.scale.x,e=this._sr*this.scale.x,i=-this._sr*this.scale.y,n=this._cr*this.scale.y,s=this.position.x,o=this.position.y,(this.pivot.x||this.pivot.y)&&(s-=this.pivot.x*t+this.pivot.y*i,o-=this.pivot.x*e+this.pivot.y*n),h.a=t*a.a+e*a.c,h.b=t*a.b+e*a.d,h.c=i*a.a+n*a.c,h.d=i*a.b+n*a.d,h.tx=s*a.a+o*a.c+a.tx,h.ty=s*a.b+o*a.d+a.ty):(t=this.scale.x,n=this.scale.y,s=this.position.x-this.pivot.x*t,o=this.position.y-this.pivot.y*n,h.a=t*a.a,h.b=t*a.b,h.c=n*a.c,h.d=n*a.d,h.tx=s*a.a+o*a.c+a.tx,h.ty=s*a.b+o*a.d+a.ty),this.worldAlpha=this.alpha*this.parent.worldAlpha},r.DisplayObject.prototype.displayObjectUpdateTransform=r.DisplayObject.prototype.updateTransform,r.DisplayObject.prototype.getBounds=function(t){return t=t,r.EmptyRectangle},r.DisplayObject.prototype.getLocalBounds=function(){return this.getBounds(r.identityMatrix)},r.DisplayObject.prototype.setStageReference=function(t){this.stage=t,this._interactive&&(this.stage.dirty=!0)},r.DisplayObject.prototype.generateTexture=function(t,e,i){var n=this.getLocalBounds(),s=new r.RenderTexture(0|n.width,0|n.height,i,e,t);return r.DisplayObject._tempMatrix.tx=-n.x,r.DisplayObject._tempMatrix.ty=-n.y,s.render(this,r.DisplayObject._tempMatrix),s},r.DisplayObject.prototype.updateCache=function(){this._generateCachedSprite()},r.DisplayObject.prototype.toGlobal=function(t){return this.displayObjectUpdateTransform(),this.worldTransform.apply(t)},r.DisplayObject.prototype.toLocal=function(t,e){return e&&(t=e.toGlobal(t)),this.displayObjectUpdateTransform(),this.worldTransform.applyInverse(t)},r.DisplayObject.prototype._renderCachedSprite=function(t){this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?r.Sprite.prototype._renderWebGL.call(this._cachedSprite,t):r.Sprite.prototype._renderCanvas.call(this._cachedSprite,t)},r.DisplayObject.prototype._generateCachedSprite=function(){this._cacheAsBitmap=!1;var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.texture.resize(0|t.width,0|t.height);else{var e=new r.RenderTexture(0|t.width,0|t.height);this._cachedSprite=new r.Sprite(e),this._cachedSprite.worldTransform=this.worldTransform}var i=this._filters;this._filters=null,this._cachedSprite.filters=i,r.DisplayObject._tempMatrix.tx=-t.x,r.DisplayObject._tempMatrix.ty=-t.y,this._cachedSprite.texture.render(this,r.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-(t.x/t.width),this._cachedSprite.anchor.y=-(t.y/t.height),this._filters=i,this._cacheAsBitmap=!0},r.DisplayObject.prototype._destroyCachedSprite=function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)},r.DisplayObject.prototype._renderWebGL=function(t){t=t},r.DisplayObject.prototype._renderCanvas=function(t){t=t},r.DisplayObject._tempMatrix=new r.Matrix,Object.defineProperty(r.DisplayObject.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(r.DisplayObject.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t}}),r.DisplayObjectContainer=function(){r.DisplayObject.call(this),this.children=[]},r.DisplayObjectContainer.prototype=Object.create(r.DisplayObject.prototype),r.DisplayObjectContainer.prototype.constructor=r.DisplayObjectContainer,Object.defineProperty(r.DisplayObjectContainer.prototype,"width",{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}}),Object.defineProperty(r.DisplayObjectContainer.prototype,"height",{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}}),r.DisplayObjectContainer.prototype.addChild=function(t){return this.addChildAt(t,this.children.length)},r.DisplayObjectContainer.prototype.addChildAt=function(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),this.stage&&t.setStageReference(this.stage),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},r.DisplayObjectContainer.prototype.swapChildren=function(t,e){if(t!==e){var i=this.getChildIndex(t),r=this.getChildIndex(e);if(0>i||0>r)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[r]=t}},r.DisplayObjectContainer.prototype.getChildIndex=function(t){var e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e},r.DisplayObjectContainer.prototype.setChildIndex=function(t,e){if(0>e||e>=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)},r.DisplayObjectContainer.prototype.getChildAt=function(t){if(0>t||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]},r.DisplayObjectContainer.prototype.removeChild=function(t){var e=this.children.indexOf(t);return-1!==e?this.removeChildAt(e):void 0},r.DisplayObjectContainer.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return this.stage&&e.removeStageReference(),e.parent=void 0,this.children.splice(t,1),e},r.DisplayObjectContainer.prototype.removeChildren=function(t,e){var i=t||0,r="number"==typeof e?e:this.children.length,n=r-i;if(n>0&&r>=n){for(var s=this.children.splice(i,n),o=0;o<s.length;o++){var a=s[o];this.stage&&a.removeStageReference(),a.parent=void 0}return s}if(0===n&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},r.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var t=0,e=this.children.length;e>t;t++)this.children[t].updateTransform()},r.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=r.DisplayObjectContainer.prototype.updateTransform,r.DisplayObjectContainer.prototype.getBounds=function(){if(0===this.children.length)return r.EmptyRectangle;for(var t,e,i,n=1/0,s=1/0,o=-1/0,a=-1/0,h=!1,l=0,u=this.children.length;u>l;l++){var c=this.children[l];c.visible&&(h=!0,t=this.children[l].getBounds(),n=n<t.x?n:t.x,s=s<t.y?s:t.y,e=t.width+t.x,i=t.height+t.y,o=o>e?o:e,a=a>i?a:i)}if(!h)return r.EmptyRectangle;var d=this._bounds;return d.x=n,d.y=s,d.width=o-n,d.height=a-s,d},r.DisplayObjectContainer.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=r.identityMatrix;for(var e=0,i=this.children.length;i>e;e++)this.children[e].updateTransform();var n=this.getBounds();return this.worldTransform=t,n},r.DisplayObjectContainer.prototype.setStageReference=function(t){this.stage=t,this._interactive&&(this.stage.dirty=!0);for(var e=0,i=this.children.length;i>e;e++){var r=this.children[e];r.setStageReference(t)}},r.DisplayObjectContainer.prototype.removeStageReference=function(){for(var t=0,e=this.children.length;e>t;t++){var i=this.children[t];i.removeStageReference()}this._interactive&&(this.stage.dirty=!0),this.stage=null},r.DisplayObjectContainer.prototype._renderWebGL=function(t){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(t);var e,i;if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t)}},r.DisplayObjectContainer.prototype._renderCanvas=function(t){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(t);this._mask&&t.maskManager.pushMask(this._mask,t);for(var e=0,i=this.children.length;i>e;e++){var r=this.children[e];r._renderCanvas(t)}this._mask&&t.maskManager.popMask(t)}},r.Sprite=function(t){r.DisplayObjectContainer.call(this),this.anchor=new r.Point,this.texture=t||r.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.blendMode=r.blendModes.NORMAL,this.shader=null,this.texture.baseTexture.hasLoaded?this.onTextureUpdate():this.texture.on("update",this.onTextureUpdate.bind(this)),this.renderable=!0},r.Sprite.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Sprite.prototype.constructor=r.Sprite,Object.defineProperty(r.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(r.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),r.Sprite.prototype.setTexture=function(t){this.texture=t,this.cachedTint=16777215},r.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},r.Sprite.prototype.getBounds=function(t){var e=this.texture.frame.width,i=this.texture.frame.height,r=e*(1-this.anchor.x),n=e*-this.anchor.x,s=i*(1-this.anchor.y),o=i*-this.anchor.y,a=t||this.worldTransform,h=a.a,l=a.b,u=a.c,c=a.d,d=a.tx,p=a.ty,f=-1/0,g=-1/0,m=1/0,v=1/0;if(0===l&&0===u)0>h&&(h*=-1),0>c&&(c*=-1),m=h*n+d,f=h*r+d,v=c*o+p,g=c*s+p;else{var x=h*n+u*o+d,y=c*o+l*n+p,b=h*r+u*o+d,T=c*o+l*r+p,w=h*r+u*s+d,S=c*s+l*r+p,C=h*n+u*s+d,A=c*s+l*n+p;m=m>x?x:m,m=m>b?b:m,m=m>w?w:m,m=m>C?C:m,v=v>y?y:v,v=v>T?T:v,v=v>S?S:v,v=v>A?A:v,f=x>f?x:f,f=b>f?b:f,f=w>f?w:f,f=C>f?C:f,g=y>g?y:g,g=T>g?T:g,g=S>g?S:g,g=A>g?A:g}var _=this._bounds;return _.x=m,_.width=f-m,_.y=v,_.height=g-v,this._currentBounds=_,_},r.Sprite.prototype._renderWebGL=function(t){if(this.visible&&!(this.alpha<=0)){var e,i;if(this._mask||this._filters){var r=t.spriteBatch;for(this._filters&&(r.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(r.stop(),t.maskManager.pushMask(this.mask,t),r.start()),r.render(this),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t);r.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),r.start()}else for(t.spriteBatch.render(this),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t)}},r.Sprite.prototype._renderCanvas=function(t){if(!(this.visible===!1||0===this.alpha||this.texture.crop.width<=0||this.texture.crop.height<=0)){if(this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,t.context.globalCompositeOperation=r.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t),this.texture.valid){var e=this.texture.baseTexture.resolution/t.resolution;t.context.globalAlpha=this.worldAlpha,t.smoothProperty&&t.scaleMode!==this.texture.baseTexture.scaleMode&&(t.scaleMode=this.texture.baseTexture.scaleMode,t.context[t.smoothProperty]=t.scaleMode===r.scaleModes.LINEAR);var i=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,n=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height;t.roundPixels?(t.context.setTransform(this.worldTransform.a,this.worldTransform.b,this.worldTransform.c,this.worldTransform.d,this.worldTransform.tx*t.resolution|0,this.worldTransform.ty*t.resolution|0),i=0|i,n=0|n):t.context.setTransform(this.worldTransform.a,this.worldTransform.b,this.worldTransform.c,this.worldTransform.d,this.worldTransform.tx*t.resolution,this.worldTransform.ty*t.resolution),16777215!==this.tint?(this.cachedTint!==this.tint&&(this.cachedTint=this.tint,this.tintedTexture=r.CanvasTinter.getTintedTexture(this,this.tint)),t.context.drawImage(this.tintedTexture,0,0,this.texture.crop.width,this.texture.crop.height,i/e,n/e,this.texture.crop.width/e,this.texture.crop.height/e)):t.context.drawImage(this.texture.baseTexture.source,this.texture.crop.x,this.texture.crop.y,this.texture.crop.width,this.texture.crop.height,i/e,n/e,this.texture.crop.width/e,this.texture.crop.height/e)}for(var s=0,o=this.children.length;o>s;s++)this.children[s]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},r.Sprite.fromFrame=function(t){var e=r.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache'+this);return new r.Sprite(e)},r.Sprite.fromImage=function(t,e,i){var n=r.Texture.fromImage(t,e,i);return new r.Sprite(n)},r.SpriteBatch=function(t){r.DisplayObjectContainer.call(this),this.textureThing=t,this.ready=!1},r.SpriteBatch.prototype=Object.create(r.DisplayObjectContainer.prototype),r.SpriteBatch.prototype.constructor=r.SpriteBatch,r.SpriteBatch.prototype.initWebGL=function(t){this.fastSpriteBatch=new r.WebGLFastSpriteBatch(t),this.ready=!0},r.SpriteBatch.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},r.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||this.initWebGL(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},r.SpriteBatch.prototype._renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.children.length){var e=t.context;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var i=this.worldTransform,r=!0,n=0;n<this.children.length;n++){var s=this.children[n];if(s.visible){var o=s.texture,a=o.frame;if(e.globalAlpha=this.worldAlpha*s.alpha,s.rotation%(2*Math.PI)===0)r&&(e.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),r=!1),e.drawImage(o.baseTexture.source,a.x,a.y,a.width,a.height,s.anchor.x*-a.width*s.scale.x+s.position.x+.5|0,s.anchor.y*-a.height*s.scale.y+s.position.y+.5|0,a.width*s.scale.x,a.height*s.scale.y);else{r||(r=!0),s.displayObjectUpdateTransform();var h=s.worldTransform;t.roundPixels?e.setTransform(h.a,h.b,h.c,h.d,0|h.tx,0|h.ty):e.setTransform(h.a,h.b,h.c,h.d,h.tx,h.ty),e.drawImage(o.baseTexture.source,a.x,a.y,a.width,a.height,s.anchor.x*-a.width+.5|0,s.anchor.y*-a.height+.5|0,a.width,a.height)}}}}},r.MovieClip=function(t){r.Sprite.call(this,t[0]),this.textures=t,this.animationSpeed=1,this.loop=!0,this.onComplete=null,this.currentFrame=0,this.playing=!1},r.MovieClip.prototype=Object.create(r.Sprite.prototype),r.MovieClip.prototype.constructor=r.MovieClip,Object.defineProperty(r.MovieClip.prototype,"totalFrames",{get:function(){return this.textures.length}}),r.MovieClip.prototype.stop=function(){this.playing=!1},r.MovieClip.prototype.play=function(){this.playing=!0},r.MovieClip.prototype.gotoAndStop=function(t){this.playing=!1,this.currentFrame=t;var e=this.currentFrame+.5|0;this.setTexture(this.textures[e%this.textures.length])},r.MovieClip.prototype.gotoAndPlay=function(t){this.currentFrame=t,this.playing=!0},r.MovieClip.prototype.updateTransform=function(){if(this.displayObjectContainerUpdateTransform(),this.playing){this.currentFrame+=this.animationSpeed;var t=this.currentFrame+.5|0;this.currentFrame=this.currentFrame%this.textures.length,this.loop||t<this.textures.length?this.setTexture(this.textures[t%this.textures.length]):t>=this.textures.length&&(this.gotoAndStop(this.textures.length-1),this.onComplete&&this.onComplete())}},r.MovieClip.fromFrames=function(t){for(var e=[],i=0;i<t.length;i++)e.push(new r.Texture.fromFrame(t[i]));return new r.MovieClip(e)},r.MovieClip.fromImages=function(t){for(var e=[],i=0;i<t.length;i++)e.push(new r.Texture.fromImage(t[i]));return new r.MovieClip(e)},r.FilterBlock=function(){this.visible=!0,this.renderable=!0},r.FilterBlock.prototype.constructor=r.FilterBlock,r.Text=function(t,e){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.resolution=1,r.Sprite.call(this,r.Texture.fromCanvas(this.canvas)),this.setText(t),this.setStyle(e)},r.Text.prototype=Object.create(r.Sprite.prototype),r.Text.prototype.constructor=r.Text,Object.defineProperty(r.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(r.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),r.Text.prototype.setStyle=function(t){t=t||{},t.font=t.font||"bold 20pt Arial",t.fill=t.fill||"black",t.align=t.align||"left",t.stroke=t.stroke||"black",t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.wordWrapWidth=t.wordWrapWidth||100,t.dropShadow=t.dropShadow||!1,t.dropShadowAngle=t.dropShadowAngle||Math.PI/6,t.dropShadowDistance=t.dropShadowDistance||4,t.dropShadowColor=t.dropShadowColor||"black",this.style=t,this.dirty=!0},r.Text.prototype.setText=function(t){this.text=t.toString()||" ",this.dirty=!0},r.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this.resolution,this.context.font=this.style.font;var t=this.text;this.style.wordWrap&&(t=this.wordWrap(this.text));for(var e=t.split(/(?:\r\n|\r|\n)/),i=[],r=0,n=this.determineFontProperties(this.style.font),s=0;s<e.length;s++){var o=this.context.measureText(e[s]).width;i[s]=o,r=Math.max(r,o)}var a=r+this.style.strokeThickness;this.style.dropShadow&&(a+=this.style.dropShadowDistance),this.canvas.width=(a+this.context.lineWidth)*this.resolution;var h=n.fontSize+this.style.strokeThickness,l=h*e.length;this.style.dropShadow&&(l+=this.style.dropShadowDistance),this.canvas.height=l*this.resolution,this.context.scale(this.resolution,this.resolution),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.lineWidth=this.style.strokeThickness,this.context.textBaseline="alphabetic";var u,c;if(this.style.dropShadow){this.context.fillStyle=this.style.dropShadowColor;var d=Math.sin(this.style.dropShadowAngle)*this.style.dropShadowDistance,p=Math.cos(this.style.dropShadowAngle)*this.style.dropShadowDistance;for(s=0;s<e.length;s++)u=this.style.strokeThickness/2,c=this.style.strokeThickness/2+s*h+n.ascent,"right"===this.style.align?u+=r-i[s]:"center"===this.style.align&&(u+=(r-i[s])/2),this.style.fill&&this.context.fillText(e[s],u+d,c+p)}for(this.context.fillStyle=this.style.fill,s=0;s<e.length;s++)u=this.style.strokeThickness/2,c=this.style.strokeThickness/2+s*h+n.ascent,"right"===this.style.align?u+=r-i[s]:"center"===this.style.align&&(u+=(r-i[s])/2),this.style.stroke&&this.style.strokeThickness&&this.context.strokeText(e[s],u,c),this.style.fill&&this.context.fillText(e[s],u,c);this.updateTexture()},r.Text.prototype.updateTexture=function(){this.texture.baseTexture.width=this.canvas.width,this.texture.baseTexture.height=this.canvas.height,this.texture.crop.width=this.texture.frame.width=this.canvas.width,this.texture.crop.height=this.texture.frame.height=this.canvas.height,this._width=this.canvas.width,this._height=this.canvas.height,this.texture.baseTexture.dirty()},r.Text.prototype._renderWebGL=function(t){this.dirty&&(this.resolution=t.resolution,this.updateText(),this.dirty=!1),r.Sprite.prototype._renderWebGL.call(this,t)},r.Text.prototype._renderCanvas=function(t){this.dirty&&(this.resolution=t.resolution,this.updateText(),this.dirty=!1),r.Sprite.prototype._renderCanvas.call(this,t)},r.Text.prototype.determineFontProperties=function(t){var e=r.Text.fontPropertiesCache[t];if(!e){e={};var i=r.Text.fontPropertiesCanvas,n=r.Text.fontPropertiesContext;n.font=t;var s=Math.ceil(n.measureText("|Mq").width),o=Math.ceil(n.measureText("M").width),a=2*o;o=1.4*o|0,i.width=s,i.height=a,n.fillStyle="#f00",n.fillRect(0,0,s,a),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText("|MÉq",0,o);var h,l,u=n.getImageData(0,0,s,a).data,c=u.length,d=4*s,p=0,f=!1;for(h=0;o>h;h++){for(l=0;d>l;l+=4)if(255!==u[p+l]){f=!0;break}if(f)break;p+=d}for(e.ascent=o-h,p=c-d,f=!1,h=a;h>o;h--){for(l=0;d>l;l+=4)if(255!==u[p+l]){f=!0;break}if(f)break;p-=d}e.descent=h-o,e.descent+=6,e.fontSize=e.ascent+e.descent,r.Text.fontPropertiesCache[t]=e}return e},r.Text.prototype.wordWrap=function(t){for(var e="",i=t.split("\n"),r=0;r<i.length;r++){for(var n=this.style.wordWrapWidth,s=i[r].split(" "),o=0;o<s.length;o++){var a=this.context.measureText(s[o]).width,h=a+this.context.measureText(" ").width;0===o||h>n?(o>0&&(e+="\n"),e+=s[o],n=this.style.wordWrapWidth-a):(n-=h,e+=" "+s[o])}r<i.length-1&&(e+="\n")}return e},r.Text.prototype.getBounds=function(t){return this.dirty&&(this.updateText(),this.dirty=!1),r.Sprite.prototype.getBounds.call(this,t)},r.Text.prototype.destroy=function(t){this.context=null,this.canvas=null,this.texture.destroy(void 0===t?!0:t)},r.Text.fontPropertiesCache={},r.Text.fontPropertiesCanvas=document.createElement("canvas"),r.Text.fontPropertiesContext=r.Text.fontPropertiesCanvas.getContext("2d"),r.BitmapText=function(t,e){r.DisplayObjectContainer.call(this),this.textWidth=0,this.textHeight=0,this._pool=[],this.setText(t),this.setStyle(e),this.updateText(),this.dirty=!1},r.BitmapText.prototype=Object.create(r.DisplayObjectContainer.prototype),r.BitmapText.prototype.constructor=r.BitmapText,r.BitmapText.prototype.setText=function(t){this.text=t||" ",this.dirty=!0},r.BitmapText.prototype.setStyle=function(t){t=t||{},t.align=t.align||"left",this.style=t;var e=t.font.split(" ");this.fontName=e[e.length-1],this.fontSize=e.length>=2?parseInt(e[e.length-2],10):r.BitmapText.fonts[this.fontName].size,this.dirty=!0,this.tint=t.tint},r.BitmapText.prototype.updateText=function(){for(var t=r.BitmapText.fonts[this.fontName],e=new r.Point,i=null,n=[],s=0,o=[],a=0,h=this.fontSize/t.size,l=0;l<this.text.length;l++){var u=this.text.charCodeAt(l);if(/(?:\r\n|\r|\n)/.test(this.text.charAt(l)))o.push(e.x),s=Math.max(s,e.x),a++,e.x=0,e.y+=t.lineHeight,i=null;else{var c=t.chars[u];c&&(i&&c.kerning[i]&&(e.x+=c.kerning[i]),n.push({texture:c.texture,line:a,charCode:u,position:new r.Point(e.x+c.xOffset,e.y+c.yOffset)}),e.x+=c.xAdvance,i=u)}}o.push(e.x),s=Math.max(s,e.x);var d=[];for(l=0;a>=l;l++){var p=0;"right"===this.style.align?p=s-o[l]:"center"===this.style.align&&(p=(s-o[l])/2),d.push(p)}var f=this.children.length,g=n.length,m=this.tint||16777215;for(l=0;g>l;l++){var v=f>l?this.children[l]:this._pool.pop();v?v.setTexture(n[l].texture):v=new r.Sprite(n[l].texture),v.position.x=(n[l].position.x+d[n[l].line])*h,v.position.y=n[l].position.y*h,v.scale.x=v.scale.y=h,v.tint=m,v.parent||this.addChild(v)}for(;this.children.length>g;){var x=this.getChildAt(this.children.length-1);this._pool.push(x),this.removeChild(x)}this.textWidth=s*h,this.textHeight=(e.y+t.lineHeight)*h},r.BitmapText.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),r.DisplayObjectContainer.prototype.updateTransform.call(this)},r.BitmapText.fonts={},r.InteractionData=function(){this.global=new r.Point,this.target=null,this.originalEvent=null},r.InteractionData.prototype.getLocalPosition=function(t,e){var i=t.worldTransform,n=this.global,s=i.a,o=i.c,a=i.tx,h=i.b,l=i.d,u=i.ty,c=1/(s*l+o*-h);return e=e||new r.Point,e.x=l*c*n.x+-o*c*n.y+(u*o-a*l)*c,e.y=s*c*n.y+-h*c*n.x+(-u*s+a*h)*c,e},r.InteractionData.prototype.constructor=r.InteractionData,r.InteractionManager=function(t){this.stage=t,this.mouse=new r.InteractionData,this.touches={},this.tempPoint=new r.Point,this.mouseoverEnabled=!0,this.pool=[],this.interactiveItems=[],this.interactionDOMElement=null,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this.mouseOut=!1,this.resolution=1,this._tempPoint=new r.Point
},r.InteractionManager.prototype.constructor=r.InteractionManager,r.InteractionManager.prototype.collectInteractiveSprite=function(t,e){for(var i=t.children,r=i.length,n=r-1;n>=0;n--){var s=i[n];s._interactive?(e.interactiveChildren=!0,this.interactiveItems.push(s),s.children.length>0&&this.collectInteractiveSprite(s,s)):(s.__iParent=null,s.children.length>0&&this.collectInteractiveSprite(s,e))}},r.InteractionManager.prototype.setTarget=function(t){this.target=t,this.resolution=t.resolution,null===this.interactionDOMElement&&this.setTargetDomElement(t.view)},r.InteractionManager.prototype.setTargetDomElement=function(t){this.removeEvents(),window.navigator.msPointerEnabled&&(t.style["-ms-content-zooming"]="none",t.style["-ms-touch-action"]="none"),this.interactionDOMElement=t,t.addEventListener("mousemove",this.onMouseMove,!0),t.addEventListener("mousedown",this.onMouseDown,!0),t.addEventListener("mouseout",this.onMouseOut,!0),t.addEventListener("touchstart",this.onTouchStart,!0),t.addEventListener("touchend",this.onTouchEnd,!0),t.addEventListener("touchmove",this.onTouchMove,!0),window.addEventListener("mouseup",this.onMouseUp,!0)},r.InteractionManager.prototype.removeEvents=function(){this.interactionDOMElement&&(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]="",this.interactionDOMElement.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,window.removeEventListener("mouseup",this.onMouseUp,!0))},r.InteractionManager.prototype.update=function(){if(this.target){var t=Date.now(),e=t-this.last;if(e=e*r.INTERACTION_FREQUENCY/1e3,!(1>e)){this.last=t;var i=0;this.dirty&&this.rebuildInteractiveGraph();var n=this.interactiveItems.length,s="inherit",o=!1;for(i=0;n>i;i++){var a=this.interactiveItems[i];a.__hit=this.hitTest(a,this.mouse),this.mouse.target=a,a.__hit&&!o?(a.buttonMode&&(s=a.defaultCursor),a.interactiveChildren||(o=!0),a.__isOver||(a.mouseover&&a.mouseover(this.mouse),a.__isOver=!0)):a.__isOver&&(a.mouseout&&a.mouseout(this.mouse),a.__isOver=!1)}this.currentCursorStyle!==s&&(this.currentCursorStyle=s,this.interactionDOMElement.style.cursor=s)}}},r.InteractionManager.prototype.rebuildInteractiveGraph=function(){this.dirty=!1;for(var t=this.interactiveItems.length,e=0;t>e;e++)this.interactiveItems[e].interactiveChildren=!1;this.interactiveItems=[],this.stage.interactive&&this.interactiveItems.push(this.stage),this.collectInteractiveSprite(this.stage,this.stage)},r.InteractionManager.prototype.onMouseMove=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t;var e=this.interactionDOMElement.getBoundingClientRect();this.mouse.global.x=(t.clientX-e.left)*(this.target.width/e.width)/this.resolution,this.mouse.global.y=(t.clientY-e.top)*(this.target.height/e.height)/this.resolution;for(var i=this.interactiveItems.length,r=0;i>r;r++){var n=this.interactiveItems[r];n.mousemove&&n.mousemove(this.mouse)}},r.InteractionManager.prototype.onMouseDown=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t,r.AUTO_PREVENT_DEFAULT&&this.mouse.originalEvent.preventDefault();for(var e=this.interactiveItems.length,i=this.mouse.originalEvent,n=2===i.button||3===i.which,s=n?"rightdown":"mousedown",o=n?"rightclick":"click",a=n?"__rightIsDown":"__mouseIsDown",h=n?"__isRightDown":"__isDown",l=0;e>l;l++){var u=this.interactiveItems[l];if((u[s]||u[o])&&(u[a]=!0,u.__hit=this.hitTest(u,this.mouse),u.__hit&&(u[s]&&u[s](this.mouse),u[h]=!0,!u.interactiveChildren)))break}},r.InteractionManager.prototype.onMouseOut=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t;var e=this.interactiveItems.length;this.interactionDOMElement.style.cursor="inherit";for(var i=0;e>i;i++){var r=this.interactiveItems[i];r.__isOver&&(this.mouse.target=r,r.mouseout&&r.mouseout(this.mouse),r.__isOver=!1)}this.mouseOut=!0,this.mouse.global.x=-1e4,this.mouse.global.y=-1e4},r.InteractionManager.prototype.onMouseUp=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t;for(var e=this.interactiveItems.length,i=!1,r=this.mouse.originalEvent,n=2===r.button||3===r.which,s=n?"rightup":"mouseup",o=n?"rightclick":"click",a=n?"rightupoutside":"mouseupoutside",h=n?"__isRightDown":"__isDown",l=0;e>l;l++){var u=this.interactiveItems[l];(u[o]||u[s]||u[a])&&(u.__hit=this.hitTest(u,this.mouse),u.__hit&&!i?(u[s]&&u[s](this.mouse),u[h]&&u[o]&&u[o](this.mouse),u.interactiveChildren||(i=!0)):u[h]&&u[a]&&u[a](this.mouse),u[h]=!1)}},r.InteractionManager.prototype.hitTest=function(t,e){var i=e.global;if(!t.worldVisible)return!1;t.worldTransform.applyInverse(i,this._tempPoint);var n,s=this._tempPoint.x,o=this._tempPoint.y;if(e.target=t,t.hitArea&&t.hitArea.contains)return t.hitArea.contains(s,o);if(t instanceof r.Sprite){var a,h=t.texture.frame.width,l=t.texture.frame.height,u=-h*t.anchor.x;if(s>u&&u+h>s&&(a=-l*t.anchor.y,o>a&&a+l>o))return!0}else if(t instanceof r.Graphics){var c=t.graphicsData;for(n=0;n<c.length;n++){var d=c[n];if(d.fill&&d.shape&&d.shape.contains(s,o))return!0}}var p=t.children.length;for(n=0;p>n;n++){var f=t.children[n],g=this.hitTest(f,e);if(g)return e.target=t,!0}return!1},r.InteractionManager.prototype.onTouchMove=function(t){this.dirty&&this.rebuildInteractiveGraph();var e,i=this.interactionDOMElement.getBoundingClientRect(),r=t.changedTouches,n=0;for(n=0;n<r.length;n++){var s=r[n];e=this.touches[s.identifier],e.originalEvent=t,e.global.x=(s.clientX-i.left)*(this.target.width/i.width)/this.resolution,e.global.y=(s.clientY-i.top)*(this.target.height/i.height)/this.resolution,!navigator.isCocoonJS||i.left||i.top||t.target.style.width||t.target.style.height||(e.global.x=s.clientX,e.global.y=s.clientY);for(var o=0;o<this.interactiveItems.length;o++){var a=this.interactiveItems[o];a.touchmove&&a.__touchData&&a.__touchData[s.identifier]&&a.touchmove(e)}}},r.InteractionManager.prototype.onTouchStart=function(t){this.dirty&&this.rebuildInteractiveGraph();var e=this.interactionDOMElement.getBoundingClientRect();r.AUTO_PREVENT_DEFAULT&&t.preventDefault();for(var i=t.changedTouches,n=0;n<i.length;n++){var s=i[n],o=this.pool.pop();o||(o=new r.InteractionData),o.originalEvent=t,this.touches[s.identifier]=o,o.global.x=(s.clientX-e.left)*(this.target.width/e.width)/this.resolution,o.global.y=(s.clientY-e.top)*(this.target.height/e.height)/this.resolution,!navigator.isCocoonJS||e.left||e.top||t.target.style.width||t.target.style.height||(o.global.x=s.clientX,o.global.y=s.clientY);for(var a=this.interactiveItems.length,h=0;a>h;h++){var l=this.interactiveItems[h];if((l.touchstart||l.tap)&&(l.__hit=this.hitTest(l,o),l.__hit&&(l.touchstart&&l.touchstart(o),l.__isDown=!0,l.__touchData=l.__touchData||{},l.__touchData[s.identifier]=o,!l.interactiveChildren)))break}}},r.InteractionManager.prototype.onTouchEnd=function(t){this.dirty&&this.rebuildInteractiveGraph();for(var e=this.interactionDOMElement.getBoundingClientRect(),i=t.changedTouches,r=0;r<i.length;r++){var n=i[r],s=this.touches[n.identifier],o=!1;s.global.x=(n.clientX-e.left)*(this.target.width/e.width)/this.resolution,s.global.y=(n.clientY-e.top)*(this.target.height/e.height)/this.resolution,!navigator.isCocoonJS||e.left||e.top||t.target.style.width||t.target.style.height||(s.global.x=n.clientX,s.global.y=n.clientY);for(var a=this.interactiveItems.length,h=0;a>h;h++){var l=this.interactiveItems[h];l.__touchData&&l.__touchData[n.identifier]&&(l.__hit=this.hitTest(l,l.__touchData[n.identifier]),s.originalEvent=t,(l.touchend||l.tap)&&(l.__hit&&!o?(l.touchend&&l.touchend(s),l.__isDown&&l.tap&&l.tap(s),l.interactiveChildren||(o=!0)):l.__isDown&&l.touchendoutside&&l.touchendoutside(s),l.__isDown=!1),l.__touchData[n.identifier]=null)}this.pool.push(s),this.touches[n.identifier]=null}},r.Stage=function(t){r.DisplayObjectContainer.call(this),this.worldTransform=new r.Matrix,this.interactive=!0,this.interactionManager=new r.InteractionManager(this),this.dirty=!0,this.stage=this,this.stage.hitArea=new r.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(t)},r.Stage.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Stage.prototype.constructor=r.Stage,r.Stage.prototype.setInteractionDelegate=function(t){this.interactionManager.setTargetDomElement(t)},r.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var t=0,e=this.children.length;e>t;t++)this.children[t].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},r.Stage.prototype.setBackgroundColor=function(t){this.backgroundColor=t||0,this.backgroundColorSplit=r.hex2rgb(this.backgroundColor);var e=this.backgroundColor.toString(16);e="000000".substr(0,6-e.length)+e,this.backgroundColorString="#"+e},r.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},function(t){for(var e=0,i=["ms","moz","webkit","o"],r=0;r<i.length&&!t.requestAnimationFrame;++r)t.requestAnimationFrame=t[i[r]+"RequestAnimationFrame"],t.cancelAnimationFrame=t[i[r]+"CancelAnimationFrame"]||t[i[r]+"CancelRequestAnimationFrame"];t.requestAnimationFrame||(t.requestAnimationFrame=function(i){var r=(new Date).getTime(),n=Math.max(0,16-(r-e)),s=t.setTimeout(function(){i(r+n)},n);return e=r+n,s}),t.cancelAnimationFrame||(t.cancelAnimationFrame=function(t){clearTimeout(t)}),t.requestAnimFrame=t.requestAnimationFrame}(this),r.hex2rgb=function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},r.rgb2hex=function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){return function(t){function e(){for(var r=arguments.length,s=new Array(r);r--;)s[r]=arguments[r];return s=n.concat(s),i.apply(this instanceof e?this:t,s)}var i=this,r=arguments.length-1,n=[];if(r>0)for(n.length=r;r--;)n[r]=arguments[r+1];if("function"!=typeof i)throw new TypeError;return e.prototype=function s(t){return t&&(s.prototype=t),this instanceof s?void 0:new s}(i.prototype),e}}()),r.AjaxRequest=function(){var t=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];if(!window.ActiveXObject)return window.XMLHttpRequest?new window.XMLHttpRequest:!1;for(var e=0;e<t.length;e++)try{return new window.ActiveXObject(t[e])}catch(i){}},r.canUseNewCanvasBlendModes=function(){if("undefined"==typeof document)return!1;var t=document.createElement("canvas");t.width=1,t.height=1;var e=t.getContext("2d");return e.fillStyle="#000",e.fillRect(0,0,1,1),e.globalCompositeOperation="multiply",e.fillStyle="#fff",e.fillRect(0,0,1,1),0===e.getImageData(0,0,1,1).data[0]},r.getNextPowerOfTwo=function(t){if(t>0&&0===(t&t-1))return t;for(var e=1;t>e;)e<<=1;return e},r.isPowerOfTwo=function(t,e){return t>0&&0===(t&t-1)&&e>0&&0===(e&e-1)},r.EventTarget={call:function(t){t&&(t=t.prototype||t,r.EventTarget.mixin(t))},mixin:function(t){t.listeners=function(t){return this._listeners=this._listeners||{},this._listeners[t]?this._listeners[t].slice():[]},t.emit=t.dispatchEvent=function(t,e){if(this._listeners=this._listeners||{},"object"==typeof t&&(e=t,t=t.type),e&&e.__isEventObject===!0||(e=new r.Event(this,t,e)),this._listeners&&this._listeners[t]){var i,n=this._listeners[t].slice(0),s=n.length,o=n[0];for(i=0;s>i;o=n[++i])if(o.call(this,e),e.stoppedImmediate)return this;if(e.stopped)return this}return this.parent&&this.parent.emit&&this.parent.emit.call(this.parent,t,e),this},t.on=t.addEventListener=function(t,e){return this._listeners=this._listeners||{},(this._listeners[t]=this._listeners[t]||[]).push(e),this},t.once=function(t,e){function i(){e.apply(r.off(t,i),arguments)}this._listeners=this._listeners||{};var r=this;return i._originalHandler=e,this.on(t,i)},t.off=t.removeEventListener=function(t,e){if(this._listeners=this._listeners||{},!this._listeners[t])return this;for(var i=this._listeners[t],r=e?i.length:0;r-->0;)(i[r]===e||i[r]._originalHandler===e)&&i.splice(r,1);return 0===i.length&&delete this._listeners[t],this},t.removeAllListeners=function(t){return this._listeners=this._listeners||{},this._listeners[t]?(delete this._listeners[t],this):this}}},r.Event=function(t,e,i){this.__isEventObject=!0,this.stopped=!1,this.stoppedImmediate=!1,this.target=t,this.type=e,this.data=i,this.content=i,this.timeStamp=Date.now()},r.Event.prototype.stopPropagation=function(){this.stopped=!0},r.Event.prototype.stopImmediatePropagation=function(){this.stoppedImmediate=!0},r.autoDetectRenderer=function(t,e,i){t||(t=800),e||(e=600);var n=function(){try{var t=document.createElement("canvas");return!!window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(e){return!1}}();return n?new r.WebGLRenderer(t,e,i):new r.CanvasRenderer(t,e,i)},r.autoDetectRecommendedRenderer=function(t,e,i){t||(t=800),e||(e=600);var n=function(){try{var t=document.createElement("canvas");return!!window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(e){return!1}}(),s=/Android/i.test(navigator.userAgent);return n&&!s?new r.WebGLRenderer(t,e,i):new r.CanvasRenderer(t,e,i)},r.PolyK={},r.PolyK.Triangulate=function(t){var e=!0,i=t.length>>1;if(3>i)return[];for(var n=[],s=[],o=0;i>o;o++)s.push(o);o=0;for(var a=i;a>3;){var h=s[(o+0)%a],l=s[(o+1)%a],u=s[(o+2)%a],c=t[2*h],d=t[2*h+1],p=t[2*l],f=t[2*l+1],g=t[2*u],m=t[2*u+1],v=!1;if(r.PolyK._convex(c,d,p,f,g,m,e)){v=!0;for(var x=0;a>x;x++){var y=s[x];if(y!==h&&y!==l&&y!==u&&r.PolyK._PointInTriangle(t[2*y],t[2*y+1],c,d,p,f,g,m)){v=!1;break}}}if(v)n.push(h,l,u),s.splice((o+1)%a,1),a--,o=0;else if(o++>3*a){if(!e)return null;for(n=[],s=[],o=0;i>o;o++)s.push(o);o=0,a=i,e=!1}}return n.push(s[0],s[1],s[2]),n},r.PolyK._PointInTriangle=function(t,e,i,r,n,s,o,a){var h=o-i,l=a-r,u=n-i,c=s-r,d=t-i,p=e-r,f=h*h+l*l,g=h*u+l*c,m=h*d+l*p,v=u*u+c*c,x=u*d+c*p,y=1/(f*v-g*g),b=(v*m-g*x)*y,T=(f*x-g*m)*y;return b>=0&&T>=0&&1>b+T},r.PolyK._convex=function(t,e,i,r,n,s,o){return(e-r)*(n-i)+(i-t)*(s-r)>=0===o},r.initDefaultShaders=function(){},r.CompileVertexShader=function(t,e){return r._CompileShader(t,e,t.VERTEX_SHADER)},r.CompileFragmentShader=function(t,e){return r._CompileShader(t,e,t.FRAGMENT_SHADER)},r._CompileShader=function(t,e,i){var r=e.join("\n"),n=t.createShader(i);return t.shaderSource(n,r),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(window.console.log(t.getShaderInfoLog(n)),null)},r.compileProgram=function(t,e,i){var n=r.CompileFragmentShader(t,i),s=r.CompileVertexShader(t,e),o=t.createProgram();return t.attachShader(o,s),t.attachShader(o,n),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)||window.console.log("Could not initialise shaders"),o},r.PixiShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},r.PixiShader.prototype.constructor=r.PixiShader,r.PixiShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc||r.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];for(var i in this.uniforms)this.uniforms[i].uniformLocation=t.getUniformLocation(e,i);this.initUniforms(),this.program=e},r.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms){t=this.uniforms[i];var r=t.type;"sampler2D"===r?(t._init=!1,null!==t.value&&this.initSampler2D(t)):"mat2"===r||"mat3"===r||"mat4"===r?(t.glMatrix=!0,t.glValueLength=1,"mat2"===r?t.glFunc=e.uniformMatrix2fv:"mat3"===r?t.glFunc=e.uniformMatrix3fv:"mat4"===r&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+r],t.glValueLength="2f"===r||"2i"===r?2:"3f"===r||"3i"===r?3:"4f"===r||"4i"===r?4:1)}},r.PixiShader.prototype.initSampler2D=function(t){if(t.value&&t.value.baseTexture&&t.value.baseTexture.hasLoaded){var e=this.gl;if(e.activeTexture(e["TEXTURE"+this.textureCount]),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),t.textureData){var i=t.textureData,r=i.magFilter?i.magFilter:e.LINEAR,n=i.minFilter?i.minFilter:e.LINEAR,s=i.wrapS?i.wrapS:e.CLAMP_TO_EDGE,o=i.wrapT?i.wrapT:e.CLAMP_TO_EDGE,a=i.luminance?e.LUMINANCE:e.RGBA;if(i.repeat&&(s=e.REPEAT,o=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var h=i.width?i.width:512,l=i.height?i.height:2,u=i.border?i.border:0;e.texImage2D(e.TEXTURE_2D,0,a,h,l,u,a,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,a,e.RGBA,e.UNSIGNED_BYTE,t.value.baseTexture.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o)}e.uniform1i(t.uniformLocation,this.textureCount),t._init=!0,this.textureCount++}},r.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms)t=this.uniforms[i],1===t.glValueLength?t.glMatrix===!0?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[e.id]?r.instances[e.id].updateTexture(t.value.baseTexture):e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(t))},r.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},r.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"],r.PixiFastShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.textureCount=0,this.init()},r.PixiFastShader.prototype.constructor=r.PixiFastShader,r.PixiFastShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.uMatrix=t.getUniformLocation(e,"uMatrix"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aPositionCoord=t.getAttribLocation(e,"aPositionCoord"),this.aScale=t.getAttribLocation(e,"aScale"),this.aRotation=t.getAttribLocation(e,"aRotation"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=e},r.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},r.StripShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"],this.init()},r.StripShader.prototype.constructor=r.StripShader,r.StripShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},r.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},r.PrimitiveShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},r.PrimitiveShader.prototype.constructor=r.PrimitiveShader,r.PrimitiveShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},r.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},r.ComplexPrimitiveShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},r.ComplexPrimitiveShader.prototype.constructor=r.ComplexPrimitiveShader,r.ComplexPrimitiveShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.color=t.getUniformLocation(e,"color"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},r.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},r.WebGLGraphics=function(){},r.WebGLGraphics.renderGraphics=function(t,e){var i,n=e.gl,s=e.projection,o=e.offset,a=e.shaderManager.primitiveShader;t.dirty&&r.WebGLGraphics.updateGraphics(t,n);for(var h=t._webGL[n.id],l=0;l<h.data.length;l++)1===h.data[l].mode?(i=h.data[l],e.stencilManager.pushStencil(t,i,e),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(i.indices.length-4)),e.stencilManager.popStencil(t,i,e)):(i=h.data[l],e.shaderManager.setShader(a),a=e.shaderManager.primitiveShader,n.uniformMatrix3fv(a.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform1f(a.flipY,1),n.uniform2f(a.projectionVector,s.x,-s.y),n.uniform2f(a.offsetVector,-o.x,-o.y),n.uniform3fv(a.tintColor,r.hex2rgb(t.tint)),n.uniform1f(a.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,i.buffer),n.vertexAttribPointer(a.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(a.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i.indexBuffer),n.drawElements(n.TRIANGLE_STRIP,i.indices.length,n.UNSIGNED_SHORT,0))},r.WebGLGraphics.updateGraphics=function(t,e){var i=t._webGL[e.id];i||(i=t._webGL[e.id]={lastIndex:0,data:[],gl:e}),t.dirty=!1;var n;if(t.clearDirty){for(t.clearDirty=!1,n=0;n<i.data.length;n++){var s=i.data[n];s.reset(),r.WebGLGraphics.graphicsDataPool.push(s)}i.data=[],i.lastIndex=0}var o;for(n=i.lastIndex;n<t.graphicsData.length;n++){var a=t.graphicsData[n];if(a.type===r.Graphics.POLY){if(a.points=a.shape.points.slice(),a.shape.closed&&(a.points[0]!==a.points[a.points.length-2]||a.points[1]!==a.points[a.points.length-1])&&a.points.push(a.points[0],a.points[1]),a.fill&&a.points.length>=6)if(a.points.length<12){o=r.WebGLGraphics.switchMode(i,0);var h=r.WebGLGraphics.buildPoly(a,o);h||(o=r.WebGLGraphics.switchMode(i,1),r.WebGLGraphics.buildComplexPoly(a,o))}else o=r.WebGLGraphics.switchMode(i,1),r.WebGLGraphics.buildComplexPoly(a,o);a.lineWidth>0&&(o=r.WebGLGraphics.switchMode(i,0),r.WebGLGraphics.buildLine(a,o))}else o=r.WebGLGraphics.switchMode(i,0),a.type===r.Graphics.RECT?r.WebGLGraphics.buildRectangle(a,o):a.type===r.Graphics.CIRC||a.type===r.Graphics.ELIP?r.WebGLGraphics.buildCircle(a,o):a.type===r.Graphics.RREC&&r.WebGLGraphics.buildRoundedRectangle(a,o);i.lastIndex++}for(n=0;n<i.data.length;n++)o=i.data[n],o.dirty&&o.upload()},r.WebGLGraphics.switchMode=function(t,e){var i;return t.data.length?(i=t.data[t.data.length-1],(i.mode!==e||1===e)&&(i=r.WebGLGraphics.graphicsDataPool.pop()||new r.WebGLGraphicsData(t.gl),i.mode=e,t.data.push(i))):(i=r.WebGLGraphics.graphicsDataPool.pop()||new r.WebGLGraphicsData(t.gl),i.mode=e,t.data.push(i)),i.dirty=!0,i},r.WebGLGraphics.buildRectangle=function(t,e){var i=t.shape,n=i.x,s=i.y,o=i.width,a=i.height;if(t.fill){var h=r.hex2rgb(t.fillColor),l=t.fillAlpha,u=h[0]*l,c=h[1]*l,d=h[2]*l,p=e.points,f=e.indices,g=p.length/6;p.push(n,s),p.push(u,c,d,l),p.push(n+o,s),p.push(u,c,d,l),p.push(n,s+a),p.push(u,c,d,l),p.push(n+o,s+a),p.push(u,c,d,l),f.push(g,g,g+1,g+2,g+3,g+3)}if(t.lineWidth){var m=t.points;t.points=[n,s,n+o,s,n+o,s+a,n,s+a,n,s],r.WebGLGraphics.buildLine(t,e),t.points=m}},r.WebGLGraphics.buildRoundedRectangle=function(t,e){var i=t.shape,n=i.x,s=i.y,o=i.width,a=i.height,h=i.radius,l=[];if(l.push(n,s+h),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n,s+a-h,n,s+a,n+h,s+a)),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n+o-h,s+a,n+o,s+a,n+o,s+a-h)),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n+o,s+h,n+o,s,n+o-h,s)),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n+h,s,n,s,n,s+h)),t.fill){var u=r.hex2rgb(t.fillColor),c=t.fillAlpha,d=u[0]*c,p=u[1]*c,f=u[2]*c,g=e.points,m=e.indices,v=g.length/6,x=r.PolyK.Triangulate(l),y=0;for(y=0;y<x.length;y+=3)m.push(x[y]+v),m.push(x[y]+v),m.push(x[y+1]+v),m.push(x[y+2]+v),m.push(x[y+2]+v);for(y=0;y<l.length;y++)g.push(l[y],l[++y],d,p,f,c)}if(t.lineWidth){var b=t.points;t.points=l,r.WebGLGraphics.buildLine(t,e),t.points=b}},r.WebGLGraphics.quadraticBezierCurve=function(t,e,i,r,n,s){function o(t,e,i){var r=e-t;return t+r*i}for(var a,h,l,u,c,d,p=20,f=[],g=0,m=0;p>=m;m++)g=m/p,a=o(t,i,g),h=o(e,r,g),l=o(i,n,g),u=o(r,s,g),c=o(a,l,g),d=o(h,u,g),f.push(c,d);return f},r.WebGLGraphics.buildCircle=function(t,e){var i,n,s=t.shape,o=s.x,a=s.y;t.type===r.Graphics.CIRC?(i=s.radius,n=s.radius):(i=s.width,n=s.height);var h=40,l=2*Math.PI/h,u=0;if(t.fill){var c=r.hex2rgb(t.fillColor),d=t.fillAlpha,p=c[0]*d,f=c[1]*d,g=c[2]*d,m=e.points,v=e.indices,x=m.length/6;for(v.push(x),u=0;h+1>u;u++)m.push(o,a,p,f,g,d),m.push(o+Math.sin(l*u)*i,a+Math.cos(l*u)*n,p,f,g,d),v.push(x++,x++);v.push(x-1)}if(t.lineWidth){var y=t.points;for(t.points=[],u=0;h+1>u;u++)t.points.push(o+Math.sin(l*u)*i,a+Math.cos(l*u)*n);r.WebGLGraphics.buildLine(t,e),t.points=y}},r.WebGLGraphics.buildLine=function(t,e){var i=0,n=t.points;if(0!==n.length){if(t.lineWidth%2)for(i=0;i<n.length;i++)n[i]+=.5;var s=new r.Point(n[0],n[1]),o=new r.Point(n[n.length-2],n[n.length-1]);if(s.x===o.x&&s.y===o.y){n=n.slice(),n.pop(),n.pop(),o=new r.Point(n[n.length-2],n[n.length-1]);var a=o.x+.5*(s.x-o.x),h=o.y+.5*(s.y-o.y);n.unshift(a,h),n.push(a,h)}var l,u,c,d,p,f,g,m,v,x,y,b,T,w,S,C,A,_,E,R,M,L,F,B=e.points,P=e.indices,D=n.length/2,I=n.length,O=B.length/6,G=t.lineWidth/2,U=r.hex2rgb(t.lineColor),k=t.lineAlpha,N=U[0]*k,j=U[1]*k,W=U[2]*k;for(c=n[0],d=n[1],p=n[2],f=n[3],v=-(d-f),x=c-p,F=Math.sqrt(v*v+x*x),v/=F,x/=F,v*=G,x*=G,B.push(c-v,d-x,N,j,W,k),B.push(c+v,d+x,N,j,W,k),i=1;D-1>i;i++)c=n[2*(i-1)],d=n[2*(i-1)+1],p=n[2*i],f=n[2*i+1],g=n[2*(i+1)],m=n[2*(i+1)+1],v=-(d-f),x=c-p,F=Math.sqrt(v*v+x*x),v/=F,x/=F,v*=G,x*=G,y=-(f-m),b=p-g,F=Math.sqrt(y*y+b*b),y/=F,b/=F,y*=G,b*=G,S=-x+d-(-x+f),C=-v+p-(-v+c),A=(-v+c)*(-x+f)-(-v+p)*(-x+d),_=-b+m-(-b+f),E=-y+p-(-y+g),R=(-y+g)*(-b+f)-(-y+p)*(-b+m),M=S*E-_*C,Math.abs(M)<.1?(M+=10.1,B.push(p-v,f-x,N,j,W,k),B.push(p+v,f+x,N,j,W,k)):(l=(C*R-E*A)/M,u=(_*A-S*R)/M,L=(l-p)*(l-p)+(u-f)+(u-f),L>19600?(T=v-y,w=x-b,F=Math.sqrt(T*T+w*w),T/=F,w/=F,T*=G,w*=G,B.push(p-T,f-w),B.push(N,j,W,k),B.push(p+T,f+w),B.push(N,j,W,k),B.push(p-T,f-w),B.push(N,j,W,k),I++):(B.push(l,u),B.push(N,j,W,k),B.push(p-(l-p),f-(u-f)),B.push(N,j,W,k)));
for(c=n[2*(D-2)],d=n[2*(D-2)+1],p=n[2*(D-1)],f=n[2*(D-1)+1],v=-(d-f),x=c-p,F=Math.sqrt(v*v+x*x),v/=F,x/=F,v*=G,x*=G,B.push(p-v,f-x),B.push(N,j,W,k),B.push(p+v,f+x),B.push(N,j,W,k),P.push(O),i=0;I>i;i++)P.push(O++);P.push(O-1)}},r.WebGLGraphics.buildComplexPoly=function(t,e){var i=t.points.slice();if(!(i.length<6)){var n=e.indices;e.points=i,e.alpha=t.fillAlpha,e.color=r.hex2rgb(t.fillColor);for(var s,o,a=1/0,h=-1/0,l=1/0,u=-1/0,c=0;c<i.length;c+=2)s=i[c],o=i[c+1],a=a>s?s:a,h=s>h?s:h,l=l>o?o:l,u=o>u?o:u;i.push(a,l,h,l,h,u,a,u);var d=i.length/2;for(c=0;d>c;c++)n.push(c)}},r.WebGLGraphics.buildPoly=function(t,e){var i=t.points;if(!(i.length<6)){var n=e.points,s=e.indices,o=i.length/2,a=r.hex2rgb(t.fillColor),h=t.fillAlpha,l=a[0]*h,u=a[1]*h,c=a[2]*h,d=r.PolyK.Triangulate(i);if(!d)return!1;var p=n.length/6,f=0;for(f=0;f<d.length;f+=3)s.push(d[f]+p),s.push(d[f]+p),s.push(d[f+1]+p),s.push(d[f+2]+p),s.push(d[f+2]+p);for(f=0;o>f;f++)n.push(i[2*f],i[2*f+1],l,u,c,h);return!0}},r.WebGLGraphics.graphicsDataPool=[],r.WebGLGraphicsData=function(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},r.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},r.WebGLGraphicsData.prototype.upload=function(){var t=this.gl;this.glPoints=new r.Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new r.Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1},r.glContexts=[],r.instances=[],r.WebGLRenderer=function(t,e,i){if(i)for(var n in r.defaultRenderOptions)"undefined"==typeof i[n]&&(i[n]=r.defaultRenderOptions[n]);else i=r.defaultRenderOptions;r.defaultRenderer||(r.sayHello("webGL"),r.defaultRenderer=this),this.type=r.WEBGL_RENDERER,this.resolution=i.resolution,this.transparent=i.transparent,this.autoResize=i.autoResize||!1,this.preserveDrawingBuffer=i.preserveDrawingBuffer,this.clearBeforeRender=i.clearBeforeRender,this.width=t||800,this.height=e||600,this.view=i.view||document.createElement("canvas"),this.contextLostBound=this.handleContextLost.bind(this),this.contextRestoredBound=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.contextLostBound,!1),this.view.addEventListener("webglcontextrestored",this.contextRestoredBound,!1),this._contextOptions={alpha:this.transparent,antialias:i.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:i.preserveDrawingBuffer},this.projection=new r.Point,this.offset=new r.Point(0,0),this.shaderManager=new r.WebGLShaderManager,this.spriteBatch=new r.WebGLSpriteBatch,this.maskManager=new r.WebGLMaskManager,this.filterManager=new r.WebGLFilterManager,this.stencilManager=new r.WebGLStencilManager,this.blendModeManager=new r.WebGLBlendModeManager,this.renderSession={},this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()},r.WebGLRenderer.prototype.constructor=r.WebGLRenderer,r.WebGLRenderer.prototype.initContext=function(){var t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.glContextId=t.id=r.WebGLRenderer.glContextId++,r.glContexts[this.glContextId]=t,r.instances[this.glContextId]=this,t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.shaderManager.setContext(t),this.spriteBatch.setContext(t),this.maskManager.setContext(t),this.filterManager.setContext(t),this.blendModeManager.setContext(t),this.stencilManager.setContext(t),this.renderSession.gl=this.gl,this.resize(this.width,this.height)},r.WebGLRenderer.prototype.render=function(t){if(!this.contextLost){this.__stage!==t&&(t.interactive&&t.interactionManager.removeEvents(),this.__stage=t),t.updateTransform();var e=this.gl;t._interactive?t._interactiveEventsAdded||(t._interactiveEventsAdded=!0,t.interactionManager.setTarget(this)):t._interactiveEventsAdded&&(t._interactiveEventsAdded=!1,t.interactionManager.setTarget(this)),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,null),this.clearBeforeRender&&(this.transparent?e.clearColor(0,0,0,0):e.clearColor(t.backgroundColorSplit[0],t.backgroundColorSplit[1],t.backgroundColorSplit[2],1),e.clear(e.COLOR_BUFFER_BIT)),this.renderDisplayObject(t,this.projection)}},r.WebGLRenderer.prototype.renderDisplayObject=function(t,e,i){this.renderSession.blendModeManager.setBlendMode(r.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=i?-1:1,this.renderSession.projection=e,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,i),t._renderWebGL(this.renderSession),this.spriteBatch.end()},r.WebGLRenderer.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},r.WebGLRenderer.prototype.updateTexture=function(t){if(t.hasLoaded){var e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&r.isPowerOfTwo(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,t._glTextures[e.id]}},r.WebGLRenderer.prototype.handleContextLost=function(t){t.preventDefault(),this.contextLost=!0},r.WebGLRenderer.prototype.handleContextRestored=function(){this.initContext();for(var t in r.TextureCache){var e=r.TextureCache[t].baseTexture;e._glTextures=[]}this.contextLost=!1},r.WebGLRenderer.prototype.destroy=function(){this.view.removeEventListener("webglcontextlost",this.contextLostBound),this.view.removeEventListener("webglcontextrestored",this.contextRestoredBound),r.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null},r.WebGLRenderer.prototype.mapBlendModes=function(){var t=this.gl;r.blendModesWebGL||(r.blendModesWebGL=[],r.blendModesWebGL[r.blendModes.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.ADD]=[t.SRC_ALPHA,t.DST_ALPHA],r.blendModesWebGL[r.blendModes.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.SCREEN]=[t.SRC_ALPHA,t.ONE],r.blendModesWebGL[r.blendModes.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA])},r.WebGLRenderer.glContextId=0,r.WebGLBlendModeManager=function(){this.currentBlendMode=99999},r.WebGLBlendModeManager.prototype.constructor=r.WebGLBlendModeManager,r.WebGLBlendModeManager.prototype.setContext=function(t){this.gl=t},r.WebGLBlendModeManager.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var e=r.blendModesWebGL[this.currentBlendMode];return this.gl.blendFunc(e[0],e[1]),!0},r.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},r.WebGLMaskManager=function(){},r.WebGLMaskManager.prototype.constructor=r.WebGLMaskManager,r.WebGLMaskManager.prototype.setContext=function(t){this.gl=t},r.WebGLMaskManager.prototype.pushMask=function(t,e){var i=e.gl;t.dirty&&r.WebGLGraphics.updateGraphics(t,i),t._webGL[i.id].data.length&&e.stencilManager.pushStencil(t,t._webGL[i.id].data[0],e)},r.WebGLMaskManager.prototype.popMask=function(t,e){var i=this.gl;e.stencilManager.popStencil(t,t._webGL[i.id].data[0],e)},r.WebGLMaskManager.prototype.destroy=function(){this.gl=null},r.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},r.WebGLStencilManager.prototype.setContext=function(t){this.gl=t},r.WebGLStencilManager.prototype.pushStencil=function(t,e,i){var r=this.gl;this.bindGraphics(t,e,i),0===this.stencilStack.length&&(r.enable(r.STENCIL_TEST),r.clear(r.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(e);var n=this.count;r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.ALWAYS,0,255),r.stencilOp(r.KEEP,r.KEEP,r.INVERT),1===e.mode?(r.drawElements(r.TRIANGLE_FAN,e.indices.length-4,r.UNSIGNED_SHORT,0),this.reverse?(r.stencilFunc(r.EQUAL,255-n,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)):(r.stencilFunc(r.EQUAL,n,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(e.indices.length-4)),this.reverse?r.stencilFunc(r.EQUAL,255-(n+1),255):r.stencilFunc(r.EQUAL,n+1,255),this.reverse=!this.reverse):(this.reverse?(r.stencilFunc(r.EQUAL,n,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)):(r.stencilFunc(r.EQUAL,255-n,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)),r.drawElements(r.TRIANGLE_STRIP,e.indices.length,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,n+1,255):r.stencilFunc(r.EQUAL,255-(n+1),255)),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),this.count++},r.WebGLStencilManager.prototype.bindGraphics=function(t,e,i){this._currentGraphics=t;var n,s=this.gl,o=i.projection,a=i.offset;1===e.mode?(n=i.shaderManager.complexPrimitiveShader,i.shaderManager.setShader(n),s.uniform1f(n.flipY,i.flipY),s.uniformMatrix3fv(n.translationMatrix,!1,t.worldTransform.toArray(!0)),s.uniform2f(n.projectionVector,o.x,-o.y),s.uniform2f(n.offsetVector,-a.x,-a.y),s.uniform3fv(n.tintColor,r.hex2rgb(t.tint)),s.uniform3fv(n.color,e.color),s.uniform1f(n.alpha,t.worldAlpha*e.alpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(n.aVertexPosition,2,s.FLOAT,!1,8,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(n=i.shaderManager.primitiveShader,i.shaderManager.setShader(n),s.uniformMatrix3fv(n.translationMatrix,!1,t.worldTransform.toArray(!0)),s.uniform1f(n.flipY,i.flipY),s.uniform2f(n.projectionVector,o.x,-o.y),s.uniform2f(n.offsetVector,-a.x,-a.y),s.uniform3fv(n.tintColor,r.hex2rgb(t.tint)),s.uniform1f(n.alpha,t.worldAlpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(n.aVertexPosition,2,s.FLOAT,!1,24,0),s.vertexAttribPointer(n.colorAttribute,4,s.FLOAT,!1,24,8),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer))},r.WebGLStencilManager.prototype.popStencil=function(t,e,i){var r=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)r.disable(r.STENCIL_TEST);else{var n=this.count;this.bindGraphics(t,e,i),r.colorMask(!1,!1,!1,!1),1===e.mode?(this.reverse=!this.reverse,this.reverse?(r.stencilFunc(r.EQUAL,255-(n+1),255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)):(r.stencilFunc(r.EQUAL,n+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(e.indices.length-4)),r.stencilFunc(r.ALWAYS,0,255),r.stencilOp(r.KEEP,r.KEEP,r.INVERT),r.drawElements(r.TRIANGLE_FAN,e.indices.length-4,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,n,255):r.stencilFunc(r.EQUAL,255-n,255)):(this.reverse?(r.stencilFunc(r.EQUAL,n+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)):(r.stencilFunc(r.EQUAL,255-(n+1),255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)),r.drawElements(r.TRIANGLE_STRIP,e.indices.length,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,n,255):r.stencilFunc(r.EQUAL,255-n,255)),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}},r.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},r.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var t=0;t<this.maxAttibs;t++)this.attribState[t]=!1;this.stack=[]},r.WebGLShaderManager.prototype.constructor=r.WebGLShaderManager,r.WebGLShaderManager.prototype.setContext=function(t){this.gl=t,this.primitiveShader=new r.PrimitiveShader(t),this.complexPrimitiveShader=new r.ComplexPrimitiveShader(t),this.defaultShader=new r.PixiShader(t),this.fastShader=new r.PixiFastShader(t),this.stripShader=new r.StripShader(t),this.setShader(this.defaultShader)},r.WebGLShaderManager.prototype.setAttribs=function(t){var e;for(e=0;e<this.tempAttribState.length;e++)this.tempAttribState[e]=!1;for(e=0;e<t.length;e++){var i=t[e];this.tempAttribState[i]=!0}var r=this.gl;for(e=0;e<this.attribState.length;e++)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.tempAttribState[e]?r.enableVertexAttribArray(e):r.disableVertexAttribArray(e))},r.WebGLShaderManager.prototype.setShader=function(t){return this._currentId===t._UID?!1:(this._currentId=t._UID,this.currentShader=t,this.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)},r.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null},r.WebGLSpriteBatch=function(){this.vertSize=5,this.size=2e3;var t=4*this.size*4*this.vertSize,e=6*this.size;this.vertices=new r.ArrayBuffer(t),this.positions=new r.Float32Array(this.vertices),this.colors=new r.Uint32Array(this.vertices),this.indices=new r.Uint16Array(e),this.lastIndexCount=0;for(var i=0,n=0;e>i;i+=6,n+=4)this.indices[i+0]=n+0,this.indices[i+1]=n+1,this.indices[i+2]=n+2,this.indices[i+3]=n+0,this.indices[i+4]=n+2,this.indices[i+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=new r.AbstractFilter(["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"])},r.WebGLSpriteBatch.prototype.setContext=function(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999;var e=new r.PixiShader(t);e.fragmentSrc=this.defaultShader.fragmentSrc,e.uniforms={},e.init(),this.defaultShader.shaders[t.id]=e},r.WebGLSpriteBatch.prototype.begin=function(t){this.renderSession=t,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},r.WebGLSpriteBatch.prototype.end=function(){this.flush()},r.WebGLSpriteBatch.prototype.render=function(t){var e=t.texture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture);var i=e._uvs;if(i){var r,n,s,o,a=t.anchor.x,h=t.anchor.y;if(e.trim){var l=e.trim;n=l.x-a*l.width,r=n+e.crop.width,o=l.y-h*l.height,s=o+e.crop.height}else r=e.frame.width*(1-a),n=e.frame.width*-a,s=e.frame.height*(1-h),o=e.frame.height*-h;var u=4*this.currentBatchSize*this.vertSize,c=e.baseTexture.resolution,d=t.worldTransform,p=d.a/c,f=d.b/c,g=d.c/c,m=d.d/c,v=d.tx,x=d.ty,y=this.colors,b=this.positions;this.renderSession.roundPixels?(b[u]=p*n+g*o+v|0,b[u+1]=m*o+f*n+x|0,b[u+5]=p*r+g*o+v|0,b[u+6]=m*o+f*r+x|0,b[u+10]=p*r+g*s+v|0,b[u+11]=m*s+f*r+x|0,b[u+15]=p*n+g*s+v|0,b[u+16]=m*s+f*n+x|0):(b[u]=p*n+g*o+v,b[u+1]=m*o+f*n+x,b[u+5]=p*r+g*o+v,b[u+6]=m*o+f*r+x,b[u+10]=p*r+g*s+v,b[u+11]=m*s+f*r+x,b[u+15]=p*n+g*s+v,b[u+16]=m*s+f*n+x),b[u+2]=i.x0,b[u+3]=i.y0,b[u+7]=i.x1,b[u+8]=i.y1,b[u+12]=i.x2,b[u+13]=i.y2,b[u+17]=i.x3,b[u+18]=i.y3;var T=t.tint;y[u+4]=y[u+9]=y[u+14]=y[u+19]=(T>>16)+(65280&T)+((255&T)<<16)+(255*t.worldAlpha<<24),this.sprites[this.currentBatchSize++]=t}},r.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new r.TextureUvs);var i=t._uvs;t.tilePosition.x%=e.baseTexture.width*t.tileScaleOffset.x,t.tilePosition.y%=e.baseTexture.height*t.tileScaleOffset.y;var n=t.tilePosition.x/(e.baseTexture.width*t.tileScaleOffset.x),s=t.tilePosition.y/(e.baseTexture.height*t.tileScaleOffset.y),o=t.width/e.baseTexture.width/(t.tileScale.x*t.tileScaleOffset.x),a=t.height/e.baseTexture.height/(t.tileScale.y*t.tileScaleOffset.y);i.x0=0-n,i.y0=0-s,i.x1=1*o-n,i.y1=0-s,i.x2=1*o-n,i.y2=1*a-s,i.x3=0-n,i.y3=1*a-s;var h=t.tint,l=(h>>16)+(65280&h)+((255&h)<<16)+(255*t.alpha<<24),u=this.positions,c=this.colors,d=t.width,p=t.height,f=t.anchor.x,g=t.anchor.y,m=d*(1-f),v=d*-f,x=p*(1-g),y=p*-g,b=4*this.currentBatchSize*this.vertSize,T=e.baseTexture.resolution,w=t.worldTransform,S=w.a/T,C=w.b/T,A=w.c/T,_=w.d/T,E=w.tx,R=w.ty;u[b++]=S*v+A*y+E,u[b++]=_*y+C*v+R,u[b++]=i.x0,u[b++]=i.y0,c[b++]=l,u[b++]=S*m+A*y+E,u[b++]=_*y+C*m+R,u[b++]=i.x1,u[b++]=i.y1,c[b++]=l,u[b++]=S*m+A*x+E,u[b++]=_*x+C*m+R,u[b++]=i.x2,u[b++]=i.y2,c[b++]=l,u[b++]=S*v+A*x+E,u[b++]=_*x+C*v+R,u[b++]=i.x3,u[b++]=i.y3,c[b++]=l,this.sprites[this.currentBatchSize++]=t},r.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e=this.gl;if(this.dirty){this.dirty=!1,e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t=this.defaultShader.shaders[e.id];var i=4*this.vertSize;e.vertexAttribPointer(t.aVertexPosition,2,e.FLOAT,!1,i,0),e.vertexAttribPointer(t.aTextureCoord,2,e.FLOAT,!1,i,8),e.vertexAttribPointer(t.colorAttribute,4,e.UNSIGNED_BYTE,!0,i,16)}if(this.currentBatchSize>.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var n=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}for(var s,o,a,h,l=0,u=0,c=null,d=this.renderSession.blendModeManager.currentBlendMode,p=null,f=!1,g=!1,m=0,v=this.currentBatchSize;v>m;m++){if(h=this.sprites[m],s=h.texture.baseTexture,o=h.blendMode,a=h.shader||this.defaultShader,f=d!==o,g=p!==a,(c!==s||f||g)&&(this.renderBatch(c,l,u),u=m,l=0,c=s,f&&(d=o,this.renderSession.blendModeManager.setBlendMode(d)),g)){p=a,t=p.shaders[e.id],t||(t=new r.PixiShader(e),t.fragmentSrc=p.fragmentSrc,t.uniforms=p.uniforms,t.init(),p.shaders[e.id]=t),this.renderSession.shaderManager.setShader(t),t.dirty&&t.syncUniforms();var x=this.renderSession.projection;e.uniform2f(t.projectionVector,x.x,x.y);var y=this.renderSession.offset;e.uniform2f(t.offsetVector,y.x,y.y)}l++}this.renderBatch(c,l,u),this.currentBatchSize=0}},r.WebGLSpriteBatch.prototype.renderBatch=function(t,e,i){if(0!==e){var r=this.gl;t._dirty[r.id]?this.renderSession.renderer.updateTexture(t):r.bindTexture(r.TEXTURE_2D,t._glTextures[r.id]),r.drawElements(r.TRIANGLES,6*e,r.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount++}},r.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},r.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},r.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},r.WebGLFastSpriteBatch=function(t){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var e=4*this.size*this.vertSize,i=6*this.maxSize;this.vertices=new r.Float32Array(e),this.indices=new r.Uint16Array(i),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var n=0,s=0;i>n;n+=6,s+=4)this.indices[n+0]=s+0,this.indices[n+1]=s+1,this.indices[n+2]=s+2,this.indices[n+3]=s+0,this.indices[n+4]=s+2,this.indices[n+5]=s+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(t)},r.WebGLFastSpriteBatch.prototype.constructor=r.WebGLFastSpriteBatch,r.WebGLFastSpriteBatch.prototype.setContext=function(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW)},r.WebGLFastSpriteBatch.prototype.begin=function(t,e){this.renderSession=e,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=t.worldTransform.toArray(!0),this.start()},r.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},r.WebGLFastSpriteBatch.prototype.render=function(t){var e=t.children,i=e[0];if(i.texture._uvs){this.currentBaseTexture=i.texture.baseTexture,i.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(i.blendMode));for(var r=0,n=e.length;n>r;r++)this.renderSprite(e[r]);this.flush()}},r.WebGLFastSpriteBatch.prototype.renderSprite=function(t){if(t.visible&&(t.texture.baseTexture===this.currentBaseTexture||(this.flush(),this.currentBaseTexture=t.texture.baseTexture,t.texture._uvs))){var e,i,r,n,s,o,a,h,l=this.vertices;if(e=t.texture._uvs,i=t.texture.frame.width,r=t.texture.frame.height,t.texture.trim){var u=t.texture.trim;s=u.x-t.anchor.x*u.width,n=s+t.texture.crop.width,a=u.y-t.anchor.y*u.height,o=a+t.texture.crop.height}else n=t.texture.frame.width*(1-t.anchor.x),s=t.texture.frame.width*-t.anchor.x,o=t.texture.frame.height*(1-t.anchor.y),a=t.texture.frame.height*-t.anchor.y;h=4*this.currentBatchSize*this.vertSize,l[h++]=s,l[h++]=a,l[h++]=t.position.x,l[h++]=t.position.y,l[h++]=t.scale.x,l[h++]=t.scale.y,l[h++]=t.rotation,l[h++]=e.x0,l[h++]=e.y1,l[h++]=t.alpha,l[h++]=n,l[h++]=a,l[h++]=t.position.x,l[h++]=t.position.y,l[h++]=t.scale.x,l[h++]=t.scale.y,l[h++]=t.rotation,l[h++]=e.x1,l[h++]=e.y1,l[h++]=t.alpha,l[h++]=n,l[h++]=o,l[h++]=t.position.x,l[h++]=t.position.y,l[h++]=t.scale.x,l[h++]=t.scale.y,l[h++]=t.rotation,l[h++]=e.x2,l[h++]=e.y2,l[h++]=t.alpha,l[h++]=s,l[h++]=o,l[h++]=t.position.x,l[h++]=t.position.y,l[h++]=t.scale.x,l[h++]=t.scale.y,l[h++]=t.rotation,l[h++]=e.x3,l[h++]=e.y3,l[h++]=t.alpha,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()}},r.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.currentBaseTexture._glTextures[t.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,t),t.bindTexture(t.TEXTURE_2D,this.currentBaseTexture._glTextures[t.id]),this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var e=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}t.drawElements(t.TRIANGLES,6*this.currentBatchSize,t.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},r.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},r.WebGLFastSpriteBatch.prototype.start=function(){var t=this.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y),t.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aPositionCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.aScale,2,t.FLOAT,!1,i,16),t.vertexAttribPointer(this.shader.aRotation,1,t.FLOAT,!1,i,24),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,28),t.vertexAttribPointer(this.shader.colorAttribute,1,t.FLOAT,!1,i,36)},r.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},r.WebGLFilterManager.prototype.constructor=r.WebGLFilterManager,r.WebGLFilterManager.prototype.setContext=function(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()},r.WebGLFilterManager.prototype.begin=function(t,e){this.renderSession=t,this.defaultShader=t.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=e},r.WebGLFilterManager.prototype.pushFilter=function(t){var e=this.gl,i=this.renderSession.projection,n=this.renderSession.offset;t._filterArea=t.target.filterArea||t.target.getBounds(),this.filterStack.push(t);var s=t.filterPasses[0];this.offsetX+=t._filterArea.x,this.offsetY+=t._filterArea.y;var o=this.texturePool.pop();o?o.resize(this.width,this.height):o=new r.FilterTexture(this.gl,this.width,this.height),e.bindTexture(e.TEXTURE_2D,o.texture);var a=t._filterArea,h=s.padding;a.x-=h,a.y-=h,a.width+=2*h,a.height+=2*h,a.x<0&&(a.x=0),a.width>this.width&&(a.width=this.width),a.y<0&&(a.y=0),a.height>this.height&&(a.height=this.height),e.bindFramebuffer(e.FRAMEBUFFER,o.frameBuffer),e.viewport(0,0,a.width,a.height),i.x=a.width/2,i.y=-a.height/2,n.x=-a.x,n.y=-a.y,e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t._glFilterTexture=o},r.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,e=this.filterStack.pop(),i=e._filterArea,n=e._glFilterTexture,s=this.renderSession.projection,o=this.renderSession.offset;if(e.filterPasses.length>1){t.viewport(0,0,i.width,i.height),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=i.height,this.vertexArray[2]=i.width,this.vertexArray[3]=i.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=i.width,this.vertexArray[7]=0,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray);var a=n,h=this.texturePool.pop();h||(h=new r.FilterTexture(this.gl,this.width,this.height)),h.resize(this.width,this.height),t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.BLEND);for(var l=0;l<e.filterPasses.length-1;l++){var u=e.filterPasses[l];t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a.texture),this.applyFilterPass(u,i,i.width,i.height);var c=a;a=h,h=c}t.enable(t.BLEND),n=a,this.texturePool.push(h)}var d=e.filterPasses[e.filterPasses.length-1];this.offsetX-=i.x,this.offsetY-=i.y;var p=this.width,f=this.height,g=0,m=0,v=this.buffer;if(0===this.filterStack.length)t.colorMask(!0,!0,!0,!0);else{var x=this.filterStack[this.filterStack.length-1];i=x._filterArea,p=i.width,f=i.height,g=i.x,m=i.y,v=x._glFilterTexture.frameBuffer}s.x=p/2,s.y=-f/2,o.x=g,o.y=m,i=e._filterArea;var y=i.x-g,b=i.y-m;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=y,this.vertexArray[1]=b+i.height,this.vertexArray[2]=y+i.width,this.vertexArray[3]=b+i.height,this.vertexArray[4]=y,this.vertexArray[5]=b,this.vertexArray[6]=y+i.width,this.vertexArray[7]=b,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray),t.viewport(0,0,p,f),t.bindFramebuffer(t.FRAMEBUFFER,v),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n.texture),this.applyFilterPass(d,i,p,f),this.texturePool.push(n),e._glFilterTexture=null},r.WebGLFilterManager.prototype.applyFilterPass=function(t,e,i,n){var s=this.gl,o=t.shaders[s.id];o||(o=new r.PixiShader(s),o.fragmentSrc=t.fragmentSrc,o.uniforms=t.uniforms,o.init(),t.shaders[s.id]=o),this.renderSession.shaderManager.setShader(o),s.uniform2f(o.projectionVector,i/2,-n/2),s.uniform2f(o.offsetVector,0,0),t.uniforms.dimensions&&(t.uniforms.dimensions.value[0]=this.width,t.uniforms.dimensions.value[1]=this.height,t.uniforms.dimensions.value[2]=this.vertexArray[0],t.uniforms.dimensions.value[3]=this.vertexArray[5]),o.syncUniforms(),s.bindBuffer(s.ARRAY_BUFFER,this.vertexBuffer),s.vertexAttribPointer(o.aVertexPosition,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this.uvBuffer),s.vertexAttribPointer(o.aTextureCoord,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this.colorBuffer),s.vertexAttribPointer(o.colorAttribute,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.indexBuffer),s.drawElements(s.TRIANGLES,6,s.UNSIGNED_SHORT,0),this.renderSession.drawCount++},r.WebGLFilterManager.prototype.initShaderBuffers=function(){var t=this.gl;this.vertexBuffer=t.createBuffer(),this.uvBuffer=t.createBuffer(),this.colorBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.vertexArray=new r.Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW),this.uvArray=new r.Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvArray,t.STATIC_DRAW),this.colorArray=new r.Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),t.bindBuffer(t.ARRAY_BUFFER,this.colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colorArray,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),t.STATIC_DRAW)},r.WebGLFilterManager.prototype.destroy=function(){var t=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var e=0;e<this.texturePool.length;e++)this.texturePool[e].destroy();this.texturePool=null,t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.uvBuffer),t.deleteBuffer(this.colorBuffer),t.deleteBuffer(this.indexBuffer)},r.FilterTexture=function(t,e,i,n){this.gl=t,this.frameBuffer=t.createFramebuffer(),this.texture=t.createTexture(),n=n||r.scaleModes.DEFAULT,t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n===r.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n===r.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer),t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture,0),this.renderBuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.renderBuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,this.renderBuffer),this.resize(e,i)
},r.FilterTexture.prototype.constructor=r.FilterTexture,r.FilterTexture.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},r.FilterTexture.prototype.resize=function(t,e){if(this.width!==t||this.height!==e){this.width=t,this.height=e;var i=this.gl;i.bindTexture(i.TEXTURE_2D,this.texture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,e,0,i.RGBA,i.UNSIGNED_BYTE,null),i.bindRenderbuffer(i.RENDERBUFFER,this.renderBuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,e)}},r.FilterTexture.prototype.destroy=function(){var t=this.gl;t.deleteFramebuffer(this.frameBuffer),t.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},r.CanvasBuffer=function(t,e){this.width=t,this.height=e,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e},r.CanvasBuffer.prototype.constructor=r.CanvasBuffer,r.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},r.CanvasBuffer.prototype.resize=function(t,e){this.width=this.canvas.width=t,this.height=this.canvas.height=e},r.CanvasMaskManager=function(){},r.CanvasMaskManager.prototype.constructor=r.CanvasMaskManager,r.CanvasMaskManager.prototype.pushMask=function(t,e){var i=e.context;i.save();var n=t.alpha,s=t.worldTransform,o=e.resolution;i.setTransform(s.a*o,s.b*o,s.c*o,s.d*o,s.tx*o,s.ty*o),r.CanvasGraphics.renderGraphicsMask(t,i),i.clip(),t.worldAlpha=n},r.CanvasMaskManager.prototype.popMask=function(t){t.context.restore()},r.CanvasTinter=function(){},r.CanvasTinter.getTintedTexture=function(t,e){var i=t.texture;e=r.CanvasTinter.roundColor(e);var n="#"+("00000"+(0|e).toString(16)).substr(-6);if(i.tintCache=i.tintCache||{},i.tintCache[n])return i.tintCache[n];var s=r.CanvasTinter.canvas||document.createElement("canvas");if(r.CanvasTinter.tintMethod(i,e,s),r.CanvasTinter.convertTintToImage){var o=new Image;o.src=s.toDataURL(),i.tintCache[n]=o}else i.tintCache[n]=s,r.CanvasTinter.canvas=null;return s},r.CanvasTinter.tintWithMultiply=function(t,e,i){var r=i.getContext("2d"),n=t.crop;i.width=n.width,i.height=n.height,r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,n.width,n.height),r.globalCompositeOperation="multiply",r.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height)},r.CanvasTinter.tintWithOverlay=function(t,e,i){var r=i.getContext("2d"),n=t.crop;i.width=n.width,i.height=n.height,r.globalCompositeOperation="copy",r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,n.width,n.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height)},r.CanvasTinter.tintWithPerPixel=function(t,e,i){var n=i.getContext("2d"),s=t.crop;i.width=s.width,i.height=s.height,n.globalCompositeOperation="copy",n.drawImage(t.baseTexture.source,s.x,s.y,s.width,s.height,0,0,s.width,s.height);for(var o=r.hex2rgb(e),a=o[0],h=o[1],l=o[2],u=n.getImageData(0,0,s.width,s.height),c=u.data,d=0;d<c.length;d+=4)c[d+0]*=a,c[d+1]*=h,c[d+2]*=l;n.putImageData(u,0,0)},r.CanvasTinter.roundColor=function(t){var e=r.CanvasTinter.cacheStepsPerColorChannel,i=r.hex2rgb(t);return i[0]=Math.min(255,i[0]/e*e),i[1]=Math.min(255,i[1]/e*e),i[2]=Math.min(255,i[2]/e*e),r.rgb2hex(i)},r.CanvasTinter.cacheStepsPerColorChannel=8,r.CanvasTinter.convertTintToImage=!1,r.CanvasTinter.canUseMultiply=r.canUseNewCanvasBlendModes(),r.CanvasTinter.tintMethod=r.CanvasTinter.canUseMultiply?r.CanvasTinter.tintWithMultiply:r.CanvasTinter.tintWithPerPixel,r.CanvasRenderer=function(t,e,i){if(i)for(var n in r.defaultRenderOptions)"undefined"==typeof i[n]&&(i[n]=r.defaultRenderOptions[n]);else i=r.defaultRenderOptions;r.defaultRenderer||(r.sayHello("Canvas"),r.defaultRenderer=this),this.type=r.CANVAS_RENDERER,this.resolution=i.resolution,this.clearBeforeRender=i.clearBeforeRender,this.transparent=i.transparent,this.autoResize=i.autoResize||!1,this.width=t||800,this.height=e||600,this.width*=this.resolution,this.height*=this.resolution,this.view=i.view||document.createElement("canvas"),this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.view.width=this.width*this.resolution,this.view.height=this.height*this.resolution,this.count=0,this.maskManager=new r.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:null,roundPixels:!1},this.mapBlendModes(),this.resize(t,e),"imageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="imageSmoothingEnabled":"webkitImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="webkitImageSmoothingEnabled":"mozImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="mozImageSmoothingEnabled":"oImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="oImageSmoothingEnabled":"msImageSmoothingEnabled"in this.context&&(this.renderSession.smoothProperty="msImageSmoothingEnabled")},r.CanvasRenderer.prototype.constructor=r.CanvasRenderer,r.CanvasRenderer.prototype.render=function(t){t.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=r.blendModes.NORMAL,this.context.globalCompositeOperation=r.blendModesCanvas[r.blendModes.NORMAL],navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):(this.context.fillStyle=t.backgroundColorString,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t),t.interactive&&(t._interactiveEventsAdded||(t._interactiveEventsAdded=!0,t.interactionManager.setTarget(this)))},r.CanvasRenderer.prototype.destroy=function(t){"undefined"==typeof t&&(t=!0),t&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},r.CanvasRenderer.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px")},r.CanvasRenderer.prototype.renderDisplayObject=function(t,e){this.renderSession.context=e||this.context,this.renderSession.resolution=this.resolution,t._renderCanvas(this.renderSession)},r.CanvasRenderer.prototype.mapBlendModes=function(){r.blendModesCanvas||(r.blendModesCanvas=[],r.canUseNewCanvasBlendModes()?(r.blendModesCanvas[r.blendModes.NORMAL]="source-over",r.blendModesCanvas[r.blendModes.ADD]="lighter",r.blendModesCanvas[r.blendModes.MULTIPLY]="multiply",r.blendModesCanvas[r.blendModes.SCREEN]="screen",r.blendModesCanvas[r.blendModes.OVERLAY]="overlay",r.blendModesCanvas[r.blendModes.DARKEN]="darken",r.blendModesCanvas[r.blendModes.LIGHTEN]="lighten",r.blendModesCanvas[r.blendModes.COLOR_DODGE]="color-dodge",r.blendModesCanvas[r.blendModes.COLOR_BURN]="color-burn",r.blendModesCanvas[r.blendModes.HARD_LIGHT]="hard-light",r.blendModesCanvas[r.blendModes.SOFT_LIGHT]="soft-light",r.blendModesCanvas[r.blendModes.DIFFERENCE]="difference",r.blendModesCanvas[r.blendModes.EXCLUSION]="exclusion",r.blendModesCanvas[r.blendModes.HUE]="hue",r.blendModesCanvas[r.blendModes.SATURATION]="saturation",r.blendModesCanvas[r.blendModes.COLOR]="color",r.blendModesCanvas[r.blendModes.LUMINOSITY]="luminosity"):(r.blendModesCanvas[r.blendModes.NORMAL]="source-over",r.blendModesCanvas[r.blendModes.ADD]="lighter",r.blendModesCanvas[r.blendModes.MULTIPLY]="source-over",r.blendModesCanvas[r.blendModes.SCREEN]="source-over",r.blendModesCanvas[r.blendModes.OVERLAY]="source-over",r.blendModesCanvas[r.blendModes.DARKEN]="source-over",r.blendModesCanvas[r.blendModes.LIGHTEN]="source-over",r.blendModesCanvas[r.blendModes.COLOR_DODGE]="source-over",r.blendModesCanvas[r.blendModes.COLOR_BURN]="source-over",r.blendModesCanvas[r.blendModes.HARD_LIGHT]="source-over",r.blendModesCanvas[r.blendModes.SOFT_LIGHT]="source-over",r.blendModesCanvas[r.blendModes.DIFFERENCE]="source-over",r.blendModesCanvas[r.blendModes.EXCLUSION]="source-over",r.blendModesCanvas[r.blendModes.HUE]="source-over",r.blendModesCanvas[r.blendModes.SATURATION]="source-over",r.blendModesCanvas[r.blendModes.COLOR]="source-over",r.blendModesCanvas[r.blendModes.LUMINOSITY]="source-over"))},r.CanvasGraphics=function(){},r.CanvasGraphics.renderGraphics=function(t,e){var i=t.worldAlpha;t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1);for(var n=0;n<t.graphicsData.length;n++){var s=t.graphicsData[n],o=s.shape,a=s._fillTint,h=s._lineTint;if(e.lineWidth=s.lineWidth,s.type===r.Graphics.POLY){e.beginPath();var l=o.points;e.moveTo(l[0],l[1]);for(var u=1;u<l.length/2;u++)e.lineTo(l[2*u],l[2*u+1]);o.closed&&e.lineTo(l[0],l[1]),l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&e.closePath(),s.fill&&(e.globalAlpha=s.fillAlpha*i,e.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),e.fill()),s.lineWidth&&(e.globalAlpha=s.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),e.stroke())}else if(s.type===r.Graphics.RECT)(s.fillColor||0===s.fillColor)&&(e.globalAlpha=s.fillAlpha*i,e.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),e.fillRect(o.x,o.y,o.width,o.height)),s.lineWidth&&(e.globalAlpha=s.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),e.strokeRect(o.x,o.y,o.width,o.height));else if(s.type===r.Graphics.CIRC)e.beginPath(),e.arc(o.x,o.y,o.radius,0,2*Math.PI),e.closePath(),s.fill&&(e.globalAlpha=s.fillAlpha*i,e.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),e.fill()),s.lineWidth&&(e.globalAlpha=s.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),e.stroke());else if(s.type===r.Graphics.ELIP){var c=2*o.width,d=2*o.height,p=o.x-c/2,f=o.y-d/2;e.beginPath();var g=.5522848,m=c/2*g,v=d/2*g,x=p+c,y=f+d,b=p+c/2,T=f+d/2;e.moveTo(p,T),e.bezierCurveTo(p,T-v,b-m,f,b,f),e.bezierCurveTo(b+m,f,x,T-v,x,T),e.bezierCurveTo(x,T+v,b+m,y,b,y),e.bezierCurveTo(b-m,y,p,T+v,p,T),e.closePath(),s.fill&&(e.globalAlpha=s.fillAlpha*i,e.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),e.fill()),s.lineWidth&&(e.globalAlpha=s.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),e.stroke())}else if(s.type===r.Graphics.RREC){var w=o.x,S=o.y,C=o.width,A=o.height,_=o.radius,E=Math.min(C,A)/2|0;_=_>E?E:_,e.beginPath(),e.moveTo(w,S+_),e.lineTo(w,S+A-_),e.quadraticCurveTo(w,S+A,w+_,S+A),e.lineTo(w+C-_,S+A),e.quadraticCurveTo(w+C,S+A,w+C,S+A-_),e.lineTo(w+C,S+_),e.quadraticCurveTo(w+C,S,w+C-_,S),e.lineTo(w+_,S),e.quadraticCurveTo(w,S,w,S+_),e.closePath(),(s.fillColor||0===s.fillColor)&&(e.globalAlpha=s.fillAlpha*i,e.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),e.fill()),s.lineWidth&&(e.globalAlpha=s.lineAlpha*i,e.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),e.stroke())}}},r.CanvasGraphics.renderGraphicsMask=function(t,e){var i=t.graphicsData.length;if(0!==i){i>1&&(i=1,window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var n=0;1>n;n++){var s=t.graphicsData[n],o=s.shape;if(s.type===r.Graphics.POLY){e.beginPath();var a=o.points;e.moveTo(a[0],a[1]);for(var h=1;h<a.length/2;h++)e.lineTo(a[2*h],a[2*h+1]);a[0]===a[a.length-2]&&a[1]===a[a.length-1]&&e.closePath()}else if(s.type===r.Graphics.RECT)e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.closePath();else if(s.type===r.Graphics.CIRC)e.beginPath(),e.arc(o.x,o.y,o.radius,0,2*Math.PI),e.closePath();else if(s.type===r.Graphics.ELIP){var l=2*o.width,u=2*o.height,c=o.x-l/2,d=o.y-u/2;e.beginPath();var p=.5522848,f=l/2*p,g=u/2*p,m=c+l,v=d+u,x=c+l/2,y=d+u/2;e.moveTo(c,y),e.bezierCurveTo(c,y-g,x-f,d,x,d),e.bezierCurveTo(x+f,d,m,y-g,m,y),e.bezierCurveTo(m,y+g,x+f,v,x,v),e.bezierCurveTo(x-f,v,c,y+g,c,y),e.closePath()}else if(s.type===r.Graphics.RREC){var b=o.points,T=b[0],w=b[1],S=b[2],C=b[3],A=b[4],_=Math.min(S,C)/2|0;A=A>_?_:A,e.beginPath(),e.moveTo(T,w+A),e.lineTo(T,w+C-A),e.quadraticCurveTo(T,w+C,T+A,w+C),e.lineTo(T+S-A,w+C),e.quadraticCurveTo(T+S,w+C,T+S,w+C-A),e.lineTo(T+S,w+A),e.quadraticCurveTo(T+S,w,T+S-A,w),e.lineTo(T+A,w),e.quadraticCurveTo(T,w,T,w+A),e.closePath()}}}},r.CanvasGraphics.updateGraphicsTint=function(t){if(16777215!==t.tint)for(var e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,r=(255&t.tint)/255,n=0;n<t.graphicsData.length;n++){var s=t.graphicsData[n],o=0|s.fillColor,a=0|s.lineColor;s._fillTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*r*255,s._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*r*255}},r.Graphics=function(){r.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=r.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new r.Rectangle(0,0,1,1),this.dirty=!0,this.webGLDirty=!1,this.cachedSpriteDirty=!1},r.Graphics.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Graphics.prototype.constructor=r.Graphics,Object.defineProperty(r.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),r.Graphics.prototype.lineStyle=function(t,e,i){if(this.lineWidth=t||0,this.lineColor=e||0,this.lineAlpha=arguments.length<3?1:i,this.currentPath){if(this.currentPath.shape.points.length)return this.drawShape(new r.Polygon(this.currentPath.shape.points.slice(-2))),this;this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha}return this},r.Graphics.prototype.moveTo=function(t,e){return this.drawShape(new r.Polygon([t,e])),this},r.Graphics.prototype.lineTo=function(t,e){return this.currentPath.shape.points.push(t,e),this.dirty=!0,this},r.Graphics.prototype.quadraticCurveTo=function(t,e,i,r){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var n,s,o=20,a=this.currentPath.shape.points;0===a.length&&this.moveTo(0,0);for(var h=a[a.length-2],l=a[a.length-1],u=0,c=1;o>=c;c++)u=c/o,n=h+(t-h)*u,s=l+(e-l)*u,a.push(n+(t+(i-t)*u-n)*u,s+(e+(r-e)*u-s)*u);return this.dirty=!0,this},r.Graphics.prototype.bezierCurveTo=function(t,e,i,r,n,s){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var o,a,h,l,u,c=20,d=this.currentPath.shape.points,p=d[d.length-2],f=d[d.length-1],g=0,m=1;c>=m;m++)g=m/c,o=1-g,a=o*o,h=a*o,l=g*g,u=l*g,d.push(h*p+3*a*g*t+3*o*l*i+u*n,h*f+3*a*g*e+3*o*l*r+u*s);return this.dirty=!0,this},r.Graphics.prototype.arcTo=function(t,e,i,r,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);var s=this.currentPath.shape.points,o=s[s.length-2],a=s[s.length-1],h=a-e,l=o-t,u=r-e,c=i-t,d=Math.abs(h*c-l*u);if(1e-8>d||0===n)(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);else{var p=h*h+l*l,f=u*u+c*c,g=h*u+l*c,m=n*Math.sqrt(p)/d,v=n*Math.sqrt(f)/d,x=m*g/p,y=v*g/f,b=m*c+v*l,T=m*u+v*h,w=l*(v+x),S=h*(v+x),C=c*(m+y),A=u*(m+y),_=Math.atan2(S-T,w-b),E=Math.atan2(A-T,C-b);this.arc(b+t,T+e,n,_,E,l*u>c*h)}return this.dirty=!0,this},r.Graphics.prototype.arc=function(t,e,i,r,n,s){var o,a=t+Math.cos(r)*i,h=e+Math.sin(r)*i;if(this.currentPath?(o=this.currentPath.shape.points,0===o.length?o.push(a,h):(o[o.length-2]!==a||o[o.length-1]!==h)&&o.push(a,h)):(this.moveTo(a,h),o=this.currentPath.shape.points),r===n)return this;!s&&r>=n?n+=2*Math.PI:s&&n>=r&&(r+=2*Math.PI);var l=s?-1*(r-n):n-r,u=Math.abs(l)/(2*Math.PI)*40;if(0===l)return this;for(var c=l/(2*u),d=2*c,p=Math.cos(c),f=Math.sin(c),g=u-1,m=g%1/g,v=0;g>=v;v++){var x=v+m*v,y=c+r+d*x,b=Math.cos(y),T=-Math.sin(y);o.push((p*b+f*T)*i+t,(p*-T+f*b)*i+e)}return this.dirty=!0,this},r.Graphics.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},r.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},r.Graphics.prototype.drawRect=function(t,e,i,n){return this.drawShape(new r.Rectangle(t,e,i,n)),this},r.Graphics.prototype.drawRoundedRect=function(t,e,i,n,s){return this.drawShape(new r.RoundedRectangle(t,e,i,n,s)),this},r.Graphics.prototype.drawCircle=function(t,e,i){return this.drawShape(new r.Circle(t,e,i)),this},r.Graphics.prototype.drawEllipse=function(t,e,i,n){return this.drawShape(new r.Ellipse(t,e,i,n)),this},r.Graphics.prototype.drawPolygon=function(t){return t instanceof Array||(t=Array.prototype.slice.call(arguments)),this.drawShape(new r.Polygon(t)),this},r.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this},r.Graphics.prototype.generateTexture=function(t,e){t=t||1;var i=this.getBounds(),n=new r.CanvasBuffer(i.width*t,i.height*t),s=r.Texture.fromCanvas(n.canvas,e);return s.baseTexture.resolution=t,n.context.scale(t,t),n.context.translate(-i.x,-i.y),r.CanvasGraphics.renderGraphics(this,n.context),s},r.Graphics.prototype._renderWebGL=function(t){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void r.Sprite.prototype._renderWebGL.call(this._cachedSprite,t);if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;var e=r.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),r.WebGLGraphics.renderGraphics(this,t),this.children.length){t.spriteBatch.start();for(var i=0,n=this.children.length;n>i;i++)this.children[i]._renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount++,t.spriteBatch.start()}},r.Graphics.prototype._renderCanvas=function(t){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void r.Sprite.prototype._renderCanvas.call(this._cachedSprite,t);var e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=r.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t);var n=t.resolution;e.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*n,i.ty*n),r.CanvasGraphics.renderGraphics(this,e);for(var s=0,o=this.children.length;o>s;s++)this.children[s]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},r.Graphics.prototype.getBounds=function(t){if(this.isMask)return r.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var e=this._localBounds,i=e.x,n=e.width+e.x,s=e.y,o=e.height+e.y,a=t||this.worldTransform,h=a.a,l=a.b,u=a.c,c=a.d,d=a.tx,p=a.ty,f=h*n+u*o+d,g=c*o+l*n+p,m=h*i+u*o+d,v=c*o+l*i+p,x=h*i+u*s+d,y=c*s+l*i+p,b=h*n+u*s+d,T=c*s+l*n+p,w=f,S=g,C=f,A=g;return C=C>m?m:C,C=C>x?x:C,C=C>b?b:C,A=A>v?v:A,A=A>y?y:A,A=A>T?T:A,w=m>w?m:w,w=x>w?x:w,w=b>w?b:w,S=v>S?v:S,S=y>S?y:S,S=T>S?T:S,this._bounds.x=C,this._bounds.width=w-C,this._bounds.y=A,this._bounds.height=S-A,this._bounds},r.Graphics.prototype.updateLocalBounds=function(){var t=1/0,e=-1/0,i=1/0,n=-1/0;if(this.graphicsData.length)for(var s,o,a,h,l,u,c=0;c<this.graphicsData.length;c++){var d=this.graphicsData[c],p=d.type,f=d.lineWidth;if(s=d.shape,p===r.Graphics.RECT||p===r.Graphics.RREC)a=s.x-f/2,h=s.y-f/2,l=s.width+f,u=s.height+f,t=t>a?a:t,e=a+l>e?a+l:e,i=i>h?h:i,n=h+u>n?h+u:n;else if(p===r.Graphics.CIRC)a=s.x,h=s.y,l=s.radius+f/2,u=s.radius+f/2,t=t>a-l?a-l:t,e=a+l>e?a+l:e,i=i>h-u?h-u:i,n=h+u>n?h+u:n;else if(p===r.Graphics.ELIP)a=s.x,h=s.y,l=s.width+f/2,u=s.height+f/2,t=t>a-l?a-l:t,e=a+l>e?a+l:e,i=i>h-u?h-u:i,n=h+u>n?h+u:n;else{o=s.points;for(var g=0;g<o.length;g+=2)a=o[g],h=o[g+1],t=t>a-f?a-f:t,e=a+f>e?a+f:e,i=i>h-f?h-f:i,n=h+f>n?h+f:n}}else t=0,e=0,i=0,n=0;var m=this.boundsPadding;this._localBounds.x=t-m,this._localBounds.width=e-t+2*m,this._localBounds.y=i-m,this._localBounds.height=n-i+2*m},r.Graphics.prototype._generateCachedSprite=function(){var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{var e=new r.CanvasBuffer(t.width,t.height),i=r.Texture.fromCanvas(e.canvas);this._cachedSprite=new r.Sprite(i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-(t.x/t.width),this._cachedSprite.anchor.y=-(t.y/t.height),this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,r.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},r.Graphics.prototype.updateCachedSpriteTexture=function(){var t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=e.frame.width=i.width,e.crop.height=e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()},r.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},r.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null;var e=new r.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===r.Graphics.POLY&&(e.shape.closed=this.filling,this.currentPath=e),this.dirty=!0,e},r.GraphicsData=function(t,e,i,r,n,s,o){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=r,this.fillAlpha=n,this._fillTint=r,this.fill=s,this.shape=o,this.type=o.type},r.Graphics.POLY=0,r.Graphics.RECT=1,r.Graphics.CIRC=2,r.Graphics.ELIP=3,r.Graphics.RREC=4,r.Polygon.prototype.type=r.Graphics.POLY,r.Rectangle.prototype.type=r.Graphics.RECT,r.Circle.prototype.type=r.Graphics.CIRC,r.Ellipse.prototype.type=r.Graphics.ELIP,r.RoundedRectangle.prototype.type=r.Graphics.RREC,r.Strip=function(t){r.DisplayObjectContainer.call(this),this.texture=t,this.uvs=new r.Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new r.Float32Array([0,0,100,0,100,100,0,100]),this.colors=new r.Float32Array([1,1,1,1]),this.indices=new r.Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=r.blendModes.NORMAL,this.canvasPadding=0,this.drawMode=r.Strip.DrawModes.TRIANGLE_STRIP},r.Strip.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Strip.prototype.constructor=r.Strip,r.Strip.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||(t.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(t),t.shaderManager.setShader(t.shaderManager.stripShader),this._renderStrip(t),t.spriteBatch.start())},r.Strip.prototype._initWebGL=function(t){var e=t.gl;this._vertexBuffer=e.createBuffer(),this._indexBuffer=e.createBuffer(),this._uvBuffer=e.createBuffer(),this._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colors,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)},r.Strip.prototype._renderStrip=function(t){var e=t.gl,i=t.projection,n=t.offset,s=t.shaderManager.stripShader,o=this.drawMode===r.Strip.DrawModes.TRIANGLE_STRIP?e.TRIANGLE_STRIP:e.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode),e.uniformMatrix3fv(s.translationMatrix,!1,this.worldTransform.toArray(!0)),e.uniform2f(s.projectionVector,i.x,-i.y),e.uniform2f(s.offsetVector,-n.x,-n.y),e.uniform1f(s.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.STATIC_DRAW),e.vertexAttribPointer(s.aVertexPosition,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.vertexAttribPointer(s.aTextureCoord,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),this.texture.baseTexture._dirty[e.id]?t.renderer.updateTexture(this.texture.baseTexture):e.bindTexture(e.TEXTURE_2D,this.texture.baseTexture._glTextures[e.id]),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)):(e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices),e.vertexAttribPointer(s.aVertexPosition,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.vertexAttribPointer(s.aTextureCoord,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),this.texture.baseTexture._dirty[e.id]?t.renderer.updateTexture(this.texture.baseTexture):e.bindTexture(e.TEXTURE_2D,this.texture.baseTexture._glTextures[e.id]),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),e.drawElements(o,this.indices.length,e.UNSIGNED_SHORT,0)},r.Strip.prototype._renderCanvas=function(t){var e=t.context,i=this.worldTransform;t.roundPixels?e.setTransform(i.a,i.b,i.c,i.d,0|i.tx,0|i.ty):e.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),this.drawMode===r.Strip.DrawModes.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(e):this._renderCanvasTriangles(e)},r.Strip.prototype._renderCanvasTriangleStrip=function(t){var e=this.vertices,i=this.uvs,r=e.length/2;this.count++;for(var n=0;r-2>n;n++){var s=2*n;this._renderCanvasDrawTriangle(t,e,i,s,s+2,s+4)}},r.Strip.prototype._renderCanvasTriangles=function(t){var e=this.vertices,i=this.uvs,r=this.indices,n=r.length;this.count++;for(var s=0;n>s;s+=3){var o=2*r[s],a=2*r[s+1],h=2*r[s+2];this._renderCanvasDrawTriangle(t,e,i,o,a,h)}},r.Strip.prototype._renderCanvasDrawTriangle=function(t,e,i,r,n,s){var o=this.texture.baseTexture.source,a=this.texture.width,h=this.texture.height,l=e[r],u=e[n],c=e[s],d=e[r+1],p=e[n+1],f=e[s+1],g=i[r]*a,m=i[n]*a,v=i[s]*a,x=i[r+1]*h,y=i[n+1]*h,b=i[s+1]*h;if(this.canvasPadding>0){var T=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,S=(l+u+c)/3,C=(d+p+f)/3,A=l-S,_=d-C,E=Math.sqrt(A*A+_*_);l=S+A/E*(E+T),d=C+_/E*(E+w),A=u-S,_=p-C,E=Math.sqrt(A*A+_*_),u=S+A/E*(E+T),p=C+_/E*(E+w),A=c-S,_=f-C,E=Math.sqrt(A*A+_*_),c=S+A/E*(E+T),f=C+_/E*(E+w)}t.save(),t.beginPath(),t.moveTo(l,d),t.lineTo(u,p),t.lineTo(c,f),t.closePath(),t.clip();var R=g*y+x*v+m*b-y*v-x*m-g*b,M=l*y+x*c+u*b-y*c-x*u-l*b,L=g*u+l*v+m*c-u*v-l*m-g*c,F=g*y*c+x*u*v+l*m*b-l*y*v-x*m*c-g*u*b,B=d*y+x*f+p*b-y*f-x*p-d*b,P=g*p+d*v+m*f-p*v-d*m-g*f,D=g*y*f+x*p*v+d*m*b-d*y*v-x*m*f-g*p*b;t.transform(M/R,B/R,L/R,P/R,F/R,D/R),t.drawImage(o,0,0),t.restore()},r.Strip.prototype.renderStripFlat=function(t){var e=this.context,i=t.vertices,r=i.length/2;this.count++,e.beginPath();for(var n=1;r-2>n;n++){var s=2*n,o=i[s],a=i[s+2],h=i[s+4],l=i[s+1],u=i[s+3],c=i[s+5];e.moveTo(o,l),e.lineTo(a,u),e.lineTo(h,c)}e.fillStyle="#FF0000",e.fill(),e.closePath()},r.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},r.Strip.prototype.getBounds=function(t){for(var e=t||this.worldTransform,i=e.a,n=e.b,s=e.c,o=e.d,a=e.tx,h=e.ty,l=-1/0,u=-1/0,c=1/0,d=1/0,p=this.vertices,f=0,g=p.length;g>f;f+=2){var m=p[f],v=p[f+1],x=i*m+s*v+a,y=o*v+n*m+h;c=c>x?x:c,d=d>y?y:d,l=x>l?x:l,u=y>u?y:u}if(c===-1/0||1/0===u)return r.EmptyRectangle;var b=this._bounds;return b.x=c,b.width=l-c,b.y=d,b.height=u-d,this._currentBounds=b,b},r.Strip.DrawModes={TRIANGLE_STRIP:0,TRIANGLES:1},r.Rope=function(t,e){r.Strip.call(this,t),this.points=e,this.vertices=new r.Float32Array(4*e.length),this.uvs=new r.Float32Array(4*e.length),this.colors=new r.Float32Array(2*e.length),this.indices=new r.Uint16Array(2*e.length),this.refresh()},r.Rope.prototype=Object.create(r.Strip.prototype),r.Rope.prototype.constructor=r.Rope,r.Rope.prototype.refresh=function(){var t=this.points;if(!(t.length<1)){var e=this.uvs,i=t[0],r=this.indices,n=this.colors;this.count-=.2,e[0]=0,e[1]=0,e[2]=0,e[3]=1,n[0]=1,n[1]=1,r[0]=0,r[1]=1;for(var s,o,a,h=t.length,l=1;h>l;l++)s=t[l],o=4*l,a=l/(h-1),l%2?(e[o]=a,e[o+1]=0,e[o+2]=a,e[o+3]=1):(e[o]=a,e[o+1]=0,e[o+2]=a,e[o+3]=1),o=2*l,n[o]=1,n[o+1]=1,o=2*l,r[o]=o,r[o+1]=o+1,i=s}},r.Rope.prototype.updateTransform=function(){var t=this.points;if(!(t.length<1)){var e,i=t[0],n={x:0,y:0};this.count-=.2;for(var s,o,a,h,l,u=this.vertices,c=t.length,d=0;c>d;d++)s=t[d],o=4*d,e=d<t.length-1?t[d+1]:s,n.y=-(e.x-i.x),n.x=e.y-i.y,a=10*(1-d/(c-1)),a>1&&(a=1),h=Math.sqrt(n.x*n.x+n.y*n.y),l=this.texture.height/2,n.x/=h,n.y/=h,n.x*=l,n.y*=l,u[o]=s.x+n.x,u[o+1]=s.y+n.y,u[o+2]=s.x-n.x,u[o+3]=s.y-n.y,i=s;r.DisplayObjectContainer.prototype.updateTransform.call(this)}},r.Rope.prototype.setTexture=function(t){this.texture=t},r.TilingSprite=function(t,e,i){r.Sprite.call(this,t),this._width=e||100,this._height=i||100,this.tileScale=new r.Point(1,1),this.tileScaleOffset=new r.Point(1,1),this.tilePosition=new r.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=r.blendModes.NORMAL},r.TilingSprite.prototype=Object.create(r.Sprite.prototype),r.TilingSprite.prototype.constructor=r.TilingSprite,Object.defineProperty(r.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(r.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),r.TilingSprite.prototype.setTexture=function(t){this.texture!==t&&(this.texture=t,this.refreshTexture=!0,this.cachedTint=16777215)},r.TilingSprite.prototype._renderWebGL=function(t){if(this.visible!==!1&&0!==this.alpha){var e,i;for(this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),!this.tilingTexture||this.refreshTexture?(this.generateTilingTexture(!0),this.tilingTexture&&this.tilingTexture.needsUpdate&&(t.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)):t.spriteBatch.renderTilingSprite(this),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t);t.spriteBatch.stop(),this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this._mask,t),t.spriteBatch.start()}},r.TilingSprite.prototype._renderCanvas=function(t){if(this.visible!==!1&&0!==this.alpha){var e=t.context;this._mask&&t.maskManager.pushMask(this._mask,e),e.globalAlpha=this.worldAlpha;var i,n,s=this.worldTransform,o=t.resolution;if(e.setTransform(s.a*o,s.b*o,s.c*o,s.d*o,s.tx*o,s.ty*o),!this.__tilePattern||this.refreshTexture){if(this.generateTilingTexture(!1),!this.tilingTexture)return;this.__tilePattern=e.createPattern(this.tilingTexture.baseTexture.source,"repeat")}this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=r.blendModesCanvas[t.currentBlendMode]);var a=this.tilePosition,h=this.tileScale;for(a.x%=this.tilingTexture.baseTexture.width,a.y%=this.tilingTexture.baseTexture.height,e.scale(h.x,h.y),e.translate(a.x+this.anchor.x*-this._width,a.y+this.anchor.y*-this._height),e.fillStyle=this.__tilePattern,e.fillRect(-a.x,-a.y,this._width/h.x,this._height/h.y),e.scale(1/h.x,1/h.y),e.translate(-a.x+this.anchor.x*this._width,-a.y+this.anchor.y*this._height),this._mask&&t.maskManager.popMask(t.context),i=0,n=this.children.length;n>i;i++)this.children[i]._renderCanvas(t)
}},r.TilingSprite.prototype.getBounds=function(){var t=this._width,e=this._height,i=t*(1-this.anchor.x),r=t*-this.anchor.x,n=e*(1-this.anchor.y),s=e*-this.anchor.y,o=this.worldTransform,a=o.a,h=o.b,l=o.c,u=o.d,c=o.tx,d=o.ty,p=a*r+l*s+c,f=u*s+h*r+d,g=a*i+l*s+c,m=u*s+h*i+d,v=a*i+l*n+c,x=u*n+h*i+d,y=a*r+l*n+c,b=u*n+h*r+d,T=-1/0,w=-1/0,S=1/0,C=1/0;S=S>p?p:S,S=S>g?g:S,S=S>v?v:S,S=S>y?y:S,C=C>f?f:C,C=C>m?m:C,C=C>x?x:C,C=C>b?b:C,T=p>T?p:T,T=g>T?g:T,T=v>T?v:T,T=y>T?y:T,w=f>w?f:w,w=m>w?m:w,w=x>w?x:w,w=b>w?b:w;var A=this._bounds;return A.x=S,A.width=T-S,A.y=C,A.height=w-C,this._currentBounds=A,A},r.TilingSprite.prototype.onTextureUpdate=function(){},r.TilingSprite.prototype.generateTilingTexture=function(t){if(this.texture.baseTexture.hasLoaded){var e,i,n=this.originalTexture||this.texture,s=n.frame,o=s.width!==n.baseTexture.width||s.height!==n.baseTexture.height,a=!1;if(t?(e=r.getNextPowerOfTwo(s.width),i=r.getNextPowerOfTwo(s.height),(s.width!==e||s.height!==i||n.baseTexture.width!==e||n.baseTexture.height||i)&&(a=!0)):o&&(e=s.width,i=s.height,a=!0),a){var h;this.tilingTexture&&this.tilingTexture.isTiling?(h=this.tilingTexture.canvasBuffer,h.resize(e,i),this.tilingTexture.baseTexture.width=e,this.tilingTexture.baseTexture.height=i,this.tilingTexture.needsUpdate=!0):(h=new r.CanvasBuffer(e,i),this.tilingTexture=r.Texture.fromCanvas(h.canvas),this.tilingTexture.canvasBuffer=h,this.tilingTexture.isTiling=!0),h.context.drawImage(n.baseTexture.source,n.crop.x,n.crop.y,n.crop.width,n.crop.height,0,0,e,i),this.tileScaleOffset.x=s.width/e,this.tileScaleOffset.y=s.height/i}else this.tilingTexture&&this.tilingTexture.isTiling&&this.tilingTexture.destroy(!0),this.tileScaleOffset.x=1,this.tileScaleOffset.y=1,this.tilingTexture=n;this.refreshTexture=!1,this.originalTexture=this.texture,this.texture=this.tilingTexture,this.tilingTexture.baseTexture._powerOf2=!0}};var n={radDeg:180/Math.PI,degRad:Math.PI/180,temp:[],Float32Array:"undefined"==typeof Float32Array?Array:Float32Array,Uint16Array:"undefined"==typeof Uint16Array?Array:Uint16Array};n.BoneData=function(t,e){this.name=t,this.parent=e},n.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1,inheritScale:!0,inheritRotation:!0,flipX:!1,flipY:!1},n.SlotData=function(t,e){this.name=t,this.boneData=e},n.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null,additiveBlending:!1},n.IkConstraintData=function(t){this.name=t,this.bones=[]},n.IkConstraintData.prototype={target:null,bendDirection:1,mix:1},n.Bone=function(t,e,i){this.data=t,this.skeleton=e,this.parent=i,this.setToSetupPose()},n.Bone.yDown=!1,n.Bone.prototype={x:0,y:0,rotation:0,rotationIK:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,worldFlipX:!1,worldFlipY:!1,updateWorldTransform:function(){var t=this.parent;if(t)this.worldX=this.x*t.m00+this.y*t.m01+t.worldX,this.worldY=this.x*t.m10+this.y*t.m11+t.worldY,this.data.inheritScale?(this.worldScaleX=t.worldScaleX*this.scaleX,this.worldScaleY=t.worldScaleY*this.scaleY):(this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY),this.worldRotation=this.data.inheritRotation?t.worldRotation+this.rotationIK:this.rotationIK,this.worldFlipX=t.worldFlipX!=this.flipX,this.worldFlipY=t.worldFlipY!=this.flipY;else{var e=this.skeleton.flipX,i=this.skeleton.flipY;this.worldX=e?-this.x:this.x,this.worldY=i!=n.Bone.yDown?-this.y:this.y,this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY,this.worldRotation=this.rotationIK,this.worldFlipX=e!=this.flipX,this.worldFlipY=i!=this.flipY}var r=this.worldRotation*n.degRad,s=Math.cos(r),o=Math.sin(r);this.worldFlipX?(this.m00=-s*this.worldScaleX,this.m01=o*this.worldScaleY):(this.m00=s*this.worldScaleX,this.m01=-o*this.worldScaleY),this.worldFlipY!=n.Bone.yDown?(this.m10=-o*this.worldScaleX,this.m11=-s*this.worldScaleY):(this.m10=o*this.worldScaleX,this.m11=s*this.worldScaleY)},setToSetupPose:function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.rotationIK=this.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.flipX=t.flipX,this.flipY=t.flipY},worldToLocal:function(t){var e=t[0]-this.worldX,i=t[1]-this.worldY,r=this.m00,s=this.m10,o=this.m01,a=this.m11;this.worldFlipX!=(this.worldFlipY!=n.Bone.yDown)&&(r=-r,a=-a);var h=1/(r*a-o*s);t[0]=e*r*h-i*o*h,t[1]=i*a*h-e*s*h},localToWorld:function(t){var e=t[0],i=t[1];t[0]=e*this.m00+i*this.m01+this.worldX,t[1]=e*this.m10+i*this.m11+this.worldY}},n.Slot=function(t,e){this.data=t,this.bone=e,this.setToSetupPose()},n.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,attachmentVertices:[],setAttachment:function(t){this.attachment=t,this._attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0},setAttachmentTime:function(t){this._attachmentTime=this.bone.skeleton.time-t},getAttachmentTime:function(){return this.bone.skeleton.time-this._attachmentTime},setToSetupPose:function(){var t=this.data;this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a;for(var e=this.bone.skeleton.data.slots,i=0,r=e.length;r>i;i++)if(e[i]==t){this.setAttachment(t.attachmentName?this.bone.skeleton.getAttachmentBySlotIndex(i,t.attachmentName):null);break}}},n.IkConstraint=function(t,e){this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=[];for(var i=0,r=t.bones.length;r>i;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findBone(t.target.name)},n.IkConstraint.prototype={apply:function(){var t=this.target,e=this.bones;switch(e.length){case 1:n.IkConstraint.apply1(e[0],t.worldX,t.worldY,this.mix);break;case 2:n.IkConstraint.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.mix)}}},n.IkConstraint.apply1=function(t,e,i,r){var s=t.data.inheritRotation&&t.parent?t.parent.worldRotation:0,o=t.rotation,a=Math.atan2(i-t.worldY,e-t.worldX)*n.radDeg-s;t.rotationIK=o+(a-o)*r},n.IkConstraint.apply2=function(t,e,i,r,s,o){var a=e.rotation,h=t.rotation;if(!o)return e.rotationIK=a,void(t.rotationIK=h);var l,u,c=n.temp,d=t.parent;d?(c[0]=i,c[1]=r,d.worldToLocal(c),i=(c[0]-t.x)*d.worldScaleX,r=(c[1]-t.y)*d.worldScaleY):(i-=t.x,r-=t.y),e.parent==t?(l=e.x,u=e.y):(c[0]=e.x,c[1]=e.y,e.parent.localToWorld(c),t.worldToLocal(c),l=c[0],u=c[1]);var p=l*t.worldScaleX,f=u*t.worldScaleY,g=Math.atan2(f,p),m=Math.sqrt(p*p+f*f),v=e.data.length*e.worldScaleX,x=2*m*v;if(1e-4>x)return void(e.rotationIK=a+(Math.atan2(r,i)*n.radDeg-h-a)*o);var y=(i*i+r*r-m*m-v*v)/x;-1>y?y=-1:y>1&&(y=1);var b=Math.acos(y)*s,T=m+v*y,w=v*Math.sin(b),S=Math.atan2(r*T-i*w,i*T+r*w),C=(S-g)*n.radDeg-h;C>180?C-=360:-180>C&&(C+=360),t.rotationIK=h+C*o,C=(b+g)*n.radDeg-a,C>180?C-=360:-180>C&&(C+=360),e.rotationIK=a+(C+t.worldRotation-e.parent.worldRotation)*o},n.Skin=function(t){this.name=t,this.attachments={}},n.Skin.prototype={addAttachment:function(t,e,i){this.attachments[t+":"+e]=i},getAttachment:function(t,e){return this.attachments[t+":"+e]},_attachAll:function(t,e){for(var i in e.attachments){var r=i.indexOf(":"),n=parseInt(i.substring(0,r)),s=i.substring(r+1),o=t.slots[n];if(o.attachment&&o.attachment.name==s){var a=this.getAttachment(n,s);a&&o.setAttachment(a)}}}},n.Animation=function(t,e,i){this.name=t,this.timelines=e,this.duration=i},n.Animation.prototype={apply:function(t,e,i,r,n){r&&0!=this.duration&&(i%=this.duration,e%=this.duration);for(var s=this.timelines,o=0,a=s.length;a>o;o++)s[o].apply(t,e,i,n,1)},mix:function(t,e,i,r,n,s){r&&0!=this.duration&&(i%=this.duration,e%=this.duration);for(var o=this.timelines,a=0,h=o.length;h>a;a++)o[a].apply(t,e,i,n,s)}},n.Animation.binarySearch=function(t,e,i){var r=0,n=Math.floor(t.length/i)-2;if(!n)return i;for(var s=n>>>1;;){if(t[(s+1)*i]<=e?r=s+1:n=s,r==n)return(r+1)*i;s=r+n>>>1}},n.Animation.binarySearch1=function(t,e){var i=0,r=t.length-2;if(!r)return 1;for(var n=r>>>1;;){if(t[n+1]<=e?i=n+1:r=n,i==r)return i+1;n=i+r>>>1}},n.Animation.linearSearch=function(t,e,i){for(var r=0,n=t.length-i;n>=r;r+=i)if(t[r]>e)return r;return-1},n.Curves=function(){this.curves=[]},n.Curves.prototype={setLinear:function(t){this.curves[19*t]=0},setStepped:function(t){this.curves[19*t]=1},setCurve:function(t,e,i,r,n){var s=.1,o=s*s,a=o*s,h=3*s,l=3*o,u=6*o,c=6*a,d=2*-e+r,p=2*-i+n,f=3*(e-r)+1,g=3*(i-n)+1,m=e*h+d*l+f*a,v=i*h+p*l+g*a,x=d*u+f*c,y=p*u+g*c,b=f*c,T=g*c,w=19*t,S=this.curves;S[w++]=2;for(var C=m,A=v,_=w+19-1;_>w;w+=2)S[w]=C,S[w+1]=A,m+=x,v+=y,x+=b,y+=T,C+=m,A+=v},getCurvePercent:function(t,e){e=0>e?0:e>1?1:e;var i=this.curves,r=19*t,n=i[r];if(0===n)return e;if(1==n)return 0;r++;for(var s=0,o=r,a=r+19-1;a>r;r+=2)if(s=i[r],s>=e){var h,l;return r==o?(h=0,l=0):(h=i[r-2],l=i[r-1]),l+(i[r+1]-l)*(e-h)/(s-h)}var u=i[r-1];return u+(1-u)*(e-s)/(1-s)}},n.RotateTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=2*t},n.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(t,e,i){t*=2,this.frames[t]=e,this.frames[t+1]=i},apply:function(t,e,i,r,s){var o=this.frames;if(!(i<o[0])){var a=t.bones[this.boneIndex];if(i>=o[o.length-2]){for(var h=a.data.rotation+o[o.length-1]-a.rotation;h>180;)h-=360;for(;-180>h;)h+=360;return void(a.rotation+=h*s)}var l=n.Animation.binarySearch(o,i,2),u=o[l-1],c=o[l],d=1-(i-c)/(o[l-2]-c);d=this.curves.getCurvePercent(l/2-1,d);for(var h=o[l+1]-u;h>180;)h-=360;for(;-180>h;)h+=360;for(h=a.data.rotation+(u+h*d)-a.rotation;h>180;)h-=360;for(;-180>h;)h+=360;a.rotation+=h*s}}},n.TranslateTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=3*t},n.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(t,e,i,r){t*=3,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r},apply:function(t,e,i,r,s){var o=this.frames;if(!(i<o[0])){var a=t.bones[this.boneIndex];if(i>=o[o.length-3])return a.x+=(a.data.x+o[o.length-2]-a.x)*s,void(a.y+=(a.data.y+o[o.length-1]-a.y)*s);var h=n.Animation.binarySearch(o,i,3),l=o[h-2],u=o[h-1],c=o[h],d=1-(i-c)/(o[h+-3]-c);d=this.curves.getCurvePercent(h/3-1,d),a.x+=(a.data.x+l+(o[h+1]-l)*d-a.x)*s,a.y+=(a.data.y+u+(o[h+2]-u)*d-a.y)*s}}},n.ScaleTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=3*t},n.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(t,e,i,r){t*=3,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r},apply:function(t,e,i,r,s){var o=this.frames;if(!(i<o[0])){var a=t.bones[this.boneIndex];if(i>=o[o.length-3])return a.scaleX+=(a.data.scaleX*o[o.length-2]-a.scaleX)*s,void(a.scaleY+=(a.data.scaleY*o[o.length-1]-a.scaleY)*s);var h=n.Animation.binarySearch(o,i,3),l=o[h-2],u=o[h-1],c=o[h],d=1-(i-c)/(o[h+-3]-c);d=this.curves.getCurvePercent(h/3-1,d),a.scaleX+=(a.data.scaleX*(l+(o[h+1]-l)*d)-a.scaleX)*s,a.scaleY+=(a.data.scaleY*(u+(o[h+2]-u)*d)-a.scaleY)*s}}},n.ColorTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=5*t},n.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/5},setFrame:function(t,e,i,r,n,s){t*=5,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r,this.frames[t+3]=n,this.frames[t+4]=s},apply:function(t,e,i,r,s){var o=this.frames;if(!(i<o[0])){var a,h,l,u;if(i>=o[o.length-5]){var c=o.length-1;a=o[c-3],h=o[c-2],l=o[c-1],u=o[c]}else{var d=n.Animation.binarySearch(o,i,5),p=o[d-4],f=o[d-3],g=o[d-2],m=o[d-1],v=o[d],x=1-(i-v)/(o[d-5]-v);x=this.curves.getCurvePercent(d/5-1,x),a=p+(o[d+1]-p)*x,h=f+(o[d+2]-f)*x,l=g+(o[d+3]-g)*x,u=m+(o[d+4]-m)*x}var y=t.slots[this.slotIndex];1>s?(y.r+=(a-y.r)*s,y.g+=(h-y.g)*s,y.b+=(l-y.b)*s,y.a+=(u-y.a)*s):(y.r=a,y.g=h,y.b=l,y.a=u)}}},n.AttachmentTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=t,this.attachmentNames=[],this.attachmentNames.length=t},n.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},apply:function(t,e,i){var r=this.frames;if(i<r[0])return void(e>i&&this.apply(t,e,Number.MAX_VALUE,null,0));e>i&&(e=-1);var s=i>=r[r.length-1]?r.length-1:n.Animation.binarySearch1(r,i)-1;if(!(r[s]<e)){var o=this.attachmentNames[s];t.slots[this.slotIndex].setAttachment(o?t.getAttachmentBySlotIndex(this.slotIndex,o):null)}}},n.EventTimeline=function(t){this.frames=[],this.frames.length=t,this.events=[],this.events.length=t},n.EventTimeline.prototype={getFrameCount:function(){return this.frames.length},setFrame:function(t,e,i){this.frames[t]=e,this.events[t]=i},apply:function(t,e,i,r,s){if(r){var o=this.frames,a=o.length;if(e>i)this.apply(t,e,Number.MAX_VALUE,r,s),e=-1;else if(e>=o[a-1])return;if(!(i<o[0])){var h;if(e<o[0])h=0;else{h=n.Animation.binarySearch1(o,e);for(var l=o[h];h>0&&o[h-1]==l;)h--}for(var u=this.events;a>h&&i>=o[h];h++)r.push(u[h])}}}},n.DrawOrderTimeline=function(t){this.frames=[],this.frames.length=t,this.drawOrders=[],this.drawOrders.length=t},n.DrawOrderTimeline.prototype={getFrameCount:function(){return this.frames.length},setFrame:function(t,e,i){this.frames[t]=e,this.drawOrders[t]=i},apply:function(t,e,i){var r=this.frames;if(!(i<r[0])){var s;s=i>=r[r.length-1]?r.length-1:n.Animation.binarySearch1(r,i)-1;var o=t.drawOrder,a=t.slots,h=this.drawOrders[s];if(h)for(var l=0,u=h.length;u>l;l++)o[l]=t.slots[h[l]];else for(var l=0,u=a.length;u>l;l++)o[l]=a[l]}}},n.FfdTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=t,this.frameVertices=[],this.frameVertices.length=t},n.FfdTimeline.prototype={slotIndex:0,attachment:0,getFrameCount:function(){return this.frames.length},setFrame:function(t,e,i){this.frames[t]=e,this.frameVertices[t]=i},apply:function(t,e,i,r,s){var o=t.slots[this.slotIndex];if(o.attachment==this.attachment){var a=this.frames;if(!(i<a[0])){var h=this.frameVertices,l=h[0].length,u=o.attachmentVertices;if(u.length!=l&&(s=1),u.length=l,i>=a[a.length-1]){var c=h[a.length-1];if(1>s)for(var d=0;l>d;d++)u[d]+=(c[d]-u[d])*s;else for(var d=0;l>d;d++)u[d]=c[d]}else{var p=n.Animation.binarySearch1(a,i),f=a[p],g=1-(i-f)/(a[p-1]-f);g=this.curves.getCurvePercent(p-1,0>g?0:g>1?1:g);var m=h[p-1],v=h[p];if(1>s)for(var d=0;l>d;d++){var x=m[d];u[d]+=(x+(v[d]-x)*g-u[d])*s}else for(var d=0;l>d;d++){var x=m[d];u[d]=x+(v[d]-x)*g}}}}}},n.IkConstraintTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=3*t},n.IkConstraintTimeline.prototype={ikConstraintIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(t,e,i,r){t*=3,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r},apply:function(t,e,i,r,s){var o=this.frames;if(!(i<o[0])){var a=t.ikConstraints[this.ikConstraintIndex];if(i>=o[o.length-3])return a.mix+=(o[o.length-2]-a.mix)*s,void(a.bendDirection=o[o.length-1]);var h=n.Animation.binarySearch(o,i,3),l=o[h+-2],u=o[h],c=1-(i-u)/(o[h+-3]-u);c=this.curves.getCurvePercent(h/3-1,c);var d=l+(o[h+1]-l)*c;a.mix+=(d-a.mix)*s,a.bendDirection=o[h+-1]}}},n.FlipXTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=2*t},n.FlipXTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(t,e,i){t*=2,this.frames[t]=e,this.frames[t+1]=i?1:0},apply:function(t,e,i){var r=this.frames;if(i<r[0])return void(e>i&&this.apply(t,e,Number.MAX_VALUE,null,0));e>i&&(e=-1);var s=(i>=r[r.length-2]?r.length:n.Animation.binarySearch(r,i,2))-2;r[s]<e||(t.bones[boneIndex].flipX=0!=r[s+1])}},n.FlipYTimeline=function(t){this.curves=new n.Curves(t),this.frames=[],this.frames.length=2*t},n.FlipYTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(t,e,i){t*=2,this.frames[t]=e,this.frames[t+1]=i?1:0},apply:function(t,e,i){var r=this.frames;if(i<r[0])return void(e>i&&this.apply(t,e,Number.MAX_VALUE,null,0));e>i&&(e=-1);var s=(i>=r[r.length-2]?r.length:n.Animation.binarySearch(r,i,2))-2;r[s]<e||(t.bones[boneIndex].flipY=0!=r[s+1])}},n.SkeletonData=function(){this.bones=[],this.slots=[],this.skins=[],this.events=[],this.animations=[],this.ikConstraints=[]},n.SkeletonData.prototype={name:null,defaultSkin:null,width:0,height:0,version:null,hash:null,findBone:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},findBoneIndex:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].name==t)return i;return-1},findSlot:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].name==t)return slot[i];return null},findSlotIndex:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].name==t)return i;return-1},findSkin:function(t){for(var e=this.skins,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},findEvent:function(t){for(var e=this.events,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},findAnimation:function(t){for(var e=this.animations,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},findIkConstraint:function(t){for(var e=this.ikConstraints,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null}},n.Skeleton=function(t){this.data=t,this.bones=[];for(var e=0,i=t.bones.length;i>e;e++){var r=t.bones[e],s=r.parent?this.bones[t.bones.indexOf(r.parent)]:null;this.bones.push(new n.Bone(r,this,s))}this.slots=[],this.drawOrder=[];for(var e=0,i=t.slots.length;i>e;e++){var o=t.slots[e],a=this.bones[t.bones.indexOf(o.boneData)],h=new n.Slot(o,a);this.slots.push(h),this.drawOrder.push(h)}this.ikConstraints=[];for(var e=0,i=t.ikConstraints.length;i>e;e++)this.ikConstraints.push(new n.IkConstraint(t.ikConstraints[e],this));this.boneCache=[],this.updateCache()},n.Skeleton.prototype={x:0,y:0,skin:null,r:1,g:1,b:1,a:1,time:0,flipX:!1,flipY:!1,updateCache:function(){var t=this.ikConstraints,e=t.length,i=e+1,r=this.boneCache;r.length>i&&(r.length=i);for(var n=0,s=r.length;s>n;n++)r[n].length=0;for(;r.length<i;)r[r.length]=[];var o=r[0],a=this.bones;t:for(var n=0,s=a.length;s>n;n++){var h=a[n],l=h;do{for(var u=0;e>u;u++)for(var c=t[u],d=c.bones[0],p=c.bones[c.bones.length-1];;){if(l==p){r[u].push(h),r[u+1].push(h);continue t}if(p==d)break;p=p.parent}l=l.parent}while(l);o[o.length]=h}},updateWorldTransform:function(){for(var t=this.bones,e=0,i=t.length;i>e;e++){var r=t[e];r.rotationIK=r.rotation}for(var e=0,n=this.boneCache.length-1;;){for(var s=this.boneCache[e],o=0,a=s.length;a>o;o++)s[o].updateWorldTransform();if(e==n)break;this.ikConstraints[e].apply(),e++}},setToSetupPose:function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},setBonesToSetupPose:function(){for(var t=this.bones,e=0,i=t.length;i>e;e++)t[e].setToSetupPose();for(var r=this.ikConstraints,e=0,i=r.length;i>e;e++){var n=r[e];n.bendDirection=n.data.bendDirection,n.mix=n.data.mix}},setSlotsToSetupPose:function(){for(var t=this.slots,e=this.drawOrder,i=0,r=t.length;r>i;i++)e[i]=t[i],t[i].setToSetupPose(i)},getRootBone:function(){return this.bones.length?this.bones[0]:null},findBone:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return e[i];return null},findBoneIndex:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return i;return-1},findSlot:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return e[i];return null},findSlotIndex:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return i;return-1},setSkinByName:function(t){var e=this.data.findSkin(t);if(!e)throw"Skin not found: "+t;this.setSkin(e)},setSkin:function(t){if(t)if(this.skin)t._attachAll(this,this.skin);else for(var e=this.slots,i=0,r=e.length;r>i;i++){var n=e[i],s=n.data.attachmentName;if(s){var o=t.getAttachment(i,s);o&&n.setAttachment(o)}}this.skin=t},getAttachmentBySlotName:function(t,e){return this.getAttachmentBySlotIndex(this.data.findSlotIndex(t),e)},getAttachmentBySlotIndex:function(t,e){if(this.skin){var i=this.skin.getAttachment(t,e);if(i)return i}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null},setAttachment:function(t,e){for(var i=this.slots,r=0,n=i.length;n>r;r++){var s=i[r];if(s.data.name==t){var o=null;if(e&&(o=this.getAttachmentBySlotIndex(r,e),!o))throw"Attachment not found: "+e+", for slot: "+t;return void s.setAttachment(o)}}throw"Slot not found: "+t},findIkConstraint:function(t){for(var e=this.ikConstraints,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return e[i];return null},update:function(t){this.time+=t}},n.EventData=function(t){this.name=t},n.EventData.prototype={intValue:0,floatValue:0,stringValue:null},n.Event=function(t){this.data=t},n.Event.prototype={intValue:0,floatValue:0,stringValue:null},n.AttachmentType={region:0,boundingbox:1,mesh:2,skinnedmesh:3},n.RegionAttachment=function(t){this.name=t,this.offset=[],this.offset.length=8,this.uvs=[],this.uvs.length=8},n.RegionAttachment.prototype={type:n.AttachmentType.region,x:0,y:0,rotation:0,scaleX:1,scaleY:1,width:0,height:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,setUVs:function(t,e,i,r,n){var s=this.uvs;n?(s[2]=t,s[3]=r,s[4]=t,s[5]=e,s[6]=i,s[7]=e,s[0]=i,s[1]=r):(s[0]=t,s[1]=r,s[2]=t,s[3]=e,s[4]=i,s[5]=e,s[6]=i,s[7]=r)},updateOffset:function(){var t=this.width/this.regionOriginalWidth*this.scaleX,e=this.height/this.regionOriginalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.regionOffsetX*t,r=-this.height/2*this.scaleY+this.regionOffsetY*e,s=i+this.regionWidth*t,o=r+this.regionHeight*e,a=this.rotation*n.degRad,h=Math.cos(a),l=Math.sin(a),u=i*h+this.x,c=i*l,d=r*h+this.y,p=r*l,f=s*h+this.x,g=s*l,m=o*h+this.y,v=o*l,x=this.offset;x[0]=u-p,x[1]=d+c,x[2]=u-v,x[3]=m+c,x[4]=f-v,x[5]=m+g,x[6]=f-p,x[7]=d+g},computeVertices:function(t,e,i,r){t+=i.worldX,e+=i.worldY;var n=i.m00,s=i.m01,o=i.m10,a=i.m11,h=this.offset;r[0]=h[0]*n+h[1]*s+t,r[1]=h[0]*o+h[1]*a+e,r[2]=h[2]*n+h[3]*s+t,r[3]=h[2]*o+h[3]*a+e,r[4]=h[4]*n+h[5]*s+t,r[5]=h[4]*o+h[5]*a+e,r[6]=h[6]*n+h[7]*s+t,r[7]=h[6]*o+h[7]*a+e}},n.MeshAttachment=function(t){this.name=t},n.MeshAttachment.prototype={type:n.AttachmentType.mesh,vertices:null,uvs:null,regionUVs:null,triangles:null,hullLength:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionU:0,regionV:0,regionU2:0,regionV2:0,regionRotate:!1,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,edges:null,width:0,height:0,updateUVs:function(){var t=this.regionU2-this.regionU,e=this.regionV2-this.regionV,i=this.regionUVs.length;if(this.uvs&&this.uvs.length==i||(this.uvs=new n.Float32Array(i)),this.regionRotate)for(var r=0;i>r;r+=2)this.uvs[r]=this.regionU+this.regionUVs[r+1]*t,this.uvs[r+1]=this.regionV+e-this.regionUVs[r]*e;else for(var r=0;i>r;r+=2)this.uvs[r]=this.regionU+this.regionUVs[r]*t,this.uvs[r+1]=this.regionV+this.regionUVs[r+1]*e},computeWorldVertices:function(t,e,i,r){var n=i.bone;t+=n.worldX,e+=n.worldY;var s=n.m00,o=n.m01,a=n.m10,h=n.m11,l=this.vertices,u=l.length;i.attachmentVertices.length==u&&(l=i.attachmentVertices);for(var c=0;u>c;c+=2){var d=l[c],p=l[c+1];r[c]=d*s+p*o+t,r[c+1]=d*a+p*h+e}}},n.SkinnedMeshAttachment=function(t){this.name=t},n.SkinnedMeshAttachment.prototype={type:n.AttachmentType.skinnedmesh,bones:null,weights:null,uvs:null,regionUVs:null,triangles:null,hullLength:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionU:0,regionV:0,regionU2:0,regionV2:0,regionRotate:!1,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,edges:null,width:0,height:0,updateUVs:function(){var t=this.regionU2-this.regionU,e=this.regionV2-this.regionV,i=this.regionUVs.length;if(this.uvs&&this.uvs.length==i||(this.uvs=new n.Float32Array(i)),this.regionRotate)for(var r=0;i>r;r+=2)this.uvs[r]=this.regionU+this.regionUVs[r+1]*t,this.uvs[r+1]=this.regionV+e-this.regionUVs[r]*e;else for(var r=0;i>r;r+=2)this.uvs[r]=this.regionU+this.regionUVs[r]*t,this.uvs[r+1]=this.regionV+this.regionUVs[r+1]*e},computeWorldVertices:function(t,e,i,r){var n,s,o,a,h,l,u,c=i.bone.skeleton.bones,d=this.weights,p=this.bones,f=0,g=0,m=0,v=0,x=p.length;if(i.attachmentVertices.length)for(var y=i.attachmentVertices;x>g;f+=2){for(s=0,o=0,n=p[g++]+g;n>g;g++,m+=3,v+=2)a=c[p[g]],h=d[m]+y[v],l=d[m+1]+y[v+1],u=d[m+2],s+=(h*a.m00+l*a.m01+a.worldX)*u,o+=(h*a.m10+l*a.m11+a.worldY)*u;r[f]=s+t,r[f+1]=o+e}else for(;x>g;f+=2){for(s=0,o=0,n=p[g++]+g;n>g;g++,m+=3)a=c[p[g]],h=d[m],l=d[m+1],u=d[m+2],s+=(h*a.m00+l*a.m01+a.worldX)*u,o+=(h*a.m10+l*a.m11+a.worldY)*u;r[f]=s+t,r[f+1]=o+e}}},n.BoundingBoxAttachment=function(t){this.name=t,this.vertices=[]},n.BoundingBoxAttachment.prototype={type:n.AttachmentType.boundingbox,computeWorldVertices:function(t,e,i,r){t+=i.worldX,e+=i.worldY;for(var n=i.m00,s=i.m01,o=i.m10,a=i.m11,h=this.vertices,l=0,u=h.length;u>l;l+=2){var c=h[l],d=h[l+1];r[l]=c*n+d*s+t,r[l+1]=c*o+d*a+e}}},n.AnimationStateData=function(t){this.skeletonData=t,this.animationToMixTime={}},n.AnimationStateData.prototype={defaultMix:0,setMixByName:function(t,e,i){var r=this.skeletonData.findAnimation(t);if(!r)throw"Animation not found: "+t;var n=this.skeletonData.findAnimation(e);if(!n)throw"Animation not found: "+e;this.setMix(r,n,i)},setMix:function(t,e,i){this.animationToMixTime[t.name+":"+e.name]=i},getMix:function(t,e){var i=t.name+":"+e.name;return this.animationToMixTime.hasOwnProperty(i)?this.animationToMixTime[i]:this.defaultMix}},n.TrackEntry=function(){},n.TrackEntry.prototype={next:null,previous:null,animation:null,loop:!1,delay:0,time:0,lastTime:-1,endTime:0,timeScale:1,mixTime:0,mixDuration:0,mix:1,onStart:null,onEnd:null,onComplete:null,onEvent:null},n.AnimationState=function(t){this.data=t,this.tracks=[],this.events=[]},n.AnimationState.prototype={onStart:null,onEnd:null,onComplete:null,onEvent:null,timeScale:1,update:function(t){t*=this.timeScale;for(var e=0;e<this.tracks.length;e++){var i=this.tracks[e];if(i){if(i.time+=t*i.timeScale,i.previous){var r=t*i.previous.timeScale;i.previous.time+=r,i.mixTime+=r}var n=i.next;n?(n.time=i.lastTime-n.delay,n.time>=0&&this.setCurrent(e,n)):!i.loop&&i.lastTime>=i.endTime&&this.clearTrack(e)}}},apply:function(t){for(var e=0;e<this.tracks.length;e++){var i=this.tracks[e];if(i){this.events.length=0;var r=i.time,n=i.lastTime,s=i.endTime,o=i.loop;!o&&r>s&&(r=s);var a=i.previous;if(a){var h=a.time;!a.loop&&h>a.endTime&&(h=a.endTime),a.animation.apply(t,h,h,a.loop,null);var l=i.mixTime/i.mixDuration*i.mix;l>=1&&(l=1,i.previous=null),i.animation.mix(t,i.lastTime,r,o,this.events,l)}else 1==i.mix?i.animation.apply(t,i.lastTime,r,o,this.events):i.animation.mix(t,i.lastTime,r,o,this.events,i.mix);for(var u=0,c=this.events.length;c>u;u++){var d=this.events[u];i.onEvent&&i.onEvent(e,d),this.onEvent&&this.onEvent(e,d)}if(o?n%s>r%s:s>n&&r>=s){var p=Math.floor(r/s);i.onComplete&&i.onComplete(e,p),this.onComplete&&this.onComplete(e,p)}i.lastTime=i.time}}},clearTracks:function(){for(var t=0,e=this.tracks.length;e>t;t++)this.clearTrack(t);this.tracks.length=0},clearTrack:function(t){if(!(t>=this.tracks.length)){var e=this.tracks[t];e&&(e.onEnd&&e.onEnd(t),this.onEnd&&this.onEnd(t),this.tracks[t]=null)}},_expandToIndex:function(t){if(t<this.tracks.length)return this.tracks[t];for(;t>=this.tracks.length;)this.tracks.push(null);return null},setCurrent:function(t,e){var i=this._expandToIndex(t);if(i){var r=i.previous;i.previous=null,i.onEnd&&i.onEnd(t),this.onEnd&&this.onEnd(t),e.mixDuration=this.data.getMix(i.animation,e.animation),e.mixDuration>0&&(e.mixTime=0,e.previous=r&&i.mixTime/i.mixDuration<.5?r:i)}this.tracks[t]=e,e.onStart&&e.onStart(t),this.onStart&&this.onStart(t)},setAnimationByName:function(t,e,i){var r=this.data.skeletonData.findAnimation(e);if(!r)throw"Animation not found: "+e;return this.setAnimation(t,r,i)},setAnimation:function(t,e,i){var r=new n.TrackEntry;return r.animation=e,r.loop=i,r.endTime=e.duration,this.setCurrent(t,r),r},addAnimationByName:function(t,e,i,r){var n=this.data.skeletonData.findAnimation(e);if(!n)throw"Animation not found: "+e;return this.addAnimation(t,n,i,r)},addAnimation:function(t,e,i,r){var s=new n.TrackEntry;s.animation=e,s.loop=i,s.endTime=e.duration;var o=this._expandToIndex(t);if(o){for(;o.next;)o=o.next;o.next=s}else this.tracks[t]=s;return 0>=r&&(o?r+=o.endTime-this.data.getMix(o.animation,e):r=0),s.delay=r,s},getCurrent:function(t){return t>=this.tracks.length?null:this.tracks[t]}},n.SkeletonJson=function(t){this.attachmentLoader=t},n.SkeletonJson.prototype={scale:1,readSkeletonData:function(t,e){var i=new n.SkeletonData;i.name=e;var r=t.skeleton;r&&(i.hash=r.hash,i.version=r.spine,i.width=r.width||0,i.height=r.height||0);for(var s=t.bones,o=0,a=s.length;a>o;o++){var h=s[o],l=null;if(h.parent&&(l=i.findBone(h.parent),!l))throw"Parent bone not found: "+h.parent;var u=new n.BoneData(h.name,l);u.length=(h.length||0)*this.scale,u.x=(h.x||0)*this.scale,u.y=(h.y||0)*this.scale,u.rotation=h.rotation||0,u.scaleX=h.hasOwnProperty("scaleX")?h.scaleX:1,u.scaleY=h.hasOwnProperty("scaleY")?h.scaleY:1,u.inheritScale=h.hasOwnProperty("inheritScale")?h.inheritScale:!0,u.inheritRotation=h.hasOwnProperty("inheritRotation")?h.inheritRotation:!0,i.bones.push(u)}var c=t.ik;if(c)for(var o=0,a=c.length;a>o;o++){for(var d=c[o],p=new n.IkConstraintData(d.name),s=d.bones,f=0,g=s.length;g>f;f++){var m=i.findBone(s[f]);if(!m)throw"IK bone not found: "+s[f];p.bones.push(m)}if(p.target=i.findBone(d.target),!p.target)throw"Target bone not found: "+d.target;p.bendDirection=!d.hasOwnProperty("bendPositive")||d.bendPositive?1:-1,p.mix=d.hasOwnProperty("mix")?d.mix:1,i.ikConstraints.push(p)}for(var v=t.slots,o=0,a=v.length;a>o;o++){var x=v[o],u=i.findBone(x.bone);if(!u)throw"Slot bone not found: "+x.bone;var y=new n.SlotData(x.name,u),b=x.color;b&&(y.r=this.toColor(b,0),y.g=this.toColor(b,1),y.b=this.toColor(b,2),y.a=this.toColor(b,3)),y.attachmentName=x.attachment,y.additiveBlending=x.additive&&"true"==x.additive,i.slots.push(y)}var T=t.skins;for(var w in T)if(T.hasOwnProperty(w)){var S=T[w],C=new n.Skin(w);for(var A in S)if(S.hasOwnProperty(A)){var _=i.findSlotIndex(A),E=S[A];for(var R in E)if(E.hasOwnProperty(R)){var M=this.readAttachment(C,R,E[R]);M&&C.addAttachment(_,R,M)}}i.skins.push(C),"default"==C.name&&(i.defaultSkin=C)}var L=t.events;for(var F in L)if(L.hasOwnProperty(F)){var B=L[F],P=new n.EventData(F);P.intValue=B["int"]||0,P.floatValue=B["float"]||0,P.stringValue=B.string||null,i.events.push(P)}var D=t.animations;for(var I in D)D.hasOwnProperty(I)&&this.readAnimation(I,D[I],i);return i},readAttachment:function(t,e,i){e=i.name||e;var r=n.AttachmentType[i.type||"region"],s=i.path||e,o=this.scale;if(r==n.AttachmentType.region){var a=this.attachmentLoader.newRegionAttachment(t,e,s);if(!a)return null;a.path=s,a.x=(i.x||0)*o,a.y=(i.y||0)*o,a.scaleX=i.hasOwnProperty("scaleX")?i.scaleX:1,a.scaleY=i.hasOwnProperty("scaleY")?i.scaleY:1,a.rotation=i.rotation||0,a.width=(i.width||0)*o,a.height=(i.height||0)*o;var h=i.color;return h&&(a.r=this.toColor(h,0),a.g=this.toColor(h,1),a.b=this.toColor(h,2),a.a=this.toColor(h,3)),a.updateOffset(),a}if(r==n.AttachmentType.mesh){var l=this.attachmentLoader.newMeshAttachment(t,e,s);return l?(l.path=s,l.vertices=this.getFloatArray(i,"vertices",o),l.triangles=this.getIntArray(i,"triangles"),l.regionUVs=this.getFloatArray(i,"uvs",1),l.updateUVs(),h=i.color,h&&(l.r=this.toColor(h,0),l.g=this.toColor(h,1),l.b=this.toColor(h,2),l.a=this.toColor(h,3)),l.hullLength=2*(i.hull||0),i.edges&&(l.edges=this.getIntArray(i,"edges")),l.width=(i.width||0)*o,l.height=(i.height||0)*o,l):null}if(r==n.AttachmentType.skinnedmesh){var l=this.attachmentLoader.newSkinnedMeshAttachment(t,e,s);if(!l)return null;l.path=s;for(var u=this.getFloatArray(i,"uvs",1),c=this.getFloatArray(i,"vertices",1),d=[],p=[],f=0,g=c.length;g>f;){var m=0|c[f++];p[p.length]=m;for(var v=f+4*m;v>f;)p[p.length]=c[f],d[d.length]=c[f+1]*o,d[d.length]=c[f+2]*o,d[d.length]=c[f+3],f+=4}return l.bones=p,l.weights=d,l.triangles=this.getIntArray(i,"triangles"),l.regionUVs=u,l.updateUVs(),h=i.color,h&&(l.r=this.toColor(h,0),l.g=this.toColor(h,1),l.b=this.toColor(h,2),l.a=this.toColor(h,3)),l.hullLength=2*(i.hull||0),i.edges&&(l.edges=this.getIntArray(i,"edges")),l.width=(i.width||0)*o,l.height=(i.height||0)*o,l
}if(r==n.AttachmentType.boundingbox){for(var x=this.attachmentLoader.newBoundingBoxAttachment(t,e),c=i.vertices,f=0,g=c.length;g>f;f++)x.vertices.push(c[f]*o);return x}throw"Unknown attachment type: "+r},readAnimation:function(t,e,i){var r=[],s=0,o=e.slots;for(var a in o)if(o.hasOwnProperty(a)){var h=o[a],l=i.findSlotIndex(a);for(var u in h)if(h.hasOwnProperty(u)){var c=h[u];if("color"==u){var d=new n.ColorTimeline(c.length);d.slotIndex=l;for(var p=0,f=0,g=c.length;g>f;f++){var m=c[f],v=m.color,x=this.toColor(v,0),y=this.toColor(v,1),b=this.toColor(v,2),T=this.toColor(v,3);d.setFrame(p,m.time,x,y,b,T),this.readCurve(d,p,m),p++}r.push(d),s=Math.max(s,d.frames[5*d.getFrameCount()-5])}else{if("attachment"!=u)throw"Invalid timeline type for a slot: "+u+" ("+a+")";var d=new n.AttachmentTimeline(c.length);d.slotIndex=l;for(var p=0,f=0,g=c.length;g>f;f++){var m=c[f];d.setFrame(p++,m.time,m.name)}r.push(d),s=Math.max(s,d.frames[d.getFrameCount()-1])}}}var w=e.bones;for(var S in w)if(w.hasOwnProperty(S)){var C=i.findBoneIndex(S);if(-1==C)throw"Bone not found: "+S;var A=w[S];for(var u in A)if(A.hasOwnProperty(u)){var c=A[u];if("rotate"==u){var d=new n.RotateTimeline(c.length);d.boneIndex=C;for(var p=0,f=0,g=c.length;g>f;f++){var m=c[f];d.setFrame(p,m.time,m.angle),this.readCurve(d,p,m),p++}r.push(d),s=Math.max(s,d.frames[2*d.getFrameCount()-2])}else if("translate"==u||"scale"==u){var d,_=1;"scale"==u?d=new n.ScaleTimeline(c.length):(d=new n.TranslateTimeline(c.length),_=this.scale),d.boneIndex=C;for(var p=0,f=0,g=c.length;g>f;f++){var m=c[f],E=(m.x||0)*_,R=(m.y||0)*_;d.setFrame(p,m.time,E,R),this.readCurve(d,p,m),p++}r.push(d),s=Math.max(s,d.frames[3*d.getFrameCount()-3])}else{if("flipX"!=u&&"flipY"!=u)throw"Invalid timeline type for a bone: "+u+" ("+S+")";var E="flipX"==u,d=E?new n.FlipXTimeline(c.length):new n.FlipYTimeline(c.length);d.boneIndex=C;for(var M=E?"x":"y",p=0,f=0,g=c.length;g>f;f++){var m=c[f];d.setFrame(p,m.time,m[M]||!1),p++}r.push(d),s=Math.max(s,d.frames[2*d.getFrameCount()-2])}}}var L=e.ik;for(var F in L)if(L.hasOwnProperty(F)){var B=i.findIkConstraint(F),c=L[F],d=new n.IkConstraintTimeline(c.length);d.ikConstraintIndex=i.ikConstraints.indexOf(B);for(var p=0,f=0,g=c.length;g>f;f++){var m=c[f],P=m.hasOwnProperty("mix")?m.mix:1,D=!m.hasOwnProperty("bendPositive")||m.bendPositive?1:-1;d.setFrame(p,m.time,P,D),this.readCurve(d,p,m),p++}r.push(d),s=Math.max(s,d.frames[3*d.frameCount-3])}var I=e.ffd;for(var O in I){var G=i.findSkin(O),h=I[O];for(a in h){var l=i.findSlotIndex(a),U=h[a];for(var k in U){var c=U[k],d=new n.FfdTimeline(c.length),N=G.getAttachment(l,k);if(!N)throw"FFD attachment not found: "+k;d.slotIndex=l,d.attachment=N;var j,W=N.type==n.AttachmentType.mesh;j=W?N.vertices.length:N.weights.length/3*2;for(var p=0,f=0,g=c.length;g>f;f++){var Y,m=c[f];if(m.vertices){var V=m.vertices,Y=[];Y.length=j;var X=m.offset||0,H=V.length;if(1==this.scale)for(var z=0;H>z;z++)Y[z+X]=V[z];else for(var z=0;H>z;z++)Y[z+X]=V[z]*this.scale;if(W)for(var q=N.vertices,z=0,H=Y.length;H>z;z++)Y[z]+=q[z]}else W?Y=N.vertices:(Y=[],Y.length=j);d.setFrame(p,m.time,Y),this.readCurve(d,p,m),p++}r[r.length]=d,s=Math.max(s,d.frames[d.frameCount-1])}}}var K=e.drawOrder;if(K||(K=e.draworder),K){for(var d=new n.DrawOrderTimeline(K.length),J=i.slots.length,p=0,f=0,g=K.length;g>f;f++){var Q=K[f],$=null;if(Q.offsets){$=[],$.length=J;for(var z=J-1;z>=0;z--)$[z]=-1;var Z=Q.offsets,te=[];te.length=J-Z.length;for(var ee=0,ie=0,z=0,H=Z.length;H>z;z++){var re=Z[z],l=i.findSlotIndex(re.slot);if(-1==l)throw"Slot not found: "+re.slot;for(;ee!=l;)te[ie++]=ee++;$[ee+re.offset]=ee++}for(;J>ee;)te[ie++]=ee++;for(var z=J-1;z>=0;z--)-1==$[z]&&($[z]=te[--ie])}d.setFrame(p++,Q.time,$)}r.push(d),s=Math.max(s,d.frames[d.getFrameCount()-1])}var ne=e.events;if(ne){for(var d=new n.EventTimeline(ne.length),p=0,f=0,g=ne.length;g>f;f++){var se=ne[f],oe=i.findEvent(se.name);if(!oe)throw"Event not found: "+se.name;var ae=new n.Event(oe);ae.intValue=se.hasOwnProperty("int")?se["int"]:oe.intValue,ae.floatValue=se.hasOwnProperty("float")?se["float"]:oe.floatValue,ae.stringValue=se.hasOwnProperty("string")?se.string:oe.stringValue,d.setFrame(p++,se.time,ae)}r.push(d),s=Math.max(s,d.frames[d.getFrameCount()-1])}i.animations.push(new n.Animation(t,r,s))},readCurve:function(t,e,i){var r=i.curve;r?"stepped"==r?t.curves.setStepped(e):r instanceof Array&&t.curves.setCurve(e,r[0],r[1],r[2],r[3]):t.curves.setLinear(e)},toColor:function(t,e){if(8!=t.length)throw"Color hexidecimal length must be 8, recieved: "+t;return parseInt(t.substring(2*e,2*e+2),16)/255},getFloatArray:function(t,e,i){var r=t[e],s=new n.Float32Array(r.length),o=0,a=r.length;if(1==i)for(;a>o;o++)s[o]=r[o];else for(;a>o;o++)s[o]=r[o]*i;return s},getIntArray:function(t,e){for(var i=t[e],r=new n.Uint16Array(i.length),s=0,o=i.length;o>s;s++)r[s]=0|i[s];return r}},n.Atlas=function(t,e){this.textureLoader=e,this.pages=[],this.regions=[];var i=new n.AtlasReader(t),r=[];r.length=4;for(var s=null;;){var o=i.readLine();if(null===o)break;if(o=i.trim(o),o.length)if(s){var a=new n.AtlasRegion;a.name=o,a.page=s,a.rotate="true"==i.readValue(),i.readTuple(r);var h=parseInt(r[0]),l=parseInt(r[1]);i.readTuple(r);var u=parseInt(r[0]),c=parseInt(r[1]);a.u=h/s.width,a.v=l/s.height,a.rotate?(a.u2=(h+c)/s.width,a.v2=(l+u)/s.height):(a.u2=(h+u)/s.width,a.v2=(l+c)/s.height),a.x=h,a.y=l,a.width=Math.abs(u),a.height=Math.abs(c),4==i.readTuple(r)&&(a.splits=[parseInt(r[0]),parseInt(r[1]),parseInt(r[2]),parseInt(r[3])],4==i.readTuple(r)&&(a.pads=[parseInt(r[0]),parseInt(r[1]),parseInt(r[2]),parseInt(r[3])],i.readTuple(r))),a.originalWidth=parseInt(r[0]),a.originalHeight=parseInt(r[1]),i.readTuple(r),a.offsetX=parseInt(r[0]),a.offsetY=parseInt(r[1]),a.index=parseInt(i.readValue()),this.regions.push(a)}else{s=new n.AtlasPage,s.name=o,2==i.readTuple(r)&&(s.width=parseInt(r[0]),s.height=parseInt(r[1]),i.readTuple(r)),s.format=n.Atlas.Format[r[0]],i.readTuple(r),s.minFilter=n.Atlas.TextureFilter[r[0]],s.magFilter=n.Atlas.TextureFilter[r[1]];var d=i.readValue();s.uWrap=n.Atlas.TextureWrap.clampToEdge,s.vWrap=n.Atlas.TextureWrap.clampToEdge,"x"==d?s.uWrap=n.Atlas.TextureWrap.repeat:"y"==d?s.vWrap=n.Atlas.TextureWrap.repeat:"xy"==d&&(s.uWrap=s.vWrap=n.Atlas.TextureWrap.repeat),e.load(s,o,this),this.pages.push(s)}else s=null}},n.Atlas.prototype={findRegion:function(t){for(var e=this.regions,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},dispose:function(){for(var t=this.pages,e=0,i=t.length;i>e;e++)this.textureLoader.unload(t[e].rendererObject)},updateUVs:function(t){for(var e=this.regions,i=0,r=e.length;r>i;i++){var n=e[i];n.page==t&&(n.u=n.x/t.width,n.v=n.y/t.height,n.rotate?(n.u2=(n.x+n.height)/t.width,n.v2=(n.y+n.width)/t.height):(n.u2=(n.x+n.width)/t.width,n.v2=(n.y+n.height)/t.height))}}},n.Atlas.Format={alpha:0,intensity:1,luminanceAlpha:2,rgb565:3,rgba4444:4,rgb888:5,rgba8888:6},n.Atlas.TextureFilter={nearest:0,linear:1,mipMap:2,mipMapNearestNearest:3,mipMapLinearNearest:4,mipMapNearestLinear:5,mipMapLinearLinear:6},n.Atlas.TextureWrap={mirroredRepeat:0,clampToEdge:1,repeat:2},n.AtlasPage=function(){},n.AtlasPage.prototype={name:null,format:null,minFilter:null,magFilter:null,uWrap:null,vWrap:null,rendererObject:null,width:0,height:0},n.AtlasRegion=function(){},n.AtlasRegion.prototype={page:null,name:null,x:0,y:0,width:0,height:0,u:0,v:0,u2:0,v2:0,offsetX:0,offsetY:0,originalWidth:0,originalHeight:0,index:0,rotate:!1,splits:null,pads:null},n.AtlasReader=function(t){this.lines=t.split(/\r\n|\r|\n/)},n.AtlasReader.prototype={index:0,trim:function(t){return t.replace(/^\s+|\s+$/g,"")},readLine:function(){return this.index>=this.lines.length?null:this.lines[this.index++]},readValue:function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw"Invalid line: "+t;return this.trim(t.substring(e+1))},readTuple:function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw"Invalid line: "+e;for(var r=0,n=i+1;3>r;r++){var s=e.indexOf(",",n);if(-1==s)break;t[r]=this.trim(e.substr(n,s-n)),n=s+1}return t[r]=this.trim(e.substring(n)),r+1}},n.AtlasAttachmentLoader=function(t){this.atlas=t},n.AtlasAttachmentLoader.prototype={newRegionAttachment:function(t,e,i){var r=this.atlas.findRegion(i);if(!r)throw"Region not found in atlas: "+i+" (region attachment: "+e+")";var s=new n.RegionAttachment(e);return s.rendererObject=r,s.setUVs(r.u,r.v,r.u2,r.v2,r.rotate),s.regionOffsetX=r.offsetX,s.regionOffsetY=r.offsetY,s.regionWidth=r.width,s.regionHeight=r.height,s.regionOriginalWidth=r.originalWidth,s.regionOriginalHeight=r.originalHeight,s},newMeshAttachment:function(t,e,i){var r=this.atlas.findRegion(i);if(!r)throw"Region not found in atlas: "+i+" (mesh attachment: "+e+")";var s=new n.MeshAttachment(e);return s.rendererObject=r,s.regionU=r.u,s.regionV=r.v,s.regionU2=r.u2,s.regionV2=r.v2,s.regionRotate=r.rotate,s.regionOffsetX=r.offsetX,s.regionOffsetY=r.offsetY,s.regionWidth=r.width,s.regionHeight=r.height,s.regionOriginalWidth=r.originalWidth,s.regionOriginalHeight=r.originalHeight,s},newSkinnedMeshAttachment:function(t,e,i){var r=this.atlas.findRegion(i);if(!r)throw"Region not found in atlas: "+i+" (skinned mesh attachment: "+e+")";var s=new n.SkinnedMeshAttachment(e);return s.rendererObject=r,s.regionU=r.u,s.regionV=r.v,s.regionU2=r.u2,s.regionV2=r.v2,s.regionRotate=r.rotate,s.regionOffsetX=r.offsetX,s.regionOffsetY=r.offsetY,s.regionWidth=r.width,s.regionHeight=r.height,s.regionOriginalWidth=r.originalWidth,s.regionOriginalHeight=r.originalHeight,s},newBoundingBoxAttachment:function(t,e){return new n.BoundingBoxAttachment(e)}},n.SkeletonBounds=function(){this.polygonPool=[],this.polygons=[],this.boundingBoxes=[]},n.SkeletonBounds.prototype={minX:0,minY:0,maxX:0,maxY:0,update:function(t,e){var i=t.slots,r=i.length,s=t.x,o=t.y,a=this.boundingBoxes,h=this.polygonPool,l=this.polygons;a.length=0;for(var u=0,c=l.length;c>u;u++)h.push(l[u]);l.length=0;for(var u=0;r>u;u++){var d=i[u],p=d.attachment;if(p.type==n.AttachmentType.boundingbox){a.push(p);var f,g=h.length;g>0?(f=h[g-1],h.splice(g-1,1)):f=[],l.push(f),f.length=p.vertices.length,p.computeWorldVertices(s,o,d.bone,f)}}e&&this.aabbCompute()},aabbCompute:function(){for(var t=this.polygons,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=Number.MIN_VALUE,n=Number.MIN_VALUE,s=0,o=t.length;o>s;s++)for(var a=t[s],h=0,l=a.length;l>h;h+=2){var u=a[h],c=a[h+1];e=Math.min(e,u),i=Math.min(i,c),r=Math.max(r,u),n=Math.max(n,c)}this.minX=e,this.minY=i,this.maxX=r,this.maxY=n},aabbContainsPoint:function(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY},aabbIntersectsSegment:function(t,e,i,r){var n=this.minX,s=this.minY,o=this.maxX,a=this.maxY;if(n>=t&&n>=i||s>=e&&s>=r||t>=o&&i>=o||e>=a&&r>=a)return!1;var h=(r-e)/(i-t),l=h*(n-t)+e;if(l>s&&a>l)return!0;if(l=h*(o-t)+e,l>s&&a>l)return!0;var u=(s-e)/h+t;return u>n&&o>u?!0:(u=(a-e)/h+t,u>n&&o>u?!0:!1)},aabbIntersectsSkeleton:function(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY},containsPoint:function(t,e){for(var i=this.polygons,r=0,n=i.length;n>r;r++)if(this.polygonContainsPoint(i[r],t,e))return this.boundingBoxes[r];return null},intersectsSegment:function(t,e,i,r){for(var n=this.polygons,s=0,o=n.length;o>s;s++)if(n[s].intersectsSegment(t,e,i,r))return this.boundingBoxes[s];return null},polygonContainsPoint:function(t,e,i){for(var r=t.length,n=r-2,s=!1,o=0;r>o;o+=2){var a=t[o+1],h=t[n+1];if(i>a&&h>=i||i>h&&a>=i){var l=t[o];l+(i-a)/(h-a)*(t[n]-l)<e&&(s=!s)}n=o}return s},polygonIntersectsSegment:function(t,e,i,r,n){for(var s=t.length,o=e-r,a=i-n,h=e*n-i*r,l=t[s-2],u=t[s-1],c=0;s>c;c+=2){var d=t[c],p=t[c+1],f=l*p-u*d,g=l-d,m=u-p,v=o*m-a*g,x=(h*g-o*f)/v;if((x>=l&&d>=x||x>=d&&l>=x)&&(x>=e&&r>=x||x>=r&&e>=x)){var y=(h*m-a*f)/v;if((y>=u&&p>=y||y>=p&&u>=y)&&(y>=i&&n>=y||y>=n&&i>=y))return!0}l=d,u=p}return!1},getPolygon:function(t){var e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]},getWidth:function(){return this.maxX-this.minX},getHeight:function(){return this.maxY-this.minY}},n.Bone.yDown=!0,r.AnimCache={},r.SpineTextureLoader=function(t,e){r.EventTarget.call(this),this.basePath=t,this.crossorigin=e,this.loadingCount=0},r.SpineTextureLoader.prototype=r.SpineTextureLoader,r.SpineTextureLoader.prototype.load=function(t,e){if(t.rendererObject=r.BaseTexture.fromImage(this.basePath+"/"+e,this.crossorigin),!t.rendererObject.hasLoaded){var i=this;++i.loadingCount,t.rendererObject.addEventListener("loaded",function(){--i.loadingCount,i.dispatchEvent({type:"loadedBaseTexture",content:i})})}},r.SpineTextureLoader.prototype.unload=function(t){t.destroy(!0)},r.Spine=function(t){if(r.DisplayObjectContainer.call(this),this.spineData=r.AnimCache[t],!this.spineData)throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+t);this.skeleton=new n.Skeleton(this.spineData),this.skeleton.updateWorldTransform(),this.stateData=new n.AnimationStateData(this.spineData),this.state=new n.AnimationState(this.stateData),this.slotContainers=[];for(var e=0,i=this.skeleton.drawOrder.length;i>e;e++){var s=this.skeleton.drawOrder[e],o=s.attachment,a=new r.DisplayObjectContainer;if(this.slotContainers.push(a),this.addChild(a),o instanceof n.RegionAttachment){var h=o.rendererObject.name,l=this.createSprite(s,o);s.currentSprite=l,s.currentSpriteName=h,a.addChild(l)}else{if(!(o instanceof n.MeshAttachment))continue;var u=this.createMesh(s,o);s.currentMesh=u,s.currentMeshName=o.name,a.addChild(u)}}this.autoUpdate=!0},r.Spine.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Spine.prototype.constructor=r.Spine,Object.defineProperty(r.Spine.prototype,"autoUpdate",{get:function(){return this.updateTransform===r.Spine.prototype.autoUpdateTransform},set:function(t){this.updateTransform=t?r.Spine.prototype.autoUpdateTransform:r.DisplayObjectContainer.prototype.updateTransform}}),r.Spine.prototype.update=function(t){this.state.update(t),this.state.apply(this.skeleton),this.skeleton.updateWorldTransform();for(var e=this.skeleton.drawOrder,i=0,s=e.length;s>i;i++){var o=e[i],a=o.attachment,h=this.slotContainers[i];if(a){var l=a.type;if(l===n.AttachmentType.region){if(a.rendererObject&&(!o.currentSpriteName||o.currentSpriteName!==a.name)){var u=a.rendererObject.name;if(void 0!==o.currentSprite&&(o.currentSprite.visible=!1),o.sprites=o.sprites||{},void 0!==o.sprites[u])o.sprites[u].visible=!0;else{var c=this.createSprite(o,a);h.addChild(c)}o.currentSprite=o.sprites[u],o.currentSpriteName=u}var d=o.bone;h.position.x=d.worldX+a.x*d.m00+a.y*d.m01,h.position.y=d.worldY+a.x*d.m10+a.y*d.m11,h.scale.x=d.worldScaleX,h.scale.y=d.worldScaleY,h.rotation=-(o.bone.worldRotation*n.degRad),o.currentSprite.tint=r.rgb2hex([o.r,o.g,o.b])}else{if(l!==n.AttachmentType.skinnedmesh){h.visible=!1;continue}if(!o.currentMeshName||o.currentMeshName!==a.name){var p=a.name;if(void 0!==o.currentMesh&&(o.currentMesh.visible=!1),o.meshes=o.meshes||{},void 0!==o.meshes[p])o.meshes[p].visible=!0;else{var f=this.createMesh(o,a);h.addChild(f)}o.currentMesh=o.meshes[p],o.currentMeshName=p}a.computeWorldVertices(o.bone.skeleton.x,o.bone.skeleton.y,o,o.currentMesh.vertices)}h.visible=!0,h.alpha=o.a}else h.visible=!1}},r.Spine.prototype.autoUpdateTransform=function(){this.lastTime=this.lastTime||Date.now();var t=.001*(Date.now()-this.lastTime);this.lastTime=Date.now(),this.update(t),r.DisplayObjectContainer.prototype.updateTransform.call(this)},r.Spine.prototype.createSprite=function(t,e){var i=e.rendererObject,s=i.page.rendererObject,o=new r.Rectangle(i.x,i.y,i.rotate?i.height:i.width,i.rotate?i.width:i.height),a=new r.Texture(s,o),h=new r.Sprite(a),l=i.rotate?.5*Math.PI:0;return h.scale.set(i.width/i.originalWidth,i.height/i.originalHeight),h.rotation=l-e.rotation*n.degRad,h.anchor.x=h.anchor.y=.5,t.sprites=t.sprites||{},t.sprites[i.name]=h,h},r.Spine.prototype.createMesh=function(t,e){var i=e.rendererObject,n=i.page.rendererObject,s=new r.Texture(n),o=new r.Strip(s);return o.drawMode=r.Strip.DrawModes.TRIANGLES,o.canvasPadding=1.5,o.vertices=new r.Float32Array(e.uvs.length),o.uvs=e.uvs,o.indices=e.triangles,t.meshes=t.meshes||{},t.meshes[e.name]=o,o},r.BaseTextureCache={},r.BaseTextureCacheIdGenerator=0,r.BaseTexture=function(t,e){if(this.resolution=1,this.width=100,this.height=100,this.scaleMode=e||r.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=t,this._UID=r._UID++,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this._dirty=[!0,!0,!0,!0],t){if((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height)this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty();else{var i=this;this.source.onload=function(){i.hasLoaded=!0,i.width=i.source.naturalWidth||i.source.width,i.height=i.source.naturalHeight||i.source.height,i.dirty(),i.dispatchEvent({type:"loaded",content:i})},this.source.onerror=function(){i.dispatchEvent({type:"error",content:i})}}this.imageUrl=null,this._powerOf2=!1}},r.BaseTexture.prototype.constructor=r.BaseTexture,r.EventTarget.mixin(r.BaseTexture.prototype),r.BaseTexture.prototype.destroy=function(){this.imageUrl?(delete r.BaseTextureCache[this.imageUrl],delete r.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src="")):this.source&&this.source._pixiId&&delete r.BaseTextureCache[this.source._pixiId],this.source=null,this.unloadFromGPU()},r.BaseTexture.prototype.updateSourceImage=function(t){this.hasLoaded=!1,this.source.src=null,this.source.src=t},r.BaseTexture.prototype.dirty=function(){for(var t=0;t<this._glTextures.length;t++)this._dirty[t]=!0},r.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var t=this._glTextures.length-1;t>=0;t--){var e=this._glTextures[t],i=r.glContexts[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()},r.BaseTexture.fromImage=function(t,e,i){var n=r.BaseTextureCache[t];if(void 0===e&&-1===t.indexOf("data:")&&(e=!0),!n){var s=new Image;e&&(s.crossOrigin=""),s.src=t,n=new r.BaseTexture(s,i),n.imageUrl=t,r.BaseTextureCache[t]=n,-1!==t.indexOf(r.RETINA_PREFIX+".")&&(n.resolution=2)}return n},r.BaseTexture.fromCanvas=function(t,e){t._pixiId||(t._pixiId="canvas_"+r.TextureCacheIdGenerator++);var i=r.BaseTextureCache[t._pixiId];return i||(i=new r.BaseTexture(t,e),r.BaseTextureCache[t._pixiId]=i),i},r.TextureCache={},r.FrameCache={},r.TextureCacheIdGenerator=0,r.Texture=function(t,e,i,n){this.noFrame=!1,e||(this.noFrame=!0,e=new r.Rectangle(0,0,1,1)),t instanceof r.Texture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=n,this.valid=!1,this.requiresUpdate=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new r.Rectangle(0,0,1,1),t.hasLoaded?(this.noFrame&&(e=new r.Rectangle(0,0,t.width,t.height)),this.setFrame(e)):t.addEventListener("loaded",this.onBaseTextureLoaded.bind(this))},r.Texture.prototype.constructor=r.Texture,r.EventTarget.mixin(r.Texture.prototype),r.Texture.prototype.onBaseTextureLoaded=function(){var t=this.baseTexture;t.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new r.Rectangle(0,0,t.width,t.height)),this.setFrame(this.frame),this.dispatchEvent({type:"update",content:this})},r.Texture.prototype.destroy=function(t){t&&this.baseTexture.destroy(),this.valid=!1},r.Texture.prototype.setFrame=function(t){if(this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,!this.trim&&(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()},r.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new r.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i},r.Texture.fromImage=function(t,e,i){var n=r.TextureCache[t];return n||(n=new r.Texture(r.BaseTexture.fromImage(t,e,i)),r.TextureCache[t]=n),n},r.Texture.fromFrame=function(t){var e=r.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache ');return e},r.Texture.fromCanvas=function(t,e){var i=r.BaseTexture.fromCanvas(t,e);return new r.Texture(i)},r.Texture.addTextureToCache=function(t,e){r.TextureCache[e]=t},r.Texture.removeTextureFromCache=function(t){var e=r.TextureCache[t];return delete r.TextureCache[t],delete r.BaseTextureCache[t],e},r.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},r.Texture.emptyTexture=new r.Texture(new r.BaseTexture),r.RenderTexture=function(t,e,i,n,s){if(this.width=t||100,this.height=e||100,this.resolution=s||1,this.frame=new r.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new r.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new r.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=n||r.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,r.Texture.call(this,this.baseTexture,new r.Rectangle(0,0,this.width,this.height)),this.renderer=i||r.defaultRenderer,this.renderer.type===r.WEBGL_RENDERER){var o=this.renderer.gl;this.baseTexture._dirty[o.id]=!1,this.textureBuffer=new r.FilterTexture(o,this.width*this.resolution,this.height*this.resolution,this.baseTexture.scaleMode),this.baseTexture._glTextures[o.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new r.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new r.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this._updateUvs()},r.RenderTexture.prototype=Object.create(r.Texture.prototype),r.RenderTexture.prototype.constructor=r.RenderTexture,r.RenderTexture.prototype.resize=function(t,e,i){(t!==this.width||e!==this.height)&&(this.valid=t>0&&e>0,this.width=this.frame.width=this.crop.width=t,this.height=this.frame.height=this.crop.height=e,i&&(this.baseTexture.width=this.width,this.baseTexture.height=this.height),this.renderer.type===r.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width*this.resolution,this.height*this.resolution))},r.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===r.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},r.RenderTexture.prototype.renderWebGL=function(t,e,i){if(this.valid){var r=t.worldTransform;r.identity(),r.translate(0,2*this.projection.y),e&&r.append(e),r.scale(1,-1),t.worldAlpha=1;for(var n=t.children,s=0,o=n.length;o>s;s++)n[s].updateTransform();var a=this.renderer.gl;a.viewport(0,0,this.width*this.resolution,this.height*this.resolution),a.bindFramebuffer(a.FRAMEBUFFER,this.textureBuffer.frameBuffer),i&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(t,this.projection,this.textureBuffer.frameBuffer),this.renderer.spriteBatch.dirty=!0}},r.RenderTexture.prototype.renderCanvas=function(t,e,i){if(this.valid){var r=t.worldTransform;r.identity(),e&&r.append(e),t.worldAlpha=1;for(var n=t.children,s=0,o=n.length;o>s;s++)n[s].updateTransform();i&&this.textureBuffer.clear();var a=this.textureBuffer.context,h=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(t,a),this.renderer.resolution=h}},r.RenderTexture.prototype.getImage=function(){var t=new Image;return t.src=this.getBase64(),t},r.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},r.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===r.WEBGL_RENDERER){var t=this.renderer.gl,e=this.textureBuffer.width,i=this.textureBuffer.height,n=new Uint8Array(4*e*i);t.bindFramebuffer(t.FRAMEBUFFER,this.textureBuffer.frameBuffer),t.readPixels(0,0,e,i,t.RGBA,t.UNSIGNED_BYTE,n),t.bindFramebuffer(t.FRAMEBUFFER,null);var s=new r.CanvasBuffer(e,i),o=s.context.getImageData(0,0,e,i);return o.data.set(n),s.context.putImageData(o,0,0),s.canvas}return this.textureBuffer.canvas},r.RenderTexture.tempMatrix=new r.Matrix,r.VideoTexture=function(t,e){if(!t)throw new Error("No video source element specified.");(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),r.BaseTexture.call(this,t,e),this.autoUpdate=!1,this.updateBound=this._onUpdate.bind(this),t.complete||(this._onCanPlay=this.onCanPlay.bind(this),t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("play",this.onPlayStart.bind(this)),t.addEventListener("pause",this.onPlayStop.bind(this)))},r.VideoTexture.prototype=Object.create(r.BaseTexture.prototype),r.VideoTexture.constructor=r.VideoTexture,r.VideoTexture.prototype._onUpdate=function(){this.autoUpdate&&(window.requestAnimationFrame(this.updateBound),this.dirty())},r.VideoTexture.prototype.onPlayStart=function(){this.autoUpdate||(window.requestAnimationFrame(this.updateBound),this.autoUpdate=!0)},r.VideoTexture.prototype.onPlayStop=function(){this.autoUpdate=!1},r.VideoTexture.prototype.onCanPlay=function(){"canplaythrough"===event.type&&(this.hasLoaded=!0,this.source&&(this.source.removeEventListener("canplay",this._onCanPlay),this.source.removeEventListener("canplaythrough",this._onCanPlay),this.width=this.source.videoWidth,this.height=this.source.videoHeight,this.__loaded||(this.__loaded=!0,this.dispatchEvent({type:"loaded",content:this}))))},r.VideoTexture.prototype.destroy=function(){this.source&&this.source._pixiId&&(r.BaseTextureCache[this.source._pixiId]=null,delete r.BaseTextureCache[this.source._pixiId],this.source._pixiId=null,delete this.source._pixiId),r.BaseTexture.prototype.destroy.call(this)},r.VideoTexture.baseTextureFromVideo=function(t,e){t._pixiId||(t._pixiId="video_"+r.TextureCacheIdGenerator++);var i=r.BaseTextureCache[t._pixiId];return i||(i=new r.VideoTexture(t,e),r.BaseTextureCache[t._pixiId]=i),i},r.VideoTexture.textureFromVideo=function(t,e){var i=r.VideoTexture.baseTextureFromVideo(t,e);return new r.Texture(i)},r.VideoTexture.fromUrl=function(t,e){var i=document.createElement("video");return i.src=t,i.autoPlay=!0,i.play(),r.VideoTexture.textureFromVideo(i,e)},r.AssetLoader=function(t,e){this.assetURLs=t,this.crossorigin=e,this.loadersByType={jpg:r.ImageLoader,jpeg:r.ImageLoader,png:r.ImageLoader,gif:r.ImageLoader,webp:r.ImageLoader,json:r.JsonLoader,atlas:r.AtlasLoader,anim:r.SpineLoader,xml:r.BitmapFontLoader,fnt:r.BitmapFontLoader}},r.EventTarget.mixin(r.AssetLoader.prototype),r.AssetLoader.prototype.constructor=r.AssetLoader,r.AssetLoader.prototype._getDataType=function(t){var e="data:",i=t.slice(0,e.length).toLowerCase();if(i===e){var r=t.slice(e.length),n=r.indexOf(",");if(-1===n)return null;var s=r.slice(0,n).split(";")[0];return s&&"text/plain"!==s.toLowerCase()?s.split("/").pop().toLowerCase():"txt"}return null},r.AssetLoader.prototype.load=function(){function t(t){e.onAssetLoaded(t.data.content)}var e=this;this.loadCount=this.assetURLs.length;for(var i=0;i<this.assetURLs.length;i++){var r=this.assetURLs[i],n=this._getDataType(r);n||(n=r.split("?").shift().split(".").pop().toLowerCase());var s=this.loadersByType[n];if(!s)throw new Error(n+" is an unsupported file type");var o=new s(r,this.crossorigin);o.on("loaded",t),o.load()}},r.AssetLoader.prototype.onAssetLoaded=function(t){this.loadCount--,this.emit("onProgress",{content:this,loader:t}),this.onProgress&&this.onProgress(t),this.loadCount||(this.emit("onComplete",{content:this}),this.onComplete&&this.onComplete())},r.JsonLoader=function(t,e){this.url=t,this.crossorigin=e,this.baseUrl=t.replace(/[^\/]*$/,""),this.loaded=!1},r.JsonLoader.prototype.constructor=r.JsonLoader,r.EventTarget.mixin(r.JsonLoader.prototype),r.JsonLoader.prototype.load=function(){window.XDomainRequest&&this.crossorigin?(this.ajaxRequest=new window.XDomainRequest,this.ajaxRequest.timeout=3e3,this.ajaxRequest.onerror=this.onError.bind(this),this.ajaxRequest.ontimeout=this.onError.bind(this),this.ajaxRequest.onprogress=function(){},this.ajaxRequest.onload=this.onJSONLoaded.bind(this)):(this.ajaxRequest=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP"),this.ajaxRequest.onreadystatechange=this.onReadyStateChanged.bind(this)),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.send()},r.JsonLoader.prototype.onReadyStateChanged=function(){4!==this.ajaxRequest.readyState||200!==this.ajaxRequest.status&&-1!==window.location.href.indexOf("http")||this.onJSONLoaded()},r.JsonLoader.prototype.onJSONLoaded=function(){if(!this.ajaxRequest.responseText)return void this.onError();if(this.json=JSON.parse(this.ajaxRequest.responseText),this.json.frames&&this.json.meta&&this.json.meta.image){var t=this.baseUrl+this.json.meta.image,e=new r.ImageLoader(t,this.crossorigin),i=this.json.frames;this.texture=e.texture.baseTexture,e.addEventListener("loaded",this.onLoaded.bind(this));for(var s in i){var o=i[s].frame;if(o){var a=new r.Rectangle(o.x,o.y,o.w,o.h),h=a.clone(),l=null;if(i[s].trimmed){var u=i[s].sourceSize,c=i[s].spriteSourceSize;l=new r.Rectangle(c.x,c.y,u.w,u.h)}r.TextureCache[s]=new r.Texture(this.texture,a,h,l)}}e.load()}else if(this.json.bones)if(r.AnimCache[this.url])this.onLoaded();else{var d=this.url.substr(0,this.url.lastIndexOf("."))+".atlas",p=new r.JsonLoader(d,this.crossorigin),f=this;p.onJSONLoaded=function(){if(!this.ajaxRequest.responseText)return void this.onError();var t=new r.SpineTextureLoader(this.url.substring(0,this.url.lastIndexOf("/"))),e=new n.Atlas(this.ajaxRequest.responseText,t),i=new n.AtlasAttachmentLoader(e),s=new n.SkeletonJson(i),o=s.readSkeletonData(f.json);r.AnimCache[f.url]=o,f.spine=o,f.spineAtlas=e,f.spineAtlasLoader=p,t.loadingCount>0?t.addEventListener("loadedBaseTexture",function(t){t.content.content.loadingCount<=0&&f.onLoaded()}):f.onLoaded()},p.load()}else this.onLoaded()},r.JsonLoader.prototype.onLoaded=function(){this.loaded=!0,this.dispatchEvent({type:"loaded",content:this})},r.JsonLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},r.AtlasLoader=function(t,e){this.url=t,this.baseUrl=t.replace(/[^\/]*$/,""),this.crossorigin=e,this.loaded=!1},r.AtlasLoader.constructor=r.AtlasLoader,r.EventTarget.mixin(r.AtlasLoader.prototype),r.AtlasLoader.prototype.load=function(){this.ajaxRequest=new r.AjaxRequest,this.ajaxRequest.onreadystatechange=this.onAtlasLoaded.bind(this),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/json"),this.ajaxRequest.send(null)},r.AtlasLoader.prototype.onAtlasLoaded=function(){if(4===this.ajaxRequest.readyState)if(200===this.ajaxRequest.status||-1===window.location.href.indexOf("http")){this.atlas={meta:{image:[]},frames:[]};var t=this.ajaxRequest.responseText.split(/\r?\n/),e=-3,i=0,n=null,s=!1,o=0,a=0,h=this.onLoaded.bind(this);for(o=0;o<t.length;o++)if(t[o]=t[o].replace(/^\s+|\s+$/g,""),""===t[o]&&(s=o+1),t[o].length>0){if(s===o)this.atlas.meta.image.push(t[o]),i=this.atlas.meta.image.length-1,this.atlas.frames.push({}),e=-3;else if(e>0)if(e%7===1)null!=n&&(this.atlas.frames[i][n.name]=n),n={name:t[o],frame:{}};else{var l=t[o].split(" ");if(e%7===3)n.frame.x=Number(l[1].replace(",","")),n.frame.y=Number(l[2]);
else if(e%7===4)n.frame.w=Number(l[1].replace(",","")),n.frame.h=Number(l[2]);else if(e%7===5){var u={x:0,y:0,w:Number(l[1].replace(",","")),h:Number(l[2])};u.w>n.frame.w||u.h>n.frame.h?(n.trimmed=!0,n.realSize=u):n.trimmed=!1}}e++}if(null!=n&&(this.atlas.frames[i][n.name]=n),this.atlas.meta.image.length>0){for(this.images=[],a=0;a<this.atlas.meta.image.length;a++){var c=this.baseUrl+this.atlas.meta.image[a],d=this.atlas.frames[a];this.images.push(new r.ImageLoader(c,this.crossorigin));for(o in d){var p=d[o].frame;p&&(r.TextureCache[o]=new r.Texture(this.images[a].texture.baseTexture,{x:p.x,y:p.y,width:p.w,height:p.h}),d[o].trimmed&&(r.TextureCache[o].realSize=d[o].realSize,r.TextureCache[o].trim.x=0,r.TextureCache[o].trim.y=0))}}for(this.currentImageId=0,a=0;a<this.images.length;a++)this.images[a].on("loaded",h);this.images[this.currentImageId].load()}else this.onLoaded()}else this.onError()},r.AtlasLoader.prototype.onLoaded=function(){this.images.length-1>this.currentImageId?(this.currentImageId++,this.images[this.currentImageId].load()):(this.loaded=!0,this.emit("loaded",{content:this}))},r.AtlasLoader.prototype.onError=function(){this.emit("error",{content:this})},r.SpriteSheetLoader=function(t,e){this.url=t,this.crossorigin=e,this.baseUrl=t.replace(/[^\/]*$/,""),this.texture=null,this.frames={}},r.SpriteSheetLoader.prototype.constructor=r.SpriteSheetLoader,r.EventTarget.mixin(r.SpriteSheetLoader.prototype),r.SpriteSheetLoader.prototype.load=function(){var t=this,e=new r.JsonLoader(this.url,this.crossorigin);e.on("loaded",function(e){t.json=e.data.content.json,t.onLoaded()}),e.load()},r.SpriteSheetLoader.prototype.onLoaded=function(){this.emit("loaded",{content:this})},r.ImageLoader=function(t,e){this.texture=r.Texture.fromImage(t,e),this.frames=[]},r.ImageLoader.prototype.constructor=r.ImageLoader,r.EventTarget.mixin(r.ImageLoader.prototype),r.ImageLoader.prototype.load=function(){this.texture.baseTexture.hasLoaded?this.onLoaded():this.texture.baseTexture.on("loaded",this.onLoaded.bind(this))},r.ImageLoader.prototype.onLoaded=function(){this.emit("loaded",{content:this})},r.ImageLoader.prototype.loadFramedSpriteSheet=function(t,e,i){this.frames=[];for(var n=Math.floor(this.texture.width/t),s=Math.floor(this.texture.height/e),o=0,a=0;s>a;a++)for(var h=0;n>h;h++,o++){var l=new r.Texture(this.texture.baseTexture,{x:h*t,y:a*e,width:t,height:e});this.frames.push(l),i&&(r.TextureCache[i+"-"+o]=l)}this.load()},r.BitmapFontLoader=function(t,e){this.url=t,this.crossorigin=e,this.baseUrl=t.replace(/[^\/]*$/,""),this.texture=null},r.BitmapFontLoader.prototype.constructor=r.BitmapFontLoader,r.EventTarget.mixin(r.BitmapFontLoader.prototype),r.BitmapFontLoader.prototype.load=function(){this.ajaxRequest=new r.AjaxRequest,this.ajaxRequest.onreadystatechange=this.onXMLLoaded.bind(this),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/xml"),this.ajaxRequest.send(null)},r.BitmapFontLoader.prototype.onXMLLoaded=function(){if(4===this.ajaxRequest.readyState&&(200===this.ajaxRequest.status||-1===window.location.protocol.indexOf("http"))){var t=this.ajaxRequest.responseXML;if(!t||/MSIE 9/i.test(navigator.userAgent)||navigator.isCocoonJS)if("function"==typeof window.DOMParser){var e=new DOMParser;t=e.parseFromString(this.ajaxRequest.responseText,"text/xml")}else{var i=document.createElement("div");i.innerHTML=this.ajaxRequest.responseText,t=i}var n=this.baseUrl+t.getElementsByTagName("page")[0].getAttribute("file"),s=new r.ImageLoader(n,this.crossorigin);this.texture=s.texture.baseTexture;var o={},a=t.getElementsByTagName("info")[0],h=t.getElementsByTagName("common")[0];o.font=a.getAttribute("face"),o.size=parseInt(a.getAttribute("size"),10),o.lineHeight=parseInt(h.getAttribute("lineHeight"),10),o.chars={};for(var l=t.getElementsByTagName("char"),u=0;u<l.length;u++){var c=parseInt(l[u].getAttribute("id"),10),d=new r.Rectangle(parseInt(l[u].getAttribute("x"),10),parseInt(l[u].getAttribute("y"),10),parseInt(l[u].getAttribute("width"),10),parseInt(l[u].getAttribute("height"),10));o.chars[c]={xOffset:parseInt(l[u].getAttribute("xoffset"),10),yOffset:parseInt(l[u].getAttribute("yoffset"),10),xAdvance:parseInt(l[u].getAttribute("xadvance"),10),kerning:{},texture:r.TextureCache[c]=new r.Texture(this.texture,d)}}var p=t.getElementsByTagName("kerning");for(u=0;u<p.length;u++){var f=parseInt(p[u].getAttribute("first"),10),g=parseInt(p[u].getAttribute("second"),10),m=parseInt(p[u].getAttribute("amount"),10);o.chars[g].kerning[f]=m}r.BitmapText.fonts[o.font]=o,s.addEventListener("loaded",this.onLoaded.bind(this)),s.load()}},r.BitmapFontLoader.prototype.onLoaded=function(){this.emit("loaded",{content:this})},r.SpineLoader=function(t,e){this.url=t,this.crossorigin=e,this.loaded=!1},r.SpineLoader.prototype.constructor=r.SpineLoader,r.EventTarget.mixin(r.SpineLoader.prototype),r.SpineLoader.prototype.load=function(){var t=this,e=new r.JsonLoader(this.url,this.crossorigin);e.on("loaded",function(e){t.json=e.data.content.json,t.onLoaded()}),e.load()},r.SpineLoader.prototype.onLoaded=function(){this.loaded=!0,this.emit("loaded",{content:this})},r.AbstractFilter=function(t,e){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=e||{},this.fragmentSrc=t||[]},r.AbstractFilter.prototype.constructor=r.AbstractFilter,r.AbstractFilter.prototype.syncUniforms=function(){for(var t=0,e=this.shaders.length;e>t;t++)this.shaders[t].dirty=!0},r.AlphaMaskFilter=function(t){r.AbstractFilter.call(this),this.passes=[this],t.baseTexture._powerOf2=!0,this.uniforms={mask:{type:"sampler2D",value:t},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},t.baseTexture.hasLoaded?(this.uniforms.mask.value.x=t.width,this.uniforms.mask.value.y=t.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),t.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D mask;","uniform sampler2D uSampler;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {"," vec2 mapCords = vTextureCoord.xy;"," mapCords += (dimensions.zw + offset)/ dimensions.xy ;"," mapCords.y *= -1.0;"," mapCords.y += 1.0;"," mapCords *= dimensions.xy / mapDimensions;"," vec4 original = texture2D(uSampler, vTextureCoord);"," float maskAlpha = texture2D(mask, mapCords).r;"," original *= maskAlpha;"," gl_FragColor = original;","}"]},r.AlphaMaskFilter.prototype=Object.create(r.AbstractFilter.prototype),r.AlphaMaskFilter.prototype.constructor=r.AlphaMaskFilter,r.AlphaMaskFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.mask.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.mask.value.height,this.uniforms.mask.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(r.AlphaMaskFilter.prototype,"map",{get:function(){return this.uniforms.mask.value},set:function(t){this.uniforms.mask.value=t}}),r.ColorMatrixFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","}"]},r.ColorMatrixFilter.prototype=Object.create(r.AbstractFilter.prototype),r.ColorMatrixFilter.prototype.constructor=r.ColorMatrixFilter,Object.defineProperty(r.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(t){this.uniforms.matrix.value=t}}),r.GrayFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={gray:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float gray;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);","}"]},r.GrayFilter.prototype=Object.create(r.AbstractFilter.prototype),r.GrayFilter.prototype.constructor=r.GrayFilter,Object.defineProperty(r.GrayFilter.prototype,"gray",{get:function(){return this.uniforms.gray.value},set:function(t){this.uniforms.gray.value=t}}),r.DisplacementFilter=function(t){r.AbstractFilter.call(this),this.passes=[this],t.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:t},scale:{type:"2f",value:{x:30,y:30}},offset:{type:"2f",value:{x:0,y:0}},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},t.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=t.width,this.uniforms.mapDimensions.value.y=t.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),t.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {"," vec2 mapCords = vTextureCoord.xy;"," mapCords += (dimensions.zw + offset)/ dimensions.xy ;"," mapCords.y *= -1.0;"," mapCords.y += 1.0;"," vec2 matSample = texture2D(displacementMap, mapCords).xy;"," matSample -= 0.5;"," matSample *= scale;"," matSample /= mapDimensions;"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));"," gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);"," vec2 cord = vTextureCoord;","}"]},r.DisplacementFilter.prototype=Object.create(r.AbstractFilter.prototype),r.DisplacementFilter.prototype.constructor=r.DisplacementFilter,r.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(r.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(t){this.uniforms.displacementMap.value=t}}),Object.defineProperty(r.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(t){this.uniforms.scale.value=t}}),Object.defineProperty(r.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value=t}}),r.PixelateFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:0},dimensions:{type:"4fv",value:new r.Float32Array([1e4,100,10,10])},pixelSize:{type:"2f",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {"," vec2 coord = vTextureCoord;"," vec2 size = dimensions.xy/pixelSize;"," vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;"," gl_FragColor = texture2D(uSampler, color);","}"]},r.PixelateFilter.prototype=Object.create(r.AbstractFilter.prototype),r.PixelateFilter.prototype.constructor=r.PixelateFilter,Object.defineProperty(r.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(t){this.dirty=!0,this.uniforms.pixelSize.value=t}}),r.BlurXFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," vec4 sum = vec4(0.0);"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;"," gl_FragColor = sum;","}"]},r.BlurXFilter.prototype=Object.create(r.AbstractFilter.prototype),r.BlurXFilter.prototype.constructor=r.BlurXFilter,Object.defineProperty(r.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.dirty=!0,this.uniforms.blur.value=1/7e3*t}}),r.BlurYFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," vec4 sum = vec4(0.0);"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;"," gl_FragColor = sum;","}"]},r.BlurYFilter.prototype=Object.create(r.AbstractFilter.prototype),r.BlurYFilter.prototype.constructor=r.BlurYFilter,Object.defineProperty(r.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.uniforms.blur.value=1/7e3*t}}),r.BlurFilter=function(){this.blurXFilter=new r.BlurXFilter,this.blurYFilter=new r.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},r.BlurFilter.prototype=Object.create(r.AbstractFilter.prototype),r.BlurFilter.prototype.constructor=r.BlurFilter,Object.defineProperty(r.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYFilter.blur=t}}),Object.defineProperty(r.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}}),Object.defineProperty(r.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t}}),r.InvertFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","}"]},r.InvertFilter.prototype=Object.create(r.AbstractFilter.prototype),r.InvertFilter.prototype.constructor=r.InvertFilter,Object.defineProperty(r.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(t){this.uniforms.invert.value=t}}),r.SepiaFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","}"]},r.SepiaFilter.prototype=Object.create(r.AbstractFilter.prototype),r.SepiaFilter.prototype.constructor=r.SepiaFilter,Object.defineProperty(r.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(t){this.uniforms.sepia.value=t}}),r.TwistFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"2f",value:{x:.5,y:.5}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float radius;","uniform float angle;","uniform vec2 offset;","void main(void) {"," vec2 coord = vTextureCoord - offset;"," float distance = length(coord);"," if (distance < radius) {"," float ratio = (radius - distance) / radius;"," float angleMod = ratio * ratio * angle;"," float s = sin(angleMod);"," float c = cos(angleMod);"," coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);"," }"," gl_FragColor = texture2D(uSampler, coord+offset);","}"]},r.TwistFilter.prototype=Object.create(r.AbstractFilter.prototype),r.TwistFilter.prototype.constructor=r.TwistFilter,Object.defineProperty(r.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(t){this.dirty=!0,this.uniforms.offset.value=t}}),Object.defineProperty(r.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(t){this.dirty=!0,this.uniforms.radius.value=t}}),Object.defineProperty(r.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(t){this.dirty=!0,this.uniforms.angle.value=t}}),r.ColorStepFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={step:{type:"1f",value:5}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float step;","void main(void) {"," vec4 color = texture2D(uSampler, vTextureCoord);"," color = floor(color * step) / step;"," gl_FragColor = color;","}"]},r.ColorStepFilter.prototype=Object.create(r.AbstractFilter.prototype),r.ColorStepFilter.prototype.constructor=r.ColorStepFilter,Object.defineProperty(r.ColorStepFilter.prototype,"step",{get:function(){return this.uniforms.step.value},set:function(t){this.uniforms.step.value=t}}),r.DotScreenFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {"," float s = sin(angle), c = cos(angle);"," vec2 tex = vTextureCoord * dimensions.xy;"," vec2 point = vec2("," c * tex.x - s * tex.y,"," s * tex.x + c * tex.y"," ) * scale;"," return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {"," vec4 color = texture2D(uSampler, vTextureCoord);"," float average = (color.r + color.g + color.b) / 3.0;"," gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},r.DotScreenFilter.prototype=Object.create(r.AbstractFilter.prototype),r.DotScreenFilter.prototype.constructor=r.DotScreenFilter,Object.defineProperty(r.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(t){this.dirty=!0,this.uniforms.scale.value=t}}),Object.defineProperty(r.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(t){this.dirty=!0,this.uniforms.angle.value=t}}),r.CrossHatchFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);"," gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"," if (lum < 1.00) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.75) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.50) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.3) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }","}"]},r.CrossHatchFilter.prototype=Object.create(r.AbstractFilter.prototype),r.CrossHatchFilter.prototype.constructor=r.CrossHatchFilter,Object.defineProperty(r.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.uniforms.blur.value=1/7e3*t}}),r.RGBSplitFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"2f",value:{x:20,y:20}},green:{type:"2f",value:{x:-20,y:20}},blue:{type:"2f",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;"," gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;"," gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;"," gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},r.RGBSplitFilter.prototype=Object.create(r.AbstractFilter.prototype),r.RGBSplitFilter.prototype.constructor=r.RGBSplitFilter,Object.defineProperty(r.RGBSplitFilter.prototype,"red",{get:function(){return this.uniforms.red.value},set:function(t){this.uniforms.red.value=t}}),Object.defineProperty(r.RGBSplitFilter.prototype,"green",{get:function(){return this.uniforms.green.value},set:function(t){this.uniforms.green.value=t}}),Object.defineProperty(r.RGBSplitFilter.prototype,"blue",{get:function(){return this.uniforms.blue.value},set:function(t){this.uniforms.blue.value=t}}),"undefined"!=typeof i?("undefined"!=typeof e&&e.exports&&(i=e.exports=r),i.PIXI=r):"undefined"!=typeof define&&define.amd?define(r):t.PIXI=r}).call(this)},{}],randomColor:[function(t,e,i){!function(t,r){if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof i){var n=r();"object"==typeof e&&e&&e.exports&&(i=e.exports=n),i.randomColor=n}else t.randomColor=r()}(this,function(){function t(t){var e=s(t.hue),i=h(e);return 0>i&&(i=360+i),i}function e(t,e){if("random"===e.luminosity)return h([0,100]);if("monochrome"===e.hue)return 0;var i=o(t),r=i[0],n=i[1];switch(e.luminosity){case"bright":r=55;break;case"dark":r=n-10;break;case"light":n=55}return h([r,n])}function i(t,e,i){var r=n(t,e),s=100;switch(i.luminosity){case"dark":s=r+20;break;case"light":r=(s+r)/2;break;case"random":r=0,s=100}return h([r,s])}function r(t,e){switch(e.format){case"hsvArray":return t;case"hsv":return p("hsv",t);case"rgbArray":return d(t);case"rgb":return p("rgb",d(t));default:return l(t)}}function n(t,e){for(var i=a(t).lowerBounds,r=0;r<i.length-1;r++){var n=i[r][0],s=i[r][1],o=i[r+1][0],h=i[r+1][1];if(e>=n&&o>=e){var l=(h-s)/(o-n),u=s-l*n;return l*e+u}}return 0}function s(t){if("number"==typeof parseInt(t)){var e=parseInt(t);if(360>e&&e>0)return[e,e]}if("string"==typeof t&&f[t]){var i=f[t];if(i.hueRange)return i.hueRange}return[0,360]}function o(t){return a(t).saturationRange}function a(t){t>=334&&360>=t&&(t-=360);for(var e in f){var i=f[e];if(i.hueRange&&t>=i.hueRange[0]&&t<=i.hueRange[1])return f[e]}return"Color not found"}function h(t){return Math.floor(t[0]+Math.random()*(t[1]+1-t[0]))}function l(t){function e(t){var e=t.toString(16);return 1==e.length?"0"+e:e}var i=d(t),r="#"+e(i[0])+e(i[1])+e(i[2]);return r}function u(t,e,i){var r=i[0][0],n=i[i.length-1][0],s=i[i.length-1][1],o=i[0][1];f[t]={hueRange:e,lowerBounds:i,saturationRange:[r,n],brightnessRange:[s,o]}}function c(){u("monochrome",null,[[0,0],[100,0]]),u("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),u("orange",[19,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),u("yellow",[47,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),u("green",[63,158],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),u("blue",[159,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),u("purple",[258,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),u("pink",[283,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]])}function d(t){var e=t[0];0===e&&(e=1),360===e&&(e=359),e/=360;var i=t[1]/100,r=t[2]/100,n=Math.floor(6*e),s=6*e-n,o=r*(1-i),a=r*(1-s*i),h=r*(1-(1-s)*i),l=256,u=256,c=256;switch(n){case 0:l=r,u=h,c=o;break;case 1:l=a,u=r,c=o;break;case 2:l=o,u=r,c=h;break;case 3:l=o,u=a,c=r;break;case 4:l=h,u=o,c=r;break;case 5:l=r,u=o,c=a}var d=[Math.floor(255*l),Math.floor(255*u),Math.floor(255*c)];return d}function p(t,e){return t+"("+e.join(", ")+")"}var f={};c();var g=function(n){n=n||{};var s,o,a;if(n.count){var h=n.count,l=[];for(n.count=!1;h>l.length;)l.push(g(n));return l}return s=t(n),o=e(s,n),a=i(s,o,n),r([s,o,a],n)};return g})},{}]},{},[]);