(()=>{"use strict";var t,e,n,i=function(){function t(t,e,n){this.family=t,this.value=e,this.red=n,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,n,i,r,o){void 0===r&&(r=!1),void 0===o&&(o=0),t.save(),t.translate(e+75*i/2,n+100*i/2),t.rotate(o+this.tilt),r?t.drawImage(this.imgBack,-75*i/2,-100*i/2,75*i,100*i):(t.drawImage(this.imgFront,-75*i/2,-100*i/2,75*i,100*i),t.drawImage(this.img,-75*i/2,-100*i/2,75*i,100*i)),t.restore()},t.prototype.isLessThan=function(t){return this.family0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0))return[];var e=this.tiles.pop(),n=this.count(e.getFamily(),e.getValue());if(n>=1&&!t){var i=this.find(e.getFamily(),e.getValue()),o=this.toGroup(!0);if(this.tiles.push(i),this.sort(),void 0!==o)return this.tiles.push(e),this.sort(),o.push(new r([e,i])),o}if(n>=2){i=this.find(e.getFamily(),e.getValue());var s=this.find(e.getFamily(),e.getValue());if(o=this.toGroup(t),this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==o)return o.push(new r([e,i,s])),this.tiles.push(e),this.sort(),o}if(this.count(e.getFamily(),e.getValue()-1)*this.count(e.getFamily(),e.getValue()-2)>0&&(i=this.find(e.getFamily(),e.getValue()-1),s=this.find(e.getFamily(),e.getValue()-2),o=this.toGroup(t),this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==o))return o.push(new r([s,i,e])),this.tiles.push(e),this.sort(),o;this.tiles.push(e),this.tiles.sort()},t.prototype.drawHand=function(t,e,n,i,r,o,s,a){void 0===o&&(o=void 0),void 0===s&&(s=!1),void 0===a&&(a=0);for(var l=(75+i)*r,u=Math.cos(a)*l,c=Math.sin(a)*l,h=0;h0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0;){var n=Math.floor(Math.random()*this.tiles.length);t=[this.tiles[0],this.tiles[n]],this.tiles[n]=t[0],this.tiles[0]=t[1],e.push(this.tiles.shift())}this.tiles=e},t.prototype.getRandomHand=function(){var t=new o;this.shuffle();for(var e=0;e<13;e++)t.push(this.pop());return t},t.prototype.cleanup=function(){this.tiles.forEach((function(t){return t.cleanup()})),this.tiles=[]},t.prototype.preload=function(){return t=this,e=void 0,i=function(){var t;return function(t,e){var n,i,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=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]500&&t.getDeck().length()>0){d=i;var r=Math.floor(Math.random()*t.getHands()[p].length());null==t||t.discard(p,r),p=(p+1)%4,null==t||t.pick(p),null==t||t.getHands()[0].sort()}var o=i-y;o=0&&s=910&&o<=985?s:void 0},r=function(n){0===p&&void 0!==e&&t.getDeck().length()>0&&(null==t||t.discard(0,e),p++,null==t||t.pick(p))},v.push((function(){g.removeEventListener("mousemove",i),g.removeEventListener("mousedown",r)})),g.addEventListener("mousemove",i),g.addEventListener("mousedown",r),requestAnimationFrame(k),window.cleanup=x,[2]}var i,r}))}))}().catch(console.error)})();