var e=window.matchMedia("(max-width: 600px)");if(e.matches){var t=document.getElementById("gameField");t.style.height=window.innerHeight-75+"px"}const o={colors:["#FFFFFF","#FFFAC8","#FABEBE","#AAFFC3","#E6BEFF","#46F0F0","#FFE119","#BCF60C","#F58231","#3CB44B","#F032E6","#808000","#008080","#9A6324","#E6194B","#4363D8","#911EB4","#800000","#000075","#000000"],colorsAlt:[0,1,6,8,13,14,17,5,3,7,9,11,12,2,4,10,16,15,18,19],numGuesses:6,numAnswerBlocks:[3,4],colorWeight:[[.5,.34,.16],[.4,.3,.2,.1]],graphSplit:[[50,8,17,25],[50,5,10,15,20]],correctColor:"forestgreen",misplacedColorLight:"#FFEA00",misplacedColorDark:"#d4c200",wrongColorLight:"#d3d3d3",wrongColorDark:"#36393b",graphBorderLight:"#ffffff",graphBorderDark:"#222425",lsWinStreak:"winStreak",lsLongestStreak:"longestStreak",lsWins:"wins",lsWinsHard:"winsHard",lsLastCompleted:"lastCompleted",lsMode:"mode",lsSeenFaq:"seenFaq",lsDarkMode:"darkMode",lsPaletteMode:"paletteMode",lsContSession:"contSession"};var r=0,a=0,l=localStorage.getItem(o.lsSeenFaq),s=null!=localStorage.getItem(o.lsPaletteMode)?localStorage.getItem(o.lsPaletteMode):0,n=localStorage.getItem(o.lsDarkMode);const d=window.matchMedia("(prefers-color-scheme: dark)");var c=document.getElementById("lightDarkIcon");1==n?(document.body.classList.add("dark-mode"),c.classList.remove("fa-moon"),c.classList.add("fa-sun")):null==n&&d.matches?(n=1,localStorage.setItem(o.lsDarkMode,1),document.body.classList.add("dark-mode"),c.classList.remove("fa-moon"),c.classList.add("fa-sun")):n=0;var i=1==n?o.wrongColorDark:o.wrongColorLight,u=1==n?o.misplacedColorDark:o.misplacedColorLight,g=1==n?o.graphBorderDark:o.graphBorderLight;1!=l&&setTimeout((function(){document.getElementById("faqModal").style.display="block"}),400),localStorage.setItem(o.lsSeenFaq,"1");var m,h,b,p,y=null!=localStorage.getItem(o.lsMode)?localStorage.getItem(o.lsMode):0,f=document.querySelector(".switch-button-case.right"),k=document.querySelector(".switch-button-case.left");function C(){f.classList.remove("active-case"),k.classList.add("active-case")}function v(){f.classList.add("active-case"),k.classList.remove("active-case")}switch(document.getElementById("switchButton").style.display="initial",0==y){case!0:k.classList.add("active-case");break;case!1:f.classList.add("active-case")}k.addEventListener("click",(function(){f.classList.contains("active-case")&&1==y&&(C(),localStorage.setItem(o.lsMode,0),window.location.reload())}),!1),f.addEventListener("click",(function(){k.classList.contains("active-case")&&0==y&&(v(),localStorage.setItem(o.lsMode,1),window.location.reload())}),!1);var B,w,M,L,E=0,I=0,A=0,S=[],F=[...Array(o.numGuesses)].map(e=>Array(o.numAnswerBlocks[y]).fill(-1)),W=[...Array(o.numGuesses)].map(e=>Array(o.numAnswerBlocks[y]).fill(0)),D=[Array(o.colors.length).fill(0),Array(o.colors.length).fill(0)],x=[],G=[],T=-1,q=[],H=[],P=[],N=[];for(let e=0;e=0&&(x[T].classList.remove("avgBlockSelected"),T=-1)}function le(){if(I==o.numAnswerBlocks[y]){var e=new Hashids,t=[y,...F[0]],r=e.encode(t);document.getElementById("shareText").value="https://colorfle.com/puzzle?p="+r,We.style.display="block"}}function se(e,t){var o=2==A?finalPie:B;o.data.datasets[0].data=[50,50];var r=[Ie(e),t];o.data.datasets[0].backgroundColor=r,o.update()}function ne(){var e=[],t="rgb(211, 211, 211)";if(1==I)t=o.colors[F[E][0]];else if(2==I||3==I||4==I){t=Ie(Be(E))}e.push(t);for(let t=o.numAnswerBlocks[y]-1;t>=0;t--)t0&&E<6&&(I--,ne(),ae(),F[E][I]=-1,S[E][I].style.backgroundColor=1==n?"#878a8c":"#D3D3D3",S[E][I].removeAttribute("data-animation"))}function ce(e){if(0==A&&I255&&(t=255),(r=Math.round(r))>255&&(r=255),(a=Math.round(a))>255&&(a=255),ge({r:t,y:r,b:a})}function ye(e){var t=fe(e),o=Ce(e);return{r:(t.r+o.r)/2,g:(t.g+o.g)/2,b:(t.b+o.b)/2}}function fe(e){var t=0,r=0,a=0;for(let s=0;s255&&(t=255),(r=Math.round(r))>255&&(r=255),(a=Math.round(a))>255&&(a=255),ge({r:t,y:r,b:a})}function ke(e){var t=0,r=0,a=0;for(let l=0;l255&&(t=255),(r=Math.round(r))>255&&(r=255),(a=Math.round(a))>255&&(a=255),{r:t,g:r,b:a}}function Ce(e){var t=0,r=0,a=0;for(let s=0;s255&&(t=255),(r=Math.round(r))>255&&(r=255),(a=Math.round(a))>255&&(a=255),{r:t,g:r,b:a}}function ve(e){var t=Ee(e),o=Le(e);return{r:(t.r+o.r)/2,g:(t.g+o.g)/2,b:(t.b+o.b)/2}}function Be(e){var t=Me(e),o=we(e);return{r:(t.r+o.r)/2,g:(t.g+o.g)/2,b:(t.b+o.b)/2}}function we(e){var t=0,r=0,a=0,l=0;for(let s=0;s-1?",":" ";n=n.substr(4).split(")")[0].split(d);let c=+n[0],i=+n[1],u=+n[2];t+=c*o.colorWeight[y][s],r+=i*o.colorWeight[y][s],a+=u*o.colorWeight[y][s],l+=o.colorWeight[y][s]}return(t=Math.round(t/l))>255&&(t=255),(r=Math.round(r/l))>255&&(r=255),(a=Math.round(a/l))>255&&(a=255),{r:t,g:r,b:a}}function Me(e){var t=0,r=0,a=0,l=0;for(let n=0;n-1?",":" ";var s;d=d.substr(4).split(")")[0].split(c),(s={}).r=+d[0],s.g=+d[1],s.b=+d[2],ryb=ue(s),t+=ryb.r*o.colorWeight[y][n],r+=ryb.y*o.colorWeight[y][n],a+=ryb.b*o.colorWeight[y][n],l+=o.colorWeight[y][n]}return(t=Math.round(t/l))>255&&(t=255),(r=Math.round(r/l))>255&&(r=255),(a=Math.round(a/l))>255&&(a=255),s=ge({r:t,y:r,b:a})}function Le(e){var t=0,r=0,a=0;for(let l=0;l-1?",":" ";s=s.substr(4).split(")")[0].split(n);let d=+s[0],c=+s[1],i=+s[2];t+=d*o.colorWeight[y][l],r+=c*o.colorWeight[y][l],a+=i*o.colorWeight[y][l]}return(t=Math.round(t))>255&&(t=255),(r=Math.round(r))>255&&(r=255),(a=Math.round(a))>255&&(a=255),{r:t,g:r,b:a}}function Ee(e){var t=0,r=0,a=0;for(let s=0;s-1?",":" ";var l;n=n.substr(4).split(")")[0].split(d),(l={}).r=+n[0],l.g=+n[1],l.b=+n[2],ryb=ue(l),t+=ryb.r*o.colorWeight[y][s],r+=ryb.y*o.colorWeight[y][s],a+=ryb.b*o.colorWeight[y][s]}return(t=Math.round(t))>255&&(t=255),(r=Math.round(r))>255&&(r=255),(a=Math.round(a))>255&&(a=255),l=ge({r:t,y:r,b:a})}function Ie(e){return"rgb("+e.r+","+e.g+","+e.b+")"}document.addEventListener("keyup",(function(e){"Enter"===e.code&&le(),"Backspace"===e.code&&de()}));var Ae=document.getElementById("faqModal"),Se=document.getElementById("faq-button"),Fe=document.getElementById("faqClose"),We=document.getElementById("statsModal");Se.onclick=function(){Ae.style.display="block"},Fe.onclick=function(){Ae.style.display="none"};var De=document.getElementById("statsModalContent"),xe=document.getElementById("faqModalContent");Ae.addEventListener("touchstart",(function(e){xe.contains(e.target)||(Ae.style.display="none",e.stopPropagation(),e.preventDefault())})),We.addEventListener("touchstart",(function(e){De.contains(e.target)||(We.style.display="none",e.stopPropagation(),e.preventDefault())})),window.onclick=function(e){e.target==Ae&&(Ae.style.display="none"),e.target==We&&(We.style.display="none")};var Ge=document.getElementById("lightdark-button");(qe=document.getElementById("statsClose")).onclick=function(){We.style.display="none"},Ge.onclick=function(){1!=n?(n=1,localStorage.setItem(o.lsDarkMode,n),document.body.classList.add("dark-mode"),c.classList.remove("fa-moon"),c.classList.add("fa-sun"),g=o.graphBorderDark,B.data.datasets[0].borderColor=g,B.update()):(n=0,localStorage.setItem(o.lsDarkMode,n),document.body.classList.remove("dark-mode"),c.classList.remove("fa-sun"),c.classList.add("fa-moon"),g=o.graphBorderLight,B.data.datasets[0].borderColor=g,B.update())};var Te=document.getElementById("settingsModal"),qe=document.getElementById("statsClose");settingsClose.onclick=function(){Te.style.display="none"};var He=document.getElementById("shareButton");function Pe(){var e=(new Date).getTime(),t=countDownDate.getTime()-e,o=Math.floor(t%864e5/36e5),r=Math.floor(t%36e5/6e4),a=Math.floor(t%6e4/1e3);document.getElementById("timerTilNext").innerHTML=o+"h "+r+"m "+a+"s",0==o&&0==r&&0==a&&(clearInterval(countdownTimer),document.getElementById("timerTilNext").innerHTML="Available now!")}function Ne(){var e=new Hashids,t=[y,...F[0]],o=e.encode(t),r="I created a Colorfle puzzle! Try it at https://colorfle.com/puzzle?p="+o;navigator.clipboard.writeText(r);var a=document.getElementById("snackbar");a.className="show",setTimeout((function(){a.className=a.className.replace("show","")}),3e3),Re(o)}function Re(e){null!=window.writeGameShared&&window.writeGameShared(e)}He.onclick=Ne;var ze=document.getElementById("homeTitle");ze.onclick=function(){localStorage.setItem(o.lsContSession,1),window.location.href="/"};