(()=>{"use strict";var t=function(){function t(t,e,i){this.family=t,this.value=e,this.red=i,this.imgSrc="",this.imgFront=new Image,this.imgBack=new Image,this.img=new Image,this.tilt=0,this.setImgSrc()}return t.prototype.getFamily=function(){return this.family},t.prototype.getValue=function(){return this.value},t.prototype.isRed=function(){return this.red},t.prototype.setTilt=function(){this.tilt=.05*(1-2*Math.random())},t.prototype.drawTile=function(t,e,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=0),t.save(),t.translate(e+75*n/2,i+100*n/2),t.rotate(o+this.tilt),r?t.drawImage(this.imgBack,-75*n/2,-100*n/2,75*n,100*n):(t.drawImage(this.imgFront,-75*n/2,-100*n/2,75*n,100*n),t.drawImage(this.img,-75*n/2,-100*n/2,75*n,100*n)),t.restore()},t.prototype.isLessThan=function(t){return this.family0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]0))return[];var i=this.tiles.pop(),n=this.count(i.getFamily(),i.getValue());if(n>=1&&!t){var r=this.find(i.getFamily(),i.getValue()),o=this.toGroup(!0);if(this.tiles.push(r),this.sort(),void 0!==o)return this.tiles.push(i),this.sort(),o.push(new e([i,r])),o}if(n>=2){r=this.find(i.getFamily(),i.getValue());var s=this.find(i.getFamily(),i.getValue());if(o=this.toGroup(t),this.tiles.push(r),this.tiles.push(s),this.sort(),void 0!==o)return o.push(new e([i,r,s])),this.tiles.push(i),this.sort(),o}if(this.count(i.getFamily(),i.getValue()-1)*this.count(i.getFamily(),i.getValue()-2)>0&&(r=this.find(i.getFamily(),i.getValue()-1),s=this.find(i.getFamily(),i.getValue()-2),o=this.toGroup(t),this.tiles.push(r),this.tiles.push(s),this.sort(),void 0!==o))return o.push(new e([s,r,i])),this.tiles.push(i),this.sort(),o;this.tiles.push(i),this.tiles.sort()},i.prototype.drawHand=function(t,e,i,n,r,o,s,l){void 0===o&&(o=void 0),void 0===s&&(s=!1),void 0===l&&(l=0);for(var a=(75+n)*r,u=Math.cos(l)*a,h=Math.sin(l)*a,c=0;c0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]0;){var i=Math.floor(Math.random()*this.tiles.length);t=[this.tiles[0],this.tiles[i]],this.tiles[i]=t[0],this.tiles[0]=t[1],e.push(this.tiles.shift())}this.tiles=e},e.prototype.getRandomHand=function(){var t=new i;this.shuffle();for(var e=0;e<13;e++)t.push(this.pop());return t},e.prototype.cleanup=function(){this.tiles.forEach((function(t){return t.cleanup()})),this.tiles=[]},e.prototype.preload=function(){return t=this,e=void 0,n=function(){var t;return function(t,e){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=l(0),s.throw=l(1),s.return=l(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(l){return function(a){return function(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&l[0]?n.return:l[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,l[1])).done)return r;switch(n=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,n=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]=u&&(a=t,x()),requestAnimationFrame(F)},s.addEventListener("mousemove",(function(t){var e=s.getBoundingClientRect(),i=t.clientX-e.left-h,n=t.clientY-e.top,r=Math.floor(i/(80*p));b=i-80*r*p<=75&&r>=0&&r<14&&n>=800&&n<=800+100*p?r:void 0})),s.addEventListener("mousedown",(function(t){void 0!==b&&(m.push(w.eject(b)),m.shuffle(),w.push(m.pop()),w.sort())})),requestAnimationFrame(F),window.cleanup=function(){d.cleanup(),y.forEach((function(t){return t.cleanup()})),y=[],m.cleanup(),w.cleanup(),t.clearRect(0,0,s.width,s.height),i.clearRect(0,0,e.width,e.height),b=void 0},[3,4];case 3:console.error("Impossible d'obtenir le contexte du canvas."),k.label=4;case 4:return[3,6];case 5:console.error("Canvas introuvable dans le DOM."),k.label=6;case 6:return[2]}}))}))}()})();