import{a as e,o as t,r as n,t as r}from"./i18n-CjHYiQIU.js";import{n as i,r as a}from"./riddles-BL25uVdU.js";var o=t(),s=e();function c({completedIds:e,playedIds:t,bestResults:c,onPlay:l,onBack:u,goalHint:d}){let{language:f,strings:p}=r(),m=p.w4.riddleSelectionScreen,h=p.w4.common.difficulty,[g,_]=(0,o.useState)(`all`),[v,y]=(0,o.useState)(`all`),[b,x]=(0,o.useState)(`all`),[S,C]=(0,o.useState)(`difficulty`),w=(0,o.useMemo)(()=>i(f).filter(e=>g===`all`||e.metadata.difficulty===g).filter(n=>v===`all`||v===`solved`&&e.includes(n.id)||v===`unsolved`&&!e.includes(n.id)||v===`played`&&t.includes(n.id)||v===`unplayed`&&!t.includes(n.id)).filter(e=>b===`all`||b===`short`&&e.answer.length<=4||b===`mid`&&e.answer.length>=5&&e.answer.length<=8||b===`long`&&e.answer.length>=9).sort((n,r)=>S===`difficulty`||S===`order`?n.metadata.order-r.metadata.order:S===`length`?n.answer.length-r.answer.length||n.metadata.order-r.metadata.order:S===`title`?n.title.localeCompare(r.title,f):S===`last-played`?(c[r.id]?.completedAt??``).localeCompare(c[n.id]?.completedAt??``):S===`unplayed-first`?Number(t.includes(n.id))-Number(t.includes(r.id)):Number(e.includes(n.id))-Number(e.includes(r.id))),[c,e,g,f,b,t,S,v]);return(0,s.jsxs)(`main`,{className:`screen thorn-screen thorn-free-screen`,children:[(0,s.jsxs)(`header`,{className:`screen-heading archive-heading`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`p`,{className:`eyebrow`,children:m.eyebrow}),(0,s.jsx)(`h1`,{children:m.title})]}),(0,s.jsx)(`button`,{onClick:u,children:p.w4.common.back})]}),(0,s.jsx)(`p`,{className:`free-intro`,children:m.intro}),(0,s.jsxs)(`section`,{className:`filter-bar archive-filters`,"aria-label":m.filtersAriaLabel,children:[(0,s.jsxs)(`label`,{children:[m.difficultyLabel,(0,s.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),children:[(0,s.jsx)(`option`,{value:`all`,children:m.all}),a.map(e=>(0,s.jsx)(`option`,{value:e,children:h[e]},e))]})]}),(0,s.jsxs)(`label`,{children:[m.statusLabel,(0,s.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),children:[(0,s.jsx)(`option`,{value:`all`,children:m.all}),(0,s.jsx)(`option`,{value:`unsolved`,children:m.unsolved}),(0,s.jsx)(`option`,{value:`solved`,children:m.solved}),(0,s.jsx)(`option`,{value:`unplayed`,children:m.neverPlayed}),(0,s.jsx)(`option`,{value:`played`,children:m.played})]})]}),(0,s.jsxs)(`label`,{children:[m.answerLengthLabel,(0,s.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),children:[(0,s.jsx)(`option`,{value:`all`,children:m.all}),(0,s.jsx)(`option`,{value:`short`,children:m.short}),(0,s.jsx)(`option`,{value:`mid`,children:m.medium}),(0,s.jsx)(`option`,{value:`long`,children:m.long})]})]}),(0,s.jsxs)(`label`,{children:[m.sortLabel,(0,s.jsxs)(`select`,{value:S,onChange:e=>C(e.target.value),children:[(0,s.jsx)(`option`,{value:`difficulty`,children:m.sortDifficulty}),(0,s.jsx)(`option`,{value:`order`,children:m.collectionOrder}),(0,s.jsx)(`option`,{value:`length`,children:m.sortLength}),(0,s.jsx)(`option`,{value:`title`,children:m.sortTitle}),(0,s.jsx)(`option`,{value:`last-played`,children:m.lastPlayed}),(0,s.jsx)(`option`,{value:`unplayed-first`,children:m.neverPlayedFirst}),(0,s.jsx)(`option`,{value:`unsolved-first`,children:m.unsolvedFirst})]})]})]}),d&&(0,s.jsx)(`p`,{className:`archive-goal-hint`,children:d}),(0,s.jsx)(`p`,{className:`result-count`,children:n(m.matches,{count:w.length})}),(0,s.jsx)(`div`,{className:`riddle-grid archive-grid`,children:w.map(t=>{let r=e.includes(t.id);return(0,s.jsxs)(`button`,{className:`riddle-card archive-card${r?` solved`:``}`,onClick:()=>l(t.id),children:[(0,s.jsx)(`span`,{className:`card-number`,children:String(t.metadata.order).padStart(3,`0`)}),(0,s.jsx)(`span`,{className:`difficulty ${t.metadata.difficulty}`,children:h[t.metadata.difficulty]}),(0,s.jsx)(`strong`,{children:t.title}),(0,s.jsx)(`span`,{className:`archive-status`,children:r?m.solved:m.unsolved}),(0,s.jsx)(`small`,{children:c[t.id]?n(m.lettersWithBest,{length:t.answer.length,score:c[t.id].score}):n(m.letters,{length:t.answer.length})})]},t.id)})})]})}export{c as RiddleSelectionScreen};