import{R as e,r as g}from"./index-56c1d501.js";import{c as $e}from"./clsx-e0889333.js";import{B as P,u as k,a as S,m as b,c as Pe,b as Ge,d as Ue,e as We,t as He,A as B,Q as Ye,P as Ve}from"./redux-thunk-93cdf4f0.js";import{a as re,g as ze}from"./ststistic-3f81b54e.js";import{F as G,q as Fe,a as q}from"./index-63998e7b.js";import{b as Xe}from"./index-01effd93.js";import{u as O}from"./use-sound.esm-86ef9aee.js";import{a as Ke,s as qe}from"./sadTrombone-a3e2bf79.js";import{c as Je}from"./correct-answer-tone-2b1e449a.js";import{s as Qe}from"./shake-and-roll-dice-soundbible-657c135f.js";import{u as Ze}from"./use-drag-controls-effae275.js";import{u as et}from"./use-animation-894d55ea.js";import{d as tt,p as at,a as lt,P as ot}from"./index-bdb71453.js";import"./fingerprint-374ab551.js";import{_ as nt}from"./preload-helper-f61836a9.js";import"./recaptcha-v3-f0e7cd4f.js";import"./index-f11686b8.js";const de="SET_SETTINGS",J="SET_GLOBAL_MODAL",ue="CLOSE_GLOBAL_MODAL",pe="START_NEW_GAME",fe="SET_GAME_STATE",ge="SELECT_DISC",be="PUT_DISC",ye="SET_RECORDED_TIME",xe="SET_ROLLING_RESULT",Q="SET_TURN",Ee="SET_GAME_WINNER",$="MODAL/COMPLETED",H="MODAL/MENU",Y="MODAL/SETTING",V="MODAL/HOW_TO_PLAY",z="MODAL/STATICS",he=document.getElementById("root").getAttribute("data-game-title").replaceAll("\\",""),we=document.getElementById("root").getAttribute("data-no-moves-available-next-player-will-play").replaceAll("\\",""),rt=document.getElementById("root").getAttribute("data-got-a-double-dices-redoubled").replaceAll("\\",""),st=document.getElementById("root").getAttribute("data-its-your-turn-please-roll-the-dice").replaceAll("\\",""),ct=document.getElementById("root").getAttribute("data-the-bot-will-go-first-please-roll-the-dice").replaceAll("\\",""),it=document.getElementById("root").getAttribute("data-you-win").replaceAll("\\",""),mt=document.getElementById("root").getAttribute("data-bot-win").replaceAll("\\",""),dt=document.getElementById("root").getAttribute("data-game-over").replaceAll("\\","");document.getElementById("root").getAttribute("data-time").replaceAll("\\","");const Z=document.getElementById("root").getAttribute("data-cancel").replaceAll("\\",""),ke=document.getElementById("root").getAttribute("data-new-game").replaceAll("\\",""),ut=document.getElementById("root").getAttribute("data-loading").replaceAll("\\",""),ve=document.getElementById("root").getAttribute("data-menu").replaceAll("\\",""),Ne=document.getElementById("root").getAttribute("data-options").replaceAll("\\",""),pt=document.getElementById("root").getAttribute("data-how-to-play").replaceAll("\\",""),Ae=document.getElementById("root").getAttribute("data-statics").replaceAll("\\",""),ft=document.getElementById("root").getAttribute("data-theme").replaceAll("\\","");document.getElementById("root").getAttribute("data-background").replaceAll("\\","");const gt=document.getElementById("root").getAttribute("data-sound").replaceAll("\\",""),bt=document.getElementById("root").getAttribute("data-total-played").replaceAll("\\",""),yt=document.getElementById("root").getAttribute("data-win-ratio").replaceAll("\\",""),xt=document.getElementById("root").getAttribute("data-win-streak").replaceAll("\\",""),Et=document.getElementById("root").getAttribute("data-highest-win-streak").replaceAll("\\",""),ht=document.getElementById("root").getAttribute("data-average-win-time").replaceAll("\\",""),wt=document.getElementById("root").getAttribute("data-fastest-win-time").replaceAll("\\",""),kt=document.getElementById("root").getAttribute("data-latest-win-time").replaceAll("\\",""),vt=document.getElementById("root").getAttribute("data-reset").replaceAll("\\",""),Se=document.getElementById("root").getAttribute("data-you").replaceAll("\\",""),ee=document.getElementById("root").getAttribute("data-bot").replaceAll("\\",""),Nt=document.getElementById("root").getAttribute("data-how-to-play-description").replaceAll("<game-title>",he).replaceAll("\\",""),At=document.getElementById("root").getAttribute("data-roll").replaceAll("\\",""),St=document.getElementById("root").getAttribute("data-notes").replaceAll("\\",""),_t=document.getElementById("root").getAttribute("data-are-you-sure-you-want-to-reset-stats").replaceAll("\\",""),Tt=document.getElementById("root").getAttribute("data-ok").replaceAll("\\","");document.documentElement.lang;const I={PLAYING:1,LOADING:2,THINKING:3,ENDED:4},X=["Easy","Medium","Hard","Expert"],It=[{label:ke,newGame:!0},{label:Ne,modalName:Y},{label:pt,modalName:V},{label:Ae,modalName:z}],Lt=(t=!1)=>{const a=new Date().toLocaleDateString();let l=localStorage.getItem("backgammon-browserVisitId");return(t||!(localStorage.getItem("backgammon-currentDate")===a&&l))&&(localStorage.removeItem("persist:"+localStorage.getItem("backgammon-browserVisitId")),l=Math.random().toString(36).substr(2,9),localStorage.setItem("backgammon-currentDate",a),localStorage.setItem("backgammon-browserVisitId",l)),l},C=t=>JSON.parse(JSON.stringify(t)),W=t=>{const a=Math.floor(t/3600),l=Math.floor(t%3600/60),o=t%60,r=`${l.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`;return a===0?r:`${a.toString().padStart(2,"0")}:${r}`},jt=t=>{const a=new Date(t);return W(Math.floor((new Date().getTime()-a.getTime())/1e3))},_e=(t,a)=>{const{left:l,right:o,top:r,bottom:s}=a.current.getBoundingClientRect();return t.clientX>=l&&t.clientX<=o&&t.clientY>=r&&t.clientY<=s},K={played:0,completed:[],failed:0,streak:0,maxStreak:0},Te=(t,a,l)=>{const o=Ie();o.played+=t,o.completed.push(...a),o.failed+=l,l===0?(o.streak+=1,o.maxStreak=Math.max(o.maxStreak,o.streak)):o.streak=0,localStorage.setItem("backgammon-state","Completed"),localStorage.setItem("backgammon-stats",JSON.stringify(o))},Ie=()=>{const t=localStorage.getItem("backgammon-stats");return t?JSON.parse(t):K},Ct=()=>(localStorage.setItem("backgammon-stats",JSON.stringify(K)),K),Mt=({playedTime:t,difficulty:a})=>{Te(1,[{playedTime:t,difficulty:a}],0)},Rt=()=>{Te(1,[],1)},R=15,y=1,N=2,Le=()=>{const t=[23,23,12,12,12,12,12,7,7,7,5,5,5,5,5];return Array.from({length:R*2},(a,l)=>{const o=l<R,r=o?t[l%R]:23-t[l%R];return{owner:o?y:N,index:o?`B${l}`:`W${l-R}`,position:r,dragable:!1}})},te=(t,a=y,l)=>{const o=[];for(let r=t.length-1;r>=0;r--)t[r].owner===a?a===y&&t[r].position===-1||a===N&&t[r].position===24||o.includes(t[r].position)?t[r].dragable=!1:(je(t,t[r],l).length>0?t[r].dragable=!0:t[r].dragable=!1,o.push(t[r].position)):t[r].dragable=!1},je=(t,a,l)=>{if(a&&l.length>0){const{position:o}=a,r=a.owner===y;if(Me(t,a.owner)&&(r?o!==24:o!==-1))return[];const s=new Map;t.filter(m=>m.owner!==a.owner).forEach(m=>{const u=m.position;s.has(u)?s.set(u,s.get(u)+1):s.set(u,1)});const c=[...s.keys()].filter(m=>s.get(m)>1);Ce(t,a.owner)===!1&&c.push(r?-1:24);const i=t.filter(({owner:m})=>m===a.owner).map(({position:m})=>m);i.sort((m,u)=>a.owner===y?u-m:m-u);const p=a.position===i[0],f=new Set,d=(m,u=0,x=[])=>{for(let w=0;w<m.length;w++){if(x.includes(w))continue;const v=u+m[w];let E=r?o-v:o+v;p&&(E=r?Math.max(E,-1):Math.min(E,24)),E>=-1&&E<=24&&(f.add(E),c.includes(E)||d(m,v,[...x,w]))}};return d(l),f.size===0?[]:[...f].filter(m=>!c.includes(m))}return[]},Ce=(t,a)=>{const l=a===y;return t.filter(o=>o.owner===a&&(l?o.position>5:o.position<18)).length===0},Me=(t,a)=>{const l=a===y;return t.filter(o=>o.owner===a&&(l?o.position===24:o.position===-1)).length>0},ae=(t,a)=>t.filter(l=>l.owner===a&&l.dragable).length===0,Dt=(t,a)=>t.filter(l=>l.owner===a&&(a===y?l.position<=-1:l.position>=24)).length===R,Bt=(t,a=[])=>{const l=Ot(t,a),o=Math.max(...l.map(({score:s})=>s)),r=l.filter(s=>s.score===o);return r.length>0?r[Math.floor(Math.random()*r.length)].history:[]},Ot=(t,a=[])=>{const l=[];function o(r,s=[],c,n=0){const i=C(r);if(te(i,N,a),ae(i,N)||s.length===0){const p=$t(i,n);l.push({history:c.reverse(),score:p})}else{const p=new Map;i.filter(m=>m.owner===y).forEach(m=>{const u=m.position;p.has(u)?p.set(u,p.get(u)+1):p.set(u,1)});const f=[...p.keys()].filter(m=>p.get(m)>1);Ce(i,N)===!1&&f.push(24);const d=Me(i,N);i.filter(({dragable:m})=>m).forEach(m=>{(d&&m.position===-1||!d||m.position<24)&&s.forEach((u,x,w)=>{const v=Math.min(m.position+u,24);if(f.includes(v)===!1){const E=C(r.filter(({index:h})=>h!==m.index)),A=C(r.find(({index:h})=>h===m.index));A.position=v,E.push(A);let T=n;E.forEach((h,L)=>{h.position===v&&h.owner===y&&(E[L].position=-1,T++)}),o(E,w.filter((h,L)=>L!==x),[...c,C({item:m,step:u})],T)}})})}}return o(t,a,[]),l},M={blockades:1.3,blots:1.4,bar:{me:1.3,opponent:1.3},chambers:[1.1,1.3,1.5,1.7,3],kickEnemy:1.5},$t=(t,a=0)=>{let l=0,o=0,r=0;const s=new Map;t.filter(i=>i.owner===N).forEach(i=>{const p=i.position;s.has(p)?s.set(p,s.get(p)+1):s.set(p,1)}),s.forEach((i,p)=>{i===1?o++:i>1&&(l+=1,r=M.chambers[Math.floor(p/6)],l*=r)});let c=t.filter(({owner:i,position:p})=>i===y&&p===24).length*M.bar.opponent-t.filter(({owner:i,position:p})=>i===N&&p===-1).length*M.bar.me;return 200-t.filter(({owner:i,position:p})=>i===N&&p!==-1).reduce((i,p)=>i+p.position,0)+c+l*M.blockades-o*M.blots+a*M.kickEnemy},le=(t=X[0])=>a=>{a({type:fe,payload:I.LOADING});const l=[y,N][Math.floor(Math.random()*2)];return l===y?P.info(st):l===N&&P.info(ct),new Promise(async(o,r)=>{try{a({type:pe,payload:{difficulty:t,turn:l}}),localStorage.setItem("backgammon-state","Running"),o()}catch(s){r(s)}})},Pt=()=>t=>{t({type:ye})},se=t=>a=>{a({type:ge,payload:t})},oe=(t,a=null,l=null)=>(o,r)=>{const{table:s,turn:c,rollingResult:n,status:i,created:p}=r().backgammon;if(a=a===null?r().backgammon.selected:a,a){if(i===I.ENDED)return;const f=c===y?a.position-t:t-a.position,d=C(s.filter(({index:w})=>w!==a.index)),m=C(s.find(({index:w})=>w===a.index));m.position=t,d.push(m),d.forEach((w,v)=>{w.position===t&&w.owner!==a.owner&&(d[v].position=a.owner===y?-1:24)});let u=c,x=n;if(Dt(d,c))c===1?re("backgammon","success",p.getTime()):c===2&&re("backgammon","fail",p.getTime()),o({type:Ee,payload:{winner:c}}),o({type:J,payload:!0,name:$});else{const w=Ut(n,f),v=[];w.forEach(E=>{const A=n.findIndex((T,h)=>E===T&&!v.includes(h));v.push(A)}),x=n.filter((E,A)=>!v.includes(A)),te(d,c,x),x.length===0?u=u===y?N:y:ae(d,c)&&(P.info(we),u=u===y?N:y,setTimeout(()=>{o({type:Q,payload:u})},2e3))}o({type:be,newTable:d,turn:u,rollingResult:x}),l()}},Gt=(t,a)=>(l,o)=>{const{table:r,turn:s}=o().backgammon,c=C(r);te(c,s,t),l({type:xe,payload:t,newTable:c});let n=s;if(ae(c,s)&&(P.info(we),n=n===y?N:y,setTimeout(()=>{l({type:Q,payload:n})},2e3)),s===N){const i=Bt(c,t),p=setInterval(()=>{const f=i.pop();f?oe(f.item.position+f.step,f.item,f.item.position+f.step>=24?a.correctAnswerSound:a.flipDiscSound)(l,o):clearInterval(p)},1e3)}},Ut=(t,a)=>{let l=[];const o=[];function r(s,c,n){n===a?l=[...c]:n>a&&o.push([...c]);for(let i=s;i<t.length;i++)c.push(t[i]),r(i+1,c,n+t[i]),c.pop()}return r(0,[],0),l.length>0?l:o.length>0?(o.sort((s,c)=>s.length-c.length),o[0]):[]},ce=({text:t=ee,playing:a=!0})=>{const{boardType:l}=k(({user:r})=>r.settings),o=[["white-pulse text-white bg-majky-600","bg-gray-200 text-majky-600 shadow-black/50"],["white-pulse text-white bg-red-600/70","bg-red-600/40 text-white shadow-black/50"],["white-pulse text-white bg-red-600/70","bg-red-600/40 text-white shadow-black/50"]][l];return e.createElement("div",{className:`flex w-full flex-auto flex-col items-center justify-center rounded-xl text-center text-lg font-medium shadow-inner md:text-xl ${a?o[0]:o[1]}`},e.createElement(G,{icon:Xe}),e.createElement("span",{className:"block"},t))},Wt="/build/assets/woosh-mark-diangelo-f5513727.mp3",Re=g.createContext(),U=()=>g.useContext(Re),Ht=({children:t})=>{const a=k(({user:n})=>n.settings.playSound),[l]=O(Ke,{soundEnabled:a,html5:!0}),[o]=O(qe,{soundEnabled:a,html5:!0}),[r]=O(Je,{soundEnabled:a,html5:!0}),[s]=O(Wt,{soundEnabled:a,html5:!0}),[c]=O(Qe,{soundEnabled:a,html5:!0});return e.createElement(Re.Provider,{value:{applauseSound:l,sadTromboneSound:o,correctAnswerSound:r,shakeNRollDiceSound:c,flipDiscSound:s}},t)},Yt=({data:t})=>{const a=Ze(),l=et(),o=g.useRef(),r=S(),{selected:s,status:c,turn:n}=k(({backgammon:u})=>u),{flipDiscSound:i}=U();function p(u){if(c===I.PLAYING&&n===y){if(s)return null;if(!t.dragable)return l.start({x:[-8,8,-5,5,-3,3,0],transition:{duration:.5}});l.start({scale:1.1}),a.start(u),i(),r(se(t))}}const f=()=>{c===I.PLAYING&&o.current&&l.start({type:"onDragEnd",x:0,y:0,scale:1})},{boardType:d}=k(({user:u})=>u.settings),m=[["bg-black","bg-white"],["bg-black","bg-white"],["bg-black","bg-white"]][d];return e.createElement(b.div,{ref:o,key:`stone-${t.index}`,layoutId:`stone-${t.index}`,className:`relative h-6 shadow shadow-black max-xs:h-4 md:h-8 md:w-8 min-[1180px]:h-6 min-[1180px]:w-6 min-[1450px]:h-11 min-[1450px]:w-11
        ${(t.owner===y?t.position>-1:t.position<24)?"aspect-square rounded-full":"aspect-[1/3] rounded-none lg:aspect-[3/1]"}
        ${t.owner===y?m[0]:m[1]} 
        ${s===null?t.dragable&&"!bg-blue-400":t.index===s.index&&"!bg-green-400"}`,animate:l,drag:!0,dragControls:a,onPointerDown:p,onPointerUp:f,onDragEnd:f,dragListener:!1,onAnimationComplete:u=>{u.type==="onDragEnd"&&r(se(null))},whileTap:{cursor:"grabbing"}})},F=g.memo(Yt),ie=({className:t})=>e.createElement("svg",{className:t,viewBox:"0 0 100 100",preserveAspectRatio:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("polygon",{points:"50,0 100,100 0,100"})),Vt=({index:t,isPutable:a=!1})=>{const{table:l,selected:o}=k(({backgammon:d})=>d),{flipDiscSound:r}=U(),s=S(),[c,n]=g.useState(!1),i=g.useRef();g.useEffect(()=>{const d=m=>{i.current&&n(_e(m,i))};return a&&o?document.addEventListener("pointermove",d):n(!1),()=>{document.removeEventListener("pointermove",d)}},[o,a]),g.useEffect(()=>{const d=()=>{c&&s(oe(t,null,r))};return document.addEventListener("pointerup",d),()=>{document.removeEventListener("pointerup",d)}},[c]);const{boardType:p}=k(({user:d})=>d.settings),f=[["fill-majky-600","fill-white"],["fill-yellow-600/80","fill-red-600/40"],["fill-red-600/80","fill-red-600/40"]][p];return e.createElement("div",{ref:i,className:"relative flex flex-col items-center justify-center"},e.createElement(ie,{className:`absolute h-full w-6 stroke-gray-400 max-xs:w-4 md:w-12 min-[1180px]:w-10 min-[1450px]:w-12 ${f[t%2]}  ${t>11?"top-0 -scale-y-100":"bottom-0"}`}),a&&e.createElement(ie,{className:`absolute z-20 h-full w-6 stroke-2 ${c?"fill-green-400/80 stroke-green-400":"fill-blue-400/80 stroke-blue-400"} max-xs:w-4 md:w-14  ${t>11?"top-0 -scale-y-100":"bottom-0"}`}),l.filter(({position:d})=>d===t).map((d,m)=>e.createElement("div",{key:`disc-${d.index}`,className:"absolute z-30",style:t>11?{top:`${m%5*18+Math.floor(m/5)%2*8}%`}:{bottom:`${m%5*18+Math.floor(m/5)%2*8}%`}},e.createElement(F,{data:d}))))},zt=()=>{const t=S(),{rollingResult:a,turn:l,status:o,created:r}=k(({backgammon:h})=>h),{shakeNRollDiceSound:s,flipDiscSound:c,correctAnswerSound:n}=U(),i=l===y?0:1,[p,f]=g.useState(0),[d,m]=g.useState([1,1]),[u,x]=g.useState(!1);g.useEffect(()=>{u&&ze("backgammon",r.getTime())},[u]);const w=()=>{if(o===I.PLAYING){f(Oe=>Oe+1);const h=d.map(()=>Math.floor(Math.random()*6)+1);m(h);const L=h[0]===h[1]?[...h,...h]:h;h[0]===h[1]&&P.info(rt),s(),setTimeout(()=>{t(Gt(L,{flipDiscSound:c,correctAnswerSound:n}))},1e3)}};g.useEffect(()=>{l===N&&setTimeout(()=>{w()},1e3)},[l]);const{boardType:v}=k(({user:h})=>h.settings),E=[["border-gray-100 bg-white","border-red-400 bg-red-600"],["border-gray-100 bg-gray-200","border-gray-900 bg-gray-900"],["border-gray-100 bg-gray-200","border-red-400 bg-red-600"]][v],A=[[["red","black"],["white","white"]],[["red","black"],["white","white"]],[["red","black"],["white","white"]]][v],T=["bg-majky-600 text-white","bg-yellow-500/50 text-red-600","bg-red-500/50 text-red-600"][v];return e.createElement("div",{className:"flex h-20 min-[1180px]:h-32 min-[1350px]:h-20 select-none flex-col items-center justify-center md:flex-row min-[1180px]:flex-col min-[1350px]:flex-row"},e.createElement("div",{className:"flex select-none items-center justify-center","data-roll-count-mod5":p%5},d.map((h,L)=>e.createElement("div",{className:"diePad p-2",key:L},e.createElement("div",{className:"die relative aspect-square h-6 transition-transform duration-1000 ease-in-out md:h-16","data-result":h,style:{transformStyle:"preserve-3d"}},e.createElement("div",{className:`face-1 absolute h-full w-full border ${E[i]}`},e.createElement("svg",{fill:`${A[i][0]}`,viewBox:"0 0 4 4"},e.createElement("circle",{r:"0.6",cx:"2",cy:"2"}))),e.createElement("div",{className:`face-2 absolute h-full w-full border ${E[i]}`},e.createElement("svg",{fill:`${A[i][1]}`,viewBox:"0 0 4 4"},e.createElement("circle",{r:"0.4",cx:"3",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"1",cy:"3"}))),e.createElement("div",{className:`face-3 absolute h-full w-full border ${E[i]}`},e.createElement("svg",{fill:`${A[i][1]}`,viewBox:"0 0 4 4"},e.createElement("circle",{r:"0.4",cx:"3",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"2",cy:"2"}),e.createElement("circle",{r:"0.4",cx:"1",cy:"3"}))),e.createElement("div",{className:`face-4 absolute h-full w-full border ${E[i]}`},e.createElement("svg",{fill:`${A[i][1]}`,viewBox:"0 0 4 4"},e.createElement("circle",{r:"0.4",cx:"1",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"1",cy:"3"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"3"}))),e.createElement("div",{className:`face-5 absolute h-full w-full border ${E[i]}`},e.createElement("svg",{fill:`${A[i][1]}`,viewBox:"0 0 4 4"},e.createElement("circle",{r:"0.4",cx:"1",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"2",cy:"2"}),e.createElement("circle",{r:"0.4",cx:"1",cy:"3"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"3"}))),e.createElement("div",{className:`face-6 absolute h-full w-full border ${E[i]}`},e.createElement("svg",{fill:`${A[i][1]}`,viewBox:"0 0 4 4"},e.createElement("circle",{r:"0.4",cx:"1",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"1"}),e.createElement("circle",{r:"0.4",cx:"1",cy:"2"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"2"}),e.createElement("circle",{r:"0.4",cx:"1",cy:"3"}),e.createElement("circle",{r:"0.4",cx:"3",cy:"3"}))))))),e.createElement(b.div,{onClick:()=>{w(),x(!0)},className:`flex h-12 items-center justify-center rounded-full px-4 text-sm sm:text-lg lg:text-xs font-medium shadow shadow-black transition-opacity md:h-16 2xl:text-md ${T} ${a.length===0&&l===y?"opacity-100":"pointer-events-none opacity-0"}`,whileTap:{scale:.9}},e.createElement("div",{className:"flex flex-col items-center justify-center"},At,e.createElement("div",{className:"text-xs"}," ",[`(${Se})`,`(${ee})`][i])),e.createElement("img",{className:"pointer-events-none ml-1 h-8 lg:h-6 select-none object-contain 2xl:h-10",src:new URL("/build/assets/logo.png",self.location).href,alt:"logo"})))},me=({isPlayerBox:t=!1,isPutable:a=!1})=>{const{table:l,selected:o}=k(({backgammon:d})=>d),{correctAnswerSound:r}=U(),s=S(),[c,n]=g.useState(!1),i=g.useRef();g.useEffect(()=>{const d=m=>{i.current&&n(_e(m,i))};return o?document.addEventListener("pointermove",d):n(!1),()=>{document.removeEventListener("pointermove",d)}},[o]),g.useEffect(()=>{const d=()=>{c&&s(oe(t?-1:24,null,r))};return document.addEventListener("pointerup",d),()=>{document.removeEventListener("pointerup",d)}},[c,s,t]);const{boardType:p}=k(({user:d})=>d.settings),f=["bg-gray-200","bg-red-600/40","bg-red-600/40"][p];return e.createElement("div",{ref:i,className:`flex flex-1 items-center justify-start space-x-0.5 rounded-xl p-2 shadow-inner shadow-black/50 lg:flex-col lg:space-y-0.5  ${a?c?"bg-green-400":"bg-blue-400":f}`},l.filter(({owner:d,position:m})=>t?d===y&&m<=-1:d===N&&m>=24).map(d=>e.createElement(F,{data:d,key:`disc-${d.index}`})))},Ft=()=>{const{table:t}=k(({backgammon:a})=>a);return e.createElement("div",{className:"flex w-6 flex-col space-y-4 bg-white/30 max-xs:w-4 md:w-11"},e.createElement("div",{className:"relative flex-auto"},t.filter(({owner:a,position:l})=>a===y&&l>=24).map((a,l)=>e.createElement("div",{className:"absolute z-20",style:{top:`${5+l*5}%`},key:`disc-${a.index}`},e.createElement(F,{data:a})))),e.createElement("div",{className:"relative flex-auto"},t.filter(({owner:a,position:l})=>a===N&&l<=-1).map((a,l)=>e.createElement("div",{className:"absolute z-20",style:{bottom:`${5+l*5}%`},key:`disc-${a.index}`},e.createElement(F,{data:a})))))},Xt=()=>{const{turn:t,table:a,selected:l,rollingResult:o}=k(({backgammon:f})=>f),r=S();g.useEffect(()=>{r(le())},[r]);const s=je(a,l,o),c=(f,d,m=!1)=>Array.from({length:d},(x,w)=>f+(m?-w:w)).map(x=>e.createElement(Vt,{key:`column-${x}`,index:x,isPutable:s.includes(x)})),{boardType:n}=k(({user:f})=>f.settings),i=["bg-gray-800","bg-yellow-200","bg-gray-200"][n],p=["bg-gray-200 shadow-gray-600","bg-yellow-100 shadow-yellow-600","bg-gray-100 shadow-gray-600"][n];return e.createElement(b.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`relative my-4 flex h-full w-full flex-1  touch-none select-none gap-2 rounded-xl p-2 shadow-lg shadow-black max-lg:flex-col lg:flex-row lg:p-4 ${i}`},e.createElement("div",{className:"flex justify-between max-lg:min-h-12 max-lg:flex-row max-lg:space-x-4 lg:basis-1/12 lg:flex-col lg:space-y-4"},e.createElement(ce,{text:Se,playing:t===y}),e.createElement(ce,{text:ee,playing:t===N,isRight:!0})),e.createElement("div",{className:`flex grow justify-between space-x-1 rounded-xl  ${i}`},e.createElement("div",{className:`flex flex-1 flex-col space-y-2 border p-0.5 shadow-inner ${p}`},e.createElement("div",{className:"grid flex-1 grid-cols-6 rounded-xl"},c(12,6)),e.createElement("div",{className:"h-20 min-[1180px]:h-32 min-[1350px]:h-20"}),e.createElement("div",{className:"grid flex-1 grid-cols-6 rounded-xl"},c(11,6,!0))),e.createElement(Ft,null),e.createElement("div",{className:`flex flex-1 flex-col space-y-2 border p-0.5 shadow-inner ${p}`},e.createElement("div",{className:"grid flex-1 grid-cols-6 rounded-xl"},c(18,6)),e.createElement(zt,null),e.createElement("div",{className:"grid flex-1 grid-cols-6 rounded-xl"},c(5,6,!0)))),e.createElement("div",{className:"flex justify-between max-lg:min-h-12 max-lg:flex-row max-lg:space-x-4 lg:basis-1/12 lg:flex-col lg:space-y-4"},e.createElement(me,{isPutable:s.includes(24)}),e.createElement(me,{isPlayerBox:!0,isPutable:s.includes(-1)})))},ne=()=>{const[t,a]=g.useState(localStorage.getItem("backgammon-theme")||"light"),l=t==="dark"?"light":"dark";return g.useEffect(()=>{const o=window.document.documentElement;o.classList.remove(l),o.classList.add(t),localStorage.setItem("backgammon-theme",t)},[t,l]),[t,a]},Kt={settings:{boardType:0,playSound:!1,autoMove:!0,language:"en"},modals:{[Y]:!1,[V]:!1,[z]:!1,[$]:!1,[H]:!1},rules:[],solvingTime:0},qt=(t=Kt,a)=>{switch(a.type){case de:return{...t,settings:{...t.settings,...a.payload}};case J:return{...t,modals:{...t.modals,[a.name]:a.payload}};case ue:return{...t,modals:{...t.modals,[a.name]:a.payload}};default:return t}},Jt={difficulty:X[2],created:new Date,recordedTime:null,status:I.LOADING,winner:0,table:Le(),turn:y,rollingResult:[],selected:null,putableColumns:[]},Qt=(t=Jt,a)=>{switch(a.type){case pe:return{...t,created:new Date,recordedTime:null,status:I.PLAYING,winner:0,table:Le(),rollingResult:[],selected:null,putableColumns:[],...a.payload};case fe:return{...t,status:a.payload};case ge:return{...t,selected:a.payload};case be:return{...t,turn:a.turn,table:a.newTable,rollingResult:a.rollingResult,selected:null};case xe:return{...t,rollingResult:a.payload,table:a.newTable};case Q:return{...t,rollingResult:[],turn:a.payload};case ye:return{...t,recordedTime:jt(t.created)};case Ee:return{...t,winner:a.payload.winner,status:I.ENDED};default:return t}},Zt=Pe({user:qt,backgammon:Qt}),ea={key:Lt(!1),storage:tt},ta=at(ea,Zt),aa=We,De=Ge(ta,aa(Ue(He))),la=lt(De);const oa=()=>e.createElement(b.div,{className:"dark:text-slate fixed left-0 top-0 flex h-screen w-screen items-center justify-center dark:bg-slate-900",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},e.createElement(b.div,{className:"grid grid-cols-2 gap-2",style:{transform:"rotate(var(--rotate))"},initial:{"--rotate":"0deg"},animate:{"--rotate":"360deg"},transition:{duration:2,repeat:1/0,ease:"linear"}},Array.from({length:4},(t,a)=>e.createElement(b.div,{key:a,className:`aspect-square w-16 rounded-full shadow ${["bg-red-600","bg-blue-600","bg-blue-600","bg-red-600"][a]}`,style:{transform:"rotate(calc(-1 * var(--rotate)))"}})))),_=({className:t="",disabled:a=!1,children:l,onClick:o=()=>{}})=>{const[r,s]=g.useState([]),c=g.useRef(null);return g.useEffect(()=>{const n=p=>{const f=c.current,{left:d,top:m}=f.getBoundingClientRect(),u=p.clientX-d,x=p.clientY-m,v=Math.max(f.clientWidth,f.clientHeight)*2/2,E={x:u,y:x,radius:v,id:Date.now()};s(A=>[...A,E]),setTimeout(()=>{s(A=>A.filter(T=>T.id!==E.id))},1e3)},i=c.current;return i.addEventListener("click",n),()=>{i.removeEventListener("click",n)}},[s]),e.createElement(b.button,{ref:c,layout:!0,type:"button",className:`relative overflow-hidden shadow ${t} !outline-none ${a&&"!pointer-events-none"}`,disabled:a,onClick:o,whileHover:{scale:a?1:1.05},whileTap:{scale:a?1:.95}},l,r.map(n=>e.createElement("span",{key:n.id,className:"ripple",style:{left:n.x-n.radius+"px",top:n.y-n.radius+"px",width:n.radius*2+"px",height:n.radius*2+"px"}})))},na=t=>a=>{a({type:de,payload:t})},Be=(t,a)=>l=>{l({type:J,name:t,payload:a})},D=t=>a=>{a({type:ue,name:t,payload:null})},ra=()=>{const t=S();return e.createElement("header",{className:"flex h-16 w-full items-center justify-between border-b-2 border-slate-200 px-3 dark:border-slate-400 max-xs:h-8"},e.createElement("div",{className:"ml-0 md:ml-4"},e.createElement("h1",{className:"flex flex-auto select-none items-center space-x-0 text-2xl font-bold md:space-x-4 md:text-3xl"},e.createElement("img",{className:"mr-1 aspect-square h-12 object-contain",src:new URL("/build/assets/logo.png",self.location).href,alt:"logo"}),e.createElement("span",{className:"text-majky-600 dark:text-majky-400"},he))),e.createElement("div",{className:"relative"},e.createElement(_,{className:"rounded border border-majky-600 bg-majky-600 px-3 py-2 text-white shadow shadow-white dark:bg-slate-900/50 dark:text-majky-400 max-xs:px-1 max-xs:py-0.5",onClick:()=>{t(Be(H,!0))}},e.createElement(G,{icon:Fe}),e.createElement("div",{className:"hidden md:pl-2 lg:inline-block"},ve))))},sa="/build/assets/board-0-5d83885f.webp",ca="/build/assets/board-1-c496278e.webp",ia="/build/assets/board-2-a2fcf50b.webp",ma=({id:t,checked:a,onChange:l})=>e.createElement("div",{className:"inline-flex items-center"},e.createElement("div",{className:"relative inline-block h-4 w-8 cursor-pointer rounded-full border dark:border-majky-400"},e.createElement("input",{id:t,type:"checkbox",className:"peer absolute left-0 top-0 h-4 w-8 cursor-pointer appearance-none rounded-full bg-majky-100 transition-colors duration-300 checked:bg-majky-500 peer-checked:border-majky-500 peer-checked:before:bg-majky-500 dark:bg-majky-800 dark:checked:bg-majky-300 dark:peer-checked:border-majky-300 dark:peer-checked:before:bg-majky-300",checked:a,onChange:l}),e.createElement("label",{htmlFor:t,className:"before:content[''] before:bg-blue-slate-500 absolute -left-1  top-2/4 h-5 w-5 -translate-y-2/4 cursor-pointer rounded-full border border-majky-100 bg-white shadow-md transition-all duration-300 before:absolute before:left-2/4 before:top-2/4 before:block before:h-10 before:w-10 before:-translate-x-2/4 before:-translate-y-2/4 before:rounded-full before:opacity-0 before:transition-opacity hover:before:opacity-10 peer-checked:translate-x-full peer-checked:border-majky-500 peer-checked:before:bg-majky-500 dark:border-majky-400"},e.createElement("div",{className:"left-2/4 top-2/4 inline-block -translate-x-2/4 -translate-y-2/4 rounded-full p-5","data-ripple-dark":"true"})))),da=()=>{const t=k(({user:s})=>{var c;return((c=s==null?void 0:s.modals)==null?void 0:c[Y])||null}),a=S(),{settings:l}=k(({user:s})=>s),o=(s,c)=>{a(na({[s]:c}))},r=()=>{a(D(Y))};return ne(),e.createElement(B,null,t&&e.createElement(b.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-50 flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:r},e.createElement(b.div,{className:"relative max-h-full w-full overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-900/80 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-screen-md",onClick:s=>{s.stopPropagation()}},e.createElement(G,{className:"absolute left-4 top-4 h-6 w-6 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:r,icon:q}),e.createElement(b.h2,{layout:!0,className:"border-b border-majky-600 pb-1 pt-7 text-center text-2xl font-bold text-majky-800 shadow dark:text-majky-400"},Ne),e.createElement(b.div,{className:"my-4 p-4 text-center shadow"},e.createElement("div",{className:"mb-2 border-b pb-1 text-base font-bold text-gray-600 dark:text-majky-400"},ft),e.createElement("div",{className:"flex items-center justify-evenly"},Array.from({length:3},(s,c)=>e.createElement(_,{key:`options-board-types-${c}`,onClick:()=>{o("boardType",c)},className:`relative flex aspect-[5/4] w-24 items-center justify-center rounded border border-transparent bg-white p-2 font-bold text-gray-600 shadow hover:border-gray-600 hover:bg-gray-100 dark:bg-transparent dark:text-majky-400 dark:hover:border-majky-400 max-xs:py-1 md:w-36 ${l.boardType===c&&"!border-majky-400 shadow-majky-400"}`},e.createElement("img",{className:"w-24 object-fill md:w-36",src:new URL(Object.assign({"../../../../../image/backgammon/board-0.webp":sa,"../../../../../image/backgammon/board-1.webp":ca,"../../../../../image/backgammon/board-2.webp":ia})[`../../../../../image/backgammon/board-${c}.webp`],self.location).href,alt:`/images/board-${c}.webp`})))),e.createElement("div",{className:"mt-8 flex flex-col items-center md:space-y-4"},e.createElement("div",{className:"mt-2 flex w-full max-w-60 cursor-pointer space-x-8 text-base font-bold text-gray-600 dark:text-majky-400 sm:mt-0"},e.createElement(ma,{id:"options-play-sound",onChange:s=>{o("playSound",s.target.checked)},checked:l.playSound}),e.createElement("label",{className:"text-balance",htmlFor:"options-play-sound"},gt)))))))},ua=()=>e.createElement(b.div,{initial:{backdropFilter:"blur(0px)",opacity:0},animate:{backdropFilter:"blur(4px)",opacity:1},exit:{backdropFilter:"blur(0px)",opacity:0},transition:{duration:.6},className:"fixed left-0 top-0 z-50 h-screen w-screen bg-black/30"},e.createElement(b.img,{initial:{y:-300},animate:{y:0},exit:{y:-300},transition:{delay:.3,type:"spring"},className:"absolute left-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l1-b15bb7e9.png",self.location).href,alt:"celebration_l1.png"}),e.createElement(b.img,{initial:{y:-400},animate:{y:0},exit:{y:-300},transition:{delay:.4,type:"spring"},className:"absolute left-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l2-25c12ae6.png",self.location).href,alt:"celebration_l2.png"}),e.createElement(b.img,{initial:{y:-500},animate:{y:0},exit:{y:-300},transition:{delay:.1,type:"spring"},className:"absolute left-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l3-24b64409.png",self.location).href,alt:"celebration_l3.png"}),e.createElement(b.img,{initial:{y:-400,scaleX:-1},animate:{y:0,scaleX:-1},exit:{y:-300,scaleX:-1},transition:{delay:.4,type:"spring"},className:"absolute right-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l1-b15bb7e9.png",self.location).href,alt:"celebration_r1.png"}),e.createElement(b.img,{initial:{y:-500,scaleX:-1},animate:{y:0,scaleX:-1},exit:{y:-300,scaleX:-1},transition:{delay:.1,type:"spring"},className:"absolute right-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l2-25c12ae6.png",self.location).href,alt:"celebration_r2.png"}),e.createElement(b.img,{initial:{y:-300,scaleX:-1},animate:{y:0,scaleX:-1},exit:{y:-300,scaleX:-1},transition:{delay:.3,type:"spring"},className:"absolute right-0 top-0 w-1/4",src:new URL("/build/assets/celebration_l3-24b64409.png",self.location).href,alt:"celebration_l3.png"}),e.createElement("div",{className:"absolute left-1/2 top-0 -ml-[25%] w-1/2"},e.createElement(b.img,{initial:{y:-100},animate:{y:0},exit:{y:-100},transition:{delay:.1,type:"spring"},className:"absolute -top-2 ml-[12.5%] w-3/4 origin-top",src:new URL("/build/assets/celebration_c1-27ee5f77.png",self.location).href,alt:"celebration_c1.png"}),e.createElement(b.img,{initial:{y:-300},animate:{y:0},exit:{y:-300},transition:{delay:.5,type:"spring"},className:"absolute top-0 w-full",src:new URL("/build/assets/celebration_c2-33815d62.png",self.location).href,alt:"celebration_c2.png"}))),pa=()=>{const t=S(),a=k(({user:n})=>{var i;return((i=n==null?void 0:n.modals)==null?void 0:i[$])||null}),{created:l,difficulty:o,winner:r}=k(({backgammon:n})=>n),{applauseSound:s,sadTromboneSound:c}=U();return g.useEffect(()=>{a&&r>0&&localStorage.getItem("backgammon-state")==="Running"&&(t(Pt()),r===1?(s(),Mt({playedTime:Math.floor((new Date().getTime()-l.getTime())/1e3),difficulty:o})):r===2&&(c(),Rt()))},[a,r]),e.createElement(g.Fragment,null,a&&r===1&&e.createElement(ua,null),e.createElement(B,null,a&&e.createElement(b.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-50 flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:n=>{n.stopPropagation()}},e.createElement(b.div,{className:"max-h-full w-full grid-cols-1 rounded border bg-white p-2 pb-4 shadow-md dark:border-majky-400 dark:bg-slate-900/80 max-sm:w-full md:max-w-screen-xs md:p-4"},e.createElement("div",{className:"flex w-full flex-1 flex-col items-center justify-center"},e.createElement("h2",{className:"w-full max-w-60 text-center text-xl font-bold text-majky-800 dark:text-majky-400 xs:text-2xl"},r===1?it:r===2?mt:dt),e.createElement("div",{className:"relative mt-6 grid w-full max-w-60 grid-cols-2 gap-2"},e.createElement(_,{onClick:()=>{t(D($))},className:"rounded border border-transparent bg-majky-600 py-2 text-base font-bold  text-white  dark:bg-majky-400 dark:text-slate-900  max-xs:py-1"},Z),e.createElement(_,{onClick:n=>{n.stopPropagation(),localStorage.setItem("backgammon-state","Initialized"),t(le(X[0])),t(D($))},className:"rounded border border-transparent bg-majky-600 py-2 text-base font-bold  text-white  dark:bg-majky-400 dark:text-slate-900  max-xs:py-1"},ke)))))))},fa=()=>{const t=k(({user:o})=>{var r;return((r=o==null?void 0:o.modals)==null?void 0:r[H])||null}),a=S(),l=()=>{a(D(H))};return ne(),e.createElement(B,null,t&&e.createElement(b.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:l},e.createElement(b.div,{className:"relative flex max-h-full w-full flex-col overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-800 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-xs",onClick:o=>{o.stopPropagation()}},e.createElement(G,{className:"absolute left-4 top-4 h-6 w-6 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:l,icon:q}),e.createElement(b.h2,{layout:!0,className:"border-b  border-majky-600 pb-1 pt-7 text-center text-2xl font-bold text-majky-800 shadow dark:text-majky-400"},ve),e.createElement(b.div,{className:"my-4 grid grid-cols-1 gap-1 text-center"},It.map(({label:o,to:r,modalName:s,newGame:c},n)=>e.createElement(b.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{y:0,opacity:1,transition:{delay:n*.1}},closed:{y:10,opacity:0}},key:`menu-button-${n}`},e.createElement(_,{onClick:()=>{c&&(localStorage.setItem("backgammon-state","Initialized"),a(le(X[0]))),s&&a(Be(s,!0)),l()},className:"rounded border  border-transparent bg-white px-2 py-2 text-base font-bold text-gray-600 shadow-none hover:border-gray-600 hover:bg-gray-100  dark:bg-slate-800  dark:text-majky-400 dark:hover:border-majky-400 max-xs:py-1"},o)))))))},ga=()=>{const t=S(),{settings:a,modals:l}=k(({user:p})=>p),o=(l==null?void 0:l[V])||null,r=()=>{t(D(V))},[s,c]=g.useState(null),[n,i]=g.useState(!1);return g.useEffect(()=>{o&&(async()=>{i(!0);try{c(Nt)}catch(f){console.error(f)}finally{i(!1)}})()},[o,s,a.language]),e.createElement(B,null,o&&e.createElement(b.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-[10000] flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:r},e.createElement(b.div,{className:"relative max-h-full w-full overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-900/80 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-screen-md",onClick:r},n?e.createElement("p",{className:"my-4 text-center"},ut):e.createElement("div",{className:"px-4 text-gray-600 dark:text-gray-300",dangerouslySetInnerHTML:{__html:s}}))))},ba=({isOpen:t,setIsOpen:a,onOK:l=()=>{}})=>(g.useEffect(()=>{const o=()=>{a(!1)};return t&&document.addEventListener("click",o),()=>{t&&document.removeEventListener("click",o)}},[t,a]),e.createElement(B,null,t&&e.createElement(b.div,{className:"absolute left-0 right-0 z-50 w-60 rounded border  border-majky-400 bg-white   px-3 py-4 shadow-md dark:bg-slate-900 max-sm:w-60 lg:mt-2 mx-auto",initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1,y:0},closed:{opacity:0,y:-30,transition:{delay:.2,duration:.1}}},onClick:o=>{o.stopPropagation()}},e.createElement("h2",{className:"relative px-2 text-center font-medium text-majky-800 dark:text-majky-400"},_t,e.createElement(G,{className:"absolute right-0 top-0 cursor-pointer hover:text-majky-600 active:text-majky-500",onClick:()=>{a(!1)},icon:q})),e.createElement(b.div,{className:"mt-4 grid grid-cols-2 gap-2  font-medium"},e.createElement(_,{className:"rounded border-majky-200 bg-majky-50 py-1 text-center text-majky-800  dark:bg-slate-800 dark:text-majky-400",onClick:()=>{a(!1)}},Z),e.createElement(_,{className:" rounded border-majky-200  bg-majky-400 py-1 text-center text-white dark:bg-majky-600 dark:text-slate-800",onClick:()=>{l(),a(!1)}},Tt))))),j=({label:t,value:a})=>e.createElement("div",{className:"mt-2 w-full md:max-w-96"},e.createElement("span",{className:"inline-block w-40 text-right "},t),e.createElement("span",{className:"pl-4"},":"),e.createElement("span",{className:" inline-block w-32 md:w-40"},a)),ya=()=>{var p,f,d,m;const t=k(({user:u})=>{var x;return((x=u==null?void 0:u.modals)==null?void 0:x[z])||null}),a=S(),[l,o]=g.useState(!1),[r,s]=g.useState(!1),c=()=>{a(D(z))},[n,i]=g.useState(null);return g.useEffect(()=>{t&&i(Ie())},[t]),e.createElement(B,null,t&&e.createElement(b.div,{initial:"closed",animate:"open",exit:"closed",layout:!0,variants:{open:{opacity:1},closed:{opacity:0}},className:"fixed left-0 top-0 z-50 flex h-screen w-screen flex-col items-center justify-center bg-black/50 p-4",onClick:c},e.createElement("div",{className:"relative flex max-h-full w-full flex-col items-center justify-between overflow-y-auto overflow-x-hidden rounded border bg-white pb-4 shadow-md dark:border-majky-400  dark:bg-slate-900/80 max-md:fixed max-md:left-0 max-md:top-0 max-md:h-full max-sm:w-full md:max-w-screen-md",onClick:u=>{u.stopPropagation()}},e.createElement("h2",{className:"w-full border-b border-majky-600 pb-1 pt-7 text-center text-2xl font-bold text-majky-800 shadow dark:text-majky-400"},Ae),e.createElement("div",{className:"mt-4 flex w-full flex-col items-center text-center"},e.createElement(j,{label:bt,value:n==null?void 0:n.played}),e.createElement(j,{label:yt,value:`${(n==null?void 0:n.played)>0?parseInt((1-(n==null?void 0:n.failed)/(n==null?void 0:n.played))*100):0}%`}),e.createElement(j,{label:xt,value:n==null?void 0:n.streak}),e.createElement(j,{label:Et,value:n==null?void 0:n.maxStreak}),e.createElement(j,{label:ht,value:W(Math.floor(((p=n==null?void 0:n.completed)==null?void 0:p.reduce((u,{playedTime:x})=>u+x,0))/(((f=n==null?void 0:n.completed)==null?void 0:f.length)||1)))}),e.createElement(j,{label:wt,value:W(Math.max(...(d=(n==null?void 0:n.completed)||[])==null?void 0:d.map(({playedTime:u})=>u),0))}),e.createElement(j,{label:kt,value:W(Math.min(...(m=(n==null?void 0:n.completed)||[])==null?void 0:m.map(({playedTime:u})=>u),0))})),e.createElement("div",{className:"mt-4 text-balance text-center text-sm text-majky-600"},St),e.createElement("div",{className:"mt-4 grid w-full max-w-80 grid-cols-2 gap-2 font-medium"},e.createElement(_,{className:"rounded border-majky-200  bg-majky-50 py-1 text-center text-majky-800  dark:bg-slate-800 dark:text-majky-400",onClick:u=>{o(!0),s(x=>!x)}},vt),e.createElement(_,{className:" rounded border-majky-200  bg-majky-400 py-1 text-center text-white dark:bg-majky-600 dark:text-slate-800",onClick:c},Z))),e.createElement(ba,{isOpen:r,setIsOpen:s,onOK:()=>{i(Ct())}})))},xa=({children:t})=>(k(({user:a})=>a),e.createElement(Ht,null,e.createElement(Ye,{position:"top-center",newestOnTop:!0,closeOnClick:!0,limit:1,stacked:!0,toastClassName:"bg-white dark:text-slate-100 dark:bg-slate-900"}),e.createElement("div",{className:"relative flex h-full min-h-dvh w-full flex-auto !select-none flex-col items-center justify-start overflow-hidden bg-white bg-cover bg-center transition-all dark:bg-slate-900 dark:text-slate-100"},e.createElement("div",{className:"relative flex min-h-dvh w-full max-w-screen-xl flex-col items-start justify-start"},e.createElement(ra,null),t),e.createElement(fa,null),e.createElement(da,null),e.createElement(ga,null),e.createElement(ya,null),e.createElement(pa,null))));function Ea(){return ne(),e.createElement(Ve,{store:De},e.createElement(ot,{loading:null,persistor:la},e.createElement(g.Suspense,{fallback:e.createElement(oa,null)},e.createElement(xa,null,e.createElement(Xt,null)))))}const ha=t=>{t&&t instanceof Function&&nt(()=>import("./web-vitals-23d6d37b.js"),[]).then(({getCLS:a,getFID:l,getFCP:o,getLCP:r,getTTFB:s})=>{a(t),l(t),o(t),r(t),s(t)})},wa=$e.createRoot(document.getElementById("root"));wa.render(e.createElement(e.StrictMode,null,e.createElement(Ea,null)));ha();