text: (function(){requirejs.config({waitSeconds:60,paths:{rot:"../lib/rot.js/rot",lodash:"../lib/lodash/lodash"},shim:{}}),define("config",function(){}),define("entity",[],function(){function e(e,t,n){this.game=e,this.position=t,this.sprite=n}return e.prototype={move:function(e,t){this.position.x+=e,this.position.y+=t},act:function(){},draw:function(){this.game.display.draw(this.position.x,this.position.y,this.sprite.symbol,this.sprite.color)}},e}),define("lightPasses",[],function(){return function(t){return function(n,r){return n+","+r in t}}}),define("player",["entity","lightPasses"],function(t,n){function i(e,n){t.call(this,e,n,{symbol:"@",color:"#ff0"})}var r={38:0,33:1,39:2,34:3,40:4,35:5,37:6,36:7};return i.prototype=Object.create(t.prototype,{act:{value:function(){this.game.engine.lock(),this.game.draw(),window.addEventListener("keydown",this)}},handleEvent:{value:function(t){var n=t.keyCode;if(n===13||n===32){var i=this.position.x+","+this.position.y;this.game.map[i]!=="*"?alert("There is no box here!"):i===this.game.ananas?(alert("Hooray! You found an ananas and won this game."),this.game.engine.lock(),window.removeEventListener("keydown",this)):alert("This box is empty")}if(!(n in r))return;var s=e.DIRS[8][r[n]],o=this.position.x+s[0],u=this.position.y+s[1],a=o+","+u;if(!(a in this.game.map))return;this.position.x=o,this.position.y=u,window.removeEventListener("keydown",this),this.game.engine.unlock()}}}),i}),define("pedro",["entity"],function(t){function n(e,n){t.call(this,e,n,{symbol:"P",color:"red"})}function r(t,n){function s(e,n){return e+","+n in t.map}function o(e,t){i.push([e,t])}var r=t.player.position,i=[],u=new e.Path.AStar(r.x,r.y,s,{topology:8});return u.compute(n.position.x,n.position.y,o),i}return n.prototype=Object.create(t.prototype,{act:{value:function(){var e=r(this.game,this);e.shift(),e.length<=1?(this.game.engine.lock(),alert("Game over - you were captured by Pedro!")):(this.position.x=e[0][0],this.position.y=e[0][1])}}}),n});var e={isSupported:function(){return!!document.createElement("canvas").getContext&&!!Function.prototype.bind},DEFAULT_WIDTH:80,DEFAULT_HEIGHT:25,DIRS:{4:[[0,-1],[1,0],[0,1],[-1,0]],8:[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]],6:[[-1,-1],[1,-1],[2,0],[1,1],[-1,1],[-2,0]]},VK_CANCEL:3,VK_HELP:6,VK_BACK_SPACE:8,VK_TAB:9,VK_CLEAR:12,VK_RETURN:13,VK_ENTER:14,VK_SHIFT:16,VK_CONTROL:17,VK_ALT:18,VK_PAUSE:19,VK_CAPS_LOCK:20,VK_ESCAPE:27,VK_SPACE:32,VK_PAGE_UP:33,VK_PAGE_DOWN:34,VK_END:35,VK_HOME:36,VK_LEFT:37,VK_UP:38,VK_RIGHT:39,VK_DOWN:40,VK_PRINTSCREEN:44,VK_INSERT:45,VK_DELETE:46,VK_0:48,VK_1:49,VK_2:50,VK_3:51,VK_4:52,VK_5:53,VK_6:54,VK_7:55,VK_8:56,VK_9:57,VK_COLON:58,VK_SEMICOLON:59,VK_LESS_THAN:60,VK_EQUALS:61,VK_GREATER_THAN:62,VK_QUESTION_MARK:63,VK_AT:64,VK_A:65,VK_B:66,VK_C:67,VK_D:68,VK_E:69,VK_F:70,VK_G:71,VK_H:72,VK_I:73,VK_J:74,VK_K:75,VK_L:76,VK_M:77,VK_N:78,VK_O:79,VK_P:80,VK_Q:81,VK_R:82,VK_S:83,VK_T:84,VK_U:85,VK_V:86,VK_W:87,VK_X:88,VK_Y:89,VK_Z:90,VK_CONTEXT_MENU:93,VK_NUMPAD0:96,VK_NUMPAD1:97,VK_NUMPAD2:98,VK_NUMPAD3:99,VK_NUMPAD4:100,VK_NUMPAD5:101,VK_NUMPAD6:102,VK_NUMPAD7:103,VK_NUMPAD8:104,VK_NUMPAD9:105,VK_MULTIPLY:106,VK_ADD:107,VK_SEPARATOR:108,VK_SUBTRACT:109,VK_DECIMAL:110,VK_DIVIDE:111,VK_F1:112,VK_F2:113,VK_F3:114,VK_F4:115,VK_F5:116,VK_F6:117,VK_F7:118,VK_F8:119,VK_F9:120,VK_F10:121,VK_F11:122,VK_F12:123,VK_F13:124,VK_F14:125,VK_F15:126,VK_F16:127,VK_F17:128,VK_F18:129,VK_F19:130,VK_F20:131,VK_F21:132,VK_F22:133,VK_F23:134,VK_F24:135,VK_NUM_LOCK:144,VK_SCROLL_LOCK:145,VK_CIRCUMFLEX:160,VK_EXCLAMATION:161,VK_DOUBLE_QUOTE:162,VK_HASH:163,VK_DOLLAR:164,VK_PERCENT:165,VK_AMPERSAND:166,VK_UNDERSCORE:167,VK_OPEN_PAREN:168,VK_CLOSE_PAREN:169,VK_ASTERISK:170,VK_PLUS:171,VK_PIPE:172,VK_HYPHEN_MINUS:173,VK_OPEN_CURLY_BRACKET:174,VK_CLOSE_CURLY_BRACKET:175,VK_TILDE:176,VK_COMMA:188,VK_PERIOD:190,VK_SLASH:191,VK_BACK_QUOTE:192,VK_OPEN_BRACKET:219,VK_BACK_SLASH:220,VK_CLOSE_BRACKET:221,VK_QUOTE:222,VK_META:224,VK_ALTGR:225,VK_WIN:91,VK_KANA:21,VK_HANGUL:21,VK_EISU:22,VK_JUNJA:23,VK_FINAL:24,VK_HANJA:25,VK_KANJI:25,VK_CONVERT:28,VK_NONCONVERT:29,VK_ACCEPT:30,VK_MODECHANGE:31,VK_SELECT:41,VK_PRINT:42,VK_EXECUTE:43,VK_SLEEP:95};e.Text={RE_COLORS:/%([bc]){([^}]*)}/g,TYPE_TEXT:0,TYPE_NEWLINE:1,TYPE_FG:2,TYPE_BG:3,measure:function(e,t){var n={width:0,height:1},r=this.tokenize(e,t),i=0;for(var s=0;s<r.length;s++){var o=r[s];switch(o.type){case this.TYPE_TEXT:i+=o.value.length;break;case this.TYPE_NEWLINE:n.height++,n.width=Math.max(n.width,i),i=0}}return n.width=Math.max(n.width,i),n},tokenize:function(t,n){var r=[],i=0;t.replace(this.RE_COLORS,function(n,s,o,u){var a=t.substring(i,u);return a.length&&r.push({type:e.Text.TYPE_TEXT,value:a}),r.push({type:s=="c"?e.Text.TYPE_FG:e.Text.TYPE_BG,value:o.trim()}),i=u+n.length,""});var s=t.substring(i);return s.length&&r.push({type:e.Text.TYPE_TEXT,value:s}),this._breakLines(r,n)},_breakLines:function(t,n){n||(n=Infinity);var r=0,i=0,s=-1;while(r<t.length){var o=t[r];o.type==e.Text.TYPE_NEWLINE&&(i=0,s=-1);if(o.type!=e.Text.TYPE_TEXT){r++;continue}while(i==0&&o.value.charAt(0)==" ")o.value=o.value.substring(1);var u=o.value.indexOf("\n");if(u!=-1){o.value=this._breakInsideToken(t,r,u,!0);var a=o.value.split("");while(a[a.length-1]==" ")a.pop();o.value=a.join("")}if(!o.value.length){t.splice(r,1);continue}if(i+o.value.length>n){var u=-1;for(;;){var f=o.value.indexOf(" ",u+1);if(f==-1)break;if(i+f>n)break;u=f}if(u!=-1)o.value=this._breakInsideToken(t,r,u,!0);else if(s!=-1){var o=t[s],l=o.value.lastIndexOf(" ");o.value=this._breakInsideToken(t,s,l,!0),r=s}else o.value=this._breakInsideToken(t,r,n-i,!1)}else i+=o.value.length,o.value.indexOf(" ")!=-1&&(s=r);r++}t.push({type:e.Text.TYPE_NEWLINE});var c=null;for(var r=0;r<t.length;r++){var o=t[r];switch(o.type){case e.Text.TYPE_TEXT:c=o;break;case e.Text.TYPE_NEWLINE:if(c){var a=c.value.split("");while(a[a.length-1]==" ")a.pop();c.value=a.join("")}c=null}}return t.pop(),t},_breakInsideToken:function(t,n,r,i){var s={type:e.Text.TYPE_NEWLINE},o={type:e.Text.TYPE_TEXT,value:t[n].value.substring(r+(i?1:0))};return t.splice(n+1,0,s,o),t[n].value.substring(0,r)}},Array.prototype.random=function(){return this.length?this[Math.floor(e.RNG.getUniform()*this.length)]:null},Array.prototype.randomize=function(){var e=[];while(this.length){var t=this.indexOf(this.random());e.push(this.splice(t,1)[0])}return e},Number.prototype.mod=function(e){return(this%e+e)%e},String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.substring(1)},String.prototype.lpad=function(e,t){var n=e||"0",r=t||2,i="";while(i.length<r-this.length)i+=n;return i=i.substring(0,r-this.length),i+this},String.prototype.rpad=function(e,t){var n=e||"0",r=t||2,i="";while(i.length<r-this.length)i+=n;return i=i.substring(0,r-this.length),this+i},String.format=function(e){var t=String.format.map,n=Array.prototype.slice.call(arguments,1),r=function(r,i,s,o){if(e.charAt(o-1)=="%")return r.substring(1);if(!n.length)return r;var u=n[0],a=i||s,f=a.split(","),l=f.shift(),c=t[l.toLowerCase()];if(!c)return r;var u=n.shift(),h=u[c].apply(u,f),p=l.charAt(0);return p!=p.toLowerCase()&&(h=h.capitalize()),h};return e.replace(/%(?:([a-z]+)|(?:{([^}]+)}))/gi,r)},String.format.map={s:"toString"},String.prototype.format=function(){var e=Array.prototype.slice.call(arguments);return e.unshift(this),String.format.apply(String,e)},Object.create||(Object.create=function(e){var t=function(){};return t.prototype=e,new t}),Function.prototype.extend=function(e){return this.prototype=Object.create(e.prototype),this.prototype.constructor=this,this},window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,1e3/60)},window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(e){return clearTimeout(e)},e.Display=function(t){var n=document.createElement("canvas");this._context=n.getContext("2d"),this._data={},this._dirty=!1,this._options={},this._backend=null;var r={width:e.DEFAULT_WIDTH,height:e.DEFAULT_HEIGHT,transpose:!1,layout:"rect",fontSize:15,spacing:1,border:0,fontFamily:"monospace",fontStyle:"",fg:"#ccc",bg:"#000",tileWidth:32,tileHeight:32,tileMap:{},tileSet:null};for(var i in t)r[i]=t[i];this.setOptions(r),this.DEBUG=this.DEBUG.bind(this),this._tick=this._tick.bind(this),requestAnimationFrame(this._tick)},e.Display.prototype.DEBUG=function(e,t,n){var r=[this._options.bg,this._options.fg];this.draw(e,t,null,null,r[n%r.length])},e.Display.prototype.clear=function(){this._data={},this._dirty=!0},e.Display.prototype.setOptions=function(t){for(var n in t)this._options[n]=t[n];if(t.width||t.height||t.fontSize||t.fontFamily||t.spacing||t.layout){t.layout&&(this._backend=new(e.Display[t.layout.capitalize()])(this._context));var r=(this._options.fontStyle?this._options.fontStyle+" ":"")+this._options.fontSize+"px "+this._options.fontFamily;this._context.font=r,this._backend.compute(this._options),this._context.font=r,this._context.textAlign="center",this._context.textBaseline="middle",this._dirty=!0}return this},e.Display.prototype.getOptions=function(){return this._options},e.Display.prototype.getContainer=function(){return this._context.canvas},e.Display.prototype.computeSize=function(e,t){return this._backend.computeSize(e,t,this._options)},e.Display.prototype.computeFontSize=function(e,t){return this._backend.computeFontSize(e,t,this._options)},e.Display.prototype.eventToPosition=function(e){if(e.touches)var t=e.touches[0].clientX,n=e.touches[0].clientY;else var t=e.clientX,n=e.clientY;var r=this._context.canvas.getBoundingClientRect();return t-=r.left,n-=r.top,t<0||n<0||t>=this._context.canvas.width||n>=this._context.canvas.height?[-1,-1]:this._backend.eventToPosition(t,n)},e.Display.prototype.draw=function(e,t,n,r,i){r||(r=this._options.fg),i||(i=this._options.bg),this._data[e+","+t]=[e,t,n,r,i];if(this._dirty===!0)return;this._dirty||(this._dirty={}),this._dirty[e+","+t]=!0},e.Display.prototype.drawText=function(t,n,r,i){var s=null,o=null,u=t,a=n,f=1;i||(i=this._options.width-t);var l=e.Text.tokenize(r,i);while(l.length){var c=l.shift();switch(c.type){case e.Text.TYPE_TEXT:for(var h=0;h<c.value.length;h++)this.draw(u++,a,c.value.charAt(h),s,o);break;case e.Text.TYPE_FG:s=c.value||null;break;case e.Text.TYPE_BG:o=c.value||null;break;case e.Text.TYPE_NEWLINE:u=t,a++,f++}}return f},e.Display.prototype._tick=function(){requestAnimationFrame(this._tick);if(!this._dirty)return;if(this._dirty===!0){this._context.fillStyle=this._options.bg,this._context.fillRect(0,0,this._context.canvas.width,this._context.canvas.height);for(var e in this._data)this._draw(e,!1)}else for(var t in this._dirty)this._draw(t,!0);this._dirty=!1},e.Display.prototype._draw=function(e,t){var n=this._data[e];n[4]!=this._options.bg&&(t=!0),this._backend.draw(n,t)},e.Display.Backend=function(e){this._context=e},e.Display.Backend.prototype.compute=function(e){},e.Display.Backend.prototype.draw=function(e,t){},e.Display.Backend.prototype.computeSize=function(e,t){},e.Display.Backend.prototype.computeFontSize=function(e,t){},e.Display.Backend.prototype.eventToPosition=function(e,t){},e.Display.Rect=function(t){e.Display.Backend.call(this,t),this._spacingX=0,this._spacingY=0,this._canvasCache={},this._options={}},e.Display.Rect.extend(e.Display.Backend),e.Display.Rect.cache=!1,e.Display.Rect.prototype.compute=function(e){this._canvasCache={},this._options=e;var t=Math.ceil(this._context.measureText("W").width);this._spacingX=Math.ceil(e.spacing*t),this._spacingY=Math.ceil(e.spacing*e.fontSize),this._context.canvas.width=e.width*this._spacingX,this._context.canvas.height=e.height*this._spacingY},e.Display.Rect.prototype.draw=function(e,t){this.constructor.cache?this._drawWithCache(e,t):this._drawNoCache(e,t)},e.Display.Rect.prototype._drawWithCache=function(e,t){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],u=""+i+s+o;if(u in this._canvasCache)var a=this._canvasCache[u];else{var f=this._options.border,a=document.createElement("canvas"),l=a.getContext("2d");a.width=this._spacingX,a.height=this._spacingY,l.fillStyle=o,l.fillRect(f,f,a.width-f,a.height-f);if(i){l.fillStyle=s,l.font=this._context.font,l.textAlign="center",l.textBaseline="middle";var c=[].concat(i);for(var h=0;h<c.length;h++)l.fillText(c[h],this._spacingX/2,this._spacingY/2)}this._canvasCache[u]=a}this._context.drawImage(a,n*this._spacingX,r*this._spacingY)},e.Display.Rect.prototype._drawNoCache=function(e,t){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4];if(t){var u=this._options.border;this._context.fillStyle=o,this._context.fillRect(n*this._spacingX+u,r*this._spacingY+u,this._spacingX-u,this._spacingY-u)}if(!i)return;this._context.fillStyle=s;var a=[].concat(i);for(var f=0;f<a.length;f++)this._context.fillText(a[f],(n+.5)*this._spacingX,(r+.5)*this._spacingY)},e.Display.Rect.prototype.computeSize=function(e,t){var n=Math.floor(e/this._spacingX),r=Math.floor(t/this._spacingY);return[n,r]},e.Display.Rect.prototype.computeFontSize=function(e,t){var n=Math.floor(e/this._options.width),r=Math.floor(t/this._options.height),i=this._context.font;this._context.font="100px "+this._options.fontFamily;var s=Math.ceil(this._context.measureText("W").width);this._context.font=i;var o=s/100,u=o*r/n;return u>1&&(r=Math.floor(r/u)),Math.floor(r/this._options.spacing)},e.Display.Rect.prototype.eventToPosition=function(e,t){return[Math.floor(e/this._spacingX),Math.floor(t/this._spacingY)]},e.Display.Hex=function(t){e.Display.Backend.call(this,t),this._spacingX=0,this._spacingY=0,this._hexSize=0,this._options={}},e.Display.Hex.extend(e.Display.Backend),e.Display.Hex.prototype.compute=function(e){this._options=e;var t=Math.ceil(this._context.measureText("W").width);this._hexSize=Math.floor(e.spacing*(e.fontSize+t/Math.sqrt(3))/2),this._spacingX=this._hexSize*Math.sqrt(3)/2,this._spacingY=this._hexSize*1.5;if(e.transpose)var n="height",r="width";else var n="width",r="height";this._context.canvas[n]=Math.ceil((e.width+1)*this._spacingX),this._context.canvas[r]=Math.ceil((e.height-1)*this._spacingY+2*this._hexSize)},e.Display.Hex.prototype.draw=function(e,t){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],u=[(n+1)*this._spacingX,r*this._spacingY+this._hexSize];this._options.transpose&&u.reverse(),t&&(this._context.fillStyle=o,this._fill(u[0],u[1]));if(!i)return;this._context.fillStyle=s;var a=[].concat(i);for(var f=0;f<a.length;f++)this._context.fillText(a[f],u[0],u[1])},e.Display.Hex.prototype.computeSize=function(e,t){this._options.transpose&&(e+=t,t=e-t,e-=t);var n=Math.floor(e/this._spacingX)-1,r=Math.floor((t-2*this._hexSize)/this._spacingY+1);return[n,r]},e.Display.Hex.prototype.computeFontSize=function(e,t){this._options.transpose&&(e+=t,t=e-t,e-=t);var n=2*e/((this._options.width+1)*Math.sqrt(3))-1,r=t/(2+1.5*(this._options.height-1)),i=Math.min(n,r),s=this._context.font;this._context.font="100px "+this._options.fontFamily;var o=Math.ceil(this._context.measureText("W").width);this._context.font=s;var u=o/100;i=Math.floor(i)+1;var a=2*i/(this._options.spacing*(1+u/Math.sqrt(3)));return Math.ceil(a)-1},e.Display.Hex.prototype.eventToPosition=function(e,t){if(this._options.transpose){e+=t,t=e-t,e-=t;var n="width"}else var n="height";var r=this._context.canvas[n]/this._options[n];return t=Math.floor(t/r),t.mod(2)?(e-=this._spacingX,e=1+2*Math.floor(e/(2*this._spacingX))):e=2*Math.floor(e/(2*this._spacingX)),[e,t]},e.Display.Hex.prototype._fill=function(e,t){var n=this._hexSize,r=this._options.border;this._context.beginPath(),this._options.transpose?(this._context.moveTo(e-n+r,t),this._context.lineTo(e-n/2+r,t+this._spacingX-r),this._context.lineTo(e+n/2-r,t+this._spacingX-r),this._context.lineTo(e+n-r,t),this._context.lineTo(e+n/2-r,t-this._spacingX+r),this._context.lineTo(e-n/2+r,t-this._spacingX+r),this._context.lineTo(e-n+r,t)):(this._context.moveTo(e,t-n+r),this._context.lineTo(e+this._spacingX-r,t-n/2+r),this._context.lineTo(e+this._spacingX-r,t+n/2-r),this._context.lineTo(e,t+n-r),this._context.lineTo(e-this._spacingX+r,t+n/2-r),this._context.lineTo(e-this._spacingX+r,t-n/2+r),this._context.lineTo(e,t-n+r)),this._context.fill()},e.Display.Tile=function(t){e.Display.Rect.call(this,t),this._options={}},e.Display.Tile.extend(e.Display.Rect),e.Display.Tile.prototype.compute=function(e){this._options=e,this._context.canvas.width=e.width*e.tileWidth,this._context.canvas.height=e.height*e.tileHeight},e.Display.Tile.prototype.draw=function(e,t){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],u=this._options.tileWidth,a=this._options.tileHeight;if(t){var f=this._options.border;this._context.fillStyle=o,this._context.fillRect(n*u,r*a,u,a)}if(!i)return;var l=[].concat(i);for(var c=0;c<l.length;c++){var h=this._options.tileMap[l[c]];if(!h)throw new Error("Char '"+l[c]+"' not found in tileMap");this._context.drawImage(this._options.tileSet,h[0],h[1],u,a,n*u,r*a,u,a)}},e.Display.Tile.prototype.computeSize=function(e,t){var n=Math.floor(e/this._options.tileWidth),r=Math.floor(t/this._options.tileHeight);return[n,r]},e.Display.Tile.prototype.computeFontSize=function(e,t){var n=Math.floor(e/this._options.width),r=Math.floor(t/this._options.height);return[n,r]},e.Display.Tile.prototype.eventToPosition=function(e,t){return[Math.floor(e/this._options.tileWidth),Math.floor(t/this._options.tileHeight)]},e.RNG={getSeed:function(){return this._seed},setSeed:function(e){return e=e<1?1/e:e,this._seed=e,this._s0=(e>>>0)*this._frac,e=e*69069+1>>>0,this._s1=e*this._frac,e=e*69069+1>>>0,this._s2=e*this._frac,this._c=1,this},getUniform:function(){var e=2091639*this._s0+this._c*this._frac;return this._s0=this._s1,this._s1=this._s2,this._c=e|0,this._s2=e-this._c,this._s2},getUniformInt:function(e,t){var n=Math.max(e,t),r=Math.min(e,t);return Math.floor(this.getUniform()*(n-r+1))+r},getNormal:function(e,t){do var n=2*this.getUniform()-1,r=2*this.getUniform()-1,i=n*n+r*r;while(i>1||i==0);var s=n*Math.sqrt(-2*Math.log(i)/i);return(e||0)+s*(t||1)},getPercentage:function(){return 1+Math.floor(this.getUniform()*100)},getWeightedValue:function(e){var t=[],n=0;for(var r in e)n+=e[r];var i=Math.floor(this.getUniform()*n),s=0;for(var r in e){s+=e[r];if(i<s)return r}return null},getState:function(){return[this._s0,this._s1,this._s2,this._c]},setState:function(e){return this._s0=e[0],this._s1=e[1],this._s2=e[2],this._c=e[3],this},_s0:0,_s1:0,_s2:0,_c:0,_frac:2.3283064365386963e-10},e.RNG.setSeed(Date.now()),e.StringGenerator=function(e){this._options={words:!1,order:3,prior:.001};for(var t in e)this._options[t]=e[t];this._boundary=String.fromCharCode(0),this._suffix=this._boundary,this._prefix=[];for(var n=0;n<this._options.order;n++)this._prefix.push(this._boundary);this._priorValues={},this._priorValues[this._boundary]=this._options.prior,this._data={}},e.StringGenerator.prototype.clear=function(){this._data={},this._priorValues={}},e.StringGenerator.prototype.generate=function(){var e=[this._sample(this._prefix)];while(e[e.length-1]!=this._boundary)e.push(this._sample(e));return this._join(e.slice(0,-1))},e.StringGenerator.prototype.observe=function(e){var t=this._split(e);for(var n=0;n<t.length;n++)this._priorValues[t[n]]=this._options.prior;t=this._prefix.concat(t).concat(this._suffix);for(var n=this._options.order;n<t.length;n++){var r=t.slice(n-this._options.order,n),i=t[n];for(var s=0;s<r.length;s++){var o=r.slice(s);this._observeEvent(o,i)}}},e.StringGenerator.prototype.getStats=function(){var e=[],t=0;for(var n in this._priorValues)t++;t--,e.push("distinct samples: "+t);var r=0,i=0;for(var n in this._data){r++;for(var s in this._data[n])i++}return e.push("dictionary size (contexts): "+r),e.push("dictionary size (events): "+i),e.join(", ")},e.StringGenerator.prototype._split=function(e){return e.split(this._options.words?/\s+/:"")},e.StringGenerator.prototype._join=function(e){return e.join(this._options.words?" ":"")},e.StringGenerator.prototype._observeEvent=function(e,t){var n=this._join(e);n in this._data||(this._data[n]={});var r=this._data[n];t in r||(r[t]=0),r[t]++},e.StringGenerator.prototype._sample=function(e){e=this._backoff(e);var t=this._join(e),n=this._data[t],r={};if(this._options.prior){for(var i in this._priorValues)r[i]=this._priorValues[i];for(var i in n)r[i]+=n[i]}else r=n;return this._pickRandom(r)},e.StringGenerator.prototype._backoff=function(e){e.length>this._options.order?e=e.slice(-this._options.order):e.length<this._options.order&&(e=this._prefix.slice(0,this._options.order-e.length).concat(e));while(!(this._join(e)in this._data)&&e.length>0)e=e.slice(1);return e},e.StringGenerator.prototype._pickRandom=function(t){var n=0;for(var r in t)n+=t[r];var i=e.RNG.getUniform()*n,s=0;for(var r in t){s+=t[r];if(i<s)return r}},e.EventQueue=function(){this._time=0,this._events=[],this._eventTimes=[]},e.EventQueue.prototype.getTime=function(){return this._time},e.EventQueue.prototype.clear=function(){return this._events=[],this._eventTimes=[],this},e.EventQueue.prototype.add=function(e,t){var n=this._events.length;for(var r=0;r<this._eventTimes.length;r++)if(this._eventTimes[r]>t){n=r;break}this._events.splice(n,0,e),this._eventTimes.splice(n,0,t)},e.EventQueue.prototype.get=function(){if(!this._events.length)return null;var e=this._eventTimes.splice(0,1)[0];if(e>0){this._time+=e;for(var t=0;t<this._eventTimes.length;t++)this._eventTimes[t]-=e}return this._events.splice(0,1)[0]},e.EventQueue.prototype.remove=function(e){var t=this._events.indexOf(e);return t==-1?!1:(this._remove(t),!0)},e.EventQueue.prototype._remove=function(e){this._events.splice(e,1),this._eventTimes.splice(e,1)},e.Scheduler=function(){this._queue=new e.EventQueue,this._repeat=[],this._current=null},e.Scheduler.prototype.getTime=function(){return this._queue.getTime()},e.Scheduler.prototype.add=function(e,t){return t&&this._repeat.push(e),this},e.Scheduler.prototype.clear=function(){return this._queue.clear(),this._repeat=[],this._current=null,this},e.Scheduler.prototype.remove=function(e){var t=this._queue.remove(e),n=this._repeat.indexOf(e);return n!=-1&&this._repeat.splice(n,1),this._current==e&&(this._current=null),t},e.Scheduler.prototype.next=function(){return this._current=this._queue.get(),this._current},e.Scheduler.Simple=function(){e.Scheduler.call(this)},e.Scheduler.Simple.extend(e.Scheduler),e.Scheduler.Simple.prototype.add=function(t,n){return this._queue.add(t,0),e.Scheduler.prototype.add.call(this,t,n)},e.Scheduler.Simple.prototype.next=function(){return this._current&&this._repeat.indexOf(this._current)!=-1&&this._queue.add(this._current,0),e.Scheduler.prototype.next.call(this)},e.Scheduler.Speed=function(){e.Scheduler.call(this)},e.Scheduler.Speed.extend(e.Scheduler),e.Scheduler.Speed.prototype.add=function(t,n){return this._queue.add(t,1/t.getSpeed()),e.Scheduler.prototype.add.call(this,t,n)},e.Scheduler.Speed.prototype.next=function(){return this._current&&this._repeat.indexOf(this._current)!=-1&&this._queue.add(this._current,1/this._current.getSpeed()),e.Scheduler.prototype.next.call(this)},e.Scheduler.Action=function(){e.Scheduler.call(this),this._defaultDuration=1,this._duration=this._defaultDuration},e.Scheduler.Action.extend(e.Scheduler),e.Scheduler.Action.prototype.add=function(t,n,r){return this._queue.add(t,r||this._defaultDuration),e.Scheduler.prototype.add.call(this,t,n)},e.Scheduler.Action.prototype.clear=function(){return this._duration=this._defaultDuration,e.Scheduler.prototype.clear.call(this)},e.Scheduler.Action.prototype.remove=function(t){return t==this._current&&(this._duration=this._defaultDuration),e.Scheduler.prototype.remove.call(this,t)},e.Scheduler.Action.prototype.next=function(){return this._current&&this._repeat.indexOf(this._current)!=-1&&(this._queue.add(this._current,this._duration||this._defaultDuration),this._duration=this._defaultDuration),e.Scheduler.prototype.next.call(this)},e.Scheduler.Action.prototype.setDuration=function(e){return this._current&&(this._duration=e),this},e.Engine=function(e){this._scheduler=e,this._lock=1},e.Engine.prototype.start=function(){return this.unlock()},e.Engine.prototype.lock=function(){return this._lock++,this},e.Engine.prototype.unlock=function(){if(!this._lock)throw new Error("Cannot unlock unlocked engine");this._lock--;while(!this._lock){var e=this._scheduler.next();if(!e)return this.lock();var t=e.act();t&&t.then&&(this.lock(),t.then(this.unlock.bind(this)))}return this},e.Map=function(t,n){this._width=t||e.DEFAULT_WIDTH,this._height=n||e.DEFAULT_HEIGHT},e.Map.prototype.create=function(e){},e.Map.prototype._fillMap=function(e){var t=[];for(var n=0;n<this._width;n++){t.push([]);for(var r=0;r<this._height;r++)t[n].push(e)}return t},e.Map.Arena=function(t,n){e.Map.call(this,t,n)},e.Map.Arena.extend(e.Map),e.Map.Arena.prototype.create=function(e){var t=this._width-1,n=this._height-1;for(var r=0;r<=t;r++)for(var i=0;i<=n;i++){var s=r&&i&&r<t&&i<n;e(r,i,s?0:1)}return this},e.Map.DividedMaze=function(t,n){e.Map.call(this,t,n),this._stack=[]},e.Map.DividedMaze.extend(e.Map),e.Map.DividedMaze.prototype.create=function(e){var t=this._width,n=this._height;this._map=[];for(var r=0;r<t;r++){this._map.push([]);for(var i=0;i<n;i++){var s=r==0||i==0||r+1==t||i+1==n;this._map[r].push(s?1:0)}}this._stack=[[1,1,t-2,n-2]],this._process();for(var r=0;r<t;r++)for(var i=0;i<n;i++)e(r,i,this._map[r][i]);return this._map=null,this},e.Map.DividedMaze.prototype._process=function(){while(this._stack.length){var e=this._stack.shift();this._partitionRoom(e)}},e.Map.DividedMaze.prototype._partitionRoom=function(e){var t=[],n=[];for(var r=e[0]+1;r<e[2];r++){var i=this._map[r][e[1]-1],s=this._map[r][e[3]+1];i&&s&&!(r%2)&&t.push(r)}for(var o=e[1]+1;o<e[3];o++){var u=this._map[e[0]-1][o],a=this._map[e[2]+1][o];u&&a&&!(o%2)&&n.push(o)}if(!t.length||!n.length)return;var f=t.random(),l=n.random();this._map[f][l]=1;var c=[],h=[];c.push(h);for(var r=e[0];r<f;r++)this._map[r][l]=1,h.push([r,l]);var h=[];c.push(h);for(var r=f+1;r<=e[2];r++)this._map[r][l]=1,h.push([r,l]);var h=[];c.push(h);for(var o=e[1];o<l;o++)this._map[f][o]=1,h.push([f,o]);var h=[];c.push(h);for(var o=l+1;o<=e[3];o++)this._map[f][o]=1,h.push([f,o]);var p=c.random();for(var r=0;r<c.length;r++){var h=c[r];if(h==p)continue;var d=h.random();this._map[d[0]][d[1]]=0}this._stack.push([e[0],e[1],f-1,l-1]),this._stack.push([f+1,e[1],e[2],l-1]),this._stack.push([e[0],l+1,f-1,e[3]]),this._stack.push([f+1,l+1,e[2],e[3]])},e.Map.IceyMaze=function(t,n,r){e.Map.call(this,t,n),this._regularity=r||0},e.Map.IceyMaze.extend(e.Map),e.Map.IceyMaze.prototype.create=function(t){var n=this._width,r=this._height,i=this._fillMap(1);n-=n%2?1:2,r-=r%2?1:2;var s=0,o=0,u=0,a=0,f=0,l=!1,c=[[0,0],[0,0],[0,0],[0,0]];do{s=1+2*Math.floor(e.RNG.getUniform()*(n-1)/2),o=1+2*Math.floor(e.RNG.getUniform()*(r-1)/2),f||(i[s][o]=0);if(!i[s][o]){this._randomize(c);do{Math.floor(e.RNG.getUniform()*(this._regularity+1))==0&&this._randomize(c),l=!0;for(var h=0;h<4;h++){u=s+c[h][0]*2,a=o+c[h][1]*2;if(this._isFree(i,u,a,n,r)){i[u][a]=0,i[s+c[h][0]][o+c[h][1]]=0,s=u,o=a,l=!1,f++;break}}}while(!l)}}while(f+1<n*r/4);for(var h=0;h<this._width;h++)for(var p=0;p<this._height;p++)t(h,p,i[h][p]);return this._map=null,this},e.Map.IceyMaze.prototype._randomize=function(t){for(var n=0;n<4;n++)t[n][0]=0,t[n][1]=0;switch(Math.floor(e.RNG.getUniform()*4)){case 0:t[0][0]=-1,t[1][0]=1,t[2][1]=-1,t[3][1]=1;break;case 1:t[3][0]=-1,t[2][0]=1,t[1][1]=-1,t[0][1]=1;break;case 2:t[2][0]=-1,t[3][0]=1,t[0][1]=-1,t[1][1]=1;break;case 3:t[1][0]=-1,t[0][0]=1,t[3][1]=-1,t[2][1]=1}},e.Map.IceyMaze.prototype._isFree=function(e,t,n,r,i){return t<1||n<1||t>=r||n>=i?!1:e[t][n]},e.Map.EllerMaze=function(t,n){e.Map.call(this,t,n)},e.Map.EllerMaze.extend(e.Map),e.Map.EllerMaze.prototype.create=function(t){var n=this._fillMap(1),r=Math.ceil((this._width-2)/2),i=.375,s=[],o=[];for(var u=0;u<r;u++)s.push(u),o.push(u);s.push(r-1);for(var a=1;a+3<this._height;a+=2)for(var u=0;u<r;u++){var f=2*u+1,l=a;n[f][l]=0,u!=s[u+1]&&e.RNG.getUniform()>i&&(this._addToList(u,s,o),n[f+1][l]=0),u!=s[u]&&e.RNG.getUniform()>i?this._removeFromList(u,s,o):n[f][l+1]=0}for(var u=0;u<r;u++){var f=2*u+1,l=a;n[f][l]=0,u!=s[u+1]&&(u==s[u]||e.RNG.getUniform()>i)&&(this._addToList(u,s,o),n[f+1][l]=0),this._removeFromList(u,s,o)}for(var u=0;u<this._width;u++)for(var a=0;a<this._height;a++)t(u,a,n[u][a]);return this},e.Map.EllerMaze.prototype._removeFromList=function(e,t,n){n[t[e]]=n[e],t[n[e]]=t[e],n[e]=e,t[e]=e},e.Map.EllerMaze.prototype._addToList=function(e,t,n){n[t[e+1]]=n[e],t[n[e]]=t[e+1],n[e]=e+1,t[e+1]=e},e.Map.Cellular=function(t,n,r){e.Map.call(this,t,n),this._options={born:[5,6,7,8],survive:[4,5,6,7,8],topology:8,connected:!1},this.setOptions(r),this._dirs=e.DIRS[this._options.topology],this._map=this._fillMap(0)},e.Map.Cellular.extend(e.Map),e.Map.Cellular.prototype.randomize=function(t){for(var n=0;n<this._width;n++)for(var r=0;r<this._height;r++)this._map[n][r]=e.RNG.getUniform()<t?1:0;return this},e.Map.Cellular.prototype.setOptions=function(e){for(var t in e)this._options[t]=e[t]},e.Map.Cellular.prototype.set=function(e,t,n){this._map[e][t]=n},e.Map.Cellular.prototype.create=function(e){var t=this._fillMap(0),n=this._options.born,r=this._options.survive;for(var i=0;i<this._height;i++){var s=1,o=0;this._options.topology==6&&(s=2,o=i%2);for(var u=o;u<this._width;u+=s){var a=this._map[u][i],f=this._getNeighbors(u,i);a&&r.indexOf(f)!=-1?t[u][i]=1:!a&&n.indexOf(f)!=-1&&(t[u][i]=1)}}this._map=t,this._options.connected&&this._completeMaze();if(e)for(var u=0;u<this._width;u++)for(var i=0;i<this._height;i++)e(u,i,t[u][i])},e.Map.Cellular.prototype._getNeighbors=function(e,t){var n=0;for(var r=0;r<this._dirs.length;r++){var i=this._dirs[r],s=e+i[0],o=t+i[1];if(s<0||s>=this._width||s<0||o>=this._width)continue;n+=this._map[s][o]==1?1:0}return n},e.Map.Cellular.prototype._completeMaze=function(){var t=[],n={};for(var r=0;r<this._width;r++)for(var i=0;i<this._height;i++)if(this._freeSpace(r,i)){var s=[r,i];n[this._pointKey(s)]=s,t.push([r,i])}var o=t[e.RNG.getUniformInt(0,t.length-1)],u=this._pointKey(o),a={};a[u]=o,delete n[u],this._findConnected(a,n,[o]);while(Object.keys(n).length>0){var s=this._getFromTo(a,n),f=s[0],l=s[1],c={};c[this._pointKey(f)]=f,this._findConnected(c,n,[f],!0),this._tunnelToConnected(l,f,a,n);for(var h in c){var p=c[h];this._map[p[0]][p[1]]=0,a[h]=p,delete n[h]}}},e.Map.Cellular.prototype._getFromTo=function(t,n){var r,i,s,o=Object.keys(t),u=Object.keys(n);for(var a=0;a<5;a++){if(o.length<u.length){var f=o;i=t[f[e.RNG.getUniformInt(0,f.length-1)]],r=this._getClosest(i,n)}else{var f=u;r=n[f[e.RNG.getUniformInt(0,f.length-1)]],i=this._getClosest(r,t)}s=(r[0]-i[0])*(r[0]-i[0])+(r[1]-i[1])*(r[1]-i[1]);if(s<64)break}return[r,i]},e.Map.Cellular.prototype._getClosest=function(e,t){var n=null,r=null;for(k in t){var i=t[k],s=(i[0]-e[0])*(i[0]-e[0])+(i[1]-e[1])*(i[1]-e[1]);if(r==null||s<r)r=s,n=i}return n},e.Map.Cellular.prototype._findConnected=function(e,t,n,r){while(n.length>0){var i=n.splice(0,1)[0],s=[[i[0]+1,i[1]],[i[0]-1,i[1]],[i[0],i[1]+1],[i[0],i[1]-1]];for(var o=0;o<s.length;o++){var u=this._pointKey(s[o]);e[u]==null&&this._freeSpace(s[o][0],s[o][1])&&(e[u]=s[o],r||delete t[u],n.push(s[o]))}}},e.Map.Cellular.prototype._tunnelToConnected=function(e,t,n,r){var i=this._pointKey(t),s,o;t[0]<e[0]?(s=t,o=e):(s=e,o=t);for(var u=s[0];u<=o[0];u++){this._map[u][s[1]]=0;var a=[u,s[1]],f=this._pointKey(a);n[f]=a,delete r[f]}var l=o[0];t[1]<e[1]?(s=t,o=e):(s=e,o=t);for(var c=s[1];c<o[1];c++){this._map[l][c]=0;var a=[l,c],f=this._pointKey(a);n[f]=a,delete r[f]}},e.Map.Cellular.prototype._freeSpace=function(e,t){return e>=0&&e<this._width&&t>=0&&t<this._height&&this._map[e][t]!=1},e.Map.Cellular.prototype._pointKey=function(e){return e[0]+"."+e[1]},e.Map.Dungeon=function(t,n){e.Map.call(this,t,n),this._rooms=[],this._corridors=[]},e.Map.Dungeon.extend(e.Map),e.Map.Dungeon.prototype.getRooms=function(){return this._rooms},e.Map.Dungeon.prototype.getCorridors=function(){return this._corridors},e.Map.Digger=function(t,n,r){e.Map.Dungeon.call(this,t,n),this._options={roomWidth:[3,9],roomHeight:[3,5],corridorLength:[3,10],dugPercentage:.2,timeLimit:1e3};for(var i in r)this._options[i]=r[i];this._features={Room:4,Corridor:4},this._featureAttempts=20,this._walls={},this._digCallback=this._digCallback.bind(this),this._canBeDugCallback=this._canBeDugCallback.bind(this),this._isWallCallback=this._isWallCallback.bind(this),this._priorityWallCallback=this._priorityWallCallback.bind(this)},e.Map.Digger.extend(e.Map.Dungeon),e.Map.Digger.prototype.create=function(e){this._rooms=[],this._corridors=[],this._map=this._fillMap(1),this._walls={},this._dug=0;var t=(this._width-2)*(this._height-2);this._firstRoom();var n=Date.now();do{var r=Date.now();if(r-n>this._options.timeLimit)break;var i=this._findWall();if(!i)break;var s=i.split(","),o=parseInt(s[0]),u=parseInt(s[1]),a=this._getDiggingDirection(o,u);if(!a)continue;var f=0;do{f++;if(this._tryFeature(o,u,a[0],a[1])){this._removeSurroundingWalls(o,u),this._removeSurroundingWalls(o-a[0],u-a[1]);break}}while(f<this._featureAttempts);var l=0;for(var c in this._walls)this._walls[c]>1&&l++}while(this._dug/t<this._options.dugPercentage||l);this._addDoors();if(e)for(var h=0;h<this._width;h++)for(var p=0;p<this._height;p++)e(h,p,this._map[h][p]);return this._walls={},this._map=null,this},e.Map.Digger.prototype._digCallback=function(e,t,n){n==0||n==2?(this._map[e][t]=0,this._dug++):this._walls[e+","+t]=1},e.Map.Digger.prototype._isWallCallback=function(e,t){return e<0||t<0||e>=this._width||t>=this._height?!1:this._map[e][t]==1},e.Map.Digger.prototype._canBeDugCallback=function(e,t){return e<1||t<1||e+1>=this._width||t+1>=this._height?!1:this._map[e][t]==1},e.Map.Digger.prototype._priorityWallCallback=function(e,t){this._walls[e+","+t]=2},e.Map.Digger.prototype._firstRoom=function(){var t=Math.floor(this._width/2),n=Math.floor(this._height/2),r=e.Map.Feature.Room.createRandomCenter(t,n,this._options);this._rooms.push(r),r.create(this._digCallback)},e.Map.Digger.prototype._findWall=function(){var e=[],t=[];for(var n in this._walls){var r=this._walls[n];r==2?t.push(n):e.push(n)}var i=t.length?t:e;if(!i.length)return null;var n=i.random();return delete this._walls[n],n},e.Map.Digger.prototype._tryFeature=function(t,n,r,i){var s=e.RNG.getWeightedValue(this._features);return s=e.Map.Feature[s].createRandomAt(t,n,r,i,this._options),s.isValid(this._isWallCallback,this._canBeDugCallback)?(s.create(this._digCallback),s instanceof e.Map.Feature.Room&&this._rooms.push(s),s instanceof e.Map.Feature.Corridor&&(s.createPriorityWalls(this._priorityWallCallback),this._corridors.push(s)),!0):!1},e.Map.Digger.prototype._removeSurroundingWalls=function(t,n){var r=e.DIRS[4];for(var i=0;i<r.length;i++){var s=r[i],o=t+s[0],u=n+s[1];delete this._walls[o+","+u];var o=t+2*s[0],u=n+2*s[1];delete this._walls[o+","+u]}},e.Map.Digger.prototype._getDiggingDirection=function(t,n){var r=null,i=e.DIRS[4];for(var s=0;s<i.length;s++){var o=i[s],u=t+o[0],a=n+o[1];if(u<0||a<0||u>=this._width||a>=this._width)return null;if(!this._map[u][a]){if(r)return null;r=o}}return r?[-r[0],-r[1]]:null},e.Map.Digger.prototype._addDoors=function(){var e=this._map,t=function(t,n){return e[t][n]==1};for(var n=0;n<this._rooms.length;n++){var r=this._rooms[n];r.clearDoors(),r.addDoors(t)}},e.Map.Uniform=function(t,n,r){e.Map.Dungeon.call(this,t,n),this._options={roomWidth:[3,9],roomHeight:[3,5],roomDugPercentage:.1,timeLimit:1e3};for(var i in r)this._options[i]=r[i];this._roomAttempts=20,this._corridorAttempts=20,this._connected=[],this._unconnected=[],this._digCallback=this._digCallback.bind(this),this._canBeDugCallback=this._canBeDugCallback.bind(this),this._isWallCallback=this._isWallCallback.bind(this)},e.Map.Uniform.extend(e.Map.Dungeon),e.Map.Uniform.prototype.create=function(e){var t=Date.now();for(;;){var n=Date.now();if(n-t>this._options.timeLimit)return null;this._map=this._fillMap(1),this._dug=0,this._rooms=[],this._unconnected=[],this._generateRooms();if(this._rooms.length<2)continue;if(this._generateCorridors())break}if(e)for(var r=0;r<this._width;r++)for(var i=0;i<this._height;i++)e(r,i,this._map[r][i]);return this},e.Map.Uniform.prototype._generateRooms=function(){var e=this._width-2,t=this._height-2;do{var n=this._generateRoom();if(this._dug/(e*t)>this._options.roomDugPercentage)break}while(n)},e.Map.Uniform.prototype._generateRoom=function(){var t=0;while(t<this._roomAttempts){t++;var n=e.Map.Feature.Room.createRandom(this._width,this._height,this._options);if(!n.isValid(this._isWallCallback,this._canBeDugCallback))continue;return n.create(this._digCallback),this._rooms.push(n),n}return null},e.Map.Uniform.prototype._generateCorridors=function(){var e=0;while(e<this._corridorAttempts){e++,this._corridors=[],this._map=this._fillMap(1);for(var t=0;t<this._rooms.length;t++){var n=this._rooms[t];n.clearDoors(),n.create(this._digCallback)}this._unconnected=this._rooms.slice().randomize(),this._connected=[],this._unconnected.length&&this._connected.push(this._unconnected.pop());for(;;){var r=this._connected.random(),i=this._closestRoom(this._unconnected,r),s=this._closestRoom(this._connected,i),o=this._connectRooms(i,s);if(!o)break;if(!this._unconnected.length)return!0}}return!1},e.Map.Uniform.prototype._closestRoom=function(e,t){var n=Infinity,r=t.getCenter(),i=null;for(var s=0;s<e.length;s++){var o=e[s],u=o.getCenter(),a=u[0]-r[0],f=u[1]-r[1],l=a*a+f*f;l<n&&(n=l,i=o)}return i},e.Map.Uniform.prototype._connectRooms=function(e,t){var n=e.getCenter(),r=t.getCenter(),i=r[0]-n[0],s=r[1]-n[1];if(Math.abs(i)<Math.abs(s))var o=s>0?2:0,u=(o+2)%4,a=t.getLeft(),f=t.getRight(),l=0;else var o=i>0?1:3,u=(o+2)%4,a=t.getTop(),f=t.getBottom(),l=1;var c=this._placeInWall(e,o);if(!c)return!1;if(c[l]>=a&&c[l]<=f){var h=c.slice(),p=null;switch(u){case 0:p=t.getTop()-1;break;case 1:p=t.getRight()+1;break;case 2:p=t.getBottom()+1;break;case 3:p=t.getLeft()-1}h[(l+1)%2]=p,this._digLine([c,h])}else if(c[l]<a-1||c[l]>f+1){var d=c[l]-r[l];switch(u){case 0:case 1:var v=d<0?3:1;break;case 2:case 3:var v=d<0?1:3}u=(u+v)%4;var h=this._placeInWall(t,u);if(!h)return!1;var m=[0,0];m[l]=c[l];var g=(l+1)%2;m[g]=h[g],this._digLine([c,m,h])}else{var g=(l+1)%2,h=this._placeInWall(t,u);if(!h)return;var m=Math.round((h[g]+c[g])/2),y=[0,0],b=[0,0];y[l]=c[l],y[g]=m,b[l]=h[l],b[g]=m,this._digLine([c,y,b,h])}e.addDoor(c[0],c[1]),t.addDoor(h[0],h[1]);var l=this._unconnected.indexOf(e);l!=-1&&(this._unconnected.splice(l,1),this._connected.push(e));var l=this._unconnected.indexOf(t);return l!=-1&&(this._unconnected.splice(l,1),this._connected.push(t)),!0},e.Map.Uniform.prototype._placeInWall=function(e,t){var n=[0,0],r=[0,0],i=0;switch(t){case 0:r=[1,0],n=[e.getLeft(),e.getTop()-1],i=e.getRight()-e.getLeft()+1;break;case 1:r=[0,1],n=[e.getRight()+1,e.getTop()],i=e.getBottom()-e.getTop()+1;break;case 2:r=[1,0],n=[e.getLeft(),e.getBottom()+1],i=e.getRight()-e.getLeft()+1;break;case 3:r=[0,1],n=[e.getLeft()-1,e.getTop()],i=e.getBottom()-e.getTop()+1}var s=[],o=-2;for(var u=0;u<i;u++){var a=n[0]+u*r[0],f=n[1]+u*r[1];s.push(null);var l=this._map[a][f]==1;l?o!=u-1&&(s[u]=[a,f]):(o=u,u&&(s[u-1]=null))}for(var u=s.length-1;u>=0;u--)s[u]||s.splice(u,1);return s.length?s.random():null},e.Map.Uniform.prototype._digLine=function(t){for(var n=1;n<t.length;n++){var r=t[n-1],i=t[n],s=new e.Map.Feature.Corridor(r[0],r[1],i[0],i[1]);s.create(this._digCallback),this._corridors.push(s)}},e.Map.Uniform.prototype._digCallback=function(e,t,n){this._map[e][t]=n,n==0&&this._dug++},e.Map.Uniform.prototype._isWallCallback=function(e,t){return e<0||t<0||e>=this._width||t>=this._height?!1:this._map[e][t]==1},e.Map.Uniform.prototype._canBeDugCallback=function(e,t){return e<1||t<1||e+1>=this._width||t+1>=this._height?!1:this._map[e][t]==1},e.Map.Rogue=function(t,n,r){e.Map.call(this,t,n),this._options={cellWidth:3,cellHeight:3};for(var i in r)this._options[i]=r[i];this._options.hasOwnProperty("roomWidth")||(this._options.roomWidth=this._calculateRoomSize(this._width,this._options.cellWidth)),this._options.hasOwnProperty.roomHeight||(this._options.roomHeight=this._calculateRoomSize(this._height,this._options.cellHeight))},e.Map.Rogue.extend(e.Map),e.Map.Rogue.prototype.create=function(e){this.map=this._fillMap(1),this.rooms=[],this.connectedCells=[],this._initRooms(),this._connectRooms(),this._connectUnconnectedRooms(),this._createRandomRoomConnections(),this._createRooms(),this._createCorridors();if(e)for(var t=0;t<this._width;t++)for(var n=0;n<this._height;n++)e(t,n,this.map[t][n]);return this},e.Map.Rogue.prototype._getRandomInt=function(t,n){return Math.floor(e.RNG.getUniform()*(n-t+1))+t},e.Map.Rogue.prototype._calculateRoomSize=function(e,t){var n=Math.floor(e/t*.8),r=Math.floor(e/t*.25);return r<2&&(r=2),n<2&&(n=2),[r,n]},e.Map.Rogue.prototype._initRooms=function(){for(var e=0;e<this._options.cellWidth;e++){this.rooms.push([]);for(var t=0;t<this._options.cellHeight;t++)this.rooms[e].push({x:0,y:0,width:0,height:0,connections:[],cellx:e,celly:t})}},e.Map.Rogue.prototype._connectRooms=function(){var t=this._getRandomInt(0,this._options.cellWidth-1),n=this._getRandomInt(0,this._options.cellHeight-1),r,i,s,o=!1,u,a;do{var f=[0,2,4,6];f=f.randomize();do{o=!1,r=f.pop(),i=t+e.DIRS[8][r][0],s=n+e.DIRS[8][r][1];if(i<0||i>=this._options.cellWidth)continue;if(s<0||s>=this._options.cellHeight)continue;u=this.rooms[t][n];if(u.connections.length>0&&u["connections"][0][0]==i&&u["connections"][0][1]==s)break;a=this.rooms[i][s],a["connections"].length==0&&(a.connections.push([t,n]),this.connectedCells.push([i,s]),t=i,n=s,o=!0)}while(f.length>0&&o==0)}while(f.length>0)},e.Map.Rogue.prototype._connectUnconnectedRooms=function(){var t=this._options.cellWidth,n=this._options.cellHeight,r;this.connectedCells=this.connectedCells.randomize();var i,s,o;for(var u=0;u<this._options.cellWidth;u++)for(var a=0;a<this._options.cellHeight;a++){i=this.rooms[u][a];if(i["connections"].length==0){var f=[0,2,4,6];f=f.randomize();var o=!1;do{var l=f.pop(),c=u+e.DIRS[8][l][0],h=a+e.DIRS[8][l][1];if(c<0||c>=t||h<0||h>=n)continue;s=this.rooms[c][h],o=!0;if(s["connections"].length==0)break;for(var p=0;p<s.connections.length;p++)if(s["connections"][p][0]==u&&s["connections"][p][1]==a){o=!1;break}if(o)break}while(f.length);o?i.connections.push([s.cellx,s.celly]):console.log("-- Unable to connect room.")}}},e.Map.Rogue.prototype._createRandomRoomConnections=function(e){},e.Map.Rogue.prototype._createRooms=function(){var e=this._width,t=this._height,n=this._options.cellWidth,r=this._options.cellHeight,i=Math.floor(this._width/n),s=Math.floor(this._height/r),o,u,a=this._options.roomWidth,f=this._options.roomHeight,l,c,h,p,d;for(var v=0;v<n;v++)for(var m=0;m<r;m++){l=i*v,c=s*m,l==0&&(l=1),c==0&&(c=1),o=this._getRandomInt(a[0],a[1]),u=this._getRandomInt(f[0],f[1]);if(m>0){d=this.rooms[v][m-1];while(c-(d.y+d.height)<3)c++}if(v>0){d=this.rooms[v-1][m];while(l-(d.x+d.width)<3)l++}var g=Math.round(this._getRandomInt(0,i-o)/2),y=Math.round(this._getRandomInt(0,s-u)/2);while(l+g+o>=e)g?g--:o--;while(c+y+u>=t)y?y--:u--;l+=g,c+=y,this.rooms[v][m].x=l,this.rooms[v][m].y=c,this.rooms[v][m].width=o,this.rooms[v][m].height=u;for(var b=l;b<l+o;b++)for(var w=c;w<c+u;w++)this.map[b][w]=0}},e.Map.Rogue.prototype._getWallPosition=function(e,t){var n,r,i;if(t==1||t==3)n=this._getRandomInt(e.x+1,e.x+e.width-2),t==1?(r=e.y-2,i=r+1):(r=e.y+e.height+1,i=r-1),this.map[n][i]=0;else if(t==2||t==4)r=this._getRandomInt(e.y+1,e.y+e.height-2),t==2?(n=e.x+e.width+1,i=n-1):(n=e.x-2,i=n+1),this.map[i][r]=0;return[n,r]},e.Map.Rogue.prototype._drawCorridore=function(t,n){var r=n[0]-t[0],i=n[1]-t[1],s=t[0],o=t[1],u,a,f,l,c=[],h=Math.abs(r),p=Math.abs(i),d=e.RNG.getUniform(),v=d,m=1-d;a=r>0?2:6,f=i>0?4:0,h<p?(u=Math.ceil(p*v),c.push([f,u]),c.push([a,h]),u=Math.floor(p*m),c.push([f,u])):(u=Math.ceil(h*v),c.push([a,u]),c.push([f,p]),u=Math.floor(h*m),c.push([a,u])),this.map[s][o]=0;while(c.length>0){l=c.pop();while(l[1]>0)s+=e.DIRS[8][l[0]][0],o+=e.DIRS[8][l[0]][1],this.map[s][o]=0,l[1]=l[1]-1}},e.Map.Rogue.prototype._createCorridors=function(){var e=this._options.cellWidth,t=this._options.cellHeight,n,r,i,s,o;for(var u=0;u<e;u++)for(var a=0;a<t;a++){n=this.rooms[u][a];for(var f=0;f<n.connections.length;f++)r=n.connections[f],i=this.rooms[r[0]][r[1]],i.cellx>n.cellx?(s=2,o=4):i.cellx<n.cellx?(s=4,o=2):i.celly>n.celly?(s=3,o=1):i.celly<n.celly&&(s=1,o=3),this._drawCorridore(this._getWallPosition(n,s),this._getWallPosition(i,o))}},e.Map.Feature=function(){},e.Map.Feature.prototype.isValid=function(e){},e.Map.Feature.prototype.create=function(e){},e.Map.Feature.prototype.debug=function(){},e.Map.Feature.createRandomAt=function(e,t,n,r,i){},e.Map.Feature.Room=function(e,t,n,r,i,s){this._x1=e,this._y1=t,this._x2=n,this._y2=r,this._doors={},arguments.length>4&&this.addDoor(i,s)},e.Map.Feature.Room.extend(e.Map.Feature),e.Map.Feature.Room.createRandomAt=function(t,n,r,i,s){var o=s.roomWidth[0],u=s.roomWidth[1],a=o+Math.floor(e.RNG.getUniform()*(u-o+1)),o=s.roomHeight[0],u=s.roomHeight[1],f=o+Math.floor(e.RNG.getUniform()*(u-o+1));if(r==1){var l=n-Math.floor(e.RNG.getUniform()*f);return new this(t+1,l,t+a,l+f-1,t,n)}if(r==-1){var l=n-Math.floor(e.RNG.getUniform()*f);return new this(t-a,l,t-1,l+f-1,t,n)}if(i==1){var c=t-Math.floor(e.RNG.getUniform()*a);return new this(c,n+1,c+a-1,n+f,t,n)}if(i==-1){var c=t-Math.floor(e.RNG.getUniform()*a);return new this(c,n-f,c+a-1,n-1,t,n)}},e.Map.Feature.Room.createRandomCenter=function(t,n,r){var i=r.roomWidth[0],s=r.roomWidth[1],o=i+Math.floor(e.RNG.getUniform()*(s-i+1)),i=r.roomHeight[0],s=r.roomHeight[1],u=i+Math.floor(e.RNG.getUniform()*(s-i+1)),a=t-Math.floor(e.RNG.getUniform()*o),f=n-Math.floor(e.RNG.getUniform()*u),l=a+o-1,c=f+u-1;return new this(a,f,l,c)},e.Map.Feature.Room.createRandom=function(t,n,r){var i=r.roomWidth[0],s=r.roomWidth[1],o=i+Math.floor(e.RNG.getUniform()*(s-i+1)),i=r.roomHeight[0],s=r.roomHeight[1],u=i+Math.floor(e.RNG.getUniform()*(s-i+1)),a=t-o-1,f=n-u-1,l=1+Math.floor(e.RNG.getUniform()*a),c=1+Math.floor(e.RNG.getUniform()*f),h=l+o-1,p=c+u-1;return new this(l,c,h,p)},e.Map.Feature.Room.prototype.addDoor=function(e,t){return this._doors[e+","+t]=1,this},e.Map.Feature.Room.prototype.getDoors=function(e){for(var t in this._doors){var n=t.split(",");e(parseInt(n[0]),parseInt(n[1]))}return this},e.Map.Feature.Room.prototype.clearDoors=function(){return this._doors={},this},e.Map.Feature.Room.prototype.addDoors=function(e){var t=this._x1-1,n=this._x2+1,r=this._y1-1,i=this._y2+1;for(var s=t;s<=n;s++)for(var o=r;o<=i;o++){if(s!=t&&s!=n&&o!=r&&o!=i)continue;if(e(s,o))continue;this.addDoor(s,o)}return this},e.Map.Feature.Room.prototype.debug=function(){console.log("room",this._x1,this._y1,this._x2,this._y2)},e.Map.Feature.Room.prototype.isValid=function(e,t){var n=this._x1-1,r=this._x2+1,i=this._y1-1,s=this._y2+1;for(var o=n;o<=r;o++)for(var u=i;u<=s;u++)if(o==n||o==r||u==i||u==s){if(!e(o,u))return!1}else if(!t(o,u))return!1;return!0},e.Map.Feature.Room.prototype.create=function(e){var t=this._x1-1,n=this._x2+1,r=this._y1-1,i=this._y2+1,s=0;for(var o=t;o<=n;o++)for(var u=r;u<=i;u++)o+","+u in this._doors?s=2:o==t||o==n||u==r||u==i?s=1:s=0,e(o,u,s)},e.Map.Feature.Room.prototype.getCenter=function(){return[Math.round((this._x1+this._x2)/2),Math.round((this._y1+this._y2)/2)]},e.Map.Feature.Room.prototype.getLeft=function(){return this._x1},e.Map.Feature.Room.prototype.getRight=function(){return this._x2},e.Map.Feature.Room.prototype.getTop=function(){return this._y1},e.Map.Feature.Room.prototype.getBottom=function(){return this._y2},e.Map.Feature.Corridor=function(e,t,n,r){this._startX=e,this._startY=t,this._endX=n,this._endY=r,this._endsWithAWall=!0},e.Map.Feature.Corridor.extend(e.Map.Feature),e.Map.Feature.Corridor.createRandomAt=function(t,n,r,i,s){var o=s.corridorLength[0],u=s.corridorLength[1],a=o+Math.floor(e.RNG.getUniform()*(u-o+1));return new this(t,n,t+r*a,n+i*a)},e.Map.Feature.Corridor.prototype.debug=function(){console.log("corridor",this._startX,this._startY,this._endX,this._endY)},e.Map.Feature.Corridor.prototype.isValid=function(e,t){var n=this._startX,r=this._startY,i=this._endX-n,s=this._endY-r,o=1+Math.max(Math.abs(i),Math.abs(s));i&&(i/=Math.abs(i)),s&&(s/=Math.abs(s));var u=s,a=-i,f=!0;for(var l=0;l<o;l++){var c=n+l*i,h=r+l*s;t(c,h)||(f=!1),e(c+u,h+a)||(f=!1),e(c-u,h-a)||(f=!1);if(!f){o=l,this._endX=c-i,this._endY=h-s;break}}if(o==0)return!1;if(o==1&&e(this._endX+i,this._endY+s))return!1;var p=!e(this._endX+i+u,this._endY+s+a),d=!e(this._endX+i-u,this._endY+s-a);return this._endsWithAWall=e(this._endX+i,this._endY+s),(p||d)&&this._endsWithAWall?!1:!0},e.Map.Feature.Corridor.prototype.create=function(e){var t=this._startX,n=this._startY,r=this._endX-t,i=this._endY-n,s=1+Math.max(Math.abs(r),Math.abs(i));r&&(r/=Math.abs(r)),i&&(i/=Math.abs(i));var o=i,u=-r;for(var a=0;a<s;a++){var f=t+a*r,l=n+a*i;e(f,l,0)}return!0},e.Map.Feature.Corridor.prototype.createPriorityWalls=function(e){if(!this._endsWithAWall)return;var t=this._startX,n=this._startY,r=this._endX-t,i=this._endY-n;r&&(r/=Math.abs(r)),i&&(i/=Math.abs(i));var s=i,o=-r;e(this._endX+r,this._endY+i),e(this._endX+s,this._endY+o),e(this._endX-s,this._endY-o)},e.Noise=function(){},e.Noise.prototype.get=function(e,t){},e.Noise.Simplex=function(t){e.Noise.call(this),this._F2=.5*(Math.sqrt(3)-1),this._G2=(3-Math.sqrt(3))/6,this._gradients=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];var n=[],r=t||256;for(var i=0;i<r;i++)n.push(i);n=n.randomize(),this._perms=[],this._indexes=[];for(var i=0;i<2*r;i++)this._perms.push(n[i%r]),this._indexes.push(this._perms[i]%this._gradients.length)},e.Noise.Simplex.extend(e.Noise),e.Noise.Simplex.prototype.get=function(e,t){var n=this._perms,r=this._indexes,i=n.length/2,s=this._G2,o=0,u=0,a=0,f,l=(e+t)*this._F2,c=Math.floor(e+l),h=Math.floor(t+l),p=(c+h)*s,d=c-p,v=h-p,m=e-d,g=t-v,y,b;m>g?(y=1,b=0):(y=0,b=1);var w=m-y+s,E=g-b+s,S=m-1+2*s,x=g-1+2*s,T=c.mod(i),N=h.mod(i),C=.5-m*m-g*g;if(C>=0){C*=C,f=r[T+n[N]];var k=this._gradients[f];o=C*C*(k[0]*m+k[1]*g)}var L=.5-w*w-E*E;if(L>=0){L*=L,f=r[T+y+n[N+b]];var k=this._gradients[f];u=L*L*(k[0]*w+k[1]*E)}var A=.5-S*S-x*x;if(A>=0){A*=A,f=r[T+1+n[N+1]];var k=this._gradients[f];a=A*A*(k[0]*S+k[1]*x)}return 70*(o+u+a)},e.FOV=function(e,t){this._lightPasses=e,this._options={topology:8};for(var n in t)this._options[n]=t[n]},e.FOV.prototype.compute=function(e,t,n,r){},e.FOV.prototype._getCircle=function(t,n,r){var i=[],s,o,u;switch(this._options.topology){case 4:o=1,u=[0,1],s=[e.DIRS[8][7],e.DIRS[8][1],e.DIRS[8][3],e.DIRS[8][5]];break;case 6:s=e.DIRS[6],o=1,u=[-1,1];break;case 8:s=e.DIRS[4],o=2,u=[-1,1]}var a=t+u[0]*r,f=n+u[1]*r;for(var l=0;l<s.length;l++)for(var c=0;c<r*o;c++)i.push([a,f]),a+=s[l][0],f+=s[l][1];return i},e.FOV.DiscreteShadowcasting=function(t,n){e.FOV.call(this,t,n)},e.FOV.DiscreteShadowcasting.extend(e.FOV),e.FOV.DiscreteShadowcasting.prototype.compute=function(e,t,n,r){var i=this._coords,s=this._map;r(e,t,0);if(!this._lightPasses(e,t))return;var o=[],u,a,f,l,c;for(var h=1;h<=n;h++){var p=this._getCircle(e,t,h),d=360/p.length;for(var v=0;v<p.length;v++){f=p[v][0],l=p[v][1],u=d*(v-.5),a=u+d,c=!this._lightPasses(f,l),this._visibleCoords(Math.floor(u),Math.ceil(a),c,o)&&r(f,l,h,1);if(o.length==2&&o[0]==0&&o[1]==360)return}}},e.FOV.DiscreteShadowcasting.prototype._visibleCoords=function(e,t,n,r){if(e<0){var i=arguments.callee(0,t,n,r),s=arguments.callee(360+e,360,n,r);return i||s}var o=0;while(o<r.length&&r[o]<e)o++;if(o==r.length)return n&&r.push(e,t),!0;var u=0;if(o%2){while(o<r.length&&r[o]<t)o++,u++;return u==0?!1:(n&&(u%2?r.splice(o-u,u,t):r.splice(o-u,u)),!0)}while(o<r.length&&r[o]<t)o++,u++;return e==r[o-u]&&u==1?!1:(n&&(u%2?r.splice(o-u,u,e):r.splice(o-u,u,e,t)),!0)},e.FOV.PreciseShadowcasting=function(t,n){e.FOV.call(this,t,n)},e.FOV.PreciseShadowcasting.extend(e.FOV),e.FOV.PreciseShadowcasting.prototype.compute=function(e,t,n,r){r(e,t,0,1);if(!this._lightPasses(e,t))return;var i=[],s,o,u,a,f,l;for(var c=1;c<=n;c++){var h=this._getCircle(e,t,c),p=h.length;for(var d=0;d<p;d++){s=h[d][0],o=h[d][1],a=[d?2*d-1:2*p-1,2*p],f=[2*d+1,2*p],u=!this._lightPasses(s,o),l=this._checkVisibility(a,f,u,i),l&&r(s,o,c,l);if(i.length==2&&i[0][0]==0&&i[1][0]==i[1][1])return}}},e.FOV.PreciseShadowcasting.prototype._checkVisibility=function(e,t,n,r){if(e[0]>t[0]){var i=this._checkVisibility(e,[e[1],e[1]],n,r),s=this._checkVisibility([0,1],t,n,r);return(i+s)/2}var o=0,u=!1;while(o<r.length){var a=r[o],f=a[0]*e[1]-e[0]*a[1];if(f>=0){f==0&&!(o%2)&&(u=!0);break}o++}var l=r.length,c=!1;while(l--){var a=r[l],f=t[0]*a[1]-a[0]*t[1];if(f>=0){f==0&&l%2&&(c=!0);break}}var h=!0;o==l&&(u||c)?h=!1:u&&c&&o+1==l&&l%2?h=!1:o>l&&o%2&&(h=!1);if(!h)return 0;var p,d,v=l-o+1;if(v%2)if(o%2){var d=r[o];p=(t[0]*d[1]-d[0]*t[1])/(d[1]*t[1]),n&&r.splice(o,v,t)}else{var d=r[l];p=(d[0]*e[1]-e[0]*d[1])/(e[1]*d[1]),n&&r.splice(o,v,e)}else{if(!(o%2))return n&&r.splice(o,v,e,t),1;var m=r[o],g=r[l];p=(g[0]*m[1]-m[0]*g[1])/(m[1]*g[1]),n&&r.splice(o,v)}var y=(t[0]*e[1]-e[0]*t[1])/(e[1]*t[1]);return p/y},e.FOV.RecursiveShadowcasting=function(t,n){e.FOV.call(this,t,n)},e.FOV.RecursiveShadowcasting.extend(e.FOV),e.FOV.RecursiveShadowcasting.OCTANTS=[[-1,0,0,1],[0,-1,1,0],[0,-1,-1,0],[-1,0,0,-1],[1,0,0,-1],[0,1,-1,0],[0,1,1,0],[1,0,0,1]],e.FOV.RecursiveShadowcasting.prototype.compute=function(t,n,r,i){i(t,n,0,!0);for(var s=0;s<e.FOV.RecursiveShadowcasting.OCTANTS.length;s++)this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[s],r,i)},e.FOV.RecursiveShadowcasting.prototype.compute180=function(t,n,r,i,s){s(t,n,0,!0);var o=(i-1+8)%8,u=(i-2+8)%8,a=(i+1+8)%8;this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[u],r,s),this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[o],r,s),this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[i],r,s),this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[a],r,s)},e.FOV.RecursiveShadowcasting.prototype.compute90=function(t,n,r,i,s){s(t,n,0,!0);var o=(i-1+8)%8;this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[i],r,s),this._renderOctant(t,n,e.FOV.RecursiveShadowcasting.OCTANTS[o],r,s)},e.FOV.RecursiveShadowcasting.prototype._renderOctant=function(e,t,n,r,i){this._castVisibility(e,t,1,1,0,r+1,n[0],n[1],n[2],n[3],i)},e.FOV.RecursiveShadowcasting.prototype._castVisibility=function(e,t,n,r,i,s,o,u,a,f,l){if(r<i)return;for(var c=n;c<=s;c++){var h=-c-1,p=-c,d=!1,v=0;while(h<=0){h+=1;var m=e+h*o+p*u,g=t+h*a+p*f,y=(h-.5)/(p+.5),b=(h+.5)/(p-.5);if(b>r)continue;if(y<i)break;h*h+p*p<s*s&&l(m,g,c,!0);if(!d)!this._lightPasses(m,g)&&c<s&&(d=!0,this._castVisibility(e,t,c+1,r,y,s,o,u,a,f,l),v=b);else{if(!this._lightPasses(m,g)){v=b;continue}d=!1,r=v}}if(d)break}},e.Color={fromString:function(e){var t,n;if(e in this._cache)t=this._cache[e];else{if(e.charAt(0)=="#"){var r=e.match(/[0-9a-f]/gi).map(function(e){return parseInt(e,16)});if(r.length==3)t=r.map(function(e){return e*17});else{for(var i=0;i<3;i++)r[i+1]+=16*r[i],r.splice(i,1);t=r}}else(n=e.match(/rgb\(([0-9, ]+)\)/i))?t=n[1].split(/\s*,\s*/).map(function(e){return parseInt(e)}):t=[0,0,0];this._cache[e]=t}return t.slice()},add:function(e,t){var n=e.slice();for(var r=0;r<3;r++)for(var i=1;i<arguments.length;i++)n[r]+=arguments[i][r];return n},add_:function(e,t){for(var n=0;n<3;n++)for(var r=1;r<arguments.length;r++)e[n]+=arguments[r][n];return e},multiply:function(e,t){var n=e.slice();for(var r=0;r<3;r++){for(var i=1;i<arguments.length;i++)n[r]*=arguments[i][r]/255;n[r]=Math.round(n[r])}return n},multiply_:function(e,t){for(var n=0;n<3;n++){for(var r=1;r<arguments.length;r++)e[n]*=arguments[r][n]/255;e[n]=Math.round(e[n])}return e},interpolate:function(e,t,n){arguments.length<3&&(n=.5);var r=e.slice();for(var i=0;i<3;i++)r[i]=Math.round(r[i]+n*(t[i]-e[i]));return r},interpolateHSL:function(e,t,n){arguments.length<3&&(n=.5);var r=this.rgb2hsl(e),i=this.rgb2hsl(t);for(var s=0;s<3;s++)r[s]+=n*(i[s]-r[s]);return this.hsl2rgb(r)},randomize:function(t,n){n instanceof Array||(n=e.RNG.getNormal(0,n));var r=t.slice();for(var i=0;i<3;i++)r[i]+=n instanceof Array?Math.round(e.RNG.getNormal(0,n[i])):n;return r},rgb2hsl:function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.max(t,n,r),s=Math.min(t,n,r),o,u,a=(i+s)/2;if(i==s)o=u=0;else{var f=i-s;u=a>.5?f/(2-i-s):f/(i+s);switch(i){case t:o=(n-r)/f+(n<r?6:0);break;case n:o=(r-t)/f+2;break;case r:o=(t-n)/f+4}o/=6}return[o,u,a]},hsl2rgb:function(e){var t=e[2];if(e[1]==0)return t=Math.round(t*255),[t,t,t];function n(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var r=e[1],i=t<.5?t*(1+r):t+r-t*r,s=2*t-i,o=n(s,i,e[0]+1/3),u=n(s,i,e[0]),a=n(s,i,e[0]-1/3);return[Math.round(o*255),Math.round(u*255),Math.round(a*255)]},toRGB:function(e){return"rgb("+this._clamp(e[0])+","+this._clamp(e[1])+","+this._clamp(e[2])+")"},toHex:function(e){var t=[];for(var n=0;n<3;n++)t.push(this._clamp(e[n]).toString(16).lpad("0",2));return"#"+t.join("")},_clamp:function(e){return e<0?0:e>255?255:e},_cache:{black:[0,0,0],navy:[0,0,128],darkblue:[0,0,139],mediumblue:[0,0,205],blue:[0,0,255],darkgreen:[0,100,0],green:[0,128,0],teal:[0,128,128],darkcyan:[0,139,139],deepskyblue:[0,191,255],darkturquoise:[0,206,209],mediumspringgreen:[0,250,154],lime:[0,255,0],springgreen:[0,255,127],aqua:[0,255,255],cyan:[0,255,255],midnightblue:[25,25,112],dodgerblue:[30,144,255],forestgreen:[34,139,34],seagreen:[46,139,87],darkslategray:[47,79,79],darkslategrey:[47,79,79],limegreen:[50,205,50],mediumseagreen:[60,179,113],turquoise:[64,224,208],royalblue:[65,105,225],steelblue:[70,130,180],darkslateblue:[72,61,139],mediumturquoise:[72,209,204],indigo:[75,0,130],darkolivegreen:[85,107,47],cadetblue:[95,158,160],cornflowerblue:[100,149,237],mediumaquamarine:[102,205,170],dimgray:[105,105,105],dimgrey:[105,105,105],slateblue:[106,90,205],olivedrab:[107,142,35],slategray:[112,128,144],slategrey:[112,128,144],lightslategray:[119,136,153],lightslategrey:[119,136,153],mediumslateblue:[123,104,238],lawngreen:[124,252,0],chartreuse:[127,255,0],aquamarine:[127,255,212],maroon:[128,0,0],purple:[128,0,128],olive:[128,128,0],gray:[128,128,128],grey:[128,128,128],skyblue:[135,206,235],lightskyblue:[135,206,250],blueviolet:[138,43,226],darkred:[139,0,0],darkmagenta:[139,0,139],saddlebrown:[139,69,19],darkseagreen:[143,188,143],lightgreen:[144,238,144],mediumpurple:[147,112,216],darkviolet:[148,0,211],palegreen:[152,251,152],darkorchid:[153,50,204],yellowgreen:[154,205,50],sienna:[160,82,45],brown:[165,42,42],darkgray:[169,169,169],darkgrey:[169,169,169],lightblue:[173,216,230],greenyellow:[173,255,47],paleturquoise:[175,238,238],lightsteelblue:[176,196,222],powderblue:[176,224,230],firebrick:[178,34,34],darkgoldenrod:[184,134,11],mediumorchid:[186,85,211],rosybrown:[188,143,143],darkkhaki:[189,183,107],silver:[192,192,192],mediumvioletred:[199,21,133],indianred:[205,92,92],peru:[205,133,63],chocolate:[210,105,30],tan:[210,180,140],lightgray:[211,211,211],lightgrey:[211,211,211],palevioletred:[216,112,147],thistle:[216,191,216],orchid:[218,112,214],goldenrod:[218,165,32],crimson:[220,20,60],gainsboro:[220,220,220],plum:[221,160,221],burlywood:[222,184,135],lightcyan:[224,255,255],lavender:[230,230,250],darksalmon:[233,150,122],violet:[238,130,238],palegoldenrod:[238,232,170],lightcoral:[240,128,128],khaki:[240,230,140],aliceblue:[240,248,255],honeydew:[240,255,240],azure:[240,255,255],sandybrown:[244,164,96],wheat:[245,222,179],beige:[245,245,220],whitesmoke:[245,245,245],mintcream:[245,255,250],ghostwhite:[248,248,255],salmon:[250,128,114],antiquewhite:[250,235,215],linen:[250,240,230],lightgoldenrodyellow:[250,250,210],oldlace:[253,245,230],red:[255,0,0],fuchsia:[255,0,255],magenta:[255,0,255],deeppink:[255,20,147],orangered:[255,69,0],tomato:[255,99,71],hotpink:[255,105,180],coral:[255,127,80],darkorange:[255,140,0],lightsalmon:[255,160,122],orange:[255,165,0],lightpink:[255,182,193],pink:[255,192,203],gold:[255,215,0],peachpuff:[255,218,185],navajowhite:[255,222,173],moccasin:[255,228,181],bisque:[255,228,196],mistyrose:[255,228,225],blanchedalmond:[255,235,205],papayawhip:[255,239,213],lavenderblush:[255,240,245],seashell:[255,245,238],cornsilk:[255,248,220],lemonchiffon:[255,250,205],floralwhite:[255,250,240],snow:[255,250,250],yellow:[255,255,0],lightyellow:[255,255,224],ivory:[255,255,240],white:[255,255,255]}},e.Lighting=function(e,t){this._reflectivityCallback=e,this._options={passes:1,emissionThreshold:100,range:10},this._fov=null,this._lights={},this._reflectivityCache={},this._fovCache={},this.setOptions(t)},e.Lighting.prototype.setOptions=function(e){for(var t in e)this._options[t]=e[t];return e.range&&this.reset(),this},e.Lighting.prototype.setFOV=function(e){return this._fov=e,this._fovCache={},this},e.Lighting.prototype.setLight=function(t,n,r){var i=t+","+n;return r?this._lights[i]=typeof r=="string"?e.Color.fromString(r):r:delete this._lights[i],this},e.Lighting.prototype.reset=function(){return this._reflectivityCache={},this._fovCache={},this},e.Lighting.prototype.compute=function(t){var n={},r={},i={};for(var s in this._lights){var o=this._lights[s];s in r||(r[s]=[0,0,0]),e.Color.add_(r[s],o)}for(var u=0;u<this._options.passes;u++){this._emitLight(r,i,n);if(u+1==this._options.passes)continue;r=this._computeEmitters(i,n)}for(var a in i){var f=a.split(","),l=parseInt(f[0]),c=parseInt(f[1]);t(l,c,i[a])}return this},e.Lighting.prototype._emitLight=function(e,t,n){for(var r in e){var i=r.split(","),s=parseInt(i[0]),o=parseInt(i[1]);this._emitLightFromCell(s,o,e[r],t),n[r]=1}return this},e.Lighting.prototype._computeEmitters=function(e,t){var n={};for(var r in e){if(r in t)continue;var i=e[r];if(r in this._reflectivityCache)var s=this._reflectivityCache[r];else{var o=r.split(","),u=parseInt(o[0]),a=parseInt(o[1]),s=this._reflectivityCallback(u,a);this._reflectivityCache[r]=s}if(s==0)continue;var f=[],l=0;for(var c=0;c<3;c++){var h=Math.round(i[c]*s);f[c]=h,l+=h}l>this._options.emissionThreshold&&(n[r]=f)}return n},e.Lighting.prototype._emitLightFromCell=function(e,t,n,r){var i=e+","+t;if(i in this._fovCache)var s=this._fovCache[i];else var s=this._updateFOV(e,t);for(var o in s){var u=s[o];if(o in r)var a=r[o];else{var a=[0,0,0];r[o]=a}for(var f=0;f<3;f++)a[f]+=Math.round(n[f]*u)}return this},e.Lighting.prototype._updateFOV=function(e,t){var n=e+","+t,r={};this._fovCache[n]=r;var i=this._options.range,s=function(e,t,n,s){var o=e+","+t,u=s*(1-n/i);if(u==0)return;r[o]=u};return this._fov.compute(e,t,i,s.bind(this)),r},e.Path=function(t,n,r,i){this._toX=t,this._toY=n,this._fromX=null,this._fromY=null,this._passableCallback=r,this._options={topology:8};for(var s in i)this._options[s]=i[s];this._dirs=e.DIRS[this._options.topology],this._options.topology==8&&(this._dirs=[this._dirs[0],this._dirs[2],this._dirs[4],this._dirs[6],this._dirs[1],this._dirs[3],this._dirs[5],this._dirs[7]])},e.Path.prototype.compute=function(e,t,n){},e.Path.prototype._getNeighbors=function(e,t){var n=[];for(var r=0;r<this._dirs.length;r++){var i=this._dirs[r],s=e+i[0],o=t+i[1];if(!this._passableCallback(s,o))continue;n.push([s,o])}return n},e.Path.Dijkstra=function(t,n,r,i){e.Path.call(this,t,n,r,i),this._computed={},this._todo=[],this._add(t,n,null)},e.Path.Dijkstra.extend(e.Path),e.Path.Dijkstra.prototype.compute=function(e,t,n){var r=e+","+t;r in this._computed||this._compute(e,t);if(!(r in this._computed))return;var i=this._computed[r];while(i)n(i.x,i.y),i=i.prev},e.Path.Dijkstra.prototype._compute=function(e,t){while(this._todo.length){var n=this._todo.shift();if(n.x==e&&n.y==t)return;var r=this._getNeighbors(n.x,n.y);for(var i=0;i<r.length;i++){var s=r[i],o=s[0],u=s[1],a=o+","+u;if(a in this._computed)continue;this._add(o,u,n)}}},e.Path.Dijkstra.prototype._add=function(e,t,n){var r={x:e,y:t,prev:n};this._computed[e+","+t]=r,this._todo.push(r)},e.Path.AStar=function(t,n,r,i){e.Path.call(this,t,n,r,i),this._todo=[],this._done={},this._fromX=null,this._fromY=null},e.Path.AStar.extend(e.Path),e.Path.AStar.prototype.compute=function(e,t,n){this._todo=[],this._done={},this._fromX=e,this._fromY=t,this._add(this._toX,this._toY,null);while(this._todo.length){var r=this._todo.shift();if(r.x==e&&r.y==t)break;var i=this._getNeighbors(r.x,r.y);for(var s=0;s<i.length;s++){var o=i[s],u=o[0],a=o[1],f=u+","+a;if(f in this._done)continue;this._add(u,a,r)}}var r=this._done[e+","+t];if(!r)return;while(r)n(r.x,r.y),r=r.prev},e.Path.AStar.prototype._add=function(e,t,n){var r={x:e,y:t,prev:n,g:n?n.g+1:0,h:this._distance(e,t)};this._done[e+","+t]=r;var i=r.g+r.h;for(var s=0;s<this._todo.length;s++){var o=this._todo[s];if(i<o.g+o.h){this._todo.splice(s,0,r);return}}this._todo.push(r)},e.Path.AStar.prototype._distance=function(e,t){switch(this._options.topology){case 4:return Math.abs(e-this._fromX)+Math.abs(t-this._fromY);case 6:var n=Math.abs(e-this._fromX),r=Math.abs(t-this._fromY);return r+Math.max(0,(n-r)/2);case 8:return Math.max(Math.abs(e-this._fromX),Math.abs(t-this._fromY))}},define("rot",function(){}),function(){function Lt(e,t){if(e!==t){var n=e===e,r=t===t;if(e>t||!n||typeof e=="undefined"&&r)return 1;if(e<t||!r||typeof t=="undefined"&&n)return-1}return 0}function At(e,t,n){var r=e.length,i=n?r:-1;while(n?i--:++i<r)if(t(e[i],i,e))return i;return-1}function Ot(e,t,n){if(t!==t)return Rt(e,n);var r=n-1,i=e.length;while(++r<i)if(e[r]===t)return r;return-1}function Mt(e){return typeof e=="function"||!1}function _t(e){return typeof e=="string"?e:e==null?"":e+""}function Dt(e){return e.charCodeAt(0)}function Pt(e,t){var n=-1,r=e.length;while(++n<r&&t.indexOf(e.charAt(n))>-1);return n}function Ht(e,t){var n=e.length;while(n--&&t.indexOf(e.charAt(n))>-1);return n}function Bt(e,t){return Lt(e.criteria,t.criteria)||e.index-t.index}function jt(e,t,n){var r=-1,i=e.criteria,s=t.criteria,o=i.length,u=n.length;while(++r<o){var a=Lt(i[r],s[r]);if(a)return r>=u?a:a*(n[r]?1:-1)}return e.index-t.index}function Ft(e){return mt[e]}function It(e){return gt[e]}function qt(e){return"\\"+wt[e]}function Rt(e,t,n){var r=e.length,i=t+(n?0:-1);while(n?i--:++i<r){var s=e[i];if(s!==s)return i}return-1}function Ut(e){return!!e&&typeof e=="object"}function zt(e){return e<=160&&e>=9&&e<=13||e==32||e==160||e==5760||e==6158||e>=8192&&(e<=8202||e==8232||e==8233||e==8239||e==8287||e==12288||e==65279)}function Wt(e,t){var n=-1,r=e.length,i=-1,s=[];while(++n<r)e[n]===t&&(e[n]=b,s[++i]=n);return s}function Xt(e,t){var n,r=-1,i=e.length,s=-1,o=[];while(++r<i){var u=e[r],a=t?t(u,r,e):u;if(!r||n!==a)n=a,o[++s]=u}return o}function Vt(e){var t=-1,n=e.length;while(++t<n&&zt(e.charCodeAt(t)));return t}function $t(e){var t=e.length;while(t--&&zt(e.charCodeAt(t)));return t}function Jt(e){return yt[e]}function Kt(C){function Fn(e){if(Ut(e)&&!Yo(e)&&!(e instanceof Un)){if(e instanceof qn)return e;if(Zt.call(e,"__chain__")&&Zt.call(e,"__wrapped__"))return ss(e)}return new qn(e)}function In(){}function qn(e,t,n){this.__wrapped__=e,this.__actions__=n||[],this.__chain__=!!t}function Un(e){this.__wrapped__=e,this.__actions__=null,this.__dir__=1,this.__dropCount__=0,this.__filtered__=!1,this.__iteratees__=null,this.__takeCount__=On,this.__views__=null}function zn(){var e=this.__actions__,t=this.__iteratees__,n=this.__views__,r=new Un(this.__wrapped__);return r.__actions__=e?er(e):null,r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=t?er(t):null,r.__takeCount__=this.__takeCount__,r.__views__=n?er(n):null,r}function Wn(){if(this.__filtered__){var e=new Un(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Xn(){var e=this.__wrapped__.value();if(!Yo(e))return ti(e,this.__actions__);var t=this.__dir__,n=t<0,r=Ri(0,e.length,this.__views__),i=r.start,s=r.end,o=s-i,u=n?s:i-1,a=Tn(o,this.__takeCount__),f=this.__iteratees__,l=f?f.length:0,c=0,h=[];e:while(o--&&c<a){u+=t;var p=-1,d=e[u];while(++p<l){var y=f[p],b=y.iteratee,w=y.type;if(w==v){y.done&&(n?u>y.index:u<y.index)&&(y.count=0,y.done=!1),y.index=u;if(!y.done){var E=y.limit;if(!(y.done=E>-1?y.count++>=E:!b(d)))continue e}}else{var S=b(d);if(w==g)d=S;else if(!S){if(w==m)continue e;break e}}}h[c++]=d}return h}function Vn(){this.__data__={}}function $n(e){return this.has(e)&&delete this.__data__[e]}function Jn(t){return t=="__proto__"?e:this.__data__[t]}function Kn(e){return e!="__proto__"&&Zt.call(this.__data__,e)}function Qn(e,t){return e!="__proto__"&&(this.__data__[e]=t),this}function Gn(e){var t=e?e.length:0;this.data={hash:wn(null),set:new pn};while(t--)this.push(e[t])}function Yn(e,t){var n=e.data,r=typeof t=="string"||uu(t)?n.set.has(t):n.hash[t];return r?0:-1}function Zn(e){var t=this.data;typeof e=="string"||uu(e)?t.set.add(e):t.hash[e]=!0}function er(e,t){var n=-1,r=e.length;t||(t=O(r));while(++n<r)t[n]=e[n];return t}function tr(e,t){var n=-1,r=e.length;while(++n<r)if(t(e[n],n,e)===!1)break;return e}function nr(e,t){var n=e.length;while(n--)if(t(e[n],n,e)===!1)break;return e}function rr(e,t){var n=-1,r=e.length;while(++n<r)if(!t(e[n],n,e))return!1;return!0}function ir(e,t){var n=-1,r=e.length,i=-1,s=[];while(++n<r){var o=e[n];t(o,n,e)&&(s[++i]=o)}return s}function sr(e,t){var n=-1,r=e.length,i=O(r);while(++n<r)i[n]=t(e[n],n,e);return i}function or(e){var t=-1,n=e.length,r=An;while(++t<n){var i=e[t];i>r&&(r=i)}return r}function ur(e){var t=-1,n=e.length,r=On;while(++t<n){var i=e[t];i<r&&(r=i)}return r}function ar(e,t,n,r){var i=-1,s=e.length;r&&s&&(n=e[++i]);while(++i<s)n=t(n,e[i],i,e);return n}function fr(e,t,n,r){var i=e.length;r&&i&&(n=e[--i]);while(i--)n=t(n,e[i],i,e);return n}function lr(e,t){var n=-1,r=e.length;while(++n<r)if(t(e[n],n,e))return!0;return!1}function cr(e){var t=e.length,n=0;while(t--)n+=+e[t]||0;return n}function hr(e,t){return typeof e=="undefined"?t:e}function pr(e,t,n,r){return typeof e=="undefined"||!Zt.call(r,n)?t:e}function dr(e,t,n){var r=_u(t);if(!n)return mr(t,e,r);var i=-1,s=r.length;while(++i<s){var o=r[i],u=e[o],a=n(u,t[o],o,e,t);if((a===a?a!==u:u===u)||typeof u=="undefined"&&!(o in e))e[o]=a}return e}function vr(t,n){var r=-1,i=t.length,s=Ji(i),o=n.length,u=O(o);while(++r<o){var a=n[r];s?(a=parseFloat(a),u[r]=Xi(a,i)?t[a]:e):u[r]=t[a]}return u}function mr(e,t,n){n||(n=t,t={});var r=-1,i=n.length;while(++r<i){var s=n[r];t[s]=e[s]}return t}function gr(e,t,n){var r=typeof e;return r=="function"?typeof t=="undefined"?e:ii(e,t,n):e==null?ma:r=="object"?Ir(e):typeof t=="undefined"?zr(e+""):qr(e+"",t)}function yr(e,t,n,r,i,s,o){var u;n&&(u=i?n(e,r,i):n(e));if(typeof u!="undefined")return u;if(!uu(e))return e;var a=Yo(e);if(a){u=Ui(e);if(!t)return er(e,u)}else{var f=tn.call(e),l=f==N;if(!(f==L||f==w||l&&!i))return dt[f]?Wi(e,f,t):i?e:{};u=zi(l?{}:e);if(!t)return mr(e,u,_u(e))}s||(s=[]),o||(o=[]);var c=s.length;while(c--)if(s[c]==e)return o[c];return s.push(e),o.push(u),(a?tr:_r)(e,function(r,i){u[i]=yr(r,t,n,i,e,s,o)}),u}function wr(t,n,r){if(typeof t!="function")throw new xt(y);return dn(function(){t.apply(e,r)},n)}function Er(e,t){var n=e?e.length:0,r=[];if(!n)return r;var i=-1,s=qi(),o=s==Ot,u=o&&t.length>=200?pi(t):null,a=t.length;u&&(s=Yn,o=!1,t=u);e:while(++i<n){var f=e[i];if(o&&f===f){var l=a;while(l--)if(t[l]===f)continue e;r.push(f)}else s(t,f,0)<0&&r.push(f)}return r}function Tr(e,t){var n=!0;return Sr(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function Nr(e,t,n,r){var i=e.length;n=n==null?0:+n||0,n<0&&(n=-n>i?0:i+n),r=typeof r=="undefined"||r>i?i:+r||0,r<0&&(r+=i),i=n>r?0:r>>>0,n>>>=0;while(n<i)e[n++]=t;return e}function Cr(e,t){var n=[];return Sr(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function kr(e,t,n,r){var i;return n(e,function(e,n,s){if(t(e,n,s))return i=r?n:e,!1}),i}function Lr(e,t,n){var r=-1,i=e.length,s=-1,o=[];while(++r<i){var u=e[r];if(Ut(u)&&Ji(u.length)&&(Yo(u)||Go(u))){t&&(u=Lr(u,t,n));var a=-1,f=u.length;o.length+=f;while(++a<f)o[++s]=u[a]}else n||(o[++s]=u)}return o}function Mr(e,t){return Ar(e,t,Du)}function _r(e,t){return Ar(e,t,_u)}function Dr(e,t){return Or(e,t,_u)}function Pr(e,t){var n=-1,r=t.length,i=-1,s=[];while(++n<r){var o=t[n];ou(e[o])&&(s[++i]=o)}return s}function Hr(e,t,n,r,i,s){if(e===t)return e!==0||1/e==1/t;var o=typeof e,u=typeof t;return o!="function"&&o!="object"&&u!="function"&&u!="object"||e==null||t==null?e!==e&&t!==t:Br(e,t,Hr,n,r,i,s)}function Br(e,t,n,r,i,s,o){var u=Yo(e),a=Yo(t),f=E,l=E;u||(f=tn.call(e),f==w?f=L:f!=L&&(u=mu(e))),a||(l=tn.call(t),l==w?l=L:l!=L&&(a=mu(t)));var c=f==L||i&&f==N,h=l==L||i&&l==N,p=f==l;if(p&&!u&&!c)return Pi(e,t,f);if(i){if(!p&&(!c||!h))return!1}else{var d=c&&Zt.call(e,"__wrapped__"),v=h&&Zt.call(t,"__wrapped__");if(d||v)return n(d?e.value():e,v?t.value():t,r,i,s,o);if(!p)return!1}s||(s=[]),o||(o=[]);var m=s.length;while(m--)if(s[m]==e)return o[m]==t;s.push(e),o.push(t);var g=(u?Di:Hi)(e,t,n,r,i,s,o);return s.pop(),o.pop(),g}function jr(t,n,r,i,s){var o=-1,u=n.length,a=!s;while(++o<u)if(a&&i[o]?r[o]!==t[n[o]]:!(n[o]in t))return!1;o=-1;while(++o<u){var f=n[o],l=t[f],c=r[o];if(a&&i[o])var h=typeof l!="undefined"||f in t;else h=s?s(l,c,f):e,typeof h=="undefined"&&(h=Hr(c,l,s,!0));if(!h)return!1}return!0}function Fr(e,t){var n=[];return Sr(e,function(e,r,i){n.push(t(e,r,i))}),n}function Ir(e){var t=_u(e),n=t.length;if(!n)return va(!0);if(n==1){var r=t[0],i=e[r];if(Ki(i))return function(e){return e!=null&&e[r]===i&&(typeof i!="undefined"||r in is(e))}}var s=O(n),o=O(n);while(n--)i=e[t[n]],s[n]=i,o[n]=Ki(i);return function(e){return e!=null&&jr(is(e),t,s,o)}}function qr(e,t){return Ki(t)?function(n){return n!=null&&n[e]===t&&(typeof t!="undefined"||e in is(n))}:function(n){return n!=null&&Hr(t,n[e],null,!0)}}function Rr(t,n,r,i,s){if(!uu(t))return t;var o=Ji(n.length)&&(Yo(n)||mu(n));return(o?tr:_r)(n,function(n,u,a){if(Ut(n))return i||(i=[]),s||(s=[]),Ur(t,a,u,Rr,r,i,s);var f=t[u],l=r?r(f,n,u,t,a):e,c=typeof l=="undefined";c&&(l=n),(o||typeof l!="undefined")&&(c||(l===l?l!==f:f===f))&&(t[u]=l)}),t}function Ur(t,n,r,i,s,o,u){var a=o.length,f=n[r];while(a--)if(o[a]==f){t[r]=u[a];return}var l=t[r],c=s?s(l,f,r,t,n):e,h=typeof c=="undefined";h&&(c=f,Ji(f.length)&&(Yo(f)||mu(f))?c=Yo(l)?l:l&&l.length?er(l):[]:pu(f)||Go(f)?c=Go(l)?bu(l):pu(l)?l:{}:h=!1),o.push(f),u.push(c);if(h)t[r]=i(c,f,s,o,u);else if(c===c?c!==l:l===l)t[r]=c}function zr(t){return function(n){return n==null?e:n[t]}}function Wr(e,t){return e+fn(Ln()*(t-e+1))}function Xr(e,t,n,r,i){return i(e,function(e,i,s){n=r?(r=!1,e):t(n,e,i,s)}),n}function $r(e,t,n){var r=-1,i=e.length;t=t==null?0:+t||0,t<0&&(t=-t>i?0:i+t),n=typeof n=="undefined"||n>i?i:+n||0,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;var s=O(i);while(++r<i)s[r]=e[r+t];return s}function Jr(e,t){var n;return Sr(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function Kr(e,t){var n=e.length;e.sort(t);while(n--)e[n]=e[n].value;return e}function Qr(t,n,r){var i=-1,s=t.length,o=Ji(s)?O(s):[];return Sr(t,function(t){var r=n.length,s=O(r);while(r--)s[r]=t==null?e:t[n[r]];o[++i]={criteria:s,index:i,value:t}}),Kr(o,function(e,t){return jt(e,t,r)})}function Gr(e,t){var n=0;return Sr(e,function(e,r,i){n+=+t(e,r,i)||0}),n}function Yr(e,t){var n=-1,r=qi(),i=e.length,s=r==Ot,o=s&&i>=200,u=o?pi():null,a=[];u?(r=Yn,s=!1):(o=!1,u=t?[]:a);e:while(++n<i){var f=e[n],l=t?t(f,n,e):f;if(s&&f===f){var c=u.length;while(c--)if(u[c]===l)continue e;t&&u.push(l),a.push(f)}else r(u,l,0)<0&&((t||o)&&u.push(l),a.push(f))}return a}function Zr(e,t){var n=-1,r=t.length,i=O(r);while(++n<r)i[n]=e[t[n]];return i}function ei(e,t,n,r){var i=e.length,s=r?i:-1;while((r?s--:++s<i)&&t(e[s],s,e));return n?$r(e,r?0:s,r?s+1:i):$r(e,r?s+1:0,r?i:s)}function ti(e,t){var n=e;n instanceof Un&&(n=n.value());var r=-1,i=t.length;while(++r<i){var s=[n],o=t[r];cn.apply(s,o.args),n=o.func.apply(o.thisArg,s)}return n}function ni(e,t,n){var r=0,i=e?e.length:r;if(typeof t=="number"&&t===t&&i<=Dn){while(r<i){var s=r+i>>>1,o=e[s];(n?o<=t:o<t)?r=s+1:i=s}return i}return ri(e,t,ma,n)}function ri(e,t,n,r){t=n(t);var i=0,s=e?e.length:0,o=t!==t,u=typeof t=="undefined";while(i<s){var a=fn((i+s)/2),f=n(e[a]),l=f===f;if(o)var c=l||r;else u?c=l&&(r||typeof f!="undefined"):c=r?f<=t:f<t;c?i=a+1:s=a}return Tn(s,_n)}function ii(e,t,n){if(typeof e!="function")return ma;if(typeof t=="undefined")return e;switch(n){case 1:return function(n){return e.call(t,n)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,s){return e.call(t,n,r,i,s)};case 5:return function(n,r,i,s,o){return e.call(t,n,r,i,s,o)}}return function(){return e.apply(t,arguments)}}function si(e){return on.call(e,0)}function oi(e,t,n){var r=n.length,i=-1,s=xn(e.length-r,0),o=-1,u=t.length,a=O(s+u);while(++o<u)a[o]=t[o];while(++i<r)a[n[i]]=e[i];while(s--)a[o++]=e[i++];return a}function ui(e,t,n){var r=-1,i=n.length,s=-1,o=xn(e.length-i,0),u=-1,a=t.length,f=O(o+a);while(++s<o)f[s]=e[s];var l=s;while(++u<a)f[l+u]=t[u];while(++r<i)f[l+n[r]]=e[s++];return f}function ai(e,t){return function(n,r,i){var s=t?t():{};r=ji(r,i,3);if(Yo(n)){var o=-1,u=n.length;while(++o<u){var a=n[o];e(s,a,r(a,o,n),n)}}else Sr(n,function(t,n,i){e(s,t,r(t,n,i),i)});return s}}function fi(e){return function(){var t=arguments,n=t.length,r=t[0];if(n<2||r==null)return r;var i=t[n-2],s=t[n-1],o=t[3];n>3&&typeof i=="function"?(i=ii(i,s,5),n-=2):(i=n>2&&typeof s=="function"?s:null,n-=i?1:0),o&&Vi(t[1],t[2],o)&&(i=n==3?null:i,n=2);var u=0;while(++u<n){var a=t[u];a&&e(r,a,i)}return r}}function li(e,t){return function(n,r){var i=n?n.length:0;if(!Ji(i))return e(n,r);var s=t?i:-1,o=is(n);while(t?s--:++s<i)if(r(o[s],s,o)===!1)break;return n}}function ci(e){return function(t,n,r){var i=is(t),s=r(t),o=s.length,u=e?o:-1;while(e?u--:++u<o){var a=s[u];if(n(i[a],a,i)===!1)break}return t}}function hi(e,t){function r(){var i=this&&this!==kt&&this instanceof r?n:e;return i.apply(t,arguments)}var n=vi(e);return r}function di(e){return function(t){var n=-1,r=ha($u(t)),i=r.length,s="";while(++n<i)s=e(s,r[n],n);return s}}function vi(e){return function(){var t=br(e.prototype),n=e.apply(t,arguments);return uu(n)?n:t}}function mi(e){function t(n,r,i){i&&Vi(n,r,i)&&(r=null);var s=_i(n,e,null,null,null,null,null,r);return s.placeholder=t.placeholder,s}return t}function gi(e,t){return function(n,r,i){i&&Vi(n,r,i)&&(r=null);var s=ji(),o=r==null;if(s!==gr||!o)o=!1,r=s(r,i,3);if(o){var u=Yo(n);if(!!u||!vu(n))return e(u?n:rs(n));r=Dt}return Bi(n,r,t)}}function yi(t,n){return function(r,i,s){i=ji(i,s,3);if(Yo(r)){var o=At(r,i,n);return o>-1?r[o]:e}return kr(r,i,t)}}function bi(e){return function(t,n,r){return!t||!t.length?-1:(n=ji(n,r,3),At(t,n,e))}}function wi(e){return function(t,n,r){return n=ji(n,r,3),kr(t,n,e,!0)}}function Ei(e){return function(){var t=arguments.length;if(!t)return function(){return arguments[0]};var n,r=e?t:-1,i=0,s=O(t);while(e?r--:++r<t){var o=s[i++]=arguments[r];if(typeof o!="function")throw new xt(y);var u=n?"":Ii(o);n=u=="wrapper"?new qn([]):n}r=n?-1:t;while(++r<t){o=s[r],u=Ii(o);var a=u=="wrapper"?Fi(o):null;a&&$i(a[0])?n=n[Ii(a[0])].apply(n,a[3]):n=o.length==1&&$i(o)?n[u]():n.thru(o)}return function(){var e=arguments;if(n&&e.length==1&&Yo(e[0]))return n.plant(e[0]).value();var r=0,i=s[r].apply(this,e);while(++r<t)i=s[r].call(this,i);return i}}}function Si(e,t){return function(n,r,i){return typeof r=="function"&&typeof i=="undefined"&&Yo(n)?e(n,r):t(n,ii(r,i,3))}}function xi(e){return function(t,n,r){if(typeof n!="function"||typeof r!="undefined")n=ii(n,r,3);return e(t,n,Du)}}function Ti(e){return function(t,n,r){if(typeof n!="function"||typeof r!="undefined")n=ii(n,r,3);return e(t,n)}}function Ni(e){return function(t,n,r){return t=_t(t),t&&(e?t:"")+Ai(t,n,r)+(e?"":t)}}function Ci(e){var t=Xo(function(n,r){var i=Wt(r,t.placeholder);return _i(n,e,null,r,i)});return t}function ki(e,t){return function(n,r,i,s){var o=arguments.length<3;return typeof r=="function"&&typeof s=="undefined"&&Yo(n)?e(n,r,i,o):Xr(n,ji(r,s,4),i,o,t)}}function Li(t,l,c,h,p,d,v,m,g,y){function k(){var i=arguments.length,s=i,o=O(i);while(s--)o[s]=arguments[s];h&&(o=oi(o,h,p)),d&&(o=ui(o,d,v));if(S||T){var f=k.placeholder,L=Wt(o,f);i-=L.length;if(i<y){var A=m?er(m):null,M=xn(y-i,0),_=S?L:null,D=S?null:L,P=S?o:null,H=S?null:o;l|=S?u:a,l&=~(S?a:u),x||(l&=~(n|r));var B=[t,l,c,P,_,H,D,A,g,M],j=Li.apply(e,B);return $i(t)&&es(j,B),j.placeholder=f,j}}var F=w?c:this;E&&(t=F[C]),m&&(o=Zi(o,m)),b&&g<o.length&&(o.length=g);var I=this&&this!==kt&&this instanceof k?N||vi(t):t;return I.apply(F,o)}var b=l&f,w=l&n,E=l&r,S=l&s,x=l&i,T=l&o,N=!E&&vi(t),C=t;return k}function Ai(e,t,n){var r=e.length;t=+t;if(r>=t||!En(t))return"";var i=t-r;return n=n==null?" ":n+"",na(n,un(i/n.length)).slice(0,i)}function Oi(e,t,r,i){function u(){var t=-1,n=arguments.length,a=-1,f=i.length,l=O(n+f);while(++a<f)l[a]=i[a];while(n--)l[a++]=arguments[++t];var c=this&&this!==kt&&this instanceof u?o:e;return c.apply(s?r:this,l)}var s=t&n,o=vi(e);return u}function Mi(e){return function(t,n,r,i){var s=ji(r);return s===gr&&r==null?ni(t,n,e):ri(t,n,s(r,i,1),e)}}function _i(t,i,s,o,f,l,c,h){var p=i&r;if(!p&&typeof t!="function")throw new xt(y);var d=o?o.length:0;d||(i&=~(u|a),o=f=null),d-=f?f.length:0;if(i&a){var v=o,m=f;o=f=null}var g=p?null:Fi(t),b=[t,i,s,o,f,v,m,l,c,h];g&&(Qi(b,g),i=b[1],h=b[9]),b[9]=h==null?p?0:t.length:xn(h-d,0)||0;if(i==n)var w=hi(b[0],b[2]);else i!=u&&i!=(n|u)||!!b[4].length?w=Li.apply(e,b):w=Oi.apply(e,b);var E=g?Vr:es;return E(w,b)}function Di(t,n,r,i,s,o,u){var a=-1,f=t.length,l=n.length,c=!0;if(f!=l&&!(s&&l>f))return!1;while(c&&++a<f){var h=t[a],p=n[a];c=e,i&&(c=s?i(p,h,a):i(h,p,a));if(typeof c=="undefined")if(s){var d=l;while(d--){p=n[d],c=h&&h===p||r(h,p,i,s,o,u);if(c)break}}else c=h&&h===p||r(h,p,i,s,o,u)}return!!c}function Pi(e,t,n){switch(n){case S:case x:return+e==+t;case T:return e.name==t.name&&e.message==t.message;case k:return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case A:case M:return e==t+""}return!1}function Hi(t,n,r,i,s,o,u){var a=_u(t),f=a.length,l=_u(n),c=l.length;if(f!=c&&!s)return!1;var h=s,p=-1;while(++p<f){var d=a[p],v=s?d in n:Zt.call(n,d);if(v){var m=t[d],g=n[d];v=e,i&&(v=s?i(g,m,d):i(m,g,d)),typeof v=="undefined"&&(v=m&&m===g||r(m,g,i,s,o,u))}if(!v)return!1;h||(h=d=="constructor")}if(!h){var y=t.constructor,b=n.constructor;if(y!=b&&"constructor"in t&&"constructor"in n&&!(typeof y=="function"&&y instanceof y&&typeof b=="function"&&b instanceof b))return!1}return!0}function Bi(e,t,n){var r=n?On:An,i=r,s=i;return Sr(e,function(e,o,u){var a=t(e,o,u);if((n?a<i:a>i)||a===r&&a===s)i=a,s=e}),s}function ji(e,t,n){var r=Fn.callback||da;return r=r===da?gr:r,n?r(e,t,n):r}function qi(e,t,n){var r=Fn.indexOf||bs;return r=r===bs?Ot:r,e?r(e,t,n):r}function Ri(e,t,n){var r=-1,i=n?n.length:0;while(++r<i){var s=n[r],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=Tn(t,e+o);break;case"takeRight":e=xn(e,t-o)}}return{start:e,end:t}}function Ui(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&Zt.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function zi(e){var t=e.constructor;return typeof t=="function"&&t instanceof t||(t=wt),new t}function Wi(e,t,n){var r=e.constructor;switch(t){case D:return si(e);case S:case x:return new r(+e);case P:case H:case B:case j:case F:case I:case q:case R:case U:var i=e.buffer;return new r(n?si(i):i,e.byteOffset,e.length);case k:case M:return new r(e);case A:var s=new r(e.source,tt.exec(e));s.lastIndex=e.lastIndex}return s}function Xi(e,t){return e=+e,t=t==null?Hn:t,e>-1&&e%1==0&&e<t}function Vi(e,t,n){if(!uu(n))return!1;var r=typeof t;if(r=="number")var i=n.length,s=Ji(i)&&Xi(t,i);else s=r=="string"&&t in n;if(s){var o=n[t];return e===e?e===o:o!==o}return!1}function $i(e){var t=Ii(e);return!!t&&e===Fn[t]&&t in Un.prototype}function Ji(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Hn}function Ki(e){return e===e&&(e===0?1/e>0:!uu(e))}function Qi(e,t){var r=e[1],o=t[1],u=r|o,a=u<f,c=o==f&&r==s||o==f&&r==l&&e[7].length<=t[8]||o==(f|l)&&r==s;if(!a&&!c)return e;o&n&&(e[2]=t[2],u|=r&n?0:i);var h=t[3];if(h){var p=e[3];e[3]=p?oi(p,h,t[4]):er(h),e[4]=p?Wt(e[3],b):er(t[4])}return h=t[5],h&&(p=e[5],e[5]=p?ui(p,h,t[6]):er(h),e[6]=p?Wt(e[5],b):er(t[6])),h=t[7],h&&(e[7]=er(h)),o&f&&(e[8]=e[8]==null?t[8]:Tn(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=u,e}function Gi(e,t){e=is(e);var n=-1,r=t.length,i={};while(++n<r){var s=t[n];s in e&&(i[s]=e[s])}return i}function Yi(e,t){var n={};return Mr(e,function(e,r,i){t(e,r,i)&&(n[r]=e)}),n}function Zi(t,n){var r=t.length,i=Tn(n.length,r),s=er(t);while(i--){var o=n[i];t[i]=Xi(o,r)?s[o]:e}return t}function ts(e){var t,n=Fn.support;if(!Ut(e)||tn.call(e)!=L||!Zt.call(e,"constructor")&&(t=e.constructor,typeof t=="function"&&!(t instanceof t)))return!1;var r;return Mr(e,function(e,t){r=t}),typeof r=="undefined"||Zt.call(e,r)}function ns(e){var t=Du(e),n=t.length,r=n&&e.length,i=Fn.support,s=r&&Ji(r)&&(Yo(e)||i.nonEnumArgs&&Go(e)),o=-1,u=[];while(++o<n){var a=t[o];(s&&Xi(a,r)||Zt.call(e,a))&&u.push(a)}return u}function rs(e){return e==null?[]:Ji(e.length)?uu(e)?e:wt(e):Ru(e)}function is(e){return uu(e)?e:wt(e)}function ss(e){return e instanceof Un?e.clone():new qn(e.__wrapped__,e.__chain__,er(e.__actions__))}function os(e,t,n){(n?Vi(e,t,n):t==null)?t=1:t=xn(+t||1,1);var r=0,i=e?e.length:0,s=-1,o=O(un(i/t));while(r<i)o[++s]=$r(e,r,r+=t);return o}function us(e){var t=-1,n=e?e.length:0,r=-1,i=[];while(++t<n){var s=e[t];s&&(i[++r]=s)}return i}function fs(e,t,n){var r=e?e.length:0;if(!r)return[];if(n?Vi(e,t,n):t==null)t=1;return $r(e,t<0?0:t)}function ls(e,t,n){var r=e?e.length:0;if(!r)return[];if(n?Vi(e,t,n):t==null)t=1;return t=r-(+t||0),$r(e,0,t<0?0:t)}function cs(e,t,n){return e&&e.length?ei(e,ji(t,n,3),!0,!0):[]}function hs(e,t,n){return e&&e.length?ei(e,ji(t,n,3),!0):[]}function ps(e,t,n,r){var i=e?e.length:0;return i?(n&&typeof n!="number"&&Vi(e,t,n)&&(n=0,r=i),Nr(e,t,n,r)):[]}function ms(t){return t?t[0]:e}function gs(e,t,n){var r=e?e.length:0;return n&&Vi(e,t,n)&&(t=!1),r?Lr(e,t):[]}function ys(e){var t=e?e.length:0;return t?Lr(e,!0):[]}function bs(e,t,n){var r=e?e.length:0;if(!r)return-1;if(typeof n=="number")n=n<0?xn(r+n,0):n;else if(n){var i=ni(e,t),s=e[i];return(t===t?t===s:s!==s)?i:-1}return Ot(e,t,n||0)}function ws(e){return ls(e,1)}function Es(){var e=[],t=-1,n=arguments.length,r=[],i=qi(),s=i==Ot;while(++t<n){var o=arguments[t];if(Yo(o)||Go(o))e.push(o),r.push(s&&o.length>=120?pi(t&&o):null)}n=e.length;var u=e[0],a=-1,f=u?u.length:0,l=[],c=r[0];e:while(++a<f){o=u[a];if((c?Yn(c,o):i(l,o,0))<0){t=n;while(--t){var h=r[t];if((h?Yn(h,o):i(e[t],o,0))<0)continue e}c&&c.push(o),l.push(o)}}return l}function Ss(t){var n=t?t.length:0;return n?t[n-1]:e}function xs(e,t,n){var r=e?e.length:0;if(!r)return-1;var i=r;if(typeof n=="number")i=(n<0?xn(r+n,0):Tn(n||0,r-1))+1;else if(n){i=ni(e,t,!0)-1;var s=e[i];return(t===t?t===s:s!==s)?i:-1}if(t!==t)return Rt(e,i,!0);while(i--)if(e[i]===t)return i;return-1}function Ts(){var e=arguments,t=e[0];if(!t||!t.length)return t;var n=0,r=qi(),i=e.length;while(++n<i){var s=0,o=e[n];while((s=r(t,o,s))>-1)vn.call(t,s,1)}return t}function Cs(e,t,n){var r=-1,i=e?e.length:0,s=[];t=ji(t,n,3);while(++r<i){var o=e[r];t(o,r,e)&&(s.push(o),vn.call(e,r--,1),i--)}return s}function ks(e){return fs(e,1)}function Ls(e,t,n){var r=e?e.length:0;return r?(n&&typeof n!="number"&&Vi(e,t,n)&&(t=0,n=r),$r(e,t,n)):[]}function Ms(e,t,n){var r=e?e.length:0;if(!r)return[];if(n?Vi(e,t,n):t==null)t=1;return $r(e,0,t<0?0:t)}function _s(e,t,n){var r=e?e.length:0;if(!r)return[];if(n?Vi(e,t,n):t==null)t=1;return t=r-(+t||0),$r(e,t<0?0:t)}function Ds(e,t,n){return e&&e.length?ei(e,ji(t,n,3),!1,!0):[]}function Ps(e,t,n){return e&&e.length?ei(e,ji(t,n,3)):[]}function Bs(e,t,n,r){var i=e?e.length:0;if(!i)return[];t!=null&&typeof t!="boolean"&&(r=n,n=Vi(e,t,r)?null:t,t=!1);var s=ji();if(s!==gr||n!=null)n=s(n,r,3);return t&&qi()==Ot?Xt(e,n):Yr(e,n)}function js(e){var t=-1,n=(e&&e.length&&or(sr(e,Yt)))>>>0,r=O(n);while(++t<n)r[t]=sr(e,zr(t));return r}function Is(){var e=-1,t=arguments.length;while(++e<t){var n=arguments[e];if(Yo(n)||Go(n))var r=r?Er(r,n).concat(Er(n,r)):n}return r?Yr(r):[]}function Rs(e,t){var n=-1,r=e?e.length:0,i={};r&&!t&&!Yo(e[0])&&(t=[]);while(++n<r){var s=e[n];t?i[s]=t[n]:s&&(i[s[0]]=s[1])}return i}function Us(e){var t=Fn(e);return t.__chain__=!0,t}function zs(e,t,n){return t.call(n,e),e}function Ws(e,t,n){return t.call(n,e)}function Xs(){return Us(this)}function Vs(){return new qn(this.value(),this.__chain__)}function $s(e){var t,n=this;while(n instanceof In){var r=ss(n);t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t}function Js(){var e=this.__wrapped__;return e instanceof Un?(this.__actions__.length&&(e=new Un(this)),new qn(e.reverse(),this.__chain__)):this.thru(function(e){return e.reverse()})}function Ks(){return this.value()+""}function Qs(){return ti(this.__wrapped__,this.__actions__)}function Zs(e,t,n){var r=Yo(e)?rr:Tr;n&&Vi(e,t,n)&&(t=null);if(typeof t!="function"||typeof n!="undefined")t=ji(t,n,3);return r(e,t)}function eo(e,t,n){var r=Yo(e)?ir:Cr;return t=ji(t,n,3),r(e,t)}function ro(e,t){return to(e,Ir(t))}function uo(e,t,n,r){var i=e?e.length:0;return Ji(i)||(e=Ru(e),i=e.length),i?(typeof n!="number"||r&&Vi(t,n,r)?n=0:n=n<0?xn(i+n,0):n||0,typeof e=="string"||!Yo(e)&&vu(e)?n<i&&e.indexOf(t,n)>-1:qi(e,t,n)>-1):!1}function lo(e,t,n){var r=Yo(e)?sr:Fr;return t=ji(t,n,3),r(e,t)}function ho(e,t){return lo(e,zr(t))}function mo(e,t,n){var r=Yo(e)?ir:Cr;return t=ji(t,n,3),r(e,function(e,n,r){return!t(e,n,r)})}function go(t,n,r){if(r?Vi(t,n,r):n==null){t=rs(t);var i=t.length;return i>0?t[Wr(0,i-1)]:e}var s=yo(t);return s.length=Tn(n<0?0:+n||0,s.length),s}function yo(e){e=rs(e);var t=-1,n=e.length,r=O(n);while(++t<n){var i=Wr(0,t);t!=i&&(r[t]=r[i]),r[i]=e[t]}return r}function bo(e){var t=e?e.length:0;return Ji(t)?t:_u(e).length}function wo(e,t,n){var r=Yo(e)?lr:Jr;n&&Vi(e,t,n)&&(t=null);if(typeof t!="function"||typeof n!="undefined")t=ji(t,n,3);return r(e,t)}function Eo(e,t,n){if(e==null)return[];var r=-1,i=e.length,s=Ji(i)?O(i):[];return n&&Vi(e,t,n)&&(t=null),t=ji(t,n,3),Sr(e,function(e,n,i){s[++r]={criteria:t(e,n,i),index:r,value:e}}),Kr(s,Bt)}function So(){var e=arguments,t=e[0],n=e[3],r=0,i=e.length-1;if(t==null)return[];var s=O(i);while(r<i)s[r]=e[++r];return n&&Vi(e[1],e[2],n)&&(s=e[1]),Qr(t,Lr(s),[])}function xo(e,t,n,r){return e==null?[]:(r&&Vi(t,n,r)&&(n=null),Yo(t)||(t=t==null?[]:[t]),Yo(n)||(n=n==null?[]:[n]),Qr(e,t,n))}function To(e,t){return eo(e,Ir(t))}function Co(e,t){if(typeof t!="function"){if(typeof e!="function")throw new xt(y);var n=e;e=t,t=n}return e=En(e=+e)?e:0,function(){if(--e<1)return t.apply(this,arguments)}}function ko(e,t,n){return n&&Vi(e,t,n)&&(t=null),t=e&&t==null?e.length:xn(+t||0,0),_i(e,f,null,null,null,null,t)}function Lo(e,t){var n;if(typeof t!="function"){if(typeof e!="function")throw new xt(y);var r=e;e=t,t=r}return function(){return--e>0?n=t.apply(this,arguments):t=null,n}}function Po(t,n,r){function v(){f&&an(f),s&&an(s),s=f=l=e}function m(){var r=n-(No()-u);if(r<=0||r>n){s&&an(s);var h=l;s=f=l=e,h&&(c=No(),o=t.apply(a,i),!f&&!s&&(i=a=null))}else f=dn(m,r)}function g(){f&&an(f),s=f=l=e;if(p||h!==n)c=No(),o=t.apply(a,i),!f&&!s&&(i=a=null)}function b(){i=arguments,u=No(),a=this,l=p&&(f||!d);if(h===!1)var e=d&&!f;else{!s&&!d&&(c=u);var r=h-(u-c),v=r<=0||r>h;v?(s&&(s=an(s)),c=u,o=t.apply(a,i)):s||(s=dn(g,r))}return v&&f?f=an(f):!f&&n!==h&&(f=dn(m,n)),e&&(v=!0,o=t.apply(a,i)),v&&!f&&!s&&(i=a=null),o}var i,s,o,u,a,f,l,c=0,h=!1,p=!0;if(typeof t!="function")throw new xt(y);n=n<0?0:+n||0;if(r===!0){var d=!0;p=!1}else uu(r)&&(d=r.leading,h="maxWait"in r&&xn(+r.maxWait||0,n),p="trailing"in r?r.trailing:p);return b.cancel=v,b}function Io(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new xt(y);var n=function(){var r=arguments,i=n.cache,s=t?t.apply(this,r):r[0];if(i.has(s))return i.get(s);var o=e.apply(this,r);return i.set(s,o),o};return n.cache=new Io.Cache,n}function qo(e){if(typeof e!="function")throw new xt(y);return function(){return!e.apply(this,arguments)}}function Ro(e){return Lo(e,2)}function Xo(e,t){if(typeof e!="function")throw new xt(y);return t=xn(typeof t=="undefined"?e.length-1:+t||0,0),function(){var n=arguments,r=-1,i=xn(n.length-t,0),s=O(i);while(++r<i)s[r]=n[t+r];switch(t){case 0:return e.call(this,s);case 1:return e.call(this,n[0],s);case 2:return e.call(this,n[0],n[1],s)}var o=O(t+1);r=-1;while(++r<t)o[r]=n[r];return o[t]=s,e.apply(this,o)}}function Vo(e){if(typeof e!="function")throw new xt(y);return function(t){return e.apply(this,t)}}function $o(e,t,n){var r=!0,i=!0;if(typeof e!="function")throw new xt(y);return n===!1?r=!1:uu(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),vt.leading=r,vt.maxWait=+t,vt.trailing=i,Po(e,t,vt)}function Jo(e,t){return t=t==null?ma:t,_i(t,u,null,[e],[])}function Ko(e,t,n,r){return t&&typeof t!="boolean"&&Vi(e,t,n)?t=!1:typeof t=="function"&&(r=n,n=t,t=!1),n=typeof n=="function"&&ii(n,r,1),yr(e,t,n)}function Qo(e,t,n){return t=typeof t=="function"&&ii(t,n,1),yr(e,!0,t)}function Go(t){var n=Ut(t)?t.length:e;return Ji(n)&&tn.call(t)==w}function Zo(e){return e===!0||e===!1||Ut(e)&&tn.call(e)==S}function eu(e){return Ut(e)&&tn.call(e)==x}function tu(e){return!!e&&e.nodeType===1&&Ut(e)&&tn.call(e).indexOf("Element")>-1}function nu(e){if(e==null)return!0;var t=e.length;return Ji(t)&&(Yo(e)||vu(e)||Go(e)||Ut(e)&&ou(e.splice))?!t:!_u(e).length}function ru(t,n,r,i){r=typeof r=="function"&&ii(r,i,3);if(!r&&Ki(t)&&Ki(n))return t===n;var s=r?r(t,n):e;return typeof s=="undefined"?Hr(t,n,r):!!s}function iu(e){return Ut(e)&&typeof e.message=="string"&&tn.call(e)==T}function uu(e){var t=typeof e;return t=="function"||!!e&&t=="object"}function au(e,t,n,r){var i=_u(t),s=i.length;if(!s)return!0;if(e==null)return!1;n=typeof n=="function"&&ii(n,r,3);if(!n&&s==1){var o=i[0],u=t[o];if(Ki(u))return u===e[o]&&(typeof u!="undefined"||o in is(e))}var a=O(s),f=O(s);while(s--)u=a[s]=t[i[s]],f[s]=Ki(u);return jr(is(e),i,a,f,n)}function fu(e){return hu(e)&&e!=+e}function lu(e){return e==null?!1:tn.call(e)==N?rn.test(Gt.call(e)):Ut(e)&&rt.test(e)}function cu(e){return e===null}function hu(e){return typeof e=="number"||Ut(e)&&tn.call(e)==k}function du(e){return Ut(e)&&tn.call(e)==A||!1}function vu(e){return typeof e=="string"||Ut(e)&&tn.call(e)==M}function mu(e){return Ut(e)&&Ji(e.length)&&!!pt[tn.call(e)]}function gu(e){return typeof e=="undefined"}function yu(e){var t=e?e.length:0;return Ji(t)?t?er(e):[]:Ru(e)}function bu(e){return mr(e,Du(e))}function Eu(e,t,n){var r=br(e);return n&&Vi(e,t,n)&&(t=null),t?mr(t,r,_u(t)):r}function Au(e){return Pr(e,Du(e))}function Ou(e,t){return e?Zt.call(e,t):!1}function Mu(e,t,n){n&&Vi(e,t,n)&&(t=null);var r=-1,i=_u(e),s=i.length,o={};while(++r<s){var u=i[r],a=e[u];t?Zt.call(o,a)?o[a].push(u):o[a]=[u]:o[a]=u}return o}function Du(e){if(e==null)return[];uu(e)||(e=wt(e));var t=e.length;t=t&&Ji(t)&&(Yo(e)||Rn.nonEnumArgs&&Go(e))&&t||0;var n=e.constructor,r=-1,i=typeof n=="function"&&n.prototype===e,s=O(t),o=t>0;while(++r<t)s[r]=r+"";for(var u in e)(!o||!Xi(u,t))&&(u!="constructor"||!i&&!!Zt.call(e,u))&&s.push(u);return s}function Pu(e,t,n){var r={};return t=ji(t,n,3),_r(e,function(e,n,i){r[n]=t(e,n,i)}),r}function ju(e){var t=-1,n=_u(e),r=n.length,i=O(r);while(++t<r){var s=n[t];i[t]=[s,e[s]]}return i}function Iu(t,n,r){var i=t==null?e:t[n];return typeof i=="undefined"&&(i=r),ou(i)?i.call(t):i}function qu(e,t,n,r){var i=Yo(e)||mu(e);t=ji(t,r,4);if(n==null)if(i||uu(e)){var s=e.constructor;i?n=Yo(e)?new s:[]:n=br(ou(s)&&s.prototype)}else n={};return(i?tr:_r)(e,function(e,r,i){return t(n,e,r,i)}),n}function Ru(e){return Zr(e,_u(e))}function Uu(e){return Zr(e,Du(e))}function zu(e,t,n){return t=+t||0,typeof n=="undefined"?(n=t,t=0):n=+n||0,e>=t&&e<n}function Wu(e,t,n){n&&Vi(e,t,n)&&(t=n=null);var r=e==null,i=t==null;n==null&&(i&&typeof e=="boolean"?(n=e,e=1):typeof t=="boolean"&&(n=t,i=!0)),r&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0;if(n||e%1||t%1){var s=Ln();return Tn(e+s*(t-e+parseFloat("1e-"+((s+"").length-1))),t)}return Wr(e,t)}function Vu(e){return e=_t(e),e&&e.charAt(0).toUpperCase()+e.slice(1)}function $u(e){return e=_t(e),e&&e.replace(it,Ft).replace(Z,"")}function Ju(e,t,n){e=_t(e),t+="";var r=e.length;return n=typeof n=="undefined"?r:Tn(n<0?0:+n||0,r),n-=t.length,n>=0&&e.indexOf(t,n)==n}function Ku(e){return e=_t(e),e&&K.test(e)?e.replace($,It):e}function Qu(e){return e=_t(e),e&&ut.test(e)?e.replace(ot,"\\$&"):e}function Yu(e,t,n){e=_t(e),t=+t;var r=e.length;if(r>=t||!En(t))return e;var i=(t-r)/2,s=fn(i),o=un(i);return n=Ai("",o,n),n.slice(0,s)+e+n}function ta(e,t,n){return n&&Vi(e,t,n)&&(t=0),kn(e,t)}function na(e,t){var n="";e=_t(e),t=+t;if(t<1||!e||!En(t))return n;do t%2&&(n+=e),t=fn(t/2),e+=e;while(t);return n}function sa(e,t,n){return e=_t(e),n=n==null?0:Tn(n<0?0:+n||0,e.length),e.lastIndexOf(t,n)==n}function oa(t,n,r){var i=Fn.templateSettings;r&&Vi(t,n,r)&&(n=r=null),t=_t(t),n=dr(dr({},r||n),i,pr);var s=dr(dr({},n.imports),i.imports,pr),o=_u(s),u=Zr(s,o),a,f,l=0,c=n.interpolate||st,h="__p += '",p=Et((n.escape||st).source+"|"+c.source+"|"+(c===Y?et:st).source+"|"+(n.evaluate||st).source+"|$","g"),d="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++ht+"]")+"\n";t.replace(p,function(e,n,r,i,s,o){return r||(r=i),h+=t.slice(l,o).replace(at,qt),n&&(a=!0,h+="' +\n__e("+n+") +\n'"),s&&(f=!0,h+="';\n"+s+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),l=o+e.length,e}),h+="';\n";var v=n.variable;v||(h="with (obj) {\n"+h+"\n}\n"),h=(f?h.replace(z,""):h).replace(W,"$1").replace(X,"$1;"),h="function("+(v||"obj")+") {\n"+(v?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var m=pa(function(){return gt(o,d+"return "+h).apply(e,u)});m.source=h;if(iu(m))throw m;return m}function ua(e,t,n){var r=e;return e=_t(e),e?(n?Vi(r,t,n):t==null)?e.slice(Vt(e),$t(e)+1):(t+="",e.slice(Pt(e,t),Ht(e,t)+1)):e}function aa(e,t,n){var r=e;return e=_t(e),e?(n?Vi(r,t,n):t==null)?e.slice(Vt(e)):e.slice(Pt(e,t+"")):e}function fa(e,t,n){var r=e;return e=_t(e),e?(n?Vi(r,t,n):t==null)?e.slice(0,$t(e)+1):e.slice(0,Ht(e,t+"")+1):e}function la(e,t,n){n&&Vi(e,t,n)&&(t=null);var r=c,i=h;if(t!=null)if(uu(t)){var s="separator"in t?t.separator:s;r="length"in t?+t.length||0:r,i="omission"in t?_t(t.omission):i}else r=+t||0;e=_t(e);if(r>=e.length)return e;var o=r-i.length;if(o<1)return i;var u=e.slice(0,o);if(s==null)return u+i;if(du(s)){if(e.slice(o).search(s)){var a,f,l=e.slice(0,o);s.global||(s=Et(s.source,(tt.exec(s)||"")+"g")),s.lastIndex=0;while(a=s.exec(l))f=a.index;u=u.slice(0,f==null?o:f)}}else if(e.indexOf(s,o)!=o){var p=u.lastIndexOf(s);p>-1&&(u=u.slice(0,p))}return u+i}function ca(e){return e=_t(e),e&&J.test(e)?e.replace(V,Jt):e}function ha(e,t,n){return n&&Vi(e,t,n)&&(t=null),e=_t(e),e.match(t||ft)||[]}function da(e,t,n){return n&&Vi(e,t,n)&&(t=null),Ut(e)?ga(e):gr(e,t)}function va(e){return function(){return e}}function ma(e){return e}function ga(e){return Ir(yr(e,!0))}function ya(e,t){return qr(e+"",yr(t,!0))}function ba(e,t,n){if(n==null){var r=uu(t),i=r&&_u(t),s=i&&i.length&&Pr(t,i);if(s?!s.length:!r)s=!1,n=t,t=e,e=this}s||(s=Pr(t,_u(t)));var o=!0,u=-1,a=ou(e),f=s.length;n===!1?o=!1:uu(n)&&"chain"in n&&(o=n.chain);while(++u<f){var l=s[u],c=t[l];e[l]=c,a&&(e.prototype[l]=function(t){return function(){var n=this.__chain__;if(o||n){var r=e(this.__wrapped__),i=r.__actions__=er(this.__actions__);return i.push({func:t,args:arguments,thisArg:e}),r.__chain__=n,r}var s=[this.value()];return cn.apply(s,arguments),t.apply(e,s)}}(c))}return e}function wa(){return C._=nn,this}function Ea(){}function Sa(e){return zr(e+"")}function xa(t){return function(n){return t==null?e:t[n]}}function Ta(e,t,n){n&&Vi(e,t,n)&&(t=n=null),e=+e||0,n=n==null?1:+n||0,t==null?(t=e,e=0):t=+t||0;var r=-1,i=xn(un((t-e)/(n||1)),0),s=O(i);while(++r<i)s[r]=e,e+=n;return s}function Na(e,t,n){e=+e;if(e<1||!En(e))return[];var r=-1,i=O(Tn(e,Mn));t=ii(t,n,1);while(++r<e)r<Mn?i[r]=t(r):t(r);return i}function Ca(e){var t=++en;return _t(e)+t}function ka(e,t){return e+t}function Oa(e,t,n){n&&Vi(e,t,n)&&(t=null);var r=ji(),i=t==null;if(r!==gr||!i)i=!1,t=r(t,n,3);return i?cr(Yo(e)?e:rs(e)):Gr(e,t)}C=C?Qt.defaults(kt.Object(),C,Qt.pick(kt,ct)):kt;var O=C.Array,_=C.Date,mt=C.Error,gt=C.Function,yt=C.Math,bt=C.Number,wt=C.Object,Et=C.RegExp,St=C.String,xt=C.TypeError,Tt=O.prototype,Nt=wt.prototype,Ct=St.prototype,zt=(zt=C.window)&&zt.document,Gt=gt.prototype.toString,Yt=zr("length"),Zt=Nt.hasOwnProperty,en=0,tn=Nt.toString,nn=C._,rn=Et("^"+Qu(tn).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),sn=lu(sn=C.ArrayBuffer)&&sn,on=lu(on=sn&&(new sn(0)).slice)&&on,un=yt.ceil,an=C.clearTimeout,fn=yt.floor,ln=lu(ln=wt.getPrototypeOf)&&ln,cn=Tt.push,hn=Nt.propertyIsEnumerable,pn=lu(pn=C.Set)&&pn,dn=C.setTimeout,vn=Tt.splice,mn=lu(mn=C.Uint8Array)&&mn,gn=lu(gn=C.WeakMap)&&gn,yn=function(){try{var e=lu(e=C.Float64Array)&&e,t=new e(new sn(10),0,1)&&e}catch(n){}return t}(),bn=lu(bn=O.isArray)&&bn,wn=lu(wn=wt.create)&&wn,En=C.isFinite,Sn=lu(Sn=wt.keys)&&Sn,xn=yt.max,Tn=yt.min,Nn=lu(Nn=_.now)&&Nn,Cn=lu(Cn=bt.isFinite)&&Cn,kn=C.parseInt,Ln=yt.random,An=bt.NEGATIVE_INFINITY,On=bt.POSITIVE_INFINITY,Mn=yt.pow(2,32)-1,_n=Mn-1,Dn=Mn>>>1,Pn=yn?yn.BYTES_PER_ELEMENT:0,Hn=yt.pow(2,53)-1,Bn=gn&&new gn,jn={},Rn=Fn.support={};(function(e){Rn.funcDecomp=/\bthis\b/.test(function(){return this}),Rn.funcNames=typeof gt.name=="string";try{Rn.dom=zt.createDocumentFragment().nodeType===11}catch(t){Rn.dom=!1}try{Rn.nonEnumArgs=!hn.call(arguments,1)}catch(t){Rn.nonEnumArgs=!0}})(0,0),Fn.templateSettings={escape:Q,evaluate:G,interpolate:Y,variable:"",imports:{_:Fn}};var br=function(){function e(){}return function(t){if(uu(t)){e.prototype=t;var n=new e;e.prototype=null}return n||C.Object()}}(),Sr=li(_r),xr=li(Dr,!0),Ar=ci(),Or=ci(!0),Vr=Bn?function(e,t){return Bn.set(e,t),e}:ma;on||(si=!sn||!mn?va(null):function(e){var t=e.byteLength,n=yn?fn(t/Pn):0,r=n*Pn,i=new sn(t);if(n){var s=new yn(i,0,n);s.set(new yn(e,0,n))}return t!=r&&(s=new mn(i,r),s.set(new mn(e,r))),i});var pi=!wn||!pn?va(null):function(e){return new Gn(e)},Fi=Bn?function(e){return Bn.get(e)}:Ea,Ii=function(){return Rn.funcNames?va.name=="constant"?zr("name"):function(e){var t=e.name,n=jn[t],r=n?n.length:0;while(r--){var i=n[r],s=i.func;if(s==null||s==e)return i.name}return t}:va("")}(),es=function(){var e=0,t=0;return function(n,r){var i=No(),s=d-(i-t);t=i;if(s>0){if(++e>=p)return n}else e=0;return Vr(n,r)}}(),as=Xo(function(e,t){return Yo(e)||Go(e)?Er(e,Lr(t,!1,!0)):[]}),ds=bi(),vs=bi(!0),Ns=Xo(function(e,t){e||(e=[]),t=Lr(t);var n=t.length,r=vr(e,t);t.sort(Lt);while(n--){var i=parseFloat(t[n]);if(i!=s&&Xi(i)){var s=i;vn.call(e,i,1)}}return r}),As=Mi(),Os=Mi(!0),Hs=Xo(function(e){return Yr(Lr(e,!1,!0))}),Fs=Xo(function(e,t){return Yo(e)||Go(e)?Er(e,t):[]}),qs=Xo(js),Gs=Xo(function(e,t){var n=e?e.length:0;return Ji(n)&&(e=rs(e)),vr(e,Lr(t))}),Ys=ai(function(e,t,n){Zt.call(e,n)?++e[n]:e[n]=1}),to=yi(Sr),no=yi(xr,!0),io=Si(tr,Sr),so=Si(nr,xr),oo=ai(function(e,t,n){Zt.call(e,n)?e[n].push(t):e[n]=[t]}),ao=ai(function(e,t,n){e[n]=t}),fo=Xo(function(t,n,r){var i=-1,s=typeof n=="function",o=t?t.length:0,u=Ji(o)?O(o):[];return Sr(t,function(t){var o=s?n:t!=null&&t[n];u[++i]=o?o.apply(t,r):e}),u}),co=ai(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),po=ki(ar,Sr),vo=ki(fr,xr),No=Nn||function(){return(new _).getTime()},Ao=Xo(function(e,t,r){var i=n;if(r.length){var s=Wt(r,Ao.placeholder);i|=u}return _i(e,i,t,r,s)}),Oo=Xo(function(e,t){t=t.length?Lr(t):Au(e);var r=-1,i=t.length;while(++r<i){var s=t[r];e[s]=_i(e[s],n,e)}return e}),Mo=Xo(function(e,t,i){var s=n|r;if(i.length){var o=Wt(i,Mo.placeholder);s|=u}return _i(t,s,e,i,o)}),_o=mi(s),Do=mi(o),Ho=Xo(function(e,t){return wr(e,1,t)}),Bo=Xo(function(e,t,n){return wr(e,t,n)}),jo=Ei(),Fo=Ei(!0),Uo=Ci(u),zo=Ci(a),Wo=Xo(function(e,t){return _i(e,l,null,null,null,Lr(t))}),Yo=bn||function(e){return Ut(e)&&Ji(e.length)&&tn.call(e)==E};Rn.dom||(tu=function(e){return!!e&&e.nodeType===1&&Ut(e)&&!pu(e)});var su=Cn||function(e){return typeof e=="number"&&En(e)},ou=Mt(/x/)||mn&&!Mt(mn)?function(e){return tn.call(e)==N}:Mt,pu=ln?function(e){if(!e||tn.call(e)!=L)return!1;var t=e.valueOf,n=lu(t)&&(n=ln(t))&&ln(n);return n?e==n||ln(e)==n:ts(e)}:ts,wu=fi(dr),Su=Xo(function(t){var n=t[0];return n==null?n:(t.push(hr),wu.apply(e,t))}),xu=wi(_r),Tu=wi(Dr),Nu=xi(Ar),Cu=xi(Or),ku=Ti(_r),Lu=Ti(Dr),_u=Sn?function(e){if(e)var t=e.constructor,n=e.length;return typeof t=="function"&&t.prototype===e||typeof e!="function"&&n&&Ji(n)?ns(e):uu(e)?Sn(e):[]}:ns,Hu=fi(Rr),Bu=Xo(function(e,t){if(e==null)return{};if(typeof t[0]!="function"){var t=sr(Lr(t),St);return Gi(e,Er(Du(e),t))}var n=ii(t[0],t[1],3);return Yi(e,function(e,t,r){return!n(e,t,r)})}),Fu=Xo(function(e,t){return e==null?{}:typeof t[0]=="function"?Yi(e,ii(t[0],t[1],3)):Gi(e,Lr(t))}),Xu=di(function(e,t,n){return t=t.toLowerCase(),e+(n?t.charAt(0).toUpperCase()+t.slice(1):t)}),Gu=di(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),Zu=Ni(),ea=Ni(!0);kn(lt+"08")!=8&&(ta=function(e,t,n){return(n?Vi(e,t,n):t==null)?t=0:t&&(t=+t),e=ua(e),kn(e,t||(nt.test(e)?16:10))});var ra=di(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}),ia=di(function(e,t,n){return e+(n?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))}),pa=Xo(function(t,n){try{return t.apply(e,n)}catch(r){return iu(r)?r:new mt(r)}}),La=gi(or),Aa=gi(ur,!0);return Fn.prototype=In.prototype,qn.prototype=br(In.prototype),qn.prototype.constructor=qn,Un.prototype=br(In.prototype),Un.prototype.constructor=Un,Vn.prototype["delete"]=$n,Vn.prototype.get=Jn,Vn.prototype.has=Kn,Vn.prototype.set=Qn,Gn.prototype.push=Zn,Io.Cache=Vn,Fn.after=Co,Fn.ary=ko,Fn.assign=wu,Fn.at=Gs,Fn.before=Lo,Fn.bind=Ao,Fn.bindAll=Oo,Fn.bindKey=Mo,Fn.callback=da,Fn.chain=Us,Fn.chunk=os,Fn.compact=us,Fn.constant=va,Fn.countBy=Ys,Fn.create=Eu,Fn.curry=_o,Fn.curryRight=Do,Fn.debounce=Po,Fn.defaults=Su,Fn.defer=Ho,Fn.delay=Bo,Fn.difference=as,Fn.drop=fs,Fn.dropRight=ls,Fn.dropRightWhile=cs,Fn.dropWhile=hs,Fn.fill=ps,Fn.filter=eo,Fn.flatten=gs,Fn.flattenDeep=ys,Fn.flow=jo,Fn.flowRight=Fo,Fn.forEach=io,Fn.forEachRight=so,Fn.forIn=Nu,Fn.forInRight=Cu,Fn.forOwn=ku,Fn.forOwnRight=Lu,Fn.functions=Au,Fn.groupBy=oo,Fn.indexBy=ao,Fn.initial=ws,Fn.intersection=Es,Fn.invert=Mu,Fn.invoke=fo,Fn.keys=_u,Fn.keysIn=Du,Fn.map=lo,Fn.mapValues=Pu,Fn.matches=ga,Fn.matchesProperty=ya,Fn.memoize=Io,Fn.merge=Hu,Fn.mixin=ba,Fn.negate=qo,Fn.omit=Bu,Fn.once=Ro,Fn.pairs=ju,Fn.partial=Uo,Fn.partialRight=zo,Fn.partition=co,Fn.pick=Fu,Fn.pluck=ho,Fn.property=Sa,Fn.propertyOf=xa,Fn.pull=Ts,Fn.pullAt=Ns,Fn.range=Ta,Fn.rearg=Wo,Fn.reject=mo,Fn.remove=Cs,Fn.rest=ks,Fn.restParam=Xo,Fn.shuffle=yo,Fn.slice=Ls,Fn.sortBy=Eo,Fn.sortByAll=So,Fn.sortByOrder=xo,Fn.spread=Vo,Fn.take=Ms,Fn.takeRight=_s,Fn.takeRightWhile=Ds,Fn.takeWhile=Ps,Fn.tap=zs,Fn.throttle=$o,Fn.thru=Ws,Fn.times=Na,Fn.toArray=yu,Fn.toPlainObject=bu,Fn.transform=qu,Fn.union=Hs,Fn.uniq=Bs,Fn.unzip=js,Fn.values=Ru,Fn.valuesIn=Uu,Fn.where=To,Fn.without=Fs,Fn.wrap=Jo,Fn.xor=Is,Fn.zip=qs,Fn.zipObject=Rs,Fn.backflow=Fo,Fn.collect=lo,Fn.compose=Fo,Fn.each=io,Fn.eachRight=so,Fn.extend=wu,Fn.iteratee=da,Fn.methods=Au,Fn.object=Rs,Fn.select=eo,Fn.tail=ks,Fn.unique=Bs,ba(Fn,Fn),Fn.add=ka,Fn.attempt=pa,Fn.camelCase=Xu,Fn.capitalize=Vu,Fn.clone=Ko,Fn.cloneDeep=Qo,Fn.deburr=$u,Fn.endsWith=Ju,Fn.escape=Ku,Fn.escapeRegExp=Qu,Fn.every=Zs,Fn.find=to,Fn.findIndex=ds,Fn.findKey=xu,Fn.findLast=no,Fn.findLastIndex=vs,Fn.findLastKey=Tu,Fn.findWhere=ro,Fn.first=ms,Fn.has=Ou,Fn.identity=ma,Fn.includes=uo,Fn.indexOf=bs,Fn.inRange=zu,Fn.isArguments=Go,Fn.isArray=Yo,Fn.isBoolean=Zo,Fn.isDate=eu,Fn.isElement=tu,Fn.isEmpty=nu,Fn.isEqual=ru,Fn.isError=iu,Fn.isFinite=su,Fn.isFunction=ou,Fn.isMatch=au,Fn.isNaN=fu,Fn.isNative=lu,Fn.isNull=cu,Fn.isNumber=hu,Fn.isObject=uu,Fn.isPlainObject=pu,Fn.isRegExp=du,Fn.isString=vu,Fn.isTypedArray=mu,Fn.isUndefined=gu,Fn.kebabCase=Gu,Fn.last=Ss,Fn.lastIndexOf=xs,Fn.max=La,Fn.min=Aa,Fn.noConflict=wa,Fn.noop=Ea,Fn.now=No,Fn.pad=Yu,Fn.padLeft=Zu,Fn.padRight=ea,Fn.parseInt=ta,Fn.random=Wu,Fn.reduce=po,Fn.reduceRight=vo,Fn.repeat=na,Fn.result=Iu,Fn.runInContext=Kt,Fn.size=bo,Fn.snakeCase=ra,Fn.some=wo,Fn.sortedIndex=As,Fn.sortedLastIndex=Os,Fn.startCase=ia,Fn.startsWith=sa,Fn.sum=Oa,Fn.template=oa,Fn.trim=ua,Fn.trimLeft=aa,Fn.trimRight=fa,Fn.trunc=la,Fn.unescape=ca,Fn.uniqueId=Ca,Fn.words=ha,Fn.all=Zs,Fn.any=wo,Fn.contains=uo,Fn.detect=to,Fn.foldl=po,Fn.foldr=vo,Fn.head=ms,Fn.include=uo,Fn.inject=po,ba(Fn,function(){var e={};return _r(Fn,function(t,n){Fn.prototype[n]||(e[n]=t)}),e}(),!1),Fn.sample=go,Fn.prototype.sample=function(e){return!this.__chain__&&e==null?go(this.value()):this.thru(function(t){return go(t,e)})},Fn.VERSION=t,tr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){Fn[e].placeholder=Fn}),tr(["dropWhile","filter","map","takeWhile"],function(e,t){var n=t!=g,r=t==v;Un.prototype[e]=function(e,i){var s=this.__filtered__,o=s&&r?new Un(this):this.clone(),u=o.__iteratees__||(o.__iteratees__=[]);return u.push({done:!1,count:0,index:0,iteratee:ji(e,i,1),limit:-1,type:t}),o.__filtered__=s||n,o}}),tr(["drop","take"],function(e,t){var n=e+"While";Un.prototype[e]=function(n){var r=this.__filtered__,i=r&&!t?this.dropWhile():this.clone();n=n==null?1:xn(fn(n)||0,0);if(r)t?i.__takeCount__=Tn(i.__takeCount__,n):Ss(i.__iteratees__).limit=n;else{var s=i.__views__||(i.__views__=[]);s.push({size:n,type:e+(i.__dir__<0?"Right":"")})}return i},Un.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()},Un.prototype[e+"RightWhile"]=function(e,t){return this.reverse()[n](e,t).reverse()}}),tr(["first","last"],function(e,t){var n="take"+(t?"Right":"");Un.prototype[e]=function(){return this[n](1).value()[0]}}),tr(["initial","rest"],function(e,t){var n="drop"+(t?"":"Right");Un.prototype[e]=function(){return this[n](1)}}),tr(["pluck","where"],function(e,t){var n=t?"filter":"map",r=t?Ir:zr;Un.prototype[e]=function(e){return this[n](r(e))}}),Un.prototype.compact=function(){return this.filter(ma)},Un.prototype.reject=function(e,t){return e=ji(e,t,1),this.filter(function(t){return!e(t)})},Un.prototype.slice=function(e,t){e=e==null?0:+e||0;var n=e<0?this.takeRight(-e):this.drop(e);return typeof t!="undefined"&&(t=+t||0,n=t<0?n.dropRight(-t):n.take(t-e)),n},Un.prototype.toArray=function(){return this.drop(0)},_r(Un.prototype,function(e,t){var n=Fn[t];if(!n)return;var r=/^(?:filter|map|reject)|While$/.test(t),i=/^(?:first|last)$/.test(t);Fn.prototype[t]=function(){var t=arguments,s=t.length,o=this.__chain__,u=this.__wrapped__,a=!!this.__actions__.length,f=u instanceof Un,l=t[0],c=f||Yo(u);c&&r&&typeof l=="function"&&l.length!=1&&(f=c=!1);var h=f&&!a;if(i&&!o)return h?e.call(u):n.call(Fn,this.value());var p=function(e){var r=[e];return cn.apply(r,t),n.apply(Fn,r)};if(c){var d=h?u:new Un(this),v=e.apply(d,t);if(!i&&(a||v.__actions__)){var m=v.__actions__||(v.__actions__=[]);m.push({func:Ws,args:[p],thisArg:Fn})}return new qn(v,o)}return this.thru(p)}}),tr(["concat","join","pop","push","replace","shift","sort","splice","split","unshift"],function(e){var t=(/^(?:replace|split)$/.test(e)?Ct:Tt)[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:join|pop|replace|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;return r&&!this.__chain__?t.apply(this.value(),e):this[n](function(n){return t.apply(n,e)})}}),_r(Un.prototype,function(e,t){var n=Fn[t];if(n){var r=n.name,i=jn[r]||(jn[r]=[]);i.push({name:t,func:n})}}),jn[Li(null,r).name]=[{name:"wrapper",func:null}],Un.prototype.clone=zn,Un.prototype.reverse=Wn,Un.prototype.value=Xn,Fn.prototype.chain=Xs,Fn.prototype.commit=Vs,Fn.prototype.plant=$s,Fn.prototype.reverse=Js,Fn.prototype.toString=Ks,Fn.prototype.run=Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=Qs,Fn.prototype.collect=Fn.prototype.map,Fn.prototype.head=Fn.prototype.first,Fn.prototype.select=Fn.prototype.filter,Fn.prototype.tail=Fn.prototype.rest,Fn}var e,t="3.6.0",n=1,r=2,i=4,s=8,o=16,u=32,a=64,f=128,l=256,c=30,h="...",p=150,d=16,v=0,m=1,g=2,y="Expected a function",b="__lodash_placeholder__",w="[object Arguments]",E="[object Array]",S="[object Boolean]",x="[object Date]",T="[object Error]",N="[object Function]",C="[object Map]",k="[object Number]",L="[object Object]",A="[object RegExp]",O="[object Set]",M="[object String]",_="[object WeakMap]",D="[object ArrayBuffer]",P="[object Float32Array]",H="[object Float64Array]",B="[object Int8Array]",j="[object Int16Array]",F="[object Int32Array]",I="[object Uint8Array]",q="[object Uint8ClampedArray]",R="[object Uint16Array]",U="[object Uint32Array]",z=/\b__p \+= '';/g,W=/\b(__p \+=) '' \+/g,X=/(__e\(.*?\)|\b__t\)) \+\n'';/g,V=/&(?:amp|lt|gt|quot|#39|#96);/g,$=/[&<>"'`]/g,J=RegExp(V.source),K=RegExp($.source),Q=/<%-([\s\S]+?)%>/g,G=/<%([\s\S]+?)%>/g,Y=/<%=([\s\S]+?)%>/g,Z=/[\u0300-\u036f\ufe20-\ufe23]/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,tt=/\w*$/,nt=/^0[xX]/,rt=/^\[object .+?Constructor\]$/,it=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,st=/($^)/,ot=/[.*+?^${}()|[\]\/\\]/g,ut=RegExp(ot.source),at=/['\n\r\u2028\u2029\\]/g,ft=function(){var e="[A-Z\\xc0-\\xd6\\xd8-\\xde]",t="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(e+"+(?="+e+t+")|"+e+"?"+t+"|"+e+"+|[0-9]+","g")}(),lt=" 	\f ﻿\n\r\u2028\u2029 ᠎             　",ct=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window"],ht=-1,pt={};pt[P]=pt[H]=pt[B]=pt[j]=pt[F]=pt[I]=pt[q]=pt[R]=pt[U]=!0,pt[w]=pt[E]=pt[D]=pt[S]=pt[x]=pt[T]=pt[N]=pt[C]=pt[k]=pt[L]=pt[A]=pt[O]=pt[M]=pt[_]=!1;var dt={};dt[w]=dt[E]=dt[D]=dt[S]=dt[x]=dt[P]=dt[H]=dt[B]=dt[j]=dt[F]=dt[k]=dt[L]=dt[A]=dt[M]=dt[I]=dt[q]=dt[R]=dt[U]=!0,dt[T]=dt[N]=dt[C]=dt[O]=dt[_]=!1;var vt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},gt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},yt={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#96;":"`"},bt={"function":!0,object:!0},wt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Et=bt[typeof exports]&&exports&&!exports.nodeType&&exports,St=bt[typeof module]&&module&&!module.nodeType&&module,xt=Et&&St&&typeof global=="object"&&global,Tt=bt[typeof self]&&self&&self.Object&&self,Nt=bt[typeof window]&&window&&window.Object&&window,Ct=St&&St.exports===Et&&Et,kt=xt||Nt!==(this&&this.window)&&Nt||Tt||this,Qt=Kt();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(kt._=Qt,define("lodash",[],function(){return Qt})):Et&&St?Ct?(St.exports=Qt)._=Qt:Et._=Qt:kt._=Qt}.call(this),require(["config"],function(){"use strict";require(["player","pedro","lightPasses","rot","lodash"],function(t,n,r){function i(r){function i(t,n){for(var r=0;r<10;r++){var i=Math.floor(e.RNG.getUniform()*n.length),s=n.splice(i,1)[0];t.map[s]="*",r||(t.ananas=s)}}function s(t,n,r){var i=Math.floor(e.RNG.getUniform()*r.length),s=r.splice(i,1)[0],o=s.split(","),u=parseInt(o[0]),a=parseInt(o[1]);return new n(t,{x:u,y:a})}var o=new e.Map.Digger,u=[],a=function(e,t,n){if(n)return;var i=e+","+t;u.push(i),r.map[i]="."};o.create(a.bind(r)),i(r,u),r.player=s(r,t,u),r.pedro=s(r,n,u)}var s={ananas:null,display:null,draw:function(){function n(e,n){function r(t,n,r,i){e.lit.push(t+","+n)}e.shadowcaster.compute(n.position.x,n.position.y,t,r)}var t=5;this.lit=[],n(this,this.player),n(this,this.pedro);var r=[];this.shadowcaster.compute(this.player.position.x,this.player.position.y,50,function(e,t,n,i){r.push(e+","+t)});var i=_.intersection(this.lit,r);this.display.clear();for(var s=0;s<i.length;s++){var o=i[s],u=o.split(","),a=parseInt(u[0]),f=parseInt(u[1]);this.display.draw(a,f,this.map[o])}this.player.draw();var l=this.pedro.position.x+","+this.pedro.position.y;_.indexOf(i,l)>-1&&this.pedro.draw()},engine:null,init:function(){this.display=new e.Display,document.body.appendChild(this.display.getContainer()),i(this);var n=new e.Scheduler.Simple;n.add(this.player,!0),n.add(this.pedro,!0),this.shadowcaster=new e.FOV.RecursiveShadowcasting(r(this.map)),this.engine=new e.Engine(n),this.engine.start()},lit:[],map:{},pedro:null,player:null,shadowcaster:null};s.init()})}),define("game",function(){}),require(["game"])})();