text: (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  CanvasRenderingContext2D.prototype.storeLoadedImage=function(t,n){this.images||(this.images={}),this.images[t]=n},CanvasRenderingContext2D.prototype.getLoadedImage=function(t){return this.images[t]?this.images[t]:void 0},CanvasRenderingContext2D.prototype.followSprite=function(t){this.centralSprite=t},CanvasRenderingContext2D.prototype.getCentralPosition=function(){return{map:this.centralSprite.mapPosition,canvas:[Math.round(.5*this.canvas.width),Math.round(.5*this.canvas.height),0]}},CanvasRenderingContext2D.prototype.mapPositionToCanvasPosition=function(t){var n=this.getCentralPosition(),e=n.map,o=n.canvas,i=e[0]-t[0],a=e[1]-t[1];return[o[0]-i,o[1]-a]},CanvasRenderingContext2D.prototype.canvasPositionToMapPosition=function(t){var n=this.getCentralPosition(),e=n.map,o=n.canvas,i=o[0]-t[0],a=o[1]-t[1];return[e[0]-i,e[1]-a]},CanvasRenderingContext2D.prototype.getCentreOfViewport=function(){return(this.canvas.width/2).floor()},CanvasRenderingContext2D.prototype.getMiddleOfViewport=function(){return(this.canvas.height/2).floor()},CanvasRenderingContext2D.prototype.getBelowViewport=function(){return this.canvas.height.floor()},CanvasRenderingContext2D.prototype.getMapBelowViewport=function(){var t=this.getBelowViewport();return this.canvasPositionToMapPosition([0,t])[1]},CanvasRenderingContext2D.prototype.getRandomlyInTheCentreOfCanvas=function(t){var n=0,e=this.canvas.width;return t&&(n-=t,e+=t),Number.random(n,e)},CanvasRenderingContext2D.prototype.getRandomlyInTheCentreOfMap=function(t){var n=this.getRandomlyInTheCentreOfCanvas(t);return this.canvasPositionToMapPosition([n,0])[0]},CanvasRenderingContext2D.prototype.getRandomMapPositionBelowViewport=function(){var t=this.getRandomlyInTheCentreOfCanvas(),n=this.getBelowViewport();return this.canvasPositionToMapPosition([t,n])},CanvasRenderingContext2D.prototype.getRandomMapPositionAboveViewport=function(){var t=this.getRandomlyInTheCentreOfCanvas(),n=this.getAboveViewport();return this.canvasPositionToMapPosition([t,n])},CanvasRenderingContext2D.prototype.getTopOfViewport=function(){return this.canvasPositionToMapPosition([0,0])[1]},CanvasRenderingContext2D.prototype.getAboveViewport=function(){return 0-(this.canvas.height/4).floor()};
  },{}],2:[function(require,module,exports){
  Function.prototype.method=function(t,n){return this.prototype[t]=n,this},Object.method("superior",function(t){var n=this,r=n[t];return function(){return r.apply(n,arguments)}});
  },{}],3:[function(require,module,exports){
  var SpriteArray=require("./spriteArray"),EventedLoop=require("eventedloop");!function(t){function i(t,i){var e=new SpriteArray,n=new SpriteArray,o=new SpriteArray,a=t.getContext("2d"),c=a.getCentreOfViewport(),r=0,s=!1,u=this,h=[],d=[],f=new EventedLoop;this.addStaticObject=function(t){e.push(t)},this.addStaticObjects=function(t){t.forEach(this.addStaticObject.bind(this))},this.addMovingObject=function(t,i){i&&e.onPush(function(e){e.data&&e.data.hitBehaviour[i]&&e.onHitting(t,e.data.hitBehaviour[i])},!0),n.push(t)},this.addUIElement=function(t){o.push(t)},this.beforeCycle=function(t){h.push(t)},this.afterCycle=function(t){d.push(t)},this.setMouseX=function(t){c=t},this.setMouseY=function(t){r=t},i.setMapPosition(0,0),i.setMapPositionTarget(0,-10),a.followSprite(i);var p=0;this.cycle=function(){h.each(function(t){t()});var t=a.canvasPositionToMapPosition([c,r]);i.isJumping||i.setMapPositionTarget(t[0],t[1]),p++,i.cycle(),n.each(function(t){t.cycle(a)}),e.cull(),e.each(function(t){t.cycle&&t.cycle()}),o.each(function(t){t.cycle&&t.cycle()}),d.each(function(t){t()})},u.draw=function(){t.width=t.width,i.draw(a),i.cycle(),n.each(function(t){t.draw(a)}),e.each(function(t){t.draw&&t.draw(a,"main")}),o.each(function(t){t.draw&&t.draw(a,"main")})},this.start=function(){f.start()},this.pause=function(){s=!0,f.stop()},this.isPaused=function(){return s},this.reset=function(){s=!1,e=new SpriteArray,n=new SpriteArray,c=a.getCentreOfViewport(),r=0,i.reset(),i.setMapPosition(0,0,0),this.start()}.bind(this),f.on("20",this.cycle),f.on("20",this.draw)}t.game=i}(this),"undefined"!=typeof module&&(module.exports=this.game);
  },{"./spriteArray":12,"eventedloop":16}],4:[function(require,module,exports){
  !function(t){function n(){var t=function(){return Math.floor(65536*Math.random()).toString(16)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}t.guid=n}(this),"undefined"!=typeof module&&(module.exports=this.guid);
  },{}],5:[function(require,module,exports){
  function InfoBox(t){var i=this;return i.lines=t.initialLines,i.top=t.position.top,i.right=t.position.right,i.bottom=t.position.bottom,i.left=t.position.left,i.width=t.width,i.height=t.height,i.setLines=function(t){i.lines=t},i.draw=function(t){t.font="11px monospace";var o=0;i.lines.each(function(n){var e,s,h=+t.font.slice(0,2),f=t.measureText(n).width,l=1.5*h;i.top?s=i.top+o:i.bottom&&(s=t.canvas.height-i.top-l+o),i.right?e=t.canvas.width-i.right-f:i.left&&(e=i.left),o+=l,t.fillText(n,e,s)})},i}"undefined"!=typeof module&&(module.exports=InfoBox);
  },{}],6:[function(require,module,exports){
  function isMobileDevice(){return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?!0:!1}module.exports=isMobileDevice;
  },{}],7:[function(require,module,exports){
  var Sprite=require("./sprite");!function(i){function t(i){function t(i){s+=1,n.isEating=!0,n.isMoving=!1,6>s?setTimeout(function(){t(i)},300):(s=0,n.isEating=!1,n.isMoving=!0,i())}var n=new Sprite(i),e=n.superior("draw"),r=1,s=0,a=6;return n.isEating=!1,n.isFull=!1,n.setSpeed(a),n.draw=function(i){var t=function(){var i=n.movingToward[0]-n.canvasX;return n.isEating?"eating"+s:(r+.1>2?r=.1:r+=.1,i>=0?"sEast"+Math.ceil(r):0>i?"sWest"+Math.ceil(r):void 0)};return e(i,t())},n.startEating=t,n}i.monster=t}(this),"undefined"!=typeof module&&(module.exports=this.monster);
  },{"./sprite":11}],8:[function(require,module,exports){
  !function(){for(var o,e=function(){},n=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],r=n.length,i=window.console=window.console||{};r--;)o=n[r],i[o]||(i[o]=e)}();
  },{}],9:[function(require,module,exports){
  var Sprite=require("./sprite");"undefined"!=typeof navigator?navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate:navigator={vibrate:!1},function(e){function t(e){function t(){f.setSpeed(b),f.isMoving=!0,f.hasBeenHit=!1,f.isJumping=!1,f.isPerformingTrick=!1,d&&clearInterval(d),f.setMapPosition(void 0,void 0,0)}function s(){f.isMoving=!1,f.hasBeenHit=!0,f.isJumping=!1,f.isPerformingTrick=!1,d&&clearInterval(d),f.setMapPosition(void 0,void 0,0)}function i(){var e=f.getSpeed();f.setSpeed(e+2),f.setSpeedY(e+2),f.isMoving=!0,f.hasBeenHit=!1,f.isJumping=!0,f.setMapPosition(void 0,void 0,1)}function n(){if(f.direction)return f.direction<=90?"east":f.direction>90&&f.direction<150?"esEast":f.direction>=150&&f.direction<180?"sEast":180===f.direction?"south":f.direction>180&&f.direction<=210?"sWest":f.direction>210&&f.direction<270?"wsWest":f.direction>=270?"west":"south";var e=f.movingToward[0]-f.mapPosition[0],t=f.movingToward[1]-f.mapPosition[1];return 0>=t?e>0?"east":"west":m.esEast(e)?"esEast":m.sEast(e)?"sEast":m.wsWest(e)?"wsWest":m.sWest(e)?"sWest":"south"}function o(e){g[e]&&f.setDirection(g[e]),f.isMoving="west"===e||"east"===e?!1:!0}function a(){return"blank"}function r(){return"jumping"}function u(){return console.log("Trick step is",T),0===T?"jumping":1===T?"somersault1":"somersault2"}function c(e,t,s){return 0===s||1===s?t:(t>e&&(e+=f.getSpeed()*(s/l)),e>t&&(e-=f.getSpeed()*(s/l)),e)}var p,d,g={west:270,wsWest:240,sWest:195,south:180,sEast:165,esEast:120,east:90},f=new Sprite(e),v={draw:f.superior("draw"),cycle:f.superior("cycle"),getSpeedX:f.superior("getSpeedX"),getSpeedY:f.superior("getSpeedY"),hits:f.superior("hits")},m={esEast:function(e){return e>300},sEast:function(e){return e>75},wsWest:function(e){return-300>e},sWest:function(e){return-75>e}},h=!0,w=[],E=0,b=5,l=70,S=0,k=0,W=0,P=1,T=0;return f.isMoving=!0,f.hasBeenHit=!1,f.isJumping=!1,f.isPerformingTrick=!1,f.setSpeed(b),f.reset=function(){w=[],E=0,f.isMoving=!0,f.hasBeenHit=!1,h=!0,t()},f.stop=function(){o(f.direction>180?"west":"east")},f.turnEast=function(){var e=n();switch(e){case"west":o("wsWest");break;case"wsWest":o("sWest");break;case"sWest":o("south");break;case"south":o("sEast");break;case"sEast":o("esEast");break;case"esEast":o("east");break;default:o("south")}},f.turnWest=function(){var e=n();switch(e){case"east":o("esEast");break;case"esEast":o("sEast");break;case"sEast":o("south");break;case"south":o("sWest");break;case"sWest":o("wsWest");break;case"wsWest":o("west");break;default:o("south")}},f.stepWest=function(){f.mapPosition[0]-=2*f.speed},f.stepEast=function(){f.mapPosition[0]+=2*f.speed},f.setMapPositionTarget=function(e,t){f.hasBeenHit||(Math.abs(f.mapPosition[0]-e)<=75&&(e=f.mapPosition[0]),f.movingToward=[e,t])},f.startMovingIfPossible=function(){f.hasBeenHit||f.isBeingEaten||(f.isMoving=!0)},f.setTurnEaseCycles=function(e){l=e},f.getPixelsTravelledDownMountain=function(){return E},f.resetSpeed=function(){f.setSpeed(b)},f.cycle=function(){f.isMoving&&(E+=f.speed),f.isJumping&&f.setMapPositionTarget(void 0,f.mapPosition[1]+f.getSpeed()),v.cycle(),f.checkHittableObjects()},f.draw=function(e){var t=function(){return f.isBeingEaten?a():f.isJumping?f.isPerformingTrick?u():r():f.hasBeenHit?"hit":n()};return v.draw(e,t())},f.hits=function(e){return-1!==w.indexOf(e.id)?!1:e.occupiesZIndex(f.mapPosition[2])?v.hits(e)?!0:!1:!1},f.speedBoost=function(){var e=f.speed;h&&(h=!1,f.setSpeed(2*f.speed),setTimeout(function(){f.setSpeed(e),setTimeout(function(){h=!0},1e4)},2e3))},f.attemptTrick=function(){f.isJumping&&(f.isPerformingTrick=!0,d=setInterval(function(){T>=2?T=0:T+=1},300))},f.getSpeedX=function(){return"esEast"===n()||"wsWest"===n()?(k=.5,S=c(S,f.getSpeed()*k,k)):"sEast"===n()||"sWest"===n()?(k=.33,S=c(S,f.getSpeed()*k,k)):S=c(S,0,k)},f.setSpeedY=function(e){W=e},f.getSpeedY=function(){return f.isJumping?W:"esEast"===n()||"wsWest"===n()?(P=.6,W=c(W,.6*f.getSpeed(),.6)):"sEast"===n()||"sWest"===n()?(P=.85,W=c(W,.85*f.getSpeed(),.85)):"east"===n()||"west"===n()?(P=1,W=0):W=c(W,f.getSpeed(),P)},f.hasHitObstacle=function(e){s(),navigator.vibrate&&navigator.vibrate(500),w.push(e.id),f.resetSpeed(),p&&clearTimeout(p),p=setTimeout(function(){t()},1500)},f.hasHitJump=function(){i(),p&&clearTimeout(p),p=setTimeout(function(){t()},1e3)},f.isEatenBy=function(e,t){f.hasHitObstacle(e),e.startEating(t),w.push(e.id),f.isMoving=!1,f.isBeingEaten=!0},f.reset=function(){w=[],E=0,f.isMoving=!0,f.isJumping=!1,f.hasBeenHit=!1,h=!0},f}e.skier=t}(this),"undefined"!=typeof module&&(module.exports=this.skier);
  },{"./sprite":11}],10:[function(require,module,exports){
  var Sprite=require("./sprite");!function(e){function r(e){function r(){{var e=t.movingToward[0]-t.mapPosition[0];t.movingToward[1]-t.mapPosition[1]}return o.sEast(e)?"sEast":"sWest"}var t=new Sprite(e),n={draw:t.superior("draw"),cycle:t.superior("cycle")},o={sEast:function(e){return e>0},sWest:function(e){return 0>=e}},i=3;return t.setSpeed(i),t.cycle=function(e){1===Number.random(10)&&(t.setMapPositionTarget(e.getRandomlyInTheCentreOfMap()),t.setSpeed(i+Number.random(-1,1))),t.setMapPositionTarget(void 0,e.getMapBelowViewport()+600),n.cycle()},t.draw=function(e){var t=function(){return r()};return n.draw(e,t())},t}e.snowboarder=r}(this),"undefined"!=typeof module&&(module.exports=this.snowboarder);
  },{"./sprite":11}],11:[function(require,module,exports){
  !function(t){function i(t){function i(t){g.canvasX+=t.toNumber()}function o(t){g.canvasY+=t.toNumber()}function n(i){return g.data.hitBoxes&&t.hitBoxes[i]?t.hitBoxes[i]:void 0}function a(t){return t=Math.round(2*t)/2}function s(){if(g.isMoving){var t=g.mapPosition[0],i=g.mapPosition[1];if("undefined"!=typeof g.direction){var e=g.direction-90;0>e&&(e=360+e),t+=a(g.speed*Math.cos(e*(Math.PI/180))),i+=a(g.speed*Math.sin(e*(Math.PI/180)))}else"undefined"!=typeof g.movingToward[0]&&(t>g.movingToward[0]?t-=Math.min(g.getSpeedX(),Math.abs(t-g.movingToward[0])):t<g.movingToward[0]&&(t+=Math.min(g.getSpeedX(),Math.abs(t-g.movingToward[0])))),"undefined"!=typeof g.movingToward[1]&&(i>g.movingToward[1]?i-=Math.min(g.getSpeedY(),Math.abs(i-g.movingToward[1])):i<g.movingToward[1]&&(i+=Math.min(g.getSpeedY(),Math.abs(i-g.movingToward[1]))));g.setMapPosition(t,i)}}var r,d={},c=[0],g=this;return g.direction=void 0,g.mapPosition=[0,0,0],g.id=e(),g.canvasX=0,g.canvasY=0,g.canvasZ=0,g.height=0,g.speed=0,g.data=t||{parts:{}},g.movingToward=[0,0],g.metresDownTheMountain=0,g.movingWithConviction=!1,g.deleted=!1,g.maxHeight=function(){return Object.values(g.data.parts).map(function(t){return t[3]}).max()}(),g.isMoving=!0,g.data.parts||(g.data.parts={}),t&&t.id&&(g.id=t.id),t&&t.zIndexesOccupied&&(c=t.zIndexesOccupied),this.draw=function(t,i){var e=g.data.parts[i];g.height=e[3],g.width=e[2];var o=t.mapPositionToCanvasPosition(g.mapPosition);g.setCanvasPosition(o[0],o[1]),t.drawImage(t.getLoadedImage(g.data.$imageFile),e[0],e[1],e[2],e[3],g.canvasX,g.canvasY,e[2],e[3])},this.setMapPosition=function(t,i,e){"undefined"==typeof t&&(t=g.mapPosition[0]),"undefined"==typeof i&&(i=g.mapPosition[1]),"undefined"==typeof e?e=g.mapPosition[2]:g.zIndexesOccupied=[e],g.mapPosition=[t,i,e]},this.setCanvasPosition=function(t,e){t&&(!Object.isString(t)||"+"!==t.first()&&"-"!==t.first()?g.canvasX=t:i(t)),e&&(!Object.isString(e)||"+"!==e.first()&&"-"!==e.first()?g.canvasY=e:o(e))},this.getCanvasPositionX=function(){return g.canvasX},this.getCanvasPositionY=function(){return g.canvasY},this.getLeftHitBoxEdge=function(t){t=t||0;var i=this.getCanvasPositionX();return n(t)&&(i+=n(t)[0]),i},this.getTopHitBoxEdge=function(t){t=t||0;var i=this.getCanvasPositionY();return n(t)&&(i+=n(t)[1]),i},this.getRightHitBoxEdge=function(t){return t=t||0,n(t)?g.canvasX+n(t)[2]:g.canvasX+g.width},this.getBottomHitBoxEdge=function(t){return t=t||0,n(t)?g.canvasY+n(t)[3]:g.canvasY+g.height},this.getPositionInFrontOf=function(){return[g.canvasX,g.canvasY+g.height]},this.setSpeed=function(t){g.speed=t,g.speedX=t,g.speedY=t},this.incrementSpeedBy=function(t){g.speed+=t},g.getSpeed=function(){return g.speed},g.getSpeedX=function(){return g.speed},g.getSpeedY=function(){return g.speed},this.setHeight=function(t){g.height=t},this.setWidth=function(t){g.width=t},this.getMaxHeight=function(){return g.maxHeight},g.getMovingTowardOpposite=function(){if(!g.isMoving)return[0,0];var t=g.movingToward[0]-g.mapPosition[0],i=g.movingToward[1]-g.mapPosition[1],e=Math.abs(t)>75?0-t:0,o=-i;return[e,o]},this.checkHittableObjects=function(){Object.keys(d,function(t,i){i.object.deleted?delete d[t]:i.object.hits(g)&&i.callbacks.each(function(t){t(g,i.object)})})},this.cycle=function(){g.checkHittableObjects(),r&&g.setMapPositionTarget(r.mapPosition[0],r.mapPosition[1],!0),s()},this.setMapPositionTarget=function(t,i,e){e&&(g.movingWithConviction=!1),g.movingWithConviction||("undefined"==typeof t&&(t=g.movingToward[0]),"undefined"==typeof i&&(i=g.movingToward[1]),g.movingToward=[t,i],g.movingWithConviction=!1)},this.setDirection=function(t){t>=360&&(t=360-t),g.direction=t,g.movingToward=void 0},this.resetDirection=function(){g.direction=void 0},this.setMapPositionTargetWithConviction=function(t,i){g.setMapPositionTarget(t,i),g.movingWithConviction=!0},this.follow=function(t){r=t},this.stopFollowing=function(){r=!1},this.onHitting=function(t,i){return d[t.id]?d[t.id].callbacks.push(i):void(d[t.id]={object:t,callbacks:[i]})},this.deleteOnNextCycle=function(){g.deleted=!0},this.occupiesZIndex=function(t){return c.indexOf(t)>=0},this.hits=function(t){var i=!1,e=!1;return t.getTopHitBoxEdge(g.mapPosition[2])<=g.getBottomHitBoxEdge(g.mapPosition[2])&&t.getBottomHitBoxEdge(g.mapPosition[2])>=g.getBottomHitBoxEdge(g.mapPosition[2])&&(i=!0),t.getTopHitBoxEdge(g.mapPosition[2])<=g.getTopHitBoxEdge(g.mapPosition[2])&&t.getBottomHitBoxEdge(g.mapPosition[2])>=g.getTopHitBoxEdge(g.mapPosition[2])&&(i=!0),t.getLeftHitBoxEdge(g.mapPosition[2])<=g.getRightHitBoxEdge(g.mapPosition[2])&&t.getRightHitBoxEdge(g.mapPosition[2])>=g.getRightHitBoxEdge(g.mapPosition[2])&&(e=!0),t.getLeftHitBoxEdge(g.mapPosition[2])<=g.getLeftHitBoxEdge(g.mapPosition[2])&&t.getRightHitBoxEdge(g.mapPosition[2])>=g.getLeftHitBoxEdge(g.mapPosition[2])&&(e=!0),i&&e},this.isAboveOnCanvas=function(t){return g.canvasY+g.height<t},this.isBelowOnCanvas=function(t){return g.canvasY>t},g}var e=require("./guid");i.createObjects=function(t,e){function o(t){var o=e.position;if(Number.random(100+e.rateModifier)<=t.dropRate){var n=new i(t.sprite);return n.setSpeed(0),Object.isFunction(o)&&(o=o()),n.setMapPosition(o[0],o[1]),t.sprite.hitBehaviour&&t.sprite.hitBehaviour.skier&&e.player&&n.onHitting(e.player,t.sprite.hitBehaviour.skier),n}}Array.isArray(t)||(t=[t]),e=Object.merge(e,{rateModifier:0,dropRate:1,position:[0,0]},!1,!1);var n=t.map(o).remove(void 0);return n},t.sprite=i}(this),"undefined"!=typeof module&&(module.exports=this.sprite);
  },{"./guid":4}],12:[function(require,module,exports){
  !function(t){function e(){return this.pushHandlers=[],this}e.prototype=Object.create(Array.prototype),e.prototype.onPush=function(t,e){this.pushHandlers.push(t),e&&this.each(t)},e.prototype.push=function(t){Array.prototype.push.call(this,t),this.pushHandlers.each(function(e){e(t)})},e.prototype.cull=function(){this.each(function(t,e){return t.deleted?delete this[e]:void 0})},t.spriteArray=e}(this),"undefined"!=typeof module&&(module.exports=this.spriteArray);
  },{}],13:[function(require,module,exports){
  function loadImages(e,t){function i(){o+=1,o===e.length&&t(s)}var o=0,s={};e.each(function(e){var t=new Image;t.onload=i,t.src=e,dContext.storeLoadedImage(e,t)})}function monsterHitsSkierBehaviour(e,t){t.isEatenBy(e,function(){livesLeft-=1,e.isFull=!0,e.isEating=!1,t.isBeingEaten=!1,e.setSpeed(t.getSpeed()),e.stopFollowing();var i=dContext.getRandomMapPositionAboveViewport();e.setMapPositionTarget(i[0],i[1])})}function startNeverEndingGame(){function e(){monstersComeOut=!1,distanceTravelledInMetres=0,livesLeft=5,highScore=localStorage.getItem("highScore"),d.reset(),d.addStaticObject(r)}function t(){d.isPaused()||(highScore=localStorage.setItem("highScore",distanceTravelledInMetres),a.setLines(["Game over!","Hit space to restart"]),d.pause(),d.cycle())}function i(e,t){var i=Math.max(800-mainCanvas.width,0);Number.random(1e3+i)<=t&&e()}function o(){var e=new Monster(sprites.monster),t=dContext.getRandomMapPositionAboveViewport();e.setMapPosition(t[0],t[1]),e.follow(n),e.onHitting(n,monsterHitsSkierBehaviour),d.addMovingObject(e,"monster")}function s(){var e=new Snowboarder(sprites.snowboarder),t=dContext.getRandomMapPositionAboveViewport(),i=dContext.getRandomMapPositionBelowViewport();e.setMapPosition(t[0],t[1]),e.setMapPositionTarget(i[0],i[1]),e.onHitting(n,sprites.snowboarder.hitBehaviour.skier),d.addMovingObject(e)}var n,r,a,d;n=new Skier(sprites.skier),n.setMapPosition(0,0),n.setMapPositionTarget(0,-10),d=new Game(mainCanvas,n),r=new Sprite(sprites.signStart),d.addStaticObject(r),r.setMapPosition(-50,0),dContext.followSprite(n),a=new InfoBox({initialLines:["SkiFree.js",infoBoxControls,"Travelled 0m","High Score: "+highScore,"Skiers left: "+livesLeft,"Created by Dan Hough (@basicallydan)"],position:{top:15,right:10}}),d.beforeCycle(function(){var e=[];n.isMoving&&(e=Sprite.createObjects([{sprite:sprites.smallTree,dropRate:4},{sprite:sprites.tallTree,dropRate:2},{sprite:sprites.jump,dropRate:1},{sprite:sprites.thickSnow,dropRate:1},{sprite:sprites.rock,dropRate:1}],{rateModifier:Math.max(800-mainCanvas.width,0),position:function(){return dContext.getRandomMapPositionBelowViewport()},player:n})),d.addStaticObjects(e),i(s,.01),distanceTravelledInMetres=parseFloat(n.getPixelsTravelledDownMountain()/pixelsPerMetre).toFixed(1),d.isPaused()||a.setLines(["SkiFree.js",infoBoxControls,"Travelled "+distanceTravelledInMetres+"m","Skiers left: "+livesLeft,"High Score: "+highScore,"Created by Dan Hough (@basicallydan)","Current Speed: "+n.getSpeed()])}),d.afterCycle(function(){0===livesLeft&&t()}),d.addUIElement(a),$(mainCanvas).mousemove(function(e){d.setMouseX(e.pageX),d.setMouseY(e.pageY),n.resetDirection(),n.startMovingIfPossible()}).bind("click",function(e){d.setMouseX(e.pageX),d.setMouseY(e.pageY),n.resetDirection(),n.startMovingIfPossible()}).focus(),Mousetrap.bind("f",n.speedBoost),Mousetrap.bind("t",n.attemptTrick),Mousetrap.bind(["w","up"],function(){n.stop()}),Mousetrap.bind(["a","left"],function(){270===n.direction?n.stepWest():n.turnWest()}),Mousetrap.bind(["s","down"],function(){n.setDirection(180),n.startMovingIfPossible()}),Mousetrap.bind(["d","right"],function(){90===n.direction?n.stepEast():n.turnEast()}),Mousetrap.bind("m",o),Mousetrap.bind("b",s),Mousetrap.bind("space",e);Hammer(mainCanvas).on("hold",function(e){d.setMouseX(e.position[0].x),d.setMouseY(e.position[0].y)}).on("tap",function(e){d.setMouseX(e.position[0].x),d.setMouseY(e.position[0].y)}).on("drag",function(e){d.setMouseX(e.position.x),d.setMouseY(e.position.y)}).on("doubletap",function(){n.speedBoost()});n.isMoving=!1,n.setDirection(270),d.start()}function resizeCanvas(){mainCanvas.width=window.innerWidth,mainCanvas.height=window.innerHeight}require("./lib/canvasRenderingContext2DExtensions"),require("./lib/extenders"),require("./lib/plugins");var Hammer=require("hammerjs"),Mousetrap=require("br-mousetrap"),isMobileDevice=require("./lib/isMobileDevice"),SpriteArray=require("./lib/spriteArray"),Monster=require("./lib/monster"),Sprite=require("./lib/sprite"),Snowboarder=require("./lib/snowboarder"),Skier=require("./lib/skier"),InfoBox=require("./lib/infoBox"),Game=require("./lib/game"),mainCanvas=document.getElementById("skifree-canvas"),dContext=mainCanvas.getContext("2d"),imageSources=["sprite-characters.png","skifree-objects.png"],global=this,infoBoxControls="Use the mouse or WASD to control the player";isMobileDevice()&&(infoBoxControls="Tap or drag on the piste to control the player");var sprites=require("./spriteInfo"),pixelsPerMetre=18,monstersComeOut=!1,distanceTravelledInMetres=0,livesLeft=5,highScore=0;localStorage.getItem("highScore")&&(highScore=localStorage.getItem("highScore")),window.addEventListener("resize",resizeCanvas,!1),resizeCanvas(),loadImages(imageSources,startNeverEndingGame),this.exports=window;
  },{"./lib/canvasRenderingContext2DExtensions":1,"./lib/extenders":2,"./lib/game":3,"./lib/infoBox":5,"./lib/isMobileDevice":6,"./lib/monster":7,"./lib/plugins":8,"./lib/skier":9,"./lib/snowboarder":10,"./lib/sprite":11,"./lib/spriteArray":12,"./spriteInfo":14,"br-mousetrap":15,"hammerjs":18}],14:[function(require,module,exports){
  !function(e){function i(e){e.deleteOnNextCycle()}function t(e,i){i.deleteOnNextCycle()}function s(e,i){i.hasHitObstacle(e)}function a(e,i){i.hasHitObstacle(e)}function r(e,i){i.hasHitJump(e)}function o(e,i){i.hasHitObstacle(e)}var n={skier:{$imageFile:"sprite-characters.png",parts:{blank:[0,0,0,0],east:[0,0,24,34],esEast:[24,0,24,34],sEast:[49,0,17,34],south:[65,0,17,34],sWest:[49,37,17,34],wsWest:[24,37,24,34],west:[0,37,24,34],hit:[0,78,31,31],jumping:[84,0,32,34],somersault1:[116,0,32,34],somersault2:[148,0,32,34]},hitBoxes:{0:[7,20,27,34]},id:"player",hitBehaviour:{}},smallTree:{$imageFile:"skifree-objects.png",parts:{main:[0,28,30,34]},hitBoxes:{0:[0,18,30,34]},hitBehaviour:{}},tallTree:{$imageFile:"skifree-objects.png",parts:{main:[95,66,32,64]},zIndexesOccupied:[0,1],hitBoxes:{0:[0,54,32,64],1:[0,10,32,54]},hitBehaviour:{}},thickSnow:{$imageFile:"skifree-objects.png",parts:{main:[143,53,43,10]},hitBehaviour:{}},rock:{$imageFile:"skifree-objects.png",parts:{main:[30,52,23,11]},hitBehaviour:{}},monster:{$imageFile:"sprite-characters.png",parts:{sEast1:[64,112,26,43],sEast2:[90,112,32,43],sWest1:[64,158,26,43],sWest2:[90,158,32,43],eating1:[122,112,34,43],eating2:[156,112,31,43],eating3:[187,112,31,43],eating4:[219,112,25,43],eating5:[243,112,26,43]},hitBehaviour:{}},jump:{$imageFile:"skifree-objects.png",parts:{main:[109,55,32,8]},hitBehaviour:{}},signStart:{$imageFile:"skifree-objects.png",parts:{main:[260,103,42,27]},hitBehaviour:{}},snowboarder:{$imageFile:"sprite-characters.png",parts:{sEast:[73,229,20,29],sWest:[95,228,26,30]},hitBehaviour:{}}};n.monster.hitBehaviour.tree=i,n.smallTree.hitBehaviour.monster=t,n.tallTree.hitBehaviour.monster=t,n.smallTree.hitBehaviour.skier=s,n.tallTree.hitBehaviour.skier=s,n.rock.hitBehaviour.skier=a,n.jump.hitBehaviour.skier=r,n.snowboarder.hitBehaviour.skier=o,e.spriteInfo=n}(this),"undefined"!=typeof module&&(module.exports=this.spriteInfo);
  },{}],15:[function(require,module,exports){
  /**
   * Copyright 2012 Craig Campbell
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   *
   * Mousetrap is a simple keyboard shortcut library for Javascript with
   * no external dependencies
   *
   * @version 1.1.3
   * @url craig.is/killing/mice
   */
  (function() {
  
      /**
       * mapping of special keycodes to their corresponding keys
       *
       * everything in this dictionary cannot use keypress events
       * so it has to be here to map to the correct keycodes for
       * keyup/keydown events
       *
       * @type {Object}
       */
      var _MAP = {
              8: 'backspace',
              9: 'tab',
              13: 'enter',
              16: 'shift',
              17: 'ctrl',
              18: 'alt',
              20: 'capslock',
              27: 'esc',
              32: 'space',
              33: 'pageup',
              34: 'pagedown',
              35: 'end',
              36: 'home',
              37: 'left',
              38: 'up',
              39: 'right',
              40: 'down',
              45: 'ins',
              46: 'del',
              91: 'meta',
              93: 'meta',
              224: 'meta'
          },
  
          /**
           * mapping for special characters so they can support
           *
           * this dictionary is only used incase you want to bind a
           * keyup or keydown event to one of these keys
           *
           * @type {Object}
           */
          _KEYCODE_MAP = {
              106: '*',
              107: '+',
              109: '-',
              110: '.',
              111 : '/',
              186: ';',
              187: '=',
              188: ',',
              189: '-',
              190: '.',
              191: '/',
              192: '`',
              219: '[',
              220: '\\',
              221: ']',
              222: '\''
          },
  
          /**
           * this is a mapping of keys that require shift on a US keypad
           * back to the non shift equivelents
           *
           * this is so you can use keyup events with these keys
           *
           * note that this will only work reliably on US keyboards
           *
           * @type {Object}
           */
          _SHIFT_MAP = {
              '~': '`',
              '!': '1',
              '@': '2',
              '#': '3',
              '$': '4',
              '%': '5',
              '^': '6',
              '&': '7',
              '*': '8',
              '(': '9',
              ')': '0',
              '_': '-',
              '+': '=',
              ':': ';',
              '\"': '\'',
              '<': ',',
              '>': '.',
              '?': '/',
              '|': '\\'
          },
  
          /**
           * this is a list of special strings you can use to map
           * to modifier keys when you specify your keyboard shortcuts
           *
           * @type {Object}
           */
          _SPECIAL_ALIASES = {
              'option': 'alt',
              'command': 'meta',
              'return': 'enter',
              'escape': 'esc'
          },
  
          /**
           * variable to store the flipped version of _MAP from above
           * needed to check if we should use keypress or not when no action
           * is specified
           *
           * @type {Object|undefined}
           */
          _REVERSE_MAP,
  
          /**
           * a list of all the callbacks setup via Mousetrap.bind()
           *
           * @type {Object}
           */
          _callbacks = {},
  
          /**
           * direct map of string combinations to callbacks used for trigger()
           *
           * @type {Object}
           */
          _direct_map = {},
  
          /**
           * keeps track of what level each sequence is at since multiple
           * sequences can start out with the same sequence
           *
           * @type {Object}
           */
          _sequence_levels = {},
  
          /**
           * variable to store the setTimeout call
           *
           * @type {null|number}
           */
          _reset_timer,
  
          /**
           * temporary state where we will ignore the next keyup
           *
           * @type {boolean|string}
           */
          _ignore_next_keyup = false,
  
          /**
           * are we currently inside of a sequence?
           * type of action ("keyup" or "keydown" or "keypress") or false
           *
           * @type {boolean|string}
           */
          _inside_sequence = false;
  
      /**
       * loop through the f keys, f1 to f19 and add them to the map
       * programatically
       */
      for (var i = 1; i < 20; ++i) {
          _MAP[111 + i] = 'f' + i;
      }
  
      /**
       * loop through to map numbers on the numeric keypad
       */
      for (i = 0; i <= 9; ++i) {
          _MAP[i + 96] = i;
      }
  
      /**
       * cross browser add event method
       *
       * @param {Element|HTMLDocument} object
       * @param {string} type
       * @param {Function} callback
       * @returns void
       */
      function _addEvent(object, type, callback) {
          if (object.addEventListener) {
              object.addEventListener(type, callback, false);
              return;
          }
  
          object.attachEvent('on' + type, callback);
      }
  
      /**
       * takes the event and returns the key character
       *
       * @param {Event} e
       * @return {string}
       */
      function _characterFromEvent(e) {
  
          // for keypress events we should return the character as is
          if (e.type == 'keypress') {
              return String.fromCharCode(e.which);
          }
  
          // for non keypress events the special maps are needed
          if (_MAP[e.which]) {
              return _MAP[e.which];
          }
  
          if (_KEYCODE_MAP[e.which]) {
              return _KEYCODE_MAP[e.which];
          }
  
          // if it is not in the special map
          return String.fromCharCode(e.which).toLowerCase();
      }
  
      /**
       * checks if two arrays are equal
       *
       * @param {Array} modifiers1
       * @param {Array} modifiers2
       * @returns {boolean}
       */
      function _modifiersMatch(modifiers1, modifiers2) {
          return modifiers1.sort().join(',') === modifiers2.sort().join(',');
      }
  
      /**
       * resets all sequence counters except for the ones passed in
       *
       * @param {Object} do_not_reset
       * @returns void
       */
      function _resetSequences(do_not_reset) {
          do_not_reset = do_not_reset || {};
  
          var active_sequences = false,
              key;
  
          for (key in _sequence_levels) {
              if (do_not_reset[key]) {
                  active_sequences = true;
                  continue;
              }
              _sequence_levels[key] = 0;
          }
  
          if (!active_sequences) {
              _inside_sequence = false;
          }
      }
  
      /**
       * finds all callbacks that match based on the keycode, modifiers,
       * and action
       *
       * @param {string} character
       * @param {Array} modifiers
       * @param {Event|Object} e
       * @param {boolean=} remove - should we remove any matches
       * @param {string=} combination
       * @returns {Array}
       */
      function _getMatches(character, modifiers, e, remove, combination) {
          var i,
              callback,
              matches = [],
              action = e.type;
  
          // if there are no events related to this keycode
          if (!_callbacks[character]) {
              return [];
          }
  
          // if a modifier key is coming up on its own we should allow it
          if (action == 'keyup' && _isModifier(character)) {
              modifiers = [character];
          }
  
          // loop through all callbacks for the key that was pressed
          // and see if any of them match
          for (i = 0; i < _callbacks[character].length; ++i) {
              callback = _callbacks[character][i];
  
              // if this is a sequence but it is not at the right level
              // then move onto the next match
              if (callback.seq && _sequence_levels[callback.seq] != callback.level) {
                  continue;
              }
  
              // if the action we are looking for doesn't match the action we got
              // then we should keep going
              if (action != callback.action) {
                  continue;
              }
  
              // if this is a keypress event and the meta key and control key
              // are not pressed that means that we need to only look at the
              // character, otherwise check the modifiers as well
              //
              // chrome will not fire a keypress if meta or control is down
              // safari will fire a keypress if meta or meta+shift is down
              // firefox will fire a keypress if meta or control is down
              if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
  
                  // remove is used so if you change your mind and call bind a
                  // second time with a new function the first one is overwritten
                  if (remove && callback.combo == combination) {
                      _callbacks[character].splice(i, 1);
                  }
  
                  matches.push(callback);
              }
          }
  
          return matches;
      }
  
      /**
       * takes a key event and figures out what the modifiers are
       *
       * @param {Event} e
       * @returns {Array}
       */
      function _eventModifiers(e) {
          var modifiers = [];
  
          if (e.shiftKey) {
              modifiers.push('shift');
          }
  
          if (e.altKey) {
              modifiers.push('alt');
          }
  
          if (e.ctrlKey) {
              modifiers.push('ctrl');
          }
  
          if (e.metaKey) {
              modifiers.push('meta');
          }
  
          return modifiers;
      }
  
      /**
       * actually calls the callback function
       *
       * if your callback function returns false this will use the jquery
       * convention - prevent default and stop propogation on the event
       *
       * @param {Function} callback
       * @param {Event} e
       * @returns void
       */
      function _fireCallback(callback, e) {
          if (callback(e) === false) {
              if (e.preventDefault) {
                  e.preventDefault();
              }
  
              if (e.stopPropagation) {
                  e.stopPropagation();
              }
  
              e.returnValue = false;
              e.cancelBubble = true;
          }
      }
  
      /**
       * handles a character key event
       *
       * @param {string} character
       * @param {Event} e
       * @returns void
       */
      function _handleCharacter(character, e) {
  
          // if this event should not happen stop here
          if (Mousetrap.stopCallback(e, e.target || e.srcElement)) {
              return;
          }
  
          var callbacks = _getMatches(character, _eventModifiers(e), e),
              i,
              do_not_reset = {},
              processed_sequence_callback = false;
  
          // loop through matching callbacks for this key event
          for (i = 0; i < callbacks.length; ++i) {
  
              // fire for all sequence callbacks
              // this is because if for example you have multiple sequences
              // bound such as "g i" and "g t" they both need to fire the
              // callback for matching g cause otherwise you can only ever
              // match the first one
              if (callbacks[i].seq) {
                  processed_sequence_callback = true;
  
                  // keep a list of which sequences were matches for later
                  do_not_reset[callbacks[i].seq] = 1;
                  _fireCallback(callbacks[i].callback, e);
                  continue;
              }
  
              // if there were no sequence matches but we are still here
              // that means this is a regular match so we should fire that
              if (!processed_sequence_callback && !_inside_sequence) {
                  _fireCallback(callbacks[i].callback, e);
              }
          }
  
          // if you are inside of a sequence and the key you are pressing
          // is not a modifier key then we should reset all sequences
          // that were not matched by this key event
          if (e.type == _inside_sequence && !_isModifier(character)) {
              _resetSequences(do_not_reset);
          }
      }
  
      /**
       * handles a keydown event
       *
       * @param {Event} e
       * @returns void
       */
      function _handleKey(e) {
  
          // normalize e.which for key events
          // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
          e.which = typeof e.which == "number" ? e.which : e.keyCode;
  
          var character = _characterFromEvent(e);
  
          // no character found then stop
          if (!character) {
              return;
          }
  
          if (e.type == 'keyup' && _ignore_next_keyup == character) {
              _ignore_next_keyup = false;
              return;
          }
  
          _handleCharacter(character, e);
      }
  
      /**
       * determines if the keycode specified is a modifier key or not
       *
       * @param {string} key
       * @returns {boolean}
       */
      function _isModifier(key) {
          return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
      }
  
      /**
       * called to set a 1 second timeout on the specified sequence
       *
       * this is so after each key press in the sequence you have 1 second
       * to press the next key before you have to start over
       *
       * @returns void
       */
      function _resetSequenceTimer() {
          clearTimeout(_reset_timer);
          _reset_timer = setTimeout(_resetSequences, 1000);
      }
  
      /**
       * reverses the map lookup so that we can look for specific keys
       * to see what can and can't use keypress
       *
       * @return {Object}
       */
      function _getReverseMap() {
          if (!_REVERSE_MAP) {
              _REVERSE_MAP = {};
              for (var key in _MAP) {
  
                  // pull out the numeric keypad from here cause keypress should
                  // be able to detect the keys from the character
                  if (key > 95 && key < 112) {
                      continue;
                  }
  
                  if (_MAP.hasOwnProperty(key)) {
                      _REVERSE_MAP[_MAP[key]] = key;
                  }
              }
          }
          return _REVERSE_MAP;
      }
  
      /**
       * picks the best action based on the key combination
       *
       * @param {string} key - character for key
       * @param {Array} modifiers
       * @param {string=} action passed in
       */
      function _pickBestAction(key, modifiers, action) {
  
          // if no action was picked in we should try to pick the one
          // that we think would work best for this key
          if (!action) {
              action = _getReverseMap()[key] ? 'keydown' : 'keypress';
          }
  
          // modifier keys don't work as expected with keypress,
          // switch to keydown
          if (action == 'keypress' && modifiers.length) {
              action = 'keydown';
          }
  
          return action;
      }
  
      /**
       * binds a key sequence to an event
       *
       * @param {string} combo - combo specified in bind call
       * @param {Array} keys
       * @param {Function} callback
       * @param {string=} action
       * @returns void
       */
      function _bindSequence(combo, keys, callback, action) {
  
          // start off by adding a sequence level record for this combination
          // and setting the level to 0
          _sequence_levels[combo] = 0;
  
          // if there is no action pick the best one for the first key
          // in the sequence
          if (!action) {
              action = _pickBestAction(keys[0], []);
          }
  
          /**
           * callback to increase the sequence level for this sequence and reset
           * all other sequences that were active
           *
           * @param {Event} e
           * @returns void
           */
          var _increaseSequence = function(e) {
                  _inside_sequence = action;
                  ++_sequence_levels[combo];
                  _resetSequenceTimer();
              },
  
              /**
               * wraps the specified callback inside of another function in order
               * to reset all sequence counters as soon as this sequence is done
               *
               * @param {Event} e
               * @returns void
               */
              _callbackAndReset = function(e) {
                  _fireCallback(callback, e);
  
                  // we should ignore the next key up if the action is key down
                  // or keypress.  this is so if you finish a sequence and
                  // release the key the final key will not trigger a keyup
                  if (action !== 'keyup') {
                      _ignore_next_keyup = _characterFromEvent(e);
                  }
  
                  // weird race condition if a sequence ends with the key
                  // another sequence begins with
                  setTimeout(_resetSequences, 10);
              },
              i;
  
          // loop through keys one at a time and bind the appropriate callback
          // function.  for any key leading up to the final one it should
          // increase the sequence. after the final, it should reset all sequences
          for (i = 0; i < keys.length; ++i) {
              _bindSingle(keys[i], i < keys.length - 1 ? _increaseSequence : _callbackAndReset, action, combo, i);
          }
      }
  
      /**
       * binds a single keyboard combination
       *
       * @param {string} combination
       * @param {Function} callback
       * @param {string=} action
       * @param {string=} sequence_name - name of sequence if part of sequence
       * @param {number=} level - what part of the sequence the command is
       * @returns void
       */
      function _bindSingle(combination, callback, action, sequence_name, level) {
  
          // make sure multiple spaces in a row become a single space
          combination = combination.replace(/\s+/g, ' ');
  
          var sequence = combination.split(' '),
              i,
              key,
              keys,
              modifiers = [];
  
          // if this pattern is a sequence of keys then run through this method
          // to reprocess each pattern one key at a time
          if (sequence.length > 1) {
              _bindSequence(combination, sequence, callback, action);
              return;
          }
  
          // take the keys from this pattern and figure out what the actual
          // pattern is all about
          keys = combination === '+' ? ['+'] : combination.split('+');
  
          for (i = 0; i < keys.length; ++i) {
              key = keys[i];
  
              // normalize key names
              if (_SPECIAL_ALIASES[key]) {
                  key = _SPECIAL_ALIASES[key];
              }
  
              // if this is not a keypress event then we should
              // be smart about using shift keys
              // this will only work for US keyboards however
              if (action && action != 'keypress' && _SHIFT_MAP[key]) {
                  key = _SHIFT_MAP[key];
                  modifiers.push('shift');
              }
  
              // if this key is a modifier then add it to the list of modifiers
              if (_isModifier(key)) {
                  modifiers.push(key);
              }
          }
  
          // depending on what the key combination is
          // we will try to pick the best event for it
          action = _pickBestAction(key, modifiers, action);
  
          // make sure to initialize array if this is the first time
          // a callback is added for this key
          if (!_callbacks[key]) {
              _callbacks[key] = [];
          }
  
          // remove an existing match if there is one
          _getMatches(key, modifiers, {type: action}, !sequence_name, combination);
  
          // add this call back to the array
          // if it is a sequence put it at the beginning
          // if not put it at the end
          //
          // this is important because the way these are processed expects
          // the sequence ones to come first
          _callbacks[key][sequence_name ? 'unshift' : 'push']({
              callback: callback,
              modifiers: modifiers,
              action: action,
              seq: sequence_name,
              level: level,
              combo: combination
          });
      }
  
      /**
       * binds multiple combinations to the same callback
       *
       * @param {Array} combinations
       * @param {Function} callback
       * @param {string|undefined} action
       * @returns void
       */
      function _bindMultiple(combinations, callback, action) {
          for (var i = 0; i < combinations.length; ++i) {
              _bindSingle(combinations[i], callback, action);
          }
      }
  
      // start!
      _addEvent(document, 'keypress', _handleKey);
      _addEvent(document, 'keydown', _handleKey);
      _addEvent(document, 'keyup', _handleKey);
  
      var Mousetrap = {
  
          /**
           * binds an event to mousetrap
           *
           * can be a single key, a combination of keys separated with +,
           * an array of keys, or a sequence of keys separated by spaces
           *
           * be sure to list the modifier keys first to make sure that the
           * correct key ends up getting bound (the last key in the pattern)
           *
           * @param {string|Array} keys
           * @param {Function} callback
           * @param {string=} action - 'keypress', 'keydown', or 'keyup'
           * @returns void
           */
          bind: function(keys, callback, action) {
              _bindMultiple(keys instanceof Array ? keys : [keys], callback, action);
              _direct_map[keys + ':' + action] = callback;
              return this;
          },
  
          /**
           * unbinds an event to mousetrap
           *
           * the unbinding sets the callback function of the specified key combo
           * to an empty function and deletes the corresponding key in the
           * _direct_map dict.
           *
           * the keycombo+action has to be exactly the same as
           * it was defined in the bind method
           *
           * TODO: actually remove this from the _callbacks dictionary instead
           * of binding an empty function
           *
           * @param {string|Array} keys
           * @param {string} action
           * @returns void
           */
          unbind: function(keys, action) {
              if (_direct_map[keys + ':' + action]) {
                  delete _direct_map[keys + ':' + action];
                  this.bind(keys, function() {}, action);
              }
              return this;
          },
  
          /**
           * triggers an event that has already been bound
           *
           * @param {string} keys
           * @param {string=} action
           * @returns void
           */
          trigger: function(keys, action) {
              _direct_map[keys + ':' + action]();
              return this;
          },
  
          /**
           * resets the library back to its initial state.  this is useful
           * if you want to clear out the current keyboard shortcuts and bind
           * new ones - for example if you switch to another page
           *
           * @returns void
           */
          reset: function() {
              _callbacks = {};
              _direct_map = {};
              return this;
          },
  
         /**
          * should we stop this event before firing off callbacks
          *
          * @param {Event} e
          * @param {Element} element
          * @return {boolean}
          */
          stopCallback: function(e, element) {
  
              // if the element has the class "mousetrap" then no need to stop
              if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
                  return false;
              }
  
              // stop for input, select, and textarea
              return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || (element.contentEditable && element.contentEditable == 'true');
          }
      };
  
      // expose mousetrap to the global object
      window.Mousetrap = Mousetrap;
  
      // expose mousetrap as an AMD module
      if (typeof define == 'function' && define.amd) {
          define('mousetrap', function() { return Mousetrap; });
      }
      // browserify support
      if(typeof module === 'object' && module.exports) {
          module.exports = Mousetrap;
      }
  }) ();
  
  },{}],16:[function(require,module,exports){
  (function (global){(function() {
      var root = this;
      var EventEmitter = require('events').EventEmitter;
  	var _ = require('underscore');
  	var intervalParser = /([0-9\.]+)(ms|s|m|h)?/;
  	var root = global || window;
  
  	// Lil bit of useful polyfill...
  	if (typeof(Function.prototype.inherits) === 'undefined') {
  		Function.prototype.inherits = function(parent) {
  			this.prototype = Object.create(parent.prototype);
  		};
  	}
  
  	if (typeof(Array.prototype.removeOne) === 'undefined') {
  		Array.prototype.removeOne = function() {
  			var what, a = arguments, L = a.length, ax;
  			while (L && this.length) {
  				what = a[--L];
  				while ((ax = this.indexOf(what)) !== -1) {
  					return this.splice(ax, 1);
  				}
  			}
  		};
  	}
  
  	function greatestCommonFactor(intervals) {
  		var sumOfModuli = 1;
  		var interval = _.min(intervals);
  		while (sumOfModuli !== 0) {
  			sumOfModuli = _.reduce(intervals, function(memo, i){ return memo + (i % interval); }, 0);
  			if (sumOfModuli !== 0) {
  				interval -= 10;
  			}
  		}
  		return interval;
  	}
  
  	function parseEvent(e) {
  		var intervalGroups = intervalParser.exec(e);
  		if (!intervalGroups) {
  			throw new Error('I don\'t understand that particular interval');
  		}
  		var intervalAmount = +intervalGroups[1];
  		var intervalType = intervalGroups[2] || 'ms';
  		if (intervalType === 's') {
  			intervalAmount = intervalAmount * 1000;
  		} else if (intervalType === 'm') {
  			intervalAmount = intervalAmount * 1000 * 60;
  		} else if (intervalType === 'h') {
  			intervalAmount = intervalAmount * 1000 * 60 * 60;
  		} else if (!!intervalType && intervalType !== 'ms') {
  			throw new Error('You can only specify intervals of ms, s, m, or h');
  		}
  		if (intervalAmount < 10 || intervalAmount % 10 !== 0) {
  			// We only deal in 10's of milliseconds for simplicity
  			throw new Error('You can only specify 10s of milliseconds, trust me on this one');
  		}
  		return {
  			amount:intervalAmount,
  			type:intervalType
  		};
  	}
  
  	function EventedLoop() {
  		this.intervalId = undefined;
  		this.intervalLength = undefined;
  		this.intervalsToEmit = {};
  		this.currentTick = 1;
  		this.maxTicks = 0;
  		this.listeningForFocus = false;
  
  		// Private method
  		var determineIntervalLength = function () {
  			var potentialIntervalLength = greatestCommonFactor(_.keys(this.intervalsToEmit));
  			var changed = false;
  
  			if (this.intervalLength) {
  				if (potentialIntervalLength !== this.intervalLength) {
  					// Looks like we need a new interval
  					this.intervalLength = potentialIntervalLength;
  					changed = true;
  				}
  			} else {
  				this.intervalLength = potentialIntervalLength;
  			}
  
  			this.maxTicks = _.max(_.map(_.keys(this.intervalsToEmit), function(a) { return +a; })) / this.intervalLength;
  			return changed;
  		}.bind(this);
  
  		this.on('newListener', function (e) {
  			if (e === 'removeListener' || e === 'newListener') return; // We don't care about that one
  			var intervalInfo = parseEvent(e);
  			var intervalAmount = intervalInfo.amount;
  
  			this.intervalsToEmit[+intervalAmount] = _.union(this.intervalsToEmit[+intervalAmount] || [], [e]);
  			
  			if (determineIntervalLength() && this.isStarted()) {
  				this.stop().start();
  			}
  		});
  
  		this.on('removeListener', function (e) {
  			if (EventEmitter.listenerCount(this, e) > 0) return;
  			var intervalInfo = parseEvent(e);
  			var intervalAmount = intervalInfo.amount;
  
  			var removedEvent = this.intervalsToEmit[+intervalAmount].removeOne(e);
  			if (this.intervalsToEmit[+intervalAmount].length === 0) {
  				delete this.intervalsToEmit[+intervalAmount];
  			}
  			console.log('Determining interval length after removal of', removedEvent);
  			determineIntervalLength();
  
  			if (determineIntervalLength() && this.isStarted()) {
  				this.stop().start();
  			}
  		});
  	}
  
  	EventedLoop.inherits(EventEmitter);
  
  	// Public methods
  	EventedLoop.prototype.tick = function () {
  		var milliseconds = this.currentTick * this.intervalLength;
  		_.each(this.intervalsToEmit, function (events, key) {
  			if (milliseconds % key === 0) {
  				_.each(events, function(e) { this.emit(e, e, key); }.bind(this));
  			}
  		}.bind(this));
  		this.currentTick += 1;
  		if (this.currentTick > this.maxTicks) {
  			this.currentTick = 1;
  		}
  		return this;
  	};
  
  	EventedLoop.prototype.start = function () {
  		if (!this.intervalLength) {
  			throw new Error('You haven\'t specified any interval callbacks. Use EventedLoop.on(\'500ms\', function () { ... }) to do so, and then you can start');
  		}
  		if (this.intervalId) {
  			return console.log('No need to start the loop again, it\'s already started.');
  		}
  
  		this.intervalId = setInterval(this.tick.bind(this), this.intervalLength);
  
  		if (root && !this.listeningForFocus && root.addEventListener) {
  			root.addEventListener('focus', function() {
  				this.start();
  			}.bind(this));
  
  			root.addEventListener('blur', function() {
  				this.stop();
  			}.bind(this));
  
  			this.listeningForFocus = true;
  		}
  		return this;
  	};
  
  	EventedLoop.prototype.stop = function () {
  		clearInterval(this.intervalId);
  		this.intervalId = undefined;
  		return this;
  	};
  
  	EventedLoop.prototype.isStarted = function () {
  		return !!this.intervalId;
  	};
  
  	EventedLoop.prototype.every = EventedLoop.prototype.on;
  
      // Export the EventedLoop object for **Node.js** or other
      // commonjs systems. Otherwise, add it as a global object to the root
      if (typeof exports !== 'undefined') {
          if (typeof module !== 'undefined' && module.exports) {
              exports = module.exports = EventedLoop;
          }
          exports.EventedLoop = EventedLoop;
      }
      if (typeof window !== 'undefined') {
          window.EventedLoop = EventedLoop;
      }
  }).call(this);}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  },{"events":19,"underscore":17}],17:[function(require,module,exports){
  //     Underscore.js 1.6.0
  //     http://underscorejs.org
  //     (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  //     Underscore may be freely distributed under the MIT license.
  
  (function() {
  
    // Baseline setup
    // --------------
  
    // Establish the root object, `window` in the browser, or `exports` on the server.
    var root = this;
  
    // Save the previous value of the `_` variable.
    var previousUnderscore = root._;
  
    // Establish the object that gets returned to break out of a loop iteration.
    var breaker = {};
  
    // Save bytes in the minified (but not gzipped) version:
    var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
  
    // Create quick reference variables for speed access to core prototypes.
    var
      push             = ArrayProto.push,
      slice            = ArrayProto.slice,
      concat           = ArrayProto.concat,
      toString         = ObjProto.toString,
      hasOwnProperty   = ObjProto.hasOwnProperty;
  
    // All **ECMAScript 5** native function implementations that we hope to use
    // are declared here.
    var
      nativeForEach      = ArrayProto.forEach,
      nativeMap          = ArrayProto.map,
      nativeReduce       = ArrayProto.reduce,
      nativeReduceRight  = ArrayProto.reduceRight,
      nativeFilter       = ArrayProto.filter,
      nativeEvery        = ArrayProto.every,
      nativeSome         = ArrayProto.some,
      nativeIndexOf      = ArrayProto.indexOf,
      nativeLastIndexOf  = ArrayProto.lastIndexOf,
      nativeIsArray      = Array.isArray,
      nativeKeys         = Object.keys,
      nativeBind         = FuncProto.bind;
  
    // Create a safe reference to the Underscore object for use below.
    var _ = function(obj) {
      if (obj instanceof _) return obj;
      if (!(this instanceof _)) return new _(obj);
      this._wrapped = obj;
    };
  
    // Export the Underscore object for **Node.js**, with
    // backwards-compatibility for the old `require()` API. If we're in
    // the browser, add `_` as a global object via a string identifier,
    // for Closure Compiler "advanced" mode.
    if (typeof exports !== 'undefined') {
      if (typeof module !== 'undefined' && module.exports) {
        exports = module.exports = _;
      }
      exports._ = _;
    } else {
      root._ = _;
    }
  
    // Current version.
    _.VERSION = '1.6.0';
  
    // Collection Functions
    // --------------------
  
    // The cornerstone, an `each` implementation, aka `forEach`.
    // Handles objects with the built-in `forEach`, arrays, and raw objects.
    // Delegates to **ECMAScript 5**'s native `forEach` if available.
    var each = _.each = _.forEach = function(obj, iterator, context) {
      if (obj == null) return obj;
      if (nativeForEach && obj.forEach === nativeForEach) {
        obj.forEach(iterator, context);
      } else if (obj.length === +obj.length) {
        for (var i = 0, length = obj.length; i < length; i++) {
          if (iterator.call(context, obj[i], i, obj) === breaker) return;
        }
      } else {
        var keys = _.keys(obj);
        for (var i = 0, length = keys.length; i < length; i++) {
          if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;
        }
      }
      return obj;
    };
  
    // Return the results of applying the iterator to each element.
    // Delegates to **ECMAScript 5**'s native `map` if available.
    _.map = _.collect = function(obj, iterator, context) {
      var results = [];
      if (obj == null) return results;
      if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
      each(obj, function(value, index, list) {
        results.push(iterator.call(context, value, index, list));
      });
      return results;
    };
  
    var reduceError = 'Reduce of empty array with no initial value';
  
    // **Reduce** builds up a single result from a list of values, aka `inject`,
    // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
    _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
      var initial = arguments.length > 2;
      if (obj == null) obj = [];
      if (nativeReduce && obj.reduce === nativeReduce) {
        if (context) iterator = _.bind(iterator, context);
        return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
      }
      each(obj, function(value, index, list) {
        if (!initial) {
          memo = value;
          initial = true;
        } else {
          memo = iterator.call(context, memo, value, index, list);
        }
      });
      if (!initial) throw new TypeError(reduceError);
      return memo;
    };
  
    // The right-associative version of reduce, also known as `foldr`.
    // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
    _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
      var initial = arguments.length > 2;
      if (obj == null) obj = [];
      if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
        if (context) iterator = _.bind(iterator, context);
        return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
      }
      var length = obj.length;
      if (length !== +length) {
        var keys = _.keys(obj);
        length = keys.length;
      }
      each(obj, function(value, index, list) {
        index = keys ? keys[--length] : --length;
        if (!initial) {
          memo = obj[index];
          initial = true;
        } else {
          memo = iterator.call(context, memo, obj[index], index, list);
        }
      });
      if (!initial) throw new TypeError(reduceError);
      return memo;
    };
  
    // Return the first value which passes a truth test. Aliased as `detect`.
    _.find = _.detect = function(obj, predicate, context) {
      var result;
      any(obj, function(value, index, list) {
        if (predicate.call(context, value, index, list)) {
          result = value;
          return true;
        }
      });
      return result;
    };
  
    // Return all the elements that pass a truth test.
    // Delegates to **ECMAScript 5**'s native `filter` if available.
    // Aliased as `select`.
    _.filter = _.select = function(obj, predicate, context) {
      var results = [];
      if (obj == null) return results;
      if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context);
      each(obj, function(value, index, list) {
        if (predicate.call(context, value, index, list)) results.push(value);
      });
      return results;
    };
  
    // Return all the elements for which a truth test fails.
    _.reject = function(obj, predicate, context) {
      return _.filter(obj, function(value, index, list) {
        return !predicate.call(context, value, index, list);
      }, context);
    };
  
    // Determine whether all of the elements match a truth test.
    // Delegates to **ECMAScript 5**'s native `every` if available.
    // Aliased as `all`.
    _.every = _.all = function(obj, predicate, context) {
      predicate || (predicate = _.identity);
      var result = true;
      if (obj == null) return result;
      if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context);
      each(obj, function(value, index, list) {
        if (!(result = result && predicate.call(context, value, index, list))) return breaker;
      });
      return !!result;
    };
  
    // Determine if at least one element in the object matches a truth test.
    // Delegates to **ECMAScript 5**'s native `some` if available.
    // Aliased as `any`.
    var any = _.some = _.any = function(obj, predicate, context) {
      predicate || (predicate = _.identity);
      var result = false;
      if (obj == null) return result;
      if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context);
      each(obj, function(value, index, list) {
        if (result || (result = predicate.call(context, value, index, list))) return breaker;
      });
      return !!result;
    };
  
    // Determine if the array or object contains a given value (using `===`).
    // Aliased as `include`.
    _.contains = _.include = function(obj, target) {
      if (obj == null) return false;
      if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
      return any(obj, function(value) {
        return value === target;
      });
    };
  
    // Invoke a method (with arguments) on every item in a collection.
    _.invoke = function(obj, method) {
      var args = slice.call(arguments, 2);
      var isFunc = _.isFunction(method);
      return _.map(obj, function(value) {
        return (isFunc ? method : value[method]).apply(value, args);
      });
    };
  
    // Convenience version of a common use case of `map`: fetching a property.
    _.pluck = function(obj, key) {
      return _.map(obj, _.property(key));
    };
  
    // Convenience version of a common use case of `filter`: selecting only objects
    // containing specific `key:value` pairs.
    _.where = function(obj, attrs) {
      return _.filter(obj, _.matches(attrs));
    };
  
    // Convenience version of a common use case of `find`: getting the first object
    // containing specific `key:value` pairs.
    _.findWhere = function(obj, attrs) {
      return _.find(obj, _.matches(attrs));
    };
  
    // Return the maximum element or (element-based computation).
    // Can't optimize arrays of integers longer than 65,535 elements.
    // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797)
    _.max = function(obj, iterator, context) {
      if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
        return Math.max.apply(Math, obj);
      }
      var result = -Infinity, lastComputed = -Infinity;
      each(obj, function(value, index, list) {
        var computed = iterator ? iterator.call(context, value, index, list) : value;
        if (computed > lastComputed) {
          result = value;
          lastComputed = computed;
        }
      });
      return result;
    };
  
    // Return the minimum element (or element-based computation).
    _.min = function(obj, iterator, context) {
      if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
        return Math.min.apply(Math, obj);
      }
      var result = Infinity, lastComputed = Infinity;
      each(obj, function(value, index, list) {
        var computed = iterator ? iterator.call(context, value, index, list) : value;
        if (computed < lastComputed) {
          result = value;
          lastComputed = computed;
        }
      });
      return result;
    };
  
    // Shuffle an array, using the modern version of the
    // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
    _.shuffle = function(obj) {
      var rand;
      var index = 0;
      var shuffled = [];
      each(obj, function(value) {
        rand = _.random(index++);
        shuffled[index - 1] = shuffled[rand];
        shuffled[rand] = value;
      });
      return shuffled;
    };
  
    // Sample **n** random values from a collection.
    // If **n** is not specified, returns a single random element.
    // The internal `guard` argument allows it to work with `map`.
    _.sample = function(obj, n, guard) {
      if (n == null || guard) {
        if (obj.length !== +obj.length) obj = _.values(obj);
        return obj[_.random(obj.length - 1)];
      }
      return _.shuffle(obj).slice(0, Math.max(0, n));
    };
  
    // An internal function to generate lookup iterators.
    var lookupIterator = function(value) {
      if (value == null) return _.identity;
      if (_.isFunction(value)) return value;
      return _.property(value);
    };
  
    // Sort the object's values by a criterion produced by an iterator.
    _.sortBy = function(obj, iterator, context) {
      iterator = lookupIterator(iterator);
      return _.pluck(_.map(obj, function(value, index, list) {
        return {
          value: value,
          index: index,
          criteria: iterator.call(context, value, index, list)
        };
      }).sort(function(left, right) {
        var a = left.criteria;
        var b = right.criteria;
        if (a !== b) {
          if (a > b || a === void 0) return 1;
          if (a < b || b === void 0) return -1;
        }
        return left.index - right.index;
      }), 'value');
    };
  
    // An internal function used for aggregate "group by" operations.
    var group = function(behavior) {
      return function(obj, iterator, context) {
        var result = {};
        iterator = lookupIterator(iterator);
        each(obj, function(value, index) {
          var key = iterator.call(context, value, index, obj);
          behavior(result, key, value);
        });
        return result;
      };
    };
  
    // Groups the object's values by a criterion. Pass either a string attribute
    // to group by, or a function that returns the criterion.
    _.groupBy = group(function(result, key, value) {
      _.has(result, key) ? result[key].push(value) : result[key] = [value];
    });
  
    // Indexes the object's values by a criterion, similar to `groupBy`, but for
    // when you know that your index values will be unique.
    _.indexBy = group(function(result, key, value) {
      result[key] = value;
    });
  
    // Counts instances of an object that group by a certain criterion. Pass
    // either a string attribute to count by, or a function that returns the
    // criterion.
    _.countBy = group(function(result, key) {
      _.has(result, key) ? result[key]++ : result[key] = 1;
    });
  
    // Use a comparator function to figure out the smallest index at which
    // an object should be inserted so as to maintain order. Uses binary search.
    _.sortedIndex = function(array, obj, iterator, context) {
      iterator = lookupIterator(iterator);
      var value = iterator.call(context, obj);
      var low = 0, high = array.length;
      while (low < high) {
        var mid = (low + high) >>> 1;
        iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
      }
      return low;
    };
  
    // Safely create a real, live array from anything iterable.
    _.toArray = function(obj) {
      if (!obj) return [];
      if (_.isArray(obj)) return slice.call(obj);
      if (obj.length === +obj.length) return _.map(obj, _.identity);
      return _.values(obj);
    };
  
    // Return the number of elements in an object.
    _.size = function(obj) {
      if (obj == null) return 0;
      return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
    };
  
    // Array Functions
    // ---------------
  
    // Get the first element of an array. Passing **n** will return the first N
    // values in the array. Aliased as `head` and `take`. The **guard** check
    // allows it to work with `_.map`.
    _.first = _.head = _.take = function(array, n, guard) {
      if (array == null) return void 0;
      if ((n == null) || guard) return array[0];
      if (n < 0) return [];
      return slice.call(array, 0, n);
    };
  
    // Returns everything but the last entry of the array. Especially useful on
    // the arguments object. Passing **n** will return all the values in
    // the array, excluding the last N. The **guard** check allows it to work with
    // `_.map`.
    _.initial = function(array, n, guard) {
      return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
    };
  
    // Get the last element of an array. Passing **n** will return the last N
    // values in the array. The **guard** check allows it to work with `_.map`.
    _.last = function(array, n, guard) {
      if (array == null) return void 0;
      if ((n == null) || guard) return array[array.length - 1];
      return slice.call(array, Math.max(array.length - n, 0));
    };
  
    // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
    // Especially useful on the arguments object. Passing an **n** will return
    // the rest N values in the array. The **guard**
    // check allows it to work with `_.map`.
    _.rest = _.tail = _.drop = function(array, n, guard) {
      return slice.call(array, (n == null) || guard ? 1 : n);
    };
  
    // Trim out all falsy values from an array.
    _.compact = function(array) {
      return _.filter(array, _.identity);
    };
  
    // Internal implementation of a recursive `flatten` function.
    var flatten = function(input, shallow, output) {
      if (shallow && _.every(input, _.isArray)) {
        return concat.apply(output, input);
      }
      each(input, function(value) {
        if (_.isArray(value) || _.isArguments(value)) {
          shallow ? push.apply(output, value) : flatten(value, shallow, output);
        } else {
          output.push(value);
        }
      });
      return output;
    };
  
    // Flatten out an array, either recursively (by default), or just one level.
    _.flatten = function(array, shallow) {
      return flatten(array, shallow, []);
    };
  
    // Return a version of the array that does not contain the specified value(s).
    _.without = function(array) {
      return _.difference(array, slice.call(arguments, 1));
    };
  
    // Split an array into two arrays: one whose elements all satisfy the given
    // predicate, and one whose elements all do not satisfy the predicate.
    _.partition = function(array, predicate) {
      var pass = [], fail = [];
      each(array, function(elem) {
        (predicate(elem) ? pass : fail).push(elem);
      });
      return [pass, fail];
    };
  
    // Produce a duplicate-free version of the array. If the array has already
    // been sorted, you have the option of using a faster algorithm.
    // Aliased as `unique`.
    _.uniq = _.unique = function(array, isSorted, iterator, context) {
      if (_.isFunction(isSorted)) {
        context = iterator;
        iterator = isSorted;
        isSorted = false;
      }
      var initial = iterator ? _.map(array, iterator, context) : array;
      var results = [];
      var seen = [];
      each(initial, function(value, index) {
        if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
          seen.push(value);
          results.push(array[index]);
        }
      });
      return results;
    };
  
    // Produce an array that contains the union: each distinct element from all of
    // the passed-in arrays.
    _.union = function() {
      return _.uniq(_.flatten(arguments, true));
    };
  
    // Produce an array that contains every item shared between all the
    // passed-in arrays.
    _.intersection = function(array) {
      var rest = slice.call(arguments, 1);
      return _.filter(_.uniq(array), function(item) {
        return _.every(rest, function(other) {
          return _.contains(other, item);
        });
      });
    };
  
    // Take the difference between one array and a number of other arrays.
    // Only the elements present in just the first array will remain.
    _.difference = function(array) {
      var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
      return _.filter(array, function(value){ return !_.contains(rest, value); });
    };
  
    // Zip together multiple lists into a single array -- elements that share
    // an index go together.
    _.zip = function() {
      var length = _.max(_.pluck(arguments, 'length').concat(0));
      var results = new Array(length);
      for (var i = 0; i < length; i++) {
        results[i] = _.pluck(arguments, '' + i);
      }
      return results;
    };
  
    // Converts lists into objects. Pass either a single array of `[key, value]`
    // pairs, or two parallel arrays of the same length -- one of keys, and one of
    // the corresponding values.
    _.object = function(list, values) {
      if (list == null) return {};
      var result = {};
      for (var i = 0, length = list.length; i < length; i++) {
        if (values) {
          result[list[i]] = values[i];
        } else {
          result[list[i][0]] = list[i][1];
        }
      }
      return result;
    };
  
    // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
    // we need this function. Return the position of the first occurrence of an
    // item in an array, or -1 if the item is not included in the array.
    // Delegates to **ECMAScript 5**'s native `indexOf` if available.
    // If the array is large and already in sort order, pass `true`
    // for **isSorted** to use binary search.
    _.indexOf = function(array, item, isSorted) {
      if (array == null) return -1;
      var i = 0, length = array.length;
      if (isSorted) {
        if (typeof isSorted == 'number') {
          i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);
        } else {
          i = _.sortedIndex(array, item);
          return array[i] === item ? i : -1;
        }
      }
      if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
      for (; i < length; i++) if (array[i] === item) return i;
      return -1;
    };
  
    // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
    _.lastIndexOf = function(array, item, from) {
      if (array == null) return -1;
      var hasIndex = from != null;
      if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
        return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
      }
      var i = (hasIndex ? from : array.length);
      while (i--) if (array[i] === item) return i;
      return -1;
    };
  
    // Generate an integer Array containing an arithmetic progression. A port of
    // the native Python `range()` function. See
    // [the Python documentation](http://docs.python.org/library/functions.html#range).
    _.range = function(start, stop, step) {
      if (arguments.length <= 1) {
        stop = start || 0;
        start = 0;
      }
      step = arguments[2] || 1;
  
      var length = Math.max(Math.ceil((stop - start) / step), 0);
      var idx = 0;
      var range = new Array(length);
  
      while(idx < length) {
        range[idx++] = start;
        start += step;
      }
  
      return range;
    };
  
    // Function (ahem) Functions
    // ------------------
  
    // Reusable constructor function for prototype setting.
    var ctor = function(){};
  
    // Create a function bound to a given object (assigning `this`, and arguments,
    // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
    // available.
    _.bind = function(func, context) {
      var args, bound;
      if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
      if (!_.isFunction(func)) throw new TypeError;
      args = slice.call(arguments, 2);
      return bound = function() {
        if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
        ctor.prototype = func.prototype;
        var self = new ctor;
        ctor.prototype = null;
        var result = func.apply(self, args.concat(slice.call(arguments)));
        if (Object(result) === result) return result;
        return self;
      };
    };
  
    // Partially apply a function by creating a version that has had some of its
    // arguments pre-filled, without changing its dynamic `this` context. _ acts
    // as a placeholder, allowing any combination of arguments to be pre-filled.
    _.partial = function(func) {
      var boundArgs = slice.call(arguments, 1);
      return function() {
        var position = 0;
        var args = boundArgs.slice();
        for (var i = 0, length = args.length; i < length; i++) {
          if (args[i] === _) args[i] = arguments[position++];
        }
        while (position < arguments.length) args.push(arguments[position++]);
        return func.apply(this, args);
      };
    };
  
    // Bind a number of an object's methods to that object. Remaining arguments
    // are the method names to be bound. Useful for ensuring that all callbacks
    // defined on an object belong to it.
    _.bindAll = function(obj) {
      var funcs = slice.call(arguments, 1);
      if (funcs.length === 0) throw new Error('bindAll must be passed function names');
      each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
      return obj;
    };
  
    // Memoize an expensive function by storing its results.
    _.memoize = function(func, hasher) {
      var memo = {};
      hasher || (hasher = _.identity);
      return function() {
        var key = hasher.apply(this, arguments);
        return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
      };
    };
  
    // Delays a function for the given number of milliseconds, and then calls
    // it with the arguments supplied.
    _.delay = function(func, wait) {
      var args = slice.call(arguments, 2);
      return setTimeout(function(){ return func.apply(null, args); }, wait);
    };
  
    // Defers a function, scheduling it to run after the current call stack has
    // cleared.
    _.defer = function(func) {
      return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
    };
  
    // Returns a function, that, when invoked, will only be triggered at most once
    // during a given window of time. Normally, the throttled function will run
    // as much as it can, without ever going more than once per `wait` duration;
    // but if you'd like to disable the execution on the leading edge, pass
    // `{leading: false}`. To disable execution on the trailing edge, ditto.
    _.throttle = function(func, wait, options) {
      var context, args, result;
      var timeout = null;
      var previous = 0;
      options || (options = {});
      var later = function() {
        previous = options.leading === false ? 0 : _.now();
        timeout = null;
        result = func.apply(context, args);
        context = args = null;
      };
      return function() {
        var now = _.now();
        if (!previous && options.leading === false) previous = now;
        var remaining = wait - (now - previous);
        context = this;
        args = arguments;
        if (remaining <= 0) {
          clearTimeout(timeout);
          timeout = null;
          previous = now;
          result = func.apply(context, args);
          context = args = null;
        } else if (!timeout && options.trailing !== false) {
          timeout = setTimeout(later, remaining);
        }
        return result;
      };
    };
  
    // Returns a function, that, as long as it continues to be invoked, will not
    // be triggered. The function will be called after it stops being called for
    // N milliseconds. If `immediate` is passed, trigger the function on the
    // leading edge, instead of the trailing.
    _.debounce = function(func, wait, immediate) {
      var timeout, args, context, timestamp, result;
  
      var later = function() {
        var last = _.now() - timestamp;
        if (last < wait) {
          timeout = setTimeout(later, wait - last);
        } else {
          timeout = null;
          if (!immediate) {
            result = func.apply(context, args);
            context = args = null;
          }
        }
      };
  
      return function() {
        context = this;
        args = arguments;
        timestamp = _.now();
        var callNow = immediate && !timeout;
        if (!timeout) {
          timeout = setTimeout(later, wait);
        }
        if (callNow) {
          result = func.apply(context, args);
          context = args = null;
        }
  
        return result;
      };
    };
  
    // Returns a function that will be executed at most one time, no matter how
    // often you call it. Useful for lazy initialization.
    _.once = function(func) {
      var ran = false, memo;
      return function() {
        if (ran) return memo;
        ran = true;
        memo = func.apply(this, arguments);
        func = null;
        return memo;
      };
    };
  
    // Returns the first function passed as an argument to the second,
    // allowing you to adjust arguments, run code before and after, and
    // conditionally execute the original function.
    _.wrap = function(func, wrapper) {
      return _.partial(wrapper, func);
    };
  
    // Returns a function that is the composition of a list of functions, each
    // consuming the return value of the function that follows.
    _.compose = function() {
      var funcs = arguments;
      return function() {
        var args = arguments;
        for (var i = funcs.length - 1; i >= 0; i--) {
          args = [funcs[i].apply(this, args)];
        }
        return args[0];
      };
    };
  
    // Returns a function that will only be executed after being called N times.
    _.after = function(times, func) {
      return function() {
        if (--times < 1) {
          return func.apply(this, arguments);
        }
      };
    };
  
    // Object Functions
    // ----------------
  
    // Retrieve the names of an object's properties.
    // Delegates to **ECMAScript 5**'s native `Object.keys`
    _.keys = function(obj) {
      if (!_.isObject(obj)) return [];
      if (nativeKeys) return nativeKeys(obj);
      var keys = [];
      for (var key in obj) if (_.has(obj, key)) keys.push(key);
      return keys;
    };
  
    // Retrieve the values of an object's properties.
    _.values = function(obj) {
      var keys = _.keys(obj);
      var length = keys.length;
      var values = new Array(length);
      for (var i = 0; i < length; i++) {
        values[i] = obj[keys[i]];
      }
      return values;
    };
  
    // Convert an object into a list of `[key, value]` pairs.
    _.pairs = function(obj) {
      var keys = _.keys(obj);
      var length = keys.length;
      var pairs = new Array(length);
      for (var i = 0; i < length; i++) {
        pairs[i] = [keys[i], obj[keys[i]]];
      }
      return pairs;
    };
  
    // Invert the keys and values of an object. The values must be serializable.
    _.invert = function(obj) {
      var result = {};
      var keys = _.keys(obj);
      for (var i = 0, length = keys.length; i < length; i++) {
        result[obj[keys[i]]] = keys[i];
      }
      return result;
    };
  
    // Return a sorted list of the function names available on the object.
    // Aliased as `methods`
    _.functions = _.methods = function(obj) {
      var names = [];
      for (var key in obj) {
        if (_.isFunction(obj[key])) names.push(key);
      }
      return names.sort();
    };
  
    // Extend a given object with all the properties in passed-in object(s).
    _.extend = function(obj) {
      each(slice.call(arguments, 1), function(source) {
        if (source) {
          for (var prop in source) {
            obj[prop] = source[prop];
          }
        }
      });
      return obj;
    };
  
    // Return a copy of the object only containing the whitelisted properties.
    _.pick = function(obj) {
      var copy = {};
      var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
      each(keys, function(key) {
        if (key in obj) copy[key] = obj[key];
      });
      return copy;
    };
  
     // Return a copy of the object without the blacklisted properties.
    _.omit = function(obj) {
      var copy = {};
      var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
      for (var key in obj) {
        if (!_.contains(keys, key)) copy[key] = obj[key];
      }
      return copy;
    };
  
    // Fill in a given object with default properties.
    _.defaults = function(obj) {
      each(slice.call(arguments, 1), function(source) {
        if (source) {
          for (var prop in source) {
            if (obj[prop] === void 0) obj[prop] = source[prop];
          }
        }
      });
      return obj;
    };
  
    // Create a (shallow-cloned) duplicate of an object.
    _.clone = function(obj) {
      if (!_.isObject(obj)) return obj;
      return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
    };
  
    // Invokes interceptor with the obj, and then returns obj.
    // The primary purpose of this method is to "tap into" a method chain, in
    // order to perform operations on intermediate results within the chain.
    _.tap = function(obj, interceptor) {
      interceptor(obj);
      return obj;
    };
  
    // Internal recursive comparison function for `isEqual`.
    var eq = function(a, b, aStack, bStack) {
      // Identical objects are equal. `0 === -0`, but they aren't identical.
      // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
      if (a === b) return a !== 0 || 1 / a == 1 / b;
      // A strict comparison is necessary because `null == undefined`.
      if (a == null || b == null) return a === b;
      // Unwrap any wrapped objects.
      if (a instanceof _) a = a._wrapped;
      if (b instanceof _) b = b._wrapped;
      // Compare `[[Class]]` names.
      var className = toString.call(a);
      if (className != toString.call(b)) return false;
      switch (className) {
        // Strings, numbers, dates, and booleans are compared by value.
        case '[object String]':
          // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
          // equivalent to `new String("5")`.
          return a == String(b);
        case '[object Number]':
          // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
          // other numeric values.
          return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
        case '[object Date]':
        case '[object Boolean]':
          // Coerce dates and booleans to numeric primitive values. Dates are compared by their
          // millisecond representations. Note that invalid dates with millisecond representations
          // of `NaN` are not equivalent.
          return +a == +b;
        // RegExps are compared by their source patterns and flags.
        case '[object RegExp]':
          return a.source == b.source &&
                 a.global == b.global &&
                 a.multiline == b.multiline &&
                 a.ignoreCase == b.ignoreCase;
      }
      if (typeof a != 'object' || typeof b != 'object') return false;
      // Assume equality for cyclic structures. The algorithm for detecting cyclic
      // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
      var length = aStack.length;
      while (length--) {
        // Linear search. Performance is inversely proportional to the number of
        // unique nested structures.
        if (aStack[length] == a) return bStack[length] == b;
      }
      // Objects with different constructors are not equivalent, but `Object`s
      // from different frames are.
      var aCtor = a.constructor, bCtor = b.constructor;
      if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
                               _.isFunction(bCtor) && (bCtor instanceof bCtor))
                          && ('constructor' in a && 'constructor' in b)) {
        return false;
      }
      // Add the first object to the stack of traversed objects.
      aStack.push(a);
      bStack.push(b);
      var size = 0, result = true;
      // Recursively compare objects and arrays.
      if (className == '[object Array]') {
        // Compare array lengths to determine if a deep comparison is necessary.
        size = a.length;
        result = size == b.length;
        if (result) {
          // Deep compare the contents, ignoring non-numeric properties.
          while (size--) {
            if (!(result = eq(a[size], b[size], aStack, bStack))) break;
          }
        }
      } else {
        // Deep compare objects.
        for (var key in a) {
          if (_.has(a, key)) {
            // Count the expected number of properties.
            size++;
            // Deep compare each member.
            if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
          }
        }
        // Ensure that both objects contain the same number of properties.
        if (result) {
          for (key in b) {
            if (_.has(b, key) && !(size--)) break;
          }
          result = !size;
        }
      }
      // Remove the first object from the stack of traversed objects.
      aStack.pop();
      bStack.pop();
      return result;
    };
  
    // Perform a deep comparison to check if two objects are equal.
    _.isEqual = function(a, b) {
      return eq(a, b, [], []);
    };
  
    // Is a given array, string, or object empty?
    // An "empty" object has no enumerable own-properties.
    _.isEmpty = function(obj) {
      if (obj == null) return true;
      if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
      for (var key in obj) if (_.has(obj, key)) return false;
      return true;
    };
  
    // Is a given value a DOM element?
    _.isElement = function(obj) {
      return !!(obj && obj.nodeType === 1);
    };
  
    // Is a given value an array?
    // Delegates to ECMA5's native Array.isArray
    _.isArray = nativeIsArray || function(obj) {
      return toString.call(obj) == '[object Array]';
    };
  
    // Is a given variable an object?
    _.isObject = function(obj) {
      return obj === Object(obj);
    };
  
    // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
    each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
      _['is' + name] = function(obj) {
        return toString.call(obj) == '[object ' + name + ']';
      };
    });
  
    // Define a fallback version of the method in browsers (ahem, IE), where
    // there isn't any inspectable "Arguments" type.
    if (!_.isArguments(arguments)) {
      _.isArguments = function(obj) {
        return !!(obj && _.has(obj, 'callee'));
      };
    }
  
    // Optimize `isFunction` if appropriate.
    if (typeof (/./) !== 'function') {
      _.isFunction = function(obj) {
        return typeof obj === 'function';
      };
    }
  
    // Is a given object a finite number?
    _.isFinite = function(obj) {
      return isFinite(obj) && !isNaN(parseFloat(obj));
    };
  
    // Is the given value `NaN`? (NaN is the only number which does not equal itself).
    _.isNaN = function(obj) {
      return _.isNumber(obj) && obj != +obj;
    };
  
    // Is a given value a boolean?
    _.isBoolean = function(obj) {
      return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
    };
  
    // Is a given value equal to null?
    _.isNull = function(obj) {
      return obj === null;
    };
  
    // Is a given variable undefined?
    _.isUndefined = function(obj) {
      return obj === void 0;
    };
  
    // Shortcut function for checking if an object has a given property directly
    // on itself (in other words, not on a prototype).
    _.has = function(obj, key) {
      return hasOwnProperty.call(obj, key);
    };
  
    // Utility Functions
    // -----------------
  
    // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
    // previous owner. Returns a reference to the Underscore object.
    _.noConflict = function() {
      root._ = previousUnderscore;
      return this;
    };
  
    // Keep the identity function around for default iterators.
    _.identity = function(value) {
      return value;
    };
  
    _.constant = function(value) {
      return function () {
        return value;
      };
    };
  
    _.property = function(key) {
      return function(obj) {
        return obj[key];
      };
    };
  
    // Returns a predicate for checking whether an object has a given set of `key:value` pairs.
    _.matches = function(attrs) {
      return function(obj) {
        if (obj === attrs) return true; //avoid comparing an object to itself.
        for (var key in attrs) {
          if (attrs[key] !== obj[key])
            return false;
        }
        return true;
      }
    };
  
    // Run a function **n** times.
    _.times = function(n, iterator, context) {
      var accum = Array(Math.max(0, n));
      for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i);
      return accum;
    };
  
    // Return a random integer between min and max (inclusive).
    _.random = function(min, max) {
      if (max == null) {
        max = min;
        min = 0;
      }
      return min + Math.floor(Math.random() * (max - min + 1));
    };
  
    // A (possibly faster) way to get the current timestamp as an integer.
    _.now = Date.now || function() { return new Date().getTime(); };
  
    // List of HTML entities for escaping.
    var entityMap = {
      escape: {
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        "'": '&#x27;'
      }
    };
    entityMap.unescape = _.invert(entityMap.escape);
  
    // Regexes containing the keys and values listed immediately above.
    var entityRegexes = {
      escape:   new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
      unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
    };
  
    // Functions for escaping and unescaping strings to/from HTML interpolation.
    _.each(['escape', 'unescape'], function(method) {
      _[method] = function(string) {
        if (string == null) return '';
        return ('' + string).replace(entityRegexes[method], function(match) {
          return entityMap[method][match];
        });
      };
    });
  
    // If the value of the named `property` is a function then invoke it with the
    // `object` as context; otherwise, return it.
    _.result = function(object, property) {
      if (object == null) return void 0;
      var value = object[property];
      return _.isFunction(value) ? value.call(object) : value;
    };
  
    // Add your own custom functions to the Underscore object.
    _.mixin = function(obj) {
      each(_.functions(obj), function(name) {
        var func = _[name] = obj[name];
        _.prototype[name] = function() {
          var args = [this._wrapped];
          push.apply(args, arguments);
          return result.call(this, func.apply(_, args));
        };
      });
    };
  
    // Generate a unique integer id (unique within the entire client session).
    // Useful for temporary DOM ids.
    var idCounter = 0;
    _.uniqueId = function(prefix) {
      var id = ++idCounter + '';
      return prefix ? prefix + id : id;
    };
  
    // By default, Underscore uses ERB-style template delimiters, change the
    // following template settings to use alternative delimiters.
    _.templateSettings = {
      evaluate    : /<%([\s\S]+?)%>/g,
      interpolate : /<%=([\s\S]+?)%>/g,
      escape      : /<%-([\s\S]+?)%>/g
    };
  
    // When customizing `templateSettings`, if you don't want to define an
    // interpolation, evaluation or escaping regex, we need one that is
    // guaranteed not to match.
    var noMatch = /(.)^/;
  
    // Certain characters need to be escaped so that they can be put into a
    // string literal.
    var escapes = {
      "'":      "'",
      '\\':     '\\',
      '\r':     'r',
      '\n':     'n',
      '\t':     't',
      '\u2028': 'u2028',
      '\u2029': 'u2029'
    };
  
    var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
  
    // JavaScript micro-templating, similar to John Resig's implementation.
    // Underscore templating handles arbitrary delimiters, preserves whitespace,
    // and correctly escapes quotes within interpolated code.
    _.template = function(text, data, settings) {
      var render;
      settings = _.defaults({}, settings, _.templateSettings);
  
      // Combine delimiters into one regular expression via alternation.
      var matcher = new RegExp([
        (settings.escape || noMatch).source,
        (settings.interpolate || noMatch).source,
        (settings.evaluate || noMatch).source
      ].join('|') + '|$', 'g');
  
      // Compile the template source, escaping string literals appropriately.
      var index = 0;
      var source = "__p+='";
      text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
        source += text.slice(index, offset)
          .replace(escaper, function(match) { return '\\' + escapes[match]; });
  
        if (escape) {
          source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
        }
        if (interpolate) {
          source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
        }
        if (evaluate) {
          source += "';\n" + evaluate + "\n__p+='";
        }
        index = offset + match.length;
        return match;
      });
      source += "';\n";
  
      // If a variable is not specified, place data values in local scope.
      if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
  
      source = "var __t,__p='',__j=Array.prototype.join," +
        "print=function(){__p+=__j.call(arguments,'');};\n" +
        source + "return __p;\n";
  
      try {
        render = new Function(settings.variable || 'obj', '_', source);
      } catch (e) {
        e.source = source;
        throw e;
      }
  
      if (data) return render(data, _);
      var template = function(data) {
        return render.call(this, data, _);
      };
  
      // Provide the compiled function source as a convenience for precompilation.
      template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
  
      return template;
    };
  
    // Add a "chain" function, which will delegate to the wrapper.
    _.chain = function(obj) {
      return _(obj).chain();
    };
  
    // OOP
    // ---------------
    // If Underscore is called as a function, it returns a wrapped object that
    // can be used OO-style. This wrapper holds altered versions of all the
    // underscore functions. Wrapped objects may be chained.
  
    // Helper function to continue chaining intermediate results.
    var result = function(obj) {
      return this._chain ? _(obj).chain() : obj;
    };
  
    // Add all of the Underscore functions to the wrapper object.
    _.mixin(_);
  
    // Add all mutator Array functions to the wrapper.
    each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
      var method = ArrayProto[name];
      _.prototype[name] = function() {
        var obj = this._wrapped;
        method.apply(obj, arguments);
        if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
        return result.call(this, obj);
      };
    });
  
    // Add all accessor Array functions to the wrapper.
    each(['concat', 'join', 'slice'], function(name) {
      var method = ArrayProto[name];
      _.prototype[name] = function() {
        return result.call(this, method.apply(this._wrapped, arguments));
      };
    });
  
    _.extend(_.prototype, {
  
      // Start chaining a wrapped Underscore object.
      chain: function() {
        this._chain = true;
        return this;
      },
  
      // Extracts the result from a wrapped and chained object.
      value: function() {
        return this._wrapped;
      }
  
    });
  
    // AMD registration happens at the end for compatibility with AMD loaders
    // that may not enforce next-turn semantics on modules. Even though general
    // practice for AMD registration is to be anonymous, underscore registers
    // as a named module because, like jQuery, it is a base library that is
    // popular enough to be bundled in a third party lib, but not be part of
    // an AMD load request. Those cases could generate an error when an
    // anonymous define() is called outside of a loader request.
    if (typeof define === 'function' && define.amd) {
      define('underscore', [], function() {
        return _;
      });
    }
  }).call(this);
  
  },{}],18:[function(require,module,exports){
  /*! Hammer.JS - v1.0.7dev - 2014-02-18
   * http://eightmedia.github.com/hammer.js
   *
   * Copyright (c) 2014 Jorik Tangelder <j.tangelder@gmail.com>;
   * Licensed under the MIT license */
  
  (function(window, undefined) {
    'use strict';
  
  /**
   * Hammer
   * use this to create instances
   * @param   {HTMLElement}   element
   * @param   {Object}        options
   * @returns {Hammer.Instance}
   * @constructor
   */
  var Hammer = function(element, options) {
    return new Hammer.Instance(element, options || {});
  };
  
  // default settings
  Hammer.defaults = {
    // add styles and attributes to the element to prevent the browser from doing
    // its native behavior. this doesnt prevent the scrolling, but cancels
    // the contextmenu, tap highlighting etc
    // set to false to disable this
    stop_browser_behavior: {
      // this also triggers onselectstart=false for IE
      userSelect       : 'none',
      // this makes the element blocking in IE10 >, you could experiment with the value
      // see for more options this issue; https://github.com/EightMedia/hammer.js/issues/241
      touchAction      : 'none',
      touchCallout     : 'none',
      contentZooming   : 'none',
      userDrag         : 'none',
      tapHighlightColor: 'rgba(0,0,0,0)'
    }
  
    //
    // more settings are defined per gesture at gestures.js
    //
  };
  
  // detect touchevents
  Hammer.HAS_POINTEREVENTS = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
  Hammer.HAS_TOUCHEVENTS = ('ontouchstart' in window);
  
  // dont use mouseevents on mobile devices
  Hammer.MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android|silk/i;
  Hammer.NO_MOUSEEVENTS = Hammer.HAS_TOUCHEVENTS && window.navigator.userAgent.match(Hammer.MOBILE_REGEX);
  
  // eventtypes per touchevent (start, move, end)
  // are filled by Hammer.event.determineEventTypes on setup
  Hammer.EVENT_TYPES = {};
  
  // direction defines
  Hammer.DIRECTION_DOWN = 'down';
  Hammer.DIRECTION_LEFT = 'left';
  Hammer.DIRECTION_UP = 'up';
  Hammer.DIRECTION_RIGHT = 'right';
  
  // pointer type
  Hammer.POINTER_MOUSE = 'mouse';
  Hammer.POINTER_TOUCH = 'touch';
  Hammer.POINTER_PEN = 'pen';
  
  // interval in which Hammer recalculates current velocity in ms
  Hammer.UPDATE_VELOCITY_INTERVAL = 20;
  
  // touch event defines
  Hammer.EVENT_START = 'start';
  Hammer.EVENT_MOVE = 'move';
  Hammer.EVENT_END = 'end';
  
  // hammer document where the base events are added at
  Hammer.DOCUMENT = window.document;
  
  // plugins and gestures namespaces
  Hammer.plugins = Hammer.plugins || {};
  Hammer.gestures = Hammer.gestures || {};
  
  
  // if the window events are set...
  Hammer.READY = false;
  
  /**
   * setup events to detect gestures on the document
   */
  function setup() {
    if(Hammer.READY) {
      return;
    }
  
    // find what eventtypes we add listeners to
    Hammer.event.determineEventTypes();
  
    // Register all gestures inside Hammer.gestures
    Hammer.utils.each(Hammer.gestures, function(gesture){
      Hammer.detection.register(gesture);
    });
  
    // Add touch events on the document
    Hammer.event.onTouch(Hammer.DOCUMENT, Hammer.EVENT_MOVE, Hammer.detection.detect);
    Hammer.event.onTouch(Hammer.DOCUMENT, Hammer.EVENT_END, Hammer.detection.detect);
  
    // Hammer is ready...!
    Hammer.READY = true;
  }
  
  Hammer.utils = {
    /**
     * extend method,
     * also used for cloning when dest is an empty object
     * @param   {Object}    dest
     * @param   {Object}    src
     * @parm  {Boolean}  merge    do a merge
     * @returns {Object}    dest
     */
    extend: function extend(dest, src, merge) {
      for(var key in src) {
        if(dest[key] !== undefined && merge) {
          continue;
        }
        dest[key] = src[key];
      }
      return dest;
    },
  
  
    /**
     * for each
     * @param obj
     * @param iterator
     */
    each: function(obj, iterator, context) {
      var i, length;
      // native forEach on arrays
      if ('forEach' in obj) {
        obj.forEach(iterator, context);
      }
      // arrays
      else if(obj.length !== undefined) {
        for (i = 0, length = obj.length; i < length; i++) {
          if (iterator.call(context, obj[i], i, obj) === false) {
            return;
          }
        }
      }
      // objects
      else {
        for (i in obj) {
          if (obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj) === false) {
            return;
          }
        }
      }
    },
  
    /**
     * find if a node is in the given parent
     * used for event delegation tricks
     * @param   {HTMLElement}   node
     * @param   {HTMLElement}   parent
     * @returns {boolean}       has_parent
     */
    hasParent: function(node, parent) {
      while(node) {
        if(node == parent) {
          return true;
        }
        node = node.parentNode;
      }
      return false;
    },
  
  
    /**
     * get the center of all the touches
     * @param   {Array}     touches
     * @returns {Object}    center
     */
    getCenter: function getCenter(touches) {
      var valuesX = [], valuesY = [];
  
      Hammer.utils.each(touches, function(touch) {
        // I prefer clientX because it ignore the scrolling position
        valuesX.push(typeof touch.clientX !== 'undefined' ? touch.clientX : touch.pageX );
        valuesY.push(typeof touch.clientY !== 'undefined' ? touch.clientY : touch.pageY );
      });
  
      return {
        pageX: ((Math.min.apply(Math, valuesX) + Math.max.apply(Math, valuesX)) / 2),
        pageY: ((Math.min.apply(Math, valuesY) + Math.max.apply(Math, valuesY)) / 2)
      };
    },
  
  
    /**
     * calculate the velocity between two points
     * @param   {Number}    delta_time
     * @param   {Number}    delta_x
     * @param   {Number}    delta_y
     * @returns {Object}    velocity
     */
    getVelocity: function getVelocity(delta_time, delta_x, delta_y) {
      return {
        x: Math.abs(delta_x / delta_time) || 0,
        y: Math.abs(delta_y / delta_time) || 0
      };
    },
  
  
    /**
     * calculate the angle between two coordinates
     * @param   {Touch}     touch1
     * @param   {Touch}     touch2
     * @returns {Number}    angle
     */
    getAngle: function getAngle(touch1, touch2) {
      var y = touch2.pageY - touch1.pageY,
        x = touch2.pageX - touch1.pageX;
      return Math.atan2(y, x) * 180 / Math.PI;
    },
  
  
    /**
     * angle to direction define
     * @param   {Touch}     touch1
     * @param   {Touch}     touch2
     * @returns {String}    direction constant, like Hammer.DIRECTION_LEFT
     */
    getDirection: function getDirection(touch1, touch2) {
      var x = Math.abs(touch1.pageX - touch2.pageX),
        y = Math.abs(touch1.pageY - touch2.pageY);
  
      if(x >= y) {
        return touch1.pageX - touch2.pageX > 0 ? Hammer.DIRECTION_LEFT : Hammer.DIRECTION_RIGHT;
      }
      else {
        return touch1.pageY - touch2.pageY > 0 ? Hammer.DIRECTION_UP : Hammer.DIRECTION_DOWN;
      }
    },
  
  
    /**
     * calculate the distance between two touches
     * @param   {Touch}     touch1
     * @param   {Touch}     touch2
     * @returns {Number}    distance
     */
    getDistance: function getDistance(touch1, touch2) {
      var x = touch2.pageX - touch1.pageX,
        y = touch2.pageY - touch1.pageY;
      return Math.sqrt((x * x) + (y * y));
    },
  
  
    /**
     * calculate the scale factor between two touchLists (fingers)
     * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
     * @param   {Array}     start
     * @param   {Array}     end
     * @returns {Number}    scale
     */
    getScale: function getScale(start, end) {
      // need two fingers...
      if(start.length >= 2 && end.length >= 2) {
        return this.getDistance(end[0], end[1]) /
          this.getDistance(start[0], start[1]);
      }
      return 1;
    },
  
  
    /**
     * calculate the rotation degrees between two touchLists (fingers)
     * @param   {Array}     start
     * @param   {Array}     end
     * @returns {Number}    rotation
     */
    getRotation: function getRotation(start, end) {
      // need two fingers
      if(start.length >= 2 && end.length >= 2) {
        return this.getAngle(end[1], end[0]) -
          this.getAngle(start[1], start[0]);
      }
      return 0;
    },
  
  
    /**
     * boolean if the direction is vertical
     * @param    {String}    direction
     * @returns  {Boolean}   is_vertical
     */
    isVertical: function isVertical(direction) {
      return (direction == Hammer.DIRECTION_UP || direction == Hammer.DIRECTION_DOWN);
    },
  
  
    /**
     * stop browser default behavior with css props
     * @param   {HtmlElement}   element
     * @param   {Object}        css_props
     */
    stopDefaultBrowserBehavior: function stopDefaultBrowserBehavior(element, css_props) {
      if(!css_props || !element || !element.style) {
        return;
      }
  
      // with css properties for modern browsers
      Hammer.utils.each(['webkit', 'khtml', 'moz', 'Moz', 'ms', 'o', ''], function(vendor) {
        Hammer.utils.each(css_props, function(value, prop) {
            // vender prefix at the property
            if(vendor) {
              prop = vendor + prop.substring(0, 1).toUpperCase() + prop.substring(1);
            }
            // set the style
            if(prop in element.style) {
              element.style[prop] = value;
            }
        });
      });
  
      // also the disable onselectstart
      if(css_props.userSelect == 'none') {
        element.onselectstart = function() {
          return false;
        };
      }
  
      // and disable ondragstart
      if(css_props.userDrag == 'none') {
        element.ondragstart = function() {
          return false;
        };
      }
    },
  
  
    /**
     * reverts all changes made by 'stopDefaultBrowserBehavior'
     * @param   {HtmlElement}   element
     * @param   {Object}        css_props
     */
    startDefaultBrowserBehavior: function startDefaultBrowserBehavior(element, css_props) {
      if(!css_props || !element || !element.style) {
        return;
      }
  
      // with css properties for modern browsers
      Hammer.utils.each(['webkit', 'khtml', 'moz', 'Moz', 'ms', 'o', ''], function(vendor) {
        Hammer.utils.each(css_props, function(value, prop) {
            // vender prefix at the property
            if(vendor) {
              prop = vendor + prop.substring(0, 1).toUpperCase() + prop.substring(1);
            }
            // reset the style
            if(prop in element.style) {
              element.style[prop] = '';
            }
        });
      });
  
      // also the enable onselectstart
      if(css_props.userSelect == 'none') {
        element.onselectstart = null;
      }
  
      // and enable ondragstart
      if(css_props.userDrag == 'none') {
        element.ondragstart = null;
      }
    }
  };
  
  
  /**
   * create new hammer instance
   * all methods should return the instance itself, so it is chainable.
   * @param   {HTMLElement}       element
   * @param   {Object}            [options={}]
   * @returns {Hammer.Instance}
   * @constructor
   */
  Hammer.Instance = function(element, options) {
    var self = this;
  
    // setup HammerJS window events and register all gestures
    // this also sets up the default options
    setup();
  
    this.element = element;
  
    // start/stop detection option
    this.enabled = true;
  
    // merge options
    this.options = Hammer.utils.extend(
      Hammer.utils.extend({}, Hammer.defaults),
      options || {});
  
    // add some css to the element to prevent the browser from doing its native behavoir
    if(this.options.stop_browser_behavior) {
      Hammer.utils.stopDefaultBrowserBehavior(this.element, this.options.stop_browser_behavior);
    }
  
    // start detection on touchstart
    this._eventStartHandler = Hammer.event.onTouch(element, Hammer.EVENT_START, function(ev) {
      if(self.enabled) {
        Hammer.detection.startDetect(self, ev);
      }
    });
  
    // keep a list of user event handlers which needs to be removed when calling 'dispose'
    this._eventHandler = [];
  
    // return instance
    return this;
  };
  
  
  Hammer.Instance.prototype = {
    /**
     * bind events to the instance
     * @param   {String}      gesture
     * @param   {Function}    handler
     * @returns {Hammer.Instance}
     */
    on: function onEvent(gesture, handler) {
      var gestures = gesture.split(' ');
      Hammer.utils.each(gestures, function(gesture) {
        this.element.addEventListener(gesture, handler, false);
        this._eventHandler.push({ gesture: gesture, handler: handler });
      }, this);
      return this;
    },
  
  
    /**
     * unbind events to the instance
     * @param   {String}      gesture
     * @param   {Function}    handler
     * @returns {Hammer.Instance}
     */
    off: function offEvent(gesture, handler) {
      var gestures = gesture.split(' ');
      Hammer.utils.each(gestures, function(gesture) {
        this.element.removeEventListener(gesture, handler, false);
  
        // remove the event handler from the internal list
        var index = -1;
        Hammer.utils.each(this._eventHandler, function(eventHandler, i) {
          if (index === -1 && eventHandler.gesture === gesture && eventHandler.handler === handler) {
            index = i;
          }
        }, this);
  
        if (index > -1) {
          this._eventHandler.splice(index, 1);
        }
      }, this);
      return this;
    },
  
  
    /**
     * trigger gesture event
     * @param   {String}      gesture
     * @param   {Object}      [eventData]
     * @returns {Hammer.Instance}
     */
    trigger: function triggerEvent(gesture, eventData) {
      // optional
      if(!eventData) {
        eventData = {};
      }
  
      // create DOM event
      var event = Hammer.DOCUMENT.createEvent('Event');
      event.initEvent(gesture, true, true);
      event.gesture = eventData;
  
      // trigger on the target if it is in the instance element,
      // this is for event delegation tricks
      var element = this.element;
      if(Hammer.utils.hasParent(eventData.target, element)) {
        element = eventData.target;
      }
  
      element.dispatchEvent(event);
      return this;
    },
  
  
    /**
     * enable of disable hammer.js detection
     * @param   {Boolean}   state
     * @returns {Hammer.Instance}
     */
    enable: function enable(state) {
      this.enabled = state;
      return this;
    },
  
  
    /**
     * dispose this hammer instance
     * @returns {Hammer.Instance}
     */
    dispose: function dispose() {
  
      // undo all changes made by stop_browser_behavior
      if(this.options.stop_browser_behavior) {
        Hammer.utils.startDefaultBrowserBehavior(this.element, this.options.stop_browser_behavior);
      }
  
      // unbind all custom event handlers
      Hammer.utils.each(this._eventHandler, function(eventHandler) {
        this.element.removeEventListener(eventHandler.gesture, eventHandler.handler, false);
      }, this);
      this._eventHandler.length = 0;
  
      // unbind the start event listener
      Hammer.event.unbindDom(this.element, Hammer.EVENT_TYPES[Hammer.EVENT_START], this._eventStartHandler);
      return this;
    }
  };
  
  
  /**
   * this holds the last move event,
   * used to fix empty touchend issue
   * see the onTouch event for an explanation
   * @type {Object}
   */
  var last_move_event = null;
  
  
  /**
   * when the mouse is hold down, this is true
   * @type {Boolean}
   */
  var enable_detect = false;
  
  
  /**
   * when touch events have been fired, this is true
   * @type {Boolean}
   */
  var touch_triggered = false;
  
  
  Hammer.event = {
    /**
     * simple addEventListener
     * @param   {HTMLElement}   element
     * @param   {String}        type
     * @param   {Function}      handler
     */
    bindDom: function(element, type, handler) {
      var types = type.split(' ');
      Hammer.utils.each(types, function(type){
        element.addEventListener(type, handler, false);
      });
    },
  
  
    /**
     * simple removeEventListener
     * @param   {HTMLElement}   element
     * @param   {String}        type
     * @param   {Function}      handler
     */
    unbindDom: function(element, type, handler) {
      var types = type.split(' ');
      Hammer.utils.each(types, function(type){
        element.removeEventListener(type, handler, false);
      });
    },
  
  
    /**
     * touch events with mouse fallback
     * @param   {HTMLElement}   element
     * @param   {String}        eventType        like Hammer.EVENT_MOVE
     * @param   {Function}      handler
     */
    onTouch: function onTouch(element, eventType, handler) {
      var self = this;
  
      var fn = function bindDomOnTouch(ev) {
        var sourceEventType = ev.type.toLowerCase();
  
        // onmouseup, but when touchend has been fired we do nothing.
        // this is for touchdevices which also fire a mouseup on touchend
        if(sourceEventType.match(/mouse/) && touch_triggered) {
          return;
        }
  
        // mousebutton must be down or a touch event
        else if(sourceEventType.match(/touch/) ||   // touch events are always on screen
          sourceEventType.match(/pointerdown/) || // pointerevents touch
          (sourceEventType.match(/mouse/) && ev.which === 1)   // mouse is pressed
          ) {
          enable_detect = true;
        }
  
        // mouse isn't pressed
        else if(sourceEventType.match(/mouse/) && !ev.which) {
          enable_detect = false;
        }
  
  
        // we are in a touch event, set the touch triggered bool to true,
        // this for the conflicts that may occur on ios and android
        if(sourceEventType.match(/touch|pointer/)) {
          touch_triggered = true;
        }
  
        // count the total touches on the screen
        var count_touches = 0;
  
        // when touch has been triggered in this detection session
        // and we are now handling a mouse event, we stop that to prevent conflicts
        if(enable_detect) {
          // update pointerevent
          if(Hammer.HAS_POINTEREVENTS && eventType != Hammer.EVENT_END) {
            count_touches = Hammer.PointerEvent.updatePointer(eventType, ev);
          }
          // touch
          else if(sourceEventType.match(/touch/)) {
            count_touches = ev.touches.length;
          }
          // mouse
          else if(!touch_triggered) {
            count_touches = sourceEventType.match(/up/) ? 0 : 1;
          }
  
          // if we are in a end event, but when we remove one touch and
          // we still have enough, set eventType to move
          if(count_touches > 0 && eventType == Hammer.EVENT_END) {
            eventType = Hammer.EVENT_MOVE;
          }
          // no touches, force the end event
          else if(!count_touches) {
            eventType = Hammer.EVENT_END;
          }
  
          // store the last move event
          if(count_touches || last_move_event === null) {
            last_move_event = ev;
          }
  
          // trigger the handler
          handler.call(Hammer.detection, self.collectEventData(element, eventType, self.getTouchList(last_move_event, eventType), ev));
  
          // remove pointerevent from list
          if(Hammer.HAS_POINTEREVENTS && eventType == Hammer.EVENT_END) {
            count_touches = Hammer.PointerEvent.updatePointer(eventType, ev);
          }
        }
  
        // on the end we reset everything
        if(!count_touches) {
          last_move_event = null;
          enable_detect = false;
          touch_triggered = false;
          Hammer.PointerEvent.reset();
        }
      };
  
      this.bindDom(element, Hammer.EVENT_TYPES[eventType], fn);
  
      // return the bound function to be able to unbind it later
      return fn;
      },
  
  
    /**
     * we have different events for each device/browser
     * determine what we need and set them in the Hammer.EVENT_TYPES constant
     */
    determineEventTypes: function determineEventTypes() {
      // determine the eventtype we want to set
      var types;
  
      // pointerEvents magic
      if(Hammer.HAS_POINTEREVENTS) {
        types = Hammer.PointerEvent.getEvents();
      }
      // on Android, iOS, blackberry, windows mobile we dont want any mouseevents
      else if(Hammer.NO_MOUSEEVENTS) {
        types = [
          'touchstart',
          'touchmove',
          'touchend touchcancel'];
      }
      // for non pointer events browsers and mixed browsers,
      // like chrome on windows8 touch laptop
      else {
        types = [
          'touchstart mousedown',
          'touchmove mousemove',
          'touchend touchcancel mouseup'];
      }
  
      Hammer.EVENT_TYPES[Hammer.EVENT_START] = types[0];
      Hammer.EVENT_TYPES[Hammer.EVENT_MOVE] = types[1];
      Hammer.EVENT_TYPES[Hammer.EVENT_END] = types[2];
    },
  
  
    /**
     * create touchlist depending on the event
     * @param   {Object}    ev
     * @param   {String}    eventType   used by the fakemultitouch plugin
     */
    getTouchList: function getTouchList(ev/*, eventType*/) {
      // get the fake pointerEvent touchlist
      if(Hammer.HAS_POINTEREVENTS) {
        return Hammer.PointerEvent.getTouchList();
      }
      // get the touchlist
      else if(ev.touches) {
        return ev.touches;
      }
      // make fake touchlist from mouse position
      else {
        ev.identifier = 1;
        return [ev];
      }
    },
  
  
    /**
     * collect event data for Hammer js
     * @param   {HTMLElement}   element
     * @param   {String}        eventType        like Hammer.EVENT_MOVE
     * @param   {Object}        eventData
     */
    collectEventData: function collectEventData(element, eventType, touches, ev) {
      // find out pointerType
      var pointerType = Hammer.POINTER_TOUCH;
      if(ev.type.match(/mouse/) || Hammer.PointerEvent.matchType(Hammer.POINTER_MOUSE, ev)) {
        pointerType = Hammer.POINTER_MOUSE;
      }
  
      return {
        center     : Hammer.utils.getCenter(touches),
        timeStamp  : new Date().getTime(),
        target     : ev.target,
        touches    : touches,
        eventType  : eventType,
        pointerType: pointerType,
        srcEvent   : ev,
  
        /**
         * prevent the browser default actions
         * mostly used to disable scrolling of the browser
         */
        preventDefault: function() {
          if(this.srcEvent.preventManipulation) {
            this.srcEvent.preventManipulation();
          }
  
          if(this.srcEvent.preventDefault) {
            this.srcEvent.preventDefault();
          }
        },
  
        /**
         * stop bubbling the event up to its parents
         */
        stopPropagation: function() {
          this.srcEvent.stopPropagation();
        },
  
        /**
         * immediately stop gesture detection
         * might be useful after a swipe was detected
         * @return {*}
         */
        stopDetect: function() {
          return Hammer.detection.stopDetect();
        }
      };
    }
  };
  
  Hammer.PointerEvent = {
    /**
     * holds all pointers
     * @type {Object}
     */
    pointers: {},
  
    /**
     * get a list of pointers
     * @returns {Array}     touchlist
     */
    getTouchList: function() {
      var self = this;
      var touchlist = [];
  
      // we can use forEach since pointerEvents only is in IE10
      Hammer.utils.each(self.pointers, function(pointer){
        touchlist.push(pointer);
      });
  
      return touchlist;
    },
  
    /**
     * update the position of a pointer
     * @param   {String}   type             Hammer.EVENT_END
     * @param   {Object}   pointerEvent
     */
    updatePointer: function(type, pointerEvent) {
      if(type == Hammer.EVENT_END) {
        delete this.pointers[pointerEvent.pointerId];
      }
      else {
        pointerEvent.identifier = pointerEvent.pointerId;
        this.pointers[pointerEvent.pointerId] = pointerEvent;
      }
  
      return Object.keys(this.pointers).length;
    },
  
    /**
     * check if ev matches pointertype
     * @param   {String}        pointerType     Hammer.POINTER_MOUSE
     * @param   {PointerEvent}  ev
     */
    matchType: function(pointerType, ev) {
      if(!ev.pointerType) {
        return false;
      }
  
      var pt = ev.pointerType,
        types = {};
      types[Hammer.POINTER_MOUSE] = (pt === ev.MSPOINTER_TYPE_MOUSE || pt === Hammer.POINTER_MOUSE);
      types[Hammer.POINTER_TOUCH] = (pt === ev.MSPOINTER_TYPE_TOUCH || pt === Hammer.POINTER_TOUCH);
      types[Hammer.POINTER_PEN] = (pt === ev.MSPOINTER_TYPE_PEN || pt === Hammer.POINTER_PEN);
      return types[pointerType];
    },
  
  
    /**
     * get events
     */
    getEvents: function() {
      return [
        'pointerdown MSPointerDown',
        'pointermove MSPointerMove',
        'pointerup pointercancel MSPointerUp MSPointerCancel'
      ];
    },
  
    /**
     * reset the list
     */
    reset: function() {
      this.pointers = {};
    }
  };
  
  
  Hammer.detection = {
    // contains all registred Hammer.gestures in the correct order
    gestures: [],
  
    // data of the current Hammer.gesture detection session
    current : null,
  
    // the previous Hammer.gesture session data
    // is a full clone of the previous gesture.current object
    previous: null,
  
    // when this becomes true, no gestures are fired
    stopped : false,
  
  
    /**
     * start Hammer.gesture detection
     * @param   {Hammer.Instance}   inst
     * @param   {Object}            eventData
     */
    startDetect: function startDetect(inst, eventData) {
      // already busy with a Hammer.gesture detection on an element
      if(this.current) {
        return;
      }
  
      this.stopped = false;
  
      this.current = {
        inst      : inst, // reference to HammerInstance we're working for
        startEvent: Hammer.utils.extend({}, eventData), // start eventData for distances, timing etc
        lastEvent : false, // last eventData
        lastVEvent: false, // last eventData for velocity.
        velocity  : false, // current velocity
        name      : '' // current gesture we're in/detected, can be 'tap', 'hold' etc
      };
  
      this.detect(eventData);
    },
  
  
    /**
     * Hammer.gesture detection
     * @param   {Object}    eventData
     */
    detect: function detect(eventData) {
      if(!this.current || this.stopped) {
        return;
      }
  
      // extend event data with calculations about scale, distance etc
      eventData = this.extendEventData(eventData);
  
      // instance options
      var inst_options = this.current.inst.options;
  
      // call Hammer.gesture handlers
      Hammer.utils.each(this.gestures, function(gesture) {
        // only when the instance options have enabled this gesture
        if(!this.stopped && inst_options[gesture.name] !== false) {
          // if a handler returns false, we stop with the detection
          if(gesture.handler.call(gesture, eventData, this.current.inst) === false) {
            this.stopDetect();
            return false;
          }
        }
      }, this);
  
      // store as previous event event
      if(this.current) {
        this.current.lastEvent = eventData;
      }
  
      // endevent, but not the last touch, so dont stop
      if(eventData.eventType == Hammer.EVENT_END && !eventData.touches.length - 1) {
        this.stopDetect();
      }
  
      return eventData;
    },
  
  
    /**
     * clear the Hammer.gesture vars
     * this is called on endDetect, but can also be used when a final Hammer.gesture has been detected
     * to stop other Hammer.gestures from being fired
     */
    stopDetect: function stopDetect() {
      // clone current data to the store as the previous gesture
      // used for the double tap gesture, since this is an other gesture detect session
      this.previous = Hammer.utils.extend({}, this.current);
  
      // reset the current
      this.current = null;
  
      // stopped!
      this.stopped = true;
    },
  
  
    /**
     * extend eventData for Hammer.gestures
     * @param   {Object}   ev
     * @returns {Object}   ev
     */
    extendEventData: function extendEventData(ev) {
      var startEv = this.current.startEvent,
          lastVEv = this.current.lastVEvent;
  
      // if the touches change, set the new touches over the startEvent touches
      // this because touchevents don't have all the touches on touchstart, or the
      // user must place his fingers at the EXACT same time on the screen, which is not realistic
      // but, sometimes it happens that both fingers are touching at the EXACT same time
      if(startEv && (ev.touches.length != startEv.touches.length || ev.touches === startEv.touches)) {
        // extend 1 level deep to get the touchlist with the touch objects
        startEv.touches = [];
        Hammer.utils.each(ev.touches, function(touch) {
          startEv.touches.push(Hammer.utils.extend({}, touch));
        });
      }
  
      var delta_time = ev.timeStamp - startEv.timeStamp
        , delta_x = ev.center.pageX - startEv.center.pageX
        , delta_y = ev.center.pageY - startEv.center.pageY
        , interimAngle
        , interimDirection
        , velocity = this.current.velocity;
    
      if (lastVEv !== false && ev.timeStamp - lastVEv.timeStamp > Hammer.UPDATE_VELOCITY_INTERVAL) {
    
          velocity =  Hammer.utils.getVelocity(ev.timeStamp - lastVEv.timeStamp, ev.center.pageX - lastVEv.center.pageX, ev.center.pageY - lastVEv.center.pageY);
          this.current.lastVEvent = ev;
    
          if (velocity.x > 0 && velocity.y > 0) {
              this.current.velocity = velocity;
          }
    
      } else if(this.current.velocity === false) {
          velocity = Hammer.utils.getVelocity(delta_time, delta_x, delta_y);
          this.current.velocity = velocity;
          this.current.lastVEvent = ev;
      }
  
      // end events (e.g. dragend) don't have useful values for interimDirection & interimAngle
      // because the previous event has exactly the same coordinates
      // so for end events, take the previous values of interimDirection & interimAngle
      // instead of recalculating them and getting a spurious '0'
      if(ev.eventType === 'end') {
        interimAngle = this.current.lastEvent && this.current.lastEvent.interimAngle;
        interimDirection = this.current.lastEvent && this.current.lastEvent.interimDirection;
      }
      else {
        interimAngle = this.current.lastEvent && Hammer.utils.getAngle(this.current.lastEvent.center, ev.center);
        interimDirection = this.current.lastEvent && Hammer.utils.getDirection(this.current.lastEvent.center, ev.center);
      }
  
      Hammer.utils.extend(ev, {
        deltaTime: delta_time,
  
        deltaX: delta_x,
        deltaY: delta_y,
  
        velocityX: velocity.x,
        velocityY: velocity.y,
  
        distance: Hammer.utils.getDistance(startEv.center, ev.center),
  
        angle: Hammer.utils.getAngle(startEv.center, ev.center),
        interimAngle: interimAngle,
  
        direction: Hammer.utils.getDirection(startEv.center, ev.center),
        interimDirection: interimDirection,
  
        scale: Hammer.utils.getScale(startEv.touches, ev.touches),
        rotation: Hammer.utils.getRotation(startEv.touches, ev.touches),
  
        startEvent: startEv
      });
  
      return ev;
    },
  
  
    /**
     * register new gesture
     * @param   {Object}    gesture object, see gestures.js for documentation
     * @returns {Array}     gestures
     */
    register: function register(gesture) {
      // add an enable gesture options if there is no given
      var options = gesture.defaults || {};
      if(options[gesture.name] === undefined) {
        options[gesture.name] = true;
      }
  
      // extend Hammer default options with the Hammer.gesture options
      Hammer.utils.extend(Hammer.defaults, options, true);
  
      // set its index
      gesture.index = gesture.index || 1000;
  
      // add Hammer.gesture to the list
      this.gestures.push(gesture);
  
      // sort the list by index
      this.gestures.sort(function(a, b) {
        if(a.index < b.index) { return -1; }
        if(a.index > b.index) { return 1; }
        return 0;
      });
  
      return this.gestures;
    }
  };
  
  
  /**
   * Drag
   * Move with x fingers (default 1) around on the page. Blocking the scrolling when
   * moving left and right is a good practice. When all the drag events are blocking
   * you disable scrolling on that area.
   * @events  drag, drapleft, dragright, dragup, dragdown
   */
  Hammer.gestures.Drag = {
    name     : 'drag',
    index    : 50,
    defaults : {
      drag_min_distance            : 10,
  
      // Set correct_for_drag_min_distance to true to make the starting point of the drag
      // be calculated from where the drag was triggered, not from where the touch started.
      // Useful to avoid a jerk-starting drag, which can make fine-adjustments
      // through dragging difficult, and be visually unappealing.
      correct_for_drag_min_distance: true,
  
      // set 0 for unlimited, but this can conflict with transform
      drag_max_touches             : 1,
  
      // prevent default browser behavior when dragging occurs
      // be careful with it, it makes the element a blocking element
      // when you are using the drag gesture, it is a good practice to set this true
      drag_block_horizontal        : false,
      drag_block_vertical          : false,
  
      // drag_lock_to_axis keeps the drag gesture on the axis that it started on,
      // It disallows vertical directions if the initial direction was horizontal, and vice versa.
      drag_lock_to_axis            : false,
  
      // drag lock only kicks in when distance > drag_lock_min_distance
      // This way, locking occurs only when the distance has become large enough to reliably determine the direction
      drag_lock_min_distance       : 25
    },
  
    triggered: false,
    handler  : function dragGesture(ev, inst) {
      // current gesture isnt drag, but dragged is true
      // this means an other gesture is busy. now call dragend
      if(Hammer.detection.current.name != this.name && this.triggered) {
        inst.trigger(this.name + 'end', ev);
        this.triggered = false;
        return;
      }
  
      // max touches
      if(inst.options.drag_max_touches > 0 &&
        ev.touches.length > inst.options.drag_max_touches) {
        return;
      }
  
      switch(ev.eventType) {
        case Hammer.EVENT_START:
          this.triggered = false;
          break;
  
        case Hammer.EVENT_MOVE:
          // when the distance we moved is too small we skip this gesture
          // or we can be already in dragging
          if(ev.distance < inst.options.drag_min_distance &&
            Hammer.detection.current.name != this.name) {
            return;
          }
  
          // we are dragging!
          if(Hammer.detection.current.name != this.name) {
            Hammer.detection.current.name = this.name;
            if(inst.options.correct_for_drag_min_distance && ev.distance > 0) {
              // When a drag is triggered, set the event center to drag_min_distance pixels from the original event center.
              // Without this correction, the dragged distance would jumpstart at drag_min_distance pixels instead of at 0.
              // It might be useful to save the original start point somewhere
              var factor = Math.abs(inst.options.drag_min_distance / ev.distance);
              Hammer.detection.current.startEvent.center.pageX += ev.deltaX * factor;
              Hammer.detection.current.startEvent.center.pageY += ev.deltaY * factor;
  
              // recalculate event data using new start point
              ev = Hammer.detection.extendEventData(ev);
            }
          }
  
          // lock drag to axis?
          if(Hammer.detection.current.lastEvent.drag_locked_to_axis || (inst.options.drag_lock_to_axis && inst.options.drag_lock_min_distance <= ev.distance)) {
            ev.drag_locked_to_axis = true;
          }
          var last_direction = Hammer.detection.current.lastEvent.direction;
          if(ev.drag_locked_to_axis && last_direction !== ev.direction) {
            // keep direction on the axis that the drag gesture started on
            if(Hammer.utils.isVertical(last_direction)) {
              ev.direction = (ev.deltaY < 0) ? Hammer.DIRECTION_UP : Hammer.DIRECTION_DOWN;
            }
            else {
              ev.direction = (ev.deltaX < 0) ? Hammer.DIRECTION_LEFT : Hammer.DIRECTION_RIGHT;
            }
          }
  
          // first time, trigger dragstart event
          if(!this.triggered) {
            inst.trigger(this.name + 'start', ev);
            this.triggered = true;
          }
  
          // trigger normal event
          inst.trigger(this.name, ev);
  
          // direction event, like dragdown
          inst.trigger(this.name + ev.direction, ev);
  
          // block the browser events
          if((inst.options.drag_block_vertical && Hammer.utils.isVertical(ev.direction)) ||
            (inst.options.drag_block_horizontal && !Hammer.utils.isVertical(ev.direction))) {
            ev.preventDefault();
          }
          break;
  
        case Hammer.EVENT_END:
          // trigger dragend
          if(this.triggered) {
            inst.trigger(this.name + 'end', ev);
          }
  
          this.triggered = false;
          break;
      }
    }
  };
  
  /**
   * Hold
   * Touch stays at the same place for x time
   * @events  hold
   */
  Hammer.gestures.Hold = {
    name    : 'hold',
    index   : 10,
    defaults: {
      hold_timeout  : 500,
      hold_threshold: 1
    },
    timer   : null,
    handler : function holdGesture(ev, inst) {
      switch(ev.eventType) {
        case Hammer.EVENT_START:
          // clear any running timers
          clearTimeout(this.timer);
  
          // set the gesture so we can check in the timeout if it still is
          Hammer.detection.current.name = this.name;
  
          // set timer and if after the timeout it still is hold,
          // we trigger the hold event
          this.timer = setTimeout(function() {
            if(Hammer.detection.current.name == 'hold') {
              inst.trigger('hold', ev);
            }
          }, inst.options.hold_timeout);
          break;
  
        // when you move or end we clear the timer
        case Hammer.EVENT_MOVE:
          if(ev.distance > inst.options.hold_threshold) {
            clearTimeout(this.timer);
          }
          break;
  
        case Hammer.EVENT_END:
          clearTimeout(this.timer);
          break;
      }
    }
  };
  
  /**
   * Release
   * Called as last, tells the user has released the screen
   * @events  release
   */
  Hammer.gestures.Release = {
    name   : 'release',
    index  : Infinity,
    handler: function releaseGesture(ev, inst) {
      if(ev.eventType == Hammer.EVENT_END) {
        inst.trigger(this.name, ev);
      }
    }
  };
  
  /**
   * Swipe
   * triggers swipe events when the end velocity is above the threshold
   * @events  swipe, swipeleft, swiperight, swipeup, swipedown
   */
  Hammer.gestures.Swipe = {
    name    : 'swipe',
    index   : 40,
    defaults: {
      // set 0 for unlimited, but this can conflict with transform
      swipe_min_touches: 1,
      swipe_max_touches: 1,
      swipe_velocity   : 0.7
    },
    handler : function swipeGesture(ev, inst) {
      if(ev.eventType == Hammer.EVENT_END) {
        // max touches
        if(inst.options.swipe_max_touches > 0 &&
          ev.touches.length < inst.options.swipe_min_touches &&
          ev.touches.length > inst.options.swipe_max_touches) {
          return;
        }
  
        // when the distance we moved is too small we skip this gesture
        // or we can be already in dragging
        if(ev.velocityX > inst.options.swipe_velocity ||
          ev.velocityY > inst.options.swipe_velocity) {
          // trigger swipe events
          inst.trigger(this.name, ev);
          inst.trigger(this.name + ev.direction, ev);
        }
      }
    }
  };
  
  /**
   * Tap/DoubleTap
   * Quick touch at a place or double at the same place
   * @events  tap, doubletap
   */
  Hammer.gestures.Tap = {
    name    : 'tap',
    index   : 100,
    defaults: {
      tap_max_touchtime : 250,
      tap_max_distance  : 10,
      tap_always        : true,
      doubletap_distance: 20,
      doubletap_interval: 300
    },
    handler : function tapGesture(ev, inst) {
      if(ev.eventType == Hammer.EVENT_MOVE && !Hammer.detection.current.reachedTapMaxDistance) {
        //Track the distance we've moved. If it's above the max ONCE, remember that (fixes #406).
        Hammer.detection.current.reachedTapMaxDistance = (ev.distance > inst.options.tap_max_distance);
      } else if(ev.eventType == Hammer.EVENT_END && ev.srcEvent.type != 'touchcancel') {
        // previous gesture, for the double tap since these are two different gesture detections
        var prev = Hammer.detection.previous,
          did_doubletap = false;
  
        // when the touchtime is higher then the max touch time
        // or when the moving distance is too much
        if(Hammer.detection.current.reachedTapMaxDistance || ev.deltaTime > inst.options.tap_max_touchtime) {
          return;
        }
  
        // check if double tap
        if(prev && prev.name == 'tap' &&
          (ev.timeStamp - prev.lastEvent.timeStamp) < inst.options.doubletap_interval &&
          ev.distance < inst.options.doubletap_distance) {
          inst.trigger('doubletap', ev);
          did_doubletap = true;
        }
  
        // do a single tap
        if(!did_doubletap || inst.options.tap_always) {
          Hammer.detection.current.name = 'tap';
          inst.trigger(Hammer.detection.current.name, ev);
        }
      }
    }
  };
  
  /**
   * Touch
   * Called as first, tells the user has touched the screen
   * @events  touch
   */
  Hammer.gestures.Touch = {
    name    : 'touch',
    index   : -Infinity,
    defaults: {
      // call preventDefault at touchstart, and makes the element blocking by
      // disabling the scrolling of the page, but it improves gestures like
      // transforming and dragging.
      // be careful with using this, it can be very annoying for users to be stuck
      // on the page
      prevent_default    : false,
  
      // disable mouse events, so only touch (or pen!) input triggers events
      prevent_mouseevents: false
    },
    handler : function touchGesture(ev, inst) {
      if(inst.options.prevent_mouseevents && ev.pointerType == Hammer.POINTER_MOUSE) {
        ev.stopDetect();
        return;
      }
  
      if(inst.options.prevent_default) {
        ev.preventDefault();
      }
  
      if(ev.eventType == Hammer.EVENT_START) {
        inst.trigger(this.name, ev);
      }
    }
  };
  
  
  /**
   * Transform
   * User want to scale or rotate with 2 fingers
   * @events  transform, pinch, pinchin, pinchout, rotate
   */
  Hammer.gestures.Transform = {
    name     : 'transform',
    index    : 45,
    defaults : {
      // factor, no scale is 1, zoomin is to 0 and zoomout until higher then 1
      transform_min_scale   : 0.01,
      // rotation in degrees
      transform_min_rotation: 1,
      // prevent default browser behavior when two touches are on the screen
      // but it makes the element a blocking element
      // when you are using the transform gesture, it is a good practice to set this true
      transform_always_block: false
    },
    triggered: false,
    handler  : function transformGesture(ev, inst) {
      // current gesture isnt drag, but dragged is true
      // this means an other gesture is busy. now call dragend
      if(Hammer.detection.current.name != this.name && this.triggered) {
        inst.trigger(this.name + 'end', ev);
        this.triggered = false;
        return;
      }
  
      // atleast multitouch
      if(ev.touches.length < 2) {
        return;
      }
  
      // prevent default when two fingers are on the screen
      if(inst.options.transform_always_block) {
        ev.preventDefault();
      }
  
      switch(ev.eventType) {
        case Hammer.EVENT_START:
          this.triggered = false;
          break;
  
        case Hammer.EVENT_MOVE:
          var scale_threshold = Math.abs(1 - ev.scale);
          var rotation_threshold = Math.abs(ev.rotation);
  
          // when the distance we moved is too small we skip this gesture
          // or we can be already in dragging
          if(scale_threshold < inst.options.transform_min_scale &&
            rotation_threshold < inst.options.transform_min_rotation) {
            return;
          }
  
          // we are transforming!
          Hammer.detection.current.name = this.name;
  
          // first time, trigger dragstart event
          if(!this.triggered) {
            inst.trigger(this.name + 'start', ev);
            this.triggered = true;
          }
  
          inst.trigger(this.name, ev); // basic transform event
  
          // trigger rotate event
          if(rotation_threshold > inst.options.transform_min_rotation) {
            inst.trigger('rotate', ev);
          }
  
          // trigger pinch event
          if(scale_threshold > inst.options.transform_min_scale) {
            inst.trigger('pinch', ev);
            inst.trigger('pinch' + ((ev.scale < 1) ? 'in' : 'out'), ev);
          }
          break;
  
        case Hammer.EVENT_END:
          // trigger dragend
          if(this.triggered) {
            inst.trigger(this.name + 'end', ev);
          }
  
          this.triggered = false;
          break;
      }
    }
  };
  
    // Based off Lo-Dash's excellent UMD wrapper (slightly modified) - https://github.com/bestiejs/lodash/blob/master/lodash.js#L5515-L5543
    // some AMD build optimizers, like r.js, check for specific condition patterns like the following:
    if(typeof define == 'function' && define.amd) {
      // define as an anonymous module
      define(function() { return Hammer; });
    }
  
    // check for `exports` after `define` in case a build optimizer adds an `exports` object
    else if(typeof module === 'object' && module.exports) {
      module.exports = Hammer;
    }
  
    else {
      window.Hammer = Hammer;
    }
  
  })(window);
  
  },{}],19:[function(require,module,exports){
  // Copyright Joyent, Inc. and other Node contributors.
  //
  // Permission is hereby granted, free of charge, to any person obtaining a
  // copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to permit
  // persons to whom the Software is furnished to do so, subject to the
  // following conditions:
  //
  // The above copyright notice and this permission notice shall be included
  // in all copies or substantial portions of the Software.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  function EventEmitter() {
    this._events = this._events || {};
    this._maxListeners = this._maxListeners || undefined;
  }
  module.exports = EventEmitter;
  
  // Backwards-compat with node 0.10.x
  EventEmitter.EventEmitter = EventEmitter;
  
  EventEmitter.prototype._events = undefined;
  EventEmitter.prototype._maxListeners = undefined;
  
  // By default EventEmitters will print a warning if more than 10 listeners are
  // added to it. This is a useful default which helps finding memory leaks.
  EventEmitter.defaultMaxListeners = 10;
  
  // Obviously not all Emitters should be limited to 10. This function allows
  // that to be increased. Set to zero for unlimited.
  EventEmitter.prototype.setMaxListeners = function(n) {
    if (!isNumber(n) || n < 0 || isNaN(n))
      throw TypeError('n must be a positive number');
    this._maxListeners = n;
    return this;
  };
  
  EventEmitter.prototype.emit = function(type) {
    var er, handler, len, args, i, listeners;
  
    if (!this._events)
      this._events = {};
  
    // If there is no 'error' event listener then throw.
    if (type === 'error') {
      if (!this._events.error ||
          (isObject(this._events.error) && !this._events.error.length)) {
        er = arguments[1];
        if (er instanceof Error) {
          throw er; // Unhandled 'error' event
        } else {
          throw TypeError('Uncaught, unspecified "error" event.');
        }
        return false;
      }
    }
  
    handler = this._events[type];
  
    if (isUndefined(handler))
      return false;
  
    if (isFunction(handler)) {
      switch (arguments.length) {
        // fast cases
        case 1:
          handler.call(this);
          break;
        case 2:
          handler.call(this, arguments[1]);
          break;
        case 3:
          handler.call(this, arguments[1], arguments[2]);
          break;
        // slower
        default:
          len = arguments.length;
          args = new Array(len - 1);
          for (i = 1; i < len; i++)
            args[i - 1] = arguments[i];
          handler.apply(this, args);
      }
    } else if (isObject(handler)) {
      len = arguments.length;
      args = new Array(len - 1);
      for (i = 1; i < len; i++)
        args[i - 1] = arguments[i];
  
      listeners = handler.slice();
      len = listeners.length;
      for (i = 0; i < len; i++)
        listeners[i].apply(this, args);
    }
  
    return true;
  };
  
  EventEmitter.prototype.addListener = function(type, listener) {
    var m;
  
    if (!isFunction(listener))
      throw TypeError('listener must be a function');
  
    if (!this._events)
      this._events = {};
  
    // To avoid recursion in the case that type === "newListener"! Before
    // adding it to the listeners, first emit "newListener".
    if (this._events.newListener)
      this.emit('newListener', type,
                isFunction(listener.listener) ?
                listener.listener : listener);
  
    if (!this._events[type])
      // Optimize the case of one listener. Don't need the extra array object.
      this._events[type] = listener;
    else if (isObject(this._events[type]))
      // If we've already got an array, just append.
      this._events[type].push(listener);
    else
      // Adding the second element, need to change to array.
      this._events[type] = [this._events[type], listener];
  
    // Check for listener leak
    if (isObject(this._events[type]) && !this._events[type].warned) {
      var m;
      if (!isUndefined(this._maxListeners)) {
        m = this._maxListeners;
      } else {
        m = EventEmitter.defaultMaxListeners;
      }
  
      if (m && m > 0 && this._events[type].length > m) {
        this._events[type].warned = true;
        console.error('(node) warning: possible EventEmitter memory ' +
                      'leak detected. %d listeners added. ' +
                      'Use emitter.setMaxListeners() to increase limit.',
                      this._events[type].length);
        console.trace();
      }
    }
  
    return this;
  };
  
  EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  
  EventEmitter.prototype.once = function(type, listener) {
    if (!isFunction(listener))
      throw TypeError('listener must be a function');
  
    var fired = false;
  
    function g() {
      this.removeListener(type, g);
  
      if (!fired) {
        fired = true;
        listener.apply(this, arguments);
      }
    }
  
    g.listener = listener;
    this.on(type, g);
  
    return this;
  };
  
  // emits a 'removeListener' event iff the listener was removed
  EventEmitter.prototype.removeListener = function(type, listener) {
    var list, position, length, i;
  
    if (!isFunction(listener))
      throw TypeError('listener must be a function');
  
    if (!this._events || !this._events[type])
      return this;
  
    list = this._events[type];
    length = list.length;
    position = -1;
  
    if (list === listener ||
        (isFunction(list.listener) && list.listener === listener)) {
      delete this._events[type];
      if (this._events.removeListener)
        this.emit('removeListener', type, listener);
  
    } else if (isObject(list)) {
      for (i = length; i-- > 0;) {
        if (list[i] === listener ||
            (list[i].listener && list[i].listener === listener)) {
          position = i;
          break;
        }
      }
  
      if (position < 0)
        return this;
  
      if (list.length === 1) {
        list.length = 0;
        delete this._events[type];
      } else {
        list.splice(position, 1);
      }
  
      if (this._events.removeListener)
        this.emit('removeListener', type, listener);
    }
  
    return this;
  };
  
  EventEmitter.prototype.removeAllListeners = function(type) {
    var key, listeners;
  
    if (!this._events)
      return this;
  
    // not listening for removeListener, no need to emit
    if (!this._events.removeListener) {
      if (arguments.length === 0)
        this._events = {};
      else if (this._events[type])
        delete this._events[type];
      return this;
    }
  
    // emit removeListener for all listeners on all events
    if (arguments.length === 0) {
      for (key in this._events) {
        if (key === 'removeListener') continue;
        this.removeAllListeners(key);
      }
      this.removeAllListeners('removeListener');
      this._events = {};
      return this;
    }
  
    listeners = this._events[type];
  
    if (isFunction(listeners)) {
      this.removeListener(type, listeners);
    } else {
      // LIFO order
      while (listeners.length)
        this.removeListener(type, listeners[listeners.length - 1]);
    }
    delete this._events[type];
  
    return this;
  };
  
  EventEmitter.prototype.listeners = function(type) {
    var ret;
    if (!this._events || !this._events[type])
      ret = [];
    else if (isFunction(this._events[type]))
      ret = [this._events[type]];
    else
      ret = this._events[type].slice();
    return ret;
  };
  
  EventEmitter.listenerCount = function(emitter, type) {
    var ret;
    if (!emitter._events || !emitter._events[type])
      ret = 0;
    else if (isFunction(emitter._events[type]))
      ret = 1;
    else
      ret = emitter._events[type].length;
    return ret;
  };
  
  function isFunction(arg) {
    return typeof arg === 'function';
  }
  
  function isNumber(arg) {
    return typeof arg === 'number';
  }
  
  function isObject(arg) {
    return typeof arg === 'object' && arg !== null;
  }
  
  function isUndefined(arg) {
    return arg === void 0;
  }
  
  },{}]},{},[13])