diff --git a/dist/GameEngineWorker.js b/dist/GameEngineWorker.js index 5110f6d..a9a3ea7 100644 --- a/dist/GameEngineWorker.js +++ b/dist/GameEngineWorker.js @@ -1 +1 @@ -!function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=25)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){var r=i(12);function n(t,e){for(var i=0;i{void 0===t.graph.get(this)._connectivity&&0>r.indexOf(t)&&r.push(t)})}}}add(t){return 1this.add(t)):(t.graph.set(this,new Map),this.nodes.set(t.id,t),t)}delete(t){return 1this.delete(t)):(t.graph.delete(this),this.nodes.delete(t.id),t)}edge(t,e,i=1,r=1){if(!t.graph.has(this)||!e.graph.has(this))throw new Error("Nodes must be on the same graph");return null===i?t.graph.get(this).delete(e):t.graph.get(this).set(e,i),null===r?e.graph.get(this).delete(t):e.graph.get(this).set(t,r),this}cost(t,e){return this.adjacent(t,e)?t.graph.get(this).get(e):null}}e.fromArray=function(t,i={}){let r=e.fromArray.X(t,i.order),n=e.fromArray.Y(t,i.order),s=e.fromArray.at.bind(null,t,i.order),o=[],a=null;for(let t,h=1;hu(t.x,t.y)}),t.connect(),t.X=r,t.Y=n,t.TORUS=i.torus,a||(a=t.nodes)}return 1+t}get size(){return this.nodes.length}add(t){if(1=this.score(n))break;this.nodes[r]=e,this.nodes[t]=n,t=r}return this}sink(t){let e=this.nodes[t],i=this.score(e);for(;;){let r=2*(t+1),n=r-1,s=null;if(n{this._worker_path_callback=i.callback,delete i.callback,this.worker.postMessage(["path",t,e,i])},this.worker.onmessage=t=>{let e=JSON.parse(t.data);switch(e[0]){case"path":this._worker_path_callback(e[1])}}}}path(t,e,i={}){if(i.jps)return this.jps(t,e,i);let r=new g(t=>t.estimated),n=new Map,s=this.graphs[i.layer||0];if(t=s.node(t,!0),e=s.node(e,!0),r.add({node:t,estimated:0}),n.set(t,{score:0,from:null}),!i.static||s.connected(t,e))for(;r.size;){let t=r.pop().node;if(t===e)break;s.neighbors(t).map(o=>{let a=(n.has(t)?n.get(t).score:0)+s.cost(t,o);a<(n.has(o)?n.get(o).score:1/0)&&(n.set(o,{score:a,from:t}),r.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))}),r.delete(t)}let o=[];if(n.has(e)){let t=e;for(o.push(e);null!==(t=n.get(t).from);)o.push(t);o=o.reverse()}return i.callback&&i.callback(o,n),o}}if(j.JPS=class{constructor(){}static access(t,e,i,r){return t.adjacent(e,r?t.node(i,!0):i)}static neighborhood(t,e,i,r){let n=[],s=i.get(r).from||null;if(null===s)return e.neighbors(r);{let i={x:b(r.x-s.x),y:b(r.y-s.y)};if(0!=i.x&&0!=i.y){let s=t(r,{x:r.x+i.x,y:r.y},!0),o=t(r,{x:r.x,y:r.y+i.y},!0);(s||o)&&(n.push(e.node({x:r.x+i.x,y:r.y+i.y},!0)),s&&(n.push(e.node({x:r.x+i.x,y:r.y},!0)),!t(r,{x:r.x,y:r.y-i.y},!0)&&n.push(e.node({x:r.x+i.x,y:r.y-i.y},!0))),o&&(n.push(e.node({x:r.x,y:r.y+i.y},!0)),!t(r,{x:r.x-i.x,y:r.y},!0)&&n.push(e.node({x:r.x-i.x,y:r.y+i.y},!0))))}else t(r,{x:r.x+i.x,y:r.y+i.y},!0)&&(n.push(e.node({x:r.x+i.x,y:r.y+i.y},!0)),0==i.x?0!=i.y&&(!t(r,{x:r.x-1,y:r.y},!0)&&n.push(e.node({x:r.x-1,y:r.y+i.y},!0)),!t(r,{x:r.x+1,y:r.y},!0)&&n.push(e.node({x:r.x+1,y:r.y+i.y},!0))):(!t(r,{x:r.x,y:r.y-1},!0)&&n.push(e.node({x:r.x+i.x,y:r.y-1},!0)),!t(r,{x:r.x,y:r.y+1},!0)&&n.push(e.node({x:r.x+i.x,y:r.y+1},!0))))}return n.filter(t=>t)}static jump(t,e,i,r,n,s){for(;;){if(!t(s,n))return null;if(n.x===r.x&&n.y===r.y)return n;let o={x:b(n.x-s.x),y:b(n.y-s.y)};if(0!=o.x&&0!=o.y){if(!t(n,{x:n.x-o.x,y:n.y},!0)&&t(n,{x:n.x-o.x,y:n.y+o.y},!0)||!t(n,{x:n.x,y:n.y-o.y},!0)&&t(n,{x:n.x+o.x,y:n.y-o.y},!0))return n;let s=j.JPS.jump.bind(this,t,e,i,r);if(null!==s(e.node({x:n.x+o.x,y:n.y},!0),n)||null!==s(e.node({x:n.x,y:n.y+o.y},!0),n))return n}else if(0!=o.x){if(!t(n,{x:n.x,y:n.y-1},!0)&&t(n,{x:n.x+o.x,y:n.y-1},!0)||!t(n,{x:n.x,y:n.y+1},!0)&&t(n,{x:n.x+o.x,y:n.y+1},!0))return n}else if(0!=o.y&&(!t(n,{x:n.x-1,y:n.y},!0)&&t(n,{x:n.x-1,y:n.y+o.y},!0)||!t(n,{x:n.x+1,y:n.y},!0)&&t(n,{x:n.x+1,y:n.y+o.y},!0)))return n;s=n,n=e.node({x:n.x+o.x,y:n.y+o.y},!0)}return null}},j.prototype.jps=function(t,e,i={}){if(this.graphs[i.layer||0].TORUS)return console.warn("Torus map aren't yet supported by JPS"),i.callback&&i.callback([],new Map),[];let r=new g(t=>t.estimated),n=new Map,s=this.graphs[i.layer||0],o=null;t=s.node(t,!0),e=s.node(e,!0),r.add({node:t,estimated:0}),n.set(t,{score:0,from:null});let a=j.JPS.access.bind(this,s),u=j.JPS.neighborhood.bind(this,a,s,n),c=j.JPS.jump.bind(this,a,s,n,e);if(!i.static||s.connected(t,e))for(;r.size;){let t=r.pop().node;if(t===e)break;u(t).map(a=>{if(null!==(o=c(a,t))){let a=(n.has(t)?n.get(t).score:0)+s.cost(t,o);a<(n.has(o)?n.get(o).score:1/0)&&(n.set(o,{score:a,from:t,jumped:!0}),r.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))}}),r.delete(t)}let l=[];if(n.has(e)){let i=e;for(;i.x!=t.x||i.y!=t.y;)for(let t=n.get(i).from;i.x!=t.x||i.y!=t.y;)l.push(i),i=s.node({x:i.x+b(t.x-i.x),y:i.y+b(t.y-i.y)},!0);l.push(i),l.reverse()}return i.callback&&i.callback(l,n),l},"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){let a;onmessage=function(b){let c=b.data;switch(c[0]){case"constructor":if("cost"in c[2]){let a=/^\((.*?)\)\s*=>\s*{/.test(c[2].cost),b=/^function /.test(c[2].cost);c[2].cost=eval(`(${a||b?"":"function "}${c[2].cost})`)}a=new j(c[1],c[2]);break;case"path":postMessage(JSON.stringify(["path",a.path(c[1],c[2],c[3])]))}}}a.Lowlight.Astar={Graph:e,Node:f,BinaryHeap:g,Heuristic:h,Configuration:j,WorkerError:i}}("undefined"==typeof window?this:window)},function(t,e){function i(e){return t.exports=i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,i(e)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){var r=i(11).default,n=i(13);t.exports=function(t){var e=n(t,"string");return"symbol"==r(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){var r=i(11).default;t.exports=function(t,e){if("object"!=r(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){(function(t){var r;!function(t,n,s){function o(t){var e,i=this,r=(e=4022871197,function(t){t=String(t);for(var i=0;i>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});i.next=function(){var t=2091639*i.s0+2.3283064365386963e-10*i.c;return i.s0=i.s1,i.s1=i.s2,i.s2=t-(i.c=0|t)},i.c=1,i.s0=r(" "),i.s1=r(" "),i.s2=r(" "),i.s0-=r(t),i.s0<0&&(i.s0+=1),i.s1-=r(t),i.s1<0&&(i.s1+=1),i.s2-=r(t),i.s2<0&&(i.s2+=1),r=null}function a(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function h(t,e){var i=new o(t),r=e&&e.state,n=i.next;return n.int32=function(){return 4294967296*i.next()|0},n.double=function(){return n()+11102230246251565e-32*(2097152*n()|0)},n.quick=n,r&&("object"==typeof r&&a(r,i),n.state=function(){return a(i,{})}),n}n&&n.exports?n.exports=h:i(3)&&i(8)?void 0===(r=function(){return h}.call(e,i,e,n))||(n.exports=r):this.alea=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var r;!function(t,n,s){function o(t){var e=this,i="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:i+=t;for(var r=0;r>>0)/4294967296};return n.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},n.int32=i.next,n.quick=n,r&&("object"==typeof r&&a(r,i),n.state=function(){return a(i,{})}),n}n&&n.exports?n.exports=h:i(3)&&i(8)?void 0===(r=function(){return h}.call(e,i,e,n))||(n.exports=r):this.xor128=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var r;!function(t,n,s){function o(t){var e=this,i="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:i+=t;for(var r=0;r>>4),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function h(t,e){var i=new o(t),r=e&&e.state,n=function(){return(i.next()>>>0)/4294967296};return n.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},n.int32=i.next,n.quick=n,r&&("object"==typeof r&&a(r,i),n.state=function(){return a(i,{})}),n}n&&n.exports?n.exports=h:i(3)&&i(8)?void 0===(r=function(){return h}.call(e,i,e,n))||(n.exports=r):this.xorwow=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var r;!function(t,n,s){function o(t){var e=this;e.next=function(){var t,i,r=e.x,n=e.i;return t=r[n],i=(t^=t>>>7)^t<<24,i^=(t=r[n+1&7])^t>>>10,i^=(t=r[n+3&7])^t>>>3,i^=(t=r[n+4&7])^t<<7,t=r[n+7&7],i^=(t^=t<<13)^t<<9,r[n]=i,e.i=n+1&7,i},function(t,e){var i,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,i=0;i0;--i)t.next()}(e,t)}function a(t,e){return e.x=t.x.slice(),e.i=t.i,e}function h(t,e){null==t&&(t=+new Date);var i=new o(t),r=e&&e.state,n=function(){return(i.next()>>>0)/4294967296};return n.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},n.int32=i.next,n.quick=n,r&&(r.x&&a(r,i),n.state=function(){return a(i,{})}),n}n&&n.exports?n.exports=h:i(3)&&i(8)?void 0===(r=function(){return h}.call(e,i,e,n))||(n.exports=r):this.xorshift7=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var r;!function(t,n,s){function o(t){var e=this;e.next=function(){var t,i,r=e.w,n=e.X,s=e.i;return e.w=r=r+1640531527|0,i=n[s+34&127],t=n[s=s+1&127],i^=i<<13,t^=t<<17,i^=i>>>15,t^=t>>>12,i=n[s]=i^t,e.i=s,i+(r^r>>>16)|0},function(t,e){var i,r,n,s,o,a=[],h=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,h=Math.max(h,e.length)),n=0,s=-32;s>>15,r^=r<<4,r^=r>>>13,s>=0&&(o=o+1640531527|0,n=0==(i=a[127&s]^=r+o)?n+1:0);for(n>=128&&(a[127&(e&&e.length||0)]=-1),n=127,s=512;s>0;--s)r=a[n+34&127],i=a[n=n+1&127],r^=r<<13,i^=i<<17,r^=r>>>15,i^=i>>>12,a[n]=r^i;t.w=o,t.X=a,t.i=n}(e,t)}function a(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function h(t,e){null==t&&(t=+new Date);var i=new o(t),r=e&&e.state,n=function(){return(i.next()>>>0)/4294967296};return n.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},n.int32=i.next,n.quick=n,r&&(r.X&&a(r,i),n.state=function(){return a(i,{})}),n}n&&n.exports?n.exports=h:i(3)&&i(8)?void 0===(r=function(){return h}.call(e,i,e,n))||(n.exports=r):this.xor4096=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var r;!function(t,n,s){function o(t){var e=this,i="";e.next=function(){var t=e.b,i=e.c,r=e.d,n=e.a;return t=t<<25^t>>>7^i,i=i-r|0,r=r<<24^r>>>8^n,n=n-t|0,e.b=t=t<<20^t>>>12^i,e.c=i=i-r|0,e.d=r<<16^i>>>16^n,e.a=n-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):i+=t;for(var r=0;r>>0)/4294967296};return n.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},n.int32=i.next,n.quick=n,r&&("object"==typeof r&&a(r,i),n.state=function(){return a(i,{})}),n}n&&n.exports?n.exports=h:i(3)&&i(8)?void 0===(r=function(){return h}.call(e,i,e,n))||(n.exports=r):this.tychei=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){var r;!function(n,s,o){var a,h=o.pow(256,6),u=o.pow(2,52),c=2*u;function l(t,e,i){var r=[],l=g(function t(e,i){var r,n=[],s=typeof e;if(i&&"object"==s)for(r in e)try{n.push(t(e[r],i-1))}catch(t){}return n.length?n:"string"==s?e:e+"\0"}((e=1==e?{entropy:!0}:e||{}).entropy?[t,y(s)]:null==t?function(){try{var t;return a&&(t=a.randomBytes)?t=t(256):(t=new Uint8Array(256),(n.crypto||n.msCrypto).getRandomValues(t)),y(t)}catch(t){var e=n.navigator,i=e&&e.plugins;return[+new Date,n,i,n.screen,y(s)]}}():t,3),r),p=new d(r),x=function(){for(var t=p.g(6),e=h,i=0;t=c;)t/=2,e/=2,i>>>=1;return(t+i)/e};return x.int32=function(){return 0|p.g(4)},x.quick=function(){return p.g(4)/4294967296},x.double=x,g(y(p.S),s),(e.pass||i||function(t,e,i,r){return r&&(r.S&&f(r,p),t.state=function(){return f(p,{})}),i?(o.random=t,e):t})(x,l,"global"in e?e.global:this==o,e.state)}function d(t){var e,i=t.length,r=this,n=0,s=r.i=r.j=0,o=r.S=[];for(i||(t=[i++]);n<256;)o[n]=n++;for(n=0;n<256;n++)o[n]=o[s=255&s+t[n%i]+(e=o[n])],o[s]=e;(r.g=function(t){for(var e,i=0,n=r.i,s=r.j,o=r.S;t--;)e=o[n=255&n+1],i=256*i+o[255&(o[n]=o[s=255&s+e])+(o[s]=e)];return r.i=n,r.j=s,i})(256)}function f(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function g(t,e){for(var i,r=t+"",n=0;n360?i-360:i<0?360+i:i},p=function(t,e){for(var i,r,n=t.length-1;n>0;n--)i=Math.floor((e?e():Math.random())*(n+1)),r=t[n],t[n]=t[i],t[i]=r;return t},x=i(9),v=i.n(x),k=i(10),T=function(){return d()((function t(e,i,r,n,s,o,h,u,l,d){c()(this,t),this.width=null==e?20:e,this.height=null==i?20:i,this.generateWalls=null!=r&&r,this.borderWalls=null!=n&&n,this.maze=null!=s&&s,this.mazeFirstPosition=new f(1,1,a.RIGHT),this.mazeForceAuto=null!=h&&h,this.grid,this.initialGrid,this.fruitPos,this.fruitPosGold,this.customGrid=o,this.seedGrid=u?""+parseInt(u):void 0,this.seedGame=u?""+parseInt(l):void 0,this.rngGrid,this.rngGame,this.probGoldFruitIncrease=null!=d&&d}),[{key:"init",value:function(){if(null!=this.customGrid||null!=this.initialGrid){var t;t=null!=this.initialGrid?this.initialGrid:this.customGrid,this.height=t.length,this.width=t[0].length,this.initialGrid=new Array(this.height),this.grid=new Array(this.height);for(var e=0;e.65||this.maze?this.grid[i][n]=r.WALL:this.grid[i][n]=r.EMPTY}this.maze?this.generateMaze():this.generateWalls&&this.fixWalls(this.borderWalls)}this.fruitPosGold=null}},{key:"reset",value:function(){this.grid=void 0,this.initialGrid=void 0,this.fruitPos=void 0,this.fruitPosGold=void 0,this.rngGrid=new v.a(this.seedGrid),this.rngGame=new v.a(this.seedGame)}},{key:"fixWalls",value:function(t){var e,i,n,s;t?(e=1,n=this.height-1,i=1,s=this.width-1):(e=0,n=this.height,i=0,s=this.width);for(var o=e;o=this.width-1)continue;this.get(new f(e+2,t))!=r.EMPTY&&(this.set(r.EMPTY,new f(e+2,t)),this.set(r.EMPTY,new f(e+1,t)),this.maze_recursion(t,e+2));break;case a.BOTTOM:if(t+2>=this.height-1)continue;this.get(new f(e,t+2))!=r.EMPTY&&(this.set(r.EMPTY,new f(e,t+2)),this.set(r.EMPTY,new f(e,t+1)),this.maze_recursion(t+2,e));break;case a.LEFT:if(e-2<=0)continue;this.get(new f(e-2,t))!=r.EMPTY&&(this.set(r.EMPTY,new f(e-2,t)),this.set(r.EMPTY,new f(e-1,t)),this.maze_recursion(t,e-2))}}},{key:"generateMaze",value:function(){this.mazeFirstPosition=new f(1,1,a.RIGHT),this.set(r.EMPTY,this.mazeFirstPosition),this.maze_recursion(1,1)}},{key:"set",value:function(t,e){this.grid[e.y][e.x]=t}},{key:"get",value:function(t){return this.grid[t.y][t.x]}},{key:"valToChar",value:function(t){switch(t){case r.EMPTY:return"-";case r.SNAKE:return"o";case r.SNAKE_DEAD:return"O";case r.FRUIT:return"x";case r.WALL:return"#";case r.SURROUNDED:return"/";case r.FRUIT_GOLD:return"X"}}},{key:"getImageCase",value:function(t){switch(this.get(t)){case r.WALL:return"wall.png";case r.FRUIT:return"fruit.png";case r.FRUIT_GOLD:return"fruit_gold.png";case r.EMPTY:case r.SNAKE:case r.SNAKE_DEAD:case r.SURROUNDED:case r.CROSSED:return""}return"unknown.png"}},{key:"getGraph",value:function(t){for(var e=new Array(this.height),i=0;i0))return!!(this.getTotal(r.EMPTY)<=0&&this.fruitPosGold);do{if(i=this.getRandomPosition(),(n=this.detectCorridor(i))&&this.get(i)==r.EMPTY&&this.set(r.SURROUNDED,i),this.getTotal(r.EMPTY)<=0)return!!this.fruitPosGold}while(this.get(i)!=r.EMPTY||this.isFruitSurrounded(i,!0)||this.maze&&!this.testFruitMaze(i,s)||n);return e?(this.fruitPosGold=i,this.set(r.FRUIT_GOLD,i)):(this.fruitPos=i,this.set(r.FRUIT,i)),this.maze||null!=this.fruitPosGold||1!=g(1,this.probGoldFruitIncrease?3:t>1?o.PROB_GOLD_FRUIT_MULTIPLE_PLAYERS:o.PROB_GOLD_FRUIT_1_PLAYER,this.rngGame)||this.setFruit(t,!0),!0}},{key:"testFruitMaze",value:function(t,e){var i=this.getGraph(!0);return new k.Astar.Configuration(i,{order:"yx",torus:!1,diagonals:!1,cutting:!1,cost:function(t,e){return 1==e?null:1}}).path({x:this.mazeFirstPosition.x,y:this.mazeFirstPosition.y},{x:t.x,y:t.y}).length0;){var h=o[0];o.shift();for(var u=[this.getNextPosition(h,a.UP),this.getNextPosition(h,a.BOTTOM),this.getNextPosition(h,a.LEFT),this.getNextPosition(h,a.RIGHT)],c=0;c-1){if(o.push(u[c]),i.indexOf(this.get(u[c]))>-1)return!1;e&&this.get(u[c])==r.EMPTY?(this.set(r.SURROUNDED,u[c]),s[u[c].y][u[c].x]=r.SURROUNDED):s[u[c].y][u[c].x]=r.CROSSED}}return(e&&(this.get(t)==r.EMPTY||this.get(t)==r.FRUIT)||this.get(t)==r.FRUIT_GOLD)&&this.set(r.SURROUNDED,t),!0}},{key:"isFruitSurrounded",value:function(t,e){var i=this.isCaseSurrounded(t,!1,[r.SNAKE],[r.EMPTY,r.SNAKE]);return i&&e&&this.isCaseSurrounded(t,!0,[r.SNAKE],[r.EMPTY,r.SNAKE]),i}},{key:"detectCorridor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.grid?JSON.parse(JSON.stringify(this.grid)):null;if(this.maze||!t||!e)return!1;var i=this.getNextPosition(t,a.TOP),n=this.getNextPosition(t,a.BOTTOM),s=this.getNextPosition(t,a.RIGHT),o=this.getNextPosition(t,a.LEFT),h=this.isDeadPosition(i,!0,!0),u=this.isDeadPosition(n,!0,!0),c=this.isDeadPosition(s,!0,!0),l=this.isDeadPosition(o,!0,!0),d=h+u+c+l;if(d<=1||this.isDeadPosition(t,!0))return!1;if(d>=3)return!0;e[t.y][t.x]=r.CROSSED;var f=e[i.y][i.x]!=r.CROSSED&&this.detectCorridor(i,e),g=e[n.y][n.x]!=r.CROSSED&&this.detectCorridor(n,e),y=e[o.y][o.x]!=r.CROSSED&&this.detectCorridor(o,e),p=e[s.y][s.x]!=r.CROSSED&&this.detectCorridor(s,e);return!!(g||f||y||p)}},{key:"getOnLine",value:function(t,e){for(var i=0,r=0;r=this.width&&(i.x=0),i.y<0?i.y=this.height-1:i.y>=this.height&&(i.y=0),i}},{key:"getDirectionTo",value:function(t,e){return this.getNextPosition(t,a.UP).equals(e)?a.UP:this.getNextPosition(t,a.BOTTOM).equals(e)?a.BOTTOM:this.getNextPosition(t,a.RIGHT).equals(e)?a.RIGHT:this.getNextPosition(t,a.LEFT).equals(e)?a.LEFT:-1}},{key:"invertDirection",value:function(t){return t==a.UP?a.BOTTOM:t==a.BOTTOM?a.UP:t==a.RIGHT?a.LEFT:t==a.LEFT?a.RIGHT:null}},{key:"isDeadPosition",value:function(t,e,i){return!e&&this.get(t)==r.SNAKE||this.get(t)==r.WALL||this.get(t)==r.SNAKE_DEAD||!!i&&this.get(t)==r.SURROUNDED}},{key:"toString",value:function(){for(var t="",e=0;eu.x?l=c.x-u.x>t.grid.width/2?h.LEFT:h.RIGHT:c.xt.grid.width/2?h.RIGHT:h.LEFT:c.yt.grid.height/2?h.BOTTOM:h.UP:c.y>u.y&&(l=c.y-u.y>t.grid.height/2?h.UP:h.BOTTOM);var d=t.getNextPosition(u,l);if(t.grid.isDeadPosition(d)){for(var f=this.direction,g=null,y=1;y1){var p=new f(y[1].x,y[1].y);return new f(null,null,t.getDirectionTo(h,p)).convertToKeyDirection()}y=null}return null}}])}(P);function U(t,e,i){return e=M()(e),m()(t,function(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return function(){return!!t}()}()?Reflect.construct(e,i||[],M()(t).constructor):e.apply(t,i))}var F=function(t){function e(t){var i;return c()(this,e),(i=U(this,e,[!0])).aiLow=new L(t),i._aiLevelText="high",i}return R()(e,t),d()(e,[{key:"ai",value:function(t){var i,r,n,s,o,a=(i=e,r="ai",n=this,s=3,o=b()(M()(1&s?i.prototype:i),r,n),2&s&&"function"==typeof o?function(t){return o.apply(n,t)}:o)([t]);return a||this.aiLow.ai(t)}}])}(D);function N(t,e,i){return e=M()(e),m()(t,function(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return function(){return!!t}()}()?Reflect.construct(e,i||[],M()(t).constructor):e.apply(t,i))}var H,B=function(t){function e(){var t;return c()(this,e),(t=N(this,e))._aiLevelText="mock",t}return R()(e,t),d()(e,[{key:"ai",value:function(){return null}}])}(P),z=function(){function t(e,i,r,o,h,u,l,d){c()(this,t),this.direction=null==e?a.RIGHT:e,this.initialDirection=this.direction,this.initialLength=null==i?3:i,this.initTriedDirections=[],this.errorInit=!1,this.grid=r||new T,this.queue=[],this.lastKey=-1,this.lastTail,this.lastTailMoved,this.ticksDead=0,this.player=null==o?n.HUMAN:o,this.aiLevel=null==h?s.DEFAULT:h,this.autoRetry=null!=u&&u,this.score=0,this.gameOver=!1,this.scoreMax=!1,this.color,this.name=null==l?"Snake":l,this.snakeAI=new P,this.customAI=d,this.ticksWithoutAction=0,this.initAI()}return d()(t,[{key:"init",value:function(){if(this.initialLength<=0)return this.errorInit=!0,!1;this.grid.maze&&this.initTriedDirections.length<=0&&(this.initialDirection=this.grid.mazeFirstPosition.direction,this.direction=this.initialDirection);var t=0,e=0;if(this.initialDirection==a.RIGHT&&-1==this.initTriedDirections.indexOf(a.RIGHT)||this.initialDirection==a.LEFT&&-1==this.initTriedDirections.indexOf(a.LEFT)){for(var i=0;i=this.initialLength){t++;break}}else if(this.initialDirection==a.UP&&-1==this.initTriedDirections.indexOf(a.UP)||this.initialDirection==a.BOTTOM&&-1==this.initTriedDirections.indexOf(a.BOTTOM))for(var u=0;u=this.initialLength){e++;break}if(this.initTriedDirections.push(this.initialDirection),t<=0&&(this.initialDirection==a.RIGHT||this.initialDirection==a.LEFT)||e<=0&&(this.initialDirection==a.UP||this.initialDirection==a.BOTTOM))return-1==this.initTriedDirections.indexOf(a.RIGHT)?(this.initialDirection=a.RIGHT,this.direction=a.RIGHT,this.init()):-1==this.initTriedDirections.indexOf(a.LEFT)?(this.initialDirection=a.LEFT,this.direction=a.LEFT,this.init()):-1==this.initTriedDirections.indexOf(a.UP)?(this.initialDirection=a.UP,this.direction=a.UP,this.init()):-1==this.initTriedDirections.indexOf(a.BOTTOM)?(this.initialDirection=a.BOTTOM,this.direction=a.BOTTOM,this.init()):(this.errorInit=!0,!1);for(var d,g,y=!0,p=[];y;){if(y=!1,!(d=this.grid.maze?this.grid.mazeFirstPosition:this.grid.getRandomPosition()))return this.errorInit=!0,!1;g=new f(d.x,d.y,this.initialDirection),p=[];for(var x=this.initialLength-1;x>=0;x--)x=0&&t=this.grid.width*t)return!0;if((this.direction==a.UP||this.direction==a.BOTTOM)&&this.ticksWithoutAction>=this.grid.height*e)return!0}return!1}},{key:"getAILevelText",value:function(){return this.snakeAI?this.snakeAI.aiLevelText:"???"}}])}(),C=function(){return d()((function t(e){c()(this,t),this.name=e,this.callbacks=[]}),[{key:"registerCallback",value:function(t){this.callbacks.push(t)}}])}(),j=function(){return d()((function t(){c()(this,t),this.events={}}),[{key:"registerEvent",value:function(t){this.events[t]=new C(t)}},{key:"dispatchEvent",value:function(t,e){for(var i=this.events[t].callbacks,r=0,n=i.length;r1)&&(this.errorOccurred=!0):this.snakes=[this.snakes],this.grid instanceof T==0)this.errorOccurred=!0;else if(!this.errorOccurred){this.initGridAndSnakes();for(var t=g(0,360,this.grid?new v.a(this.grid.seedGame):null),e=0;e-1&&this.snakes[i].setGameOver(this.ticks)}},{key:"getNBPlayer",value:function(t){var e=0;if(null!=this.snakes)for(var i=0;i0||this.getNBPlayer(n.HYBRID_HUMAN_AI)>0)&&-1!=(this.getPlayer(1,n.HYBRID_HUMAN_AI)||this.getPlayer(1,n.HUMAN)).lastKey)){for(var i=0;i0&&this.initialSpeed>1&&(this.initialSpeed=Math.ceil(-this.initialSpeedUntouched/100*this.snakes[i].score+this.initialSpeedUntouched),this.initialSpeed=this.initialSpeed<1?1:this.initialSpeed)):(this.snakes[i].insert(u),this.grid.maze||(this.snakes[i].remove(),this.snakes[i].lastTailMoved=!0))}this.scoreMax||!a||this.clientSidePredictionsMode||(e=!this.grid.setFruit(this.snakes.length))}this.scoreMax||e||!this.grid.detectCorridor(this.grid.fruitPos)&&!this.grid.isFruitSurrounded(this.grid.fruitPos,!0)||this.clientSidePredictionsMode||(e=!this.grid.setFruit(this.snakes.length)),this.scoreMax||null==this.grid.fruitPosGold||!this.grid.detectCorridor(this.grid.fruitPosGold)&&!this.grid.isFruitSurrounded(this.grid.fruitPosGold,!0)||(this.grid.set(r.EMPTY,this.grid.fruitPosGold),this.grid.fruitPosGold=null);for(var c=0,l=0;l=this.snakes.length||e||d)&&(this.stop(),this.snakes.length>1&&(this.gameFinished=!0)),this.reactor.dispatchEvent("onUpdate"),t&&this.reactor.dispatchEvent("onScoreIncreased")}this.tick()}}},{key:"onReset",value:function(t){this.reactor.addEventListener("onReset",t)}},{key:"onStart",value:function(t){this.reactor.addEventListener("onStart",t)}},{key:"onContinue",value:function(t){this.reactor.addEventListener("onContinue",t)}},{key:"onStop",value:function(t){this.reactor.addEventListener("onStop",t)}},{key:"onPause",value:function(t){this.reactor.addEventListener("onPause",t)}},{key:"onExit",value:function(t){this.reactor.addEventListener("onExit",t)}},{key:"onKill",value:function(t){this.reactor.addEventListener("onKill",t)}},{key:"onScoreIncreased",value:function(t){this.reactor.addEventListener("onScoreIncreased",t)}},{key:"onUpdate",value:function(t){this.reactor.addEventListener("onUpdate",t)}},{key:"onUpdateCounter",value:function(t){this.reactor.addEventListener("onUpdateCounter",t)}}])}();function W(t){var e=JSON.parse(JSON.stringify(t));if(e)for(var i=0;i1&&"init"==e[0]){var i=q(e[1].snakes,e[1].grid),r=i.grid,s=i.snakes;(H=new Y(r,s,e[1].speed,e[1].enablePause,e[1].enableRetry,e[1].progressiveSpeed)).init(),self.postMessage(["init",{snakes:W(H.snakes),grid:K(H.grid),enablePause:H.enablePause,enableRetry:H.enableRetry,progressiveSpeed:H.progressiveSpeed,offsetFrame:H.speed*o.TIME_MULTIPLIER,errorOccurred:H.errorOccurred}]),H.onReset((function(){self.postMessage(["reset",{paused:H.paused,isReseted:H.isReseted,exited:H.exited,snakes:W(H.snakes),grid:K(H.grid),numFruit:H.numFruit,ticks:H.ticks,scoreMax:H.scoreMax,gameOver:H.gameOver,gameFinished:H.gameFinished,gameMazeWin:H.gameMazeWin,starting:H.starting,initialSpeed:H.initialSpeed,speed:H.speed,offsetFrame:H.speed*o.TIME_MULTIPLIER,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred,aiStuck:H.aiStuck,precAiStuck:!1}])})),H.onStart((function(){self.postMessage(["start",{snakes:W(H.snakes),grid:K(H.grid),starting:H.starting,countBeforePlay:H.countBeforePlay,paused:H.paused,isReseted:H.isReseted,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred}])})),H.onPause((function(){self.postMessage(["pause",{paused:H.paused,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred}])})),H.onContinue((function(){self.postMessage(["continue",{confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred}])})),H.onStop((function(){self.postMessage(["stop",{paused:H.paused,scoreMax:H.scoreMax,gameOver:H.gameOver,gameFinished:H.gameFinished,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred}])})),H.onExit((function(){self.postMessage(["exit",{paused:H.paused,gameOver:H.gameOver,gameFinished:H.gameFinished,exited:H.exited,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred}])})),H.onKill((function(){self.postMessage(["kill",{paused:H.paused,gameOver:H.gameOver,killed:H.killed,snakes:W(H.snakes),grid:K(H.grid),gameFinished:H.gameFinished,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:H.errorOccurred}])})),H.onScoreIncreased((function(){self.postMessage(["scoreIncreased",{}])})),H.onUpdate((function(){self.postMessage(["update",{paused:H.paused,isReseted:H.isReseted,exited:H.exited,snakes:W(H.snakes),grid:K(H.grid),numFruit:H.numFruit,ticks:H.ticks,scoreMax:H.scoreMax,gameOver:H.gameOver,gameFinished:H.gameFinished,gameMazeWin:H.gameMazeWin,starting:H.starting,initialSpeed:H.initialSpeed,speed:H.speed,countBeforePlay:H.countBeforePlay,offsetFrame:0,errorOccurred:H.errorOccurred,aiStuck:H.aiStuck}])})),H.onUpdateCounter((function(){self.postMessage(["updateCounter",{paused:H.paused,isReseted:H.isReseted,exited:H.exited,snakes:W(H.snakes),grid:K(H.grid),numFruit:H.numFruit,ticks:H.ticks,scoreMax:H.scoreMax,gameOver:H.gameOver,gameFinished:H.gameFinished,gameMazeWin:H.gameMazeWin,starting:H.starting,initialSpeed:H.initialSpeed,speed:H.speed,countBeforePlay:H.countBeforePlay,errorOccurred:H.errorOccurred}])}))}else if(null!=H){switch(e[0]){case"reset":H.reset();break;case"start":H.start();break;case"stop":H.stop(!1);break;case"finish":H.stop(!0);break;case"pause":H.pause();break;case"kill":H.kill();break;case"tick":H.paused=!1,H.countBeforePlay=-1,H.tick();break;case"ping":self.postMessage("pong");break;case"exit":H.exit();break;case"forceStart":H.forceStart();break;case"key":if(e.length>1){H.lastKey=e[1];var a=H.getPlayer(1,n.HUMAN)||H.getPlayer(1,n.HYBRID_HUMAN_AI);null!=a&&null!=a.lastKey&&(a.lastKey=e[1])}break;case"update":if(e.length>1)if("snakes"==e[1].key){var h=q(e[1].data);h&&(H.snakes=h.snakes)}else if("grid"==e[1].key){var u=q(null,e[1].data);u&&(H.grid=u.grid)}else H[e[1].key]=e[1].data;break;case"destroySnakes":e[1]&&e[2]&&H.destroySnakes(e[1],e[2])}}else"ping"==e&&self.postMessage("pong")},self.postMessage("ready")}]); \ No newline at end of file +(()=>{var __webpack_modules__={293:function(module){(function(a){var b=Math.sign,c=Math.min,d=Math.abs;void 0===a.Lowlight&&(a.Lowlight={}),"object"==typeof module.exports&&(module.exports=a.Lowlight);class e{constructor(){this.nodes=new Map}id(t){return t}node(t,e=!1){return e?this.nodes.get(this.id(arguments[0])):this.nodes.get(t)}data(t,e){return 2===arguments.length&&(t.graph.get(this)._data=e),t.graph.get(this)._data}adjacent(t,e){return t.graph.get(this).has(e)}neighbors(t){return Array.from(t.graph.get(this).keys())}connected(t,e){return t.graph.get(this)._connectivity===e.graph.get(this)._connectivity}connect(){let t=Array.from(this.nodes.values()),e=0;for(let e=0;e{void 0===t.graph.get(this)._connectivity&&0>r.indexOf(t)&&r.push(t)}))}}}add(t){return 1this.add(t))):(t.graph.set(this,new Map),this.nodes.set(t.id,t),t)}delete(t){return 1this.delete(t))):(t.graph.delete(this),this.nodes.delete(t.id),t)}edge(t,e,i=1,r=1){if(!t.graph.has(this)||!e.graph.has(this))throw new Error("Nodes must be on the same graph");return null===i?t.graph.get(this).delete(e):t.graph.get(this).set(e,i),null===r?e.graph.get(this).delete(t):e.graph.get(this).set(t,r),this}cost(t,e){return this.adjacent(t,e)?t.graph.get(this).get(e):null}}e.fromArray=function(t,i={}){let r=e.fromArray.X(t,i.order),s=e.fromArray.Y(t,i.order),n=e.fromArray.at.bind(null,t,i.order),o=[],a=null;for(let t,h=1;hu(t.x,t.y)}),t.connect(),t.X=r,t.Y=s,t.TORUS=i.torus,a||(a=t.nodes)}return 1+t}get size(){return this.nodes.length}add(t){if(1=this.score(s))break;this.nodes[r]=e,this.nodes[t]=s,t=r}return this}sink(t){let e=this.nodes[t],i=this.score(e);for(;;){let r=2*(t+1),s=r-1,n=null;if(s{this._worker_path_callback=i.callback,delete i.callback,this.worker.postMessage(["path",t,e,i])},this.worker.onmessage=t=>{let e=JSON.parse(t.data);"path"===e[0]&&this._worker_path_callback(e[1])}}}path(t,e,i={}){if(i.jps)return this.jps(t,e,i);let r=new g((t=>t.estimated)),s=new Map,n=this.graphs[i.layer||0];if(t=n.node(t,!0),e=n.node(e,!0),r.add({node:t,estimated:0}),s.set(t,{score:0,from:null}),!i.static||n.connected(t,e))for(;r.size;){let t=r.pop().node;if(t===e)break;n.neighbors(t).map((o=>{let a=(s.has(t)?s.get(t).score:0)+n.cost(t,o);a<(s.has(o)?s.get(o).score:1/0)&&(s.set(o,{score:a,from:t}),r.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))})),r.delete(t)}let o=[];if(s.has(e)){let t=e;for(o.push(e);null!==(t=s.get(t).from);)o.push(t);o=o.reverse()}return i.callback&&i.callback(o,s),o}}if(j.JPS=class{constructor(){}static access(t,e,i,r){return t.adjacent(e,r?t.node(i,!0):i)}static neighborhood(t,e,i,r){let s=[],n=i.get(r).from||null;if(null===n)return e.neighbors(r);{let i={x:b(r.x-n.x),y:b(r.y-n.y)};if(0!=i.x&&0!=i.y){let n=t(r,{x:r.x+i.x,y:r.y},!0),o=t(r,{x:r.x,y:r.y+i.y},!0);(n||o)&&(s.push(e.node({x:r.x+i.x,y:r.y+i.y},!0)),n&&(s.push(e.node({x:r.x+i.x,y:r.y},!0)),!t(r,{x:r.x,y:r.y-i.y},!0)&&s.push(e.node({x:r.x+i.x,y:r.y-i.y},!0))),o&&(s.push(e.node({x:r.x,y:r.y+i.y},!0)),!t(r,{x:r.x-i.x,y:r.y},!0)&&s.push(e.node({x:r.x-i.x,y:r.y+i.y},!0))))}else t(r,{x:r.x+i.x,y:r.y+i.y},!0)&&(s.push(e.node({x:r.x+i.x,y:r.y+i.y},!0)),0==i.x?0!=i.y&&(!t(r,{x:r.x-1,y:r.y},!0)&&s.push(e.node({x:r.x-1,y:r.y+i.y},!0)),!t(r,{x:r.x+1,y:r.y},!0)&&s.push(e.node({x:r.x+1,y:r.y+i.y},!0))):(!t(r,{x:r.x,y:r.y-1},!0)&&s.push(e.node({x:r.x+i.x,y:r.y-1},!0)),!t(r,{x:r.x,y:r.y+1},!0)&&s.push(e.node({x:r.x+i.x,y:r.y+1},!0))))}return s.filter((t=>t))}static jump(t,e,i,r,s,n){for(;;){if(!t(n,s))return null;if(s.x===r.x&&s.y===r.y)return s;let o={x:b(s.x-n.x),y:b(s.y-n.y)};if(0!=o.x&&0!=o.y){if(!t(s,{x:s.x-o.x,y:s.y},!0)&&t(s,{x:s.x-o.x,y:s.y+o.y},!0)||!t(s,{x:s.x,y:s.y-o.y},!0)&&t(s,{x:s.x+o.x,y:s.y-o.y},!0))return s;let n=j.JPS.jump.bind(this,t,e,i,r);if(null!==n(e.node({x:s.x+o.x,y:s.y},!0),s)||null!==n(e.node({x:s.x,y:s.y+o.y},!0),s))return s}else if(0!=o.x){if(!t(s,{x:s.x,y:s.y-1},!0)&&t(s,{x:s.x+o.x,y:s.y-1},!0)||!t(s,{x:s.x,y:s.y+1},!0)&&t(s,{x:s.x+o.x,y:s.y+1},!0))return s}else if(0!=o.y&&(!t(s,{x:s.x-1,y:s.y},!0)&&t(s,{x:s.x-1,y:s.y+o.y},!0)||!t(s,{x:s.x+1,y:s.y},!0)&&t(s,{x:s.x+1,y:s.y+o.y},!0)))return s;n=s,s=e.node({x:s.x+o.x,y:s.y+o.y},!0)}return null}},j.prototype.jps=function(t,e,i={}){if(this.graphs[i.layer||0].TORUS)return console.warn("Torus map aren't yet supported by JPS"),i.callback&&i.callback([],new Map),[];let r=new g((t=>t.estimated)),s=new Map,n=this.graphs[i.layer||0],o=null;t=n.node(t,!0),e=n.node(e,!0),r.add({node:t,estimated:0}),s.set(t,{score:0,from:null});let a=j.JPS.access.bind(this,n),u=j.JPS.neighborhood.bind(this,a,n,s),c=j.JPS.jump.bind(this,a,n,s,e);if(!i.static||n.connected(t,e))for(;r.size;){let t=r.pop().node;if(t===e)break;u(t).map((a=>{if(null!==(o=c(a,t))){let a=(s.has(t)?s.get(t).score:0)+n.cost(t,o);a<(s.has(o)?s.get(o).score:1/0)&&(s.set(o,{score:a,from:t,jumped:!0}),r.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))}})),r.delete(t)}let l=[];if(s.has(e)){let i=e;for(;i.x!=t.x||i.y!=t.y;)for(let t=s.get(i).from;i.x!=t.x||i.y!=t.y;)l.push(i),i=n.node({x:i.x+b(t.x-i.x),y:i.y+b(t.y-i.y)},!0);l.push(i),l.reverse()}return i.callback&&i.callback(l,s),l},"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){let a;onmessage=function(b){let c=b.data;switch(c[0]){case"constructor":if("cost"in c[2]){let a=/^\((.*?)\)\s*=>\s*{/.test(c[2].cost),b=/^function /.test(c[2].cost);c[2].cost=eval(`(${a||b?"":"function "}${c[2].cost})`)}a=new j(c[1],c[2]);break;case"path":postMessage(JSON.stringify(["path",a.path(c[1],c[2],c[3])]))}}}a.Lowlight.Astar={Graph:e,Node:f,BinaryHeap:g,Heuristic:h,Configuration:j,WorkerError:i}})("undefined"==typeof window?this:window)},391:(t,e,i)=>{var r=i(180),s=i(181),n=i(31),o=i(67),a=i(833),h=i(717),u=i(801);u.alea=r,u.xor128=s,u.xorwow=n,u.xorshift7=o,u.xor4096=a,u.tychei=h,t.exports=u},180:function(t,e,i){var r;!function(t,s){function n(t){var e,i=this,r=(e=4022871197,function(t){t=String(t);for(var i=0;i>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});i.next=function(){var t=2091639*i.s0+2.3283064365386963e-10*i.c;return i.s0=i.s1,i.s1=i.s2,i.s2=t-(i.c=0|t)},i.c=1,i.s0=r(" "),i.s1=r(" "),i.s2=r(" "),i.s0-=r(t),i.s0<0&&(i.s0+=1),i.s1-=r(t),i.s1<0&&(i.s1+=1),i.s2-=r(t),i.s2<0&&(i.s2+=1),r=null}function o(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function a(t,e){var i=new n(t),r=e&&e.state,s=i.next;return s.int32=function(){return 4294967296*i.next()|0},s.double=function(){return s()+11102230246251565e-32*(2097152*s()|0)},s.quick=s,r&&("object"==typeof r&&o(r,i),s.state=function(){return o(i,{})}),s}s&&s.exports?s.exports=a:i.amdD&&i.amdO?void 0===(r=function(){return a}.call(e,i,e,s))||(s.exports=r):this.alea=a}(0,t=i.nmd(t),i.amdD)},717:function(t,e,i){var r;!function(t,s){function n(t){var e=this,i="";e.next=function(){var t=e.b,i=e.c,r=e.d,s=e.a;return t=t<<25^t>>>7^i,i=i-r|0,r=r<<24^r>>>8^s,s=s-t|0,e.b=t=t<<20^t>>>12^i,e.c=i=i-r|0,e.d=r<<16^i>>>16^s,e.a=s-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):i+=t;for(var r=0;r>>0)/4294967296};return s.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=i.next,s.quick=s,r&&("object"==typeof r&&o(r,i),s.state=function(){return o(i,{})}),s}s&&s.exports?s.exports=a:i.amdD&&i.amdO?void 0===(r=function(){return a}.call(e,i,e,s))||(s.exports=r):this.tychei=a}(0,t=i.nmd(t),i.amdD)},181:function(t,e,i){var r;!function(t,s){function n(t){var e=this,i="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:i+=t;for(var r=0;r>>0)/4294967296};return s.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=i.next,s.quick=s,r&&("object"==typeof r&&o(r,i),s.state=function(){return o(i,{})}),s}s&&s.exports?s.exports=a:i.amdD&&i.amdO?void 0===(r=function(){return a}.call(e,i,e,s))||(s.exports=r):this.xor128=a}(0,t=i.nmd(t),i.amdD)},833:function(t,e,i){var r;!function(t,s){function n(t){var e=this;e.next=function(){var t,i,r=e.w,s=e.X,n=e.i;return e.w=r=r+1640531527|0,i=s[n+34&127],t=s[n=n+1&127],i^=i<<13,t^=t<<17,i^=i>>>15,t^=t>>>12,i=s[n]=i^t,e.i=n,i+(r^r>>>16)|0},function(t,e){var i,r,s,n,o,a=[],h=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,h=Math.max(h,e.length)),s=0,n=-32;n>>15,r^=r<<4,r^=r>>>13,n>=0&&(o=o+1640531527|0,s=0==(i=a[127&n]^=r+o)?s+1:0);for(s>=128&&(a[127&(e&&e.length||0)]=-1),s=127,n=512;n>0;--n)r=a[s+34&127],i=a[s=s+1&127],r^=r<<13,i^=i<<17,r^=r>>>15,i^=i>>>12,a[s]=r^i;t.w=o,t.X=a,t.i=s}(e,t)}function o(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function a(t,e){null==t&&(t=+new Date);var i=new n(t),r=e&&e.state,s=function(){return(i.next()>>>0)/4294967296};return s.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=i.next,s.quick=s,r&&(r.X&&o(r,i),s.state=function(){return o(i,{})}),s}s&&s.exports?s.exports=a:i.amdD&&i.amdO?void 0===(r=function(){return a}.call(e,i,e,s))||(s.exports=r):this.xor4096=a}(0,t=i.nmd(t),i.amdD)},67:function(t,e,i){var r;!function(t,s){function n(t){var e=this;e.next=function(){var t,i,r=e.x,s=e.i;return t=r[s],i=(t^=t>>>7)^t<<24,i^=(t=r[s+1&7])^t>>>10,i^=(t=r[s+3&7])^t>>>3,i^=(t=r[s+4&7])^t<<7,t=r[s+7&7],i^=(t^=t<<13)^t<<9,r[s]=i,e.i=s+1&7,i},function(t,e){var i,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,i=0;i0;--i)t.next()}(e,t)}function o(t,e){return e.x=t.x.slice(),e.i=t.i,e}function a(t,e){null==t&&(t=+new Date);var i=new n(t),r=e&&e.state,s=function(){return(i.next()>>>0)/4294967296};return s.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=i.next,s.quick=s,r&&(r.x&&o(r,i),s.state=function(){return o(i,{})}),s}s&&s.exports?s.exports=a:i.amdD&&i.amdO?void 0===(r=function(){return a}.call(e,i,e,s))||(s.exports=r):this.xorshift7=a}(0,t=i.nmd(t),i.amdD)},31:function(t,e,i){var r;!function(t,s){function n(t){var e=this,i="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:i+=t;for(var r=0;r>>4),e.next()}function o(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function a(t,e){var i=new n(t),r=e&&e.state,s=function(){return(i.next()>>>0)/4294967296};return s.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=i.next,s.quick=s,r&&("object"==typeof r&&o(r,i),s.state=function(){return o(i,{})}),s}s&&s.exports?s.exports=a:i.amdD&&i.amdO?void 0===(r=function(){return a}.call(e,i,e,s))||(s.exports=r):this.xorwow=a}(0,t=i.nmd(t),i.amdD)},801:function(t,e,i){var r;!function(s,n,o){var a,h=256,u=o.pow(h,6),c=o.pow(2,52),l=2*c,d=255;function f(t,e,i){var r=[],d=v(p((e=1==e?{entropy:!0}:e||{}).entropy?[t,x(n)]:null==t?function(){try{var t;return a&&(t=a.randomBytes)?t=t(h):(t=new Uint8Array(h),(s.crypto||s.msCrypto).getRandomValues(t)),x(t)}catch(t){var e=s.navigator,i=e&&e.plugins;return[+new Date,s,i,s.screen,x(n)]}}():t,3),r),f=new g(r),k=function(){for(var t=f.g(6),e=u,i=0;t=l;)t/=2,e/=2,i>>>=1;return(t+i)/e};return k.int32=function(){return 0|f.g(4)},k.quick=function(){return f.g(4)/4294967296},k.double=k,v(x(f.S),n),(e.pass||i||function(t,e,i,r){return r&&(r.S&&y(r,f),t.state=function(){return y(f,{})}),i?(o.random=t,e):t})(k,d,"global"in e?e.global:this==o,e.state)}function g(t){var e,i=t.length,r=this,s=0,n=r.i=r.j=0,o=r.S=[];for(i||(t=[i++]);s{}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var i=__webpack_module_cache__[t]={id:t,loaded:!1,exports:{}};return __webpack_modules__[t].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.amdD=function(){throw new Error("define cannot be used indirect")},__webpack_require__.amdO={},__webpack_require__.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(t,e)=>{for(var i in e)__webpack_require__.o(e,i)&&!__webpack_require__.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var __webpack_exports__={};(()=>{"use strict";const t=0,e=1,i=2,r=3,s=4,n=5,o=6,a=7,h="PLAYER_AI",u="PLAYER_HUMAN",c="PLAYER_HYBRID_HUMAN_AI",l="AI_LEVEL_RANDOM",d="AI_LEVEL_LOW",f="AI_LEVEL_DEFAULT",g="AI_LEVEL_HIGH",y="AI_LEVEL_ULTRA",p="AI_LEVEL_CUSTOM",v="AI_LEVEL_MOCK",x=15,k=100,m=50,w=0,b=0,P=1,_=2,O=3,S=4,A=5,D=6,M=7,G=38,I=39,T=40,E=37;function L(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function z(t){return z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},z(t)}function N(t){var e=function(t){if("object"!=z(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=z(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==z(e)?e:e+""}function F(t,e){for(var i=0;i.65||this.maze?this.grid[s][n]=r:this.grid[s][n]=t}this.maze?this.generateMaze():this.generateWalls&&this.fixWalls(this.borderWalls)}this.fruitPosGold=null}},{key:"reset",value:function(){this.grid=void 0,this.initialGrid=void 0,this.fruitPos=void 0,this.fruitPosGold=void 0,this.rngGrid=new(W())(this.seedGrid),this.rngGame=new(W())(this.seedGame)}},{key:"fixWalls",value:function(e){var i,s,n,o;e?(i=1,n=this.height-1,s=1,o=this.width-1):(i=0,n=this.height,s=0,o=this.width);for(var a=i;a0;s--)i=Math.floor((e?e():Math.random())*(s+1)),r=t[s],t[s]=t[i],t[i]=r;return t}([w,P,_,O],this.rngGrid),s=0;s=this.width-1)continue;this.get(new j(i+2,e))!=t&&(this.set(t,new j(i+2,e)),this.set(t,new j(i+1,e)),this.maze_recursion(e,i+2));break;case _:if(e+2>=this.height-1)continue;this.get(new j(i,e+2))!=t&&(this.set(t,new j(i,e+2)),this.set(t,new j(i,e+1)),this.maze_recursion(e+2,i));break;case O:if(i-2<=0)continue;this.get(new j(i-2,e))!=t&&(this.set(t,new j(i-2,e)),this.set(t,new j(i-1,e)),this.maze_recursion(e,i-2))}}},{key:"generateMaze",value:function(){this.mazeFirstPosition=new j(1,1,P),this.set(t,this.mazeFirstPosition),this.maze_recursion(1,1)}},{key:"set",value:function(t,e){this.grid[e.y][e.x]=t}},{key:"get",value:function(t){return this.grid[t.y][t.x]}},{key:"valToChar",value:function(a){switch(a){case t:return"-";case e:return"o";case s:return"O";case i:return"x";case r:return"#";case n:return"/";case o:return"X"}}},{key:"getImageCase",value:function(h){switch(this.get(h)){case r:return"wall.png";case i:return"fruit.png";case o:return"fruit_gold.png";case t:case e:case s:case n:case a:return""}return"unknown.png"}},{key:"getGraph",value:function(t){for(var i=new Array(this.height),r=0;r0))return!!(this.getTotal(t)<=0&&this.fruitPosGold);do{if(s=this.getRandomPosition(),(a=this.detectCorridor(s))&&this.get(s)==t&&this.set(n,s),this.getTotal(t)<=0)return!!this.fruitPosGold}while(this.get(s)!=t||this.isFruitSurrounded(s,!0)||this.maze&&!this.testFruitMaze(s,h)||a);return r?(this.fruitPosGold=s,this.set(o,s)):(this.fruitPos=s,this.set(i,s)),this.maze||null!=this.fruitPosGold||1!=C(1,this.probGoldFruitIncrease?3:e>1?m:k,this.rngGame)||this.setFruit(e,!0),!0}},{key:"testFruitMaze",value:function(e,i){var r=this.getGraph(!0);return new B.Astar.Configuration(r,{order:"yx",torus:!1,diagonals:!1,cutting:!1,cost:function(t,e){return 1==e?null:1}}).path({x:this.mazeFirstPosition.x,y:this.mazeFirstPosition.y},{x:e.x,y:e.y}).length0;){var l=c[0];c.shift();for(var d=[this.getNextPosition(l,w),this.getNextPosition(l,_),this.getNextPosition(l,O),this.getNextPosition(l,P)],f=0;f-1){if(c.push(d[f]),s.indexOf(this.get(d[f]))>-1)return!1;r&&this.get(d[f])==t?(this.set(n,d[f]),u[d[f].y][d[f].x]=n):u[d[f].y][d[f].x]=a}}return(r&&(this.get(e)==t||this.get(e)==i)||this.get(e)==o)&&this.set(n,e),!0}},{key:"isFruitSurrounded",value:function(i,r){var s=this.isCaseSurrounded(i,!1,[e],[t,e]);return s&&r&&this.isCaseSurrounded(i,!0,[e],[t,e]),s}},{key:"detectCorridor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.grid?JSON.parse(JSON.stringify(this.grid)):null;if(this.maze||!t||!e)return!1;var i=this.getNextPosition(t,b),r=this.getNextPosition(t,_),s=this.getNextPosition(t,P),n=this.getNextPosition(t,O),o=this.isDeadPosition(i,!0,!0)+this.isDeadPosition(r,!0,!0)+this.isDeadPosition(s,!0,!0)+this.isDeadPosition(n,!0,!0);if(o<=1||this.isDeadPosition(t,!0))return!1;if(o>=3)return!0;e[t.y][t.x]=a;var h=e[i.y][i.x]!=a&&this.detectCorridor(i,e),u=e[r.y][r.x]!=a&&this.detectCorridor(r,e),c=e[n.y][n.x]!=a&&this.detectCorridor(n,e),l=e[s.y][s.x]!=a&&this.detectCorridor(s,e);return!!(u||h||c||l)}},{key:"getOnLine",value:function(t,e){for(var i=0,r=0;r=this.width&&(i.x=0),i.y<0?i.y=this.height-1:i.y>=this.height&&(i.y=0),i}},{key:"getDirectionTo",value:function(t,e){return this.getNextPosition(t,w).equals(e)?w:this.getNextPosition(t,_).equals(e)?_:this.getNextPosition(t,P).equals(e)?P:this.getNextPosition(t,O).equals(e)?O:-1}},{key:"invertDirection",value:function(t){return t==w?_:t==_?w:t==P?O:t==O?P:null}},{key:"isDeadPosition",value:function(t,i,o){return!i&&this.get(t)==e||this.get(t)==r||this.get(t)==s||!!o&&this.get(t)==n}},{key:"toString",value:function(){for(var t="",e=0;en.x?h=a.x-n.x>t.grid.width/2?E:I:a.xt.grid.width/2?I:E:a.yt.grid.height/2?T:G:a.y>n.y&&(h=a.y-n.y>t.grid.height/2?G:T);var u=t.getNextPosition(n,h);if(t.grid.isDeadPosition(u)){for(var c=this.direction,l=null,d=1;d1){var f=new j(d[1].x,d[1].y);return new j(null,null,t.getDirectionTo(n,f)).convertToKeyDirection()}d=null}return null}}])}(K);function rt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(rt=function(){return!!t})()}var st=function(t){function e(t){var i,r,s,n;return L(this,e),r=this,n=[!0],s=H(s=e),(i=J(r,rt()?Reflect.construct(s,n||[],H(r).constructor):s.apply(r,n))).aiLow=new tt(t),i._aiLevelText="high",i}return Y(e,t),R(e,[{key:"ai",value:function(t){var i,r,s;return(i=e,r=this,"function"==typeof(s=X(H(1&3?i.prototype:i),"ai",r))?function(t){return s.apply(r,t)}:s)([t])||this.aiLow.ai(t)}}])}(it);function nt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(nt=function(){return!!t})()}var ot,at=function(t){function e(){var t,i,r,s;return L(this,e),i=this,r=H(r=e),(t=J(i,nt()?Reflect.construct(r,[],H(i).constructor):r.apply(i,s)))._aiLevelText="mock",t}return Y(e,t),R(e,[{key:"ai",value:function(){return null}}])}(K),ht=function(){function r(t,e,i,s,n,o,a,h){L(this,r),this.direction=null==t?P:t,this.initialDirection=this.direction,this.initialLength=null==e?3:e,this.initTriedDirections=[],this.errorInit=!1,this.grid=i||new U,this.queue=[],this.lastKey=-1,this.lastTail,this.lastTailMoved,this.ticksDead=0,this.player=null==s?u:s,this.aiLevel=null==n?f:n,this.autoRetry=null!=o&&o,this.score=0,this.gameOver=!1,this.scoreMax=!1,this.color,this.name=null==a?"Snake":a,this.snakeAI=new K,this.customAI=h,this.ticksWithoutAction=0,this.initAI()}return R(r,[{key:"init",value:function(){if(this.initialLength<=0)return this.errorInit=!0,!1;this.grid.maze&&this.initTriedDirections.length<=0&&(this.initialDirection=this.grid.mazeFirstPosition.direction,this.direction=this.initialDirection);var e=0,i=0;if(this.initialDirection==P&&-1==this.initTriedDirections.indexOf(P)||this.initialDirection==O&&-1==this.initTriedDirections.indexOf(O)){for(var r=0;r=this.initialLength){e++;break}}else if(this.initialDirection==w&&-1==this.initTriedDirections.indexOf(w)||this.initialDirection==_&&-1==this.initTriedDirections.indexOf(_))for(var o=0;o=this.initialLength){i++;break}if(this.initTriedDirections.push(this.initialDirection),e<=0&&(this.initialDirection==P||this.initialDirection==O)||i<=0&&(this.initialDirection==w||this.initialDirection==_))return-1==this.initTriedDirections.indexOf(P)?(this.initialDirection=P,this.direction=P,this.init()):-1==this.initTriedDirections.indexOf(O)?(this.initialDirection=O,this.direction=O,this.init()):-1==this.initTriedDirections.indexOf(w)?(this.initialDirection=w,this.direction=w,this.init()):-1==this.initTriedDirections.indexOf(_)?(this.initialDirection=_,this.direction=_,this.init()):(this.errorInit=!0,!1);for(var l,d,f=!0,y=[];f;){if(f=!1,!(l=this.grid.maze?this.grid.mazeFirstPosition:this.grid.getRandomPosition()))return this.errorInit=!0,!1;d=new j(l.x,l.y,this.initialDirection),y=[];for(var p=this.initialLength-1;p>=0;p--)p=0&&t=this.grid.width*t)return!0;if((this.direction==w||this.direction==_)&&this.ticksWithoutAction>=this.grid.height*e)return!0}return!1}},{key:"getAILevelText",value:function(){return this.snakeAI?this.snakeAI.aiLevelText:"???"}}])}(),ut=function(){return R((function t(e){L(this,t),this.name=e,this.callbacks=[]}),[{key:"registerCallback",value:function(t){this.callbacks.push(t)}}])}(),ct=function(){return R((function t(){L(this,t),this.events={}}),[{key:"registerEvent",value:function(t){this.events[t]=new ut(t)}},{key:"dispatchEvent",value:function(t,e){for(var i=this.events[t].callbacks,r=0,s=i.length;r1)&&(this.errorOccurred=!0):this.snakes=[this.snakes],this.grid instanceof U==0)this.errorOccurred=!0;else if(!this.errorOccurred){this.initGridAndSnakes();for(var t=C(0,360,this.grid?new(W())(this.grid.seedGame):null),e=0;e360?s-360:s<0?360+s:s,this.snakes[e].color=t)}var i,r,s}},{key:"initGridAndSnakes",value:function(){if(this.grid.reset(),this.grid.init(),null!=this.snakes){for(var t=0;t-1&&this.snakes[i].setGameOver(this.ticks)}},{key:"getNBPlayer",value:function(t){var e=0;if(null!=this.snakes)for(var i=0;i0||this.getNBPlayer(c)>0)&&-1!=(this.getPlayer(1,c)||this.getPlayer(1,u)).lastKey)){for(var s=0;s0&&this.initialSpeed>1&&(this.initialSpeed=Math.ceil(-this.initialSpeedUntouched/100*this.snakes[s].score+this.initialSpeedUntouched),this.initialSpeed=this.initialSpeed<1?1:this.initialSpeed)):(this.snakes[s].insert(f),this.grid.maze||(this.snakes[s].remove(),this.snakes[s].lastTailMoved=!0))}this.scoreMax||!a||this.clientSidePredictionsMode||(r=!this.grid.setFruit(this.snakes.length))}this.scoreMax||r||!this.grid.detectCorridor(this.grid.fruitPos)&&!this.grid.isFruitSurrounded(this.grid.fruitPos,!0)||this.clientSidePredictionsMode||(r=!this.grid.setFruit(this.snakes.length)),this.scoreMax||null==this.grid.fruitPosGold||!this.grid.detectCorridor(this.grid.fruitPosGold)&&!this.grid.isFruitSurrounded(this.grid.fruitPosGold,!0)||(this.grid.set(t,this.grid.fruitPosGold),this.grid.fruitPosGold=null);for(var g=0,y=0;y=this.snakes.length||r||p)&&(this.stop(),this.snakes.length>1&&(this.gameFinished=!0)),this.reactor.dispatchEvent("onUpdate"),e&&this.reactor.dispatchEvent("onScoreIncreased")}this.tick()}}},{key:"onReset",value:function(t){this.reactor.addEventListener("onReset",t)}},{key:"onStart",value:function(t){this.reactor.addEventListener("onStart",t)}},{key:"onContinue",value:function(t){this.reactor.addEventListener("onContinue",t)}},{key:"onStop",value:function(t){this.reactor.addEventListener("onStop",t)}},{key:"onPause",value:function(t){this.reactor.addEventListener("onPause",t)}},{key:"onExit",value:function(t){this.reactor.addEventListener("onExit",t)}},{key:"onKill",value:function(t){this.reactor.addEventListener("onKill",t)}},{key:"onScoreIncreased",value:function(t){this.reactor.addEventListener("onScoreIncreased",t)}},{key:"onUpdate",value:function(t){this.reactor.addEventListener("onUpdate",t)}},{key:"onUpdateCounter",value:function(t){this.reactor.addEventListener("onUpdateCounter",t)}}])}();function dt(t){var e=JSON.parse(JSON.stringify(t));if(e)for(var i=0;i1&&"init"==e[0]){var i=gt(e[1].snakes,e[1].grid),r=i.grid,s=i.snakes;(ot=new lt(r,s,e[1].speed,e[1].enablePause,e[1].enableRetry,e[1].progressiveSpeed)).init(),self.postMessage(["init",{snakes:dt(ot.snakes),grid:ft(ot.grid),enablePause:ot.enablePause,enableRetry:ot.enableRetry,progressiveSpeed:ot.progressiveSpeed,offsetFrame:ot.speed*x,errorOccurred:ot.errorOccurred}]),ot.onReset((function(){self.postMessage(["reset",{paused:ot.paused,isReseted:ot.isReseted,exited:ot.exited,snakes:dt(ot.snakes),grid:ft(ot.grid),numFruit:ot.numFruit,ticks:ot.ticks,scoreMax:ot.scoreMax,gameOver:ot.gameOver,gameFinished:ot.gameFinished,gameMazeWin:ot.gameMazeWin,starting:ot.starting,initialSpeed:ot.initialSpeed,speed:ot.speed,offsetFrame:ot.speed*x,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred,aiStuck:ot.aiStuck,precAiStuck:!1}])})),ot.onStart((function(){self.postMessage(["start",{snakes:dt(ot.snakes),grid:ft(ot.grid),starting:ot.starting,countBeforePlay:ot.countBeforePlay,paused:ot.paused,isReseted:ot.isReseted,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred}])})),ot.onPause((function(){self.postMessage(["pause",{paused:ot.paused,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred}])})),ot.onContinue((function(){self.postMessage(["continue",{confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred}])})),ot.onStop((function(){self.postMessage(["stop",{paused:ot.paused,scoreMax:ot.scoreMax,gameOver:ot.gameOver,gameFinished:ot.gameFinished,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred}])})),ot.onExit((function(){self.postMessage(["exit",{paused:ot.paused,gameOver:ot.gameOver,gameFinished:ot.gameFinished,exited:ot.exited,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred}])})),ot.onKill((function(){self.postMessage(["kill",{paused:ot.paused,gameOver:ot.gameOver,killed:ot.killed,snakes:dt(ot.snakes),grid:ft(ot.grid),gameFinished:ot.gameFinished,confirmReset:!1,confirmExit:!1,getInfos:!1,getInfosGame:!1,errorOccurred:ot.errorOccurred}])})),ot.onScoreIncreased((function(){self.postMessage(["scoreIncreased",{}])})),ot.onUpdate((function(){self.postMessage(["update",{paused:ot.paused,isReseted:ot.isReseted,exited:ot.exited,snakes:dt(ot.snakes),grid:ft(ot.grid),numFruit:ot.numFruit,ticks:ot.ticks,scoreMax:ot.scoreMax,gameOver:ot.gameOver,gameFinished:ot.gameFinished,gameMazeWin:ot.gameMazeWin,starting:ot.starting,initialSpeed:ot.initialSpeed,speed:ot.speed,countBeforePlay:ot.countBeforePlay,offsetFrame:0,errorOccurred:ot.errorOccurred,aiStuck:ot.aiStuck}])})),ot.onUpdateCounter((function(){self.postMessage(["updateCounter",{paused:ot.paused,isReseted:ot.isReseted,exited:ot.exited,snakes:dt(ot.snakes),grid:ft(ot.grid),numFruit:ot.numFruit,ticks:ot.ticks,scoreMax:ot.scoreMax,gameOver:ot.gameOver,gameFinished:ot.gameFinished,gameMazeWin:ot.gameMazeWin,starting:ot.starting,initialSpeed:ot.initialSpeed,speed:ot.speed,countBeforePlay:ot.countBeforePlay,errorOccurred:ot.errorOccurred}])}))}else if(null!=ot)switch(e[0]){case"reset":ot.reset();break;case"start":ot.start();break;case"stop":ot.stop(!1);break;case"finish":ot.stop(!0);break;case"pause":ot.pause();break;case"kill":ot.kill();break;case"tick":ot.paused=!1,ot.countBeforePlay=-1,ot.tick();break;case"ping":self.postMessage("pong");break;case"exit":ot.exit();break;case"forceStart":ot.forceStart();break;case"key":if(e.length>1){ot.lastKey=e[1];var n=ot.getPlayer(1,u)||ot.getPlayer(1,c);null!=n&&null!=n.lastKey&&(n.lastKey=e[1])}break;case"update":if(e.length>1)if("snakes"==e[1].key){var o=gt(e[1].data);o&&(ot.snakes=o.snakes)}else if("grid"==e[1].key){var a=gt(null,e[1].data);a&&(ot.grid=a.grid)}else ot[e[1].key]=e[1].data;break;case"destroySnakes":e[1]&&e[2]&&ot.destroySnakes(e[1],e[2])}else"ping"==e&&self.postMessage("pong")},self.postMessage("ready")})()})(); \ No newline at end of file diff --git a/dist/SnakeIA-node.js b/dist/SnakeIA-node.js index ee5c00d..d6d7a46 100644 --- a/dist/SnakeIA-node.js +++ b/dist/SnakeIA-node.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SnakeIA=e():t.SnakeIA=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=25)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){var n=i(12);function r(t,e){for(var i=0;i{void 0===t.graph.get(this)._connectivity&&0>n.indexOf(t)&&n.push(t)})}}}add(t){return 1this.add(t)):(t.graph.set(this,new Map),this.nodes.set(t.id,t),t)}delete(t){return 1this.delete(t)):(t.graph.delete(this),this.nodes.delete(t.id),t)}edge(t,e,i=1,n=1){if(!t.graph.has(this)||!e.graph.has(this))throw new Error("Nodes must be on the same graph");return null===i?t.graph.get(this).delete(e):t.graph.get(this).set(e,i),null===n?e.graph.get(this).delete(t):e.graph.get(this).set(t,n),this}cost(t,e){return this.adjacent(t,e)?t.graph.get(this).get(e):null}}e.fromArray=function(t,i={}){let n=e.fromArray.X(t,i.order),r=e.fromArray.Y(t,i.order),s=e.fromArray.at.bind(null,t,i.order),o=[],a=null;for(let t,h=1;hc(t.x,t.y)}),t.connect(),t.X=n,t.Y=r,t.TORUS=i.torus,a||(a=t.nodes)}return 1+t}get size(){return this.nodes.length}add(t){if(1=this.score(r))break;this.nodes[n]=e,this.nodes[t]=r,t=n}return this}sink(t){let e=this.nodes[t],i=this.score(e);for(;;){let n=2*(t+1),r=n-1,s=null;if(r{this._worker_path_callback=i.callback,delete i.callback,this.worker.postMessage(["path",t,e,i])},this.worker.onmessage=t=>{let e=JSON.parse(t.data);switch(e[0]){case"path":this._worker_path_callback(e[1])}}}}path(t,e,i={}){if(i.jps)return this.jps(t,e,i);let n=new g(t=>t.estimated),r=new Map,s=this.graphs[i.layer||0];if(t=s.node(t,!0),e=s.node(e,!0),n.add({node:t,estimated:0}),r.set(t,{score:0,from:null}),!i.static||s.connected(t,e))for(;n.size;){let t=n.pop().node;if(t===e)break;s.neighbors(t).map(o=>{let a=(r.has(t)?r.get(t).score:0)+s.cost(t,o);a<(r.has(o)?r.get(o).score:1/0)&&(r.set(o,{score:a,from:t}),n.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))}),n.delete(t)}let o=[];if(r.has(e)){let t=e;for(o.push(e);null!==(t=r.get(t).from);)o.push(t);o=o.reverse()}return i.callback&&i.callback(o,r),o}}if(j.JPS=class{constructor(){}static access(t,e,i,n){return t.adjacent(e,n?t.node(i,!0):i)}static neighborhood(t,e,i,n){let r=[],s=i.get(n).from||null;if(null===s)return e.neighbors(n);{let i={x:b(n.x-s.x),y:b(n.y-s.y)};if(0!=i.x&&0!=i.y){let s=t(n,{x:n.x+i.x,y:n.y},!0),o=t(n,{x:n.x,y:n.y+i.y},!0);(s||o)&&(r.push(e.node({x:n.x+i.x,y:n.y+i.y},!0)),s&&(r.push(e.node({x:n.x+i.x,y:n.y},!0)),!t(n,{x:n.x,y:n.y-i.y},!0)&&r.push(e.node({x:n.x+i.x,y:n.y-i.y},!0))),o&&(r.push(e.node({x:n.x,y:n.y+i.y},!0)),!t(n,{x:n.x-i.x,y:n.y},!0)&&r.push(e.node({x:n.x-i.x,y:n.y+i.y},!0))))}else t(n,{x:n.x+i.x,y:n.y+i.y},!0)&&(r.push(e.node({x:n.x+i.x,y:n.y+i.y},!0)),0==i.x?0!=i.y&&(!t(n,{x:n.x-1,y:n.y},!0)&&r.push(e.node({x:n.x-1,y:n.y+i.y},!0)),!t(n,{x:n.x+1,y:n.y},!0)&&r.push(e.node({x:n.x+1,y:n.y+i.y},!0))):(!t(n,{x:n.x,y:n.y-1},!0)&&r.push(e.node({x:n.x+i.x,y:n.y-1},!0)),!t(n,{x:n.x,y:n.y+1},!0)&&r.push(e.node({x:n.x+i.x,y:n.y+1},!0))))}return r.filter(t=>t)}static jump(t,e,i,n,r,s){for(;;){if(!t(s,r))return null;if(r.x===n.x&&r.y===n.y)return r;let o={x:b(r.x-s.x),y:b(r.y-s.y)};if(0!=o.x&&0!=o.y){if(!t(r,{x:r.x-o.x,y:r.y},!0)&&t(r,{x:r.x-o.x,y:r.y+o.y},!0)||!t(r,{x:r.x,y:r.y-o.y},!0)&&t(r,{x:r.x+o.x,y:r.y-o.y},!0))return r;let s=j.JPS.jump.bind(this,t,e,i,n);if(null!==s(e.node({x:r.x+o.x,y:r.y},!0),r)||null!==s(e.node({x:r.x,y:r.y+o.y},!0),r))return r}else if(0!=o.x){if(!t(r,{x:r.x,y:r.y-1},!0)&&t(r,{x:r.x+o.x,y:r.y-1},!0)||!t(r,{x:r.x,y:r.y+1},!0)&&t(r,{x:r.x+o.x,y:r.y+1},!0))return r}else if(0!=o.y&&(!t(r,{x:r.x-1,y:r.y},!0)&&t(r,{x:r.x-1,y:r.y+o.y},!0)||!t(r,{x:r.x+1,y:r.y},!0)&&t(r,{x:r.x+1,y:r.y+o.y},!0)))return r;s=r,r=e.node({x:r.x+o.x,y:r.y+o.y},!0)}return null}},j.prototype.jps=function(t,e,i={}){if(this.graphs[i.layer||0].TORUS)return console.warn("Torus map aren't yet supported by JPS"),i.callback&&i.callback([],new Map),[];let n=new g(t=>t.estimated),r=new Map,s=this.graphs[i.layer||0],o=null;t=s.node(t,!0),e=s.node(e,!0),n.add({node:t,estimated:0}),r.set(t,{score:0,from:null});let a=j.JPS.access.bind(this,s),c=j.JPS.neighborhood.bind(this,a,s,r),u=j.JPS.jump.bind(this,a,s,r,e);if(!i.static||s.connected(t,e))for(;n.size;){let t=n.pop().node;if(t===e)break;c(t).map(a=>{if(null!==(o=u(a,t))){let a=(r.has(t)?r.get(t).score:0)+s.cost(t,o);a<(r.has(o)?r.get(o).score:1/0)&&(r.set(o,{score:a,from:t,jumped:!0}),n.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))}}),n.delete(t)}let l=[];if(r.has(e)){let i=e;for(;i.x!=t.x||i.y!=t.y;)for(let t=r.get(i).from;i.x!=t.x||i.y!=t.y;)l.push(i),i=s.node({x:i.x+b(t.x-i.x),y:i.y+b(t.y-i.y)},!0);l.push(i),l.reverse()}return i.callback&&i.callback(l,r),l},"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){let a;onmessage=function(b){let c=b.data;switch(c[0]){case"constructor":if("cost"in c[2]){let a=/^\((.*?)\)\s*=>\s*{/.test(c[2].cost),b=/^function /.test(c[2].cost);c[2].cost=eval(`(${a||b?"":"function "}${c[2].cost})`)}a=new j(c[1],c[2]);break;case"path":postMessage(JSON.stringify(["path",a.path(c[1],c[2],c[3])]))}}}a.Lowlight.Astar={Graph:e,Node:f,BinaryHeap:g,Heuristic:h,Configuration:j,WorkerError:i}}("undefined"==typeof window?this:window)},function(t,e){function i(e){return t.exports=i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,i(e)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){var n=i(11).default,r=i(13);t.exports=function(t){var e=r(t,"string");return"symbol"==n(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){var n=i(11).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,i){(function(t){var n;!function(t,r,s){function o(t){var e,i=this,n=(e=4022871197,function(t){t=String(t);for(var i=0;i>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)});i.next=function(){var t=2091639*i.s0+2.3283064365386963e-10*i.c;return i.s0=i.s1,i.s1=i.s2,i.s2=t-(i.c=0|t)},i.c=1,i.s0=n(" "),i.s1=n(" "),i.s2=n(" "),i.s0-=n(t),i.s0<0&&(i.s0+=1),i.s1-=n(t),i.s1<0&&(i.s1+=1),i.s2-=n(t),i.s2<0&&(i.s2+=1),n=null}function a(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function h(t,e){var i=new o(t),n=e&&e.state,r=i.next;return r.int32=function(){return 4294967296*i.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,n&&("object"==typeof n&&a(n,i),r.state=function(){return a(i,{})}),r}r&&r.exports?r.exports=h:i(3)&&i(8)?void 0===(n=function(){return h}.call(e,i,e,r))||(r.exports=n):this.alea=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var n;!function(t,r,s){function o(t){var e=this,i="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:i+=t;for(var n=0;n>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&("object"==typeof n&&a(n,i),r.state=function(){return a(i,{})}),r}r&&r.exports?r.exports=h:i(3)&&i(8)?void 0===(n=function(){return h}.call(e,i,e,r))||(r.exports=n):this.xor128=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var n;!function(t,r,s){function o(t){var e=this,i="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:i+=t;for(var n=0;n>>4),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function h(t,e){var i=new o(t),n=e&&e.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&("object"==typeof n&&a(n,i),r.state=function(){return a(i,{})}),r}r&&r.exports?r.exports=h:i(3)&&i(8)?void 0===(n=function(){return h}.call(e,i,e,r))||(r.exports=n):this.xorwow=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var n;!function(t,r,s){function o(t){var e=this;e.next=function(){var t,i,n=e.x,r=e.i;return t=n[r],i=(t^=t>>>7)^t<<24,i^=(t=n[r+1&7])^t>>>10,i^=(t=n[r+3&7])^t>>>3,i^=(t=n[r+4&7])^t<<7,t=n[r+7&7],i^=(t^=t<<13)^t<<9,n[r]=i,e.i=r+1&7,i},function(t,e){var i,n=[];if(e===(0|e))n[0]=e;else for(e=""+e,i=0;i0;--i)t.next()}(e,t)}function a(t,e){return e.x=t.x.slice(),e.i=t.i,e}function h(t,e){null==t&&(t=+new Date);var i=new o(t),n=e&&e.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&(n.x&&a(n,i),r.state=function(){return a(i,{})}),r}r&&r.exports?r.exports=h:i(3)&&i(8)?void 0===(n=function(){return h}.call(e,i,e,r))||(r.exports=n):this.xorshift7=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var n;!function(t,r,s){function o(t){var e=this;e.next=function(){var t,i,n=e.w,r=e.X,s=e.i;return e.w=n=n+1640531527|0,i=r[s+34&127],t=r[s=s+1&127],i^=i<<13,t^=t<<17,i^=i>>>15,t^=t>>>12,i=r[s]=i^t,e.i=s,i+(n^n>>>16)|0},function(t,e){var i,n,r,s,o,a=[],h=128;for(e===(0|e)?(n=e,e=null):(e+="\0",n=0,h=Math.max(h,e.length)),r=0,s=-32;s>>15,n^=n<<4,n^=n>>>13,s>=0&&(o=o+1640531527|0,r=0==(i=a[127&s]^=n+o)?r+1:0);for(r>=128&&(a[127&(e&&e.length||0)]=-1),r=127,s=512;s>0;--s)n=a[r+34&127],i=a[r=r+1&127],n^=n<<13,i^=i<<17,n^=n>>>15,i^=i>>>12,a[r]=n^i;t.w=o,t.X=a,t.i=r}(e,t)}function a(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function h(t,e){null==t&&(t=+new Date);var i=new o(t),n=e&&e.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&(n.X&&a(n,i),r.state=function(){return a(i,{})}),r}r&&r.exports?r.exports=h:i(3)&&i(8)?void 0===(n=function(){return h}.call(e,i,e,r))||(r.exports=n):this.xor4096=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){(function(t){var n;!function(t,r,s){function o(t){var e=this,i="";e.next=function(){var t=e.b,i=e.c,n=e.d,r=e.a;return t=t<<25^t>>>7^i,i=i-n|0,n=n<<24^n>>>8^r,r=r-t|0,e.b=t=t<<20^t>>>12^i,e.c=i=i-n|0,e.d=n<<16^i>>>16^r,e.a=r-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):i+=t;for(var n=0;n>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&("object"==typeof n&&a(n,i),r.state=function(){return a(i,{})}),r}r&&r.exports?r.exports=h:i(3)&&i(8)?void 0===(n=function(){return h}.call(e,i,e,r))||(r.exports=n):this.tychei=h}(0,t,i(3))}).call(this,i(7)(t))},function(t,e,i){var n;!function(r,s,o){var a,h=o.pow(256,6),c=o.pow(2,52),u=2*c;function l(t,e,i){var n=[],l=y(function t(e,i){var n,r=[],s=typeof e;if(i&&"object"==s)for(n in e)try{r.push(t(e[n],i-1))}catch(t){}return r.length?r:"string"==s?e:e+"\0"}((e=1==e?{entropy:!0}:e||{}).entropy?[t,g(s)]:null==t?function(){try{var t;return a&&(t=a.randomBytes)?t=t(256):(t=new Uint8Array(256),(r.crypto||r.msCrypto).getRandomValues(t)),g(t)}catch(t){var e=r.navigator,i=e&&e.plugins;return[+new Date,r,i,r.screen,g(s)]}}():t,3),n),p=new d(n),T=function(){for(var t=p.g(6),e=h,i=0;t=u;)t/=2,e/=2,i>>>=1;return(t+i)/e};return T.int32=function(){return 0|p.g(4)},T.quick=function(){return p.g(4)/4294967296},T.double=T,y(g(p.S),s),(e.pass||i||function(t,e,i,n){return n&&(n.S&&f(n,p),t.state=function(){return f(p,{})}),i?(o.random=t,e):t})(T,l,"global"in e?e.global:this==o,e.state)}function d(t){var e,i=t.length,n=this,r=0,s=n.i=n.j=0,o=n.S=[];for(i||(t=[i++]);r<256;)o[r]=r++;for(r=0;r<256;r++)o[r]=o[s=255&s+t[r%i]+(e=o[r])],o[s]=e;(n.g=function(t){for(var e,i=0,r=n.i,s=n.j,o=n.S;t--;)e=o[r=255&r+1],i=256*i+o[255&(o[r]=o[s=255&s+e])+(o[s]=e)];return n.i=r,n.j=s,i})(256)}function f(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function y(t,e){for(var i,n=t+"",r=0;r360?i-360:i<0?360+i:i},shuffle:function(t,e){for(var i,n,r=t.length-1;r>0;r--)i=Math.floor((e?e():Math.random())*(r+1)),n=t[r],t[r]=t[i],t[i]=n;return t},millisecondsFormat:function(t){return t/=1e3,("0"+Math.trunc(t/60)).slice(-2)+":"+("0"+Math.trunc(t%60)).slice(-2)},secondsFormat:function(t){return this.millisecondsFormat(1e3*t)}},l=function(){function t(e,i,n){s()(this,t),this.x=e,this.y=i,this.direction=n}return a()(t,[{key:"copy",value:function(){return new t(this.x,this.y,this.direction)}},{key:"convertToKeyDirection",value:function(){switch(this.direction){case n.Direction.UP:return n.Key.UP;case n.Direction.RIGHT:return n.Key.RIGHT;case n.Direction.LEFT:return n.Key.LEFT;case n.Direction.BOTTOM:return n.Key.BOTTOM;default:return this.direction}}},{key:"convertToSimpleDirection",value:function(){switch(this.direction){case n.Key.UP:return n.Direction.UP;case n.Key.RIGHT:return n.Direction.RIGHT;case n.Key.LEFT:return n.Direction.LEFT;case n.Key.BOTTOM:return n.Direction.BOTTOM;default:return this.direction}}},{key:"equals",value:function(t){return null!=t&&(this.x==t.x&&this.y==t.y)}}])}(),d=i(9),f=i.n(d),y=i(10),g=function(){return a()((function t(e,i,r,o,a,h,c,u,d,f){s()(this,t),this.width=null==e?20:e,this.height=null==i?20:i,this.generateWalls=null!=r&&r,this.borderWalls=null!=o&&o,this.maze=null!=a&&a,this.mazeFirstPosition=new l(1,1,n.Direction.RIGHT),this.mazeForceAuto=null!=c&&c,this.grid,this.initialGrid,this.fruitPos,this.fruitPosGold,this.customGrid=h,this.seedGrid=u?""+parseInt(u):void 0,this.seedGame=u?""+parseInt(d):void 0,this.rngGrid,this.rngGame,this.probGoldFruitIncrease=null!=f&&f}),[{key:"init",value:function(){if(null!=this.customGrid||null!=this.initialGrid){var t;t=null!=this.initialGrid?this.initialGrid:this.customGrid,this.height=t.length,this.width=t[0].length,this.initialGrid=new Array(this.height),this.grid=new Array(this.height);for(var e=0;e.65||this.maze?this.grid[i][r]=n.CaseType.WALL:this.grid[i][r]=n.CaseType.EMPTY}this.maze?this.generateMaze():this.generateWalls&&this.fixWalls(this.borderWalls)}this.fruitPosGold=null}},{key:"reset",value:function(){this.grid=void 0,this.initialGrid=void 0,this.fruitPos=void 0,this.fruitPosGold=void 0,this.rngGrid=new f.a(this.seedGrid),this.rngGame=new f.a(this.seedGame)}},{key:"fixWalls",value:function(t){var e,i,r,s;t?(e=1,r=this.height-1,i=1,s=this.width-1):(e=0,r=this.height,i=0,s=this.width);for(var o=e;o=this.width-1)continue;this.get(new l(e+2,t))!=n.CaseType.EMPTY&&(this.set(n.CaseType.EMPTY,new l(e+2,t)),this.set(n.CaseType.EMPTY,new l(e+1,t)),this.maze_recursion(t,e+2));break;case n.Direction.BOTTOM:if(t+2>=this.height-1)continue;this.get(new l(e,t+2))!=n.CaseType.EMPTY&&(this.set(n.CaseType.EMPTY,new l(e,t+2)),this.set(n.CaseType.EMPTY,new l(e,t+1)),this.maze_recursion(t+2,e));break;case n.Direction.LEFT:if(e-2<=0)continue;this.get(new l(e-2,t))!=n.CaseType.EMPTY&&(this.set(n.CaseType.EMPTY,new l(e-2,t)),this.set(n.CaseType.EMPTY,new l(e-1,t)),this.maze_recursion(t,e-2))}}},{key:"generateMaze",value:function(){this.mazeFirstPosition=new l(1,1,n.Direction.RIGHT),this.set(n.CaseType.EMPTY,this.mazeFirstPosition),this.maze_recursion(1,1)}},{key:"set",value:function(t,e){this.grid[e.y][e.x]=t}},{key:"get",value:function(t){return this.grid[t.y][t.x]}},{key:"valToChar",value:function(t){switch(t){case n.CaseType.EMPTY:return"-";case n.CaseType.SNAKE:return"o";case n.CaseType.SNAKE_DEAD:return"O";case n.CaseType.FRUIT:return"x";case n.CaseType.WALL:return"#";case n.CaseType.SURROUNDED:return"/";case n.CaseType.FRUIT_GOLD:return"X"}}},{key:"getImageCase",value:function(t){switch(this.get(t)){case n.CaseType.WALL:return"wall.png";case n.CaseType.FRUIT:return"fruit.png";case n.CaseType.FRUIT_GOLD:return"fruit_gold.png";case n.CaseType.EMPTY:case n.CaseType.SNAKE:case n.CaseType.SNAKE_DEAD:case n.CaseType.SURROUNDED:case n.CaseType.CROSSED:return""}return"unknown.png"}},{key:"getGraph",value:function(t){for(var e=new Array(this.height),i=0;i0))return!!(this.getTotal(n.CaseType.EMPTY)<=0&&this.fruitPosGold);do{if(i=this.getRandomPosition(),(r=this.detectCorridor(i))&&this.get(i)==n.CaseType.EMPTY&&this.set(n.CaseType.SURROUNDED,i),this.getTotal(n.CaseType.EMPTY)<=0)return!!this.fruitPosGold}while(this.get(i)!=n.CaseType.EMPTY||this.isFruitSurrounded(i,!0)||this.maze&&!this.testFruitMaze(i,s)||r);return e?(this.fruitPosGold=i,this.set(n.CaseType.FRUIT_GOLD,i)):(this.fruitPos=i,this.set(n.CaseType.FRUIT,i)),this.maze||null!=this.fruitPosGold||1!=u.randRange(1,this.probGoldFruitIncrease?3:t>1?n.Setting.PROB_GOLD_FRUIT_MULTIPLE_PLAYERS:n.Setting.PROB_GOLD_FRUIT_1_PLAYER,this.rngGame)||this.setFruit(t,!0),!0}},{key:"testFruitMaze",value:function(t,e){var i=this.getGraph(!0);return new y.Astar.Configuration(i,{order:"yx",torus:!1,diagonals:!1,cutting:!1,cost:function(t,e){return 1==e?null:1}}).path({x:this.mazeFirstPosition.x,y:this.mazeFirstPosition.y},{x:t.x,y:t.y}).length0;){var a=o[0];o.shift();for(var h=[this.getNextPosition(a,n.Direction.UP),this.getNextPosition(a,n.Direction.BOTTOM),this.getNextPosition(a,n.Direction.LEFT),this.getNextPosition(a,n.Direction.RIGHT)],c=0;c-1){if(o.push(h[c]),i.indexOf(this.get(h[c]))>-1)return!1;e&&this.get(h[c])==n.CaseType.EMPTY?(this.set(n.CaseType.SURROUNDED,h[c]),s[h[c].y][h[c].x]=n.CaseType.SURROUNDED):s[h[c].y][h[c].x]=n.CaseType.CROSSED}}return(e&&(this.get(t)==n.CaseType.EMPTY||this.get(t)==n.CaseType.FRUIT)||this.get(t)==n.CaseType.FRUIT_GOLD)&&this.set(n.CaseType.SURROUNDED,t),!0}},{key:"isFruitSurrounded",value:function(t,e){var i=this.isCaseSurrounded(t,!1,[n.CaseType.SNAKE],[n.CaseType.EMPTY,n.CaseType.SNAKE]);return i&&e&&this.isCaseSurrounded(t,!0,[n.CaseType.SNAKE],[n.CaseType.EMPTY,n.CaseType.SNAKE]),i}},{key:"detectCorridor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.grid?JSON.parse(JSON.stringify(this.grid)):null;if(this.maze||!t||!e)return!1;var i=this.getNextPosition(t,n.Direction.TOP),r=this.getNextPosition(t,n.Direction.BOTTOM),s=this.getNextPosition(t,n.Direction.RIGHT),o=this.getNextPosition(t,n.Direction.LEFT),a=this.isDeadPosition(i,!0,!0),h=this.isDeadPosition(r,!0,!0),c=this.isDeadPosition(s,!0,!0),u=this.isDeadPosition(o,!0,!0),l=a+h+c+u;if(l<=1||this.isDeadPosition(t,!0))return!1;if(l>=3)return!0;e[t.y][t.x]=n.CaseType.CROSSED;var d=e[i.y][i.x]!=n.CaseType.CROSSED&&this.detectCorridor(i,e),f=e[r.y][r.x]!=n.CaseType.CROSSED&&this.detectCorridor(r,e),y=e[o.y][o.x]!=n.CaseType.CROSSED&&this.detectCorridor(o,e),g=e[s.y][s.x]!=n.CaseType.CROSSED&&this.detectCorridor(s,e);return!!(f||d||y||g)}},{key:"getOnLine",value:function(t,e){for(var i=0,n=0;n=this.width&&(i.x=0),i.y<0?i.y=this.height-1:i.y>=this.height&&(i.y=0),i}},{key:"getDirectionTo",value:function(t,e){return this.getNextPosition(t,n.Direction.UP).equals(e)?n.Direction.UP:this.getNextPosition(t,n.Direction.BOTTOM).equals(e)?n.Direction.BOTTOM:this.getNextPosition(t,n.Direction.RIGHT).equals(e)?n.Direction.RIGHT:this.getNextPosition(t,n.Direction.LEFT).equals(e)?n.Direction.LEFT:-1}},{key:"invertDirection",value:function(t){return t==n.Direction.UP?n.Direction.BOTTOM:t==n.Direction.BOTTOM?n.Direction.UP:t==n.Direction.RIGHT?n.Direction.LEFT:t==n.Direction.LEFT?n.Direction.RIGHT:null}},{key:"isDeadPosition",value:function(t,e,i){return!e&&this.get(t)==n.CaseType.SNAKE||this.get(t)==n.CaseType.WALL||this.get(t)==n.CaseType.SNAKE_DEAD||!!i&&this.get(t)==n.CaseType.SURROUNDED}},{key:"toString",value:function(){for(var t="",e=0;eh.x?u=c.x-h.x>t.grid.width/2?n.Key.LEFT:n.Key.RIGHT:c.xt.grid.width/2?n.Key.RIGHT:n.Key.LEFT:c.yt.grid.height/2?n.Key.BOTTOM:n.Key.UP:c.y>h.y&&(u=c.y-h.y>t.grid.height/2?n.Key.UP:n.Key.BOTTOM);var l=t.getNextPosition(h,u);if(t.grid.isDeadPosition(l)){for(var d=this.direction,f=null,y=1;y1){var T=new l(p[1].x,p[1].y);return new l(null,null,t.getDirectionTo(h,T)).convertToKeyDirection()}p=null}return null}}])}(p);function _(t,e,i){return e=k()(e),v()(t,function(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return function(){return!!t}()}()?Reflect.construct(e,i||[],k()(t).constructor):e.apply(t,i))}var L=function(t){function e(t){var i;return s()(this,e),(i=_(this,e,[!0])).aiLow=new R(t),i._aiLevelText="high",i}return O()(e,t),a()(e,[{key:"ai",value:function(t){var i,n,r,s,o,a=(i=e,n="ai",r=this,s=3,o=P()(k()(1&s?i.prototype:i),n,r),2&s&&"function"==typeof o?function(t){return o.apply(r,t)}:o)([t]);return a||this.aiLow.ai(t)}}])}(S);function b(t,e,i){return e=k()(e),v()(t,function(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return function(){return!!t}()}()?Reflect.construct(e,i||[],k()(t).constructor):e.apply(t,i))}var w=function(t){function e(){var t;return s()(this,e),(t=b(this,e))._aiLevelText="mock",t}return O()(e,t),a()(e,[{key:"ai",value:function(){return null}}])}(p),C=function(){function t(e,i,r,o,a,h,c,u){s()(this,t),this.direction=null==e?n.Direction.RIGHT:e,this.initialDirection=this.direction,this.initialLength=null==i?3:i,this.initTriedDirections=[],this.errorInit=!1,this.grid=r||new g,this.queue=[],this.lastKey=-1,this.lastTail,this.lastTailMoved,this.ticksDead=0,this.player=null==o?n.PlayerType.HUMAN:o,this.aiLevel=null==a?n.AiLevel.DEFAULT:a,this.autoRetry=null!=h&&h,this.score=0,this.gameOver=!1,this.scoreMax=!1,this.color,this.name=null==c?"Snake":c,this.snakeAI=new p,this.customAI=u,this.ticksWithoutAction=0,this.initAI()}return a()(t,[{key:"init",value:function(){if(this.initialLength<=0)return this.errorInit=!0,!1;this.grid.maze&&this.initTriedDirections.length<=0&&(this.initialDirection=this.grid.mazeFirstPosition.direction,this.direction=this.initialDirection);var t=0,e=0;if(this.initialDirection==n.Direction.RIGHT&&-1==this.initTriedDirections.indexOf(n.Direction.RIGHT)||this.initialDirection==n.Direction.LEFT&&-1==this.initTriedDirections.indexOf(n.Direction.LEFT)){for(var i=0;i=this.initialLength){t++;break}}else if(this.initialDirection==n.Direction.UP&&-1==this.initTriedDirections.indexOf(n.Direction.UP)||this.initialDirection==n.Direction.BOTTOM&&-1==this.initTriedDirections.indexOf(n.Direction.BOTTOM))for(var o=0;o=this.initialLength){e++;break}if(this.initTriedDirections.push(this.initialDirection),t<=0&&(this.initialDirection==n.Direction.RIGHT||this.initialDirection==n.Direction.LEFT)||e<=0&&(this.initialDirection==n.Direction.UP||this.initialDirection==n.Direction.BOTTOM))return-1==this.initTriedDirections.indexOf(n.Direction.RIGHT)?(this.initialDirection=n.Direction.RIGHT,this.direction=n.Direction.RIGHT,this.init()):-1==this.initTriedDirections.indexOf(n.Direction.LEFT)?(this.initialDirection=n.Direction.LEFT,this.direction=n.Direction.LEFT,this.init()):-1==this.initTriedDirections.indexOf(n.Direction.UP)?(this.initialDirection=n.Direction.UP,this.direction=n.Direction.UP,this.init()):-1==this.initTriedDirections.indexOf(n.Direction.BOTTOM)?(this.initialDirection=n.Direction.BOTTOM,this.direction=n.Direction.BOTTOM,this.init()):(this.errorInit=!0,!1);for(var c,u,d=!0,f=[];d;){if(d=!1,!(c=this.grid.maze?this.grid.mazeFirstPosition:this.grid.getRandomPosition()))return this.errorInit=!0,!1;u=new l(c.x,c.y,this.initialDirection),f=[];for(var y=this.initialLength-1;y>=0;y--)y=0&&t=this.grid.width*t)return!0;if((this.direction==n.Direction.UP||this.direction==n.Direction.BOTTOM)&&this.ticksWithoutAction>=this.grid.height*e)return!0}return!1}},{key:"getAILevelText",value:function(){return this.snakeAI?this.snakeAI.aiLevelText:"???"}}])}(),G=function(){return a()((function t(e){s()(this,t),this.games=null==e?[]:e,this.reactor=new c,this.reactor.registerEvent("onStart"),this.reactor.registerEvent("onPause"),this.reactor.registerEvent("onContinue"),this.reactor.registerEvent("onStop"),this.reactor.registerEvent("onReset"),this.reactor.registerEvent("onExit"),this.reactor.registerEvent("onScoreIncreased"),this.init()}),[{key:"init",value:function(){for(var t=this,e=0;ei&&(i=this.games[n].snakes[r].score);if(i>=0)for(var s=0,o=0;o=i&&(t.push(this.games[o].snakes[a]),e.push(s)),s++;return{winners:t,score:i,index:e}}}])}(),U=function(){return a()((function t(e,i,n,r,o,a,h){s()(this,t),this.grid=e,this.snakes=i,this.speed=null==n?8:n,this.initialSpeed=null==n?8:n,this.initialSpeedUntouched=null==n?8:n,this.enablePause=null==r||r,this.enableRetry=null==o||o,this.progressiveSpeed=null!=a&&a,this.aiStuckLimit=null==h?3:h,this.countBeforePlay=3,this.lastKey=-1,this.numFruit=1,this.ticks=0,this.firstStart=!0,this.starting=!1,this.paused=!0,this.exited=!1,this.killed=!1,this.isReseted=!0,this.gameOver=!1,this.gameFinished=!1,this.gameMazeWin=!1,this.scoreMax=!1,this.errorOccurred=!1,this.clientSidePredictionsMode=!1,this.aiStuck=!1,this.intervalPlay,this.reactor=new c,this.reactor.registerEvent("onStart"),this.reactor.registerEvent("onPause"),this.reactor.registerEvent("onContinue"),this.reactor.registerEvent("onReset"),this.reactor.registerEvent("onStop"),this.reactor.registerEvent("onExit"),this.reactor.registerEvent("onKill"),this.reactor.registerEvent("onScoreIncreased"),this.reactor.registerEvent("onUpdate"),this.reactor.registerEvent("onUpdateCounter")}),[{key:"init",value:function(){if(!this.clientSidePredictionsMode)if(null==this.snakes?(this.errorOccurred=!0,this.snakes=[]):Array.isArray(this.snakes)?(Array.isArray(this.snakes)&&this.snakes.length<=0||this.grid.maze&&this.snakes.length>1)&&(this.errorOccurred=!0):this.snakes=[this.snakes],this.grid instanceof g==0)this.errorOccurred=!0;else if(!this.errorOccurred){this.initGridAndSnakes();for(var t=u.randRange(0,360,this.grid?new f.a(this.grid.seedGame):null),e=0;e-1&&this.snakes[i].setGameOver(this.ticks)}},{key:"getNBPlayer",value:function(t){var e=0;if(null!=this.snakes)for(var i=0;i0||this.getNBPlayer(n.PlayerType.HYBRID_HUMAN_AI)>0)&&-1!=(this.getPlayer(1,n.PlayerType.HYBRID_HUMAN_AI)||this.getPlayer(1,n.PlayerType.HUMAN)).lastKey)){for(var i=0;i0&&this.initialSpeed>1&&(this.initialSpeed=Math.ceil(-this.initialSpeedUntouched/100*this.snakes[i].score+this.initialSpeedUntouched),this.initialSpeed=this.initialSpeed<1?1:this.initialSpeed)):(this.snakes[i].insert(a),this.grid.maze||(this.snakes[i].remove(),this.snakes[i].lastTailMoved=!0))}this.scoreMax||!s||this.clientSidePredictionsMode||(e=!this.grid.setFruit(this.snakes.length))}this.scoreMax||e||!this.grid.detectCorridor(this.grid.fruitPos)&&!this.grid.isFruitSurrounded(this.grid.fruitPos,!0)||this.clientSidePredictionsMode||(e=!this.grid.setFruit(this.snakes.length)),this.scoreMax||null==this.grid.fruitPosGold||!this.grid.detectCorridor(this.grid.fruitPosGold)&&!this.grid.isFruitSurrounded(this.grid.fruitPosGold,!0)||(this.grid.set(n.CaseType.EMPTY,this.grid.fruitPosGold),this.grid.fruitPosGold=null);for(var h=0,c=0;c=this.snakes.length||e||u)&&(this.stop(),this.snakes.length>1&&(this.gameFinished=!0)),this.reactor.dispatchEvent("onUpdate"),t&&this.reactor.dispatchEvent("onScoreIncreased")}this.tick()}}},{key:"onReset",value:function(t){this.reactor.addEventListener("onReset",t)}},{key:"onStart",value:function(t){this.reactor.addEventListener("onStart",t)}},{key:"onContinue",value:function(t){this.reactor.addEventListener("onContinue",t)}},{key:"onStop",value:function(t){this.reactor.addEventListener("onStop",t)}},{key:"onPause",value:function(t){this.reactor.addEventListener("onPause",t)}},{key:"onExit",value:function(t){this.reactor.addEventListener("onExit",t)}},{key:"onKill",value:function(t){this.reactor.addEventListener("onKill",t)}},{key:"onScoreIncreased",value:function(t){this.reactor.addEventListener("onScoreIncreased",t)}},{key:"onUpdate",value:function(t){this.reactor.addEventListener("onUpdate",t)}},{key:"onUpdateCounter",value:function(t){this.reactor.addEventListener("onUpdateCounter",t)}}])}()}])})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SnakeIA=e():t.SnakeIA=e()}("undefined"!=typeof self?self:this,(()=>(()=>{var __webpack_modules__={293:function(module){(function(a){var b=Math.sign,c=Math.min,d=Math.abs;void 0===a.Lowlight&&(a.Lowlight={}),"object"==typeof module.exports&&(module.exports=a.Lowlight);class e{constructor(){this.nodes=new Map}id(t){return t}node(t,e=!1){return e?this.nodes.get(this.id(arguments[0])):this.nodes.get(t)}data(t,e){return 2===arguments.length&&(t.graph.get(this)._data=e),t.graph.get(this)._data}adjacent(t,e){return t.graph.get(this).has(e)}neighbors(t){return Array.from(t.graph.get(this).keys())}connected(t,e){return t.graph.get(this)._connectivity===e.graph.get(this)._connectivity}connect(){let t=Array.from(this.nodes.values()),e=0;for(let e=0;e{void 0===t.graph.get(this)._connectivity&&0>n.indexOf(t)&&n.push(t)}))}}}add(t){return 1this.add(t))):(t.graph.set(this,new Map),this.nodes.set(t.id,t),t)}delete(t){return 1this.delete(t))):(t.graph.delete(this),this.nodes.delete(t.id),t)}edge(t,e,i=1,n=1){if(!t.graph.has(this)||!e.graph.has(this))throw new Error("Nodes must be on the same graph");return null===i?t.graph.get(this).delete(e):t.graph.get(this).set(e,i),null===n?e.graph.get(this).delete(t):e.graph.get(this).set(t,n),this}cost(t,e){return this.adjacent(t,e)?t.graph.get(this).get(e):null}}e.fromArray=function(t,i={}){let n=e.fromArray.X(t,i.order),r=e.fromArray.Y(t,i.order),s=e.fromArray.at.bind(null,t,i.order),o=[],a=null;for(let t,h=1;hc(t.x,t.y)}),t.connect(),t.X=n,t.Y=r,t.TORUS=i.torus,a||(a=t.nodes)}return 1+t}get size(){return this.nodes.length}add(t){if(1=this.score(r))break;this.nodes[n]=e,this.nodes[t]=r,t=n}return this}sink(t){let e=this.nodes[t],i=this.score(e);for(;;){let n=2*(t+1),r=n-1,s=null;if(r{this._worker_path_callback=i.callback,delete i.callback,this.worker.postMessage(["path",t,e,i])},this.worker.onmessage=t=>{let e=JSON.parse(t.data);"path"===e[0]&&this._worker_path_callback(e[1])}}}path(t,e,i={}){if(i.jps)return this.jps(t,e,i);let n=new g((t=>t.estimated)),r=new Map,s=this.graphs[i.layer||0];if(t=s.node(t,!0),e=s.node(e,!0),n.add({node:t,estimated:0}),r.set(t,{score:0,from:null}),!i.static||s.connected(t,e))for(;n.size;){let t=n.pop().node;if(t===e)break;s.neighbors(t).map((o=>{let a=(r.has(t)?r.get(t).score:0)+s.cost(t,o);a<(r.has(o)?r.get(o).score:1/0)&&(r.set(o,{score:a,from:t}),n.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))})),n.delete(t)}let o=[];if(r.has(e)){let t=e;for(o.push(e);null!==(t=r.get(t).from);)o.push(t);o=o.reverse()}return i.callback&&i.callback(o,r),o}}if(j.JPS=class{constructor(){}static access(t,e,i,n){return t.adjacent(e,n?t.node(i,!0):i)}static neighborhood(t,e,i,n){let r=[],s=i.get(n).from||null;if(null===s)return e.neighbors(n);{let i={x:b(n.x-s.x),y:b(n.y-s.y)};if(0!=i.x&&0!=i.y){let s=t(n,{x:n.x+i.x,y:n.y},!0),o=t(n,{x:n.x,y:n.y+i.y},!0);(s||o)&&(r.push(e.node({x:n.x+i.x,y:n.y+i.y},!0)),s&&(r.push(e.node({x:n.x+i.x,y:n.y},!0)),!t(n,{x:n.x,y:n.y-i.y},!0)&&r.push(e.node({x:n.x+i.x,y:n.y-i.y},!0))),o&&(r.push(e.node({x:n.x,y:n.y+i.y},!0)),!t(n,{x:n.x-i.x,y:n.y},!0)&&r.push(e.node({x:n.x-i.x,y:n.y+i.y},!0))))}else t(n,{x:n.x+i.x,y:n.y+i.y},!0)&&(r.push(e.node({x:n.x+i.x,y:n.y+i.y},!0)),0==i.x?0!=i.y&&(!t(n,{x:n.x-1,y:n.y},!0)&&r.push(e.node({x:n.x-1,y:n.y+i.y},!0)),!t(n,{x:n.x+1,y:n.y},!0)&&r.push(e.node({x:n.x+1,y:n.y+i.y},!0))):(!t(n,{x:n.x,y:n.y-1},!0)&&r.push(e.node({x:n.x+i.x,y:n.y-1},!0)),!t(n,{x:n.x,y:n.y+1},!0)&&r.push(e.node({x:n.x+i.x,y:n.y+1},!0))))}return r.filter((t=>t))}static jump(t,e,i,n,r,s){for(;;){if(!t(s,r))return null;if(r.x===n.x&&r.y===n.y)return r;let o={x:b(r.x-s.x),y:b(r.y-s.y)};if(0!=o.x&&0!=o.y){if(!t(r,{x:r.x-o.x,y:r.y},!0)&&t(r,{x:r.x-o.x,y:r.y+o.y},!0)||!t(r,{x:r.x,y:r.y-o.y},!0)&&t(r,{x:r.x+o.x,y:r.y-o.y},!0))return r;let s=j.JPS.jump.bind(this,t,e,i,n);if(null!==s(e.node({x:r.x+o.x,y:r.y},!0),r)||null!==s(e.node({x:r.x,y:r.y+o.y},!0),r))return r}else if(0!=o.x){if(!t(r,{x:r.x,y:r.y-1},!0)&&t(r,{x:r.x+o.x,y:r.y-1},!0)||!t(r,{x:r.x,y:r.y+1},!0)&&t(r,{x:r.x+o.x,y:r.y+1},!0))return r}else if(0!=o.y&&(!t(r,{x:r.x-1,y:r.y},!0)&&t(r,{x:r.x-1,y:r.y+o.y},!0)||!t(r,{x:r.x+1,y:r.y},!0)&&t(r,{x:r.x+1,y:r.y+o.y},!0)))return r;s=r,r=e.node({x:r.x+o.x,y:r.y+o.y},!0)}return null}},j.prototype.jps=function(t,e,i={}){if(this.graphs[i.layer||0].TORUS)return console.warn("Torus map aren't yet supported by JPS"),i.callback&&i.callback([],new Map),[];let n=new g((t=>t.estimated)),r=new Map,s=this.graphs[i.layer||0],o=null;t=s.node(t,!0),e=s.node(e,!0),n.add({node:t,estimated:0}),r.set(t,{score:0,from:null});let a=j.JPS.access.bind(this,s),c=j.JPS.neighborhood.bind(this,a,s,r),u=j.JPS.jump.bind(this,a,s,r,e);if(!i.static||s.connected(t,e))for(;n.size;){let t=n.pop().node;if(t===e)break;c(t).map((a=>{if(null!==(o=u(a,t))){let a=(r.has(t)?r.get(t).score:0)+s.cost(t,o);a<(r.has(o)?r.get(o).score:1/0)&&(r.set(o,{score:a,from:t,jumped:!0}),n.set({node:o,estimated:a+h[i.heuristic||this.heuristic](o,e,i.heuristicOptions||this.heuristicOptions)}))}})),n.delete(t)}let l=[];if(r.has(e)){let i=e;for(;i.x!=t.x||i.y!=t.y;)for(let t=r.get(i).from;i.x!=t.x||i.y!=t.y;)l.push(i),i=s.node({x:i.x+b(t.x-i.x),y:i.y+b(t.y-i.y)},!0);l.push(i),l.reverse()}return i.callback&&i.callback(l,r),l},"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){let a;onmessage=function(b){let c=b.data;switch(c[0]){case"constructor":if("cost"in c[2]){let a=/^\((.*?)\)\s*=>\s*{/.test(c[2].cost),b=/^function /.test(c[2].cost);c[2].cost=eval(`(${a||b?"":"function "}${c[2].cost})`)}a=new j(c[1],c[2]);break;case"path":postMessage(JSON.stringify(["path",a.path(c[1],c[2],c[3])]))}}}a.Lowlight.Astar={Graph:e,Node:f,BinaryHeap:g,Heuristic:h,Configuration:j,WorkerError:i}})("undefined"==typeof window?this:window)},391:(t,e,i)=>{var n=i(180),r=i(181),s=i(31),o=i(67),a=i(833),h=i(717),c=i(801);c.alea=n,c.xor128=r,c.xorwow=s,c.xorshift7=o,c.xor4096=a,c.tychei=h,t.exports=c},180:function(t,e,i){var n;!function(t,r){function s(t){var e,i=this,n=(e=4022871197,function(t){t=String(t);for(var i=0;i>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)});i.next=function(){var t=2091639*i.s0+2.3283064365386963e-10*i.c;return i.s0=i.s1,i.s1=i.s2,i.s2=t-(i.c=0|t)},i.c=1,i.s0=n(" "),i.s1=n(" "),i.s2=n(" "),i.s0-=n(t),i.s0<0&&(i.s0+=1),i.s1-=n(t),i.s1<0&&(i.s1+=1),i.s2-=n(t),i.s2<0&&(i.s2+=1),n=null}function o(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function a(t,e){var i=new s(t),n=e&&e.state,r=i.next;return r.int32=function(){return 4294967296*i.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,n&&("object"==typeof n&&o(n,i),r.state=function(){return o(i,{})}),r}r&&r.exports?r.exports=a:i.amdD&&i.amdO?void 0===(n=function(){return a}.call(e,i,e,r))||(r.exports=n):this.alea=a}(0,t=i.nmd(t),i.amdD)},717:function(t,e,i){var n;!function(t,r){function s(t){var e=this,i="";e.next=function(){var t=e.b,i=e.c,n=e.d,r=e.a;return t=t<<25^t>>>7^i,i=i-n|0,n=n<<24^n>>>8^r,r=r-t|0,e.b=t=t<<20^t>>>12^i,e.c=i=i-n|0,e.d=n<<16^i>>>16^r,e.a=r-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):i+=t;for(var n=0;n>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&("object"==typeof n&&o(n,i),r.state=function(){return o(i,{})}),r}r&&r.exports?r.exports=a:i.amdD&&i.amdO?void 0===(n=function(){return a}.call(e,i,e,r))||(r.exports=n):this.tychei=a}(0,t=i.nmd(t),i.amdD)},181:function(t,e,i){var n;!function(t,r){function s(t){var e=this,i="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:i+=t;for(var n=0;n>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&("object"==typeof n&&o(n,i),r.state=function(){return o(i,{})}),r}r&&r.exports?r.exports=a:i.amdD&&i.amdO?void 0===(n=function(){return a}.call(e,i,e,r))||(r.exports=n):this.xor128=a}(0,t=i.nmd(t),i.amdD)},833:function(t,e,i){var n;!function(t,r){function s(t){var e=this;e.next=function(){var t,i,n=e.w,r=e.X,s=e.i;return e.w=n=n+1640531527|0,i=r[s+34&127],t=r[s=s+1&127],i^=i<<13,t^=t<<17,i^=i>>>15,t^=t>>>12,i=r[s]=i^t,e.i=s,i+(n^n>>>16)|0},function(t,e){var i,n,r,s,o,a=[],h=128;for(e===(0|e)?(n=e,e=null):(e+="\0",n=0,h=Math.max(h,e.length)),r=0,s=-32;s>>15,n^=n<<4,n^=n>>>13,s>=0&&(o=o+1640531527|0,r=0==(i=a[127&s]^=n+o)?r+1:0);for(r>=128&&(a[127&(e&&e.length||0)]=-1),r=127,s=512;s>0;--s)n=a[r+34&127],i=a[r=r+1&127],n^=n<<13,i^=i<<17,n^=n>>>15,i^=i>>>12,a[r]=n^i;t.w=o,t.X=a,t.i=r}(e,t)}function o(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function a(t,e){null==t&&(t=+new Date);var i=new s(t),n=e&&e.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&(n.X&&o(n,i),r.state=function(){return o(i,{})}),r}r&&r.exports?r.exports=a:i.amdD&&i.amdO?void 0===(n=function(){return a}.call(e,i,e,r))||(r.exports=n):this.xor4096=a}(0,t=i.nmd(t),i.amdD)},67:function(t,e,i){var n;!function(t,r){function s(t){var e=this;e.next=function(){var t,i,n=e.x,r=e.i;return t=n[r],i=(t^=t>>>7)^t<<24,i^=(t=n[r+1&7])^t>>>10,i^=(t=n[r+3&7])^t>>>3,i^=(t=n[r+4&7])^t<<7,t=n[r+7&7],i^=(t^=t<<13)^t<<9,n[r]=i,e.i=r+1&7,i},function(t,e){var i,n=[];if(e===(0|e))n[0]=e;else for(e=""+e,i=0;i0;--i)t.next()}(e,t)}function o(t,e){return e.x=t.x.slice(),e.i=t.i,e}function a(t,e){null==t&&(t=+new Date);var i=new s(t),n=e&&e.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&(n.x&&o(n,i),r.state=function(){return o(i,{})}),r}r&&r.exports?r.exports=a:i.amdD&&i.amdO?void 0===(n=function(){return a}.call(e,i,e,r))||(r.exports=n):this.xorshift7=a}(0,t=i.nmd(t),i.amdD)},31:function(t,e,i){var n;!function(t,r){function s(t){var e=this,i="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:i+=t;for(var n=0;n>>4),e.next()}function o(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function a(t,e){var i=new s(t),n=e&&e.state,r=function(){return(i.next()>>>0)/4294967296};return r.double=function(){do{var t=((i.next()>>>11)+(i.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=i.next,r.quick=r,n&&("object"==typeof n&&o(n,i),r.state=function(){return o(i,{})}),r}r&&r.exports?r.exports=a:i.amdD&&i.amdO?void 0===(n=function(){return a}.call(e,i,e,r))||(r.exports=n):this.xorwow=a}(0,t=i.nmd(t),i.amdD)},801:function(t,e,i){var n;!function(r,s,o){var a,h=256,c=o.pow(h,6),u=o.pow(2,52),l=2*u,d=255;function y(t,e,i){var n=[],d=T(p((e=1==e?{entropy:!0}:e||{}).entropy?[t,v(s)]:null==t?function(){try{var t;return a&&(t=a.randomBytes)?t=t(h):(t=new Uint8Array(h),(r.crypto||r.msCrypto).getRandomValues(t)),v(t)}catch(t){var e=r.navigator,i=e&&e.plugins;return[+new Date,r,i,r.screen,v(s)]}}():t,3),n),y=new f(n),x=function(){for(var t=y.g(6),e=c,i=0;t=l;)t/=2,e/=2,i>>>=1;return(t+i)/e};return x.int32=function(){return 0|y.g(4)},x.quick=function(){return y.g(4)/4294967296},x.double=x,T(v(y.S),s),(e.pass||i||function(t,e,i,n){return n&&(n.S&&g(n,y),t.state=function(){return g(y,{})}),i?(o.random=t,e):t})(x,d,"global"in e?e.global:this==o,e.state)}function f(t){var e,i=t.length,n=this,r=0,s=n.i=n.j=0,o=n.S=[];for(i||(t=[i++]);r{}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var i=__webpack_module_cache__[t]={id:t,loaded:!1,exports:{}};return __webpack_modules__[t].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.amdD=function(){throw new Error("define cannot be used indirect")},__webpack_require__.amdO={},__webpack_require__.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(t,e)=>{for(var i in e)__webpack_require__.o(e,i)&&!__webpack_require__.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},__webpack_require__.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Event:()=>o,GameConstants:()=>t,GameEngine:()=>b,GameGroup:()=>S,GameUtils:()=>h,Grid:()=>y,Position:()=>c,Reactor:()=>a,Snake:()=>w});const t={CaseType:{EMPTY:0,SNAKE:1,FRUIT:2,WALL:3,SNAKE_DEAD:4,SURROUNDED:5,FRUIT_GOLD:6,CROSSED:7},PlayerType:{AI:"PLAYER_AI",HUMAN:"PLAYER_HUMAN",HYBRID_HUMAN_AI:"PLAYER_HYBRID_HUMAN_AI"},AiLevel:{RANDOM:"AI_LEVEL_RANDOM",LOW:"AI_LEVEL_LOW",DEFAULT:"AI_LEVEL_DEFAULT",HIGH:"AI_LEVEL_HIGH",ULTRA:"AI_LEVEL_ULTRA",CUSTOM:"AI_LEVEL_CUSTOM",MOCK:"AI_LEVEL_MOCK"},OutputType:{TEXT:"OUTPUT_TEXT",GRAPHICAL:"OUTPUT_GRAPHICAL"},Setting:{CANVAS_WIDTH:800,CANVAS_HEIGHT:600,FONT_FAMILY:"Delius",FONT_SIZE:32,HEADER_HEIGHT_DEFAULT:75,TARGET_FPS:60,TIME_MULTIPLIER:15,IMAGE_SNAKE_HUE:75,IMAGE_SNAKE_SATURATION:50,IMAGE_SNAKE_VALUE:77,CARS_TO_PRERENDER:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","×"],APP_VERSION:"2.2",DATE_VERSION:"10/18/2020",PROB_GOLD_FRUIT_1_PLAYER:100,PROB_GOLD_FRUIT_MULTIPLE_PLAYERS:50,INFO_NOTIF_COLOR:"rgba(52, 152, 219, 0.5)",ERROR_NOTIF_COLOR:"rgba(231, 76, 60, 0.5)"},Direction:{UP:0,TOP:0,RIGHT:1,BOTTOM:2,DOWN:2,LEFT:3,ANGLE_1:4,ANGLE_2:5,ANGLE_3:6,ANGLE_4:7},Key:{UP:38,RIGHT:39,BOTTOM:40,LEFT:37,ENTER:13},Error:{ROOM_NOT_FOUND:"ROOM_NOT_FOUND",ROOM_ALREADY_JOINED:"ROOM_ALREADY_JOINED",INVALID_SETTINGS:"INVALID_SETTINGS",MAX_ROOM_LIMIT_REACHED:"MAX_ROOM_LIMIT_REACHED",AUTHENTICATION_REQUIRED:"AUTHENTICATION_REQUIRED",ALREADY_CREATED_ROOM:"ALREADY_CREATED_ROOM",BANNED:"BANNED",DISCONNECTED:"DISCONNECTED"},GameState:{STARTING:"STARTING",STARTED:"STARTED",SEARCHING_PLAYERS:"SEARCHING_PLAYERS",AUTHENTICATION_SUCCESS:"AUTHENTICATION_SUCCESS"}};function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function n(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function r(t,e){for(var i=0;i360?i-360:i<0?360+i:i},shuffle:function(t,e){for(var i,n,r=t.length-1;r>0;r--)i=Math.floor((e?e():Math.random())*(r+1)),n=t[r],t[r]=t[i],t[i]=n;return t},millisecondsFormat:function(t){return t/=1e3,("0"+Math.trunc(t/60)).slice(-2)+":"+("0"+Math.trunc(t%60)).slice(-2)},secondsFormat:function(t){return this.millisecondsFormat(1e3*t)}};var c=function(){function i(t,n,r){e(this,i),this.x=t,this.y=n,this.direction=r}return s(i,[{key:"copy",value:function(){return new i(this.x,this.y,this.direction)}},{key:"convertToKeyDirection",value:function(){switch(this.direction){case t.Direction.UP:return t.Key.UP;case t.Direction.RIGHT:return t.Key.RIGHT;case t.Direction.LEFT:return t.Key.LEFT;case t.Direction.BOTTOM:return t.Key.BOTTOM;default:return this.direction}}},{key:"convertToSimpleDirection",value:function(){switch(this.direction){case t.Key.UP:return t.Direction.UP;case t.Key.RIGHT:return t.Direction.RIGHT;case t.Key.LEFT:return t.Direction.LEFT;case t.Key.BOTTOM:return t.Direction.BOTTOM;default:return this.direction}}},{key:"equals",value:function(t){return null!=t&&this.x==t.x&&this.y==t.y}}])}(),u=__webpack_require__(391),l=__webpack_require__.n(u),d=__webpack_require__(293),y=function(){return s((function i(n,r,s,o,a,h,u,l,d,y){e(this,i),this.width=null==n?20:n,this.height=null==r?20:r,this.generateWalls=null!=s&&s,this.borderWalls=null!=o&&o,this.maze=null!=a&&a,this.mazeFirstPosition=new c(1,1,t.Direction.RIGHT),this.mazeForceAuto=null!=u&&u,this.grid,this.initialGrid,this.fruitPos,this.fruitPosGold,this.customGrid=h,this.seedGrid=l?""+parseInt(l):void 0,this.seedGame=l?""+parseInt(d):void 0,this.rngGrid,this.rngGame,this.probGoldFruitIncrease=null!=y&&y}),[{key:"init",value:function(){if(null!=this.customGrid||null!=this.initialGrid){var e;e=null!=this.initialGrid?this.initialGrid:this.customGrid,this.height=e.length,this.width=e[0].length,this.initialGrid=new Array(this.height),this.grid=new Array(this.height);for(var i=0;i.65||this.maze?this.grid[n][r]=t.CaseType.WALL:this.grid[n][r]=t.CaseType.EMPTY}this.maze?this.generateMaze():this.generateWalls&&this.fixWalls(this.borderWalls)}this.fruitPosGold=null}},{key:"reset",value:function(){this.grid=void 0,this.initialGrid=void 0,this.fruitPos=void 0,this.fruitPosGold=void 0,this.rngGrid=new(l())(this.seedGrid),this.rngGame=new(l())(this.seedGame)}},{key:"fixWalls",value:function(e){var i,n,r,s;e?(i=1,r=this.height-1,n=1,s=this.width-1):(i=0,r=this.height,n=0,s=this.width);for(var o=i;o=this.width-1)continue;this.get(new c(i+2,e))!=t.CaseType.EMPTY&&(this.set(t.CaseType.EMPTY,new c(i+2,e)),this.set(t.CaseType.EMPTY,new c(i+1,e)),this.maze_recursion(e,i+2));break;case t.Direction.BOTTOM:if(e+2>=this.height-1)continue;this.get(new c(i,e+2))!=t.CaseType.EMPTY&&(this.set(t.CaseType.EMPTY,new c(i,e+2)),this.set(t.CaseType.EMPTY,new c(i,e+1)),this.maze_recursion(e+2,i));break;case t.Direction.LEFT:if(i-2<=0)continue;this.get(new c(i-2,e))!=t.CaseType.EMPTY&&(this.set(t.CaseType.EMPTY,new c(i-2,e)),this.set(t.CaseType.EMPTY,new c(i-1,e)),this.maze_recursion(e,i-2))}}},{key:"generateMaze",value:function(){this.mazeFirstPosition=new c(1,1,t.Direction.RIGHT),this.set(t.CaseType.EMPTY,this.mazeFirstPosition),this.maze_recursion(1,1)}},{key:"set",value:function(t,e){this.grid[e.y][e.x]=t}},{key:"get",value:function(t){return this.grid[t.y][t.x]}},{key:"valToChar",value:function(e){switch(e){case t.CaseType.EMPTY:return"-";case t.CaseType.SNAKE:return"o";case t.CaseType.SNAKE_DEAD:return"O";case t.CaseType.FRUIT:return"x";case t.CaseType.WALL:return"#";case t.CaseType.SURROUNDED:return"/";case t.CaseType.FRUIT_GOLD:return"X"}}},{key:"getImageCase",value:function(e){switch(this.get(e)){case t.CaseType.WALL:return"wall.png";case t.CaseType.FRUIT:return"fruit.png";case t.CaseType.FRUIT_GOLD:return"fruit_gold.png";case t.CaseType.EMPTY:case t.CaseType.SNAKE:case t.CaseType.SNAKE_DEAD:case t.CaseType.SURROUNDED:case t.CaseType.CROSSED:return""}return"unknown.png"}},{key:"getGraph",value:function(e){for(var i=new Array(this.height),n=0;n0))return!!(this.getTotal(t.CaseType.EMPTY)<=0&&this.fruitPosGold);do{if(n=this.getRandomPosition(),(r=this.detectCorridor(n))&&this.get(n)==t.CaseType.EMPTY&&this.set(t.CaseType.SURROUNDED,n),this.getTotal(t.CaseType.EMPTY)<=0)return!!this.fruitPosGold}while(this.get(n)!=t.CaseType.EMPTY||this.isFruitSurrounded(n,!0)||this.maze&&!this.testFruitMaze(n,s)||r);return i?(this.fruitPosGold=n,this.set(t.CaseType.FRUIT_GOLD,n)):(this.fruitPos=n,this.set(t.CaseType.FRUIT,n)),this.maze||null!=this.fruitPosGold||1!=h.randRange(1,this.probGoldFruitIncrease?3:e>1?t.Setting.PROB_GOLD_FRUIT_MULTIPLE_PLAYERS:t.Setting.PROB_GOLD_FRUIT_1_PLAYER,this.rngGame)||this.setFruit(e,!0),!0}},{key:"testFruitMaze",value:function(e,i){var n=this.getGraph(!0);return new d.Astar.Configuration(n,{order:"yx",torus:!1,diagonals:!1,cutting:!1,cost:function(t,e){return 1==e?null:1}}).path({x:this.mazeFirstPosition.x,y:this.mazeFirstPosition.y},{x:e.x,y:e.y}).length0;){var a=o[0];o.shift();for(var h=[this.getNextPosition(a,t.Direction.UP),this.getNextPosition(a,t.Direction.BOTTOM),this.getNextPosition(a,t.Direction.LEFT),this.getNextPosition(a,t.Direction.RIGHT)],c=0;c-1){if(o.push(h[c]),n.indexOf(this.get(h[c]))>-1)return!1;i&&this.get(h[c])==t.CaseType.EMPTY?(this.set(t.CaseType.SURROUNDED,h[c]),s[h[c].y][h[c].x]=t.CaseType.SURROUNDED):s[h[c].y][h[c].x]=t.CaseType.CROSSED}}return(i&&(this.get(e)==t.CaseType.EMPTY||this.get(e)==t.CaseType.FRUIT)||this.get(e)==t.CaseType.FRUIT_GOLD)&&this.set(t.CaseType.SURROUNDED,e),!0}},{key:"isFruitSurrounded",value:function(e,i){var n=this.isCaseSurrounded(e,!1,[t.CaseType.SNAKE],[t.CaseType.EMPTY,t.CaseType.SNAKE]);return n&&i&&this.isCaseSurrounded(e,!0,[t.CaseType.SNAKE],[t.CaseType.EMPTY,t.CaseType.SNAKE]),n}},{key:"detectCorridor",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.grid?JSON.parse(JSON.stringify(this.grid)):null;if(this.maze||!e||!i)return!1;var n=this.getNextPosition(e,t.Direction.TOP),r=this.getNextPosition(e,t.Direction.BOTTOM),s=this.getNextPosition(e,t.Direction.RIGHT),o=this.getNextPosition(e,t.Direction.LEFT),a=this.isDeadPosition(n,!0,!0)+this.isDeadPosition(r,!0,!0)+this.isDeadPosition(s,!0,!0)+this.isDeadPosition(o,!0,!0);if(a<=1||this.isDeadPosition(e,!0))return!1;if(a>=3)return!0;i[e.y][e.x]=t.CaseType.CROSSED;var h=i[n.y][n.x]!=t.CaseType.CROSSED&&this.detectCorridor(n,i),c=i[r.y][r.x]!=t.CaseType.CROSSED&&this.detectCorridor(r,i),u=i[o.y][o.x]!=t.CaseType.CROSSED&&this.detectCorridor(o,i),l=i[s.y][s.x]!=t.CaseType.CROSSED&&this.detectCorridor(s,i);return!!(c||h||u||l)}},{key:"getOnLine",value:function(t,e){for(var i=0,n=0;n=this.width&&(n.x=0),n.y<0?n.y=this.height-1:n.y>=this.height&&(n.y=0),n}},{key:"getDirectionTo",value:function(e,i){return this.getNextPosition(e,t.Direction.UP).equals(i)?t.Direction.UP:this.getNextPosition(e,t.Direction.BOTTOM).equals(i)?t.Direction.BOTTOM:this.getNextPosition(e,t.Direction.RIGHT).equals(i)?t.Direction.RIGHT:this.getNextPosition(e,t.Direction.LEFT).equals(i)?t.Direction.LEFT:-1}},{key:"invertDirection",value:function(e){return e==t.Direction.UP?t.Direction.BOTTOM:e==t.Direction.BOTTOM?t.Direction.UP:e==t.Direction.RIGHT?t.Direction.LEFT:e==t.Direction.LEFT?t.Direction.RIGHT:null}},{key:"isDeadPosition",value:function(e,i,n){return!i&&this.get(e)==t.CaseType.SNAKE||this.get(e)==t.CaseType.WALL||this.get(e)==t.CaseType.SNAKE_DEAD||!!n&&this.get(e)==t.CaseType.SURROUNDED}},{key:"toString",value:function(){for(var t="",e=0;eo.x?h=a.x-o.x>e.grid.width/2?t.Key.LEFT:t.Key.RIGHT:a.xe.grid.width/2?t.Key.RIGHT:t.Key.LEFT:a.ye.grid.height/2?t.Key.BOTTOM:t.Key.UP:a.y>o.y&&(h=a.y-o.y>e.grid.height/2?t.Key.UP:t.Key.BOTTOM);var c=e.getNextPosition(o,h);if(e.grid.isDeadPosition(c)){for(var u=this.direction,l=null,d=1;d1){var g=new c(f[1].x,f[1].y);return new c(null,null,e.getDirectionTo(o,g)).convertToKeyDirection()}f=null}return null}}])}(f);function O(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(O=function(){return!!t})()}var A=function(t){function i(t){var n,r,s,o;return e(this,i),r=this,o=[!0],s=p(s=i),(n=g(r,O()?Reflect.construct(s,o||[],p(r).constructor):s.apply(r,o))).aiLow=new _(t),n._aiLevelText="high",n}return x(i,t),s(i,[{key:"ai",value:function(t){var e,n,r;return(e=i,n=this,"function"==typeof(r=T(p(1&3?e.prototype:e),"ai",n))?function(t){return r.apply(n,t)}:r)([t])||this.aiLow.ai(t)}}])}(m);function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}var R=function(t){function i(){var t,n,r,s;return e(this,i),n=this,r=p(r=i),(t=g(n,I()?Reflect.construct(r,[],p(n).constructor):r.apply(n,s)))._aiLevelText="mock",t}return x(i,t),s(i,[{key:"ai",value:function(){return null}}])}(f),w=function(){function i(n,r,s,o,a,h,c,u){e(this,i),this.direction=null==n?t.Direction.RIGHT:n,this.initialDirection=this.direction,this.initialLength=null==r?3:r,this.initTriedDirections=[],this.errorInit=!1,this.grid=s||new y,this.queue=[],this.lastKey=-1,this.lastTail,this.lastTailMoved,this.ticksDead=0,this.player=null==o?t.PlayerType.HUMAN:o,this.aiLevel=null==a?t.AiLevel.DEFAULT:a,this.autoRetry=null!=h&&h,this.score=0,this.gameOver=!1,this.scoreMax=!1,this.color,this.name=null==c?"Snake":c,this.snakeAI=new f,this.customAI=u,this.ticksWithoutAction=0,this.initAI()}return s(i,[{key:"init",value:function(){if(this.initialLength<=0)return this.errorInit=!0,!1;this.grid.maze&&this.initTriedDirections.length<=0&&(this.initialDirection=this.grid.mazeFirstPosition.direction,this.direction=this.initialDirection);var e=0,i=0;if(this.initialDirection==t.Direction.RIGHT&&-1==this.initTriedDirections.indexOf(t.Direction.RIGHT)||this.initialDirection==t.Direction.LEFT&&-1==this.initTriedDirections.indexOf(t.Direction.LEFT)){for(var n=0;n=this.initialLength){e++;break}}else if(this.initialDirection==t.Direction.UP&&-1==this.initTriedDirections.indexOf(t.Direction.UP)||this.initialDirection==t.Direction.BOTTOM&&-1==this.initTriedDirections.indexOf(t.Direction.BOTTOM))for(var o=0;o=this.initialLength){i++;break}if(this.initTriedDirections.push(this.initialDirection),e<=0&&(this.initialDirection==t.Direction.RIGHT||this.initialDirection==t.Direction.LEFT)||i<=0&&(this.initialDirection==t.Direction.UP||this.initialDirection==t.Direction.BOTTOM))return-1==this.initTriedDirections.indexOf(t.Direction.RIGHT)?(this.initialDirection=t.Direction.RIGHT,this.direction=t.Direction.RIGHT,this.init()):-1==this.initTriedDirections.indexOf(t.Direction.LEFT)?(this.initialDirection=t.Direction.LEFT,this.direction=t.Direction.LEFT,this.init()):-1==this.initTriedDirections.indexOf(t.Direction.UP)?(this.initialDirection=t.Direction.UP,this.direction=t.Direction.UP,this.init()):-1==this.initTriedDirections.indexOf(t.Direction.BOTTOM)?(this.initialDirection=t.Direction.BOTTOM,this.direction=t.Direction.BOTTOM,this.init()):(this.errorInit=!0,!1);for(var u,l,d=!0,y=[];d;){if(d=!1,!(u=this.grid.maze?this.grid.mazeFirstPosition:this.grid.getRandomPosition()))return this.errorInit=!0,!1;l=new c(u.x,u.y,this.initialDirection),y=[];for(var f=this.initialLength-1;f>=0;f--)f=0&&t=this.grid.width*e)return!0;if((this.direction==t.Direction.UP||this.direction==t.Direction.BOTTOM)&&this.ticksWithoutAction>=this.grid.height*i)return!0}return!1}},{key:"getAILevelText",value:function(){return this.snakeAI?this.snakeAI.aiLevelText:"???"}}])}(),S=function(){return s((function t(i){e(this,t),this.games=null==i?[]:i,this.reactor=new a,this.reactor.registerEvent("onStart"),this.reactor.registerEvent("onPause"),this.reactor.registerEvent("onContinue"),this.reactor.registerEvent("onStop"),this.reactor.registerEvent("onReset"),this.reactor.registerEvent("onExit"),this.reactor.registerEvent("onScoreIncreased"),this.init()}),[{key:"init",value:function(){for(var t=this,e=0;ei&&(i=this.games[n].snakes[r].score);if(i>=0)for(var s=0,o=0;o=i&&(t.push(this.games[o].snakes[a]),e.push(s)),s++;return{winners:t,score:i,index:e}}}])}(),b=function(){return s((function t(i,n,r,s,o,h,c){e(this,t),this.grid=i,this.snakes=n,this.speed=null==r?8:r,this.initialSpeed=null==r?8:r,this.initialSpeedUntouched=null==r?8:r,this.enablePause=null==s||s,this.enableRetry=null==o||o,this.progressiveSpeed=null!=h&&h,this.aiStuckLimit=null==c?3:c,this.countBeforePlay=3,this.lastKey=-1,this.numFruit=1,this.ticks=0,this.firstStart=!0,this.starting=!1,this.paused=!0,this.exited=!1,this.killed=!1,this.isReseted=!0,this.gameOver=!1,this.gameFinished=!1,this.gameMazeWin=!1,this.scoreMax=!1,this.errorOccurred=!1,this.clientSidePredictionsMode=!1,this.aiStuck=!1,this.intervalPlay,this.reactor=new a,this.reactor.registerEvent("onStart"),this.reactor.registerEvent("onPause"),this.reactor.registerEvent("onContinue"),this.reactor.registerEvent("onReset"),this.reactor.registerEvent("onStop"),this.reactor.registerEvent("onExit"),this.reactor.registerEvent("onKill"),this.reactor.registerEvent("onScoreIncreased"),this.reactor.registerEvent("onUpdate"),this.reactor.registerEvent("onUpdateCounter")}),[{key:"init",value:function(){if(!this.clientSidePredictionsMode)if(null==this.snakes?(this.errorOccurred=!0,this.snakes=[]):Array.isArray(this.snakes)?(Array.isArray(this.snakes)&&this.snakes.length<=0||this.grid.maze&&this.snakes.length>1)&&(this.errorOccurred=!0):this.snakes=[this.snakes],this.grid instanceof y==0)this.errorOccurred=!0;else if(!this.errorOccurred){this.initGridAndSnakes();for(var t=h.randRange(0,360,this.grid?new(l())(this.grid.seedGame):null),e=0;e-1&&this.snakes[i].setGameOver(this.ticks)}},{key:"getNBPlayer",value:function(t){var e=0;if(null!=this.snakes)for(var i=0;i0||this.getNBPlayer(t.PlayerType.HYBRID_HUMAN_AI)>0)&&-1!=(this.getPlayer(1,t.PlayerType.HYBRID_HUMAN_AI)||this.getPlayer(1,t.PlayerType.HUMAN)).lastKey)){for(var n=0;n0&&this.initialSpeed>1&&(this.initialSpeed=Math.ceil(-this.initialSpeedUntouched/100*this.snakes[n].score+this.initialSpeedUntouched),this.initialSpeed=this.initialSpeed<1?1:this.initialSpeed)):(this.snakes[n].insert(a),this.grid.maze||(this.snakes[n].remove(),this.snakes[n].lastTailMoved=!0))}this.scoreMax||!s||this.clientSidePredictionsMode||(i=!this.grid.setFruit(this.snakes.length))}this.scoreMax||i||!this.grid.detectCorridor(this.grid.fruitPos)&&!this.grid.isFruitSurrounded(this.grid.fruitPos,!0)||this.clientSidePredictionsMode||(i=!this.grid.setFruit(this.snakes.length)),this.scoreMax||null==this.grid.fruitPosGold||!this.grid.detectCorridor(this.grid.fruitPosGold)&&!this.grid.isFruitSurrounded(this.grid.fruitPosGold,!0)||(this.grid.set(t.CaseType.EMPTY,this.grid.fruitPosGold),this.grid.fruitPosGold=null);for(var h=0,c=0;c=this.snakes.length||i||u)&&(this.stop(),this.snakes.length>1&&(this.gameFinished=!0)),this.reactor.dispatchEvent("onUpdate"),e&&this.reactor.dispatchEvent("onScoreIncreased")}this.tick()}}},{key:"onReset",value:function(t){this.reactor.addEventListener("onReset",t)}},{key:"onStart",value:function(t){this.reactor.addEventListener("onStart",t)}},{key:"onContinue",value:function(t){this.reactor.addEventListener("onContinue",t)}},{key:"onStop",value:function(t){this.reactor.addEventListener("onStop",t)}},{key:"onPause",value:function(t){this.reactor.addEventListener("onPause",t)}},{key:"onExit",value:function(t){this.reactor.addEventListener("onExit",t)}},{key:"onKill",value:function(t){this.reactor.addEventListener("onKill",t)}},{key:"onScoreIncreased",value:function(t){this.reactor.addEventListener("onScoreIncreased",t)}},{key:"onUpdate",value:function(t){this.reactor.addEventListener("onUpdate",t)}},{key:"onUpdateCounter",value:function(t){this.reactor.addEventListener("onUpdateCounter",t)}}])}()})(),__webpack_exports__})())); \ No newline at end of file diff --git a/dist/SnakeIA.js b/dist/SnakeIA.js index 9b4839e..e54ae58 100644 --- a/dist/SnakeIA.js +++ b/dist/SnakeIA.js @@ -1,12 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SnakeIA=t():e.SnakeIA=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=79)}([function(e,t,n){"undefined"!=typeof self&&self,e.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;nn.length-1&&(b=n.length-1),e.fillStyle=n[b],e.strokeStyle=n[b]}"center"==s?(g=Math.round(e.canvas.width/2-e.measureText(y).width/2),E=Math.round(l+i*m)):"right"==s?(g=Math.round(e.canvas.width-e.measureText(y).width-15),E=Math.round(l+i*m)):"left"==s?(g=5,E=Math.round(l+i*m)):(g=Math.round(a),E=Math.round(l+i*m)),e.fillText(y,g,E),h&&(e.lineWidth=1,e.beginPath(),e.moveTo(g,E+3),e.lineTo(Math.round(g+v),E+3),e.stroke()),v>f&&(f=v),0==m&&(p=E)}return e.restore(),{x:g,y:p,height:i*d.length,width:f}}},wrapText:function(e,t){if(e.length>t){for(var n=t;n>0&&" "!=e[n];n--);if(n>0){var i=e.substring(0,n),r=e.substring(n+1);return i+"\n"+this.wrapText(r,t)}}return e},wrapTextLines:function(e,t,n,i,r,s){if(e&&t){e.save(),e.font=i+"px "+r;for(var o=t.split("\n"),a="",l=n||e.measureText("A").width,u=Math.round(e.canvas.width/l),c=0,h=0,d=0;dh&&(h=p)}}return e.restore(),{text:a,height:c,width:h,carWidth:l}}return{text:"",height:0,width:0,carWidth:0}},drawArrow:function(e,t,n,i,r){e.save(),e.lineCap="round",e.lineWidth=8,e.strokeStyle="#FF0000",e.filter="",e.beginPath();var s=i-t,o=r-n,a=Math.atan2(o,s);e.moveTo(t,n),e.lineTo(i,r),e.moveTo(i,r),e.lineTo(i-20*Math.cos(a-Math.PI/6),r-20*Math.sin(a-Math.PI/6)),e.moveTo(i,r),e.lineTo(i-20*Math.cos(a+Math.PI/6),r-20*Math.sin(a+Math.PI/6)),e.stroke(),e.restore()},clear:function(e){e.clearRect(0,0,e.canvas.width,e.canvas.height)},isFilterHueAvailable:function(){var e=document.createElement("canvas");e.width=5,e.height=5;var t=e.getContext("2d");t.fillStyle="#FF0000",t.filter="hue-rotate(90deg)",t.fillRect(0,0,5,5);var n=t.getImageData(0,0,1,1).data;return 255!=n[0]||0!=n[1]||0!=n[2]},blurCanvas:function(e,t){e.save(),e.filter="blur("+t+"px)",this.drawImageData(e,e.canvas,0,0,e.canvas.width,e.canvas.height),e.restore()},getFontSize:function(e){return Math.floor(parseInt(e.font.match(/\d+/),10)/1.25)},autoResizeCanvas:function(e,t,n){if(document.fullscreenElement)document.fullscreenElement==e?(e.width=window.innerWidth,e.height=window.innerHeight):(e.width=t,e.height=n);else if(t>=.85*document.documentElement.clientWidth){var i=t/n;e.width=.85*document.documentElement.clientWidth,e.height=e.width/i}else e.width=t,e.height=n},enableAutoResizeCanvas:function(e,t,n){var i=this;e&&"true"!=e.getAttribute("autoresize-canvas-event")&&(this.autoResizeCanvas(e,t,n),window.addEventListener("resize",(function(){e.setAttribute("autoresize-canvas-event","true"),i.autoResizeCanvas(e,t,n)})))},autoResizeCanvasFullscreen:function(e,t){document.fullscreenElement==(t||e)&&(e.width=window.innerWidth,e.height=window.innerHeight,t&&(t.width=window.innerWidth,t.height=window.innerHeight))},enableAutoResizeCanvasFullscreen:function(e,t){var n=this;e&&"true"!=e.getAttribute("autoresizefullscreen-canvas-event")&&(this.autoResizeCanvasFullscreen(e,t),window.addEventListener("resize",(function(){e.setAttribute("autoresizefullscreen-canvas-event","true"),n.autoResizeCanvasFullscreen(e,t)})))},toggleFullscreen:function(e,t){if(e){var n=e.width,i=e.height;if(t&&(t.width=n,t.height=i),document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():(t||e).requestFullscreen?(t||e).requestFullscreen():(t||e).mozRequestFullScreen?(t||e).mozRequestFullScreen():(t||e).webkitRequestFullscreen?(t||e).webkitRequestFullscreen():(t||e).msRequestFullscreen?(t||e).msRequestFullscreen():(t||e).oRequestFullscreen&&(t||e).oRequestFullscreen(),this.enableAutoResizeCanvasFullscreen(e,t),"true"!=e.getAttribute("fullscreenchange-canvas-event")){e.setAttribute("fullscreenchange-canvas-event","true");var r=function(){document.fullscreenElement!=(t||e)&&(e.width=n,e.height=i,t&&(t.width=n,t.height=i))};void 0!==document.onfullscreenchange?document.onfullscreenchange=r:void 0!==document.onmsfullscreenchange?document.onmsfullscreenchange=r:void 0!==document.onmozfullscreenchange?document.onmozfullscreenchange=r:void 0!==document.onwebkitfullscreenchange?document.onwebkitfullscreenchange=r:void 0!==document.onokitfullscreenchange&&(document.onofullscreenchange=r)}}}},E=function(){function e(t,n,i,r,o,a,l,u){s()(this,e),this.x=t||0,this.y=n||0,this.initialX=t,this.initialY=n,this._width=i,this._height=r,this.alignement=o||"default",this.verticalAlignement=a||"default",this.canvasContext2d,this.triggersClick=[],this.triggersHover=[],this.triggersDown=[],this.triggersScroll=[],this.init=!1,this.initEvents=!1,this.selected=!1,this.clicked=!1,this.hovered=!1,this.disabled=!1,this.disableAnimation=l||!1,this.scrollDisabled=u||!1,this.offsetScrollX=0,this.offsetScrollY=0,this.touchEventStartX=0,this.touchEventStartY=0,this.touchEventStartTimestamp=0,this.tooltip}return a()(e,[{key:"draw",value:function(e){var t=this,n=e.canvas,i=n.getContext("2d");if(this.canvasContext2d=i,!this.initEvent&&null!=i){n.addEventListener("mousemove",(function(e){if(t.disabled)t.hovered=!1,t.clicked=!1,t.tooltip&&(t.tooltip.disabled=!0);else if(t.isInside(t.getMousePos(n,e))){if(null==t.triggersHover||t.disabled||t.triggersHover.forEach((function(e){return e()})),t.tooltip){var i=t.getMousePos(n,e);t.tooltip.x=i.x+10,t.tooltip.y=i.y+10,t.tooltip.disabled=!1}t.hovered=!0}else t.hovered=!1,t.tooltip&&(t.tooltip.disabled=!0)}),!1),n.addEventListener("click",(function(e){t.disabled?(t.hovered=!1,t.clicked=!1):t.isInside(t.getMousePos(n,e))?(null!=t.triggersClick&&t.triggersClick.forEach((function(e){return e()})),t.selected=!0):(t.clicked=!1,t.selected=!1)}),!1),n.addEventListener("mousedown",(function(e){t.disabled?(t.hovered=!1,t.clicked=!1):t.isInside(t.getMousePos(n,e))?(null!=t.triggersDown&&t.triggersDown.forEach((function(e){return e()})),t.clicked=!0):t.clicked=!1}),!1),n.addEventListener("mouseup",(function(){t.clicked=!1}),!1),n.addEventListener("wheel",(function(e){!t.hovered||t.disabled||t.scrollDisabled||(t.offsetScrollX+=e.deltaX,t.offsetScrollY+=e.deltaY,null!=t.triggersScroll&&t.triggersScroll.forEach((function(t){return t(e.deltaX,e.deltaY)})))}));var r=function(e){var i=e.changedTouches[0],r=t.getMousePos(n,i);t.isInside(r)?(t.hovered=!0,t.selected=!0):(t.hovered=!1,t.selected=!1),t.hovered&&!t.disabled&&(t.touchEventStartX=r.x,t.touchEventStartY=r.y,t.touchEventStartTimestamp=e.timestamp)};n.addEventListener("touchstart",r),n.addEventListener("touchend",r),n.addEventListener("touchmove",(function(e){!function(e){var i=e.changedTouches[0],r=t.getMousePos(n,i);!t.hovered||t.disabled||t.scrollDisabled||(t.offsetScrollX+=t.touchEventStartX-r.x,t.offsetScrollY+=t.touchEventStartY-r.y,null!=t.triggersScroll&&t.triggersScroll.forEach((function(e){return e(t.touchEventStartX-r.x,t.touchEventStartY-r.y)})),t.touchEventStartX=r.x,t.touchEventStartY=r.y)}(e),e.preventDefault()}))}this.disabled&&(this.selected=!1,this.clicked=!1,this.hovered=!1,this.tooltip&&(this.tooltip.disabled=!0)),this.initEvent=!0}},{key:"getMousePos",value:function(e,t){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}},{key:"isInside",value:function(e){return e.x>this.x&&e.xthis.y}},{key:"disable",value:function(){this.disabled=!0}},{key:"enable",value:function(){this.disabled=!1}},{key:"setClickAction",value:function(e){this.triggersClick=[e]}},{key:"addClickAction",value:function(e){this.triggersClick.push(e)}},{key:"removeClickAction",value:function(e){this.triggersClick=this.triggersClick.filter((function(t){return t!=e}))}},{key:"removeAllClickActions",value:function(){this.triggersClick=[]}},{key:"setHoverAction",value:function(e){this.triggersHover=[e]}},{key:"addHoverAction",value:function(e){this.triggersHover.push(e)}},{key:"removeHoverAction",value:function(e){this.triggersHover=this.triggersHover.filter((function(t){return t!=e}))}},{key:"removeAllHoverActions",value:function(){this.triggersHover=[]}},{key:"setDownAction",value:function(e){this.triggersDown=[e]}},{key:"addDownAction",value:function(e){this.triggersDown.push(e)}},{key:"removeDownAction",value:function(e){this.triggersDown=this.triggersDown.filter((function(t){return t!=e}))}},{key:"removeAllDownActions",value:function(){this.triggersDown=[]}},{key:"setScrollAction",value:function(e){this.triggersScroll=[e]}},{key:"addScrollAction",value:function(e){this.triggersScroll.push(e)}},{key:"removeScrollAction",value:function(e){this.triggersScroll=this.triggersScroll.filter((function(t){return t!=e}))}},{key:"removeAllScrollActions",value:function(){this.triggersScroll=[]}},{key:"height",get:function(){return this._height},set:function(e){this._height=e}},{key:"width",get:function(){return this._width},set:function(e){this._width=e}}]),e}();function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}var k=function(e){f()(n,e);var t=b(n);function n(e,r,o,a,l,u,c,h,d,f,g,p,m,y,v){var E;return s()(this,n),(E=t.call(this,r,o,h,d,a,v)).autoWidth=null==E.width,E.autoHeight=null==E.height,E.text=e,E.fontSizeInitial=f,E.fontSize=E.fontSizeInitial||Math.floor(i.Setting.FONT_SIZE/1.25),E.fontFamily=g||i.Setting.FONT_FAMILY,E.fontColor=p||"white",E.color=l||"rgba(0, 0, 0, 0)",E.colorHover=u||"#95a5a6",E.colorDown=c||"#727F80",E.image,E.imgSrc=m,E.imageLoader=y,E}return a()(n,[{key:"draw",value:function(e){h()(y()(n.prototype),"draw",this).call(this,e);var t=e.canvas,r=t.getContext("2d");r.save(),this.fontSize=this.fontSizeInitial||Math.floor(i.Setting.FONT_SIZE/1.25),r.font=this.fontSize+"px "+this.fontFamily;var s=this.textWrapped,o=s.text.split("\n").length,a=s.width;if(null!=this.imgSrc&&null!=this.imageLoader&&this.loadImage(this.imageLoader),"center"==this.alignement?this.x=t.width/2-this.width/2-this.initialX:"right"==this.alignement?this.x=t.width-this.width-5-this.initialX:"left"==this.alignement&&(this.x=5),"bottom"==this.verticalAlignement?this.y=t.height-this.height-5-this.initialY:"center"==this.verticalAlignement?this.y=t.height/2-this.height/2-this.initialY:"top"==this.verticalAlignement&&(this.y=15),this.hovered&&this.clicked?r.fillStyle=this.colorDown:this.hovered?r.fillStyle=this.colorHover:r.fillStyle=this.color,r.fillRect(Math.round(this.x),Math.round(this.y),Math.round(this.width),Math.round(this.height)),this.selected){var l=r.strokeStyle,u=r.lineWidth;r.strokeStyle="#a2cdd8",r.lineWidth=3,r.strokeRect(Math.round(this.x),Math.round(this.y),Math.round(this.width),Math.round(this.height)),r.strokeStyle=l,r.lineWidth=u}if(null!=this.image){var c,d;if(this.image.width>this.width||this.image.height>this.height){var f=this.image.width/this.image.height;c=Math.floor(this.width/1.25),d=Math.floor(c/f)}var g=this.x+this.width/2-c/2,p=this.y+this.height/2-d/2;v.drawImage(r,this.image,Math.round(g),Math.round(p),Math.round(c),Math.round(d))}else if(null!=this.text){r.textBaseline="middle",r.fillStyle=this.fontColor;var m=this.x+this.width/2-a/2,E=this.y+this.height/2-(o-1)*(this.fontSize/2);v.drawText(r,this.text,this.fontColor,this.fontSize,this.fontFamily,"center"==this.alignement?"center":"default","default",Math.round(m),Math.round(E),!0)}r.restore()}},{key:"loadImage",value:function(e){this.image=e.get(this.imgSrc)}},{key:"textWrapped",get:function(){return v.wrapTextLines(this.canvasContext2d,this.text,null,this.fontSize,this.fontFamily)}},{key:"height",get:function(){if(this.image){var e=this.image.height;if(this.autoHeight)return 1.5*e}else if(this.text){var t=this.textWrapped.height;if(this.autoHeight)return t+this.fontSize/1.5}return h()(y()(n.prototype),"height",this)},set:function(e){u()(y()(n.prototype),"height",e,this,!0),this.autoHeight=!1}},{key:"width",get:function(){if(this.image){var e=this.image.width;if(this.autoWidth)return 1.25*e}else if(this.text){var t=this.textWrapped,i=t.width;if(this.autoWidth)return i+2*t.carWidth}return h()(y()(n.prototype),"width",this)},set:function(e){u()(y()(n.prototype),"width",e,this,!0),this.autoWidth=!1}}]),n}(E),A=function(e){f()(n,e);var t=b(n);function n(e,i,r,o,a,l,u,c,h,d){return s()(this,n),t.call(this,null,i,r,o,c,h,null,l,u,null,null,null,e,d,a)}return n}(k),w=function(){function e(){s()(this,e),this.images={},this.imagesResized={},this.triedLoading=0,this.hasError=!1,this.nbImagesToLoad=1,this.firstImage=!0}return a()(e,[{key:"load",value:function(e,t){var n=this;if(this.firstImage&&(this.nbImagesToLoad=e.length,this.firstImage=!1),!(e.length>0))return t();this.loadImage(e[0],(function(i){if(1!=i)return n.hasError=!0,t();e.shift(),n.load(e,t)}))}},{key:"loadImage",value:function(e,t){var n=this;this.triedLoading++;var i=new Image;i.src=e,i.onload=function(){return null==n.images?t(!1):(n.images[e]=i,n.triedLoading=0,t(!0))},i.onerror=function(){if(n.triedLoading>=5)return null!=n.images&&(n.images[e]=i),n.triedLoading=0,t(!1);setTimeout((function(){n.loadImage(e,t)}),250)}}},{key:"get",value:function(e,t,n){if(null!=this.images&&this.images.hasOwnProperty(e)){var i=this.images[e];if(!t&&!n||i.width==t&&i.height==n)return i;var r=Math.round(t),s=Math.round(n),o=e+"@"+r+"-"+s;if(!this.imagesResized.hasOwnProperty(o)){var a=document.createElement("canvas"),l=a.getContext("2d");a.width=r,a.height=s,v.drawImage(l,i,0,0,r,s,0,0,i.width,i.height),this.imagesResized[o]=a}return this.imagesResized[o]}return null}},{key:"clear",value:function(){this.images=null}}]),e}(),S=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(e,r,o,a,l,u,c,h,d,f){var g;return s()(this,n),(g=t.call(this,0,0,0,0,null,null,d)).text=e,g.textColor=null==r?"rgba(255, 255, 255, 0.75)":r,g.backgroundColor=null==o?"rgba(46, 204, 113, 0.5)":o,g.delayBeforeClosing=null==a?5:a,g.fontSizeInitial=u,g.fontSize=g.fontSizeInitial||Math.floor(i.Setting.FONT_SIZE/1.25),g.fontFamily=null==c?i.Setting.FONT_FAMILY:c,g.animationDelay=null==l?500:l,g.foreGround=null!=h&&h,g.timeLastFrame=0,g.animationTime=0,g.closed=!0,g.closing=!1,g.easingFunction=f,g.closeButton=new A(null,null,5,"right",null,32,32),g.closeButton.image=new Image,g.closeButton.image.src=i.Setting.CLOSE_ICON,g}return a()(n,[{key:"draw",value:function(e){var t=this;if(null!=this.text){h()(y()(n.prototype),"draw",this).call(this,e);var r=e.canvas,s=r.getContext("2d");s.save(),this.init||(this.timeLastFrame=performance.now()),null!=this.closeButton&&this.closeButton.setClickAction((function(){t.close()}));var o=performance.now()-this.timeLastFrame;this.timeLastFrame=performance.now(),this.animationTime>=1e3*this.delayBeforeClosing&&!this.closing&&!this.closed&&this.close(),this.fontSize=this.fontSizeInitial||i.Setting.FONT_SIZE;var a=v.wrapTextLines(s,this.text,null,this.fontSize,this.fontFamily).height+this.fontSize/2,l=r.width,u=1;if(this.closing?this.disableAnimation?this.animationTime=-1:this.animationTime-=o:this.animationTime+=o,this.animationTime<0&&(this.closed=!0,this.closing=!1),this.closed)this.disableCloseButton();else{this.disableAnimation||(u=this.animationTime/this.animationDelay),this.easingFunction&&(u=this.easingFunction(u));var c=r.height-a*(u<=1?u:1);s.fillStyle=this.backgroundColor,s.fillRect(0,c,l,a),v.drawText(s,this.text,this.textColor,this.fontSize,this.fontFamily,"center","default",null,c+this.fontSize,!0),null!=this.closeButton&&(this.closeButton.y=c+5,this.closeButton.draw(s)),this.enableCloseButton()}s.restore(),this.init=!0}}},{key:"close",value:function(){this.disableCloseButton(),this.closing||(this.closing=!0,this.animationTime=this.animationDelay)}},{key:"open",value:function(){this.timeLastFrame=0,this.animationTime=0,this.init=!1,this.closed=!1,this.closing=!1}},{key:"disableCloseButton",value:function(){null!=this.closeButton&&null!=this.closeButton&&this.closeButton instanceof k&&this.closeButton.disable()}},{key:"enableCloseButton",value:function(){null!=this.closeButton&&null!=this.closeButton&&this.closeButton instanceof k&&this.closeButton.enable()}},{key:"copy",value:function(){return new n(this.text,this.textColor,this.backgroundColor,this.delayBeforeClosing,this.animationDelay,this.fontSize,this.fontFamily,this.foreGround)}}]),n}(E),I=n(8),T=n.n(I),L=n(7),C=n.n(L),R=n(3),x=n.n(R),O=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(e,i){var r,o;s()(this,n),o=t.call(this,0,0,0,0),_.set(T()(o),{writable:!0,value:[]});for(var a=arguments.length,l=new Array(a>2?a-2:0),u=2;u=x()(this,_).length?this.selectedComponent=0:this.selectedComponent<0&&(this.selectedComponent=x()(this,_).length-1),x()(this,_).forEach((function(e){return s+=e.height}));var o=(r.canvas.height-(s||0))/2||0;x()(this,_).forEach((function(e,n){if(e instanceof E){if(e.y=o,e.initialY=o,t.selectedComponent==n?e.selected=!0:e.selected=!1,e.enable(),e.draw(r),t.selectedComponent==n&&t.lastKey==i.Key.ENTER&&null!=e.triggersClick&&e.triggersClick.length>0&&!e.disabled)return t.lastKey=-1,t.selectedComponent=0,void e.triggersClick.forEach((function(e){return e()}));o+=e.height+8}}))}r.restore()}this.lastKey=-1}},{key:"set",value:function(){this.clear(),this.addAll.apply(this,arguments),this.enable()}},{key:"add",value:function(e){this.addAll(e)}},{key:"addAll",value:function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i0&&(s=r-this.lastTime),this.lastTime=r,this.totalTime+=s,i.fillStyle=this.backgroundColor,i.fillRect(Math.round(this.x),Math.round(this.y),Math.round(this.width),Math.round(this.height)),i.strokeStyle=this.selected?this.borderColorHover:this.borderColor,i.lineWidth=this.borderSize,i.strokeRect(Math.round(this.x),Math.round(this.y),Math.round(this.width),Math.round(this.height)),this.canvasTmp.width=t.width,this.canvasTmp.height=t.height;for(var o=this.canvasTmp.getContext("2d"),a=this.x+5,l=-1;l-1&&(a+=v.drawText(o,this.text[l],this.fontColor,this.fontSize,this.fontFamily,"default","default",a-this.offsetX,this.y+this.fontSize,!1).width+1),this.positionEnd==l+1&&this.selected&&(this.totalTime<=500?(o.strokeStyle=this.borderColor,o.lineWidth=1,o.beginPath(),o.moveTo(a-this.offsetX,this.y+3),o.lineTo(a-this.offsetX,this.y+this.fontSize),o.stroke()):this.totalTime>1e3&&(this.totalTime=0),this.offsetX=Math.max(0,Math.round(a-this.x-this.width+8)));v.drawImageData(i,this.canvasTmp,this.x+this.borderSize,this.y+this.borderSize,this.width-2*this.borderSize,this.height-2*this.borderSize,this.x+this.borderSize,this.y+this.borderSize,this.width-2*this.borderSize,this.height-2*this.borderSize),(this.hovered||this.clicked)&&(t.style.cursor="text"),this.selected||(this.totalTime=0),i.restore()}},{key:"click",value:function(){this.input.focus()}}]),n}(E),B=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(e,r,o,a,l,u,c,h,d,f,g){var p;return s()(this,n),(p=t.call(this,r,o)).text=e,p.color=u||"#000000",p.fontSize=a||i.Setting.FONT_SIZE,p.fontFamily=l||i.Setting.FONT_FAMILY,p.alignement=c||"default",p.verticalAlignement=h||"default",p.wrap=d||!0,p.bold=f||!1,p.underline=g||!1,p}return a()(n,[{key:"draw",value:function(e){h()(y()(n.prototype),"draw",this).call(this,e);var t=e.canvas.getContext("2d");t.save();var i=v.drawText(t,this.text,this.color,this.fontSize,this.fontFamily,this.alignement,this.verticalAlignement,this.initialX,this.initialY,this.wrap,this.bold,this.underline);this.x=i.x,this.y=i.y-this.fontSize,t.restore()}},{key:"height",get:function(){return v.wrapTextLines(this.canvasContext2d,this.text,null,this.fontSize,this.fontFamily).height},set:function(e){u()(y()(n.prototype),"height",e,this,!0)}},{key:"width",get:function(){return v.wrapTextLines(this.canvasContext2d,this.text,null,this.fontSize,this.fontFamily).width},set:function(e){u()(y()(n.prototype),"width",e,this,!0)}}]),n}(E),M=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(e,i,r,o,a,l,u,c,h,d,f,g,p){var m;return s()(this,n),(m=t.call(this,e,i,r,o,a,l||"#0000EE",h,d,f,g,p||!0)).colorHover=u||"#4D4DFF",m.colorDown=c||"#EE7700",m.initialColor=m.color,m.initialUnderline=m.underline,m}return a()(n,[{key:"draw",value:function(e){h()(y()(n.prototype),"draw",this).call(this,e);var t=e.canvas;this.clicked?(this.underline=!1,this.color=this.colorDown,t.style.cursor="pointer"):this.hovered?(this.underline=!1,this.color=this.colorHover,t.style.cursor="pointer"):(this.underline=this.initialUnderline,this.color=this.initialColor),this.init=!0}}]),n}(B),D=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(e,r,o,a,l,u,c,h){var d;return s()(this,n),(d=t.call(this,0,0,0,0)).text=e,d.backgroundColor=a||"rgba(255, 255, 255, 0.25)",d.fontColor=l||"#FFFFFF",d.fontSize=r||i.Setting.FONT_SIZE,d.fontFamily=o||i.Setting.FONT_FAMILY,d.wrap=u||!0,d.bold=c||!1,d.underline=h||!1,d.disabled=!0,d}return a()(n,[{key:"draw",value:function(e){if(h()(y()(n.prototype),"draw",this).call(this,e),!this.disabled){var t=e.canvas,i=t.getContext("2d");i.save(),this.x+this.width+10>t.width&&(this.x-=this.width+10),this.y+this.height+10>t.height&&(this.y-=this.height+10),i.fillStyle=this.backgroundColor,i.fillRect(this.x,this.y,this.width+10,this.height+10);var r=v.drawText(i,this.text,this.fontColor,this.fontSize,this.fontFamily,null,null,this.x+5,this.y+this.fontSize,this.wrap,this.bold,this.underline);this.width=r.width,this.height=r.height,i.restore()}}}]),n}(E),F=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(){var e,i;return s()(this,n),i=t.call(this,0,0,0,0),N.set(T()(i),{writable:!0,value:[]}),(e=i).addAll.apply(e,arguments),i.canvas,i}return a()(n,[{key:"draw",value:function(e){var t=this;h()(y()(n.prototype),"draw",this).call(this,e);var i=e.canvas,r=i.getContext("2d");r.save(),i.style.cursor="default";var s=x()(this,N).filter((function(e){return e&&e instanceof E&&!(e instanceof O)&&!(e instanceof D)&&!(e instanceof S)})),o=x()(this,N).filter((function(e){return e&&e instanceof O})).filter((function(e){return!e.disabled}))[0],a=x()(this,N).filter((function(e){return e&&e instanceof D})),l=x()(this,N).filter((function(e){return e&&e instanceof P})),u=x()(this,N).filter((function(e){return e&&e instanceof S&&!e.foreGround})),c=x()(this,N).filter((function(e){return e&&e instanceof S&&e.foreGround}));l&&l.forEach((function(e){return e.canvas=t.canvas})),o?s&&s.forEach((function(e){return e.disable()})):s&&s.forEach((function(e){return e.enable()})),s&&s.forEach((function(e){return e.draw(r)})),u&&u.forEach((function(e){return e.draw(r)})),a&&a.forEach((function(e){return e.draw(r)})),o&&o.draw(r),c&&c.forEach((function(e){return e.draw(r)})),r.restore()}},{key:"add",value:function(e){this.addAll(e)}},{key:"addAll",value:function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i0&&(this.currentFPS=this.frames-this.lastFrame),this.lastFrame=this.frames}}]),n}(B),H=function(e){f()(n,e);var t=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=y()(e);if(t){var r=y()(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return p()(this,n)}}(n);function n(e,i,r,o,a,l,u,c,h,d,f,g){var p;return s()(this,n),p=t.call(this,e,i,r,o,d,f,h),G.set(T()(p),{writable:!0,value:0}),V.set(T()(p),{writable:!0,value:0}),p.backgroundColor=a||"#bdc3c7",p.foregroundColor=l||"#27ae60",p.percent=null==u?0:u,C()(T()(p),G,p.percent),p.easingFunction=g,p.animationDuration=c||2,p.lastTime=0,p.totalTime=0,p}return a()(n,[{key:"draw",value:function(e){h()(y()(n.prototype),"draw",this).call(this,e);var t=e.canvas,i=t.getContext("2d");i.save();var r=performance.now(),s=0,o=x()(this,G)==this.percent||this.disableAnimation?1:this.totalTime/(1e3*this.animationDuration);this.easingFunction&&(o=this.easingFunction(o));var a=Math.round(Math.min(this.width,this.width*(x()(this,G)+(this.percent-x()(this,G))*o)));x()(this,G)==this.percent||this.disableAnimation?(this.totalTime=0,this.lastTime=0):(this.lastTime>0&&(s=r-this.lastTime),this.totalTime+=s,this.totalTime>=1e3*this.animationDuration?(C()(this,G,this.percent),this.totalTime=0,this.lastTime=0):this.lastTime=r);var l=this.x,u=this.y;"center"==this.alignement?l=Math.round(t.width/2-this.width/2):"right"==this.alignement?l=Math.round(t.width-(this.width-15)):"left"==this.alignement&&(l=5),"center"==this.verticalAlignement?u=Math.round(t.height/2-this.height/2):"top"==this.verticalAlignement?u=5:"bottom"==this.verticalAlignement&&(u=Math.round(t.height-this.height-5)),i.fillStyle=this.backgroundColor,i.fillRect(l,u,this.width,this.height),i.fillStyle=this.foregroundColor,i.fillRect(l,u,a,this.height),i.restore()}}]),n}(E),G=new WeakMap,V=new WeakMap,z=function(){function e(t,n,i,r,o,a){s()(this,e),Y.set(this,{writable:!0,value:void 0}),this.width=i||600,this.height=r||400,this.scene=t,this.scene.canvas=this,this.container=document.createElement("div"),this.canvas=n||document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.container.appendChild(this.canvas),this.started=!1,this.maxFPS=a||-1,C()(this,Y,0),o&&this.autoResize()}return a()(e,[{key:"draw",value:function(){var e=this.canvas.getContext("2d");v.clear(e),scene.draw(e)}},{key:"startDraw",value:function(){var e=this;this.started=!0,requestAnimationFrame((function(t){if(e.started){var n=t-x()(e,Y);(e.maxFPS<1||n>1e3/e.maxFPS)&&(C()(e,Y,t),e.draw()),e.startDraw()}}))}},{key:"stopDraw",value:function(){this.started=!1}},{key:"appendTo",value:function(e){e.appendChild(this.container)}},{key:"toggleFullscreen",value:function(){v.toggleFullscreen(this.canvas,this.container)}},{key:"autoResize",value:function(){v.enableAutoResizeCanvas(this.canvas,this.width,this.height)}}]),e}(),Y=new WeakMap,j={easeInCubic:function(e){return e*e*e},easeOutBounce:function(e){var t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutCubic:function(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2},easeInOutSine:function(e){return-(Math.cos(Math.PI*e)-1)/2},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2},easeInOutCirc:function(e){return e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2},easeInOutQuad:function(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2},easeInOutExpo:function(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2},easeInOutBack:function(e){var t=2.5949095;return e<.5?Math.pow(2*e,2)*(7.189819*e-t)/2:(Math.pow(2*e-2,2)*((t+1)*(2*e-2)+t)+2)/2}}}])},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var i=n(38);function r(e,t){for(var n=0;n1?{type:f[r],data:e.substring(1)}:{type:f[r]}:g}r=new Uint8Array(e)[0];var s=o(e,1);return p&&"blob"===n&&(s=new p([s])),{type:f[r],data:s}},t.decodeBase64Packet=function(e,t){var n=f[e.charAt(0)];if(!i)return{type:n,data:{base64:!0,data:e.substr(1)}};var r=i.decode(e.substr(1));return"blob"===t&&p&&(r=new p([r])),{type:n,data:r}},t.encodePayload=function(e,n,i){"function"==typeof n&&(i=n,n=null);var r=s(e);if(n&&r)return p&&!h?t.encodePayloadAsBlob(e,i):t.encodePayloadAsArrayBuffer(e,i);if(!e.length)return i("0:");m(e,(function(e,i){t.encodePacket(e,!!r&&n,!1,(function(e){i(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return i(t.join(""))}))},t.decodePayload=function(e,n,i){if("string"!=typeof e)return t.decodePayloadAsBinary(e,n,i);var r;if("function"==typeof n&&(i=n,n=null),""===e)return i(g,0,1);for(var s,o,a="",l=0,u=e.length;l0;){for(var a=new Uint8Array(r),l=0===a[0],u="",c=1;255!==a[c];c++){if(u.length>310)return i(g,0,1);u+=a[c]}r=o(r,2+u.length),u=parseInt(u);var h=o(r,0,u);if(l)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var d=new Uint8Array(h);h="";for(c=0;c=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}).call(this,n(20))},function(e,t){t.encode=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){for(var t={},n=e.split("&"),i=0,r=n.length;i=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}).call(this,n(20))},function(module,exports,__webpack_require__){!function(a){var b=Math.sign,c=Math.min,d=Math.abs;void 0===a.Lowlight&&(a.Lowlight={}),"object"==typeof module.exports&&(module.exports=a.Lowlight);class e{constructor(){this.nodes=new Map}id(e){return e}node(e,t=!1){return t?this.nodes.get(this.id(arguments[0])):this.nodes.get(e)}data(e,t){return 2===arguments.length&&(e.graph.get(this)._data=t),e.graph.get(this)._data}adjacent(e,t){return e.graph.get(this).has(t)}neighbors(e){return Array.from(e.graph.get(this).keys())}connected(e,t){return e.graph.get(this)._connectivity===t.graph.get(this)._connectivity}connect(){let e=Array.from(this.nodes.values()),t=0;for(let t=0;t{void 0===e.graph.get(this)._connectivity&&0>i.indexOf(e)&&i.push(e)})}}}add(e){return 1this.add(e)):(e.graph.set(this,new Map),this.nodes.set(e.id,e),e)}delete(e){return 1this.delete(e)):(e.graph.delete(this),this.nodes.delete(e.id),e)}edge(e,t,n=1,i=1){if(!e.graph.has(this)||!t.graph.has(this))throw new Error("Nodes must be on the same graph");return null===n?e.graph.get(this).delete(t):e.graph.get(this).set(t,n),null===i?t.graph.get(this).delete(e):t.graph.get(this).set(e,i),this}cost(e,t){return this.adjacent(e,t)?e.graph.get(this).get(t):null}}e.fromArray=function(t,n={}){let i=e.fromArray.X(t,n.order),r=e.fromArray.Y(t,n.order),s=e.fromArray.at.bind(null,t,n.order),o=[],a=null;for(let t,l=1;lu(e.x,e.y)}),t.connect(),t.X=i,t.Y=r,t.TORUS=n.torus,a||(a=t.nodes)}return 1+e}get size(){return this.nodes.length}add(e){if(1=this.score(r))break;this.nodes[i]=t,this.nodes[e]=r,e=i}return this}sink(e){let t=this.nodes[e],n=this.score(t);for(;;){let i=2*(e+1),r=i-1,s=null;if(r{this._worker_path_callback=n.callback,delete n.callback,this.worker.postMessage(["path",e,t,n])},this.worker.onmessage=e=>{let t=JSON.parse(e.data);switch(t[0]){case"path":this._worker_path_callback(t[1])}}}}path(e,t,n={}){if(n.jps)return this.jps(e,t,n);let i=new g(e=>e.estimated),r=new Map,s=this.graphs[n.layer||0];if(e=s.node(e,!0),t=s.node(t,!0),i.add({node:e,estimated:0}),r.set(e,{score:0,from:null}),!n.static||s.connected(e,t))for(;i.size;){let e=i.pop().node;if(e===t)break;s.neighbors(e).map(o=>{let a=(r.has(e)?r.get(e).score:0)+s.cost(e,o);a<(r.has(o)?r.get(o).score:1/0)&&(r.set(o,{score:a,from:e}),i.set({node:o,estimated:a+h[n.heuristic||this.heuristic](o,t,n.heuristicOptions||this.heuristicOptions)}))}),i.delete(e)}let o=[];if(r.has(t)){let e=t;for(o.push(t);null!==(e=r.get(e).from);)o.push(e);o=o.reverse()}return n.callback&&n.callback(o,r),o}}if(j.JPS=class{constructor(){}static access(e,t,n,i){return e.adjacent(t,i?e.node(n,!0):n)}static neighborhood(e,t,n,i){let r=[],s=n.get(i).from||null;if(null===s)return t.neighbors(i);{let n={x:b(i.x-s.x),y:b(i.y-s.y)};if(0!=n.x&&0!=n.y){let s=e(i,{x:i.x+n.x,y:i.y},!0),o=e(i,{x:i.x,y:i.y+n.y},!0);(s||o)&&(r.push(t.node({x:i.x+n.x,y:i.y+n.y},!0)),s&&(r.push(t.node({x:i.x+n.x,y:i.y},!0)),!e(i,{x:i.x,y:i.y-n.y},!0)&&r.push(t.node({x:i.x+n.x,y:i.y-n.y},!0))),o&&(r.push(t.node({x:i.x,y:i.y+n.y},!0)),!e(i,{x:i.x-n.x,y:i.y},!0)&&r.push(t.node({x:i.x-n.x,y:i.y+n.y},!0))))}else e(i,{x:i.x+n.x,y:i.y+n.y},!0)&&(r.push(t.node({x:i.x+n.x,y:i.y+n.y},!0)),0==n.x?0!=n.y&&(!e(i,{x:i.x-1,y:i.y},!0)&&r.push(t.node({x:i.x-1,y:i.y+n.y},!0)),!e(i,{x:i.x+1,y:i.y},!0)&&r.push(t.node({x:i.x+1,y:i.y+n.y},!0))):(!e(i,{x:i.x,y:i.y-1},!0)&&r.push(t.node({x:i.x+n.x,y:i.y-1},!0)),!e(i,{x:i.x,y:i.y+1},!0)&&r.push(t.node({x:i.x+n.x,y:i.y+1},!0))))}return r.filter(e=>e)}static jump(e,t,n,i,r,s){for(;;){if(!e(s,r))return null;if(r.x===i.x&&r.y===i.y)return r;let o={x:b(r.x-s.x),y:b(r.y-s.y)};if(0!=o.x&&0!=o.y){if(!e(r,{x:r.x-o.x,y:r.y},!0)&&e(r,{x:r.x-o.x,y:r.y+o.y},!0)||!e(r,{x:r.x,y:r.y-o.y},!0)&&e(r,{x:r.x+o.x,y:r.y-o.y},!0))return r;let s=j.JPS.jump.bind(this,e,t,n,i);if(null!==s(t.node({x:r.x+o.x,y:r.y},!0),r)||null!==s(t.node({x:r.x,y:r.y+o.y},!0),r))return r}else if(0!=o.x){if(!e(r,{x:r.x,y:r.y-1},!0)&&e(r,{x:r.x+o.x,y:r.y-1},!0)||!e(r,{x:r.x,y:r.y+1},!0)&&e(r,{x:r.x+o.x,y:r.y+1},!0))return r}else if(0!=o.y&&(!e(r,{x:r.x-1,y:r.y},!0)&&e(r,{x:r.x-1,y:r.y+o.y},!0)||!e(r,{x:r.x+1,y:r.y},!0)&&e(r,{x:r.x+1,y:r.y+o.y},!0)))return r;s=r,r=t.node({x:r.x+o.x,y:r.y+o.y},!0)}return null}},j.prototype.jps=function(e,t,n={}){if(this.graphs[n.layer||0].TORUS)return console.warn("Torus map aren't yet supported by JPS"),n.callback&&n.callback([],new Map),[];let i=new g(e=>e.estimated),r=new Map,s=this.graphs[n.layer||0],o=null;e=s.node(e,!0),t=s.node(t,!0),i.add({node:e,estimated:0}),r.set(e,{score:0,from:null});let a=j.JPS.access.bind(this,s),l=j.JPS.neighborhood.bind(this,a,s,r),u=j.JPS.jump.bind(this,a,s,r,t);if(!n.static||s.connected(e,t))for(;i.size;){let e=i.pop().node;if(e===t)break;l(e).map(a=>{if(null!==(o=u(a,e))){let a=(r.has(e)?r.get(e).score:0)+s.cost(e,o);a<(r.has(o)?r.get(o).score:1/0)&&(r.set(o,{score:a,from:e,jumped:!0}),i.set({node:o,estimated:a+h[n.heuristic||this.heuristic](o,t,n.heuristicOptions||this.heuristicOptions)}))}}),i.delete(e)}let c=[];if(r.has(t)){let n=t;for(;n.x!=e.x||n.y!=e.y;)for(let e=r.get(n).from;n.x!=e.x||n.y!=e.y;)c.push(n),n=s.node({x:n.x+b(e.x-n.x),y:n.y+b(e.y-n.y)},!0);c.push(n),c.reverse()}return n.callback&&n.callback(c,r),c},"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){let a;onmessage=function(b){let c=b.data;switch(c[0]){case"constructor":if("cost"in c[2]){let a=/^\((.*?)\)\s*=>\s*{/.test(c[2].cost),b=/^function /.test(c[2].cost);c[2].cost=eval(`(${a||b?"":"function "}${c[2].cost})`)}a=new j(c[1],c[2]);break;case"path":postMessage(JSON.stringify(["path",a.path(c[1],c[2],c[3])]))}}}a.Lowlight.Astar={Graph:e,Node:f,BinaryHeap:g,Heuristic:h,Configuration:j,WorkerError:i}}("undefined"==typeof window?this:window)},function(e,t,n){var i=n(51),r=n(21),s=n(29),o=n(13)("socket.io-client");e.exports=t=l;var a=t.managers={};function l(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var n,r=i(e),l=r.source,u=r.id,c=r.path,h=a[u]&&c in a[u].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(o("ignoring socket cache for %s",l),n=s(l,t)):(a[u]||(o("new io instance for %s",l),a[u]=s(l,t)),n=a[u]),r.query&&!t.query&&(t.query=r.query),n.socket(r.path,t)}t.protocol=r.protocol,t.connect=l,t.Manager=n(29),t.Socket=n(35)},function(e,t){function n(t){return e.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,n(t)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){var n,i,r=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var l,u=[],c=!1,h=-1;function d(){c&&l&&(c=!1,l.length?u=l.concat(u):h=-1,u.length&&f())}function f(){if(!c){var e=a(d);c=!0;for(var t=u.length;t;){for(l=u,u=[];++h1)for(var n=1;n - * @license MIT - */ -var i=n(59),r=n(60),s=n(61);function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function g(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(e).length;default:if(i)return H(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return L(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function m(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function y(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=l.from(t,i)),l.isBuffer(t))return 0===t.length?-1:v(e,t,n,i,r);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,i,r){var s,o=1,a=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){var c=-1;for(s=n;sa&&(n=a-l),s=n;s>=0;s--){for(var h=!0,d=0;dr&&(i=r):i=r;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o>8,r=n%256,s.push(r),s.push(i);return s}(t,e.length-n),e,n,i)}function I(e,t,n){return 0===t&&n===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var i=[],r=t;r239?4:u>223?3:u>191?2:1;if(r+h<=n)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(s=e[r+1]))&&(l=(31&u)<<6|63&s)>127&&(c=l);break;case 3:s=e[r+1],o=e[r+2],128==(192&s)&&128==(192&o)&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=e[r+1],o=e[r+2],a=e[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,i.push(c>>>10&1023|55296),c=56320|1023&c),i.push(c),r+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",i=0;for(;i0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},l.prototype.compare=function(e,t,n,i,r){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),t<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&t>=n)return 0;if(i>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(i,r),c=e.slice(t,n),h=0;hr)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return k(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return w(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function L(e,t,n){var i="";n=Math.min(e.length,n);for(var r=t;ri)&&(n=i);for(var r="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function _(e,t,n,i,r,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function P(e,t,n,i){t<0&&(t=65535+t+1);for(var r=0,s=Math.min(e.length-n,2);r>>8*(i?r:1-r)}function B(e,t,n,i){t<0&&(t=4294967295+t+1);for(var r=0,s=Math.min(e.length-n,4);r>>8*(i?r:3-r)&255}function M(e,t,n,i,r,s){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,i,s){return s||M(e,0,n,4),r.write(e,t,n,i,23,4),n+4}function F(e,t,n,i,s){return s||M(e,0,n,8),r.write(e,t,n,i,52,8),n+8}l.prototype.slice=function(e,t){var n,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t0&&(r*=256);)i+=this[e+--t]*r;return i},l.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},l.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var i=this[e],r=1,s=0;++s=(r*=128)&&(i-=Math.pow(2,8*t)),i},l.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var i=t,r=1,s=this[e+--i];i>0&&(r*=256);)s+=this[e+--i]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*t)),s},l.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),r.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),r.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),r.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),r.read(this,e,!1,52,8)},l.prototype.writeUIntLE=function(e,t,n,i){(e=+e,t|=0,n|=0,i)||_(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+r]=e/s&255;return t+n},l.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);_(this,e,t,n,r-1,-r)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+n},l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);_(this,e,t,n,r-1,-r)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||_(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,i){if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;--r)e[r+t]=this[r+n];else if(s<1e3||!l.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function G(e){return i.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}).call(this,n(58))},function(e,t,n){var i=n(64),r=n(25);e.exports=function(e){var t=e.xdomain,n=e.xscheme,s=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||i))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&s)return new XDomainRequest}catch(e){}if(!t)try{return new(r[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}},function(e,t){e.exports="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},function(e,t,n){var i=n(12),r=n(11);function s(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.withCredentials=e.withCredentials,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}e.exports=s,r(s.prototype),s.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},s.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},s.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},s.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},s.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},s.prototype.onData=function(e){var t=i.decodePacket(e,this.socket.binaryType);this.onPacket(t)},s.prototype.onPacket=function(e){this.emit("packet",e)},s.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(e,t){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(e){var t=e,r=e.indexOf("["),s=e.indexOf("]");-1!=r&&-1!=s&&(e=e.substring(0,r)+e.substring(r,s).replace(/:/g,";")+e.substring(s,e.length));for(var o,a,l=n.exec(e||""),u={},c=14;c--;)u[i[c]]=l[c]||"";return-1!=r&&-1!=s&&(u.source=t,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=function(e,t){var n=t.replace(/\/{2,9}/g,"/").split("/");"/"!=t.substr(0,1)&&0!==t.length||n.splice(0,1);"/"==t.substr(t.length-1,1)&&n.splice(n.length-1,1);return n}(0,u.path),u.queryKey=(o=u.query,a={},o.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(a[t]=n)})),a),u}},function(e,t,n){(function(t){e.exports=function(e){return n&&t.isBuffer(e)||i&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))};var n="function"==typeof t&&"function"==typeof t.isBuffer,i="function"==typeof ArrayBuffer}).call(this,n(23).Buffer)},function(e,t,n){var i=n(62),r=n(35),s=n(11),o=n(21),a=n(36),l=n(37),u=n(13)("socket.io-client:manager"),c=n(34),h=n(78),d=Object.prototype.hasOwnProperty;function f(e,t){if(!(this instanceof f))return new f(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new h({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=t.parser||o;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}e.exports=f,f.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)d.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},f.prototype.updateSocketIds=function(){for(var e in this.nsps)d.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},f.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},s(f.prototype),f.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},f.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},f.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},f.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},f.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},f.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},f.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},f.prototype.open=f.prototype.connect=function(e,t){if(u("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;u("opening %s",this.uri),this.engine=i(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var s=a(n,"open",(function(){r.onopen(),e&&e()})),o=a(n,"error",(function(t){if(u("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",t),e){var n=new Error("Connection error");n.data=t,e(n)}else r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var l=this._timeout;u("connect attempt will timeout after %d",l),0===l&&s.destroy();var c=setTimeout((function(){u("connect attempt timed out after %d",l),s.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",l)}),l);this.subs.push({destroy:function(){clearTimeout(c)}})}return this.subs.push(s),this.subs.push(o),this},f.prototype.onopen=function(){u("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(a(e,"data",l(this,"ondata"))),this.subs.push(a(e,"ping",l(this,"onping"))),this.subs.push(a(e,"pong",l(this,"onpong"))),this.subs.push(a(e,"error",l(this,"onerror"))),this.subs.push(a(e,"close",l(this,"onclose"))),this.subs.push(a(this.decoder,"decoded",l(this,"ondecoded")))},f.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},f.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},f.prototype.ondata=function(e){this.decoder.add(e)},f.prototype.ondecoded=function(e){this.emit("packet",e)},f.prototype.onerror=function(e){u("error",e),this.emitAll("error",e)},f.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new r(this,e,t),this.nsps[e]=n;var i=this;n.on("connecting",s),n.on("connect",(function(){n.id=i.generateId(e)})),this.autoConnect&&s()}function s(){~c(i.connecting,n)||i.connecting.push(n)}return n},f.prototype.destroy=function(e){var t=c(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},f.prototype.packet=function(e){u("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,(function(n){for(var i=0;i0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},f.prototype.cleanup=function(){u("cleanup");for(var e=this.subs.length,t=0;t=this._reconnectionAttempts)u("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();u("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(u("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(u("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(u("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},f.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,n){var i=n(24),r=n(65),s=n(74),o=n(75);t.polling=function(e){var t=!1,n=!1,o=!1!==e.jsonp;if("undefined"!=typeof location){var a="https:"===location.protocol,l=location.port;l||(l=a?443:80),t=e.hostname!==location.hostname||l!==e.port,n=e.secure!==a}if(e.xdomain=t,e.xscheme=n,"open"in new i(e)&&!e.forceJSONP)return new r(e);if(!o)throw new Error("JSONP disabled");return new s(e)},t.websocket=o},function(e,t,n){var i=n(26),r=n(14),s=n(12),o=n(15),a=n(33),l=n(16)("engine.io-client:polling");e.exports=c;var u=null!=new(n(24))({xdomain:!1}).responseType;function c(e){var t=e&&e.forceBase64;u&&!t||(this.supportsBinary=!1),i.call(this,e)}o(c,i),c.prototype.name="polling",c.prototype.doOpen=function(){this.poll()},c.prototype.pause=function(e){var t=this;function n(){l("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var i=0;this.polling&&(l("we are currently polling - waiting to pause"),i++,this.once("pollComplete",(function(){l("pre-pause polling complete"),--i||n()}))),this.writable||(l("we are currently writing - waiting to pause"),i++,this.once("drain",(function(){l("pre-pause writing complete"),--i||n()})))}else n()},c.prototype.poll=function(){l("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},c.prototype.onData=function(e){var t=this;l("polling got data %s",e);s.decodePayload(e,this.socket.binaryType,(function(e,n,i){if("opening"===t.readyState&&"open"===e.type&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():l('ignoring poll - transport state "%s"',this.readyState))},c.prototype.doClose=function(){var e=this;function t(){l("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(l("transport open - closing"),t()):(l("transport not open - deferring close"),this.once("open",t))},c.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};s.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},c.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=a()),this.supportsBinary||e.sid||(e.b64=1),e=r.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e}},function(e,t,n){(function(t){var i=n(22),r=Object.prototype.toString,s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===r.call(Blob),o="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===r.call(File);e.exports=function e(n){if(!n||"object"!=typeof n)return!1;if(i(n)){for(var r=0,a=n.length;r0);return t}function u(){var e=l(+new Date);return e!==i?(o=0,i=e):e+"."+l(o++)}for(;a<64;a++)s[r[a]]=a;u.encode=l,u.decode=function(e){var t=0;for(a=0;a>>0,t=(i*=t)>>>0,t+=4294967296*(i-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=i(" "),n.s1=i(" "),n.s2=i(" "),n.s0-=i(e),n.s0<0&&(n.s0+=1),n.s1-=i(e),n.s1<0&&(n.s1+=1),n.s2-=i(e),n.s2<0&&(n.s2+=1),i=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function l(e,t){var n=new o(e),i=t&&t.state,r=n.next;return r.int32=function(){return 4294967296*n.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n(6)&&n(10)?void 0===(i=function(){return l}.call(t,n,t,r))||(r.exports=i):this.alea=l}(0,e,n(6))}).call(this,n(9)(e))},function(e,t,n){(function(e){var i;!function(e,r,s){function o(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var i=0;i>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n(6)&&n(10)?void 0===(i=function(){return l}.call(t,n,t,r))||(r.exports=i):this.xor128=l}(0,e,n(6))}).call(this,n(9)(e))},function(e,t,n){(function(e){var i;!function(e,r,s){function o(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var i=0;i>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function l(e,t){var n=new o(e),i=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n(6)&&n(10)?void 0===(i=function(){return l}.call(t,n,t,r))||(r.exports=i):this.xorwow=l}(0,e,n(6))}).call(this,n(9)(e))},function(e,t,n){(function(e){var i;!function(e,r,s){function o(e){var t=this;t.next=function(){var e,n,i=t.x,r=t.i;return e=i[r],n=(e^=e>>>7)^e<<24,n^=(e=i[r+1&7])^e>>>10,n^=(e=i[r+3&7])^e>>>3,n^=(e=i[r+4&7])^e<<7,e=i[r+7&7],n^=(e^=e<<13)^e<<9,i[r]=n,t.i=r+1&7,n},function(e,t){var n,i=[];if(t===(0|t))i[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function l(e,t){null==e&&(e=+new Date);var n=new o(e),i=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,i&&(i.x&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n(6)&&n(10)?void 0===(i=function(){return l}.call(t,n,t,r))||(r.exports=i):this.xorshift7=l}(0,e,n(6))}).call(this,n(9)(e))},function(e,t,n){(function(e){var i;!function(e,r,s){function o(e){var t=this;t.next=function(){var e,n,i=t.w,r=t.X,s=t.i;return t.w=i=i+1640531527|0,n=r[s+34&127],e=r[s=s+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=r[s]=n^e,t.i=s,n+(i^i>>>16)|0},function(e,t){var n,i,r,s,o,a=[],l=128;for(t===(0|t)?(i=t,t=null):(t+="\0",i=0,l=Math.max(l,t.length)),r=0,s=-32;s>>15,i^=i<<4,i^=i>>>13,s>=0&&(o=o+1640531527|0,r=0==(n=a[127&s]^=i+o)?r+1:0);for(r>=128&&(a[127&(t&&t.length||0)]=-1),r=127,s=512;s>0;--s)i=a[r+34&127],n=a[r=r+1&127],i^=i<<13,n^=n<<17,i^=i>>>15,n^=n>>>12,a[r]=i^n;e.w=o,e.X=a,e.i=r}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function l(e,t){null==e&&(e=+new Date);var n=new o(e),i=t&&t.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,i&&(i.X&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n(6)&&n(10)?void 0===(i=function(){return l}.call(t,n,t,r))||(r.exports=i):this.xor4096=l}(0,e,n(6))}).call(this,n(9)(e))},function(e,t,n){(function(e){var i;!function(e,r,s){function o(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,i=t.d,r=t.a;return e=e<<25^e>>>7^n,n=n-i|0,i=i<<24^i>>>8^r,r=r-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-i|0,t.d=i<<16^n>>>16^r,t.a=r-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var i=0;i>>0)/4294967296};return r.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},r.int32=n.next,r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=l:n(6)&&n(10)?void 0===(i=function(){return l}.call(t,n,t,r))||(r.exports=i):this.tychei=l}(0,e,n(6))}).call(this,n(9)(e))},function(e,t,n){var i;!function(r,s,o){var a,l=o.pow(256,6),u=o.pow(2,52),c=2*u;function h(e,t,n){var i=[],h=g(function e(t,n){var i,r=[],s=typeof t;if(n&&"object"==s)for(i in t)try{r.push(e(t[i],n-1))}catch(e){}return r.length?r:"string"==s?t:t+"\0"}((t=1==t?{entropy:!0}:t||{}).entropy?[e,p(s)]:null==e?function(){try{var e;return a&&(e=a.randomBytes)?e=e(256):(e=new Uint8Array(256),(r.crypto||r.msCrypto).getRandomValues(e)),p(e)}catch(e){var t=r.navigator,n=t&&t.plugins;return[+new Date,r,n,r.screen,p(s)]}}():e,3),i),m=new d(i),y=function(){for(var e=m.g(6),t=l,n=0;e=c;)e/=2,t/=2,n>>>=1;return(e+n)/t};return y.int32=function(){return 0|m.g(4)},y.quick=function(){return m.g(4)/4294967296},y.double=y,g(p(m.S),s),(t.pass||n||function(e,t,n,i){return i&&(i.S&&f(i,m),e.state=function(){return f(m,{})}),n?(o.random=e,t):e})(y,h,"global"in t?t.global:this==o,t.state)}function d(e){var t,n=e.length,i=this,r=0,s=i.i=i.j=0,o=i.S=[];for(n||(e=[n++]);r<256;)o[r]=r++;for(r=0;r<256;r++)o[r]=o[s=255&s+e[r%n]+(t=o[r])],o[s]=t;(i.g=function(e){for(var t,n=0,r=i.i,s=i.j,o=i.S;e--;)t=o[r=255&r+1],n=256*n+o[255&(o[r]=o[s=255&s+t])+(o[s]=t)];return i.i=r,i.j=s,n})(256)}function f(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function g(e,t){for(var n,i=e+"",r=0;r0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var o=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*o;case"days":case"day":case"d":return o*s;case"hours":case"hour":case"hrs":case"hr":case"h":return o*r;case"minutes":case"minute":case"mins":case"min":case"m":return o*i;case"seconds":case"second":case"secs":case"sec":case"s":return o*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}(e);if("number"===l&&!1===isNaN(e))return t.long?o(a=e,s,"day")||o(a,r,"hour")||o(a,i,"minute")||o(a,n,"second")||a+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=r)return Math.round(e/r)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(i){function r(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG),e}(t=e.exports=n(55)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var i="color: "+this.color;e.splice(1,0,i,"color: inherit");var r=0,s=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(s=r))})),e.splice(s,0,i)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=r,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}).call(this,n(20))},function(e,t,n){function i(e){var n;function i(){if(i.enabled){var e=i,r=+new Date,s=r-(n||r);e.diff=s,e.prev=n,e.curr=r,n=r;for(var o=new Array(arguments.length),a=0;a0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var o=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*o;case"days":case"day":case"d":return o*s;case"hours":case"hour":case"hrs":case"hr":case"h":return o*r;case"minutes":case"minute":case"mins":case"min":case"m":return o*i;case"seconds":case"second":case"secs":case"sec":case"s":return o*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}(e);if("number"===l&&!1===isNaN(e))return t.long?o(a=e,s,"day")||o(a,r,"hour")||o(a,i,"minute")||o(a,n,"second")||a+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=r)return Math.round(e/r)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){var i=n(22),r=n(28),s=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),a="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);t.deconstructPacket=function(e){var t=[],n=e.data,s=e;return s.data=function e(t,n){if(!t)return t;if(r(t)){var s={_placeholder:!0,num:n.length};return n.push(t),s}if(i(t)){for(var o=new Array(t.length),a=0;a=0&&t.num0?o-4:o;for(n=0;n>16&255,l[c++]=t>>8&255,l[c++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,l[c++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,l[c++]=t>>8&255,l[c++]=255&t);return l},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=0,a=n-r;oa?a:o+16383));1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(e,t){ -/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ -t.read=function(e,t,n,i,r){var s,o,a=8*r-i-1,l=(1<>1,c=-7,h=n?r-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=i;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,i),s-=u}return(f?-1:1)*o*Math.pow(2,s-i)},t.write=function(e,t,n,i,r,s){var o,a,l,u=8*s-r-1,c=(1<>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:s-1,g=i?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,r),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,r),o=0));r>=8;e[n+f]=255&a,f+=g,a/=256,r-=8);for(o=o<0;e[n+f]=255&o,f+=g,o/=256,u-=8);e[n+f-g]|=128*p}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){e.exports=n(63),e.exports.parser=n(12)},function(e,t,n){var i=n(30),r=n(11),s=n(16)("engine.io-client:socket"),o=n(34),a=n(12),l=n(27),u=n(14);function c(e,t){if(!(this instanceof c))return new c(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=l(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=l(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=u.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.withCredentials=!1!==t.withCredentials,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||void 0,this.key=t.key||void 0,this.passphrase=t.passphrase||void 0,this.cert=t.cert||void 0,this.ca=t.ca||void 0,this.ciphers=t.ciphers||void 0,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}e.exports=c,c.priorWebsocketSuccess=!1,r(c.prototype),c.protocol=a.protocol,c.Socket=c,c.Transport=n(26),c.transports=n(30),c.parser=n(12),c.prototype.createTransport=function(e){s('creating transport "%s"',e);var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=a.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new i[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,withCredentials:n.withCredentials||this.withCredentials,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},c.prototype.open=function(){var e;if(this.rememberUpgrade&&c.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},c.prototype.setTransport=function(e){s("setting transport %s",e.name);var t=this;this.transport&&(s("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},c.prototype.probe=function(e){s('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,i=this;function r(){if(i.onlyBinaryUpgrades){var r=!this.supportsBinary&&i.transport.supportsBinary;n=n||r}n||(s('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(r){if(!n)if("pong"===r.type&&"probe"===r.data){if(s('probe transport "%s" pong',e),i.upgrading=!0,i.emit("upgrading",t),!t)return;c.priorWebsocketSuccess="websocket"===t.name,s('pausing current transport "%s"',i.transport.name),i.transport.pause((function(){n||"closed"!==i.readyState&&(s("changing transport and sending upgrade packet"),d(),i.setTransport(t),t.send([{type:"upgrade"}]),i.emit("upgrade",t),t=null,i.upgrading=!1,i.flush())}))}else{s('probe transport "%s" failed',e);var o=new Error("probe error");o.transport=t.name,i.emit("upgradeError",o)}})))}function o(){n||(n=!0,d(),t.close(),t=null)}function a(n){var r=new Error("probe error: "+n);r.transport=t.name,o(),s('probe transport "%s" failed because of error: %s',e,n),i.emit("upgradeError",r)}function l(){a("transport closed")}function u(){a("socket closed")}function h(e){t&&e.name!==t.name&&(s('"%s" works - aborting "%s"',e.name,t.name),o())}function d(){t.removeListener("open",r),t.removeListener("error",a),t.removeListener("close",l),i.removeListener("close",u),i.removeListener("upgrading",h)}c.priorWebsocketSuccess=!1,t.once("open",r),t.once("error",a),t.once("close",l),this.once("close",u),this.once("upgrading",h),t.open()},c.prototype.onOpen=function(){if(s("socket open"),this.readyState="open",c.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){s("starting upgrade probes");for(var e=0,t=this.upgrades.length;ei&&(n=i),t>=i||t>=n||0===i)return new ArrayBuffer(0);for(var r=new Uint8Array(e),s=new Uint8Array(n-t),o=t,a=0;o=55296&&t<=56319&&r=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function l(e,t){return s(e>>t&63|128)}function u(e,t){if(0==(4294967168&e))return s(e);var n="";return 0==(4294965248&e)?n=s(e>>6&31|192):0==(4294901760&e)?(a(e,t)||(e=65533),n=s(e>>12&15|224),n+=l(e,6)):0==(4292870144&e)&&(n=s(e>>18&7|240),n+=l(e,12),n+=l(e,6)),n+=s(63&e|128)}function c(){if(r>=i)throw Error("Invalid byte index");var e=255&n[r];if(r++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function h(e){var t,s;if(r>i)throw Error("Invalid byte index");if(r==i)return!1;if(t=255&n[r],r++,0==(128&t))return t;if(192==(224&t)){if((s=(31&t)<<6|c())>=128)return s;throw Error("Invalid continuation byte")}if(224==(240&t)){if((s=(15&t)<<12|c()<<6|c())>=2048)return a(s,e)?s:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(s=(7&t)<<18|c()<<12|c()<<6|c())>=65536&&s<=1114111)return s;throw Error("Invalid UTF-8 detected")}e.exports={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,i=o(e),r=i.length,s=-1,a="";++s65535&&(r+=s((t-=65536)>>>10&1023|55296),t=56320|1023&t),r+=s(t);return r}(u)}}},function(e,t){!function(e){"use strict";t.encode=function(t){var n,i=new Uint8Array(t),r=i.length,s="";for(n=0;n>2],s+=e[(3&i[n])<<4|i[n+1]>>4],s+=e[(15&i[n+1])<<2|i[n+2]>>6],s+=e[63&i[n+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s},t.decode=function(t){var n,i,r,s,o,a=.75*t.length,l=t.length,u=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var c=new ArrayBuffer(a),h=new Uint8Array(c);for(n=0;n>4,h[u++]=(15&r)<<4|s>>2,h[u++]=(3&s)<<6|63&o;return c}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},function(e,t){var n=void 0!==n?n:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,i=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),r=i&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),s=n&&n.prototype.append&&n.prototype.getBlob;function o(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e}))}function a(e,t){t=t||{};var i=new n;return o(e).forEach((function(e){i.append(e)})),t.type?i.getBlob(t.type):i.getBlob()}function l(e,t){return new Blob(o(e),t||{})}"undefined"!=typeof Blob&&(a.prototype=Blob.prototype,l.prototype=Blob.prototype),e.exports=i?r?Blob:l:s?a:void 0},function(e,t,n){function i(e){var n;function i(){if(i.enabled){var e=i,r=+new Date,s=r-(n||r);e.diff=s,e.prev=n,e.curr=r,n=r;for(var o=new Array(arguments.length),a=0;a0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var o=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*o;case"days":case"day":case"d":return o*s;case"hours":case"hour":case"hrs":case"hr":case"h":return o*r;case"minutes":case"minute":case"mins":case"min":case"m":return o*i;case"seconds":case"second":case"secs":case"sec":case"s":return o*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}(e);if("number"===l&&!1===isNaN(e))return t.long?o(a=e,s,"day")||o(a,r,"hour")||o(a,i,"minute")||o(a,n,"second")||a+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=r)return Math.round(e/r)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){var i=n(31),r=n(15),s=n(25);e.exports=c;var o,a=/\n/g,l=/\\n/g;function u(){}function c(e){i.call(this,e),this.query=this.query||{},o||(o=s.___eio=s.___eio||[]),this.index=o.length;var t=this;o.push((function(e){t.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){t.script&&(t.script.onerror=u)}),!1)}r(c,i),c.prototype.supportsBinary=!1,c.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),i.prototype.doClose.call(this)},c.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},c.prototype.doWrite=function(e,t){var n=this;if(!this.form){var i,r=document.createElement("form"),s=document.createElement("textarea"),o=this.iframeId="eio_iframe_"+this.index;r.className="socketio",r.style.position="absolute",r.style.top="-1000px",r.style.left="-1000px",r.target=o,r.method="POST",r.setAttribute("accept-charset","utf-8"),s.name="d",r.appendChild(s),document.body.appendChild(r),this.form=r,this.area=s}function u(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='