Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 1756 lines (1756 sloc) 861 KB
var cc=cc||{};function ClassManager(){return arguments.callee.name||arguments.callee.toString().match(/^function ([^(]+)/)[1]}ClassManager.id=0|998*Math.random();
ClassManager.compileSuper=function(a,b,c){for(var d=a.toString(),e=d.indexOf("("),f=d.indexOf(")"),e=d.substring(e+1,f),e=e.trim(),f=d.indexOf("{"),g=d.lastIndexOf("}"),d=d.substring(f+1,g);-1!=d.indexOf("this._super");)var f=d.indexOf("this._super"),g=d.indexOf("(",f),h=d.indexOf(")",g),h=d.substring(g+1,h),h=(h=h.trim())?",":"",k=arguments.callee.ClassManager(),d=d.substring(0,f)+k+"["+c+"]."+b+".call(this"+h+d.substring(g+1);return Function(e,d)};ClassManager.compileSuper.ClassManager=ClassManager;
ClassManager.getNewID=function(){return this.id++};
(function(){var a=!1,b=/\b_super\b/,c=document.ccConfig&&document.ccConfig.CLASS_RELEASE_MODE?document.ccConfig.CLASS_RELEASE_MODE:null;c&&console.log("release Mode");cc.Class=function(){};cc.Class.extend=function(d){function e(){!a&&this.ctor&&this.ctor.apply(this,arguments)}var f=this.prototype;a=!0;var g=new this;a=!1;e.id=ClassManager.getNewID();ClassManager[e.id]=f;for(var h in d)c&&"function"==typeof d[h]&&"function"==typeof f[h]&&b.test(d[h])?g[h]=ClassManager.compileSuper(d[h],h,e.id):"function"==
typeof d[h]&&"function"==typeof f[h]&&b.test(d[h])?g[h]=function(a,b){return function(){var c=this._super;this._super=f[a];var d=b.apply(this,arguments);this._super=c;return d}}(h,d[h]):g[h]=d[h];g.__pid=e.id;e.prototype=g;e.prototype.constructor=e;e.extend=arguments.callee;e.implement=function(a){for(var b in a)g[b]=a[b]};return e}})();cc.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a};
cc.base=function(a,b,c){var d=arguments.callee.caller;if(d.superClass_)return ret=d.superClass_.constructor.apply(a,Array.prototype.slice.call(arguments,1));for(var e=Array.prototype.slice.call(arguments,2),f=!1,g=a.constructor;g;g=g.superClass_&&g.superClass_.constructor)if(g.prototype[b]===d)f=!0;else if(f)return g.prototype[b].apply(a,e);if(a[b]===d)return a.constructor.prototype[b].apply(a,e);throw Error("cc.base called from a method of one name to a method of a different name");};
cc.concatObjectProperties=function(a,b){a||(a={});for(var c in b)a[c]=b[c];return a};cc.clone=function(a){var b=a instanceof Array?[]:{},c;for(c in a){var d=a[c];b[c]=d instanceof Array?cc.clone(d):"object"==typeof d&&!(d instanceof cc.Node)&&!(d instanceof HTMLElement)?cc.clone(d):d}return b};cc.associateWithNative=function(a,b){};cc.IS_SHOW_DEBUG_ON_PAGE=cc.IS_SHOW_DEBUG_ON_PAGE||!1;
cc._logToWebPage=function(a){var b=document.getElementById("logInfoList");if(!b){var c=document.createElement("Div");c.setAttribute("id","logInfoDiv");cc.canvas.parentNode.appendChild(c);c.setAttribute("width","300");c.setAttribute("height",cc.canvas.height);c.style.zIndex="99999";c.style.position="absolute";c.style.top="0";c.style.left="0";b=document.createElement("ul");c.appendChild(b);b.setAttribute("id","logInfoList");b.style.height="450px";b.style.color="#fff";b.style.textAlign="left";b.style.listStyle=
"disc outside";b.style.fontSize="12px";b.style.fontFamily="arial";b.style.padding="0 0 0 20px";b.style.margin="0";b.style.textShadow="0 0 3px #000";b.style.zIndex="99998";b.style.position="absolute";b.style.top="0";b.style.left="0";b.style.overflowY="hidden";var d=document.createElement("Div");c.appendChild(d);d.style.width="300px";d.style.height=cc.canvas.height+"px";d.style.opacity="0.1";d.style.background="#fff";d.style.border="1px solid #dfdfdf";d.style.borderRadius="8px"}c=document.createElement("li");
c.innerHTML=a;0==b.childNodes.length?b.appendChild(c):b.insertBefore(c,b.childNodes[0])};cc.log=function(a){cc.IS_SHOW_DEBUG_ON_PAGE?cc._logToWebPage(a):console.log(a)};cc.MessageBox=function(a){console.log(a)};cc.Assert=function(a,b){console.assert?console.assert(a,b):a||b&&alert(b)};
cc.initDebugSetting=function(){0==cc.COCOS2D_DEBUG?(cc.log=function(){},cc.logINFO=function(){},cc.logERROR=function(){},cc.Assert=function(){}):1==cc.COCOS2D_DEBUG?(cc.logINFO=cc.log,cc.logERROR=function(){}):1<cc.COCOS2D_DEBUG&&(cc.logINFO=cc.log,cc.logERROR=cc.log)};cc.LANGUAGE_ENGLISH=0;cc.LANGUAGE_CHINESE=1;cc.LANGUAGE_FRENCH=2;cc.LANGUAGE_ITALIAN=3;cc.LANGUAGE_GERMAN=4;cc.LANGUAGE_SPANISH=5;cc.LANGUAGE_RUSSIAN=6;cc.create3DContext=function(a,b){for(var c=["webgl","experimental-webgl","webkit-3d","moz-webgl"],d=null,e=0;e<c.length;++e){try{d=a.getContext(c[e],b)}catch(f){}if(d)break}return d};cc.Browser={};
(function(){cc.Browser.ua=navigator.userAgent.toLowerCase();cc.Browser.platform=navigator.platform.toLowerCase();cc.Browser.UA=cc.Browser.ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0];cc.Browser.mode="ie"==cc.Browser.UA[1]&&document.documentMode;cc.Browser.type="version"==cc.Browser.UA[1]?cc.Browser.UA[3]:cc.Browser.UA[1];cc.Browser.isMobile=-1!=cc.Browser.ua.indexOf("mobile")||-1!=cc.Browser.ua.indexOf("android");cc._userRenderMode=
parseInt(document.ccConfig.renderMode)||0;if(1===cc._userRenderMode)cc.Browser.supportWebGL=!1;else{cc.Browser.supportWebGL=null!=window.WebGLRenderingContext;var a=document.createElement("Canvas"),a=cc.create3DContext(a,{stencil:!0,preserveDrawingBuffer:!0});cc.Browser.supportWebGL=null!=a}2===cc._userRenderMode&&!cc.Browser.supportWebGL&&(cc.__renderDoesnotSupport=!0)})();cc.RenderDoesnotSupport=function(){return"undefined"===cc.__renderDoesnotSupport?!1:cc.__renderDoesnotSupport};
cc.$=function(a){var b=this==cc?document:this;if(a=a instanceof HTMLElement?a:b.querySelector(a))a.find=a.find||cc.$,a.hasClass=a.hasClass||function(a){return this.className.match(RegExp("(\\s|^)"+a+"(\\s|$)"))},a.addClass=a.addClass||function(a){this.hasClass(a)||(this.className&&(this.className+=" "),this.className+=a);return this},a.removeClass=a.removeClass||function(a){this.hasClass(a)&&(this.className=this.className.replace(a,""));return this},a.remove=a.remove||function(){this.parentNode&&
this.parentNode.removeChild(this);return this},a.appendTo=a.appendTo||function(a){a.appendChild(this);return this},a.prependTo=a.prependTo||function(a){a.childNodes[0]?a.insertBefore(this,a.childNodes[0]):a.appendChild(this);return this},a.transforms=a.transforms||function(){this.style[cc.$.trans]=cc.$.translate(this.position)+cc.$.rotate(this.rotation)+cc.$.scale(this.scale)+cc.$.skew(this.skew);return this},a.position=a.position||{x:0,y:0},a.rotation=a.rotation||0,a.scale=a.scale||{x:1,y:1},a.skew=
a.skew||{x:0,y:0},a.translates=function(a,b){this.position.x=a;this.position.y=b;this.transforms();return this},a.rotate=function(a){this.rotation=a;this.transforms();return this},a.resize=function(a,b){this.scale.x=a;this.scale.y=b;this.transforms();return this},a.setSkew=function(a,b){this.skew.x=a;this.skew.y=b;this.transforms();return this};return a};
switch(cc.Browser.type){case "firefox":cc.$.pfx="Moz";cc.$.hd=!0;break;case "chrome":case "safari":cc.$.pfx="webkit";cc.$.hd=!0;break;case "opera":cc.$.pfx="O";cc.$.hd=!1;break;case "ie":cc.$.pfx="ms";cc.$.hd=!1;break;default:cc.$.pfx="webkit",cc.$.hd=!0}cc.$.trans=cc.$.pfx+"Transform";cc.$.translate=cc.$.hd?function(a){return"translate3d("+a.x+"px, "+a.y+"px, 0) "}:function(a){return"translate("+a.x+"px, "+a.y+"px) "};
cc.$.rotate=cc.$.hd?function(a){return"rotateZ("+a+"deg) "}:function(a){return"rotate("+a+"deg) "};cc.$.scale=function(a){return"scale("+a.x+", "+a.y+") "};cc.$.skew=function(a){return"skewX("+-a.x+"deg) skewY("+a.y+"deg)"};cc.$new=function(a){return cc.$(document.createElement(a))};cc.$.findpos=function(a){var b=0,c=0;do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent);return{x:b,y:c}};cc.Codec={name:"Jacob__Codec"};cc.unzip=function(){return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,arguments)};cc.unzipBase64=function(){var a=cc.Codec.Base64.decode.apply(cc.Codec.Base64,arguments);return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,[a])};cc.unzipBase64AsArray=function(a,b){b=b||1;var c=this.unzipBase64(a),d=[],e,f,g;e=0;for(g=c.length/b;e<g;e++){d[e]=0;for(f=b-1;0<=f;--f)d[e]+=c.charCodeAt(e*b+f)<<8*f}return d};
cc.unzipAsArray=function(a,b){b=b||1;var c=this.unzip(a),d=[],e,f,g;e=0;for(g=c.length/b;e<g;e++){d[e]=0;for(f=b-1;0<=f;--f)d[e]+=c.charCodeAt(e*b+f)<<8*f}return d};cc.StringToArray=function(a){a=a.split(",");var b=[],c;for(c=0;c<a.length;c++)b.push(parseInt(a[c]));return b};cc.Codec.Base64={name:"Jacob__Codec__Base64"};cc.Codec.Base64._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\x3d";
cc.Codec.Base64.decode=function(a){var b=[],c,d,e,f,g,h=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<a.length;)c=this._keyStr.indexOf(a.charAt(h++)),d=this._keyStr.indexOf(a.charAt(h++)),f=this._keyStr.indexOf(a.charAt(h++)),g=this._keyStr.indexOf(a.charAt(h++)),c=c<<2|d>>4,d=(d&15)<<4|f>>2,e=(f&3)<<6|g,b.push(String.fromCharCode(c)),64!=f&&b.push(String.fromCharCode(d)),64!=g&&b.push(String.fromCharCode(e));return b=b.join("")};
cc.Codec.Base64.decodeAsArray=function(a,b){var c=this.decode(a),d=[],e,f,g;e=0;for(g=c.length/b;e<g;e++){d[e]=0;for(f=b-1;0<=f;--f)d[e]+=c.charCodeAt(e*b+f)<<8*f}return d};cc.uint8ArrayToUint32Array=function(a){if(0!=a.length%4)return null;for(var b=a.length/4,c=window.Uint32Array?new Uint32Array(b):[],d=0;d<b;d++){var e=4*d;c[d]=a[e]+256*a[e+1]+65536*a[e+2]+16777216*a[e+3]}return c};cc.Codec.GZip=function(a){this.data=a;this.debug=!1;this.gpflags=void 0;this.files=0;this.unzipped=[];this.buf32k=Array(32768);this.bIdx=0;this.modeZIP=!1;this.bytepos=0;this.bb=1;this.bits=0;this.nameBuf=[];this.fileout=void 0;this.literalTree=Array(cc.Codec.GZip.LITERALS);this.distanceTree=Array(32);this.treepos=0;this.Places=null;this.len=0;this.fpos=Array(17);this.fpos[0]=0;this.fmax=this.flens=void 0};cc.Codec.GZip.gunzip=function(a){return(new cc.Codec.GZip(a)).gunzip()[0][0]};
cc.Codec.GZip.HufNode=function(){this.b1=this.b0=0;this.jump=null;this.jumppos=-1};cc.Codec.GZip.LITERALS=288;cc.Codec.GZip.NAMEMAX=256;
cc.Codec.GZip.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,
97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255];
cc.Codec.GZip.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0];cc.Codec.GZip.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99];cc.Codec.GZip.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];cc.Codec.GZip.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];cc.Codec.GZip.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
cc.Codec.GZip.prototype.gunzip=function(){this.outputArr=[];this.nextFile();return this.unzipped};cc.Codec.GZip.prototype.readByte=function(){this.bits+=8;return this.bytepos<this.data.length?this.data.charCodeAt(this.bytepos++):-1};cc.Codec.GZip.prototype.byteAlign=function(){this.bb=1};cc.Codec.GZip.prototype.readBit=function(){var a;this.bits++;a=this.bb&1;this.bb>>=1;0==this.bb&&(this.bb=this.readByte(),a=this.bb&1,this.bb=this.bb>>1|128);return a};
cc.Codec.GZip.prototype.readBits=function(a){for(var b=0,c=a;c--;)b=b<<1|this.readBit();a&&(b=cc.Codec.GZip.bitReverse[b]>>8-a);return b};cc.Codec.GZip.prototype.flushBuffer=function(){this.bIdx=0};cc.Codec.GZip.prototype.addBuffer=function(a){this.buf32k[this.bIdx++]=a;this.outputArr.push(String.fromCharCode(a));32768==this.bIdx&&(this.bIdx=0)};
cc.Codec.GZip.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]==this.len)return this.fpos[this.len]++;this.fpos[this.len]++}};
cc.Codec.GZip.prototype.Rec=function(){var a=this.Places[this.treepos],b;if(17==this.len)return-1;this.treepos++;this.len++;b=this.IsPat();if(0<=b)a.b0=b;else if(a.b0=32768,this.Rec())return-1;b=this.IsPat();if(0<=b)a.b1=b,a.jump=null;else if(a.b1=32768,a.jump=this.Places[this.treepos],a.jumppos=this.treepos,this.Rec())return-1;this.len--;return 0};
cc.Codec.GZip.prototype.CreateTree=function(a,b,c,d){this.Places=a;this.treepos=0;this.flens=c;this.fmax=b;for(a=0;17>a;a++)this.fpos[a]=0;this.len=0;return this.Rec()?-1:0};cc.Codec.GZip.prototype.DecodeValue=function(a){for(var b,c,d=0,e=a[d];;)if(b=this.readBit()){if(!(e.b1&32768))return e.b1;e=e.jump;b=a.length;for(c=0;c<b;c++)if(a[c]===e){d=c;break}}else{if(!(e.b0&32768))return e.b0;d++;e=a[d]}return-1};
cc.Codec.GZip.prototype.DeflateLoop=function(){var a,b,c,d,e;do if(a=this.readBit(),c=this.readBits(2),0==c){this.byteAlign();c=this.readByte();c|=this.readByte()<<8;b=this.readByte();b|=this.readByte()<<8;for((c^~b)&65535&&document.write("BlockLen checksum mismatch\n");c--;)b=this.readByte(),this.addBuffer(b)}else if(1==c)for(;;)if(c=cc.Codec.GZip.bitReverse[this.readBits(7)]>>1,23<c?(c=c<<1|this.readBit(),199<c?(c-=128,c=c<<1|this.readBit()):(c-=48,143<c&&(c+=136))):c+=256,256>c)this.addBuffer(c);
else if(256==c)break;else{var f;c-=257;e=this.readBits(cc.Codec.GZip.cplext[c])+cc.Codec.GZip.cplens[c];c=cc.Codec.GZip.bitReverse[this.readBits(5)]>>3;8<cc.Codec.GZip.cpdext[c]?(f=this.readBits(8),f|=this.readBits(cc.Codec.GZip.cpdext[c]-8)<<8):f=this.readBits(cc.Codec.GZip.cpdext[c]);f+=cc.Codec.GZip.cpdist[c];for(c=0;c<e;c++)b=this.buf32k[this.bIdx-f&32767],this.addBuffer(b)}else if(2==c){var g=Array(320);b=257+this.readBits(5);f=1+this.readBits(5);d=4+this.readBits(4);for(c=0;19>c;c++)g[c]=0;
for(c=0;c<d;c++)g[cc.Codec.GZip.border[c]]=this.readBits(3);e=this.distanceTree.length;for(d=0;d<e;d++)this.distanceTree[d]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.distanceTree,19,g,0))return this.flushBuffer(),1;e=b+f;d=0;for(var h=-1;d<e;)if(h++,c=this.DecodeValue(this.distanceTree),16>c)g[d++]=c;else if(16==c){var k;c=3+this.readBits(2);if(d+c>e)return this.flushBuffer(),1;for(k=d?g[d-1]:0;c--;)g[d++]=k}else{c=17==c?3+this.readBits(3):11+this.readBits(7);if(d+c>e)return this.flushBuffer(),
1;for(;c--;)g[d++]=0}e=this.literalTree.length;for(d=0;d<e;d++)this.literalTree[d]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.literalTree,b,g,0))return this.flushBuffer(),1;e=this.literalTree.length;for(d=0;d<e;d++)this.distanceTree[d]=new cc.Codec.GZip.HufNode;c=[];for(d=b;d<g.length;d++)c[d-b]=g[d];if(this.CreateTree(this.distanceTree,f,c,0))return this.flushBuffer(),1;for(;;)if(c=this.DecodeValue(this.literalTree),256<=c){c-=256;if(0==c)break;c--;e=this.readBits(cc.Codec.GZip.cplext[c])+
cc.Codec.GZip.cplens[c];c=this.DecodeValue(this.distanceTree);8<cc.Codec.GZip.cpdext[c]?(f=this.readBits(8),f|=this.readBits(cc.Codec.GZip.cpdext[c]-8)<<8):f=this.readBits(cc.Codec.GZip.cpdext[c]);for(f+=cc.Codec.GZip.cpdist[c];e--;)b=this.buf32k[this.bIdx-f&32767],this.addBuffer(b)}else this.addBuffer(c)}while(!a);this.flushBuffer();this.byteAlign();return 0};cc.Codec.GZip.prototype.unzipFile=function(a){var b;this.gunzip();for(b=0;b<this.unzipped.length;b++)if(this.unzipped[b][1]==a)return this.unzipped[b][0]};
cc.Codec.GZip.prototype.nextFile=function(){this.outputArr=[];this.modeZIP=!1;var a=[];a[0]=this.readByte();a[1]=this.readByte();120==a[0]&&218==a[1]&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),"geonext.gxt"],this.files++);31==a[0]&&139==a[1]&&(this.skipdir(),this.unzipped[this.files]=[this.outputArr.join(""),"file"],this.files++);if(80==a[0]&&75==a[1]&&(this.modeZIP=!0,a[2]=this.readByte(),a[3]=this.readByte(),3==a[2]&&4==a[3])){a[0]=this.readByte();a[1]=this.readByte();
this.gpflags=this.readByte();this.gpflags|=this.readByte()<<8;a=this.readByte();a|=this.readByte()<<8;this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();var b=this.readByte(),b=b|this.readByte()<<8,c=this.readByte(),c=c|this.readByte()<<8,d=0;for(this.nameBuf=[];b--;){var e=this.readByte();"/"==e|":"==e?d=0:d<cc.Codec.GZip.NAMEMAX-1&&(this.nameBuf[d++]=String.fromCharCode(e))}this.fileout||
(this.fileout=this.nameBuf);for(var d=0;d<c;)this.readByte(),d++;8==a&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),this.nameBuf.join("")],this.files++);this.skipdir()}};
cc.Codec.GZip.prototype.skipdir=function(){var a=[],b;this.gpflags&8&&(a[0]=this.readByte(),a[1]=this.readByte(),a[2]=this.readByte(),a[3]=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte());this.modeZIP&&this.nextFile();a[0]=this.readByte();if(8!=a[0])return 0;this.gpflags=this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();if(this.gpflags&4){a[0]=
this.readByte();a[2]=this.readByte();this.len=a[0]+256*a[1];for(a=0;a<this.len;a++)this.readByte()}if(this.gpflags&8){a=0;for(this.nameBuf=[];b=this.readByte();){if("7"==b||":"==b)a=0;a<cc.Codec.GZip.NAMEMAX-1&&(this.nameBuf[a++]=b)}}if(this.gpflags&16)for(;this.readByte(););this.gpflags&2&&(this.readByte(),this.readByte());this.DeflateLoop();this.readByte();this.readByte();this.readByte();this.readByte();this.modeZIP&&this.nextFile()};cc.INVALID_INDEX=-1;cc.PI=Math.PI;cc.FLT_MAX=parseFloat("3.402823466e+38F");cc.RAD=cc.PI/180;cc.DEG=180/cc.PI;cc.UINT_MAX=4294967295;cc.SWAP=function(a,b,c){if("object"==typeof c&&"undefined"!=typeof c.x&&"undefined"!=typeof c.y){var d=c[a];c[a]=c[b];c[b]=d}else cc.Assert(!1,"CC_SWAP is being modified from original macro, please check usage")};cc.lerp=function(a,b,c){return a+(b-a)*c};cc.RANDOM_MINUS1_1=function(){return 2*(Math.random()-0.5)};cc.RANDOM_0_1=function(){return Math.random()};
cc.DEGREES_TO_RADIANS=function(a){return a*cc.RAD};cc.RADIANS_TO_DEGREES=function(a){return a*cc.DEG};cc.REPEAT_FOREVER=Number.MAX_VALUE-1;cc.BLEND_SRC=cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA?1:770;cc.BLEND_DST=771;cc.NODE_DRAW_SETUP=function(a){a._shaderProgram&&(a._shaderProgram.use(),a._shaderProgram.setUniformForModelViewProjectionMatrixWithMat4(a._mvpMatrix))};cc.ENABLE_DEFAULT_GL_STATES=function(){};cc.DISABLE_DEFAULT_GL_STATES=function(){};
cc.INCREMENT_GL_DRAWS=function(a){cc.g_NumberOfDraws+=a};cc.FLT_EPSILON=1.192092896E-7;cc.CONTENT_SCALE_FACTOR=cc.IS_RETINA_DISPLAY_SUPPORTED?function(){return cc.Director.getInstance().getContentScaleFactor()}:function(){return 1};cc.POINT_POINTS_TO_PIXELS=function(a){return cc.p(a.x*cc.CONTENT_SCALE_FACTOR(),a.y*cc.CONTENT_SCALE_FACTOR())};cc.SIZE_POINTS_TO_PIXELS=function(a){return cc.size(a.width*cc.CONTENT_SCALE_FACTOR(),a.height*cc.CONTENT_SCALE_FACTOR())};
cc.SIZE_PIXELS_TO_POINTS=function(a){return cc.size(a.width/cc.CONTENT_SCALE_FACTOR(),a.height/cc.CONTENT_SCALE_FACTOR())};cc.POINT_PIXELS_TO_POINTS=function(a){return cc.p(a.x/cc.CONTENT_SCALE_FACTOR(),a.y/cc.CONTENT_SCALE_FACTOR())};cc.RECT_PIXELS_TO_POINTS=cc.IS_RETINA_DISPLAY_SUPPORTED?function(a){return cc.rect(a.origin.x/cc.CONTENT_SCALE_FACTOR(),a.origin.y/cc.CONTENT_SCALE_FACTOR(),a.size.width/cc.CONTENT_SCALE_FACTOR(),a.size.height/cc.CONTENT_SCALE_FACTOR())}:function(a){return a};
cc.RECT_POINTS_TO_PIXELS=cc.IS_RETINA_DISPLAY_SUPPORTED?function(a){return cc.rect(a.origin.x*cc.CONTENT_SCALE_FACTOR(),a.origin.y*cc.CONTENT_SCALE_FACTOR(),a.size.width*cc.CONTENT_SCALE_FACTOR(),a.size.height*cc.CONTENT_SCALE_FACTOR())}:function(a){return a};if(!cc.Browser.supportWebGL){var gl=gl||{};gl.ONE=1;gl.ZERO=0;gl.SRC_ALPHA=770;gl.ONE_MINUS_SRC_ALPHA=771;gl.ONE_MINUS_DST_COLOR=775}cc.CHECK_GL_ERROR_DEBUG=function(){var a=cc.renderContext.getError();a&&cc.log("WebGL error "+a)};cc.SAX_NONE=0;cc.SAX_KEY=1;cc.SAX_DICT=2;cc.SAX_INT=3;cc.SAX_REAL=4;cc.SAX_STRING=5;cc.SAX_ARRAY=6;var Uint8Array=Uint8Array||Array;
if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){var IEBinaryToArray_ByteStr_Script='\x3c!-- IEBinaryToArray_ByteStr --\x3e\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n IEBinaryToArray_ByteStr \x3d CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n Dim lastIndex\r\n lastIndex \x3d LenB(Binary)\r\n if lastIndex mod 2 Then\r\n IEBinaryToArray_ByteStr_Last \x3d Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n Else\r\n IEBinaryToArray_ByteStr_Last \x3d ""\r\n End If\r\nEnd Function\r\n',myVBScript=
document.createElement("script");myVBScript.type="text/vbscript";myVBScript.textContent=IEBinaryToArray_ByteStr_Script;document.body.appendChild(myVBScript);cc._convertResponseBodyToText=function(a){for(var b={},c=0;256>c;c++)for(var d=0;256>d;d++)b[String.fromCharCode(c+256*d)]=String.fromCharCode(c)+String.fromCharCode(d);c=IEBinaryToArray_ByteStr(a);a=IEBinaryToArray_ByteStr_Last(a);return c.replace(/[\s\S]/g,function(a){return b[a]})+a}}
cc.FileUtils=cc.Class.extend({_fileDataCache:null,_textFileCache:null,_directory:null,_filenameLookupDict:null,_searchResolutionsOrderArray:null,_searchPathArray:null,ctor:function(){this._fileDataCache={};this._textFileCache={};this._searchPathArray=[];this._searchPathArray.push("");this._searchResolutionsOrderArray=[];this._searchResolutionsOrderArray.push("")},getByteArrayFromFile:function(a,b,c){return this._fileDataCache.hasOwnProperty(a)?this._fileDataCache[a]:this._loadBinaryFileData(a)},_getXMLHttpRequest:function(){return window.XMLHttpRequest?
new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},unloadBinaryFileData:function(a){this._fileDataCache.hasOwnProperty(a)&&delete this._fileDataCache[a]},preloadBinaryFileData:function(a){a=this.fullPathFromRelativePath(a);var b=this,c=this._getXMLHttpRequest();c.open("GET",a,!0);/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?(c.setRequestHeader("Accept-Charset","x-user-defined"),c.onreadystatechange=function(d){4==c.readyState&&(200==c.status&&(d=cc._convertResponseBodyToText(c.responseBody))&&
(b._fileDataCache[a]=b._stringConvertToArray(d)),cc.Loader.getInstance().onResLoaded())}):(c.overrideMimeType&&c.overrideMimeType("text/plain; charset\x3dx-user-defined"),c.onload=function(d){if(d=c.responseText)cc.Loader.getInstance().onResLoaded(),b._fileDataCache[a]=b._stringConvertToArray(d)});c.send(null)},_loadBinaryFileData:function(a){var b=this._getXMLHttpRequest();b.open("GET",a,!1);var c=null;if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){b.setRequestHeader("Accept-Charset",
"x-user-defined");b.send(null);if(200!=b.status)return null;if(b=cc._convertResponseBodyToText(b.responseBody))c=this._stringConvertToArray(b),this._fileDataCache[a]=c}else{b.overrideMimeType&&b.overrideMimeType("text/plain; charset\x3dx-user-defined");b.send(null);if(200!=b.status)return null;c=this._stringConvertToArray(b.responseText);this._fileDataCache[a]=c}return c},_stringConvertToArray:function(a){if(!a)return null;for(var b=new Uint8Array(a.length),c=0;c<a.length;c++)b[c]=a.charCodeAt(c)&
255;return b},unloadTextFileData:function(a){this._textFileCache.hasOwnProperty(a)&&delete this._textFileCache[a]},preloadTextFileData:function(a){a=this.fullPathFromRelativePath(a);var b=this,c=this._getXMLHttpRequest();c.open("GET",a,!0);/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?(c.setRequestHeader("Accept-Charset","x-user-defined"),c.onreadystatechange=function(d){4==c.readyState&&(200==c.status&&(d=cc._convertResponseBodyToText(c.responseBody))&&(b._textFileCache[a]=
d),cc.Loader.getInstance().onResLoaded())}):(c.overrideMimeType&&c.overrideMimeType("text/plain; charset\x3dx-user-defined"),c.onload=function(d){c.responseText&&(cc.Loader.getInstance().onResLoaded(),b._fileDataCache[a]=c.responseText)});c.send(null)},_loadTextFileData:function(a){var b=this._getXMLHttpRequest();b.open("GET",a,!1);var c=null;if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){b.setRequestHeader("Accept-Charset","x-user-defined");b.send(null);if(200!=b.status)return null;
if(b=cc._convertResponseBodyToText(b.responseBody))c=b,this._textFileCache[a]=b}else{b.overrideMimeType&&b.overrideMimeType("text/plain; charset\x3dx-user-defined");b.send(null);if(200!=b.status)return null;c=b.responseText;this._textFileCache[a]=c}return c},getTextFileData:function(a){return this._textFileCache.hasOwnProperty(a)?this._textFileCache[a]:this._loadTextFileData(a)},getFileDataFromZip:function(a,b,c){},removeSuffixFromFile:function(a){},popupNotify:!0,fullPathFromRelativePath:function(a){return a},
fullPathForFilename:function(a){var b=!1;a=this._getNewFilename(a);var c;if(a&&1<a.length&&1==a.indexOf(":"))return a;for(var d=0;d<this._searchPathArray.length;d++){for(var e=this._searchPathArray[d],f=0;f<this._searchResolutionsOrderArray.length;f++)if(c=this._getPathForFilename(a,this._searchResolutionsOrderArray[f],e)){b=!0;break}if(b)break}return b?c:a},loadFilenameLookup:function(a){var b=this.fullPathForFilename(a);if(0<b.length){var b=cc.SAXParser.getInstance().parse(b),c=parseInt(b.metadata.version);
1!=c?cc.log("cocos2d: ERROR: Invalid filenameLookup dictionary version: "+c+". Filename: "+a):this.setFilenameLookupDictionary(b.filenames)}},setFilenameLookupDictionary:function(a){this._filenameLookupDict=a},fullPathFromRelativeFile:function(a,b){var c;if(a)return c=b.substring(0,b.lastIndexOf("/")+1),c+a;c=b.substring(0,b.lastIndexOf("."));return c+".png"},setSearchResolutionsOrder:function(a){this._searchResolutionsOrderArray=a},getSearchResolutionsOrder:function(){return this._searchResolutionsOrderArray},
setSearchPath:function(a){this._searchPathArray=a},getSearchPath:function(){return this._searchPathArray},getResourceDirectory:function(){return this._directory},setResourcePath:function(a){},dictionaryWithContentsOfFile:function(a){return this.rootDict=cc.SAXParser.getInstance().parse(a)},getStringFromFile:function(a){return cc.SAXParser.getInstance().getList(a)},dictionaryWithContentsOfFileThreadSafe:function(a){return(new cc.DictMaker).dictionaryWithContentsOfFile(a)},getWriteablePath:function(){return""},
setPopupNotify:function(a){cc.popupNotify=a},isPopupNotify:function(){return cc.popupNotify},_resourceRootPath:"",getResourceRootPath:function(){return this._resourceRootPath},setResourceRootPath:function(a){this._resourceRootPath=a},_getNewFilename:function(a){var b=null,b=this._filenameLookupDict?this._filenameLookupDict[a]:null;!b||0===b.length?b=a:cc.log("FOUND NEW FILE NAME: "+b);return b},_getPathForFilename:function(a,b,c){var d;d=this.getResourceRootPath();a&&0<a.length&&(0===a.indexOf("/")||
0===a.indexOf("\\"))?d="":0<d.length&&"\\"!=d[d.length-1]&&"/"!=d[d.length-1]&&(d+="/");var e=a,f="",g=a.lastIndexOf("/");-1!=g&&(f=a.substr(0,g+1),e=a.substr(g+1));a=c;0<a.length&&a.lastIndexOf("/")!==a.length-1&&(a+="/");a=a+f+b;0<a.length&&a.lastIndexOf("/")!==a.length-1&&(a+="/");a+=e;return d+=a}});cc.s_SharedFileUtils=null;cc.FileUtils.getInstance=function(){null==cc.s_SharedFileUtils&&(cc.s_SharedFileUtils=new cc.FileUtils);return cc.s_SharedFileUtils};
cc.DictMaker=cc.Class.extend({rootDict:[],dictionaryWithContentsOfFile:function(a){return this.rootDict=cc.SAXParser.getInstance().parse(a)}});cc.Color3B=function(a,b,c){switch(arguments.length){case 0:this.b=this.g=this.r=0;break;case 1:a&&a instanceof cc.Color3B?(this.r=0|a.r||0,this.g=0|a.g||0,this.b=0|a.b||0):this.b=this.g=this.r=0;break;case 3:this.r=0|a||0;this.g=0|b||0;this.b=0|c||0;break;default:throw"unknown argument type";}};cc.c3b=function(a,b,c){return new cc.Color3B(a,b,c)};cc.integerToColor3B=function(a){a=a||0;var b=new cc.Color3B;b.r=a&255;b.g=a>>8&255;b.b=a>>16&255;return b};cc.c3=cc.c3b;
Object.defineProperties(cc,{WHITE:{get:function(){return cc.c3b(255,255,255)}},YELLOW:{get:function(){return cc.c3b(255,255,0)}},BLUE:{get:function(){return cc.c3b(0,0,255)}},GREEN:{get:function(){return cc.c3b(0,255,0)}},RED:{get:function(){return cc.c3b(255,0,0)}},MAGENTA:{get:function(){return cc.c3b(255,0,255)}},BLACK:{get:function(){return cc.c3b(0,0,0)}},ORANGE:{get:function(){return cc.c3b(255,127,0)}},GRAY:{get:function(){return cc.c3b(166,166,166)}}});
cc.white=function(){return new cc.Color3B(255,255,255)};cc.yellow=function(){return new cc.Color3B(255,255,0)};cc.blue=function(){return new cc.Color3B(0,0,255)};cc.green=function(){return new cc.Color3B(0,255,0)};cc.red=function(){return new cc.Color3B(255,0,0)};cc.magenta=function(){return new cc.Color3B(255,0,255)};cc.black=function(){return new cc.Color3B(0,0,0)};cc.orange=function(){return new cc.Color3B(255,127,0)};cc.gray=function(){return new cc.Color3B(166,166,166)};
cc.Color4B=function(a,b,c,d){this.r=0|a;this.g=0|b;this.b=0|c;this.a=0|d};cc.c4b=function(a,b,c,d){return new cc.Color4B(a,b,c,d)};cc.c4=cc.c4b;cc.Color4F=function(a,b,c,d){this.r=a;this.g=b;this.b=c;this.a=d};cc.c4f=function(a,b,c,d){return new cc.Color4F(a,b,c,d)};cc.c4FFromccc3B=function(a){return new cc.Color4F(a.r/255,a.g/255,a.b/255,1)};cc.c4FFromccc4B=function(a){return new cc.Color4F(a.r/255,a.g/255,a.b/255,a.a/255)};
cc.c4BFromccc4F=function(a){return new cc.Color4B(0|255*a.r,0|255*a.g,0|255*a.b,0|255*a.a)};cc.c4FEqual=function(a,b){return a.r==b.r&&a.g==b.g&&a.b==b.b&&a.a==b.a};cc.Vertex2F=function(a,b){this.x=a||0;this.y=b||0};cc.Vertex2=function(a,b){return new cc.Vertex2F(a,b)};cc.Vertex3F=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};cc.vertex3=function(a,b,c){return new cc.Vertex3F(a,b,c)};cc.Tex2F=function(a,b){this.u=a||0;this.v=b||0};cc.tex2=function(a,b){return new cc.Tex2F(a,b)};
cc.PointSprite=function(a,b,c){this.pos=a||new cc.Vertex2F(0,0);this.color=b||new cc.Color4B(0,0,0,0);this.size=c||0};cc.Quad2=function(a,b,c,d){this.tl=a||new cc.Vertex2F(0,0);this.tr=b||new cc.Vertex2F(0,0);this.bl=c||new cc.Vertex2F(0,0);this.br=d||new cc.Vertex2F(0,0)};cc.Quad3=function(a,b,c,d){this.bl=a||new cc.Vertex3F(0,0,0);this.br=b||new cc.Vertex3F(0,0,0);this.tl=c||new cc.Vertex3F(0,0,0);this.tr=d||new cc.Vertex3F(0,0,0)};cc.GridSize=function(a,b){this.x=a;this.y=b};
cc.g=function(a,b){return new cc.GridSize(a,b)};cc.V2F_C4B_T2F=function(a,b,c){this.vertices=a||new cc.Vertex2F(0,0);this.colors=b||new cc.Color4B(0,0,0,0);this.texCoords=c||new cc.Tex2F(0,0)};cc.V2F_C4F_T2F=function(a,b,c){this.vertices=a||new cc.Vertex2F(0,0);this.colors=b||new cc.Color4F(0,0,0,0);this.texCoords=c||new cc.Tex2F(0,0)};cc.V3F_C4B_T2F=function(a,b,c){this.vertices=a||new cc.Vertex3F(0,0,0);this.colors=b||new cc.Color4B(0,0,0,0);this.texCoords=c||new cc.Tex2F(0,0)};
cc.V2F_C4B_T2F_Triangle=function(a,b,c){this.a=a||new cc.V2F_C4B_T2F;this.b=b||new cc.V2F_C4B_T2F;this.c=c||new cc.V2F_C4B_T2F};cc.V2F_C4B_T2F_Quad=function(a,b,c,d){this.bl=a||new cc.V2F_C4B_T2F;this.br=b||new cc.V2F_C4B_T2F;this.tl=c||new cc.V2F_C4B_T2F;this.tr=d||new cc.V2F_C4B_T2F};
cc.V2F_C4B_T2F_QuadZero=function(){return new cc.V2F_C4B_T2F_Quad(new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)))};
cc.V3F_C4B_T2F_Quad=function(a,b,c,d){this.tl=a||new cc.V3F_C4B_T2F;this.bl=b||new cc.V3F_C4B_T2F;this.tr=c||new cc.V3F_C4B_T2F;this.br=d||new cc.V3F_C4B_T2F};
cc.V3F_C4B_T2F_QuadZero=function(){return new cc.V3F_C4B_T2F_Quad(new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)))};
cc.V3F_C4B_T2F_QuadCopy=function(a){return!a?cc.V3F_C4B_T2F_QuadZero():new cc.V3F_C4B_T2F_Quad(new cc.V3F_C4B_T2F(new cc.Vertex3F(a.tl.vertices.x,a.tl.vertices.y,a.tl.vertices.z),new cc.Color4B(a.tl.colors.r,a.tl.colors.g,a.tl.colors.b,a.tl.colors.a),new cc.Tex2F(a.tl.texCoords.u,a.tl.texCoords.v)),new cc.V3F_C4B_T2F(new cc.Vertex3F(a.bl.vertices.x,a.bl.vertices.y,a.bl.vertices.z),new cc.Color4B(a.bl.colors.r,a.bl.colors.g,a.bl.colors.b,a.bl.colors.a),new cc.Tex2F(a.bl.texCoords.u,a.bl.texCoords.v)),
new cc.V3F_C4B_T2F(new cc.Vertex3F(a.tr.vertices.x,a.tr.vertices.y,a.tr.vertices.z),new cc.Color4B(a.tr.colors.r,a.tr.colors.g,a.tr.colors.b,a.tr.colors.a),new cc.Tex2F(a.tr.texCoords.u,a.tr.texCoords.v)),new cc.V3F_C4B_T2F(new cc.Vertex3F(a.br.vertices.x,a.br.vertices.y,a.br.vertices.z),new cc.Color4B(a.br.colors.r,a.br.colors.g,a.br.colors.b,a.br.colors.a),new cc.Tex2F(a.br.texCoords.u,a.br.texCoords.v)))};
cc.V3F_C4B_T2F_QuadsCopy=function(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++)b.push(cc.V3F_C4B_T2F_QuadCopy(a[c]));return b};cc.V2F_C4F_T2F_Quad=function(a,b,c,d){this.bl=a||new cc.V2F_C4F_T2F;this.br=b||new cc.V2F_C4F_T2F;this.tl=c||new cc.V2F_C4F_T2F;this.tr=d||new cc.V2F_C4F_T2F};cc.BlendFunc=function(a,b){this.src=a;this.dst=b};cc.BlendFuncDisable=function(){return new cc.BlendFunc(gl.ONE,gl.ZERO)};
cc.convertColor3BtoHexString=function(a){var b=a.r.toString(16),c=a.g.toString(16),d=a.b.toString(16);return"#"+(16>a.r?"0"+b:b)+(16>a.g?"0"+c:c)+(16>a.b?"0"+d:d)};
cc.Browser.supportWebGL&&(cc.Color4B=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Color4B.BYTES_PER_ELEMENT);this._offset=f||0;this._rU8=new Uint8Array(this._arrayBuffer,this._offset,1);this._gU8=new Uint8Array(this._arrayBuffer,this._offset+Uint8Array.BYTES_PER_ELEMENT,1);this._bU8=new Uint8Array(this._arrayBuffer,this._offset+2*Uint8Array.BYTES_PER_ELEMENT,1);this._aU8=new Uint8Array(this._arrayBuffer,this._offset+3*Uint8Array.BYTES_PER_ELEMENT,1);this._rU8[0]=a||0;this._gU8[0]=
b||0;this._bU8[0]=c||0;this._aU8[0]=d||0},cc.Color4B.BYTES_PER_ELEMENT=4,Object.defineProperties(cc.Color4B.prototype,{r:{get:function(){return this._rU8[0]},set:function(a){this._rU8[0]=a},enumerable:!0},g:{get:function(){return this._gU8[0]},set:function(a){this._gU8[0]=a},enumerable:!0},b:{get:function(){return this._bU8[0]},set:function(a){this._bU8[0]=a},enumerable:!0},a:{get:function(){return this._aU8[0]},set:function(a){this._aU8[0]=a},enumerable:!0}}),cc.Color4F=function(a,b,c,d,e,f){this._arrayBuffer=
e||new ArrayBuffer(cc.Color4F.BYTES_PER_ELEMENT);this._offset=f||0;this._rF32=new Float32Array(this._arrayBuffer,this._offset,1);this._rF32[0]=a||0;this._gF32=new Float32Array(this._arrayBuffer,this._offset+Float32Array.BYTES_PER_ELEMENT,1);this._gF32[0]=b||0;this._bF32=new Float32Array(this._arrayBuffer,this._offset+2*Float32Array.BYTES_PER_ELEMENT,1);this._bF32[0]=c||0;this._aF32=new Float32Array(this._arrayBuffer,this._offset+3*Float32Array.BYTES_PER_ELEMENT,1);this._aF32[0]=d||0},cc.Color4F.BYTES_PER_ELEMENT=
16,Object.defineProperties(cc.Color4F.prototype,{r:{get:function(){return this._rF32[0]},set:function(a){this._rF32[0]=a},enumerable:!0},g:{get:function(){return this._gF32[0]},set:function(a){this._gF32[0]=a},enumerable:!0},b:{get:function(){return this._bF32[0]},set:function(a){this._bF32[0]=a},enumerable:!0},a:{get:function(){return this._aF32[0]},set:function(a){this._aF32[0]=a},enumerable:!0}}),cc.Vertex2F=function(a,b,c,d){this._arrayBuffer=c||new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);
this._offset=d||0;this._xF32=new Float32Array(this._arrayBuffer,this._offset,1);this._yF32=new Float32Array(this._arrayBuffer,this._offset+4,1);this._xF32[0]=a||0;this._yF32[0]=b||0},cc.Vertex2F.BYTES_PER_ELEMENT=8,Object.defineProperties(cc.Vertex2F.prototype,{x:{get:function(){return this._xF32[0]},set:function(a){this._xF32[0]=a},enumerable:!0},y:{get:function(){return this._yF32[0]},set:function(a){this._yF32[0]=a},enumerable:!0}}),cc.Vertex3F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);
this._offset=e||0;this._xF32=new Float32Array(this._arrayBuffer,this._offset,1);this._xF32[0]=a||0;this._yF32=new Float32Array(this._arrayBuffer,this._offset+Float32Array.BYTES_PER_ELEMENT,1);this._yF32[0]=b||0;this._zF32=new Float32Array(this._arrayBuffer,this._offset+2*Float32Array.BYTES_PER_ELEMENT,1);this._zF32[0]=c||0},cc.Vertex3F.BYTES_PER_ELEMENT=12,Object.defineProperties(cc.Vertex3F.prototype,{x:{get:function(){return this._xF32[0]},set:function(a){this._xF32[0]=a},enumerable:!0},y:{get:function(){return this._yF32[0]},
set:function(a){this._yF32[0]=a},enumerable:!0},z:{get:function(){return this._zF32[0]},set:function(a){this._zF32[0]=a},enumerable:!0}}),cc.Tex2F=function(a,b,c,d){this._arrayBuffer=c||new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);this._offset=d||0;this._uF32=new Float32Array(this._arrayBuffer,this._offset,1);this._vF32=new Float32Array(this._arrayBuffer,this._offset+4,1);this._uF32[0]=a||0;this._vF32[0]=b||0},cc.Tex2F.BYTES_PER_ELEMENT=8,Object.defineProperties(cc.Tex2F.prototype,{u:{get:function(){return this._uF32[0]},
set:function(a){this._uF32[0]=a},enumerable:!0},v:{get:function(){return this._vF32[0]},set:function(a){this._vF32[0]=a},enumerable:!0}}),cc.Quad2=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);this._offset=f||0;this._tl=a?new cc.Vertex2F(a.x,a.y,this._arrayBuffer,0):new cc.Vertex2F(0,0,this._arrayBuffer,0);this._tr=b?new cc.Vertex2F(b.x,b.y,this._arrayBuffer,cc.Vertex2F.BYTES_PER_ELEMENT):new cc.Vertex2F(0,0,this._arrayBuffer,cc.Vertex2F.BYTES_PER_ELEMENT);
this._bl=c?new cc.Vertex2F(c.x,c.y,this._arrayBuffer,2*cc.Vertex2F.BYTES_PER_ELEMENT):new cc.Vertex2F(0,0,this._arrayBuffer,2*cc.Vertex2F.BYTES_PER_ELEMENT);this._br=d?new cc.Vertex2F(d.x,d.y,this._arrayBuffer,3*cc.Vertex2F.BYTES_PER_ELEMENT):new cc.Vertex2F(0,0,this._arrayBuffer,3*cc.Vertex2F.BYTES_PER_ELEMENT)},cc.Quad2.BYTES_PER_ELEMENT=32,Object.defineProperties(cc.Quad2.prototype,{tl:{get:function(){return this._tl},set:function(a){this._tl.x=a.x;this._tl.y=a.y},enumerable:!0},tr:{get:function(){return this._tr},
set:function(a){this._tr.x=a.x;this._tr.y=a.y},enumerable:!0},bl:{get:function(){return this._bl},set:function(a){this._bl.x=a.x;this._bl.y=a.y},enumerable:!0},br:{get:function(){return this._br},set:function(a){this._br.x=a.x;this._br.y=a.y},enumerable:!0}}),cc.V3F_C4B_T2F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);this._offset=e||0;this._vertices=a?new cc.Vertex3F(a.x,a.y,a.z,this._arrayBuffer,this._offset):new cc.Vertex3F(0,0,0,this._arrayBuffer,
this._offset);this._colors=b?new cc.Color4B(b.r,b.g,b.b,b.a,this._arrayBuffer,this._offset+cc.Vertex3F.BYTES_PER_ELEMENT):new cc.Color4B(0,0,0,0,this._arrayBuffer,this._offset+cc.Vertex3F.BYTES_PER_ELEMENT);this._texCoords=c?new cc.Tex2F(c.u,c.v,this._arrayBuffer,this._offset+cc.Vertex3F.BYTES_PER_ELEMENT+cc.Color4B.BYTES_PER_ELEMENT):new cc.Tex2F(0,0,this._arrayBuffer,this._offset+cc.Vertex3F.BYTES_PER_ELEMENT+cc.Color4B.BYTES_PER_ELEMENT)},cc.V3F_C4B_T2F.BYTES_PER_ELEMENT=24,Object.defineProperties(cc.V3F_C4B_T2F.prototype,
{vertices:{get:function(){return this._vertices},set:function(a){this._vertices.x=a.x;this._vertices.y=a.y;this._vertices.z=a.z},enumerable:!0},colors:{get:function(){return this._colors},set:function(a){this._colors.r=a.r;this._colors.g=a.g;this._colors.b=a.b;this._colors.a=a.a},enumerable:!0},texCoords:{get:function(){return this._texCoords},set:function(a){this._texCoords.u=a.u;this._texCoords.v=a.v},enumerable:!0}}),cc.V3F_C4B_T2F_Quad=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);
this._offset=f||0;this._tl=a?new cc.V3F_C4B_T2F(a.vertices,a.colors,a.texCoords,this._arrayBuffer,this._offset):new cc.V3F_C4B_T2F(null,null,null,this._arrayBuffer,this._offset);this._bl=b?new cc.V3F_C4B_T2F(b.vertices,b.colors,b.texCoords,this._arrayBuffer,this._offset+cc.V3F_C4B_T2F.BYTES_PER_ELEMENT):new cc.V3F_C4B_T2F(null,null,null,this._arrayBuffer,this._offset+cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);this._tr=c?new cc.V3F_C4B_T2F(c.vertices,c.colors,c.texCoords,this._arrayBuffer,this._offset+2*cc.V3F_C4B_T2F.BYTES_PER_ELEMENT):
new cc.V3F_C4B_T2F(null,null,null,this._arrayBuffer,this._offset+2*cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);this._br=d?new cc.V3F_C4B_T2F(d.vertices,d.colors,d.texCoords,this._arrayBuffer,this._offset+3*cc.V3F_C4B_T2F.BYTES_PER_ELEMENT):new cc.V3F_C4B_T2F(null,null,null,this._arrayBuffer,this._offset+3*cc.V3F_C4B_T2F.BYTES_PER_ELEMENT)},cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT=96,Object.defineProperties(cc.V3F_C4B_T2F_Quad.prototype,{tl:{get:function(){return this._tl},set:function(a){this._tl.vertices=a.vertices;
this._tl.colors=a.colors;this._tl.texCoords=a.texCoords},enumerable:!0},bl:{get:function(){return this._bl},set:function(a){this._bl.vertices=a.vertices;this._bl.colors=a.colors;this._bl.texCoords=a.texCoords},enumerable:!0},tr:{get:function(){return this._tr},set:function(a){this._tr.vertices=a.vertices;this._tr.colors=a.colors;this._tr.texCoords=a.texCoords},enumerable:!0},br:{get:function(){return this._br},set:function(a){this._br.vertices=a.vertices;this._br.colors=a.colors;this._br.texCoords=
a.texCoords},enumerable:!0},arrayBuffer:{get:function(){return this._arrayBuffer},enumerable:!0}}),cc.V3F_C4B_T2F_QuadZero=function(){return new cc.V3F_C4B_T2F_Quad},cc.V2F_C4B_T2F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);this._offset=e||0;this._vertices=a?new cc.Vertex2F(a.x,a.y,this._arrayBuffer,this._offset):new cc.Vertex2F(0,0,this._arrayBuffer,this._offset);this._colors=b?new cc.Color4B(b.r,b.g,b.b,b.a,this._arrayBuffer,this._offset+cc.Vertex2F.BYTES_PER_ELEMENT):
new cc.Color4B(0,0,0,0,this._arrayBuffer,this._offset+cc.Vertex2F.BYTES_PER_ELEMENT);this._texCoords=c?new cc.Tex2F(c.u,c.v,this._arrayBuffer,this._offset+cc.Vertex2F.BYTES_PER_ELEMENT+cc.Color4B.BYTES_PER_ELEMENT):new cc.Tex2F(0,0,this._arrayBuffer,this._offset+cc.Vertex2F.BYTES_PER_ELEMENT+cc.Color4B.BYTES_PER_ELEMENT)},cc.V2F_C4B_T2F.BYTES_PER_ELEMENT=20,Object.defineProperties(cc.V2F_C4B_T2F.prototype,{vertices:{get:function(){return this._vertices},set:function(a){this._vertices.x=a.x;this._vertices.y=
a.y},enumerable:!0},colors:{get:function(){return this._colors},set:function(a){this._colors.r=a.r;this._colors.g=a.g;this._colors.b=a.b;this._colors.a=a.a},enumerable:!0},texCoords:{get:function(){return this._texCoords},set:function(a){this._texCoords.u=a.u;this._texCoords.v=a.v},enumerable:!0}}),cc.V2F_C4B_T2F_Triangle=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);this._offset=e||0;this._a=a?new cc.V2F_C4B_T2F(a.vertices,a.colors,a.texCoords,
this._arrayBuffer,this._offset):new cc.V2F_C4B_T2F(null,null,null,this._arrayBuffer,this._offset);this._b=b?new cc.V2F_C4B_T2F(b.vertices,b.colors,b.texCoords,this._arrayBuffer,this._offset+cc.V2F_C4B_T2F.BYTES_PER_ELEMENT):new cc.V2F_C4B_T2F(null,null,null,this._arrayBuffer,this._offset+cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);this._c=c?new cc.V2F_C4B_T2F(c.vertices,c.colors,c.texCoords,this._arrayBuffer,this._offset+2*cc.V2F_C4B_T2F.BYTES_PER_ELEMENT):new cc.V2F_C4B_T2F(null,null,null,this._arrayBuffer,
this._offset+2*cc.V2F_C4B_T2F.BYTES_PER_ELEMENT)},cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT=60,Object.defineProperties(cc.V2F_C4B_T2F_Triangle.prototype,{a:{get:function(){return this._a},set:function(a){this._a.vertices=a.vertices;this._a.colors=a.colors;this._a.texCoords=a.texCoords},enumerable:!0},b:{get:function(){return this._b},set:function(a){this._b.vertices=a.vertices;this._b.colors=a.colors;this._b.texCoords=a.texCoords},enumerable:!0},c:{get:function(){return this._c},set:function(a){this._c.vertices=
a.vertices;this._c.colors=a.colors;this._c.texCoords=a.texCoords},enumerable:!0}}));cc.convertHexNumToColor3B=function(a){var b=a.substr(1).split("");a=parseInt("0x"+b[0]+b[1]);var c=parseInt("0x"+b[2]+b[3]),b=parseInt("0x"+b[4]+b[5]);return new cc.Color3B(a,c,b)};cc.TEXT_ALIGNMENT_LEFT=0;cc.TEXT_ALIGNMENT_CENTER=1;cc.TEXT_ALIGNMENT_RIGHT=2;cc.VERTICAL_TEXT_ALIGNMENT_TOP=0;cc.VERTICAL_TEXT_ALIGNMENT_CENTER=1;cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM=2;
cc._Dictionary=cc.Class.extend({_keyMapTb:null,_valueMapTb:null,__currId:0,ctor:function(){this._keyMapTb={};this._valueMapTb={};this.__currId=2<<(0|10*Math.random())},__getKey:function(){this.__currId++;return"key_"+this.__currId},setObject:function(a,b){if(null!=b){var c=this.__getKey();this._keyMapTb[c]=b;this._valueMapTb[c]=a}},objectForKey:function(a){if(null==a)return null;for(var b in this._keyMapTb)if(this._keyMapTb[b]===a)return this._valueMapTb[b];return null},valueForKey:function(a){return this.objectForKey(a)},
removeObjectForKey:function(a){if(null!=a)for(var b in this._keyMapTb)if(this._keyMapTb[b]===a){delete this._valueMapTb[b];delete this._keyMapTb[b];break}},removeObjectsForKeys:function(a){if(null!=a)for(var b=0;b<a.length;b++)this.removeObjectForKey(a[b])},allKeys:function(){var a=[],b;for(b in this._keyMapTb)a.push(this._keyMapTb[b]);return a},removeAllObjects:function(){this._keyMapTb={};this._valueMapTb={}},count:function(){return this.allKeys().length}});cc.UIInterfaceOrientationLandscapeLeft=-90;cc.UIInterfaceOrientationLandscapeRight=90;cc.UIInterfaceOrientationPortraitUpsideDown=180;cc.UIInterfaceOrientationPortrait=0;cc.Acceleration=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.timestamp=d||0};cc.Accelerometer=cc.Class.extend({setDelegate:function(a){cc.AccelerometerDispatcher.getInstance().addDelegate(a)},setAccelerometerInterval:function(a){cc.AccelerometerDispatcher.getInstance().setAccelerometerInterval(a)}});
cc.AccelerometerDispatcher=cc.Class.extend({_delegate:null,_acceleration:null,_deviceEvent:null,_interval:0.1,_minus:1,init:function(){this._acceleration=new cc.Acceleration;this._deviceEvent=window.DeviceMotionEvent||window.DeviceOrientationEvent;/Android/.test(navigator.userAgent)&&(this._minus=-1);return!0},getDelegate:function(){return this._delegate},addDelegate:function(a){this._delegate=a;a=this.didAccelerate.bind(this);this._delegate?this._deviceEvent==window.DeviceMotionEvent?window.addEventListener("devicemotion",
a,!1):window.addEventListener("deviceorientation",a,!1):this._deviceEvent==window.DeviceMotionEvent?window.removeEventListener("devicemotion",a):window.removeEventListener("deviceorientation",a)},setAccelerometerInterval:function(a){this._interval!==a&&(this._interval=a)},didAccelerate:function(a){if(this._delegate){this._deviceEvent==window.DeviceMotionEvent?(a=a.accelerationIncludingGravity,this._acceleration.x=0.1*this._minus*a.x,this._acceleration.y=0.1*this._minus*a.y,this._acceleration.z=0.1*
a.z):(this._acceleration.x=0.981*(a.gamma/90),this._acceleration.y=0.981*-(a.beta/90),this._acceleration.z=0.981*(a.alpha/90));this._acceleration.timestamp=(new Date).getTime();a=this._acceleration.x;switch(window.orientation){case cc.UIInterfaceOrientationLandscapeRight:this._acceleration.x=-this._acceleration.y;this._acceleration.y=a;break;case cc.UIInterfaceOrientationLandscapeLeft:this._acceleration.x=this._acceleration.y;this._acceleration.y=-a;break;case cc.UIInterfaceOrientationPortraitUpsideDown:this._acceleration.x=
-this._acceleration.x,this._acceleration.y=-this._acceleration.y}this._delegate.onAccelerometer(this._acceleration)}}});cc.AccelerometerDispatcher.getInstance=function(){this._instance||(this._instance=new cc.AccelerometerDispatcher,this._instance.init());return this._instance};cc.RESOLUTION_POLICY={EXACTFIT:0,NOBORDER:1,SHOW_ALL:2,UNKNOWN:3};cc.Touches=[];cc.TouchesIntergerDict={};
cc.EGLView=cc.Class.extend({_delegate:null,_screenSize:null,_designResolutionSize:null,_viewPortRect:null,_viewName:"",_scaleX:1,_scaleY:1,_indexBitsUsed:0,_maxTouches:5,_resolutionPolicy:cc.RESOLUTION_POLICY.UNKNOWN,_initialize:!1,_captured:!1,_wnd:null,_hDC:null,_hRC:null,_accelerometerKeyHook:null,_supportTouch:!1,_contentTranslateLeftTop:null,_menu:null,_wndProc:null,_frameZoomFactor:1,ctor:function(){this._viewName="Cocos2dHTML5";this._screenSize=cc.SizeZero();this._designResolutionSize=cc.SizeZero();
this._viewPortRect=cc.RectZero();this._delegate=cc.Director.getInstance().getTouchDispatcher();this._contentTranslateLeftTop={left:0,top:0};this._hDC=cc.canvas;this._hRC=cc.renderContext},initialize:function(){this._initialize=!0;this._adjustSize();var a=this._adjustSize.bind(this);window.addEventListener("resize",a,!1)},_adjustSize:function(){var a=cc.container.parentNode===document.body?document.documentElement:cc.container.parentNode;cc.canvas.width=a.clientWidth;cc.canvas.height=a.clientHeight;
"opengl"in sys.capabilities||cc.renderContext.translate(0,cc.canvas.height);if(a=document.querySelector("#"+document.ccConfig.tag).parentNode)a.style.width=cc.canvas.width+"px",a.style.height=cc.canvas.height+"px";if(a=document.body)a.style.padding="0px",a.style.border="0px",a.style.margin="0px";this._screenSize=cc.size(cc.canvas.width,cc.canvas.height);this.setDesignResolutionSize()},_adjustSizeKeepCanvasSize:function(){"opengl"in sys.capabilities||cc.renderContext.translate(0,cc.canvas.height);
this._screenSize=cc.size(cc.canvas.width,cc.canvas.height);this.setDesignResolutionSize()},end:function(){},isOpenGLReady:function(){return null!=this._hDC&&null!=this._hRC},setFrameZoomFactor:function(a){this._frameZoomFactor=a;this.centerWindow();cc.Director.getInstance().setProjection(cc.Director.getInstance().getProjection())},swapBuffers:function(){},setIMEKeyboardState:function(a){},setContentScaleFactor:function(a){cc.Assert(this._resolutionPolicy==cc.RESOLUTION_POLICY.UNKNOWN);this._scaleX=
this._scaleY=a;return!0},setContentTranslateLeftTop:function(a,b){this._contentTranslateLeftTop={left:a,top:b}},getContentTranslateLeftTop:function(){return this._contentTranslateLeftTop},getFrameSize:function(){return this._screenSize},setFrameSize:function(a,b){this._designResolutionSize=this._screenSize=cc.size(a,b);this.centerWindow();cc.Director.getInstance().setProjection(cc.Director.getInstance().getProjection())},centerWindow:function(){},setAccelerometerKeyHook:function(a){this._accelerometerKeyHook=
a},getVisibleSize:function(){return this._resolutionPolicy===cc.RESOLUTION_POLICY.NOBORDER?cc.size(this._screenSize.width/this._scaleX,this._screenSize.height/this._scaleY):this._designResolutionSize},getVisibleOrigin:function(){return this._resolutionPolicy===cc.RESOLUTION_POLICY.NOBORDER?cc.p((this._designResolutionSize.width-this._screenSize.width/this._scaleX)/2,(this._designResolutionSize.height-this._screenSize.height/this._scaleY)/2):cc.p(0,0)},canSetContentScaleFactor:function(){return!0},
setDesignResolutionSize:function(a,b,c){cc.Assert(c!==cc.RESOLUTION_POLICY.UNKNOWN,"should set resolutionPolicy");this._initialize||this.initialize();if(!(0==a||0==b)){null!=a&&null!=b&&(this._designResolutionSize=cc.size(a,b));null!=c&&(this._resolutionPolicy=c);this._scaleX=this._screenSize.width/this._designResolutionSize.width;this._scaleY=this._screenSize.height/this._designResolutionSize.height;this._resolutionPolicy===cc.RESOLUTION_POLICY.NOBORDER&&(this._scaleX=this._scaleY=Math.max(this._scaleX,
this._scaleY));this._resolutionPolicy===cc.RESOLUTION_POLICY.SHOW_ALL&&(this._scaleX=this._scaleY=Math.min(this._scaleX,this._scaleY));c=this._designResolutionSize.width*this._scaleX;var d=this._designResolutionSize.height*this._scaleY;this._viewPortRect=cc.rect((this._screenSize.width-c)/2,(this._screenSize.height-d)/2,c,d);cc.Director.getInstance()._winSizeInPoints=this.getDesignResolutionSize();if(cc.renderContextType===cc.CANVAS){b=a=0;if(this._resolutionPolicy===cc.RESOLUTION_POLICY.SHOW_ALL){a=
(this._screenSize.width-c)/2;b=-(this._screenSize.height-d)/2;var e=cc.renderContext;e.beginPath();e.rect(a,-d+b,c,d);e.clip();e.closePath()}cc.renderContext.translate(a,b);cc.renderContext.scale(this._scaleX,this._scaleY)}else cc.Director.getInstance()._createStatsLabel(),cc.Director.getInstance().setGLDefaultValues()}},getDesignResolutionSize:function(){return this._designResolutionSize},setTouchDelegate:function(a){this._delegate=a},setViewPortInPoints:function(a,b,c,d){cc.renderContext.viewport(a*
this._scaleX*this._frameZoomFactor+this._viewPortRect.origin.x*this._frameZoomFactor,b*this._scaleY*this._frameZoomFactor+this._viewPortRect.origin.y*this._frameZoomFactor,c*this._scaleX*this._frameZoomFactor,d*this._scaleY*this._frameZoomFactor)},setScissorInPoints:function(a,b,c,d){cc.renderContext.scissor(a*this._scaleX*this._frameZoomFactor+this._viewPortRect.origin.x*this._frameZoomFactor,b*this._scaleY*this._frameZoomFactor+this._viewPortRect.origin.y*this._frameZoomFactor,c*this._scaleX*this._frameZoomFactor,
d*this._scaleY*this._frameZoomFactor)},setViewName:function(a){null!=a&&0<a.length&&(this._viewName=a)},getViewName:function(){return this._viewName},getViewPortRect:function(){return this._viewPortRect},getScaleX:function(){return this._scaleX},getScaleY:function(){return this._scaleY},convertToLocationInView:function(a,b,c){return{x:a-c.left,y:c.top+c.height-b}},handleTouchesBegin:function(a,b,c,d){for(var e=[],f=0;f<a;++f){var g=b[f],h=c[f],k=d[f],l=0;if(null==cc.TouchesIntergerDict[g])if(l=this._getUnUsedIndex(),
-1==l)cc.log("The touches is more than MAX_TOUCHES, nUnusedIndex \x3d "+l);else{var m=cc.Touches[l]=new cc.Touch;m.setTouchInfo(l,(h-this._viewPortRect.origin.x)/this._scaleX,(k-this._viewPortRect.origin.y)/this._scaleY);cc.TouchesIntergerDict[g]=0|l;e.push(m)}}0!=e.length&&this._delegate.touchesBegan(e,null)},handleTouchesMove:function(a,b,c,d){for(var e=[],f=0;f<a;++f){var g=c[f],h=d[f],k=cc.TouchesIntergerDict[b[f]];if(null!=k){var l=cc.Touches[k];if(l)l.setTouchInfo(k,(g-this._viewPortRect.origin.x)/
this._scaleX,(h-this._viewPortRect.origin.y)/this._scaleY),e.push(l);else return}}0!=e.length&&this._delegate.touchesMoved(e,null)},handleTouchesEnd:function(a,b,c,d){var e=[];this.getSetOfTouchesEndOrCancel(e,a,b,c,d);this._delegate.touchesEnded(e,null)},handleTouchesCancel:function(a,b,c,d){var e=[];this.getSetOfTouchesEndOrCancel(e,a,b,c,d);this._delegate.touchesCancelled(e,null)},getSetOfTouchesEndOrCancel:function(a,b,c,d,e){for(var f=0;f<b;++f){var g=c[f],h=d[f],k=e[f],l=cc.TouchesIntergerDict[g];
if(null!=l){var m=cc.Touches[l];if(m)m.setTouchInfo(l,(h-this._viewPortRect.origin.x)/this._scaleX,(k-this._viewPortRect.origin.y)/this._scaleY),a.push(m),cc.Touches[l]=null,this._removeUsedIndexBit(l),delete cc.TouchesIntergerDict[g];else break}}},_getUnUsedIndex:function(){var a,b=this._indexBitsUsed;for(a=0;a<this._maxTouches;a++){if(!(b&1))return this._indexBitsUsed|=1<<a,a;b>>=1}return-1},_removeUsedIndexBit:function(a){0>a||a>=this._maxTouches||(a=~(1<<a),this._indexBitsUsed&=a)},touchesBegan:function(a,
b){for(var c=[],d=[],e=[],f=0,g=0;g<a.length;g++)c[f]=g,d[f]=a[g].getLocation().x,e[f]=a[g].getLocation().y,++f;this.handleTouchesBegin(f,c,d,e)},touchesMoved:function(a,b){for(var c=[],d=[],e=[],f=0,g=0;g<a.length;g++)c[f]=g,d[f]=a[g].getLocation().x,e[f]=a[g].getLocation().y,++f;this.handleTouchesMove(f,c,d,e)},touchesEnded:function(a,b){for(var c=[],d=[],e=[],f=0,g=0;g<a.length;g++)c[f]=g,d[f]=a[g].getLocation().x,e[f]=a[g].getLocation().y,++f;this.handleTouchesEnd(f,c,d,e)},touchesCancelled:function(a,
b){for(var c=[],d=[],e=[],f=0,g=0;g<a.length;g++)c[f]=g,d[f]=a[g].getLocation().x,e[f]=a[g].getLocation().y,++f;this.handleTouchesCancel(f,c,d,e)}});cc.EGLView.getInstance=function(){this._instance||(this._instance=new cc.EGLView);return this._instance};cc.FMT_JPG=0;cc.FMT_PNG=1;cc.FMT_TIFF=2;cc.FMT_RAWDATA=3;cc.FMT_UNKNOWN=4;cc.ALIGN_CENTER=51;cc.ALIGN_TOP=19;cc.ALIGN_TOP_RIGHT=18;cc.ALIGN_RIGHT=50;cc.ALIGN_BOTTOM_RIGHT=34;cc.ALIGN_BOTTOM=35;cc.ALIGN_BOTTOM_LEFT=33;cc.ALIGN_LEFT=49;cc.ALIGN_TOP_LEFT=17;cc.RGB_PREMULTIPLY_APLHA=function(a,b,c,d){return a*(d+1)>>8|b*(d+1)>>8<<8|c*(d+1)>>8<<16|d<<24};cc.tImageSource=function(a,b,c){this.data=a;this.size=b||0;this.offset=c||0};
cc.pngReadCallback=function(a,b,c){var d=new cc.tImageSource,d=cc.png_get_io_ptr(a);d.offset+c<=d.size?(cc.memcpy(b,d.data+d.offset,c),d.offset+=c):cc.png_error(a,"pngReaderCallback failed")};cc.getImageFormatByData=function(a){return 8<a.length&&137==a[0]&&80==a[1]&&78==a[2]&&71==a[3]&&13==a[4]&&10==a[5]&&26==a[6]&&10==a[7]?cc.FMT_PNG:2<a.length&&(73==a[0]&&73==a[1]||77==a[0]&&77==a[1]||255==a[0]&&216==a[1])?cc.FMT_TIFF:cc.FMT_UNKNOWN};
cc.Image=cc.Class.extend({_width:0,_height:0,_bitsPerComponent:0,_data:0,_hasAlpha:!1,_preMulti:!1,initWithImageFile:function(a,b){var c=cc.FileUtils.getInstance().getFileData(a,"rb");return null!=c&&0<c.length?this.initWithImageData(c,c.length,b):!1},initWithImageFileThreadSafe:function(a,b){return this.initWithImageFile(a,b)},initWithImageData:function(a,b,c,d,e,f){f=f||8;d=d||0;e=e||0;c=c||cc.FMT_UNKNOWN;return!a||0>=b?!1:cc.FMT_PNG==c?this._initWithPngData(a,b):cc.FMT_JPG==c?this._initWithJpgData(a,
b):cc.FMT_TIFF==c?this._initWithTiffData(a,b):cc.FMT_RAWDATA==c?this._initWithRawData(a,b,d,e,f):8<b&&137==a[0]&&80==a[1]&&78==a[2]&&71==a[3]&&13==a[4]&&10==a[5]&&26==a[6]&&10==a[7]?this._initWithPngData(a,b):2<b&&(73==a[0]&&73==a[1]||77==a[0]&&77==a[1]||255==a[0]&&216==a[1])?this._initWithTiffData(a,b):!1},getData:function(){return this._data},getDataLen:function(){return this._width*this._height},hasAlpha:function(){return this._hasAlpha},isPremultipliedAlpha:function(){return this._preMulti},getWidth:function(){return this._width},
getHeight:function(){return this._height},getBitsPerComponent:function(){return this._bitsPerComponent},saveToFile:function(a,b){cc.log("doesn't support saveToFile on Cocos2d-Html5");return!1},_initWithJpgData:function(a,b){return!1},_initWithPngData:function(a,b){return!1},_initWithTiffData:function(a,b){return!1},_initWithRawData:function(a,b,c,d,e){return!1},_saveImageToPNG:function(a,b){return!1},_saveImageToJPG:function(a){return!1},initWithString:function(a,b,c,d,e,f){return!1}});/*
zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
(function(){function a(a){throw a;}function b(a,b){var c=a.split("."),d=y;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&b!==C?d[e]=b:d=d[e]?d[e]:d[e]={}}function c(a){if("string"===typeof a){a=a.split("");var b,c;b=0;for(c=a.length;b<c;b++)a[b]=(a[b].charCodeAt(0)&255)>>>0}b=1;c=0;for(var d=a.length,e,f=0;0<d;){e=1024<d?1024:d;d-=e;do b+=a[f++],c+=b;while(--e);b%=65521;c%=65521}return(c<<16|b)>>>0}function d(b,c){this.index="number"===typeof c?
c:0;this.i=0;this.buffer=b instanceof(w?Uint8Array:Array)?b:new (w?Uint8Array:Array)(32768);2*this.buffer.length<=this.index&&a(Error("invalid index"));this.buffer.length<=this.index&&this.f()}function e(a){this.buffer=new (w?Uint16Array:Array)(2*a);this.length=0}function f(a){var b=a.length,c=0,d=Number.POSITIVE_INFINITY,e,f,g,h,k,l,m,n,q;for(n=0;n<b;++n)a[n]>c&&(c=a[n]),a[n]<d&&(d=a[n]);e=1<<c;f=new (w?Uint32Array:Array)(e);g=1;h=0;for(k=2;g<=c;){for(n=0;n<b;++n)if(a[n]===g){l=0;m=h;for(q=0;q<g;++q)l=
l<<1|m&1,m>>=1;for(q=l;q<e;q+=k)f[q]=g<<16|n;++h}++g;h<<=1;k<<=1}return[f,c,d]}function g(a,b){this.h=I;this.w=0;this.input=a;this.b=0;b&&(b.lazy&&(this.w=b.lazy),"number"===typeof b.compressionType&&(this.h=b.compressionType),b.outputBuffer&&(this.a=w&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"===typeof b.outputIndex&&(this.b=b.outputIndex));this.a||(this.a=new (w?Uint8Array:Array)(32768))}function h(a,b){this.length=a;this.G=b}function k(){var b=J;switch(D){case 3===
b:return[257,b-3,0];case 4===b:return[258,b-4,0];case 5===b:return[259,b-5,0];case 6===b:return[260,b-6,0];case 7===b:return[261,b-7,0];case 8===b:return[262,b-8,0];case 9===b:return[263,b-9,0];case 10===b:return[264,b-10,0];case 12>=b:return[265,b-11,1];case 14>=b:return[266,b-13,1];case 16>=b:return[267,b-15,1];case 18>=b:return[268,b-17,1];case 22>=b:return[269,b-19,2];case 26>=b:return[270,b-23,2];case 30>=b:return[271,b-27,2];case 34>=b:return[272,b-31,2];case 42>=b:return[273,b-35,3];case 50>=
b:return[274,b-43,3];case 58>=b:return[275,b-51,3];case 66>=b:return[276,b-59,3];case 82>=b:return[277,b-67,4];case 98>=b:return[278,b-83,4];case 114>=b:return[279,b-99,4];case 130>=b:return[280,b-115,4];case 162>=b:return[281,b-131,5];case 194>=b:return[282,b-163,5];case 226>=b:return[283,b-195,5];case 257>=b:return[284,b-227,5];case 258===b:return[285,b-258,0];default:a("invalid length: "+b)}}function l(b,c){function d(b,c){var e=b.G,f=[],g=0,h;h=L[b.length];f[g++]=h&65535;f[g++]=h>>16&255;f[g++]=
h>>24;var k;switch(D){case 1===e:k=[0,e-1,0];break;case 2===e:k=[1,e-2,0];break;case 3===e:k=[2,e-3,0];break;case 4===e:k=[3,e-4,0];break;case 6>=e:k=[4,e-5,1];break;case 8>=e:k=[5,e-7,1];break;case 12>=e:k=[6,e-9,2];break;case 16>=e:k=[7,e-13,2];break;case 24>=e:k=[8,e-17,3];break;case 32>=e:k=[9,e-25,3];break;case 48>=e:k=[10,e-33,4];break;case 64>=e:k=[11,e-49,4];break;case 96>=e:k=[12,e-65,5];break;case 128>=e:k=[13,e-97,5];break;case 192>=e:k=[14,e-129,6];break;case 256>=e:k=[15,e-193,6];break;
case 384>=e:k=[16,e-257,7];break;case 512>=e:k=[17,e-385,7];break;case 768>=e:k=[18,e-513,8];break;case 1024>=e:k=[19,e-769,8];break;case 1536>=e:k=[20,e-1025,9];break;case 2048>=e:k=[21,e-1537,9];break;case 3072>=e:k=[22,e-2049,10];break;case 4096>=e:k=[23,e-3073,10];break;case 6144>=e:k=[24,e-4097,11];break;case 8192>=e:k=[25,e-6145,11];break;case 12288>=e:k=[26,e-8193,12];break;case 16384>=e:k=[27,e-12289,12];break;case 24576>=e:k=[28,e-16385,13];break;case 32768>=e:k=[29,e-24577,13];break;default:a("invalid distance")}h=
k;f[g++]=h[0];f[g++]=h[1];f[g++]=h[2];e=0;for(g=f.length;e<g;++e)q[u++]=f[e];s[f[0]]++;r[f[3]]++;t=b.length+c-1;n=null}var e,f,g,k,l,m={},n,q=w?new Uint16Array(2*c.length):[],u=0,t=0,s=new (w?Uint32Array:Array)(286),r=new (w?Uint32Array:Array)(30),v=b.w,A;if(!w){for(g=0;285>=g;)s[g++]=0;for(g=0;29>=g;)r[g++]=0}s[256]=1;e=0;for(f=c.length;e<f;++e){g=l=0;for(k=3;g<k&&e+g!==f;++g)l=l<<8|c[e+g];m[l]===C&&(m[l]=[]);g=m[l];if(!(0<t--)){for(;0<g.length&&32768<e-g[0];)g.shift();if(e+3>=f){n&&d(n,-1);g=0;
for(k=f-e;g<k;++g)A=c[e+g],q[u++]=A,++s[A];break}if(0<g.length){l=k=C;var B=0,y=C,z=C,x=y=C,F=c.length,z=0,x=g.length;a:for(;z<x;z++){k=g[x-z-1];y=3;if(3<B){for(y=B;3<y;y--)if(c[k+y-1]!==c[e+y-1])continue a;y=B}for(;258>y&&e+y<F&&c[k+y]===c[e+y];)++y;y>B&&(l=k,B=y);if(258===y)break}k=new h(B,e-l);n?n.length<k.length?(A=c[e-1],q[u++]=A,++s[A],d(k,0)):d(n,-1):k.length<v?n=k:d(k,0)}else n?d(n,-1):(A=c[e],q[u++]=A,++s[A])}g.push(e)}q[u++]=256;s[256]++;b.L=s;b.K=r;return w?q.subarray(0,u):q}function m(a,
b){function c(a){var b=q[a][u[a]];b===m?(c(a+1),c(a+1)):--n[b];++u[a]}var d=a.length,f=new e(572),g=new (w?Uint8Array:Array)(d),h,k,l;if(!w)for(k=0;k<d;k++)g[k]=0;for(k=0;k<d;++k)0<a[k]&&f.push(k,a[k]);d=Array(f.length/2);h=new (w?Uint32Array:Array)(f.length/2);if(1===d.length)return g[f.pop().index]=1,g;k=0;for(l=f.length/2;k<l;++k)d[k]=f.pop(),h[k]=d[k].value;var m=h.length;k=new (w?Uint16Array:Array)(b);var f=new (w?Uint8Array:Array)(b),n=new (w?Uint8Array:Array)(m);l=Array(b);var q=Array(b),u=
Array(b),s=(1<<b)-m,t=1<<b-1,r,v,y;k[b-1]=m;for(r=0;r<b;++r)s<t?f[r]=0:(f[r]=1,s-=t),s<<=1,k[b-2-r]=(k[b-1-r]/2|0)+m;k[0]=f[0];l[0]=Array(k[0]);q[0]=Array(k[0]);for(r=1;r<b;++r)k[r]>2*k[r-1]+f[r]&&(k[r]=2*k[r-1]+f[r]),l[r]=Array(k[r]),q[r]=Array(k[r]);for(s=0;s<m;++s)n[s]=b;for(t=0;t<k[b-1];++t)l[b-1][t]=h[t],q[b-1][t]=t;for(s=0;s<b;++s)u[s]=0;1===f[b-1]&&(--n[0],++u[b-1]);for(r=b-2;0<=r;--r){v=s=0;y=u[r+1];for(t=0;t<k[r];t++)v=l[r+1][y]+l[r+1][y+1],v>h[s]?(l[r][t]=v,q[r][t]=m,y+=2):(l[r][t]=h[s],
q[r][t]=s,++s);u[r]=0;1===f[r]&&c(r)}h=n;k=0;for(l=d.length;k<l;++k)g[d[k].index]=h[k];return g}function n(b){var c=new (w?Uint16Array:Array)(b.length),d=[],e=[],f=0,g,h,k;g=0;for(h=b.length;g<h;g++)d[b[g]]=(d[b[g]]|0)+1;g=1;for(h=16;g<=h;g++)e[g]=f,f+=d[g]|0,f>1<<g&&a("overcommitted"),f<<=1;65536>f&&a("undercommitted");g=0;for(h=b.length;g<h;g++){f=e[b[g]];e[b[g]]+=1;d=c[g]=0;for(k=b[g];d<k;d++)c[g]=c[g]<<1|f&1,f>>>=1}return c}function q(a,b){this.input=a;this.a=new (w?Uint8Array:Array)(32768);this.h=
H.j;var c={},d;if((b||!(b={}))&&"number"===typeof b.compressionType)this.h=b.compressionType;for(d in b)c[d]=b[d];c.outputBuffer=this.a;this.z=new g(this.input,c)}function s(b,c){this.k=[];this.l=32768;this.e=this.g=this.c=this.q=0;this.input=w?new Uint8Array(b):b;this.s=!1;this.m=N;this.B=!1;if(c||!(c={}))c.index&&(this.c=c.index),c.bufferSize&&(this.l=c.bufferSize),c.bufferType&&(this.m=c.bufferType),c.resize&&(this.B=c.resize);switch(this.m){case Q:this.b=32768;this.a=new (w?Uint8Array:Array)(32768+
this.l+258);break;case N:this.b=0;this.a=new (w?Uint8Array:Array)(this.l);this.f=this.J;this.t=this.H;this.o=this.I;break;default:a(Error("invalid inflate mode"))}}function v(b,c){for(var d=b.g,e=b.e,f=b.input,g=b.c,h;e<c;)h=f[g++],h===C&&a(Error("input buffer is broken")),d|=h<<e,e+=8;b.g=d>>>c;b.e=e-c;b.c=g;return d&(1<<c)-1}function t(b,c){for(var d=b.g,e=b.e,f=b.input,g=b.c,h=c[0],k=c[1],l;e<k;)l=f[g++],l===C&&a(Error("input buffer is broken")),d|=l<<e,e+=8;f=h[d&(1<<k)-1];h=f>>>16;b.g=d>>h;b.e=
e-h;b.c=g;return f&65535}function z(a){function b(a,c,d){var e,f,g,h;for(h=0;h<a;)switch(e=t(this,c),e){case 16:for(g=3+v(this,2);g--;)d[h++]=f;break;case 17:for(g=3+v(this,3);g--;)d[h++]=0;f=0;break;case 18:for(g=11+v(this,7);g--;)d[h++]=0;f=0;break;default:f=d[h++]=e}return d}var c=v(a,5)+257,d=v(a,5)+1,e=v(a,4)+4,g=new (w?Uint8Array:Array)(R.length),h;for(h=0;h<e;++h)g[R[h]]=v(a,3);e=f(g);g=new (w?Uint8Array:Array)(c);h=new (w?Uint8Array:Array)(d);a.o(f(b.call(a,c,e,g)),f(b.call(a,d,e,h)))}function x(b,
c){var d,e;this.input=b;this.c=0;if(c||!(c={}))c.index&&(this.c=c.index),c.verify&&(this.M=c.verify);d=b[this.c++];e=b[this.c++];switch(d&15){case M:this.method=M;break;default:a(Error("unsupported compression method"))}0!==((d<<8)+e)%31&&a(Error("invalid fcheck flag:"+((d<<8)+e)%31));e&32&&a(Error("fdict flag is not supported"));this.A=new s(b,{index:this.c,bufferSize:c.bufferSize,bufferType:c.bufferType,resize:c.resize})}var C=void 0,D=!0,y=this,w="undefined"!==typeof Uint8Array&&"undefined"!==
typeof Uint16Array&&"undefined"!==typeof Uint32Array;d.prototype.f=function(){var a=this.buffer,b,c=a.length,d=new (w?Uint8Array:Array)(c<<1);if(w)d.set(a);else for(b=0;b<c;++b)d[b]=a[b];return this.buffer=d};d.prototype.d=function(a,b,c){var d=this.buffer,e=this.index,f=this.i,g=d[e];c&&1<b&&(a=8<b?(F[a&255]<<24|F[a>>>8&255]<<16|F[a>>>16&255]<<8|F[a>>>24&255])>>32-b:F[a]>>8-b);if(8>b+f)g=g<<b|a,f+=b;else for(c=0;c<b;++c)g=g<<1|a>>b-c-1&1,8===++f&&(f=0,d[e++]=F[g],g=0,e===d.length&&(d=this.f()));
d[e]=g;this.buffer=d;this.i=f;this.index=e};d.prototype.finish=function(){var a=this.buffer,b=this.index,c;0<this.i&&(a[b]<<=8-this.i,a[b]=F[a[b]],b++);w?c=a.subarray(0,b):(a.length=b,c=a);return c};var u=new (w?Uint8Array:Array)(256),r;for(r=0;256>r;++r){for(var B=r,E=B,G=7,B=B>>>1;B;B>>>=1)E<<=1,E|=B&1,--G;u[r]=(E<<G&255)>>>0}var F=u,u=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,
498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,
3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,
2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,
2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,
2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,
711928724,3020668471,3272380065,1510334235,755167117];w&&new Uint32Array(u);e.prototype.getParent=function(a){return 2*((a-2)/4|0)};e.prototype.push=function(a,b){var c,d,e=this.buffer,f;c=this.length;e[this.length++]=b;for(e[this.length++]=a;0<c;)if(d=this.getParent(c),e[c]>e[d])f=e[c],e[c]=e[d],e[d]=f,f=e[c+1],e[c+1]=e[d+1],e[d+1]=f,c=d;else break;return this.length};e.prototype.pop=function(){var a,b,c=this.buffer,d,e,f;b=c[0];a=c[1];this.length-=2;c[0]=c[this.length];c[1]=c[this.length+1];for(f=
0;;){e=2*f+2;if(e>=this.length)break;e+2<this.length&&c[e+2]>c[e]&&(e+=2);if(c[e]>c[f])d=c[f],c[f]=c[e],c[e]=d,d=c[f+1],c[f+1]=c[e+1],c[e+1]=d;else break;f=e}return{index:a,value:b,length:this.length}};var I=2,u={NONE:0,r:1,j:I,N:3},K=[];for(r=0;288>r;r++)switch(D){case 143>=r:K.push([r+48,8]);break;case 255>=r:K.push([r-144+400,9]);break;case 279>=r:K.push([r-256+0,7]);break;case 287>=r:K.push([r-280+192,8]);break;default:a("invalid literal: "+r)}g.prototype.n=function(){var b,c,e,f,g=this.input;
switch(this.h){case 0:e=0;for(f=g.length;e<f;){c=w?g.subarray(e,e+65535):g.slice(e,e+65535);e+=c.length;var h=e===f,k=C,q=k=C,q=k=C,r=this.a,s=this.b;if(w){for(r=new Uint8Array(this.a.buffer);r.length<=s+c.length+5;)r=new Uint8Array(r.length<<1);r.set(this.a)}k=h?1:0;r[s++]=k|0;k=c.length;q=~k+65536&65535;r[s++]=k&255;r[s++]=k>>>8&255;r[s++]=q&255;r[s++]=q>>>8&255;if(w)r.set(c,s),s+=c.length,r=r.subarray(0,s);else{k=0;for(q=c.length;k<q;++k)r[s++]=c[k];r.length=s}this.b=s;this.a=r}break;case 1:e=
new d(new Uint8Array(this.a.buffer),this.b);e.d(1,1,D);e.d(1,2,D);g=l(this,g);c=0;for(h=g.length;c<h;c++)if(f=g[c],d.prototype.d.apply(e,K[f]),256<f)e.d(g[++c],g[++c],D),e.d(g[++c],5),e.d(g[++c],g[++c],D);else if(256===f)break;this.a=e.finish();this.b=this.a.length;break;case I:f=new d(new Uint8Array(this.a),this.b);var t,u,v,y=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B,z,k=Array(19),A,r=I;f.d(1,1,D);f.d(r,2,D);g=l(this,g);q=m(this.L,15);B=n(q);r=m(this.K,7);s=n(r);for(t=286;257<t&&0===q[t-
1];t--);for(u=30;1<u&&0===r[u-1];u--);var x=t,F=u;b=new (w?Uint32Array:Array)(x+F);var H=new (w?Uint32Array:Array)(316),E,G;z=new (w?Uint8Array:Array)(19);for(A=v=0;A<x;A++)b[v++]=q[A];for(A=0;A<F;A++)b[v++]=r[A];if(!w){A=0;for(F=z.length;A<F;++A)z[A]=0}A=E=0;for(F=b.length;A<F;A+=v){for(v=1;A+v<F&&b[A+v]===b[A];++v);x=v;if(0===b[A])if(3>x)for(;0<x--;)H[E++]=0,z[0]++;else for(;0<x;)G=138>x?x:138,G>x-3&&G<x&&(G=x-3),10>=G?(H[E++]=17,H[E++]=G-3,z[17]++):(H[E++]=18,H[E++]=G-11,z[18]++),x-=G;else if(H[E++]=
b[A],z[b[A]]++,x--,3>x)for(;0<x--;)H[E++]=b[A],z[b[A]]++;else for(;0<x;)G=6>x?x:6,G>x-3&&G<x&&(G=x-3),H[E++]=16,H[E++]=G-3,z[16]++,x-=G}b=w?H.subarray(0,E):H.slice(0,E);z=m(z,7);for(A=0;19>A;A++)k[A]=z[y[A]];for(v=19;4<v&&0===k[v-1];v--);y=n(z);f.d(t-257,5,D);f.d(u-1,5,D);f.d(v-4,4,D);for(A=0;A<v;A++)f.d(k[A],3,D);A=0;for(k=b.length;A<k;A++)if(c=b[A],f.d(y[c],z[c],D),16<=c){A++;switch(c){case 16:h=2;break;case 17:h=3;break;case 18:h=7;break;default:a("invalid code: "+c)}f.d(b[A],h,D)}h=[B,q];s=[s,
r];c=h[0];h=h[1];r=s[0];B=s[1];s=0;for(k=g.length;s<k;++s)if(e=g[s],f.d(c[e],h[e],D),256<e)f.d(g[++s],g[++s],D),q=g[++s],f.d(r[q],B[q],D),f.d(g[++s],g[++s],D);else if(256===e)break;this.a=f.finish();this.b=this.a.length;break;default:a("invalid compression type")}return this.a};r=[];var J;for(J=3;258>=J;J++)B=k(),r[J]=B[2]<<24|B[1]<<16|B[0];var L=w?new Uint32Array(r):r,H=u;q.prototype.n=function(){var b,d,e,f,g=0;f=this.a;b=M;switch(b){case M:d=Math.LOG2E*Math.log(32768)-8;break;default:a(Error("invalid compression method"))}d=
d<<4|b;f[g++]=d;switch(b){case M:switch(this.h){case H.NONE:e=0;break;case H.r:e=1;break;case H.j:e=2;break;default:a(Error("unsupported compression type"))}break;default:a(Error("invalid compression method"))}b=e<<6|0;f[g++]=b|31-(256*d+b)%31;b=c(this.input);this.z.b=g;f=this.z.n();g=f.length;w&&(f=new Uint8Array(f.buffer),f.length<=g+4&&(this.a=new Uint8Array(f.length+4),this.a.set(f),f=this.a),f=f.subarray(0,g+4));f[g++]=b>>24&255;f[g++]=b>>16&255;f[g++]=b>>8&255;f[g++]=b&255;return f};b("Zlib.Deflate",
q);b("Zlib.Deflate.compress",function(a,b){return(new q(a,b)).n()});b("Zlib.Deflate.CompressionType",H);b("Zlib.Deflate.CompressionType.NONE",H.NONE);b("Zlib.Deflate.CompressionType.FIXED",H.r);b("Zlib.Deflate.CompressionType.DYNAMIC",H.j);var Q=0,N=1,u={D:Q,C:N};s.prototype.p=function(){for(;!this.s;){var b=v(this,3);b&1&&(this.s=D);b>>>=1;switch(b){case 0:var b=this.input,c=this.c,d=this.a,e=this.b,f=C,g=C,h=C,k=d.length,f=C;this.e=this.g=0;f=b[c++];f===C&&a(Error("invalid uncompressed block header: LEN (first byte)"));
g=f;f=b[c++];f===C&&a(Error("invalid uncompressed block header: LEN (second byte)"));g|=f<<8;f=b[c++];f===C&&a(Error("invalid uncompressed block header: NLEN (first byte)"));h=f;f=b[c++];f===C&&a(Error("invalid uncompressed block header: NLEN (second byte)"));h|=f<<8;g===~h&&a(Error("invalid uncompressed block header: length verify"));c+g>b.length&&a(Error("input buffer is broken"));switch(this.m){case Q:for(;e+g>d.length;){f=k-e;g-=f;if(w)d.set(b.subarray(c,c+f),e),e+=f,c+=f;else for(;f--;)d[e++]=
b[c++];this.b=e;d=this.f();e=this.b}break;case N:for(;e+g>d.length;)d=this.f({v:2});break;default:a(Error("invalid inflate mode"))}if(w)d.set(b.subarray(c,c+g),e),e+=g,c+=g;else for(;g--;)d[e++]=b[c++];this.c=c;this.b=e;this.a=d;break;case 1:this.o(U,V);break;case 2:z(this);break;default:a(Error("unknown BTYPE: "+b))}}return this.t()};r=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];var R=w?new Uint16Array(r):r;r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,
258,258,258];var S=w?new Uint16Array(r):r;r=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0];var O=w?new Uint8Array(r):r;r=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];var T=w?new Uint16Array(r):r;r=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];var P=w?new Uint8Array(r):r;r=new (w?Uint8Array:Array)(288);B=0;for(E=r.length;B<E;++B)r[B]=143>=B?8:255>=B?9:279>=B?7:8;var U=f(r);r=new (w?Uint8Array:
Array)(30);B=0;for(E=r.length;B<E;++B)r[B]=5;var V=f(r);s.prototype.o=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e=c.length-258,f,g,h;256!==(f=t(this,a));)if(256>f)d>=e&&(this.b=d,c=this.f(),d=this.b),c[d++]=f;else{f-=257;h=S[f];0<O[f]&&(h+=v(this,O[f]));f=t(this,b);g=T[f];0<P[f]&&(g+=v(this,P[f]));for(d>=e&&(this.b=d,c=this.f(),d=this.b);h--;)c[d]=c[d++-g]}for(;8<=this.e;)this.e-=8,this.c--;this.b=d};s.prototype.I=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e=c.length,f,g,h;256!==
(f=t(this,a));)if(256>f)d>=e&&(c=this.f(),e=c.length),c[d++]=f;else{f-=257;h=S[f];0<O[f]&&(h+=v(this,O[f]));f=t(this,b);g=T[f];0<P[f]&&(g+=v(this,P[f]));for(d+h>e&&(c=this.f(),e=c.length);h--;)c[d]=c[d++-g]}for(;8<=this.e;)this.e-=8,this.c--;this.b=d};s.prototype.f=function(){var a=new (w?Uint8Array:Array)(this.b-32768),b=this.b-32768,c,d,e=this.a;if(w)a.set(e.subarray(32768,a.length));else{c=0;for(d=a.length;c<d;++c)a[c]=e[c+32768]}this.k.push(a);this.q+=a.length;if(w)e.set(e.subarray(b,b+32768));
else for(c=0;32768>c;++c)e[c]=e[b+c];this.b=32768;return e};s.prototype.J=function(a){var b,c=this.input.length/this.c+1|0,d,e,f,g=this.input,h=this.a;a&&("number"===typeof a.v&&(c=a.v),"number"===typeof a.F&&(c+=a.F));2>c?(d=(g.length-this.c)/this.u[2],f=258*(d/2)|0,e=f<h.length?h.length+f:h.length<<1):e=h.length*c;w?(b=new Uint8Array(e),b.set(h)):b=h;return this.a=b};s.prototype.t=function(){var a=0,b=this.a,c=this.k,d,e=new (w?Uint8Array:Array)(this.q+(this.b-32768)),f,g,h,k;if(0===c.length)return w?
this.a.subarray(32768,this.b):this.a.slice(32768,this.b);f=0;for(g=c.length;f<g;++f){d=c[f];h=0;for(k=d.length;h<k;++h)e[a++]=d[h]}f=32768;for(g=this.b;f<g;++f)e[a++]=b[f];this.k=[];return this.buffer=e};s.prototype.H=function(){var a,b=this.b;w?this.B?(a=new Uint8Array(b),a.set(this.a.subarray(0,b))):a=this.a.subarray(0,b):(this.a.length>b&&(this.a.length=b),a=this.a);return this.buffer=a};x.prototype.p=function(){var b=this.input,d,e;d=this.A.p();this.c=this.A.c;this.M&&(e=(b[this.c++]<<24|b[this.c++]<<
16|b[this.c++]<<8|b[this.c++])>>>0,e!==c(d)&&a(Error("invalid adler-32 checksum")));return d};b("Zlib.Inflate",x);b("Zlib.Inflate.BufferType",u);u.ADAPTIVE=u.C;u.BLOCK=u.D;b("Zlib.Inflate.prototype.decompress",x.prototype.p);u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];w&&new Uint16Array(u);u=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258];w&&new Uint16Array(u);u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0];w&&new Uint8Array(u);
u=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];w&&new Uint16Array(u);u=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];w&&new Uint8Array(u);u=new (w?Uint8Array:Array)(288);r=0;for(B=u.length;r<B;++r)u[r]=143>=r?8:255>=r?9:279>=r?7:8;f(u);u=new (w?Uint8Array:Array)(30);r=0;for(B=u.length;r<B;++r)u[r]=5;f(u);var M=8}).call(this);cc.Point=function(a,b){this.x=a||0;this.y=b||0};cc.PointMake=function(a,b){return new cc.Point(a,b)};cc.p=function(a,b){return{x:a,y:b}};cc._p=cc.p;cc.PointZero=function(){return cc.p(0,0)};Object.defineProperties(cc,{POINT_ZERO:{get:function(){return cc.p(0,0)}},SIZE_ZERO:{get:function(){return cc.size(0,0)}},RECT_ZERO:{get:function(){return cc.rect(0,0,0,0)}}});cc.pointEqualToPoint=function(a,b){return!a||!b?!1:a.x==b.x&&a.y==b.y};cc.Point.CCPointEqualToPoint=cc.pointEqualToPoint;
cc.Size=function(a,b){this.width=a||0;this.height=b||0};cc.SizeMake=function(a,b){return cc.size(a,b)};cc.size=function(a,b){return{width:a,height:b}};cc._size=cc.size;cc.SizeZero=function(){return cc.size(0,0)};cc.sizeEqualToSize=function(a,b){return!a||!b?!1:a.width==b.width&&a.height==b.height};cc.Size.CCSizeEqualToSize=cc.sizeEqualToSize;
cc.Rect=function(a,b,c,d){switch(arguments.length){case 0:this.origin=cc.p(0,0);this.size=cc.size(0,0);break;case 1:if(a)if(a instanceof cc.Rect)this.origin=cc.p(a.origin.x,a.origin.y),this.size=cc.size(a.size.width,a.size.height);else throw"unknown argument type";else this.origin=cc.p(0,0),this.size=cc.size(0,0);break;case 2:this.origin=a?cc.p(a.x,a.y):cc.p(0,0);this.size=b?cc.size(b.width,b.height):cc.size(0,0);break;case 4:this.origin=cc.p(a||0,b||0);this.size=cc.size(c||0,d||0);break;default:throw"unknown argument type";
}};cc.RectMake=function(a,b,c,d){return cc.rect(a,b,c,d)};cc.rect=function(a,b,c,d){return new cc.Rect(a,b,c,d)};cc._rect=cc.rect;cc.RectZero=function(){return cc.rect(0,0,0,0)};cc.rectEqualToRect=function(a,b){return!a||!b?!1:cc.Point.CCPointEqualToPoint(a.origin,b.origin)&&cc.Size.CCSizeEqualToSize(a.size,b.size)};
cc.rectContainsRect=function(a,b){return!a||!b||a.origin.x>=b.origin.x||a.origin.y>=b.origin.y||a.origin.x+a.size.width<=b.origin.x+b.size.width||a.origin.y+a.size.height<=b.origin.y+b.size.height?!1:!0};cc.rectGetMaxX=function(a){return a.origin.x+a.size.width};cc.rectGetMidX=function(a){return a.origin.x+a.size.width/2};cc.rectGetMinX=function(a){return a.origin.x};cc.rectGetMaxY=function(a){return a.origin.y+a.size.height};cc.rectGetMidY=function(a){return a.origin.y+a.size.height/2};
cc.rectGetMinY=function(a){return a.origin.y};cc.rectContainsPoint=function(a,b){var c=!1;b.x>=cc.Rect.CCRectGetMinX(a)&&(b.x<=cc.Rect.CCRectGetMaxX(a)&&b.y>=cc.Rect.CCRectGetMinY(a)&&b.y<=cc.Rect.CCRectGetMaxY(a))&&(c=!0);return c};cc.rectIntersectsRect=function(a,b){return!(cc.Rect.CCRectGetMaxX(a)<cc.Rect.CCRectGetMinX(b)||cc.Rect.CCRectGetMaxX(b)<cc.Rect.CCRectGetMinX(a)||cc.Rect.CCRectGetMaxY(a)<cc.Rect.CCRectGetMinY(b)||cc.Rect.CCRectGetMaxY(b)<cc.Rect.CCRectGetMinY(a))};
cc.rectOverlapsRect=function(a,b){return a.origin.x+a.size.width<b.origin.x||b.origin.x+b.size.width<a.origin.x||a.origin.y+a.size.height<b.origin.y||b.origin.y+b.size.height<a.origin.y?!1:!0};cc.rectUnion=function(a,b){var c=cc.rect(0,0,0,0);c.origin.x=Math.min(a.origin.x,b.origin.x);c.origin.y=Math.min(a.origin.y,b.origin.y);c.size.width=Math.max(a.origin.x+a.size.width,b.origin.x+b.size.width)-c.origin.x;c.size.height=Math.max(a.origin.y+a.size.height,b.origin.y+b.size.height)-c.origin.y;return c};
cc.rectIntersection=function(a,b){var c=cc.rect(Math.max(cc.Rect.CCRectGetMinX(a),cc.Rect.CCRectGetMinX(b)),Math.max(cc.Rect.CCRectGetMinY(a),cc.Rect.CCRectGetMinY(b)),0,0);c.size.width=Math.min(cc.Rect.CCRectGetMaxX(a),cc.Rect.CCRectGetMaxX(b))-cc.Rect.CCRectGetMinX(c);c.size.height=Math.min(cc.Rect.CCRectGetMaxY(a),cc.Rect.CCRectGetMaxY(b))-cc.Rect.CCRectGetMinY(c);return c};cc.Rect.prototype.getX=function(){return this.origin.x};cc.Rect.prototype.setX=function(a){this.origin.x=a};
cc.Rect.prototype.getY=function(){return this.origin.y};cc.Rect.prototype.setY=function(a){this.origin.y=a};cc.Rect.prototype.getWidth=function(){return this.size.width};cc.Rect.prototype.setWidth=function(a){this.size.width=a};cc.Rect.prototype.getHeight=function(){return this.size.height};cc.Rect.prototype.setHeight=function(a){this.size.height=a};
Object.defineProperties(cc.Rect.prototype,{x:{get:function(){return this.getX()},set:function(a){this.setX(a)},enumerable:!0,configurable:!0},y:{get:function(){return this.getY()},set:function(a){this.setY(a)},enumerable:!0,configurable:!0},width:{get:function(){return this.getWidth()},set:function(a){this.setWidth(a)},enumerable:!0,configurable:!0},height:{get:function(){return this.getHeight()},set:function(a){this.setHeight(a)},enumerable:!0,configurable:!0}});cc.Rect.CCRectEqualToRect=cc.rectEqualToRect;
cc.Rect.CCRectContainsRect=cc.rectContainsRect;cc.Rect.CCRectGetMaxX=cc.rectGetMaxX;cc.Rect.CCRectGetMidX=cc.rectGetMidX;cc.Rect.CCRectGetMinX=cc.rectGetMinX;cc.Rect.CCRectGetMaxY=cc.rectGetMaxY;cc.Rect.CCRectGetMidY=cc.rectGetMidY;cc.Rect.CCRectGetMinY=cc.rectGetMinY;cc.Rect.CCRectContainsPoint=cc.rectContainsPoint;cc.Rect.CCRectIntersectsRect=cc.rectIntersectsRect;cc.Rect.CCRectUnion=cc.rectUnion;cc.Rect.CCRectIntersection=cc.rectIntersection;var sys=sys||{};try{sys.localStorage=window.localStorage}catch(e$$40){"SECURITY_ERR"===e$$40.name&&cc.log("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"),sys.localStorage=function(){}}
Object.defineProperties(sys,{capabilities:{get:function(){var a={canvas:!0};cc.Browser.supportWebGL&&(a.opengl=!0);"ontouchstart"in document.documentElement?a.touches=!0:"onmouseup"in document.documentElement&&(a.mouse=!0);"onkeyup"in document.documentElement&&(a.keyboard=!0);if(window.DeviceMotionEvent||window.DeviceOrientationEvent)a.accelerometer=!0;return a},enumerable:!0,configurable:!0},os:{get:function(){var a=navigator.userAgent.match(/(iPad|iPhone|iPod)/i)?!0:!1,b=navigator.userAgent.match(/android/i)||
navigator.platform.match(/android/i)?!0:!1,c=navigator.appVersion;-1!=navigator.appVersion.indexOf("Win")?c="Windows":-1!=navigator.appVersion.indexOf("Mac")?c="OS X":-1!=navigator.appVersion.indexOf("X11")?c="UNIX":-1!=navigator.appVersion.indexOf("Linux")?c="Linux":a?c="iOS":b&&(c="Android");return c},enumerable:!0,configurable:!0},platform:{get:function(){return"browser"},enumerable:!0,configurable:!0},version:{get:function(){return cc.ENGINE_VERSION},enumerable:!0,configurable:!0}});
sys.garbageCollect=function(){};sys.dumpRoot=function(){};sys.restartVM=function(){};cc.ENGINE_VERSION="Cocos2d-html5-v2.1.3";cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL=0;cc.DIRECTOR_STATS_POSITION=cc.p(0,0);cc.DIRECTOR_FPS_INTERVAL=0.5;cc.COCOSNODE_RENDER_SUBPIXEL=1;cc.SPRITEBATCHNODE_RENDER_SUBPIXEL=1;cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA=1;cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP=0;cc.TEXTURE_ATLAS_USE_VAO=0;cc.TEXTURE_NPOT_SUPPORT=0;cc.RETINA_DISPLAY_SUPPORT=1;cc.RETINA_DISPLAY_FILENAME_SUFFIX="-hd";cc.USE_LA88_LABELS=1;cc.SPRITE_DEBUG_DRAW=0;cc.SPRITEBATCHNODE_DEBUG_DRAW=0;
cc.LABELBMFONT_DEBUG_DRAW=0;cc.LABELATLAS_DEBUG_DRAW=0;cc.IS_RETINA_DISPLAY_SUPPORTED=1;cc.DEFAULT_ENGINE=cc.ENGINE_VERSION+"-canvas";cc.config={platform:sys.platform};cc.dumpConfig=function(){for(var a in sys)cc.log(a+" \x3d "+sys[a])};cc.ENABLE_GL_STATE_CACHE=1;cc.splitWithForm=function(a,b){if(a&&0!=a.length){var c=a.indexOf("{"),d=a.indexOf("}");if(!(-1==c||-1==d)&&!(c>d))if(c=a.substr(c+1,d-c-1),0!=c.length){var d=c.indexOf("{"),e=c.indexOf("}");-1!=d||-1!=e||(b=c.split(","))}}return b};
cc.RectFromString=function(a){var b=cc.RectZero();if(a){var c=a.indexOf("{")+1,d=a.lastIndexOf("}",a.length);-1==c||-1==d||(a=a.substring(c,d),c=a.indexOf("}"),-1!=c&&(c=a.indexOf(",",c),-1!=c&&(b=a.substr(0,c),a=a.substr(c+1,a.length-c),c=cc.splitWithForm(b),b=cc.splitWithForm(a),a=parseFloat(c[0]),c=parseFloat(c[1]),d=parseFloat(b[0]),b=parseFloat(b[1]),b=cc.rect(a,c,d,b))))}return b};
cc.PointFromString=function(a){var b=cc.PointZero();try{if(""==a)return b;var c=cc.splitWithForm(a),d=parseFloat(c[0]),e=parseFloat(c[1]),b=cc.p(d,e)}catch(f){}return b};cc.SizeFromString=function(a){var b=cc.SizeZero();try{if(""==a)return b;var c=cc.splitWithForm(a),d=parseFloat(c[0]),e=parseFloat(c[1]),b=cc.size(d,e)}catch(f){}return b};cc.Set=cc.Class.extend({ctor:function(a){this._set=a?[].concat(a._set):[]},copy:function(){return new cc.Set(this)},mutableCopy:function(){return this.copy()},count:function(){return this._set.length},addObject:function(a){cc.ArrayContainsObject(this._set,a)||(this._set.push(a),this._set.sort(function(a,c){return a-c}))},removeObject:function(a){for(var b=0,c=0,d=0;c<this._set.length;c++)this._set[c]!=a&&(this._set[d++]=this._set[c],b++);this._set.length=b},begin:function(){return this._set&&0<this._set.length?
this._set[0]:null},end:function(){return this._set&&0<this._set.length?this._set[this._set.length-1]:null},containsObject:function(a){return cc.ArrayContainsObject(this._set,a)},anyObject:function(){return this._set&&0<this._set.length?this._set[0]:null},_set:null});cc.NSMutableSet=cc.Set;cc.kmVec2=function(a,b){this.x=a||0;this.y=b||0};cc.kmVec2Fill=function(a,b,c){a.x=b;a.y=c;return a};cc.kmVec2Length=function(a){return Math.sqrt(cc.kmSQR(a.x)+cc.kmSQR(a.y))};cc.kmVec2LengthSq=function(a){return cc.kmSQR(a.x)+cc.kmSQR(a.y)};cc.kmVec2Normalize=function(a,b){var c=1/cc.kmVec2Length(b),d=new cc.kmVec2;d.x=b.x*c;d.y=b.y*c;a.x=d.x;a.y=d.y;return a};cc.kmVec2Add=function(a,b,c){a.x=b.x+c.x;a.y=b.y+c.y;return a};cc.kmVec2Dot=function(a,b){return a.x*b.x+a.y*b.y};
cc.kmVec2Subtract=function(a,b,c){a.x=b.x-c.x;a.y=b.y-c.y;return a};cc.kmVec2Transform=function(a,b,c){var d=new cc.kmVec2;d.x=b.x*c.mat[0]+b.y*c.mat[3]+c.mat[6];d.y=b.x*c.mat[1]+b.y*c.mat[4]+c.mat[7];a.x=d.x;a.y=d.y;return a};cc.kmVec2TransformCoord=function(a,b,c){return null};cc.kmVec2Scale=function(a,b,c){a.x=b.x*c;a.y=b.y*c;return a};cc.kmVec2AreEqual=function(a,b){return a.x<b.x+cc.kmEpsilon&&a.x>b.x-cc.kmEpsilon&&a.y<b.y+cc.kmEpsilon&&a.y>b.y-cc.kmEpsilon};cc.kmVec3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};cc.kmVec3Fill=function(a,b,c,d){if(!a)return new cc.kmVec3(b,c,d);a.x=b;a.y=c;a.z=d;return a};cc.kmVec3Length=function(a){return Math.sqrt(cc.kmSQR(a.x)+cc.kmSQR(a.y)+cc.kmSQR(a.z))};cc.kmVec3LengthSq=function(a){return cc.kmSQR(a.x)+cc.kmSQR(a.y)+cc.kmSQR(a.z)};cc.kmVec3Normalize=function(a,b){var c=1/cc.kmVec3Length(b);a.x=b.x*c;a.y=b.y*c;a.z=b.z*c;return a};
cc.kmVec3Cross=function(a,b,c){a.x=b.y*c.z-b.z*c.y;a.y=b.z*c.x-b.x*c.z;a.z=b.x*c.y-b.y*c.x;return a};cc.kmVec3Dot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};cc.kmVec3Add=function(a,b,c){a.x=b.x+c.x;a.y=b.y+c.y;a.z=b.z+c.z;return a};cc.kmVec3Subtract=function(a,b,c){a.x=b.x-c.x;a.y=b.y-c.y;a.z=b.z-c.z;return a};
cc.kmVec3Transform=function(a,b,c){a.x=b.x*c.mat[0]+b.y*c.mat[4]+b.z*c.mat[8]+c.mat[12];a.y=b.x*c.mat[1]+b.y*c.mat[5]+b.z*c.mat[9]+c.mat[13];a.z=b.x*c.mat[2]+b.y*c.mat[6]+b.z*c.mat[10]+c.mat[14];return a};cc.kmVec3TransformNormal=function(a,b,c){a.x=b.x*c.mat[0]+b.y*c.mat[4]+b.z*c.mat[8];a.y=b.x*c.mat[1]+b.y*c.mat[5]+b.z*c.mat[9];a.z=b.x*c.mat[2]+b.y*c.mat[6]+b.z*c.mat[10];return a};
cc.kmVec3TransformCoord=function(a,b,c){var d=new cc.kmVec4,e=new cc.kmVec4;cc.kmVec4Fill(e,b.x,b.y,b.z,1);cc.kmVec4Transform(d,e,c);a.x=d.x/d.w;a.y=d.y/d.w;a.z=d.z/d.w;return a};cc.kmVec3Scale=function(a,b,c){a.x=b.x*c;a.y=b.y*c;a.z=b.z*c;return a};cc.kmVec3AreEqual=function(a,b){return a.x<b.x+cc.kmEpsilon&&a.x>b.x-cc.kmEpsilon&&a.y<b.y+cc.kmEpsilon&&a.y>b.y-cc.kmEpsilon&&a.z<b.z+cc.kmEpsilon&&a.z>b.z-cc.kmEpsilon?1:0};
cc.kmVec3InverseTransform=function(a,b,c){b=new cc.kmVec3(b.x-c.mat[12],b.y-c.mat[13],b.z-c.mat[14]);a.x=b.x*c.mat[0]+b.y*c.mat[1]+b.z*c.mat[2];a.y=b.x*c.mat[4]+b.y*c.mat[5]+b.z*c.mat[6];a.z=b.x*c.mat[8]+b.y*c.mat[9]+b.z*c.mat[10];return a};cc.kmVec3InverseTransformNormal=function(a,b,c){a.x=b.x*c.mat[0]+b.y*c.mat[1]+b.z*c.mat[2];a.y=b.x*c.mat[4]+b.y*c.mat[5]+b.z*c.mat[6];a.z=b.x*c.mat[8]+b.y*c.mat[9]+b.z*c.mat[10];return a};cc.kmVec3Assign=function(a,b){if(a==b)return a;a.x=b.x;a.y=b.y;a.z=b.z;return a};
cc.kmVec3Zero=function(a){a.x=0;a.y=0;a.z=0;return a};cc.kmVec3ToTypeArray=function(a){if(!a)return null;var b=new Float32Array(3);b[0]=a.x;b[1]=a.y;b[2]=a.z;return b};cc.kmVec4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||0};cc.kmVec4Fill=function(a,b,c,d,e){a.x=b;a.y=c;a.z=d;a.w=e;return a};cc.kmVec4Add=function(a,b,c){a.x=b.x+c.x;a.y=b.y+c.y;a.z=b.z+c.z;a.w=b.w+c.w;return a};cc.kmVec4Dot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w};cc.kmVec4Length=function(a){return Math.sqrt(cc.kmSQR(a.x)+cc.kmSQR(a.y)+cc.kmSQR(a.z)+cc.kmSQR(a.w))};cc.kmVec4LengthSq=function(a){return cc.kmSQR(a.x)+cc.kmSQR(a.y)+cc.kmSQR(a.z)+cc.kmSQR(a.w)};
cc.kmVec4Lerp=function(a,b,c,d){return a};cc.kmVec4Normalize=function(a,b){var c=1/cc.kmVec4Length(b);a.x*=c;a.y*=c;a.z*=c;a.w*=c;return a};cc.kmVec4Scale=function(a,b,c){cc.kmVec4Normalize(a,b);a.x*=c;a.y*=c;a.z*=c;a.w*=c;return a};cc.kmVec4Subtract=function(a,b,c){a.x=b.x-c.x;a.y=b.y-c.y;a.z=b.z-c.z;a.w=b.w-c.w;return a};
cc.kmVec4Transform=function(a,b,c){a.x=b.x*c.mat[0]+b.y*c.mat[4]+b.z*c.mat[8]+b.w*c.mat[12];a.y=b.x*c.mat[1]+b.y*c.mat[5]+b.z*c.mat[9]+b.w*c.mat[13];a.z=b.x*c.mat[2]+b.y*c.mat[6]+b.z*c.mat[10]+b.w*c.mat[14];a.w=b.x*c.mat[3]+b.y*c.mat[7]+b.z*c.mat[11]+b.w*c.mat[15];return a};cc.kmVec4TransformArray=function(a,b,c,d,e,f){for(var g=0;g<f;)cc.kmVec4Transform(a+g*b,c+g*d,e),++g;return a};
cc.kmVec4AreEqual=function(a,b){return a.x<b.x+cc.kmEpsilon&&a.x>b.x-cc.kmEpsilon&&a.y<b.y+cc.kmEpsilon&&a.y>b.y-cc.kmEpsilon&&a.z<b.z+cc.kmEpsilon&&a.z>b.z-cc.kmEpsilon&&a.w<b.w+cc.kmEpsilon&&a.w>b.w-cc.kmEpsilon};cc.kmVec4Assign=function(a,b){cc.Assert(a!=b,"same object!");a.x=b.x;a.y=b.y;a.z=b.z;a.w=b.w;return a};cc.kmVec4ToTypeArray=function(a){if(!a)return null;var b=new Float32Array(4);b[0]=a.x;b[1]=a.y;b[2]=a.z;b[3]=a.w;return b};cc.kmScalar=Number;cc.kmBool=Number;cc.kmEnum=Number;cc.KM_FALSE=0;cc.KM_TRUE=1;cc.kmPI=3.141592;cc.kmPIOver180=0.017453;cc.kmPIUnder180=57.295779;cc.kmEpsilon=0.015625;cc.kmSQR=function(a){return a*a};cc.kmDegreesToRadians=function(a){return a*cc.kmPIOver180};cc.kmRadiansToDegrees=function(a){return a*cc.kmPIUnder180};cc.kmMin=function(a,b){return a<b?a:b};cc.kmMax=function(a,b){return a>b?a:b};cc.kmAlmostEqual=function(a,b){return a+cc.kmEpsilon>b&&a-cc.kmEpsilon<b};cc.kmRay2=function(a,b){this.start=a||new cc.kmVec2;this.start=a||new cc.kmVec2};cc.kmRay2Fill=function(a,b,c,d,e){a.start.x=b;a.start.y=c;a.dir.x=d;a.dir.y=e};
cc.kmRay2IntersectLineSegment=function(a,b,c,d){var e=a.start.x,f=a.start.y,g=a.start.x+a.dir.x;a=a.start.y+a.dir.y;var h=b.x,k=b.y,l=c.x,m=c.y,n=(m-k)*(g-e)-(l-h)*(a-f);if(n>-cc.kmEpsilon&&n<cc.kmEpsilon)return cc.KM_FALSE;k=((l-h)*(f-k)-(m-k)*(e-h))/n;h=e+k*(g-e);k=f+k*(a-f);if(h<cc.kmMin(b.x,c.x)-cc.kmEpsilon||h>cc.kmMax(b.x,c.x)+cc.kmEpsilon||k<cc.kmMin(b.y,c.y)-cc.kmEpsilon||k>cc.kmMax(b.y,c.y)+cc.kmEpsilon||h<cc.kmMin(e,g)-cc.kmEpsilon||h>cc.kmMax(e,g)+cc.kmEpsilon||k<cc.kmMin(f,a)-cc.kmEpsilon||
k>cc.kmMax(f,a)+cc.kmEpsilon)return cc.KM_FALSE;d.x=h;d.y=k;return cc.KM_TRUE};cc.calculate_line_normal=function(a,b,c){var d=new cc.kmVec2;cc.kmVec2Subtract(d,b,a);c.x=-d.y;c.y=d.x;cc.kmVec2Normalize(c,c)};
cc.kmRay2IntersectTriangle=function(a,b,c,d,e,f){var g=new cc.kmVec2,h=new cc.kmVec2,k=new cc.kmVec2,l=1E4,m=cc.KM_FALSE,n;cc.kmRay2IntersectLineSegment(a,b,c,g)&&(n=new cc.kmVec2,m=cc.KM_TRUE,n=cc.kmVec2Length(cc.kmVec2Subtract(n,g,a.start)),n<l&&(h.x=g.x,h.y=g.y,l=n,cc.calculate_line_normal(b,c,k)));cc.kmRay2IntersectLineSegment(a,c,d,g)&&(n=new cc.kmVec2,m=cc.KM_TRUE,n=cc.kmVec2Length(cc.kmVec2Subtract(n,g,a.start)),n<l&&(h.x=g.x,h.y=g.y,l=n,cc.calculate_line_normal(c,d,k)));cc.kmRay2IntersectLineSegment(a,
d,b,g)&&(n=new cc.kmVec2,m=cc.KM_TRUE,n=cc.kmVec2Length(cc.kmVec2Subtract(n,g,a.start)),n<l&&(h.x=g.x,h.y=g.y,cc.calculate_line_normal(d,b,k)));m&&(e.x=h.x,e.y=h.y,f&&(f.x=k.x,f.y=k.y));return m};cc.kmRay2IntersectCircle=function(a,b,c,d){cc.Assert(0,"Not implemented");return 0};var Float32Array=Float32Array||Array;cc.kmMat3=function(){this.mat=new Float32Array([0,0,0,0,0,0,0,0,0])};cc.kmMat3Fill=function(a,b){for(var c=0;9>c;c++)a.mat[c]=b;return a};
cc.kmMat3Adjugate=function(a,b){a.mat[0]=b.mat[4]*b.mat[8]-b.mat[5]*b.mat[7];a.mat[1]=b.mat[2]*b.mat[7]-b.mat[1]*b.mat[8];a.mat[2]=b.mat[1]*b.mat[5]-b.mat[2]*b.mat[4];a.mat[3]=b.mat[5]*b.mat[6]-b.mat[3]*b.mat[8];a.mat[4]=b.mat[0]*b.mat[8]-b.mat[2]*b.mat[6];a.mat[5]=b.mat[2]*b.mat[3]-b.mat[0]*b.mat[5];a.mat[6]=b.mat[3]*b.mat[7]-b.mat[4]*b.mat[6];a.mat[8]=b.mat[0]*b.mat[4]-b.mat[1]*b.mat[3];return a};
cc.kmMat3Identity=function(a){a.mat[1]=a.mat[2]=a.mat[3]=a.mat[5]=a.mat[6]=a.mat[7]=0;a.mat[0]=a.mat[4]=a.mat[8]=1;return a};cc.kmMat3Inverse=function(a,b,c){var d=new cc.kmMat3;if(0===b)return null;b=1/b;cc.kmMat3Adjugate(d,c);cc.kmMat3ScalarMultiply(a,d,b);return a};cc.kmMat3._identity=new Float32Array([1,0,0,0,1,0,0,0,1]);cc.kmMat3IsIdentity=function(a){for(var b=0;9>b;b++)if(cc.kmMat3._identity[b]!==a.mat[b])return!1;return!0};
cc.kmMat3Transpose=function(a,b){var c,d;for(c=0;3>c;++c)for(d=0;3>d;++d)a.mat[3*c+d]=b.mat[3*d+c];return a};cc.kmMat3Determinant=function(a){var b;b=a.mat[0]*a.mat[4]*a.mat[8]+a.mat[1]*a.mat[5]*a.mat[6]+a.mat[2]*a.mat[3]*a.mat[7];return b-=a.mat[2]*a.mat[4]*a.mat[6]+a.mat[0]*a.mat[5]*a.mat[7]+a.mat[1]*a.mat[3]*a.mat[8]};
cc.kmMat3Multiply=function(a,b,c){b=b.mat;c=c.mat;a.mat[0]=b[0]*c[0]+b[3]*c[1]+b[6]*c[2];a.mat[1]=b[1]*c[0]+b[4]*c[1]+b[7]*c[2];a.mat[2]=b[2]*c[0]+b[5]*c[1]+b[8]*c[2];a.mat[3]=b[0]*c[3]+b[3]*c[4]+b[6]*c[5];a.mat[4]=b[1]*c[3]+b[4]*c[4]+b[7]*c[5];a.mat[5]=b[2]*c[3]+b[5]*c[4]+b[8]*c[5];a.mat[6]=b[0]*c[6]+b[3]*c[7]+b[6]*c[8];a.mat[7]=b[1]*c[6]+b[4]*c[7]+b[7]*c[8];a.mat[8]=b[2]*c[6]+b[5]*c[7]+b[8]*c[8];return a};cc.kmMat3ScalarMultiply=function(a,b,c){for(var d=0;9>d;d++)a.mat[d]=b.mat[d]*c;return a};
cc.kmMat3RotationAxisAngle=function(a,b,c){var d=Math.cos(c);c=Math.sin(c);a.mat[0]=d+b.x*b.x*(1-d);a.mat[1]=b.z*c+b.y*b.x*(1-d);a.mat[2]=-b.y*c+b.z*b.x*(1-d);a.mat[3]=-b.z*c+b.x*b.y*(1-d);a.mat[4]=d+b.y*b.y*(1-d);a.mat[5]=b.x*c+b.z*b.y*(1-d);a.mat[6]=b.y*c+b.x*b.z*(1-d);a.mat[7]=-b.x*c+b.y*b.z*(1-d);a.mat[8]=d+b.z*b.z*(1-d);return a};cc.kmMat3Assign=function(a,b){cc.Assert(a!=b,"Is same object");for(var c=0;9>c;c++)a.mat[c]=b.mat[c];return a};
cc.kmMat3AreEqual=function(a,b){if(a==b)return!0;for(var c=0;9>c;++c)if(!(a.mat[c]+cc.kmEpsilon>b.mat[c]&&a.mat[c]-cc.kmEpsilon<b.mat[c]))return!1;return!0};cc.kmMat3RotationX=function(a,b){a.mat[0]=1;a.mat[1]=0;a.mat[2]=0;a.mat[3]=0;a.mat[4]=Math.cos(b);a.mat[5]=Math.sin(b);a.mat[6]=0;a.mat[7]=-Math.sin(b);a.mat[8]=Math.cos(b);return a};
cc.kmMat3RotationY=function(a,b){a.mat[0]=Math.cos(b);a.mat[1]=0;a.mat[2]=-Math.sin(b);a.mat[3]=0;a.mat[4]=1;a.mat[5]=0;a.mat[6]=Math.sin(b);a.mat[7]=0;a.mat[8]=Math.cos(b);return a};cc.kmMat3RotationZ=function(a,b){a.mat[0]=Math.cos(b);a.mat[1]=-Math.sin(b);a.mat[2]=0;a.mat[3]=Math.sin(b);a.mat[4]=Math.cos(b);a.mat[5]=0;a.mat[6]=0;a.mat[7]=0;a.mat[8]=1;return a};
cc.kmMat3Rotation=function(a,b){a.mat[0]=Math.cos(b);a.mat[1]=Math.sin(b);a.mat[2]=0;a.mat[3]=-Math.sin(b);a.mat[4]=Math.cos(b);a.mat[5]=0;a.mat[6]=0;a.mat[7]=0;a.mat[8]=1;return a};cc.kmMat3Scaling=function(a,b,c){cc.kmMat3Identity(a);a.mat[0]=b;a.mat[4]=c;return a};cc.kmMat3Translation=function(a,b,c){cc.kmMat3Identity(a);a.mat[6]=b;a.mat[7]=c;return a};
cc.kmMat3RotationQuaternion=function(a,b){if(!b||!a)return null;a.mat[0]=1-2*(b.y*b.y+b.z*b.z);a.mat[1]=2*(b.x*b.y-b.w*b.z);a.mat[2]=2*(b.x*b.z+b.w*b.y);a.mat[3]=2*(b.x*b.y+b.w*b.z);a.mat[4]=1-2*(b.x*b.x+b.z*b.z);a.mat[5]=2*(b.y*b.z-b.w*b.x);a.mat[6]=2*(b.x*b.z-b.w*b.y);a.mat[7]=2*(b.y*b.z+b.w*b.x);a.mat[8]=1-2*(b.x*b.x+b.y*b.y);return a};cc.kmMat3RotationToAxisAngle=function(a,b,c){cc.kmQuaternionRotationMatrix(void 0,c);cc.kmQuaternionToAxisAngle(void 0,a,b);return a};cc.kmMat4=function(){this.mat=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])};cc.kmMat4Fill=function(a,b){a.mat[0]=a.mat[1]=a.mat[2]=a.mat[3]=a.mat[4]=a.mat[5]=a.mat[6]=a.mat[7]=a.mat[8]=a.mat[9]=a.mat[10]=a.mat[11]=a.mat[12]=a.mat[13]=a.mat[14]=a.mat[15]=b};cc.kmMat4Identity=function(a){a.mat[1]=a.mat[2]=a.mat[3]=a.mat[4]=a.mat[6]=a.mat[7]=a.mat[8]=a.mat[9]=a.mat[11]=a.mat[12]=a.mat[13]=a.mat[14]=0;a.mat[0]=a.mat[5]=a.mat[10]=a.mat[15]=1;return a};
cc.kmMat4._get=function(a,b,c){return a.mat[b+4*c]};cc.kmMat4._set=function(a,b,c,d){a.mat[b+4*c]=d};cc.kmMat4._swap=function(a,b,c,d,e){var f=cc.kmMat4._get(a,b,c);cc.kmMat4._set(a,b,c,cc.kmMat4._get(a,d,e));cc.kmMat4._set(a,d,e,f)};
cc.kmMat4._gaussj=function(a,b){var c,d=0,e=0,f,g,h,k=[0,0,0,0],l=[0,0,0,0],m=[0,0,0,0];for(c=0;4>c;c++){for(f=h=0;4>f;f++)if(1!=m[f])for(g=0;4>g;g++)0==m[g]&&Math.abs(cc.kmMat4._get(a,f,g))>=h&&(h=Math.abs(cc.kmMat4._get(a,f,g)),e=f,d=g);++m[d];if(e!=d){for(f=0;4>f;f++)cc.kmMat4._swap(a,e,f,d,f);for(f=0;4>f;f++)cc.kmMat4._swap(b,e,f,d,f)}l[c]=e;k[c]=d;if(0==cc.kmMat4._get(a,d,d))return cc.KM_FALSE;g=1/cc.kmMat4._get(a,d,d);cc.kmMat4._set(a,d,d,1);for(f=0;4>f;f++)cc.kmMat4._set(a,d,f,cc.kmMat4._get(a,
d,f)*g);for(f=0;4>f;f++)cc.kmMat4._set(b,d,f,cc.kmMat4._get(b,d,f)*g);for(g=0;4>g;g++)if(g!=d){h=cc.kmMat4._get(a,g,d);cc.kmMat4._set(a,g,d,0);for(f=0;4>f;f++)cc.kmMat4._set(a,g,f,cc.kmMat4._get(a,g,f)-cc.kmMat4._get(a,d,f)*h);for(f=0;4>f;f++)cc.kmMat4._set(b,g,f,cc.kmMat4._get(a,g,f)-cc.kmMat4._get(b,d,f)*h)}}for(f=3;0<=f;f--)if(l[f]!=k[f])for(g=0;4>g;g++)cc.kmMat4._swap(a,g,l[f],g,k[f]);return cc.KM_TRUE};cc.kmMat4._identity=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
cc.kmMat4Inverse=function(a,b){var c=new cc.kmMat4,d=new cc.kmMat4;cc.kmMat4Assign(c,b);cc.kmMat4Identity(d);if(cc.kmMat4._gaussj(c,d)==cc.KM_FALSE)return null;cc.kmMat4Assign(a,c);return a};cc.kmMat4IsIdentity=function(a){for(var b=0;16>b;b++)if(cc.kmMat4._identity[b]!=a.mat[b])return!1;return!0};cc.kmMat4Transpose=function(a,b){var c,d;for(d=0;4>d;++d)for(c=0;4>c;++c)a.mat[4*d+c]=b.mat[4*c+d];return a};
cc.kmMat4Multiply=function(a,b,c){var d=b.mat[0],e=b.mat[1],f=b.mat[2],g=b.mat[3],h=b.mat[4],k=b.mat[5],l=b.mat[6],m=b.mat[7],n=b.mat[8],q=b.mat[9],s=b.mat[10],v=b.mat[11],t=b.mat[12],z=b.mat[13],x=b.mat[14];b=b.mat[15];var C=c.mat[0],D=c.mat[1],y=c.mat[2],w=c.mat[3],u=c.mat[4],r=c.mat[5],B=c.mat[6],E=c.mat[7],G=c.mat[8],F=c.mat[9],I=c.mat[10],K=c.mat[11],J=c.mat[12],L=c.mat[13],H=c.mat[14];c=c.mat[15];a.mat[0]=C*d+D*h+y*n+w*t;a.mat[1]=C*e+D*k+y*q+w*z;a.mat[2]=C*f+D*l+y*s+w*x;a.mat[3]=C*g+D*m+y*v+
w*b;a.mat[4]=u*d+r*h+B*n+E*t;a.mat[5]=u*e+r*k+B*q+E*z;a.mat[6]=u*f+r*l+B*s+E*x;a.mat[7]=u*g+r*m+B*v+E*b;a.mat[8]=G*d+F*h+I*n+K*t;a.mat[9]=G*e+F*k+I*q+K*z;a.mat[10]=G*f+F*l+I*s+K*x;a.mat[11]=G*g+F*m+I*v+K*b;a.mat[12]=J*d+L*h+H*n+c*t;a.mat[13]=J*e+L*k+H*q+c*z;a.mat[14]=J*f+L*l+H*s+c*x;a.mat[15]=J*g+L*m+H*v+c*b;return a};
cc.getMat4MultiplyValue=function(a,b){var c=a.mat,d=b.mat,e=new Float32Array(16);e[0]=c[0]*d[0]+c[4]*d[1]+c[8]*d[2]+c[12]*d[3];e[1]=c[1]*d[0]+c[5]*d[1]+c[9]*d[2]+c[13]*d[3];e[2]=c[2]*d[0]+c[6]*d[1]+c[10]*d[2]+c[14]*d[3];e[3]=c[3]*d[0]+c[7]*d[1]+c[11]*d[2]+c[15]*d[3];e[4]=c[0]*d[4]+c[4]*d[5]+c[8]*d[6]+c[12]*d[7];e[5]=c[1]*d[4]+c[5]*d[5]+c[9]*d[6]+c[13]*d[7];e[6]=c[2]*d[4]+c[6]*d[5]+c[10]*d[6]+c[14]*d[7];e[7]=c[3]*d[4]+c[7]*d[5]+c[11]*d[6]+c[15]*d[7];e[8]=c[0]*d[8]+c[4]*d[9]+c[8]*d[10]+c[12]*d[11];
e[9]=c[1]*d[8]+c[5]*d[9]+c[9]*d[10]+c[13]*d[11];e[10]=c[2]*d[8]+c[6]*d[9]+c[10]*d[10]+c[14]*d[11];e[11]=c[3]*d[8]+c[7]*d[9]+c[11]*d[10]+c[15]*d[11];e[12]=c[0]*d[12]+c[4]*d[13]+c[8]*d[14]+c[12]*d[15];e[13]=c[1]*d[12]+c[5]*d[13]+c[9]*d[14]+c[13]*d[15];e[14]=c[2]*d[12]+c[6]*d[13]+c[10]*d[14]+c[14]*d[15];e[15]=c[3]*d[12]+c[7]*d[13]+c[11]*d[14]+c[15]*d[15];return e};
cc.getMat4MultiplyWithMat4=function(a,b,c){a=a.mat;b=b.mat;var d=c.mat;d[0]=a[0]*b[0]+a[4]*b[1]+a[8]*b[2]+a[12]*b[3];d[1]=a[1]*b[0]+a[5]*b[1]+a[9]*b[2]+a[13]*b[3];d[2]=a[2]*b[0]+a[6]*b[1]+a[10]*b[2]+a[14]*b[3];d[3]=a[3]*b[0]+a[7]*b[1]+a[11]*b[2]+a[15]*b[3];d[4]=a[0]*b[4]+a[4]*b[5]+a[8]*b[6]+a[12]*b[7];d[5]=a[1]*b[4]+a[5]*b[5]+a[9]*b[6]+a[13]*b[7];d[6]=a[2]*b[4]+a[6]*b[5]+a[10]*b[6]+a[14]*b[7];d[7]=a[3]*b[4]+a[7]*b[5]+a[11]*b[6]+a[15]*b[7];d[8]=a[0]*b[8]+a[4]*b[9]+a[8]*b[10]+a[12]*b[11];d[9]=a[1]*
b[8]+a[5]*b[9]+a[9]*b[10]+a[13]*b[11];d[10]=a[2]*b[8]+a[6]*b[9]+a[10]*b[10]+a[14]*b[11];d[11]=a[3]*b[8]+a[7]*b[9]+a[11]*b[10]+a[15]*b[11];d[12]=a[0]*b[12]+a[4]*b[13]+a[8]*b[14]+a[12]*b[15];d[13]=a[1]*b[12]+a[5]*b[13]+a[9]*b[14]+a[13]*b[15];d[14]=a[2]*b[12]+a[6]*b[13]+a[10]*b[14]+a[14]*b[15];d[15]=a[3]*b[12]+a[7]*b[13]+a[11]*b[14]+a[15]*b[15];return c.mat};
cc.kmMat4Assign=function(a,b){a.mat[0]=b.mat[0];a.mat[1]=b.mat[1];a.mat[2]=b.mat[2];a.mat[3]=b.mat[3];a.mat[4]=b.mat[4];a.mat[5]=b.mat[5];a.mat[6]=b.mat[6];a.mat[7]=b.mat[7];a.mat[8]=b.mat[8];a.mat[9]=b.mat[9];a.mat[10]=b.mat[10];a.mat[11]=b.mat[11];a.mat[12]=b.mat[12];a.mat[13]=b.mat[13];a.mat[14]=b.mat[14];a.mat[15]=b.mat[15];return a};
cc.kmMat4AreEqual=function(a,b){cc.Assert(a!=b,"You are comparing the same thing!");for(var c=0;16>c;c++)if(!(a.mat[c]+cc.kmEpsilon>b.mat[c]&&a.mat[c]-cc.kmEpsilon<b.mat[c]))return!1;return!0};cc.kmMat4RotationX=function(a,b){a.mat[0]=1;a.mat[1]=0;a.mat[2]=0;a.mat[3]=0;a.mat[4]=0;a.mat[5]=Math.cos(b);a.mat[6]=Math.sin(b);a.mat[7]=0;a.mat[8]=0;a.mat[9]=-Math.sin(b);a.mat[10]=Math.cos(b);a.mat[11]=0;a.mat[12]=0;a.mat[13]=0;a.mat[14]=0;a.mat[15]=1;return a};
cc.kmMat4RotationY=function(a,b){a.mat[0]=Math.cos(b);a.mat[1]=0;a.mat[2]=-Math.sin(b);a.mat[3]=0;a.mat[4]=0;a.mat[5]=1;a.mat[6]=0;a.mat[7]=0;a.mat[8]=Math.sin(b);a.mat[9]=0;a.mat[10]=Math.cos(b);a.mat[11]=0;a.mat[12]=0;a.mat[13]=0;a.mat[14]=0;a.mat[15]=1;return a};
cc.kmMat4RotationZ=function(a,b){a.mat[0]=Math.cos(b);a.mat[1]=Math.sin(b);a.mat[2]=0;a.mat[3]=0;a.mat[4]=-Math.sin(b);a.mat[5]=Math.cos(b);a.mat[6]=0;a.mat[7]=0;a.mat[8]=0;a.mat[9]=0;a.mat[10]=1;a.mat[11]=0;a.mat[12]=0;a.mat[13]=0;a.mat[14]=0;a.mat[15]=1;return a};
cc.kmMat4RotationPitchYawRoll=function(a,b,c,d){var e=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=b*c,k=e*c;a.mat[0]=f*g;a.mat[4]=f*d;a.mat[8]=-c;a.mat[1]=h*g-e*d;a.mat[5]=h*d+e*g;a.mat[9]=b*f;a.mat[2]=k*g+b*d;a.mat[6]=k*d-b*g;a.mat[10]=e*f;a.mat[3]=a.mat[7]=a.mat[11]=0;a.mat[15]=1;return a};
cc.kmMat4RotationQuaternion=function(a,b){a.mat[0]=1-2*(b.y*b.y+b.z*b.z);a.mat[1]=2*(b.x*b.y+b.z*b.w);a.mat[2]=2*(b.x*b.z-b.y*b.w);a.mat[3]=0;a.mat[4]=2*(b.x*b.y-b.z*b.w);a.mat[5]=1-2*(b.x*b.x+b.z*b.z);a.mat[6]=2*(b.z*b.y+b.x*b.w);a.mat[7]=0;a.mat[8]=2*(b.x*b.z+b.y*b.w);a.mat[9]=2*(b.y*b.z-b.x*b.w);a.mat[10]=1-2*(b.x*b.x+b.y*b.y);a.mat[11]=0;a.mat[12]=0;a.mat[13]=0;a.mat[14]=0;a.mat[15]=1;return a};
cc.kmMat4RotationTranslation=function(a,b,c){a.mat[0]=b.mat[0];a.mat[1]=b.mat[1];a.mat[2]=b.mat[2];a.mat[3]=0;a.mat[4]=b.mat[3];a.mat[5]=b.mat[4];a.mat[6]=b.mat[5];a.mat[7]=0;a.mat[8]=b.mat[6];a.mat[9]=b.mat[7];a.mat[10]=b.mat[8];a.mat[11]=0;a.mat[12]=c.x;a.mat[13]=c.y;a.mat[14]=c.z;a.mat[15]=1;return a};
cc.kmMat4Scaling=function(a,b,c,d){a.mat[0]=b;a.mat[5]=c;a.mat[10]=d;a.mat[15]=1;a.mat[1]=a.mat[2]=a.mat[3]=a.mat[4]=a.mat[6]=a.mat[7]=a.mat[8]=a.mat[9]=a.mat[11]=a.mat[12]=a.mat[13]=a.mat[14]=0;return a};cc.kmMat4Translation=function(a,b,c,d){a.mat[0]=a.mat[5]=a.mat[10]=a.mat[15]=1;a.mat[1]=a.mat[2]=a.mat[3]=a.mat[4]=a.mat[6]=a.mat[7]=a.mat[8]=a.mat[9]=a.mat[11]=0;a.mat[12]=b;a.mat[13]=c;a.mat[14]=d;return a};
cc.kmMat4GetUpVec3=function(a,b){a.x=b.mat[4];a.y=b.mat[5];a.z=b.mat[6];cc.kmVec3Normalize(a,a);return a};cc.kmMat4GetRightVec3=function(a,b){a.x=b.mat[0];a.y=b.mat[1];a.z=b.mat[2];cc.kmVec3Normalize(a,a);return a};cc.kmMat4GetForwardVec3=function(a,b){a.x=b.mat[8];a.y=b.mat[9];a.z=b.mat[10];cc.kmVec3Normalize(a,a);return a};
cc.kmMat4PerspectiveProjection=function(a,b,c,d,e){var f=cc.kmDegreesToRadians(b/2);b=e-d;var g=Math.sin(f);if(0==b||0==g||0==c)return null;f=Math.cos(f)/g;cc.kmMat4Identity(a);a.mat[0]=f/c;a.mat[5]=f;a.mat[10]=-(e+d)/b;a.mat[11]=-1;a.mat[14]=-2*d*e/b;a.mat[15]=0;return a};cc.kmMat4OrthographicProjection=function(a,b,c,d,e,f,g){cc.kmMat4Identity(a);a.mat[0]=2/(c-b);a.mat[5]=2/(e-d);a.mat[10]=-2/(g-f);a.mat[12]=-((c+b)/(c-b));a.mat[13]=-((e+d)/(e-d));a.mat[14]=-((g+f)/(g-f));return a};
cc.kmMat4LookAt=function(a,b,c,d){var e=new cc.kmVec3,f=new cc.kmVec3,g=new cc.kmVec3,h=new cc.kmVec3,k=new cc.kmMat4;cc.kmVec3Subtract(e,c,b);cc.kmVec3Normalize(e,e);cc.kmVec3Assign(f,d);cc.kmVec3Normalize(f,f);cc.kmVec3Cross(g,e,f);cc.kmVec3Normalize(g,g);cc.kmVec3Cross(h,g,e);cc.kmVec3Normalize(g,g);cc.kmMat4Identity(a);a.mat[0]=g.x;a.mat[4]=g.y;a.mat[8]=g.z;a.mat[1]=h.x;a.mat[5]=h.y;a.mat[9]=h.z;a.mat[2]=-e.x;a.mat[6]=-e.y;a.mat[10]=-e.z;cc.kmMat4Translation(k,-b.x,-b.y,-b.z);cc.kmMat4Multiply(a,
a,k);return a};cc.kmMat4RotationAxisAngle=function(a,b,c){var d=Math.cos(c);c=Math.sin(c);var e=new cc.kmVec3;cc.kmVec3Normalize(e,b);a.mat[0]=d+e.x*e.x*(1-d);a.mat[1]=e.z*c+e.y*e.x*(1-d);a.mat[2]=-e.y*c+e.z*e.x*(1-d);a.mat[3]=0;a.mat[4]=-e.z*c+e.x*e.y*(1-d);a.mat[5]=d+e.y*e.y*(1-d);a.mat[6]=e.x*c+e.z*e.y*(1-d);a.mat[7]=0;a.mat[8]=e.y*c+e.x*e.z*(1-d);a.mat[9]=-e.x*c+e.y*e.z*(1-d);a.mat[10]=d+e.z*e.z*(1-d);a.mat[11]=0;a.mat[12]=0;a.mat[13]=0;a.mat[14]=0;a.mat[15]=1;return a};
cc.kmMat4ExtractRotation=function(a,b){a.mat[0]=b.mat[0];a.mat[1]=b.mat[1];a.mat[2]=b.mat[2];a.mat[3]=b.mat[4];a.mat[4]=b.mat[5];a.mat[5]=b.mat[6];a.mat[6]=b.mat[8];a.mat[7]=b.mat[9];a.mat[8]=b.mat[10];return a};
cc.kmMat4ExtractPlane=function(a,b,c){switch(c){case cc.KM_PLANE_RIGHT:a.a=b.mat[3]-b.mat[0];a.b=b.mat[7]-b.mat[4];a.c=b.mat[11]-b.mat[8];a.d=b.mat[15]-b.mat[12];break;case cc.KM_PLANE_LEFT:a.a=b.mat[3]+b.mat[0];a.b=b.mat[7]+b.mat[4];a.c=b.mat[11]+b.mat[8];a.d=b.mat[15]+b.mat[12];break;case cc.KM_PLANE_BOTTOM:a.a=b.mat[3]+b.mat[1];a.b=b.mat[7]+b.mat[5];a.c=b.mat[11]+b.mat[9];a.d=b.mat[15]+b.mat[13];break;case cc.KM_PLANE_TOP:a.a=b.mat[3]-b.mat[1];a.b=b.mat[7]-b.mat[5];a.c=b.mat[11]-b.mat[9];a.d=b.mat[15]-
b.mat[13];break;case cc.KM_PLANE_FAR:a.a=b.mat[3]-b.mat[2];a.b=b.mat[7]-b.mat[6];a.c=b.mat[11]-b.mat[10];a.d=b.mat[15]-b.mat[14];break;case cc.KM_PLANE_NEAR:a.a=b.mat[3]+b.mat[2];a.b=b.mat[7]+b.mat[6];a.c=b.mat[11]+b.mat[10];a.d=b.mat[15]+b.mat[14];break;default:cc.Assert(0,"Invalid plane index")}b=Math.sqrt(a.a*a.a+a.b*a.b+a.c*a.c);a.a/=b;a.b/=b;a.c/=b;a.d/=b;return a};
cc.kmMat4RotationToAxisAngle=function(a,b,c){var d=new cc.kmQuaternion,e=new cc.kmMat3;cc.kmMat4ExtractRotation(e,c);cc.kmQuaternionRotationMatrix(d,e);cc.kmQuaternionToAxisAngle(d,a,b);return a};cc.KM_PLANE_LEFT=0;cc.KM_PLANE_RIGHT=1;cc.KM_PLANE_BOTTOM=2;cc.KM_PLANE_TOP=3;cc.KM_PLANE_NEAR=4;cc.KM_PLANE_FAR=5;cc.kmPlane=function(a,b,c,d){this.a=a||0;this.b=b||0;this.c=c||0;this.d=d||0};cc.POINT_INFRONT_OF_PLANE=0;cc.POINT_BEHIND_PLANE=1;cc.POINT_ON_PLANE=2;cc.kmPlaneDot=function(a,b){return a.a*b.x+a.b*b.y+a.c*b.z+a.d*b.w};cc.kmPlaneDotCoord=function(a,b){return a.a*b.x+a.b*b.y+a.c*b.z+a.d};cc.kmPlaneDotNormal=function(a,b){return a.a*b.x+a.b*b.y+a.c*b.z};
cc.kmPlaneFromPointNormal=function(a,b,c){a.a=c.x;a.b=c.y;a.c=c.z;a.d=-cc.kmVec3Dot(c,b);return a};cc.kmPlaneFromPoints=function(a,b,c,d){var e=new cc.kmVec3,f=new cc.kmVec3,g=new cc.kmVec3;cc.kmVec3Subtract(f,c,b);cc.kmVec3Subtract(g,d,b);cc.kmVec3Cross(e,f,g);cc.kmVec3Normalize(e,e);a.a=e.x;a.b=e.y;a.c=e.z;a.d=cc.kmVec3Dot(cc.kmVec3Scale(e,e,-1),b);return a};cc.kmPlaneIntersectLine=function(a,b,c,d){a=new cc.kmVec3;cc.Assert(0,"Not implemented");cc.kmVec3Subtract(a,d,c);return null};
cc.kmPlaneNormalize=function(a,b){var c=new cc.kmVec3;c.x=b.a;c.y=b.b;c.z=b.c;var d=1/cc.kmVec3Length(c);cc.kmVec3Normalize(c,c);a.a=c.x;a.b=c.y;a.c=c.z;a.d=b.d*d;return a};cc.kmPlaneScale=function(a,b,c){cc.Assert(0,"Not implemented");return null};cc.kmPlaneClassifyPoint=function(a,b){var c=a.a*b.x+a.b*b.y+a.c*b.z+a.d;return 0.0010<c?cc.POINT_INFRONT_OF_PLANE:-0.0010>c?cc.POINT_BEHIND_PLANE:cc.POINT_ON_PLANE};cc.kmQuaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||0};cc.kmQuaternionConjugate=function(a,b){a.x=-b.x;a.y=-b.y;a.z=-b.z;a.w=b.w;return a};cc.kmQuaternionDot=function(a,b){return a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z};cc.kmQuaternionExp=function(a,b){return a};cc.kmQuaternionIdentity=function(a){a.x=0;a.y=0;a.z=0;a.w=1;return a};
cc.kmQuaternionInverse=function(a,b){var c=cc.kmQuaternionLength(b),d=new cc.kmQuaternion;if(Math.abs(c)>cc.kmEpsilon)return a.x=0,a.y=0,a.z=0,a.w=0,a;cc.kmQuaternionScale(a,cc.kmQuaternionConjugate(d,b),1/c);return a};cc.kmQuaternionIsIdentity=function(a){return 0==a.x&&0==a.y&&0==a.z&&1==a.w};cc.kmQuaternionLength=function(a){return Math.sqrt(cc.kmQuaternionLengthSq(a))};cc.kmQuaternionLengthSq=function(a){return a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w};cc.kmQuaternionLn=function(a,b){return a};
cc.kmQuaternionMultiply=function(a,b,c){a.w=b.w*c.w-b.x*c.x-b.y*c.y-b.z*c.z;a.x=b.w*c.x+b.x*c.w+b.y*c.z-b.z*c.y;a.y=b.w*c.y+b.y*c.w+b.z*c.x-b.x*c.z;a.z=b.w*c.z+b.z*c.w+b.x*c.y-b.y*c.x;return a};cc.kmQuaternionNormalize=function(a,b){var c=cc.kmQuaternionLength(b);cc.Assert(Math.abs(c)>cc.kmEpsilon,"");cc.kmQuaternionScale(a,b,1/c);return a};cc.kmQuaternionRotationAxis=function(a,b,c){c*=0.5;var d=Math.sin(c);a.w=Math.cos(c);a.x=b.x*d;a.y=b.y*d;a.z=b.z*d;return a};
cc.kmQuaternionRotationMatrix=function(a,b){var c,d,e,f;c=[];d=f=0;if(!b)return null;c[0]=b.mat[0];c[1]=b.mat[3];c[2]=b.mat[6];c[4]=b.mat[1];c[5]=b.mat[4];c[6]=b.mat[7];c[8]=b.mat[2];c[9]=b.mat[5];c[10]=b.mat[8];c[15]=1;var g=c[0];d=g[0]+g[5]+g[10]+1;d>cc.kmEpsilon?(f=2*Math.sqrt(d),c=(g[9]-g[6])/f,d=(g[2]-g[8])/f,e=(g[4]-g[1])/f,f*=0.25):g[0]>g[5]&&g[0]>g[10]?(f=2*Math.sqrt(1+g[0]-g[5]-g[10]),c=0.25*f,d=(g[4]+g[1])/f,e=(g[2]+g[8])/f,f=(g[9]-g[6])/f):g[5]>g[10]?(f=2*Math.sqrt(1+g[5]-g[0]-g[10]),c=
(g[4]+g[1])/f,d=0.25*f,e=(g[9]+g[6])/f,f=(g[2]-g[8])/f):(f=2*Math.sqrt(1+g[10]-g[0]-g[5]),c=(g[2]+g[8])/f,d=(g[9]+g[6])/f,e=0.25*f,f=(g[4]-g[1])/f);a.x=c;a.y=d;a.z=e;a.w=f;return a};
cc.kmQuaternionRotationYawPitchRoll=function(a,b,c,d){var e,f,g,h,k;e=cc.kmDegreesToRadians(c)/2;f=cc.kmDegreesToRadians(b)/2;g=cc.kmDegreesToRadians(d)/2;d=Math.cos(e);b=Math.cos(f);c=Math.cos(g);e=Math.sin(e);f=Math.sin(f);g=Math.sin(g);h=b*c;k=f*g;a.w=d*h+e*k;a.x=e*h-d*k;a.y=d*f*c+e*b*g;a.z=d*b*g-e*f*c;cc.kmQuaternionNormalize(a,a);return a};
cc.kmQuaternionSlerp=function(a,b,c,d){if(b.x==c.x&&b.y==c.y&&b.z==c.z&&b.w==c.w)return a.x=b.x,a.y=b.y,a.z=b.z,a.w=b.w,a;var e=cc.kmQuaternionDot(b,c),f=Math.acos(e),g=Math.sqrt(1-cc.kmSQR(e)),e=Math.sin(d*f)/g;d=Math.sin((1-d)*f)/g;f=new cc.kmQuaternion;g=new cc.kmQuaternion;cc.kmQuaternionScale(f,b,d);cc.kmQuaternionScale(g,c,e);cc.kmQuaternionAdd(a,f,g);return a};
cc.kmQuaternionToAxisAngle=function(a,b,c){Math.acos(a.w);c=Math.sqrt(cc.kmSQR(a.x)+cc.kmSQR(a.y)+cc.kmSQR(a.z));c>-cc.kmEpsilon&&c<cc.kmEpsilon||c<2*cc.kmPI+cc.kmEpsilon&&c>2*cc.kmPI-cc.kmEpsilon?(b.x=0,b.y=0,b.z=1):(b.x=a.x/c,b.y=a.y/c,b.z=a.z/c,cc.kmVec3Normalize(b,b))};cc.kmQuaternionScale=function(a,b,c){a.x=b.x*c;a.y=b.y*c;a.z=b.z*c;a.w=b.w*c;return a};cc.kmQuaternionAssign=function(a,b){a.x=b.x;a.y=b.y;a.z=b.z;a.w=b.w;return a};
cc.kmQuaternionAdd=function(a,b,c){a.x=b.x+c.x;a.y=b.y+c.y;a.z=b.z+c.z;a.w=b.w+c.w;return a};
cc.kmQuaternionRotationBetweenVec3=function(a,b,c,d){var e=new cc.kmVec3,f=new cc.kmVec3;cc.kmVec3Assign(e,b);cc.kmVec3Assign(f,c);cc.kmVec3Normalize(e,e);cc.kmVec3Normalize(f,f);c=cc.kmVec3Dot(e,f);if(1<=c)return cc.kmQuaternionIdentity(a),a;-0.999999>c?Math.abs(cc.kmVec3LengthSq(d))<cc.kmEpsilon?cc.kmQuaternionRotationAxis(a,d,cc.kmPI):(e=new cc.kmVec3,f=new cc.kmVec3,f.x=1,f.y=0,f.z=0,cc.kmVec3Cross(e,f,b),Math.abs(cc.kmVec3LengthSq(e))<cc.kmEpsilon&&(f=new cc.kmVec3,f.x=0,f.y=1,f.z=0,cc.kmVec3Cross(e,
f,b)),cc.kmVec3Normalize(e,e),cc.kmQuaternionRotationAxis(a,e,cc.kmPI)):(b=Math.sqrt(2*(1+c)),d=1/b,c=new cc.kmVec3,cc.kmVec3Cross(c,e,f),a.x=c.x*d,a.y=c.y*d,a.z=c.z*d,a.w=0.5*b,cc.kmQuaternionNormalize(a,a));return a};cc.kmQuaternionMultiplyVec3=function(a,b,c){var d=new cc.kmVec3,e=new cc.kmVec3,f=new cc.kmVec3;f.x=b.x;f.y=b.y;f.z=b.z;cc.kmVec3Cross(d,f,c);cc.kmVec3Cross(e,f,d);cc.kmVec3Scale(d,d,2*b.w);cc.kmVec3Scale(e,e,2);cc.kmVec3Add(a,c,d);cc.kmVec3Add(a,a,e);return a};cc.kmAABB=function(a,b){this.min=a||new cc.kmVec3;this.max=b||new cc.kmVec3};cc.kmAABBContainsPoint=function(a,b){return a.x>=b.min.x&&a.x<=b.max.x&&a.y>=b.min.y&&a.y<=b.max.y&&a.z>=b.min.z&&a.z<=b.max.z?cc.KM_TRUE:cc.KM_FALSE};cc.kmAABBAssign=function(a,b){cc.kmVec3Assign(a.min,b.min);cc.kmVec3Assign(a.max,b.max);return a};cc.kmAABBScale=function(a,b,c){cc.Assert(0,"Not implemented");return 0};cc.km_mat4_stack=function(a,b,c,d){this.top=c;this.stack=d};cc.km_mat4_stack.INITIAL_SIZE=30;cc.km_mat4_stack_initialize=function(a){a.stack=[];a.top=null};cc.km_mat4_stack_push=function(a,b){a.stack.push(a.top);a.top=new cc.kmMat4;cc.kmMat4Assign(a.top,b)};cc.km_mat4_stack_pop=function(a,b){a.top=a.stack.pop()};cc.km_mat4_stack_release=function(a){a.stack=null;a.top=null};cc.KM_GL_MODELVIEW=5888;cc.KM_GL_PROJECTION=5889;cc.KM_GL_TEXTURE=5890;cc.modelview_matrix_stack=new cc.km_mat4_stack;cc.projection_matrix_stack=new cc.km_mat4_stack;cc.texture_matrix_stack=new cc.km_mat4_stack;cc.current_stack=null;cc.initialized=!1;
cc.lazyInitialize=function(){if(!cc.initialized){var a=new cc.kmMat4;cc.km_mat4_stack_initialize(cc.modelview_matrix_stack);cc.km_mat4_stack_initialize(cc.projection_matrix_stack);cc.km_mat4_stack_initialize(cc.texture_matrix_stack);cc.current_stack=cc.modelview_matrix_stack;cc.initialized=!0;cc.kmMat4Identity(a);cc.km_mat4_stack_push(cc.modelview_matrix_stack,a);cc.km_mat4_stack_push(cc.projection_matrix_stack,a);cc.km_mat4_stack_push(cc.texture_matrix_stack,a)}};cc.lazyInitialize();
cc.kmGLFreeAll=function(){cc.km_mat4_stack_release(cc.modelview_matrix_stack);cc.km_mat4_stack_release(cc.projection_matrix_stack);cc.km_mat4_stack_release(cc.texture_matrix_stack);cc.initialized=!1;cc.current_stack=null};cc.kmGLPushMatrix=function(){cc.km_mat4_stack_push(cc.current_stack,cc.current_stack.top)};cc.kmGLPushMatrixWitMat4=function(a){cc.current_stack.stack.push(cc.current_stack.top);cc.kmMat4Assign(a,cc.current_stack.top);cc.current_stack.top=a};
cc.kmGLPopMatrix=function(){cc.current_stack.top=cc.current_stack.stack.pop()};cc.kmGLMatrixMode=function(a){switch(a){case cc.KM_GL_MODELVIEW:cc.current_stack=cc.modelview_matrix_stack;break;case cc.KM_GL_PROJECTION:cc.current_stack=cc.projection_matrix_stack;break;case cc.KM_GL_TEXTURE:cc.current_stack=cc.texture_matrix_stack;break;default:cc.Assert(0,"Invalid matrix mode specified")}};cc.kmGLLoadIdentity=function(){cc.kmMat4Identity(cc.current_stack.top)};
cc.kmGLLoadMatrix=function(a){cc.kmMat4Assign(cc.current_stack.top,a)};cc.kmGLMultMatrix=function(a){cc.kmMat4Multiply(cc.current_stack.top,cc.current_stack.top,a)};cc.kmGLTranslatef=function(a,b,c){var d=new cc.kmMat4;cc.kmMat4Translation(d,a,b,c);cc.kmMat4Multiply(cc.current_stack.top,cc.current_stack.top,d)};
cc.kmGLRotatef=function(a,b,c,d){b=new cc.kmVec3(b,c,d);c=new cc.kmMat4;cc.kmMat4RotationAxisAngle(c,b,cc.kmDegreesToRadians(a));cc.kmMat4Multiply(cc.current_stack.top,cc.current_stack.top,c)};cc.kmGLScalef=function(a,b,c){var d=new cc.kmMat4;cc.kmMat4Scaling(d,a,b,c);cc.kmMat4Multiply(cc.current_stack.top,cc.current_stack.top,d)};
cc.kmGLGetMatrix=function(a,b){switch(a){case cc.KM_GL_MODELVIEW:cc.kmMat4Assign(b,cc.modelview_matrix_stack.top);break;case cc.KM_GL_PROJECTION:cc.kmMat4Assign(b,cc.projection_matrix_stack.top);break;case cc.KM_GL_TEXTURE:cc.kmMat4Assign(b,cc.texture_matrix_stack.top);break;default:cc.Assert(1,"Invalid matrix mode specified")}};cc.AffineTransform=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.tx=e;this.ty=f};cc.__AffineTransformMake=function(a,b,c,d,e,f){return{a:a,b:b,c:c,d:d,tx:e,ty:f}};cc.AffineTransformMake=function(a,b,c,d,e,f){return{a:a,b:b,c:c,d:d,tx:e,ty:f}};cc.__PointApplyAffineTransform=function(a,b){return{x:b.a*a.x+b.c*a.y+b.tx,y:b.b*a.x+b.d*a.y+b.ty}};cc.PointApplyAffineTransform=function(a,b){return{x:b.a*a.x+b.c*a.y+b.tx,y:b.b*a.x+b.d*a.y+b.ty}};
cc.__SizeApplyAffineTransform=function(a,b){return{width:b.a*a.width+b.c*a.height,height:b.b*a.width+b.d*a.height}};cc.SizeApplyAffineTransform=function(a,b){return{width:b.a*a.width+b.c*a.height,height:b.b*a.width+b.d*a.height}};cc.AffineTransformMakeIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}};cc.AffineTransformIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}};
cc.RectApplyAffineTransform=function(a,b){var c=cc.Rect.CCRectGetMinY(a),d=cc.Rect.CCRectGetMinX(a),e=cc.Rect.CCRectGetMaxX(a),f=cc.Rect.CCRectGetMaxY(a),g=cc.PointApplyAffineTransform(cc.p(d,c),b),c=cc.PointApplyAffineTransform(cc.p(e,c),b),d=cc.PointApplyAffineTransform(cc.p(d,f),b),h=cc.PointApplyAffineTransform(cc.p(e,f),b),e=Math.min(Math.min(g.x,c.x),Math.min(d.x,h.x)),f=Math.max(Math.max(g.x,c.x),Math.max(d.x,h.x)),k=Math.min(Math.min(g.y,c.y),Math.min(d.y,h.y)),g=Math.max(Math.max(g.y,c.y),
Math.max(d.y,h.y));return cc.rect(e,k,f-e,g-k)};cc.AffineTransformTranslate=function(a,b,c){return{a:a.a,b:a.b,c:a.c,d:a.d,tx:a.tx+a.a*b+a.c*c,ty:a.ty+a.b*b+a.d*c}};cc.AffineTransformScale=function(a,b,c){return{a:a.a*b,b:a.b*b,c:a.c*c,d:a.d*c,tx:a.tx,ty:a.ty}};cc.AffineTransformRotate=function(a,b){var c=Math.sin(b),d=Math.cos(b);return{a:a.a*d+a.c*c,b:a.b*d+a.d*c,c:a.c*d-a.a*c,d:a.d*d-a.b*c,tx:a.tx,ty:a.ty}};
cc.AffineTransformConcat=function(a,b){return{a:a.a*b.a+a.b*b.c,b:a.a*b.b+a.b*b.d,c:a.c*b.a+a.d*b.c,d:a.c*b.b+a.d*b.d,tx:a.tx*b.a+a.ty*b.c+b.tx,ty:a.tx*b.b+a.ty*b.d+b.ty}};cc.AffineTransformEqualToTransform=function(a,b){return a.a===b.a&&a.b===b.b&&a.c===b.c&&a.d===b.d&&a.tx===b.tx&&a.ty===b.ty};cc.AffineTransformInvert=function(a){var b=1/(a.a*a.d-a.b*a.c);return{a:b*a.d,b:-b*a.b,c:-b*a.c,d:b*a.a,tx:b*(a.c*a.ty-a.d*a.tx),ty:b*(a.b*a.tx-a.a*a.ty)}};cc.POINT_EPSILON=parseFloat("1.192092896e-07F");cc.pNeg=function(a){return cc.p(-a.x,-a.y)};cc.pAdd=function(a,b){return cc.p(a.x+b.x,a.y+b.y)};cc.pSub=function(a,b){return cc.p(a.x-b.x,a.y-b.y)};cc.pMult=function(a,b){return cc.p(a.x*b,a.y*b)};cc.pMidpoint=function(a,b){return cc.pMult(cc.pAdd(a,b),0.5)};cc.pDot=function(a,b){return a.x*b.x+a.y*b.y};cc.pCross=function(a,b){return a.x*b.y-a.y*b.x};cc.pPerp=function(a){return cc.p(-a.y,a.x)};cc.pRPerp=function(a){return cc.p(a.y,-a.x)};
cc.pProject=function(a,b){return cc.pMult(b,cc.pDot(a,b)/cc.pDot(b,b))};cc.pRotate=function(a,b){return cc.p(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x)};cc.pUnrotate=function(a,b){return cc.p(a.x*b.x+a.y*b.y,a.y*b.x-a.x*b.y)};cc.pLengthSQ=function(a){return cc.pDot(a,a)};cc.pDistanceSQ=function(a,b){return cc.pLengthSQ(cc.pSub(a,b))};cc.pLength=function(a){return Math.sqrt(cc.pLengthSQ(a))};cc.pDistance=function(a,b){return cc.pLength(cc.pSub(a,b))};cc.pNormalize=function(a){return cc.pMult(a,1/cc.pLength(a))};
cc.pForAngle=function(a){return cc.p(Math.cos(a),Math.sin(a))};cc.pToAngle=function(a){return Math.atan2(a.y,a.x)};cc.clampf=function(a,b,c){if(b>c){var d=b;b=c;c=d}return a<b?b:a<c?a:c};cc.pClamp=function(a,b,c){return cc.p(cc.clampf(a.x,b.x,c.x),cc.clampf(a.y,b.y,c.y))};cc.pFromSize=function(a){return cc.p(a.width,a.height)};cc.pCompOp=function(a,b){return cc.p(b(a.x),b(a.y))};cc.pLerp=function(a,b,c){return cc.pAdd(cc.pMult(a,1-c),cc.pMult(b,c))};
cc.pFuzzyEqual=function(a,b,c){return a.x-c<=b.x&&b.x<=a.x+c&&a.y-c<=b.y&&b.y<=a.y+c?!0:!1};cc.pCompMult=function(a,b){return cc.p(a.x*b.x,a.y*b.y)};cc.pAngleSigned=function(a,b){var c=cc.pNormalize(a),d=cc.pNormalize(b),c=Math.atan2(c.x*d.y-c.y*d.x,cc.pDot(c,d));return Math.abs(c)<cc.POINT_EPSILON?0:c};cc.pAngle=function(a,b){var c=Math.acos(cc.pDot(cc.pNormalize(a),cc.pNormalize(b)));return Math.abs(c)<cc.POINT_EPSILON?0:c};
cc.pRotateByAngle=function(a,b,c){a=cc.pSub(a,b);var d=Math.cos(c);c=Math.sin(c);var e=a.x;a.x=e*d-a.y*c+b.x;a.y=e*c+a.y*d+b.y;return a};cc.pLineIntersect=function(a,b,c,d,e){if(a.x==b.x&&a.y==b.y||c.x==d.x&&c.y==d.y)return!1;var f=b.x-a.x;b=b.y-a.y;var g=d.x-c.x;d=d.y-c.y;var h=a.x-c.x;a=a.y-c.y;c=d*f-g*b;e.x=g*a-d*h;e.y=f*a-b*h;if(0==c)return 0==e.x||0==e.y?!0:!1;e.x/=c;e.y/=c;return!0};
cc.pSegmentIntersect=function(a,b,c,d){var e=cc.p(0,0);return cc.pLineIntersect(a,b,c,d,e)&&0<=e.x&&1>=e.x&&0<=e.y&&1>=e.y?!0:!1};cc.pIntersectPoint=function(a,b,c,d){var e=cc.p(0,0);return cc.pLineIntersect(a,b,c,d,e)?(c=cc.p(0,0),c.x=a.x+e.x*(b.x-a.x),c.y=a.y+e.x*(b.y-a.y),c):cc.PointZero()};cc.pSameAs=function(a,b){return null!=a&&null!=b?a.x==b.x&&a.y==b.y:!1};cc.PNGReader=cc.Class.extend({ctor:function(a){var b,c,d,e;this.data=a;this.pos=8;this.palette=[];this.imgData=[];this.transparency={};this.animation=null;this.text={};for(d=null;;){b=this.readUInt32();e=a=void 0;e=[];for(a=0;4>a;++a)e.push(String.fromCharCode(this.data[this.pos++]));a=e.join("");switch(a){case "IHDR":this.width=this.readUInt32();this.height=this.readUInt32();this.bits=this.data[this.pos++];this.colorType=this.data[this.pos++];this.compressionMethod=this.data[this.pos++];this.filterMethod=
this.data[this.pos++];this.interlaceMethod=this.data[this.pos++];break;case "acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||Infinity,frames:[]};break;case "PLTE":this.palette=this.read(b);break;case "fcTL":d&&this.animation.frames.push(d);this.pos+=4;d={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()};a=this.readUInt16();b=this.readUInt16()||100;d.delay=1E3*a/b;d.disposeOp=this.data[this.pos++];d.blendOp=this.data[this.pos++];
d.data=[];break;case "IDAT":case "fdAT":"fdAT"===a&&(this.pos+=4,b-=4);a=(null!=d?d.data:void 0)||this.imgData;for(e=0;0<=b?e<b:e>b;0<=b?++e:--e)a.push(this.data[this.pos++]);break;case "tRNS":this.transparency={};switch(this.colorType){case 3:this.transparency.indexed=this.read(b);b=255-this.transparency.indexed.length;if(0<b)for(a=0;0<=b?a<b:a>b;0<=b?++a:--a)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(b)[0];break;case 2:this.transparency.rgb=this.read(b)}break;
case "tEXt":e=this.read(b);b=e.indexOf(0);a=String.fromCharCode.apply(String,e.slice(0,b));this.text[a]=String.fromCharCode.apply(String,e.slice(b+1));break;case "IEND":d&&this.animation.frames.push(d);a:{switch(this.colorType){case 0:case 3:case 4:d=1;break a;case 2:case 6:d=3;break a}d=void 0}this.colors=d;this.hasAlphaChannel=4===(c=this.colorType)||6===c;c=this.colors+(this.hasAlphaChannel?1:0);this.pixelBitlength=this.bits*c;a:{switch(this.colors){case 1:c="DeviceGray";break a;case 3:c="DeviceRGB";
break a}c=void 0}this.colorSpace=c;Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData));return;default:this.pos+=b}this.pos+=4;if(this.pos>this.data.length)throw Error("Incomplete or corrupt PNG file");}},read:function(a){var b,c;c=[];for(b=0;0<=a?b<a:b>a;0<=a?++b:--b)c.push(this.data[this.pos++]);return c},readUInt32:function(){var a,b,c,d;a=this.data[this.pos++]<<24;b=this.data[this.pos++]<<16;c=this.data[this.pos++]<<8;d=this.data[this.pos++];return a|b|c|d},readUInt16:function(){var a,
b;a=this.data[this.pos++]<<8;b=this.data[this.pos++];return a|b},decodePixels:function(a){var b,c,d,e,f,g,h,k,l,m,n,q,s,v,t;null==a&&(a=this.imgData);if(0===a.length)return new Uint8Array(0);a=(new Zlib.Inflate(a,{index:0,verify:!1})).decompress();k=this.pixelBitlength/8;q=k*this.width;l=new Uint8Array(q*this.height);g=a.length;for(c=m=n=0;m<g;){switch(a[m++]){case 0:for(b=0;b<q;b+=1)l[c++]=a[m++];break;case 1:for(e=s=0;s<q;e=s+=1)b=a[m++],f=e<k?0:l[c-k],l[c++]=(b+f)%256;break;case 2:for(e=f=0;f<
q;e=f+=1)b=a[m++],d=(e-e%k)/k,s=n&&l[(n-1)*q+d*k+e%k],l[c++]=(s+b)%256;break;case 3:for(e=t=0;t<q;e=t+=1)b=a[m++],d=(e-e%k)/k,f=e<k?0:l[c-k],s=n&&l[(n-1)*q+d*k+e%k],l[c++]=(b+Math.floor((f+s)/2))%256;break;case 4:for(e=t=0;t<q;e=t+=1)b=a[m++],d=(e-e%k)/k,f=e<k?0:l[c-k],0===n?s=v=0:(s=l[(n-1)*q+d*k+e%k],v=d&&l[(n-1)*q+(d-1)*k+e%k]),h=f+s-v,e=Math.abs(h-f),d=Math.abs(h-s),h=Math.abs(h-v),f=e<=d&&e<=h?f:d<=h?s:v,l[c++]=(b+f)%256;break;default:throw Error("Invalid filter algorithm: "+a[m-1]);}n++}return l},
copyToImageData:function(a,b){var c,d,e,f,g,h,k,l;d=this.colors;l=null;c=this.hasAlphaChannel;this.palette.length&&(l=null!=(e=this._decodedPalette)?e:this._decodedPalette=this.decodePalette(),d=4,c=!0);e=a.data||a;k=e.length;g=l||b;f=h=0;if(1===d)for(;f<k;)d=l?4*b[f/4]:h,h=g[d++],e[f++]=h,e[f++]=h,e[f++]=h,e[f++]=c?g[d++]:255,h=d;else for(;f<k;)d=l?4*b[f/4]:h,e[f++]=g[d++],e[f++]=g[d++],e[f++]=g[d++],e[f++]=c?g[d++]:255,h=d},decodePalette:function(){var a,b,c,d,e,f,g,h,k;c=this.palette;f=this.transparency.indexed||
[];e=new Uint8Array((f.length||0)+c.length);b=g=a=d=0;for(h=c.length;g<h;b=g+=3)e[d++]=c[b],e[d++]=c[b+1],e[d++]=c[b+2],e[d++]=null!=(k=f[a++])?k:255;return e},render:function(a){var b;a.width=this.width;a.height=this.height;a=a.getContext("2d");b=a.createImageData(this.width,this.height);this.copyToImageData(b,this.decodePixels());return a.putImageData(b,0,0)}});cc.TIFFReader=cc.Class.extend({_littleEndian:!1,_tiffData:null,_fileDirectories:null,ctor:function(){this._fileDirectories=[]},getUint8:function(a){return this._tiffData[a]},getUint16:function(a){return this._littleEndian?this._tiffData[a+1]<<8|this._tiffData[a]:this._tiffData[a]<<8|this._tiffData[a+1]},getUint32:function(a){var b=this._tiffData;return this._littleEndian?b[a+3]<<24|b[a+2]<<16|b[a+1]<<8|b[a]:b[a]<<24|b[a+1]<<16|b[a+2]<<8|b[a+3]},checkLittleEndian:function(){var a=this.getUint16(0);
if(18761===a)this.littleEndian=!0;else if(19789===a)this.littleEndian=!1;else throw console.log(a),TypeError("Invalid byte order value.");return this.littleEndian},hasTowel:function(){if(42!==this.getUint16(2))throw RangeError("You forgot your towel!");return!0},getFieldTypeName:function(a){var b=this.fieldTypeNames;return a in b?b[a]:null},getFieldTagName:function(a){var b=this.fieldTagNames;if(a in b)return b[a];console.log("Unknown Field Tag:",a);return"Tag"+a},getFieldTypeLength:function(a){return-1!==
["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(a)?1:-1!==["SHORT","SSHORT"].indexOf(a)?2:-1!==["LONG","SLONG","FLOAT"].indexOf(a)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(a)?8:null},getFieldValues:function(a,b,c,d){a=[];var e=this.getFieldTypeLength(b);if(4>=e*c)!1===this.littleEndian?a.push(d>>>8*(4-e)):a.push(d);else for(var f=0;f<c;f++){var g=e*f;8<=e?-1!==["RATIONAL","SRATIONAL"].indexOf(b)?(a.push(this.getUint32(d+g)),a.push(this.getUint32(d+g+4))):cc.log("Can't handle this field type or size"):
a.push(this.getBytes(e,d+g))}"ASCII"===b&&a.forEach(function(a,b,c){c[b]=String.fromCharCode(a)});return a},getBytes:function(a,b){if(0>=a)cc.log("No bytes requested");else{if(1>=a)return this.getUint8(b);if(2>=a)return this.getUint16(b);if(3>=a)return this.getUint32(b)>>>8;if(4>=a)return this.getUint32(b);cc.log("Too many bytes requested")}},getBits:function(a,b,c){c=c||0;b+=Math.floor(c/8);var d=c+a;a=32-a;var e,f;0>=d?console.log("No bits requested"):8>=d?(e=24+c,f=this.getUint8(b)):16>=d?(e=16+
c,f=this.getUint16(b)):32>=d?(e=c,f=this.getUint32(b)):console.log("Too many bits requested");return{bits:f<<e>>>a,byteOffset:b+Math.floor(d/8),bitOffset:d%8}},parseFileDirectory:function(a){var b=this.getUint16(a),c=[];a+=2;for(var d=0;d<b;a+=12,d++){var e=this.getUint16(a),f=this.getUint16(a+2),g=this.getUint32(a+4),h=this.getUint32(a+8),e=this.getFieldTagName(e),f=this.getFieldTypeName(f),g=this.getFieldValues(e,f,g,h);c[e]={type:f,values:g}}this.fileDirectories.push(c);b=this.getUint32(a);0!==
b&&this.parseFileDirectory(b)},clampColorSample:function(a,b){var c=Math.pow(2,8-b);return Math.floor(a*c+(c-1))},parseTIFF:function(a,b){b=b||document.createElement("canvas");this._tiffData=a;this.canvas=b;this.checkLittleEndian();if(this.hasTowel()){var c=this.getUint32(4);this.fileDirectories=[];this.parseFileDirectory(c);var d=this.fileDirectories[0],c=d.ImageWidth.values[0],e=d.ImageLength.values[0];this.canvas.width=c;this.canvas.height=e;var f=[],g=d.Compression?d.Compression.values[0]:1,h=
d.SamplesPerPixel.values[0],k=[],l=0,m=!1;d.BitsPerSample.values.forEach(function(a,b,c){k[b]={bitsPerSample:a,hasBytesPerSample:!1,bytesPerSample:void 0};0===a%8&&(k[b].hasBytesPerSample=!0,k[b].bytesPerSample=a/8);l+=a},this);if(0===l%8)var m=!0,n=l/8;var q=d.StripOffsets.values,s=q.length;if(d.StripByteCounts)var v=d.StripByteCounts.values;else if(cc.log("Missing StripByteCounts!"),1===s)v=[Math.ceil(c*e*l/8)];else throw Error("Cannot recover from missing StripByteCounts");for(var t=0;t<s;t++){var z=
q[t];f[t]=[];for(var x=v[t],C=0,D=0,y=1,w=!0,u=[],r=0,B=0,E=0;C<x;C+=y)switch(g){case 1:y=0;for(u=[];y<h;y++)if(k[y].hasBytesPerSample)u.push(this.getBytes(k[y].bytesPerSample,z+C+k[y].bytesPerSample*y));else{var G=this.getBits(k[y].bitsPerSample,z+C,D);u.push(G.bits);C=G.byteOffset-z;D=G.bitOffset;throw RangeError("Cannot handle sub-byte bits per sample");}f[t].push(u);if(m)y=n;else throw y=0,RangeError("Cannot handle sub-byte bits per pixel");break;case 32773:if(w){var w=!1,F=1,I=1,y=this.getInt8(z+
C);0<=y&&127>=y?F=y+1:-127<=y&&-1>=y?I=-y+1:w=!0}else{for(var K=this.getUint8(z+C),y=0;y<I;y++){if(k[B].hasBytesPerSample)E=E<<8*r|K,r++,r===k[B].bytesPerSample&&(u.push(E),E=r=0,B++);else throw RangeError("Cannot handle sub-byte bits per sample");B===h&&(f[t].push(u),u=[],B=0)}F--;0===F&&(w=!0)}y=1}}if(b.getContext){n=this.canvas.getContext("2d");n.fillStyle="rgba(255, 255, 255, 0)";t=d.RowsPerStrip?d.RowsPerStrip.values[0]:e;z=f.length;e%=t;e=0===e?t:e;C=t;g=0;u=d.PhotometricInterpretation.values[0];
F=[];I=0;d.ExtraSamples&&(F=d.ExtraSamples.values,I=F.length);if(d.ColorMap)var G=d.ColorMap.values,J=Math.pow(2,k[0].bitsPerSample);for(t=0;t<z;t++){t+1===z&&(C=e);d=f[t].length;g*=t;for(m=h=0;h<C,m<d;h++)for(q=0;q<c;q++,m++){v=f[t][m];w=D=x=0;s=1;if(0<I)for(x=0;x<I;x++)if(1===F[x]||2===F[x]){s=v[3+x]/256;break}switch(u){case 0:if(k[0].hasBytesPerSample)var L=Math.pow(16,2*k[0].bytesPerSample);v.forEach(function(a,b,c){c[b]=L-a});case 1:x=D=w=this.clampColorSample(v[0],k[0].bitsPerSample);break;
case 2:x=this.clampColorSample(v[0],k[0].bitsPerSample);D=this.clampColorSample(v[1],k[1].bitsPerSample);w=this.clampColorSample(v[2],k[2].bitsPerSample);break;case 3:if(void 0===G)throw Error("Palette image missing color map");v=v[0];x=this.clampColorSample(G[v],16);D=this.clampColorSample(G[J+v],16);w=this.clampColorSample(G[2*J+v],16);break;default:throw RangeError("Unknown Photometric Interpretation:",u);}n.fillStyle="rgba("+x+", "+D+", "+w+", "+s+")";n.fillRect(q,g+h,1,1)}g=C}}return this.canvas}},
fieldTagNames:{315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",
296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",
559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",
40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop"},fieldTypeNames:{1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"}});cc.TIFFReader.__instance=null;
cc.TIFFReader.getInstance=function(){cc.TIFFReader.__instance||(cc.TIFFReader.__instance=new cc.TIFFReader);return cc.TIFFReader.__instance};cc.UserDefault=cc.Class.extend({_db:null,init:function(){this._db=this._getLocalStorage();return!0},_getLocalStorage:function(){try{if(sys.localStorage)return sys.localStorage}catch(a){}},_getWebSqlDatabase:function(){},getBoolForKey:function(a,b){var c=this._getValueForKey(a);return"true"==c?!0:"false"==c?!1:c?Boolean(c):b||!1},getIntegerForKey:function(a,b){var c=this._getValueForKey(a);return c?parseInt(c):b||0},getFloatForKey:function(a,b){var c=this._getValueForKey(a);return c?parseFloat(c):
b||0},getDoubleForKey:function(a,b){return this.getFloatForKey(a,b)},getStringForKey:function(a,b){var c=this._getValueForKey(a);return c?String(c):b||""},_getValueForKey:function(a){var b;this._db&&(b=this._db.getItem(a));return b},setBoolForKey:function(a,b){this.setStringForKey(a,String(b))},setIntegerForKey:function(a,b){a&&this._setValueForKey(a,parseInt(b))},setFloatForKey:function(a,b){a&&this._setValueForKey(a,parseFloat(b))},setDoubleForKey:function(a,b){return this.setFloatForKey(a,b)},
setStringForKey:function(a,b){a&&this._setValueForKey(a,String(b))},_setValueForKey:function(a,b){this._db&&this._db.setItem(a,b)}});cc.UserDefault.getInstance=function(){this._sUserDefault||(this._sUserDefault=new cc.UserDefault,this._sUserDefault.init());return this._sUserDefault};cc.UserDefault.purgeInstanceUserDefault=function(){cc.hasOwnProperty("Browser")&&this._db&&this._db.clear()};cc.UserDefault._sUserDefault=null;cc.UserDefault._isFilePathInitialized=!1;cc.vertexLineToPolygon=function(a,b,c,d,e){e+=d;if(!(1>=e)){b*=0.5;for(var f,g=e-1,h=d;h<e;h++){f=2*h;var k=cc.p(a[2*h],a[2*h+1]),l;if(0===h)l=cc.pPerp(cc.pNormalize(cc.pSub(k,cc.p(a[2*(h+1)],a[2*(h+1)+1]))));else if(h===g)l=cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2*(h-1)],a[2*(h-1)+1]),k)));else{l=cc.p(a[2*(h-1)],a[2*(h-1)+1]);var m=cc.p(a[2*(h+1)],a[2*(h+1)+1]),n=cc.pNormalize(cc.pSub(m,k)),q=cc.pNormalize(cc.pSub(l,k)),s=Math.acos(cc.pDot(n,q));l=s<cc.DEGREES_TO_RADIANS(70)?cc.pPerp(cc.pNormalize(cc.pMidpoint(n,
q))):s<cc.DEGREES_TO_RADIANS(170)?cc.pNormalize(cc.pMidpoint(n,q)):cc.pPerp(cc.pNormalize(cc.pSub(m,l)))}l=cc.pMult(l,b);c[2*f]=k.x+l.x;c[2*f+1]=k.y+l.y;c[2*(f+1)]=k.x-l.x;c[2*(f+1)+1]=k.y-l