import{S as xe,i as Ee,s as Pe,e as V,k as K,c as z,a as D,m as Z,d as b,b as p,g as W,J as w,K as Ae,L as ue,n as de,M as at,t as ee,h as te,N as ve,O as we,P as lt,Q as be,l as _e,j as pe,R as tt,T as ye,U as ot,V as rt,x as Re,y as Be,z as De,r as ne,p as ie,C as Ne,q as Se,f as me,W as st,w as it,X as ct,o as Ce}from"../chunks/index-ad2956d2.js";var ae=(l=>(l[l.INITIAL=0]="INITIAL",l.CORRECT="correct",l.PRESENT="present",l.ABSENT="absent",l))(ae||{});function ut(l,e){const r=[...l],t=r[e];for(const n of[...t].reverse())if(n.letter){n.letter="";break}return r}function ft(l,e,r){const t=[...l],n=t[e];for(const a of n)if(!a.letter){a.letter=r;break}return t}const Ue={[ae.CORRECT]:"#00b81a",[ae.PRESENT]:"#ffc80a",[ae.ABSENT]:"#d9d9d9",[ae.INITIAL]:"#5d5d5d"};function Ve(l,e,r){const t=l.slice();return t[4]=e[r],t[6]=r,t}function ze(l,e,r){const t=l.slice();return t[7]=e[r],t}function ht(l){let e,r=l[7]+"",t;return{c(){e=V("span"),t=ee(r)},l(n){e=z(n,"SPAN",{});var a=D(e);t=te(a,r),a.forEach(b)},m(n,a){W(n,e,a),w(e,t)},p:de,d(n){n&&b(e)}}}function mt(l){let e,r;return{c(){e=V("span"),r=ee("Space")},l(t){e=z(t,"SPAN",{});var n=D(e);r=te(n,"Space"),n.forEach(b)},m(t,n){W(t,e,n),w(e,r)},p:de,d(t){t&&b(e)}}}function dt(l){let e,r;return{c(){e=ve("svg"),r=ve("path"),this.h()},l(t){e=we(t,"svg",{xmlns:!0,height:!0,viewBox:!0,width:!0});var n=D(e);r=we(n,"path",{fill:!0,d:!0}),D(r).forEach(b),n.forEach(b),this.h()},h(){p(r,"fill","currentColor"),p(r,"d","M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z"),p(e,"xmlns","http://www.w3.org/2000/svg"),p(e,"height","24"),p(e,"viewBox","0 0 24 24"),p(e,"width","24")},m(t,n){W(t,e,n),w(e,r)},p:de,d(t){t&&b(e)}}}function Le(l){let e,r,t,n;function a(y,C){return y[7]==="Backspace"?dt:y[7]===" "?mt:ht}let u=a(l)(l);function m(){return l[3](l[7])}return{c(){e=V("button"),u.c(),this.h()},l(y){e=z(y,"BUTTON",{class:!0});var C=D(e);u.l(C),C.forEach(b),this.h()},h(){p(e,"class",r=l[0][l[7]]+" "+(l[7].length>1&&"big")+" svelte-1bl9l4p")},m(y,C){W(y,e,C),u.m(e,null),t||(n=Ae(e,"click",m),t=!0)},p(y,C){l=y,u.p(l,C),C&1&&r!==(r=l[0][l[7]]+" "+(l[7].length>1&&"big")+" svelte-1bl9l4p")&&p(e,"class",r)},d(y){y&&b(e),u.d(),t=!1,n()}}}function je(l){let e,r,t=l[4],n=[];for(let a=0;an("keyup",u);return l.$$set=u=>{"letterStates"in u&&r(0,t=u.letterStates)},[t,n,a,o]}class vt extends xe{constructor(e){super(),Ee(this,e,gt,pt,Pe,{letterStates:0})}}function ke(l,{delay:e=0,duration:r=400,easing:t=lt}={}){const n=+getComputedStyle(l).opacity;return{delay:e,duration:r,easing:t,css:a=>`opacity: ${a*n}`}}var nt={exports:{}};(function(l){(function(e){var r=J(),t=M(),n=Q(),a=L(),o={imagePlaceholder:void 0,cacheBust:!1},u={toSvg:m,toPng:C,toJpeg:T,toBlob:I,toPixelData:y,impl:{fontFaces:n,images:a,util:r,inliner:t,options:{}}};l.exports=u;function m(s,i){return i=i||{},X(i),Promise.resolve(s).then(function(c){return R(c,i.filter,!0)}).then(A).then(q).then(f).then(function(c){return j(c,i.width||r.width(s),i.height||r.height(s))});function f(c){return i.bgcolor&&(c.style.backgroundColor=i.bgcolor),i.width&&(c.style.width=i.width+"px"),i.height&&(c.style.height=i.height+"px"),i.style&&Object.keys(i.style).forEach(function(v){c.style[v]=i.style[v]}),c}}function y(s,i){return x(s,i||{}).then(function(f){return f.getContext("2d").getImageData(0,0,r.width(s),r.height(s)).data})}function C(s,i){return x(s,i||{}).then(function(f){return f.toDataURL()})}function T(s,i){return i=i||{},x(s,i).then(function(f){return f.toDataURL("image/jpeg",i.quality||1)})}function I(s,i){return x(s,i||{}).then(r.canvasToBlob)}function X(s){typeof s.imagePlaceholder=="undefined"?u.impl.options.imagePlaceholder=o.imagePlaceholder:u.impl.options.imagePlaceholder=s.imagePlaceholder,typeof s.cacheBust=="undefined"?u.impl.options.cacheBust=o.cacheBust:u.impl.options.cacheBust=s.cacheBust}function x(s,i){return m(s,i).then(r.makeImage).then(r.delay(100)).then(function(c){var v=f(s);return v.getContext("2d").drawImage(c,0,0),v});function f(c){var v=document.createElement("canvas");if(v.width=i.width||r.width(c),v.height=i.height||r.height(c),i.bgcolor){var E=v.getContext("2d");E.fillStyle=i.bgcolor,E.fillRect(0,0,v.width,v.height)}return v}}function R(s,i,f){if(!f&&i&&!i(s))return Promise.resolve();return Promise.resolve(s).then(c).then(function(g){return v(s,g,i)}).then(function(g){return E(s,g)});function c(g){return g instanceof HTMLCanvasElement?r.makeImage(g.toDataURL()):g.cloneNode(!1)}function v(g,k,N){var G=g.childNodes;if(G.length===0)return Promise.resolve(k);return S(k,r.asArray(G),N).then(function(){return k});function S(_,O,d){var H=Promise.resolve();return O.forEach(function(Y){H=H.then(function(){return R(Y,d)}).then(function($){$&&_.appendChild($)})}),H}}function E(g,k){if(!(k instanceof Element))return k;return Promise.resolve().then(N).then(G).then(S).then(_).then(function(){return k});function N(){O(window.getComputedStyle(g),k.style);function O(d,H){d.cssText?H.cssText=d.cssText:Y(d,H);function Y($,re){r.asArray($).forEach(function(h){re.setProperty(h,$.getPropertyValue(h),$.getPropertyPriority(h))})}}}function G(){[":before",":after"].forEach(function(d){O(d)});function O(d){var H=window.getComputedStyle(g,d),Y=H.getPropertyValue("content");if(Y===""||Y==="none")return;var $=r.uid();k.className=k.className+" "+$;var re=document.createElement("style");re.appendChild(h($,d,H)),k.appendChild(re);function h(P,U,B){var F="."+P+":"+U,le=B.cssText?Te(B):Ie(B);return document.createTextNode(F+"{"+le+"}");function Te(oe){var se=oe.getPropertyValue("content");return oe.cssText+" content: "+se+";"}function Ie(oe){return r.asArray(oe).map(se).join("; ")+";";function se(he){return he+": "+oe.getPropertyValue(he)+(oe.getPropertyPriority(he)?" !important":"")}}}}}function S(){g instanceof HTMLTextAreaElement&&(k.innerHTML=g.value),g instanceof HTMLInputElement&&k.setAttribute("value",g.value)}function _(){k instanceof SVGElement&&(k.setAttribute("xmlns","http://www.w3.org/2000/svg"),k instanceof SVGRectElement&&["width","height"].forEach(function(O){var d=k.getAttribute(O);!d||k.style.setProperty(O,d)}))}}}function A(s){return n.resolveAll().then(function(i){var f=document.createElement("style");return s.appendChild(f),f.appendChild(document.createTextNode(i)),s})}function q(s){return a.inlineAll(s).then(function(){return s})}function j(s,i,f){return Promise.resolve(s).then(function(c){return c.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(c)}).then(r.escapeXhtml).then(function(c){return''+c+""}).then(function(c){return''+c+""}).then(function(c){return"data:image/svg+xml;charset=utf-8,"+c})}function J(){return{escape:_,parseExtension:i,mimeType:f,dataAsUrl:S,isDataUrl:c,canvasToBlob:E,resolveUrl:g,getAndEncode:G,uid:k(),delay:O,asArray:d,escapeXhtml:H,makeImage:N,width:Y,height:$};function s(){var h="application/font-woff",P="image/jpeg";return{woff:h,woff2:h,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:P,jpeg:P,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}function i(h){var P=/\.([^\.\/]*?)$/g.exec(h);return P?P[1]:""}function f(h){var P=i(h).toLowerCase();return s()[P]||""}function c(h){return h.search(/^(data:)/)!==-1}function v(h){return new Promise(function(P){for(var U=window.atob(h.toDataURL().split(",")[1]),B=U.length,F=new Uint8Array(B),le=0;le{c||(c=ye(e,ke,{},!0)),c.run(1)}),v=!0)},o(_){c||(c=ye(e,ke,{},!1)),c.run(0),v=!1},d(_){_&&b(e),ue(N,_),ue(S,_),l[8](null),_&&c&&c.end(),E=!1,ot(g)}}}const ce=10,fe=1;function _t(l,e,r){let{message:t=null}=e,{board:n}=e,{currentRowIndex:a}=e,{imagePaths:o}=e,u,m=!1;async function y(x){try{await navigator.clipboard.write([new ClipboardItem({"image/png":wt.toBlob(x)})]),r(4,m=!0),setTimeout(()=>r(4,m=!1),1e3),console.log("Fetched image copied.")}catch(R){console.log(R.name,R.message)}}const C=ce/10;function T(x){rt[x?"unshift":"push"](()=>{u=x,r(3,u)})}const I=()=>y(u),X=()=>window.location.reload();return l.$$set=x=>{"message"in x&&r(0,t=x.message),"board"in x&&r(1,n=x.board),"currentRowIndex"in x&&r(7,a=x.currentRowIndex),"imagePaths"in x&&r(2,o=x.imagePaths)},[t,n,o,u,m,y,C,a,T,I,X]}class yt extends xe{constructor(e){super(),Ee(this,e,_t,bt,Pe,{message:0,board:1,currentRowIndex:7,imagePaths:2})}}function kt(l){let e,r,t,n;return{c(){e=V("div"),r=ee(l[0]),this.h()},l(a){e=z(a,"DIV",{class:!0});var o=D(e);r=te(o,l[0]),o.forEach(b),this.h()},h(){p(e,"class","message svelte-1upiv4")},m(a,o){W(a,e,o),w(e,r),n=!0},p(a,[o]){(!n||o&1)&&pe(r,a[0])},i(a){n||(tt(()=>{t||(t=ye(e,ke,{},!0)),t.run(1)}),n=!0)},o(a){t||(t=ye(e,ke,{},!1)),t.run(0),n=!1},d(a){a&&b(e),a&&t&&t.end()}}}function xt(l,e,r){let{message:t=null}=e;return l.$$set=n=>{"message"in n&&r(0,t=n.message)},[t]}class Et extends xe{constructor(e){super(),Ee(this,e,xt,kt,Pe,{message:0})}}function qe(l,e,r){const t=l.slice();return t[19]=e[r],t[21]=r,t}function We(l,e,r){const t=l.slice();return t[22]=e[r],t[21]=r,t}function Ye(l,e,r){const t=l.slice();return t[24]=e[r],t}function Ke(l){let e,r,t,n,a,o,u,m,y,C,T,I,X,x,R=l[5]&&Ze(l),A=l[6]&&l[8]&&Je(l),q=l[0],j=[];for(let s=0;sct(I,"letterStates",Q)),I.$on("keyup",l[11]),{c(){e=V("div"),R&&R.c(),r=K(),A&&A.c(),t=K(),n=V("header"),a=V("h1"),o=ee("WORDALLE"),u=K(),m=V("div");for(let s=0;s{R=null}),Se()),s[6]&&s[8]?A?(A.p(s,i),i&320&&ne(A,1)):(A=Je(s),A.c(),ne(A,1),A.m(e,t)):A&&(Ce(),ie(A,1,1,()=>{A=null}),Se()),i&1){q=s[0];let c;for(c=0;cX=!1)),I.$set(f)},i(s){x||(ne(R),ne(A),ne(I.$$.fragment,s),x=!0)},o(s){ie(R),ie(A),ie(I.$$.fragment,s),x=!1},d(s){s&&b(e),R&&R.d(),A&&A.d(),ue(j,s),ue(M,s),Ne(I)}}}function Ze(l){let e,r;return e=new Et({props:{message:l[5]}}),{c(){Re(e.$$.fragment)},l(t){Be(e.$$.fragment,t)},m(t,n){De(e,t,n),r=!0},p(t,n){const a={};n&32&&(a.message=t[5]),e.$set(a)},i(t){r||(ne(e.$$.fragment,t),r=!0)},o(t){ie(e.$$.fragment,t),r=!1},d(t){Ne(e,t)}}}function Je(l){let e,r;return e=new yt({props:{board:l[3],currentRowIndex:l[4],imagePaths:l[0],message:l[6]}}),{c(){Re(e.$$.fragment)},l(t){Be(e.$$.fragment,t)},m(t,n){De(e,t,n),r=!0},p(t,n){const a={};n&8&&(a.board=t[3]),n&16&&(a.currentRowIndex=t[4]),n&1&&(a.imagePaths=t[0]),n&64&&(a.message=t[6]),e.$set(a)},i(t){r||(ne(e.$$.fragment,t),r=!0)},o(t){ie(e.$$.fragment,t),r=!1},d(t){Ne(e,t)}}}function Qe(l){let e,r,t,n;return{c(){e=V("div"),r=V("img"),n=K(),this.h()},l(a){e=z(a,"DIV",{});var o=D(e);r=z(o,"IMG",{src:!0,alt:!0,class:!0}),n=Z(o),o.forEach(b),this.h()},h(){be(r.src,t=l[24])||p(r,"src",t),p(r,"alt",""),p(r,"class","w-full h-full")},m(a,o){W(a,e,o),w(e,r),w(e,n)},p(a,o){o&1&&!be(r.src,t=a[24])&&p(r,"src",t)},d(a){a&&b(e)}}}function $e(l){let e,r,t=l[22].letter+"",n,a,o,u=l[22].letter+"",m,y,C;return{c(){e=V("div"),r=V("div"),n=ee(t),a=K(),o=V("div"),m=ee(u),this.h()},l(T){e=z(T,"DIV",{class:!0});var I=D(e);r=z(I,"DIV",{class:!0,style:!0});var X=D(r);n=te(X,t),X.forEach(b),a=Z(I),o=z(I,"DIV",{class:!0,style:!0});var x=D(o);m=te(x,u),x.forEach(b),I.forEach(b),this.h()},h(){p(r,"class","front svelte-1ah7mm7"),me(r,"transition-delay",l[21]*l[1]+"ms"),p(o,"class",y="back "+l[22].state+" svelte-1ah7mm7"),me(o,"transition-delay",l[21]*l[1]+"ms"),me(o,"animation-delay",l[21]*100+"ms"),p(e,"class",C="tile "+(l[22].letter&&"filled")+" "+(l[22].state&&"revealed")+" svelte-1ah7mm7")},m(T,I){W(T,e,I),w(e,r),w(r,n),w(e,a),w(e,o),w(o,m)},p(T,I){I&8&&t!==(t=T[22].letter+"")&&pe(n,t),I&2&&me(r,"transition-delay",T[21]*T[1]+"ms"),I&8&&u!==(u=T[22].letter+"")&&pe(m,u),I&8&&y!==(y="back "+T[22].state+" svelte-1ah7mm7")&&p(o,"class",y),I&2&&me(o,"transition-delay",T[21]*T[1]+"ms"),I&8&&C!==(C="tile "+(T[22].letter&&"filled")+" "+(T[22].state&&"revealed")+" svelte-1ah7mm7")&&p(e,"class",C)},d(T){T&&b(e)}}}function et(l){let e,r,t,n=l[19],a=[];for(let o=0;o{t=null}),Se())},i(n){r||(ne(t),r=!0)},o(n){ie(t),r=!1},d(n){t&&t.d(n),n&&b(e)}}}const ge=1e3;function Tt(l,e,r){let t,n,a,o,u={},m,y=0,C="",T="",I=-1,X=!1,x=!0;it(async()=>{const L=await fetch("data").then(f=>f.json()),s=Object.keys(L),i=s[~~(Math.random()*s.length)];return t=i.replace(/_/g," "),r(0,n=L[i].slice(0,6)),console.log(t),a=i.length,r(1,o=ge/a),r(3,m=Array.from({length:6},()=>Array.from({length:a},()=>({letter:"",state:ae.INITIAL})))),window.addEventListener("keyup",R),document.body.style.setProperty("--cols",`${a}`),()=>window.removeEventListener("keyup",R)});const R=L=>{A(L.key)};function A(L){!x||(/^[a-zA-Z ]$/.test(L)?r(3,m=ft(m,y,L.toLowerCase())):L==="Backspace"?r(3,m=ut(m,y)):L==="Enter"&&q())}function q(){const L=[...m],s=L[y],i={};if(s.every(f=>f.letter)){s.map(c=>c.letter).join("");const f=t.split("");s.forEach((c,v)=>{f[v]===c.letter&&(c.state=i[c.letter]=ae.CORRECT,f[v]=null)}),s.forEach(c=>{!c.state&&f.includes(c.letter)&&(c.state=ae.PRESENT,f[f.indexOf(c.letter)]=null,i[c.letter]||(i[c.letter]=ae.PRESENT))}),s.forEach(c=>{c.state||(c.state=ae.ABSENT,i[c.letter]||(i[c.letter]=ae.ABSENT))}),x=!1,s.every(c=>c.state===ae.CORRECT)?setTimeout(()=>{r(6,T=["Genius","Magnificent","Impressive","Splendid","Great","Phew"][y]),r(8,X=!0)},ge):y{x=!0},ge)):setTimeout(()=>{j(t.toUpperCase(),-1)},ge)}else J(),j("Not enough letters");r(3,m=L),r(2,u=i)}function j(L,s=1e3){r(5,C=L),s>0&&setTimeout(()=>{r(5,C="")},s)}function J(){r(7,I=y),setTimeout(()=>{r(7,I=-1)},1e3)}function M(L){u=L,r(2,u)}return[n,o,u,m,y,C,T,I,X,A,M,({detail:L})=>A(L)]}class At extends xe{constructor(e){super(),Ee(this,e,Tt,Pt,Pe,{})}}export{At as default};