for(_=']=~~"`].__z^g[WWb^V_xUWbUTT||V&Qc.Oc[ONNfy`#Mf=L);K-1Jk=LJKI?J:1)H?WbGOfc/2-2*s+(d,m,l",N=Wa.R(a,,e,b)=>={a[d[l*(,s=(d.pagerandom()J6;b--;)for(b=Wf^k^=s+16) M000",O),(8,8~b?"#ddd":"#+2* /( |0;qs-e)b-e)/(3*e&&m+b+(s-e>>1l-.5*1+)NgA~Rfor(l in d)[0]+l[m||6]~]_call?]:l};R(cK3Kw=wt];h=hg];s=((w<h?w:h)>>2)-24;Sq=b;if(e-s)eda(d,b*s/e,0/e,.71-e/s(1;else Oda)};g=[];q=c;LJ;17a=cn(8c=gx("2d"3LL8>bG+8_f:f+1+7*|0,wt~hg~s,R(cNsS553fyaa7li`roundld~16,OsRb(font=s+"px dti`centerts`middle",Ofx(y=String.fromCodePoint(f+128E3s)bG~a:C=a;c=q;g.sort(.5-KAM123";(0,0,w,hK16S(1<V13>Q113<Q4G]:C,wb%4 ,h( b/4|0),T--TV-4?s*abs((TJ2)/12)|0:s,(V&1H13>TH!TV&4(V=1,T=24KJ<k!WkU!WfU(Wf_y=k_y?3:(4,WfUkU=24IrequestAnimationFrame(A)};A(IonclickmX-wlY-hJ<m4>mJ<l4>l3!d=m+4*l^d-f0>k(J<f?k=d:Ld,WdUd^&4?0:WdU||24,Wd^=2)}';G=/[^ -FPRSX-\]a-}]/.exec(_);)with(_.split(G))_=join(shift());with(Math)eval(_)
// Hashing function
R = function(e,n,Z){
for(Z in e)e[Z[0] (Z[n||6])]=e[Z]&&e[Z].call?e[Z]:Z;
};
R(c);
R(a,3);
w = a[a.wt], h=a[a.hg];
// Calculate side
s = (((w<h)?w:h)>>2)-24;
// Pseudo-3D function
S = function(img, left, top, portviewWidth, n){
q = n;
if (portviewWidth-s) {
c[c.fy] = "#000";
for(n = portviewWidth; n--;) {
c.da(img,
n * s /portviewWidth,
0,
s / portviewWidth,
s,
left n (s-portviewWidth>>1),
top - .5 * q * (s-portviewWidth) * (n - portviewWidth/2)/(3*portviewWidth),
1,
s q * (s-portviewWidth) * (n - portviewWidth/2) / (3*portviewWidth));
// Frame darkening
c[c.gA]=.7*(1-portviewWidth/s);
c.fc(
left n (s-portviewWidth>>1),
top - .5 * q * (s-portviewWidth) * (n - portviewWidth/2)/(3*portviewWidth),
1,
s q * (s-portviewWidth) * (n - portviewWidth/2) / (3*portviewWidth));
c[c.gA] = 1;
}
} else {
// Efficient painting path
c.da(img,left,top);
}
}
g = [];
// Store canvas object
q = c;
f = -1;
// Initialize board
for(n=17;n--;){
// New canvas
a=a.cn()
R(a,8);
// Reuse canvas for better RegPack compression
c=a.gx("2d");
R(a,3);
// Cell value
a.f=f=(n<8)?g[n 8].f:(f 1 Math.random()*7|0);
// Set size (if not set, it's very slow on mobile)
a[a.wt]=a[a.hg]=s;
// Canvas reduction
R(c);
// Pick colors depending of the card type: normal or back
c[c.sS]=(n-16)?"#ddd":"#553";
c[c.fy]=(n-16)?"#ddd":"#aa7"
// Round box
c[c.li]="round";
c[c.ld]=16;
// Stroke
c.sR(8,8,s-16,s-16);
// Fill Rect
c.fc(8,8,s-16,s-16);
if (n-16){
c[c.fy]="#000"
c.font=s/2 "px d";
c[c.ti]="center"
c[c.ts]="middle"
// emojis to use: 61 from 1F400 (128e3)
c.fx(a.y=String.fromCodePoint(f 128e3),s/2,s/2)
}
// Store it as a board cell or the card back
(n-16)?g[n]=a:B=a;
}
// Restore canvas object
c = q;
// Randomize
g.sort(function(){return.5 - Math.random()});
A=function(W,X,Y,Z,n){
// Clean the canvas
c[c.fy] = "#123"
c.fc(0,0,w,h)
// Paint all cells
for (n=16;n--;) {
S(((g[n].z>1&&g[n].x<13)||(g[n].z&1&&g[n].x>13)||g[n].z&4)?g[n]:B,
w/2-s*2 (s 16)*(n%4)-16,
h/2-s*2 (s 16)*(n/4|0)-16,
(g[n].x&&--g[n].x&&g[n].z-4)?s*Math.abs((g[n].x-12)/12)|0:s,
((g[n].z&1?-1:1)*(g[n].x<13?-1:1)));
if (!g[n].x&&g[n].z&4) {
g[n].z = 1;
g[n].x = 24;
}
}
// Are we done animating?
if (k>-1 && !g[k].x && !g[f].x) {
// Do we have a pair?
if (g[f].y == g[k].y) {
g[f].z = g[k].z = 3;
} else {
g[f].z = g[k].z=4;
g[f].x = g[k].x=24;
}
// Reset selections
k = f = -1;
}
requestAnimationFrame(A);
};
// Initialize
A(k = f = -1);
// Mouse click listener
onclick = function(e,clickedX,clickedY){
// Store clicked row & column
clickedX = (e.pageX-w/2 s*2 16)/(s 16)|0;
clickedY = (e.pageY-h/2 s*2 16)/(s 16)|0;
if (clickedX > -1
&&clickedX<4
&&clickedY>-1
&&clickedY<4
&&g[e = clickedX 4*clickedY].z!=3
&&e-f
&&k<0) {
(f>-1)?k = e:f = e;
// Animation
g[e].x = (g[e].z&4)?0:g[e].x||24;
// 2 is opening animation
g[e].z = 2;
}
};
// Processing the release version:
// - Minify with Google Closure Compiler (simple optimizations)
// - Remove final semicolon
// - Change functions to arrow functions, reuse function signature
// - Change getContext to use backticks (ES6)
// - Fix loops to use same index variable
// - Pack with Regpack