commit 5140919697e0c6552be194d6f46b61513000b5d5 Author: Jörn-Michael Miehe Date: Sun Sep 30 20:21:59 2018 +0200 gitify diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..93f1361 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bd1a834 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:latest + +# global deps +RUN npm install gulp-cli -g + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +# If you are building your code for production +# RUN npm install --only=production + +# Bundle app source +COPY . . +RUN gulp + +EXPOSE 8080 + +CMD [ "npm", "start" ] diff --git a/client/js/00-selfcall.js b/client/js/00-selfcall.js new file mode 100644 index 0000000..4607cbc --- /dev/null +++ b/client/js/00-selfcall.js @@ -0,0 +1,2 @@ +// self-calling function +$(function () { diff --git a/client/js/10-config.js b/client/js/10-config.js new file mode 100644 index 0000000..f8929ae --- /dev/null +++ b/client/js/10-config.js @@ -0,0 +1,16 @@ +const CONF = { + playmat: { + w: 1600, + h: 900, + }, + + card: { + w: 172, + h: 240, + }, + + anim: { + time: 300, + func: "smootherStep", + }, +} diff --git a/client/js/10-framework-init.js b/client/js/10-framework-init.js new file mode 100644 index 0000000..6394325 --- /dev/null +++ b/client/js/10-framework-init.js @@ -0,0 +1,5 @@ +// init Socket.IO +var socket = io(); + +// init CraftyJS framework +Crafty.init(); diff --git a/client/js/20-component-card.js b/client/js/20-component-card.js new file mode 100644 index 0000000..3efde8b --- /dev/null +++ b/client/js/20-component-card.js @@ -0,0 +1,78 @@ +Crafty.c("Card", { + required: "2D, Canvas, Mouse, Tween", + + init: function () { + this.attr({ + w: 1* CONF.card.w, + h: 1* CONF.card.h, + tapped: false, + rotation: 0, + }); + this.origin("center"); + }, + + remove: function () { + Crafty.log("Card was removed!"); + }, + + place: function (px, py) { + this.tween({ x: px, y: py }, CONF.anim.time, CONF.anim.func); + return this; + }, + + events: { + Tap: function (newState) { + this.tapped = !!newState; + let _rotation = this.baseRot + 90 * this.tapped; + this.tween({ rotation: _rotation }, CONF.anim.time, CONF.anim.func); + }, + + ToggleTap: function () { + this.trigger("Tap", !this.tapped); + }, + + MouseOver: function () { + this.z_old = this._z; + this.z = 1; + }, + + MouseOut: function () { + this.z = this.z_old; + delete this.z_old; + } + }, + +}); + +Crafty.c("EnemyCard", { + required: "Card", + + init: function () { + this.baseRot = 180; + this.rotation = this.baseRot; + }, + +}); + +Crafty.c("AllyCard", { + required: "Card, Draggable", + + init: function () { + this.baseRot = 0; + this.rotation = this.baseRot; + }, + + events: { + DoubleClick: function () { + this.trigger("ToggleTap"); + }, + + StopDrag: function () { + function round100(v) { + return Math.round(v / 100) * 100; + } + this.place(round100(this._x), round100(this._y)); + }, + }, + +}); diff --git a/client/js/30-scene-game.js b/client/js/30-scene-game.js new file mode 100644 index 0000000..ce7ff7b --- /dev/null +++ b/client/js/30-scene-game.js @@ -0,0 +1,56 @@ +Crafty.viewport.clampToEntities = false; + +Crafty.viewport.follow( + Crafty.e("2D, Color, Canvas") + .attr({ + x: 0, + y: 0, + w: 1* CONF.playmat.w, + h: 2* CONF.playmat.h, + }) + .color("teal") + .origin("center") +); + +Crafty.bind("ViewportResize", function () { + let sX = this.viewport._width / 1600, + sY = this.viewport._height / 1800; + + this.viewport.scale(Math.min(sX, sY)); +}); + +Crafty.trigger("ViewportResize"); + +// Testing playmat + +Crafty.sprite(997, 582, "//i.imgur.com/cwGQdAS.png", { playmat: [0, 0] }); + +Crafty.e("playmat, 2D, Canvas") + .attr({ x: 0, y: 900, w: 1600, h: 900 }); + +Crafty.e("playmat, 2D, Canvas") + .attr({ x: 0, y: 900, w: 1600, h: 900 }) + .origin("top middle") + .attr({ rotation:180 }); + +// Testing some entities + +Crafty.sprite(480, 670, "//www.fftcgmognet.com/images/cards/hd/1/1/107.jpg", { shantotto: [0, 0] }); + +let card = Crafty.e("shantotto, AllyCard") + .attr({ x: 0, y: 0 }) + .bind("DoubleClick", function () { + this.destroy(); + }); + +Crafty.e("shantotto, AllyCard") + .place(300, 0); + +Crafty.e("shantotto, AllyCard") + .place(600, 0); + +Crafty.e("shantotto, EnemyCard") + .place(900, 0); + +// Crafty.e("shantotto, AllyCard") +// .attr({ x: 0, y: 0, w: 1200, h: 1675 }); diff --git a/client/js/99-selfcall.js b/client/js/99-selfcall.js new file mode 100644 index 0000000..27b8217 --- /dev/null +++ b/client/js/99-selfcall.js @@ -0,0 +1 @@ +}); diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..eb9abb9 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,22 @@ +var gulp = require('gulp'); +var sourcemaps = require('gulp-sourcemaps'); +var concat = require('gulp-concat'); +var uglify = require('gulp-uglify-es').default; +var selfExecute = require('gulp-self-execute'); + +var paths = { + scripts: 'client/js/**/*.js', + images: 'client/img/**/*' +}; + +gulp.task('js', function(){ + return gulp.src(paths.scripts) + .pipe(sourcemaps.init()) + .pipe(concat('app.min.js')) + .pipe(uglify()) + .pipe(selfExecute()) + .pipe(sourcemaps.write()) + .pipe(gulp.dest('static')) +}); + +gulp.task('default', [ 'js' ]); diff --git a/package.json b/package.json new file mode 100644 index 0000000..f5b84f9 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "socket-io-crafty", + "version": "0.0.1", + "description": "Socket.IO for a CraftyJS game on Node.js on Docker", + "author": "JMM ", + "main": "server.js", + "scripts": { + "start": "node server.js" + }, + "dependencies": { + "express": "^4.16.1", + "socket.io": "^2.1.1", + "gulp": "*", + "gulp-concat": "*", + "gulp-sourcemaps": "*", + "gulp-uglify-es": "*" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..6fa9bd2 --- /dev/null +++ b/server.js @@ -0,0 +1,23 @@ +// libraries +var + http = require('http'), + socketio = require('socket.io'), + express = require('express'); + +// socket.io framework +let app = express(); +let web = http.Server(app); +let io = socketio(web); + +// Listen server +web.listen(8080, function () { + console.log('listening on port 8080'); +}); + +// Static content +app.use(express.static(__dirname + '/static')); + +// Server logic +io.on('connection', function (socket) { + console.log('a user connected'); +}); diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..346c01a --- /dev/null +++ b/static/index.html @@ -0,0 +1,13 @@ + + + + Crafty Things + + + + + + + + + diff --git a/static/lib/crafty-min.js b/static/lib/crafty-min.js new file mode 100644 index 0000000..a652928 --- /dev/null +++ b/static/lib/crafty-min.js @@ -0,0 +1,14 @@ +/** + * craftyjs 0.9.0 + * http://craftyjs.com/ + * + * Copyright 2018, Louis Stowasser + * Licensed under the MIT license. + */ + + +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g1)for(var c=1;c0&&(c/=g,d/=g)}a.x=c,a.y=d},updateTriggerInput:function(a){a.active?a.input.isActive()||(a.active=!1,g.trigger("TriggerInputUp",a),a.downFor=0):a.input.isActive()&&(a.downFor=Date.now()-a.input.timeDown,a.active=!0,g.trigger("TriggerInputDown",a))},updateDpadInput:function(a,b){var c,d,e;for(c in a.directions)d=a.directions[c],d.active=!1,d.input.isActive()&&("all"===b?d.active=!0:e?("first"===b&&e.input.timeDown>d.input.timeDown&&(e=d),"last"===b&&e.input.timeDown=0?this.touchPoints[b]:null)){var c=this._touchPointsPool.pop()||{};this._setTouchPoint(c,a),this.touchPoints.push(c),this.triggerTouchEvent(c.eventName,c)}},_handleMove:function(a){var b=this._indexOfTouchPoint(a.identifier),c=b>=0?this.touchPoints[b]:null;c&&(this._setTouchPoint(c,a),this.triggerTouchEvent(c.eventName,c))},_handleEnd:function(a){var b=this._indexOfTouchPoint(a.identifier),c=b>=0?this.touchPoints[b]:null;c&&(this._setTouchPoint(c,a),this.triggerTouchEvent(c.eventName,c),this.touchPoints.splice(b,1),c.target=null,c.entity=null,c.originalEvent=null,this._touchPointsPool.push(c))}},d.c("TouchState",d.__touchStateTemplate),d.s("Touch",d.extend.call({triggerTouchEvent:function(a,b){d.trigger(a,b)}},d.__touchStateTemplate),{},!1)},{"../core/core.js":10}],9:[function(a,b,c){var d=a("../core/core.js"),e=function(a,b){this.timePerFrame=1e3/d.timer.FPS(),this.duration=a,"function"==typeof b?this.easing_function=b:"string"==typeof b&&this.standardEasingFunctions[b]?this.easing_function=this.standardEasingFunctions[b]:this.easing_function=this.standardEasingFunctions.linear,this.reset()};e.prototype={duration:0,clock:0,steps:null,complete:!1,paused:!1,reset:function(){this.loops=1,this.clock=0,this.complete=!1,this.paused=!1},repeat:function(a){this.loops=a},setProgress:function(a,b){this.clock=this.duration*a,void 0!==b&&(this.loops=b)},pause:function(){this.paused=!0},resume:function(){this.paused=!1,this.complete=!1},tick:function(a){if(!this.paused&&!this.complete)for(this.clock+=a,this.frames=Math.floor(this.clock/this.timePerFrame);this.clock>=this.duration&&!1===this.complete;)this.loops--,this.loops>0?this.clock-=this.duration:this.complete=!0},time:function(){return Math.min(this.clock/this.duration,1)},value:function(){return this.easing_function(this.time())},standardEasingFunctions:{linear:function(a){return a},smoothStep:function(a){return(3-2*a)*a*a},smootherStep:function(a){return(6*a*a-15*a+10)*a*a*a},easeInQuad:function(a){return a*a},easeOutQuad:function(a){return a*(2-a)},easeInOutQuad:function(a){return a<.5?2*a*a:(4-2*a)*a-1}}},b.exports=e},{"../core/core.js":10}],10:[function(a,b,c){function d(){var a=f++;return a in i?d():a}function e(a){if(null===a||"object"!=typeof a)return a;var b=a.constructor();for(var c in a)b[c]=e(a[c]);return b}var f,g,h,i,j,k,l,m,n,o,p=a("./version"),q=function(a){return new q.fn.init(a)};h={},m=Array.prototype.slice,n=/\s*,\s*/,o=/\s+/;var r=function(){f=1,g=0,i={},l={},j={},k=[]};r(),q.fn=q.prototype={init:function(a){if("string"!=typeof a)return a||(a=0)in i||(i[a]=this),a in i?(this[0]=a,this.length=1,this.__c||(this.__c={}),this._callbacks||q._addCallbackMethods(this),i[a]||(i[a]=this),i[a]):(this.length=0,this);var b,c,d,e,f,g,h,j,k,m=0,p=!1,r=!1;if("*"===a){j=0;for(b in i)this[j]=+b,j++;return this.length=j,1===j?i[this[0]]:this}if(-1!==a.indexOf(",")?(r=!0,c=n):-1!==a.indexOf(" ")&&(p=!0,c=o),r){for(d=a.split(c),e={},j=0,k=d.length;j=0&&(this[m++]=j)}else{f=l[a];for(h in f)this[m++]=+h}return this.length=m,1===m?i[this[m-1]]:(q._addCallbackMethods(this),this)},setName:function(a){var b=String(a);return this._entityName=b,this.trigger("NewEntityName",b),this},getName:function(a){return this._entityName},addComponent:function(a){var b,c,d,e=0;for(b=1===arguments.length&&-1!==a.indexOf(",")?a.split(n):arguments;e1)for(b=arguments.length;d-1?(d=a.split("."),c=d.shift(),d.join("."),this._attr_get(d.join("."),b[c])):b[a]},_attr_set:function(){var a,b,c;return"string"==typeof arguments[0]?(a=this._set_create_object(arguments[0],arguments[1]),b=!!arguments[2],c=arguments[3]||arguments[0].indexOf(".")>-1):(a=arguments[0],b=!!arguments[1],c=!!arguments[2]),b||this.trigger("Change",a),c?this._recursive_extend(a,this):this.extend.call(this,a),this},_set_create_object:function(a,b){var c,d,e,f={};return a.indexOf(".")>-1?(c=a.split("."),d=c.shift(),e=c.join("."),f[d]=this._set_create_object(e,b)):f[a]=b,f},_recursive_extend:function(a,b){var c;for(c in a)a[c].constructor===Object?b[c]=this._recursive_extend(a[c],b[c]):b[c]=a[c];return b},toArray:function(){return m.call(this,0)},timeout:function(a,b){return this.each(function(){var c=this;setTimeout(function(){a.call(c)},b)}),this},bind:function(a,b){if(1===this.length)this._bindCallback(a,b);else for(var c=0;c=b||a+b<0)return;return a>=0?i[this[a]]:i[this[a+b]]}for(var c=0,d=[];c0&&q.trigger("MeasureWaitTime",m-h),c+i>=m)return void(h=m);var n=m-(c+i);n>20*k&&(i+=n-k,n=k),"fixed"===d?(l=Math.ceil(n/k),l=Math.min(l,e),b=k):"variable"===d?(l=1,b=n,b=Math.min(b,f)):"semifixed"===d&&(l=Math.ceil(n/f),b=n/l);for(var o=0;o0&&(a=m,q.trigger("PreRender"),q.trigger("RenderScene"),q.trigger("PostRender"),m=Date.now(),q.trigger("MeasureRenderTime",m-a)),h=m},FPS:function(a){if(void 0===a)return j;j=a,k=1e3/j,q.trigger("FPSChange",a)},simulateFrames:function(a,b){for(b=b||k;a-- >0;){var c={frame:g++,dt:b};q.trigger("EnterFrame",c),q.trigger("UpdateFrame",c),q.trigger("ExitFrame",c)}q.trigger("PreRender"),q.trigger("RenderScene"),q.trigger("PostRender")}}}(),e:function(){var a=d();return i[a]=null,i[a]=q(a),arguments.length>0&&i[a].addComponent.apply(i[a],arguments),i[a].setName("Entity #"+a),i[a].addComponent("obj"),q.trigger("NewEntity",{id:a}),i[a]},c:function(a,b){h[a]=b},trigger:function(a,b){var c,d,e=j[a]||(j[a]={});for(c in e)e.hasOwnProperty(c)&&(d=e[c])&&0!==d.length&&d.context._runCallbacks(a,b)},bind:function(a,b){return this._bindCallback(a,b),b},uniqueBind:function(a,b){return this.unbind(a,b),this.bind(a,b)},one:function(a,b){var c=this,d=function(e){b.call(c,e),c.unbind(a,d)};return c.bind(a,d)},unbind:function(a,b){this._unbindCallbacks(a,b)},frame:function(){return g},entities:function(){return i},components:function(){return h},isComp:function(a){return a in h},debug:function(a){return"handlers"===a?j:i},settings:function(){var a={},b={};return{register:function(a,c){b[a]=c},modify:function(c,d){b[c]&&(b[c].call(a[c],d),a[c]=d)},get:function(b){return a[b]}}}(),defineField:function(a,b,c,d){Object.defineProperty(a,b,{get:c,set:d,configurable:!1,enumerable:!0})},clone:e}),"function"==typeof define&&define("crafty",[],function(){return q}),b.exports=q},{"./version":19}],11:[function(a,b,c){(function(b){var c=a("../core/core.js"),d="undefined"!=typeof window&&window.document;!function(){var a=c.support={},e="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase()||void 0!==b&&b.version,f=/(webkit)[ \/]([\w.]+)/.exec(e)||/(o)pera(?:.*version)?[ \/]([\w.]+)/.exec(e)||/(ms)ie ([\w.]+)/.exec(e)||/(moz)illa(?:.*? rv:([\w.]+))?/.exec(e)||/(v)\d+\.(\d+)/.exec(e)||[],g=/iPad|iPod|iPhone|Android|webOS|IEMobile/i.exec(e);if(g&&(c.mobile=g[0]),a.defineProperty=function(){if(!("defineProperty"in Object))return!1;try{Object.defineProperty({},"x",{})}catch(a){return!1}return!0}(),a.audio="undefined"!=typeof window&&"canPlayType"in d.createElement("audio"),a.prefix=f[1]||f[0],"moz"===a.prefix&&(a.prefix="Moz"),"o"===a.prefix&&(a.prefix="O"),"v"===a.prefix&&(a.prefix="node"),f[2]&&(a.versionName=f[2],a.version=+f[2].split(".")[0]),a.canvas="undefined"!=typeof window&&"getContext"in d.createElement("canvas"),a.canvas){var h;try{var i=d.createElement("canvas");h=i.getContext("webgl")||i.getContext("experimental-webgl"),h.viewportWidth=a.canvas.width,h.viewportHeight=a.canvas.height}catch(a){}a.webgl=!!h}else a.webgl=!1;a.css3dtransform="undefined"!=typeof window&&(void 0!==d.createElement("div").style.Perspective||void 0!==d.createElement("div").style[a.prefix+"Perspective"]),a.deviceorientation="undefined"!=typeof window&&(void 0!==window.DeviceOrientationEvent||void 0!==window.OrientationEvent),a.devicemotion="undefined"!=typeof window&&void 0!==window.DeviceMotionEvent}()}).call(this,a("_process"))},{"../core/core.js":10,_process:1}],12:[function(a,b,c){var d=a("../core/core.js");b.exports={assets:{},__paths:{audio:"",images:""},paths:function(a){if(void 0===a)return this.__paths;a.audio&&(this.__paths.audio=a.audio),a.images&&(this.__paths.images=a.images)},asset:function(a,b){return 1===arguments.length?d.assets[a]:d.assets[a]?void 0:(d.assets[a]=b,this.trigger("NewAsset",{key:a,value:b}),b)},imageWhitelist:["jpg","jpeg","gif","png","svg"],load:function(a,b,c,e){function f(){var a=this.src;this.removeEventListener&&this.removeEventListener("canplaythrough",f,!1),m++,c&&c({loaded:m,total:n,percent:m/n*100,src:a}),m===n&&b&&b()}function g(){var a=this.src;e&&e({loaded:m,total:n,percent:m/n*100,src:a}),++m===n&&b&&b()}if(Array.isArray(a))return void d.log("Calling Crafty.load with an array of assets no longer works; see the docs for more details.");a="string"==typeof a?JSON.parse(a):a;var h,i,j,k,l,m=0,n=(a.audio?Object.keys(a.audio).length:0)+(a.images?Object.keys(a.images).length:0)+(a.sprites?Object.keys(a.sprites).length:0),o=d.paths(),p=function(a){return a.substr(a.lastIndexOf(".")+1).toLowerCase()},q=function(a,b){return-1===b.search("://")?"audio"===a?o.audio+b:o.images+b:b},r=function(a){return d.asset(a)||null},s=function(a){return d.support.audio&&d.audio.supports(p(a))};for(k in a)for(l in a[k])if(a[k].hasOwnProperty(l)){if(h=a[k][l],j=null,"audio"===k){if("object"==typeof h){var t=[];for(var u in h)i=q(k,h[u]),r(i)||!s(h[u])||d.audio.sounds[l]||t.push(i);t.length>0&&(j=d.audio.add(l,t))}else"string"==typeof h&&(i=q(k,h),r(i)||!s(h)||d.audio.sounds[l]||(j=d.audio.add(l,i)));j&&(j=j.obj),j&&j.addEventListener&&j.addEventListener("canplaythrough",f,!1)}else l="sprites"===k?l:h,i=q(k,l),!r(i)&&function(a){return-1!==d.imageWhitelist.indexOf(p(a))}(l)&&(j=new Image,"sprites"===k&&d.sprite(h.tile,h.tileh,i,h.map,h.paddingX,h.paddingY,h.paddingAroundBorder),d.asset(i,j),function(a,b){a.onload=f,"webkit"===d.support.prefix&&(a.src=""),a.src=b}(j,i));j?j.onerror=g:g.call({src:i})}0===n&&b&&b()},removeAssets:function(a){a="string"==typeof a?JSON.parse(a):a;var b,c,e,f,g=d.paths(),h=function(a,b){return-1===b.search("://")?"audio"===a?g.audio+b:g.images+b:b};for(e in a)for(f in a[e])if(a[e].hasOwnProperty(f))if(b=a[e][f],"audio"===e)if("object"==typeof b)for(var i in b)c=h(e,b[i]),d.asset(c)&&d.audio.remove(f);else"string"==typeof b&&(c=h(e,b),d.asset(c)&&d.audio.remove(f));else if(f="sprites"===e?f:b,c=h(e,f),d.asset(c)){if("sprites"===e)for(var j in b.map)delete d.components()[j];delete d.assets[c]}}}},{ +"../core/core.js":10}],13:[function(a,b,c){var d=a("../core/core.js");b.exports={init:function(){this.changed=[],this.bind("Change",this._changed_attributes),this.bind("Change",this._changed_triggers)},_changed_triggers:function(a,b){var c;b=d.extend.call({pre:""},b);for(c in a)this.trigger("Change["+b.pre+c+"]",a[c]),a[c].constructor===Object&&this._changed_triggers(a[c],{pre:b.pre+c+"."})},_changed_attributes:function(a){var b;for(b in a)this.changed.push(b);return this},is_dirty:function(a){return 0===arguments.length?!!this.changed.length:this.changed.indexOf(a)>-1}}},{"../core/core.js":10}],14:[function(a,b,c){var d=a("../core/core.js");b.exports={_scenes:{},_current:null,scene:function(a,b,c){if(1===arguments.length||"function"!=typeof arguments[1])return void d.enterScene(a,arguments[1]);d.defineScene(a,b,c)},defineScene:function(a,b,c){if("function"!=typeof b)throw"Init function is the wrong type.";this._scenes[a]={},this._scenes[a].initialize=b,void 0!==c&&(this._scenes[a].uninitialize=c)},enterScene:function(a,b){if("function"==typeof b)throw"Scene data cannot be a function";d.trigger("SceneDestroy",{newScene:a}),d.viewport.reset(),d("2D").each(function(){this.has("Persist")||this.destroy()}),null!==this._current&&"uninitialize"in this._scenes[this._current]&&this._scenes[this._current].uninitialize.call(this);var c=this._current;this._current=a,d.trigger("SceneChange",{oldScene:c,newScene:a}),this._scenes.hasOwnProperty(a)?this._scenes[a].initialize.call(this,b):d.error('The scene "'+a+'" does not exist')}}},{"../core/core.js":10}],15:[function(a,b,c){var d=a("../core/core.js");try{var e="undefined"!=typeof window&&window.localStorage||new a("node-localstorage").LocalStorage("./localStorage")}catch(a){var e=null}var f=function(a,b){var c=b;if(!e)return d.error("Local storage is not accessible. (Perhaps you are including crafty.js cross-domain?)"),!1;if(1===arguments.length)try{return JSON.parse(e.getItem(a))}catch(b){return e.getItem(a)}else"object"==typeof b&&(c=JSON.stringify(b)),e.setItem(a,c)};f.remove=function(a){if(!e)return void d.error("Local storage is not accessible. (Perhaps you are including crafty.js cross-domain?)");e.removeItem(a)},b.exports=f},{"../core/core.js":10}],16:[function(a,b,c){function d(a,b){var c={};for(var d in b)c[d]=b[d];for(d in a)d in b||(c[d]=a[d]);return c}var e=a("../core/core.js");e._systems={},e.s=function(a,b,c,d){if(!b)return e._systems[a];"boolean"==typeof c&&(d=c,c=null),!1===d?(e._systems[a]=new e.CraftySystem(a,b,c),e.trigger("SystemLoaded",a)):e._registerLazySystem(a,b,c)},e._registerLazySystem=function(a,b,c){Object.defineProperty(e._systems,a,{get:function(){return Object.defineProperty(e._systems,a,{value:new e.CraftySystem(a,b,c),writable:!0,enumerable:!0,configurable:!0}),e.trigger("SystemLoaded",a),e._systems[a]},configurable:!0})},e.CraftySystem=function(){var a=1;return function(b,c,f){if(this.name=b,!c)return this;if(this._systemTemplate=c,this.extend(c),this.options=d(this.options,f),e._addCallbackMethods(this),this[0]="system"+a++,"properties"in c){var g=c.properties;for(var h in g)Object.defineProperty(this,h,g[h])}if("events"in c){var i=c.events;for(var j in i){var k="function"==typeof i[j]?i[j]:c[i[j]];this.bind(j,k)}}"function"==typeof this.init&&this.init(b)}}(),e.CraftySystem.prototype={extend:function(a){for(var b in a)void 0===this[b]&&(this[b]=a[b])},bind:function(a,b){return this._bindCallback(a,b),this},trigger:function(a,b){return this._runCallbacks(a,b),this},unbind:function(a,b){return this._unbindCallbacks(a,b),this},one:function(a,b){var c=this,d=function(e){b.call(c,e),c.unbind(a,d)};return c.bind(a,d)},uniqueBind:function(a,b){return this.unbind(a,b),this.bind(a,b)},destroy:function(){e.trigger("SystemDestroyed",this),"function"==typeof this.remove&&this.remove(),this._unbindAll(),delete e._systems[this.name]}}},{"../core/core.js":10}],17:[function(a,b,c){b.exports={delaySpeed:1,init:function(){this._delays=[],this._delaysPaused=!1,this.bind("UpdateFrame",function(a){if(!this._delaysPaused)for(var b=this._delays.length;--b>=0;){var c=this._delays[b];if(!1===c)this._delays.splice(b,1);else{for(c.accumulator+=a.dt*this.delaySpeed;c.accumulator>=c.delay&&c.repeat>=0;)c.accumulator-=c.delay,c.repeat--,c.callback.call(this);c.repeat<0&&(this._delays.splice(b,1),"function"==typeof c.callbackOff&&c.callbackOff.call(this))}}})},delay:function(a,b,c,d){return this._delays.push({accumulator:0,callback:a,callbackOff:d,delay:b,repeat:(c<0?1/0:c)||0}),this},cancelDelay:function(a){for(var b=this._delays.length;--b>=0;){var c=this._delays[b];c&&c.callback===a&&(this._delays[b]=!1)}return this},pauseDelays:function(){this._delaysPaused=!0},resumeDelays:function(){this._delaysPaused=!1}}},{}],18:[function(a,b,c){var d=a("../core/core.js");b.exports={tweenSpeed:1,init:function(){this.tweenGroup={},this.tweenStart={},this.tweens=[],this.uniqueBind("UpdateFrame",this._tweenTick)},_tweenTick:function(a){var b,c,d;for(d=this.tweens.length-1;d>=0;d--)b=this.tweens[d],b.easing.tick(a.dt*this.tweenSpeed),c=b.easing.value(),this._doTween(b.props,c),b.easing.complete&&(this.tweens.splice(d,1),this._endTween(b.props))},_doTween:function(a,b){for(var c in a)this[c]=(1-b)*this.tweenStart[c]+b*a[c]},tween:function(a,b,c){var e={props:a,easing:new d.easing(b,c)};for(var f in a)void 0!==this.tweenGroup[f]&&this.cancelTween(f),this.tweenStart[f]=this[f],this.tweenGroup[f]=a;return this.tweens.push(e),this},cancelTween:function(a){if("string"==typeof a)"object"==typeof this.tweenGroup[a]&&delete this.tweenGroup[a][a];else if("object"==typeof a)for(var b in a)this.cancelTween(b);return this},pauseTweens:function(){this.tweens.map(function(a){a.easing.pause()})},resumeTweens:function(){this.tweens.map(function(a){a.easing.resume()})},_endTween:function(a){var b=!1;for(var c in a)b=!0,delete this.tweenGroup[c];b&&this.trigger("TweenEnd",a)}}},{"../core/core.js":10}],19:[function(a,b,c){b.exports="0.9.0"},{}],20:[function(a,b,c){b.exports=function(b){b&&(a=b);var c=a("./core/core");a("./core/extensions"),c.easing=a("./core/animation"),c.c("Model",a("./core/model")),c.extend(a("./core/scenes")),c.storage=a("./core/storage"),c.c("Delay",a("./core/time")),c.c("Tween",a("./core/tween"));var d=a("./spatial/spatial-grid");return c.HashMap=d,c.map=new d,a("./core/systems"),a("./spatial/2d"),a("./spatial/motion"),a("./spatial/platform"),a("./spatial/collision"),a("./spatial/rect-manager"),a("./spatial/math"),a("./controls/controls-system"),a("./controls/controls"),a("./controls/keyboard"),a("./controls/keycodes"),a("./controls/mouse"),a("./controls/touch"),a("./debug/logging"),c}},{"./controls/controls":4,"./controls/controls-system":3,"./controls/keyboard":5,"./controls/keycodes":6,"./controls/mouse":7,"./controls/touch":8,"./core/animation":9,"./core/core":10,"./core/extensions":11,"./core/model":13,"./core/scenes":14,"./core/storage":15,"./core/systems":16,"./core/time":17,"./core/tween":18,"./debug/logging":23,"./spatial/2d":54,"./spatial/collision":55,"./spatial/math":56,"./spatial/motion":57,"./spatial/platform":58,"./spatial/rect-manager":59,"./spatial/spatial-grid":60}],21:[function(a,b,c){var d=a("./crafty-common.js")();d.extend(a("./core/loader")),d.extend(a("./inputs/dom-events")),a("./graphics/layers"),a("./graphics/canvas"),a("./graphics/canvas-layer"),a("./graphics/webgl"),a("./graphics/webgl-layer"),a("./graphics/color"),a("./graphics/dom"),a("./graphics/dom-helper"),a("./graphics/dom-layer"),a("./graphics/drawing"),a("./graphics/gl-textures"),a("./graphics/renderable"),a("./graphics/html"),a("./graphics/image"),a("./graphics/particles"),a("./graphics/sprite-animation"),a("./graphics/sprite"),a("./graphics/text"),a("./graphics/viewport"),a("./isometric/diamond-iso"),a("./isometric/isometric"),a("./inputs/util"),a("./inputs/device"),a("./inputs/keyboard"),a("./inputs/lifecycle"),a("./inputs/mouse"),a("./inputs/pointer"),a("./inputs/touch"),a("./sound/sound"),a("./debug/debug-layer"),a("./aliases").defineAliases(d),window&&(window.Crafty=d),b.exports=d},{"./aliases":2,"./core/loader":12,"./crafty-common.js":20,"./debug/debug-layer":22,"./graphics/canvas":25,"./graphics/canvas-layer":24,"./graphics/color":26,"./graphics/dom":29,"./graphics/dom-helper":27,"./graphics/dom-layer":28,"./graphics/drawing":30,"./graphics/gl-textures":31,"./graphics/html":32,"./graphics/image":33,"./graphics/layers":34,"./graphics/particles":35,"./graphics/renderable":36,"./graphics/sprite":38,"./graphics/sprite-animation":37,"./graphics/text":39,"./graphics/viewport":40,"./graphics/webgl":42,"./graphics/webgl-layer":41,"./inputs/device":43,"./inputs/dom-events":44,"./inputs/keyboard":45,"./inputs/lifecycle":46,"./inputs/mouse":47,"./inputs/pointer":48,"./inputs/touch":49,"./inputs/util":50,"./isometric/diamond-iso":51,"./isometric/isometric":52,"./sound/sound":53}],22:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.c("DebugCanvas",{init:function(){this.requires("2D"),d.DebugCanvas.context||d.DebugCanvas.init(),d.DebugCanvas.add(this),this._debug={alpha:1,lineWidth:1},this.bind("RemoveComponent",this.onDebugRemove),this.bind("Remove",this.onDebugDestroy)},onDebugRemove:function(a){"DebugCanvas"===a&&d.DebugCanvas.remove(this)},onDebugDestroy:function(a){d.DebugCanvas.remove(this)},debugAlpha:function(a){return this._debug.alpha=a,this},debugFill:function(a){return void 0===a&&(a="red"),this._debug.fillStyle=a,this},debugStroke:function(a){return void 0===a&&(a="red"),this._debug.strokeStyle=a,this},debugDraw:function(a){var b=a.globalAlpha,c=this._debug;c.alpha&&(a.globalAlpha=this._debug.alpha),c.strokeStyle&&(a.strokeStyle=c.strokeStyle),c.lineWidth&&(a.lineWidth=c.lineWidth),c.fillStyle&&(a.fillStyle=c.fillStyle),this.trigger("DebugDraw",a),a.globalAlpha=b}}),d.c("DebugRectangle",{init:function(){this.requires("2D, DebugCanvas")},debugRectangle:function(a){return this.debugRect=a,this.unbind("DebugDraw",this.drawDebugRect),this.bind("DebugDraw",this.drawDebugRect),this},drawDebugRect:function(a){var b=this.debugRect;null!==b&&void 0!==b&&b._h&&b._w&&(this._debug.fillStyle&&a.fillRect(b._x,b._y,b._w,b._h),this._debug.strokeStyle&&a.strokeRect(b._x,b._y,b._w,b._h))}}),d.c("WiredMBR",{init:function(){this.requires("DebugRectangle").debugStroke("purple")},events:{PreRender:function(){this.debugRectangle(this._mbr||this)}}});var f={init:function(){this.requires("DebugRectangle").debugFill("pink")},events:{PreRender:function(){this.debugRectangle(this._mbr||this)}}};d.c("SolidMBR",f),d.c("VisibleMBR",f),d.c("DebugPolygon",{init:function(){this.requires("2D, DebugCanvas")},debugPolygon:function(a){return this.polygon=a,this.unbind("DebugDraw",this.drawDebugPolygon),this.bind("DebugDraw",this.drawDebugPolygon),this},drawDebugPolygon:function(a){if(void 0!==this.polygon){a.beginPath();for(var b=this.polygon.points,c=b.length,d=0;d=0;c--)b[c]===a&&b.splice(c,1)},init:function(){if(!d.DebugCanvas.context){if(!d.support.canvas)return d.trigger("NoCanvas"),void d.stop();var a;a=e.createElement("canvas"),a.width=d.viewport.width,a.height=d.viewport.height,a.style.position="absolute",a.style.left="0px",a.style.top="0px",a.id="debug-canvas",a.style.zIndex=1e5,d.stage.elem.appendChild(a),d.DebugCanvas.context=a.getContext("2d"),d.DebugCanvas._canvas=a}d.unbind("RenderScene",d.DebugCanvas.renderScene),d.bind("RenderScene",d.DebugCanvas.renderScene)},renderScene:function(a){a=a||d.viewport.rect();var b,c=d.DebugCanvas.entities,e=0,f=c.length,g=d.DebugCanvas.context,h=d.viewport;g.setTransform(h._scale,0,0,h._scale,Math.round(h._x*h._scale),Math.round(h._y*h._scale)),g.clearRect(a._x,a._y,a._w,a._h);for(var i=null;e.6||a?this._drawAll():this._drawDirtyCells(),this._clean()}},_drawDirtyCells:function(a){var b,c,e=this._viewportRect(),f=this.__tempRect,g=this._dirtyRects,h=d.rectManager.integerBounds,i=this.context;for(a=h(a||e),this._createDirtyCells(a),this._createDirtyRects(),b=0,c=g.length;bg&&f._visible&&f._drawLayer===this&&(f.draw(i),f._changed=!1,g=f._globalZ);i.restore()},debug:function(){d.log(this._changedObjs)},_clean:function(){var a,b,c,d,e,f=this._changedObjs;for(d=0,e=f.length;d>16,b=c<0?~(a>>16):a>>16,g.push(b*e,c*e,e,e)},_resize:function(){var a=this._canvas;a.width=d.viewport.width,a.height=d.viewport.height},_setPixelart:function(a){var b=this.context;b.imageSmoothingEnabled=!a,b.mozImageSmoothingEnabled=!a,b.webkitImageSmoothingEnabled=!a,b.oImageSmoothingEnabled=!a,b.msImageSmoothingEnabled=!a}})},{"../core/core.js":10}],25:[function(a,b,c){var d=a("../core/core.js");d.c("Canvas",{init:function(){this.requires("Renderable"),this.currentRect={},this._customLayer||this._attachToLayer(d.s("DefaultCanvasLayer"))},remove:function(){this._detachFromLayer()},drawVars:{type:"canvas",pos:{},ctx:null,coord:[0,0,0,0],co:{x:0,y:0,w:0,h:0}},draw:function(a,b,c,d,e){if(this.ready){var f=this.drawVars.pos;f._x=this._x+(b||0),f._y=this._y+(c||0),f._w=d||this._w,f._h=e||this._h;var g=a||this._drawContext,h=this.__coord||[0,0,0,0],i=this.drawVars.co;i.x=h[0]+(b||0),i.y=h[1]+(c||0),i.w=d||h[2],i.h=e||h[3],(this._flipX||this._flipY||this._rotation)&&g.save(),0!==this._rotation&&(g.translate(this._origin.x+this._x,this._origin.y+this._y),f._x=-this._origin.x,f._y=-this._origin.y,g.rotate(this._rotation%360*(Math.PI/180))),(this._flipX||this._flipY)&&(g.scale(this._flipX?-1:1,this._flipY?-1:1),this._flipX&&(f._x=-(f._x+f._w)),this._flipY&&(f._y=-(f._y+f._h)));var j;return this._alpha<1&&(j=g.globalAlpha,g.globalAlpha=this._alpha),this.drawVars.ctx=g,this.trigger("Draw",this.drawVars),(0!==this._rotation||this._flipX||this._flipY)&&g.restore(),j&&(g.globalAlpha=j),this}}})},{"../core/core.js":10}],26:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({assignColor:function(){function a(a){return a._red=a._blue=a._green=0,a}function b(a){var b=a.toString(16);return 1===b.length&&(b="0"+b),b}function c(a,c,d){return"#"+b(a)+b(c)+b(d)}function d(b,c){var d,e,f,g=b.length;if(7===g)d=b.substr(1,2),e=b.substr(3,2),f=b.substr(5,2);else{if(4!==g)return a(c);d=b.substr(1,1),d+=d,e=b.substr(2,1),e+=e,f=b.substr(3,1),f+=f}return c._red=parseInt(d,16),c._green=parseInt(e,16),c._blue=parseInt(f,16),c}function f(b,c){var d=l.exec(b);return null===d||4!==d.length&&5!==d.length?a(c):(c._red=Math.round(parseFloat(d[1])),c._green=Math.round(parseFloat(d[2])),c._blue=Math.round(parseFloat(d[3])),d[4]&&(c._strength=parseFloat(d[4])),c)}function g(a,b){if(void 0===k[a]){!1===j&&(window.document.body.appendChild(i),j=!0),i.style.color=a;f(window.getComputedStyle(i).color,b),k[a]=c(b._red,b._green,b._blue)}else d(k[a],b);return b}function h(a){return"rgba("+a._red+", "+a._green+", "+a._blue+", "+a._strength+")"}var i=e.createElement("div");i.style.display="none";var j=!1,k={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#00ff00",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#ffa500",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},l=/rgba?\s*\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,?\s*([0-9.]+)?\)/;return function(a,b){b=b||{},a=a.trim().toLowerCase();"#"===a[0]?d(a,b):"r"===a[0]&&"g"===a[1]&&"b"===a[2]?f(a,b):g(a,b),b._strength=b._strength||1,b._color=h(b)}}()}),d.defaultShader("Color",new d.WebGLShader("attribute vec2 aPosition;\nattribute vec3 aOrientation;\nattribute vec2 aLayer;\nattribute vec4 aColor;\n\nvarying lowp vec4 vColor;\n\nuniform vec4 uViewport;\n\nmat4 viewportScale = mat4(2.0 / uViewport.z, 0, 0, 0, 0, -2.0 / uViewport.w, 0,0, 0, 0,1,0, -1,+1,0,1);\nvec4 viewportTranslation = vec4(uViewport.xy, 0, 0);\n\nvoid main() {\n vec2 pos = aPosition;\n vec2 entityOrigin = aOrientation.xy;\n mat2 entityRotationMatrix = mat2(cos(aOrientation.z), sin(aOrientation.z), -sin(aOrientation.z), cos(aOrientation.z));\n\n pos = entityRotationMatrix * (pos - entityOrigin) + entityOrigin;\n gl_Position = viewportScale * (viewportTranslation + vec4(pos, 1.0/(1.0+exp(aLayer.x) ), 1) );\n vColor = vec4(aColor.rgb*aColor.a*aLayer.y, aColor.a*aLayer.y);\n}","precision mediump float;\nvarying lowp vec4 vColor;\nvoid main(void) {\n\tgl_FragColor = vColor;\n}",[{name:"aPosition",width:2},{name:"aOrientation",width:3},{name:"aLayer",width:2},{name:"aColor",width:4}],function(a,b){a.program.writeVector("aColor",b._red/255,b._green/255,b._blue/255,b._strength)})),d.c("Color",{_red:0,_green:0,_blue:0,_strength:1,_color:"",ready:!0,init:function(){this.__coord=this.__coord||[0,0,0,0],this.bind("Draw",this._drawColor),this._drawLayer&&this._setupColor(this._drawLayer),this.trigger("Invalidate")},events:{LayerAttached:"_setupColor"},remove:function(){this.unbind("Draw",this._drawColor),this.has("DOM")&&(this._element.style.backgroundColor="transparent"),this.trigger("Invalidate")},_setupColor:function(a){"WebGL"===a.type&&this._establishShader("Color",d.defaultShader("Color"))},_drawColor:function(a){this._color&&("DOM"===a.type?(a.style.backgroundColor=this._color,a.style.lineHeight=0):"canvas"===a.type?(a.ctx.fillStyle=this._color,a.ctx.fillRect(a.pos._x,a.pos._y,a.pos._w,a.pos._h)):"webgl"===a.type&&a.program.draw(a,this))},color:function(a){return 0===arguments.length?this._color:(arguments.length>=3?(this._red=arguments[0],this._green=arguments[1],this._blue=arguments[2],"number"==typeof arguments[3]&&(this._strength=arguments[3])):(d.assignColor(a,this),"number"==typeof arguments[1]&&(this._strength=arguments[1])),this._color="rgba("+this._red+", "+this._green+", "+this._blue+", "+this._strength+")",this.trigger("Invalidate"),this)}})},{"../core/core.js":10}],27:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({domHelper:{innerPosition:function(a,b){b=b||{};var c=a.getBoundingClientRect(),d=c.left+(window.pageXOffset?window.pageXOffset:e.body.scrollLeft),f=c.top+(window.pageYOffset?window.pageYOffset:e.body.scrollTop),g=parseInt(this.getStyle(a,"border-left-width")||0,10)||parseInt(this.getStyle(a,"borderLeftWidth")||0,10)||0,h=parseInt(this.getStyle(a,"border-top-width")||0,10)||parseInt(this.getStyle(a,"borderTopWidth")||0,10)||0;return b.x=d+g,b.y=f+h,b},getStyle:function(a,b){var c;return a.currentStyle?c=a.currentStyle[this.camelize(b)]:window.getComputedStyle&&(c=e.defaultView.getComputedStyle(a,null).getPropertyValue(this.csselize(b))),c},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},csselize:function(a){return a.replace(/[A-Z]/g,function(a){return a?"-"+a.toLowerCase():""})},translate:function(a,b,c,f){f=f||{};var g,h=e.documentElement,i=e.body;return c?(g=c._viewportRect(),f.x=(a-d.stage.x+(h&&h.scrollLeft||i&&i.scrollLeft||0))/g._scale+g._x,f.y=(b-d.stage.y+(h&&h.scrollTop||i&&i.scrollTop||0))/g._scale+g._y):(g=d.viewport,f.x=(a-d.stage.x+(h&&h.scrollLeft||i&&i.scrollLeft||0))/g._scale-g._x,f.y=(b-d.stage.y+(h&&h.scrollTop||i&&i.scrollTop||0))/g._scale-g._y),f}}})},{"../core/core.js":10}],28:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d._registerLayerTemplate("DOM",{type:"DOM",_changedObjs:[],_div:null,events:{LayerInit:"layerInit",LayerRemove:"layerRemove",RenderScene:"_render",PixelartSet:"_setPixelart"},layerInit:function(){this._changedObjs=[];var a=this._div=e.createElement("div");d.stage.elem.appendChild(a),a.style.position="absolute",a.style.zIndex=this.options.z,a.style.transformStyle="preserve-3d"},layerRemove:function(){this._div.parentNode.removeChild(this._div)},_setPixelArt:function(a){var b=this._div.style,c=d.domHelper.camelize;a?(b[c("image-rendering")]="optimizeSpeed",b[c("image-rendering")]="-moz-crisp-edges",b[c("image-rendering")]="-o-crisp-edges",b[c("image-rendering")]="-webkit-optimize-contrast",b[c("-ms-interpolation-mode")]="nearest-neighbor",b[c("image-rendering")]="optimize-contrast",b[c("image-rendering")]="pixelated",b[c("image-rendering")]="crisp-edges"):(b[c("image-rendering")]="optimizeQuality",b[c("-ms-interpolation-mode")]="bicubic",b[c("image-rendering")]="auto")},debug:function(){d.log(this._changedObjs)},_render:function(){var a=this._changedObjs;if(this._dirtyViewport&&(this._setViewport(),this._dirtyViewport=!1),a.length){for(var b=0,c=a.length;b=0&&this._drawLayers.splice(b,1),this._drawLayers.sort(function(a,b){return a.options.z-b.options.z})},_registerLayerTemplate:function(a,b){this._drawLayerTemplates[a]=b;var c=this._commonLayerProperties;for(var d in c)b[d]||(b[d]=c[d])},_commonLayerProperties:{options:{xResponse:1,yResponse:1,scaleResponse:1,z:0},_pointerEntities:0,_dirtyViewport:!1,_cachedViewportRect:null,init:function(){this._cachedViewportRect={},this.trigger("LayerInit"),this.uniqueBind("InvalidateViewport",function(){this._dirtyViewport=!0}),this.trigger("PixelartSet",d._pixelartEnabled),d._addDrawLayerInstance(this)},remove:function(){this.trigger("LayerRemove"),d._removeDrawLayerInstance(this)},_sort:function(a,b){return a._globalZ-b._globalZ},_viewportRect:function(a){var b=this._cachedViewportRect;if(a)return b;var c=d.viewport,e=this.options,f=Math.pow(c._scale,e.scaleResponse);return b._scale=f,b._w=c._width/f,b._h=c._height/f,b._x=e.xResponse*-c._x-.5*(e.xResponse-1)*(1-1/f)*c._width,b._y=e.yResponse*-c._y-.5*(e.yResponse-1)*(1-1/f)*c._height,b},_viewTransformRect:function(a,b,c){var d=this._viewportRect(c),e=d._scale;return b=b||{},b._x=a._x*e+Math.round(-d._x*e),b._y=a._y*e+Math.round(-d._y*e),b._w=a._w*e,b._h=a._h*e,b}},createLayer:function(a,b,c){var e=this._drawLayerTemplates[b];d.s(a,e,c),d.c(a,{init:function(){this.requires("Renderable"),this._customLayer=!0,this.requires(e.type),this._attachToLayer(d.s(a))},remove:function(){this._detachFromLayer()}})}})},{"../core/core.js":10}],35:[function(a,b,c){var d=a("../core/core.js");d.c("Particles",{required:"Renderable",ready:!0,_particlesPaused:!1,init:function(){this._Particles=d.clone(this._Particles),this._Particles.init(),this._Particles.parentEntity=this},events:{UpdateFrame:function(){!this._particlesPaused&&this._Particles.active&&(this._Particles.update(),this.trigger("Invalidate"))},Draw:function(a){this._Particles.active&&"canvas"===a.type&&this._Particles.render(a)}},particles:function(a){return this._Particles.config(a),this._Particles.start(),this},_Particles:{presets:{maxParticles:150,size:18,sizeRandom:4,speed:1,speedRandom:1.2,lifeSpan:29,lifeSpanRandom:7,angle:65,angleRandom:34,startColour:[255,131,0,1],startColourRandom:[48,50,45,0],endColour:[245,35,0,0],endColourRandom:[60,60,60,0],sharpness:20,sharpnessRandom:10,spread:10,duration:-1,fastMode:!1,gravity:{x:0,y:.1},jitter:0,originOffset:{x:0,y:0}},emissionRate:0,elapsedFrames:0,emitCounter:0,active:!0,particles:[],init:function(){for(var a in this.presets)this[a]=this.presets[a]},config:function(a){a=a||{};for(var b in a)this[b]=a[b];if(this.emissionRate=this.maxParticles/this.lifeSpan,this.particles.length!==this.maxParticles){this.particles.length=0;for(var c=0,d=this.maxParticles;c100?100:f<0?0:f,a.sizeSmall=~~(d/200*f),g=h=this.startColour[0]+this.startColourRandom[0]*this.RANDM1TO1(),a.colourR=g>255?255:g<0?0:~~g,g=i=this.startColour[1]+this.startColourRandom[1]*this.RANDM1TO1(),a.colourG=g>255?255:g<0?0:~~g,g=j=this.startColour[2]+this.startColourRandom[2]*this.RANDM1TO1(),a.colourB=g>255?255:g<0?0:~~g,g=k=this.startColour[3]+this.startColourRandom[3]*this.RANDM1TO1(),a.colourA=g>1?1:g<0?0:~~(100*g)/100,l=this.endColour[0]+this.endColourRandom[0]*this.RANDM1TO1(),m=this.endColour[1]+this.endColourRandom[1]*this.RANDM1TO1(),n=this.endColour[2]+this.endColourRandom[2]*this.RANDM1TO1(),o=this.endColour[3]+this.endColourRandom[3]*this.RANDM1TO1(),a.deltaColourR=(l-h)/e,a.deltaColourG=(m-i)/e,a.deltaColourB=(n-j)/e,a.deltaColourA=(o-k)/e},update:function(){var a=this.RANDM1TO1,b=this.gravity.x,c=this.gravity.y,d=this.jitter;this.elapsedFrames++,this.duration>=0&&this.duration0?1/this.emissionRate:1/0;this.emitCounter++;for(var f,g,h=this.particles,i=0,j=h.length;i0?(g.directionX+=b,g.directionY+=c,g.positionX+=g.directionX,g.positionY+=g.directionY,d&&(g.positionX+=d*a(),g.positionY+=d*a()),f=g.colourR+g.deltaColourR,g.colourR=f>255?255:f<0?0:~~f,f=g.colourG+g.deltaColourG,g.colourG=f>255?255:f<0?0:~~f,f=g.colourB+g.deltaColourB,g.colourB=f>255?255:f<0?0:~~f,f=g.colourA+g.deltaColourA,g.colourA=f>1?1:f<0?0:~~(100*f)/100,g.timeToLive--):this.emitCounter>e&&(this.initParticle(g),this.emitCounter-=e)},render:function(a){for(var b,c=a.ctx,d=this.particles,e=0,f=d.length;e>1;if(!(b.positionX<0||b.positionX+g>a.pos._w||b.positionY<0||b.positionY+g>a.pos._h)){var i=~~(a.pos._x+b.positionX),j=~~(a.pos._y+b.positionY),k=b.colourR,l=b.colourG,m=b.colourB,n=b.colourA,o="rgba("+k+","+l+","+m+","+n+")";if(this.fastMode)c.fillStyle=o;else{var p="rgba("+k+","+l+","+m+",0)",q=c.createRadialGradient(i+h,j+h,b.sizeSmall,i+h,j+h,h);q.addColorStop(0,o),q.addColorStop(.9,p),c.fillStyle=q}c.fillRect(i,j,g,g)}}},Particle:function(){this.positionX=0,this.positionY=0,this.directionX=0,this.directionY=0,this.size=0,this.sizeSmall=0,this.timeToLive=0,this.colourR=0,this.colourG=0,this.colourB=0,this.colourA=0,this.deltaColourR=0,this.deltaColourG=0,this.deltaColourB=0,this.deltaColourA=0,this.sharpness=0},RANDM1TO1:function(){return 2*Math.random()-1}},pauseParticles:function(){this._particlesPaused=!0},resumeParticles:function(){this._particlesPaused=!1}})},{"../core/core.js":10}],36:[function(a,b,c){a("../core/core.js").c("Renderable",{_changed:!1,_alpha:1,_visible:!0,_setterRenderable:function(a,b){this[a]!==b&&(this[a]=b,this.trigger("Invalidate"))},properties:{alpha:{set:function(a){this._setterRenderable("_alpha",a)},get:function(){return this._alpha},configurable:!0,enumerable:!0},_alpha:{enumerable:!1},visible:{set:function(a){this._setterRenderable("_visible",a)},get:function(){return this._visible},configurable:!0,enumerable:!0},_visible:{enumerable:!1}},init:function(){},_hideOnUnfreeze:!1,events:{Freeze:function(){this._hideOnUnfreeze=!this._visible,this._visible=!1,this.trigger("Invalidate")},Unfreeze:function(){this._visible=!this._hideOnUnfreeze,this.trigger("Invalidate")}},_invalidateRenderable:function(){!1===this._changed&&(this._changed=!0,this._drawLayer.dirty(this))},_attachToLayer:function(a){this._drawLayer&&this._detachFromLayer(),this._drawLayer=a,a.attach(this),this.bind("Invalidate",this._invalidateRenderable),this.trigger("LayerAttached",a),this.trigger("Invalidate")},_detachFromLayer:function(){this._drawLayer&&(this._drawLayer.detach(this),this.unbind("Invalidate",this._invalidateRenderable),this.trigger("LayerDetached",this._drawLayer),delete this._drawLayer)},flip:function(a){return a=a||"X",this["_flip"+a]||(this["_flip"+a]=!0,this.trigger("Invalidate")),this},unflip:function(a){return a=a||"X",this["_flip"+a]&&(this["_flip"+a]=!1,this.trigger("Invalidate")),this}})},{"../core/core.js":10}],37:[function(a,b,c){var d=a("../core/core.js");d.c("SpriteAnimation",{_reels:null,_currentReelId:null,_currentReel:null,_isPlaying:!1,animationSpeed:1,init:function(){this._reels={}},reel:function(a,b,c,e,f,g){if(0===arguments.length)return this._currentReelId;if(1===arguments.length&&"string"==typeof a){if(void 0===this._reels[a])throw"The specified reel "+a+" is undefined.";return this.pauseAnimation(),this._currentReelId!==a&&(this._currentReelId=a,this._currentReel=this._reels[a],this._updateSprite(),this.trigger("ReelChange",this._currentReel)),this}var h,i;if(h={id:a,frames:[],currentFrame:0,easing:new d.easing(b),defaultLoops:1},h.duration=h.easing.duration,"number"==typeof c)if(g=g||1/0,f>=0)for(i=0;i=g&&(c=0,e++);else for(i=0;i>f;--i)h.frames.push([c,e]),--c<0&&(c=g-1,e--);else{if(3!==arguments.length||"object"!=typeof c)throw"Unrecognized arguments. Please see the documentation for 'reel(...)'.";h.frames=c}return this._reels[a]=h,this},animate:function(a,b){"string"==typeof a&&this.reel(a);var c=this._currentReel;if(void 0===c||null===c)throw"No reel is specified, and there is no currently active reel.";return this.pauseAnimation(),void 0===b&&(b="number"==typeof a?a:1),c.easing.reset(),this.loops(b),this._setFrame(0),this.bind("UpdateFrame",this._animationTick),this._isPlaying=!0,this.trigger("StartAnimation",c),this},resumeAnimation:function(){return!1===this._isPlaying&&null!==this._currentReel&&(this.bind("UpdateFrame",this._animationTick),this._isPlaying=!0,this._currentReel.easing.resume(),this.trigger("StartAnimation",this._currentReel)),this},pauseAnimation:function(){return!0===this._isPlaying&&(this.unbind("UpdateFrame",this._animationTick),this._isPlaying=!1,this._reels[this._currentReelId].easing.pause()),this},resetAnimation:function(){var a=this._currentReel;if(null===a)throw"No active reel to reset.";return this.reelPosition(0),a.easing.repeat(a.defaultLoops),this},loops:function(a){return 0===arguments.length?null!==this._currentReel?this._currentReel.easing.loops:0:(null!==this._currentReel&&(a<0&&(a=1/0),this._currentReel.easing.repeat(a),this._currentReel.defaultLoops=a),this)},reelPosition:function(a){if(null===this._currentReel)throw"No active reel.";if(0===arguments.length)return this._currentReel.currentFrame;var b,c=this._currentReel.frames.length;if("end"===a&&(a=c-1),a<1&&a>0)b=a,a=Math.floor(c*b);else{if(a!==Math.floor(a))throw"Position "+a+" is invalid.";a<0&&(a=c-1+a),b=a/c}return a=Math.min(a,c-1),a=Math.max(a,0),this._setProgress(b),this._setFrame(a),this},reelFrame:function(a){if(null===this._currentReel)throw"No active reel.";var b=this._currentReel.frames.indexOf(a);if(-1===b)throw"Frame name "+a+" is invalid.";return this.reelPosition(b),this},_animationTick:function(a){var b=this._reels[this._currentReelId];b.easing.tick(a.dt*this.animationSpeed);var c=b.easing.value(),d=Math.min(Math.floor(b.frames.length*c),b.frames.length-1);this._setFrame(d),!0===b.easing.complete&&(this.pauseAnimation(),this.trigger("AnimationEnd",this._currentReel))},_setFrame:function(a){var b=this._currentReel;a!==b.currentFrame&&(b.currentFrame=a,this._updateSprite(),this.trigger("FrameChange",b))},_updateSprite:function(){var a=this._currentReel,b=a.frames[a.currentFrame];"string"==typeof b?this.sprite(b):this.sprite(b[0],b[1])},_setProgress:function(a,b){this._currentReel.easing.setProgress(a,b)},isPlaying:function(a){return!!this._isPlaying&&(a?this._currentReelId===a:!!this._currentReelId)},getReel:function(a){if(0===arguments.length){if(!this._currentReelId)return null;a=this._currentReelId}return this._reels[a]}})},{"../core/core.js":10}],38:[function(a,b,c){var d=a("../core/core.js");d.defaultShader("Sprite",new d.WebGLShader("attribute vec2 aPosition;\nattribute vec3 aOrientation;\nattribute vec2 aLayer;\nattribute vec2 aTextureCoord;\n\nvarying mediump vec3 vTextureCoord;\n\nuniform vec4 uViewport;\nuniform mediump vec2 uTextureDimensions;\n\nmat4 viewportScale = mat4(2.0 / uViewport.z, 0, 0, 0, 0, -2.0 / uViewport.w, 0,0, 0, 0,1,0, -1,+1,0,1);\nvec4 viewportTranslation = vec4(uViewport.xy, 0, 0);\n\nvoid main() {\n vec2 pos = aPosition;\n vec2 entityOrigin = aOrientation.xy;\n mat2 entityRotationMatrix = mat2(cos(aOrientation.z), sin(aOrientation.z), -sin(aOrientation.z), cos(aOrientation.z));\n \n pos = entityRotationMatrix * (pos - entityOrigin) + entityOrigin ;\n gl_Position = viewportScale * (viewportTranslation + vec4(pos, 1.0/(1.0+exp(aLayer.x) ), 1) );\n vTextureCoord = vec3(aTextureCoord, aLayer.y);\n}","varying mediump vec3 vTextureCoord;\n \nuniform sampler2D uSampler;\nuniform mediump vec2 uTextureDimensions;\n\nvoid main(void) {\n highp vec2 coord = vTextureCoord.xy / uTextureDimensions;\n mediump vec4 base_color = texture2D(uSampler, coord);\n gl_FragColor = vec4(base_color.rgb*base_color.a*vTextureCoord.z, base_color.a*vTextureCoord.z);\n}",[{name:"aPosition",width:2},{name:"aOrientation",width:3},{name:"aLayer",width:2},{name:"aTextureCoord",width:2}],function(a,b){var c=a.co;a.program.writeVector("aTextureCoord",c.x,c.y,c.x,c.y+c.h,c.x+c.w,c.y,c.x+c.w,c.y+c.h)})),d.extend({sprite:function(a,b,c,e,f,g,h){var i,j,k;"string"==typeof a&&(g=f,f=e,e=b,c=a,a=1,b=1),"string"==typeof b&&(g=f,f=e,e=c,c=b,b=a),!g&&f&&(g=f),f=parseInt(f||0,10),g=parseInt(g||0,10);var l=function(){this.ready=!0,this.trigger("Invalidate")};(k=d.asset(c))||(k=new Image,k.src=c,d.asset(c,k),k.onload=function(){for(var a in e)d(a).each(l)});var m=function(){this.requires("2D, Sprite"),this.__trim=[0,0,0,0],this.__image=c,this.__map=e,this.__coord=[this.__coord[0],this.__coord[1],this.__coord[2],this.__coord[3]],this.__tile=a,this.__tileh=b,this.__padding=[f,g],this.__padBorder=h,this.sprite(this.__coord[0],this.__coord[1],this.__coord[2],this.__coord[3]),this.img=k,this.img.complete&&this.img.width>0&&(this.ready=!0,this.trigger("Invalidate")),this.w=this.__coord[2],this.h=this.__coord[3],this._setupSpriteImage(this._drawLayer)};for(i in e)e.hasOwnProperty(i)&&(j=e[i],d.c(i,{ready:!1,__coord:[j[0],j[1],j[2]||1,j[3]||1],init:m}));return this}}),d.c("Sprite",{__image:"",__tile:0,__tileh:0,__padding:null,__trim:null,img:null,ready:!1,init:function(){this.__trim=[0,0,0,0],this.bind("Draw",this._drawSprite),this.bind("LayerAttached",this._setupSpriteImage)},remove:function(){this.unbind("Draw",this._drawSprite),this.unbind("LayerAttached",this._setupSpriteImage)},_setupSpriteImage:function(a){this.__image&&this.img&&a&&"WebGL"===a.type&&(this._establishShader(this.__image,d.defaultShader("Sprite")),this.program.setTexture(a.makeTexture(this.__image,this.img,!1)))},_drawSprite:function(a){var b=a.co,c=a.pos,d=a.ctx;if("canvas"===a.type)d.drawImage(this.img,b.x,b.y,b.w,b.h,c._x,c._y,c._w,c._h);else if("DOM"===a.type){var e=this._h/b.h,f=this._w/b.w,g=this._element.style,h=g.backgroundColor;"initial"===h&&(h="");var i=h+" url('"+this.__image+"') no-repeat";i!==g.background&&(g.background=i),g.backgroundPosition="-"+b.x*f+"px -"+b.y*e+"px",1===e&&1===f||(g.backgroundSize=this.img.width*f+"px "+this.img.height*e+"px")}else"webgl"===a.type&&a.program.draw(a,this)},sprite:function(a,b,c,d){if("string"==typeof a){var e=this.__map[a];if(!e)return this;a=e[0],b=e[1],c=e[2]||1,d=e[3]||1}return this.__coord=this.__coord||[0,0,0,0],this.__coord[0]=a*(this.__tile+this.__padding[0])+(this.__padBorder?this.__padding[0]:0)+this.__trim[0],this.__coord[1]=b*(this.__tileh+this.__padding[1])+(this.__padBorder?this.__padding[1]:0)+this.__trim[1],void 0!==c&&void 0!==d&&(this.__coord[2]=this.__trim[2]||c*this.__tile||this.__tile,this.__coord[3]=this.__trim[3]||d*this.__tileh||this.__tileh),this.trigger("Invalidate"),this},crop:function(a,b,c,d){var e=this._mbr||this.pos();return this.__trim=[],this.__trim[0]=a,this.__trim[1]=b,this.__trim[2]=c,this.__trim[3]=d,this.__coord[0]+=a,this.__coord[1]+=b,this.__coord[2]=c,this.__coord[3]=d,this._w=c,this._h=d,this.trigger("Invalidate",e),this}})},{"../core/core.js":10}],39:[function(a,b,c){var d=a("../core/core.js");d.c("Text",{_text:"",defaultSize:"10px",defaultFamily:"sans-serif",defaultVariant:"normal",defaultLineHeight:"normal",defaultTextAlign:"left",ready:!0,init:function(){this.requires("2D"),this._textFont={type:"",weight:"",size:this.defaultSize,lineHeight:this.defaultLineHeight,family:this.defaultFamily,variant:this.defaultVariant},this._textAlign=this.defaultTextAlign},events:{Draw:function(a){var b=this._fontString();if("DOM"===a.type){var c=this._element,d=c.style;d.color=this._textColor,d.font=b,d.textAlign=this._textAlign,c.innerHTML=this._text}else if("canvas"===a.type){var e=a.ctx;e.save(),e.textBaseline="top",e.fillStyle=this._textColor||"rgb(0,0,0)",e.font=b,e.textAlign=this._textAlign,e.fillText(this._text,a.pos._x,a.pos._y),e.restore()}},SetStyle:function(a){switch(a){case"textAlign":this._textAlign=this._element.style.textAlign;break;case"color":this.textColor(this._element.style.color);break;case"fontType":this._textFont.type=this._element.style.fontType;break;case"fontWeight":this._textFont.weight=this._element.style.fontWeight;break;case"fontSize":this._textFont.size=this._element.style.fontSize;break;case"fontFamily":this._textFont.family=this._element.style.fontFamily;break;case"fontVariant":this._textFont.variant=this._element.style.fontVariant;break;case"lineHeight":this._textFont.lineHeight=this._element.style.lineHeight}}},remove:function(){this.unbind(this._textUpdateEvent,this._dynamicTextUpdate)},_getFontHeight:function(){var a=/([a-zA-Z]+)\b/,b={px:1,pt:4/3,pc:16,cm:96/2.54,mm:96/25.4,in:96,em:void 0,ex:void 0};return function(c){var d=parseFloat(c),e=a.exec(c),f=e?e[1]:"px";return void 0!==b[f]?Math.ceil(d*b[f]):Math.ceil(d)}}(),_textGenerator:null,text:function(a,b){return void 0===a||null===a?this._text:("function"==typeof a?(this._text=a.call(this,b),this._textGenerator=a):(this._text=a,this._textGenerator=null),this.has("Canvas")&&this._resizeForCanvas(),this.trigger("Invalidate"),this)},_dynamicTextOn:!1,_textUpdateEvent:null,_dynamicTextUpdate:function(a){this._textGenerator&&this.text(this._textGenerator,a)},dynamicTextGeneration:function(a,b){return this.unbind(this._textUpdateEvent,this._dynamicTextUpdate),a&&(this._textUpdateEvent=b||"UpdateFrame",this.bind(this._textUpdateEvent,this._dynamicTextUpdate)),this},_resizeForCanvas:function(){var a=this._drawContext;a.font=this._fontString(),this.w=a.measureText(this._text).width;var b=this._textFont.size||this.defaultSize;this.h=1.1*this._getFontHeight(b),"left"===this._textAlign||"start"===this._textAlign?this.offsetBoundary(0,0,0,0):"center"===this._textAlign?this.offsetBoundary(this.w/2,0,-this.w/2,0):"end"!==this._textAlign&&"right"!==this._textAlign||this.offsetBoundary(this.w,0,-this.w,0)},_fontString:function(){return this._textFont.type+" "+this._textFont.variant+" "+this._textFont.weight+" "+this._textFont.size+" / "+this._textFont.lineHeight+" "+this._textFont.family},textColor:function(a){return d.assignColor(a,this),this._textColor="rgba("+this._red+", "+this._green+", "+this._blue+", "+this._strength+")",this.trigger("Invalidate"),this},textAlign:function(a){return this._textAlign=a,this.has("Canvas")&&this._resizeForCanvas(),this.trigger("Invalidate"),this},textFont:function(a,b){if(1===arguments.length){if("string"==typeof a)return this._textFont[a];if("object"==typeof a)for(var c in a)this._textFont[c]="family"===c?"'"+a[c]+"'":a[c]}else this._textFont[a]=b;return this.has("Canvas")&&this._resizeForCanvas(),this.trigger("Invalidate"),this},unselectable:function(){return this.has("DOM")&&(this.css({"-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",cursor:"default"}),this.trigger("Invalidate")),this}})},{"../core/core.js":10}],40:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({viewport:{clampToEntities:!0,_width:0,_height:0,_x:0,_y:0,_scale:1,bounds:null,scroll:function(a,b){this[a]=b,d.trigger("ViewportScroll"),d.trigger("InvalidateViewport")},rect_object:{_x:0,_y:0,_w:0,_h:0},rect:function(a){return a=a||this.rect_object,a._x=-this._x,a._y=-this._y,a._w=this._width/this._scale,a._h=this._height/this._scale,a},pan:function(){function a(a){h.tick(a.dt);var i=h.value();d.viewport.x=(1-i)*f+i*c,d.viewport.y=(1-i)*g+i*e,d.viewport._clamp(),h.complete&&(b(),d.trigger("CameraAnimationDone"))}function b(){d.unbind("UpdateFrame",a)}var c,e,f,g,h;return d._preBind("StopCamera",b),function(b,i,j,k){d.trigger("StopCamera"),"reset"!==b&&(f=d.viewport._x,g=d.viewport._y,c=f-b,e=g-i,h=new d.easing(j,k),d.uniqueBind("UpdateFrame",a))}}(),follow:function(){function a(){var a=d.viewport._scale;d.viewport.scroll("_x",-(this.x+this.w/2-d.viewport.width/2/a-e*a)),d.viewport.scroll("_y",-(this.y+this.h/2-d.viewport.height/2/a-f*a)),d.viewport._clamp()}function b(){c&&(c.unbind("Move",a),c.unbind("ViewportScale",a),c.unbind("ViewportResize",a))}var c,e,f;return d._preBind("StopCamera",b),function(b,g,h){b&&b.has("2D")&&(d.trigger("StopCamera"),c=b,e=void 0!==g?g:0,f=void 0!==h?h:0,b.bind("Move",a),b.bind("ViewportScale",a),b.bind("ViewportResize",a),a.call(b))}}(),centerOn:function(a,b){var c=a.x+d.viewport.x,e=a.y+d.viewport.y,f=a.w/2,g=a.h/2,h=d.viewport.width/2/d.viewport._scale,i=d.viewport.height/2/d.viewport._scale,j=c+f-h,k=e+g-i;d.viewport.pan(j,k,b)},zoom:function(){function a(){d.unbind("UpdateFrame",b)}function b(b){var e,l;k.tick(b.dt),e=Math.pow(f,k.value()),l=1===f?k.value():(1/e-1)/(1/f-1),d.viewport.scale(e*c),d.viewport.scroll("_x",g*(1-l)+h*l),d.viewport.scroll("_y",i*(1-l)+j*l),d.viewport._clamp(),k.complete&&(a(),d.trigger("CameraAnimationDone"))}d._preBind("StopCamera",a);var c,e,f,g,h,i,j,k;return function(a,l,m,n,o){if(!a)return void d.viewport.scale(1);arguments.length<=2&&(n=l,l=d.viewport.x-d.viewport.width,m=d.viewport.y-d.viewport.height),d.trigger("StopCamera"),c=d.viewport._scale,f=a,e=c*f,g=d.viewport.x,i=d.viewport.y,h=-(l-d.viewport.width/(2*e)),j=-(m-d.viewport.height/(2*e)),k=new d.easing(n,o),d.uniqueBind("UpdateFrame",b)}}(),scale:function(){return function(a){this._scale=a||1,d.trigger("InvalidateViewport"),d.trigger("ViewportScale")}}(),mouselook:function(){function a(a){g||a.target||(d.trigger("StopCamera"),h.x=a.clientX,h.y=a.clientY,g=!0)}function b(a){if(g){i.x=a.clientX-h.x,i.y=a.clientY-h.y,h.x=a.clientX,h.y=a.clientY;var b=d.viewport;b.x+=i.x/b._scale,b.y+=i.y/b._scale,b._clamp()}}function c(a){g&&(g=!1)}var e,f=!1,g=!1,h={x:0,y:0},i={x:0,y:0};return function(g){e=d.s("Mouse"),g&&!f?(e.bind("MouseDown",a),e.bind("MouseMove",b),e.bind("MouseUp",c),f=g):!g&&f&&(e.unbind("MouseDown",a),e.unbind("MouseMove",b),e.unbind("MouseUp",c),f=g)}}(),_clamp:function(){if(this.clampToEntities){var a=d.clone(this.bounds)||d.map.boundaries();a.max.x*=this._scale,a.min.x*=this._scale,a.max.y*=this._scale,a.min.y*=this._scale,a.max.x-a.min.x>d.viewport.width?d.viewport.x<(-a.max.x+d.viewport.width)/this._scale?d.viewport.x=(-a.max.x+d.viewport.width)/this._scale:d.viewport.x>-a.min.x&&(d.viewport.x=-a.min.x):d.viewport.x=-1*(a.min.x+(a.max.x-a.min.x)/2-d.viewport.width/2),a.max.y-a.min.y>d.viewport.height?d.viewport.y<(-a.max.y+d.viewport.height)/this._scale?d.viewport.y=(-a.max.y+d.viewport.height)/this._scale:d.viewport.y>-a.min.y&&(d.viewport.y=-a.min.y):d.viewport.y=-1*(a.min.y+(a.max.y-a.min.y)/2-d.viewport.height/2)}},init:function(a,b,c){void 0===c&&void 0===b&&void 0!==a&&"number"!=typeof a&&(c=a,a=window.innerWidth,b=window.innerHeight),d.createLayer("DefaultCanvasLayer","Canvas",{z:20}),d.createLayer("DefaultDOMLayer","DOM",{z:30}),d.createLayer("DefaultWebGLLayer","WebGL",{z:10}),this._defineViewportProperties(),this._x=0,this._y=0,this._scale=1,this.bounds=null,this._width=a||window.innerWidth,this._height=b||window.innerHeight,void 0===c&&(c="cr-stage");var f;if("string"==typeof c)f=e.getElementById(c);else{if(!("undefined"!=typeof HTMLElement?c instanceof HTMLElement:c instanceof Element))throw new TypeError("stage_elem must be a string or an HTMLElement");f=c}d.stage={x:0,y:0,fullscreen:!1,elem:f||e.createElement("div")},a||b||(e.body.style.overflow="hidden",d.stage.fullscreen=!0),d.addEvent(this,window,"resize",d.viewport.reload),d.addEvent(this,window,"blur",function(){d.settings.get("autoPause")&&(d._paused||d.pause())}),d.addEvent(this,window,"focus",function(){d._paused&&d.settings.get("autoPause")&&d.pause()}),d.settings.register("stageSelectable",function(a){d.stage.elem.onselectstart=a?function(){return!0}:function(){return!1}}),d.settings.modify("stageSelectable",!1),d.settings.register("stageContextMenu",function(a){d.stage.elem.oncontextmenu=a?function(){return!0}:function(){return!1}}),d.settings.modify("stageContextMenu",!1),d.settings.register("autoPause",function(){}),d.settings.modify("autoPause",!1),f||(e.body.appendChild(d.stage.elem),d.stage.elem.id=c);var g,h=d.stage.elem.style;if(h.width=this.width+"px",h.height=this.height+"px",h.overflow="hidden",d.bind("ViewportResize",function(){d.trigger("InvalidateViewport")}),d.mobile){void 0!==typeof h.webkitTapHighlightColor&&(h.webkitTapHighlightColor="rgba(0,0,0,0)");var i=e.createElement("meta"),j=e.getElementsByTagName("head")[0];i=e.createElement("meta"),i.setAttribute("name","apple-mobile-web-app-capable"),i.setAttribute("content","yes"),j.appendChild(i),d.addEvent(this,d.stage.elem,"touchmove",function(a){a.preventDefault()})}h.position="relative",g=d.domHelper.innerPosition(d.stage.elem),d.stage.x=g.x,d.stage.y=g.y,d.uniqueBind("ViewportResize",this._resize)},_resize:function(){d.stage.elem.style.width=d.viewport.width+"px",d.stage.elem.style.height=d.viewport.height+"px"},_defineViewportProperties:function(){Object.defineProperty(this,"x",{set:function(a){this.scroll("_x",a)},get:function(){return this._x},configurable:!0}),Object.defineProperty(this,"y",{set:function(a){this.scroll("_y",a)},get:function(){return this._y},configurable:!0}),Object.defineProperty(this,"width",{set:function(a){this._width=a,d.trigger("ViewportResize")},get:function(){return this._width},configurable:!0}),Object.defineProperty(this,"height",{set:function(a){this._height=a,d.trigger("ViewportResize")},get:function(){return this._height},configurable:!0})},reload:function(){var a,b=window.innerWidth,c=window.innerHeight;d.stage.fullscreen&&(this._width=b,this._height=c,d.trigger("ViewportResize")),a=d.domHelper.innerPosition(d.stage.elem),d.stage.x=a.x,d.stage.y=a.y},reset:function(){d.viewport.mouselook(!1),d.trigger("StopCamera"),d.viewport.scroll("_x",0),d.viewport.scroll("_y",0),d.viewport.scale(1)},onScreen:function(a){return d.viewport._x+a._x+a._w>0&&d.viewport._y+a._y+a._h>0&&d.viewport._x+a._x=this.max_size)){var b=Math.min(a,this.max_size),c=new Float32Array(4*b*this.stride),d=new Uint16Array(6*b);c.set(this._attributeArray),d.set(this._indexArray),this._attributeArray=c,this._indexArray=d,this.array_size=b}},registerEntity:function(a){if(0===this._registryHoles.length){if(this._registrySize>=this.max_size)throw"Number of entities exceeds maximum limit.";this._registrySize>=this.array_size&&this.growArrays(2*this.array_size),a._glBufferIndex=this._registrySize,this._registrySize++}else a._glBufferIndex=this._registryHoles.pop()},unregisterEntity:function(a){"number"==typeof a._glBufferIndex&&this._registryHoles.push(a._glBufferIndex),a._glBufferIndex=null},resetRegistry:function(){this._maxElement=0,this._registryHoles.length=0},setCurrentEntity:function(a){this.ent_offset=4*a._glBufferIndex,this.ent=a},switchTo:function(){var a=this.context;a.useProgram(this.shader),a.bindBuffer(a.ARRAY_BUFFER,this._attributeBuffer);for(var b,c=this.attributes,d=0;d0?1:-1,e={acceleration:b,rawAcceleration:"["+Math.round(b.x)+", "+Math.round(b.y)+", "+Math.round(b.z)+"]",facingUp:c,tiltLR:Math.round(b.x/9.81*-90),tiltFB:Math.round((b.y+9.81)/9.81*90*c)};d.device._deviceMotionCallback(e)},deviceOrientation:function(a){this._deviceOrientationCallback=a,d.support.deviceorientation&&(window.DeviceOrientationEvent?d.addEvent(this,window,"deviceorientation",this._normalizeDeviceOrientation):window.OrientationEvent&&d.addEvent(this,window,"MozOrientation",this._normalizeDeviceOrientation))},deviceMotion:function(a){this._deviceMotionCallback=a,d.support.devicemotion&&window.DeviceMotionEvent&&d.addEvent(this,window,"devicemotion",this._normalizeDeviceMotion)}}})},{"../core/core.js":10}],44:[function(a,b,c){b.exports={_events:{},addEvent:function(a,b,c,d){3===arguments.length&&(d=c,c=b,b=window.document);var e=a[0]||"",f=function(b){d.call(a,b)};this._events[e+b+c+d]||(this._events[e+b+c+d]=f,b.addEventListener(c,f,!1))},removeEvent:function(a,b,c,d){3===arguments.length&&(d=c,c=b,b=window.document);var e=a[0]||"",f=this._events[e+b+c+d];f&&(b.removeEventListener(c,f,!1),delete this._events[e+b+c+d])}}},{}],45:[function(a,b,c){var d=a("../core/core.js");d.s("Keyboard",d.extend.call(d.extend.call(new d.__eventDispatcher,{_evt:{eventName:"",key:0,which:0,originalEvent:null},prepareEvent:function(a){var b=this._evt,c=a.type;return b.eventName="keydown"===c?"KeyDown":"keyup"===c?"KeyUp":c,b.which=null!==a.charCode?a.charCode:a.keyCode,b.key=a.keyCode||a.which,b.originalEvent=a,b},triggerKeyEvent:function(a,b){d.trigger(a,b)},dispatchEvent:function(a){var b=this.prepareEvent(a);this.triggerKey(b.eventName,b)}}),d.__keyboardStateTemplate),{},!1),d.c("Keyboard",{isDown:function(a){return d.s("Keyboard").isKeyDown(a)}})},{"../core/core.js":10}],46:[function(a,b,c){var d=a("../core/core.js"),e=window.document,f=void 0!==e.onwheel?"wheel":void 0!==e.onmousewheel?"mousewheel":"DOMMouseScroll";d._preBind("Load",function(){d.addEvent(this,e.body,"mouseup",d.detectBlur),d.addEvent(d.s("Keyboard"),window,"blur",d.s("Keyboard").resetKeyDown),d.addEvent(d.s("Mouse"),window,"mouseup",d.s("Mouse").resetButtonDown),d.addEvent(d.s("Touch"),window,"touchend",d.s("Touch").resetTouchPoints),d.addEvent(d.s("Touch"),window,"touchcancel",d.s("Touch").resetTouchPoints),d.addEvent(d.s("Keyboard"),"keydown",d.s("Keyboard").processEvent),d.addEvent(d.s("Keyboard"),"keyup",d.s("Keyboard").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"mousedown",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"mouseup",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"mousemove",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"click",d.s("Mouse").processEvent),d.addEvent(d.s("Mouse"),d.stage.elem,"dblclick",d.s("Mouse").processEvent),d.addEvent(this,d.stage.elem,"touchstart",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchmove",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchend",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchcancel",this._touchDispatch),d.addEvent(this,d.stage.elem,"touchleave",this._touchDispatch),d.addEvent(d.s("MouseWheel"),d.stage.elem,f,d.s("MouseWheel").processEvent)}),d.bind("Pause",function(){d.s("Keyboard").resetKeyDown(),d.s("Mouse").resetButtonDown()}),d._preBind("CraftyStop",function(){d.s("Keyboard").resetKeyDown(),d.s("Mouse").resetButtonDown()}),d._preBind("CraftyStop",function(){d.removeEvent(this,e.body,"mouseup",d.detectBlur),d.removeEvent(d.s("Keyboard"),window,"blur",d.s("Keyboard").resetKeyDown),d.removeEvent(d.s("Mouse"),window,"mouseup",d.s("Mouse").resetButtonDown),d.removeEvent(d.s("Touch"),window,"touchend",d.s("Touch").resetTouchPoints),d.removeEvent(d.s("Touch"),window,"touchcancel",d.s("Touch").resetTouchPoints),d.removeEvent(d.s("Keyboard"),"keydown",d.s("Keyboard").processEvent),d.removeEvent(d.s("Keyboard"),"keyup",d.s("Keyboard").processEvent),d.stage&&(d.removeEvent(d.s("Mouse"),d.stage.elem,"mousedown",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"mouseup",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"mousemove",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"click",d.s("Mouse").processEvent),d.removeEvent(d.s("Mouse"),d.stage.elem,"dblclick",d.s("Mouse").processEvent),d.removeEvent(this,d.stage.elem,"touchstart",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchmove",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchend",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchcancel",this._touchDispatch),d.removeEvent(this,d.stage.elem,"touchleave",this._touchDispatch),d.removeEvent(d.s("MouseWheel"),d.stage.elem,f,d.s("MouseWheel").processEvent))})},{"../core/core.js":10}],47:[function(a,b,c){var d=a("../core/core.js");d.s("MouseWheel",d.extend.call(new d.__eventDispatcher,{_evt:{eventName:"",direction:0,target:null,clientX:0,clientY:0,realX:0,realY:0,originalEvent:null},_mouseSystem:null,prepareEvent:function(a){var b=this._mouseSystem;b||(this._mouseSystem=b=d.s("Mouse"));var c=this._evt;return c.eventName="MouseWheelScroll",c.direction=a.detail<0||a.wheelDelta>0||a.deltaY<0?1:-1,c.clientX=void 0!==a.clientX?a.clientX:b.lastMouseEvent.clientX,c.clientY=void 0!==a.clientY?a.clientY:b.lastMouseEvent.clientY,d.translatePointerEventCoordinates(a,c),c.target=b.mouseObjs?d.findPointerEventTargetByComponent("Mouse",a):null,c.originalEvent=a,c},dispatchEvent:function(a){var b=this.prepareEvent(a);d.trigger("MouseWheelScroll",b)}}),{},!1),d.s("Mouse",d.extend.call(d.extend.call(new d.__eventDispatcher,{normedEventNames:{mousedown:"MouseDown",mouseup:"MouseUp",dblclick:"DoubleClick",click:"Click",mousemove:"MouseMove"},_evt:{eventName:"",mouseButton:-1,target:null,clientX:0,clientY:0,realX:0,realY:0,originalEvent:null},mouseObjs:0,over:null,prepareEvent:function(a){var b=this._evt,c=a.type;return b.eventName=this.normedEventNames[c]||c,void 0===a.which?b.mouseButton=a.button<2?d.mouseButtons.LEFT:4===a.button?d.mouseButtons.MIDDLE:d.mouseButtons.RIGHT:b.mouseButton=a.which<2?d.mouseButtons.LEFT:2===a.which?d.mouseButtons.MIDDLE:d.mouseButtons.RIGHT,b.clientX=a.clientX,b.clientY=a.clientY,d.translatePointerEventCoordinates(a,b),b.target=this.mouseObjs?d.findPointerEventTargetByComponent("Mouse",a):null,b.originalEvent=a,b},triggerMouseEvent:function(a,b){this.trigger(a,b);var c=this.over,d=b.target;"MouseMove"===a&&c!==d&&(c&&(b.eventName="MouseOut",b.target=c,c.trigger("MouseOut",b),b.eventName="MouseMove",b.target=d),this.over=d,d&&(b.eventName="MouseOver",d.trigger("MouseOver",b),b.eventName="MouseMove")),d&&d.trigger(a,b)},dispatchEvent:function(a){var b=this.prepareEvent(a);this.triggerMouse(b.eventName,b)}}),d.__mouseStateTemplate),{},!1),d.c("Mouse",{required:"AreaMap",init:function(){d.s("Mouse").mouseObjs++},remove:function(){d.s("Mouse").mouseObjs--}}),d.c("MouseDrag",{_dragging:!1,required:"Mouse",events:{MouseDown:"_ondown"},init:function(){this._ondown=this._ondown.bind(this),this._ondrag=this._ondrag.bind(this),this._onup=this._onup.bind(this)},_ondown:function(a){a.mouseButton===d.mouseButtons.LEFT&&this.startDrag(a)},_ondrag:function(a){if(!this._dragging||0===a.realX||0===a.realY)return!1;this.trigger("Dragging",a)},_onup:function(a){a.mouseButton===d.mouseButtons.LEFT&&this.stopDrag(a)},startDrag:function(a){if(!this._dragging)return this._dragging=!0,d.s("Mouse").bind("MouseMove",this._ondrag),d.s("Mouse").bind("MouseUp",this._onup),this.trigger("StartDrag",a||d.s("Mouse").lastMouseEvent),this},stopDrag:function(a){if(this._dragging)return this._dragging=!1,d.s("Mouse").unbind("MouseMove",this._ondrag),d.s("Mouse").unbind("MouseUp",this._onup),this.trigger("StopDrag",a||d.s("Mouse").lastMouseEvent),this}})},{"../core/core.js":10}],48:[function(a,b,c){var d=a("../core/core.js");d.extend({findPointerEventTargetByComponent:function(a,b,c){var e=b.target||b.srcElement||d.stage.elem;c=void 0!==c?c:b.clientY,b=void 0!==b.clientX?b.clientX:b;var f,g,h,i,j,k=null,l=-1/0;if("CANVAS"!==e.nodeName){for(;"string"!=typeof e.id&&-1===e.id.indexOf("ent");)e=e.parentNode;var m=d(parseInt(e.id.replace("ent",""),10));j=d.domHelper.translate(b,c,m._drawLayer),m.__c[a]&&m.isAt(j.x,j.y)&&(k=m)}if(!k)for(var n in d._drawLayers){var o=d._drawLayers[n];if(!(o._pointerEntities<=0))for(j=d.domHelper.translate(b,c,o),g=d.map.unfilteredSearch({_x:j.x,_y:j.y,_w:1,_h:1}),i=0,h=g.length;il&&f.__c[a]&&f.isAt(j.x,j.y)&&(l=f._globalZ,k=f)}return k},translatePointerEventCoordinates:function(a,b){b=b||a;var c=d.domHelper.translate(a.clientX,a.clientY,void 0,this.__pointerPos);b.realX=c.x,b.realY=c.y},__pointerPos:{x:0,y:0}}),d.c("AreaMap",{init:function(){this.has("Renderable")&&this._drawLayer&&this._drawLayer._pointerEntities++},remove:function(a){!a&&this.has("Renderable")&&this._drawLayer&&this._drawLayer._pointerEntities--},events:{LayerAttached:function(a){a._pointerEntities++},LayerDetached:function(a){a._pointerEntities--}},areaMap:function(a){if(arguments.length>1){var b=Array.prototype.slice.call(arguments,0);a=new d.polygon(b)}else a=a.constructor===Array?new d.polygon(a.slice()):a.clone();return a.shift(this._x,this._y),this.mapArea=a,this.attach(this.mapArea),this.trigger("NewAreaMap",a),this}}),d.c("Button",{init:function(){var a=!d.mobile||d.mobile&&!d.multitouch()?"Mouse":"Touch";this.requires(a)}})},{"../core/core.js":10}],49:[function(a,b,c){var d=a("../core/core.js");d.extend({multitouch:function(a){return"boolean"!=typeof a?this._multitouch:(this._multitouch=a,this)},_multitouch:!1,_touchDispatch:function(){function a(a){var b,d;"touchstart"===a.type?b="mousedown":"touchmove"===a.type?b="mousemove":"touchend"===a.type?b="mouseup":"touchcancel"===a.type?b="mouseup":"touchleave"===a.type&&(b="mouseup"),a.touches&&a.touches.length?d=a.touches[0]:a.changedTouches&&a.changedTouches.length&&(d=a.changedTouches[0]);var f=document.createEvent("MouseEvent");if(f.initMouseEvent(b,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,a.relatedTarget),d.target.dispatchEvent(f),"mousedown"===b)c=d.clientX,e=d.clientY;else if("mouseup"===b){var g=d.clientX-c,h=d.clientY-e;g*g+h*h<=256&&(b="click",f=document.createEvent("MouseEvent"),f.initMouseEvent(b,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,a.relatedTarget),d.target.dispatchEvent(f))}a.preventDefault()}var b,c=0,e=0;return function(c){d._multitouch?(b||(b=d.s("Touch")),b.processEvent(c)):a(c)}}()}),d.s("Touch",d.extend.call(d.extend.call(new d.__eventDispatcher,{normedEventNames:{touchstart:"TouchStart",touchmove:"TouchMove",touchend:"TouchEnd",touchcancel:"TouchCancel"},_evt:{eventName:"",identifier:-1,target:null,entity:null,realX:0,realY:0,originalEvent:null},touchObjs:0,overs:{},prepareEvent:function(a,b){var c=this._evt;return c.eventName=this.normedEventNames[b]||b,c.identifier=a.identifier,d.translatePointerEventCoordinates(a,c),c.target=this.touchObjs?d.findPointerEventTargetByComponent("Touch",a):null,c.entity=c.target,c},triggerTouchEvent:function(a,b){this.trigger(a,b);var c=b.identifier,d=b.target,e=this.overs[c];e&&("TouchMove"===a&&e!==d||"TouchEnd"===a||"TouchCancel"===a)&&(b.eventName="TouchOut",b.target=e,b.entity=e,e.trigger("TouchOut",b),b.eventName=a,b.target=d,b.entity=d,delete this.overs[c]),d&&d.trigger(a,b),d&&("TouchStart"===a||"TouchMove"===a&&e!==d)&&(b.eventName="TouchOver",d.trigger("TouchOver",b),b.eventName=a,this.overs[c]=d)},dispatchEvent:function(a){for(var b,c=a.changedTouches,d=0,e=c.length;d=112&&a.key<=135))return a.stopPropagation?a.stopPropagation():a.cancelBubble=!0,!(!a.target||"INPUT"!==a.target.nodeName&&"TEXTAREA"!==a.target.nodeName)||(a.preventDefault?a.preventDefault():a.returnValue=!1,!1)}},d.extend({selected:!0,detectBlur:function(a){var b=a.clientX>d.stage.x&&a.clientXd.stage.y&&a.clientY0&&e0&&f0?b:a/2,this},place:function(a,b,c,e){var f=this.pos2px(a,b);return f.top-=c*(this._tile.height/2),e.x=f.left+d.viewport._x,e.y=f.top+d.viewport._y,e.z+=c,this},pos2px:function(a,b){return{left:a*this._tile.width+(1&b)*(this._tile.width/2),top:b*this._tile.height/2}},px2pos:function(a,b){return{x:-Math.ceil(-a/this._tile.width-.5*(1&b)),y:b/this._tile.height*2}},centerAt:function(a,b){if("number"==typeof a&&"number"==typeof b){var c=this.pos2px(a,b);return d.viewport._x=-c.left+d.viewport.width/2-this._tile.width/2,d.viewport._y=-c.top+d.viewport.height/2-this._tile.height/2,this}return{top:-d.viewport._y+d.viewport.height/2-this._tile.height/2,left:-d.viewport._x+d.viewport.width/2-this._tile.width/2}},area:function(){var a=this.centerAt(),b=this.px2pos(-a.left+d.viewport.width/2,-a.top+d.viewport.height/2),c=this.px2pos(-a.left-d.viewport.width/2,-a.top-d.viewport.height/2);return{x:{start:b.x,end:c.x},y:{start:b.y,end:c.y}}}}})},{"../core/core.js":10}],53:[function(a,b,c){var d=a("../core/core.js"),e=window.document;d.extend({audio:{sounds:{},supported:null,codecs:{ogg:'audio/ogg; codecs="vorbis"',wav:'audio/wav; codecs="1"',webma:'audio/webm; codecs="vorbis"',mp3:'audio/mpeg; codecs="mp3"',m4a:'audio/mp4; codecs="mp4a.40.2"'},volume:1,muted:!1,paused:!1,playCheck:null,_canPlay:function(){if(this.supported={},d.support.audio){var a,b=this.audioElement();for(var c in this.codecs)a=b.canPlayType(this.codecs[c]),this.supported[c]=""!==a&&"no"!==a}},supports:function(a){return null===this.supported&&this._canPlay(),!!this.supported[a]},audioElement:function(){return"undefined"!=typeof Audio?new Audio(""):e.createElement("audio")},create:function(a,b){var c=b.substr(b.lastIndexOf(".")+1).toLowerCase();if(!this.supports(c))return!1;var e=this.audioElement();return e.id=a,e.preload="auto",e.volume=d.audio.volume,e.src=b,d.asset(b,e),this.sounds[a]={obj:e,played:0,volume:d.audio.volume},this.sounds[a]},add:function(a,b){if(d.support.audio){var c,e;if(1===arguments.length&&"object"==typeof a)for(var f in a)for(c in a[f])if(e=d.audio.create(f,a[f][c]))break;if("string"==typeof a&&("string"==typeof b&&(e=d.audio.create(a,b)),"object"==typeof b))for(c in b)if(e=d.audio.create(a,b[c]))break;return e}},play:function(a,b,c){if(0!==b&&d.support.audio&&this.sounds[a]){var e=this.sounds[a],f=this.getOpenChannel();if(!f)return null;f.id=a,f.repeat=b;var g=f.obj;return f.volume=e.volume=e.obj.volume=c||d.audio.volume,g.volume=e.volume,g.src=e.obj.src,this.muted&&(g.volume=0),g.play(),e.played++,f.onEnd=function(){e.played0&&this._cascade(a)}),this.bind("Rotate",function(a){var b=this._cbr||this._mbr||this;this._entry.update(b),this._children.length>0&&this._cascadeRotation(a)}),this.bind("Remove",function(){if(this._children){for(var a=0;a-1e-10?0:i,j=j<1e-10&&j>-1e-10?0:j;var k=d*i+f*j,l=-d*j+f*i,m=e*i+f*j,n=-e*j+f*i,o=e*i+h*j,p=-e*j+h*i,q=d*i+h*j,r=-d*j+h*i,s=Math.floor(Math.min(k,m,o,q)+a),t=Math.floor(Math.min(l,n,p,r)+b),u=Math.ceil(Math.max(k,m,o,q)+a),v=Math.ceil(Math.max(l,n,p,r)+b);if(this._mbr?(this._mbr._x=s,this._mbr._y=t,this._mbr._w=u-s,this._mbr._h=v-t):this._mbr={_x:s,_y:t,_w:u-s,_h:v-t},this._cbr){var w=this._cbr,x=w.cx,y=w.cy,z=w.r,A=a+(x+this._x-a)*i+(y+this._y-b)*j,B=b-(x+this._x-a)*j+(y+this._y-b)*i;w._x=Math.min(A-z,s),w._y=Math.min(B-z,t),w._w=Math.max(A+z,u)-w._x,w._h=Math.max(B+z,v)-w._y}},_rotate:function(a){var b=this._rotation-a;0!==b&&(this._rotation=a,this._calculateMBR(),this.trigger("Rotate",b))},area:function(){return this._w*this._h},intersect:function(a,b,c,d){var e,f=this._mbr||this;return e="object"==typeof a?a:{_x:a,_y:b,_w:c,_h:d},f._xe._x&&f._ye._y},within:function(a,b,c,d){var e,f=this._mbr||this;return e="object"==typeof a?a:{_x:a,_y:b,_w:c,_h:d},e._x<=f._x&&e._x+e._w>=f._x+f._w&&e._y<=f._y&&e._y+e._h>=f._y+f._h},contains:function(a,b,c,d){var e,f=this._mbr||this;return e="object"==typeof a?a:{_x:a,_y:b,_w:c,_h:d},e._x>=f._x&&e._x+e._w<=f._x+f._w&&e._y>=f._y&&e._y+e._h<=f._y+f._h},pos:function(a){return a=a||{},a._x=this._x,a._y=this._y,a._w=this._w,a._h=this._h,a},mbr:function(a){return a=a||{},this._mbr?(a._x=this._mbr._x,a._y=this._mbr._y,a._w=this._mbr._w,a._h=this._mbr._h,a):this.pos(a)},isAt:function(a,b){if(this.mapArea)return this.mapArea.containsPoint(a,b);if(this.map)return this.map.containsPoint(a,b);var c=this._mbr||this;return c._x<=a&&c._x+c._w>=a&&c._y<=b&&c._y+c._h>=b},move:function(a,b){return"n"===a.charAt(0)&&(this.y-=b),"s"===a.charAt(0)&&(this.y+=b),"e"!==a&&"e"!==a.charAt(1)||(this.x+=b),"w"!==a&&"w"!==a.charAt(1)||(this.x-=b),this},shift:function(a,b,c,d){return(a||b)&&this._setPosition(this._x+a,this._y+b),c&&(this.w+=c),d&&(this.h+=d),this},_cascade:function(a){if(a)for(var b,c=0,d=this._children,e=d.length,f=this._x-a._x,g=this._y-a._y,h=this._w-a._w,i=this._h-a._h;c1&&(a=Array.prototype.slice.call(arguments,0)),this.points=a},d.polygon.prototype={containsPoint:function(a,b){var c,d,e=this.points,f=e.length/2,g=!1;for(c=0,d=f-1;cb!=e[2*d+1]>b&&a<(e[2*d]-e[2*c])*(b-e[2*c+1])/(e[2*d+1]-e[2*c+1])+e[2*c]&&(g=!g);return g},shift:function(a,b){for(var c=0,d=this.points,e=d.length;c=0&&e<=1&&c>=0&&c=0&&c=0&&cthis.mtx.length||b<1||b>this.mtx[0].length?null:this.mtx[a-1][b-1]}}},{"../core/core.js":10}],55:[function(a,b,c){var d=a("../core/core.js"),e=Math.PI/180;d.extend({raycast:function(a,b){for(var c,e,f="obj",g=1/0,h=!0,i=2,j=arguments.length;ig)return!0;if(c.map&&c.__c[f]&&!o[c[0]]){o[c[0]]=!0;var e=c.map.intersectRay(a,b);e1){var b=Array.prototype.slice.call(arguments,0);a=new d.polygon(b)}else a=a.constructor===Array?new d.polygon(a.slice()):a.clone();this._findBounds(a.points)}else a=new d.polygon([0,0,this._w,0,this._w,this._h,0,this._h]),this.bind("Resize",this._resizeMap),this._cbr=null;return this.rotation&&a.rotate(this.rotation,this._origin.x,this._origin.y,Math.cos(-this.rotation*e),Math.sin(-this.rotation*e)),this.map=a,this.attach(this.map),this.map.shift(this._x,this._y),this.trigger("NewHitbox",a),this},cbr:function(a){return a=a||{},this._cbr?(a._x=this._cbr._x,a._y=this._cbr._y,a._w=this._cbr._w,a._h=this._cbr._h,a):this.mbr(a)},_findBounds:function(a){for(var b=1/0,c=-1/0,d=1/0,e=-1/0,f=a.length,g=0;gc&&(c=a[g]),a[g+1]e&&(e=a[g+1]);var h={cx:(b+c)/2,cy:(d+e)/2,r:Math.sqrt((c-b)*(c-b)+(e-d)*(e-d))/2};return b>=0&&d>=0&&(this._checkBounds=function(){null===this._cbr&&this._w=0&&d>=0&&c<=this._w&&e<=this._h?(this._cbr=null,!1):(this._cbr=h,this._calculateMBR(),!0)},_resizeMap:function(a){var b,c,d=this.rotation*e,f=this.map.points;"w"===a.axis?(d?(b=a.amount*Math.cos(d),c=a.amount*Math.sin(d)):(b=a.amount,c=0),f[2]+=b,f[3]+=c):(d?(c=a.amount*Math.cos(d),b=-a.amount*Math.sin(d)):(b=0,c=a.amount),f[6]+=b,f[7]+=c),f[4]+=b,f[5]+=c},_collisionHitDupes:[],_collisionHitResults:[],hit:function(a,b){var c=this._cbr||this._mbr||this,e=this._collisionHitResults;e.length=0,e=d.map.unfilteredSearch(c,e);var f=e.length;if(!f)return null;var g,h,i=0,j=this._collisionHitDupes;for(b=b||[],j.length=0;ig&&(g=j),jh&&(h=j),j=0)return!1;i>s&&(s=i,t=q,u=r)}for(l=0;lg&&(g=j),jh&&(h=j),j=0)return!1;i>s&&(s=i,t=q,u=r)}return{overlap:s,nx:t,ny:u}}})},{"../core/core.js":10}],56:[function(a,b,c){var d=a("../core/core.js");d.math={abs:function(a){return a<0?-a:a},amountOf:function(a,b,c){return bc?c:a=b&&a<=c}},d.math.Vector2D=function(){function a(b,c){if(b instanceof a)this.x=b.x,this.y=b.y;else if(2===arguments.length)this.x=b,this.y=c;else if(arguments.length>0)throw"Unexpected number of arguments for Vector2D()"}return a.prototype.x=0,a.prototype.y=0,a.prototype.add=function(a){return this.x+=a.x,this.y+=a.y,this},a.prototype.angleBetween=function(a){return Math.atan2(this.x*a.y-this.y*a.x,this.x*a.x+this.y*a.y)},a.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)},a.prototype.clone=function(){return new a(this)},a.prototype.distance=function(a){return Math.sqrt((a.x-this.x)*(a.x-this.x)+(a.y-this.y)*(a.y-this.y))},a.prototype.distanceSq=function(a){return(a.x-this.x)*(a.x-this.x)+(a.y-this.y)*(a.y-this.y)},a.prototype.divide=function(a){return this.x/=a.x,this.y/=a.y,this},a.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y},a.prototype.crossProduct=function(a){return this.x*a.y-this.y*a.x},a.prototype.equals=function(b){return b instanceof a&&this.x===b.x&&this.y===b.y},a.prototype.perpendicular=function(b){return b=b||new a,b.setValues(-this.y,this.x)},a.prototype.getNormal=function(b,c){return c=c||new a,c.setValues(b.y-this.y,this.x-b.x).normalize()},a.prototype.isZero=function(){return 0===this.x&&0===this.y},a.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},a.prototype.magnitudeSq=function(){return this.x*this.x+this.y*this.y},a.prototype.multiply=function(a){return this.x*=a.x,this.y*=a.y,this},a.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},a.prototype.normalize=function(){var a=Math.sqrt(this.x*this.x+this.y*this.y);return 0===a?(this.x=1,this.y=0):(this.x/=a,this.y/=a),this},a.prototype.scale=function(a,b){return void 0===b&&(b=a),this.x*=a,this.y*=b,this},a.prototype.scaleToMagnitude=function(a){var b=a/this.magnitude();return this.x*=b,this.y*=b,this},a.prototype.setValues=function(b,c){return b instanceof a?(this.x=b.x,this.y=b.y):(this.x=b,this.y=c),this},a.prototype.subtract=function(a){return this.x-=a.x,this.y-=a.y,this},a.prototype.toString=function(){return"Vector2D("+this.x+", "+this.y+")"},a.prototype.translate=function(a,b){return void 0===b&&(b=a),this.x+=a,this.y+=b,this},a.tripleProduct=function(a,b,c,e){e=e||new d.math.Vector2D;var f=a.dotProduct(c),g=b.dotProduct(c);return e.setValues(b.x*f-a.x*g,b.y*f-a.y*g)},a}(),d.math.Matrix2D=function(){function a(b,c,d,e,f,g){if(b instanceof a)this.a=b.a,this.b=b.b,this.c=b.c,this.d=b.d,this.e=b.e,this.f=b.f;else if(6===arguments.length)this.a=b,this.b=c,this.c=d,this.d=e,this.e=f,this.f=g;else if(arguments.length>0)throw"Unexpected number of arguments for Matrix2D()"}return a.prototype.a=1,a.prototype.b=0,a.prototype.c=0,a.prototype.d=1,a.prototype.e=0,a.prototype.f=0,a.prototype.apply=function(a){var b=a.x;return a.x=b*this.a+a.y*this.c+this.e,a.y=b*this.b+a.y*this.d+this.f,a},a.prototype.clone=function(){return new a(this)},a.prototype.combine=function(a){var b=this.a;return this.a=b*a.a+this.b*a.c,this.b=b*a.b+this.b*a.d,b=this.c,this.c=b*a.a+this.d*a.c,this.d=b*a.b+this.d*a.d,b=this.e,this.e=b*a.a+this.f*a.c+a.e,this.f=b*a.b+this.f*a.d+a.f,this},a.prototype.equals=function(b){return b instanceof a&&this.a===b.a&&this.b===b.b&&this.c===b.c&&this.d===b.d&&this.e===b.e&&this.f===b.f},a.prototype.determinant=function(){return this.a*this.d-this.b*this.c},a.prototype.invert=function(){var a=this.determinant();if(0!==a){var b={a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f};this.a=b.d/a,this.b=-b.b/a,this.c=-b.c/a,this.d=b.a/a,this.e=(b.c*b.f-b.e*b.d)/a,this.f=(b.e*b.b-b.a*b.f)/a}return this},a.prototype.isIdentity=function(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.e&&0===this.f},a.prototype.isInvertible=function(){return 0!==this.determinant()},a.prototype.preRotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a;return this.a=b*d-c*this.b,this.b=c*d+b*this.b,d=this.c,this.c=b*d-c*this.d,this.d=c*d+b*this.d,this},a.prototype.preScale=function(a,b){return void 0===b&&(b=a),this.a*=a,this.b*=b,this.c*=a,this.d*=b,this},a.prototype.preTranslate=function(a,b){return"number"==typeof a?(this.e+=a,this.f+=b):(this.e+=a.x,this.f+=a.y),this},a.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a;return this.a=b*d-c*this.b,this.b=c*d+b*this.b,d=this.c,this.c=b*d-c*this.d,this.d=c*d+b*this.d,d=this.e,this.e=b*d-c*this.f,this.f=c*d+b*this.f,this},a.prototype.scale=function(a,b){return void 0===b&&(b=a),this.a*=a,this.b*=b,this.c*=a,this.d*=b,this.e*=a,this.f*=b,this},a.prototype.setValues=function(b,c,d,e,f,g){return b instanceof a?(this.a=b.a,this.b=b.b,this.c=b.c,this.d=b.d,this.e=b.e,this.f=b.f):(this.a=b,this.b=c,this.c=d,this.d=e,this.e=f,this.f=g),this},a.prototype.toString=function(){return"Matrix2D(["+this.a+", "+this.c+", "+this.e+"] ["+this.b+", "+this.d+", "+this.f+"] [0, 0, 1])"},a.prototype.translate=function(a,b){return"number"==typeof a?(this.e+=this.a*a+this.c*b,this.f+=this.b*a+this.d*b):(this.e+=this.a*a.x+this.c*a.y,this.f+=this.b*a.x+this.d*a.y),this},a}()},{"../core/core.js":10}],57:[function(a,b,c){var d=a("../core/core.js"),e=function(a,b,c,e){var f=b+c,g="_"+f,h={key:"",oldValue:0};e?d.defineField(a,f,function(){return this[g]},function(a){var b=this[g];a!==b&&(this[g]=a,h.key=f,h.oldValue=b,this.trigger("MotionChange",h))}):d.defineField(a,f,function(){return this[g]},function(a){}),Object.defineProperty(a,g,{value:0,writable:!0,enumerable:!1,configurable:!1})},f=function(a,b,c,e){var f=b+"x",g=b+"y",h="_"+f,i="_"+g;return c?(d.defineField(e,"x",function(){return a[h]},function(b){a[f]=b}),d.defineField(e,"y",function(){return a[i]},function(b){a[g]=b})):(d.defineField(e,"x",function(){return a[h]},function(a){}),d.defineField(e,"y",function(){return a[i]},function(a){})),Object.seal&&Object.seal(e),e};d.c("AngularMotion",{_vrotation:0,_arotation:0,_drotation:0,init:function(){this.requires("2D"),e(this,"v","rotation",!0),e(this,"a","rotation",!0),e(this,"d","rotation",!1),this.__oldRotationDirection=0,this.bind("UpdateFrame",this._angularMotionTick)},remove:function(a){this.unbind("UpdateFrame",this._angularMotionTick)},resetAngularMotion:function(){return this._drotation=0,this.vrotation=0,this.arotation=0,this},_angularMotionTick:function(a){var b=a.dt/1e3,c=this._rotation,d=this._vrotation,e=this._arotation,f=c+d*b+.5*e*b*b;this.vrotation=d+e*b;var g=this._vrotation,h=g?g<0?-1:1:0;this.__oldRotationDirection!==h&&(this.__oldRotationDirection=h,this.trigger("NewRotationDirection",h)),this._drotation=f-c,0!==this._drotation&&(this.rotation=f,this.trigger("Rotated",c))}}),d.c("Motion",{_vx:0,_vy:0,_ax:0,_ay:0,_dx:0,_dy:0,init:function(){this.requires("2D"),e(this,"v","x",!0),e(this,"v","y",!0),this._velocity=f(this,"v",!0,new d.math.Vector2D),e(this,"a","x",!0),e(this,"a","y",!0),this._acceleration=f(this,"a",!0,new d.math.Vector2D),e(this,"d","x",!1),e(this,"d","y",!1),this._motionDelta=f(this,"d",!1,new d.math.Vector2D),this.__oldDirection={x:0,y:0},this.bind("UpdateFrame",this._linearMotionTick)},remove:function(a){this.unbind("UpdateFrame",this._linearMotionTick)},resetMotion:function(){return this.vx=0,this.vy=0,this.ax=0,this.ay=0,this._dx=0,this._dy=0,this},motionDelta:function(){return this._motionDelta},velocity:function(){return this._velocity},acceleration:function(){return this._acceleration},ccdbr:function(a){var b=this._cbr||this._mbr||this,c=this._dx,d=this._dy,e=0,f=0,g=c>0?e=c:-c,h=d>0?f=d:-d;return a=a||{},a._x=b._x-e,a._y=b._y-f,a._w=b._w+g,a._h=b._h+h,a},_linearMotionTick:function(a){var b=a.dt/1e3,c=this._vx,d=this._ax,e=this._vy,f=this._ay,g=c*b+.5*d*b*b,h=e*b+.5*f*b*b;this.vx=c+d*b,this.vy=e+f*b;var i=this.__oldDirection,j=this._vx,k=j?j<0?-1:1:0,l=this._vy,m=l?l<0?-1:1:0;i.x===k&&i.y===m||(i.x=k,i.y=m,this.trigger("NewDirection",i)),this._dx=g,this._dy=h,this._setPosition(this._x+g,this._y+h)}})},{"../core/core.js":10}],58:[function(a,b,c){var d=a("../core/core.js");d.c("Supportable",{_ground:null,_groundComp:null,_preventGroundTunneling:!1,canLand:!0,init:function(){this.requires("2D"),this.__area={_x:0,_y:0,_w:0,_h:0},this.defineField("ground",function(){return this._ground},function(a){})},remove:function(a){this.unbind("UpdateFrame",this._detectGroundTick)},startGroundDetection:function(a){return a&&(this._groundComp=a),this.uniqueBind("UpdateFrame",this._detectGroundTick),this},stopGroundDetection:function(){return this.unbind("UpdateFrame",this._detectGroundTick),this},preventGroundTunneling:function(a){return void 0===a&&(a=!0),a&&this.requires("Motion"),this._preventGroundTunneling=a,this},_detectGroundTick:function(){var a,b=this._groundComp,c=this._ground,e=d.rectManager.overlap;if(this._preventGroundTunneling)a=this.ccdbr(this.__area);else{var f=this._cbr||this._mbr||this;a=this.__area,a._x=f._x,a._y=f._y,a._w=f._w,a._h=f._h}if(a._h++,c){var g=c._cbr||c._mbr||c;c.__c[b]&&d(c[0])===c&&e(g,a)||(this._ground=null,this.trigger("LiftedOffGround",c),c=null)}if(!c)for(var h,i,j=d.map.unfilteredSearch(a),k=0,l=j.length;kc._x+c._w?this.x=c._x+c._w-1:this._x+this._wb._x&&a._yb._y},integerBounds:function(a){return a._x=Math.floor(a._x),a._y=Math.floor(a._y),a._w=Math.ceil(a._w),a._h=Math.ceil(a._h),a},mergeSet:function(a){if(a.length<2)return a;for(var b=a.length-1;b--;)this.overlap(a[b],a[b+1])&&(this.merge(a[b],a[b+1],a[b]),a.splice(b+1,1));return a},boundingRect:function(a){if(a&&a.length){var b,c,d=1,e=a.length,f=a[0];for(f=[f._x,f._y,f._x+f._w,f._y+f._h];df[2]&&(f[2]=c[2]),c[3]>f[3]&&(f[3]=c[3]),d++;return c=f,f={_x:c[0],_y:c[1],_w:c[2]-c[0],_h:c[3]-c[1]}}},_pool:function(){var a=[],b=0;return{get:function(c,d,e,f){a.length<=b&&a.push({});var g=a[b++];return g._x=c,g._y=d,g._w=e,g._h=f,g},copy:function(c){a.length<=b&&a.push({});var d=a[b++];return d._x=c._x,d._y=c._y,d._w=c._w,d._h=c._h,d},recycle:function(a){b--}}}()}})},{"../core/core.js":10}],60:[function(a,b,c){function d(a,b,c){this.keys=a,this.map=c,this.obj=b}var e,f={},g=function(a){e=a||64,this.map={},this.boundsDirty=!1,this.coordBoundsDirty=!1,this.boundsHash={maxX:-1/0,maxY:-1/0,minX:1/0,minY:1/0},this.boundsCoords={maxX:-1/0,maxY:-1/0,minX:1/0,minY:1/0}};g.key=function(a,b){return a=a._cbr||a._mbr||a,b=b||{},b.x1=Math.floor(a._x/e),b.y1=Math.floor(a._y/e),b.x2=Math.floor((a._w+a._x)/e),b.y2=Math.floor((a._h+a._y)/e),b},g.hash=function(a){return a.x1+" "+a.y1+" "+a.x2+" "+a.y2},g.cellsize=function(){return e},g.prototype={insert:function(a,b){var c,e,f,h=g.key(a,b&&b.keys);for(b=b||new d(h,a,this),c=h.x1;c<=h.x2;c++)for(e=h.y1;e<=h.y2;e++)f=c<<16^e,this.map[f]||(this.map[f]=[]),this.map[f].push(a);return this.boundsDirty=!0,b},_searchHolder:[],search:function(a,b){var c,d,e,h,i=g.key(a,f),j=this._searchHolder;b=b||[],j.length=0;var k;for(c=i.x1;c<=i.x2;c++)for(d=i.y1;d<=i.y2;d++)if(h=this.map[c<<16^d])for(e=0;ea._x&&k._ya._y&&b.push(h[e]));return b},unfilteredSearch:function(a,b){var c,d,e,h,i=g.key(a,f);for(b=b||[],c=i.x1;c<=i.x2;c++)for(d=i.y1;d<=i.y2;d++)if(h=this.map[c<<16^d])for(e=0;e>16,h=f<<16>>16;if(h<0&&(g=~g),g>=a.maxX){a.maxX=g;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.maxX=Math.max(b.maxX,d.x+d.w))}if(g<=a.minX){a.minX=g;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.minX=Math.min(b.minX,d.x))}if(h>=a.maxY){a.maxY=h;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.maxY=Math.max(b.maxY,d.y+d.h))}if(h<=a.minY){a.minY=h;for(c in e)"object"==typeof(d=e[c])&&"requires"in d&&(b.minY=Math.min(b.minY,d.y))}}this.boundsDirty=!1,this.coordBoundsDirty=!1}},traverseRay:function(a,b,c){var d=b.x,h=b.y;a={_x:a._x,_y:a._y,_w:0,_h:0};var i,j=this._keyBoundaries(),k=g.key(a,f),l=k.x1,m=k.y1,n=j.minX,o=j.minY,p=j.maxX,q=j.maxY,r=d>0?1:d<0?-1:0,s=h>0?1:h<0?-1:0,t=d>=0?(l+1)*e:l*e,u=h>=0?(m+1)*e:m*e,v=-1/0,w=0,x=0,y=1/0,z=1/0;for(0!==d&&(i=1/d,y=(t-a._x)*i,w=e*r*i),0!==h&&(i=1/h,z=(u-a._y)*i,x=e*s*i);1===r&&lp&&p!==-1/0||1===s&&mq&&q!==-1/0;)y=0&&n0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("